import{u as R}from"./userStore-Cvp-HM2T.js";import{P as U}from"./PageStageView-DgoYiUD6.js";import{F as L,a as W,b as A}from"./FormRunner-c2WiJ-xZ.js";import{u as I,c as P,d as M,S as V}from"./workspaceStore-C02eSYYX.js";import{e as K,O as x,r as p,C as B,b as N,b8 as j,M as q,K as T,f as G,n as _,j as H,p as a,q as O,ae as z,aj as J,g as m,aM as Q}from"./jwt-decode.esm-C7p7KYmD.js";import{r as X}from"./redirect-BTrKaKvw.js";import{a as Y}from"./asyncComputed-DQBxAc8n.js";import{u as k}from"./uuid-BCPeGqMd.js";import{L as Z}from"./CircularLoading-Dm1gD7nh.js";import"./Watermark-BBQ6W5Iz.js";import"./constants-DMOJEfPk.js";import"./consoleCapture-BZVsCKpd.js";import"./Login.vue_vue_type_script_setup_true_lang-cmINskXx.js";import"./OTPInput-Dgj6D_cS.js";import"./Logo-DHgCZdyN.js";import"./string-BFwHOwI3.js";import"./index-CEiA6CH7.js";import"./Steps-BLjKkl-k.js";import"./index-BMpT7rIm.js";import"./runnerData-tVXldQBM.js";import"./url-DckRtskK.js";import"./colorHelpers-Aow9wfUz.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]="e5ecca8f-07f3-4dae-be5a-a46a86a49f43",n._sentryDebugIdIdentifier="sentry-dbid-e5ecca8f-07f3-4dae-be5a-a46a86a49f43")}catch{}})();const $={key:0,class:"loading"},ee=K({__name:"Form",setup(n){const o=J(),u=z(),f=x({playerKey:k()}),S=R(),b=I(),s=p(null),v=p(null),l=p(null);B(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),C())});const{loading:c,result:e,error:g,refetch:C}=Y(async()=>{f.playerKey=k();const r=o.path.slice(1),t=await P(r);if(!t){u.push({name:"error",params:{status:"404"}});return}if(l.value=t,b.state.currentPageType=t.type,t.type==="page")return document.title=t.data.title,{runnerData:null,controller:null};const i=t.data;v.value=await M();const w=new W({formRunnerData:i,logService:null,connectionManager:new A(i.id,"player",o.query,V.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}}),E=N(()=>{if(l.value?.type==="page")return!1;const r=!c.value,t=!!g.value,i=!e.value||s.value===null;return r&&(t||i)});j(()=>{E.value&&u.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&(document.title=e.value.runnerData.title)});function y(r,t){window.removeEventListener("beforeunload",d),X("player",u,r,t)}q(async()=>{window.addEventListener("beforeunload",d),window.addEventListener("pagehide",h)}),T(()=>{window.removeEventListener("beforeunload",d),window.removeEventListener("pagehide",h),e.value?.controller?.stop()});const d=r=>{if(e.value?.controller?.handleCloseAttempt())return r.preventDefault(),""},h=()=>{e.value?.controller?.closeSession()};return(r,t)=>a(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"])):a(e)&&a(e).runnerData&&s.value&&!a(g)&&!a(c)?(m(),_(L,{key:f.playerKey,"form-runner-data":a(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":a(S).email,"worker-capacity":v.value,onRedirect:y,onActionClicked:a(e)?.controller.handleActionClick,onUpdateWidgetErrors:a(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:a(e)?.controller.updateWidgetValue,onAuthComplete:a(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","worker-capacity","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):H("",!0)}}),be=Q(ee,[["__scopeId","data-v-0d259dfc"]]);export{be as default};
//# sourceMappingURL=Form-Q36AQ-tH.js.map
