import { a as e, n as t } from './chunk-BneVvdWh.js';
import { S as n } from './iframe-B-AKBcwT.js';
import { t as r } from './jsx-runtime-Bn1Ys6_W.js';
import { t as i } from './compiler-runtime-C9X80vSn.js';
import { n as a, t as o } from './clsx-D6G9p0rQ.js';
var s,
    c,
    l,
    u,
    d,
    f,
    p,
    m,
    h,
    g,
    _,
    ee,
    v,
    te,
    ne = t(() => {
        ((s = i()),
            (c = e(n(), 1)),
            ({ useEffect: l, useState: u } = c),
            (d = () => {}),
            (f = { disconnect: d, observe: d, unobserve: d }),
            (p = Object.freeze({
                bottom: void 0,
                left: void 0,
                right: void 0,
                top: void 0,
            })),
            (m = Object.freeze({
                boundingClientRect: p,
                maybeCleanupElement: d,
                maybeCleanupTimer: null,
                renderTimeSetters: new Set(),
                retryCount: 0,
                scheduleUpdate: d,
                updateBoundingClientRect: d,
                updaterFrameID: null,
            })),
            (h = 60 * 1e3),
            (g = new WeakMap()),
            (_ = f),
            typeof ResizeObserver == `function` &&
                (_ = new ResizeObserver((e, t) => {
                    for (let n of e) {
                        let e = n.target,
                            r = g.get(e);
                        if (!r) {
                            t.unobserve(e);
                            return;
                        }
                        r.scheduleUpdate();
                    }
                })),
            (ee = (e) => {
                let t = g.get(e);
                t &&
                    ((t.scheduleUpdate != null && t.scheduleUpdate !== d) ||
                        ((t.updateBoundingClientRect = () => {
                            t.updaterFrameID = null;
                            let n = e.getBoundingClientRect();
                            if (!n.height && !n.width) {
                                t.retryCount < 10 &&
                                    (t.retryCount++,
                                    (t.updaterFrameID = requestAnimationFrame(
                                        t.updateBoundingClientRect,
                                    )));
                                return;
                            }
                            if (
                                ((t.retryCount &&= 0),
                                t.boundingClientRect.bottom === n.bottom &&
                                    t.boundingClientRect.left === n.left &&
                                    t.boundingClientRect.right === n.right &&
                                    t.boundingClientRect.top === n.top)
                            )
                                return;
                            t.boundingClientRect = {
                                bottom: n.bottom,
                                left: n.left,
                                right: n.right,
                                top: n.top,
                            };
                            let r = typeof Date.now == `function` ? Date.now() : 0;
                            for (let e of t.renderTimeSetters) e(r);
                        }),
                        (t.scheduleUpdate = () => {
                            t.updaterFrameID ??= requestAnimationFrame(
                                t.updateBoundingClientRect,
                            );
                        }),
                        (t.maybeCleanupElement = () => {
                            if (
                                (t.maybeCleanupTimer != null &&
                                    (clearTimeout(t.maybeCleanupTimer),
                                    (t.maybeCleanupTimer = null)),
                                t.renderTimeSetters.size && e.closest(`html`))
                            ) {
                                t.maybeCleanupTimer = setTimeout(
                                    t.maybeCleanupElement,
                                    h,
                                );
                                return;
                            }
                            (g.delete(e), _.unobserve(e));
                        }),
                        (t.maybeCleanupTimer = setTimeout(t.maybeCleanupElement, h))));
            }),
            (v = (e, t) => {
                let n = g.get(e);
                n && (n.renderTimeSetters.delete(t), n.maybeCleanupElement());
            }),
            (te = (e) => {
                let t = (0, s.c)(9),
                    [, n] = u(0),
                    r = !1,
                    i;
                t[0] === e
                    ? (i = t[1])
                    : ((i = (e && g.get(e)) ?? null), (t[0] = e), (t[1] = i));
                let a = i;
                (e &&
                    !a &&
                    ((r = !0),
                    t[2] === e
                        ? (a = t[3])
                        : ((a = { ...m, renderTimeSetters: new Set() }),
                          g.set(e, a),
                          (t[2] = e),
                          (t[3] = a)),
                    ee(e),
                    _.observe(e)),
                    a && (a.renderTimeSetters.add(n), r && a.updateBoundingClientRect()));
                let o;
                t[4] !== e || t[5] !== n
                    ? ((o = () =>
                          e
                              ? () => {
                                    v(e, n);
                                }
                              : d),
                      (t[4] = e),
                      (t[5] = n),
                      (t[6] = o))
                    : (o = t[6]);
                let c;
                return (
                    t[7] === e ? (c = t[8]) : ((c = [e]), (t[7] = e), (t[8] = c)),
                    l(o, c),
                    a?.boundingClientRect ?? p
                );
            }));
    });
function y({ eventType: e, handler: t, ignoreUsedKeyboardEvents: n = !0, priority: r }) {
    if (!t) return O;
    let i = Math.min(E + D, Math.max(0, (r ?? 0) + D)),
        a = w[e];
    return (
        (a[i] ??= new Set()),
        a[i].add(t),
        w.config.set(t, { ignoreUsedKeyboardEvents: n, priority: i }),
        () => {
            if ((w.config.delete(t), a[i] != null && (a[i].delete(t), !a[i].size))) {
                delete a[i];
                for (let e = i; e > -1 && a[e] == null && a.length === e + 1; e--)
                    a.length = e;
            }
        }
    );
}
function b(e) {
    if (!(!e?.defaultView || e.defaultView.__useKeyboardEventsAttached__))
        return (
            (e.defaultView.__useKeyboardEventsAttached__ = !0),
            e.addEventListener(`keydown`, x),
            e.addEventListener(`keypress`, x),
            e.addEventListener(`keyup`, x),
            () => {
                (e.defaultView && (e.defaultView.__useKeyboardEventsAttached__ = !1),
                    e.removeEventListener(`keydown`, x),
                    e.removeEventListener(`keypress`, x),
                    e.removeEventListener(`keyup`, x));
            }
        );
}
function x(e) {
    let t = w[e.type],
        n = t.length,
        r = se(e);
    for (; n--; ) {
        let i = t[n];
        if (i != null)
            for (let t of i) {
                let n = w.config.get(t);
                if ((!r || n?.ignoreUsedKeyboardEvents === !1) && t(e) === !1) return;
            }
    }
}
function re(e) {
    let t = (0, S.c)(16),
        {
            ignoreUsedKeyboardEvents: n,
            onKeyDown: r,
            onKeyPress: i,
            onKeyUp: a,
            priority: o,
        } = e,
        s;
    (t[0] === Symbol.for(`react.memo_cache_sentinel`)
        ? ((s = []), (t[0] = s))
        : (s = t[0]),
        (0, C.useEffect)(ie, s));
    let c, l;
    (t[1] !== n || t[2] !== r || t[3] !== o
        ? ((c = () =>
              y({
                  eventType: `keydown`,
                  handler: r,
                  ignoreUsedKeyboardEvents: n,
                  priority: o,
              })),
          (l = [n, r, o]),
          (t[1] = n),
          (t[2] = r),
          (t[3] = o),
          (t[4] = c),
          (t[5] = l))
        : ((c = t[4]), (l = t[5])),
        (0, C.useEffect)(c, l));
    let u, d;
    (t[6] !== n || t[7] !== i || t[8] !== o
        ? ((u = () =>
              y({
                  eventType: `keypress`,
                  handler: i,
                  ignoreUsedKeyboardEvents: n,
                  priority: o,
              })),
          (d = [n, i, o]),
          (t[6] = n),
          (t[7] = i),
          (t[8] = o),
          (t[9] = u),
          (t[10] = d))
        : ((u = t[9]), (d = t[10])),
        (0, C.useEffect)(u, d));
    let f, p;
    (t[11] !== n || t[12] !== a || t[13] !== o
        ? ((f = () =>
              y({
                  eventType: `keyup`,
                  handler: a,
                  ignoreUsedKeyboardEvents: n,
                  priority: o,
              })),
          (p = [n, a, o]),
          (t[11] = n),
          (t[12] = a),
          (t[13] = o),
          (t[14] = f),
          (t[15] = p))
        : ((f = t[14]), (p = t[15])),
        (0, C.useEffect)(f, p));
}
function ie() {
    (b(document), document.querySelectorAll(`iframe`).forEach(ae));
}
function ae(e) {
    !oe(e) || !e.contentDocument || b(e.contentDocument);
}
function oe(e) {
    try {
        return typeof e.contentWindow.location.href == `string`;
    } catch {
        return !1;
    }
}
var S,
    C,
    w,
    T,
    E,
    D,
    O,
    k,
    A,
    j,
    se,
    M = t(() => {
        ((S = i()),
            (C = e(n(), 1)),
            (w = { config: new Map(), keydown: [], keypress: [], keyup: [] }),
            (T = -50),
            (E = 50),
            (D = T * -1),
            (O = () => {}),
            (k = new Set([
                `button`,
                `checkbox`,
                `color`,
                `file`,
                `hidden`,
                `image`,
                `radio`,
                `range`,
                `reset`,
                `submit`,
            ])),
            (A = new Set([
                ` `,
                `ArrowDown`,
                `ArrowLeft`,
                `ArrowRight`,
                `ArrowUp`,
                `Enter`,
            ])),
            (j = (e) =>
                e.isContentEditable || e.tagName === `TEXTAREA` || e.tagName === `INPUT`),
            (se = (e) => {
                let t = e.target;
                return t == null || !j(t)
                    ? !1
                    : t.tagName !== `INPUT` || !k.has(t.type)
                      ? !0
                      : A.has(e.key);
            }));
    }),
    ce,
    N = t(() => {
        ce = `:root{--uktdd-font-family:system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, Helvetica, Arial, sans-serif;--uktdd-body-bg-color:#fff;--uktdd-body-bg-color-hover:#69a2f9;--uktdd-body-color-hover:#fff;--uktdd-body-buffer:10px;--uktdd-body-max-height:calc(100vh - var(--uktdd-body-buffer));--uktdd-body-max-width:calc(100vw - var(--uktdd-body-buffer));--uktdd-body-min-height:50px;--uktdd-body-pad-bottom:9px;--uktdd-body-pad-left:12px;--uktdd-body-pad-right:12px;--uktdd-body-pad-top:9px;--uktdd-body-min-width:min(50px, 100%);--uktdd-label-pad-right:10px}.uktdropdown,.uktdropdown-trigger{font-family:var(--uktdd-font-family)}.uktdropdown{anchor-scope:--uktdd-anchor;width:max-content}.uktdropdown.disabled{pointer-events:none}.uktdropdown>*{cursor:default}.uktdropdown>:first-child{anchor-name:--uktdd-anchor}.uktdropdown-label{align-items:center;display:flex}.uktdropdown-label-text{padding-right:var(--uktdd-label-pad-right)}.uktdropdown-body{box-sizing:border-box;position-anchor:--uktdd-anchor;top:anchor(bottom);left:anchor(left);position-try-fallbacks:--uktdd-top-left, --uktdd-bottom-right, --uktdd-top-right;min-height:min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));max-height:var(--uktdd-body-max-height);min-width:var(--uktdd-body-min-width);max-width:var(--uktdd-body-max-width);z-index:2;padding:var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);background-color:var(--uktdd-body-bg-color);position:absolute;bottom:auto;right:auto;overflow:auto;box-shadow:0 8px 18px #00000040}.uktdropdown-body.has-items{-webkit-user-select:none;user-select:none}.uktdropdown-body [data-ukt-active]{background-color:var(--uktdd-body-bg-color-hover);color:var(--uktdd-body-color-hover)}@position-try --uktdd-top-left{bottom: anchor(top); left: anchor(left); top: auto; right: auto;}@position-try --uktdd-bottom-right{top: anchor(bottom); right: anchor(right); bottom: auto; left: auto;}@position-try --uktdd-top-right{bottom: anchor(top); right: anchor(right); top: auto; left: auto;}`;
    }),
    P,
    le,
    F,
    ue,
    I,
    L,
    R,
    de,
    z,
    B,
    fe = t(() => {
        ((P = 48),
            (le = 57),
            (F = 65),
            (ue = 15),
            (I = 0.99999),
            (L = 0.999999),
            (R = 0.81),
            (de = (e, t, n) => {
                if (
                    (n || ((e = e.trim().toUpperCase()), (t = t.trim().toUpperCase())),
                    e === t)
                )
                    return 1;
                let r = e.length,
                    i = t.length,
                    a = Math.min(r, i);
                if (!a) return 0;
                let [o, s] = r > i ? [e, t] : [t, e],
                    c = o.indexOf(s);
                if (c > -1) {
                    let e = (0.15 / (o.length - 2)) * c;
                    return Math.max(L - e, R);
                }
                let l = Math.min(0.4, 3 / a),
                    u = 0,
                    d = 0,
                    f = 0;
                for (let n = 0; n < a; n++) {
                    let r = e.charCodeAt(n),
                        i = t.charCodeAt(n),
                        a = Math.abs(r - i);
                    (r >= P && r <= le && i > F && (a = le + 1 - r),
                        (u += Math.min(ue, a)),
                        (d += ue),
                        a === 0 &&
                            (u === f ? ((f += -10 * ((n + 1) * l)), (u = f)) : --u));
                }
                return u <= 0 ? I : ((u = (d - u) / d), Math.min(I, u));
            }),
            (z = ({ excludeMismatches: e, items: t, text: n }) => {
                if (((n = n.trim().toUpperCase()), !n || !t.length)) return t;
                let [r] = t.reduce(
                    ([t, r], i) => {
                        let a = de(i.trim().toUpperCase(), n, !0);
                        if (e && a < R) return [t, r];
                        let o = t.length;
                        if (a > r[0]) o = 0;
                        else if (a > r[r.length - 1]) {
                            let e = r.findIndex((e) => e < a);
                            e !== -1 && (o = e);
                        }
                        return (t.splice(o, 0, i), r.splice(o, 0, a), [t, r]);
                    },
                    [[], []],
                );
                return r;
            }),
            (B = (e) => z(e)[0]));
    }),
    pe,
    me,
    he,
    V,
    H,
    ge = t(() => {
        (fe(),
            (pe = `[data-ukt-item], [data-ukt-value]`),
            (me = (e) => {
                if (!e) return null;
                let t = e.querySelector(`.uktdropdown-body`);
                if (!t) return null;
                let n = t.querySelectorAll(pe);
                if (n.length) return n;
                for (n = t.children; n.length === 1 && n[0].children != null; )
                    n = n[0].children;
                return (n.length === 1 && (n = t.children), n);
            }),
            (he = (e) => (e ? e.querySelector(`[data-ukt-active]`) : null)),
            (V = (e) => {
                e.forEach((e) => {
                    e.hasAttribute(`data-ukt-active`) && delete e.dataset.uktActive;
                });
            }),
            (H = ({
                dropdownElement: e,
                element: t,
                event: n,
                index: r,
                indexAddend: i,
                isExactMatch: a,
                onActiveItem: o,
                text: s,
            }) => {
                let c = me(e);
                if (!c) return;
                let l = Array.from(c);
                if (!l.length) return;
                let u = l.length - 1,
                    d = l.findIndex((e) => e.hasAttribute(`data-ukt-active`)),
                    f = d;
                if ((typeof r == `number` && (f = r < 0 ? l.length + r : r), t))
                    f = l.findIndex((e) => e === t);
                else if (typeof i == `number`)
                    (d === -1 && i === -1 ? (f = u) : (f += i),
                        (f = Math.max(0, Math.min(f, u))));
                else if (typeof s == `string`) {
                    if (!s) {
                        V(l);
                        return;
                    }
                    let e = l.map((e) => e.innerText);
                    if (a) {
                        let t = s.toLowerCase();
                        ((f = e.findIndex((e) => e.toLowerCase().startsWith(t))),
                            f === -1 && V(l));
                    } else {
                        let t = B({ items: e, text: s });
                        f = e.findIndex((e) => e === t);
                    }
                }
                let p = c[f];
                if (p == null || f === d) return;
                (V(l), p.setAttribute(`data-ukt-active`, ``));
                let m = p.innerText,
                    h = p.dataset.uktValue ?? m;
                o?.({ element: p, event: n, label: m, value: h });
                let { parentElement: g } = p,
                    _ = null;
                for (; !_ && g && g !== e; )
                    g.scrollHeight > g.clientHeight + 15
                        ? (_ = g)
                        : (g = g.parentElement);
                if (_) {
                    let e = _.getBoundingClientRect(),
                        t = p.getBoundingClientRect(),
                        n = t.top < e.top,
                        r = t.bottom > e.bottom;
                    if (n || r) {
                        let { scrollTop: r } = _;
                        (n ? (r -= e.top - t.top) : (r += t.bottom - e.bottom),
                            (_.scrollTop = r));
                    }
                }
            }));
    });
function U(e) {
    let t = (0, ve.c)(93),
        {
            allowCreate: n,
            allowEmpty: r,
            children: i,
            className: a,
            constrainHeightToAvoidClipping: s,
            disabled: c,
            hasItems: l,
            isOpenOnMount: u,
            isSearchable: d,
            keepOpenOnSubmit: f,
            label: p,
            minHeightBody: m,
            minWidthBody: h,
            name: g,
            onActiveItem: _,
            onClick: ee,
            onClose: v,
            onMouseDown: ne,
            onMouseUp: y,
            onOpen: b,
            onSubmitItem: x,
            placeholder: ie,
            style: ae,
            tabIndex: oe,
            value: S,
        } = e,
        C = r === void 0 ? !0 : r,
        w = s === void 0 ? !1 : s,
        T = l === void 0 ? !0 : l,
        E = f === void 0 ? !T : f,
        D = m === void 0 ? 50 : m,
        O = W.Children.count(i);
    if (O !== 1 && O !== 2) {
        if (O === 0) throw Error(ye + ` Received no children.`);
        console.error(`${ye} Received ${O} children.`);
    }
    let k;
    O > 1 && (k = i[0]);
    let [A, j] = (0, W.useState)(u ?? !1),
        [M, N] = (0, W.useState)(!u),
        [P, le] = (0, W.useState)(null),
        [F, ue] = (0, W.useState)(null),
        I = (0, W.useRef)(null),
        L = (0, W.useRef)(null),
        R = (0, W.useRef)(null),
        de = (0, W.useRef)(`mouse`),
        z = (0, W.useRef)(null),
        B = (0, W.useRef)(``),
        fe = (0, W.useRef)(null),
        V = (0, W.useRef)(n),
        ge = (0, W.useRef)(C),
        U = (0, W.useRef)(T),
        K = (0, W.useRef)(A),
        Se = (0, W.useRef)(M),
        Ce = (0, W.useRef)(E),
        we = (0, W.useRef)(v),
        Te = (0, W.useRef)(b),
        Ee = (0, W.useRef)(x),
        De = (0, W.useRef)(S),
        Oe,
        ke;
    (t[0] !== n ||
    t[1] !== C ||
    t[2] !== T ||
    t[3] !== A ||
    t[4] !== M ||
    t[5] !== E ||
    t[6] !== v ||
    t[7] !== b ||
    t[8] !== x ||
    t[9] !== S
        ? ((Oe = () => {
              ((V.current = n),
                  (ge.current = C),
                  (U.current = T),
                  (K.current = A),
                  (Se.current = M),
                  (Ce.current = E),
                  (we.current = v),
                  (Te.current = b),
                  (Ee.current = x),
                  (De.current = S));
          }),
          (ke = [n, C, T, A, M, E, v, b, x, S]),
          (t[0] = n),
          (t[1] = C),
          (t[2] = T),
          (t[3] = A),
          (t[4] = M),
          (t[5] = E),
          (t[6] = v),
          (t[7] = b),
          (t[8] = x),
          (t[9] = S),
          (t[10] = Oe),
          (t[11] = ke))
        : ((Oe = t[10]), (ke = t[11])),
        (0, W.useEffect)(Oe, ke));
    let Ae = (0, W.useRef)(!1),
        je,
        Me;
    (t[12] === A
        ? ((je = t[13]), (Me = t[14]))
        : ((je = () => {
              if (!Ae.current) {
                  ((Ae.current = !0), K.current && Te.current && Te.current());
                  return;
              }
              A && Te.current ? Te.current() : !A && we.current && we.current();
          }),
          (Me = [A]),
          (t[12] = A),
          (t[13] = je),
          (t[14] = Me)),
        (0, W.useEffect)(je, Me));
    let Ne;
    t[15] === Symbol.for(`react.memo_cache_sentinel`)
        ? ((Ne = () => {
              (j(!1),
                  N(!1),
                  (fe.current = null),
                  L.current != null && (clearTimeout(L.current), (L.current = null)));
          }),
          (t[15] = Ne))
        : (Ne = t[15]);
    let q = Ne,
        Pe;
    t[16] === P
        ? (Pe = t[17])
        : ((Pe = (e) => {
              if (
                  (K.current && !Ce.current && (L.current = setTimeout(q, 90)),
                  !U.current)
              )
                  return;
              let t = he(P);
              if (!t && !V.current && (!ge.current || I.current?.value)) return;
              let n = t?.innerText ?? ``;
              I.current &&
                  (t ? (I.current.value = n) : (n = I.current.value),
                  I.current === I.current.ownerDocument.activeElement &&
                      I.current.blur());
              let r = t?.dataset.uktValue ?? n;
              if (!(De.current && De.current === r)) {
                  if (t) {
                      let n = e.target;
                      if (t.matches(be)) t !== n && !t.contains(n) && t.click();
                      else {
                          let e = t.querySelectorAll(be);
                          if (e.length === 1) {
                              let t = e[0];
                              t !== n && !t.contains(n) && t.click();
                          }
                      }
                  }
                  Ee.current?.({ element: t, event: e, label: n, value: r });
              }
          }),
          (t[16] = P),
          (t[17] = Pe));
    let J = Pe,
        Fe;
    t[18] === Symbol.for(`react.memo_cache_sentinel`)
        ? ((Fe = (e) => {
              let { clientX: t, clientY: n } = e;
              de.current = `mouse`;
              let r = fe.current;
              r &&
                  ((Math.abs(r.clientX - t) < 12 && Math.abs(r.clientY - n) < 12) ||
                      N(!1));
          }),
          (t[18] = Fe))
        : (Fe = t[18]);
    let Ie = Fe,
        Le;
    t[19] !== P || t[20] !== _
        ? ((Le = (e) => {
              if (!U.current || de.current !== `mouse` || !P) return;
              let t = me(P);
              if (!t) return;
              let n = e.target,
                  r = n.closest(pe) ?? n;
              for (let n of t)
                  if (n === r) {
                      H({ dropdownElement: P, element: r, event: e, onActiveItem: _ });
                      return;
                  }
          }),
          (t[19] = P),
          (t[20] = _),
          (t[21] = Le))
        : (Le = t[21]);
    let Re = Le,
        ze;
    t[22] === P
        ? (ze = t[23])
        : ((ze = (e) => {
              if (!U.current) return;
              let t = he(P);
              if (!t) return;
              let n = e.relatedTarget;
              t !== e.target || t.contains(n) || delete t.dataset.uktActive;
          }),
          (t[22] = P),
          (t[23] = ze));
    let Be = ze,
        Ve;
    t[24] === ne
        ? (Ve = t[25])
        : ((Ve = (e) => {
              (ne && ne(e),
                  !K.current &&
                      (j(!0),
                      N(!0),
                      (fe.current = { clientX: e.clientX, clientY: e.clientY }),
                      (R.current = setTimeout(() => {
                          (N(!1), (R.current = null));
                      }, 1e3))));
          }),
          (t[24] = ne),
          (t[25] = Ve));
    let He = Ve,
        Ue;
    t[26] !== J || t[27] !== y
        ? ((Ue = (e) => {
              if ((y && y(e), Se.current || !K.current || L.current != null)) return;
              let t = e.target;
              if (!t.closest(`.uktdropdown-body`)) {
                  !Se.current && I.current !== t.ownerDocument.activeElement && q();
                  return;
              }
              U.current && J(e);
          }),
          (t[26] = J),
          (t[27] = y),
          (t[28] = Ue))
        : (Ue = t[28]);
    let We = Ue,
        Ge;
    t[29] !== P || t[30] !== J || t[31] !== _
        ? ((Ge = (e) => {
              let { altKey: t, ctrlKey: n, key: r, metaKey: i } = e,
                  a = e.target;
              if (!P) return;
              let o = () => {
                      (e.stopPropagation(),
                          e.preventDefault(),
                          (de.current = `keyboard`));
                  },
                  s = P.contains(a);
              if (!K.current) {
                  if (!s) return;
                  (r === ` ` ||
                      r === `Enter` ||
                      (U.current && (r === `ArrowUp` || r === `ArrowDown`))) &&
                      (o(), j(!0));
                  return;
              }
              let c = se(e);
              if (U.current && !c) {
                  let t = !n && !i && /^[A-Za-z0-9]$/.test(r);
                  if ((!t && B.current && (t = r === ` ` || r === `Backspace`), t)) {
                      (o(),
                          r === `Backspace`
                              ? (B.current = B.current.slice(0, -1))
                              : (B.current += r),
                          H({
                              dropdownElement: P,
                              event: e,
                              isExactMatch: V.current,
                              onActiveItem: _,
                              text: B.current,
                          }),
                          z.current != null && clearTimeout(z.current),
                          (z.current = setTimeout(() => {
                              ((B.current = ``), (z.current = null));
                          }, 1500)));
                      return;
                  }
              }
              if (r === `Enter` || (r === ` ` && !I.current)) {
                  (o(), J(e));
                  return;
              }
              if (r === `Escape` || (s && r === ` ` && !U.current)) {
                  (U.current || !c) && q();
                  return;
              }
              if (U.current) {
                  if (r === `ArrowUp`) {
                      (o(),
                          H(
                              t || i
                                  ? {
                                        dropdownElement: P,
                                        event: e,
                                        index: 0,
                                        onActiveItem: _,
                                    }
                                  : {
                                        dropdownElement: P,
                                        event: e,
                                        indexAddend: -1,
                                        onActiveItem: _,
                                    },
                          ));
                      return;
                  }
                  if (r === `ArrowDown`) {
                      (o(),
                          H(
                              t || i
                                  ? {
                                        dropdownElement: P,
                                        event: e,
                                        index: -1,
                                        onActiveItem: _,
                                    }
                                  : {
                                        dropdownElement: P,
                                        event: e,
                                        indexAddend: 1,
                                        onActiveItem: _,
                                    },
                          ));
                      return;
                  }
              }
          }),
          (t[29] = P),
          (t[30] = J),
          (t[31] = _),
          (t[32] = Ge))
        : (Ge = t[32]);
    let Ke = Ge,
        qe;
    (t[33] === Ke
        ? (qe = t[34])
        : ((qe = { ignoreUsedKeyboardEvents: !1, onKeyDown: Ke }),
          (t[33] = Ke),
          (t[34] = qe)),
        re(qe));
    let Je;
    t[35] !== u || t[36] !== _
        ? ((Je = (e) => {
              if ((le(e), !e)) return;
              let { ownerDocument: t } = e,
                  n = I.current;
              !n &&
                  e.firstElementChild &&
                  ((n = e.firstElementChild.matches(xe)
                      ? e.firstElementChild
                      : e.firstElementChild.querySelector(xe)),
                  (I.current = n));
              let r = (t) => {
                      let { target: n } = t,
                          r = n;
                      e.contains(r) || q();
                  },
                  i = (t) => {
                      let { target: n } = t;
                      if (!K.current || L.current != null) return;
                      if (Se.current) {
                          (N(!1),
                              R.current != null &&
                                  (clearTimeout(R.current), (R.current = null)));
                          return;
                      }
                      let r = n;
                      e.contains(r) || q();
                  },
                  a = (t) => {
                      let { target: n } = t;
                      if (!K.current) return;
                      let r = n;
                      e.contains(r) || r.contains(e) || q();
                  };
              (document.addEventListener(`focusin`, a),
                  document.addEventListener(`mousedown`, r),
                  document.addEventListener(`mouseup`, i),
                  t !== document &&
                      (t.addEventListener(`focusin`, a),
                      t.addEventListener(`mousedown`, r),
                      t.addEventListener(`mouseup`, i)),
                  u && e.focus());
              let o = (t) => {
                  K.current || j(!0);
                  let n = t.target,
                      r = B.current.length > n.value.length;
                  ((B.current = n.value),
                      !(r && n.value.length && he(e)) &&
                          H({
                              dropdownElement: e,
                              event: t,
                              isExactMatch: V.current,
                              onActiveItem: _,
                              text: B.current,
                          }));
              };
              return (
                  n && n.addEventListener(`input`, o),
                  () => {
                      (document.removeEventListener(`focusin`, a),
                          document.removeEventListener(`mousedown`, r),
                          document.removeEventListener(`mouseup`, i),
                          t !== document &&
                              (t.removeEventListener(`focusin`, a),
                              t.removeEventListener(`mousedown`, r),
                              t.removeEventListener(`mouseup`, i)),
                          n && n.removeEventListener(`input`, o));
                  }
              );
          }),
          (t[35] = u),
          (t[36] = _),
          (t[37] = Je))
        : (Je = t[37]);
    let Ye = Je;
    if (!(0, W.isValidElement)(k))
        if (d) {
            let e = S ?? ``,
                n;
            t[38] === Symbol.for(`react.memo_cache_sentinel`)
                ? ((n = () => j(!0)), (t[38] = n))
                : (n = t[38]);
            let r;
            (t[39] !== c || t[40] !== g || t[41] !== ie || t[42] !== e || t[43] !== oe
                ? ((r = (0, G.jsx)(`input`, {
                      autoComplete: `off`,
                      className: `uktdropdown-trigger`,
                      defaultValue: e,
                      disabled: c,
                      name: g,
                      onFocus: n,
                      placeholder: ie,
                      ref: I,
                      tabIndex: oe,
                      type: `text`,
                  })),
                  (t[39] = c),
                  (t[40] = g),
                  (t[41] = ie),
                  (t[42] = e),
                  (t[43] = oe),
                  (t[44] = r))
                : (r = t[44]),
                (k = r));
        } else {
            let e;
            (t[45] === k
                ? (e = t[46])
                : ((e = (0, G.jsx)(`button`, {
                      className: `uktdropdown-trigger`,
                      tabIndex: 0,
                      type: `button`,
                      children: k,
                  })),
                  (t[45] = k),
                  (t[46] = e)),
                (k = e));
        }
    if (p != null) {
        let e;
        t[47] === p
            ? (e = t[48])
            : ((e = (0, G.jsx)(`div`, {
                  className: `uktdropdown-label-text`,
                  children: p,
              })),
              (t[47] = p),
              (t[48] = e));
        let n;
        (t[49] !== e || t[50] !== k
            ? ((n = (0, G.jsxs)(`label`, {
                  className: `uktdropdown-label`,
                  children: [e, k],
              })),
              (t[49] = e),
              (t[50] = k),
              (t[51] = n))
            : (n = t[51]),
            (k = n));
    }
    let Xe = te(P),
        Y = te(F),
        Ze;
    t[52] !== w || t[53] !== F
        ? ((Ze = w ? _e(F) : null), (t[52] = w), (t[53] = F), (t[54] = Ze))
        : (Ze = t[54]);
    let X = te(Ze),
        Z;
    if (
        w &&
        Y.top != null &&
        Xe.top != null &&
        Xe.bottom != null &&
        X.top != null &&
        X.bottom != null
    ) {
        let e = Y.top < X.top,
            n = Y.bottom > X.bottom;
        if (e || n) {
            let e = Math.abs(Y.bottom - Xe.top) <= Math.abs(Y.top - Xe.bottom),
                n;
            (t[55] !== X.bottom ||
            t[56] !== X.top ||
            t[57] !== Y.bottom ||
            t[58] !== Y.top ||
            t[59] !== e
                ? ((n = Math.round(e ? Y.bottom - X.top : X.bottom - Y.top)),
                  (t[55] = X.bottom),
                  (t[56] = X.top),
                  (t[57] = Y.bottom),
                  (t[58] = Y.top),
                  (t[59] = e),
                  (t[60] = n))
                : (n = t[60]),
                (Z = n));
        }
    }
    let Q;
    t[61] === Z
        ? (Q = t[62])
        : ((Q =
              Z != null && Z > 0
                  ? {
                        '--uktdd-body-max-height': `calc(${Z}px - var(--uktdd-body-buffer))`,
                    }
                  : null),
          (t[61] = Z),
          (t[62] = Q));
    let $;
    t[63] === D
        ? ($ = t[64])
        : (($ = D != null && D >= 0 ? { '--uktdd-body-min-height': `${D}px` } : null),
          (t[63] = D),
          (t[64] = $));
    let Qe;
    t[65] === h
        ? (Qe = t[66])
        : ((Qe = h != null && h > 0 ? { '--uktdd-body-min-width': `${h}px` } : null),
          (t[65] = h),
          (t[66] = Qe));
    let $e;
    t[67] !== ae || t[68] !== Q || t[69] !== $ || t[70] !== Qe
        ? (($e = { ...ae, ...Q, ...$, ...Qe }),
          (t[67] = ae),
          (t[68] = Q),
          (t[69] = $),
          (t[70] = Qe),
          (t[71] = $e))
        : ($e = t[71]);
    let et = $e,
        tt;
    t[72] === Symbol.for(`react.memo_cache_sentinel`)
        ? ((tt = (0, G.jsx)(`style`, {
              href: `@acusti/dropdown/Dropdown`,
              precedence: `medium`,
              children: ce,
          })),
          (t[72] = tt))
        : (tt = t[72]);
    let nt;
    t[73] !== a || t[74] !== c || t[75] !== A || t[76] !== d
        ? ((nt = o(`uktdropdown`, a, { disabled: c, 'is-open': A, 'is-searchable': d })),
          (t[73] = a),
          (t[74] = c),
          (t[75] = A),
          (t[76] = d),
          (t[77] = nt))
        : (nt = t[77]);
    let rt;
    t[78] !== i || t[79] !== O || t[80] !== A
        ? ((rt = A
              ? (0, G.jsx)(`div`, {
                    className: `uktdropdown-body`,
                    ref: ue,
                    children: O > 1 ? i[1] : i,
                })
              : null),
          (t[78] = i),
          (t[79] = O),
          (t[80] = A),
          (t[81] = rt))
        : (rt = t[81]);
    let it;
    return (
        t[82] !== He ||
        t[83] !== Be ||
        t[84] !== Re ||
        t[85] !== We ||
        t[86] !== Ye ||
        t[87] !== ee ||
        t[88] !== et ||
        t[89] !== nt ||
        t[90] !== rt ||
        t[91] !== k
            ? ((it = (0, G.jsxs)(W.Fragment, {
                  children: [
                      tt,
                      (0, G.jsxs)(`div`, {
                          className: nt,
                          onClick: ee,
                          onMouseDown: He,
                          onMouseMove: Ie,
                          onMouseOut: Be,
                          onMouseOver: Re,
                          onMouseUp: We,
                          ref: Ye,
                          style: et,
                          children: [k, rt],
                      }),
                  ],
              })),
              (t[82] = He),
              (t[83] = Be),
              (t[84] = Re),
              (t[85] = We),
              (t[86] = Ye),
              (t[87] = ee),
              (t[88] = et),
              (t[89] = nt),
              (t[90] = rt),
              (t[91] = k),
              (t[92] = it))
            : (it = t[92]),
        it
    );
}
function _e(e) {
    for (; e?.parentElement; ) {
        if (e.parentElement.tagName === `BODY`) return null;
        let t = e.parentElement,
            n = getComputedStyle(t).overflowY;
        if (
            n === `clip` ||
            n === `hidden` ||
            ((n === `auto` || n === `scroll`) && t.scrollHeight > t.clientHeight + 1)
        )
            return t;
        e = t;
    }
    return null;
}
var ve,
    W,
    G,
    ye,
    be,
    xe,
    K = t(() => {
        ((ve = i()),
            ne(),
            M(),
            a(),
            (W = e(n(), 1)),
            N(),
            ge(),
            (G = r()),
            (ye = `@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.`),
            (be = `button, a[href], input[type="button"], input[type="submit"]`),
            (xe = `input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea`),
            (U.__docgenInfo = {
                description: ``,
                methods: [],
                displayName: `Dropdown`,
                props: {
                    allowCreate: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: `Boolean indicating if the user can submit a value not already in the
dropdown.`,
                    },
                    allowEmpty: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: `Boolean indicating if the user can submit an empty value (i.e. clear
the value). Defaults to true.`,
                        defaultValue: { value: `true`, computed: !1 },
                    },
                    children: {
                        required: !0,
                        tsType: {
                            name: `union`,
                            raw: `ChildrenTuple | JSX.Element`,
                            elements: [
                                {
                                    name: `union`,
                                    raw: `[ReactNode, ReactNode] | readonly [ReactNode, ReactNode]`,
                                    elements: [
                                        {
                                            name: `tuple`,
                                            raw: `[ReactNode, ReactNode]`,
                                            elements: [
                                                { name: `ReactNode` },
                                                { name: `ReactNode` },
                                            ],
                                        },
                                        { name: `unknown` },
                                    ],
                                },
                                { name: `JSX.Element` },
                            ],
                        },
                        description: `Can take a single React element or exactly two renderable children.`,
                    },
                    className: {
                        required: !1,
                        tsType: { name: `string` },
                        description: ``,
                    },
                    constrainHeightToAvoidClipping: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: `Constrain the dropdown body’s max-height to the nearest vertically
clipping ancestor when it still overflows after anchor-positioning
fallbacks have resolved. Defaults to false.`,
                        defaultValue: { value: `false`, computed: !1 },
                    },
                    disabled: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: ``,
                    },
                    group: {
                        required: !1,
                        tsType: { name: `string` },
                        description: `Group identifier string links dropdowns together into a menu
(like macOS top menubar).`,
                    },
                    hasItems: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: ``,
                        defaultValue: { value: `true`, computed: !1 },
                    },
                    isOpenOnMount: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: ``,
                    },
                    isSearchable: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: ``,
                    },
                    keepOpenOnSubmit: {
                        required: !1,
                        tsType: { name: `boolean` },
                        description: ``,
                        defaultValue: { value: `!hasItems`, computed: !1 },
                    },
                    label: {
                        required: !1,
                        tsType: { name: `ReactNode` },
                        description: ``,
                    },
                    minHeightBody: {
                        required: !1,
                        tsType: { name: `number` },
                        description: `Minimum height for the dropdown body in pixels. Defaults to 50.`,
                        defaultValue: { value: `50`, computed: !1 },
                    },
                    minWidthBody: {
                        required: !1,
                        tsType: { name: `number` },
                        description: ``,
                    },
                    name: {
                        required: !1,
                        tsType: { name: `string` },
                        description: `Only usable in conjunction with {isSearchable: true}.
Used as search input’s name.`,
                    },
                    onActiveItem: {
                        required: !1,
                        tsType: {
                            name: `signature`,
                            type: `function`,
                            raw: `(payload: Item) => void`,
                            signature: {
                                arguments: [
                                    {
                                        type: {
                                            name: `signature`,
                                            type: `object`,
                                            raw: `{
    element: MaybeHTMLElement;
    event: Event | SyntheticEvent<HTMLElement>;
    label: string;
    value: string;
}`,
                                            signature: {
                                                properties: [
                                                    {
                                                        key: `element`,
                                                        value: {
                                                            name: `union`,
                                                            raw: `HTMLElement | null`,
                                                            elements: [
                                                                { name: `HTMLElement` },
                                                                { name: `null` },
                                                            ],
                                                            required: !0,
                                                        },
                                                    },
                                                    {
                                                        key: `event`,
                                                        value: {
                                                            name: `union`,
                                                            raw: `Event | SyntheticEvent<HTMLElement>`,
                                                            elements: [
                                                                { name: `Event` },
                                                                {
                                                                    name: `SyntheticEvent`,
                                                                    elements: [
                                                                        {
                                                                            name: `HTMLElement`,
                                                                        },
                                                                    ],
                                                                    raw: `SyntheticEvent<HTMLElement>`,
                                                                },
                                                            ],
                                                            required: !0,
                                                        },
                                                    },
                                                    {
                                                        key: `label`,
                                                        value: {
                                                            name: `string`,
                                                            required: !0,
                                                        },
                                                    },
                                                    {
                                                        key: `value`,
                                                        value: {
                                                            name: `string`,
                                                            required: !0,
                                                        },
                                                    },
                                                ],
                                            },
                                        },
                                        name: `payload`,
                                    },
                                ],
                                return: { name: `void` },
                            },
                        },
                        description: ``,
                    },
                    onClick: {
                        required: !1,
                        tsType: {
                            name: `signature`,
                            type: `function`,
                            raw: `(event: ReactMouseEvent<HTMLElement>) => unknown`,
                            signature: {
                                arguments: [
                                    {
                                        type: {
                                            name: `ReactMouseEvent`,
                                            elements: [{ name: `HTMLElement` }],
                                            raw: `ReactMouseEvent<HTMLElement>`,
                                        },
                                        name: `event`,
                                    },
                                ],
                                return: { name: `unknown` },
                            },
                        },
                        description: ``,
                    },
                    onClose: {
                        required: !1,
                        tsType: {
                            name: `signature`,
                            type: `function`,
                            raw: `() => unknown`,
                            signature: { arguments: [], return: { name: `unknown` } },
                        },
                        description: ``,
                    },
                    onMouseDown: {
                        required: !1,
                        tsType: {
                            name: `signature`,
                            type: `function`,
                            raw: `(event: ReactMouseEvent<HTMLElement>) => unknown`,
                            signature: {
                                arguments: [
                                    {
                                        type: {
                                            name: `ReactMouseEvent`,
                                            elements: [{ name: `HTMLElement` }],
                                            raw: `ReactMouseEvent<HTMLElement>`,
                                        },
                                        name: `event`,
                                    },
                                ],
                                return: { name: `unknown` },
                            },
                        },
                        description: ``,
                    },
                    onMouseUp: {
                        required: !1,
                        tsType: {
                            name: `signature`,
                            type: `function`,
                            raw: `(event: ReactMouseEvent<HTMLElement>) => unknown`,
                            signature: {
                                arguments: [
                                    {
                                        type: {
                                            name: `ReactMouseEvent`,
                                            elements: [{ name: `HTMLElement` }],
                                            raw: `ReactMouseEvent<HTMLElement>`,
                                        },
                                        name: `event`,
                                    },
                                ],
                                return: { name: `unknown` },
                            },
                        },
                        description: ``,
                    },
                    onOpen: {
                        required: !1,
                        tsType: {
                            name: `signature`,
                            type: `function`,
                            raw: `() => unknown`,
                            signature: { arguments: [], return: { name: `unknown` } },
                        },
                        description: ``,
                    },
                    onSubmitItem: {
                        required: !1,
                        tsType: {
                            name: `signature`,
                            type: `function`,
                            raw: `(payload: Item) => void`,
                            signature: {
                                arguments: [
                                    {
                                        type: {
                                            name: `signature`,
                                            type: `object`,
                                            raw: `{
    element: MaybeHTMLElement;
    event: Event | SyntheticEvent<HTMLElement>;
    label: string;
    value: string;
}`,
                                            signature: {
                                                properties: [
                                                    {
                                                        key: `element`,
                                                        value: {
                                                            name: `union`,
                                                            raw: `HTMLElement | null`,
                                                            elements: [
                                                                { name: `HTMLElement` },
                                                                { name: `null` },
                                                            ],
                                                            required: !0,
                                                        },
                                                    },
                                                    {
                                                        key: `event`,
                                                        value: {
                                                            name: `union`,
                                                            raw: `Event | SyntheticEvent<HTMLElement>`,
                                                            elements: [
                                                                { name: `Event` },
                                                                {
                                                                    name: `SyntheticEvent`,
                                                                    elements: [
                                                                        {
                                                                            name: `HTMLElement`,
                                                                        },
                                                                    ],
                                                                    raw: `SyntheticEvent<HTMLElement>`,
                                                                },
                                                            ],
                                                            required: !0,
                                                        },
                                                    },
                                                    {
                                                        key: `label`,
                                                        value: {
                                                            name: `string`,
                                                            required: !0,
                                                        },
                                                    },
                                                    {
                                                        key: `value`,
                                                        value: {
                                                            name: `string`,
                                                            required: !0,
                                                        },
                                                    },
                                                ],
                                            },
                                        },
                                        name: `payload`,
                                    },
                                ],
                                return: { name: `void` },
                            },
                        },
                        description: ``,
                    },
                    placeholder: {
                        required: !1,
                        tsType: { name: `string` },
                        description: `Only usable in conjunction with {isSearchable: true}.
Used as search input’s placeholder.`,
                    },
                    style: {
                        required: !1,
                        tsType: { name: `CSSProperties` },
                        description: ``,
                    },
                    tabIndex: {
                        required: !1,
                        tsType: { name: `number` },
                        description: `Only usable in conjunction with {isSearchable: true}.
Used as search input’s tabIndex.`,
                    },
                    value: {
                        required: !1,
                        tsType: { name: `string` },
                        description: `Used as search input’s value if props.isSearchable === true
Used to determine if value has changed to avoid triggering onSubmitItem if not`,
                    },
                },
            }));
    }),
    Se = t(() => {});
export { U as n, K as r, Se as t };
