import{u as D}from"./userStore.5192b178.js";import{b as E,c as C,d as R}from"./FormRunner.340e2410.js";import{d as k,al as S,r as U,w as F,c as A,aR as I,U as L,R as W,u as o,ac as V,f as x,a as B,h as K,eA as M,ec as N,o as y,_ as q}from"./jwt-decode.esm.fbcfeaec.js";import{r as G}from"./redirect.32c84564.js";import{a as P}from"./asyncComputed.5a2bb5ad.js";import{u as h}from"./uuid.ee81c117.js";import{L as T}from"./CircularLoading.f87073c8.js";import{f as j}from"./workspaceStore.fb02f79a.js";import"./Login.vue_vue_type_script_setup_true_lang.626e6404.js";import"./Logo.6d480788.js";import"./string.b10c2096.js";import"./index.4d74f393.js";import"./Steps.c40d0887.js";import"./index.900c7d37.js";import"./Watermark.6a01fe65.js";import"./constants.b8ded506.js";import"./url.90414523.js";import"./colorHelpers.0cd68eec.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[a]="f62b1032-1dfa-4f21-9ffc-f1c9378e52ed",s._sentryDebugIdIdentifier="sentry-dbid-f62b1032-1dfa-4f21-9ffc-f1c9378e52ed")}catch{}})();const z={key:0,class:"loading"},H=k({__name:"Form",setup(s){const a=M(),i=N(),m=S({playerKey:h()}),g=D(),u=U(null);F(a,()=>{a.name==="form"&&w()});const{loading:d,result:t,error:p,refetch:w}=P(async()=>{m.playerKey=h();const r=a.path.slice(1),e=await j(r);if(!e){i.push({name:"error",params:{status:"404"}});return}const n=new C({formRunnerData:e,logService:null,connectionManager:new R(e.id,"player",a.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:c=>u.value=c}),l=n.getState();return u.value=l.formState,{runnerData:e,controller:n}}),b=A(()=>{const r=!d,e=!!p,n=!t||u.value===null;return r&&(e||n)});I(()=>{var r,e,n;b.value&&i.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(n=t.value)==null?void 0:n.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",f),G("player",i,r,e)}L(async()=>{window.addEventListener("beforeunload",f)}),W(()=>{window.removeEventListener("beforeunload",f)});const f=r=>{var e;if((e=t.value)!=null&&e.controller.handleCloseAttempt())return r.preventDefault(),""};return(r,e)=>{var n,l,c,v;return o(d)?(y(),V("div",z,[x(T)])):o(t)&&o(t).runnerData&&u.value&&!o(p)&&!o(d)?(y(),B(E,{key:m.playerKey,"form-runner-data":o(t).runnerData,"form-state":u.value,"is-preview":!1,"user-email":o(g).email,onRedirect:_,onActionClicked:(n=o(t))==null?void 0:n.controller.handleActionClick,onUpdateWidgetErrors:(l=o(t))==null?void 0:l.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(c=o(t))==null?void 0:c.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"])):K("",!0)}}});const de=q(H,[["__scopeId","data-v-1b2b3f4f"]]);export{de as default};
//# sourceMappingURL=Form.07e874be.js.map
