import{u as P}from"./index.9e42fc8a.js";import{d as b,H as U,b as l,ev as m,e as n,eD as y,eE as A,eF as W,v as k,a as $,f as g,u as a,ar as q,eA as L,eB as M,r as w,c as V,eL as N}from"./outputWidgets.c8053a9d.js";import{b as T,c as H,d as O,r as j}from"./FormRunner.ba6632e0.js";import{a as K}from"./asyncComputed.f7e207a4.js";import{L as z}from"./CircularLoading.ad5c4437.js";import{F as G}from"./forms.6a0bb3d6.js";import{W as E}from"./workspaces.a3b629ff.js";import"./envVars.5548ab88.js";import{K as J}from"./icons.9e4059c8.js";import"./pubsub.231a79a7.js";import"./url.d8c088a2.js";import"./Passwordless.8c4be6f9.js";import"./index.940b895a.js";import"./PlayerNavbar.0d280d97.js";import"./WidgetsFrame.9f707bc7.js";import"./Steps.120a5c3c.js";import"./Card.6e0744ae.js";import"./TabPane.dad41446.js";import"./hasIn.7ae70fa0.js";import"./Typography.e5f51e32.js";import"./record.c60a7475.js";import"./runnerData.fe27f16a.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="dd52d5bf-fd98-477a-9f60-ee7f33eafd2e",e._sentryDebugIdIdentifier="sentry-dbid-dd52d5bf-fd98-477a-9f60-ee7f33eafd2e")}catch{}})();const I=e=>(A("data-v-3e46b76c"),e=e(),W(),e),Q={class:"error"},X=I(()=>n("h1",{class:"error-header"},"Error",-1)),Y={class:"error-body"},Z={class:"error-message"},ee={class:"error-details"},re=I(()=>n("span",null,"Reload",-1)),te=[re],oe=b({__name:"Error",props:{error:{type:Object,required:!0},repeated:{type:Boolean,required:!1}},emits:["reload"],setup(e,{emit:r}){const s=e,o=U(()=>s.repeated?"Ooops. The same error occured, please try again later.":"An error occurred while loading.");function i(){r("reload")}return(h,_)=>(l(),m("div",Q,[X,n("div",Y,[n("div",Z,[n("p",null,y(o.value),1),n("p",ee,y(e.error.name)+": "+y(e.error.message),1)]),n("div",{class:"error-actions"},[n("button",{class:"btn btn-primary",onClick:i},te)])])]))}});const ae=k(oe,[["__scopeId","data-v-3e46b76c"]]),ne=b({__name:"BackButton",emits:["exitFullscreenPreview"],setup(e,{emit:r}){return(s,o)=>{const i=$("icon");return l(),m("button",{class:"back-btn",onClick:o[0]||(o[0]=h=>r("exitFullscreenPreview"))},[g(i,{class:"icon",path:a(J),width:"20",height:"20",fill:"#5A677A"},null,8,["path"]),q(" Editor ")])}}});const se=k(ne,[["__scopeId","data-v-a3f31716"]]),ie={class:"page"},ce={key:1,class:"error"},de={key:2,style:{width:"100%",height:"100%",display:"flex"}},le={style:{width:"100%",height:"100%",display:"flex"}},ue=b({__name:"FormPreview",setup(e){const r=L(),s=M(),o=w(null),i=w(null),h=s.query,_=w(null);function S(t,c){j("preview",r,t,c)}const{result:f,loading:B,refetch:x,error:F}=K(async()=>{const[t,c,v]=await Promise.all([G.get(s.params.id),E.get(),E.readTestData()]),u=new H({formRunnerData:t.makeRunnerData(c),queryParams:h,userManager:P,connectionManager:new O(t.id),onFormStart:()=>{},onFormEnd:()=>{},onRedirect:S,onAuthUpdate:d=>_.value=d,onStateUpdate:d=>o.value=d,logService:null,onStackTraceUpdate:null});t.updateInitialState("test_data",v),i.value=t.makeRunnerData(c);const p=u.getState();return o.value=p.formState,_.value=p.passwordlessUser,N({form:t,workspace:c,controller:u})}),D=async({id:t})=>{await r.push({params:{id:t},name:"formPreview",query:s.query}),x()},C=()=>{r.push(`/_editor/form/${encodeURIComponent(s.params.id)}`)};return(t,c)=>{var v,u,p,d,R;return l(),m("div",ie,[a(B)||!o.value||!i.value?(l(),V(z,{key:0})):a(F)?(l(),m("div",ce,[g(ae,{error:a(F),onReload:a(x)},null,8,["error","onReload"])])):(l(),m("main",de,[n("div",le,[g(T,{style:{height:"unset",flex:1,overflow:"hidden"},"is-preview":!1,"form-runner-data":i.value,"form-state":o.value,"user-email":(v=_.value)==null?void 0:v.claims.email,onUpdateWidgetErrors:(u=a(f))==null?void 0:u.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(p=a(f))==null?void 0:p.controller.updateWidgetValue,onActionClicked:(d=a(f))==null?void 0:d.controller.handleActionClick,onNavigate:D,onLogout:(R=a(f))==null?void 0:R.controller.logout},null,8,["form-runner-data","form-state","user-email","onUpdateWidgetErrors","onUpdateWidgetValue","onActionClicked","onLogout"]),g(se,{onExitFullscreenPreview:C})])]))])}}});const Ae=k(ue,[["__scopeId","data-v-c5c2a66b"]]);export{Ae as default};
//# sourceMappingURL=FormPreview.cb372c4e.js.map
