import{u as R}from"./userStore-DtRefrCQ.js";import{P as U}from"./PageStageView-BOmQmcX5.js";import{F as L,a as P,b as W}from"./FormRunner-Br8SmMKZ.js";import{u as A,c as I,d as V,S as M}from"./workspaceStore-D9mz6FOR.js";import{e as N,S as x,r as p,F as B,b as K,b8 as T,Q as j,P as q,f as G,n as b,j as H,p as r,v as Q,ag as z,ak as J,g as m,aN as O}from"./jwt-decode.esm-Di13oRQw.js";import{r as X}from"./redirect-KZGCDokK.js";import{a as Y}from"./asyncComputed-DOI-gBUl.js";import{u as k}from"./uuid-BlUX7GeO.js";import{L as Z}from"./CircularLoading-D6n2bEFF.js";import"./Watermark-znl7zoYd.js";import"./constants-D5_IKi1U.js";import"./consoleCapture-0m24QrWJ.js";import"./Login.vue_vue_type_script_setup_true_lang-BbCWODY7.js";import"./OTPInput-CzNQu672.js";import"./Logo-Dl3wIG-e.js";import"./string-BzsxlFG6.js";import"./index-DYCjRMHH.js";import"./Steps-DAPYlkRB.js";import"./index-BJMaxV6a.js";import"./runnerData-PSt4Y1Um.js";import"./url-BV-AFuGX.js";import"./colorHelpers-Bkim6eSt.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]="b5708ba6-461f-494f-b2fd-4b0d60ddc3d6",n._sentryDebugIdIdentifier="sentry-dbid-b5708ba6-461f-494f-b2fd-4b0d60ddc3d6")}catch{}})();const $={key:0,class:"loading"},ee=N({__name:"Form",setup(n){const o=J(),u=z(),f=x({playerKey:k()}),_=R(),S=A(),s=p(null),v=p(null),l=p(null);B(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),E())});const{loading:d,result:e,error:g,refetch:E}=Y(async()=>{f.playerKey=k();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=K(()=>{if(l.value?.type==="page")return!1;const a=!d.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",c),X("player",u,a,t)}j(async()=>{window.addEventListener("beforeunload",c),window.addEventListener("pagehide",h)}),q(()=>{window.removeEventListener("beforeunload",c),window.removeEventListener("pagehide",h),e.value?.controller?.stop()});const c=a=>{if(e.value?.controller?.handleCloseAttempt())return a.preventDefault(),""},h=()=>{e.value?.controller?.closeSession()};return(a,t)=>r(d)?(m(),G("div",$,[Q(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(d)?(m(),b(L,{key:f.playerKey,"form-runner-data":r(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":r(_).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=O(ee,[["__scopeId","data-v-0d259dfc"]]);export{Se as default};
//# sourceMappingURL=Form-DcjszIB5.js.map
