import{u as _}from"./userStore-C7NmNY8K.js";import{F as D,a as E,b as C}from"./FormRunner-DTgWAGK3.js";import{d as S,aK as k,r as R,w as F,S as U,T as A,e as I,aL as L,X as W,aM as V,l as B,B as K,p as M,D as t,g as x,m as p,ap as N}from"./jwt-decode.esm-Dca5fHH5.js";import{r as T}from"./redirect-DfjkTFaH.js";import{a as q}from"./asyncComputed-IJY6wgme.js";import{u as v}from"./uuid-CK8Ke_G7.js";import{L as G}from"./CircularLoading-ohVkmYRk.js";import{f as P}from"./workspaceStore-XJ3gN0Xg.js";import"./Login.vue_vue_type_script_setup_true_lang-BC_tHwoy.js";import"./index-DjAbyHeM.js";import"./Logo-DAfI0pPB.js";import"./string-BYR4BIXr.js";import"./index-BKOa5q_P.js";import"./Steps-C6PdqcTg.js";import"./index-BFZHdHfr.js";import"./Watermark-C95DBwfe.js";import"./constants-B1LrRAnj.js";import"./url-CoyBb3Dp.js";import"./colorHelpers-DW8ZpCiU.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="8b8177d8-f3f4-42d7-98ef-b1fa07a2547b",n._sentryDebugIdIdentifier="sentry-dbid-8b8177d8-f3f4-42d7-98ef-b1fa07a2547b")}catch{}})();const X={key:0,class:"loading"},j=S({__name:"Form",setup(n){const a=U(),i=A(),c=k({playerKey:v()}),h=_(),s=R(null);F(a,()=>{a.name==="form"&&y()});const{loading:u,result:e,error:m,refetch:y}=q(async()=>{c.playerKey=v();const o=a.path.slice(1),r=await P(o);if(!r){i.push({name:"error",params:{status:"404"}});return}const l=new D({formRunnerData:r,logService:null,connectionManager:new E(r.id,"player",a.query),onRedirect:f,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:b=>s.value=b}),w=l.getState();return s.value=w.formState,{runnerData:r,controller:l}}),g=I(()=>{const o=!u,r=!!m,l=!e||s.value===null;return o&&(r||l)});L(()=>{g.value&&i.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&e.value?.runnerData&&(document.title=e.value?.runnerData.welcomeTitle??e.value?.runnerData.title)});function f(o,r){window.removeEventListener("beforeunload",d),T("player",i,o,r)}W(async()=>{window.addEventListener("beforeunload",d)}),V(()=>{window.removeEventListener("beforeunload",d)});const d=o=>{if(e.value?.controller.handleCloseAttempt())return o.preventDefault(),""};return(o,r)=>t(u)?(p(),B("div",X,[x(G)])):t(e)&&t(e).runnerData&&s.value&&!t(m)&&!t(u)?(p(),K(C,{key:c.playerKey,"form-runner-data":t(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":t(h).email,onRedirect:f,onActionClicked:t(e)?.controller.handleActionClick,onUpdateWidgetErrors:t(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:t(e)?.controller.updateWidgetValue,onAuthComplete:t(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):M("",!0)}}),ce=N(j,[["__scopeId","data-v-9b9482e8"]]);export{ce as default};
//# sourceMappingURL=Form-ChhRJJNs.js.map
