@pactor-app/ui 1.22.0 → 1.24.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.cjs CHANGED
@@ -13279,6 +13279,10 @@ function ChatPage({
13279
13279
  conversationTitle,
13280
13280
  conversationHeaderAction,
13281
13281
  onConversationHeaderAction,
13282
+ conversationRailItems = [],
13283
+ hideArtifactRailItem = false,
13284
+ activeConversationRailKey,
13285
+ onConversationRailChange,
13282
13286
  messages = [],
13283
13287
  sending,
13284
13288
  composerPlaceholder,
@@ -13319,6 +13323,51 @@ function ChatPage({
13319
13323
  if (!controlled) setInnerOpen(next);
13320
13324
  onArtifactOpenChange?.(next);
13321
13325
  };
13326
+ const railControlled = activeConversationRailKey !== void 0;
13327
+ const [activeRailInner, setActiveRailInner] = (0, import_react67.useState)(null);
13328
+ const activeRailKey = railControlled ? activeConversationRailKey : activeRailInner;
13329
+ const setActiveRailKey = (next) => {
13330
+ if (!railControlled) setActiveRailInner(next);
13331
+ onConversationRailChange?.(next);
13332
+ };
13333
+ const visibleRailItems = conversationRailItems.filter((item) => item.hidden !== true);
13334
+ const activeRailItem = visibleRailItems.find(
13335
+ (item) => item.key === activeRailKey
13336
+ );
13337
+ const activePanelItem = activeRailItem?.display === "panel" && activeRailItem.content !== void 0 ? activeRailItem : void 0;
13338
+ const activePopoverItem = activeRailItem !== void 0 && activeRailItem.display !== "panel" && activeRailItem.content !== void 0 ? activeRailItem : void 0;
13339
+ const toggleRailItem = (item) => {
13340
+ const next = activeRailKey === item.key ? null : item.key;
13341
+ if (next !== null && item.display === "panel") {
13342
+ setOpen(false);
13343
+ }
13344
+ setActiveRailKey(next);
13345
+ };
13346
+ const toggleArtifact = () => {
13347
+ if (!open && activePanelItem) {
13348
+ setActiveRailKey(null);
13349
+ }
13350
+ setOpen(!open);
13351
+ };
13352
+ (0, import_react67.useEffect)(() => {
13353
+ if (!activePopoverItem) return;
13354
+ const onKeyDown = (event) => {
13355
+ if (event.key === "Escape") setActiveRailKey(null);
13356
+ };
13357
+ const onPointerDown = (event) => {
13358
+ const target = event.target;
13359
+ if (target.closest("[data-slot=chat-page-rail-popover]") || target.closest("[data-slot=chat-page-conv-rail]")) {
13360
+ return;
13361
+ }
13362
+ setActiveRailKey(null);
13363
+ };
13364
+ document.addEventListener("keydown", onKeyDown);
13365
+ document.addEventListener("mousedown", onPointerDown);
13366
+ return () => {
13367
+ document.removeEventListener("keydown", onKeyDown);
13368
+ document.removeEventListener("mousedown", onPointerDown);
13369
+ };
13370
+ });
13322
13371
  const { renderChildren } = (0, import_runtime26.useRenderer)();
13323
13372
  const renderSlot = (slot) => (0, import_react67.isValidElement)(slot) || typeof slot !== "object" || slot === null ? slot : renderChildren([slot]);
13324
13373
  const convCollControlled = conversationSectionCollapsed !== void 0;
@@ -13350,10 +13399,58 @@ function ChatPage({
13350
13399
  onClick: () => onMenuSelect?.(item.key)
13351
13400
  }
13352
13401
  ) }, item.key);
13402
+ const convRailButton = (item, active, onClick) => {
13403
+ const button = /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13404
+ Button2,
13405
+ {
13406
+ icon: item.icon,
13407
+ variant: "text",
13408
+ className: cn(active ? "bg-accent text-accent-foreground" : void 0, "px-2"),
13409
+ onClick
13410
+ }
13411
+ );
13412
+ return item.label !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Tooltip2, { content: item.label, side: "left", children: button }, item.key) : /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("span", { children: button }, item.key);
13413
+ };
13414
+ const convRailVisible = !hideArtifactRailItem || visibleRailItems.length > 0;
13415
+ const convRail = convRailVisible ? /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(
13416
+ "div",
13417
+ {
13418
+ "data-slot": "chat-page-conv-rail",
13419
+ className: "relative flex w-(--pactor-chat-rail-width) shrink-0 flex-col items-center gap-1 px-1 py-2",
13420
+ children: [
13421
+ !hideArtifactRailItem ? convRailButton(
13422
+ {
13423
+ key: "artifact",
13424
+ icon: open ? "panel-right-close" : "package",
13425
+ label: open ? "\u6536\u8D77\u4EA7\u7269\u533A" : artifactTitle
13426
+ },
13427
+ open,
13428
+ toggleArtifact
13429
+ ) : null,
13430
+ visibleRailItems.map(
13431
+ (item) => convRailButton(item, activeRailKey === item.key, () => toggleRailItem(item))
13432
+ ),
13433
+ activePopoverItem ? /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13434
+ "div",
13435
+ {
13436
+ "data-slot": "chat-page-rail-popover",
13437
+ className: "absolute right-full top-0 z-10 mr-2 overflow-auto rounded-lg border border-border bg-popover shadow-md",
13438
+ style: {
13439
+ width: "var(--pactor-chat-rail-popover-width)",
13440
+ maxWidth: "calc(100cqw - 2rem)",
13441
+ maxHeight: "calc(100% - 1rem)"
13442
+ },
13443
+ children: renderSlot(activePopoverItem.content)
13444
+ }
13445
+ ) : null
13446
+ ]
13447
+ }
13448
+ ) : null;
13353
13449
  const chatArea = /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)("div", { "data-slot": "chat-page-conversation", className: "flex h-full min-w-0 flex-1 flex-col", children: [
13354
13450
  /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(
13355
13451
  "div",
13356
13452
  {
13453
+ "data-slot": "chat-page-conversation-header",
13357
13454
  className: "flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5",
13358
13455
  children: [
13359
13456
  /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Text, { text: conversationTitle, strong: true }),
@@ -13365,66 +13462,62 @@ function ChatPage({
13365
13462
  variant: "text",
13366
13463
  onClick: () => onConversationHeaderAction?.()
13367
13464
  }
13368
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Tooltip2, { content: open ? "\u6536\u8D77\u4EA7\u7269\u533A" : artifactTitle, side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13369
- Button2,
13370
- {
13371
- icon: open ? "panel-right-close" : "panel-right-open",
13372
- variant: "text",
13373
- onClick: () => setOpen(!open)
13374
- }
13375
- ) })
13465
+ ) }) : null
13376
13466
  ]
13377
13467
  }
13378
13468
  ),
13379
- /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(
13380
- "div",
13381
- {
13382
- "data-slot": "chat-page-conversation-body",
13383
- className: "mx-auto flex min-h-0 w-[61.8cqw] max-w-full flex-1 flex-col",
13384
- children: [
13385
- messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13386
- Welcome,
13387
- {
13388
- title: welcome?.title,
13389
- description: welcome?.description,
13390
- prompts: welcome?.prompts,
13391
- style: { flex: 1 },
13392
- onSelect: (value) => onSend?.(value)
13393
- }
13394
- ) : /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13395
- MessageList,
13396
- {
13397
- messages,
13398
- className: "scrollbar-subtle",
13399
- style: { flex: 1, minHeight: 0, padding: 16 },
13400
- onAction: onMessageAction,
13401
- onOpenArtifacts: () => setOpen(true)
13402
- }
13403
- ),
13404
- /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13405
- Composer,
13406
- {
13407
- placeholder: composerPlaceholder,
13408
- loading: sending,
13409
- models,
13410
- model,
13411
- contexts,
13412
- contextItems,
13413
- attachments,
13414
- footer: composerFooter,
13415
- style: { padding: 16, paddingBottom: composerBottom ? 8 : 16, flexShrink: 0 },
13416
- onModelChange,
13417
- onContextItemsChange,
13418
- onAttachFiles,
13419
- onRemoveAttachment,
13420
- onRetryAttachment,
13421
- onSubmit: (text) => onSend?.(text)
13422
- }
13423
- ),
13424
- composerBottom ? /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("div", { "data-slot": "chat-page-composer-bottom", className: "shrink-0 px-4 pb-2 text-center", children: renderSlot(composerBottom) }) : null
13425
- ]
13426
- }
13427
- )
13469
+ /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)("div", { className: "flex min-h-0 flex-1", children: [
13470
+ /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(
13471
+ "div",
13472
+ {
13473
+ "data-slot": "chat-page-conversation-body",
13474
+ className: "mx-auto flex min-h-0 w-[61.8cqw] max-w-full flex-col",
13475
+ children: [
13476
+ messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13477
+ Welcome,
13478
+ {
13479
+ title: welcome?.title,
13480
+ description: welcome?.description,
13481
+ prompts: welcome?.prompts,
13482
+ style: { flex: 1 },
13483
+ onSelect: (value) => onSend?.(value)
13484
+ }
13485
+ ) : /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13486
+ MessageList,
13487
+ {
13488
+ messages,
13489
+ className: "scrollbar-subtle",
13490
+ style: { flex: 1, minHeight: 0, padding: 16 },
13491
+ onAction: onMessageAction,
13492
+ onOpenArtifacts: () => setOpen(true)
13493
+ }
13494
+ ),
13495
+ /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13496
+ Composer,
13497
+ {
13498
+ placeholder: composerPlaceholder,
13499
+ loading: sending,
13500
+ models,
13501
+ model,
13502
+ contexts,
13503
+ contextItems,
13504
+ attachments,
13505
+ footer: composerFooter,
13506
+ style: { padding: 16, paddingBottom: composerBottom ? 8 : 16, flexShrink: 0 },
13507
+ onModelChange,
13508
+ onContextItemsChange,
13509
+ onAttachFiles,
13510
+ onRemoveAttachment,
13511
+ onRetryAttachment,
13512
+ onSubmit: (text) => onSend?.(text)
13513
+ }
13514
+ ),
13515
+ composerBottom ? /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("div", { "data-slot": "chat-page-composer-bottom", className: "shrink-0 px-4 pb-2 text-center", children: renderSlot(composerBottom) }) : null
13516
+ ]
13517
+ }
13518
+ ),
13519
+ convRail
13520
+ ] })
13428
13521
  ] });
13429
13522
  const activeArtifact = artifacts.find((item) => item.id === activeArtifactId) ?? (activeArtifactId === void 0 || activeArtifactId === "" ? artifacts[artifacts.length - 1] : void 0);
13430
13523
  const artifactPanel = /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
@@ -13556,10 +13649,17 @@ function ChatPage({
13556
13649
  ]
13557
13650
  }
13558
13651
  ),
13559
- /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("div", { className: "@container h-full min-w-0 flex-1", children: open ? /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(PanelGroup, { orientation: "horizontal", style: { width: "100%", height: "100%" }, children: [
13652
+ /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("div", { className: "@container h-full min-w-0 flex-1", children: open || activePanelItem ? /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(PanelGroup, { orientation: "horizontal", style: { width: "100%", height: "100%" }, children: [
13560
13653
  /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Panel, { defaultSize: "62%", children: chatArea }),
13561
13654
  /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(ResizableHandle, { withHandle: true }),
13562
- /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Panel, { defaultSize: "38%", minSize: "380px", maxSize: "760px", children: artifactPanel })
13655
+ /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Panel, { defaultSize: "38%", minSize: "380px", maxSize: "760px", children: activePanelItem ? /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
13656
+ "div",
13657
+ {
13658
+ "data-slot": "chat-page-rail-panel",
13659
+ className: "flex h-full min-w-0 flex-col border-l border-border bg-muted",
13660
+ children: renderSlot(activePanelItem.content)
13661
+ }
13662
+ ) : artifactPanel })
13563
13663
  ] }) : chatArea })
13564
13664
  ]
13565
13665
  }
@@ -13699,10 +13799,10 @@ function EChartBase({
13699
13799
  dataIndex: params.dataIndex
13700
13800
  });
13701
13801
  });
13702
- const observer = new ResizeObserver(() => chart?.resize());
13703
- observer.observe(host);
13802
+ const observer2 = new ResizeObserver(() => chart?.resize());
13803
+ observer2.observe(host);
13704
13804
  return () => {
13705
- observer.disconnect();
13805
+ observer2.disconnect();
13706
13806
  chart?.dispose();
13707
13807
  chartRef.current = null;
13708
13808
  };
@@ -14163,6 +14263,9 @@ function buildComposedOption(input, theme) {
14163
14263
  };
14164
14264
  }
14165
14265
 
14266
+ // src/components/chart/lib/use-chart-theme.ts
14267
+ var import_react69 = require("react");
14268
+
14166
14269
  // src/components/chart/lib/color.ts
14167
14270
  var LPAREN = String.fromCharCode(40);
14168
14271
  var RPAREN = String.fromCharCode(41);
@@ -14259,6 +14362,64 @@ function getChartTheme() {
14259
14362
  return FALLBACK_THEME;
14260
14363
  }
14261
14364
  }
14365
+ function resetChartTheme() {
14366
+ cached = null;
14367
+ }
14368
+ var CHART_SKIN_CHANGE_EVENT = "pactor:skin-change";
14369
+ var listeners = /* @__PURE__ */ new Set();
14370
+ var observer = null;
14371
+ var scheduled = false;
14372
+ function scheduleNotify() {
14373
+ if (scheduled) return;
14374
+ scheduled = true;
14375
+ const enqueue = typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
14376
+ enqueue(() => {
14377
+ scheduled = false;
14378
+ resetChartTheme();
14379
+ for (const listener of [...listeners]) {
14380
+ listener();
14381
+ }
14382
+ });
14383
+ }
14384
+ function handleResourceLoad(event) {
14385
+ const target = event.target;
14386
+ if (target instanceof HTMLLinkElement || target instanceof HTMLStyleElement) {
14387
+ scheduleNotify();
14388
+ }
14389
+ }
14390
+ function subscribeChartTheme(listener) {
14391
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") {
14392
+ return () => {
14393
+ };
14394
+ }
14395
+ listeners.add(listener);
14396
+ if (!observer) {
14397
+ observer = new MutationObserver(scheduleNotify);
14398
+ observer.observe(document.documentElement, { attributes: true });
14399
+ observer.observe(document.head, {
14400
+ attributes: true,
14401
+ childList: true,
14402
+ characterData: true,
14403
+ subtree: true
14404
+ });
14405
+ document.addEventListener("load", handleResourceLoad, true);
14406
+ window.addEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
14407
+ }
14408
+ return () => {
14409
+ listeners.delete(listener);
14410
+ if (listeners.size === 0 && observer) {
14411
+ observer.disconnect();
14412
+ observer = null;
14413
+ document.removeEventListener("load", handleResourceLoad, true);
14414
+ window.removeEventListener(CHART_SKIN_CHANGE_EVENT, scheduleNotify);
14415
+ }
14416
+ };
14417
+ }
14418
+
14419
+ // src/components/chart/lib/use-chart-theme.ts
14420
+ function useChartTheme() {
14421
+ return (0, import_react69.useSyncExternalStore)(subscribeChartTheme, getChartTheme, getChartTheme);
14422
+ }
14262
14423
 
14263
14424
  // src/components/chart/AreaChart/index.tsx
14264
14425
  var import_jsx_runtime189 = require("react/jsx-runtime");
@@ -14277,7 +14438,7 @@ function AreaChart({
14277
14438
  }) {
14278
14439
  const option = buildAreaOption(
14279
14440
  { data, xKey, yKeys, stacked, fillOpacity, colors, title },
14280
- getChartTheme()
14441
+ useChartTheme()
14281
14442
  );
14282
14443
  return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
14283
14444
  EChartBase,
@@ -14308,7 +14469,7 @@ function BarChart2({
14308
14469
  }) {
14309
14470
  const option = buildBarOption(
14310
14471
  { data, yKey, yKeys: xKeys, stacked, colors, title },
14311
- getChartTheme()
14472
+ useChartTheme()
14312
14473
  );
14313
14474
  return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
14314
14475
  EChartBase,
@@ -14340,7 +14501,7 @@ function BubbleChart({
14340
14501
  }) {
14341
14502
  const option = buildBubbleOption(
14342
14503
  { data, xKey, yKey, sizeKey, seriesKey, colors, title },
14343
- getChartTheme()
14504
+ useChartTheme()
14344
14505
  );
14345
14506
  return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
14346
14507
  EChartBase,
@@ -14371,7 +14532,7 @@ function ColumnChart({
14371
14532
  }) {
14372
14533
  const option = buildColumnOption(
14373
14534
  { data, xKey, yKeys, stacked, colors, title },
14374
- getChartTheme()
14535
+ useChartTheme()
14375
14536
  );
14376
14537
  return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(
14377
14538
  EChartBase,
@@ -14401,7 +14562,7 @@ function ComposedChart({
14401
14562
  }) {
14402
14563
  const option = buildComposedOption(
14403
14564
  { data, xKey, series, colors, title },
14404
- getChartTheme()
14565
+ useChartTheme()
14405
14566
  );
14406
14567
  return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
14407
14568
  EChartBase,
@@ -14447,7 +14608,7 @@ function DonutChart({
14447
14608
  colors,
14448
14609
  title
14449
14610
  },
14450
- getChartTheme()
14611
+ useChartTheme()
14451
14612
  );
14452
14613
  return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
14453
14614
  EChartBase,
@@ -14478,7 +14639,7 @@ function FunnelChart2({
14478
14639
  }) {
14479
14640
  const option = buildFunnelOption(
14480
14641
  { data, nameKey, valueKey, sort, colors, title },
14481
- getChartTheme()
14642
+ useChartTheme()
14482
14643
  );
14483
14644
  return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
14484
14645
  EChartBase,
@@ -14509,7 +14670,7 @@ function GaugeChart2({
14509
14670
  }) {
14510
14671
  const option = buildGaugeOption(
14511
14672
  { value, min, max, thresholds, unit, title },
14512
- getChartTheme()
14673
+ useChartTheme()
14513
14674
  );
14514
14675
  return /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
14515
14676
  EChartBase,
@@ -14539,7 +14700,7 @@ function Heatmap({
14539
14700
  }) {
14540
14701
  const option = buildHeatmapOption(
14541
14702
  { data, xKey, yKey, valueKey, title },
14542
- getChartTheme()
14703
+ useChartTheme()
14543
14704
  );
14544
14705
  return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
14545
14706
  EChartBase,
@@ -14572,7 +14733,7 @@ function LineChart2({
14572
14733
  }) {
14573
14734
  const option = buildLineOption(
14574
14735
  { data, xKey, yKeys, smooth, showArea, stacked, colors, title },
14575
- getChartTheme()
14736
+ useChartTheme()
14576
14737
  );
14577
14738
  return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
14578
14739
  EChartBase,
@@ -14588,7 +14749,7 @@ function LineChart2({
14588
14749
  }
14589
14750
 
14590
14751
  // src/components/chart/MapChart/index.tsx
14591
- var import_react69 = require("react");
14752
+ var import_react70 = require("react");
14592
14753
  var import_jsx_runtime199 = require("react/jsx-runtime");
14593
14754
  var fetchedMaps = /* @__PURE__ */ new Set();
14594
14755
  function hasRegisteredMap(mapName) {
@@ -14611,7 +14772,8 @@ function MapChart2({
14611
14772
  className,
14612
14773
  style
14613
14774
  }) {
14614
- const [loadState, setLoadState] = (0, import_react69.useState)(
14775
+ const theme = useChartTheme();
14776
+ const [loadState, setLoadState] = (0, import_react70.useState)(
14615
14777
  () => geoJson || !geoJsonUrl || hasRegisteredMap(mapName) ? "idle" : "loading"
14616
14778
  );
14617
14779
  if (geoJson) {
@@ -14620,7 +14782,7 @@ function MapChart2({
14620
14782
  } catch {
14621
14783
  }
14622
14784
  }
14623
- (0, import_react69.useEffect)(() => {
14785
+ (0, import_react70.useEffect)(() => {
14624
14786
  if (geoJson || !geoJsonUrl || hasRegisteredMap(mapName) || fetchedMaps.has(mapName)) {
14625
14787
  setLoadState("idle");
14626
14788
  return;
@@ -14677,7 +14839,7 @@ function MapChart2({
14677
14839
  }
14678
14840
  );
14679
14841
  }
14680
- const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, getChartTheme());
14842
+ const option = buildMapOption({ mapName, data, nameKey, valueKey, title }, theme);
14681
14843
  return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
14682
14844
  EChartBase,
14683
14845
  {
@@ -14764,7 +14926,7 @@ function PieChart2({
14764
14926
  }) {
14765
14927
  const option = buildPieOption(
14766
14928
  { data, nameKey, valueKey, showLabel, colors, title },
14767
- getChartTheme()
14929
+ useChartTheme()
14768
14930
  );
14769
14931
  return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
14770
14932
  EChartBase,
@@ -14794,7 +14956,7 @@ function RadarChart2({
14794
14956
  }) {
14795
14957
  const option = buildRadarOption(
14796
14958
  { data, indicatorKey, yKeys, colors, title },
14797
- getChartTheme()
14959
+ useChartTheme()
14798
14960
  );
14799
14961
  return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
14800
14962
  EChartBase,
@@ -14820,7 +14982,7 @@ function SankeyChart2({
14820
14982
  className,
14821
14983
  style
14822
14984
  }) {
14823
- const option = buildSankeyOption({ nodes, links, title }, getChartTheme());
14985
+ const option = buildSankeyOption({ nodes, links, title }, useChartTheme());
14824
14986
  return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
14825
14987
  EChartBase,
14826
14988
  {
@@ -14850,7 +15012,7 @@ function ScatterChart2({
14850
15012
  }) {
14851
15013
  const option = buildScatterOption(
14852
15014
  { data, xKey, yKey, seriesKey, colors, title },
14853
- getChartTheme()
15015
+ useChartTheme()
14854
15016
  );
14855
15017
  return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(
14856
15018
  EChartBase,
@@ -14880,7 +15042,7 @@ function TreeChart2({
14880
15042
  }) {
14881
15043
  const option = buildTreeOption(
14882
15044
  { data, title, orient, edgeShape, initialTreeDepth },
14883
- getChartTheme()
15045
+ useChartTheme()
14884
15046
  );
14885
15047
  return /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(
14886
15048
  EChartBase,
@@ -15117,10 +15279,10 @@ function collectDefaultOpenKeys(registry, activeMenuId) {
15117
15279
  var import_permission = require("@pactor-app/permission");
15118
15280
  var import_router = require("@pactor-app/router");
15119
15281
  var import_runtime27 = require("@pactor-app/runtime");
15120
- var import_react71 = require("react");
15282
+ var import_react72 = require("react");
15121
15283
 
15122
15284
  // src/layout/admin/use-media-query.ts
15123
- var import_react70 = require("react");
15285
+ var import_react71 = require("react");
15124
15286
  var BREAKPOINT_PX = {
15125
15287
  xs: 480,
15126
15288
  sm: 576,
@@ -15130,10 +15292,10 @@ var BREAKPOINT_PX = {
15130
15292
  xxl: 1600
15131
15293
  };
15132
15294
  function useMediaQuery(query) {
15133
- const [matches, setMatches] = (0, import_react70.useState)(
15295
+ const [matches, setMatches] = (0, import_react71.useState)(
15134
15296
  () => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : false
15135
15297
  );
15136
- (0, import_react70.useEffect)(() => {
15298
+ (0, import_react71.useEffect)(() => {
15137
15299
  if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
15138
15300
  return;
15139
15301
  }
@@ -15176,8 +15338,8 @@ function CollapsedGroupFlyout({
15176
15338
  activeMenuId,
15177
15339
  defaultOpenKeys
15178
15340
  }) {
15179
- const [open, setOpen] = (0, import_react71.useState)(false);
15180
- const closeTimer = (0, import_react71.useRef)(void 0);
15341
+ const [open, setOpen] = (0, import_react72.useState)(false);
15342
+ const closeTimer = (0, import_react72.useRef)(void 0);
15181
15343
  const openNow = () => {
15182
15344
  window.clearTimeout(closeTimer.current);
15183
15345
  setOpen(true);
@@ -15186,7 +15348,7 @@ function CollapsedGroupFlyout({
15186
15348
  window.clearTimeout(closeTimer.current);
15187
15349
  closeTimer.current = window.setTimeout(() => setOpen(false), 200);
15188
15350
  };
15189
- (0, import_react71.useEffect)(() => () => window.clearTimeout(closeTimer.current), []);
15351
+ (0, import_react72.useEffect)(() => () => window.clearTimeout(closeTimer.current), []);
15190
15352
  return /* @__PURE__ */ (0, import_jsx_runtime206.jsxs)(Popover, { open, onOpenChange: setOpen, children: [
15191
15353
  /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(
15192
15354
  PopoverTrigger,
@@ -15370,16 +15532,16 @@ function AdminLayout({
15370
15532
  const showTabs = config.tabs ?? false;
15371
15533
  const showBreadcrumb = config.breadcrumb ?? false;
15372
15534
  const showFooter = config.footer ?? false;
15373
- const [collapsed, setCollapsed] = (0, import_react71.useState)(config.collapsed ?? false);
15535
+ const [collapsed, setCollapsed] = (0, import_react72.useState)(config.collapsed ?? false);
15374
15536
  const broken = useBreakpointBelow(config.breakpoint);
15375
15537
  const effectiveCollapsed = collapsed || broken;
15376
- const [bridgeRoute, setBridgeRoute] = (0, import_react71.useState)(
15538
+ const [bridgeRoute, setBridgeRoute] = (0, import_react72.useState)(
15377
15539
  () => (0, import_router.resolveRoute)(registry, bridge.getLocation())
15378
15540
  );
15379
- const [tabs, setTabs] = (0, import_react71.useState)([]);
15380
- const tabsRef = (0, import_react71.useRef)(tabs);
15541
+ const [tabs, setTabs] = (0, import_react72.useState)([]);
15542
+ const tabsRef = (0, import_react72.useRef)(tabs);
15381
15543
  tabsRef.current = tabs;
15382
- (0, import_react71.useEffect)(() => {
15544
+ (0, import_react72.useEffect)(() => {
15383
15545
  const handleLocation = (location) => {
15384
15546
  const next = (0, import_router.resolveRoute)(registry, location);
15385
15547
  setBridgeRoute(next);
@@ -15400,16 +15562,16 @@ function AdminLayout({
15400
15562
  }, [registry, bridge]);
15401
15563
  const route = routeProp ?? bridgeRoute;
15402
15564
  const activeMenuId = route?.activeMenu;
15403
- const visibleMenus = (0, import_react71.useMemo)(
15565
+ const visibleMenus = (0, import_react72.useMemo)(
15404
15566
  () => buildVisibleMenuTree(registry, permissionChecker),
15405
15567
  [registry, permissionChecker]
15406
15568
  );
15407
- const defaultOpenKeysRef = (0, import_react71.useRef)(null);
15569
+ const defaultOpenKeysRef = (0, import_react72.useRef)(null);
15408
15570
  if (defaultOpenKeysRef.current === null) {
15409
15571
  defaultOpenKeysRef.current = collectDefaultOpenKeys(registry, activeMenuId);
15410
15572
  }
15411
15573
  const defaultOpenKeys = defaultOpenKeysRef.current;
15412
- const activeTopId = (0, import_react71.useMemo)(() => {
15574
+ const activeTopId = (0, import_react72.useMemo)(() => {
15413
15575
  if (activeMenuId !== void 0) {
15414
15576
  const chain = findMenuChain(registry, activeMenuId);
15415
15577
  if (chain.length > 0) {
@@ -15418,11 +15580,11 @@ function AdminLayout({
15418
15580
  }
15419
15581
  return void 0;
15420
15582
  }, [registry, activeMenuId]);
15421
- const [selectedTopId, setSelectedTopId] = (0, import_react71.useState)();
15583
+ const [selectedTopId, setSelectedTopId] = (0, import_react72.useState)();
15422
15584
  const secondaryTopId = selectedTopId ?? activeTopId ?? visibleMenus.find((m) => m.type === "group")?.id ?? visibleMenus[0]?.id;
15423
15585
  const secondaryTop = visibleMenus.find((m) => m.id === secondaryTopId);
15424
15586
  const hasSecondary = (secondaryTop?.children?.length ?? 0) > 0;
15425
- const breadcrumbItems = (0, import_react71.useMemo)(() => {
15587
+ const breadcrumbItems = (0, import_react72.useMemo)(() => {
15426
15588
  if (!showBreadcrumb || activeMenuId === void 0) {
15427
15589
  return [];
15428
15590
  }
@@ -15675,7 +15837,7 @@ function BlankLayout({ children }) {
15675
15837
 
15676
15838
  // src/layout/chat/ChatLayout.tsx
15677
15839
  var import_permission2 = require("@pactor-app/permission");
15678
- var import_react72 = require("react");
15840
+ var import_react73 = require("react");
15679
15841
  var import_jsx_runtime208 = require("react/jsx-runtime");
15680
15842
  function ChatLayout({
15681
15843
  brand,
@@ -15691,7 +15853,7 @@ function ChatLayout({
15691
15853
  sidebarFooter,
15692
15854
  children
15693
15855
  }) {
15694
- const registryMenus = (0, import_react72.useMemo)(() => {
15856
+ const registryMenus = (0, import_react73.useMemo)(() => {
15695
15857
  if (menu !== void 0 || registry === void 0) {
15696
15858
  return [];
15697
15859
  }
@@ -15700,10 +15862,10 @@ function ChatLayout({
15700
15862
  return visible.flatMap((item) => menuItemToMenuData(item));
15701
15863
  }, [menu, registry, permissionChecker]);
15702
15864
  const menuItems = menu ?? registryMenus;
15703
- const [bridgePath, setBridgePath] = (0, import_react72.useState)(
15865
+ const [bridgePath, setBridgePath] = (0, import_react73.useState)(
15704
15866
  () => bridge?.getLocation().pathname ?? "/"
15705
15867
  );
15706
- (0, import_react72.useEffect)(() => {
15868
+ (0, import_react73.useEffect)(() => {
15707
15869
  if (bridge === void 0) {
15708
15870
  return;
15709
15871
  }
@@ -15711,7 +15873,7 @@ function ChatLayout({
15711
15873
  setBridgePath(location.pathname);
15712
15874
  });
15713
15875
  }, [bridge]);
15714
- const activeKey = (0, import_react72.useMemo)(() => {
15876
+ const activeKey = (0, import_react73.useMemo)(() => {
15715
15877
  if (activeMenuKey !== void 0) {
15716
15878
  return activeMenuKey;
15717
15879
  }
@@ -16086,7 +16248,7 @@ function isRecord(value) {
16086
16248
 
16087
16249
  // src/interaction/provider.tsx
16088
16250
  var import_runtime29 = require("@pactor-app/runtime");
16089
- var import_react73 = require("react");
16251
+ var import_react74 = require("react");
16090
16252
  var import_react_dom2 = require("react-dom");
16091
16253
  var import_jsx_runtime211 = require("react/jsx-runtime");
16092
16254
  var TOAST_DURATION = 3e3;
@@ -16100,11 +16262,11 @@ function InteractionProvider({
16100
16262
  bridge,
16101
16263
  children
16102
16264
  }) {
16103
- const [confirmState, setConfirmState] = (0, import_react73.useState)(null);
16104
- const [confirmOpen, setConfirmOpen] = (0, import_react73.useState)(false);
16105
- const [toasts, setToasts] = (0, import_react73.useState)([]);
16265
+ const [confirmState, setConfirmState] = (0, import_react74.useState)(null);
16266
+ const [confirmOpen, setConfirmOpen] = (0, import_react74.useState)(false);
16267
+ const [toasts, setToasts] = (0, import_react74.useState)([]);
16106
16268
  const { t } = (0, import_runtime29.useI18n)();
16107
- const { modal, message } = (0, import_react73.useMemo)(() => {
16269
+ const { modal, message } = (0, import_react74.useMemo)(() => {
16108
16270
  const pushToast = (type, content) => {
16109
16271
  const id = Date.now() + Math.random();
16110
16272
  setToasts((prev) => [...prev, { id, type, content }]);
@@ -16126,7 +16288,7 @@ function InteractionProvider({
16126
16288
  };
16127
16289
  return { modal: modalImpl, message: messageImpl };
16128
16290
  }, []);
16129
- (0, import_react73.useEffect)(() => {
16291
+ (0, import_react74.useEffect)(() => {
16130
16292
  bridge.modal = modal;
16131
16293
  bridge.message = message;
16132
16294
  return () => {
@@ -16209,7 +16371,7 @@ function InteractionProvider({
16209
16371
  // src/interaction/host.tsx
16210
16372
  var import_lucide_react38 = require("lucide-react");
16211
16373
  var import_runtime30 = require("@pactor-app/runtime");
16212
- var import_react74 = require("react");
16374
+ var import_react75 = require("react");
16213
16375
  var import_jsx_runtime212 = require("react/jsx-runtime");
16214
16376
  function toCssWidth(width) {
16215
16377
  if (width === void 0) {
@@ -16219,11 +16381,11 @@ function toCssWidth(width) {
16219
16381
  }
16220
16382
  function OverlayHost({ manager, resolvePage }) {
16221
16383
  const renderer = (0, import_runtime30.useRenderer)();
16222
- const stack = (0, import_react74.useSyncExternalStore)(
16384
+ const stack = (0, import_react75.useSyncExternalStore)(
16223
16385
  (onChange) => manager.subscribe(onChange),
16224
16386
  () => manager.stack()
16225
16387
  );
16226
- (0, import_react74.useSyncExternalStore)(
16388
+ (0, import_react75.useSyncExternalStore)(
16227
16389
  (onChange) => {
16228
16390
  const offState = renderer.context.state.subscribe(onChange);
16229
16391
  const offData = renderer.context.data.subscribe(onChange);
@@ -16370,9 +16532,9 @@ function PageOverlayBody({
16370
16532
  renderer,
16371
16533
  resolvePage
16372
16534
  }) {
16373
- const [child, setChild] = (0, import_react74.useState)(null);
16374
- const [error, setError] = (0, import_react74.useState)(null);
16375
- (0, import_react74.useEffect)(() => {
16535
+ const [child, setChild] = (0, import_react75.useState)(null);
16536
+ const [error, setError] = (0, import_react75.useState)(null);
16537
+ (0, import_react75.useEffect)(() => {
16376
16538
  if (!resolvePage) {
16377
16539
  setError(
16378
16540
  new Error(