import{u as C}from"./userStore-3DsQ903R.js";import{F as E,a as D,b as S}from"./FormRunner-CBRA7Pfm.js";import{f as R,c as F,S as U}from"./workspaceStore-CupbCNkH.js";import{e as W,Y as A,r as v,M as I,an as L,aj as M,b as V,be as x,W as B,x as K,f as N,n as j,j as P,p as t,v as q,g as y,aQ as G}from"./jwt-decode.esm-C8xLey9w.js";import{r as Q}from"./redirect-CuVgwb6-.js";import{a as T}from"./asyncComputed-DLrIrnko.js";import{u as h}from"./uuid-s80p2rPA.js";import{L as Y}from"./CircularLoading-BA-LYjen.js";import"./Login.vue_vue_type_script_setup_true_lang-BmB5hq_-.js";import"./OTPInput-enShajAi.js";import"./Logo-DwksesLM.js";import"./string-T9AIbozp.js";import"./index-Cp6uH1g7.js";import"./Steps-C2EaAj-4.js";import"./index-ZCQ0Vqbi.js";import"./Watermark-DFfATMW9.js";import"./constants-DPsHFSBH.js";import"./runnerData-Bxm1WPeV.js";import"./url-CHJjGHqh.js";import"./colorHelpers-CTyEqvwU.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="c338a87d-2503-49fb-828b-2de40573315e",n._sentryDebugIdIdentifier="sentry-dbid-c338a87d-2503-49fb-828b-2de40573315e")}catch{}})();const z={key:0,class:"loading"},H=W({__name:"Form",setup(n){const a=L(),l=M(),d=A({playerKey:h()}),g=C(),s=v(null),m=v(null);I(a,()=>{a.name==="form"&&(e.value?.controller.stop(),w())});const{loading:u,result:e,error:p,refetch:w}=T(async()=>{d.playerKey=h();const o=a.path.slice(1),r=await R(o);if(m.value=await F(),!r){l.push({name:"error",params:{status:"404"}});return}const i=new E({formRunnerData:r,logService:null,connectionManager:new D(r.id,"player",a.query,U.instance?.sessionMode??!1),onRedirect:f,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:k=>s.value=k}),b=i.getState();return s.value=b.formState,{runnerData:r,controller:i}}),_=V(()=>{const o=!u.value,r=!!p.value,i=!e.value||s.value===null;return o&&(r||i)});x(()=>{_.value&&l.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&(document.title=e.value.runnerData.title)});function f(o,r){window.removeEventListener("beforeunload",c),Q("player",l,o,r)}B(async()=>{window.addEventListener("beforeunload",c)}),K(()=>{window.removeEventListener("beforeunload",c),e.value?.controller.stop()});const c=o=>{if(e.value?.controller.handleCloseAttempt())return o.preventDefault(),""};return(o,r)=>t(u)?(y(),N("div",z,[q(Y)])):t(e)&&t(e).runnerData&&s.value&&!t(p)&&!t(u)?(y(),j(S,{key:d.playerKey,"form-runner-data":t(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":t(g).email,"worker-capacity":m.value,onRedirect:f,onActionClicked:t(e)?.controller.handleActionClick,onUpdateWidgetErrors:t(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:t(e)?.controller.updateWidgetValue,onAuthComplete:t(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","worker-capacity","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):P("",!0)}}),ve=G(H,[["__scopeId","data-v-8dc2f03e"]]);export{ve as default};
//# sourceMappingURL=Form-DiDc3UDr.js.map
