import{u as D}from"./userStore.339db438.js";import{b as E,c as C,d as R}from"./FormRunner.d1186e5c.js";import{d as k,ei as S,ec as U,al as F,r as A,w as I,c as L,aR as W,U as V,R as x,u as o,ac as B,f as K,a as M,h as N,o as y,_ as q}from"./jwt-decode.esm.32f71954.js";import{r as G}from"./redirect.2f506c19.js";import{a as P}from"./asyncComputed.f9fa4c71.js";import{u as h}from"./uuid.77e093c3.js";import{L as T}from"./CircularLoading.26cebe64.js";import{f as j}from"./workspaceStore.5dfe5329.js";import"./Login.vue_vue_type_script_setup_true_lang.6f146a14.js";import"./Logo.c75e45a8.js";import"./string.ff0b4ef9.js";import"./index.a4dc5332.js";import"./Steps.7b2e867b.js";import"./index.ddb89818.js";import"./Watermark.6e692419.js";import"./constants.b5d83622.js";import"./url.79cc02c3.js";import"./colorHelpers.b41220cb.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]="588fe712-3ab8-4799-9954-83ca6b78d978",s._sentryDebugIdIdentifier="sentry-dbid-588fe712-3ab8-4799-9954-83ca6b78d978")}catch{}})();const z={key:0,class:"loading"},H=k({__name:"Form",setup(s){const a=S(),u=U(),f=F({playerKey:h()}),g=D(),i=A(null);I(a,()=>{a.name==="form"&&b()});const{loading:d,result:t,error:p,refetch:b}=P(async()=>{f.playerKey=h();const r=a.path.slice(1),e=await j(r);if(!e){u.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=>i.value=c}),l=n.getState();return i.value=l.formState,{runnerData:e,controller:n}}),w=L(()=>{const r=!d,e=!!p,n=!t||i.value===null;return r&&(e||n)});W(()=>{var r,e,n;w.value&&u.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",m),G("player",u,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,l,c,v;return o(d)?(y(),B("div",z,[K(T)])):o(t)&&o(t).runnerData&&i.value&&!o(p)&&!o(d)?(y(),M(E,{key:f.playerKey,"form-runner-data":o(t).runnerData,"form-state":i.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"])):N("",!0)}}});const de=q(H,[["__scopeId","data-v-1b2b3f4f"]]);export{de as default};
//# sourceMappingURL=Form.723342d2.js.map
