import{u as D}from"./userStore.f3109854.js";import{b as E,c as C,d as k}from"./FormRunner.ce5ad4fd.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.7fb8faf4.js";import{r as q}from"./redirect.0e6a5558.js";import{a as G}from"./asyncComputed.7b34952b.js";import{u as h}from"./uuid.0f9d5a19.js";import{L as J}from"./CircularLoading.ea5d27d2.js";import{f as P}from"./workspaceStore.de299d82.js";import"./Login.vue_vue_type_script_setup_true_lang.b006d8d3.js";import"./Logo.648566b5.js";import"./string.d8337a2b.js";import"./index.09f330ad.js";import"./Steps.4482ff19.js";import"./index.ddb85c9b.js";import"./Watermark.37fe047e.js";import"./constants.60cb557d.js";import"./url.4e737b7f.js";import"./colorHelpers.5dd0cb4f.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]="98abe7e0-d8ef-4988-b107-db4635ceff8e",l._sentryDebugIdIdentifier="sentry-dbid-98abe7e0-d8ef-4988-b107-db4635ceff8e")}catch{}})();const j={key:0,class:"loading"},z=R({__name:"Form",setup(l){const a=S(),c=F(),f=U({playerKey:h()}),g=D(),i=I(null);A(a,()=>{a.name==="form"&&w()});const{loading:d,result:t,error:p,refetch:w}=G(async()=>{f.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=!!p,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(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:(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.ab1706e4.js.map
