import{u as D}from"./userStore.58432b7f.js";import{b as E,c as C,d as k}from"./FormRunner.6af2b2ca.js";import{d as R,eb as S,e5 as F,ae as U,r as A,w as I,c as L,aK as W,k as V,j as x,u as o,a5 as K,f as B,a as M,h as N,o as y,_ as T}from"./jwt-decode.esm.95147216.js";import{r as j}from"./redirect.3052df44.js";import{a as q}from"./asyncComputed.15a1493f.js";import{u as h}from"./uuid.36c0f5f6.js";import{L as G}from"./CircularLoading.8337813d.js";import{f as P}from"./workspaceStore.ef22b01d.js";import"./Login.vue_vue_type_script_setup_true_lang.3cf02d12.js";import"./index.82e2f482.js";import"./Logo.4a9353b0.js";import"./string.c6b418fe.js";import"./index.8cd0d351.js";import"./Steps.b9a883e9.js";import"./index.2366fc23.js";import"./Watermark.e2acb72e.js";import"./constants.5f7db9f7.js";import"./url.8c481a5a.js";import"./colorHelpers.359e9af7.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[a]="013f1467-7fad-4693-9594-fcacb45ed81a",i._sentryDebugIdIdentifier="sentry-dbid-013f1467-7fad-4693-9594-fcacb45ed81a")}catch{}})();const z={key:0,class:"loading"},H=R({__name:"Form",setup(i){const a=S(),c=F(),f=U({playerKey:h()}),g=D(),l=A(null);I(a,()=>{a.name==="form"&&w()});const{loading:d,result:t,error:p,refetch:w}=q(async()=>{f.playerKey=h();const r=a.path.slice(1),e=await P(r);if(!e){c.push({name:"error",params:{status:"404"}});return}const n=new C({formRunnerData:e,logService:null,connectionManager:new k(e.id,"player",a.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:u=>l.value=u}),s=n.getState();return l.value=s.formState,{runnerData:e,controller:n}}),b=L(()=>{const r=!d,e=!!p,n=!t||l.value===null;return r&&(e||n)});W(()=>{var r,e,n,s,u;b.value&&c.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(u=(n=t.value)==null?void 0:n.runnerData.welcomeTitle)!=null?u:(s=t.value)==null?void 0:s.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),j("player",c,r,e)}V(async()=>{window.addEventListener("beforeunload",m)}),x(()=>{window.removeEventListener("beforeunload",m)});const m=r=>{var e;if((e=t.value)!=null&&e.controller.handleCloseAttempt())return r.preventDefault(),""};return(r,e)=>{var n,s,u,v;return o(d)?(y(),K("div",z,[B(G)])):o(t)&&o(t).runnerData&&l.value&&!o(p)&&!o(d)?(y(),M(E,{key:f.playerKey,"form-runner-data":o(t).runnerData,"form-state":l.value,"is-preview":!1,"user-email":o(g).email,onRedirect:_,onActionClicked:(n=o(t))==null?void 0:n.controller.handleActionClick,onUpdateWidgetErrors:(s=o(t))==null?void 0:s.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(u=o(t))==null?void 0:u.controller.updateWidgetValue,onAuthComplete:(v=o(t))==null?void 0:v.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):N("",!0)}}});const me=T(H,[["__scopeId","data-v-972fe12c"]]);export{me as default};
//# sourceMappingURL=Form.33595b49.js.map
