import{u as D}from"./userStore.d0eca952.js";import{b as E,c as C,d as k}from"./FormRunner.6b1a9ffb.js";import{d as R,ec as S,e4 as F,ad as U,r as A,w as I,c as L,aJ as W,k as V,j as x,u as o,a4 as B,f as K,a as M,h as N,o as y,_ as T}from"./jwt-decode.esm.ea959866.js";import{r as j}from"./redirect.85d5f290.js";import{a as q}from"./asyncComputed.51381bdd.js";import{u as h}from"./uuid.86ffe9aa.js";import{L as G}from"./CircularLoading.d1c2f117.js";import{f as J}from"./workspaceStore.05920c8f.js";import"./Login.vue_vue_type_script_setup_true_lang.6d87a5c3.js";import"./Logo.12b771cc.js";import"./string.07f8f578.js";import"./index.545aeeff.js";import"./Steps.5d8a7411.js";import"./index.b21534b3.js";import"./Watermark.ed3b4d34.js";import"./constants.6ec7c497.js";import"./url.1e21ad57.js";import"./runnerData.c2d3943c.js";import"./colorHelpers.a2d56f29.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[n]="0a606bac-ad70-40a5-9674-0a6772c9e8a7",i._sentryDebugIdIdentifier="sentry-dbid-0a606bac-ad70-40a5-9674-0a6772c9e8a7")}catch{}})();const P={key:0,class:"loading"},z=R({__name:"Form",setup(i){const n=S(),c=F(),p=U({playerKey:h()}),g=D(),l=A(null);I(n,()=>{n.name==="form"&&w()});const{loading:d,result:t,error:f,refetch:w}=q(async()=>{p.playerKey=h();const r=n.path.slice(1),e=await J(r);if(!e){c.push({name:"error",params:{status:"404"}});return}const a=new C({formRunnerData:e,logService:null,connectionManager:new k(e.id,"player",n.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:u=>l.value=u}),s=a.getState();return l.value=s.formState,{runnerData:e,controller:a}}),b=L(()=>{const r=!d,e=!!f,a=!t||l.value===null;return r&&(e||a)});W(()=>{var r,e,a,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=(a=t.value)==null?void 0:a.runnerData.welcomeTitle)!=null?u:(s=t.value)==null?void 0:s.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),j("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 a,s,u,v;return o(d)?(y(),B("div",P,[K(G)])):o(t)&&o(t).runnerData&&l.value&&!o(f)&&!o(d)?(y(),M(E,{key:p.playerKey,"form-runner-data":o(t).runnerData,"form-state":l.value,"is-preview":!1,"user-email":o(g).email,onRedirect:_,onActionClicked:(a=o(t))==null?void 0:a.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 me=T(z,[["__scopeId","data-v-9b9482e8"]]);export{me as default};
//# sourceMappingURL=Form.75a517fc.js.map
