import{u as C}from"./router.c605742c.js";import{b as U,r as F,c as I,d as B}from"./FormRunner.f24da2eb.js";import{A as T}from"./api.850af954.js";import{d as x,eB as L,eN as V,D as W,e as w,g as N,f as K,aB as M,U as q,a5 as G,u as t,o as f,V as P,b as p,c as k,w as _,R as Y,aw as D,cW as j,cS as z,c_ as H,Y as J}from"./vue-router.a333e065.js";import{a as O}from"./asyncComputed.77239fe2.js";import{u as R}from"./uuid.4814b7c4.js";import{L as Q}from"./CircularLoading.89fca5e8.js";import{f as X}from"./api.3bef6029.js";import"./url.30f67d32.js";import"./Login.vue_vue_type_script_setup_true_lang.5e0d81f9.js";import"./index.26e72621.js";import"./WidgetsFrame.0e18b995.js";import"./Steps.83462b31.js";import"./Watermark.b53c8fd9.js";import"./Card.30555f3f.js";import"./TabPane.4cf5b1ee.js";import"./fetch.0f0375b3.js";import"./metadata.97c76d2d.js";import"./PhCheckCircle.vue.f4992773.js";import"./PhKanban.vue.36dae975.js";import"./PhWebhooksLogo.vue.73a957f5.js";import"./runnerData.38462a80.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[n]="f4aa37d3-9388-41e5-9744-a5244ba0b2ef",l._sentryDebugIdIdentifier="sentry-dbid-f4aa37d3-9388-41e5-9744-a5244ba0b2ef")}catch{}})();const Z={key:0,class:"loading"},$=x({__name:"Form",setup(l){const n=L(),c=V(),h=W({playerKey:R()}),E=C(),u=w(null),y=w(!1);N(n,()=>{n.name==="form"&&S()});const{loading:m,result:r,error:v,refetch:S}=O(async()=>{h.playerKey=R();const a=n.path.slice(1),e=await X(a);if(!e){c.push({name:"error",params:{status:"404"}});return}const o=n.query[T];if(!e.isInitial&&!o){y.value=!0;return}const s=new I({formRunnerData:e,logService:null,connectionManager:new B(e.id,"player",n.query),onRedirect:g,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:d=>u.value=d}),i=s.getState();return u.value=i.formState,{runnerData:e,controller:s}}),A=K(()=>{const a=!m,e=!!v,o=!r||u.value===null;return a&&(e||o)});M(()=>{var a,e,o,s,i;A.value&&c.push({name:"error",params:{status:"500"}}),!!((a=r.value)!=null&&a.runnerData)&&(e=r.value)!=null&&e.runnerData&&(document.title=(i=(o=r.value)==null?void 0:o.runnerData.welcomeTitle)!=null?i:(s=r.value)==null?void 0:s.runnerData.title)});function g(a,e){F("player",c,a,e)}q(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",b)}),G(()=>{window.removeEventListener("beforeunload",b)});const b=a=>{var e;if((e=r.value)!=null&&e.controller.handleCloseAttempt())return a.preventDefault(),""};return(a,e)=>{var o,s,i,d;return t(m)?(f(),P("div",Z,[p(Q)])):y.value?(f(),k(t(H),{key:1,class:"unset-thread-container",vertical:""},{default:_(()=>[p(t(j),null,{default:_(()=>[D("Cannot open this link directly")]),_:1}),p(t(z),{class:"message"},{default:_(()=>[D(" This form must be accessed within a thread, either by clicking on it by notification email or the Kanban board ")]),_:1})]),_:1})):t(r)&&t(r).runnerData&&u.value&&!t(v)&&!t(m)?(f(),k(U,{key:h.playerKey,"form-runner-data":t(r).runnerData,"form-state":u.value,"is-preview":!1,"user-email":(o=t(E).user)==null?void 0:o.claims.email,onRedirect:g,onActionClicked:(s=t(r))==null?void 0:s.controller.handleActionClick,onUpdateWidgetErrors:(i=t(r))==null?void 0:i.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(d=t(r))==null?void 0:d.controller.updateWidgetValue},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue"])):Y("",!0)}}});const ke=J($,[["__scopeId","data-v-038b8619"]]);export{ke as default};
//# sourceMappingURL=Form.128b4441.js.map
