import{u as R}from"./userStore-C91zXrXx.js";import{P as U}from"./PageStageView-Ifl3m5Mh.js";import{F as L,a as P,b as W}from"./FormRunner-cC9zYpha.js";import{u as A,c as I,d as V,S as M}from"./workspaceStore-DcnxpW_c.js";import{e as x,S as B,r as p,F as K,b as N,b9 as T,Q as j,P as q,f as G,n as k,j as H,p as r,v as O,ag as Q,ak as z,g as m,aO as J}from"./jwt-decode.esm-CW-ehmUm.js";import{r as X}from"./redirect-BrXIgPpP.js";import{a as Y}from"./asyncComputed-Xa1P0TNG.js";import{u as _}from"./uuid-Cebg661w.js";import{L as Z}from"./CircularLoading-ylUWWooD.js";import"./Watermark-DjDnHfrp.js";import"./constants-N9y8G168.js";import"./consoleCapture-DPCsPq9K.js";import"./Login.vue_vue_type_script_setup_true_lang-CjaOjKLT.js";import"./OTPInput-CIVvtVfG.js";import"./Logo-D7ItGdyg.js";import"./string-DG69OOx2.js";import"./index-DzVyDbXC.js";import"./Steps-r5dlhdUZ.js";import"./index-DKWrpYOr.js";import"./runnerData-B-rwjNHa.js";import"./url-AFSWCooG.js";import"./colorHelpers-9BBJQtv0.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]="0988a0a6-786d-43b2-83c0-f57765b8e87c",n._sentryDebugIdIdentifier="sentry-dbid-0988a0a6-786d-43b2-83c0-f57765b8e87c")}catch{}})();const $={key:0,class:"loading"},ee=x({__name:"Form",setup(n){const o=z(),u=Q(),f=B({playerKey:_()}),b=R(),S=A(),s=p(null),v=p(null),l=p(null);K(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),E())});const{loading:c,result:e,error:g,refetch:E}=Y(async()=>{f.playerKey=_();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:F=>s.value=F}),D=w.getState();return s.value=D.formState,{runnerData:i,controller:w}}),C=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)});T(()=>{C.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)}j(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(),k(U,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):r(e)&&r(e).runnerData&&s.value&&!r(g)&&!r(c)?(m(),k(L,{key:f.playerKey,"form-runner-data":r(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":r(b).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=J(ee,[["__scopeId","data-v-0d259dfc"]]);export{Se as default};
//# sourceMappingURL=Form-C-znyXCb.js.map
