@ai-matrx/kit 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +132 -0
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/autosave.cjs +92 -0
- package/dist/autosave.cjs.map +1 -0
- package/dist/autosave.d.cts +17 -0
- package/dist/autosave.d.ts +17 -0
- package/dist/autosave.js +72 -0
- package/dist/autosave.js.map +1 -0
- package/dist/clipboard.cjs +152 -0
- package/dist/clipboard.cjs.map +1 -0
- package/dist/clipboard.d.cts +17 -0
- package/dist/clipboard.d.ts +17 -0
- package/dist/clipboard.js +132 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/color-util.cjs +790 -0
- package/dist/color-util.cjs.map +1 -0
- package/dist/color-util.d.cts +235 -0
- package/dist/color-util.d.ts +235 -0
- package/dist/color-util.js +767 -0
- package/dist/color-util.js.map +1 -0
- package/dist/concurrency.cjs +59 -0
- package/dist/concurrency.cjs.map +1 -0
- package/dist/concurrency.d.cts +19 -0
- package/dist/concurrency.d.ts +19 -0
- package/dist/concurrency.js +38 -0
- package/dist/concurrency.js.map +1 -0
- package/dist/confirm.cjs +344 -0
- package/dist/confirm.cjs.map +1 -0
- package/dist/confirm.d.cts +132 -0
- package/dist/confirm.d.ts +132 -0
- package/dist/confirm.js +312 -0
- package/dist/confirm.js.map +1 -0
- package/dist/delimiter-guard.cjs +172 -0
- package/dist/delimiter-guard.cjs.map +1 -0
- package/dist/delimiter-guard.d.cts +119 -0
- package/dist/delimiter-guard.d.ts +119 -0
- package/dist/delimiter-guard.js +151 -0
- package/dist/delimiter-guard.js.map +1 -0
- package/dist/drafts.cjs +223 -0
- package/dist/drafts.cjs.map +1 -0
- package/dist/drafts.d.cts +62 -0
- package/dist/drafts.d.ts +62 -0
- package/dist/drafts.js +201 -0
- package/dist/drafts.js.map +1 -0
- package/dist/idb-store.cjs +178 -0
- package/dist/idb-store.cjs.map +1 -0
- package/dist/idb-store.d.cts +111 -0
- package/dist/idb-store.d.ts +111 -0
- package/dist/idb-store.js +155 -0
- package/dist/idb-store.js.map +1 -0
- package/dist/idle-scheduler.cjs +268 -0
- package/dist/idle-scheduler.cjs.map +1 -0
- package/dist/idle-scheduler.d.cts +185 -0
- package/dist/idle-scheduler.d.ts +185 -0
- package/dist/idle-scheduler.js +246 -0
- package/dist/idle-scheduler.js.map +1 -0
- package/dist/index.cjs +3113 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +897 -0
- package/dist/index.d.ts +897 -0
- package/dist/index.js +3088 -0
- package/dist/index.js.map +1 -0
- package/dist/invalidation.cjs +64 -0
- package/dist/invalidation.cjs.map +1 -0
- package/dist/invalidation.d.cts +52 -0
- package/dist/invalidation.d.ts +52 -0
- package/dist/invalidation.js +43 -0
- package/dist/invalidation.js.map +1 -0
- package/dist/json-format.cjs +319 -0
- package/dist/json-format.cjs.map +1 -0
- package/dist/json-format.d.cts +148 -0
- package/dist/json-format.d.ts +148 -0
- package/dist/json-format.js +286 -0
- package/dist/json-format.js.map +1 -0
- package/dist/latest-request.cjs +36 -0
- package/dist/latest-request.cjs.map +1 -0
- package/dist/latest-request.d.cts +29 -0
- package/dist/latest-request.d.ts +29 -0
- package/dist/latest-request.js +16 -0
- package/dist/latest-request.js.map +1 -0
- package/dist/qr.cjs +109 -0
- package/dist/qr.cjs.map +1 -0
- package/dist/qr.d.cts +47 -0
- package/dist/qr.d.ts +47 -0
- package/dist/qr.js +78 -0
- package/dist/qr.js.map +1 -0
- package/dist/react-tree.cjs +69 -0
- package/dist/react-tree.cjs.map +1 -0
- package/dist/react-tree.d.cts +38 -0
- package/dist/react-tree.d.ts +38 -0
- package/dist/react-tree.js +38 -0
- package/dist/react-tree.js.map +1 -0
- package/dist/search-scoring.cjs +116 -0
- package/dist/search-scoring.cjs.map +1 -0
- package/dist/search-scoring.d.cts +77 -0
- package/dist/search-scoring.d.ts +77 -0
- package/dist/search-scoring.js +95 -0
- package/dist/search-scoring.js.map +1 -0
- package/dist/text-case.cjs +313 -0
- package/dist/text-case.cjs.map +1 -0
- package/dist/text-case.d.cts +53 -0
- package/dist/text-case.d.ts +53 -0
- package/dist/text-case.js +292 -0
- package/dist/text-case.js.map +1 -0
- package/dist/toast.cjs +74 -0
- package/dist/toast.cjs.map +1 -0
- package/dist/toast.d.cts +92 -0
- package/dist/toast.d.ts +92 -0
- package/dist/toast.js +54 -0
- package/dist/toast.js.map +1 -0
- package/dist/url-state.cjs +212 -0
- package/dist/url-state.cjs.map +1 -0
- package/dist/url-state.d.cts +90 -0
- package/dist/url-state.d.ts +90 -0
- package/dist/url-state.js +199 -0
- package/dist/url-state.js.map +1 -0
- package/package.json +286 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/color-util/lab-delta.ts","../src/color-util/tailwind-colors.ts","../src/color-util/tailwind.ts","../src/color-util/formats.ts","../src/color-util/normalize.ts"],"sourcesContent":["/**\n * The zero-dependency perceptual-distance engine behind the string input path\n * of `findNearestTailwindColor`.\n *\n * The matrx-frontend original computed distance through colord's lab plugin\n * (`colordInstance.delta(hex)`). This module reproduces that plugin's exact\n * pipeline — sRGB → XYZ(D65) → chromatic adaptation to D50 (colord's\n * matrices, including its channel clamps) → CIE L*a*b* rounded to 2 decimals\n * → CIEDE2000 (colord >= 2.10 formulation) ÷ 100, rounded to 3 decimals and\n * clamped to [0, 1] — so the nearest-token answer is bit-identical to the\n * colord path. The test suite cross-checks this against colord itself (a\n * devDependency only).\n */\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n}\n\ninterface Lab {\n l: number;\n a: number;\n b: number;\n}\n\n/** colord's rounding helper: round to `digits` decimal places. */\nfunction round(value: number, digits = 0): number {\n const factor = Math.pow(10, digits);\n return Math.round(factor * value) / factor + 0;\n}\n\nfunction clamp(value: number, min = 0, max = 1): number {\n return value > max ? max : value > min ? value : min;\n}\n\n/** sRGB channel (0–255) → linear-light (0–1). */\nfunction linearize(channel: number): number {\n const c = channel / 255;\n return c < 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);\n}\n\n// D50 reference white (colord's constants).\nconst WHITE_X = 96.422;\nconst WHITE_Y = 100;\nconst WHITE_Z = 82.521;\n\nconst EPSILON = 216 / 24389;\nconst KAPPA = 24389 / 27;\n\n/** sRGB → XYZ(D65) → Bradford-adapted D50, clamped — colord's exact matrices. */\nfunction rgbToXyz(rgb: Rgb): { x: number; y: number; z: number } {\n const r = linearize(rgb.r);\n const g = linearize(rgb.g);\n const b = linearize(rgb.b);\n const d65 = {\n x: 100 * (0.4124564 * r + 0.3575761 * g + 0.1804375 * b),\n y: 100 * (0.2126729 * r + 0.7151522 * g + 0.072175 * b),\n z: 100 * (0.0193339 * r + 0.119192 * g + 0.9503041 * b),\n };\n const d50 = {\n x: 1.0478112 * d65.x + 0.0228866 * d65.y + -0.050127 * d65.z,\n y: 0.0295424 * d65.x + 0.9904844 * d65.y + -0.0170491 * d65.z,\n z: -0.0092345 * d65.x + 0.0150436 * d65.y + 0.7521316 * d65.z,\n };\n return {\n x: clamp(d50.x, 0, WHITE_X),\n y: clamp(d50.y, 0, WHITE_Y),\n z: clamp(d50.z, 0, WHITE_Z),\n };\n}\n\n/** RGB → CIE L*a*b*, rounded to 2 decimals exactly like colord's `toLab`. */\nexport function rgbToLab(rgb: Rgb): Lab {\n const xyz = rgbToXyz(rgb);\n let x = xyz.x / WHITE_X;\n let y = xyz.y / WHITE_Y;\n let z = xyz.z / WHITE_Z;\n x = x > EPSILON ? Math.cbrt(x) : (KAPPA * x + 16) / 116;\n y = y > EPSILON ? Math.cbrt(y) : (KAPPA * y + 16) / 116;\n z = z > EPSILON ? Math.cbrt(z) : (KAPPA * z + 16) / 116;\n return {\n l: round(116 * y - 16, 2),\n a: round(500 * (x - y), 2),\n b: round(200 * (y - z), 2),\n };\n}\n\n/** CIEDE2000 between two Lab colors — colord's exact formulation. */\nfunction ciede2000(lab1: Lab, lab2: Lab): number {\n const { l: l1, a: a1, b: b1 } = lab1;\n const { l: l2, a: a2, b: b2 } = lab2;\n const toDeg = 180 / Math.PI;\n const toRad = Math.PI / 180;\n\n const c1 = Math.pow(Math.pow(a1, 2) + Math.pow(b1, 2), 0.5);\n const c2 = Math.pow(Math.pow(a2, 2) + Math.pow(b2, 2), 0.5);\n const lBar = (l1 + l2) / 2;\n const cBar7 = Math.pow((c1 + c2) / 2, 7);\n const g = 0.5 * (1 - Math.pow(cBar7 / (cBar7 + Math.pow(25, 7)), 0.5));\n const a1p = a1 * (1 + g);\n const a2p = a2 * (1 + g);\n const c1p = Math.pow(Math.pow(a1p, 2) + Math.pow(b1, 2), 0.5);\n const c2p = Math.pow(Math.pow(a2p, 2) + Math.pow(b2, 2), 0.5);\n const cBarP = (c1p + c2p) / 2;\n let h1p = a1p === 0 && b1 === 0 ? 0 : Math.atan2(b1, a1p) * toDeg;\n let h2p = a2p === 0 && b2 === 0 ? 0 : Math.atan2(b2, a2p) * toDeg;\n if (h1p < 0) h1p += 360;\n if (h2p < 0) h2p += 360;\n\n let dhp = h2p - h1p;\n const hAbs = Math.abs(h2p - h1p);\n if (hAbs > 180 && h2p <= h1p) {\n dhp += 360;\n } else if (hAbs > 180 && h2p > h1p) {\n dhp -= 360;\n }\n let hBarP = h1p + h2p;\n if (hAbs <= 180) {\n hBarP /= 2;\n } else {\n hBarP = (h1p + h2p < 360 ? hBarP + 360 : hBarP - 360) / 2;\n }\n\n const t =\n 1 -\n 0.17 * Math.cos(toRad * (hBarP - 30)) +\n 0.24 * Math.cos(2 * toRad * hBarP) +\n 0.32 * Math.cos(toRad * (3 * hBarP + 6)) -\n 0.2 * Math.cos(toRad * (4 * hBarP - 63));\n const dL = l2 - l1;\n const dCp = c2p - c1p;\n const dHp = 2 * Math.sin((toRad * dhp) / 2) * Math.pow(c1p * c2p, 0.5);\n const sl =\n 1 +\n (0.015 * Math.pow(lBar - 50, 2)) /\n Math.pow(20 + Math.pow(lBar - 50, 2), 0.5);\n const sc = 1 + 0.045 * cBarP;\n const sh = 1 + 0.015 * cBarP * t;\n const dTheta = 30 * Math.exp(-1 * Math.pow((hBarP - 275) / 25, 2));\n // colord >= 2.10 computes the rotation term from the adjusted mean chroma\n // (C'bar^7), the standard CIEDE2000 formulation.\n const cBarP7 = Math.pow(cBarP, 7);\n const rt =\n -2 *\n Math.pow(cBarP7 / (cBarP7 + Math.pow(25, 7)), 0.5) *\n Math.sin(2 * toRad * dTheta);\n\n return Math.pow(\n Math.pow(dL / 1 / sl, 2) +\n Math.pow(dCp / 1 / sc, 2) +\n Math.pow(dHp / 1 / sh, 2) +\n (rt * dCp * dHp) / (1 * sc * 1 * sh),\n 0.5,\n );\n}\n\n/**\n * Perceptual distance between two RGB colors, normalized exactly like\n * colord's `.delta()`: CIEDE2000 / 100, rounded to 3 decimals, clamped [0,1].\n */\nexport function rgbDelta(rgb1: Rgb, rgb2: Rgb): number {\n return clamp(round(ciede2000(rgbToLab(rgb1), rgbToLab(rgb2)) / 100, 3));\n}\n\nconst HEX_RE = /^#?([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst RGB_FN_RE =\n /^rgba?\\(\\s*([+-]?[\\d.]+)\\s*[,\\s]\\s*([+-]?[\\d.]+)\\s*[,\\s]\\s*([+-]?[\\d.]+)(?:\\s*[,/]\\s*[+-]?[\\d.]+%?)?\\s*\\)$/i;\n\n/**\n * Parses the two input shapes this unit is chartered for — hex (`#rgb`,\n * `#rrggbb`, with or without `#`, alpha digits tolerated and ignored) and\n * `rgb()`/`rgba()` strings — into RGB channels. Returns `null` for anything\n * else; this is deliberately NOT a general CSS color parser.\n */\nexport function parseHexOrRgb(input: string): Rgb | null {\n const text = input.trim();\n const hexMatch = text.match(HEX_RE);\n if (hexMatch) {\n const hex = hexMatch[1] as string;\n if (hex.length === 3 || hex.length === 4) {\n return {\n r: parseInt((hex[0] as string) + hex[0], 16),\n g: parseInt((hex[1] as string) + hex[1], 16),\n b: parseInt((hex[2] as string) + hex[2], 16),\n };\n }\n return {\n r: parseInt(hex.slice(0, 2), 16),\n g: parseInt(hex.slice(2, 4), 16),\n b: parseInt(hex.slice(4, 6), 16),\n };\n }\n const rgbMatch = text.match(RGB_FN_RE);\n if (rgbMatch) {\n const r = Number(rgbMatch[1]);\n const g = Number(rgbMatch[2]);\n const b = Number(rgbMatch[3]);\n if ([r, g, b].some((v) => Number.isNaN(v))) return null;\n return { r: clamp(r, 0, 255), g: clamp(g, 0, 255), b: clamp(b, 0, 255) };\n }\n return null;\n}\n","/**\n * The Tailwind CSS default palette lookup table — ported verbatim from\n * matrx-frontend `constants/tailwind-colors.ts` (the data the S14\n * \"tailwind-color-util\" unit does its lookups against). 22 color groups,\n * shades 50–950.\n */\n\nexport interface TailwindColorGroup {\n name: string;\n shades: Record<string, string>;\n}\n\n\nexport const tailwindColors: readonly TailwindColorGroup[] = [\n {\n name: \"Slate\",\n shades: {\n \"50\": \"#f8fafc\",\n \"100\": \"#f1f5f9\",\n \"200\": \"#e2e8f0\",\n \"300\": \"#cbd5e1\",\n \"400\": \"#94a3b8\",\n \"500\": \"#64748b\",\n \"600\": \"#475569\",\n \"700\": \"#334155\",\n \"800\": \"#1e293b\",\n \"900\": \"#0f172a\",\n \"950\": \"#020617\"\n }\n },\n {\n name: \"Gray\",\n shades: {\n \"50\": \"#f9fafb\",\n \"100\": \"#f3f4f6\",\n \"200\": \"#e5e7eb\",\n \"300\": \"#d1d5db\",\n \"400\": \"#9ca3af\",\n \"500\": \"#6b7280\",\n \"600\": \"#4b5563\",\n \"700\": \"#374151\",\n \"800\": \"#1f2937\",\n \"900\": \"#111827\",\n \"950\": \"#030712\"\n }\n },\n {\n name: \"Zinc\",\n shades: {\n \"50\": \"#fafafa\",\n \"100\": \"#f4f4f5\",\n \"200\": \"#e4e4e7\",\n \"300\": \"#d4d4d8\",\n \"400\": \"#a1a1aa\",\n \"500\": \"#71717a\",\n \"600\": \"#52525b\",\n \"700\": \"#3f3f46\",\n \"800\": \"#27272a\",\n \"900\": \"#18181b\",\n \"950\": \"#09090b\"\n }\n },\n {\n name: \"Neutral\",\n shades: {\n \"50\": \"#fafafa\",\n \"100\": \"#f5f5f5\",\n \"200\": \"#e5e5e5\",\n \"300\": \"#d4d4d4\",\n \"400\": \"#a3a3a3\",\n \"500\": \"#737373\",\n \"600\": \"#525252\",\n \"700\": \"#404040\",\n \"800\": \"#262626\",\n \"900\": \"#171717\",\n \"950\": \"#0a0a0a\"\n }\n },\n {\n name: \"Stone\",\n shades: {\n \"50\": \"#fafaf9\",\n \"100\": \"#f5f5f4\",\n \"200\": \"#e7e5e4\",\n \"300\": \"#d6d3d1\",\n \"400\": \"#a8a29e\",\n \"500\": \"#78716c\",\n \"600\": \"#57534e\",\n \"700\": \"#44403c\",\n \"800\": \"#292524\",\n \"900\": \"#1c1917\",\n \"950\": \"#0c0a09\"\n }\n },\n {\n name: \"Red\",\n shades: {\n \"50\": \"#fef2f2\",\n \"100\": \"#fee2e2\",\n \"200\": \"#fecaca\",\n \"300\": \"#fca5a5\",\n \"400\": \"#f87171\",\n \"500\": \"#ef4444\",\n \"600\": \"#dc2626\",\n \"700\": \"#b91c1c\",\n \"800\": \"#991b1b\",\n \"900\": \"#7f1d1d\",\n \"950\": \"#450a0a\"\n }\n },\n {\n name: \"Orange\",\n shades: {\n \"50\": \"#fff7ed\",\n \"100\": \"#ffedd5\",\n \"200\": \"#fed7aa\",\n \"300\": \"#fdba74\",\n \"400\": \"#fb923c\",\n \"500\": \"#f97316\",\n \"600\": \"#ea580c\",\n \"700\": \"#c2410c\",\n \"800\": \"#9a3412\",\n \"900\": \"#7c2d12\",\n \"950\": \"#431407\"\n }\n },\n {\n name: \"Amber\",\n shades: {\n \"50\": \"#fffbeb\",\n \"100\": \"#fef3c7\",\n \"200\": \"#fde68a\",\n \"300\": \"#fcd34d\",\n \"400\": \"#fbbf24\",\n \"500\": \"#f59e0b\",\n \"600\": \"#d97706\",\n \"700\": \"#b45309\",\n \"800\": \"#92400e\",\n \"900\": \"#78350f\",\n \"950\": \"#451a03\"\n }\n },\n {\n name: \"Yellow\",\n shades: {\n \"50\": \"#fefce8\",\n \"100\": \"#fef9c3\",\n \"200\": \"#fef08a\",\n \"300\": \"#fde047\",\n \"400\": \"#facc15\",\n \"500\": \"#eab308\",\n \"600\": \"#ca8a04\",\n \"700\": \"#a16207\",\n \"800\": \"#854d0e\",\n \"900\": \"#713f12\",\n \"950\": \"#422006\"\n }\n },\n {\n name: \"Lime\",\n shades: {\n \"50\": \"#f7fee7\",\n \"100\": \"#ecfccb\",\n \"200\": \"#d9f99d\",\n \"300\": \"#bef264\",\n \"400\": \"#a3e635\",\n \"500\": \"#84cc16\",\n \"600\": \"#65a30d\",\n \"700\": \"#4d7c0f\",\n \"800\": \"#3f6212\",\n \"900\": \"#365314\",\n \"950\": \"#1a2e05\"\n }\n },\n {\n name: \"Green\",\n shades: {\n \"50\": \"#f0fdf4\",\n \"100\": \"#dcfce7\",\n \"200\": \"#bbf7d0\",\n \"300\": \"#86efac\",\n \"400\": \"#4ade80\",\n \"500\": \"#22c55e\",\n \"600\": \"#16a34a\",\n \"700\": \"#15803d\",\n \"800\": \"#166534\",\n \"900\": \"#14532d\",\n \"950\": \"#052e16\"\n }\n },\n {\n name: \"Emerald\",\n shades: {\n \"50\": \"#ecfdf5\",\n \"100\": \"#d1fae5\",\n \"200\": \"#a7f3d0\",\n \"300\": \"#6ee7b7\",\n \"400\": \"#34d399\",\n \"500\": \"#10b981\",\n \"600\": \"#059669\",\n \"700\": \"#047857\",\n \"800\": \"#065f46\",\n \"900\": \"#064e3b\",\n \"950\": \"#022c22\"\n }\n },\n {\n name: \"Teal\",\n shades: {\n \"50\": \"#f0fdfa\",\n \"100\": \"#ccfbf1\",\n \"200\": \"#99f6e4\",\n \"300\": \"#5eead4\",\n \"400\": \"#2dd4bf\",\n \"500\": \"#14b8a6\",\n \"600\": \"#0d9488\",\n \"700\": \"#0f766e\",\n \"800\": \"#115e59\",\n \"900\": \"#134e4a\",\n \"950\": \"#042f2e\"\n }\n },\n {\n name: \"Cyan\",\n shades: {\n \"50\": \"#ecfeff\",\n \"100\": \"#cffafe\",\n \"200\": \"#a5f3fc\",\n \"300\": \"#67e8f9\",\n \"400\": \"#22d3ee\",\n \"500\": \"#06b6d4\",\n \"600\": \"#0891b2\",\n \"700\": \"#0e7490\",\n \"800\": \"#155e75\",\n \"900\": \"#164e63\",\n \"950\": \"#083344\"\n }\n },\n {\n name: \"Sky\",\n shades: {\n \"50\": \"#f0f9ff\",\n \"100\": \"#e0f2fe\",\n \"200\": \"#bae6fd\",\n \"300\": \"#7dd3fc\",\n \"400\": \"#38bdf8\",\n \"500\": \"#0ea5e9\",\n \"600\": \"#0284c7\",\n \"700\": \"#0369a1\",\n \"800\": \"#075985\",\n \"900\": \"#0c4a6e\",\n \"950\": \"#082f49\"\n }\n },\n {\n name: \"Blue\",\n shades: {\n \"50\": \"#eff6ff\",\n \"100\": \"#dbeafe\",\n \"200\": \"#bfdbfe\",\n \"300\": \"#93c5fd\",\n \"400\": \"#60a5fa\",\n \"500\": \"#3b82f6\",\n \"600\": \"#2563eb\",\n \"700\": \"#1d4ed8\",\n \"800\": \"#1e40af\",\n \"900\": \"#1e3a8a\",\n \"950\": \"#172554\"\n }\n },\n {\n name: \"Indigo\",\n shades: {\n \"50\": \"#eef2ff\",\n \"100\": \"#e0e7ff\",\n \"200\": \"#c7d2fe\",\n \"300\": \"#a5b4fc\",\n \"400\": \"#818cf8\",\n \"500\": \"#6366f1\",\n \"600\": \"#4f46e5\",\n \"700\": \"#4338ca\",\n \"800\": \"#3730a3\",\n \"900\": \"#312e81\",\n \"950\": \"#1e1b4b\"\n }\n },\n {\n name: \"Violet\",\n shades: {\n \"50\": \"#f5f3ff\",\n \"100\": \"#ede9fe\",\n \"200\": \"#ddd6fe\",\n \"300\": \"#c4b5fd\",\n \"400\": \"#a78bfa\",\n \"500\": \"#8b5cf6\",\n \"600\": \"#7c3aed\",\n \"700\": \"#6d28d9\",\n \"800\": \"#5b21b6\",\n \"900\": \"#4c1d95\",\n \"950\": \"#2e1065\"\n }\n },\n {\n name: \"Purple\",\n shades: {\n \"50\": \"#faf5ff\",\n \"100\": \"#f3e8ff\",\n \"200\": \"#e9d5ff\",\n \"300\": \"#d8b4fe\",\n \"400\": \"#c084fc\",\n \"500\": \"#a855f7\",\n \"600\": \"#9333ea\",\n \"700\": \"#7e22ce\",\n \"800\": \"#6b21a8\",\n \"900\": \"#581c87\",\n \"950\": \"#3b0764\"\n }\n },\n {\n name: \"Fuchsia\",\n shades: {\n \"50\": \"#fdf4ff\",\n \"100\": \"#fae8ff\",\n \"200\": \"#f5d0fe\",\n \"300\": \"#f0abfc\",\n \"400\": \"#e879f9\",\n \"500\": \"#d946ef\",\n \"600\": \"#c026d3\",\n \"700\": \"#a21caf\",\n \"800\": \"#86198f\",\n \"900\": \"#701a75\",\n \"950\": \"#4a044e\"\n }\n },\n {\n name: \"Pink\",\n shades: {\n \"50\": \"#fdf2f8\",\n \"100\": \"#fce7f3\",\n \"200\": \"#fbcfe8\",\n \"300\": \"#f9a8d4\",\n \"400\": \"#f472b6\",\n \"500\": \"#ec4899\",\n \"600\": \"#db2777\",\n \"700\": \"#be185d\",\n \"800\": \"#9d174d\",\n \"900\": \"#831843\",\n \"950\": \"#500724\"\n }\n },\n {\n name: \"Rose\",\n shades: {\n \"50\": \"#fff1f2\",\n \"100\": \"#ffe4e6\",\n \"200\": \"#fecdd3\",\n \"300\": \"#fda4af\",\n \"400\": \"#fb7185\",\n \"500\": \"#f43f5e\",\n \"600\": \"#e11d48\",\n \"700\": \"#be123c\",\n \"800\": \"#9f1239\",\n \"900\": \"#881337\",\n \"950\": \"#4c0519\"\n }\n }\n] as const;\n","/**\n * The bidirectional Tailwind-token mapping — the heart of the S14 unit,\n * ported from matrx-frontend `utils/color-utils/color-change-util.ts` /\n * `tailwind-color-util.ts`.\n *\n * token → hex: `getColorFromTailwind(\"slate-500\")` → `\"#64748b\"` (plus the\n * fuzzy `formatTailwindColor` for messy user input like `\"skyblue598\"`).\n * color → token: `findNearestTailwindColor` — the verbatim nearest-match\n * scan. The original took a colord instance; the colord coupling is inverted\n * structurally: pass any object with `.delta(hex) => number` (every colord\n * instance with the lab plugin qualifies — no import, no peer), or pass a\n * plain hex / `rgb()` string and the built-in colord-identical CIEDE2000\n * engine (`lab-delta.ts`) computes the distances with zero dependencies.\n */\n\nimport { parseHexOrRgb, rgbDelta } from \"./lab-delta\";\nimport { tailwindColors } from \"./tailwind-colors\";\n\n/**\n * Anything that can measure its perceptual distance to a hex color —\n * structurally satisfied by a colord instance extended with the lab plugin.\n */\nexport interface ColorDelta {\n delta(color: string): number;\n}\n\n/**\n * Function to find the hex value for a given Tailwind color string.\n * @param tailwindColorString - The Tailwind color string (e.g., 'slate-500').\n * @returns The hex value of the corresponding color (e.g., '#64748b'), or an empty string if not found.\n */\nexport function getColorFromTailwind(tailwindColorString: string): string {\n const [colorName, shade] = tailwindColorString.split('-');\n const colorGroup = tailwindColors.find(group => group.name.toLowerCase() === (colorName ?? '').toLowerCase());\n if (colorGroup) {\n const shadeEntry = Object.entries(colorGroup.shades).find(([key]) => key === shade);\n if (shadeEntry) {\n return shadeEntry[1];\n }\n }\n return '';\n}\n\n/**\n * Function to find the nearest Tailwind color for a given input color.\n * @param inputColor - The input color: a hex or `rgb()` string, or any\n * `{ delta(hex) }` measurer (e.g. a colord instance with the lab plugin).\n * @returns The nearest Tailwind color string (e.g., 'slate-500'), or an\n * empty string when a string input cannot be parsed.\n */\nexport function findNearestTailwindColor(inputColor: string | ColorDelta): string {\n let measure: (hexValue: string) => number;\n if (typeof inputColor === \"string\") {\n const rgb = parseHexOrRgb(inputColor);\n if (!rgb) return \"\";\n measure = (hexValue) => {\n const target = parseHexOrRgb(hexValue);\n // The palette is all six-digit hex; unparseable is impossible here.\n return target ? rgbDelta(rgb, target) : Infinity;\n };\n } else {\n measure = (hexValue) => inputColor.delta(hexValue);\n }\n\n let nearestColor = \"\";\n let smallestDistance = Infinity;\n\n tailwindColors.forEach((colorGroup) => {\n Object.entries(colorGroup.shades).forEach(([shade, hexValue]) => {\n const distance = measure(hexValue);\n if (distance < smallestDistance) {\n smallestDistance = distance;\n nearestColor = `${colorGroup.name.toLowerCase()}-${shade}`;\n }\n });\n });\n\n return nearestColor;\n}\n\n/**\n * Utility to format a Tailwind color string.\n * Matches Tailwind color names and returns the closest Tailwind value.\n * Handles cases like \"skyblue600\", \"sky598\", or \"sky-600\".\n * @param tailwindColor - The user-provided Tailwind color string.\n * @returns A properly formatted Tailwind color string.\n */\nexport function formatTailwindColor(tailwindColor: string): string {\n const tailwindColorNames = [\n \"Slate\", \"Gray\", \"Zinc\", \"Neutral\", \"Stone\", \"Red\", \"Orange\", \"Amber\", \"Yellow\", \"Lime\", \"Green\",\n \"Emerald\", \"Teal\", \"Cyan\", \"Blue\", \"Indigo\", \"Violet\",\"Sky\", \"Purple\", \"Fuchsia\", \"Pink\", \"Rose\"\n ];\n\n // Step 1: Try to match the string to extract the numeric part (shade)\n const splitIndex = tailwindColor.search(/\\d/); // Find the index where numbers start\n\n // Case 1: If there is no numeric part, default to shade 500\n if (splitIndex === -1) {\n const colorName = tailwindColorNames.find(color => tailwindColor.toLowerCase().includes(color.toLowerCase()));\n if (colorName) {\n return getColorFromTailwind(`${colorName.toLowerCase()}-500`); // Default to 500 if no shade provided\n }\n }\n\n // Case 2: There is a numeric part, so handle compound names and numeric values\n if (splitIndex > 0) {\n const colorNamePart = tailwindColor.slice(0, splitIndex); // Get color name part\n let shadePart = tailwindColor.slice(splitIndex); // Get shade part\n\n // Step 2: Find all matching color names in the provided color part\n const matchedColors = tailwindColorNames.filter(color => colorNamePart.toLowerCase().includes(color.toLowerCase()));\n\n // Step 3: Sort matches based on appearance in the string (we want the first match in the original string)\n matchedColors.sort((a, b) => colorNamePart.toLowerCase().indexOf(a.toLowerCase()) - colorNamePart.toLowerCase().indexOf(b.toLowerCase()));\n\n // Step 4: Use the first matching color name (if found)\n if (matchedColors.length > 0) {\n const colorName = (matchedColors[0] as string).toLowerCase(); // The first matched color\n\n // Round the shade to the nearest 100 and convert to string\n let shade = Math.round(parseInt(shadePart) / 100) * 100;\n const formattedColor = getColorFromTailwind(`${colorName}-${shade.toString()}`);\n\n // Return the formatted color if found\n if (formattedColor) {\n return formattedColor;\n }\n }\n }\n\n // If no valid format is found, return an empty string\n return '';\n}\n","/**\n * The pure input normalizers — ported verbatim from matrx-frontend\n * `utils/color-utils/color-change-util.ts`. Each takes the messy shape a\n * human pastes (\"61, 135, 204\", \"r:61,g:135,b:204\", \"94% 29% 0% 9%\",\n * \"0x3d87cc\"…) and returns the canonical string for that format, or `''`\n * when the input does not fit — string in, string out, zero dependencies.\n *\n * ONE deliberate divergence from the original: `formatLabString` /\n * `formatLchString` logged every call (input, match, miss) with\n * unconditional `console.log`s — debug spam on a parse path, removed here.\n * Matching/return behavior is unchanged.\n */\n\n/**\n * Utility to format a hex string.\n * Adds the # prefix if missing.\n * @param hex - The user-provided hex color.\n * @returns A properly formatted hex color string.\n */\nexport function formatHex(hex: string): string {\n // Check if the hex is missing the # symbol and add it\n return hex.startsWith('#') ? hex : `#${hex}`;\n}\n\n/**\n * Utility to format an rgb string.\n * Accepts various formats like \"61, 135, 204\" or \"(61, 135, 204)\".\n * @param rgb - The user-provided rgb color.\n * @returns A properly formatted rgb color string.\n */\nexport function formatRgbString(rgb: string): string {\n // Extract numbers from the string\n const rgbValues = rgb.replace(/[^\\d,]/g, '').split(',');\n if (rgbValues.length === 3) {\n return `rgb(${(rgbValues[0] as string).trim()}, ${(rgbValues[1] as string).trim()}, ${(rgbValues[2] as string).trim()})`;\n }\n return ''; // Return an empty string for invalid cases\n}\n\n/**\n * Utility to format an RGB object.\n * Accepts various object-like formats such as '{\"r\":61,\"g\":135,\"b\":204,\"a\":1}', '\"r\":61,\"g\":135,\"b\":204,\"a\":1', or 'r:61,g:135,b:204,a:1'.\n * @param rgbObject - The user-provided RGB object-like string.\n * @returns A properly formatted RGB object.\n */\nexport function formatRgbObject(rgbObject: string): string {\n // Flexible regex to match and capture r, g, b, a values, regardless of quotes, brackets, or missing attributes\n const regex = /[\"']?r[\"']?\\s*[:=]\\s*(\\d+)\\s*[,]\\s*[\"']?g[\"']?\\s*[:=]\\s*(\\d+)\\s*[,]\\s*[\"']?b[\"']?\\s*[:=]\\s*(\\d+)(?:\\s*[,]\\s*[\"']?a[\"']?\\s*[:=]\\s*(\\d+))?/i;\n const match = rgbObject.match(regex);\n\n if (match) {\n const r = match[1], g = match[2], b = match[3], a = match[4] || 1;\n // Return a normalized RGB(A) object string\n return `{\"r\":${r},\"g\":${g},\"b\":${b},\"a\":${a}}`;\n }\n\n // If input is invalid, return an empty string\n return '';\n}\n\n/**\n * Utility to format an HSL object.\n * Accepts various object-like formats such as '{\"h\":199,\"s\":89,\"l\":48,\"a\":1}' or 'h:199,s:89,l:48,a:1'.\n * @param hslObject - The user-provided HSL object-like string.\n * @returns A properly formatted HSL object.\n */\nexport function formatHslObject(hslObject: string): string {\n // Flexible regex to match and capture h, s, l, a values, regardless of quotes, brackets, or missing attributes\n const regex = /[\"']?h[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?s[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?l[\"']?\\s*[:=]\\s*(\\d+)(?:\\s*,\\s*[\"']?a[\"']?\\s*[:=]\\s*(\\d+))?/i;\n const match = hslObject.match(regex);\n if (match) {\n const h = match[1], s = match[2], l = match[3], a = match[4] || 1;\n return `{\"h\":${h},\"s\":${s},\"l\":${l},\"a\":${a}}`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format an HSL string.\n * Accepts formats like \"hsl(199, 89%, 48%)\" or \"199, 89%, 48%\".\n * @param hslString - The user-provided HSL string.\n * @returns A properly formatted HSL string.\n */\nexport function formatHslString(hslString: string): string {\n // Extract numbers and percentage values\n const hslValues = hslString.replace(/[^\\d,%]/g, '').split(/\\s*,\\s*/);\n if (hslValues.length === 3) {\n return `hsl(${hslValues[0]}, ${hslValues[1]}%, ${hslValues[2]}%)`;\n }\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format an HSV percentage string.\n * Accepts formats like \"94% 29% 0%\" or \"(94% 29% 0%)\".\n * @param hsvString - The user-provided HSV percentage string.\n * @returns A properly formatted HSV string.\n */\nexport function formatHsvString(hsvString: string): string {\n // Remove parentheses and other non-relevant characters, then split based on spaces\n const hsvValues = hsvString.replace(/[^\\d%\\s]/g, '').split(/\\s+/).map(value => parseInt(value.replace('%', ''), 10));\n\n // Check if there are exactly 3 values for HSV (Hue, Saturation, Value)\n if (hsvValues.length === 3 && hsvValues.every(val => !isNaN(val))) {\n return `hsv(${hsvValues[0]}, ${hsvValues[1]}%, ${hsvValues[2]}%)`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format a regular CMYK string.\n * Accepts formats like \"94, 29, 0, 9\" or \"(94, 29, 0, 9)\".\n * @param cmykString - The user-provided CMYK string.\n * @returns A properly formatted CMYK string.\n */\nexport function formatRegularCmykString(cmykString: string): string {\n const cmykValues = cmykString.replace(/[^\\d,]/g, '').split(/\\s*,\\s*/);\n\n if (cmykValues.length === 4 && cmykValues.every(val => !isNaN(Number(val)))) {\n return `cmyk(${cmykValues[0]}, ${cmykValues[1]}, ${cmykValues[2]}, ${cmykValues[3]})`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format a CMYK object.\n * Accepts various object-like formats such as '{\"c\":94,\"m\":29,\"y\":0,\"k\":9,\"a\":1}' or 'c:94,m:29,y:0,k:9,a:1'.\n * @param cmykObject - The user-provided CMYK object-like string.\n * @returns A properly formatted CMYK object.\n */\nexport function formatCmykObject(cmykObject: string): string {\n // Flexible regex to match and capture c, m, y, k, a values, regardless of quotes or brackets\n const regex = /[\"']?c[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?m[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?y[\"']?\\s*[:=]\\s*(\\d+)\\s*,\\s*[\"']?k[\"']?\\s*[:=]\\s*(\\d+)(?:\\s*,\\s*[\"']?a[\"']?\\s*[:=]\\s*(\\d+))?/i;\n const match = cmykObject.match(regex);\n\n if (match) {\n const c = match[1], m = match[2], y = match[3], k = match[4], a = match[5] || 1;\n return `{\"c\":${c},\"m\":${m},\"y\":${y},\"k\":${k},\"a\":${a}}`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to format a CMYK percentage string.\n * Accepts formats like \"94% 29% 0% 9%\" or \"(94% 29% 0% 9%)\".\n * @param cmykString - The user-provided CMYK percentage string.\n * @returns A properly formatted CMYK string.\n */\nexport function formatCmykString(cmykString: string): string {\n // Remove any parentheses or extra characters, then split based on spaces\n const cmykValues = cmykString.replace(/[^\\d%\\s]/g, '').split(/\\s+/).map(value => parseInt(value.replace('%', ''), 10));\n\n if (cmykValues.length === 4 && cmykValues.every(val => !isNaN(val))) {\n return `device-cmyk(${cmykValues[0]}% ${cmykValues[1]}% ${cmykValues[2]}% ${cmykValues[3]}%)`;\n }\n return ''; // Return empty string for invalid input\n}\n\n/**\n * Utility to detect device-cmyk color strings (\"device-cmyk(94% 29% 0% 9%)\").\n * @param cmykString - The user-provided CMYK string.\n * @returns True when the string is a well-formed device-cmyk expression.\n */\nexport function isDeviceCmyk(cmykString: string): boolean {\n const regex = /device-cmyk\\(\\s*\\d+%\\s+\\d+%\\s+\\d+%\\s+\\d+%\\s*\\)/;\n return regex.test(cmykString);\n}\n\n/**\n * Utility to format an HWB string.\n * Accepts formats like \"hwb(199 24% 20%)\" or \"hwb(199deg 24% 20%)\".\n * @param hwbString - The user-provided HWB string.\n * @returns A properly formatted HWB string.\n */\nexport function formatHwbString(hwbString: string): string {\n // Extract numbers and percentage values from the HWB string\n const hwbValues = hwbString.replace(/[^\\d,%\\s]/g, '').split(/\\s+/);\n if (hwbValues.length === 3) {\n return `hwb(${hwbValues[0]}, ${hwbValues[1]}%, ${hwbValues[2]}%)`;\n }\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format a Lab string.\n * Accepts formats like \"lab(55.715 -14.02 -32.329)\" or \"55.715 -14.02 -32.329\".\n * @param labString - The user-provided Lab string.\n * @returns A properly formatted Lab string.\n */\nexport function formatLabString(labString: string): string {\n // Try matching with or without the \"lab(\" prefix\n const match = labString.match(/(?:lab\\()?\\s*(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s*\\)?/i);\n\n if (match) {\n const [, l, a, b] = match;\n return `lab(${l} ${a} ${b})`;\n }\n\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format an LCH string.\n * Accepts formats like \"lch(55.715 35.17 246.6)\" or \"55.715 35.17 246.6\".\n * @param lchString - The user-provided LCH string.\n * @returns A properly formatted LCH string.\n */\nexport function formatLchString(lchString: string): string {\n // Try matching with or without the \"lch(\" prefix\n const match = lchString.match(/(?:lch\\()?\\s*(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s+(-?\\d+(?:\\.\\d+)?)\\s*\\)?/i);\n\n if (match) {\n const [, l, c, h] = match;\n return `lch(${l} ${c} ${h})`;\n }\n\n return ''; // Return empty string for invalid cases\n}\n\n/**\n * Utility to format a hex string with 0x prefix.\n * Converts \"0x3d87cc\" to \"#3d87cc\".\n * @param hex - The user-provided hex color with 0x prefix.\n * @returns A properly formatted hex color string.\n */\nexport function formatHexWith0x(hex: string): string {\n if (hex.startsWith('0x')) {\n return `#${hex.slice(2)}`;\n }\n return ''; // Return empty string for invalid cases\n}\n","/**\n * The \"accept anything a human pastes\" waterfall — ported from matrx-frontend\n * `color-change-util.ts` `normalizeColorInput`, with the colord coupling\n * inverted: the original gated several tiers on `colord(input).isValid()`;\n * here the host injects that validity check (`createColorNormalizer({\n * isValid })` — pass `(c) => colord(c).isValid()` or any equivalent). The\n * tier ORDER, the tiers that skip validation, and the returned\n * `{ value, type }` shapes are verbatim.\n *\n * Deliberate divergence (same class as formats.ts): the original logged every\n * tier hit/miss with unconditional `console.log`s — removed.\n */\n\nimport {\n formatCmykObject,\n formatCmykString,\n formatHex,\n formatHexWith0x,\n formatHslObject,\n formatHslString,\n formatHsvString,\n formatHwbString,\n formatLabString,\n formatLchString,\n formatRegularCmykString,\n formatRgbObject,\n formatRgbString,\n isDeviceCmyk,\n} from \"./formats\";\nimport { formatTailwindColor } from \"./tailwind\";\n\nexport interface NormalizedColor {\n value: string;\n type: string;\n}\n\nexport interface ColorNormalizerOptions {\n /**\n * \"Can this string be parsed as a color?\" — the host's color engine\n * (e.g. `(c) => colord(c).isValid()`).\n */\n isValid: (color: string) => boolean;\n}\n\n/**\n * Builds `normalizeColorInput`: tries the format conversions in the original\n * fixed order until one produces a valid (or structurally well-formed) color,\n * returning `{ value, type }`, or `null` when nothing fits.\n */\nexport function createColorNormalizer({ isValid }: ColorNormalizerOptions) {\n return function normalizeColorInput(colorInput: string): NormalizedColor | null {\n // Try standard validation first\n if (isValid(colorInput)) {\n return { value: colorInput, type: 'standard' };\n }\n\n // Check for 'device-cmyk' manually\n if (isDeviceCmyk(colorInput)) {\n return { value: colorInput, type: 'device-cmyk' };\n }\n\n // Try hex conversion\n const hex = formatHex(colorInput);\n if (isValid(hex)) {\n return { value: hex, type: 'hex' };\n }\n\n // Try RGB string conversion\n const rgbString = formatRgbString(colorInput);\n if (isValid(rgbString)) {\n return { value: rgbString, type: 'rgb' };\n }\n\n // Try RGB object conversion (skip isValid for this)\n const rgbObject = formatRgbObject(colorInput);\n if (rgbObject !== '') {\n return { value: rgbObject, type: 'rgb-object' };\n }\n\n // Try HSL object conversion (skip isValid for this)\n const hslObject = formatHslObject(colorInput);\n if (hslObject !== '') {\n return { value: hslObject, type: 'hsl-object' };\n }\n\n // Try HSL string conversion\n const hslString = formatHslString(colorInput);\n if (isValid(hslString)) {\n return { value: hslString, type: 'hsl' };\n }\n\n // Try HSV string conversion\n const hsvString = formatHsvString(colorInput);\n if (isValid(hsvString)) {\n return { value: hsvString, type: 'hsv' };\n }\n\n // Try Tailwind color conversion\n const tailwindColor = formatTailwindColor(colorInput);\n if (tailwindColor !== '') {\n return { value: tailwindColor, type: 'tailwind' };\n }\n\n // Try regular CMYK string conversion (skip isValid for this)\n const regularCmykString = formatRegularCmykString(colorInput);\n if (regularCmykString !== '') {\n return { value: regularCmykString, type: 'cmyk' };\n }\n\n // Try CMYK object conversion (skip isValid for this)\n const cmykObject = formatCmykObject(colorInput);\n if (cmykObject !== '') {\n return { value: cmykObject, type: 'cmyk-object' };\n }\n\n // Try CMYK percentage string conversion (for device-cmyk)\n const cmykString = formatCmykString(colorInput);\n if (isValid(cmykString)) {\n return { value: cmykString, type: 'cmyk-percentage' };\n }\n\n // Try HWB string conversion\n const hwbString = formatHwbString(colorInput);\n if (isValid(hwbString)) {\n return { value: hwbString, type: 'hwb' };\n }\n\n // Try Lab string conversion (skip isValid for this)\n const labString = formatLabString(colorInput);\n if (labString !== '') {\n return { value: labString, type: 'lab' };\n }\n\n // Try LCH string conversion (skip isValid for this)\n const lchString = formatLchString(colorInput);\n if (lchString !== '') {\n return { value: lchString, type: 'lch' };\n }\n\n // Try hex with 0x conversion\n const hexWith0x = formatHexWith0x(colorInput);\n if (isValid(hexWith0x)) {\n return { value: hexWith0x, type: 'hex-0x' };\n }\n\n // If all else fails, return null\n return null;\n };\n}\n"],"mappings":";AA2BA,SAAS,MAAM,OAAe,SAAS,GAAW;AAChD,QAAM,SAAS,KAAK,IAAI,IAAI,MAAM;AAClC,SAAO,KAAK,MAAM,SAAS,KAAK,IAAI,SAAS;AAC/C;AAEA,SAAS,MAAM,OAAe,MAAM,GAAG,MAAM,GAAW;AACtD,SAAO,QAAQ,MAAM,MAAM,QAAQ,MAAM,QAAQ;AACnD;AAGA,SAAS,UAAU,SAAyB;AAC1C,QAAM,IAAI,UAAU;AACpB,SAAO,IAAI,UAAU,IAAI,QAAQ,K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
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/concurrency.ts
|
|
21
|
+
var concurrency_exports = {};
|
|
22
|
+
__export(concurrency_exports, {
|
|
23
|
+
runWithConcurrency: () => runWithConcurrency
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(concurrency_exports);
|
|
26
|
+
async function runWithConcurrency(items, limit, worker, shouldStart = () => true) {
|
|
27
|
+
if (items.length === 0) {
|
|
28
|
+
return { started: 0, succeeded: 0, failed: 0, failures: [] };
|
|
29
|
+
}
|
|
30
|
+
let cursor = 0;
|
|
31
|
+
let started = 0;
|
|
32
|
+
let succeeded = 0;
|
|
33
|
+
const failures = [];
|
|
34
|
+
const requestedLimit = Number.isFinite(limit) ? Math.floor(limit) : 1;
|
|
35
|
+
const workerCount = Math.max(1, Math.min(requestedLimit, items.length));
|
|
36
|
+
const runners = Array.from({ length: workerCount }, async () => {
|
|
37
|
+
while (shouldStart()) {
|
|
38
|
+
const index = cursor++;
|
|
39
|
+
if (index >= items.length) return;
|
|
40
|
+
started += 1;
|
|
41
|
+
const item = items[index];
|
|
42
|
+
try {
|
|
43
|
+
await worker(item, index);
|
|
44
|
+
succeeded += 1;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
failures.push({ item, index, error });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
await Promise.all(runners);
|
|
51
|
+
failures.sort((left, right) => left.index - right.index);
|
|
52
|
+
return {
|
|
53
|
+
started,
|
|
54
|
+
succeeded,
|
|
55
|
+
failed: failures.length,
|
|
56
|
+
failures
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=concurrency.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/concurrency.ts"],"sourcesContent":["export interface ConcurrencyFailure<T> {\n item: T;\n index: number;\n error: unknown;\n}\n\nexport interface ConcurrencyResult<T> {\n started: number;\n succeeded: number;\n failed: number;\n failures: ConcurrencyFailure<T>[];\n}\n\n/**\n * Runs independent items through a bounded worker pool. One item failing does\n * not stop the rest, and `shouldStart` can stop new work without interrupting\n * items already in flight.\n */\nexport async function runWithConcurrency<T>(\n items: readonly T[],\n limit: number,\n worker: (item: T, index: number) => Promise<void>,\n shouldStart: () => boolean = () => true,\n): Promise<ConcurrencyResult<T>> {\n if (items.length === 0) {\n return { started: 0, succeeded: 0, failed: 0, failures: [] };\n }\n\n let cursor = 0;\n let started = 0;\n let succeeded = 0;\n const failures: ConcurrencyFailure<T>[] = [];\n const requestedLimit = Number.isFinite(limit) ? Math.floor(limit) : 1;\n const workerCount = Math.max(1, Math.min(requestedLimit, items.length));\n\n const runners = Array.from({ length: workerCount }, async () => {\n while (shouldStart()) {\n const index = cursor++;\n if (index >= items.length) return;\n started += 1;\n const item = items[index] as T;\n try {\n await worker(item, index);\n succeeded += 1;\n } catch (error) {\n failures.push({ item, index, error });\n }\n }\n });\n\n await Promise.all(runners);\n failures.sort((left, right) => left.index - right.index);\n\n return {\n started,\n succeeded,\n failed: failures.length,\n failures,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,eAAsB,mBACpB,OACA,OACA,QACA,cAA6B,MAAM,MACJ;AAC/B,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC,EAAE;AAAA,EAC7D;AAEA,MAAI,SAAS;AACb,MAAI,UAAU;AACd,MAAI,YAAY;AAChB,QAAM,WAAoC,CAAC;AAC3C,QAAM,iBAAiB,OAAO,SAAS,KAAK,IAAI,KAAK,MAAM,KAAK,IAAI;AACpE,QAAM,cAAc,KAAK,IAAI,GAAG,KAAK,IAAI,gBAAgB,MAAM,MAAM,CAAC;AAEtE,QAAM,UAAU,MAAM,KAAK,EAAE,QAAQ,YAAY,GAAG,YAAY;AAC9D,WAAO,YAAY,GAAG;AACpB,YAAM,QAAQ;AACd,UAAI,SAAS,MAAM,OAAQ;AAC3B,iBAAW;AACX,YAAM,OAAO,MAAM,KAAK;AACxB,UAAI;AACF,cAAM,OAAO,MAAM,KAAK;AACxB,qBAAa;AAAA,MACf,SAAS,OAAO;AACd,iBAAS,KAAK,EAAE,MAAM,OAAO,MAAM,CAAC;AAAA,MACtC;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,QAAQ,IAAI,OAAO;AACzB,WAAS,KAAK,CAAC,MAAM,UAAU,KAAK,QAAQ,MAAM,KAAK;AAEvD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,QAAQ,SAAS;AAAA,IACjB;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface ConcurrencyFailure<T> {
|
|
2
|
+
item: T;
|
|
3
|
+
index: number;
|
|
4
|
+
error: unknown;
|
|
5
|
+
}
|
|
6
|
+
interface ConcurrencyResult<T> {
|
|
7
|
+
started: number;
|
|
8
|
+
succeeded: number;
|
|
9
|
+
failed: number;
|
|
10
|
+
failures: ConcurrencyFailure<T>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Runs independent items through a bounded worker pool. One item failing does
|
|
14
|
+
* not stop the rest, and `shouldStart` can stop new work without interrupting
|
|
15
|
+
* items already in flight.
|
|
16
|
+
*/
|
|
17
|
+
declare function runWithConcurrency<T>(items: readonly T[], limit: number, worker: (item: T, index: number) => Promise<void>, shouldStart?: () => boolean): Promise<ConcurrencyResult<T>>;
|
|
18
|
+
|
|
19
|
+
export { type ConcurrencyFailure, type ConcurrencyResult, runWithConcurrency };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface ConcurrencyFailure<T> {
|
|
2
|
+
item: T;
|
|
3
|
+
index: number;
|
|
4
|
+
error: unknown;
|
|
5
|
+
}
|
|
6
|
+
interface ConcurrencyResult<T> {
|
|
7
|
+
started: number;
|
|
8
|
+
succeeded: number;
|
|
9
|
+
failed: number;
|
|
10
|
+
failures: ConcurrencyFailure<T>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Runs independent items through a bounded worker pool. One item failing does
|
|
14
|
+
* not stop the rest, and `shouldStart` can stop new work without interrupting
|
|
15
|
+
* items already in flight.
|
|
16
|
+
*/
|
|
17
|
+
declare function runWithConcurrency<T>(items: readonly T[], limit: number, worker: (item: T, index: number) => Promise<void>, shouldStart?: () => boolean): Promise<ConcurrencyResult<T>>;
|
|
18
|
+
|
|
19
|
+
export { type ConcurrencyFailure, type ConcurrencyResult, runWithConcurrency };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/concurrency.ts
|
|
2
|
+
async function runWithConcurrency(items, limit, worker, shouldStart = () => true) {
|
|
3
|
+
if (items.length === 0) {
|
|
4
|
+
return { started: 0, succeeded: 0, failed: 0, failures: [] };
|
|
5
|
+
}
|
|
6
|
+
let cursor = 0;
|
|
7
|
+
let started = 0;
|
|
8
|
+
let succeeded = 0;
|
|
9
|
+
const failures = [];
|
|
10
|
+
const requestedLimit = Number.isFinite(limit) ? Math.floor(limit) : 1;
|
|
11
|
+
const workerCount = Math.max(1, Math.min(requestedLimit, items.length));
|
|
12
|
+
const runners = Array.from({ length: workerCount }, async () => {
|
|
13
|
+
while (shouldStart()) {
|
|
14
|
+
const index = cursor++;
|
|
15
|
+
if (index >= items.length) return;
|
|
16
|
+
started += 1;
|
|
17
|
+
const item = items[index];
|
|
18
|
+
try {
|
|
19
|
+
await worker(item, index);
|
|
20
|
+
succeeded += 1;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
failures.push({ item, index, error });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
await Promise.all(runners);
|
|
27
|
+
failures.sort((left, right) => left.index - right.index);
|
|
28
|
+
return {
|
|
29
|
+
started,
|
|
30
|
+
succeeded,
|
|
31
|
+
failed: failures.length,
|
|
32
|
+
failures
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
runWithConcurrency
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=concurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/concurrency.ts"],"sourcesContent":["export interface ConcurrencyFailure<T> {\n item: T;\n index: number;\n error: unknown;\n}\n\nexport interface ConcurrencyResult<T> {\n started: number;\n succeeded: number;\n failed: number;\n failures: ConcurrencyFailure<T>[];\n}\n\n/**\n * Runs independent items through a bounded worker pool. One item failing does\n * not stop the rest, and `shouldStart` can stop new work without interrupting\n * items already in flight.\n */\nexport async function runWithConcurrency<T>(\n items: readonly T[],\n limit: number,\n worker: (item: T, index: number) => Promise<void>,\n shouldStart: () => boolean = () => true,\n): Promise<ConcurrencyResult<T>> {\n if (items.length === 0) {\n return { started: 0, succeeded: 0, failed: 0, failures: [] };\n }\n\n let cursor = 0;\n let started = 0;\n let succeeded = 0;\n const failures: ConcurrencyFailure<T>[] = [];\n const requestedLimit = Number.isFinite(limit) ? Math.floor(limit) : 1;\n const workerCount = Math.max(1, Math.min(requestedLimit, items.length));\n\n const runners = Array.from({ length: workerCount }, async () => {\n while (shouldStart()) {\n const index = cursor++;\n if (index >= items.length) return;\n started += 1;\n const item = items[index] as T;\n try {\n await worker(item, index);\n succeeded += 1;\n } catch (error) {\n failures.push({ item, index, error });\n }\n }\n });\n\n await Promise.all(runners);\n failures.sort((left, right) => left.index - right.index);\n\n return {\n started,\n succeeded,\n failed: failures.length,\n failures,\n };\n}\n"],"mappings":";AAkBA,eAAsB,mBACpB,OACA,OACA,QACA,cAA6B,MAAM,MACJ;AAC/B,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC,EAAE;AAAA,EAC7D;AAEA,MAAI,SAAS;AACb,MAAI,UAAU;AACd,MAAI,YAAY;AAChB,QAAM,WAAoC,CAAC;AAC3C,QAAM,iBAAiB,OAAO,SAAS,KAAK,IAAI,KAAK,MAAM,KAAK,IAAI;AACpE,QAAM,cAAc,KAAK,IAAI,GAAG,KAAK,IAAI,gBAAgB,MAAM,MAAM,CAAC;AAEtE,QAAM,UAAU,MAAM,KAAK,EAAE,QAAQ,YAAY,GAAG,YAAY;AAC9D,WAAO,YAAY,GAAG;AACpB,YAAM,QAAQ;AACd,UAAI,SAAS,MAAM,OAAQ;AAC3B,iBAAW;AACX,YAAM,OAAO,MAAM,KAAK;AACxB,UAAI;AACF,cAAM,OAAO,MAAM,KAAK;AACxB,qBAAa;AAAA,MACf,SAAS,OAAO;AACd,iBAAS,KAAK,EAAE,MAAM,OAAO,MAAM,CAAC;AAAA,MACtC;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,QAAQ,IAAI,OAAO;AACzB,WAAS,KAAK,CAAC,MAAM,UAAU,KAAK,QAAQ,MAAM,KAAK;AAEvD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,QAAQ,SAAS;AAAA,IACjB;AAAA,EACF;AACF;","names":[]}
|
package/dist/confirm.cjs
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/confirm.ts
|
|
32
|
+
var confirm_exports = {};
|
|
33
|
+
__export(confirm_exports, {
|
|
34
|
+
ConfirmDialog: () => ConfirmDialog,
|
|
35
|
+
ConfirmDialogHost: () => ConfirmDialogHost,
|
|
36
|
+
confirm: () => confirm
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(confirm_exports);
|
|
39
|
+
|
|
40
|
+
// src/confirm/opener.ts
|
|
41
|
+
var STATE_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.kit.confirm-opener-state");
|
|
42
|
+
function getState() {
|
|
43
|
+
const holder = globalThis;
|
|
44
|
+
let state = holder[STATE_SLOT];
|
|
45
|
+
if (!state) {
|
|
46
|
+
state = { host: null, queue: [] };
|
|
47
|
+
holder[STATE_SLOT] = state;
|
|
48
|
+
}
|
|
49
|
+
return state;
|
|
50
|
+
}
|
|
51
|
+
function _registerHost(controller) {
|
|
52
|
+
const state = getState();
|
|
53
|
+
state.host = controller;
|
|
54
|
+
while (state.queue.length > 0) {
|
|
55
|
+
const next = state.queue.shift();
|
|
56
|
+
controller.show(next.opts, next.resolve);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function _unregisterHost(controller) {
|
|
60
|
+
const state = getState();
|
|
61
|
+
if (state.host === controller) state.host = null;
|
|
62
|
+
}
|
|
63
|
+
function confirm(opts) {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
const state = getState();
|
|
66
|
+
if (state.host) {
|
|
67
|
+
state.host.show(opts, resolve);
|
|
68
|
+
} else {
|
|
69
|
+
state.queue.push({ opts, resolve });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/confirm/host.tsx
|
|
75
|
+
var React3 = __toESM(require("react"), 1);
|
|
76
|
+
|
|
77
|
+
// src/confirm/cn.ts
|
|
78
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
79
|
+
function cn(...values) {
|
|
80
|
+
return (0, import_tailwind_merge.twMerge)(values.filter(Boolean).join(" "));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/confirm/alert-dialog.tsx
|
|
84
|
+
var React2 = __toESM(require("react"), 1);
|
|
85
|
+
var AlertDialogPrimitive = __toESM(require("@radix-ui/react-alert-dialog"), 1);
|
|
86
|
+
|
|
87
|
+
// src/react-tree.ts
|
|
88
|
+
var React = __toESM(require("react"), 1);
|
|
89
|
+
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
|
|
90
|
+
function treeContainsComponent(node, Component) {
|
|
91
|
+
if (node == null || typeof node === "boolean") return false;
|
|
92
|
+
if (Array.isArray(node)) {
|
|
93
|
+
return node.some((child) => treeContainsComponent(child, Component));
|
|
94
|
+
}
|
|
95
|
+
if (React.isValidElement(node)) {
|
|
96
|
+
if (node.type === Component) return true;
|
|
97
|
+
const props = node.props;
|
|
98
|
+
return props.children != null ? treeContainsComponent(props.children, Component) : false;
|
|
99
|
+
}
|
|
100
|
+
if (typeof node === "string" || typeof node === "number") return false;
|
|
101
|
+
if (typeof node === "object" && node.$$typeof === REACT_PORTAL_TYPE) {
|
|
102
|
+
return treeContainsComponent(
|
|
103
|
+
node.children,
|
|
104
|
+
Component
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
if (typeof node === "object" && Symbol.iterator in node) {
|
|
108
|
+
return Array.from(node).some(
|
|
109
|
+
(child) => treeContainsComponent(child, Component)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (typeof process !== "undefined" && true) {
|
|
113
|
+
const keys = typeof node === "object" ? ` with keys {${Object.keys(node).join(", ")}}` : "";
|
|
114
|
+
console.error(
|
|
115
|
+
`[treeContainsComponent] A non-renderable value${keys} is being passed as a React child. React will throw 'Objects are not valid as a React child' at the real render site. Stringify it (e.g. JSON.stringify) before rendering.`,
|
|
116
|
+
node
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/confirm/alert-dialog.tsx
|
|
123
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
124
|
+
var buttonBase = "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:pointer-events-none disabled:opacity-50 active:scale-[0.98] [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 h-9 px-4 py-2";
|
|
125
|
+
var buttonDefault = "bg-primary text-primary-foreground shadow-sm hover:bg-primary/90";
|
|
126
|
+
var buttonOutline = "border border-border bg-card shadow-sm hover:bg-accent hover:text-accent-foreground";
|
|
127
|
+
var AlertDialog = AlertDialogPrimitive.Root;
|
|
128
|
+
var AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
129
|
+
var AlertDialogOverlay = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
+
AlertDialogPrimitive.Overlay,
|
|
131
|
+
{
|
|
132
|
+
className: cn(
|
|
133
|
+
"fixed inset-0 z-[10000] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
134
|
+
className
|
|
135
|
+
),
|
|
136
|
+
...props,
|
|
137
|
+
ref
|
|
138
|
+
}
|
|
139
|
+
));
|
|
140
|
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
141
|
+
var AlertDialogContentPrimitive = React2.forwardRef(({ ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogPrimitive.Content, { ...props, ref, "aria-modal": "true" }));
|
|
142
|
+
AlertDialogContentPrimitive.displayName = "AlertDialogContentPrimitive";
|
|
143
|
+
var AlertDialogDescription = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
AlertDialogPrimitive.Description,
|
|
145
|
+
{
|
|
146
|
+
ref,
|
|
147
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
148
|
+
...props
|
|
149
|
+
}
|
|
150
|
+
));
|
|
151
|
+
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
152
|
+
var AlertDialogContent = React2.forwardRef(({ className, children, ...props }, ref) => {
|
|
153
|
+
const hasDescription = treeContainsComponent(children, AlertDialogDescription) || treeContainsComponent(children, AlertDialogPrimitive.Description);
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AlertDialogPortal, { children: [
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogOverlay, {}),
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
157
|
+
AlertDialogContentPrimitive,
|
|
158
|
+
{
|
|
159
|
+
ref,
|
|
160
|
+
className: cn(
|
|
161
|
+
"fixed left-[50%] top-[50%] z-[10000] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
162
|
+
className
|
|
163
|
+
),
|
|
164
|
+
...props,
|
|
165
|
+
children: [
|
|
166
|
+
!hasDescription && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDialogPrimitive.Description, { className: "sr-only", children: "Please confirm the action described in this dialog." }),
|
|
167
|
+
children
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] });
|
|
172
|
+
});
|
|
173
|
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
174
|
+
var AlertDialogHeader = ({
|
|
175
|
+
className,
|
|
176
|
+
...props
|
|
177
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
className: cn(
|
|
181
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
182
|
+
className
|
|
183
|
+
),
|
|
184
|
+
...props
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
188
|
+
var AlertDialogFooter = ({
|
|
189
|
+
className,
|
|
190
|
+
...props
|
|
191
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
className: cn(
|
|
195
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
196
|
+
className
|
|
197
|
+
),
|
|
198
|
+
...props
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
202
|
+
var AlertDialogTitle = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
203
|
+
AlertDialogPrimitive.Title,
|
|
204
|
+
{
|
|
205
|
+
ref,
|
|
206
|
+
className: cn("text-lg font-semibold", className),
|
|
207
|
+
...props
|
|
208
|
+
}
|
|
209
|
+
));
|
|
210
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
211
|
+
var AlertDialogAction = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
212
|
+
AlertDialogPrimitive.Action,
|
|
213
|
+
{
|
|
214
|
+
ref,
|
|
215
|
+
className: cn(buttonBase, buttonDefault, className),
|
|
216
|
+
...props
|
|
217
|
+
}
|
|
218
|
+
));
|
|
219
|
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
220
|
+
var AlertDialogCancel = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
221
|
+
AlertDialogPrimitive.Cancel,
|
|
222
|
+
{
|
|
223
|
+
ref,
|
|
224
|
+
className: cn(buttonBase, buttonOutline, "mt-2 sm:mt-0", className),
|
|
225
|
+
...props
|
|
226
|
+
}
|
|
227
|
+
));
|
|
228
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
229
|
+
|
|
230
|
+
// src/confirm/confirm-dialog.tsx
|
|
231
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
232
|
+
function SpinnerIcon({ className }) {
|
|
233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
234
|
+
"svg",
|
|
235
|
+
{
|
|
236
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
237
|
+
width: 24,
|
|
238
|
+
height: 24,
|
|
239
|
+
viewBox: "0 0 24 24",
|
|
240
|
+
fill: "none",
|
|
241
|
+
stroke: "currentColor",
|
|
242
|
+
strokeWidth: 2,
|
|
243
|
+
strokeLinecap: "round",
|
|
244
|
+
strokeLinejoin: "round",
|
|
245
|
+
"aria-hidden": "true",
|
|
246
|
+
className,
|
|
247
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
function ConfirmDialog({
|
|
252
|
+
open,
|
|
253
|
+
onOpenChange,
|
|
254
|
+
title,
|
|
255
|
+
description,
|
|
256
|
+
content,
|
|
257
|
+
contentClassName,
|
|
258
|
+
confirmLabel = "Confirm",
|
|
259
|
+
cancelLabel = "Cancel",
|
|
260
|
+
variant = "default",
|
|
261
|
+
busy = false,
|
|
262
|
+
confirmDisabled = false,
|
|
263
|
+
onConfirm
|
|
264
|
+
}) {
|
|
265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlertDialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(AlertDialogContent, { className: contentClassName, children: [
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(AlertDialogHeader, { children: [
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlertDialogTitle, { children: title }),
|
|
268
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlertDialogDescription, { children: description }) : null
|
|
269
|
+
] }),
|
|
270
|
+
content ?? null,
|
|
271
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(AlertDialogFooter, { children: [
|
|
272
|
+
cancelLabel === null ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlertDialogCancel, { className: "max-lg:min-h-11", disabled: busy, children: cancelLabel }),
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
274
|
+
AlertDialogAction,
|
|
275
|
+
{
|
|
276
|
+
disabled: busy || confirmDisabled,
|
|
277
|
+
onClick: (event) => {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
void onConfirm();
|
|
280
|
+
},
|
|
281
|
+
className: cn(
|
|
282
|
+
"max-lg:min-h-11",
|
|
283
|
+
variant === "destructive" && "bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
284
|
+
),
|
|
285
|
+
children: [
|
|
286
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SpinnerIcon, { className: "mr-2 h-4 w-4 animate-spin" }) : null,
|
|
287
|
+
confirmLabel
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
] })
|
|
292
|
+
] }) });
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// src/confirm/host.tsx
|
|
296
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
297
|
+
function ConfirmDialogHost() {
|
|
298
|
+
const [active, setActive] = React3.useState(null);
|
|
299
|
+
const [tick, setTick] = React3.useState(0);
|
|
300
|
+
const queueRef = React3.useRef([]);
|
|
301
|
+
React3.useEffect(() => {
|
|
302
|
+
const controller = {
|
|
303
|
+
show: (opts, resolve) => {
|
|
304
|
+
queueRef.current.push({ opts, resolve });
|
|
305
|
+
setTick((n) => n + 1);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
_registerHost(controller);
|
|
309
|
+
return () => _unregisterHost(controller);
|
|
310
|
+
}, []);
|
|
311
|
+
React3.useEffect(() => {
|
|
312
|
+
if (active === null && queueRef.current.length > 0) {
|
|
313
|
+
setActive(queueRef.current.shift());
|
|
314
|
+
}
|
|
315
|
+
}, [active, tick]);
|
|
316
|
+
const handleConfirm = React3.useCallback(() => {
|
|
317
|
+
if (!active) return;
|
|
318
|
+
active.resolve(true);
|
|
319
|
+
setActive(null);
|
|
320
|
+
}, [active]);
|
|
321
|
+
const handleOpenChange = React3.useCallback(
|
|
322
|
+
(open) => {
|
|
323
|
+
if (!open && active) {
|
|
324
|
+
active.resolve(false);
|
|
325
|
+
setActive(null);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
[active]
|
|
329
|
+
);
|
|
330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
331
|
+
ConfirmDialog,
|
|
332
|
+
{
|
|
333
|
+
open: !!active,
|
|
334
|
+
onOpenChange: handleOpenChange,
|
|
335
|
+
title: active?.opts.title ?? "",
|
|
336
|
+
description: active?.opts.description,
|
|
337
|
+
confirmLabel: active?.opts.confirmLabel,
|
|
338
|
+
cancelLabel: active?.opts.cancelLabel,
|
|
339
|
+
variant: active?.opts.variant,
|
|
340
|
+
onConfirm: handleConfirm
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=confirm.cjs.map
|