import{u as w}from"./userStore-CEwj0HpY.js";import{F as D,a as E,b as C}from"./FormRunner-djVhkgGz.js";import{a as k,P as R,r as S,H as F,ac as U,ad 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 p,aN as M}from"./jwt-decode.esm-CQm3LY6y.js";import{r as P}from"./redirect-DEHFkoSn.js";import{a as j}from"./asyncComputed-_0zTJceu.js";import{u as b}from"./uuid-DEeQP7e4.js";import{L as q}from"./CircularLoading-DJqJpzzK.js";import{f as G}from"./workspaceStore-BnjNoni6.js";import"./Login.vue_vue_type_script_setup_true_lang-CFrOZlEV.js";import"./Logo-BgkfgO9Z.js";import"./string-W5Qb0ZHU.js";import"./index-B7v0_G2C.js";import"./Steps-CCzu7Q5O.js";import"./index-BXlweqZj.js";import"./Watermark-B3gfKlik.js";import"./constants-BkB36yfF.js";import"./url-DLnEW9pi.js";import"./colorHelpers-DpdYunNI.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[n]="d760731b-9b9b-4e45-b027-2474f6aaef52",a._sentryDebugIdIdentifier="sentry-dbid-d760731b-9b9b-4e45-b027-2474f6aaef52")}catch{}})();const H={key:0,class:"loading"},T=k({__name:"Form",setup(a){const n=U(),i=A(),c=R({playerKey:b()}),h=w(),s=S(null);F(n,()=>{n.name==="form"&&v()});const{loading:l,result:e,error:m,refetch:v}=j(async()=>{c.playerKey=b();const o=n.path.slice(1),r=await G(o);if(!r){i.push({name:"error",params:{status:"404"}});return}const u=new D({formRunnerData:r,logService:null,connectionManager:new E(r.id,"player",n.query),onRedirect:f,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:_=>s.value=_}),g=u.getState();return s.value=g.formState,{runnerData:r,controller:u}}),y=I(()=>{const o=!l,r=!!m,u=!e||s.value===null;return o&&(r||u)});L(()=>{y.value&&i.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&e.value?.runnerData&&(document.title=e.value?.runnerData.title)});function f(o,r){window.removeEventListener("beforeunload",d),P("player",i,o,r)}W(async()=>{window.addEventListener("beforeunload",d)}),V(()=>{window.removeEventListener("beforeunload",d)});const d=o=>{if(e.value?.controller.handleCloseAttempt())return o.preventDefault(),""};return(o,r)=>t(l)?(p(),N("div",H,[K(q)])):t(e)&&t(e).runnerData&&s.value&&!t(m)&&!t(l)?(p(),x(C,{key:c.playerKey,"form-runner-data":t(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":t(h).email,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","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):B("",!0)}}),de=M(T,[["__scopeId","data-v-1b2b3f4f"]]);export{de as default};
//# sourceMappingURL=Form-CReSUOWC.js.map
