import{u as F}from"./userStore-DBMdJVjc.js";import{P as U}from"./PageStageView-iYco_AcY.js";import{F as L,a as W,b as A}from"./FormRunner-BH9Z2Awr.js";import{u as I,c as P,d as V,S as x}from"./workspaceStore-KCHQtpxL.js";import{e as K,N as M,r as p,O as N,b as B,aR as q,n as T,l as j,f as G,q as b,j as H,s as r,x as O,K as z,V as J,g as m,ar as Q}from"./jwt-decode.esm-hjaWXwux.js";import{r as X}from"./redirect-U64Eqa1h.js";import{a as Y}from"./asyncComputed-D_-SIG1g.js";import{u as _}from"./uuid-Do0lHHWb.js";import{L as Z}from"./CircularLoading-Cuf2gNcE.js";import"./Watermark-B64-avh-.js";import"./constants-BjnPUTv3.js";import"./consoleCapture-DsXB_FCi.js";import"./Login.vue_vue_type_script_setup_true_lang-BmsAHSat.js";import"./OTPInput-DeODd7XP.js";import"./Logo-CkrwUnIg.js";import"./string-RCvD6M5Y.js";import"./index-DiirI1XZ.js";import"./Steps-BocchZmV.js";import"./index-Dqh6yN2o.js";import"./runnerData-CNJxazV0.js";import"./url-GnsHFl5k.js";import"./colorHelpers-am_R58n2.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]="1602c4da-4764-49ac-8b95-9e3b89ebd0e1",n._sentryDebugIdIdentifier="sentry-dbid-1602c4da-4764-49ac-8b95-9e3b89ebd0e1")}catch{}})();const $={key:0,class:"loading"},ee=K({__name:"Form",setup(n){const o=J(),u=z(),f=M({playerKey:_()}),k=F(),S=I(),s=p(null),v=p(null),l=p(null);N(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 P(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 W({formRunnerData:i,logService:null,connectionManager:new A(i.id,"player",o.query,x.instance?.sessionMode??!1),onRedirect:y,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:R=>s.value=R}),D=w.getState();return s.value=D.formState,{runnerData:i,controller:w}}),C=B(()=>{if(l.value?.type==="page")return!1;const a=!c.value,t=!!g.value,i=!e.value||s.value===null;return a&&(t||i)});q(()=>{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)}T(async()=>{window.addEventListener("beforeunload",d),window.addEventListener("pagehide",h)}),j(()=>{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(),b(U,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):r(e)&&r(e).runnerData&&s.value&&!r(g)&&!r(c)?(m(),b(L,{key:f.playerKey,"form-runner-data":r(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":r(k).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-DWejQZ4C.js.map
