import{A as S}from"./api.cb199801.js";import{b as I,j as U}from"./workspaceStore.5911dabd.js";import{b as A,r as T,c as x,d as W}from"./FormRunner.a6968870.js";import{d as L,ea as V,eo as K,D as N,e as w,g as B,f as M,aK as q,W as j,ag as G,u as t,o as f,X as P,b as y,c as D,w as _,R as X,aF as R,d9 as $,d5 as z,dd as H,$ as J}from"./vue-router.2dfeb709.js";import{a as O}from"./asyncComputed.d236b901.js";import{u as k}from"./uuid.45a970ea.js";import{L as Q}from"./CircularLoading.3e146cf0.js";import"./fetch.caf60c74.js";import"./metadata.55d408d1.js";import"./PhBug.vue.6ea7a039.js";import"./PhCheckCircle.vue.261dd653.js";import"./PhKanban.vue.5fe284b4.js";import"./PhWebhooksLogo.vue.ffe295f3.js";import"./url.052bc6c8.js";import"./colorHelpers.8745f3a5.js";import"./Login.vue_vue_type_script_setup_true_lang.119a4225.js";import"./Logo.dfb0fe50.js";import"./string.92e45c6b.js";import"./index.b2473d3c.js";import"./index.eb043852.js";import"./Steps.e19739b3.js";import"./index.cc12dd82.js";import"./Watermark.1b0cf7e7.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]="75eb8f5a-a90a-47b0-8fc4-09753848593b",l._sentryDebugIdIdentifier="sentry-dbid-75eb8f5a-a90a-47b0-8fc4-09753848593b")}catch{}})();const Y={key:0,class:"loading"},Z=L({__name:"Form",setup(l){const o=V(),c=K(),h=N({playerKey:k()}),E=I(),u=w(null),v=w(!1);B(o,()=>{o.name==="form"&&C()});const{loading:m,result:r,error:g,refetch:C}=O(async()=>{h.playerKey=k();const a=o.path.slice(1),e=await U(a);if(!e){c.push({name:"error",params:{status:"404"}});return}const n=o.query[S];if(!e.isInitial&&!n){v.value=!0;return}const s=new x({formRunnerData:e,logService:null,connectionManager:new W(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}}),F=M(()=>{const a=!m,e=!!g,n=!r||u.value===null;return a&&(e||n)});q(()=>{var a,e,n,s,i;F.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",p),T("player",c,a,e)}j(async()=>{window.addEventListener("beforeunload",p)}),G(()=>{window.removeEventListener("beforeunload",p)});const p=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)?(f(),P("div",Y,[y(Q)])):v.value?(f(),D(t(H),{key:1,class:"unset-thread-container",vertical:""},{default:_(()=>[y(t($),null,{default:_(()=>[R("Cannot open this link directly")]),_:1}),y(t(z),{class:"message"},{default:_(()=>[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)?(f(),D(A,{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"])):X("",!0)}}});const Re=J(Z,[["__scopeId","data-v-22706e2c"]]);export{Re as default};
//# sourceMappingURL=Form.3ea21832.js.map
