@guideai/react-native 0.9.0 → 0.10.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.
Files changed (49) hide show
  1. package/README.md +6 -3
  2. package/dist/{GuideAIChat-BFu10t6D.cjs → GuideAIChat-BtbkPIvE.cjs} +285 -26
  3. package/dist/GuideAIChat-BtbkPIvE.cjs.map +1 -0
  4. package/dist/{GuideAIChat-Ba6n1ePs.js → GuideAIChat-CKW6dgl_.js} +286 -27
  5. package/dist/GuideAIChat-CKW6dgl_.js.map +1 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.ts +58 -6
  8. package/dist/index.mjs +2 -2
  9. package/dist/ui.cjs +2 -2
  10. package/dist/ui.d.ts +13 -3
  11. package/dist/ui.mjs +3 -3
  12. package/dist/{useConversations-C-OmzdeA.js → useConversations-BljCr0Od.js} +1067 -43
  13. package/dist/useConversations-BljCr0Od.js.map +1 -0
  14. package/dist/{useConversations-Chn_GKOz.cjs → useConversations-UiwD_WVF.cjs} +1067 -43
  15. package/dist/useConversations-UiwD_WVF.cjs.map +1 -0
  16. package/dist/voice.cjs +61 -23
  17. package/dist/voice.cjs.map +1 -1
  18. package/dist/voice.d.ts +13 -3
  19. package/dist/voice.mjs +62 -24
  20. package/dist/voice.mjs.map +1 -1
  21. package/package.json +1 -1
  22. package/dist/GuideAIChat-BFu10t6D.cjs.map +0 -1
  23. package/dist/GuideAIChat-BQQ8lUKs.js +0 -2795
  24. package/dist/GuideAIChat-BQQ8lUKs.js.map +0 -1
  25. package/dist/GuideAIChat-Ba6n1ePs.js.map +0 -1
  26. package/dist/GuideAIChat-CNmEo5bZ.cjs +0 -2794
  27. package/dist/GuideAIChat-CNmEo5bZ.cjs.map +0 -1
  28. package/dist/GuideAIChat-CxyWFl_o.cjs +0 -2493
  29. package/dist/GuideAIChat-CxyWFl_o.cjs.map +0 -1
  30. package/dist/GuideAIChat-DOC4zx-a.js +0 -2494
  31. package/dist/GuideAIChat-DOC4zx-a.js.map +0 -1
  32. package/dist/GuideAIChat-SU0CVNby.js +0 -2795
  33. package/dist/GuideAIChat-SU0CVNby.js.map +0 -1
  34. package/dist/GuideAIChat-W8KQ4Y6i.cjs +0 -2794
  35. package/dist/GuideAIChat-W8KQ4Y6i.cjs.map +0 -1
  36. package/dist/useConversations-B_7km_uH.js +0 -4243
  37. package/dist/useConversations-B_7km_uH.js.map +0 -1
  38. package/dist/useConversations-C-OmzdeA.js.map +0 -1
  39. package/dist/useConversations-CJEaVqch.cjs +0 -4290
  40. package/dist/useConversations-CJEaVqch.cjs.map +0 -1
  41. package/dist/useConversations-CTbQBTz-.cjs +0 -4242
  42. package/dist/useConversations-CTbQBTz-.cjs.map +0 -1
  43. package/dist/useConversations-Chn_GKOz.cjs.map +0 -1
  44. package/dist/useConversations-Ckyqbxqi.cjs +0 -4299
  45. package/dist/useConversations-Ckyqbxqi.cjs.map +0 -1
  46. package/dist/useConversations-DzhYCIiY.js +0 -4300
  47. package/dist/useConversations-DzhYCIiY.js.map +0 -1
  48. package/dist/useConversations-SbhtYN_R.js +0 -4291
  49. package/dist/useConversations-SbhtYN_R.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const React = require("react");
3
- const DRAWING_URL = /^https:\/\/res\.cloudinary\.com\/[\w-]+\/image\/upload\//;
3
+ const DRAWING_URL = /^https:\/\/(?:res\.cloudinary\.com\/[\w-]+\/image\/upload\/|(?:guideai-video-media-\d+\.s3\.[a-z0-9-]+\.amazonaws\.com|d16dyzg2d3ijry\.cloudfront\.net)\/guideai\/)/;
4
4
  const IMAGE_BLOCK = /```image[ \t]*\n([\s\S]*?)```/g;
5
5
  function headlessImages(text) {
6
6
  const images = [];
@@ -381,8 +381,9 @@ class HarnessValidator {
381
381
  if (status === 429) return "rate_limit";
382
382
  if (status && status >= 500) return "server";
383
383
  if (status === 400 || status === 422) return "validation";
384
+ if (error.includes("no auth token found")) return "auth";
384
385
  if (error.includes("timed out") || error.includes("timeout")) return "timeout";
385
- if (error.includes("connect") || error.includes("network")) return "connection";
386
+ if (error.includes("connect") || error.includes("network") || error.includes("failed to fetch") || error.includes("load failed")) return "connection";
386
387
  if (status && status >= 400) return "client";
387
388
  return result.error_type || "unknown";
388
389
  }
@@ -1070,7 +1071,7 @@ const EP = {
1070
1071
  doItRuns: () => _j([..._v, "guide-executions"]),
1071
1072
  doItRun: (runId, op) => _j([..._v, "guide-executions", encodeURIComponent(runId), ...op ? [op] : []]),
1072
1073
  chatFormat: () => _j([..._v, "chat", "format-tool-result"]),
1073
- copilotTools: () => _j([..._v, "copilot-tools", "active"]),
1074
+ copilotTools: (mode) => `${_j([..._v, "copilot-tools", "active"])}${mode ? `?chat_mode=${mode}` : ""}`,
1074
1075
  copilotStream: () => _j([..._v, "copilot", "stream"]),
1075
1076
  resolveScore: () => _j([..._v, "resolve", "score"]),
1076
1077
  resolveLocate: () => _j([..._v, "resolve", "locate"]),
@@ -1087,6 +1088,7 @@ const EP = {
1087
1088
  realtimeTranscriptionSession: () => _j([..._v, "realtime", "transcription", "session"]),
1088
1089
  realtimeSpeech: () => _j([..._v, "realtime", "speech"]),
1089
1090
  listenSession: () => _j([..._v, "realtime", "listen", "session"]),
1091
+ dictateSession: () => _j([..._v, "realtime", "dictate", "session"]),
1090
1092
  speakSession: () => _j([..._v, "realtime", "speak", "session"]),
1091
1093
  liveSession: () => _j([..._v, "realtime", "live", "session"]),
1092
1094
  // v=2: neutral voice codes (stream / pipeline / live / live-rtc).
@@ -1137,7 +1139,7 @@ class CopilotHarness {
1137
1139
  if (this.initialized) return this.isEnabled();
1138
1140
  try {
1139
1141
  const response = await this.api.get(
1140
- EP.copilotTools()
1142
+ EP.copilotTools("assistant")
1141
1143
  );
1142
1144
  if (response && response.tools && response.tools.length > 0) {
1143
1145
  this.activeTools = response;
@@ -1310,6 +1312,7 @@ class CopilotHarness {
1310
1312
  * Executes in the browser when possible, then formats the result with LLM.
1311
1313
  */
1312
1314
  async executeToolCall(toolCall, originalQuestion, onStatus, onTextDelta) {
1315
+ var _a;
1313
1316
  if (!this.canExecuteTool(toolCall)) {
1314
1317
  const errorMsg = "Tool execution is unavailable in this browser context.";
1315
1318
  this.memory.addMessage({
@@ -1375,6 +1378,28 @@ class CopilotHarness {
1375
1378
  autoExecute: false
1376
1379
  };
1377
1380
  }
1381
+ if (this.tools.canExecuteCall(toolCall)) {
1382
+ const completedSteps = [{ tool_name: toolCall.tool, tool_result: result.data }];
1383
+ const continued = await this._continueToolChain(
1384
+ toolCall.tool,
1385
+ result.data,
1386
+ originalQuestion,
1387
+ completedSteps,
1388
+ onStatus,
1389
+ onTextDelta
1390
+ );
1391
+ if (continued.autoExecuteToolCall && continued.pendingToolCall) {
1392
+ return this._runClientToolChain(
1393
+ (_a = continued.pendingToolCalls) != null ? _a : [continued.pendingToolCall],
1394
+ originalQuestion,
1395
+ onStatus,
1396
+ onTextDelta,
1397
+ void 0,
1398
+ completedSteps
1399
+ );
1400
+ }
1401
+ return continued;
1402
+ }
1378
1403
  return this._formatToolResult(
1379
1404
  toolCall.tool,
1380
1405
  result.data,
@@ -1782,6 +1807,7 @@ class CopilotHarness {
1782
1807
  const response = await this.api.post(
1783
1808
  EP.chatContinue(),
1784
1809
  {
1810
+ chat_mode: "assistant",
1785
1811
  original_question: originalQuestion,
1786
1812
  latest_tool_name: latestToolName,
1787
1813
  latest_tool_result: latestToolResult,
@@ -1823,19 +1849,19 @@ class CopilotHarness {
1823
1849
  * round trip, rather than four of each. Dependent calls still arrive one at
1824
1850
  * a time — the model only batches what it can run without waiting.
1825
1851
  */
1826
- async _runClientToolChain(initialToolCalls, originalQuestion, onStatus, onTextDelta, onToolCallEvent) {
1852
+ async _runClientToolChain(initialToolCalls, originalQuestion, onStatus, onTextDelta, onToolCallEvent, completedSteps = []) {
1827
1853
  var _a;
1828
1854
  if (!this.hasAnyLocalTools()) {
1829
1855
  return this._errorResponse("Tool execution is unavailable in this browser context.");
1830
1856
  }
1831
- const toolHistory = [];
1857
+ const toolHistory = [...completedSteps];
1832
1858
  const executed = /* @__PURE__ */ new Set();
1833
1859
  const callKey = (call) => {
1834
1860
  var _a2, _b;
1835
1861
  return `${call.tool}:${JSON.stringify((_a2 = call.params) != null ? _a2 : {})}:${JSON.stringify((_b = call.body) != null ? _b : {})}`;
1836
1862
  };
1837
1863
  let currentBatch = this._dropRepeats(initialToolCalls, executed, callKey);
1838
- let toolsRun = 0;
1864
+ let toolsRun = completedSteps.length;
1839
1865
  let repairsUsed = 0;
1840
1866
  for (let iteration = 0; currentBatch.length > 0 && iteration < MAX_CHAIN_ROUNDS; iteration += 1) {
1841
1867
  if (toolsRun + currentBatch.length > MAX_TOTAL_TOOL_CALLS) {
@@ -1996,6 +2022,7 @@ class CopilotHarness {
1996
2022
  var _a, _b;
1997
2023
  try {
1998
2024
  return await this.api.post(EP.chatExecuteTool(), {
2025
+ chat_mode: "assistant",
1999
2026
  tool: toolCall.tool,
2000
2027
  method: toolCall.method,
2001
2028
  path: toolCall.path,
@@ -2027,6 +2054,7 @@ class CopilotHarness {
2027
2054
  const rawResponse = await this.api.postRaw(
2028
2055
  EP.chatFormat(),
2029
2056
  {
2057
+ chat_mode: "assistant",
2030
2058
  tool_name: toolName,
2031
2059
  tool_result: toolResult,
2032
2060
  original_question: originalQuestion,
@@ -3141,8 +3169,8 @@ function dump(label, value) {
3141
3169
  console.log(`${label}
3142
3170
  ${text}`);
3143
3171
  }
3144
- function line(icon, text) {
3145
- console.log(`[${stamp()}] ${icon} ${text}`);
3172
+ function line(icon2, text) {
3173
+ console.log(`[${stamp()}] ${icon2} ${text}`);
3146
3174
  }
3147
3175
  function traceApi(api) {
3148
3176
  return {
@@ -3606,21 +3634,21 @@ const ID = /^[A-Za-z0-9_-]{1,24}$/;
3606
3634
  const SIZES = ["s", "m", "l"];
3607
3635
  const TONES = ["ink", "blue", "red", "green"];
3608
3636
  const PATH_DATA = /^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]*$/;
3609
- const PHOTO_URL = /^https:\/\/res\.cloudinary\.com\/[A-Za-z0-9_-]+\/image\/upload\/[^\s"'<>\\]+$/;
3637
+ const PHOTO_URL = /^https:\/\/(?:res\.cloudinary\.com\/[A-Za-z0-9_-]+\/image\/upload\/|(?:guideai-video-media-\d+\.s3\.[a-z0-9-]+\.amazonaws\.com|d16dyzg2d3ijry\.cloudfront\.net)\/guideai\/)[^\s"'<>\\]+$/;
3610
3638
  const flat = (value, max) => typeof value === "string" ? value.replace(/\s+/g, " ").trim().slice(0, max) : "";
3611
3639
  const clamp = (n, top = BOARD_H) => Math.round(Math.min(top, Math.max(0, n)) * 10) / 10;
3612
- function num(value) {
3640
+ function num$1(value) {
3613
3641
  return typeof value === "number" && Number.isFinite(value) ? value : null;
3614
3642
  }
3615
3643
  let wide = 1;
3616
3644
  function point(raw) {
3617
3645
  if (!Array.isArray(raw) || raw.length !== 2) return null;
3618
- const [x, y] = raw.map(num);
3646
+ const [x, y] = raw.map(num$1);
3619
3647
  return x === null || y === null ? null : [clamp(x * wide, BOARD_W), clamp(y)];
3620
3648
  }
3621
3649
  function box(raw) {
3622
3650
  if (!Array.isArray(raw) || raw.length !== 4) return null;
3623
- const v = raw.map(num);
3651
+ const v = raw.map(num$1);
3624
3652
  if (v.some((n) => n === null)) return null;
3625
3653
  const x = clamp(v[0] * wide, BOARD_W);
3626
3654
  const y = clamp(v[1]);
@@ -3684,7 +3712,7 @@ function item(raw) {
3684
3712
  const rows = r.rows.slice(0, LIMITS.tableRows).filter((row) => Array.isArray(row) && row.length > 0).map((row) => row.slice(0, LIMITS.tableCols).map((cell) => flat(String(cell != null ? cell : ""), LIMITS.cell)));
3685
3713
  const at = point(r.at.slice(0, 2));
3686
3714
  if (!rows.length || !at) return null;
3687
- const width = ((_a = num(r.at[2])) != null ? _a : 40) * wide;
3715
+ const width = ((_a = num$1(r.at[2])) != null ? _a : 40) * wide;
3688
3716
  return { kind: "table", id: id(r.id), rows, at: [at[0], at[1], Math.min(Math.max(5, width), BOARD_W - at[0])], tone: tone(r.tone) };
3689
3717
  }
3690
3718
  case "mark": {
@@ -3712,7 +3740,7 @@ function item(raw) {
3712
3740
  }
3713
3741
  case "turn": {
3714
3742
  const target = id(r.turn);
3715
- const by = Math.min(LIMITS.turn, Math.max(-1440, (_b = num(r.by)) != null ? _b : 360));
3743
+ const by = Math.min(LIMITS.turn, Math.max(-1440, (_b = num$1(r.by)) != null ? _b : 360));
3716
3744
  return target && by ? { kind: "turn", turn: target, by } : null;
3717
3745
  }
3718
3746
  case "pulse": {
@@ -3742,8 +3770,8 @@ function artInk(raw) {
3742
3770
  function photo(raw) {
3743
3771
  if (!raw || typeof raw !== "object") return null;
3744
3772
  const r = raw;
3745
- const w = num(r.w);
3746
- const h = num(r.h);
3773
+ const w = num$1(r.w);
3774
+ const h = num$1(r.h);
3747
3775
  if (typeof r.url !== "string" || r.url.length > 600 || !PHOTO_URL.test(r.url) || !w || !h || w <= 0 || h <= 0) return null;
3748
3776
  const credit = flat(r.credit, 60);
3749
3777
  return credit ? { url: r.url, w, h, credit } : { url: r.url, w, h };
@@ -3807,6 +3835,973 @@ function validateScene(raw) {
3807
3835
  photos
3808
3836
  };
3809
3837
  }
3838
+ const ISO_ICONS = {
3839
+ "activity": '<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"/>',
3840
+ "alert": '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',
3841
+ "balancer": '<path d="M16 3h5v5"/><path d="M8 3H3v5"/><path d="M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3"/><path d="m15 9 6-6"/>',
3842
+ "ban": '<circle cx="12" cy="12" r="10"/><path d="M4.929 4.929 19.07 19.071"/>',
3843
+ "bank": '<path d="M10 18v-7"/><path d="M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z"/><path d="M14 18v-7"/><path d="M18 18v-7"/><path d="M3 22h18"/><path d="M6 18v-7"/>',
3844
+ "bell": '<path d="M10.268 21a2 2 0 0 0 3.464 0"/><path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"/>',
3845
+ "book": '<path d="M12 5v16"/><path d="M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z"/>',
3846
+ "bot": '<path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>',
3847
+ "box": '<path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/>',
3848
+ "boxes": '<path d="M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z"/><path d="m7 16.5-4.74-2.85"/><path d="m7 16.5 5-3"/><path d="M7 16.5v5.17"/><path d="M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z"/><path d="m17 16.5-5-3"/><path d="m17 16.5 4.74-2.85"/><path d="M17 16.5v5.17"/><path d="M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z"/><path d="M12 8 7.26 5.15"/><path d="m12 8 4.74-2.85"/><path d="M12 13.5V8"/>',
3849
+ "braces": '<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"/>',
3850
+ "bug": '<path d="M12 20v-9"/><path d="M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"/><path d="M14.12 3.88 16 2"/><path d="M21 21a4 4 0 0 0-3.81-4"/><path d="M21 5a4 4 0 0 1-3.55 3.97"/><path d="M22 13h-4"/><path d="M3 21a4 4 0 0 1 3.81-4"/><path d="M3 5a4 4 0 0 0 3.55 3.97"/><path d="M6 13H2"/><path d="m8 2 1.88 1.88"/><path d="M9 7.13V6a3 3 0 1 1 6 0v1.13"/>',
3851
+ "bulb": '<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/>',
3852
+ "calendar": '<path d="M8 2v3"/><path d="M16 2v3"/><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/>',
3853
+ "camera": '<path d="M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z"/><circle cx="12" cy="13" r="3"/>',
3854
+ "car": '<path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2"/><circle cx="7" cy="17" r="2"/><path d="M9 17h6"/><circle cx="17" cy="17" r="2"/>',
3855
+ "card": '<rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/><path d="M6 14h2"/>',
3856
+ "cart": '<path d="m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18"/><path d="M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25"/><circle cx="18" cy="20" r="2"/><circle cx="8" cy="20" r="2"/>',
3857
+ "chart": '<path d="M3 3v16a2 2 0 0 0 2 2h16"/><path d="M18 17V9"/><path d="M13 17V5"/><path d="M8 17v-3"/>',
3858
+ "check": '<path d="M20 6 9 17l-5-5"/>',
3859
+ "clipboard": '<rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><path d="M12 11h4"/><path d="M12 16h4"/><path d="M8 11h.01"/><path d="M8 16h.01"/>',
3860
+ "clock": '<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>',
3861
+ "cloud": '<path d="M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"/>',
3862
+ "code": '<path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/>',
3863
+ "cookie": '<path d="M11 17h.01"/><path d="M11.496 2c.324-.016.558.292.529.615a4 4 0 004.235 4.368.713.713 0 01.758.757 4 4 0 004.366 4.237c.323-.03.63.204.614.527a10 10 0 01-2.915 6.566A1 1 0 114.93 4.918 10 10 0 0111.496 2"/><path d="M12 12h.01"/><path d="M16 16h.01"/><path d="M16 3h.01"/><path d="M21 4h.01"/><path d="M21 8h.01"/><path d="M7 14h.01"/><path d="M9 8h.01"/>',
3864
+ "cpu": '<path d="M12 20v2"/><path d="M12 2v2"/><path d="M17 20v2"/><path d="M17 2v2"/><path d="M2 12h2"/><path d="M2 17h2"/><path d="M2 7h2"/><path d="M20 12h2"/><path d="M20 17h2"/><path d="M20 7h2"/><path d="M7 20v2"/><path d="M7 2v2"/><rect x="4" y="4" width="16" height="16" rx="2"/><rect x="8" y="8" width="8" height="8" rx="1"/>',
3865
+ "database": '<ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5V19A9 3 0 0 0 21 19V5"/><path d="M3 12A9 3 0 0 0 21 12"/>',
3866
+ "dollar": '<line x1="12" x2="12" y1="2" y2="22"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>',
3867
+ "droplet": '<path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"/>',
3868
+ "eye": '<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>',
3869
+ "factory": '<path d="M12 16h.01"/><path d="M16 16h.01"/><path d="M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z"/><path d="M8 16h.01"/>',
3870
+ "file": '<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>',
3871
+ "filter": '<path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"/>',
3872
+ "fingerprint": '<path d="M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"/><path d="M14 13.12c0 2.38 0 6.38-1 8.88"/><path d="M17.29 21.02c.12-.6.43-2.3.5-3.02"/><path d="M2 12a10 10 0 0 1 18-6"/><path d="M2 16h.01"/><path d="M21.8 16c.2-2 .131-5.354 0-6"/><path d="M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"/><path d="M8.65 22c.21-.66.45-1.32.57-2"/><path d="M9 6.8a6 6 0 0 1 9 5.2v2"/>',
3873
+ "flag": '<path d="M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528"/>',
3874
+ "flask": '<path d="M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2"/><path d="M6.453 15h11.094"/><path d="M8.5 2h7"/>',
3875
+ "gauge": '<path d="m12 14 4-4"/><path d="M3.34 19a10 10 0 1 1 17.32 0"/>',
3876
+ "gift": '<path d="M12 7v14"/><path d="M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8"/><path d="M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5"/><rect x="3" y="7" width="18" height="4" rx="1"/>',
3877
+ "git": '<path d="M15 6a9 9 0 0 0-9 9V3"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/>',
3878
+ "globe": '<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>',
3879
+ "graduation": '<path d="M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z"/><path d="M22 10v6"/><path d="M6 12.5V16a6 3 0 0 0 12 0v-3.5"/>',
3880
+ "hammer": '<path d="m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9"/><path d="m18 15 4-4"/><path d="m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5"/>',
3881
+ "hash": '<line x1="4" x2="20" y1="9" y2="9"/><line x1="4" x2="20" y1="15" y2="15"/><line x1="10" x2="8" y1="3" y2="21"/><line x1="16" x2="14" y1="3" y2="21"/>',
3882
+ "heart": '<path d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"/><path d="M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27"/>',
3883
+ "home": '<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',
3884
+ "hotel": '<path d="M10 22v-6.57"/><path d="M12 11h.01"/><path d="M12 7h.01"/><path d="M14 15.43V22"/><path d="M15 16a5 5 0 0 0-6 0"/><path d="M16 11h.01"/><path d="M16 7h.01"/><path d="M8 11h.01"/><path d="M8 7h.01"/><rect x="4" y="2" width="16" height="20" rx="2"/>',
3885
+ "hourglass": '<path d="M5 22h14"/><path d="M5 2h14"/><path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22"/><path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2"/>',
3886
+ "image": '<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>',
3887
+ "inbox": '<polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>',
3888
+ "info": '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',
3889
+ "key": '<path d="M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z"/><circle cx="16.5" cy="7.5" r=".5" fill="currentColor"/>',
3890
+ "laptop": '<path d="M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z"/><path d="M20.054 15.987H3.946"/>',
3891
+ "layers": '<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/>',
3892
+ "leaf": '<path d="M11 20a10 10 0 0010-10 25.9 25.9 0 00-1.04-7.281 1 1 0 00-1.755-.325C15.833 5.5 13 5.5 9.8 6.1A7 7 0 0011 20"/><path d="M2 21a5 5 0 012.911-4.544C7.613 15.212 8.351 15.24 11 13"/>',
3893
+ "list": '<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>',
3894
+ "lock": '<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',
3895
+ "mail": '<path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7"/><rect x="2" y="4" width="20" height="16" rx="2"/>',
3896
+ "map": '<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>',
3897
+ "merge": '<path d="m8 6 4-4 4 4"/><path d="M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22"/><path d="m20 22-5-5"/>',
3898
+ "message": '<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"/>',
3899
+ "moon": '<path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/>',
3900
+ "network": '<rect x="16" y="16" width="6" height="6" rx="1"/><rect x="2" y="16" width="6" height="6" rx="1"/><rect x="9" y="2" width="6" height="6" rx="1"/><path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3"/><path d="M12 12V8"/>',
3901
+ "package": '<path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"/><path d="M12 22V12"/><polyline points="3.29 7 12 12 20.71 7"/><path d="m7.5 4.27 9 5.15"/>',
3902
+ "phone": '<rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/>',
3903
+ "plane": '<path d="M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z"/>',
3904
+ "power": '<path d="M12 2v10"/><path d="M18.4 6.6a9 9 0 1 1-12.77.04"/>',
3905
+ "radio": '<path d="M16.247 7.761a6 6 0 0 1 0 8.478"/><path d="M19.075 4.933a10 10 0 0 1 0 14.134"/><path d="M4.925 19.067a10 10 0 0 1 0-14.134"/><path d="M7.753 16.239a6 6 0 0 1 0-8.478"/><circle cx="12" cy="12" r="2"/>',
3906
+ "receipt": '<path d="M12 17V7"/><path d="M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8"/><path d="M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z"/>',
3907
+ "refresh": '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',
3908
+ "rocket": '<path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09"/><path d="M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05"/>',
3909
+ "route": '<circle cx="6" cy="19" r="3"/><path d="M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15"/><circle cx="18" cy="5" r="3"/>',
3910
+ "scale": '<path d="M12 3v18"/><path d="m19 8 3 8a5 5 0 0 1-6 0zV7"/><path d="M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1"/><path d="m5 8 3 8a5 5 0 0 1-6 0zV7"/><path d="M7 21h10"/>',
3911
+ "scroll": '<path d="M15 12h-5"/><path d="M15 8h-5"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3"/>',
3912
+ "search": '<path d="m21 21-4.34-4.34"/><circle cx="11" cy="11" r="8"/>',
3913
+ "server": '<rect width="20" height="8" x="2" y="2" rx="2" ry="2"/><rect width="20" height="8" x="2" y="14" rx="2" ry="2"/><line x1="6" x2="6.01" y1="6" y2="6"/><line x1="6" x2="6.01" y1="18" y2="18"/>',
3914
+ "settings": '<path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"/><circle cx="12" cy="12" r="3"/>',
3915
+ "share": '<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/>',
3916
+ "shield": '<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/><path d="m9 12 2 2 4-4"/>',
3917
+ "signpost": '<path d="M12 13v8"/><path d="M12 3v3"/><path d="M2.354 10.354a1.207 1.207 0 0 1 0-1.708l2.06-2.06A2 2 0 0 1 5.828 6h12.344a2 2 0 0 1 1.414.586l2.06 2.06a1.207 1.207 0 0 1 0 1.708l-2.06 2.06a2 2 0 0 1-1.414.586H5.828a2 2 0 0 1-1.414-.586z"/>',
3918
+ "siren": '<path d="M7 18v-6a5 5 0 1 1 10 0v6"/><path d="M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z"/><path d="M21 12h1"/><path d="M18.5 4.5 18 5"/><path d="M2 12h1"/><path d="M12 2v1"/><path d="m4.929 4.929.707.707"/><path d="M12 12v6"/>',
3919
+ "sparkles": '<path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"/><path d="M20 2v4"/><path d="M22 4h-4"/><circle cx="4" cy="20" r="2"/>',
3920
+ "stethoscope": '<path d="M11 2v2"/><path d="M5 2v2"/><path d="M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1"/><path d="M8 15a6 6 0 0 0 12 0v-3"/><circle cx="20" cy="10" r="2"/>',
3921
+ "store": '<path d="M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5"/><path d="M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244"/><path d="M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05"/>',
3922
+ "sun": '<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',
3923
+ "table": '<path d="M12 3v18"/><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/><path d="M3 15h18"/>',
3924
+ "terminal": '<path d="M12 19h8"/><path d="m4 17 6-6-6-6"/>',
3925
+ "ticket": '<path d="M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"/><path d="M13 5v2"/><path d="M13 17v2"/><path d="M13 11v2"/>',
3926
+ "timer": '<line x1="10" x2="14" y1="2" y2="2"/><line x1="12" x2="15" y1="14" y2="11"/><circle cx="12" cy="14" r="8"/>',
3927
+ "toggle": '<circle cx="15" cy="12" r="3"/><rect width="20" height="14" x="2" y="5" rx="7"/>',
3928
+ "trending": '<path d="M16 7h6v6"/><path d="m22 7-8.5 8.5-5-5L2 17"/>',
3929
+ "truck": '<path d="M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2"/><path d="M15 18H9"/><path d="M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14"/><circle cx="17" cy="18" r="2"/><circle cx="7" cy="18" r="2"/>',
3930
+ "undo": '<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/>',
3931
+ "unplug": '<path d="m19 5 3-3"/><path d="m2 22 3-3"/><path d="M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z"/><path d="M7.5 13.5 10 11"/><path d="M10.5 16.5 13 14"/><path d="m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z"/>',
3932
+ "user": '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',
3933
+ "users": '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><path d="M16 3.128a4 4 0 0 1 0 7.744"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><circle cx="9" cy="7" r="4"/>',
3934
+ "video": '<path d="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"/><rect x="2" y="6" width="14" height="12" rx="2"/>',
3935
+ "webhook": '<path d="M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2"/><path d="m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06"/><path d="m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8"/>',
3936
+ "wifi": '<path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/>',
3937
+ "workflow": '<rect width="8" height="8" x="3" y="3" rx="2"/><path d="M7 11v4a2 2 0 0 0 2 2h4"/><rect width="8" height="8" x="13" y="13" rx="2"/>',
3938
+ "x": '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
3939
+ "zap": '<path d="M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z"/>'
3940
+ };
3941
+ function readIsoPlan(raw) {
3942
+ if (!raw || typeof raw !== "object") return null;
3943
+ const plan = raw;
3944
+ if (plan.kind !== "iso" || !Array.isArray(plan.steps) || !plan.steps.length) return null;
3945
+ const steps = plan.steps.filter((s) => !!s && typeof s === "object").map((s) => ({ ...s, say: typeof s.say === "string" ? s.say : "", do: Array.isArray(s.do) ? s.do.filter((a) => a && typeof a === "object") : [] }));
3946
+ if (!steps.length) return null;
3947
+ return {
3948
+ kind: "iso",
3949
+ lesson: plan.lesson === true,
3950
+ title: typeof plan.title === "string" ? plan.title : "How it works",
3951
+ summary: typeof plan.summary === "string" ? plan.summary : void 0,
3952
+ sample: plan.sample === true,
3953
+ metrics: Array.isArray(plan.metrics) ? plan.metrics.filter((m) => m && typeof m.id === "string") : [],
3954
+ goals: Array.isArray(plan.goals) ? plan.goals : [],
3955
+ steps
3956
+ };
3957
+ }
3958
+ const HW = 60;
3959
+ const HH = 30;
3960
+ const P = (c, r, z = 0) => [(c - r) * HW, (c + r) * HH - z];
3961
+ const f1 = (n) => String(Math.round(n * 10) / 10);
3962
+ const pt = (p) => `${f1(p[0])},${f1(p[1])}`;
3963
+ const clamp01 = (t) => Math.max(0, Math.min(1, t));
3964
+ const lerp = (a, b, t) => a + (b - a) * t;
3965
+ const esc = (s) => String(s != null ? s : "").replace(/[&<>"]/g, (ch) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[ch]);
3966
+ const ease = {
3967
+ inOut: (t) => t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2,
3968
+ out: (t) => 1 - (1 - t) ** 3,
3969
+ pop: (t) => 1 + 2.4 * (t - 1) ** 3 + 1.4 * (t - 1) ** 2
3970
+ };
3971
+ const LINE = "#1f2430";
3972
+ const MONO = "ui-monospace, 'SF Mono', Menlo, Consolas, monospace";
3973
+ const COLORS = {
3974
+ blue: ["#cfe0ff", "#a9c4f5", "#8eaee8", "#1e3a8a"],
3975
+ orange: ["#ffd9b8", "#f9b98a", "#ee9f6a", "#7c2d12"],
3976
+ purple: ["#e6dcff", "#cbbaf7", "#b29ded", "#4c1d95"],
3977
+ green: ["#d3f2d8", "#a9e0b4", "#8acb98", "#14532d"],
3978
+ yellow: ["#fff0bf", "#fbdb80", "#f0c75c", "#713f12"],
3979
+ teal: ["#cdf3ee", "#9fded5", "#7fcbc1", "#134e4a"],
3980
+ rose: ["#ffdbe3", "#f6b2c1", "#e996a9", "#881337"],
3981
+ slate: ["#e6eaf1", "#c8d0dc", "#b0bacb", "#1e293b"],
3982
+ sand: ["#f3ece0", "#e2d6c2", "#d2c3aa", "#44403c"],
3983
+ hot: ["#ffd0cc", "#f59b94", "#e5776f", "#7f1d1d"],
3984
+ down: ["#e4e4e7", "#c4c4cb", "#a8a8b2", "#52525b"]
3985
+ };
3986
+ const ICON_COLOR = Object.fromEntries([
3987
+ ...["balancer", "signpost", "route", "network", "webhook", "share", "merge", "filter"].map((i) => [i, "orange"]),
3988
+ ...["zap", "cpu", "settings", "check", "refresh", "rocket", "flask", "hammer", "sparkles", "git"].map((i) => [i, "green"]),
3989
+ ...["globe", "clock", "calendar", "bank", "card", "dollar", "receipt", "store", "cart", "truck", "plane", "hotel", "car", "mail", "bell"].map((i) => [i, "yellow"]),
3990
+ ...["inbox", "layers", "radio", "activity", "workflow", "boxes", "package", "message"].map((i) => [i, "teal"]),
3991
+ ...["shield", "lock", "key", "fingerprint", "user", "users", "eye", "siren", "alert", "ban", "bug", "heart", "stethoscope"].map((i) => [i, "rose"]),
3992
+ ...["database", "file", "table", "chart", "list", "scroll", "clipboard", "hash", "book", "image", "video", "camera"].map((i) => [i, "purple"])
3993
+ ]);
3994
+ const TONE = { ink: LINE, blue: "#2563eb", red: "#dc2626", green: "#15803d", amber: "#b45309" };
3995
+ const TONE_BG = { ink: "#ffffff", blue: "#e0eaff", red: "#fee2e2", green: "#dcfce7", amber: "#fef3c7" };
3996
+ const PACKETS = {
3997
+ request: { label: "request", color: "#f28c3c" },
3998
+ response: { label: "response", color: "#22a35a" },
3999
+ write: { label: "write", color: "#334155" },
4000
+ heavy: { label: "heavy request", color: "#e8692a" },
4001
+ ping: { label: "health check", color: "#22a35a" },
4002
+ event: { label: "event", color: "#e0a400" },
4003
+ fail: { label: "failed request", color: "#dc2626" },
4004
+ data: { label: "data", color: "#8b5cf6" }
4005
+ };
4006
+ const PEOPLE = ["#f6b26b", "#9fc5e8", "#b4a7d6", "#93c47d", "#f4cccc", "#ffd966", "#a2c4c9"];
4007
+ const KINDS = {
4008
+ service: { r: 0.44, top: 42 },
4009
+ database: { r: 0.3, top: 46 },
4010
+ laptop: { r: 0.4, top: 46 },
4011
+ phone: { r: 0.4, top: 52 },
4012
+ crowd: { r: 0.5, top: 30 },
4013
+ queue: { r: 0.35, top: 12 },
4014
+ pages: { r: 0.35, top: 12 },
4015
+ ghost: { r: 0.44, top: 40 }
4016
+ };
4017
+ function icon(name, x, y, size, color, sw = 2) {
4018
+ var _a, _b;
4019
+ const body = (_b = (_a = ISO_ICONS[name]) != null ? _a : ISO_ICONS.box) != null ? _b : "";
4020
+ return `<g transform="translate(${f1(x - size / 2)} ${f1(y - size / 2)}) scale(${size / 24})" fill="none" stroke="${color}" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round">${body}</g>`;
4021
+ }
4022
+ function rounded(pts, r) {
4023
+ let d = "";
4024
+ const n = pts.length;
4025
+ for (let i = 0; i < n; i++) {
4026
+ const a = pts[(i - 1 + n) % n], b = pts[i], c = pts[(i + 1) % n];
4027
+ d += `${i ? "L" : "M"}${pt(cut(b, a, r))} Q${pt(b)} ${pt(cut(b, c, r))} `;
4028
+ }
4029
+ return d + "Z";
4030
+ }
4031
+ function cut(p, q, r) {
4032
+ const L = Math.hypot(q[0] - p[0], q[1] - p[1]) || 1;
4033
+ const k = Math.min(r, L / 2) / L;
4034
+ return [p[0] + (q[0] - p[0]) * k, p[1] + (q[1] - p[1]) * k];
4035
+ }
4036
+ function roundedPath(pts, r) {
4037
+ if (pts.length < 3) return "M" + pts.map(pt).join(" L");
4038
+ let d = "M" + pt(pts[0]);
4039
+ for (let i = 1; i < pts.length - 1; i++) d += ` L${pt(cut(pts[i], pts[i - 1], r))} Q${pt(pts[i])} ${pt(cut(pts[i], pts[i + 1], r))}`;
4040
+ return d + ` L${pt(pts[pts.length - 1])}`;
4041
+ }
4042
+ function along(pts, f) {
4043
+ const seg = [];
4044
+ let total = 0;
4045
+ for (let k = 1; k < pts.length; k++) {
4046
+ const L = Math.hypot(pts[k][0] - pts[k - 1][0], pts[k][1] - pts[k - 1][1]);
4047
+ seg.push(L);
4048
+ total += L;
4049
+ }
4050
+ let want = f * total;
4051
+ for (let k = 0; k < seg.length; k++) {
4052
+ if (want <= seg[k] || k === seg.length - 1) {
4053
+ const q = seg[k] ? want / seg[k] : 0;
4054
+ return [lerp(pts[k][0], pts[k + 1][0], q), lerp(pts[k][1], pts[k + 1][1], q)];
4055
+ }
4056
+ want -= seg[k];
4057
+ }
4058
+ return pts[0];
4059
+ }
4060
+ class Defs {
4061
+ constructor() {
4062
+ this.n = 0;
4063
+ this.out = [];
4064
+ }
4065
+ id(prefix) {
4066
+ this.n += 1;
4067
+ return `${prefix}${this.n}`;
4068
+ }
4069
+ }
4070
+ function roundBox(c, r, w, d, z0, h, pal, defs, radius = 9, sw = 1.6) {
4071
+ const x0 = c - w / 2, x1 = c + w / 2, r0 = r - d / 2, r1 = r + d / 2, zt = z0 + h;
4072
+ const sil = [P(x0, r0, zt), P(x1, r0, zt), P(x1, r0, z0), P(x1, r1, z0), P(x0, r1, z0), P(x0, r1, zt)];
4073
+ const id2 = defs.id("ic");
4074
+ defs.out.push(`<clipPath id="${id2}"><path d="${rounded(sil, radius)}"/></clipPath>`);
4075
+ const left = [P(x0 - 1, r1, zt + 40), P(x1, r1, zt + 40), P(x1, r1, z0 - 40), P(x0 - 1, r1, z0 - 40)];
4076
+ const top = [P(x0, r0, zt), P(x1, r0, zt), P(x1, r1, zt), P(x0, r1, zt)];
4077
+ return `<path d="${rounded(sil, radius)}" fill="${pal[2]}"/><g clip-path="url(#${id2})"><polygon points="${left.map(pt).join(" ")}" fill="${pal[1]}"/></g><path d="${rounded(top, radius * 0.8)}" fill="${pal[0]}" stroke="${LINE}" stroke-width="${sw * 0.7}" stroke-opacity=".55"/><path d="${rounded(sil, radius)}" fill="none" stroke="${LINE}" stroke-width="${sw}" stroke-linejoin="round"/>`;
4078
+ }
4079
+ function cylinder(c, r, R, z0, h, pal, defs) {
4080
+ const rx = R * HW * Math.SQRT2, ry = R * HH * Math.SQRT2;
4081
+ const [bx, by] = P(c, r, z0), [tx, ty] = P(c, r, z0 + h);
4082
+ const id2 = defs.id("ig");
4083
+ defs.out.push(`<linearGradient id="${id2}" x1="0" x2="1"><stop offset="0" stop-color="${pal[1]}"/><stop offset=".5" stop-color="${pal[1]}"/><stop offset="1" stop-color="${pal[2]}"/></linearGradient>`);
4084
+ return `<path d="M${f1(bx - rx)},${f1(by)} A${f1(rx)},${f1(ry)} 0 0 0 ${f1(bx + rx)},${f1(by)} L${f1(tx + rx)},${f1(ty)} L${f1(tx - rx)},${f1(ty)} Z" fill="url(#${id2})" stroke="${LINE}" stroke-width="1.6"/><ellipse cx="${f1(tx)}" cy="${f1(ty)}" rx="${f1(rx)}" ry="${f1(ry)}" fill="${pal[0]}" stroke="${LINE}" stroke-width="1.6"/>`;
4085
+ }
4086
+ function pill(x, y, text, o = {}) {
4087
+ var _a, _b, _c, _d, _e, _f, _g;
4088
+ const fs = (_a = o.fs) != null ? _a : 11, ic = o.icon ? fs + 4 : 0, w = text.length * fs * 0.6 + 16 + ic, h = fs + 10;
4089
+ const tone2 = (_b = o.tone) != null ? _b : "ink";
4090
+ const bg = (_d = (_c = o.bg) != null ? _c : TONE_BG[tone2]) != null ? _d : "#fff", ink = (_f = (_e = o.ink) != null ? _e : TONE[tone2]) != null ? _f : LINE;
4091
+ const x0 = o.anchor === "start" ? x : x - w / 2;
4092
+ return {
4093
+ w,
4094
+ h,
4095
+ x0,
4096
+ y0: y - h / 2,
4097
+ svg: `<g opacity="${(_g = o.alpha) != null ? _g : 1}"><rect x="${f1(x0)}" y="${f1(y - h / 2)}" width="${f1(w)}" height="${h}" rx="${h / 2}" fill="${bg}" stroke="${tone2 === "ink" ? LINE : ink}" stroke-width="1.3"/>` + (o.icon ? icon(o.icon, x0 + 8 + fs / 2, y, fs + 1, ink, 2.2) : "") + `<text x="${f1(x0 + 8 + ic + (w - 16 - ic) / 2)}" y="${f1(y + fs * 0.36)}" text-anchor="middle" font-size="${fs}" font-weight="600" fill="${ink}">${esc(text)}</text></g>`
4098
+ };
4099
+ }
4100
+ const cross = (x, y, s) => `<path d="M${f1(x - s)},${f1(y - s * 0.7)} L${f1(x + s)},${f1(y + s * 0.7)} M${f1(x + s)},${f1(y - s * 0.7)} L${f1(x - s)},${f1(y + s * 0.7)}" stroke="#dc2626" stroke-width="3.2" stroke-linecap="round"/>`;
4101
+ function person(c, r, z, col) {
4102
+ const [bx, by] = P(c, r, z), [hx, hy] = P(c, r, z + 19);
4103
+ return `<path d="M${f1(bx - 4.5)},${f1(by)} L${f1(bx - 4.5)},${f1(by - 11)} Q${f1(bx - 4.5)},${f1(by - 15)} ${f1(bx)},${f1(by - 15)} Q${f1(bx + 4.5)},${f1(by - 15)} ${f1(bx + 4.5)},${f1(by - 11)} L${f1(bx + 4.5)},${f1(by)} Z" fill="${col}" stroke="${LINE}" stroke-width="1.1"/><circle cx="${f1(hx)}" cy="${f1(hy)}" r="4.2" fill="#fde7d6" stroke="${LINE}" stroke-width="1.1"/>`;
4104
+ }
4105
+ function splitLabel(t) {
4106
+ const words = t.split(/\s+/).filter(Boolean);
4107
+ if (t.length <= 10 || words.length < 2) return [t];
4108
+ const mid = Math.ceil(words.length / 2);
4109
+ return [words.slice(0, mid).join(" "), words.slice(mid).join(" ")];
4110
+ }
4111
+ const SECONDS = {
4112
+ ms: 1e-3,
4113
+ s: 1,
4114
+ sec: 1,
4115
+ secs: 1,
4116
+ second: 1,
4117
+ seconds: 1,
4118
+ min: 60,
4119
+ mins: 60,
4120
+ minute: 60,
4121
+ minutes: 60,
4122
+ h: 3600,
4123
+ hr: 3600,
4124
+ hrs: 3600,
4125
+ hour: 3600,
4126
+ hours: 3600,
4127
+ d: 86400,
4128
+ day: 86400,
4129
+ days: 86400,
4130
+ wk: 604800,
4131
+ week: 604800,
4132
+ weeks: 604800,
4133
+ month: 2592e3,
4134
+ months: 2592e3,
4135
+ year: 31536e3,
4136
+ years: 31536e3
4137
+ };
4138
+ const SCALE = { k: 1e3, K: 1e3, M: 1e6, bn: 1e9, B: 1e9 };
4139
+ function measure(text) {
4140
+ const m = text.replace(/,/g, "").match(/(-?\d+(?:\.\d+)?)\s*([A-Za-z]+)?(?:\s*\/\s*([A-Za-z]+))?/);
4141
+ if (!m) return NaN;
4142
+ let v = parseFloat(m[1]);
4143
+ const unit = m[2], per = m[3];
4144
+ if (unit && SECONDS[unit.toLowerCase()]) v *= SECONDS[unit.toLowerCase()];
4145
+ else if (unit && SCALE[unit]) v *= SCALE[unit];
4146
+ if (per && SECONDS[per.toLowerCase()]) v /= SECONDS[per.toLowerCase()];
4147
+ return v;
4148
+ }
4149
+ const DUR = { flow: 400, add: 620, zone: 500, link: 520, send: 1500, move: 850, state: 600, gauge: 900, tag: 380, untag: 300, count: 1e3, panel: 450, remove: 450, pulse: 900 };
4150
+ const KIND_OF = (a) => Object.keys(DUR).find((k) => k in a);
4151
+ const str = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
4152
+ const num = (v, d = 0) => typeof v === "number" && Number.isFinite(v) ? v : d;
4153
+ function timeline(actions) {
4154
+ let cursor = 0, prev = null, groupEnd = 0, lane = 0;
4155
+ return actions.filter((a) => KIND_OF(a)).map((a) => {
4156
+ const kind = KIND_OF(a);
4157
+ if (kind !== prev) {
4158
+ cursor = groupEnd;
4159
+ lane = 0;
4160
+ prev = kind;
4161
+ }
4162
+ const start = cursor + lane++ * (kind === "send" ? 200 : 110);
4163
+ const dur = DUR[kind];
4164
+ groupEnd = Math.max(groupEnd, start + dur);
4165
+ return { a, kind, start, dur };
4166
+ });
4167
+ }
4168
+ function pathId(W, a, b) {
4169
+ for (const [id2, l] of W.links) if (l.from === a && l.to === b || l.from === b && l.to === a) return id2;
4170
+ return `${a}>${b}`;
4171
+ }
4172
+ function ensurePath(W, a, b, p) {
4173
+ if (!W.objs.has(a) || !W.objs.has(b)) return null;
4174
+ const id2 = pathId(W, a, b);
4175
+ if (!W.links.has(id2)) W.links.set(id2, { id: id2, from: a, to: b, style: "solid", draw: p });
4176
+ return id2;
4177
+ }
4178
+ class IsoDrawing {
4179
+ constructor(plan, reducedMotion = false) {
4180
+ this.reducedMotion = reducedMotion;
4181
+ this.cells = [-2, -2, 10, 8];
4182
+ this.vb = [0, 0, 640, 400];
4183
+ this.plan = plan;
4184
+ this.spread();
4185
+ this.fit();
4186
+ }
4187
+ /** The camera: it frames everything the plan ever draws. */
4188
+ get viewBox() {
4189
+ return this.vb.map((v) => v.toFixed(0)).join(" ");
4190
+ }
4191
+ get steps() {
4192
+ return this.plan.steps;
4193
+ }
4194
+ /** How long step *i*'s own animation runs (ms at speed 1), before its line is read. */
4195
+ stepDuration(i) {
4196
+ var _a, _b;
4197
+ if (this.reducedMotion) return 0;
4198
+ const tl = timeline((_b = (_a = this.plan.steps[i]) == null ? void 0 : _a.do) != null ? _b : []);
4199
+ return tl.reduce((m, e) => Math.max(m, e.start + e.dur), 0) + 300;
4200
+ }
4201
+ // -------------------------------------------------------------- layout
4202
+ /** Two things on one screen diagonal would hide each other: nudge the later one along. */
4203
+ spread() {
4204
+ const placed = [];
4205
+ for (const st of this.plan.steps) {
4206
+ if (st.clear) placed.length = 0;
4207
+ for (const a of st.do) {
4208
+ if (typeof a.add !== "string" || !Array.isArray(a.at) || a.is === "queue" || a.is === "pages") continue;
4209
+ let c = num(a.at[0]), r = num(a.at[1]);
4210
+ const others = placed.filter((q) => q[2] !== a.add);
4211
+ const tries = [[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [2, 0], [0, 2], [1, -1], [-1, 1]];
4212
+ const free = tries.find(([dc, dr]) => !others.some(([pc, pr]) => Math.abs(c + dc - r - dr - (pc - pr)) < 1.5 && Math.abs(c + dc + r + dr - (pc + pr)) < 3.4));
4213
+ if (free) {
4214
+ c += free[0];
4215
+ r += free[1];
4216
+ }
4217
+ a.at = [c, r];
4218
+ placed.push([c, r, a.add]);
4219
+ }
4220
+ }
4221
+ }
4222
+ /** The camera frames everything the plan ever draws, so it never jumps between steps. */
4223
+ fit() {
4224
+ const xs = [], ys = [];
4225
+ const take = (c, r, up, down) => {
4226
+ const [x2, y2] = P(c, r);
4227
+ xs.push(x2 - 75, x2 + 75);
4228
+ ys.push(y2 - up, y2 + down);
4229
+ };
4230
+ let left = false, right = false;
4231
+ for (const st of this.plan.steps) for (const a of st.do) {
4232
+ if (typeof a.add === "string" && Array.isArray(a.at)) {
4233
+ const c = num(a.at[0]) + 0.5, r = num(a.at[1]) + 0.5;
4234
+ take(c, r, a.is === "service" || !a.is ? 140 : 110, 55);
4235
+ if (["database", "queue", "pages"].includes(str(a.is)) && a.label) xs.push(P(c, r)[0] + 70 + str(a.label).length * 7.5);
4236
+ }
4237
+ if (typeof a.move === "string" && Array.isArray(a.to)) take(num(a.to[0]) + 0.5, num(a.to[1]) + 0.5, 120, 50);
4238
+ if (typeof a.zone === "string" && Array.isArray(a.at)) {
4239
+ const [c, r, w2 = 2, d = 2] = a.at.map((v) => num(v));
4240
+ for (const [cc, rr] of [[c, r], [c + w2, r], [c + w2, r + d], [c, r + d]]) take(cc, rr, 10, 10);
4241
+ }
4242
+ if (typeof a.panel === "string") {
4243
+ if (str(a.at).includes("left")) left = true;
4244
+ else right = true;
4245
+ }
4246
+ }
4247
+ if (!xs.length) take(3, 2, 100, 100);
4248
+ let x = Math.min(...xs) - 20 - (left ? 290 : 0);
4249
+ let w = Math.max(...xs) - x + 20 + (right ? 290 : 0);
4250
+ let y = Math.min(...ys) - 60;
4251
+ let h = Math.max(...ys) - y + 26;
4252
+ const want = 1.6;
4253
+ if (w / h < want) {
4254
+ const nw = h * want;
4255
+ x -= (nw - w) / 2;
4256
+ w = nw;
4257
+ } else {
4258
+ const nh = w / want;
4259
+ y -= (nh - h) / 2;
4260
+ h = nh;
4261
+ }
4262
+ this.vb = [x, y, w, h];
4263
+ }
4264
+ /** The kinds of parcel this plan sends, for the key under the scene. */
4265
+ legend() {
4266
+ const kinds = /* @__PURE__ */ new Set();
4267
+ for (const st of this.plan.steps) for (const a of st.do) {
4268
+ if (a.send || a.flow) {
4269
+ kinds.add(PACKETS[str(a.kind)] ? str(a.kind) : "request");
4270
+ if (a.bounce) kinds.add("response");
4271
+ if (num(a.fail) > 0) kinds.add("fail");
4272
+ }
4273
+ }
4274
+ return [...kinds].map((k) => ({ kind: k, label: PACKETS[k].label, color: PACKETS[k].color, ring: k === "ping" }));
4275
+ }
4276
+ /** The metric tiles as they stand at step *i*: each value, and whether it got better or worse. */
4277
+ metrics(i) {
4278
+ var _a, _b, _c, _d;
4279
+ const defs = this.plan.metrics;
4280
+ const ids = new Set(defs.map((m) => m.id));
4281
+ const fromActions = (st) => Object.fromEntries(st.do.filter((a) => typeof a.count === "string" && ids.has(a.count)).map((a) => [a.count, str(a.to)]));
4282
+ const vals = {};
4283
+ for (let k = 0; k <= i && k < this.plan.steps.length; k++) Object.assign(vals, (_a = this.plan.steps[k].metrics) != null ? _a : {}, fromActions(this.plan.steps[k]));
4284
+ const changed = /* @__PURE__ */ new Set([...Object.keys((_c = (_b = this.plan.steps[i]) == null ? void 0 : _b.metrics) != null ? _c : {}), ...Object.keys(fromActions((_d = this.plan.steps[i]) != null ? _d : { do: [] }))]);
4285
+ const value = (x) => measure(str(Array.isArray(x) ? x[0] : x));
4286
+ return defs.map((m) => {
4287
+ const v = vals[m.id];
4288
+ const text = (v == null ? "–" : str(Array.isArray(v) ? v[0] : v)).slice(0, 20);
4289
+ let tone2 = Array.isArray(v) ? str(v[1]) : "";
4290
+ if (!tone2 && m.better && v != null) {
4291
+ const first = this.plan.steps.map((st) => {
4292
+ var _a2;
4293
+ return ((_a2 = st.metrics) != null ? _a2 : {})[m.id];
4294
+ }).find((x) => x != null);
4295
+ const a0 = value(first), a1 = value(v);
4296
+ if (Number.isFinite(a0) && Number.isFinite(a1) && a0 !== a1) tone2 = (m.better === "low" ? a1 < a0 : a1 > a0) ? "good" : "bad";
4297
+ }
4298
+ const known = tone2 === "good" || tone2 === "bad" || tone2 === "warn" ? tone2 : "";
4299
+ return { id: m.id, label: m.label, text, tone: known, changed: changed.has(m.id), icon: m.icon && ISO_ICONS[m.icon] ? m.icon : void 0 };
4300
+ });
4301
+ }
4302
+ // -------------------------------------------------------------- the world at a moment
4303
+ world(i, t, live) {
4304
+ var _a;
4305
+ const W = { objs: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), zones: /* @__PURE__ */ new Map(), panels: /* @__PURE__ */ new Map(), flows: /* @__PURE__ */ new Map() };
4306
+ for (let k = 0; k < i; k++) this.apply(W, this.plan.steps[k], Infinity, null);
4307
+ this.apply(W, (_a = this.plan.steps[i]) != null ? _a : { say: "", do: [] }, t, live);
4308
+ return W;
4309
+ }
4310
+ apply(W, step, t, live) {
4311
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j2, _k, _l, _m;
4312
+ if (step.clear) {
4313
+ W.objs.clear();
4314
+ W.links.clear();
4315
+ W.zones.clear();
4316
+ W.panels.clear();
4317
+ W.flows.clear();
4318
+ }
4319
+ for (const ev of timeline(step.do)) {
4320
+ if (t !== Infinity && t < ev.start) continue;
4321
+ const p = t === Infinity ? 1 : clamp01((t - ev.start) / ev.dur);
4322
+ const a = ev.a;
4323
+ const id2 = str(a[ev.kind]);
4324
+ const o = W.objs.get(id2);
4325
+ switch (ev.kind) {
4326
+ case "add": {
4327
+ const prev = W.objs.get(id2);
4328
+ const at = Array.isArray(a.at) ? [num(a.at[0]) + 0.5, num(a.at[1]) + 0.5] : prev ? [prev.c, prev.r] : null;
4329
+ if (!at) break;
4330
+ const is = KINDS[str(a.is)] ? str(a.is) : "service";
4331
+ W.objs.set(id2, {
4332
+ ...prev != null ? prev : { tags: [] },
4333
+ id: id2,
4334
+ is,
4335
+ c: at[0],
4336
+ r: at[1],
4337
+ label: str(a.label) || (prev == null ? void 0 : prev.label),
4338
+ sub: a.sub ? str(a.sub) : void 0,
4339
+ icon: a.icon ? str(a.icon) : void 0,
4340
+ color: a.color ? str(a.color) : void 0,
4341
+ big: a.big === true,
4342
+ count: a.count != null ? num(a.count) : prev == null ? void 0 : prev.count,
4343
+ dir: a.dir ? str(a.dir) : void 0,
4344
+ fill: a.fill != null ? num(a.fill) : void 0,
4345
+ rise: p,
4346
+ tags: (_a = prev == null ? void 0 : prev.tags) != null ? _a : []
4347
+ });
4348
+ break;
4349
+ }
4350
+ case "zone": {
4351
+ if (!Array.isArray(a.at)) break;
4352
+ const [c, r, w, d] = a.at.map((v) => num(v));
4353
+ W.zones.set(id2, { c, r, w: w || 2, d: d || 2, label: str(a.label), tone: a.tone ? str(a.tone) : void 0, p });
4354
+ break;
4355
+ }
4356
+ case "link": {
4357
+ const ends = Array.isArray(a.link) ? a.link.map(str) : [];
4358
+ if (ends.length !== 2) break;
4359
+ const lid = pathId(W, ends[0], ends[1]);
4360
+ const prev = W.links.get(lid);
4361
+ W.links.set(lid, {
4362
+ id: lid,
4363
+ from: (_b = prev == null ? void 0 : prev.from) != null ? _b : ends[0],
4364
+ to: (_c = prev == null ? void 0 : prev.to) != null ? _c : ends[1],
4365
+ label: a.label ? str(a.label) : prev == null ? void 0 : prev.label,
4366
+ both: a.both === true || (prev == null ? void 0 : prev.both),
4367
+ style: a.style ? str(a.style) : (_d = prev == null ? void 0 : prev.style) != null ? _d : "solid",
4368
+ draw: prev ? 1 : p
4369
+ });
4370
+ break;
4371
+ }
4372
+ case "flow": {
4373
+ const prev = W.flows.get(id2);
4374
+ const via = Array.isArray(a.via) ? a.via.map(str) : (_e = prev == null ? void 0 : prev.via) != null ? _e : [];
4375
+ if (a.rate === 0) {
4376
+ W.flows.delete(id2);
4377
+ break;
4378
+ }
4379
+ for (let k = 0; k < via.length - 1; k++) ensurePath(W, via[k], via[k + 1], p);
4380
+ W.flows.set(id2, { via, rate: a.rate != null ? num(a.rate, 1) : (_f = prev == null ? void 0 : prev.rate) != null ? _f : 1, bounce: a.bounce === true || (prev == null ? void 0 : prev.bounce), fail: a.fail != null ? num(a.fail) : (_g = prev == null ? void 0 : prev.fail) != null ? _g : 0, kind: a.kind ? str(a.kind) : (_h = prev == null ? void 0 : prev.kind) != null ? _h : "request" });
4381
+ break;
4382
+ }
4383
+ case "send": {
4384
+ const ends = Array.isArray(a.send) ? a.send.map(str) : [];
4385
+ if (ends.length !== 2) break;
4386
+ const lid = ensurePath(W, ends[0], ends[1], p);
4387
+ if (live && p < 1 && lid) live.push({ a: { ...a, send: lid, back: ((_i = W.links.get(lid)) == null ? void 0 : _i.from) !== ends[0] }, p, dur: ev.dur });
4388
+ break;
4389
+ }
4390
+ case "panel":
4391
+ W.panels.set(id2, { ...a, p });
4392
+ break;
4393
+ case "remove":
4394
+ for (const m of [W.objs, W.links, W.zones, W.panels]) {
4395
+ const x = m.get(id2);
4396
+ if (x) {
4397
+ if (p >= 1) m.delete(id2);
4398
+ else x.alpha = 1 - p;
4399
+ }
4400
+ }
4401
+ if (p >= 1) {
4402
+ for (const [lid, l] of W.links) if (l.from === id2 || l.to === id2) W.links.delete(lid);
4403
+ }
4404
+ break;
4405
+ case "move":
4406
+ if (o && Array.isArray(a.to)) {
4407
+ if (!o.from) o.from = [o.c, o.r];
4408
+ const e = ease.inOut(p);
4409
+ o.c = lerp(o.from[0], num(a.to[0]) + 0.5, e);
4410
+ o.r = lerp(o.from[1], num(a.to[1]) + 0.5, e);
4411
+ if (p >= 1) delete o.from;
4412
+ }
4413
+ break;
4414
+ case "state": {
4415
+ const to = str(a.to);
4416
+ if (o) {
4417
+ o.state = to === "ok" ? null : to;
4418
+ o.shake = to === "down" && p < 1 ? p : 0;
4419
+ }
4420
+ break;
4421
+ }
4422
+ case "gauge":
4423
+ if (o) {
4424
+ if (o.gFrom == null) o.gFrom = (_j2 = o.gauge) != null ? _j2 : 0;
4425
+ o.gauge = lerp(o.gFrom, num(a.to), ease.out(p));
4426
+ if (p >= 1) delete o.gFrom;
4427
+ }
4428
+ break;
4429
+ case "tag":
4430
+ if (o) {
4431
+ o.tags = o.tags.filter((x) => x.text !== str(a.text));
4432
+ o.tags.push({ text: str(a.text), tone: a.tone ? str(a.tone) : void 0, icon: a.icon ? str(a.icon) : void 0, p });
4433
+ }
4434
+ break;
4435
+ case "untag":
4436
+ if (o) o.tags = o.tags.filter((x) => x.text !== str(a.text));
4437
+ break;
4438
+ case "count": {
4439
+ if (!o) break;
4440
+ const target = str(a.to), m = target.match(/-?[\d,.]+/);
4441
+ if (o.is === "crowd" || o.is === "queue" || o.is === "pages") {
4442
+ if (o.cFrom == null) o.cFrom = (_k = o.count) != null ? _k : 0;
4443
+ const end = m ? parseFloat(m[0].replace(/,/g, "")) : (_l = o.count) != null ? _l : 0;
4444
+ o.count = Math.round(lerp(o.cFrom, Math.min(end, o.is === "crowd" ? 40 : 16), ease.out(p)));
4445
+ if (p >= 1) delete o.cFrom;
4446
+ } else if (m && p < 1) {
4447
+ if (o.nFrom == null) o.nFrom = parseFloat(str((_m = o.badge) != null ? _m : "0").replace(/[^\d.-]/g, "")) || 0;
4448
+ const v = Math.round(lerp(o.nFrom, parseFloat(m[0].replace(/,/g, "")), ease.out(p)));
4449
+ o.badge = target.replace(m[0], v.toLocaleString("en-GB"));
4450
+ } else {
4451
+ o.badge = target;
4452
+ delete o.nFrom;
4453
+ }
4454
+ break;
4455
+ }
4456
+ case "pulse":
4457
+ if (o) o.pulse = p < 1 ? p : 0;
4458
+ break;
4459
+ }
4460
+ }
4461
+ }
4462
+ route(l, W) {
4463
+ const A = W.objs.get(l.from), B = W.objs.get(l.to);
4464
+ if (!A || !B) return null;
4465
+ const others = [...W.objs.values()].filter((o) => o !== A && o !== B);
4466
+ const blocked = (pts2) => {
4467
+ for (let k = 0; k < pts2.length - 1; k++) {
4468
+ const [a, b] = [pts2[k], pts2[k + 1]], n = Math.ceil(Math.hypot(b[0] - a[0], b[1] - a[1]) * 6);
4469
+ for (let s = 1; s < n; s++) {
4470
+ const c = lerp(a[0], b[0], s / n), r = lerp(a[1], b[1], s / n);
4471
+ if (others.some((o) => Math.abs(o.c - c) < 0.42 && Math.abs(o.r - r) < 0.42)) return true;
4472
+ }
4473
+ }
4474
+ return false;
4475
+ };
4476
+ let pts;
4477
+ if (Math.abs(A.c - B.c) < 0.05 || Math.abs(A.r - B.r) < 0.05) pts = [[A.c, A.r], [B.c, B.r]];
4478
+ else {
4479
+ const a = [[A.c, A.r], [A.c, B.r], [B.c, B.r]], b = [[A.c, A.r], [B.c, A.r], [B.c, B.r]];
4480
+ pts = !blocked(a) || blocked(b) ? a : b;
4481
+ if (blocked(pts)) pts = [[A.c, A.r], [B.c, B.r]];
4482
+ }
4483
+ const trim = (p, q, by) => {
4484
+ const L = Math.hypot(q[0] - p[0], q[1] - p[1]) || 1, k = Math.min(by, L * 0.45) / L;
4485
+ return [p[0] + (q[0] - p[0]) * k, p[1] + (q[1] - p[1]) * k];
4486
+ };
4487
+ pts[0] = trim(pts[0], pts[1], KINDS[A.is].r + 0.06);
4488
+ pts[pts.length - 1] = trim(pts[pts.length - 1], pts[pts.length - 2], KINDS[B.is].r + 0.1);
4489
+ return pts;
4490
+ }
4491
+ // -------------------------------------------------------------- drawing
4492
+ /**
4493
+ * Step *i* at *t* ms into its animation (Infinity: finished), as SVG text.
4494
+ * *clock* is seconds on a running clock, for traffic that keeps flowing.
4495
+ */
4496
+ svg(i, t, clock) {
4497
+ var _a, _b, _c, _d, _e, _f;
4498
+ if (this.reducedMotion) t = Infinity;
4499
+ const live = [];
4500
+ const W = this.world(i, t, live);
4501
+ const defs = new Defs();
4502
+ const out = [], over = [];
4503
+ const [c0, r0, c1, r1] = this.cells;
4504
+ const grid = [];
4505
+ for (let c = c0; c <= c1; c += 0.5) grid.push(`M${pt(P(c, r0))} L${pt(P(c, r1))}`);
4506
+ for (let r = r0; r <= r1; r += 0.5) grid.push(`M${pt(P(c0, r))} L${pt(P(c1, r))}`);
4507
+ out.push(`<path d="${grid.join(" ")}" stroke="rgba(30,36,48,.07)" stroke-width="1" fill="none"/>`);
4508
+ for (const z of W.zones.values()) out.push(this.zoneSvg(z));
4509
+ const paths = /* @__PURE__ */ new Map();
4510
+ const labels = [];
4511
+ for (const l of W.links.values()) {
4512
+ const pts = this.route(l, W);
4513
+ if (!pts) continue;
4514
+ const scr = pts.map((q) => P(q[0], q[1], 2));
4515
+ let len = 0;
4516
+ for (let k = 1; k < scr.length; k++) len += Math.hypot(scr[k][0] - scr[k - 1][0], scr[k][1] - scr[k - 1][1]);
4517
+ paths.set(l.id, pts);
4518
+ const dead = l.style === "off" || l.style === "cut" || [l.from, l.to].some((oid) => {
4519
+ var _a2;
4520
+ return ((_a2 = W.objs.get(oid)) == null ? void 0 : _a2.state) === "down";
4521
+ });
4522
+ const shown = ease.inOut(l.draw);
4523
+ const color = l.style === "cut" || dead && l.style !== "off" ? "#dc2626" : dead ? "#94a3b8" : LINE;
4524
+ let dash = "";
4525
+ if (l.style === "dashed" || dead) dash = 'stroke-dasharray="6 6"';
4526
+ if (l.style === "beat") dash = `stroke-dasharray="3 7" stroke-dashoffset="${f1(-(clock * 1e3 / 40) % 10)}"`;
4527
+ const draw = shown < 0.999 ? `stroke-dasharray="${f1(shown * len)} ${f1(len + 20)}"` : dash;
4528
+ const marker = color === "#dc2626" ? "iar" : color === "#94a3b8" ? "iag" : "ia";
4529
+ const heads = shown > 0.97 && l.style !== "off" ? `marker-end="url(#${marker})"${l.both ? ` marker-start="url(#${marker})"` : ""}` : "";
4530
+ out.push(`<path d="${roundedPath(scr, 14)}" fill="none" stroke="${color}" stroke-width="1.9" stroke-linecap="round" ${draw} ${heads} opacity="${(_a = l.alpha) != null ? _a : 1}"/>`);
4531
+ if (l.style === "cut" && shown > 0.9) {
4532
+ const m = P(...along(pts, 0.5), 2);
4533
+ over.push(`<g transform="translate(${f1(m[0])} ${f1(m[1])})"><circle r="8" fill="#fee2e2" stroke="#dc2626" stroke-width="1.5"/>${cross(0, 0, 4)}</g>`);
4534
+ }
4535
+ if (l.label && shown > 0.6) labels.push({ at: P(...along(pts, 0.5), 2), text: l.label, rank: 3, alpha: l.alpha });
4536
+ }
4537
+ const things = [];
4538
+ for (const o of W.objs.values()) things.push({ depth: o.c + o.r, o });
4539
+ for (const { a, p, dur } of live) {
4540
+ const pts = paths.get(str(a.send));
4541
+ if (!pts || p >= 1) continue;
4542
+ const e = ease.inOut(clamp01(p * (dur / DUR.send)));
4543
+ const at = along(pts, a.back ? 1 - e : e);
4544
+ things.push({ depth: at[0] + at[1] + 0.02, parcel: { at, kind: PACKETS[str(a.kind)] ? str(a.kind) : "request", q: e, label: a.label ? str(a.label) : void 0 } });
4545
+ }
4546
+ const now = this.reducedMotion ? 0.37 : clock;
4547
+ for (const fl of W.flows.values()) {
4548
+ const hops = [];
4549
+ for (let k = 0; k < fl.via.length - 1; k++) {
4550
+ const lid = pathId(W, fl.via[k], fl.via[k + 1]), info = paths.get(lid);
4551
+ if (!info) {
4552
+ hops.length = 0;
4553
+ break;
4554
+ }
4555
+ hops.push(((_b = W.links.get(lid)) == null ? void 0 : _b.from) === fl.via[k] ? info : [...info].reverse());
4556
+ }
4557
+ if (!hops.length) continue;
4558
+ const route = hops.flat(), there = 1.3 * hops.length, trip = fl.bounce ? there * 2 : there;
4559
+ const rate = Math.max(0.1, Math.min(fl.rate, 5));
4560
+ for (let k = Math.max(Math.floor((now - trip) * rate), 0); k <= Math.floor(now * rate); k++) {
4561
+ const age = now - k / rate;
4562
+ if (age < 0 || age > trip) continue;
4563
+ const failed = fl.fail > 0 && (k * 9301 + 49297) % 233280 / 233280 < fl.fail;
4564
+ const outward = age <= there, q = outward ? age / there : (age - there) / there;
4565
+ if (failed && !outward) continue;
4566
+ const at = along(route, outward ? ease.inOut(q) : 1 - ease.inOut(q));
4567
+ const kind = failed ? "fail" : outward ? PACKETS[fl.kind] ? fl.kind : "request" : "response";
4568
+ things.push({ depth: at[0] + at[1] + 0.02, parcel: { at, kind, q: failed ? q : 0.5 } });
4569
+ }
4570
+ }
4571
+ things.sort((x, y) => x.depth - y.depth);
4572
+ const bodies = [];
4573
+ for (const th of things) {
4574
+ if (th.parcel) {
4575
+ out.push(parcel(th.parcel.at, th.parcel.kind, th.parcel.q));
4576
+ if (th.parcel.label) labels.push({ at: P(th.parcel.at[0], th.parcel.at[1], 24), text: th.parcel.label, rank: 4, tone: th.parcel.kind === "fail" ? "red" : th.parcel.kind === "response" ? "green" : "amber" });
4577
+ continue;
4578
+ }
4579
+ const o = th.o, K = KINDS[o.is];
4580
+ const rise = o.rise;
4581
+ const lift = Math.max(0, (1 - ease.pop(rise)) * -26) + (o.pulse ? Math.sin(o.pulse * Math.PI) * 7 : 0);
4582
+ const shake = o.shake ? Math.sin(o.shake * Math.PI * 8) * 3 * (1 - o.shake) : 0;
4583
+ const [gx, gy] = P(o.c, o.r, 0);
4584
+ if (o.state === "hot") out.push(`<ellipse cx="${f1(gx)}" cy="${f1(gy - 18)}" rx="62" ry="44" fill="url(#ihot)"/>`);
4585
+ if (o.pulse) {
4586
+ const e = ease.out(o.pulse);
4587
+ out.push(`<ellipse cx="${f1(gx)}" cy="${f1(gy)}" rx="${f1(40 + 40 * e)}" ry="${f1(20 + 20 * e)}" fill="none" stroke="#2563eb" stroke-width="2.5" opacity="${f1(1 - e)}"/>`);
4588
+ }
4589
+ if (o.is !== "queue" && o.is !== "pages") out.push(`<ellipse cx="${f1(gx)}" cy="${f1(gy + 3)}" rx="${f1(K.r * HW * 1.5)}" ry="${f1(K.r * HH * 1.5)}" fill="rgba(30,36,48,${f1(0.08 * rise)})"/>`);
4590
+ out.push(`<g transform="translate(${f1(shake)} 0)" opacity="${f1(Math.min(1, rise * 1.6) * ((_c = o.alpha) != null ? _c : 1) * (o.state === "dim" ? 0.42 : 1))}">${this.object(o, lift, defs)}</g>`);
4591
+ const topZ = (o.is === "service" && o.big ? 47 : K.top) + lift;
4592
+ let stackY = P(o.c, o.r, topZ)[1] - 16;
4593
+ const cx = gx;
4594
+ if (o.gauge != null) {
4595
+ const v = Math.round(o.gauge), col = v >= 85 ? "#dc2626" : v >= 60 ? "#d97706" : "#16a34a";
4596
+ over.push(`<g transform="translate(${f1(cx)} ${f1(stackY)})"><rect x="-38" y="-10" width="76" height="20" rx="10" fill="#fff" stroke="${LINE}" stroke-width="1.3"/>${icon("cpu", -26, 0, 11, "#475569", 2.2)}<rect x="-17" y="-3" width="30" height="6" rx="3" fill="#e2e8f0"/><rect x="-17" y="-3" width="${f1(30 * clamp01(v / 100))}" height="6" rx="3" fill="${col}"/><text x="27" y="4" text-anchor="end" font-size="10" font-weight="700" fill="${LINE}">${v}%</text></g>`);
4597
+ stackY -= 24;
4598
+ }
4599
+ const tags = [...o.tags];
4600
+ if (o.state === "down" && !tags.some((x) => /down/i.test(x.text))) tags.unshift({ text: "DOWN", tone: "red", icon: "alert", p: 1 });
4601
+ for (const tg of tags) {
4602
+ over.push(pill(cx, stackY, tg.text, { tone: (_d = tg.tone) != null ? _d : "ink", icon: tg.icon, fs: 10.5, alpha: tg.p }).svg);
4603
+ stackY -= 23;
4604
+ }
4605
+ if (o.badge) {
4606
+ over.push(pill(cx, stackY, o.badge, { bg: "#0f172a", ink: "#fff", fs: 11 }).svg);
4607
+ stackY -= 23;
4608
+ }
4609
+ if (o.label && o.is !== "service" && o.is !== "ghost") {
4610
+ const below = o.is === "crowd" || o.is === "laptop" || o.is === "phone";
4611
+ const beside = o.is === "database" || o.is === "queue" || o.is === "pages";
4612
+ labels.push({
4613
+ at: below ? [cx, P(o.c + 0.5, o.r + 0.5, 0)[1] + 18] : P(o.c + 0.42, o.r - 0.3, beside ? 22 : 0),
4614
+ text: o.label,
4615
+ rank: 1,
4616
+ icon: o.is === "crowd" ? "users" : below ? "user" : o.is === "database" ? "database" : void 0,
4617
+ anchor: beside ? "start" : void 0,
4618
+ alpha: Math.min(1, rise * 2) * ((_e = o.alpha) != null ? _e : 1)
4619
+ });
4620
+ }
4621
+ bodies.push([cx - 40, P(o.c, o.r, topZ)[1] - 8, 80, topZ + 16]);
4622
+ }
4623
+ const placed = [];
4624
+ const hit = (a, b) => a[0] < b[0] + b[2] && b[0] < a[0] + a[2] && a[1] < b[1] + b[3] && b[1] < a[1] + a[3];
4625
+ const TRIES = [[0, 0], [0, -18], [0, 18], [30, 0], [-30, 0], [26, -16], [-26, 16], [0, -34]];
4626
+ labels.sort((a, b) => a.rank - b.rank);
4627
+ for (const L of labels) {
4628
+ let done = false;
4629
+ for (const [dx, dy] of L.rank === 1 ? [[0, 0], [0, 18], [0, -18], [28, 0], [-28, 0], [0, 34]] : TRIES) {
4630
+ const pl = pill(L.at[0] + dx, L.at[1] + dy, L.text, { tone: (_f = L.tone) != null ? _f : "ink", icon: L.icon, fs: L.rank === 1 ? 11.5 : 10, anchor: L.anchor, alpha: L.alpha });
4631
+ const box2 = [pl.x0 - 2, pl.y0 - 2, pl.w + 4, pl.h + 4];
4632
+ if (!(L.rank === 1 ? placed : [...placed, ...bodies]).some((b) => hit(box2, b))) {
4633
+ placed.push(box2);
4634
+ over.push(pl.svg);
4635
+ done = true;
4636
+ break;
4637
+ }
4638
+ }
4639
+ if (!done && L.rank === 1) {
4640
+ const pl = pill(L.at[0], L.at[1], L.text, { icon: L.icon, fs: 11.5, anchor: L.anchor, alpha: L.alpha });
4641
+ placed.push([pl.x0, pl.y0, pl.w, pl.h]);
4642
+ over.push(pl.svg);
4643
+ }
4644
+ }
4645
+ for (const pn of W.panels.values()) over.push(this.panelSvg(pn));
4646
+ const markers = [["ia", LINE], ["iar", "#dc2626"], ["iag", "#94a3b8"]].map(([id2, col]) => `<marker id="${id2}" viewBox="0 0 10 10" refX="7.5" refY="5" markerWidth="5.5" markerHeight="5.5" orient="auto-start-reverse"><path d="M0 0 L10 5 L0 10 Z" fill="${col}"/></marker>`).join("");
4647
+ const glow = '<radialGradient id="ihot"><stop offset="0" stop-color="#ef4444" stop-opacity=".38"/><stop offset="1" stop-color="#ef4444" stop-opacity="0"/></radialGradient>';
4648
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${this.viewBox}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${esc(this.plan.title)}"><defs>${markers}${glow}${defs.out.join("")}</defs><g font-family="${MONO}">${out.join("")}${over.join("")}</g></svg>`;
4649
+ }
4650
+ object(o, z, defs) {
4651
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4652
+ const fallback = o.is === "database" || o.is === "pages" ? "purple" : o.icon && ICON_COLOR[o.icon] || "blue";
4653
+ const pal = o.state === "hot" ? COLORS.hot : o.state === "down" ? COLORS.down : (_b = COLORS[(_a = o.color) != null ? _a : ""]) != null ? _b : COLORS[fallback];
4654
+ const { c, r } = o;
4655
+ let s = "";
4656
+ if (o.is === "service") {
4657
+ const w = 0.8 * (o.big ? 1.12 : 1), h = 40 * (o.big ? 1.12 : 1);
4658
+ s += roundBox(c, r, w, w, z, h, pal, defs, 11);
4659
+ const [x, y] = P(c, r, z + h);
4660
+ const lines = splitLabel((_c = o.label) != null ? _c : "");
4661
+ const ty = y - (lines.length * 12 + (o.sub ? 10 : 0) + (o.icon ? 18 : 0)) / 2 + 2;
4662
+ if (o.icon) s += icon(o.icon, x, ty + 7, 19, pal[3], 2);
4663
+ lines.forEach((ln, k) => {
4664
+ s += `<text x="${f1(x)}" y="${f1(ty + (o.icon ? 27 : 9) + k * 12)}" text-anchor="middle" font-size="12.5" font-weight="700" fill="${pal[3]}">${esc(ln)}</text>`;
4665
+ });
4666
+ if (o.sub) s += `<text x="${f1(x)}" y="${f1(ty + (o.icon ? 27 : 9) + lines.length * 12 - 1)}" text-anchor="middle" font-size="8.5" fill="${pal[3]}" opacity=".75">${esc(o.sub)}</text>`;
4667
+ if (o.state === "down") s += cross(x, y - 2, 13);
4668
+ } else if (o.is === "ghost") {
4669
+ const w = 0.8, h = 38, x0 = c - w / 2, x1 = c + w / 2, r0 = r - w / 2, r1 = r + w / 2;
4670
+ const sil = [P(x0, r0, z + h), P(x1, r0, z + h), P(x1, r0, z), P(x1, r1, z), P(x0, r1, z), P(x0, r1, z + h)];
4671
+ s += `<path d="${rounded(sil, 10)}" fill="rgba(255,255,255,.35)" stroke="${LINE}" stroke-width="1.4" stroke-dasharray="5 4"/>`;
4672
+ const [x, y] = P(c, r, z + h);
4673
+ s += `<text x="${f1(x)}" y="${f1(y + 4)}" text-anchor="middle" font-size="10.5" font-weight="700" fill="#475569">${esc((_d = o.label) != null ? _d : "?")}</text>`;
4674
+ } else if (o.is === "database") {
4675
+ const R = 0.3 * (o.big ? 1.3 : 1), h = 44 * (o.big ? 1.3 : 1);
4676
+ s += cylinder(c, r, R, z, h, pal, defs);
4677
+ if (o.fill) {
4678
+ const rx = R * HW * Math.SQRT2, ry = R * HH * Math.SQRT2, [bx, by] = P(c, r, z), fh = h * clamp01(o.fill);
4679
+ s += `<path d="M${f1(bx - rx)},${f1(by)} A${f1(rx)},${f1(ry)} 0 0 0 ${f1(bx + rx)},${f1(by)} L${f1(bx + rx)},${f1(by - fh)} A${f1(rx)},${f1(ry)} 0 0 1 ${f1(bx - rx)},${f1(by - fh)} Z" fill="#a9e0b4" stroke="${LINE}" stroke-width="1.2" opacity=".9"/>`;
4680
+ }
4681
+ const [x, y] = P(c, r, z + h * 0.42);
4682
+ s += icon((_e = o.icon) != null ? _e : "database", x, y + 6, 16, pal[3], 2);
4683
+ if (o.state === "down") s += cross(x, y - 8, 12);
4684
+ } else if (o.is === "laptop" || o.is === "phone") {
4685
+ s += roundBox(c, r, 0.78, 0.78, z, 10, COLORS.sand, defs, 12);
4686
+ const screen = o.state === "down" ? "#e4e4e7" : "#ddd6fe";
4687
+ if (o.is === "laptop") {
4688
+ s += roundBox(c + 0.02, r + 0.04, 0.46, 0.34, z + 10, 3, ["#f1f5f9", "#cbd5e1", "#94a3b8"], defs, 4, 1.3);
4689
+ const sx0 = c - 0.21, sx1 = c + 0.25, rr = r - 0.14;
4690
+ s += `<path d="${rounded([P(sx0, rr, z + 13), P(sx1, rr, z + 13), P(sx1, rr - 0.03, z + 44), P(sx0, rr - 0.03, z + 44)], 4)}" fill="#3f3f46" stroke="${LINE}" stroke-width="1.5"/>`;
4691
+ s += `<polygon points="${[P(sx0 + 0.03, rr + 2e-3, z + 16), P(sx1 - 0.03, rr + 2e-3, z + 16), P(sx1 - 0.03, rr - 0.025, z + 41), P(sx0 + 0.03, rr - 0.025, z + 41)].map(pt).join(" ")}" fill="${screen}"/>`;
4692
+ s += `<polygon points="${[P(sx0 + 0.06, rr, z + 34), P(sx1 - 0.12, rr, z + 34), P(sx1 - 0.12, rr, z + 37), P(sx0 + 0.06, rr, z + 37)].map(pt).join(" ")}" fill="#a78bfa"/>`;
4693
+ } else {
4694
+ const px = c + 0.02;
4695
+ s += `<path d="${rounded([P(px - 0.13, r, z + 10), P(px + 0.13, r, z + 10), P(px + 0.13, r, z + 54), P(px - 0.13, r, z + 54)], 6)}" fill="#3f3f46" stroke="${LINE}" stroke-width="1.5"/>`;
4696
+ s += `<path d="${rounded([P(px - 0.1, r + 2e-3, z + 14), P(px + 0.1, r + 2e-3, z + 14), P(px + 0.1, r + 2e-3, z + 50), P(px - 0.1, r + 2e-3, z + 50)], 4)}" fill="${screen}"/>`;
4697
+ s += `<polygon points="${[P(px - 0.07, r, z + 36), P(px + 0.05, r, z + 36), P(px + 0.05, r, z + 42), P(px - 0.07, r, z + 42)].map(pt).join(" ")}" fill="#a78bfa"/>`;
4698
+ }
4699
+ } else if (o.is === "crowd") {
4700
+ const n = Math.max(3, Math.min(40, Math.round((_f = o.count) != null ? _f : 8)));
4701
+ const cols = Math.ceil(Math.sqrt(n * 1.4)), rows = Math.ceil(n / cols);
4702
+ const pw = Math.min(1.5, 0.3 + cols * 0.13), pd = Math.min(1.2, 0.3 + rows * 0.13);
4703
+ s += roundBox(c, r, pw, pd, z, 9, COLORS.sand, defs, 12);
4704
+ const people = [];
4705
+ for (let k = 0; k < n; k++) {
4706
+ const i = k % cols, j = Math.floor(k / cols);
4707
+ people.push([c - pw / 2 + 0.17 + i * (pw - 0.34) / Math.max(1, cols - 1), r - pd / 2 + 0.17 + j * (pd - 0.34) / Math.max(1, rows - 1), PEOPLE[k * 3 % PEOPLE.length]]);
4708
+ }
4709
+ people.sort((a, b) => a[0] + a[1] - b[0] - b[1]);
4710
+ for (const [pc, pr, col] of people) s += person(pc, pr, z + 9, col);
4711
+ } else if (o.is === "queue" || o.is === "pages") {
4712
+ const n = Math.max(1, Math.min(16, Math.round((_g = o.count) != null ? _g : 6)));
4713
+ const dir = o.dir === "down" ? [0, 1] : o.dir === "up" ? [0, -1] : o.dir === "left" ? [-1, 0] : [1, 0];
4714
+ const step = o.is === "pages" ? 0.17 : 0.19, len = (n - 1) * step;
4715
+ const lane = [
4716
+ P(c - 0.12 * Math.abs(dir[1]) - 0.12, r - 0.12 * Math.abs(dir[0]) - 0.12, 0),
4717
+ P(c + dir[0] * len + 0.12 + 0.12 * Math.abs(dir[1]), r - 0.12, 0),
4718
+ P(c + dir[0] * len + 0.12, r + dir[1] * len + 0.12, 0),
4719
+ P(c - 0.12, r + dir[1] * len + 0.12 + 0.12 * Math.abs(dir[0]), 0)
4720
+ ];
4721
+ s += `<path d="${rounded(lane, 6)}" fill="rgba(148,163,184,.08)" stroke="${LINE}" stroke-opacity=".5" stroke-width="1.1" stroke-dasharray="4 4"/>`;
4722
+ const items = [];
4723
+ for (let k = 0; k < n; k++) items.push([c + dir[0] * k * step, r + dir[1] * k * step]);
4724
+ items.sort((a, b) => a[0] + a[1] - b[0] - b[1]);
4725
+ for (const [ic, ir] of items) {
4726
+ if (o.is === "pages") s += roundBox(ic, ir, 0.13, 0.32, z, 7, o.state === "hot" ? COLORS.hot : (_i = COLORS[(_h = o.color) != null ? _h : ""]) != null ? _i : COLORS.purple, defs, 4, 1.2);
4727
+ else {
4728
+ const [x, y] = P(ic, ir, z + 5);
4729
+ s += `<circle cx="${f1(x)}" cy="${f1(y)}" r="7" fill="${o.state === "hot" ? "#ef4444" : PACKETS.request.color}" stroke="${LINE}" stroke-width="1.2"/>`;
4730
+ }
4731
+ }
4732
+ }
4733
+ return s;
4734
+ }
4735
+ zoneSvg(z) {
4736
+ var _a;
4737
+ const e = ease.out(z.p);
4738
+ const corners = [P(z.c, z.r), P(z.c + z.w, z.r), P(z.c + z.w, z.r + z.d), P(z.c, z.r + z.d)];
4739
+ const fill = z.tone === "green" ? "rgba(34,163,90,.10)" : z.tone === "red" ? "rgba(220,38,38,.08)" : z.tone === "blue" ? "rgba(37,99,235,.08)" : "rgba(148,163,184,.06)";
4740
+ const stroke = z.tone === "green" ? "#22a35a" : z.tone === "red" ? "#dc2626" : z.tone === "blue" ? "#2563eb" : LINE;
4741
+ const [lx, ly] = P(z.c + 0.15, z.r + z.d - 0.1);
4742
+ const n = Math.hypot(HW, HH);
4743
+ const label = z.label ? `<text transform="matrix(${f1(HW / n)} ${f1(HH / n)} ${f1(-HW / n)} ${f1(HH / n)} ${f1(lx)} ${f1(ly)})" font-size="11" font-weight="700" letter-spacing="2.5" fill="${stroke}" opacity=".95">${esc(z.label.toUpperCase())}</text>` : "";
4744
+ return `<g opacity="${f1(e * ((_a = z.alpha) != null ? _a : 1))}"><path d="${rounded(corners, 14)}" fill="${fill}" stroke="${stroke}" stroke-opacity=".7" stroke-width="1.4" stroke-dasharray="7 5"/>${label}</g>`;
4745
+ }
4746
+ panelSvg(pn) {
4747
+ var _a, _b, _c, _d;
4748
+ const [vx, vy, vw, vh] = this.vb;
4749
+ const lines = ((_a = pn.lines) != null ? _a : []).slice(0, 7).map(str);
4750
+ const bars = ((_b = pn.bars) != null ? _b : []).slice(0, 5);
4751
+ const chart = pn.line && Array.isArray(pn.line.points) ? pn.line : null;
4752
+ const fs = 11, lh = 17;
4753
+ const w = Math.min(vw * 0.42, Math.max(220, ...lines.map((l) => l.replace(/^[!+~]/, "").length * fs * 0.6 + 28), str(pn.title).length * 8 + 50));
4754
+ const h = 34 + lines.length * lh + bars.length * 20 + (chart ? 70 : 0) + 8;
4755
+ const where = str(pn.at) || "top-right";
4756
+ const x = where.includes("left") ? vx + 14 : vx + vw - w - 14;
4757
+ const y = where.includes("top") ? vy + 60 : vy + vh - h - 26;
4758
+ const e = ease.out(pn.p);
4759
+ let s = `<g opacity="${f1(e * ((_c = pn.alpha) != null ? _c : 1))}" transform="translate(${f1(x)} ${f1(y + (1 - e) * 8)})"><rect width="${f1(w)}" height="${f1(h)}" rx="8" fill="#fff" stroke="${LINE}" stroke-width="1.4"/>`;
4760
+ s += icon(pn.icon && ISO_ICONS[pn.icon] ? pn.icon : "info", 16, 17, 12, "#475569", 2.2);
4761
+ s += `<text x="28" y="21" font-size="9.5" font-weight="700" letter-spacing="1.4" fill="#475569">${esc(str(pn.title).toUpperCase())}</text>`;
4762
+ s += `<line x1="10" x2="${f1(w - 10)}" y1="30" y2="30" stroke="#e2e8f0"/>`;
4763
+ let yy = 34;
4764
+ for (const raw of lines) {
4765
+ const mark = raw[0], text = /^[!+~]/.test(raw) ? raw.slice(1) : raw;
4766
+ if (mark === "!" || mark === "+") s += `<rect x="8" y="${yy + 1}" width="${f1(w - 16)}" height="${lh - 2}" rx="3" fill="${mark === "!" ? "#fee2e2" : "#dcfce7"}"/>`;
4767
+ s += `<text x="14" y="${yy + 12.5}" font-size="${fs}" fill="${mark === "!" ? "#b91c1c" : mark === "+" ? "#15803d" : mark === "~" ? "#94a3b8" : LINE}" font-weight="${mark === "!" || mark === "+" ? 700 : 500}" xml:space="preserve">${esc(text)}</text>`;
4768
+ yy += lh;
4769
+ }
4770
+ for (const [label, value, tone2] of bars) {
4771
+ const col = (_d = TONE[tone2]) != null ? _d : TONE.blue, bw = w - 140;
4772
+ s += `<text x="14" y="${yy + 13}" font-size="10.5" fill="${LINE}">${esc(label)}</text><rect x="104" y="${yy + 5}" width="${f1(bw)}" height="9" rx="4.5" fill="#eef2f7"/><rect x="104" y="${yy + 5}" width="${f1(bw * clamp01(num(value) / 100))}" height="9" rx="4.5" fill="${col}"/><text x="${f1(w - 12)}" y="${yy + 13}" text-anchor="end" font-size="10" font-weight="700" fill="${col}">${esc(value)}%</text>`;
4773
+ yy += 20;
4774
+ }
4775
+ if (chart) {
4776
+ const pts = chart.points.map(Number).filter((n) => Number.isFinite(n)).slice(0, 12);
4777
+ const max = Math.max(...pts, 1), cw = w - 40, chh = 50, ox = 26, oy = yy + 8;
4778
+ const xy = pts.map((v, i) => [ox + i * cw / Math.max(1, pts.length - 1), oy + chh - v / max * chh]);
4779
+ s += `<line x1="${ox}" y1="${oy + chh}" x2="${ox + cw}" y2="${oy + chh}" stroke="#cbd5e1"/><line x1="${ox}" y1="${oy}" x2="${ox}" y2="${oy + chh}" stroke="#cbd5e1"/>`;
4780
+ s += `<polyline points="${xy.map(pt).join(" ")}" fill="none" stroke="${LINE}" stroke-width="1.8" stroke-linejoin="round"/>`;
4781
+ if (chart.mark != null && xy.length) {
4782
+ const m = xy[Math.max(0, Math.min(xy.length - 1, chart.mark))];
4783
+ s += `<circle cx="${f1(m[0])}" cy="${f1(m[1])}" r="4" fill="#22a35a" stroke="${LINE}"/>`;
4784
+ }
4785
+ if (chart.x) s += `<text x="${ox + cw}" y="${oy + chh + 12}" text-anchor="end" font-size="9" fill="#64748b">${esc(chart.x)} →</text>`;
4786
+ if (chart.y) s += `<text x="${ox + 4}" y="${oy + 8}" font-size="9" fill="#64748b">${esc(chart.y)}</text>`;
4787
+ }
4788
+ return s + "</g>";
4789
+ }
4790
+ }
4791
+ function parcel(at, kind, q) {
4792
+ var _a;
4793
+ const [x, y] = P(at[0], at[1], 6), col = ((_a = PACKETS[kind]) != null ? _a : PACKETS.request).color;
4794
+ const shadow = `<ellipse cx="${f1(x)}" cy="${f1(y + 7)}" rx="7" ry="3.5" fill="rgba(30,36,48,.14)"/>`;
4795
+ if (kind === "write") return shadow + `<rect x="${f1(x - 5)}" y="${f1(y - 5)}" width="10" height="10" rx="2" fill="${col}" stroke="${LINE}" stroke-width="1.2"/>`;
4796
+ if (kind === "heavy") return shadow + `<rect x="${f1(x - 7.5)}" y="${f1(y - 7.5)}" width="15" height="15" rx="3" fill="${col}" stroke="${LINE}" stroke-width="1.3"/>`;
4797
+ if (kind === "ping") return shadow + `<circle cx="${f1(x)}" cy="${f1(y)}" r="5.5" fill="#fff" stroke="${col}" stroke-width="2.4"/>`;
4798
+ if (kind === "event") return shadow + `<path d="M${f1(x)},${f1(y - 7)} L${f1(x + 7)},${f1(y)} L${f1(x)},${f1(y + 7)} L${f1(x - 7)},${f1(y)} Z" fill="${col}" stroke="${LINE}" stroke-width="1.2"/>`;
4799
+ if (kind === "fail" && q > 0.82) {
4800
+ const e = (q - 0.82) / 0.18;
4801
+ return `<g opacity="${f1(1 - e * 0.6)}"><circle cx="${f1(x)}" cy="${f1(y)}" r="${f1(6 + e * 6)}" fill="#fee2e2" stroke="#dc2626" stroke-width="1.6"/>${cross(x, y, 4)}</g>`;
4802
+ }
4803
+ return shadow + `<circle cx="${f1(x)}" cy="${f1(y)}" r="5.5" fill="${col}" stroke="${LINE}" stroke-width="1.2"/>`;
4804
+ }
3810
4805
  const BLOCKS_PATH = "/api/v1/chat/blocks";
3811
4806
  const WHITEBOARD_PATH = "/api/v1/chat/whiteboard";
3812
4807
  const BLOCKS_TTL_MS = 6e4;
@@ -3834,43 +4829,60 @@ class WhiteboardStore {
3834
4829
  }
3835
4830
  /** Whether the Blueprint has the whiteboard. False when it cannot be asked. */
3836
4831
  async available() {
4832
+ return (await this.readBlocks()).on;
4833
+ }
4834
+ /** Whether the Blueprint offers a Full lesson beside the whiteboard. */
4835
+ async lessonsAvailable() {
4836
+ return (await this.readBlocks()).lessons;
4837
+ }
4838
+ readBlocks() {
3837
4839
  var _a;
3838
- if (this.blocks && this.clock() - this.blocks.at < BLOCKS_TTL_MS) return this.blocks.on;
3839
- (_a = this.blocksPending) != null ? _a : this.blocksPending = this.api().get(BLOCKS_PATH, 1e4).then((res) => {
3840
- var _a2;
3841
- return ((_a2 = res == null ? void 0 : res.blocks) == null ? void 0 : _a2.whiteboard) === true;
3842
- }, () => false).then((on) => {
3843
- this.blocks = { at: this.clock(), on };
4840
+ if (this.blocks && this.clock() - this.blocks.at < BLOCKS_TTL_MS) return Promise.resolve(this.blocks);
4841
+ (_a = this.blocksPending) != null ? _a : this.blocksPending = this.api().get(BLOCKS_PATH, 1e4).then(
4842
+ (res) => {
4843
+ var _a2, _b, _c;
4844
+ return { on: ((_a2 = res == null ? void 0 : res.blocks) == null ? void 0 : _a2.whiteboard) === true, lessons: ((_b = res == null ? void 0 : res.blocks) == null ? void 0 : _b.whiteboard) === true && ((_c = res == null ? void 0 : res.blocks) == null ? void 0 : _c.lessons) === true };
4845
+ },
4846
+ () => ({ on: false, lessons: false })
4847
+ ).then((read) => {
4848
+ this.blocks = { at: this.clock(), ...read };
3844
4849
  this.blocksPending = null;
3845
- return on;
4850
+ return read;
3846
4851
  });
3847
4852
  return this.blocksPending;
3848
4853
  }
3849
- /** Explain *question* (and the answer on screen) on the board. */
3850
- async explain(question, answer) {
4854
+ /**
4855
+ * Explain *question* (and the answer on screen) on the board. The server
4856
+ * picks a pen board or a 3D one from the Blueprint's style; *lesson* asks
4857
+ * for the Full lesson, a longer 3D lesson that plays by itself.
4858
+ */
4859
+ async explain(question, answer, options = {}) {
4860
+ var _a;
3851
4861
  const q = question.trim().slice(0, 500);
3852
4862
  if (!q) return false;
4863
+ const lesson = options.lesson === true;
3853
4864
  const a = answer ? readableAnswer(answer).slice(0, 4e3) : void 0;
3854
- const key = `${q}\0${a != null ? a : ""}`;
4865
+ const key = `${q}\0${a != null ? a : ""}\0${lesson ? "lesson" : "board"}`;
3855
4866
  const known = this.kept.get(key);
3856
4867
  if (known) {
3857
- this.set({ status: "playing", scene: known, error: null, question: q, answer: a });
4868
+ this.set({ status: "playing", scene: known, error: null, question: q, answer: a, lesson });
3858
4869
  return true;
3859
4870
  }
3860
4871
  const token = ++this.request;
3861
- this.set({ status: "loading", scene: null, error: null, question: q, answer: a });
4872
+ this.set({ status: "loading", scene: null, error: null, question: q, answer: a, lesson });
3862
4873
  try {
3863
4874
  const raw = await this.api().post(
3864
4875
  WHITEBOARD_PATH,
3865
4876
  // pictures: this board shows real photos with labelled parts.
3866
4877
  // motion: it can play motion; the server adds it only when Animate is on.
3867
- { question: q, answer: a || void 0, language: this.language(), pictures: true, motion: true },
3868
- 6e4
4878
+ // iso: it draws 3D boards; the Blueprint's style decides when one is used.
4879
+ { question: q, answer: a || void 0, language: this.language(), pictures: true, motion: true, iso: true, lesson: lesson || void 0 },
4880
+ lesson ? 9e4 : 6e4
3869
4881
  );
3870
4882
  if (token !== this.request) return false;
3871
- const scene = validateScene(raw);
4883
+ const scene = (_a = readIsoPlan(raw)) != null ? _a : validateScene(raw);
3872
4884
  this.keep(key, scene);
3873
- this.set({ status: "playing", scene, error: null, question: q, answer: a });
4885
+ this.set({ status: "playing", scene, error: null, question: q, answer: a, lesson });
3874
4886
  return true;
3875
4887
  } catch (err) {
3876
4888
  if (token !== this.request) return false;
@@ -3879,18 +4891,20 @@ class WhiteboardStore {
3879
4891
  scene: null,
3880
4892
  error: err instanceof SceneError ? "This board could not be drawn." : "The whiteboard is not available right now.",
3881
4893
  question: q,
3882
- answer: a
4894
+ answer: a,
4895
+ lesson
3883
4896
  });
3884
4897
  return false;
3885
4898
  }
3886
4899
  }
3887
4900
  /** Ask again after an error. */
3888
4901
  retry() {
3889
- if (this.state.status === "error") void this.explain(this.state.question, this.state.answer);
4902
+ if (this.state.status === "error") void this.explain(this.state.question, this.state.answer, { lesson: this.state.lesson });
3890
4903
  }
3891
- /** Play a board the host built. A board that cannot be drawn throws SceneError. */
4904
+ /** Play a board the host built (pen or 3D). A board that cannot be drawn throws SceneError. */
3892
4905
  play(scene) {
3893
- const valid = validateScene(scene);
4906
+ var _a;
4907
+ const valid = (_a = readIsoPlan(scene)) != null ? _a : validateScene(scene);
3894
4908
  this.request += 1;
3895
4909
  this.set({ status: "playing", scene: valid, error: null, question: valid.title });
3896
4910
  }
@@ -3937,20 +4951,28 @@ function useWhiteboard() {
3937
4951
  const board = GuideAI.isConfigured() ? whiteboardStore() : IDLE;
3938
4952
  const state = React.useSyncExternalStore(board.subscribe, board.getState, board.getState);
3939
4953
  const [available, setAvailable] = React.useState(false);
4954
+ const [lessons, setLessons] = React.useState(false);
3940
4955
  React.useEffect(() => {
3941
4956
  if (board === IDLE) return;
3942
4957
  let live = true;
3943
4958
  void board.available().then((on) => {
3944
4959
  if (live) setAvailable(on);
3945
4960
  });
4961
+ void board.lessonsAvailable().then((on) => {
4962
+ if (live) setLessons(on);
4963
+ });
3946
4964
  return () => {
3947
4965
  live = false;
3948
4966
  };
3949
4967
  }, [board]);
3950
4968
  return {
3951
4969
  available,
4970
+ lessons,
3952
4971
  state,
3953
- explain: React.useCallback((question, answer) => board.explain(question, answer), [board]),
4972
+ explain: React.useCallback(
4973
+ (question, answer, options) => board.explain(question, answer, options),
4974
+ [board]
4975
+ ),
3954
4976
  play: React.useCallback((scene) => board.play(scene), [board]),
3955
4977
  retry: React.useCallback(() => board.retry(), [board]),
3956
4978
  close: React.useCallback(() => board.close(), [board])
@@ -4205,21 +5227,22 @@ function useGuideAI(options = {}) {
4205
5227
  var _a2;
4206
5228
  if (message.role !== "assistant" || message.streaming || message.error || !message.content) return message;
4207
5229
  const suggestions = (_a2 = message.suggestions) != null ? _a2 : (defaultFollowUps == null ? void 0 : defaultFollowUps.length) ? defaultFollowUps : void 0;
4208
- return { ...message, suggestions, whiteboard: board.available || void 0 };
4209
- }), [messages, defaultFollowUps, board.available]);
5230
+ return { ...message, suggestions, whiteboard: board.available || void 0, lesson: board.available && board.lessons || void 0 };
5231
+ }), [messages, defaultFollowUps, board.available, board.lessons]);
4210
5232
  const last = shown[shown.length - 1];
4211
5233
  const followUps = !busy && (last == null ? void 0 : last.role) === "assistant" && !last.pendingAction ? (_d = last.suggestions) != null ? _d : [] : [];
4212
5234
  const typing = busy && messages.some((message) => message.streaming && !message.content);
4213
- const explainOnWhiteboard = React.useCallback(async (messageId) => {
5235
+ const explainOnWhiteboard = React.useCallback(async (messageId, options2) => {
4214
5236
  const answer = messages.find((message) => message.id === messageId);
4215
5237
  if (!answer || answer.role !== "assistant" || !answer.content) return false;
4216
- return board.explain(answer.question || answer.content.slice(0, 200), answer.content);
5238
+ return board.explain(answer.question || answer.content.slice(0, 200), answer.content, options2);
4217
5239
  }, [messages, board]);
4218
5240
  return {
4219
5241
  messages: shown,
4220
5242
  typing,
4221
5243
  followUps,
4222
5244
  whiteboardAvailable: board.available,
5245
+ lessonsAvailable: board.available && board.lessons,
4223
5246
  explainOnWhiteboard,
4224
5247
  input,
4225
5248
  setInput,
@@ -4285,6 +5308,7 @@ exports.BOARD_H = BOARD_H;
4285
5308
  exports.BOARD_W = BOARD_W;
4286
5309
  exports.EP = EP;
4287
5310
  exports.GuideAI = GuideAI;
5311
+ exports.IsoDrawing = IsoDrawing;
4288
5312
  exports.LIMITS = LIMITS;
4289
5313
  exports.RegistryContext = RegistryContext;
4290
5314
  exports.ScreenRegistry = ScreenRegistry;
@@ -4296,4 +5320,4 @@ exports.useGuideAIRuntime = useGuideAIRuntime;
4296
5320
  exports.useOnboarding = useOnboarding;
4297
5321
  exports.useScreenRegistry = useScreenRegistry;
4298
5322
  exports.useWhiteboard = useWhiteboard;
4299
- //# sourceMappingURL=useConversations-Chn_GKOz.cjs.map
5323
+ //# sourceMappingURL=useConversations-UiwD_WVF.cjs.map