import{u as R}from"./userStore-ZzGDEfJ0.js";import{P as U}from"./PageStageView-DAPtpvJZ.js";import{F as L,a as W,b as A}from"./FormRunner-Ct8jAHcJ.js";import{u as I,c as P,d as V,S as x}from"./workspaceStore-CMQaTfN3.js";import{e as M,S as B,r as p,G as K,ak as N,ag as G,b as T,b9 as j,Q as q,x as H,f as O,n as k,j as Q,p as r,v as z,g as m,aO as J}from"./jwt-decode.esm-BYfS37aG.js";import{r as X}from"./redirect-wT-Y8Zfd.js";import{a as Y}from"./asyncComputed-Dxf4RCwC.js";import{u as _}from"./uuid-CHgzk6MJ.js";import{L as Z}from"./CircularLoading-DSsC5jij.js";import"./Watermark-BNe5HOS9.js";import"./constants-BEWVx_ZC.js";import"./consoleCapture-BPVon_ip.js";import"./Login.vue_vue_type_script_setup_true_lang-Dh30ZzIy.js";import"./OTPInput-B76NLryy.js";import"./Logo-DKvJNxAR.js";import"./string-IQGGUV40.js";import"./index-D2Zf-HsM.js";import"./Steps-fw8in-jn.js";import"./index-Bpjq9G-y.js";import"./runnerData-CFJzN8JX.js";import"./url-xbaQsfJ1.js";import"./colorHelpers-Dr5wl109.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]="030fcb94-0de2-477f-8c4b-007a283fc0c7",n._sentryDebugIdIdentifier="sentry-dbid-030fcb94-0de2-477f-8c4b-007a283fc0c7")}catch{}})();const $={key:0,class:"loading"},ee=M({__name:"Form",setup(n){const o=N(),u=G(),f=B({playerKey:_()}),b=R(),S=I(),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 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 L({formRunnerData:i,logService:null,connectionManager:new W(i.id,"player",o.query,x.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=T(()=>{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(()=>{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)}q(async()=>{window.addEventListener("beforeunload",d),window.addEventListener("pagehide",h)}),H(()=>{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(),O("div",$,[z(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(A,{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"])):Q("",!0)}}),Se=J(ee,[["__scopeId","data-v-0d259dfc"]]);export{Se as default};
//# sourceMappingURL=Form-BvmEXZ_E.js.map
