import{u as F}from"./userStore-BD2sJQ0n.js";import{P as U}from"./PageStageView-Bjm-ro9c.js";import{F as L,a as W,b as A}from"./FormRunner-CN-NuZhX.js";import{u as I,c as P,d as V,S as K}from"./workspaceStore-B2G7PrH8.js";import{e as M,K as N,r as p,N as x,b as B,aR as q,$ as T,E as j,f as G,n as b,j as H,p as r,q as J,J as $,V as z,g as m,ar as O}from"./jwt-decode.esm-CZajAnkk.js";import{r as Q}from"./redirect-jPa4y7n_.js";import{a as X}from"./asyncComputed-DXAjR52O.js";import{u as _}from"./uuid-DSTkeDkZ.js";import{L as Y}from"./CircularLoading-D6CW-lVm.js";import"./Watermark-Bs4QVH0Z.js";import"./constants-DBenAw06.js";import"./consoleCapture-DxHXlId9.js";import"./Login.vue_vue_type_script_setup_true_lang-CbDeuNmW.js";import"./OTPInput-3zvejt3v.js";import"./Logo-DM5mhRuS.js";import"./string-CFhNxAoY.js";import"./index-CadB79EP.js";import"./Steps-XGJYDVJ8.js";import"./index-DuICX_K0.js";import"./runnerData-BvOYrde2.js";import"./url-CT13c0nd.js";import"./colorHelpers-C087BzGB.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]="6bbc58eb-c638-4c6a-889d-bfdf4515ea76",n._sentryDebugIdIdentifier="sentry-dbid-6bbc58eb-c638-4c6a-889d-bfdf4515ea76")}catch{}})();const Z={key:0,class:"loading"},ee=M({__name:"Form",setup(n){const o=z(),u=$(),f=N({playerKey:_()}),k=F(),E=I(),s=p(null),v=p(null),l=p(null);x(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),S())});const{loading:c,result:e,error:g,refetch:S}=X(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,E.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,K.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),Q("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",Z,[J(Y)])):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)}}),Ee=O(ee,[["__scopeId","data-v-0d259dfc"]]);export{Ee as default};
//# sourceMappingURL=Form-BqdTT0ND.js.map
