"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),m=require("overlayscrollbars"),I=()=>{if(typeof window>"u"){const r=()=>{};return[r,r]}let c,o;const l=window,s=typeof l.requestIdleCallback=="function",a=l.requestAnimationFrame,n=l.cancelAnimationFrame,f=s?l.requestIdleCallback:a,p=s?l.cancelIdleCallback:n,t=()=>{p(c),n(o)};return[(r,v)=>{t(),c=f(s?()=>{t(),o=a(r)}:r,typeof v=="object"?v:{timeout:2233})},t]},O=c=>{let o=null,l,s,a;const n=e.shallowRef(c||{}),[f,p]=I();return e.watch(()=>{var t;return e.unref((t=n.value)==null?void 0:t.defer)},t=>{a=t},{deep:!0,immediate:!0}),e.watch(()=>{var t;return e.unref((t=n.value)==null?void 0:t.options)},t=>{l=t,m.OverlayScrollbars.valid(o)&&o.options(l||{},!0)},{deep:!0,immediate:!0}),e.watch(()=>{var t;return e.unref((t=n.value)==null?void 0:t.events)},t=>{s=t,m.OverlayScrollbars.valid(o)&&o.on(s||{},!0)},{deep:!0,immediate:!0}),e.onUnmounted(()=>{p(),o==null||o.destroy()}),[t=>{if(m.OverlayScrollbars.valid(o))return o;const r=()=>o=m.OverlayScrollbars(t,l||{},s||{});a?f(r,a):r()},()=>o]},R=e.defineComponent({__name:"OverlayScrollbarsComponent",props:{element:{type:[String,Object],default:"div"},options:{type:Object},events:{type:Object},defer:{type:[Boolean,Object]}},emits:["osInitialized","osUpdated","osDestroyed","osScroll"],setup(c,{expose:o,emit:l}){const s=c,a={initialized:"osInitialized",updated:"osUpdated",destroyed:"osDestroyed",scroll:"osScroll"},{element:n,options:f,events:p,defer:t}=e.toRefs(s),r=e.shallowRef(null),v=e.shallowRef(null),S=e.ref(),[k,w]=O({options:f,events:S,defer:t});return o({osInstance:w,getElement:()=>r.value}),e.watchPostEffect(i=>{const{value:d}=r,{value:y}=v;d&&(k(n.value==="body"?{target:d,cancel:{body:null}}:{target:d,elements:{viewport:y,content:y}}),i(()=>{var u;return(u=w())==null?void 0:u.destroy()}))}),e.watch(()=>e.unref(p),i=>{const d=i||{};S.value=Object.keys(a).reduce((y,u)=>{const b=d[u];return y[u]=[(...h)=>l(a[u],...h),...(Array.isArray(b)?b:[b]).filter(Boolean)],y},{})},{deep:!0,immediate:!0}),(i,d)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(n)),{"data-overlayscrollbars-initialize":"",ref_key:"elementRef",ref:r},{default:e.withCtx(()=>[e.unref(n)==="body"?e.renderSlot(i.$slots,"default",{key:0}):(e.openBlock(),e.createElementBlock("div",{key:1,"data-overlayscrollbars-contents":"",ref_key:"slotRef",ref:v},[e.renderSlot(i.$slots,"default")],512))]),_:3},512))}});exports.OverlayScrollbarsComponent=R;exports.useOverlayScrollbars=O;
//# sourceMappingURL=overlayscrollbars-vue.cjs.js.map
