@seanyeh77/ui 0.16.0 → 0.18.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-C9LWyR-H.js";
2
+ import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-madGv9m_.js";
3
3
  import * as React from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
@@ -19,6 +19,8 @@ const PH = {
19
19
  "arrow-u-up-right": "<path d=\"M170.34,130.34,204.69,96H88a48,48,0,0,0,0,96h88a8,8,0,0,1,0,16H88A64,64,0,0,1,88,80H204.69L170.34,45.66a8,8,0,0,1,11.32-11.32l48,48a8,8,0,0,1,0,11.32l-48,48a8,8,0,0,1-11.32-11.32Z\"/>",
20
20
  "arrow-up": "<path d=\"M205.66,117.66a8,8,0,0,1-11.32,0L136,59.31V216a8,8,0,0,1-16,0V59.31L61.66,117.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,205.66,117.66Z\"/>",
21
21
  "arrows-clockwise": "<path d=\"M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h28.69L182.06,73.37a79.56,79.56,0,0,0-56.13-23.43h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27a96,96,0,0,1,135,.79L208,76.69V48a8,8,0,0,1,16,0ZM186.41,183.29a80,80,0,0,1-112.47-.66L59.31,168H88a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V179.31l14.63,14.63A95.43,95.43,0,0,0,130,222.06h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z\"/>",
22
+ "arrows-in-line-vertical": "<path d=\"M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM122.34,101.66a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0-11.32-11.32L136,76.69V16a8,8,0,0,0-16,0V76.69L101.66,58.34A8,8,0,0,0,90.34,69.66Zm11.32,52.68a8,8,0,0,0-11.32,0l-32,32a8,8,0,0,0,11.32,11.32L120,179.31V240a8,8,0,0,0,16,0V179.31l18.34,18.35a8,8,0,0,0,11.32-11.32Z\"/>",
23
+ "arrows-out-line-vertical": "<path d=\"M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM101.66,53.66,120,35.31V96a8,8,0,0,0,16,0V35.31l18.34,18.35a8,8,0,0,0,11.32-11.32l-32-32a8,8,0,0,0-11.32,0l-32,32a8,8,0,0,0,11.32,11.32Zm52.68,148.68L136,220.69V160a8,8,0,0,0-16,0v60.69l-18.34-18.35a8,8,0,0,0-11.32,11.32l32,32a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0-11.32-11.32Z\"/>",
22
24
  bell: "<path d=\"M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z\"/>",
23
25
  "calendar-blank": "<path d=\"M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,48v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80H48V48ZM208,208H48V96H208V208Z\"/>",
24
26
  "caret-down": "<path d=\"M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z\"/>",
@@ -112,6 +114,8 @@ const PH_FILL = {
112
114
  "arrow-u-up-right": "<path d=\"M168,136V96H88a48,48,0,0,0,0,96h88a8,8,0,0,1,0,16H88A64,64,0,0,1,88,80h80V40a8,8,0,0,1,13.66-5.66l48,48a8,8,0,0,1,0,11.32l-48,48A8,8,0,0,1,168,136Z\"/>",
113
115
  "arrow-up": "<path d=\"M207.39,115.06A8,8,0,0,1,200,120H136v96a8,8,0,0,1-16,0V120H56a8,8,0,0,1-5.66-13.66l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,207.39,115.06Z\"/>",
114
116
  "arrows-clockwise": "<path d=\"M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1-5.66-13.66L180.65,72a79.48,79.48,0,0,0-54.72-22.09h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27,96,96,0,0,1,192,60.7l18.36-18.36A8,8,0,0,1,224,48ZM186.41,183.29A80,80,0,0,1,75.35,184l18.31-18.31A8,8,0,0,0,88,152H40a8,8,0,0,0-8,8v48a8,8,0,0,0,13.66,5.66L64,195.3a95.42,95.42,0,0,0,66,26.76h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z\"/>",
117
+ "arrows-in-line-vertical": "<path d=\"M90.34,69.66A8,8,0,0,1,96,56h24V16a8,8,0,0,1,16,0V56h24a8,8,0,0,1,5.66,13.66l-32,32a8,8,0,0,1-11.32,0Zm43.32,84.68a8,8,0,0,0-11.32,0l-32,32A8,8,0,0,0,96,200h24v40a8,8,0,0,0,16,0V200h24a8,8,0,0,0,5.66-13.66ZM216,120H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Z\"/>",
118
+ "arrows-out-line-vertical": "<path d=\"M88.61,51.06a8,8,0,0,1,1.73-8.72l32-32a8,8,0,0,1,11.32,0l32,32A8,8,0,0,1,160,56H136V96a8,8,0,0,1-16,0V56H96A8,8,0,0,1,88.61,51.06ZM216,120H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm-56,80H136V160a8,8,0,0,0-16,0v40H96a8,8,0,0,0-5.66,13.66l32,32a8,8,0,0,0,11.32,0l32-32A8,8,0,0,0,160,200Z\"/>",
115
119
  bell: "<path d=\"M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216Z\"/>",
116
120
  "calendar-blank": "<path d=\"M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,48H48V48H72v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24Z\"/>",
117
121
  "caret-down": "<path d=\"M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z\"/>",
@@ -273,7 +277,7 @@ function store(key, value) {
273
277
  } catch {}
274
278
  return null;
275
279
  }
276
- function reduced() {
280
+ function reduced$1() {
277
281
  return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
278
282
  }
279
283
  const nav = typeof navigator !== "undefined" ? navigator : void 0;
@@ -1163,7 +1167,7 @@ let fadeTimer;
1163
1167
  /** Switches the theme on <html data-theme> and remembers it. */
1164
1168
  function setTheme(t) {
1165
1169
  const root = document.documentElement;
1166
- if (!reduced()) {
1170
+ if (!reduced$1()) {
1167
1171
  root.classList.add("ui-theme-fade");
1168
1172
  clearTimeout(fadeTimer);
1169
1173
  fadeTimer = setTimeout(() => root.classList.remove("ui-theme-fade"), 320);
@@ -1630,9 +1634,9 @@ function Badge({ status, variant = "chip", children, className }) {
1630
1634
  // src/internal/chart.tsx
1631
1635
  /** 0 → 1 with an ease-out over ms, restarted when target changes; 1 at once with reduced motion. */
1632
1636
  function useCountUp(target, ms) {
1633
- const [t, setT] = React.useState(reduced() ? 1 : 0);
1637
+ const [t, setT] = React.useState(reduced$1() ? 1 : 0);
1634
1638
  React.useEffect(() => {
1635
- if (reduced()) return;
1639
+ if (reduced$1()) return;
1636
1640
  let t0 = null;
1637
1641
  let raf = 0;
1638
1642
  const step = (now) => {
@@ -2202,7 +2206,7 @@ function breakable(text) {
2202
2206
  return out;
2203
2207
  }
2204
2208
  /** Source with line numbers and an optional target line: soft accent background, long lines wrap, light syntax colors. */
2205
- function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile, title, language, languageLabel, highlight = true, tokenizer = tokenize, refHref, onRef, maxHeight, sections, className, ref }) {
2209
+ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile, title, language, languageLabel, highlight = true, tokenizer = tokenize, refHref, onRef, maxHeight, sections, copy, lineNumbers = true, onCopy, onCopyError, className, ref }) {
2206
2210
  const lines = React.useMemo(() => String(code || "").replace(/\n$/, "").split("\n"), [code]);
2207
2211
  const lang = language || languageOf(file);
2208
2212
  const toks = React.useMemo(() => highlight ? tokenizer(lines, lang) : lines.map((l) => [["", l]]), [
@@ -2249,12 +2253,12 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
2249
2253
  "data-n": n,
2250
2254
  "aria-current": on && n === ta ? "location" : void 0,
2251
2255
  tabIndex: on && n === ta ? -1 : void 0,
2252
- children: [/* @__PURE__ */ jsx("span", {
2256
+ children: [lineNumbers ? /* @__PURE__ */ jsx("span", {
2253
2257
  className: "ui-cv-num",
2254
- style: { width: digits + 2 + "ch" },
2258
+ style: { width: `calc(${digits}ch + 28px)` },
2255
2259
  "aria-hidden": "true",
2256
2260
  children: n
2257
- }), /* @__PURE__ */ jsxs("span", {
2261
+ }) : null, /* @__PURE__ */ jsxs("span", {
2258
2262
  className: "ui-cv-text",
2259
2263
  children: [/* @__PURE__ */ jsx("span", {
2260
2264
  className: "ui-visually-hidden ui-cv-sr",
@@ -2329,29 +2333,50 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
2329
2333
  n: nOf(el)
2330
2334
  }));
2331
2335
  };
2332
- const head = file || title ? /* @__PURE__ */ jsxs("div", {
2336
+ const [copied, setCopied] = React.useState(false);
2337
+ const copyTimer = React.useRef(void 0);
2338
+ React.useEffect(() => () => clearTimeout(copyTimer.current), []);
2339
+ const doCopy = () => {
2340
+ copyText(code).then(() => {
2341
+ setCopied(true);
2342
+ announce(tr("已複製"));
2343
+ clearTimeout(copyTimer.current);
2344
+ copyTimer.current = setTimeout(() => setCopied(false), 2e3);
2345
+ onCopy?.(code);
2346
+ }, () => onCopyError?.());
2347
+ };
2348
+ const head = file || title || copy ? /* @__PURE__ */ jsxs("div", {
2333
2349
  className: "ui-cv-head",
2334
- children: [file ? fileHref || onFile ? /* @__PURE__ */ jsx(InlineCode, {
2335
- href: fileHref,
2336
- onClick: onFile,
2337
- className: "ui-cv-file",
2338
- children: file
2339
- }) : /* @__PURE__ */ jsx("span", {
2340
- className: "ui-cv-file",
2341
- children: file
2342
- }) : /* @__PURE__ */ jsx("span", {
2343
- className: "ui-cv-title",
2344
- children: title
2345
- }), languageLabel !== false && lang !== "plain" ? /* @__PURE__ */ jsxs("span", {
2346
- className: "ui-cv-lang",
2347
- children: [/* @__PURE__ */ jsx("span", {
2348
- className: "ui-visually-hidden",
2349
- children: tr("程式語言") + tr(":")
2350
- }), tr(languageLabel || LANGUAGE_NAMES[lang] || lang)]
2351
- }) : null]
2350
+ children: [
2351
+ file ? fileHref || onFile ? /* @__PURE__ */ jsx(InlineCode, {
2352
+ href: fileHref,
2353
+ onClick: onFile,
2354
+ className: "ui-cv-file",
2355
+ children: file
2356
+ }) : /* @__PURE__ */ jsx("span", {
2357
+ className: "ui-cv-file",
2358
+ children: file
2359
+ }) : title ? /* @__PURE__ */ jsx("span", {
2360
+ className: "ui-cv-title",
2361
+ children: title
2362
+ }) : null,
2363
+ languageLabel !== false && lang !== "plain" ? /* @__PURE__ */ jsxs("span", {
2364
+ className: "ui-cv-lang",
2365
+ children: [/* @__PURE__ */ jsx("span", {
2366
+ className: "ui-visually-hidden",
2367
+ children: tr("程式語言") + tr(":")
2368
+ }), tr(languageLabel || LANGUAGE_NAMES[lang] || lang)]
2369
+ }) : null,
2370
+ copy ? /* @__PURE__ */ jsx(IconButton, {
2371
+ className: cx("ui-cv-copy", copied && "is-copied"),
2372
+ label: copied ? tr("已複製") : tr("複製程式碼"),
2373
+ icon: copied ? CHECK : "copy",
2374
+ onClick: doCopy
2375
+ }) : null
2376
+ ]
2352
2377
  }) : null;
2353
2378
  return /* @__PURE__ */ jsxs("div", {
2354
- className: cx("ui-cv", className),
2379
+ className: cx("ui-cv", !lineNumbers && "no-nums", className),
2355
2380
  role: "region",
2356
2381
  "aria-label": file || title || tr("原始碼"),
2357
2382
  children: [
@@ -3382,7 +3407,7 @@ function DataTable(p) {
3382
3407
  const sn = snap.current;
3383
3408
  snap.current = null;
3384
3409
  const body = bodyRef.current;
3385
- if (!sn || !body || reduced() || typeof Element.prototype.animate !== "function") return;
3410
+ if (!sn || !body || reduced$1() || typeof Element.prototype.animate !== "function") return;
3386
3411
  const top0 = body.getBoundingClientRect().top;
3387
3412
  const n = Math.max(sn.order.length, visIds.length);
3388
3413
  let k = 0;
@@ -4121,9 +4146,10 @@ function DateRangePicker({ label, value, onChange, placeholder, className }) {
4121
4146
  }
4122
4147
  // src/components/DetailList/DetailList.tsx
4123
4148
  /** Labelled facts about one item: label beside the value when there is room, above it under 600 px. */
4124
- function DetailList({ items, className }) {
4149
+ function DetailList({ items, labelWidth, labelSize, className }) {
4125
4150
  return /* @__PURE__ */ jsx("dl", {
4126
- className: cx("ui-dl", className),
4151
+ className: cx("ui-dl", labelWidth === "auto" && "is-auto", typeof labelWidth === "number" && "is-fixed", labelSize === "body" && "is-body", className),
4152
+ style: typeof labelWidth === "number" ? { "--dl-label": labelWidth + "px" } : void 0,
4127
4153
  children: items.map((it, i) => /* @__PURE__ */ jsxs("div", {
4128
4154
  className: "ui-dl-item",
4129
4155
  children: [/* @__PURE__ */ jsx("dt", { children: it.label }), /* @__PURE__ */ jsx("dd", { children: it.value })]
@@ -4660,6 +4686,656 @@ function GraphLegend({ items = LEGEND_DEFAULT, className }) {
4660
4686
  }, i))
4661
4687
  });
4662
4688
  }
4689
+ // src/components/Markdown/Markdown.tsx
4690
+ const FENCE = /^ {0,3}(`{3,}|~{3,})\s*([\w+#.-]*)/;
4691
+ const HEADING = /^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/;
4692
+ const HR = /^ {0,3}([-*_])(?:\s*\1){2,}\s*$/;
4693
+ const ITEM = /^( {0,3})([-*+]|\d{1,9}[.)])(\s+|$)(.*)$/;
4694
+ const QUOTE = /^ {0,3}> ?(.*)$/;
4695
+ const TABLE_SEP = /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/;
4696
+ function cells(line) {
4697
+ let s = line.trim();
4698
+ if (s.startsWith("|")) s = s.slice(1);
4699
+ if (s.endsWith("|") && !s.endsWith("\\|")) s = s.slice(0, -1);
4700
+ const out = [];
4701
+ let cur = "";
4702
+ let code = false;
4703
+ for (let i = 0; i < s.length; i++) {
4704
+ const c = s[i];
4705
+ if (c === "\\" && s[i + 1] === "|") {
4706
+ cur += "|";
4707
+ i++;
4708
+ } else if (c === "`") {
4709
+ code = !code;
4710
+ cur += c;
4711
+ } else if (c === "|" && !code) {
4712
+ out.push(cur.trim());
4713
+ cur = "";
4714
+ } else cur += c;
4715
+ }
4716
+ out.push(cur.trim());
4717
+ return out;
4718
+ }
4719
+ const blank = (l) => !l.trim();
4720
+ const startsBlock = (l) => FENCE.test(l) || HEADING.test(l) || HR.test(l) || QUOTE.test(l) || ITEM.test(l);
4721
+ function parse(lines) {
4722
+ const out = [];
4723
+ let i = 0;
4724
+ while (i < lines.length) {
4725
+ const line = lines[i];
4726
+ if (blank(line)) {
4727
+ i++;
4728
+ continue;
4729
+ }
4730
+ const fence = FENCE.exec(line);
4731
+ if (fence) {
4732
+ const mark = fence[1];
4733
+ const body = [];
4734
+ i++;
4735
+ while (i < lines.length && !lines[i].trim().startsWith(mark)) body.push(lines[i++]);
4736
+ i++;
4737
+ out.push({
4738
+ t: "code",
4739
+ lang: fence[2].toLowerCase(),
4740
+ code: body.join("\n")
4741
+ });
4742
+ continue;
4743
+ }
4744
+ const h = HEADING.exec(line);
4745
+ if (h) {
4746
+ out.push({
4747
+ t: "h",
4748
+ level: h[1].length,
4749
+ text: h[2] ?? ""
4750
+ });
4751
+ i++;
4752
+ continue;
4753
+ }
4754
+ if (HR.test(line)) {
4755
+ out.push({ t: "hr" });
4756
+ i++;
4757
+ continue;
4758
+ }
4759
+ if (QUOTE.test(line)) {
4760
+ const body = [];
4761
+ while (i < lines.length && !blank(lines[i]) && (QUOTE.test(lines[i]) || !startsBlock(lines[i]))) {
4762
+ body.push(QUOTE.exec(lines[i])?.[1] ?? lines[i]);
4763
+ i++;
4764
+ }
4765
+ out.push({
4766
+ t: "quote",
4767
+ blocks: parse(body)
4768
+ });
4769
+ continue;
4770
+ }
4771
+ const item = ITEM.exec(line);
4772
+ if (item) {
4773
+ const ordered = /\d/.test(item[2]);
4774
+ const start = ordered ? parseInt(item[2], 10) : 1;
4775
+ const items = [];
4776
+ while (i < lines.length) {
4777
+ const m = ITEM.exec(lines[i]);
4778
+ if (!m || /\d/.test(m[2]) !== ordered) break;
4779
+ const indent = m[1].length + m[2].length + Math.max(1, Math.min(m[3].length, 4));
4780
+ const body = [m[4]];
4781
+ i++;
4782
+ while (i < lines.length) {
4783
+ const l = lines[i];
4784
+ if (blank(l)) {
4785
+ const next = lines[i + 1];
4786
+ if (next !== void 0 && /^\s+/.test(next) && next.search(/\S/) >= indent) {
4787
+ body.push("");
4788
+ i++;
4789
+ continue;
4790
+ }
4791
+ break;
4792
+ }
4793
+ const lead = l.search(/\S/);
4794
+ if (lead >= indent || lead >= 2 && ITEM.test(l.trimStart())) body.push(l.slice(Math.min(lead, indent)));
4795
+ else if (!startsBlock(l) && !ITEM.test(l)) body.push(l);
4796
+ else break;
4797
+ i++;
4798
+ }
4799
+ items.push(parse(body));
4800
+ if (i < lines.length && blank(lines[i])) {
4801
+ const next = lines[i + 1];
4802
+ if (next !== void 0 && ITEM.test(next) && /\d/.test(ITEM.exec(next)?.[2] ?? "") === ordered) {
4803
+ i++;
4804
+ continue;
4805
+ }
4806
+ break;
4807
+ }
4808
+ }
4809
+ out.push({
4810
+ t: "list",
4811
+ ordered,
4812
+ start,
4813
+ items
4814
+ });
4815
+ continue;
4816
+ }
4817
+ if (line.includes("|") && i + 1 < lines.length && TABLE_SEP.test(lines[i + 1]) && lines[i + 1].includes("-")) {
4818
+ const head = cells(line);
4819
+ const align = cells(lines[i + 1]).map((c) => c.startsWith(":") && c.endsWith(":") ? "center" : c.endsWith(":") ? "right" : c.startsWith(":") ? "left" : null);
4820
+ const rows = [];
4821
+ i += 2;
4822
+ while (i < lines.length && !blank(lines[i]) && lines[i].includes("|")) rows.push(cells(lines[i++]));
4823
+ out.push({
4824
+ t: "table",
4825
+ head,
4826
+ align,
4827
+ rows
4828
+ });
4829
+ continue;
4830
+ }
4831
+ const body = [line];
4832
+ i++;
4833
+ while (i < lines.length && !blank(lines[i]) && !startsBlock(lines[i])) body.push(lines[i++]);
4834
+ out.push({
4835
+ t: "p",
4836
+ text: body.join("\n")
4837
+ });
4838
+ }
4839
+ return out;
4840
+ }
4841
+ /** Only http, https, mailto and relative addresses are kept; anything else (javascript:, data:) is not a link. */
4842
+ function safeHref(href) {
4843
+ const h = href.trim();
4844
+ if (!h) return void 0;
4845
+ const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(h);
4846
+ if (!scheme) return h;
4847
+ return [
4848
+ "http",
4849
+ "https",
4850
+ "mailto"
4851
+ ].includes(scheme[1].toLowerCase()) ? h : void 0;
4852
+ }
4853
+ const PATH = /^(?:\.{1,2}\/)?(?:[\w.-]+\/)*[\w.-]+\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/;
4854
+ const isPath = (s) => PATH.test(s) && (s.includes("/") || /:\d/.test(s));
4855
+ const CJK = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\uff00-\uffef]/u;
4856
+ /** Inline Markdown: code spans, links, autolinks, bold, italic, hard breaks; HTML tags dropped, their text kept. */
4857
+ function inline(src, c) {
4858
+ const out = [];
4859
+ let text = "";
4860
+ const flush = () => {
4861
+ if (text) out.push(text);
4862
+ text = "";
4863
+ };
4864
+ let i = 0;
4865
+ while (i < src.length) {
4866
+ const ch = src[i];
4867
+ if (ch === "\\" && i + 1 < src.length && /[\\`*_{}[\]()#+\-.!|<>~]/.test(src[i + 1])) {
4868
+ text += src[i + 1];
4869
+ i += 2;
4870
+ continue;
4871
+ }
4872
+ if (ch === "\\" && src[i + 1] === "\n") {
4873
+ flush();
4874
+ out.push(/* @__PURE__ */ jsx("br", {}, c.k()));
4875
+ i += 2;
4876
+ continue;
4877
+ }
4878
+ if (ch === "\n") {
4879
+ if (/ {2,}$/.test(text)) {
4880
+ text = text.replace(/ +$/, "");
4881
+ flush();
4882
+ out.push(/* @__PURE__ */ jsx("br", {}, c.k()));
4883
+ } else {
4884
+ text = text.replace(/ +$/, "");
4885
+ const before = text.at(-1) ?? (typeof out.at(-1) === "string" ? String(out.at(-1)).at(-1) : "");
4886
+ const after = src.slice(i + 1).trimStart()[0] ?? "";
4887
+ if (!CJK.test(before ?? "") && !CJK.test(after)) text += " ";
4888
+ while (src[i + 1] === " ") i++;
4889
+ }
4890
+ i++;
4891
+ continue;
4892
+ }
4893
+ if (ch === "`") {
4894
+ const run = /^`+/.exec(src.slice(i))?.[0] ?? "`";
4895
+ const end = src.indexOf(run, i + run.length);
4896
+ if (end > 0) {
4897
+ flush();
4898
+ let v = src.slice(i + run.length, end).replace(/\n/g, " ");
4899
+ if (/^ .* $/.test(v)) v = v.slice(1, -1);
4900
+ out.push(code(v, c));
4901
+ i = end + run.length;
4902
+ continue;
4903
+ }
4904
+ }
4905
+ if (ch === "<") {
4906
+ const auto = /^<((?:https?:|mailto:)[^\s<>]+)>/i.exec(src.slice(i));
4907
+ if (auto) {
4908
+ flush();
4909
+ out.push(link(auto[1], [auto[1].replace(/^mailto:/i, "")], c));
4910
+ i += auto[0].length;
4911
+ continue;
4912
+ }
4913
+ const tag = /^<!--[\s\S]*?-->|^<\/?[A-Za-z][\w-]*(?:\s[^<>]*)?\/?>/.exec(src.slice(i));
4914
+ if (tag) {
4915
+ i += tag[0].length;
4916
+ continue;
4917
+ }
4918
+ }
4919
+ if (ch === "!" && src[i + 1] === "[") {
4920
+ const m = /^!\[([^\]]*)\]\([^)]*\)/.exec(src.slice(i));
4921
+ if (m) {
4922
+ text += m[1];
4923
+ i += m[0].length;
4924
+ continue;
4925
+ }
4926
+ }
4927
+ if (ch === "[") {
4928
+ const m = matchLink(src, i);
4929
+ if (m) {
4930
+ flush();
4931
+ out.push(link(m.href, inline(m.text, c), c));
4932
+ i = m.end;
4933
+ continue;
4934
+ }
4935
+ }
4936
+ if (ch === "*" || ch === "_") {
4937
+ const run = src[i + 1] === ch ? ch + ch : ch;
4938
+ const prev = src[i - 1];
4939
+ const intraword = ch === "_" && prev !== void 0 && /\w/.test(prev);
4940
+ const next = src[i + run.length];
4941
+ if (!intraword && next && !/\s/.test(next)) {
4942
+ const end = findClose(src, i + run.length, run);
4943
+ if (end > 0) {
4944
+ flush();
4945
+ const inner = inline(src.slice(i + run.length, end), c);
4946
+ out.push(run.length === 2 ? /* @__PURE__ */ jsx("strong", { children: inner }, c.k()) : /* @__PURE__ */ jsx("em", { children: inner }, c.k()));
4947
+ i = end + run.length;
4948
+ continue;
4949
+ }
4950
+ }
4951
+ }
4952
+ text += ch;
4953
+ i++;
4954
+ }
4955
+ flush();
4956
+ return out;
4957
+ function code(v, ctx) {
4958
+ const onRef = ctx.onRef;
4959
+ if (isPath(v)) {
4960
+ const href = ctx.refHref?.(v) || void 0;
4961
+ if (href || onRef) return /* @__PURE__ */ jsx(InlineCode, {
4962
+ href,
4963
+ onClick: onRef ? (e) => {
4964
+ if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;
4965
+ e.preventDefault();
4966
+ onRef(v, e);
4967
+ } : void 0,
4968
+ children: v
4969
+ }, ctx.k());
4970
+ }
4971
+ return /* @__PURE__ */ jsx(InlineCode, { children: v }, ctx.k());
4972
+ }
4973
+ }
4974
+ function matchLink(src, i) {
4975
+ let depth = 0;
4976
+ let j = i;
4977
+ for (; j < src.length; j++) {
4978
+ if (src[j] === "\\") {
4979
+ j++;
4980
+ continue;
4981
+ }
4982
+ if (src[j] === "[") depth++;
4983
+ else if (src[j] === "]" && --depth === 0) break;
4984
+ }
4985
+ if (j >= src.length || src[j + 1] !== "(") return null;
4986
+ let at = j + 2;
4987
+ while (src[at] === " ") at++;
4988
+ let depth2 = 0;
4989
+ let href = "";
4990
+ for (; at < src.length; at++) {
4991
+ const ch = src[at];
4992
+ if (/\s/.test(ch)) break;
4993
+ if (ch === "(") depth2++;
4994
+ else if (ch === ")") {
4995
+ if (depth2 === 0) break;
4996
+ depth2--;
4997
+ }
4998
+ href += ch;
4999
+ }
5000
+ const rest = /^(?:\s+(?:"[^"]*"|'[^']*'))?\s*\)/.exec(src.slice(at));
5001
+ if (!rest) return null;
5002
+ return {
5003
+ text: src.slice(i + 1, j),
5004
+ href: href.replace(/^<(.*)>$/, "$1"),
5005
+ end: at + rest[0].length
5006
+ };
5007
+ }
5008
+ function findClose(src, from, run) {
5009
+ let j = from;
5010
+ while ((j = src.indexOf(run, j)) > 0) {
5011
+ const before = src[j - 1];
5012
+ const after = src[j + run.length];
5013
+ if (before && !/\s/.test(before) && !(run[0] === "_" && after && /\w/.test(after)) && !(run.length === 1 && after === run)) return j;
5014
+ j += run.length;
5015
+ }
5016
+ return -1;
5017
+ }
5018
+ function link(raw, children, c) {
5019
+ const safe = safeHref(raw);
5020
+ if (safe === void 0) return /* @__PURE__ */ jsx(React.Fragment, { children }, c.k());
5021
+ const href = c.linkHref ? c.linkHref(safe) || void 0 : safe;
5022
+ if (!href && !c.onLink) return /* @__PURE__ */ jsx(React.Fragment, { children }, c.k());
5023
+ const outside = !!href && /^https?:/i.test(href);
5024
+ const onLink = c.onLink;
5025
+ const click = onLink ? (e) => {
5026
+ if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;
5027
+ e.preventDefault();
5028
+ onLink(safe, e);
5029
+ } : void 0;
5030
+ if (!href) return /* @__PURE__ */ jsx("button", {
5031
+ type: "button",
5032
+ className: "ui-md-link",
5033
+ onClick: click,
5034
+ children
5035
+ }, c.k());
5036
+ return /* @__PURE__ */ jsx("a", {
5037
+ className: "ui-md-link",
5038
+ href,
5039
+ onClick: click,
5040
+ ...outside && !c.onLink ? {
5041
+ target: "_blank",
5042
+ rel: "noopener noreferrer"
5043
+ } : {},
5044
+ children
5045
+ }, c.k());
5046
+ }
5047
+ const FENCE_LANG = {
5048
+ python: "py",
5049
+ javascript: "js",
5050
+ typescript: "js",
5051
+ jsx: "js",
5052
+ tsx: "js",
5053
+ bash: "sh",
5054
+ shell: "sh",
5055
+ zsh: "sh",
5056
+ console: "sh",
5057
+ "c++": "c"
5058
+ };
5059
+ const fenceLang = (l) => FENCE_LANG[l] ?? (languageOf("x." + l) !== "plain" ? languageOf("x." + l) : l || "plain");
5060
+ const NUM = /^[-+]?(?:NT\$\s?)?[\d,]+(?:\.\d+)?\s?(?:%|[A-Za-z]{1,3}|\p{Script=Han}{1,2})?$/u;
5061
+ /** Markdown from project documents and code comments, in the system's own type, code and table styles. Never runs HTML:
5062
+ * tags are dropped and their text kept; links only to http, https, mailto and relative addresses. */
5063
+ function Markdown(p) {
5064
+ let n = 0;
5065
+ const c = {
5066
+ k: () => "m" + n++,
5067
+ linkHref: p.linkHref,
5068
+ onLink: p.onLink,
5069
+ refHref: p.refHref,
5070
+ onRef: p.onRef
5071
+ };
5072
+ const src = String(p.children ?? "").replace(/\r\n?/g, "\n");
5073
+ const cls = cx("ui-md", p.size === "small" && "is-small", p.className);
5074
+ if (p.inline) return /* @__PURE__ */ jsx("span", {
5075
+ className: cx(cls, "is-inline"),
5076
+ children: inline(src.trim().replace(/\n\s*\n/g, "\n"), c)
5077
+ });
5078
+ const top = p.topLevel ?? 4;
5079
+ const render = (blocks) => blocks.map((b) => {
5080
+ switch (b.t) {
5081
+ case "h": {
5082
+ const H = `h${Math.min(6, top + b.level - 1)}`;
5083
+ return /* @__PURE__ */ jsx(H, {
5084
+ className: "ui-md-h",
5085
+ children: inline(b.text, c)
5086
+ }, c.k());
5087
+ }
5088
+ case "p": return /* @__PURE__ */ jsx("p", { children: inline(b.text, c) }, c.k());
5089
+ case "hr": return /* @__PURE__ */ jsx("hr", {}, c.k());
5090
+ case "quote": return /* @__PURE__ */ jsx("blockquote", { children: render(b.blocks) }, c.k());
5091
+ case "list": {
5092
+ const items = b.items.map((it) => /* @__PURE__ */ jsx("li", { children: it.length === 1 && it[0].t === "p" ? inline(it[0].text, c) : render(it) }, c.k()));
5093
+ return b.ordered ? /* @__PURE__ */ jsx("ol", {
5094
+ start: b.start === 1 ? void 0 : b.start,
5095
+ children: items
5096
+ }, c.k()) : /* @__PURE__ */ jsx("ul", { children: items }, c.k());
5097
+ }
5098
+ case "code": return /* @__PURE__ */ jsx(CodeView, {
5099
+ className: "ui-md-code",
5100
+ code: b.code,
5101
+ language: fenceLang(b.lang),
5102
+ languageLabel: b.lang ? void 0 : false,
5103
+ copy: true,
5104
+ lineNumbers: false,
5105
+ refHref: p.refHref,
5106
+ onRef: p.onRef
5107
+ }, c.k());
5108
+ case "table": {
5109
+ const n = b.head.length;
5110
+ const numeric = b.head.map((_, j) => b.rows.length > 0 && b.rows.every((r) => !r[j] || NUM.test(r[j])));
5111
+ const align = (j) => {
5112
+ const a = b.align[j] ?? (numeric[j] ? "right" : null);
5113
+ return a ? { textAlign: a } : void 0;
5114
+ };
5115
+ return /* @__PURE__ */ jsx("div", {
5116
+ className: "ui-md-table-wrap",
5117
+ tabIndex: 0,
5118
+ role: "region",
5119
+ "aria-label": b.head.join("、"),
5120
+ children: /* @__PURE__ */ jsxs("table", {
5121
+ className: "ui-md-table",
5122
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: b.head.map((h, j) => /* @__PURE__ */ jsx("th", {
5123
+ style: align(j),
5124
+ children: inline(h, c)
5125
+ }, j)) }) }), /* @__PURE__ */ jsx("tbody", { children: b.rows.map((r, ri) => /* @__PURE__ */ jsx("tr", { children: Array.from({ length: n }, (_, j) => /* @__PURE__ */ jsx("td", {
5126
+ className: numeric[j] ? "is-num" : void 0,
5127
+ style: align(j),
5128
+ children: inline(r[j] ?? "", c)
5129
+ }, j)) }, ri)) })]
5130
+ })
5131
+ }, c.k());
5132
+ }
5133
+ }
5134
+ });
5135
+ return /* @__PURE__ */ jsx("div", {
5136
+ className: cls,
5137
+ children: render(parse(src.split("\n")))
5138
+ });
5139
+ }
5140
+ // src/components/Section/Section.tsx
5141
+ const Group = React.createContext(null);
5142
+ const MOVE_MS = 260;
5143
+ const reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
5144
+ function readStored(key) {
5145
+ if (!key) return void 0;
5146
+ try {
5147
+ const v = localStorage.getItem("ui-section:" + key);
5148
+ return v === "1" ? true : v === "0" ? false : void 0;
5149
+ } catch {
5150
+ return;
5151
+ }
5152
+ }
5153
+ function writeStored(key, open) {
5154
+ if (!key) return;
5155
+ try {
5156
+ localStorage.setItem("ui-section:" + key, open ? "1" : "0");
5157
+ } catch {}
5158
+ }
5159
+ /** A part of a page that can be closed: the title and a one-line summary stay visible. A line between sections;
5160
+ * the caret left of the title turns when it opens (260 ms, none with reduced motion). */
5161
+ function Section(p) {
5162
+ const group = React.useContext(Group);
5163
+ const uid = React.useId();
5164
+ const [own, setOwn] = React.useState(() => readStored(p.storageKey) ?? p.defaultOpen ?? false);
5165
+ const open = p.open ?? own;
5166
+ const set = React.useCallback((v) => {
5167
+ if (p.open === void 0) setOwn(v);
5168
+ writeStored(p.storageKey, v);
5169
+ p.onOpenChange?.(v);
5170
+ }, [
5171
+ p.open,
5172
+ p.storageKey,
5173
+ p.onOpenChange
5174
+ ]);
5175
+ const setRef = React.useRef(set);
5176
+ const openRef = React.useRef(open);
5177
+ React.useLayoutEffect(() => {
5178
+ setRef.current = set;
5179
+ openRef.current = open;
5180
+ });
5181
+ const [prevOpen, setPrevOpen] = React.useState(open);
5182
+ const [linger, setLinger] = React.useState(false);
5183
+ if (prevOpen !== open) {
5184
+ setPrevOpen(open);
5185
+ setLinger(!open);
5186
+ }
5187
+ React.useEffect(() => {
5188
+ if (!linger) return;
5189
+ const t = window.setTimeout(() => setLinger(false), reduced() ? 0 : MOVE_MS);
5190
+ return () => window.clearTimeout(t);
5191
+ }, [linger]);
5192
+ const inner = React.useRef(null);
5193
+ React.useEffect(() => {
5194
+ const el = inner.current;
5195
+ if (!el || p.lazy) return;
5196
+ if (open) {
5197
+ el.removeAttribute("hidden");
5198
+ return;
5199
+ }
5200
+ const t = window.setTimeout(() => el.setAttribute("hidden", "until-found"), reduced() ? 0 : MOVE_MS);
5201
+ const found = () => setRef.current(true);
5202
+ el.addEventListener("beforematch", found);
5203
+ return () => {
5204
+ window.clearTimeout(t);
5205
+ el.removeEventListener("beforematch", found);
5206
+ };
5207
+ }, [open, p.lazy]);
5208
+ const head = React.useRef(null);
5209
+ React.useEffect(() => {
5210
+ if (!p.id) return;
5211
+ const check = () => {
5212
+ if (decodeURIComponent(location.hash.slice(1)) !== p.id) return;
5213
+ if (!openRef.current) setRef.current(true);
5214
+ requestAnimationFrame(() => head.current?.scrollIntoView({
5215
+ block: "start",
5216
+ behavior: reduced() ? "auto" : "smooth"
5217
+ }));
5218
+ };
5219
+ check();
5220
+ window.addEventListener("hashchange", check);
5221
+ return () => window.removeEventListener("hashchange", check);
5222
+ }, [p.id]);
5223
+ const seen = React.useRef(group?.all.n ?? 0);
5224
+ React.useEffect(() => {
5225
+ if (!group || group.all.n === seen.current) return;
5226
+ seen.current = group.all.n;
5227
+ if (group.all.open !== openRef.current) setRef.current(group.all.open);
5228
+ }, [
5229
+ group,
5230
+ group?.all.n,
5231
+ group?.all.open
5232
+ ]);
5233
+ const report = group?.report;
5234
+ React.useEffect(() => {
5235
+ report?.(uid, open);
5236
+ }, [
5237
+ report,
5238
+ uid,
5239
+ open
5240
+ ]);
5241
+ React.useEffect(() => () => report?.(uid, null), [report, uid]);
5242
+ const H = `h${p.level ?? 3}`;
5243
+ const body = uid + "-body";
5244
+ const showContent = !p.lazy || open || linger;
5245
+ return /* @__PURE__ */ jsxs("section", {
5246
+ id: p.id,
5247
+ className: cx("ui-sec", open && "is-open", p.className),
5248
+ children: [/* @__PURE__ */ jsx(H, {
5249
+ ref: head,
5250
+ className: "ui-sec-h",
5251
+ children: /* @__PURE__ */ jsxs("button", {
5252
+ type: "button",
5253
+ className: "ui-sec-btn",
5254
+ "aria-expanded": open,
5255
+ "aria-controls": body,
5256
+ onClick: () => set(!open),
5257
+ children: [
5258
+ /* @__PURE__ */ jsx(Icon, {
5259
+ name: "caret-right",
5260
+ size: 18,
5261
+ className: "ui-sec-caret"
5262
+ }),
5263
+ /* @__PURE__ */ jsx("span", {
5264
+ className: "ui-sec-title",
5265
+ children: p.title
5266
+ }),
5267
+ p.summary != null && p.summary !== false ? /* @__PURE__ */ jsx("span", {
5268
+ className: "ui-sec-sum",
5269
+ children: p.summary
5270
+ }) : null
5271
+ ]
5272
+ })
5273
+ }), /* @__PURE__ */ jsx("div", {
5274
+ id: body,
5275
+ className: "ui-sec-body",
5276
+ children: /* @__PURE__ */ jsx("div", {
5277
+ ref: inner,
5278
+ className: "ui-sec-in",
5279
+ children: showContent ? /* @__PURE__ */ jsx("div", {
5280
+ className: "ui-sec-content",
5281
+ children: p.children
5282
+ }) : null
5283
+ })
5284
+ })]
5285
+ });
5286
+ }
5287
+ /** A run of Sections with 「全部展開」 and 「全部收合」 above them. */
5288
+ function SectionGroup({ children, actions, className }) {
5289
+ const [all, setAll] = React.useState({
5290
+ n: 0,
5291
+ open: false
5292
+ });
5293
+ const [states, setStates] = React.useState({});
5294
+ const report = React.useCallback((key, open) => {
5295
+ setStates((s) => {
5296
+ if (open === null) return key in s ? Object.fromEntries(Object.entries(s).filter(([id]) => id !== key)) : s;
5297
+ return s[key] === open ? s : {
5298
+ ...s,
5299
+ [key]: open
5300
+ };
5301
+ });
5302
+ }, []);
5303
+ const ctx = React.useMemo(() => ({
5304
+ all,
5305
+ report
5306
+ }), [all, report]);
5307
+ const vals = Object.values(states);
5308
+ return /* @__PURE__ */ jsxs("div", {
5309
+ className: cx("ui-sec-group", className),
5310
+ children: [/* @__PURE__ */ jsxs("div", {
5311
+ className: "ui-sec-bar",
5312
+ children: [
5313
+ actions ?? null,
5314
+ /* @__PURE__ */ jsx(Button, {
5315
+ icon: "arrows-out-line-vertical",
5316
+ disabled: vals.length > 0 && vals.every(Boolean),
5317
+ onClick: () => setAll((a) => ({
5318
+ n: a.n + 1,
5319
+ open: true
5320
+ })),
5321
+ children: tr("全部展開")
5322
+ }),
5323
+ /* @__PURE__ */ jsx(Button, {
5324
+ icon: "arrows-in-line-vertical",
5325
+ disabled: !vals.some(Boolean),
5326
+ onClick: () => setAll((a) => ({
5327
+ n: a.n + 1,
5328
+ open: false
5329
+ })),
5330
+ children: tr("全部收合")
5331
+ })
5332
+ ]
5333
+ }), /* @__PURE__ */ jsx(Group.Provider, {
5334
+ value: ctx,
5335
+ children
5336
+ })]
5337
+ });
5338
+ }
4663
5339
  // src/components/KpiCard/KpiCard.tsx
4664
5340
  /** One figure with its change and a sparkline. It is a card: put several in a grid, not inside another Card. */
4665
5341
  function KpiCard(props) {
@@ -4809,6 +5485,16 @@ function byCount(n, one, many) {
4809
5485
  const t = n === 1 ? tr(one) : "";
4810
5486
  return t && t !== one ? t : tr(many);
4811
5487
  }
5488
+ /** The width of text in a font (`600 13px` and mono or sans), measured on a canvas. */
5489
+ function textWidth(text, size, code) {
5490
+ if (measure === void 0) measure = document.createElement("canvas").getContext("2d");
5491
+ const c = measure;
5492
+ if (!c) return text.length * size * .6;
5493
+ const cs = getComputedStyle(document.documentElement);
5494
+ c.font = `600 ${size}px ` + ((code ? cs.getPropertyValue("--font-mono") : cs.getPropertyValue("--font-sans")) || "sans-serif");
5495
+ return c.measureText(text).width;
5496
+ }
5497
+ const TAG_KEEP = 8;
4812
5498
  function labelWidth(text) {
4813
5499
  const parts = text.split(SPLIT).filter(Boolean);
4814
5500
  if (measure === void 0) measure = document.createElement("canvas").getContext("2d");
@@ -4911,7 +5597,6 @@ function LayerGraph(p) {
4911
5597
  const [fit, setFit] = React.useState(null);
4912
5598
  const fitted = fit && fit.at === avail ? fit : null;
4913
5599
  const NW = fitted?.nw ?? (p.nodeWidth || 200);
4914
- const NH = 60;
4915
5600
  const GAP = 56;
4916
5601
  const spreadKey = avail + "#" + p.nodes.map((n) => n.id).join("|") + "#" + p.edges.map((e) => e.from + ">" + e.to + ":" + (e.label ?? "")).join("|");
4917
5602
  const [spreadAt, setSpread] = React.useState({
@@ -4929,6 +5614,13 @@ function LayerGraph(p) {
4929
5614
  const sizeOf = (n) => n.external && !n.shared ? void 0 : n.size ?? n.fns;
4930
5615
  const sharedIds = new Set(all.filter((n) => n.shared).map((n) => n.id));
4931
5616
  const main = all.filter((n) => !n.shared);
5617
+ const tagLine = main.some((n) => {
5618
+ if (!n.tag) return false;
5619
+ const name = n.name || n.id;
5620
+ const tagW = textWidth(n.tag, 12, false) + 12 + (n.tagTone === "warning" ? 15 : 0);
5621
+ return NW - (n.external ? 24 : 28) - 6 - tagW < textWidth(name.slice(0, TAG_KEEP), 13, true) + (name.length > TAG_KEEP ? 1 : 0);
5622
+ });
5623
+ const NH = tagLine ? 76 : 60;
4932
5624
  const shared = all.filter((n) => n.shared);
4933
5625
  const edges = p.edges.filter((e) => !sharedIds.has(e.from) && !sharedIds.has(e.to));
4934
5626
  const lab = (e) => !!(e.inferred || e.declared);
@@ -5485,7 +6177,7 @@ function LayerGraph(p) {
5485
6177
  d,
5486
6178
  role: "button",
5487
6179
  tabIndex: 0,
5488
- "aria-label": tr("{from} → {to},{what}", {
6180
+ "aria-label": tr("{from} 到 {to},{what}", {
5489
6181
  from: nameOf(e.from),
5490
6182
  to: nameOf(e.to),
5491
6183
  what: markText(e).replace(/`/g, "")
@@ -5921,6 +6613,13 @@ function LayerGraph(p) {
5921
6613
  const sizeText = (n) => withNum(p.sizeLabel, n, () => byCount(n, "1 個項目", "{n} 個項目"));
5922
6614
  const externalText = p.externalLabel ?? tr("repo 外");
5923
6615
  const useText = p.useLabel ?? tr("使用 {n} 次");
6616
+ const tagOf = (n) => n.tag ? /* @__PURE__ */ jsxs("span", {
6617
+ className: cx("ui-lg-tag", n.tagTone === "warning" && "is-warning"),
6618
+ children: [n.tagTone === "warning" ? /* @__PURE__ */ jsx(Icon, {
6619
+ name: "lock",
6620
+ size: 12
6621
+ }) : null, n.tag]
6622
+ }) : null;
5924
6623
  const nodes = main.map((n) => {
5925
6624
  const q = pos[n.id];
5926
6625
  const on = n.id === sel;
@@ -5940,14 +6639,19 @@ function LayerGraph(p) {
5940
6639
  children: [
5941
6640
  /* @__PURE__ */ jsxs("span", {
5942
6641
  className: "ui-lg-head",
5943
- children: [/* @__PURE__ */ jsx("span", {
5944
- className: "ui-lg-name",
5945
- children: n.name || n.id
5946
- }), used ? /* @__PURE__ */ jsx("span", {
5947
- className: "ui-lg-use",
5948
- children: monoNums(useText.replace("{n}", ""), [used])
5949
- }) : null]
6642
+ children: [
6643
+ /* @__PURE__ */ jsx("span", {
6644
+ className: "ui-lg-name",
6645
+ children: n.name || n.id
6646
+ }),
6647
+ tagLine ? null : tagOf(n),
6648
+ used ? /* @__PURE__ */ jsx("span", {
6649
+ className: "ui-lg-use",
6650
+ children: monoNums(useText.replace("{n}", ""), [used])
6651
+ }) : null
6652
+ ]
5950
6653
  }),
6654
+ tagLine ? tagOf(n) : null,
5951
6655
  n.external ? /* @__PURE__ */ jsx("span", {
5952
6656
  className: "ui-lg-ext",
5953
6657
  children: externalText
@@ -5977,9 +6681,12 @@ function LayerGraph(p) {
5977
6681
  className: cx("ui-lg-node", "ui-lg-chip", on && "is-selected", dim && "is-dim"),
5978
6682
  "aria-pressed": p.onSelect ? on : void 0,
5979
6683
  onClick: p.onSelect ? () => pick(s.id, on) : void 0,
5980
- children: [/* @__PURE__ */ jsx("span", {
5981
- className: "ui-lg-name",
5982
- children: s.name || s.id
6684
+ children: [/* @__PURE__ */ jsxs("span", {
6685
+ className: "ui-lg-head",
6686
+ children: [/* @__PURE__ */ jsx("span", {
6687
+ className: "ui-lg-name",
6688
+ children: s.name || s.id
6689
+ }), tagOf(s)]
5983
6690
  }), /* @__PURE__ */ jsx("span", {
5984
6691
  className: "ui-lg-shared-meta",
5985
6692
  children: monoNums(sharedMeta.replace("{a}", "").replace("{b}", ""), [Object.keys(by).length, total])
@@ -6014,10 +6721,10 @@ function LayerGraph(p) {
6014
6721
  children: p.listLabels?.nodes ?? tr("項目")
6015
6722
  }), /* @__PURE__ */ jsx("ul", { children: all.map((n) => {
6016
6723
  const size = sizeOf(n);
6017
- return listItem(n.id, n.id === sel, !near(n.id), p.onSelect ? () => pick(n.id, n.id === sel) : void 0, /* @__PURE__ */ jsx("span", {
6724
+ return listItem(n.id, n.id === sel, !near(n.id), p.onSelect ? () => pick(n.id, n.id === sel) : void 0, /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
6018
6725
  className: "ui-lg-code",
6019
6726
  children: n.name || n.id
6020
- }), n.external && !n.shared ? /* @__PURE__ */ jsxs("span", {
6727
+ }), tagOf(n)] }), n.external && !n.shared ? /* @__PURE__ */ jsxs("span", {
6021
6728
  className: "ui-lg-limeta",
6022
6729
  children: [tr(","), externalText]
6023
6730
  }) : size != null ? /* @__PURE__ */ jsxs("span", {
@@ -6036,7 +6743,16 @@ function LayerGraph(p) {
6036
6743
  className: "ui-lg-code",
6037
6744
  children: nameOf(e.from)
6038
6745
  }),
6039
- " → ",
6746
+ " ",
6747
+ /* @__PURE__ */ jsx("span", {
6748
+ "aria-hidden": "true",
6749
+ children: "→"
6750
+ }),
6751
+ /* @__PURE__ */ jsx("span", {
6752
+ className: "ui-visually-hidden",
6753
+ children: tr("到")
6754
+ }),
6755
+ " ",
6040
6756
  /* @__PURE__ */ jsx("span", {
6041
6757
  className: "ui-lg-code",
6042
6758
  children: nameOf(e.to)
@@ -7894,7 +8610,7 @@ function TreeList(p) {
7894
8610
  for (const s of siblings) if (s.id !== n.id) o[s.id] = false;
7895
8611
  }
7896
8612
  o[n.id] = will;
7897
- setFresh(will && !reduced() ? { [n.id]: true } : {});
8613
+ setFresh(will && !reduced$1() ? { [n.id]: true } : {});
7898
8614
  if (will) load(n);
7899
8615
  p.onToggle?.(n, will, Object.keys(o).filter((k) => o[k]));
7900
8616
  if (!p.open) setOwnOpen(o);
@@ -8315,7 +9031,7 @@ function TreeList(p) {
8315
9031
  children: [showToggleAll ? /* @__PURE__ */ jsx(Button, {
8316
9032
  onClick: () => {
8317
9033
  const o = Object.fromEntries(folders.map((f) => [f.id, anyClosed]));
8318
- setFresh(anyClosed && !reduced() ? Object.fromEntries(folders.filter((f) => !open[f.id]).map((f) => [f.id, true])) : {});
9034
+ setFresh(anyClosed && !reduced$1() ? Object.fromEntries(folders.filter((f) => !open[f.id]).map((f) => [f.id, true])) : {});
8319
9035
  if (p.open) p.onToggleAll?.(anyClosed, anyClosed ? [.../* @__PURE__ */ new Set([...p.open, ...folders.map((f) => f.id)])] : []);
8320
9036
  else setOwnOpen(o);
8321
9037
  },
@@ -8362,6 +9078,6 @@ function TreeList(p) {
8362
9078
  })]
8363
9079
  });
8364
9080
  }
8365
- export { AccentPicker, ActionBar, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, setAccent, setLocale, setTheme, tr as t, useTour };
9081
+ export { AccentPicker, ActionBar, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Markdown, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Section, SectionGroup, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour };
8366
9082
 
8367
9083
  //# sourceMappingURL=index.js.map