import{u as S}from"./router.c2ded2b1.js";import{b as F,r as I,c as U,d as T}from"./FormRunner.58e918bd.js";import{A as x}from"./api.fb2155e2.js";import{d as L,eA as V,eM as B,D as N,e as b,g as W,f as K,aw as M,Z as q,a0 as G,u as t,o as f,et as P,b as p,c as k,w as _,ev as Z,ar as D,cR as j,cN as z,cV as H,R as J}from"./vue-router.637ad36e.js";import{a as O}from"./asyncComputed.0b7f3eaf.js";import{u as R}from"./uuid.9a0cf3c3.js";import{L as Q}from"./CircularLoading.91222c8d.js";import{f as X}from"./api.2921acd7.js";import"./url.c1cbace3.js";import"./Login.vue_vue_type_script_setup_true_lang.8f4cdf47.js";import"./index.13a24099.js";import"./WidgetsFrame.bae57e91.js";import"./Steps.99f89893.js";import"./Watermark.f63fb27f.js";import"./Card.6af2f5b2.js";import"./TabPane.db2c1289.js";import"./fetch.a7f25938.js";import"./metadata.9cd5a8e3.js";import"./PhCheckCircle.vue.92a8a97d.js";import"./PhKanban.vue.0ae2296c.js";import"./PhWebhooksLogo.vue.3f87c53c.js";import"./runnerData.8e7195b2.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]="09c4859a-3cd8-4367-b12a-3965162e98dc",l._sentryDebugIdIdentifier="sentry-dbid-09c4859a-3cd8-4367-b12a-3965162e98dc")}catch{}})();const Y={key:0,class:"loading"},$=L({__name:"Form",setup(l){const n=V(),c=B(),h=N({playerKey:R()}),A=S(),u=b(null),y=b(!1);W(n,()=>{n.name==="form"&&E()});const{loading:m,result:r,error:v,refetch:E}=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[x];if(!e.isInitial&&!o){y.value=!0;return}const s=new U({formRunnerData:e,logService:null,connectionManager:new T(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}}),C=K(()=>{const a=!m,e=!!v,o=!r||u.value===null;return a&&(e||o)});M(()=>{var a,e,o,s,i;C.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){I("player",c,a,e)}q(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",w)}),G(()=>{window.removeEventListener("beforeunload",w)});const w=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",Y,[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(F,{key:h.playerKey,"form-runner-data":t(r).runnerData,"form-state":u.value,"is-preview":!1,"user-email":(o=t(A).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"])):Z("",!0)}}});const ke=J($,[["__scopeId","data-v-038b8619"]]);export{ke as default};
//# sourceMappingURL=Form.b1c52054.js.map
