import{r as D}from"./index.c13cb307.js";import{u as k}from"./log.90d86245.js";import{F as x,R as S}from"./broker.1fe1c683.js";import{d as B,u as I,Q as w,J as m,y as r,b as o,c,e as N,q as g,H as K,G as L,N as O,O as T,v as p,p as E}from"./registerWidgets.990552e9.js";import{D as F,n as C}from"./DashPlayer.a7675809.js";import{a as V}from"./asyncComputed.5a7faf96.js";import{r as j,n as A}from"./runnerData.bbafb2b3.js";import{L as G}from"./CircularLoading.b7a09562.js";import"./passwordlessManager.43e7eeb6.js";import"./icons.d4e872e2.js";import"./Passwordless.62d0ea6a.js";import"./WidgetsFrame.b07f4485.js";import"./colors.d7a0ca86.js";import"./Modal.180a3c02.js";async function H(s){const t=await fetch(`/_api/${s}`);if(t.status==404)return null;if(!t.ok)throw new Error(await t.text());const{form:u,dash:n}=await t.json();return{form:u&&j(u),dash:n&&A(n)}}const d=s=>(O("data-v-bee3a390"),s=s(),T(),s),J={key:0,class:"loading"},Q={key:1,class:"error"},$=d(()=>p("h1",null,"Oops! Something went wrong",-1)),z=d(()=>p("p",null,"An unknown error ocurred. Please try again or contact support.",-1)),M=[$,z],U={key:2,class:"form"},W={key:3,class:"dash-wrapper"},X={key:4,class:"error not-found"},Y=d(()=>p("h1",null,"Page not found",-1)),Z=d(()=>p("p",null,"The page you requested could not be found.",-1)),ee=[Y,Z],te=B({__name:"Player",setup(s){const t=K(),u=L(),n=I({playerKey:k()}),_=({path:e})=>{u.push({name:"player",query:t.query,params:{path:e.split("/")}})},h=async()=>{n.playerKey=k()};w([()=>t.path,()=>t.query],()=>h());const{loading:P,result:a,error:b}=V(()=>{var e;return H((e=t.path.slice(1))!=null?e:"")}),f=m(()=>i.value?S.create({isLocal:!1,isPreview:!1,formPath:i.value.path}):null),i=m(()=>{var e,l;return(l=(e=a.value)==null?void 0:e.form)!=null?l:null}),y=m(()=>{var l,v;if(!((l=a.value)!=null&&l.dash))return null;const e=C.create((v=a.value)==null?void 0:v.dash,!1);return e.onRedirect(({url:R,queryParams:q})=>D(u,R,q)),e});return w(a,()=>{var e;!a.value||(a.value.form?document.title=(e=a.value.form.welcomeTitle)!=null?e:a.value.form.title:a.value.dash&&(document.title=a.value.dash.title))}),(e,l)=>r(P)?(o(),c("div",J,[N(G)])):r(b)?(o(),c("div",Q,M)):r(i)&&r(f)?(o(),c("div",U,[(o(),g(x,{key:n.playerKey,class:"player",form:r(i),params:r(t).query,broker:r(f),"enable-auto-focus":!0,onNavigate:_,onLogout:h},null,8,["form","params","broker"]))])):r(y)?(o(),c("div",W,[(o(),g(F,{key:n.playerKey,class:"player","is-preview":!1,params:r(t).query,"dash-player-state":r(y),"widgets-with-errors":[],onNavigate:_},null,8,["params","dash-player-state"]))])):(o(),c("div",X,ee))}});const fe=E(te,[["__scopeId","data-v-bee3a390"]]);export{fe as default};
//# sourceMappingURL=Player.2812b693.js.map
