import{u as E}from"./index.7dcd1439.js";import{d as U,eB as F,eA as I,G as A,r as g,J as L,aw as R,o as C,L as B,u as n,b as i,ev as c,f as W,c as q,eE as V,eF as x,e as p,v as M}from"./outputWidgets.9bb29762.js";import{b as P,r as K,c as N,d as T}from"./FormRunner.03388a78.js";import{a as G}from"./asyncComputed.ac1a0197.js";import{u as w}from"./uuid.f9c6a703.js";import{L as J}from"./CircularLoading.9425ae48.js";import{f as O}from"./api.8bd36db0.js";import"./pubsub.90d4935e.js";import"./url.c222fac4.js";import"./Passwordless.5f2ec964.js";import"./index.15996575.js";import"./icons.d08bf04b.js";import"./PlayerNavbar.9b695a29.js";import"./WidgetsFrame.ebd50b14.js";import"./Steps.151a473f.js";import"./Card.b91f4cc4.js";import"./TabPane.aa230872.js";import"./hasIn.fa8167cd.js";import"./Typography.184e8c0b.js";import"./runnerData.84b552ce.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="ec0f8abf-4077-4051-9f46-2125db5385aa",r._sentryDebugIdIdentifier="sentry-dbid-ec0f8abf-4077-4051-9f46-2125db5385aa")}catch{}})();const f=r=>(V("data-v-f61ea327"),r=r(),x(),r),j={key:0,class:"loading"},z={key:1,class:"error"},H=f(()=>p("h1",null,"Oops! Something went wrong",-1)),Q=f(()=>p("p",null,"An unknown error ocurred. Please try again or contact support.",-1)),X=[H,Q],Y={key:2,class:"form"},Z={key:3,class:"error not-found",style:{height:"100vh"}},$=f(()=>p("h1",null,"Page not found",-1)),ee=f(()=>p("p",null,"The page you requested could not be found.",-1)),te=[$,ee],oe=U({__name:"Form",setup(r){const l=F(),m=I(),h=A({playerKey:w()}),d=g(null),_=g(null);L(l,()=>D());const{loading:b,result:t,error:k,refetch:D}=G(async()=>{h.playerKey=w();const o=l.path.slice(1),e=await O(o);if(!e)return null;const a=new N({formRunnerData:e,queryParams:l.query,userManager:E,logService:null,connectionManager:new T(e.id),onRedirect:v,onFormStart:()=>{},onFormEnd:()=>{},onAuthUpdate:u=>_.value=u,onStackTraceUpdate:null,onStateUpdate:u=>d.value=u}),s=a.getState();return _.value=s.passwordlessUser,d.value=s.formState,{runnerData:e,controller:a}});R(()=>{var o,e,a,s,u;!((o=t.value)!=null&&o.runnerData)||(e=t.value)!=null&&e.runnerData&&(document.title=(u=(a=t.value)==null?void 0:a.runnerData.welcomeTitle)!=null?u:(s=t.value)==null?void 0:s.runnerData.title)});function v(o,e){K("player",m,o,e)}const S=({path:o})=>{m.push({name:"form",query:l.query,params:{path:o.split("/")}})};C(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",y)}),B(()=>{window.removeEventListener("beforeunload",y)});const y=o=>{var e;if((e=t.value)!=null&&e.controller.handleCloseAttempt())return o.preventDefault(),""};return(o,e)=>{var a,s;return n(b)?(i(),c("div",j,[W(J)])):n(k)||n(t)===null||d.value===null?(i(),c("div",z,X)):(a=n(t))!=null&&a.runnerData?(i(),c("div",Y,[(i(),q(P,{key:h.playerKey,"form-runner-data":n(t).runnerData,"form-state":d.value,"is-preview":!1,"user-email":(s=_.value)==null?void 0:s.claims.email,class:"player",onNavigate:S,onRedirect:v,onActionClicked:n(t).controller.handleActionClick,onUpdateWidgetErrors:n(t).controller.updateWidgetFrontendErrors,onUpdateWidgetValue:n(t).controller.updateWidgetValue,onLogout:n(t).controller.logout},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onLogout"]))])):(i(),c("div",Z,te))}}});const De=M(oe,[["__scopeId","data-v-f61ea327"]]);export{De as default};
//# sourceMappingURL=Form.7ccacd89.js.map
