import{u as S}from"./userStore-i0gLq6Lw.js";import{F as L,b as P,a as $}from"./FormRunner-9GgCGrzA.js";import{L as C}from"./CircularLoading-C93srCTe.js";import{e as E,r as u,S as W,ag as R,f as v,j as F,v as y,bU as M,g as c,aO as U,V as T,H as B,ak as K,b as N,bA as q,x as H,n as k,p as t}from"./jwt-decode.esm-D4VPbsXq.js";import{W as J}from"./Watermark-BGG-l2IL.js";import{b as j,f as G,c as O,S as z}from"./workspaceStore-B3Wo-cgd.js";import{r as Q}from"./redirect-B79q_bTo.js";import{a as X}from"./asyncComputed-C8n8hd2A.js";import{u as D}from"./uuid-BtxcfO0S.js";import"./Login.vue_vue_type_script_setup_true_lang-DTMN2WaT.js";import"./OTPInput-BbZeOu9k.js";import"./Logo-gbE1_hN1.js";import"./string-BKmvhOWC.js";import"./index-Ie9yuaFA.js";import"./Steps-PpcmFFlx.js";import"./index-B1Fh0yIs.js";import"./constants-HFTeRK_q.js";import"./runnerData-veWy0GOn.js";import"./url-DrKewZ5y.js";import"./colorHelpers-CSEqB2v6.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[a]="9bdb932d-7bb4-4cc9-a547-599ad8474ace",s._sentryDebugIdIdentifier="sentry-dbid-9bdb932d-7bb4-4cc9-a547-599ad8474ace")}catch{}})();const Y={class:"page-container"},Z={key:0,class:"loading"},ee={key:1,class:"error-container"},ae=["srcdoc"],te=E({__name:"PageStageView",props:{uiData:{}},setup(s){const a=s,d=R(),p=u(!0),m=u(""),r=u(!1),g=u(null);return W(async()=>{const o=S();o.loadJWT();try{const l=await j(`/_page/${a.uiData.path}`,{headers:o.authHeaders});if(l.status===401){o.removeJWT(),d.push({name:"playerLogin",query:{redirect:`/${a.uiData.path}`}});return}if(l.ok){const e=await l.text();if(e){const h=`<base href="/_page/${a.uiData.path}">`;m.value=h+e}else r.value=!0}else r.value=!0}catch{r.value=!0}p.value=!1}),(o,l)=>(c(),v("div",Y,[p.value?(c(),v("div",Z,[y(C)])):r.value?(c(),v("div",ee,[y(M,{"error-message":null,"execution-id":null,locale:"en"})])):m.value?(c(),v("iframe",{key:2,ref_key:"iframeRef",ref:g,class:"page-iframe",srcdoc:m.value,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},null,8,ae)):F("",!0),y(J,{"page-id":s.uiData.id,locale:"en"},null,8,["page-id"])]))}}),re=U(te,[["__scopeId","data-v-ec4dbe1c"]]),oe={key:0,class:"loading"},ne=E({__name:"Form",setup(s){const a=K(),d=R(),p=T({playerKey:D()}),m=S(),r=u(null),g=u(null),o=u(null);B(a,()=>{a.name==="form"&&(e.value?.controller?.stop(),x())});const{loading:l,result:e,error:h,refetch:x}=X(async()=>{p.playerKey=D();const i=a.path.slice(1),n=await G(i);if(!n){d.push({name:"error",params:{status:"404"}});return}if(o.value=n,n.type==="page")return document.title=n.data.title,{runnerData:null,controller:null};const f=n.data;g.value=await O();const b=new L({formRunnerData:f,logService:null,connectionManager:new P(f.id,"player",a.query,z.instance?.sessionMode??!1),onRedirect:w,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:V=>r.value=V}),I=b.getState();return r.value=I.formState,{runnerData:f,controller:b}}),A=N(()=>{if(o.value?.type==="page")return!1;const i=!l.value,n=!!h.value,f=!e.value||r.value===null;return i&&(n||f)});q(()=>{A.value&&d.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&(document.title=e.value.runnerData.title)});function w(i,n){window.removeEventListener("beforeunload",_),Q("player",d,i,n)}W(async()=>{window.addEventListener("beforeunload",_)}),H(()=>{window.removeEventListener("beforeunload",_),e.value?.controller?.stop()});const _=i=>{if(e.value?.controller?.handleCloseAttempt())return i.preventDefault(),""};return(i,n)=>t(l)?(c(),v("div",oe,[y(C)])):o.value&&o.value.type==="page"?(c(),k(re,{key:1,"ui-data":o.value.data},null,8,["ui-data"])):t(e)&&t(e).runnerData&&r.value&&!t(h)&&!t(l)?(c(),k($,{key:p.playerKey,"form-runner-data":t(e).runnerData,"form-state":r.value,"is-preview":!1,"user-email":t(m).email,"worker-capacity":g.value,onRedirect:w,onActionClicked:t(e)?.controller.handleActionClick,onUpdateWidgetErrors:t(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:t(e)?.controller.updateWidgetValue,onAuthComplete:t(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","worker-capacity","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):F("",!0)}}),Ee=U(ne,[["__scopeId","data-v-72290c4c"]]);export{Ee as default};
//# sourceMappingURL=Form-DI1dxmzF.js.map
