import{u as U}from"./userStore-B4jqUwEL.js";import{P as F}from"./PageStageView-rF7lRQUt.js";import{F as L,a as W,b as A}from"./FormRunner-B_EfyHdb.js";import{u as I,c as P,d as V,S as M}from"./workspaceStore-sWJCG1kE.js";import{e as x,U as B,r as p,G as K,b as N,b9 as G,R as T,Q as j,f as q,n as _,j as H,p as r,v as O,ah as Q,al as z,g as m,aO as J}from"./jwt-decode.esm-Da8x-1xB.js";import{r as X}from"./redirect-CuZp9kmH.js";import{a as Y}from"./asyncComputed-J78O2Y__.js";import{u as b}from"./uuid-BPwEXAQs.js";import{L as Z}from"./CircularLoading-B5VLBjSJ.js";import"./Watermark-CCh_fY7p.js";import"./constants-CAYghYvd.js";import"./consoleCapture-DREw56G-.js";import"./Login.vue_vue_type_script_setup_true_lang-Cryu-Vny.js";import"./OTPInput-D6Fi9zOP.js";import"./Logo-RPAetcP3.js";import"./string-CLQB_5TN.js";import"./index-BJ99xF-g.js";import"./Steps-C5mRGxJJ.js";import"./index-C1gsp_zE.js";import"./runnerData-Ck30Znt6.js";import"./url-WpgygH3Q.js";import"./colorHelpers-DWgwf-SH.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]="25051468-d1dd-459c-bd78-c2d592bd3731",n._sentryDebugIdIdentifier="sentry-dbid-25051468-d1dd-459c-bd78-c2d592bd3731")}catch{}})();const $={key:0,class:"loading"},ee=x({__name:"Form",setup(n){const o=z(),u=Q(),f=B({playerKey:b()}),k=U(),S=I(),s=p(null),v=p(null),l=p(null);K(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),E())});const{loading:d,result:e,error:g,refetch:E}=Y(async()=>{f.playerKey=b();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,M.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=N(()=>{if(l.value?.type==="page")return!1;const a=!d.value,t=!!g.value,i=!e.value||s.value===null;return a&&(t||i)});G(()=>{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)}T(async()=>{window.addEventListener("beforeunload",c),window.addEventListener("pagehide",h)}),j(()=>{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(),q("div",$,[O(Z)])):l.value&&l.value.type==="page"?(m(),_(F,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):r(e)&&r(e).runnerData&&s.value&&!r(g)&&!r(d)?(m(),_(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=J(ee,[["__scopeId","data-v-0d259dfc"]]);export{Se as default};
//# sourceMappingURL=Form-Bt8TZtWo.js.map
