import { Use as W, Value as p, prop as et, html as C, OnDispose as z, attr as i, on as k, WithElement as ut, aria as U, bind as $t, computedOf as L, style as ft, When as E, NotEmpty as Qt, Fragment as B, ForEach as mt, svg as At, svgAttr as gt, Empty as T, emitValue as j, coalesce as Jt, Ensure as Kt, OneOfType as te, Repeat as Pt, signal as Ft, input as K, emitValueAsNullableDate as ee, emitValueAsNullableDateTime as ne, emitValueAsNumber as G, emit as se, Task as Bt } from "@tempots/dom";
import { f as re } from "./colors-BW19rWA1.js";
import { g as ae } from "./timer-DzWb416P.js";
import { ElementRect as jt, AutoSelect as le } from "@tempots/ui";
import { a as X, b as P, f as oe, I as O, C as H, c as ce, d as yt, T as ie, g as ue, L as pe, e as Vt, h as de, B as bt } from "./translations-DoBmuZ5v.js";
import { C as It, m as fe, d as me, I as Ht, E as he, P as ge, S as ct, s as be, e as vt, O as at, f as Lt } from "./notice-Dgv1Puqy.js";
function Wt(t) {
  if (typeof t != "string") return !1;
  const e = t.startsWith("#") ? t.slice(1) : t;
  return /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(e);
}
function ve(t) {
  if (typeof t != "string") return !1;
  const e = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i, s = t.match(e);
  if (!s) return !1;
  const [, n, r, o] = s, a = parseInt(n, 10), u = parseInt(r, 10), l = parseInt(o, 10);
  return a >= 0 && a <= 255 && u >= 0 && u <= 255 && l >= 0 && l <= 255;
}
function xe(t) {
  if (typeof t != "string") return !1;
  const e = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i, s = t.match(e);
  if (!s) return !1;
  const [, n, r, o, a] = s, u = parseInt(n, 10), l = parseInt(r, 10), c = parseInt(o, 10), f = parseFloat(a);
  return u >= 0 && u <= 255 && l >= 0 && l <= 255 && c >= 0 && c <= 255 && f >= 0 && f <= 1;
}
function we(t) {
  if (typeof t != "string") return !1;
  const e = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i, s = t.match(e);
  if (!s) return !1;
  const [, n, r, o] = s, a = parseInt(n, 10), u = parseInt(r, 10), l = parseInt(o, 10);
  return a >= 0 && a <= 360 && u >= 0 && u <= 100 && l >= 0 && l <= 100;
}
function bn(t) {
  return Wt(t) || ve(t) || xe(t) || we(t);
}
function _e(t) {
  if (!Wt(t)) return null;
  let e = t.startsWith("#") ? t.slice(1) : t;
  return e.length === 3 && (e = e.split("").map((s) => s + s).join("")), `#${e.toLowerCase()}`;
}
function Ct(t, e, s) {
  const n = (r) => {
    const o = Math.round(Math.max(0, Math.min(255, r))).toString(16);
    return o.length === 1 ? "0" + o : o;
  };
  return `#${n(t)}${n(e)}${n(s)}`;
}
function it(t) {
  const e = _e(t);
  if (!e) return null;
  const s = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
  return s ? {
    r: parseInt(s[1], 16),
    g: parseInt(s[2], 16),
    b: parseInt(s[3], 16)
  } : null;
}
function vn(t, e) {
  const s = it(t), n = it(e);
  if (!s || !n) return null;
  const r = (c, f, b) => {
    const [h, d, x] = [c, f, b].map((m) => (m = m / 255, m <= 0.03928 ? m / 12.92 : Math.pow((m + 0.055) / 1.055, 2.4)));
    return 0.2126 * h + 0.7152 * d + 0.0722 * x;
  }, o = r(s.r, s.g, s.b), a = r(n.r, n.g, n.b), u = Math.max(o, a), l = Math.min(o, a);
  return (u + 0.05) / (l + 0.05);
}
function $e(t) {
  if (!t) return [0, 0, 0, 1];
  const s = t.trim().match(
    /^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/
  );
  if (s) {
    const c = s[1];
    if (c.length === 8) {
      const f = parseInt(c.slice(0, 2), 16), b = parseInt(c.slice(2, 4), 16), h = parseInt(c.slice(4, 6), 16), d = parseInt(c.slice(6, 8), 16) / 255;
      return [f, b, h, d];
    }
    if (c.length === 6)
      return [
        parseInt(c.slice(0, 2), 16),
        parseInt(c.slice(2, 4), 16),
        parseInt(c.slice(4, 6), 16),
        1
      ];
    if (c.length === 4) {
      const f = parseInt(c[0] + c[0], 16), b = parseInt(c[1] + c[1], 16), h = parseInt(c[2] + c[2], 16), d = parseInt(c[3] + c[3], 16) / 255;
      return [f, b, h, d];
    }
    if (c.length === 3) {
      const f = parseInt(c[0] + c[0], 16), b = parseInt(c[1] + c[1], 16), h = parseInt(c[2] + c[2], 16);
      return [f, b, h, 1];
    }
  }
  const n = t.match(
    /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i
  );
  if (n)
    return [
      parseInt(n[1], 10),
      parseInt(n[2], 10),
      parseInt(n[3], 10),
      parseFloat(n[4])
    ];
  const r = t.match(
    /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i
  );
  if (r)
    return [parseInt(r[1], 10), parseInt(r[2], 10), parseInt(r[3], 10), 1];
  const o = t.match(
    /^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i
  );
  if (o) {
    const c = parseFloat(o[1]), f = parseFloat(o[2]), b = parseFloat(o[3]), h = o[4] != null ? parseFloat(o[4]) : 1, [d, x, m] = Zt(c, f / 100, b / 100);
    return [d, x, m, h];
  }
  const a = t.match(
    /^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i
  );
  if (a) {
    const c = parseFloat(a[1]), f = parseFloat(a[2]) / 100, b = parseFloat(a[3]) / 100, h = a[4] != null ? parseFloat(a[4]) : 1, [d, x, m] = Ce(c, f, b);
    return [d, x, m, h];
  }
  const u = t.match(
    /^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i
  );
  if (u) {
    const c = u[1], f = parseFloat(u[2]), b = parseFloat(u[3]), h = u[4] != null ? parseFloat(u[4]) : 1, d = c.endsWith("%") ? Math.max(0, Math.min(1, parseFloat(c) / 100)) : Math.max(0, Math.min(1, parseFloat(c))), [x, m, $] = Me(d, f, b);
    return [x, m, $, h];
  }
  const l = it(t);
  return l ? [l.r, l.g, l.b, 1] : [0, 0, 0, 1];
}
function ye(t, e, s, n) {
  return `rgba(${Math.round(t)}, ${Math.round(e)}, ${Math.round(s)}, ${Math.max(
    0,
    Math.min(1, Math.round(n * 100) / 100)
  )})`;
}
function Ie(t) {
  let e = t + 1831565813;
  return function() {
    return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
  };
}
function Zt(t, e, s) {
  t = (t % 360 + 360) % 360;
  const n = (1 - Math.abs(2 * s - 1)) * e, r = n * (1 - Math.abs(t / 60 % 2 - 1)), o = s - n / 2;
  let a = 0, u = 0, l = 0;
  return 0 <= t && t < 60 ? [a, u, l] = [n, r, 0] : 60 <= t && t < 120 ? [a, u, l] = [r, n, 0] : 120 <= t && t < 180 ? [a, u, l] = [0, n, r] : 180 <= t && t < 240 ? [a, u, l] = [0, r, n] : 240 <= t && t < 300 ? [a, u, l] = [r, 0, n] : [a, u, l] = [n, 0, r], [
    Math.round((a + o) * 255),
    Math.round((u + o) * 255),
    Math.round((l + o) * 255)
  ];
}
function Ce(t, e, s) {
  t = (t % 360 + 360) % 360;
  const n = e + s;
  n > 1 && (e /= n, s /= n);
  const [r, o, a] = Zt(t, 1, 0.5).map((b) => b / 255), u = 1 - e - s, l = r * u + e, c = o * u + e, f = a * u + e;
  return [Math.round(l * 255), Math.round(c * 255), Math.round(f * 255)];
}
function kt(t, e, s) {
  t /= 255, e /= 255, s /= 255;
  const n = Math.max(t, e, s), r = Math.min(t, e, s);
  let o = 0, a = 0;
  const u = (n + r) / 2, l = n - r;
  if (l !== 0) {
    switch (a = u > 0.5 ? l / (2 - n - r) : l / (n + r), n) {
      case t:
        o = (e - s) / l + (e < s ? 6 : 0);
        break;
      case e:
        o = (s - t) / l + 2;
        break;
      default:
        o = (t - e) / l + 4;
    }
    o *= 60;
  }
  return [Math.round(o), Math.round(a * 100), Math.round(u * 100)];
}
function ke(t, e, s) {
  const [n] = kt(t, e, s), r = t / 255, o = e / 255, a = s / 255, u = Math.min(r, o, a), l = 1 - Math.max(r, o, a);
  return [n, Math.round(u * 100), Math.round(l * 100)];
}
function xt(t) {
  const e = t / 255;
  return e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function wt(t) {
  const e = t <= 31308e-7 ? 12.92 * t : 1.055 * Math.pow(t, 0.4166666666666667) - 0.055;
  return Math.round(Math.max(0, Math.min(1, e)) * 255);
}
function Me(t, e, s) {
  const n = s * Math.PI / 180, r = Math.cos(n) * e, o = Math.sin(n) * e, a = t + 0.3963377774 * r + 0.2158037573 * o, u = t - 0.1055613458 * r - 0.0638541728 * o, l = t - 0.0894841775 * r - 1.291485548 * o, c = a * a * a, f = u * u * u, b = l * l * l, h = 4.0767416621 * c - 3.3077115913 * f + 0.2309699292 * b, d = -1.2684380046 * c + 2.6097574011 * f - 0.3413193965 * b, x = -0.0041960863 * c - 0.7034186147 * f + 1.707614701 * b;
  return [wt(h), wt(d), wt(x)];
}
function De(t, e, s) {
  const n = xt(t), r = xt(e), o = xt(s), a = 0.4122214708 * n + 0.5363325363 * r + 0.0514459929 * o, u = 0.2119034982 * n + 0.6806995451 * r + 0.1073969566 * o, l = 0.0883024619 * n + 0.2817188376 * r + 0.6299787005 * o, c = Math.cbrt(a), f = Math.cbrt(u), b = Math.cbrt(l), h = 0.2104542553 * c + 0.793617785 * f - 0.0040720468 * b, d = 1.9779984951 * c - 2.428592205 * f + 0.4505937099 * b, x = 0.0259040371 * c + 0.7827717662 * f - 0.808675766 * b, m = Math.sqrt(d * d + x * x);
  let $ = Math.atan2(x, d) * 180 / Math.PI;
  return $ < 0 && ($ += 360), [h, m, $];
}
function lt(t, e, s, n, r, o) {
  switch (r) {
    case "hex":
      if (o) {
        const a = (l) => l.toString(16).padStart(2, "0"), u = Math.max(0, Math.min(255, Math.round(n * 255)));
        return `#${a(t)}${a(e)}${a(s)}${a(u)}`;
      }
      return Ct(t, e, s);
    case "rgb":
      return `rgb(${t}, ${e}, ${s})`;
    case "rgba":
      return `rgba(${t}, ${e}, ${s}, ${Math.round(n * 100) / 100})`;
    case "hsl": {
      const [a, u, l] = kt(t, e, s);
      return `hsl(${a}, ${u}%, ${l}%)`;
    }
    case "hsla": {
      const [a, u, l] = kt(t, e, s);
      return `hsla(${a}, ${u}%, ${l}%, ${Math.round(n * 100) / 100})`;
    }
    case "hwb": {
      const [a, u, l] = ke(t, e, s);
      return n < 1 ? `hwb(${a} ${u}% ${l}% / ${Math.round(n * 100) / 100})` : `hwb(${a} ${u}% ${l}%)`;
    }
    case "oklch": {
      const [a, u, l] = De(t, e, s), c = (Math.round(a * 1e3) / 1e3).toFixed(3), f = (Math.round(u * 1e3) / 1e3).toFixed(3), b = (Math.round(l * 10) / 10).toFixed(1), h = Math.round(n * 100) / 100;
      return o || n < 1 ? `oklch(${c} ${f} ${b} / ${h})` : `oklch(${c} ${f} ${b})`;
    }
  }
}
function ot(t, e) {
  return e ? t === "rgb" ? "rgba" : t === "hsl" ? "hsla" : t : t === "rgba" ? "rgb" : t === "hsla" ? "hsl" : t;
}
class Se extends Error {
  constructor(e = "Missing implementation") {
    super(e), this.name = "MissingImplementationError";
  }
}
const xn = (t) => Te(t).split("_").join(" "), Te = (t) => (t = t.replace(/::/g, "/"), t = t.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2"), t = t.replace(/([a-z\d])([A-Z])/g, "$1_$2"), t = t.replace(/-/g, "_"), t.toLowerCase()), wn = (t) => t.substring(0, 1).toUpperCase() + t.substring(1), Ae = (t) => {
  if (typeof Buffer < "u")
    return Buffer.from(t, "base64").toString("utf8");
  if (typeof atob < "u")
    return atob(t);
  throw new Se(
    "No implementation found for base64 decoding"
  );
};
function Et({
  onChange: t,
  value: e,
  accept: s = "*/*",
  enableClick: n = !0,
  content: r,
  disabled: o = !1,
  allowMultiple: a
}) {
  return W(X, (u) => {
    const l = p.deriveProp(e ?? []), c = et(!1), f = (v) => {
      v.preventDefault(), v.stopPropagation(), c.value = !0;
    }, b = (v) => {
      v.preventDefault(), v.stopPropagation(), (!v.currentTarget || !v.currentTarget.contains(v.relatedTarget)) && (c.value = !1);
    }, h = (v) => {
      v.preventDefault(), v.stopPropagation(), c.value = !1;
      const g = Array.from(v.dataTransfer?.files || []);
      g.length > 0 && (l.value = g, t(g));
    }, d = (v) => {
      p.get(n) && v.currentTarget.querySelector(
        'input[type="file"]'
      )?.click();
    };
    let x = null;
    const m = () => {
      if (x == null) return;
      const v = Array.from(x.files ?? []);
      v.length > 0 && (l.value = v, t(v)), x.value = "";
    }, $ = (v) => {
      p.get(n) && (v.key === "Enter" || v.key === " ") && (v.preventDefault(), d(v));
    };
    return C.div(
      z(() => p.dispose(l), c),
      i.role("button"),
      i.tabindex(
        p.map(n, (v) => v ? 0 : -1)
      ),
      i.style("position: relative;"),
      k.dragover(f),
      k.dragleave(b),
      k.drop(h),
      k.click(d),
      k.keydown($),
      // Hidden file input
      C.input(
        i.type("file"),
        i.disabled(o),
        i.accept(s),
        i.multiple(a),
        i.style(
          "position: absolute; left: -9999px; opacity: 0; pointer-events: none;"
        ),
        k.change(m),
        ut((v) => (x = v, z(
          l.on((g) => {
            const D = globalThis.DataTransfer;
            if (D != null) {
              const I = new D();
              g.forEach((_) => I.items.add(_)), v.files = I.files;
            }
          })
        )))
      ),
      // Screen reader instructions
      U.label($t(u.$.dropZoneInstructions)(n)),
      // Content
      r({ files: l, clear: () => l.value = [], change: l.set })
    );
  });
}
function Fe(t, e) {
  return t.length === e.length && t.every((s, n) => s === e[n]);
}
function Be(t, e) {
  const s = ["bc-segmented-control", `bc-segmented-control--size-${t}`];
  return e && s.push("bc-segmented-control--disabled"), s.join(" ");
}
function _n({
  options: t,
  value: e,
  onChange: s,
  size: n = "md",
  disabled: r = !1
}, ...o) {
  const a = re(t).map(([u, l]) => ({
    key: u,
    label: l
  }));
  return ut(() => {
    const u = Object.fromEntries(
      a.map((c, f) => [c.key, f])
    ), l = et(
      a.map(() => ({ left: 0, width: 0 })),
      Fe
    );
    return C.div(
      z(l),
      i.class(
        L(
          n,
          r
        )(
          (c, f) => Be(c ?? "md", f ?? !1)
        )
      ),
      C.div(
        i.class("bc-segmented-control__container"),
        C.div(
          i.class("bc-segmented-control__indicator"),
          ft.width(
            L(
              e,
              l
            )((c, f) => {
              const { width: b } = f[u[c] ?? 0];
              return `${b}px`;
            })
          ),
          ft.left(
            L(
              e,
              l
            )((c, f) => {
              const { left: b } = f[u[c] ?? 0];
              return `${b}px`;
            })
          )
        ),
        // clickable buttons
        a.map(({ label: c, key: f }, b) => C.button(
          i.type("button"),
          k.click((h) => {
            h.preventDefault(), p.get(r) || s?.(f);
          }),
          i.disabled(r),
          i.class("bc-segmented-control__segment"),
          i.class(
            p.map(e, (h) => h === f ? "bc-segmented-control__segment--active" : "bc-segmented-control__segment--inactive")
          ),
          jt((h) => {
            function d() {
              l.update((m) => {
                const $ = [...m];
                return $[b] = {
                  width: h.value.width,
                  left: h.value.localLeft
                }, $;
              });
            }
            const x = ae(d);
            return z(x, h.on(d));
          }),
          c
        ))
      ),
      ...o
    );
  });
}
function Ve(t) {
  const e = t.type.toLowerCase();
  return e.startsWith("image/") && (e.includes("jpeg") || e.includes("jpg") || e.includes("png") || e.includes("gif") || e.includes("webp") || e.includes("svg"));
}
function Le(t) {
  const e = t.type.toLowerCase();
  return e.startsWith("image/") ? "vscode-icons:file-type-image" : e.startsWith("video/") ? "vscode-icons:file-type-video" : e.startsWith("audio/") ? "vscode-icons:file-type-audio" : e.includes("pdf") ? "vscode-icons:file-type-pdf2" : e.includes("word") || e.includes("document") ? "vscode-icons:file-type-word" : e.includes("excel") || e.includes("spreadsheet") ? "vscode-icons:file-type-excel" : e.includes("powerpoint") || e.includes("presentation") ? "vscode-icons:file-type-powerpoint" : e.includes("zip") || e.includes("archive") ? "vscode-icons:file-type-zip" : e.includes("text") ? "vscode-icons:file-type-text" : e.includes("json") ? "vscode-icons:file-type-json-official" : e.includes("csv") ? "vscode-icons:file-type-csv" : e.includes("xml") ? "vscode-icons:file-type-xml" : e.includes("yaml") ? "vscode-icons:file-type-yaml-official" : "vscode-icons:file-type-binary";
}
function Rt(t) {
  return E(
    t.map(Ve),
    () => {
      const e = et(null);
      return t.on((s) => {
        e.value && URL.revokeObjectURL(e.value);
        const n = URL.createObjectURL(s);
        e.value = n;
      }), C.div(
        z(e, () => {
          e.value && URL.revokeObjectURL(e.value);
        }),
        i.class("bc-file-input__thumbnail-container"),
        C.img(
          i.src(e),
          i.alt(t.map((s) => s.name)),
          i.class("bc-file-input__thumbnail")
        )
      );
    },
    () => O({ icon: t.map(Le) })
  );
}
const Ee = (t, ...e) => {
  const {
    value: s = et([]),
    accept: n = "*/*",
    maxFiles: r,
    maxFileSize: o,
    onChange: a,
    onBlur: u,
    disabled: l,
    hasError: c,
    mode: f = "default",
    showFileList: b = !0,
    ...h
  } = t, d = s, x = p.map(f, (I) => I === "compact"), m = (I) => {
    let _ = I;
    if (r != null) {
      const w = p.get(r);
      _ = _.slice(0, w);
    }
    if (o) {
      const w = p.get(o);
      _ = _.filter((y) => y.size <= w);
    }
    a?.(_);
  }, $ = (I) => {
    const w = d.value.filter((y, M) => M !== I);
    a?.(w);
  }, v = () => {
    a?.([]);
  }, g = ({
    files: I,
    clear: _,
    change: w
  }) => W(
    X,
    (y) => C.div(
      i.class("bc-file-input__drop-zone"),
      C.div(
        i.class(
          "bc-file-input__drop-zone-content bc-file-input__drop-zone-content--empty"
        ),
        O({ icon: "mdi:cloud-upload-outline", size: "xl" }),
        C.div(
          i.class("bc-file-input__drop-zone-text"),
          $t(y.$.filesInputInstructions)(
            r,
            o,
            y.$.fileSizeUnits.value
          )
        )
      )
    )
  ), D = ({
    files: I
  }) => W(
    X,
    (_) => C.div(
      i.class("bc-file-input__compact-input"),
      E(
        I.map((w) => w.length > 0),
        () => C.span(
          i.class("bc-file-input__compact-value"),
          mt(
            I,
            (w) => C.span(
              i.class("bc-file-input__compact-value-item"),
              Rt(w),
              C.span(
                i.class("bc-file-input__compact-value-item-name"),
                w.$.name
              )
            )
          )
        ),
        () => C.span(
          i.class("bc-file-input__compact-placeholder"),
          O({ icon: "mdi:cloud-upload-outline", size: "md" }),
          " ",
          $t(_.$.filesInputInstructions)(
            r,
            o,
            _.$.fileSizeUnits.value
          )
        )
      )
    )
  );
  return W(
    X,
    (I) => P(
      {
        baseContainer: p.map(x, (_) => !_),
        disabled: l,
        hasError: c,
        after: E(
          x,
          () => E(
            d.map(({ length: _ }) => _ > 0),
            () => It(
              {
                size: "sm",
                label: I.$.clearAllFiles,
                disabled: l,
                onClick: v
              },
              i.class("bc-file-input__compact-clear")
            )
          )
        ),
        ...h,
        input: E(
          x,
          () => C.div(
            i.class("bc-file-input bc-file-input--compact"),
            Et({
              value: d,
              accept: n,
              enableClick: !0,
              allowMultiple: p.map(r ?? 1 / 0, (_) => _ > 1),
              disabled: l,
              onChange: m,
              content: D
            })
          ),
          () => C.div(
            i.class("bc-file-input"),
            Et({
              value: d,
              accept: n,
              enableClick: !0,
              allowMultiple: p.map(r ?? 1 / 0, (_) => _ > 1),
              disabled: l,
              onChange: m,
              content: g
            }),
            E(
              b,
              () => Qt(
                d,
                () => B(
                  C.div(
                    i.class("bc-file-input__file-list"),
                    mt(d, (_, w) => {
                      const y = w.index;
                      return C.div(
                        i.class("bc-file-input__file-item"),
                        C.div(
                          i.class("bc-file-input__file-icon"),
                          Rt(_)
                        ),
                        C.div(
                          i.class("bc-file-input__file-info"),
                          C.div(
                            i.class("bc-file-input__file-name"),
                            i.title(_.$.name),
                            _.$.name
                          ),
                          C.div(
                            i.class("bc-file-input__file-meta"),
                            L(
                              _.$.size,
                              I.$.fileSizeUnits
                            )(
                              (M, A) => oe(M, { units: A })
                            ),
                            " • ",
                            L(
                              _.$.type,
                              I.$.unknownType
                            )((M, A) => M || A)
                          )
                        ),
                        It(
                          {
                            size: "sm",
                            label: I.$.removeFile,
                            disabled: l,
                            onClick: () => $(y)
                          },
                          i.class("bc-file-input__remove-button")
                        )
                      );
                    })
                  ),
                  E(
                    d.map(({ length: _ }) => _ > 1),
                    () => C.div(
                      i.class(
                        "bc-file-input__clear-all-button-container"
                      ),
                      C.button(
                        i.type("button"),
                        i.class("bc-file-input__clear-all-button"),
                        i.disabled(l),
                        I.$.clearAllFiles,
                        k.click((_) => {
                          _.preventDefault(), _.stopPropagation(), v();
                        })
                      )
                    )
                  )
                )
              )
            )
          )
        )
      },
      ...e
    )
  );
};
async function Re(t) {
  return new Promise((e, s) => {
    const n = new FileReader();
    n.readAsDataURL(t), n.onload = () => {
      const r = n.result;
      e(r.split(",")[1]);
    }, n.onerror = (r) => s(r);
  });
}
function ze(t) {
  return Promise.all(t.map(Re));
}
function Ue(t) {
  if (t.length >= 4) {
    if (t[0] === 137 && t[1] === 80 && t[2] === 78 && t[3] === 71)
      return "image/png";
    if (t[0] === 255 && t[1] === 216) return "image/jpeg";
    if (t[0] === 71 && t[1] === 73 && t[2] === 70)
      return "image/gif";
    if (t[0] === 82 && t[1] === 73 && t[2] === 70 && t[3] === 70 && t.length >= 12 && t[8] === 87 && t[9] === 69 && t[10] === 66 && t[11] === 80)
      return "image/webp";
  }
  try {
    if (new TextDecoder("utf-8").decode(t.slice(0, 256)).includes("<svg")) return "image/svg+xml";
  } catch {
  }
  return "application/octet-stream";
}
function Ne(t) {
  const e = Ae(t ?? ""), s = e.length, n = new Uint8Array(s);
  for (let r = 0; r < s; r++) n[r] = e.charCodeAt(r);
  return n;
}
function Oe(t) {
  const {
    value: e,
    onChange: s,
    onInput: n,
    ...r
  } = t, o = /* @__PURE__ */ new Map(), a = p.toSignal(e).map((f) => f.map((b, h) => {
    const d = o.get(b), x = Ne(b ?? ""), m = d?.type || Ue(x), $ = d?.name ?? `file-${h}`, v = x.buffer.slice(
      x.byteOffset,
      x.byteOffset + x.byteLength
    ), g = new Blob([v], { type: m });
    return new File([g], $, { type: m });
  })), u = (f) => (b) => {
    f && ze(b).then((h) => {
      for (const [d, x] of h.entries())
        o.set(x, { name: b[d].name, type: b[d].type });
      f(h);
    });
  }, l = u(s), c = u(n);
  return Ee({
    ...r,
    value: a,
    onChange: l,
    onInput: c
  });
}
function $n(t) {
  const {
    value: e,
    onInput: s,
    onChange: n,
    ...r
  } = t;
  return Oe({
    ...r,
    maxFiles: 1,
    value: p.map(e, (o) => o == null ? [] : [o]),
    onChange: (o) => {
      n?.(o[0]);
    },
    onInput: (o) => {
      s?.(o[0]);
    }
  });
}
function Pe(t, e) {
  const [s, n, r] = t, o = s << 16 ^ n << 8 ^ r, a = Ie(o), u = 6 + Math.floor(a() * 5), l = 0.18 + a() * 0.06, c = [];
  for (let d = 0; d < u; d++) {
    const x = d / u * Math.PI * 2, m = e * (1 + (a() * 2 - 1) * l), $ = Math.cos(x) * m, v = Math.sin(x) * m;
    c.push({ x: $, y: v });
  }
  const f = (c[0].x + c[u - 1].x) / 2, b = (c[0].y + c[u - 1].y) / 2;
  let h = `M ${f.toFixed(3)} ${b.toFixed(3)}`;
  for (let d = 0; d < u; d++) {
    const x = c[d], m = c[(d + 1) % u], $ = (x.x + m.x) / 2, v = (x.y + m.y) / 2;
    h += ` Q ${x.x.toFixed(3)} ${x.y.toFixed(3)} ${$.toFixed(3)} ${v.toFixed(3)}`;
  }
  return h += " Z", h;
}
const yn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, displayValue: o, size: a, withAlpha: u } = t, l = p.map(a ?? 32, (w) => w), c = p.map(e, (w) => $e(w ?? "#000000")), f = p.map(
    c,
    ([w, y, M]) => [w, y, M]
  ), b = p.map(c, ([, , , w]) => w), h = et(p.get(b) ?? 1), d = p.map(u ?? !1, (w) => w), x = p.map(
    t.colorTextFormat ?? "rgb",
    (w) => w
  ), m = L(
    f,
    h,
    x,
    d
  )(
    ([w, y, M], A, F, S) => lt(w, y, M, A ?? 1, ot(F, S), S)
  ), $ = p.map(
    t.colorTextFormat ?? "hex",
    (w) => w
  ), v = p.map(l, (w) => `${-w / 2} ${-w / 2} ${w} ${w}`), g = L(
    f,
    l
  )((w, y) => Pe(w, y / 2)), D = L(
    f,
    h,
    d
  )(
    ([w, y, M], A, F) => F || A < 1 ? ye(w, y, M, A) : Ct(w, y, M)
  ), I = C.div(
    i.class("bc-color-swatch-input__control"),
    i.class(
      p.map(
        d,
        (w) => w ? "bc-color-swatch-input__control--alpha" : ""
      )
    ),
    i.style(
      L(l)((w) => `min-width:${w + 2}px;height:${w + 2}px`)
    ),
    // The SVG blob preview
    At.svg(
      i.class("bc-color-swatch-input__svg"),
      gt.viewBox(v),
      At.path(gt.d(g), gt.fill(D))
    ),
    // Invisible native input overlays the blob for picker and accessibility
    C.input(
      i.type("color"),
      H(t),
      // Native color input needs hex without alpha
      i.value(p.map(f, ([w, y, M]) => Ct(w, y, M))),
      i.class(
        "bc-input bc-color-swatch-input bc-color-swatch-input__native"
      ),
      s != null ? k.blur(s) : T,
      n != null ? k.change((w) => {
        const y = w.target.value;
        if (!n) return;
        const { r: M, g: A, b: F } = it(y) ?? { r: 0, g: 0, b: 0 }, S = p.get(h) ?? 1, V = ot(
          p.get($),
          p.get(d)
        ), N = lt(M, A, F, S, V, p.get(d));
        n(N);
      }) : T,
      r != null ? k.input((w) => {
        const y = w.target.value;
        if (!r) return;
        const { r: M, g: A, b: F } = it(y) ?? { r: 0, g: 0, b: 0 }, S = p.get(h) ?? 1, V = ot(
          p.get($),
          p.get(d)
        ), N = lt(M, A, F, S, V, p.get(d));
        r(N);
      }) : T
    )
  ), _ = E(
    d,
    () => C.input(
      i.type("range"),
      i.class("bc-color-swatch-input__alpha"),
      i.min(0),
      i.max(1),
      i.step(0.01),
      i.value(p.map(h, (w) => String(w ?? 1))),
      i.disabled(t.disabled),
      k.input((w) => {
        const y = parseFloat(w.target.value);
        h.set(y);
        const [M, A, F] = p.get(f), S = ot(
          p.get($),
          p.get(d)
        ), V = lt(M, A, F, y, S, p.get(d));
        r?.(V);
      }),
      k.change((w) => {
        const y = parseFloat(w.target.value);
        h.set(y);
        const [M, A, F] = p.get(f), S = ot(
          p.get($),
          p.get(d)
        ), V = lt(M, A, F, y, S, p.get(d));
        n?.(V);
      })
    )
  );
  return P({
    baseContainer: !0,
    ...t,
    // ensure our control does not try to grow
    growInput: !1,
    input: I,
    // If caller provided an `after`, append RGB before it
    after: B(
      E(
        o ?? !1,
        () => C.span(i.class("bc-color-swatch-input__rgb"), m)
      ),
      _,
      t.after
    )
  });
}, Dt = "$$tts-exp-", je = (t, e) => ut((s) => {
  const n = `${Dt}${t}`;
  return z(p.on(e, (r) => Reflect.set(s, n, r)));
}), In = (t, e) => {
  const s = `${Dt}${t}`;
  return (n) => {
    e(Reflect.get(n.target, s));
  };
}, He = (t, e) => {
  const s = `${Dt}${t}`;
  return (n) => {
    const r = n.target, o = r.selectedIndex, a = r.options[o];
    e(Reflect.get(a, s));
  };
};
function We(t, e, s) {
  const n = ["bc-card"];
  return t !== "default" && n.push(`bc-card--${t}`), e !== "md" && n.push(`bc-card--padding-${e}`), s !== "lg" && n.push(`bc-card--rounded-${s}`), n.join(" ");
}
function Cn({ variant: t = "default", size: e = "md", roundedness: s = "lg" } = {}, ...n) {
  return C.div(
    i.class(
      L(
        t,
        e,
        s
      )(
        (r, o, a) => We(
          r ?? "default",
          o ?? "md",
          a ?? "lg"
        )
      )
    ),
    ...n
  );
}
function dt(...t) {
  return C.div(i.class("bc-group"), ...t);
}
const kn = ({
  startEditing: t,
  value: e,
  onChange: s,
  placeholder: n,
  disabled: r
}) => {
  const o = p.deriveProp(t ?? !1), a = et(!1), u = p.map(r ?? !1, (l) => l);
  return C.div(
    z(o, a, () => p.dispose(u)),
    i.class("bc-editable-text"),
    i.class(
      p.map(
        u,
        (l) => l ? "bc-editable-text--disabled" : ""
      )
    ),
    U.disabled(u),
    E(
      o,
      () => C.input(
        i.placeholder(n),
        i.value(e),
        i.class("bc-editable-text__input"),
        le(),
        k.keydown((l) => {
          l.key === "Enter" ? o.set(!1) : l.key === "Escape" && (a.set(!0), o.set(!1));
        }),
        k.blur(
          j((l) => {
            if (o.set(!1), a.value) {
              a.set(!1);
              return;
            }
            s(l);
          })
        )
      ),
      () => C.span(
        k.click(() => {
          p.get(u) || o.set(!0);
        }),
        i.class("bc-editable-text__display"),
        E(
          p.map(e, (l) => l != null && l.trim() !== ""),
          () => C.span(i.class("bc-editable-text__text"), e),
          () => C.span(
            i.class("bc-editable-text__placeholder"),
            n
          )
        ),
        E(
          p.map(u, (l) => !l),
          () => C.button(
            i.type("button"),
            i.class("bc-editable-text__edit-button"),
            W(X, (l) => U.label(l.$.editLabel)),
            k.click(() => o.set(!0)),
            O({ icon: "line-md/pencil", color: "neutral" })
          )
        )
      )
    )
  );
}, Yt = (t, e, s) => Kt(
  t,
  (n) => te(n, {
    value: (r) => {
      const o = L(
        r,
        s
      )((a, u) => e(a.value, u));
      return C.option(
        z(o.dispose),
        i.selected(o),
        je("value", r.$.value),
        r.$.label
      );
    },
    group: (r) => C.optgroup(
      i.label(r.$.group),
      mt(
        r.$.options,
        (o) => Yt(
          o,
          e,
          s
        )
      )
    ),
    break: () => C.hr()
  })
), Ze = (t) => {
  const {
    value: e,
    onBlur: s,
    onChange: n,
    options: r,
    unselectedLabel: o,
    equality: a = (c, f) => c === f,
    after: u
  } = t;
  let l;
  return P(
    {
      ...t,
      after: B(
        ce({
          icon: "ph:caret-down-bold",
          color: "neutral",
          size: "sm"
        }),
        u
      ),
      input: C.select(
        ut((c) => {
          l = c;
          const f = new MutationObserver((b) => {
            const { removedNodes: h } = b[0];
            h.length > 0 && (l.selectedIndex = 0);
          });
          return f.observe(c, { childList: !0 }), z(() => f.disconnect());
        }),
        H(t),
        i.class("bc-native-select bc-input"),
        W(
          X,
          (c) => C.option(
            i.hidden("hidden"),
            Jt(o, c.$.selectOne)
          )
        ),
        mt(r, (c) => Yt(c, a, e)),
        s != null ? k.blur(s) : T,
        n != null ? k.change(He("value", (c) => n(c))) : T
      )
    },
    k.click(() => {
      l?.focus(), typeof l?.showPicker == "function" && l.showPicker();
    })
  );
};
function Ye(t) {
  const { controller: e, onChange: s, onBlur: n, ...r } = t;
  return Ze({
    ...r,
    value: e.signal,
    onChange: me(e, s),
    onBlur: fe(e, n)
  });
}
function Mn(t) {
  return Ht({
    ...t,
    content: Ye(t)
  });
}
function Xe(t, e, s) {
  const n = t.length.map((r) => r);
  return B(
    z(() => n.dispose()),
    Pt(
      n,
      (r) => {
        const o = t.item(r.index), a = [];
        return B(
          z(() => {
            o.dispose(), a.forEach((u) => u());
          }),
          e({
            list: t,
            item: o,
            position: r,
            remove: () => t.removeAt(r.index),
            move: (u) => {
              switch (u) {
                case "up":
                  if (r.index === 0) return;
                  t.move(r.index, r.index - 1);
                  break;
                case "down":
                  if (r.index === t.length.value - 1) return;
                  t.move(r.index, r.index + 1);
                  break;
                case "first":
                  t.move(r.index, 0);
                  break;
                case "last":
                  t.move(r.index, t.length.value - 1);
              }
            },
            canMove: (u) => {
              const l = (() => {
                switch (u) {
                  case "up":
                    return Ft(r.index > 0);
                  case "down":
                    return t.length.map((c) => r.index < c - 1);
                }
              })();
              return a.push(() => l.dispose()), l;
            },
            cannotMove: (u) => {
              const l = (() => {
                switch (u) {
                  case "up":
                    return Ft(r.index === 0);
                  case "down":
                    return t.length.map((c) => r.index === c - 1);
                }
              })();
              return a.push(() => l.dispose()), l;
            }
          })
        );
      },
      s
    )
  );
}
const zt = {
  9: { pattern: /^[0-9]$/ },
  A: { pattern: /^[A-Za-z]$/, transform: (t) => t.toUpperCase() },
  "*": { pattern: /^.$/ }
}, qe = (t) => t instanceof RegExp;
function Xt(t, e, s) {
  if (t == null) return [];
  const n = s ? { ...zt, ...e } : e ?? zt, r = (a, u) => {
    const l = n[u];
    l ? a.push({ type: "pattern", name: u, ...l }) : a.push({ type: "literal", char: u });
  }, o = [];
  if (typeof t == "string") {
    for (const a of t) r(o, a);
    return o;
  }
  for (const a of t)
    if (typeof a == "string")
      if (a.length <= 1) r(o, a);
      else for (const u of a) r(o, u);
    else qe(a) ? o.push({ type: "pattern", pattern: a }) : typeof a == "object" && a && o.push(a);
  return o;
}
function Ge(t, e) {
  return (s) => {
    switch (t) {
      case "digits":
        return /[0-9]/.test(s);
      case "letters":
        return /[A-Za-z]/.test(s);
      case "alphanumeric":
        return /[A-Za-z0-9]/.test(s);
      case "custom":
        return e?.(s) ?? !0;
      default:
        return !0;
    }
  };
}
function Ut(t, e, s, n, r, o) {
  const a = {
    raw: t,
    previousConformed: e,
    cursor: r ?? t.length,
    completed: !1
  }, u = n.definitions ?? {}, l = typeof s == "function" ? s(t, a) : s, c = Xt(
    l,
    u,
    n.useDefaultDefinitions ?? !0
  ), f = Ge(n.allowMode, n.allow), b = /* @__PURE__ */ new Set();
  for (const S of c) S.type === "literal" && b.add(S.char);
  if (n.prefix) for (const S of n.prefix) b.add(S);
  if (n.suffix) for (const S of n.suffix) b.add(S);
  const h = Array.from(t).filter((S) => f(S) && !b.has(S));
  if (h.length === 0) return { value: "", cursor: 0, completed: !1 };
  const d = [], x = [];
  let m = 0, $ = 0, v = 0, g = -1;
  for (const S of c) {
    if (S.type === "literal") {
      d.push(S.char), x.push({ kind: "literal", filled: !0 });
      continue;
    }
    $ += S.optional ? 0 : 1;
    const V = h[m];
    if (V == null)
      break;
    if (S.type === "any") {
      v++, d.push(S.transform ? S.transform(V) : V), x.push({ kind: "slot", filled: !0 }), g = x.length - 1, m++;
      continue;
    }
    if (S.type === "pattern")
      if (S.pattern.test(V)) {
        v++;
        const N = S.transform ? S.transform(V) : V;
        d.push(N), x.push({ kind: "slot", filled: !0 }), g = x.length - 1, m++;
      } else {
        m++;
        continue;
      }
  }
  const D = d.join(""), I = (n.prefix ?? "") + D + (n.suffix ?? "");
  let w = (n.prefix ?? "").length;
  if (g >= 0) {
    let S = g + 1;
    if ((o?.policy ?? "smart") !== "sticky")
      for (; S < x.length && x[S].kind === "literal"; ) S++;
    w += S;
  }
  const y = n.completion?.mode === "min" ? (n.completion.minChars ?? 0) <= v : n.completion?.mode === "custom" ? !!n.completion.isComplete?.(I) : $ > 0 && v >= $, M = n.pipe?.(I, { ...a, completed: y });
  let A, F = w;
  return M === !1 ? (A = e, F = e.length) : typeof M == "string" ? (A = M, F = M.length) : typeof M == "object" && M ? (A = M.value, F = M.cursor ?? M.value.length) : A = I, { value: A, cursor: F, completed: y };
}
function Qe(t, e) {
  const s = e?.strategy ?? "none";
  return s === "custom" && e?.unmask ? e.unmask(t) : s === "strip" ? t.replace(/[^A-Za-z0-9]/g, "") : t;
}
const qt = (t) => {
  const {
    value: e,
    onBlur: s,
    onChange: n,
    onInput: r,
    onAccept: o,
    onComplete: a,
    mask: u,
    definitions: l,
    useDefaultDefinitions: c,
    extraLiterals: f,
    prefix: b,
    suffix: h,
    autofix: d,
    pipe: x,
    completion: m,
    unmask: $,
    allowMode: v,
    allow: g,
    placeholder: D,
    placeholderOptions: I
  } = t, _ = L(
    e,
    u,
    l,
    c,
    f,
    b,
    h,
    d,
    m,
    $,
    v,
    D,
    I
  )((y, M, A, F, S, V, N, st, rt, tt, Q, pt, q) => M ? Ut(y ?? "", "", M, {
    definitions: A ?? {},
    useDefaultDefinitions: F ?? !0,
    extraLiterals: S ?? [],
    autofix: st ?? "none",
    completion: rt ?? { mode: "mask" },
    pipe: x ?? ((R) => R),
    unmask: tt ?? { strategy: "none" },
    allowMode: Q ?? "all",
    allow: g,
    prefix: V,
    suffix: N
  }).value : y ?? ""), w = (y, M) => {
    const A = y.value ?? "", F = p.get(e) ?? "", S = u != null ? p.get(u) : null, V = l != null ? p.get(l) : void 0, N = c != null ? p.get(c) : void 0, st = f != null ? p.get(f) : void 0, rt = d != null ? p.get(d) : void 0, tt = m != null ? p.get(m) : void 0, Q = $ != null ? p.get($) : void 0, pt = v != null ? p.get(v) : void 0, q = b != null ? p.get(b) : void 0, R = h != null ? p.get(h) : void 0, {
      value: J,
      cursor: ht,
      completed: St
    } = S ? Ut(
      A,
      F,
      S,
      {
        definitions: V ?? {},
        useDefaultDefinitions: N ?? !0,
        extraLiterals: st ?? [],
        autofix: rt ?? "none",
        completion: tt ?? { mode: "mask" },
        pipe: x ?? ((Gt) => Gt),
        unmask: Q ?? { strategy: "none" },
        allowMode: pt ?? "all",
        allow: g,
        prefix: q,
        suffix: R
      },
      y.selectionStart ?? A.length,
      t.cursor ? p.get(t.cursor) : void 0
    ) : { value: A, cursor: A.length, completed: !0 };
    if (J !== A) {
      y.value = J;
      try {
        y.setSelectionRange(ht, ht);
      } catch {
      }
    }
    const Tt = Qe(J, Q);
    o?.({
      raw: Tt,
      conformed: J,
      completed: St,
      cursor: ht
    }), M === "input" ? r?.(J) : (n?.(J), St && a?.({ raw: Tt, conformed: J }));
  };
  return B(
    z(_),
    P({
      ...t,
      input: K.text(
        H(t),
        i.value(_),
        i.class("bc-input"),
        s != null ? k.blur(s) : T,
        ut(
          (y) => y instanceof HTMLInputElement ? B(
            k.input(() => w(y, "input")),
            k.change(() => w(y, "change")),
            k.keydown((M) => {
              if (M.key !== "Backspace" || !(t.cursor ? p.get(t.cursor)?.backspaceRubberBand ?? !0 : !0)) return;
              const F = y.selectionStart ?? 0, S = y.selectionEnd ?? F;
              if (F !== S || F <= 0) return;
              const V = y.value ?? "", N = u != null ? p.get(u) : null;
              if (!N) return;
              const st = l != null ? p.get(l) : void 0, rt = c != null ? p.get(c) : !0, tt = b != null ? p.get(b) : void 0, Q = h != null ? p.get(h) : void 0, pt = Xt(
                typeof N == "function" ? N(V, {
                  raw: V,
                  previousConformed: V,
                  cursor: F,
                  completed: !1
                }) : N,
                st ?? {},
                rt ?? !0
              ), q = /* @__PURE__ */ new Set();
              for (const R of pt)
                R.type === "literal" && q.add(R.char);
              if (tt) for (const R of tt) q.add(R);
              if (Q) for (const R of Q) q.add(R);
              if (q.has(V[F - 1])) {
                let R = F - 1;
                for (; R >= 0 && q.has(V[R]); ) R--;
                R >= 0 && (M.preventDefault(), M.stopPropagation(), y.value = V.slice(0, R) + V.slice(R + 1), w(y, "input"));
              }
            })
          ) : T
        )
      )
    })
  );
};
function Y(t, e, s) {
  const n = p.map(t, (o) => o != null), r = yt.clearValue;
  return B(
    z(() => p.dispose(n)),
    E(
      n,
      () => C.button(
        i.type("button"),
        i.class("bc-input-container__reset"),
        U.label(r),
        i.title(r),
        i.disabled(e ?? !1),
        O({ icon: "mdi:close", size: "sm" }),
        k.click((o) => {
          o.preventDefault(), o.stopPropagation(), s?.(null);
        })
      )
    )
  );
}
const Dn = (t) => {
  const { value: e, onBlur: s, onChange: n, after: r, disabled: o } = t, a = Y(e, o, n);
  return P({
    ...t,
    input: K.date(
      H(t),
      i.valueAsDate(e),
      i.class("bc-input"),
      s != null ? k.blur(j(s)) : T,
      n != null ? k.change(ee(n)) : T
    ),
    after: r != null ? B(a, r) : a
  });
}, Je = (t) => {
  const e = t.getFullYear(), s = t.getMonth() + 1, n = t.getDate(), r = t.getHours(), o = t.getMinutes(), a = t.getSeconds();
  return `${e}-${s.toString().padStart(2, "0")}-${n.toString().padStart(2, "0")}T${r.toString().padStart(2, "0")}:${o.toString().padStart(2, "0")}:${a.toString().padStart(2, "0")}`;
}, Sn = (t) => {
  const { value: e, onBlur: s, onChange: n, after: r, disabled: o } = t, a = p.map(e, (l) => l != null ? Je(l) : null), u = Y(e, o, n);
  return P({
    ...t,
    input: K["datetime-local"](
      H(t),
      i.value(p.map(a, (l) => l ?? null)),
      i.class("bc-input"),
      s != null ? k.blur(j(s)) : T,
      n != null ? k.change(ne(n)) : T
    ),
    after: r != null ? B(u, r) : u
  });
}, Z = (t) => typeof t == "string" && t.trim() === "" ? null : t, nt = (t) => t ?? "", Tn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: o, disabled: a, ...u } = t, l = Y(e, a, n);
  return ie({
    ...u,
    value: p.map(e, nt),
    onChange: n != null ? (c) => n(Z(c)) : void 0,
    onInput: r != null ? (c) => r(Z(c)) : void 0,
    onBlur: s,
    after: o != null ? B(l, o) : l
  });
}, An = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: o, disabled: a, ...u } = t, l = Y(e, a, n);
  return he({
    ...u,
    value: p.map(e, nt),
    onChange: n != null ? (c) => n(Z(c)) : void 0,
    onInput: r != null ? (c) => r(Z(c)) : void 0,
    onBlur: s,
    after: o != null ? B(l, o) : l
  });
}, Fn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: o, disabled: a, ...u } = t, l = Y(e, a, n);
  return ge({
    ...u,
    value: p.map(e, nt),
    onChange: n != null ? (c) => n(Z(c)) : void 0,
    onInput: r != null ? (c) => r(Z(c)) : void 0,
    onBlur: s,
    after: o != null ? B(l, o) : l
  });
}, Ke = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, rows: o } = t;
  return P({
    baseContainer: !0,
    ...t,
    input: C.textarea(
      i.class(
        L(t.size ?? "md")(
          (a) => ue(
            !1,
            a ?? "md"
          )
        )
      ),
      H(t),
      i.rows(o ?? 3),
      i.value(e),
      i.class("bc-input"),
      s != null ? k.blur(j(s)) : T,
      n != null ? k.change(j(n)) : T,
      r != null ? k.input(j(r)) : T
    )
  });
}, Bn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: o, disabled: a, ...u } = t, l = Y(e, a, n);
  return Ke({
    ...u,
    value: p.map(e, nt),
    onChange: n != null ? (c) => n(Z(c)) : void 0,
    onInput: r != null ? (c) => r(Z(c)) : void 0,
    onBlur: s,
    after: o != null ? B(l, o) : l
  });
}, Vn = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: o, onChange: a, onInput: u, after: l } = t, c = (h) => {
    const d = n != null ? p.get(n) : void 0, x = r != null ? p.get(r) : void 0;
    return d != null && h < d ? d : x != null && h > x ? x : h;
  }, f = s != null ? W(X, (h) => {
    const d = L(
      e,
      n
    )((v, g) => g == null ? !0 : (v ?? 0) > g), x = L(
      e,
      r
    )((v, g) => g == null ? !0 : (v ?? 0) < g), m = (v) => {
      const g = p.get(e) ?? 0, D = p.get(s), I = v?.shiftKey ? 10 : 1, _ = g - D * I, w = n != null ? p.get(n) : void 0;
      if (w != null && _ < w)
        return;
      const y = c(_);
      y !== g && a && a(y);
    }, $ = (v) => {
      const g = p.get(e) ?? 0, D = p.get(s), I = v?.shiftKey ? 10 : 1, _ = g + D * I, w = r != null ? p.get(r) : void 0;
      if (w != null && _ > w)
        return;
      const y = c(_);
      y !== g && a && a(y);
    };
    return ct(
      i.class("bc-number-input-steppers"),
      // Increment second
      C.button(
        i.type("button"),
        i.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
        ),
        i.disabled(
          L(
            x,
            t.disabled ?? !1
          )((v, g) => !v || g)
        ),
        k.click((v) => $(v)),
        U.label(h.$.incrementValue),
        O({ icon: "line-md:plus", size: "xs" })
      ),
      // Decrement first (matches tests expecting first button to be decrement)
      C.button(
        i.type("button"),
        i.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
        ),
        i.disabled(
          L(
            d,
            t.disabled ?? !1
          )((v, g) => !v || g)
        ),
        k.click((v) => m(v)),
        U.label(h.$.decrementValue),
        O({ icon: "line-md:minus", size: "xs" })
      )
    );
  }) : null, b = l != null && f != null ? B(f, l) : l ?? f;
  return P({
    ...t,
    input: K.number(
      n != null ? B(
        i.min(n),
        z(
          p.on(n, (h) => {
            h < p.get(e);
          })
        )
      ) : T,
      r != null ? B(
        i.max(r),
        z(
          p.on(r, (h) => {
            h > p.get(e);
          })
        )
      ) : T,
      H(t),
      i.valueAsNumber(e),
      i.step(s),
      i.class("bc-input bc-number-input"),
      o != null ? k.blur(j(o)) : T,
      a != null ? k.change(G(a)) : T,
      u != null ? k.input(G(u)) : T,
      // Add wheel event support when step is defined
      s != null ? k.wheel((h) => {
        h.preventDefault();
        const d = p.get(e) ?? 0, x = p.get(s), m = h.shiftKey ? 10 : 1, $ = h.deltaY < 0 ? x * m : -x * m, v = c(d + $);
        v !== d && a && a(v);
      }) : T
    ),
    after: b
  });
}, Nt = (t) => {
  if (t == null || t === "") return null;
  const e = Number(t);
  return Number.isNaN(e) ? null : e;
}, Ln = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: o, onChange: a, onInput: u, after: l } = t, c = (d) => {
    const x = n != null ? p.get(n) : void 0, m = r != null ? p.get(r) : void 0;
    return x != null && d < x ? x : m != null && d > m ? m : d;
  }, f = (() => {
    if (s == null) return null;
    const d = L(
      e,
      n
    )((g, D) => {
      const I = g ?? 0;
      return D == null ? !0 : I > D;
    }), x = L(
      e,
      r
    )((g, D) => {
      const I = g ?? 0;
      return D == null ? !0 : I < D;
    }), m = (g) => {
      const D = p.get(e) ?? 0, I = p.get(s), _ = g?.shiftKey ? 10 : 1, w = D - I * _, y = n != null ? p.get(n) : void 0;
      if (y != null && w < y) return;
      const M = c(w);
      M !== D && a && a(M);
    }, $ = (g) => {
      const D = p.get(e) ?? 0, I = p.get(s), _ = g?.shiftKey ? 10 : 1, w = D + I * _, y = r != null ? p.get(r) : void 0;
      if (y != null && w > y) return;
      const M = c(w);
      M !== D && a && a(M);
    };
    return ((g, D) => ct(
      i.class("bc-number-input-steppers"),
      C.button(
        i.type("button"),
        i.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
        ),
        i.disabled(
          L(
            x,
            t.disabled ?? !1
          )((I, _) => !I || _)
        ),
        k.click((I) => $(I)),
        U.label(g),
        O({ icon: "line-md:plus", size: "xs" })
      ),
      C.button(
        i.type("button"),
        i.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
        ),
        i.disabled(
          L(
            d,
            t.disabled ?? !1
          )((I, _) => !I || _)
        ),
        k.click((I) => m(I)),
        U.label(D),
        O({ icon: "line-md:minus", size: "xs" })
      )
    ))(
      yt.incrementValue,
      yt.decrementValue
    );
  })(), b = Y(e, t.disabled, a), h = l != null && f != null ? B(f, b, l) : l != null ? B(b, l) : f != null ? B(f, b) : b;
  return P({
    ...t,
    input: K.number(
      // min/max attributes and reactive watchers (no forced correction)
      n != null ? B(
        i.min(n),
        z(
          p.on(n, (d) => {
          })
        )
      ) : T,
      r != null ? B(
        i.max(r),
        z(
          p.on(r, (d) => {
          })
        )
      ) : T,
      H(t),
      // Represent null as empty string so the field can be cleared
      i.value(p.map(e, (d) => d == null ? "" : String(d))),
      i.step(s),
      i.class("bc-input bc-number-input"),
      o != null ? k.blur(j(o)) : T,
      a != null ? k.change(
        j((d) => {
          const x = Nt(d);
          a(x);
        })
      ) : T,
      u != null ? k.input(
        j((d) => {
          const x = Nt(d);
          u(x);
        })
      ) : T,
      // Wheel support when step is defined
      s != null ? k.wheel((d) => {
        d.preventDefault();
        const x = p.get(e) ?? 0, m = p.get(s), $ = d.shiftKey ? 10 : 1, v = d.deltaY < 0 ? m * $ : -m * $, g = c(x + v);
        g !== x && a && a(g);
      }) : T
    ),
    after: h
  });
}, En = ({
  value: t,
  onChange: e,
  onInput: s,
  onBlur: n,
  offLabel: r,
  onLabel: o,
  disabled: a = !1,
  size: u = "md",
  id: l,
  color: c = "primary"
}) => {
  const f = l ?? be("switch");
  function b(m, $) {
    const v = [
      "bc-switch",
      `bc-switch--size-${$}`,
      `bc-switch--${$}`
    ];
    return m && v.push("bc-switch--disabled"), v.join(" ");
  }
  function h(m) {
    const $ = m ?? "primary", v = /* @__PURE__ */ new Map(), g = Vt($, "solid", "light"), D = Vt($, "solid", "dark");
    return v.set("--switch-track-on-bg", g.backgroundColor), v.set("--switch-track-on-label", g.textColor), v.set("--switch-track-on-bg-dark", D.backgroundColor), v.set("--switch-track-on-label-dark", D.textColor), v.set(
      "--switch-track-on-border-dark",
      de($, "dark")
    ), Array.from(v.entries()).map(([I, _]) => `${I}: ${_}`).join("; ");
  }
  const d = () => {
    p.get(a) || (e?.(!p.get(t)), s?.(!p.get(t)));
  }, x = (m) => {
    p.get(a) || (m.key === " " || m.key === "Enter") && (m.preventDefault(), d());
  };
  return C.div(
    i.class(
      L(
        a ?? !1,
        u
      )(
        (m, $) => b(m ?? !1, $ ?? "md")
      )
    ),
    i.style(
      L(c)(
        (m) => h(m)
      )
    ),
    i.id(f),
    i.role("switch"),
    i.tabindex(
      p.map(a, (m) => m ? -1 : 0)
    ),
    U.checked(t),
    U.disabled(a),
    k.click(d),
    k.keydown(x),
    n != null ? k.blur(n) : null,
    C.div(
      i.class("bc-switch__track"),
      i.class(
        p.map(
          t,
          (m) => m ? "bc-switch__track--on" : "bc-switch__track--off"
        )
      ),
      r != null ? C.div(
        U.hidden(!0),
        i.class("bc-switch__track-label bc-switch__track-label--off"),
        i.class(
          p.map(
            t,
            (m) => m ? "bc-switch__track-label--hidden" : "bc-switch__track-label--visible"
          )
        ),
        r
      ) : null,
      o != null ? C.div(
        i.class("bc-switch__track-label bc-switch__track-label--on"),
        i.class(
          p.map(
            t,
            (m) => m ? "bc-switch__track-label--visible" : "bc-switch__track-label--hidden"
          )
        ),
        o
      ) : null,
      jt(
        (m) => W(
          pe,
          ({ direction: $ }) => C.div(
            i.class("bc-switch__thumb"),
            i.class(
              p.map(
                t,
                (v) => v ? "bc-switch__thumb--on" : "bc-switch__thumb--off"
              )
            ),
            ft.transform(
              L(
                t,
                m,
                u,
                $
              )((v, { width: g }, D, I) => {
                const _ = (() => {
                  switch (D) {
                    case "xs":
                      return 5;
                    case "sm":
                      return 5.5;
                    case "md":
                      return 6;
                    case "lg":
                      return 7;
                    case "xl":
                      return 8;
                  }
                })(), w = I === "rtl" ? `calc((var(--spacing-base) * ${_}) - ${g}px)` : `calc(${g}px - (var(--spacing-base) * ${_}))`;
                return v ? `translateX(${w})` : "translateX(0)";
              })
            )
          )
        )
      )
    )
  );
}, tn = (t) => {
  const e = {
    type: "pattern",
    pattern: /[0-9A-Fa-f]/,
    transform: (n) => n.toLowerCase()
  };
  return qt({
    ...t,
    mask: [
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e
    ],
    // Sensible default placeholder; can be overridden via options.placeholder
    placeholder: t.placeholder ?? "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  });
}, Rn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: o, disabled: a, ...u } = t, l = Y(e, a, n);
  return tn({
    ...u,
    value: p.map(e, nt),
    onChange: n != null ? (c) => n(Z(c)) : void 0,
    onInput: r != null ? (c) => r(Z(c)) : void 0,
    onBlur: s,
    after: o != null ? B(l, o) : l
  });
}, en = "line-md:star-alt-filled", nn = "line-md:star-alt", sn = (t) => {
  const {
    value: e,
    onChange: s,
    disabled: n,
    max: r = 5,
    fullColor: o = "yellow",
    emptyColor: a = "neutral",
    fullIcon: u = en,
    emptyIcon: l = nn,
    size: c = "md",
    onBlur: f,
    rounding: b = 1
  } = t, h = () => {
    const g = p.get(b);
    return g > 0 ? g : 1;
  }, d = (g) => Math.min(Math.max(g, 0), p.get(r)), x = (g, D) => {
    if (p.get(n ?? !1)) return;
    const _ = g.currentTarget.getBoundingClientRect(), w = (g.clientX - _.left) / _.width, y = D - 1 + w, M = h(), A = Math.ceil(y / M) * M, F = d(A);
    s?.(F);
  }, m = (g) => {
    if (p.get(n ?? !1)) return;
    const D = h(), I = p.get(e) ?? 0;
    let _;
    switch (g.key) {
      case "ArrowRight":
      case "ArrowUp":
        _ = d(I + D);
        break;
      case "ArrowLeft":
      case "ArrowDown":
        _ = d(I - D);
        break;
      case "Home":
        _ = 0;
        break;
      case "End":
        _ = p.get(r);
        break;
      default:
        return;
    }
    g.preventDefault(), s?.(_);
  }, $ = p.map(c, (g) => `bc-icon--${g}`), v = ({ index: g, counter: D }) => C.span(
    i.class("bc-rating-input__icon-container"),
    i.class($),
    O(
      { icon: l, size: c, color: a, tone: "soft" },
      i.class("bc-rating-input__icon-empty")
    ),
    C.span(
      i.class("bc-rating-input__icon-clipper"),
      i.class($),
      ft.width(
        p.map(e, (I) => {
          const _ = Math.floor(I);
          return _ > g ? "100%" : _ < g ? "0%" : `${(I - g) * 100}%`;
        })
      ),
      O(
        { icon: u, size: c, color: o, tone: "soft" },
        i.class("bc-rating-input__icon-full")
      )
    ),
    k.click(
      se((I) => x(I, D), {
        preventDefault: !0,
        stopPropagation: !0
      })
    )
  );
  return P({
    baseContainer: !0,
    growInput: !1,
    focusableSelector: '[role="slider"]',
    ...t,
    input: C.div(
      // Common input attributes (id, required, invalid, custom classes, etc.)
      H(t),
      i.class("bc-rating-input"),
      // ARIA slider semantics
      i.role("slider"),
      i.tabindex(p.map(n ?? !1, (g) => g ? -1 : 0)),
      U.disabled(n ?? !1),
      U.valuemin(0),
      U.valuemax(p.map(r, (g) => g ?? 0)),
      U.valuenow(p.map(e, (g) => g ?? 0)),
      U.valuetext(
        L(
          e,
          r
        )((g, D) => {
          const I = g ?? 0, _ = D ?? 0;
          return `${String(I)} / ${String(_)}`;
        })
      ),
      // Keyboard & focus handlers
      k.keydown(m),
      f != null ? k.blur(f) : null,
      Pt(r, v)
    )
  });
}, zn = (t) => {
  const { value: e, onChange: s, onBlur: n, after: r, disabled: o, ...a } = t, u = Y(e, o, s);
  return sn({
    ...a,
    // Map null -> 0 for display so the control shows as empty when null
    value: p.map(e, (l) => l ?? 0),
    // Pass through numeric changes; clear button will call onChange(null)
    onChange: s,
    onBlur: n,
    after: r != null ? B(u, r) : u
  });
}, Un = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: o, onChange: a, onInput: u } = t;
  return P({
    ...t,
    // Make sure clicks anywhere focus the range input
    focusableSelector: 'input[type="range"]',
    input: C.input(
      i.type("range"),
      H(t),
      i.min(n),
      i.max(r),
      i.step(s),
      // Using value as number to keep it in sync
      i.valueAsNumber(e),
      i.class("bc-input bc-slider-input"),
      o != null ? k.blur(G(o)) : T,
      a != null ? k.change(G(a)) : T,
      u != null ? k.input(G(u)) : T
    )
  });
}, Nn = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: o, onChange: a, onInput: u } = t, l = p.map(e, (f) => {
    if (f != null) return f;
    const b = n != null ? p.get(n) : void 0;
    return typeof b == "number" ? b : 0;
  }), c = Y(e, t.disabled, (f) => {
    a?.(f);
  });
  return P(
    {
      ...t,
      focusableSelector: 'input[type="range"]',
      after: c,
      input: C.input(
        i.type("range"),
        H(t),
        i.min(n),
        i.max(r),
        i.step(s),
        i.valueAsNumber(l),
        i.class("bc-input bc-slider-input"),
        o != null ? k.blur(G(o)) : T,
        a != null ? k.change(
          G((f) => {
            a(f);
          })
        ) : T,
        u != null ? k.input(
          G((f) => {
            u(f);
          })
        ) : T
      )
    },
    // Ensure container grows input naturally
    B()
  );
};
let _t = null;
async function Mt() {
  const t = globalThis;
  return t.Temporal ? t.Temporal : (_t || (_t = import("./index.esm-DPNh6inz.js").then((e) => {
    const s = e.Temporal;
    return t.Temporal || (t.Temporal = s), s;
  })), _t);
}
const rn = (t, e) => e ? Bt(Mt, {
  then: t,
  pending: e.pending,
  error: e.error
}) : Bt(Mt, t), an = /^P(\d+([YMWD]|$)){0,4}(T(\d+([HMS]|$)){0,3})?$/i, ln = /^P(?:(\d+Y)?(\d+M)?(\d+W)?(\d+D)?)(T(\d+H)?(\d+M)?(\d+S)?)?$/i;
function on(t) {
  return {
    mask: null,
    allowMode: "custom",
    allow: (e) => /[0-9ptwdhms]/i.test(e),
    pipe: (e) => {
      const s = e.toUpperCase();
      return s.length === 0 ? s : !s.startsWith("P") || !an.test(s) ? !1 : s;
    },
    completion: {
      mode: "custom",
      isComplete: (e) => {
        const s = e.toUpperCase();
        if (!ln.test(s)) return !1;
        try {
          return t(s), !0;
        } catch {
          return !1;
        }
      }
    }
  };
}
const Ot = (t, e) => {
  if (t == null) return null;
  try {
    return t.Duration.from(e);
  } catch {
    return null;
  }
}, On = (t) => {
  const { value: e, onChange: s, after: n, disabled: r, onBlur: o } = t, a = () => {
    const c = Y(e, r, s);
    return n != null ? B(c, n) : c;
  }, u = t.placeholder != null ? T : i.placeholder("P0DT0H0M0S");
  return rn(
    (c) => qt({
      ...t,
      value: p.map(e, (f) => f?.toString() ?? ""),
      onChange: s ? (f) => s(f === "" ? null : c.Duration.from(f)) : void 0,
      onInput: void 0,
      ...on(c.Duration.from),
      placeholder: "P0DT0H0M0S",
      after: a()
    }),
    { pending: () => P({
      ...t,
      input: K.text(
        H(t),
        i.value(p.map(e, (c) => c?.toString() ?? "")),
        i.class("bc-input"),
        u,
        o != null ? k.blur(() => o()) : T,
        s != null ? k.change((c) => {
          const b = c.currentTarget?.value ?? "";
          if (b === "") {
            s(null);
            return;
          }
          const h = globalThis.Temporal, d = Ot(h, b);
          if (d != null) {
            s(d);
            return;
          }
          Mt().then((x) => {
            const m = Ot(x, b);
            m != null && s(m);
          }).catch(() => {
          });
        }) : T
      ),
      after: a()
    }) }
  );
}, cn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r } = t;
  return P({
    ...t,
    input: K.url(
      H(t),
      i.value(e),
      i.class("bc-input"),
      s != null ? k.blur(j(s)) : T,
      n != null ? k.change(j(n)) : T,
      r != null ? k.input(j(r)) : T
    )
  });
}, Pn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: o, disabled: a, ...u } = t, l = Y(e, a, n);
  return cn({
    ...u,
    value: p.map(e, nt),
    onChange: n != null ? (c) => n(Z(c)) : void 0,
    onInput: r != null ? (c) => r(Z(c)) : void 0,
    onBlur: s,
    after: o != null ? B(l, o) : l
  });
}, un = (t) => {
  const {
    controller: e,
    element: s,
    separator: n,
    showMove: r = !0,
    showRemove: o = !0,
    showAdd: a = !0,
    createItem: u,
    addLabel: l,
    controlsLayout: c = "aside",
    removeDisabled: f,
    addDisabled: b
  } = t, h = p.toSignal(c).map((m) => m === "aside"), d = (m) => {
    const $ = E(
      r ?? !1,
      () => C.div(
        i.class("bc-group--align-center"),
        i.class(
          h.map(
            (g) => g ? "bc-group--direction-column bc-group--gap-1" : "bc-group--direction-row bc-group--gap-1"
          )
        ),
        bt(
          {
            size: "xs",
            roundedness: "full",
            variant: "text",
            onClick: () => m.move("up"),
            disabled: m.cannotMove("up")
          },
          W(
            X,
            (g) => O({
              size: "xs",
              icon: "line-md:arrow-up",
              title: g.$.incrementValue
            })
          )
        ),
        bt(
          {
            size: "xs",
            roundedness: "full",
            variant: "text",
            onClick: () => m.move("down"),
            disabled: m.cannotMove("down")
          },
          W(
            X,
            (g) => O({
              size: "xs",
              icon: "line-md:arrow-down",
              title: g.$.decrementValue
            })
          )
        )
      )
    ), v = E(
      o,
      () => W(
        X,
        (g) => It({
          size: "xs",
          // Use a lowercase label to satisfy tests that query with [aria-label*="remove"]
          label: p.map(g.$.removeItem, (D) => D.toLowerCase()),
          color: "danger",
          disabled: f,
          onClick: m.remove
        })
      )
    );
    return (g) => E(
      h,
      () => dt(
        i.class("bc-group--gap-1 bc-group--align-center"),
        ct(i.class("bc-stack--grow"), g),
        ct(
          i.class("bc-stack--align-center"),
          E(
            e.signal.map((D) => D.length > 1),
            () => $
          ),
          v
        )
      ),
      () => ct(
        i.class("bc-stack--gap-2"),
        g,
        dt(
          i.class("bc-group--gap-2 bc-group--justify-between"),
          E(
            e.signal.map((D) => D.length > 1),
            () => $,
            () => C.div()
          ),
          v
        )
      )
    );
  }, x = E(
    L(a, u)((m, $) => m && $ != null),
    () => dt(
      i.class(
        "bc-group--gap-2 bc-group--align-center bc-group--justify-center"
      ),
      bt(
        {
          size: "sm",
          variant: "filled",
          onClick: () => e.push(u()),
          disabled: L(
            e.disabled,
            b ?? !1
          )(
            (m, $) => m || $
          )
        },
        W(
          X,
          (m) => dt(
            i.class("bc-group--gap-2"),
            O({ icon: "line-md:plus" }),
            l ?? m.$.addLabel
          )
        )
      )
    )
  );
  return B(
    Xe(
      e,
      (m) => d(m)(s(m)),
      n
    ),
    x
  );
}, jn = (t, ...e) => {
  const {
    controller: s,
    element: n,
    separator: r,
    showMove: o,
    showRemove: a,
    showAdd: u,
    createItem: l,
    addLabel: c,
    controlsLayout: f,
    removeDisabled: b,
    addDisabled: h,
    ...d
  } = t;
  return Ht(
    {
      ...d,
      content: un({
        controller: s,
        element: n,
        separator: r,
        showMove: o,
        showRemove: a,
        showAdd: u,
        createItem: l,
        addLabel: c,
        controlsLayout: f,
        removeDisabled: b,
        addDisabled: h
      })
    },
    ...e
  );
};
class Hn extends vt {
  branches;
  activeBranch;
  #e;
  #t = /* @__PURE__ */ new Map();
  constructor(e, s, n, r, o, a, u = at) {
    super(e, s, n, r, o, u), this.branches = a;
    const l = (f) => {
      for (const b of a)
        if (b.detect(f))
          return b.key;
      return a[0]?.key ?? "unknown";
    };
    this.activeBranch = n.map(l, at);
    const c = (f) => {
      if (this.#t.has(f))
        return this.#t.get(f);
      const b = a.find((d) => d.key === f);
      if (!b)
        throw new Error(`Unknown branch: ${f}`);
      const h = new vt(
        [...e, f],
        (d) => {
          this.change(d);
        },
        this.signal.map(
          (d) => b.detect(d) ? d : b.defaultValue(),
          u
        ),
        r.map(Lt([f])),
        {
          disabled: this.disabled,
          validationMode: this.parent.validationMode
        },
        u
      );
      return this.#t.set(f, h), h;
    };
    this.#e = this.activeBranch.map(
      (f) => c(f),
      at
    ), this.onDispose(() => {
      for (const f of this.#t.values())
        f.dispose();
      this.#t.clear(), this.activeBranch.dispose(), this.#e.dispose();
    });
  }
  /**
   * Get the controller for the currently active branch
   */
  get activeController() {
    return p.get(this.#e);
  }
  /**
   * Get a controller for a specific branch
   */
  getBranchController(e) {
    const s = this.branches.find((r) => r.key === e);
    if (!s)
      throw new Error(`Unknown branch: ${e}`);
    if (this.#t.has(e))
      return this.#t.get(e);
    const n = new vt(
      [...this.path, e],
      (r) => {
        this.change(r);
      },
      this.signal.map(
        (r) => s.detect(r) ? r : s.defaultValue(),
        at
      ),
      this.status.map(Lt([e])),
      {
        disabled: this.disabled,
        validationMode: this.parent.validationMode
      },
      at
    );
    return this.#t.set(e, n), n;
  }
  /**
   * Switch to a different branch
   */
  switchToBranch(e, s = !1) {
    const n = this.branches.find((a) => a.key === e);
    if (!n)
      throw new Error(`Unknown branch: ${e}`);
    const r = p.get(this.signal);
    if (n.detect(r))
      return !0;
    if (n.convert) {
      const a = n.convert(r);
      if (a.ok)
        return this.change(a.value), !0;
    }
    if (s && typeof window == "object" && typeof window.confirm == "function" && !window.confirm(
      "Changing type will clear the current value. Continue?"
    ))
      return !1;
    const o = n.defaultValue();
    return this.change(o), !0;
  }
  /**
   * Get the current active branch definition
   */
  get activeBranchDefinition() {
    const e = p.get(this.activeBranch);
    return this.branches.find((s) => s.key === e);
  }
}
function Wn(t) {
  return t.transform(
    (e) => e ?? null,
    (e) => e ?? void 0
  );
}
function Zn(t) {
  return t.transform(
    (e) => e ?? "",
    (e) => e === "" ? void 0 : e
  );
}
function Yn(t) {
  return t.transform(
    (e) => e ?? void 0,
    (e) => e ?? null
  );
}
export {
  we as $,
  En as A,
  un as B,
  yn as C,
  tn as D,
  je as E,
  Ee as F,
  dt as G,
  Rn as H,
  zn as I,
  Un as J,
  Nn as K,
  jn as L,
  qt as M,
  Ze as N,
  On as O,
  cn as P,
  Pn as Q,
  sn as R,
  _n as S,
  Ke as T,
  Et as U,
  Cn as V,
  rn as W,
  In as X,
  He as Y,
  ve as Z,
  xe as _,
  Y as a,
  Ct as a0,
  it as a1,
  vn as a2,
  $e as a3,
  ye as a4,
  Ie as a5,
  Zt as a6,
  Ce as a7,
  kt as a8,
  ke as a9,
  xt as aa,
  wt as ab,
  Me as ac,
  De as ad,
  lt as ae,
  ot as af,
  Mt as ag,
  wn as ah,
  xn as ai,
  Wt as b,
  _e as c,
  on as d,
  Z as e,
  Hn as f,
  Zn as g,
  Yn as h,
  bn as i,
  $n as j,
  Re as k,
  Oe as l,
  kn as m,
  nt as n,
  Xe as o,
  Ye as p,
  Mn as q,
  Dn as r,
  Sn as s,
  Wn as t,
  An as u,
  Fn as v,
  Bn as w,
  Tn as x,
  Vn as y,
  Ln as z
};
