import{u as F}from"./userStore-0WDgP3uZ.js";import{P as U}from"./PageStageView-ine_Sf3Z.js";import{F as L,a as P,b as W}from"./FormRunner-BjAO5FEz.js";import{u as A,c as I,d as V,S as M}from"./workspaceStore-C4LuPoiS.js";import{e as x,R as B,r as p,E as K,b as N,b8 as j,P as T,O as q,f as G,n as _,j as H,p as r,v as O,af as z,aj as J,g as m,aM as Q}from"./jwt-decode.esm-1W9iq5Oc.js";import{r as X}from"./redirect-BRxz-TGv.js";import{a as Y}from"./asyncComputed-ogTSBvuL.js";import{u as k}from"./uuid-aTjXpf4v.js";import{L as Z}from"./CircularLoading-HpD2QrfE.js";import"./Watermark-CWfAy4Wy.js";import"./constants-DCeOk9KD.js";import"./consoleCapture-CdpEktIH.js";import"./Login.vue_vue_type_script_setup_true_lang-CQMKk7-a.js";import"./OTPInput-BVDZmCNr.js";import"./Logo-DQ7U0XOa.js";import"./string-BXLOTiJ3.js";import"./index-Qgm5pAm_.js";import"./Steps-svCKaBUp.js";import"./index-Ds99-SZa.js";import"./runnerData-DgRTB2fA.js";import"./url-emG1RSF5.js";import"./colorHelpers-DT7BywO0.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="2f331299-8f57-4511-8a9e-666f343363c9",n._sentryDebugIdIdentifier="sentry-dbid-2f331299-8f57-4511-8a9e-666f343363c9")}catch{}})();const $={key:0,class:"loading"},ee=x({__name:"Form",setup(n){const o=J(),u=z(),f=B({playerKey:k()}),E=F(),S=A(),s=p(null),v=p(null),l=p(null);K(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),C())});const{loading:c,result:e,error:g,refetch:C}=Y(async()=>{f.playerKey=k();const a=o.path.slice(1),t=await I(a);if(!t){u.push({name:"error",params:{status:"404"}});return}if(l.value=t,S.state.currentPageType=t.type,t.type==="page")return document.title=t.data.title,{runnerData:null,controller:null};const i=t.data;v.value=await V();const w=new P({formRunnerData:i,logService:null,connectionManager:new W(i.id,"player",o.query,M.instance?.sessionMode??!1),onRedirect:y,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:R=>s.value=R}),b=w.getState();return s.value=b.formState,{runnerData:i,controller:w}}),D=N(()=>{if(l.value?.type==="page")return!1;const a=!c.value,t=!!g.value,i=!e.value||s.value===null;return a&&(t||i)});j(()=>{D.value&&u.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&(document.title=e.value.runnerData.title)});function y(a,t){window.removeEventListener("beforeunload",d),X("player",u,a,t)}T(async()=>{window.addEventListener("beforeunload",d),window.addEventListener("pagehide",h)}),q(()=>{window.removeEventListener("beforeunload",d),window.removeEventListener("pagehide",h),e.value?.controller?.stop()});const d=a=>{if(e.value?.controller?.handleCloseAttempt())return a.preventDefault(),""},h=()=>{e.value?.controller?.closeSession()};return(a,t)=>r(c)?(m(),G("div",$,[O(Z)])):l.value&&l.value.type==="page"?(m(),_(U,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):r(e)&&r(e).runnerData&&s.value&&!r(g)&&!r(c)?(m(),_(L,{key:f.playerKey,"form-runner-data":r(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":r(E).email,"worker-capacity":v.value,onRedirect:y,onActionClicked:r(e)?.controller.handleActionClick,onUpdateWidgetErrors:r(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:r(e)?.controller.updateWidgetValue,onAuthComplete:r(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","worker-capacity","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):H("",!0)}}),Se=Q(ee,[["__scopeId","data-v-0d259dfc"]]);export{Se as default};
//# sourceMappingURL=Form-IToZJlh9.js.map
