@ai-matrx/records-ui 0.116.97 → 0.116.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,31 @@
1
1
  # Changelog
2
2
 
3
- ## 0.116.97
3
+ ## 0.116.98
4
4
 
5
5
  UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
6
6
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
7
7
 
8
+ ## 0.116.97
9
+
10
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
11
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
12
+ Diff: `git diff 720a66aba9 bbcbc0da70 -- apps/shared/records-ui/src`
13
+
14
+ Changed shipped source files (21):
15
+ - `apps/shared/records-ui/src/BlockGrid.tsx`
16
+ - `apps/shared/records-ui/src/CalendarView.tsx`
17
+ - `apps/shared/records-ui/src/ChartBlock.tsx`
18
+ - `apps/shared/records-ui/src/ChartLayout.tsx`
19
+ - `apps/shared/records-ui/src/FormExtrasEditor.tsx`
20
+ - `apps/shared/records-ui/src/OrgChartLayout.tsx`
21
+ - `apps/shared/records-ui/src/PageCanvas.tsx`
22
+ - `apps/shared/records-ui/src/PivotLayout.tsx`
23
+ - `apps/shared/records-ui/src/Refusal.tsx`
24
+ - `apps/shared/records-ui/src/SectionCard.tsx`
25
+ - `apps/shared/records-ui/src/TimelineView.tsx`
26
+ - `apps/shared/records-ui/src/bare-refusals.ts`
27
+ - ...and 9 more
28
+
8
29
  ## 0.116.96
9
30
 
10
31
  SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
@@ -1,13 +1,12 @@
1
1
  "use client";
2
- "use client";
3
2
  import {
4
3
  SAVE_TO_TABLE_TYPES,
5
4
  SaveToTable,
6
5
  shapesOfSource
7
- } from "./chunk-PO7UMIDY.js";
8
- import "./chunk-ESNTHDQO.js";
6
+ } from "./chunk-HU3X5SRA.js";
7
+ import "./chunk-SB5UVLQK.js";
9
8
  import "./chunk-TABDUUEC.js";
10
- import "./chunk-6Z537SLG.js";
9
+ import "./chunk-YHPVSUK6.js";
11
10
  import "./chunk-LBZZDHV6.js";
12
11
  import "./chunk-K7OX6RG6.js";
13
12
  import "./chunk-WCQSJPLS.js";
@@ -17,4 +16,4 @@ export {
17
16
  SaveToTable,
18
17
  shapesOfSource
19
18
  };
20
- //# sourceMappingURL=SaveToTable-GYVIFMJC.js.map
19
+ //# sourceMappingURL=SaveToTable-637RHDAP.js.map
@@ -71,7 +71,7 @@ import {
71
71
  kindValueOf,
72
72
  kindValueWords,
73
73
  shapeOfValue
74
- } from "./chunk-6Z537SLG.js";
74
+ } from "./chunk-YHPVSUK6.js";
75
75
  import {
76
76
  carriesTimeOfDay,
77
77
  choiceChipLookOf,
@@ -4649,7 +4649,7 @@ import { OutboundLink as OutboundLink5 } from "@ai-matrx/kit/outbound-react";
4649
4649
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
4650
4650
  import { momentZoneOptions } from "@ai-matrx/design-system/field-formats";
4651
4651
  import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
4652
- var SaveToTable = lazy(() => import("./SaveToTable-GYVIFMJC.js").then((m) => ({ default: m.SaveToTable })));
4652
+ var SaveToTable = lazy(() => import("./SaveToTable-637RHDAP.js").then((m) => ({ default: m.SaveToTable })));
4653
4653
  var LONGEST_READ = 5e5;
4654
4654
  var FENCE = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n?```$/;
4655
4655
  function isPlainObject(v) {
@@ -14320,4 +14320,4 @@ export {
14320
14320
  RecordNameText,
14321
14321
  HeldChangeDecision
14322
14322
  };
14323
- //# sourceMappingURL=chunk-IEVLSGJZ.js.map
14323
+ //# sourceMappingURL=chunk-CPFQVQIK.js.map
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  toDropdownEntries
4
- } from "./chunk-ESNTHDQO.js";
4
+ } from "./chunk-SB5UVLQK.js";
5
5
  import {
6
6
  BOOKING_PAGE_STATE_LABEL,
7
7
  FilePicker,
@@ -34,7 +34,7 @@ import {
34
34
  shapeOfGrid,
35
35
  shapeOfValue,
36
36
  uniqueLabels
37
- } from "./chunk-6Z537SLG.js";
37
+ } from "./chunk-YHPVSUK6.js";
38
38
  import {
39
39
  calendarDayOf,
40
40
  editorKindFor,
@@ -5205,4 +5205,4 @@ export {
5205
5205
  shapesOfSource,
5206
5206
  SaveToTable
5207
5207
  };
5208
- //# sourceMappingURL=chunk-PO7UMIDY.js.map
5208
+ //# sourceMappingURL=chunk-HU3X5SRA.js.map
@@ -245,4 +245,4 @@ export {
245
245
  STRIP_FEATURE_ROWS,
246
246
  toStripAndRows
247
247
  };
248
- //# sourceMappingURL=chunk-ESNTHDQO.js.map
248
+ //# sourceMappingURL=chunk-SB5UVLQK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/objectActions.ts"],"sourcesContent":["\"use client\";\n\n// src/objectActions.ts — @ai-matrx/records-ui\n//\n// THE ONE ACTION LIST FOR A RECORD-STORE TABLE (lane TABLE-ACTIONS, v6 lane 1).\n//\n// Every menu a person meets on a table — the header ⋯, a row ⋯ on the Data\n// home, right-click, a card, the phone sheet, later ⌘K — is drawn from the\n// array `tableActions()` returns. Before this there were three hand-made lists\n// (`TABLE_MENU` in TablePage, `dataHomeRowActions` in matrx-frontend, the\n// Sheet's own v3 sections) and they drifted: no Archive, no Copy link, no\n// Duplicate, Rename and Share only as hand JSX beside the list.\n//\n// THE SHAPE IS COPIED, NOT INVENTED. It is the in-house registry pattern of\n// `features/agents/browse/agentActionRegistry.tsx` and `conversationActionRegistry.tsx`\n// in matrx-frontend: a context of HOST HANDLERS in, one ordered list out, every\n// renderer reading the same list. The one difference is deliberate: those two\n// build matrx-frontend's `ItemMenuConfig` directly, which this package cannot\n// import, so the list here is renderer-neutral (`ObjectAction[]`) and each\n// renderer has a pure adapter (`toDropdownEntries` / `toStripAndRows` here;\n// `toItemMenuConfig` and `toExtraSections` in matrx-frontend\n// `features/unified-data/actions/`).\n//\n// TWO INVARIANTS, each with a guard (`one-table-action-list-*.test.tsx`,\n// `rights-never-change-the-table-menus-shape.test.tsx`):\n// G1 — every renderer draws the same ids — none hidden, none added, disabled ones\n// drawn disabled with their reason — for every seat and with handlers missing.\n// G2 — rights change only `disabledReason`, never which ids appear, their order,\n// their verb or their rank (Airtable hides items from members; we beat it).\n// A missing host handler is the same: the action stays, disabled, with its reason.\n//\n// THE ORDER (handoff §4, the same everywhere):\n// Open · Open in new tab · Copy link | Rename · Duplicate · Move to… · Favorite |\n// Share… · Export… · Import… | Add column · Settings · History · Make … the default |\n// Built on it ▸ (Forms, Bookings, Checklists, Notifications, Portals, Inbox,\n// Dashboards, Archived records) | Archive table (last, destructive).\n// \"Add column\" and \"Make … the default\" are the header ⋯'s own entries before the\n// registry (TABLE_MENU and the designate item); they sit with Settings.\n//\n// VERB AND RANK — for the icon-strip menu. An action with a `verb` is one of the\n// platform's standard verbs (a strip icon); every other action has a `rank`, its\n// place among the feature rows. Neither changes the list's order: `toStripAndRows`\n// is a renderer that splits the same list, and G1 holds it to the same ids.\n//\n// No JSX here: this file is the `./object-actions` subpath, light enough for a\n// list row's menu to import without pulling every screen of the package.\n\nimport type { Table } from \"@ai-matrx/records\";\nimport { formatTapShortcut } from \"@ai-matrx/design-system/tap-target\";\nimport { ADD_FIELD_OPEN_LABEL } from \"./fieldTypes\";\nimport { LEVEL_WORD, levelNeededFor, type Capability, type WhatYouMayDo } from \"./rights\";\n\n/**\n * A Lucide icon NAME, kebab-case — the same currency `Table.icon` already uses.\n * Closed on purpose: each renderer maps every member to its own glyph, and a\n * new member fails that renderer's typecheck until it is mapped.\n */\nexport type ObjectActionIcon =\n | \"folder-open\"\n | \"external-link\"\n | \"link\"\n | \"pencil\"\n | \"copy\"\n | \"folder-input\"\n | \"star\"\n | \"star-off\"\n | \"share-2\"\n | \"download\"\n | \"upload\"\n | \"columns-3\"\n | \"settings\"\n | \"history\"\n | \"blocks\"\n | \"file-text\"\n | \"calendar-clock\"\n | \"list-checks\"\n | \"bell\"\n | \"door-open\"\n | \"inbox\"\n | \"layout-dashboard\"\n | \"archive-restore\"\n | \"archive\"\n | \"link-2\"\n | \"layout-grid\"\n | \"git-merge\"\n | \"split\"\n | \"arrow-up-from-line\"\n | \"corner-down-right\"\n | \"lock\"\n | \"lock-open\"\n | \"eraser\"\n | \"printer\";\n\n/** The groups, in their one order. Separators fall out of group boundaries. */\nexport type ObjectActionGroup = \"open\" | \"organize\" | \"share\" | \"manage\" | \"built-on\" | \"danger\";\n\n/**\n * THE STANDARD VERBS every object's menu shares — what the icon strip draws. One\n * per meaning; an object maps its action onto the verb, never a second \"share\".\n */\nexport type StandardVerbId =\n | \"open\"\n | \"open-new-tab\"\n | \"copy-link\"\n | \"rename\"\n | \"duplicate\"\n | \"move\"\n | \"favorite\"\n | \"share\"\n | \"export\"\n | \"import\"\n | \"settings\"\n | \"history\"\n | \"archive\";\n\nexport const STANDARD_VERBS: readonly StandardVerbId[] = [\n \"open\",\n \"open-new-tab\",\n \"copy-link\",\n \"rename\",\n \"duplicate\",\n \"move\",\n \"favorite\",\n \"share\",\n \"export\",\n \"import\",\n \"settings\",\n \"history\",\n \"archive\",\n];\n\nexport interface ObjectActionGroupDef {\n id: ObjectActionGroup;\n /** Present only on a group that renders as a submenu. */\n label?: string;\n icon?: ObjectActionIcon;\n /** Rendered as ONE submenu entry holding the group's actions. */\n submenu: boolean;\n}\n\nexport const OBJECT_ACTION_GROUPS: readonly ObjectActionGroupDef[] = [\n { id: \"open\", submenu: false },\n { id: \"organize\", submenu: false },\n { id: \"share\", submenu: false },\n { id: \"manage\", submenu: false },\n { id: \"built-on\", label: \"Built on it\", icon: \"blocks\", submenu: true },\n { id: \"danger\", submenu: false },\n];\n\nconst GROUP_IDS = new Set<string>(OBJECT_ACTION_GROUPS.map((g) => g.id));\n\n/** One thing a person can do to an object, for any renderer. */\nexport interface ObjectAction {\n /** Stable within the object's list. React key, test handle, future ⌘K id. */\n id: string;\n label: string;\n icon: ObjectActionIcon;\n group: ObjectActionGroup;\n /** The standard verb this action IS (a strip icon). Absent = a feature row. */\n verb?: StandardVerbId;\n /** A feature row's place among the rows, 1 first. Ignored when `verb` is set. */\n rank?: number;\n /** Display-only hint (\"⌘D\"). */\n shortcut?: string;\n destructive?: boolean;\n /** Present = shown disabled with this line (≤ 60 chars). Absent = enabled. */\n disabledReason?: string;\n /** Called only when enabled. The host owns the side effect and its feedback. */\n run: () => void | Promise<void>;\n}\n\n/** What the list needs to know about the table. A full `Table` satisfies it. */\nexport type TableActionSubject = Pick<Table, \"id\" | \"name\"> & Partial<Pick<Table, \"is_kernel\">>;\n\n/** The places built on a table, in their one order. */\nexport type BuiltOnDestination =\n | \"forms\"\n | \"bookings\"\n | \"checklists\"\n | \"notifications\"\n | \"portals\"\n | \"inbox\"\n | \"dashboards\"\n | \"archived\";\n\ntype Handler = (table: TableActionSubject) => void | Promise<void>;\n\n/**\n * THE SIDE EFFECTS THIS PACKAGE CANNOT OWN. Every handler is optional: one the\n * host leaves out keeps its action in the list, disabled, saying so.\n */\nexport interface TableActionHost {\n /** Origin for Copy link and Open in new tab. Default `https://www.aimatrx.com`. */\n origin?: string;\n open?: Handler;\n /** Receives the table's link (`<origin>/data/<id>`). */\n openInNewTab?: (url: string, table: TableActionSubject) => void;\n /** Receives the table's link. Runs inside the click (clipboard needs the gesture). */\n copyText?: (text: string, table: TableActionSubject) => void | Promise<void>;\n rename?: Handler;\n duplicate?: Handler;\n move?: Handler;\n /** Current favorite state; flips the Favorite label. Unknown = \"Add to favorites\". */\n isFavorite?: boolean;\n toggleFavorite?: Handler;\n share?: Handler;\n export?: Handler;\n import?: Handler;\n addColumn?: Handler;\n settings?: Handler;\n history?: Handler;\n /** Make the layout on screen the table's default. Leave out when it already is. */\n makeDefault?: Handler;\n /** The layout on screen, for \"Make Kanban the default\". */\n layoutLabel?: string;\n /** The \"Built on it\" destinations, one handler for all eight. */\n openBuiltOn?: (destination: BuiltOnDestination, table: TableActionSubject) => void;\n archive?: Handler;\n /**\n * Why an action whose handler is left out is unavailable here, by action id\n * (≤ 60 chars) — e.g. `make-default: \"Already the default\"`. Unnamed ids say\n * \"Not available here\". Never used when rights already refuse.\n */\n unavailableReasons?: Readonly<Record<string, string>>;\n /**\n * ANOTHER LANE'S ENTRIES (\"Link a record…\", a hub tile's verbs, a feature's own\n * row such as \"When a row changes, run an agent…\"). Return the same ids whatever\n * `rights` say — express rights as `disabledReason`. Each entry lands at the END\n * of its named group, in the order returned. Refused, loudly: the `danger` group\n * (Archive is always last), a group that does not exist, and an id already in\n * the list.\n */\n extend?: (table: TableActionSubject, rights: WhatYouMayDo) => readonly ObjectAction[];\n}\n\nexport interface TableActionsInput {\n table: TableActionSubject;\n rights: WhatYouMayDo;\n host: TableActionHost;\n}\n\nexport const DEFAULT_ACTION_ORIGIN = \"https://www.aimatrx.com\";\n\n/** The one link to a table: `<origin>/data/<tableId>`. */\nexport function tableLink(tableId: string, origin: string = DEFAULT_ACTION_ORIGIN): string {\n return `${origin.replace(/\\/+$/, \"\")}/data/${encodeURIComponent(tableId)}`;\n}\n\n/** The designate entry's words, matching `makeDefaultLabel` in views.ts. */\nfunction makeDefaultWords(layoutLabel: string | undefined): string {\n return layoutLabel ? `Make ${layoutLabel} the default` : \"Make this the default\";\n}\n\n// Reasons — one line, ≤ 60 characters, said on the action itself.\nexport const ACTION_NOT_HERE_REASON = \"Not available here\";\nexport const ACTION_CHECKING_ACCESS_REASON = \"Checking your access…\";\nexport const ACTION_NO_ACCESS_REASON = \"You don't have access\";\nexport const ACTION_PLATFORM_TABLE_REASON = \"Platform tables can't be changed here\";\n\n/** Why `rights` refuse `what`, in one short line — or null when they allow it. */\nexport function rightsReason(\n rights: WhatYouMayDo,\n what: Capability,\n table?: TableActionSubject,\n): string | null {\n if (!rights.known) return ACTION_CHECKING_ACCESS_REASON;\n if (what === \"structure\" && table?.is_kernel) return ACTION_PLATFORM_TABLE_REASON;\n if (rights[what]) return null;\n if (rights.level === null) return ACTION_NO_ACCESS_REASON;\n return `Needs ${LEVEL_WORD[levelNeededFor(what)]}`;\n}\n\n// Feature rows' ranks: what the strip menu shows as its first rows. Lower is first.\nconst BUILT_ON: ReadonlyArray<{ destination: BuiltOnDestination; label: string; icon: ObjectActionIcon; rank: number }> = [\n { destination: \"forms\", label: \"Forms\", icon: \"file-text\", rank: 2 },\n { destination: \"bookings\", label: \"Bookings\", icon: \"calendar-clock\", rank: 6 },\n { destination: \"checklists\", label: \"Checklists\", icon: \"list-checks\", rank: 7 },\n { destination: \"notifications\", label: \"Notifications\", icon: \"bell\", rank: 8 },\n { destination: \"portals\", label: \"Portals\", icon: \"door-open\", rank: 9 },\n { destination: \"inbox\", label: \"Inbox\", icon: \"inbox\", rank: 10 },\n { destination: \"dashboards\", label: \"Dashboards\", icon: \"layout-dashboard\", rank: 3 },\n { destination: \"archived\", label: \"Archived records\", icon: \"archive-restore\", rank: 5 },\n];\n\nconst NOOP = () => {};\n\n/**\n * THE TABLE'S KEYBOARD CHORDS (lane TABLE-ACTIONS wave 4, item 17): ⌥⇧ + one key, the same on\n * every surface that runs the list. Chosen because nothing else owns them: ⌘D is the browser's\n * bookmark, ⌘S save, ⌘P print, ⌘K the command bar, ⌘⇧K the menu's palette, ⌘Z undo — and the\n * app binds no ⌥⇧ chord. A chord is never taken while the person types in a field\n * (`objectActionForKey`). `code` is the KeyboardEvent.code, so ⌥ on a Mac (which changes\n * `key` to a symbol) still matches.\n */\nexport const TABLE_ACTION_CHORDS: Readonly<Record<string, { code: string; chord: string }>> = {\n \"copy-link\": { code: \"KeyL\", chord: \"alt+shift+l\" },\n rename: { code: \"KeyR\", chord: \"alt+shift+r\" },\n duplicate: { code: \"KeyD\", chord: \"alt+shift+d\" },\n move: { code: \"KeyM\", chord: \"alt+shift+m\" },\n favorite: { code: \"KeyF\", chord: \"alt+shift+f\" },\n share: { code: \"KeyS\", chord: \"alt+shift+s\" },\n export: { code: \"KeyE\", chord: \"alt+shift+e\" },\n import: { code: \"KeyI\", chord: \"alt+shift+i\" },\n settings: { code: \"Comma\", chord: \"alt+shift+,\" },\n history: { code: \"KeyH\", chord: \"alt+shift+h\" },\n archive: { code: \"Backspace\", chord: \"alt+shift+backspace\" },\n};\n\n/**\n * The chords with their LABEL in this platform's words — \"⌥⇧S\" on a Mac, \"Alt+Shift+S\" on Windows\n * and Linux — through the design system's one shortcut formatter (`formatTapShortcut`, the tap\n * button's tooltip), so a menu entry and the ⌘K bar read alike everywhere.\n */\nexport const TABLE_ACTION_KEYS: Readonly<Record<string, { code: string; label: string }>> = Object.fromEntries(\n Object.entries(TABLE_ACTION_CHORDS).map(([id, { code, chord }]) => [id, { code, label: formatTapShortcut(chord) }]),\n);\n\n/** The fields of a keyboard event a chord reads (a DOM KeyboardEvent satisfies it). */\nexport interface ChordEvent {\n code: string;\n altKey: boolean;\n shiftKey: boolean;\n metaKey: boolean;\n ctrlKey: boolean;\n target?: EventTarget | null;\n}\n\nfunction typingIn(target: EventTarget | null | undefined): boolean {\n const el = target as { tagName?: string; isContentEditable?: boolean } | null | undefined;\n if (!el || typeof el.tagName !== \"string\") return false;\n return el.isContentEditable === true || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName);\n}\n\n/**\n * The action a key press asks for, or null: ⌥⇧ + its key, no ⌘/Ctrl, never inside a field. A\n * disabled action is still RETURNED (the caller says its reason instead of doing nothing).\n */\nexport function objectActionForKey(actions: readonly ObjectAction[], event: ChordEvent): ObjectAction | null {\n if (!event.altKey || !event.shiftKey || event.metaKey || event.ctrlKey) return null;\n if (typingIn(event.target)) return null;\n const id = Object.keys(TABLE_ACTION_KEYS).find((k) => TABLE_ACTION_KEYS[k]!.code === event.code);\n return id ? (actions.find((a) => a.id === id) ?? null) : null;\n}\n\n/**\n * One action, from its needs: the capability it asks for and the host handler\n * that performs it. Rights speak first; a missing handler second.\n */\nfunction action(\n base: Omit<ObjectAction, \"run\" | \"disabledReason\">,\n needs: Capability,\n input: TableActionsInput,\n perform: (() => void | Promise<void>) | undefined,\n): ObjectAction {\n const chord = TABLE_ACTION_KEYS[base.id];\n if (chord && base.shortcut === undefined) base = { ...base, shortcut: chord.label };\n const refused = rightsReason(input.rights, needs, input.table);\n if (refused !== null) return { ...base, disabledReason: refused, run: NOOP };\n if (perform === undefined) {\n return { ...base, disabledReason: input.host.unavailableReasons?.[base.id] ?? ACTION_NOT_HERE_REASON, run: NOOP };\n }\n return { ...base, run: perform };\n}\n\nfunction bind(handler: Handler | undefined, table: TableActionSubject): (() => void | Promise<void>) | undefined {\n return handler ? () => handler(table) : undefined;\n}\n\n/**\n * THE TABLE'S ACTIONS, in the one order. Same ids, same order, same verbs and\n * ranks, for every seat and every host — only `disabledReason` varies.\n */\nexport function tableActions(input: TableActionsInput): ObjectAction[] {\n const { table, host } = input;\n const url = tableLink(table.id, host.origin);\n const favorite = host.isFavorite === true;\n const openInNewTab = host.openInNewTab;\n const copyText = host.copyText;\n const openBuiltOn = host.openBuiltOn;\n\n const built: ObjectAction[] = [\n action({ id: \"open\", label: \"Open\", icon: \"folder-open\", group: \"open\", verb: \"open\" }, \"read\", input, bind(host.open, table)),\n action(\n { id: \"open-new-tab\", label: \"Open in new tab\", icon: \"external-link\", group: \"open\", verb: \"open-new-tab\" },\n \"read\",\n input,\n openInNewTab ? () => openInNewTab(url, table) : undefined,\n ),\n action(\n { id: \"copy-link\", label: \"Copy link\", icon: \"link\", group: \"open\", verb: \"copy-link\" },\n \"read\",\n input,\n copyText ? () => copyText(url, table) : undefined,\n ),\n action({ id: \"rename\", label: \"Rename…\", icon: \"pencil\", group: \"organize\", verb: \"rename\" }, \"structure\", input, bind(host.rename, table)),\n action({ id: \"duplicate\", label: \"Duplicate\", icon: \"copy\", group: \"organize\", verb: \"duplicate\" }, \"read\", input, bind(host.duplicate, table)),\n action({ id: \"move\", label: \"Move to…\", icon: \"folder-input\", group: \"organize\", verb: \"move\" }, \"structure\", input, bind(host.move, table)),\n action(\n {\n id: \"favorite\",\n label: favorite ? \"Remove from favorites\" : \"Add to favorites\",\n icon: favorite ? \"star-off\" : \"star\",\n group: \"organize\",\n verb: \"favorite\",\n },\n \"read\",\n input,\n bind(host.toggleFavorite, table),\n ),\n action({ id: \"share\", label: \"Share…\", icon: \"share-2\", group: \"share\", verb: \"share\" }, \"share\", input, bind(host.share, table)),\n action({ id: \"export\", label: \"Export…\", icon: \"download\", group: \"share\", verb: \"export\" }, \"read\", input, bind(host.export, table)),\n action({ id: \"import\", label: \"Import…\", icon: \"upload\", group: \"share\", verb: \"import\" }, \"structure\", input, bind(host.import, table)),\n action({ id: \"add-column\", label: ADD_FIELD_OPEN_LABEL, icon: \"columns-3\", group: \"manage\", rank: 1 }, \"structure\", input, bind(host.addColumn, table)),\n action({ id: \"settings\", label: \"Settings\", icon: \"settings\", group: \"manage\", verb: \"settings\" }, \"structure\", input, bind(host.settings, table)),\n action({ id: \"history\", label: \"History\", icon: \"history\", group: \"manage\", verb: \"history\" }, \"read\", input, bind(host.history, table)),\n // custom.view_designate asks editor on the table — `canDesignate` in TablePage.\n action(\n { id: \"make-default\", label: makeDefaultWords(host.layoutLabel), icon: \"layout-grid\", group: \"manage\", rank: 4 },\n \"organise\",\n input,\n bind(host.makeDefault, table),\n ),\n ...BUILT_ON.map(({ destination, label, icon, rank }) =>\n action(\n { id: `built-on.${destination}`, label, icon, group: \"built-on\", rank },\n \"read\",\n input,\n openBuiltOn ? () => openBuiltOn(destination, table) : undefined,\n ),\n ),\n action(\n { id: \"archive\", label: \"Archive table\", icon: \"archive\", group: \"danger\", destructive: true, verb: \"archive\" },\n \"structure\",\n input,\n bind(host.archive, table),\n ),\n ];\n\n return withExtensions(built, host.extend ? host.extend(table, input.rights) : []);\n}\n\n/**\n * Another lane's entries, placed deterministically: each at the end of its\n * group, in the order given. Loud on every mistake that would break the\n * invariants — a `danger` entry (Archive must stay last), a group that does not\n * exist (it would be dropped by every renderer) and a duplicate id.\n */\nexport function withExtensions(base: readonly ObjectAction[], extra: readonly ObjectAction[]): ObjectAction[] {\n if (extra.length === 0) return [...base];\n const seen = new Set(base.map((a) => a.id));\n for (const entry of extra) {\n if (entry.group === \"danger\") {\n throw new Error(`Object action \"${entry.id}\": the danger group is closed to extensions.`);\n }\n if (!GROUP_IDS.has(entry.group)) {\n throw new Error(`Object action \"${entry.id}\": \"${String(entry.group)}\" is not a group.`);\n }\n if (seen.has(entry.id)) {\n throw new Error(`Object action \"${entry.id}\" is already in the list.`);\n }\n seen.add(entry.id);\n }\n const out: ObjectAction[] = [];\n for (const group of OBJECT_ACTION_GROUPS) {\n out.push(...base.filter((a) => a.group === group.id), ...extra.filter((a) => a.group === group.id));\n }\n return out;\n}\n\n/** A run of actions that renders together: a plain section, or one submenu. */\nexport interface ObjectActionSection {\n group: ObjectActionGroupDef;\n actions: ObjectAction[];\n}\n\n/**\n * THE ONE GROUPING every adapter uses: the list cut at group boundaries, in\n * group order, empty groups dropped, the order inside a group kept.\n */\nexport function groupObjectActions(actions: readonly ObjectAction[]): ObjectActionSection[] {\n const sections: ObjectActionSection[] = [];\n for (const group of OBJECT_ACTION_GROUPS) {\n const inGroup = actions.filter((a) => a.group === group.id);\n if (inGroup.length > 0) sections.push({ group, actions: inGroup });\n }\n return sections;\n}\n\n/** The header ⋯ dropdown's entries — records-ui's own renderer reads these. */\nexport type ObjectActionDropdownEntry =\n | { kind: \"separator\"; id: string }\n | { kind: \"item\"; action: ObjectAction }\n | { kind: \"submenu\"; id: string; label: string; icon: ObjectActionIcon | undefined; actions: ObjectAction[] };\n\nexport function toDropdownEntries(actions: readonly ObjectAction[]): ObjectActionDropdownEntry[] {\n const entries: ObjectActionDropdownEntry[] = [];\n groupObjectActions(actions).forEach(({ group, actions: inGroup }, index) => {\n if (index > 0) entries.push({ kind: \"separator\", id: `separator:${group.id}` });\n if (group.submenu) {\n entries.push({ kind: \"submenu\", id: group.id, label: group.label ?? group.id, icon: group.icon, actions: inGroup });\n } else {\n for (const a of inGroup) entries.push({ kind: \"item\", action: a });\n }\n });\n return entries;\n}\n\n/** The actions a dropdown draws, in order — what G1 compares. */\nexport function dropdownActions(entries: readonly ObjectActionDropdownEntry[]): ObjectAction[] {\n return entries.flatMap((e) => (e.kind === \"item\" ? [e.action] : e.kind === \"submenu\" ? e.actions : []));\n}\n\n/** The action ids a dropdown draws, in order. */\nexport function dropdownActionIds(entries: readonly ObjectActionDropdownEntry[]): string[] {\n return dropdownActions(entries).map((a) => a.id);\n}\n\n/** The icon-strip menu: standard verbs as icons, then the first feature rows, then the rest. */\nexport interface StripAndRows {\n /** Every action with a `verb`, in the list's order. */\n strip: ObjectAction[];\n /** The first `rowCount` feature actions by rank (ties keep list order). */\n rows: ObjectAction[];\n /** The remaining feature actions, behind \"More … options\", same ordering. */\n more: ObjectAction[];\n}\n\nexport const STRIP_FEATURE_ROWS = 4;\n\n/**\n * THE STRIP RENDERER'S SPLIT of the same list. Nothing is added or dropped: every\n * id lands in exactly one of strip / rows / more (G1). Unranked feature actions\n * (an extension that gave none) follow every ranked one.\n */\nexport function toStripAndRows(actions: readonly ObjectAction[], rowCount: number = STRIP_FEATURE_ROWS): StripAndRows {\n const strip = actions.filter((a) => a.verb !== undefined);\n const features = actions\n .map((a, index) => ({ a, index }))\n .filter(({ a }) => a.verb === undefined)\n .sort((x, y) => (x.a.rank ?? Infinity) - (y.a.rank ?? Infinity) || x.index - y.index)\n .map(({ a }) => a);\n return { strip, rows: features.slice(0, rowCount), more: features.slice(rowCount) };\n}\n"],"mappings":";;;;;;;;;;AAgDA,SAAS,yBAAyB;AAmE3B,IAAM,iBAA4C;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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eTextOfNode
592
592
  };
593
- //# sourceMappingURL=chunk-6Z537SLG.js.map
593
+ //# sourceMappingURL=chunk-YHPVSUK6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tableShape.ts","../src/kindValues.ts"],"sourcesContent":["\"use client\";\n\n// src/tableShape.ts — @ai-matrx/records-ui · lane SAVE-AS-TABLE-EVERYWHERE\n//\n// WHAT IN THIS TEXT IS ALREADY A TABLE. Arman, 2026-09-29: anywhere information appears in a shape\n// the system understands — a markdown table, a list or even a few bullet points, key:value lines,\n// a CSV or TSV paste, a kind value, JSON rows — the SAME \"Save to a table\" must exist. This module\n// is the one reader of those shapes: every menu asks it whether to offer the action, and the one\n// screen (`SaveToTable`) asks it for the rows. It is pure (no React, no store) so a guard, a server\n// render and a menu predicate read the same answer.\n//\n// IT IS A PARSE, NOT AN IMPORTER. It turns words into headers and rows and says what it read, in a\n// sentence. What a column IS in a table that already exists is the store's (`custom.io_import_plan`);\n// `guessColumn` only proposes the types of a NEW table's columns, and the person changes any of it\n// before anything is made.\n\nimport { codeSpanText, findTableEnd, mapInlineCodeSpans, rowCells, tableStartsAt } from \"@ai-matrx/content-ir/source\";\nimport { kindValueOf } from \"./kindValues\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\nimport { parseDelimited as readDelimited } from \"@ai-matrx/kit/delimited\";\n\n/** What kind of thing the rows were read from. */\nexport type TableShapeKind = \"table\" | \"csv\" | \"tsv\" | \"list\" | \"key_value\" | \"kind\" | \"rows\";\n\n/** Another honest way to read a list: every item split at the same delimiter. */\nexport interface TableShapeSplit {\n /** The delimiter, exactly as it sits in the items. */\n delimiter: string;\n /** The choice in words (\"Split at the dash\"). */\n label: string;\n headers: string[];\n rows: Array<Record<string, string>>;\n}\n\nexport interface TableShape {\n kind: TableShapeKind;\n /** Column labels, unique and never blank, in the order the text has them. */\n headers: string[];\n /** Every row, keyed by label. A cell the text left empty is \"\". */\n rows: Array<Record<string, string>>;\n /** One sentence a person reads: what was found and how big it is. */\n said: string;\n /** A name the text itself suggests (the heading above it), or null. */\n name: string | null;\n /** For a list: the other readings on offer. Empty for everything else. */\n splits: TableShapeSplit[];\n /** Where the shape sits in the text, as character offsets (a kind value / JSON value has none). */\n at: { start: number; end: number } | null;\n}\n\n/** The fewest items a plain list needs before it reads as rows (\"even a few bullet points\"). */\nexport const FEWEST_LIST_ITEMS = 2;\n/** The fewest `Key: value` lines that read as one record. */\nexport const FEWEST_KEY_VALUE_PAIRS = 2;\n/** Past this many characters a text is not read at all — a paste that big is a file, and the file import reads files. */\nexport const LONGEST_TEXT_READ = 2_000_000;\n\n// ── cells ──────────────────────────────────────────────────────────────────\n\n/** A markdown cell as the words it shows: emphasis, code ticks and link syntax removed (code spans by THE rule, `findInlineCodeSpans`). */\nexport function cellWords(raw: string): string {\n return mapInlineCodeSpans(raw, (_range, span) => codeSpanText(span))\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/!\\[([^\\]]*)\\]\\([^)]*\\)/g, \"$1\")\n .replace(/\\[([^\\]]+)\\]\\(([^)]*)\\)/g, \"$1\")\n .replace(/\\*\\*([^*]+)\\*\\*/g, \"$1\")\n .replace(/__([^_]+)__/g, \"$1\")\n .replace(/(^|[^\\w*])\\*([^*\\n]+)\\*(?=[^\\w*]|$)/g, \"$1$2\")\n .replace(/(^|[^\\w_])_([^_\\n]+)_(?=[^\\w_]|$)/g, \"$1$2\")\n .replace(/~~([^~]+)~~/g, \"$1\")\n .replace(/\\\\\\|/g, \"|\")\n .trim();\n}\n\n/** Labels made unique and never blank: a second \"Name\" is \"Name 2\", a blank is \"Column 3\". */\nexport function uniqueLabels(raw: readonly string[]): string[] {\n const seen = new Map<string, number>();\n return raw.map((label, index) => {\n const base = label.trim() || `Column ${index + 1}`;\n const key = base.toLowerCase();\n const count = (seen.get(key) ?? 0) + 1;\n seen.set(key, count);\n return count === 1 ? base : `${base} ${count}`;\n });\n}\n\nfunction rowsOf(headers: string[], matrix: string[][]): Array<Record<string, string>> {\n return matrix\n .filter((cells) => cells.some((c) => c.trim() !== \"\"))\n .map((cells) => {\n const row: Record<string, string> = {};\n headers.forEach((h, i) => {\n row[h] = (cells[i] ?? \"\").trim();\n });\n return row;\n });\n}\n\nfunction plural(n: number, one: string, many: string): string {\n return `${n} ${n === 1 ? one : many}`;\n}\n\nfunction sizeWords(rows: number, columns: number): string {\n return `${plural(rows, \"row\", \"rows\")} and ${plural(columns, \"column\", \"columns\")}`;\n}\n\n// ── the name the text suggests ─────────────────────────────────────────────\n\nconst HEADING = /^\\s{0,3}#{1,6}\\s+(.+?)\\s*#*\\s*$/;\nconst BOLD_LINE = /^\\s*\\*\\*([^*]+)\\*\\*:?\\s*$/;\nconst LEAD_IN = /^\\s*([^|\\-*+#>`].{1,80}?):\\s*$/;\n\n/**\n * The name the text gives what follows: the line right above it when that is a heading, a bold\n * line or a lead-in ending in a colon (\"Exercises:\"), else the nearest heading within a few lines.\n */\nfunction nameAbove(lines: string[], lineIndex: number): string | null {\n let looked = 0;\n for (let i = lineIndex - 1; i >= 0 && looked < 4; i -= 1) {\n const line = lines[i] ?? \"\";\n if (line.trim() === \"\") continue;\n looked += 1;\n const m = HEADING.exec(line) ?? (looked === 1 ? (BOLD_LINE.exec(line) ?? LEAD_IN.exec(line)) : null);\n if (m) return cellWords(m[1]!).replace(/:$/, \"\").trim() || null;\n }\n return null;\n}\n\n// ── markdown tables ────────────────────────────────────────────────────────\n\n/** A table row's cells, read by THE GFM rule (`@ai-matrx/content-ir/source`) and reduced to words. */\nfunction splitPipes(line: string): string[] {\n return rowCells(line).map(cellWords);\n}\n\n// ── lists and key:value lines ──────────────────────────────────────────────\n\nconst LIST_ITEM = /^(\\s*)(?:[-*+•]|\\d{1,3}[.)])\\s+(?:\\[[ xX]\\]\\s+)?(.*)$/;\n/** `Key: value` — the key short, the kind of words a column is named with. */\nconst KEY_VALUE = /^\\s*(?:\\*\\*|__)?([^:*_|]{1,40}?)(?::(?:\\*\\*|__)|(?:\\*\\*|__):|:)\\s+(.+)$/;\n\ninterface ListItem {\n depth: number;\n text: string;\n children: string[];\n}\n\nfunction keyValueOf(text: string): { key: string; value: string } | null {\n const m = KEY_VALUE.exec(text);\n if (!m) return null;\n const key = cellWords(m[1]!);\n const value = cellWords(m[2]!);\n if (!key || !value) return null;\n // A key is a column's name: a few words, not a clause, not a time of day (\"10:30\").\n if (key.split(/\\s+/).length > 5 || /^\\d+$/.test(key) || /https?$/i.test(key)) return null;\n return { key, value };\n}\n\n/** Records from key:value pairs: a new record starts each time the first key comes round again. */\nfunction recordsFromPairs(pairs: Array<{ key: string; value: string }>): Array<Map<string, string>> {\n const records: Array<Map<string, string>> = [];\n let current = new Map<string, string>();\n const first = pairs[0]?.key.toLowerCase();\n for (const pair of pairs) {\n const k = pair.key.toLowerCase();\n if (current.size > 0 && (k === first || [...current.keys()].some((c) => c.toLowerCase() === k))) {\n records.push(current);\n current = new Map();\n }\n current.set(pair.key, pair.value);\n }\n if (current.size > 0) records.push(current);\n return records;\n}\n\nfunction shapeFromRecords(\n records: Array<Map<string, string>>,\n base: Omit<TableShape, \"headers\" | \"rows\" | \"said\" | \"kind\" | \"splits\">,\n from: string,\n): TableShape {\n const order: string[] = [];\n for (const r of records) for (const k of r.keys()) if (!order.some((o) => o.toLowerCase() === k.toLowerCase())) order.push(k);\n const headers = uniqueLabels(order);\n const rows = records.map((r) => {\n const row: Record<string, string> = {};\n order.forEach((k, i) => {\n const hit = [...r.entries()].find(([rk]) => rk.toLowerCase() === k.toLowerCase());\n row[headers[i]!] = hit ? hit[1] : \"\";\n });\n return row;\n });\n return {\n ...base,\n kind: \"key_value\",\n headers,\n rows,\n splits: [],\n said:\n rows.length === 1\n ? `One record with ${plural(headers.length, \"value\", \"values\")} from ${from}`\n : `${sizeWords(rows.length, headers.length)} from ${from}`,\n };\n}\n\nconst SPLITS: Array<{ delimiter: string; label: string }> = [\n { delimiter: \" — \", label: \"Split at the dash\" },\n { delimiter: \" – \", label: \"Split at the dash\" },\n { delimiter: \" - \", label: \"Split at the hyphen\" },\n { delimiter: \": \", label: \"Split at the colon\" },\n { delimiter: \" | \", label: \"Split at the bar\" },\n { delimiter: \"\\t\", label: \"Split at the tab\" },\n { delimiter: \", \", label: \"Split at each comma\" },\n];\n\nfunction listSplits(items: string[]): TableShapeSplit[] {\n const out: TableShapeSplit[] = [];\n for (const { delimiter, label } of SPLITS) {\n if (!items.every((t) => t.includes(delimiter))) continue;\n if (out.some((s) => s.label === label)) continue;\n const every = delimiter === \", \";\n const parts = items.map((t) => (every ? t.split(delimiter) : [t.slice(0, t.indexOf(delimiter)), t.slice(t.indexOf(delimiter) + delimiter.length)]));\n const width = Math.max(...parts.map((p) => p.length));\n const headers = uniqueLabels(width === 2 ? [\"Item\", \"Detail\"] : Array.from({ length: width }, (_, i) => (i === 0 ? \"Item\" : `Detail ${i}`)));\n out.push({ delimiter, label, headers, rows: rowsOf(headers, parts.map((p) => p.map((c) => cellWords(c)))) });\n }\n return out;\n}\n\nfunction shapeFromList(items: ListItem[], name: string | null, at: TableShape[\"at\"]): TableShape | null {\n const top = items.filter((i) => i.depth === 0);\n if (top.length === 0) return null;\n // (1) Every item names a record and its children are that record's values.\n const withChildren = top.filter((i) => i.children.length > 0);\n if (withChildren.length === top.length && top.length >= 1) {\n const childPairs = top.map((i) => i.children.map(keyValueOf));\n if (childPairs.every((ps) => ps.length > 0 && ps.every((p) => p !== null))) {\n const lead = \"Name\";\n const records = top.map((item, idx) => {\n const r = new Map<string, string>();\n r.set(lead, cellWords(item.text).replace(/:$/, \"\"));\n for (const p of childPairs[idx]!) r.set(p!.key, p!.value);\n return r;\n });\n return shapeFromRecords(records, { name, at }, \"a list\");\n }\n }\n // (2) Every item is `Key: value` — one record, or several when the keys come round again.\n const pairs = top.map((i) => keyValueOf(i.text));\n if (pairs.length >= FEWEST_KEY_VALUE_PAIRS && pairs.every((p) => p !== null)) {\n const records = recordsFromPairs(pairs as Array<{ key: string; value: string }>);\n const sameKeys = records.every((r) => r.size === records[0]!.size);\n if (records.length === 1 || (sameKeys && records[0]!.size >= 2)) return shapeFromRecords(records, { name, at }, \"a list\");\n }\n // (3) A plain list — one column, or split, and the children kept beside their item.\n if (top.length < FEWEST_LIST_ITEMS) return null;\n const texts = top.map((i) => cellWords(i.text));\n const anyChildren = top.some((i) => i.children.length > 0);\n const headers = anyChildren ? [\"Item\", \"Details\"] : [\"Item\"];\n const rows = top.map((item, idx) => {\n const row: Record<string, string> = { Item: texts[idx]! };\n if (anyChildren) row.Details = item.children.map(cellWords).join(\"; \");\n return row;\n });\n return {\n kind: \"list\",\n headers,\n rows,\n name,\n at,\n splits: anyChildren ? [] : listSplits(texts),\n said: `${plural(rows.length, \"item\", \"items\")} from a list`,\n };\n}\n\n// ── CSV / TSV ──────────────────────────────────────────────────────────────\n\n/** CSV/TSV rows with the all-blank lines dropped — THE one reader (kit `parseDelimited`). */\nexport function parseDelimited(text: string, delimiter: \",\" | \"\\t\"): string[][] {\n return readDelimited(text, { delimiter, skipEmptyLines: \"greedy\" }).data;\n}\n\n/** A whole text that is delimited rows: every line the same width, at least two columns. */\nfunction delimitedShape(text: string, delimiter: \",\" | \"\\t\", fenced: boolean, at: TableShape[\"at\"], name: string | null): TableShape | null {\n const matrix = parseDelimited(text.trim(), delimiter);\n if (matrix.length < 2) return null;\n const width = matrix[0]!.length;\n if (width < 2) return null;\n const same = matrix.filter((r) => r.length === width).length;\n if (same / matrix.length < 0.9) return null;\n if (!fenced) {\n // Prose has commas too. A CSV cell is short; a sentence is not.\n const cells = matrix.flat();\n const long = cells.filter((c) => c.trim().length > 80).length;\n if (delimiter === \",\" && (long / cells.length > 0.2 || matrix.length < 2)) return null;\n }\n const headers = uniqueLabels(matrix[0]!.map((c) => c.trim()));\n const rows = rowsOf(headers, matrix.slice(1));\n if (rows.length === 0) return null;\n const kind = delimiter === \"\\t\" ? \"tsv\" : \"csv\";\n return {\n kind,\n headers,\n rows,\n name,\n at,\n splits: [],\n said: `${sizeWords(rows.length, headers.length)} from ${kind === \"tsv\" ? \"pasted spreadsheet cells\" : \"CSV\"}`,\n };\n}\n\n// ── JSON and kind values ───────────────────────────────────────────────────\n\nfunction cellOf(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n if (Array.isArray(value) && value.every((v) => typeof v !== \"object\" || v === null)) return value.map(cellOf).join(\", \");\n // A nested object (a kind value included) is kept whole, `__kind` and all — it is part of the data.\n return JSON.stringify(value);\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** A key as a column's label: `body_area` → \"Body area\"; a key already in words stays as written. */\nfunction labelOfKey(key: string): string {\n return /[\\s]/.test(key) || /^[A-Z]/.test(key) ? key : humanizeIdentifier(key);\n}\n\nfunction shapeFromObjects(objects: Array<Record<string, unknown>>, kind: TableShapeKind, from: string, name: string | null): TableShape | null {\n if (objects.length === 0) return null;\n const keys: string[] = [];\n for (const o of objects) for (const k of Object.keys(o)) if (k !== \"__kind\" && !keys.includes(k)) keys.push(k);\n if (keys.length === 0) return null;\n const headers = uniqueLabels(keys.map(labelOfKey));\n const rows = objects.map((o) => {\n const row: Record<string, string> = {};\n keys.forEach((k, i) => {\n row[headers[i]!] = cellOf(o[k]);\n });\n return row;\n });\n return { kind, headers, rows, name, at: null, splits: [], said: `${sizeWords(rows.length, headers.length)} from ${from}` };\n}\n\n/**\n * THE ROWS A VALUE HOLDS — a kind value (`__kind`, or a Matrx directive read by the one decoder),\n * a JSON array of objects, or an object whose largest member is one. Null when it holds none.\n */\nexport function shapeOfValue(value: unknown, name: string | null = null): TableShape | null {\n let v: unknown = value;\n if (typeof v === \"string\") {\n const t = v.trim();\n const fence = /^```(?:json|matrx)?\\s*\\n?([\\s\\S]*?)\\n?```$/.exec(t);\n const body = fence ? fence[1]!.trim() : t;\n if (!(body.startsWith(\"{\") || body.startsWith(\"[\"))) return null;\n try {\n v = JSON.parse(body);\n } catch {\n return null;\n }\n }\n if (Array.isArray(v)) {\n const objects = v.filter(isPlainObject);\n if (objects.length === 0 || objects.length < v.length) return null;\n return shapeFromObjects(objects, \"rows\", \"JSON rows\", name);\n }\n if (!isPlainObject(v)) return null;\n const kv = kindValueOf(v);\n if (kv) {\n const label = kv.kind.replace(/^directive_v\\d+_/, \"\").replace(/_/g, \" \");\n if (kv.items.length > 0) return shapeFromObjects(kv.items, \"kind\", `a ${label}`, name);\n const scalars = Object.fromEntries(Object.entries(v).filter(([k, x]) => k !== \"__kind\" && (typeof x !== \"object\" || x === null)));\n const shape = shapeFromObjects([scalars], \"kind\", `a ${label}`, name);\n if (shape) return shape;\n }\n // An object carrying one list of records: {\"exercises\": [{…}, {…}]} — the largest one.\n let best: { key: string; items: Array<Record<string, unknown>> } | null = null;\n for (const [key, member] of Object.entries(v)) {\n if (Array.isArray(member) && member.length > 0 && member.every(isPlainObject)) {\n if (!best || member.length > best.items.length) best = { key, items: member };\n }\n }\n if (best) return shapeFromObjects(best.items, kv ? \"kind\" : \"rows\", \"JSON rows\", name ?? labelOfKey(best.key));\n return null;\n}\n\n// ── the document reader ────────────────────────────────────────────────────\n\n/**\n * EVERY SHAPE IN A TEXT, top to bottom: markdown tables, lists, runs of `Key: value` lines,\n * fenced CSV / TSV / JSON blocks — and when the whole text is one CSV or TSV paste, that.\n * An empty array means the text holds nothing that reads as rows, and a menu offers nothing.\n */\nexport function readTableShapes(text: string): TableShape[] {\n if (typeof text !== \"string\" || text.trim() === \"\" || text.length > LONGEST_TEXT_READ) return [];\n const whole = text.trim();\n\n // A whole value (a kind value / JSON rows pasted or stored as the content).\n if (whole.startsWith(\"{\") || whole.startsWith(\"[\") || /^```(?:json|matrx)/.test(whole)) {\n const s = shapeOfValue(whole);\n if (s) return [{ ...s, at: { start: 0, end: text.length } }];\n }\n // A whole paste of spreadsheet cells or CSV (no markdown at all).\n if (!/^\\s*[|#>*-]/m.test(whole)) {\n if (whole.includes(\"\\t\")) {\n const s = delimitedShape(whole, \"\\t\", false, { start: 0, end: text.length }, null);\n if (s) return [s];\n }\n const s = delimitedShape(whole, \",\", false, { start: 0, end: text.length }, null);\n if (s) return [s];\n }\n\n const lines = text.split(/\\r?\\n/);\n const offsets: number[] = [];\n let pos = 0;\n for (const line of lines) {\n offsets.push(pos);\n pos += line.length + 1;\n }\n const endOf = (i: number) => (offsets[i] ?? 0) + (lines[i]?.length ?? 0);\n const shapes: TableShape[] = [];\n let i = 0;\n while (i < lines.length) {\n const line = lines[i] ?? \"\";\n\n // Fenced blocks: CSV / TSV / JSON are read; any other fence is skipped whole.\n const fence = /^\\s*```\\s*([\\w-]*)\\s*$/.exec(line);\n if (fence) {\n let j = i + 1;\n while (j < lines.length && !/^\\s*```\\s*$/.test(lines[j] ?? \"\")) j += 1;\n const body = lines.slice(i + 1, j).join(\"\\n\");\n const lang = fence[1]!.toLowerCase();\n const at = { start: offsets[i]!, end: endOf(Math.min(j, lines.length - 1)) };\n const name = nameAbove(lines, i);\n let s: TableShape | null = null;\n if (lang === \"csv\") s = delimitedShape(body, \",\", true, at, name);\n else if (lang === \"tsv\") s = delimitedShape(body, \"\\t\", true, at, name);\n else if (lang === \"json\" || lang === \"matrx\") s = shapeOfValue(body, name);\n if (s) shapes.push({ ...s, at });\n i = j + 1;\n continue;\n }\n\n // A markdown table: a row of pipes, then the separator row.\n if (tableStartsAt(lines, i)) {\n const headers = uniqueLabels(splitPipes(line));\n const j = findTableEnd(lines, i);\n const matrix: string[][] = [];\n for (let r = i + 2; r < j; r += 1) matrix.push(splitPipes(lines[r]!));\n const rows = rowsOf(headers, matrix);\n if (headers.length >= 1 && rows.length >= 1) {\n shapes.push({\n kind: \"table\",\n headers,\n rows,\n name: nameAbove(lines, i),\n at: { start: offsets[i]!, end: endOf(j - 1) },\n splits: [],\n said: `${sizeWords(rows.length, headers.length)} from a table`,\n });\n }\n i = j;\n continue;\n }\n\n // A list: consecutive items (a single blank line between items is still the same list).\n const item = LIST_ITEM.exec(line);\n if (item) {\n const baseIndent = item[1]!.length;\n const items: ListItem[] = [];\n let j = i;\n while (j < lines.length) {\n const l = lines[j] ?? \"\";\n const m = LIST_ITEM.exec(l);\n if (m) {\n const depth = m[1]!.length > baseIndent ? 1 : 0;\n if (depth === 0) items.push({ depth: 0, text: m[2]!, children: [] });\n else if (items.length > 0) items[items.length - 1]!.children.push(m[2]!);\n j += 1;\n continue;\n }\n if (l.trim() === \"\" && LIST_ITEM.test(lines[j + 1] ?? \"\")) {\n j += 1;\n continue;\n }\n // A wrapped line of the item above it.\n if (l.trim() !== \"\" && /^\\s{2,}\\S/.test(l) && items.length > 0) {\n items[items.length - 1]!.text += ` ${l.trim()}`;\n j += 1;\n continue;\n }\n break;\n }\n const s = shapeFromList(items, nameAbove(lines, i), { start: offsets[i]!, end: endOf(j - 1) });\n if (s) shapes.push(s);\n i = j;\n continue;\n }\n\n // A run of `Key: value` lines outside a list (a form result, a record written out).\n if (keyValueOf(line)) {\n let j = i;\n const pairs: Array<{ key: string; value: string }> = [];\n while (j < lines.length) {\n const l = lines[j] ?? \"\";\n const p = keyValueOf(l);\n if (p) {\n pairs.push(p);\n j += 1;\n continue;\n }\n if (l.trim() === \"\" && keyValueOf(lines[j + 1] ?? \"\")) {\n j += 1;\n continue;\n }\n break;\n }\n if (pairs.length >= FEWEST_KEY_VALUE_PAIRS) {\n const records = recordsFromPairs(pairs);\n const sameKeys = records.every((r) => r.size === records[0]!.size);\n if (records.length === 1 || (sameKeys && records[0]!.size >= 2)) {\n shapes.push(shapeFromRecords(records, { name: nameAbove(lines, i), at: { start: offsets[i]!, end: endOf(j - 1) } }, \"key and value lines\"));\n } else {\n // Keys that come round in no fixed order are a conversation: who, and what they said.\n const headers = [\"Name\", \"Text\"];\n shapes.push({\n kind: \"key_value\",\n headers,\n rows: pairs.map((p) => ({ Name: p.key, Text: p.value })),\n name: nameAbove(lines, i),\n at: { start: offsets[i]!, end: endOf(j - 1) },\n splits: [],\n said: `${plural(pairs.length, \"line\", \"lines\")}, each a name and what was said`,\n });\n }\n }\n i = Math.max(j, i + 1);\n continue;\n }\n i += 1;\n }\n return shapes;\n}\n\n/** The first shape in a text, or null — what a one-shape menu item acts on. */\nexport function readFirstTableShape(text: string): TableShape | null {\n return readTableShapes(text)[0] ?? null;\n}\n\n/** True when the text holds anything that reads as rows — every menu's \"offer it?\" predicate. */\nexport function hasTableShape(text: string): boolean {\n return readTableShapes(text).length > 0;\n}\n\n/** Headers + string rows — the shape a table renderer already holds, read as a TableShape. */\nexport function shapeOfGrid(\n headers: readonly string[],\n cells: ReadonlyArray<ReadonlyArray<string>>,\n name: string | null = null,\n /** What the rows came out of, in a word: \"table\" (a rendered table), \"sheet\" (a workbook's sheet). */\n from: string = \"table\",\n): TableShape | null {\n const labels = uniqueLabels(headers.map((h) => cellWords(String(h ?? \"\"))));\n const rows = rowsOf(labels, cells.map((r) => r.map((c) => cellWords(String(c ?? \"\")))));\n if (labels.length === 0) return null;\n // Column names with no rows under them are still a table to make (the file importer's header-only\n // file: \"the table will be created with these columns and no rows yet\").\n const said = rows.length === 0 ? `${plural(labels.length, \"column\", \"columns\")} and no rows yet` : `${sizeWords(rows.length, labels.length)} from a ${from}`;\n return { kind: \"table\", headers: labels, rows, name, at: null, splits: [], said };\n}\n\n// ── what a NEW table's columns should be ───────────────────────────────────\n\n/** A type word `custom.field_declare` takes, from `FIELD_TYPE_CHOICES`. */\nexport type GuessedFieldType =\n | \"text\"\n | \"long_text\"\n | \"number\"\n | \"currency\"\n | \"percent\"\n | \"datetime\"\n | \"checkbox\"\n | \"email\"\n | \"url\"\n | \"phone\"\n | \"select\";\n\nexport interface ColumnGuess {\n type: GuessedFieldType;\n /** A choice column's words, in the order the text first used them. */\n options?: string[];\n /** A money column's symbol. */\n unit?: string;\n /** A date column that never carries a time of day. */\n kind?: \"date\" | \"datetime\";\n}\n\n/** The most words a choice column's list may hold before it reads as text. */\nexport const MOST_GUESSED_CHOICES = 12;\n\nconst NUMBER = /^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?$/;\nconst MONEY = /^([$€£¥])\\s?([+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?)$/;\nconst PERCENT = /^[+-]?\\d+(?:\\.\\d+)?\\s?%$/;\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(?:[T ]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:?\\d{2})?)?$/;\nconst SLASH_DATE = /^\\d{1,2}\\/\\d{1,2}\\/\\d{2,4}$/;\nconst WORD_DATE = /^(?:\\d{1,2}\\s+)?(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\\.?\\s+\\d{1,2}(?:st|nd|rd|th)?,?\\s+\\d{4}$|^\\d{1,2}\\s+(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\\.?\\s+\\d{4}$/i;\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\nconst URL_WORD = /^https?:\\/\\/\\S+$/i;\nconst PHONE = /^\\+?[\\d\\s().-]{7,20}$/;\nconst YES = new Set([\"yes\", \"true\", \"y\", \"✓\", \"✔\", \"checked\", \"done\"]);\nconst NO = new Set([\"no\", \"false\", \"n\", \"✗\", \"✘\", \"unchecked\", \"\"]);\n\nfunction isDate(v: string): boolean {\n return ISO_DATE.test(v) || SLASH_DATE.test(v) || WORD_DATE.test(v);\n}\n\n/**\n * WHAT A NEW TABLE'S COLUMN SHOULD HOLD, proposed from every value in it. A column is a number, a\n * date, a yes/no, an email… only when EVERY non-blank value reads as one — one value that does not\n * (\"10-15\" among the Reps) keeps the column text, because a guess that loses a person's words is\n * worse than a text column. A few short words that repeat are a Choice, with those words as its\n * choices. It is a proposal the person sees and changes before anything is made.\n */\nexport function guessColumn(values: ReadonlyArray<string>): ColumnGuess {\n const filled = values.map((v) => String(v ?? \"\").trim()).filter((v) => v !== \"\");\n if (filled.length === 0) return { type: \"text\" };\n const every = (test: (v: string) => boolean) => filled.every(test);\n if (every((v) => YES.has(v.toLowerCase()) || NO.has(v.toLowerCase())) && filled.some((v) => YES.has(v.toLowerCase())) && filled.some((v) => !/^\\d+$/.test(v))) {\n return { type: \"checkbox\" };\n }\n if (every((v) => NUMBER.test(v))) return { type: \"number\" };\n if (every((v) => MONEY.test(v))) {\n const symbols = new Set(filled.map((v) => MONEY.exec(v)![1]!));\n if (symbols.size === 1) return { type: \"currency\", unit: [...symbols][0]! };\n }\n if (every((v) => PERCENT.test(v))) return { type: \"percent\" };\n if (every(isDate)) return { type: \"datetime\", kind: every((v) => !/\\d:\\d/.test(v)) ? \"date\" : \"datetime\" };\n if (every((v) => EMAIL.test(v))) return { type: \"email\" };\n if (every((v) => URL_WORD.test(v))) return { type: \"url\" };\n if (every((v) => PHONE.test(v) && (v.match(/\\d/g)?.length ?? 0) >= 7)) return { type: \"phone\" };\n if (filled.some((v) => v.length > 120 || v.includes(\"\\n\"))) return { type: \"long_text\" };\n const distinct: string[] = [];\n for (const v of filled) if (!distinct.some((d) => d.toLowerCase() === v.toLowerCase())) distinct.push(v);\n const short = every((v) => v.length <= 40 && v.split(/\\s+/).length <= 5);\n // Counts and ranges (\"10\", \"10-15\") repeat too, and they are measurements, not a list to pick from.\n const words = filled.filter((v) => !/\\d/.test(v)).length >= filled.length / 2;\n if (filled.length >= 3 && short && words && distinct.length < filled.length && distinct.length <= MOST_GUESSED_CHOICES) {\n return { type: \"select\", options: distinct };\n }\n return { type: \"text\" };\n}\n\n// ── what a selection over RENDERED content holds ───────────────────────────\n\nconst BLOCK_TAGS = new Set([\"P\", \"DIV\", \"SECTION\", \"ARTICLE\", \"H1\", \"H2\", \"H3\", \"H4\", \"H5\", \"H6\", \"BLOCKQUOTE\", \"PRE\", \"HEADER\", \"FOOTER\", \"BR\", \"HR\", \"DL\", \"DT\", \"DD\"]);\n\n/**\n * THE WORDS OF A SELECTION, WITH ITS SHAPE KEPT (VERIFIER-30 #1). A browser selection over a rendered\n * answer flattens to text in which a table's header cells come one per line and a list's bullets are\n * gone, so `readTableShapes` found nothing in exactly the places a person selects rows. This walks the\n * selected DOM (a `Range.cloneContents()` fragment, or any node) and writes it back as the shapes it\n * was drawn from: a table's rows as a markdown table (the first row its heading), a list's items as\n * bullets (nested items indented), every other block on its own line.\n */\nexport function shapeTextOfNode(node: Node): string {\n const out: string[] = [];\n let line = \"\";\n let rows: string[][] = [];\n const flushLine = () => {\n if (line.trim() !== \"\") out.push(line.trim());\n line = \"\";\n };\n const flushRows = () => {\n if (rows.length === 0) return;\n flushLine();\n const width = Math.max(...rows.map((r) => r.length));\n const pad = (r: string[]) => [...r, ...Array.from({ length: width - r.length }, () => \"\")];\n const cell = (c: string) => c.replace(/\\|/g, \"\\\\|\").replace(/\\s+/g, \" \").trim();\n out.push(`| ${pad(rows[0]!).map(cell).join(\" | \")} |`);\n out.push(`|${Array.from({ length: width }, () => \"---\").join(\"|\")}|`);\n for (const r of rows.slice(1)) out.push(`| ${pad(r).map(cell).join(\" | \")} |`);\n rows = [];\n };\n const textOf = (n: Node): string => (n.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n const walk = (n: Node, depth: number): void => {\n if (n.nodeType === 3) {\n line += n.textContent ?? \"\";\n return;\n }\n if (n.nodeType !== 1 && n.nodeType !== 11) return;\n const el = n as Element;\n const tag = n.nodeType === 1 ? el.tagName.toUpperCase() : \"#fragment\";\n if (tag === \"TR\") {\n const cells = Array.from(el.children).filter((c) => /^(TD|TH)$/i.test(c.tagName));\n rows.push(cells.map((c) => textOf(c)));\n return;\n }\n if (tag === \"TABLE\" || tag === \"THEAD\" || tag === \"TBODY\" || tag === \"TFOOT\") {\n for (const child of Array.from(n.childNodes)) walk(child, depth);\n if (tag === \"TABLE\") flushRows();\n return;\n }\n flushRows();\n if (tag === \"LI\") {\n flushLine();\n const own: string[] = [];\n const nested: Node[] = [];\n for (const child of Array.from(n.childNodes)) {\n if (child.nodeType === 1 && /^(UL|OL)$/i.test((child as Element).tagName)) nested.push(child);\n else own.push(child.textContent ?? \"\");\n }\n const words = own.join(\"\").replace(/\\s+/g, \" \").trim();\n if (words) out.push(`${\" \".repeat(depth)}- ${words}`);\n for (const list of nested) walk(list, depth + 1);\n return;\n }\n if (tag === \"UL\" || tag === \"OL\") {\n flushLine();\n for (const child of Array.from(n.childNodes)) walk(child, depth);\n flushLine();\n return;\n }\n const block = BLOCK_TAGS.has(tag);\n if (block) flushLine();\n for (const child of Array.from(n.childNodes)) walk(child, depth);\n if (block) flushLine();\n };\n walk(node, 0);\n flushRows();\n flushLine();\n return out.join(\"\\n\");\n}\n","// src/kindValues.ts — @ai-matrx/records-ui · lane REFERENCE-CARRY\n//\n// A CELL THAT HOLDS A KIND. A value is a kind value when it names its own shape — `__kind` — or\n// when it is a stored Matrx directive written before the Kind Directives merge (the retired 4-key\n// shell `{\"matrx_version\": 1, \"kind\": \"reference\", \"type\": \"scope\", \"items\": [...]}`, usually inside\n// a ```matrx fence). Before this, a text cell holding either printed the raw fence: Arman's\n// Department table, 2026-09-28 — Team Leader read ```matrx {\"matrx_version\":1,…}```.\n//\n// THE SHELL IS UNDERSTOOD IN ONE PLACE. Whether an object is a directive — the current shell, or\n// the retired one stored before the merge — is `@ai-matrx/content-ir/directives`' `tryDecodeDirective`\n// alone (its containment guard keeps the retired shell there). This module only takes the object out\n// of its fence and hands it, untouched, to the host's `renderKind` port, which draws it through the\n// kind system. New values are stored as `__kind` JSON, never as a fence.\n\nimport { tryDecodeDirective } from \"@ai-matrx/content-ir/directives\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\n\n/** What a cell holds when it holds a kind. */\nexport interface KindValue {\n /** The parsed object, exactly as stored (`__kind` kept — it is part of the data). */\n value: Record<string, unknown>;\n /**\n * The kind's own name: `__kind`, or for a directive the slug the one decoder reads\n * (`directive_v1_reference_scope`, the retired shell included).\n */\n kind: string;\n /** True when the one decoder read this as a Matrx directive. */\n directive: boolean;\n /** The items a directive carries (a reference's chips), when it carries any. */\n items: Record<string, unknown>[];\n}\n\nconst KIND_KEY = \"__kind\";\n/** One fenced block and nothing else: ```matrx {…}``` or ```json {…}```. */\nconst WHOLE_FENCE = /^\\s*```(?:matrx|json)?[ \\t]*\\r?\\n?([\\s\\S]*?)\\r?\\n?[ \\t]*```\\s*$/;\n\nfunction asObject(value: unknown): Record<string, unknown> | null {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) ? (value as Record<string, unknown>) : null;\n}\n\nfunction parseJsonObject(text: string): Record<string, unknown> | null {\n const trimmed = text.trim();\n if (!trimmed.startsWith(\"{\") || !trimmed.endsWith(\"}\")) return null;\n try {\n return asObject(JSON.parse(trimmed));\n } catch {\n return null;\n }\n}\n\nfunction fromObject(obj: Record<string, unknown>): KindValue | null {\n // THE ONE DECODER decides what a directive is — the current two-key shell and, for stored\n // content only, the retired 4-key one. A directive it cannot honor is not drawn as one.\n const directive = tryDecodeDirective(obj);\n if (directive) return { value: obj, kind: directive.slug, directive: true, items: [...directive.items] };\n const named = obj[KIND_KEY];\n if (typeof named === \"string\" && named.trim() !== \"\") {\n const items = Array.isArray(obj.items) ? obj.items.filter((i): i is Record<string, unknown> => asObject(i) !== null) : [];\n return { value: obj, kind: named.trim(), directive: false, items };\n }\n return null;\n}\n/**\n * The kind value a cell holds, or null. An object with `__kind`, a string that is such an object's\n * JSON, or a string that is ONE fenced block of it (```matrx / ```json), the retired directive shell\n * included. Text that merely mentions a fence among other words is text, and stays text.\n */\nexport function kindValueOf(value: unknown): KindValue | null {\n const obj = asObject(value);\n if (obj) return fromObject(obj);\n if (typeof value !== \"string\" || value.length > 200_000) return null;\n const fenced = WHOLE_FENCE.exec(value);\n const parsed = parseJsonObject(fenced ? fenced[1]! : value);\n return parsed ? fromObject(parsed) : null;\n}\n\n/** The words an item names itself by (a reference's label, a title, a name). */\nexport function kindItemWords(item: Record<string, unknown>): string | null {\n for (const key of [\"label\", \"title\", \"name\", \"display_name\"]) {\n const v = item[key];\n if (typeof v === \"string\" && v.trim() !== \"\") return v.trim();\n }\n return null;\n}\n\n/**\n * A kind value in words, for a sentence, a card, a copy or an export: the items' own names when it\n * carries named items (\"Arman Sadeghi, Tahir Mahfooz\"), else what kind of thing it is.\n */\nexport function kindValueWords(kv: KindValue): string {\n const named = kv.items.map(kindItemWords).filter((w): w is string => w !== null);\n if (named.length > 0) return named.join(\", \");\n return kindLabel(kv.kind);\n}\n\n/** A kind's name the way a person reads it: `directive_v1_reference_scope` → \"Reference Scope\". */\nexport function kindLabel(kind: string): string {\n return humanizeIdentifier(kind.replace(/^directive_v\\d+_/, \"\").replace(/_v\\d+$/, \"\")) || \"Structured value\";\n}\n"],"mappings":";;;AAgBA,SAAS,cAAc,cAAc,oBAAoB,UAAU,qBAAqB;;;ACFxF,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AAiBnC,IAAM,WAAW;AAEjB,IAAM,cAAc;AAEpB,SAAS,SAAS,OAAgD;AAChE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAoC;AACrH;AAEA,SAAS,gBAAgB,MAA8C;AACrE,QAAM,UAAU,KAAK,KAAK;AAC1B,MAAI,CAAC,QAAQ,WAAW,GAAG,KAAK,CAAC,QAAQ,SAAS,GAAG,EAAG,QAAO;AAC/D,MAAI;AACF,WAAO,SAAS,KAAK,MAAM,OAAO,CAAC;AAAA,EACrC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,WAAW,KAAgD;AAGlE,QAAM,YAAY,mBAAmB,GAAG;AACxC,MAAI,UAAW,QAAO,EAAE,OAAO,KAAK,MAAM,UAAU,MAAM,WAAW,MAAM,OAAO,CAAC,GAAG,UAAU,KAAK,EAAE;AACvG,QAAM,QAAQ,IAAI,QAAQ;AAC1B,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI;A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