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