import{u as C}from"./index.5b8dff4d.js";import{d as F,f1 as I,f7 as S,N as T,r as p,O as x,y as L,ar as V,o as W,R as B,u as a,b as _,eV as N,f as h,c as D,w as v,eX as K,am as R,cW as M,cS as q,cY as G,E as O}from"./outputWidgets.049ac64d.js";import{b as P,r as X,c as Y,d as j}from"./FormRunner.53b27dc5.js";import{A as z}from"./api.491f7a89.js";import{a as H}from"./asyncComputed.ea730548.js";import{u as E}from"./uuid.52af8294.js";import{L as J}from"./CircularLoading.8dcc9668.js";import{f as Q}from"./api.9106a1be.js";import"./fetch.869cbc1f.js";import"./pubsub.0c3367ed.js";import"./url.bfc1d6a1.js";import"./Login.vue_vue_type_script_setup_true_lang.545ba93c.js";import"./index.c1842d07.js";import"./PhArrowClockwise.vue.fd29a69e.js";import"./WidgetsFrame.c05aa68e.js";import"./Steps.52000ab5.js";import"./Watermark.13acfc81.js";import"./Card.6629bb68.js";import"./TabPane.223e6cb6.js";import"./hasIn.8c8d3925.js";import"./metadata.68579fd9.js";import"./PhCheckCircle.vue.7af99e00.js";import"./PhKanban.vue.b5adf1c2.js";import"./PhScroll.vue.6c7ddf10.js";import"./PhWebhooksLogo.vue.d32b627f.js";import"./runnerData.ea577873.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[n]="1caf4dff-2846-41bb-bfee-3bd560b20941",u._sentryDebugIdIdentifier="sentry-dbid-1caf4dff-2846-41bb-bfee-3bd560b20941")}catch{}})();const Z={key:0,class:"loading"},$=F({__name:"Form",setup(u){const n=I(),d=S(),y=T({playerKey:E()}),c=p(null),m=p(null),b=p(!1);x(n,()=>{n.name==="form"&&A()});const{loading:f,result:t,error:g,refetch:A}=H(async()=>{y.playerKey=E();const r=n.path.slice(1),e=await Q(r);if(!e){d.push({name:"error",params:{status:"404"}});return}const o=n.query[z];if(!e.isInitial&&!o){b.value=!0;return}const s=new Y({formRunnerData:e,userManager:C,logService:null,connectionManager:new j(e.id,"player",n.query),onRedirect:w,onFormStart:()=>{},onFormEnd:()=>{},onAuthUpdate:l=>m.value=l,onStackTraceUpdate:null,onStateUpdate:l=>c.value=l}),i=s.getState();return m.value=i.passwordlessUser,c.value=i.formState,{runnerData:e,controller:s}}),U=L(()=>{const r=!f,e=!!g,o=!t||c.value===null;return r&&(e||o)});V(()=>{var r,e,o,s,i;U.value&&d.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(i=(o=t.value)==null?void 0:o.runnerData.welcomeTitle)!=null?i:(s=t.value)==null?void 0:s.runnerData.title)});function w(r,e){X("player",d,r,e)}W(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",k)}),B(()=>{window.removeEventListener("beforeunload",k)});const k=r=>{var e;if((e=t.value)!=null&&e.controller.handleCloseAttempt())return r.preventDefault(),""};return(r,e)=>{var o,s,i,l;return a(f)?(_(),N("div",Z,[h(J)])):b.value?(_(),D(a(G),{key:1,class:"unset-thread-container",vertical:""},{default:v(()=>[h(a(M),null,{default:v(()=>[R("Cannot open this link directly")]),_:1}),h(a(q),{class:"message"},{default:v(()=>[R(" This form must be accessed within a thread, either by clicking on it by notification email or the Kanban board ")]),_:1})]),_:1})):a(t)&&a(t).runnerData&&c.value&&!a(g)&&!a(f)?(_(),D(P,{key:y.playerKey,"form-runner-data":a(t).runnerData,"form-state":c.value,"is-preview":!1,"user-email":(o=m.value)==null?void 0:o.claims.email,onRedirect:w,onActionClicked:(s=a(t))==null?void 0:s.controller.handleActionClick,onUpdateWidgetErrors:(i=a(t))==null?void 0:i.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(l=a(t))==null?void 0:l.controller.updateWidgetValue},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue"])):K("",!0)}}});const Ae=O($,[["__scopeId","data-v-b8fb7325"]]);export{Ae as default};
//# sourceMappingURL=Form.1e1ae404.js.map
