import{u as D}from"./userStore.6ab1e5ac.js";import{b as E,c as C,d as k}from"./FormRunner.15be6fa0.js";import{d as R,eb as S,e5 as F,ae as U,r as I,w as A,c as L,aK as W,J as V,I 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.54a1ea22.js";import{r as q}from"./redirect.586749f4.js";import{a as G}from"./asyncComputed.47aec2b5.js";import{u as h}from"./uuid.5b8ba8af.js";import{L as J}from"./CircularLoading.998b223a.js";import{f as P}from"./workspaceStore.fac1e9a9.js";import"./Login.vue_vue_type_script_setup_true_lang.5161f328.js";import"./Logo.65e0b37c.js";import"./string.61e11a30.js";import"./index.d53182ed.js";import"./Steps.dd51a108.js";import"./index.d31da2c3.js";import"./Watermark.9c9358e3.js";import"./constants.d569f33d.js";import"./url.f5664225.js";import"./colorHelpers.50ced1e9.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[a]="dae5d004-3939-4087-b658-4934c9bf8370",l._sentryDebugIdIdentifier="sentry-dbid-dae5d004-3939-4087-b658-4934c9bf8370")}catch{}})();const j={key:0,class:"loading"},z=R({__name:"Form",setup(l){const a=S(),c=F(),p=U({playerKey:h()}),g=D(),i=I(null);A(a,()=>{a.name==="form"&&w()});const{loading:d,result:t,error:f,refetch:w}=G(async()=>{p.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=>i.value=u}),s=n.getState();return i.value=s.formState,{runnerData:e,controller:n}}),b=L(()=>{const r=!d,e=!!f,n=!t||i.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),q("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",j,[B(J)])):o(t)&&o(t).runnerData&&i.value&&!o(f)&&!o(d)?(y(),M(E,{key:p.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:(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 de=T(z,[["__scopeId","data-v-972fe12c"]]);export{de as default};
//# sourceMappingURL=Form.09de384c.js.map
