import { makeProviderMark as B, localStorageProp as w, computedOf as p, Use as T, html as g, attr as u, When as b, Fragment as v, aria as f, coalesce as M, style as P, prop as x } from "@tempots/dom";
import { WhenInViewport as N, Query as R } from "@tempots/ui";
import { b as $, c as V } from "./colors-BmLYKmoH.js";
function O(e, {
  units: t = ["B", "KB", "MB", "GB", "TB"],
  decimalPlaces: o = 0,
  locale: a
} = {}) {
  if (e === 0 || e === 0n)
    return new Intl.NumberFormat(a, {
      style: "unit",
      unit: "byte",
      unitDisplay: "short",
      maximumFractionDigits: 0
    }).format(0).replace("byte", t[0]);
  let n, r;
  if (typeof e == "bigint") {
    let l = e < 0n ? -e : e;
    for (n = 0; l >= 1024n && n < t.length - 1; )
      l = l / 1024n, n++;
    r = Number(e) / Math.pow(1024, n);
  } else
    n = Math.floor(Math.log(Math.abs(e)) / Math.log(1024)), n = Math.min(n, t.length - 1), r = e / Math.pow(1024, n);
  return new Intl.NumberFormat(a, {
    style: "unit",
    unit: "byte",
    unitDisplay: "short",
    minimumFractionDigits: n === 0 ? 0 : o,
    maximumFractionDigits: n === 0 ? 0 : o
  }).format(r).replace("byte", t[n]);
}
const U = {
  loadingExtended: "Loading, please wait",
  loadingShort: "Loading...",
  locale: "Locale",
  iconDescription: "Icon",
  loadingIcon: "Loading icon",
  failedToLoadIcon: "Failed to load icon",
  editLabel: "Edit",
  selectOne: "Select one",
  selectNone: "None",
  selectMany: "Select many",
  noResults: "No results",
  passwordPlaceholderText: "Secret Password",
  togglePasswordVisibility: "Toggle password visibility",
  toggleMenu: "Toggle menu",
  toggleAside: "Toggle aside",
  mainNavigation: "Main navigation",
  sidebar: "Sidebar",
  closeDrawer: "Close drawer",
  closeModal: "Close modal",
  confirm: "Confirm",
  cancel: "Cancel",
  addLabel: "Add",
  removeItem: "Remove item",
  // languages
  currentLocale: "English",
  ar: "Arabic",
  de: "German",
  en: "English",
  es: "Spanish",
  fr: "French",
  hi: "Hindi",
  it: "Italian",
  ja: "Japanese",
  ko: "Korean",
  nl: "Dutch",
  pl: "Polish",
  pt: "Portuguese",
  ru: "Russian",
  tr: "Turkish",
  vi: "Vietnamese",
  zh: "Chinese",
  he: "Hebrew",
  fa: "Persian",
  ur: "Urdu",
  // input
  emailPlaceholderText: "Enter your email",
  incrementValue: "Increment value",
  decrementValue: "Decrement value",
  // drop zone
  dropZoneInstructions: (e) => e ? "Click to choose or drag files here, or press Enter or Space to open file selector" : "Drag files here",
  // size
  fileSizeUnits: ["Bytes", "KB", "MB", "GB", "TB"],
  // file input
  removeFile: "Remove file",
  clearAllFiles: "Clear all files",
  // inputs reset
  clearValue: "Reset",
  unknownType: "Unknown type",
  filesInputInstructions: (e, t, o) => {
    let a = e == null || e > 1 ? "Click to choose or drag files here" : "Click to choose or drag a file here";
    if (e || t) {
      const n = [];
      if (e != null && e > 1 && n.push(`up to ${e} files`), t && o) {
        const r = O(t, {
          units: o
        });
        n.push(`max ${r} each`);
      }
      n.length > 0 && (a += ` (${n.join(", ")})`);
    }
    return a;
  },
  // Pagination
  paginationLabel: "Pagination",
  firstPage: "First page",
  previousPage: "Previous page",
  nextPage: "Next page",
  lastPage: "Last page",
  // Breadcrumbs
  breadcrumbs: "Breadcrumbs",
  // Command palette
  commandPalette: "Command palette",
  typeACommand: "Type a command...",
  noResultsFound: "No results found",
  noMatchingCommands: "No matching commands",
  // Appearance
  appearanceSystem: "System",
  appearanceLight: "Light",
  appearanceDark: "Dark",
  // Dialogs
  ok: "OK",
  changeTypeConfirmation: "Changing type will clear the current value. Continue?",
  // Notifications
  notifications: "Notifications",
  markAllAsRead: "Mark all as read",
  noNotifications: "No notifications",
  // JSON Schema
  schemaConflictsDetected: "Schema Conflicts Detected",
  schemaViolationsDetected: "Schema Violations Detected",
  properties: "Properties",
  // File upload
  uploading: "Uploading...",
  dropFilesOrBrowse: "Drop files here or click to browse",
  acceptedTypes: (e) => `Accepted types: ${e}`,
  // Rich text
  enterUrlPrompt: "Enter URL:",
  exceeded: "(exceeded)",
  // PDF
  pdfPreview: "PDF Preview",
  // Lexical editor
  lexical: {
    fontFamily: "Font Family",
    fontSize: "Font Size",
    fontColor: "Font Color",
    highlightColor: "Highlight Color",
    backgroundColor: "Background Color",
    bold: "Bold",
    italic: "Italic",
    underline: "Underline",
    strikethrough: "Strikethrough",
    code: "Code",
    clearFormatting: "Clear Formatting",
    normal: "Normal",
    heading: (e) => `Heading ${e}`,
    bulletList: "Bullet List",
    orderedList: "Ordered List",
    checkList: "Check List",
    indent: "Indent",
    outdent: "Outdent",
    blockquote: "Blockquote",
    codeBlock: "Code Block",
    horizontalRule: "Horizontal Rule",
    insertTable: "Insert Table",
    link: "Link",
    undo: "Undo",
    redo: "Redo",
    cut: "Cut",
    copy: "Copy",
    paste: "Paste",
    defaultOption: "Default",
    slashCommands: "Slash commands",
    noCommandsFound: "No commands found",
    changeBlockType: "Change block type",
    blockTypes: "Block types",
    enterUrl: "Enter URL:"
  },
  // ProseMirror editor
  prosemirror: {
    bold: "Bold",
    italic: "Italic",
    code: "Inline code",
    link: "Insert link",
    removeLink: "Remove link",
    heading: (e) => `Heading ${e}`,
    bulletList: "Bullet list",
    orderedList: "Ordered list",
    blockquote: "Blockquote",
    codeBlock: "Code block",
    horizontalRule: "Horizontal rule",
    linkUrlPlaceholder: "https://example.com"
  },
  // PDF Page Viewer
  pdfPageViewer: {
    loading: "Loading PDF...",
    loadFailed: "Failed to load PDF",
    invalidPdf: "Invalid PDF file",
    pageOutOfRange: (e, t) => `Page ${e} is out of range (1-${t})`,
    renderFailed: "Failed to render PDF page"
  }
}, C = U, I = "en", j = /* @__PURE__ */ new Set([
  "ar",
  // Arabic
  "he",
  // Hebrew
  "fa",
  // Persian/Farsi
  "ur",
  // Urdu
  "ps",
  // Pashto
  "sd",
  // Sindhi
  "ku",
  // Kurdish
  "dv",
  // Divehi/Maldivian
  "yi",
  // Yiddish
  "ji",
  // Yiddish (alternative code)
  "iw",
  // Hebrew (deprecated, but still used)
  "in"
  // Indonesian (deprecated, but sometimes confused)
]);
function D(e) {
  if (!e) return "ltr";
  const t = e.split(/[-_]/)[0].toLowerCase();
  return j.has(t) ? "rtl" : "ltr";
}
function A(e, t) {
  return e === "auto" ? D(t) : e;
}
function ue(e) {
  return `b-${e}`;
}
function de(e) {
  return D(e) === "rtl";
}
function fe(e) {
  return e === "ltr" ? "rtl" : "ltr";
}
const E = {
  ltr: {
    "inline-start": "left",
    "inline-end": "right",
    "block-start": "top",
    "block-end": "bottom"
  },
  rtl: {
    "inline-start": "right",
    "inline-end": "left",
    "block-start": "top",
    "block-end": "bottom"
  }
};
function he(e, t) {
  return E[t][e];
}
const z = {
  mark: B("Locale"),
  create: (e) => {
    const t = w({
      defaultValue: navigator.language ?? "en-US",
      key: "beatui-locale"
    }), o = w({
      defaultValue: "auto",
      key: "beatui-direction-preference"
    }), a = p(
      t,
      o
    )(
      (r, i) => A(i, r)
    );
    return {
      value: {
        locale: t,
        setLocale: (r) => t.set(r),
        direction: a,
        directionPreference: o,
        setDirectionPreference: (r) => o.set(r)
      },
      dispose: () => {
        t.dispose(), o.dispose(), a.dispose();
      }
    };
  }
}, {
  variants: H,
  special: _,
  overrides: y
} = $;
function d(e, t) {
  switch (e) {
    case "white":
      return "var(--color-white)";
    case "black":
      return "var(--color-black)";
    case "transparent":
      return "transparent";
    default:
      return V(e, t);
  }
}
function S(e, t) {
  const o = _[e];
  if (!o) return;
  if (t === "light")
    return o;
  const a = y[e];
  return a ? a[t] : o;
}
function ge(e, t, o) {
  const a = y[e];
  if (a) {
    const r = a[o];
    if (r)
      return { backgroundColor: r.backgroundColor, textColor: r.color };
  }
  if (t === "solid") {
    const r = S(e, o);
    if (r)
      return {
        backgroundColor: r.backgroundColor,
        textColor: r.color
      };
  }
  const n = H[t][o];
  return {
    backgroundColor: d(e, n.bgShade),
    textColor: n.textColor
  };
}
const q = {
  light: { shade: 700, textColor: "var(--color-white)" },
  dark: { shade: 500, textColor: "var(--text-inverted-dark)" }
}, G = {
  light: { shade: 200, textColor: "var(--text-normal-light)" },
  dark: { shade: 700, textColor: "var(--text-normal-dark)" }
}, K = {
  light: { shade: 400, textColor: "var(--text-normal-light)" },
  dark: { shade: 600, textColor: "var(--text-normal-dark)" }
};
function pe(e, t, o) {
  const a = y[e];
  if (a) {
    const r = a[o];
    if (r)
      return { backgroundColor: r.backgroundColor, textColor: r.color };
  }
  if (t === "solid") {
    const r = S(e, o);
    if (r)
      return {
        backgroundColor: r.backgroundColor,
        textColor: r.color
      };
    const i = q[o];
    return {
      backgroundColor: d(e, i.shade),
      textColor: i.textColor
    };
  }
  const n = t === "light" ? G[o] : K[o];
  return {
    backgroundColor: d(e, n.shade),
    textColor: n.textColor
  };
}
function me(e, t) {
  const o = t === "light" ? 500 : 600;
  switch (e) {
    case "white":
      return t === "light" ? "var(--text-inverse-light)" : "var(--text-inverted-dark)";
    case "black":
      return "var(--color-black)";
    case "transparent":
      return "transparent";
    default:
      return d(e, o);
  }
}
function ke(e, t) {
  return e === "white" ? "var(--color-white)" : e === "black" ? "var(--color-black)" : e === "transparent" ? "inherit" : d(e, t === "light" ? 800 : 200);
}
function L(e, t, o) {
  return t === "soft" ? d(e, o === "light" ? 300 : 700) : d(e, o === "light" ? 500 : 600);
}
const W = "bui-icons", m = /* @__PURE__ */ new Map(), F = (() => {
  try {
    return typeof indexedDB < "u" && indexedDB !== null;
  } catch {
    return !1;
  }
})();
function J() {
  return F ? new Promise((e, t) => {
    const o = indexedDB.open(W, 1);
    o.onupgradeneeded = function(a) {
      const n = a.target.result;
      n.objectStoreNames.contains("icons") || n.createObjectStore("icons");
    }, o.onsuccess = function() {
      e(o.result);
    }, o.onerror = function() {
      t(o.error);
    };
  }) : Promise.reject(new Error("IndexedDB not available"));
}
const k = F ? J() : null;
async function Q(e, t) {
  try {
    if (k) {
      const o = await k;
      return new Promise((a, n) => {
        const r = o.transaction("icons", "readwrite");
        r.objectStore("icons").put(t, e), r.oncomplete = () => a(), r.onerror = n;
      });
    } else
      m.set(e, t);
  } catch {
    m.set(e, t);
  }
}
async function Y(e) {
  try {
    if (k) {
      const t = await k;
      return new Promise((o, a) => {
        const i = t.transaction("icons", "readonly").objectStore("icons").get(e);
        i.onsuccess = function() {
          o(i.result);
        }, i.onerror = a;
      });
    } else
      return m.get(e) || null;
  } catch {
    return m.get(e) || null;
  }
}
async function Z(e) {
  const t = `https://api.iconify.design/${e}.svg`;
  return fetch(t).then((o) => {
    if (o.status === 200)
      return o.text();
    throw new Error(`Failed to load icon: ${e}`);
  });
}
async function X(e) {
  const t = e.replace(":", "/"), o = await Y(t);
  if (o)
    return o;
  const a = await Z(t);
  return await Q(t, a), a;
}
function ee(e) {
  return ["bc-icon", `bc-icon--${e}`].join(" ");
}
function te(e, t = "solid") {
  if (!e) return "";
  const o = L(e, t, "light"), a = L(e, t, "dark");
  return `--icon-color: ${o}; --icon-color-dark: ${a}`;
}
function be({
  icon: e,
  size: t = "md",
  color: o,
  title: a,
  accessibility: n = "auto",
  tone: r = "solid"
}, ...i) {
  const c = p(
    n,
    a
  )((l, s) => l === "decorative" ? !1 : l === "informative" ? !0 : s != null && s !== "");
  return T(
    ie,
    (l) => g.span(
      u.class(
        p(t, o)((s) => ee(s ?? "md"))
      ),
      u.style(
        p(
          o,
          r
        )(
          (s, h) => te(s ?? void 0, h ?? "solid")
        )
      ),
      // Add accessibility attributes based on icon type
      b(
        c,
        () => v(
          u.role("img"),
          f.label(M(a, l.$.iconDescription))
        ),
        () => f.hidden(!0)
      ),
      N(
        { once: !0 },
        () => R({
          request: e,
          load: ({ request: s }) => X(s),
          convertError: String,
          success: ({ value: s }) => g.span(
            P.width("100%"),
            P.height("100%"),
            u.innerHTML(s)
          ),
          pending: () => g.span(
            u.class("animate-spin"),
            // Loading state accessibility
            b(
              c,
              () => v(u.role("img"), f.label(l.$.loadingIcon)),
              () => f.hidden(!0)
            ),
            "↻"
          ),
          failure: ({ error: s }) => g.span(
            u.title(s),
            u.class("text-red-500"),
            // Error state accessibility
            b(
              c,
              () => v(u.role("img"), f.label(l.$.failedToLoadIcon)),
              () => f.hidden(!0)
            ),
            "🚫"
          )
        })
      ),
      ...i
    )
  );
}
function oe(e) {
  const t = e.split("-"), o = [e];
  return t.length > 1 && o.push(t[0]), o;
}
function re({
  locale: e,
  defaultLocale: t = "en-US",
  defaultMessages: o,
  localeLoader: a
}) {
  const n = x(t), r = x(o), i = e.on(async (c) => {
    if (c === n.value) return;
    n.set(c);
    const l = oe(c);
    for (const s of l)
      try {
        const h = await a(s);
        if (
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
          typeof h.default == "object" && Object.keys(h).length === 1
        ) {
          console.error(
            "It appears that you are trying to load a translation module without referencing the default export. Please use `(await import(...)).default` in your loader function."
          );
          return;
        }
        if (c === n.value) {
          r.set(h);
          return;
        }
      } catch {
        continue;
      }
    console.warn(`No locale found for "${e.value}", using fallback`), c === n.value && r.set(o);
  });
  return {
    /** Clean up all resources and event listeners */
    dispose: () => {
      i(), n.dispose(), r.dispose();
    },
    /** Translation functions that return reactive signals */
    t: r
  };
}
function ne({
  defaultLocale: e,
  defaultMessages: t,
  localeLoader: o,
  providerName: a = "I18nProvider"
}) {
  return {
    mark: B(a),
    create: (n, r) => {
      const {
        value: { locale: i }
      } = r.getProvider(z.mark), { t: c, dispose: l } = re({
        locale: i,
        defaultMessages: t,
        defaultLocale: e,
        localeLoader: o
      });
      return {
        value: c,
        dispose: l
      };
    }
  };
}
const ae = /* @__PURE__ */ Object.assign({
  "./locales/ar.ts": () => import("./ar-DjMvIww5.js").then((e) => e.default),
  "./locales/de.ts": () => import("./de-wChFYqM4.js").then((e) => e.default),
  "./locales/es.ts": () => import("./es-CmPF3IGl.js").then((e) => e.default),
  "./locales/fa.ts": () => import("./fa-D696e75R.js").then((e) => e.default),
  "./locales/fr.ts": () => import("./fr-B0jeX1Hx.js").then((e) => e.default),
  "./locales/he.ts": () => import("./he-SgAsIYJA.js").then((e) => e.default),
  "./locales/hi.ts": () => import("./hi-s9oiIihq.js").then((e) => e.default),
  "./locales/it.ts": () => import("./it-Dc4IMciD.js").then((e) => e.default),
  "./locales/ja.ts": () => import("./ja-D2t2g5xj.js").then((e) => e.default),
  "./locales/ko.ts": () => import("./ko-BRylA5JZ.js").then((e) => e.default),
  "./locales/nl.ts": () => import("./nl-Dh7LUWAn.js").then((e) => e.default),
  "./locales/pl.ts": () => import("./pl-XEG-p1Q9.js").then((e) => e.default),
  "./locales/pt.ts": () => import("./pt-DYsDA2sZ.js").then((e) => e.default),
  "./locales/ru.ts": () => import("./ru-BTKBykp-.js").then((e) => e.default),
  "./locales/tr.ts": () => import("./tr-Cp8ZCUic.js").then((e) => e.default),
  "./locales/ur.ts": () => import("./ur-DkIYJxsF.js").then((e) => e.default),
  "./locales/vi.ts": () => import("./vi-DKw6PBja.js").then((e) => e.default),
  "./locales/zh.ts": () => import("./zh-CaKHseXJ.js").then((e) => e.default)
}), ie = ne({
  defaultLocale: I,
  defaultMessages: C,
  localeLoader: async (e) => {
    if (e === I) return C;
    const t = ae[`./locales/${e}.ts`];
    return t ? await t() : C;
  },
  providerName: "BeatUII18n"
});
export {
  ie as B,
  be as I,
  z as L,
  me as a,
  ge as b,
  I as c,
  C as d,
  re as e,
  O as f,
  Y as g,
  pe as h,
  F as i,
  D as j,
  ue as k,
  de as l,
  ne as m,
  fe as n,
  E as o,
  he as p,
  A as r,
  Q as s,
  ke as t
};
