"use strict";const e=require("@tempots/dom"),h=require("./input-container-B31Seozh.cjs"),s=["button:not([disabled])",'[role="button"]:not([aria-disabled="true"])',"a[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function m(...a){return e.html.div(e.attr.class("bc-toolbar"),e.attr.role("toolbar"),e.aria.orientation("horizontal"),e.WithElement(n=>{const f=()=>{const r=Array.from(n.querySelectorAll(s));r.length!==0&&r.forEach((t,o)=>t.setAttribute("tabindex",o===0?"0":"-1"))},u=r=>{const t=Array.from(n.querySelectorAll(s));if(t.length===0)return;const o=t.findIndex(c=>c===document.activeElement);let i=(o===-1?0:o)+r;i<0&&(i=t.length-1),i>=t.length&&(i=0),t.forEach(c=>c.setAttribute("tabindex","-1"));const d=t[i];d.setAttribute("tabindex","0"),d.focus()};setTimeout(f,0);const b=r=>{switch(r.key){case"ArrowRight":r.preventDefault(),u(1);break;case"ArrowLeft":r.preventDefault(),u(-1);break;case"Home":r.preventDefault(),u(-1);{const t=Array.from(n.querySelectorAll(s));if(t.length){t.forEach(l=>l.setAttribute("tabindex","-1"));const o=t[0];o.setAttribute("tabindex","0"),o.focus()}}break;case"End":r.preventDefault();{const t=Array.from(n.querySelectorAll(s));if(t.length){t.forEach(l=>l.setAttribute("tabindex","-1"));const o=t[t.length-1];o.setAttribute("tabindex","0"),o.focus()}}break}};return n.addEventListener("keydown",b),e.OnDispose(()=>{n.removeEventListener("keydown",b)})}),...a)}function v(a,...n){return h.Button({color:"neutral",roundedness:"md",variant:"light",...a},e.attr.class("bc-toolbar__button"),...n)}function A(...a){return e.html.div(e.attr.class("bc-toolbar__group"),e.attr.role("group"),...a)}function p(){return e.html.div(e.attr.class("bc-toolbar__divider"),e.attr.role("separator"),e.aria.orientation("vertical"))}function x(){return e.html.div(e.attr.class("bc-toolbar__spacer"))}exports.Toolbar=m;exports.ToolbarButton=v;exports.ToolbarDivider=p;exports.ToolbarGroup=A;exports.ToolbarSpacer=x;
