import{b as D,i as E}from"./workspaceStore.6144f2aa.js";import{a as C,r as S,c as k,d as F}from"./FormRunner.f101fed1.js";import{d as R,ec as U,eF as A,E as I,e as L,g as W,f as V,aL as x,X as B,ah as K,u as a,o as y,Y as M,b as N,c as T,S as q,a0 as G}from"./index.97914b50.js";import{a as P}from"./asyncComputed.d84da1aa.js";import{u as h}from"./uuid.b673ebc8.js";import{L as X}from"./OTPInput.0427d908.js";import"./url.9121ac6e.js";import"./colorHelpers.7fae6e3b.js";import"./Login.vue_vue_type_script_setup_true_lang.f8324f0a.js";import"./Logo.6a7a7f34.js";import"./string.8b027234.js";import"./index.19726194.js";import"./Steps.70a50a90.js";import"./index.068a6f5e.js";import"./Watermark.ec231849.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[n]="4a9e56e9-9ad5-44c5-a8af-35999c05f206",u._sentryDebugIdIdentifier="sentry-dbid-4a9e56e9-9ad5-44c5-a8af-35999c05f206")}catch{}})();const Y={key:0,class:"loading"},j=R({__name:"Form",setup(u){const n=U(),i=A(),f=I({playerKey:h()}),g=D(),c=L(null);W(n,()=>{n.name==="form"&&w()});const{loading:d,result:t,error:p,refetch:w}=P(async()=>{f.playerKey=h();const r=n.path.slice(1),e=await E(r);if(!e){i.push({name:"error",params:{status:"404"}});return}const o=new k({formRunnerData:e,logService:null,connectionManager:new F(e.id,"player",n.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:l=>c.value=l}),s=o.getState();return c.value=s.formState,{runnerData:e,controller:o}}),b=V(()=>{const r=!d,e=!!p,o=!t||c.value===null;return r&&(e||o)});x(()=>{var r,e,o,s,l;b.value&&i.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(l=(o=t.value)==null?void 0:o.runnerData.welcomeTitle)!=null?l:(s=t.value)==null?void 0:s.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),S("player",i,r,e)}B(async()=>{window.addEventListener("beforeunload",m)}),K(()=>{window.removeEventListener("beforeunload",m)});const m=r=>{var e;if((e=t.value)!=null&&e.controller.handleCloseAttempt())return r.preventDefault(),""};return(r,e)=>{var o,s,l,v;return a(d)?(y(),M("div",Y,[N(X)])):a(t)&&a(t).runnerData&&c.value&&!a(p)&&!a(d)?(y(),T(C,{key:f.playerKey,"form-runner-data":a(t).runnerData,"form-state":c.value,"is-preview":!1,"user-email":a(g).email,onRedirect:_,onActionClicked:(o=a(t))==null?void 0:o.controller.handleActionClick,onUpdateWidgetErrors:(s=a(t))==null?void 0:s.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(l=a(t))==null?void 0:l.controller.updateWidgetValue,onAuthComplete:(v=a(t))==null?void 0:v.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):q("",!0)}}});const ue=G(j,[["__scopeId","data-v-c3fd8bc9"]]);export{ue as default};
//# sourceMappingURL=Form.0cab7492.js.map
