import{R as v,a as h,b as m}from"./constants-Cx335y3L-Cz4s3oUD.js";import{an as d,R as l}from"./index-D02r7Zsc.js";function g(e,o){return(o.ctx===e.instance.$?w(o,e.instance.$)?.provides:o.ctx?.provides)??e.instance.$.provides}function w(e,o){const i=new Set,s=n=>{for(const r of n){if(!r)continue;if(r===e||r.el&&e.el&&r.el===e.el)return!0;i.add(r);let t;if(r.suspense?t=s([r.ssContent]):Array.isArray(r.children)?t=s(r.children):r.component?.vnode&&(t=s([r.component?.subTree])),t)return t;i.delete(r)}return!1};if(!s([o.subTree]))return console.error("Could not find original vnode,  will not inherit provides"),o;const c=Array.from(i).reverse();for(const n of c)if(n.component)return n.component;return o}const p=(e,o)=>{const{modifiers:i,arg:s,value:c}=e,n=Object.keys(i||{}),r=typeof c=="string"?c.split(v):c;if(o.tagName.toLowerCase()==="a"){const t=o.getAttribute("href")||"";h.test(t)&&n.push(t.replace(m,""))}return Array.prototype.concat.apply([],[s,r]).forEach(t=>typeof t=="string"&&n.push(t)),n.filter((t,a,u)=>t&&u.indexOf(t)===a)},f=(e,o,i)=>{const s=p(o,e);if(s.length===0)return;const n=g(o,i)[d]?.values;if(e.dataset.bvtoggle){const r=(e.dataset.bvtoggle||"").split(" ");if(r.length===0)return;for(const t of r){const a=n?.value.get(t);a&&(s.includes(t)||l(a).unregisterTrigger("click",e,!1))}}e.dataset.bvtoggle=s.join(" "),s.forEach(async r=>{let t=0;for(;t<5&&e.dataset.bvtoggle;){const a=n?.value.get(r);if(!a){if(t++,await new Promise(u=>setTimeout(u,100)),t<4)continue;console.warn(`[v-b-toggle] Target with ID ${r} not found`);break}l(a).unregisterTrigger("click",e,!1),l(a).registerTrigger("click",e);break}}),e.setAttribute("aria-controls",s.join(" "))},b=(e,o,i)=>{const s=p(o,e);if(s.length===0)return;const n=g(o,i)[d]?.values;s.forEach(r=>{const t=n?.value.get(r);t&&l(t).unregisterTrigger("click",e,!1)}),e.removeAttribute("aria-controls"),e.removeAttribute("aria-expanded"),e.classList.remove("collapsed"),e.classList.remove("not-collapsed"),delete e.dataset.bvtoggle},A={mounted:f,updated:f,unmounted:b};export{A as v};
