import{u as k}from"./index.4303c11c.js";import{d as E,eG as R,eM as U,N as C,r as h,O as F,D as A,az as S,o as I,R as L,u as n,b as g,ey as W,f as B,c as M,eA as V,E as x}from"./outputWidgets.e5f9ffc6.js";import{b as N,r as K,c as G,d as T}from"./FormRunner.a088e63d.js";import{a as q}from"./asyncComputed.2210bd1a.js";import{u as w}from"./uuid.6d5862ac.js";import{L as z}from"./CircularLoading.9832fa98.js";import{f as O}from"./api.e55a1f3c.js";import"./fetch.c1359dac.js";import"./pubsub.75396d00.js";import"./url.c11ddd9f.js";import"./Login.vue_vue_type_script_setup_true_lang.e0dae155.js";import"./Link.1d347d21.js";import"./Base.d0d329e2.js";import"./index.ff6bc189.js";import"./Paragraph.1cbc8077.js";import"./Text.e6c27a3b.js";import"./Title.f988141d.js";import"./index.aab66451.js";import"./PhArrowClockwise.vue.ebbdd756.js";import"./WidgetsFrame.0d60536e.js";import"./Steps.3108fe7f.js";import"./PhInfo.vue.f379b85f.js";import"./Card.a9237487.js";import"./TabPane.b891a337.js";import"./hasIn.54609e4a.js";import"./runnerData.f991c68f.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},i=new Error().stack;i&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[i]="6171e4a2-7f22-4f6a-bdca-27d587aa9ade",u._sentryDebugIdIdentifier="sentry-dbid-6171e4a2-7f22-4f6a-bdca-27d587aa9ade")}catch{}})();const P={key:0,class:"loading"},j=E({__name:"Form",setup(u){const i=R(),d=U(),p=C({playerKey:w()}),l=h(null),c=h(null);F(i,()=>D());const{loading:m,result:r,error:f,refetch:D}=q(async()=>{p.playerKey=w();const t=i.path.slice(1),e=await O(t);if(!e){d.push({name:"error",params:{status:"404"}});return}const a=new G({formRunnerData:e,userManager:k,logService:null,connectionManager:new T(e.id,"player",i.query),onRedirect:v,onFormStart:()=>{},onFormEnd:()=>{},onAuthUpdate:o=>c.value=o,onStackTraceUpdate:null,onStateUpdate:o=>l.value=o}),s=a.getState();return c.value=s.passwordlessUser,l.value=s.formState,{runnerData:e,controller:a}}),b=A(()=>{const t=!m,e=!!f,a=!r||l.value===null;return t&&(e||a)});S(()=>{var t,e,a,s,o;b.value&&d.push({name:"error",params:{status:"500"}}),!!((t=r.value)!=null&&t.runnerData)&&(e=r.value)!=null&&e.runnerData&&(document.title=(o=(a=r.value)==null?void 0:a.runnerData.welcomeTitle)!=null?o:(s=r.value)==null?void 0:s.runnerData.title)});function v(t,e){K("player",d,t,e)}I(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",_)}),L(()=>{window.removeEventListener("beforeunload",_)});const _=t=>{var e;if((e=r.value)!=null&&e.controller.handleCloseAttempt())return t.preventDefault(),""};return(t,e)=>{var a,s,o,y;return n(m)?(g(),W("div",P,[B(z)])):n(r)&&n(r).runnerData&&l.value&&!n(f)&&!n(m)?(g(),M(N,{key:p.playerKey,"form-runner-data":n(r).runnerData,"form-state":l.value,"is-preview":!1,"user-email":(a=c.value)==null?void 0:a.claims.email,onRedirect:v,onActionClicked:(s=n(r))==null?void 0:s.controller.handleActionClick,onUpdateWidgetErrors:(o=n(r))==null?void 0:o.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(y=n(r))==null?void 0:y.controller.updateWidgetValue},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue"])):V("",!0)}}});const ge=x(j,[["__scopeId","data-v-1020d95f"]]);export{ge as default};
//# sourceMappingURL=Form.ffe6e289.js.map
