import{a as N,_ as A}from"./catalogForm-d2bd8906.js";import{l as m,L as S,R as c,cK as T,N as g,ab as y,v as W,ac as $,o as D,d as b,w as E,a as L,t as j,b as o,aj as F,E as P,A as l,q as n,O as x}from"./stepForm-ea4a5b69.js";import{c as H}from"./eventListForm-2ddac9f8.js";import O from"./eventCalendarForm-5dd298d7.js";const q={class:"am-sr-only"},I={name:"AmeliaDialogForms"},X=Object.assign(I,{setup(K){let e=m("shortcodeData"),k=S({sbsNew:c(T),cbf:c(N),elf:c(H),ecf:c(O)}),s=l(0);g("dialogWrapperWidth",s);let a=l(!1);g("formDialogVisibility",a);let f=n(()=>"isRestored"in e.value?e.value.isRestored:!1),v=e.value.trigger_type&&e.value.trigger_type==="class"?[...document.getElementsByClassName(e.value.trigger)]:[document.getElementById(e.value.trigger)],p=l(100),_=l(0);g("loadDialogCounter",_),v.forEach(u=>{u.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),a.value=!0,f.value||_.value++,setTimeout(()=>{window.dispatchEvent(new Event("resize"))},p.value)})}),y(()=>{f.value&&v.forEach(u=>{u.dispatchEvent(new Event("click"))})});function B(){a.value=!1}let d=l(0);function h(){d.value=window.visualViewport.height}window.addEventListener("resize",h);let z=m("isMounted");W(()=>{z.value=!0,$("renderPopup",{resizeAfter:p}),h()});const r=m("settings");let t=n(()=>r.customizedData&&e.value.triggered_form in r.customizedData?r.customizedData[e.value.triggered_form].colors:x[e.value.triggered_form].colors),C=n(()=>r.customizedData&&e.value.triggered_form in r.customizedData?r.customizedData[e.value.triggered_form]:x[e.value.triggered_form]),V=n(()=>({"--am-c-primary":t.value.colorPrimary,"--am-c-success":t.value.colorSuccess,"--am-c-error":t.value.colorError,"--am-c-warning":t.value.colorWarning,"--am-c-main-bgr":t.value.colorMainBgr,"--am-c-main-heading-text":t.value.colorMainHeadingText,"--am-c-main-text":t.value.colorMainText,"--am-dvh":d.value?`${d.value}px`:"100dvh"}));const R={sbsNew:"Appointment Booking",cbf:"Catalog Booking",elf:"Event Booking",ecf:"Event Calendar Booking"};let M=n(()=>R[e.value.triggered_form]||"Booking");return y(()=>{e.value.triggered_form==="sbsNew"&&(s.value=C.value.sidebar.options.self.visibility?"760px":"520px"),e.value.triggered_form==="cbf"&&(s.value="1140px"),e.value.triggered_form==="elf"&&(s.value="792px")},{flush:"post"}),(u,i)=>(D(),b(A,{modelValue:o(a),"onUpdate:modelValue":i[0]||(i[0]=w=>P(a)?a.value=w:a=w),"append-to-body":!0,"modal-class":`amelia-v2-booking am-forms-dialog am-${o(e).triggered_form}`,"close-on-click-modal":!1,"close-on-press-escape":!1,"custom-styles":o(V),"used-for-shortcode":!0,width:o(s),onClosed:B},{title:E(()=>[L("span",q,j(o(M)),1)]),default:E(()=>[(D(),b(F(o(k)[o(e).triggered_form])))]),_:1},8,["modelValue","modal-class","custom-styles","width"]))}});export{X as default};
