import{a as I}from"./asyncComputed.6da48dd7.js";import{P as E}from"./project.ee914ec2.js";import"./router.4a188c48.js";import{d as k,r as y,b as _,c as C,w as a,aJ as s,ey as T,u as e,c4 as P,cG as B,t as F,J as w,f as t,e as p,eC as m,bZ as H,eu as D,ew as S,eA as U}from"./outputWidgets.d94fff8c.js";import"./index.a5166b6d.js";import{n as V}from"./index.3dad0da1.js";import{c as j,A as N}from"./Title.c70c7e79.js";import{A,a as d}from"./index.7d7e00b1.js";import{A as g}from"./index.3709b59d.js";import{F as $}from"./Form.57801503.js";import{A as R}from"./index.209f6c1c.js";import"./gateway.8dd534ee.js";import"./activeRecord.4bb9e983.js";import"./pubsub.39314a92.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[n]="d6573c4a-c0f8-42be-bdfb-62c1d761cd97",u._sentryDebugIdIdentifier="sentry-dbid-d6573c4a-c0f8-42be-bdfb-62c1d761cd97")}catch{}})();const J=k({__name:"SaveButton",props:{model:{},disabled:{type:Boolean}},emits:["error"],setup(u,{emit:n}){const r=u,i=y(!1),f=y(null);async function c(){i.value=!0;try{await r.model.save()}catch(o){o instanceof Error&&(n("error",o),B.error({message:"Error",description:o.message}),f.value=o)}finally{i.value=!1}}return addEventListener("keydown",o=>{(o.metaKey||o.ctrlKey)&&o.key==="s"&&(o.preventDefault(),c())}),addEventListener("beforeunload",o=>{r.model.hasChanges()&&(o.preventDefault(),o.returnValue="")}),(o,v)=>{var b,l,h;return _(),C(e(P),{class:T(["save-button",{changes:(b=o.model)==null?void 0:b.hasChanges()}]),loading:i.value,disabled:(h=o.disabled)!=null?h:!((l=o.model)!=null&&l.hasChanges()),onClick:v[0]||(v[0]=z=>c())},{default:a(()=>[s(" Save ")]),_:1},8,["class","loading","disabled"])}}}),K={key:0},L=k({__name:"SubdomainEditor",props:{project:{}},setup(u){const n=u,r=y(void 0),i=F.exports.debounce(async()=>{try{const{available:l}=await n.project.checkSubdomain();r.value=l?"available":"unavailable"}catch{r.value=void 0}},500);function f(){n.project.subdomain?(r.value="loading",i()):r.value="invalid"}const c=w(()=>{switch(r.value){case"invalid":return"error";case"loading":return"validating";case"available":return"success";case"unavailable":return"error";default:return}}),o=w(()=>{switch(r.value){case"loading":return"Checking availability...";case"available":return"Available";case"unavailable":return"Unavailable";case"invalid":return"Invalid subdomain";default:return}}),v=l=>{n.project.subdomain=V(l.target.value,{replacement:"-",lower:!0,strict:!0}),f()};function b(){n.project.resetChanges(),r.value=void 0}return(l,h)=>(_(),C(e(R),{direction:"vertical"},{default:a(()=>[t(e(j),{level:2},{default:a(()=>[s("Subdomain")]),_:1}),t(e(A),null,{default:a(()=>[s(" Every project in Abstra Cloud comes with a default subdomain, which will appear on all shared project links. ")]),_:1}),t(e(g),null,{default:a(()=>[t(e(d),null,{default:a(()=>[s("Forms and Dashes available at:")]),_:1}),t(e(d),{code:""},{default:a(()=>[p("span",null,m(l.project.getUrl("[PATH]")),1)]),_:1})]),_:1}),t(e(g),null,{default:a(()=>[t(e(d),null,{default:a(()=>[s("Hooks available at:")]),_:1}),t(e(d),{code:""},{default:a(()=>[p("span",null,m(l.project.getUrl("_hooks/[PATH]")),1)]),_:1})]),_:1}),t(e($),null,{default:a(()=>[t(e(N),{"validate-status":c.value,help:o.value,"has-feedback":""},{default:a(()=>[t(e(H),{value:l.project.subdomain,type:"text",loading:r.value==="loading",onInput:v},{addonBefore:a(()=>[s("https://")]),addonAfter:a(()=>[s(".abstra.app")]),_:1},8,["value","loading"])]),_:1},8,["validate-status","help"]),t(J,{model:l.project,disabled:r.value!=="available",onError:b},null,8,["model","disabled"])]),_:1}),l.project.customDomain?(_(),D("div",K,[t(e(j),{level:2},{default:a(()=>[s("Custom Domain")]),_:1}),t(e(A),null,{default:a(()=>[s(" Your project also has a custom domain: "),t(e(d),{code:""},{default:a(()=>[p("span",null,m(l.project.customDomain),1)]),_:1})]),_:1}),t(e(g),null,{default:a(()=>[t(e(d),null,{default:a(()=>[s("Forms and Dashes available at:")]),_:1}),t(e(d),{code:""},{default:a(()=>[p("span",null,m(l.project.getCustomDomainUrl("[PATH]")),1)]),_:1})]),_:1}),t(e(g),null,{default:a(()=>[t(e(d),null,{default:a(()=>[s("Hooks available at:")]),_:1}),t(e(d),{code:""},{default:a(()=>[p("span",null,m(l.project.getCustomDomainUrl("_hooks/[PATH]")),1)]),_:1})]),_:1})])):S("",!0)]),_:1}))}}),q={key:0,class:"project-settings"},re=k({__name:"ProjectSettings",setup(u){const r=U().params.projectId,{result:i}=I(()=>E.get(r));return(f,c)=>e(i)?(_(),D("div",q,[t(e(j),null,{default:a(()=>[s("Project Settings")]),_:1}),t(L,{project:e(i)},null,8,["project"])])):S("",!0)}});export{re as default};
//# sourceMappingURL=ProjectSettings.1f5c2f74.js.map
