import{u as E}from"./index.d0984c8b.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.59990c05.js";import{b as P,r as K,c as N,d as T}from"./FormRunner.3a6a1c15.js";import{a as G}from"./asyncComputed.8e0b1df8.js";import{u as w}from"./uuid.041b9d5a.js";import{L as J}from"./CircularLoading.cbb2fd0e.js";import{f as O}from"./api.55619793.js";import"./pubsub.581fae3d.js";import"./url.2d4b3ba8.js";import"./Passwordless.3f793da0.js";import"./icons.57eb7190.js";import"./PlayerNavbar.9f5fc460.js";import"./WidgetsFrame.2f980296.js";import"./Steps.978b4077.js";import"./Card.8bb4a3f2.js";import"./TabPane.6b63df71.js";import"./hasIn.a77b4ba2.js";import"./Typography.164def35.js";import"./runnerData.fd965c02.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]="0a54fee8-a65b-47b6-b265-59b6f2b082e9",r._sentryDebugIdIdentifier="sentry-dbid-0a54fee8-a65b-47b6-b265-59b6f2b082e9")}catch{}})();const m=r=>(V("data-v-a3654c5f"),r=r(),x(),r),j={key:0,class:"loading"},z={key:1,class:"error"},H=m(()=>p("h1",null,"Oops! Something went wrong",-1)),Q=m(()=>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"}},$=m(()=>p("h1",null,"Page not found",-1)),ee=m(()=>p("p",null,"The page you requested could not be found.",-1)),te=[$,ee],oe=U({__name:"Form",setup(r){const l=F(),f=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",f,o,e)}const S=({path:o})=>{f.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;return(e=t.value)==null||e.controller.handleCloseAttempt(),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 ke=M(oe,[["__scopeId","data-v-a3654c5f"]]);export{ke as default};
//# sourceMappingURL=Form.07c944ed.js.map
