import{u as D}from"./userStore.f59fc230.js";import{b as E,c as C,d as k}from"./FormRunner.f43a92cd.js";import{d as R,ec as S,e4 as F,ad as U,r as A,w as I,c as L,aJ as W,k as V,j as x,u as o,a4 as B,f as K,a as M,h as N,o as y,_ as T}from"./jwt-decode.esm.335fee36.js";import{r as j}from"./redirect.a7a548b6.js";import{a as q}from"./asyncComputed.a244f4e2.js";import{u as h}from"./uuid.aa66648a.js";import{L as G}from"./CircularLoading.a3f8d515.js";import{f as J}from"./workspaceStore.50dbc071.js";import"./Login.vue_vue_type_script_setup_true_lang.f8c4a822.js";import"./Logo.115b88fc.js";import"./string.43ee44ca.js";import"./index.2cfedf58.js";import"./Steps.26d8a3dd.js";import"./index.bb59d472.js";import"./Watermark.f033d35b.js";import"./constants.9b601448.js";import"./url.620305e5.js";import"./runnerData.d83dc7e7.js";import"./colorHelpers.4cc962fa.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]="0dcd255a-7964-49d9-8cba-9480bec4c9b3",i._sentryDebugIdIdentifier="sentry-dbid-0dcd255a-7964-49d9-8cba-9480bec4c9b3")}catch{}})();const P={key:0,class:"loading"},z=R({__name:"Form",setup(i){const a=S(),c=F(),p=U({playerKey:h()}),g=D(),l=A(null);I(a,()=>{a.name==="form"&&b()});const{loading:d,result:t,error:f,refetch:b}=q(async()=>{p.playerKey=h();const r=a.path.slice(1),e=await J(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}}),w=L(()=>{const r=!d,e=!!f,n=!t||l.value===null;return r&&(e||n)});W(()=>{var r,e,n,s,u;w.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(),B("div",P,[K(G)])):o(t)&&o(t).runnerData&&l.value&&!o(f)&&!o(d)?(y(),M(E,{key:p.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(z,[["__scopeId","data-v-9b9482e8"]]);export{me as default};
//# sourceMappingURL=Form.294ae323.js.map
