import{u as U}from"./router.c3a5f38b.js";import{b as F,r as I,c as A,d as x}from"./FormRunner.bf9d149f.js";import{A as T}from"./api.73862ceb.js";import{d as V,eu as W,eH as L,D as N,e as w,g as B,f as K,aC as M,V as q,a7 as G,u as t,W as H,b as p,c as D,w as y,R as P,o as _,ax as R,cY as Y,cU as $,d0 as j,$ as z}from"./vue-router.5e8ba7eb.js";import{a as J}from"./asyncComputed.bb3077bb.js";import{u as k}from"./uuid.c1fabc37.js";import{L as O}from"./CircularLoading.205967c8.js";import{f as Q}from"./api.3d221a29.js";import"./url.4683fc99.js";import"./Login.vue_vue_type_script_setup_true_lang.8314aa3a.js";import"./index.c5acb39e.js";import"./WidgetsFrame.c29eea1f.js";import"./Steps.a12436b8.js";import"./Watermark.22de2c07.js";import"./Card.c692bb57.js";import"./TabPane.8e50b74a.js";import"./fetch.7b08925d.js";import"./metadata.0a8ceea8.js";import"./PhBug.vue.1aaf96e1.js";import"./PhCheckCircle.vue.0084ae07.js";import"./PhKanban.vue.f8ef7c80.js";import"./PhWebhooksLogo.vue.aa4763f4.js";import"./runnerData.49bf6701.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[o]="25bde904-4ff7-4533-a76f-437873c5ed6b",l._sentryDebugIdIdentifier="sentry-dbid-25bde904-4ff7-4533-a76f-437873c5ed6b")}catch{}})();const X={key:0,class:"loading"},Z=V({__name:"Form",setup(l){const o=W(),c=L(),h=N({playerKey:k()}),E=U(),u=w(null),v=w(!1);B(o,()=>{o.name==="form"&&C()});const{loading:m,result:r,error:g,refetch:C}=J(async()=>{h.playerKey=k();const a=o.path.slice(1),e=await Q(a);if(!e){c.push({name:"error",params:{status:"404"}});return}const n=o.query[T];if(!e.isInitial&&!n){v.value=!0;return}const s=new A({formRunnerData:e,logService:null,connectionManager:new x(e.id,"player",o.query),onRedirect:b,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:d=>u.value=d}),i=s.getState();return u.value=i.formState,{runnerData:e,controller:s}}),S=K(()=>{const a=!m,e=!!g,n=!r||u.value===null;return a&&(e||n)});M(()=>{var a,e,n,s,i;S.value&&c.push({name:"error",params:{status:"500"}}),!!((a=r.value)!=null&&a.runnerData)&&(e=r.value)!=null&&e.runnerData&&(document.title=(i=(n=r.value)==null?void 0:n.runnerData.welcomeTitle)!=null?i:(s=r.value)==null?void 0:s.runnerData.title)});function b(a,e){window.removeEventListener("beforeunload",f),I("player",c,a,e)}q(async()=>{window.addEventListener("beforeunload",f)}),G(()=>{window.removeEventListener("beforeunload",f)});const f=a=>{var e;if((e=r.value)!=null&&e.controller.handleCloseAttempt())return a.preventDefault(),""};return(a,e)=>{var n,s,i,d;return t(m)?(_(),H("div",X,[p(O)])):v.value?(_(),D(t(j),{key:1,class:"unset-thread-container",vertical:""},{default:y(()=>[p(t(Y),null,{default:y(()=>[R("Cannot open this link directly")]),_:1}),p(t($),{class:"message"},{default:y(()=>[R(" 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(g)&&!t(m)?(_(),D(F,{key:h.playerKey,"form-runner-data":t(r).runnerData,"form-state":u.value,"is-preview":!1,"user-email":(n=t(E).user)==null?void 0:n.claims.email,onRedirect:b,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"])):P("",!0)}}});const Re=z(Z,[["__scopeId","data-v-d667e7b2"]]);export{Re as default};
//# sourceMappingURL=Form.95d3d5da.js.map
