import{u as w}from"./userStore-C8fkOSZz.js";import{F as D,a as E,b as C}from"./FormRunner-3VldEjCn.js";import{a as k,P as R,r as S,H as F,ac as U,ae as A,c as I,b3 as L,D as W,k as V,b as N,p as x,g as B,u as t,j as K,e as f,aN as M}from"./jwt-decode.esm-C3bBZEB2.js";import{r as P}from"./redirect-DajpE9Sy.js";import{a as j}from"./asyncComputed-BmaNPgAU.js";import{u as v}from"./uuid-DD8YIIY0.js";import{L as q}from"./CircularLoading-DDksgcKB.js";import{f as G}from"./workspaceStore-Di3f8xeY.js";import"./Login.vue_vue_type_script_setup_true_lang-a14BJ1AV.js";import"./OTPInput-BW5kuHsH.js";import"./Logo-DNmBbXy6.js";import"./string-DzKeI6fB.js";import"./index-DTtpE0Cf.js";import"./Steps-CCFr1jBb.js";import"./index-BleGAYYC.js";import"./Watermark-CP0Cjc5C.js";import"./constants-uJo_92lg.js";import"./url-DnDc1Az0.js";import"./colorHelpers-57zbC7n6.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]="01c695a8-9994-4cf1-ab3b-5238d6dca355",n._sentryDebugIdIdentifier="sentry-dbid-01c695a8-9994-4cf1-ab3b-5238d6dca355")}catch{}})();const H={key:0,class:"loading"},T=k({__name:"Form",setup(n){const a=U(),i=A(),d=R({playerKey:v()}),h=w(),s=S(null);F(a,()=>{a.name==="form"&&y()});const{loading:u,result:e,error:m,refetch:y}=j(async()=>{d.playerKey=v();const o=a.path.slice(1),r=await G(o);if(!r){i.push({name:"error",params:{status:"404"}});return}const l=new D({formRunnerData:r,logService:null,connectionManager:new E(r.id,"player",a.query),onRedirect:p,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:_=>s.value=_}),b=l.getState();return s.value=b.formState,{runnerData:r,controller:l}}),g=I(()=>{const o=!u,r=!!m,l=!e||s.value===null;return o&&(r||l)});L(()=>{g.value&&i.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&e.value?.runnerData&&(document.title=e.value?.runnerData.title)});function p(o,r){window.removeEventListener("beforeunload",c),P("player",i,o,r)}W(async()=>{window.addEventListener("beforeunload",c)}),V(()=>{window.removeEventListener("beforeunload",c),e.value?.controller.stop()});const c=o=>{if(e.value?.controller.handleCloseAttempt())return o.preventDefault(),""};return(o,r)=>t(u)?(f(),N("div",H,[K(q)])):t(e)&&t(e).runnerData&&s.value&&!t(m)&&!t(u)?(f(),x(C,{key:d.playerKey,"form-runner-data":t(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":t(h).email,onRedirect:p,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","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):B("",!0)}}),de=M(T,[["__scopeId","data-v-db766211"]]);export{de as default};
//# sourceMappingURL=Form-DWAynvTS.js.map
