@vitavision/forms 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["placeholderFor","Grid","isRecord","NO_UI"],"sources":["../src/api/schemaNode.ts","../src/api/schemaForm.ts","../src/components/SchemaForm.tsx","../src/api/valuePath.ts","../src/api/schemaValue.ts","../src/api/uiSchema.ts","../src/api/firstParagraph.ts","../src/components/valueForm/context.ts","../src/components/valueForm/chrome.tsx","../src/api/numberSpec.ts","../src/components/valueForm/leaves.tsx","../src/components/valueForm/nodes.tsx","../src/components/SchemaValueForm.tsx"],"sourcesContent":["/**\n * The schema-normalisation both forms stand on: follow a `$ref`, look through the\n * \"or null\" encodings, and name a field.\n *\n * `SchemaForm` (a flat \"unset vs override\" form) and `SchemaValueForm` (a full-value\n * editor) differ in what they do with a schema, not in how they read one. Every shape that\n * needs a decision — pydantic's `anyOf: [T, null]`, schemars' `type: [\"T\", \"null\"]`, a\n * `$ref` with the field's own `default` and `description` written beside it — is decided\n * here, once, so the two forms cannot drift into disagreeing about what a node *is*.\n */\n\n/**\n * The subset of JSON Schema (draft 2020-12, as schemars and pydantic emit it) the forms\n * read. Keywords the forms do not read are simply absent: a real schema carries `$schema`,\n * `title` and `format` on the root and the form ignores what it does not know.\n *\n * A schema imported from a `.json` file is assignable as it is; a loosely typed one needs\n * a cast (`as unknown as JsonSchema`).\n */\nexport interface JsonSchema {\n /** A reference, normally into `$defs` (`#/$defs/Name`). */\n $ref?: string | undefined;\n /** Where a nested struct or an enum lands: schemars and pydantic never inline those. */\n $defs?: Record<string, JsonSchema> | undefined;\n /** The draft-07 spelling of `$defs`. */\n definitions?: Record<string, JsonSchema> | undefined;\n /** One type, or several (`[\"integer\", \"null\"]` is a nullable integer). */\n type?: string | string[] | undefined;\n /** A human name. On a field it is a label; on a `$defs` entry it is a type name. */\n title?: string | undefined;\n /** Rustdoc or a docstring: Markdown, possibly several paragraphs. */\n description?: string | undefined;\n /** What applies when the field is absent. */\n default?: unknown;\n /** The one value allowed. */\n const?: unknown;\n /** The closed set of values allowed. */\n enum?: unknown[] | undefined;\n /** Rust integer and float widths: `uint`, `uint32`, `double`, … */\n format?: string | undefined;\n /** An object's fields, in schema order. */\n properties?: Record<string, JsonSchema> | undefined;\n /** The fields that must be present. */\n required?: string[] | undefined;\n /** `false` closes an object; a schema types a map's values. */\n additionalProperties?: JsonSchema | boolean | undefined;\n /** An array's element schema. */\n items?: JsonSchema | boolean | undefined;\n /** A tuple's per-position schemas. */\n prefixItems?: JsonSchema[] | undefined;\n /** The fewest elements. */\n minItems?: number | undefined;\n /** The most elements. */\n maxItems?: number | undefined;\n /** Exactly one of these (serde enums). */\n oneOf?: JsonSchema[] | undefined;\n /** At least one of these (`Option<T>` is `[T, null]`). */\n anyOf?: JsonSchema[] | undefined;\n /** All of these; the forms read only the one-entry form older schemars wrapped a `$ref` in. */\n allOf?: JsonSchema[] | undefined;\n /** Inclusive lower bound. */\n minimum?: number | undefined;\n /** Inclusive upper bound. */\n maximum?: number | undefined;\n /** Exclusive lower bound. */\n exclusiveMinimum?: number | undefined;\n /** Exclusive upper bound. */\n exclusiveMaximum?: number | undefined;\n /** The step a number moves in. */\n multipleOf?: number | undefined;\n /** The quantity's unit (`px`, `mm`): a vitavision extension, written by the Rust configs. */\n \"x-unit\"?: string | undefined;\n /** The schema's own answer to \"does the caller have to think about this?\" (`SchemaForm`). */\n \"x-primary\"?: boolean | undefined;\n}\n\n/** A node after its `$ref` and its \"or null\" encoding have been looked through. */\nexport interface ResolvedSchema<T extends JsonSchema = JsonSchema> {\n /** The node that says what the value *is*: no `$ref`, and no null branch left to see. */\n schema: T;\n /** True when `null` was an accepted value of the node as written. */\n nullable: boolean;\n}\n\n/** Enough hops for any real schema; a `$ref` cycle ends here instead of looping. */\nconst MAX_HOPS = 16;\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Follow a JSON Pointer `$ref` (`#`, `#/$defs/Name`, `#/definitions/Name`) from the root.\n *\n * @param ref - The `$ref` string. Only same-document references (`#…`) resolve.\n * @param root - The document the pointer starts from.\n * @returns The schema it points at, or `undefined` for an external reference, a path that\n * does not exist, or a target that is not a schema object.\n */\nexport function resolveRef(ref: string, root: JsonSchema): JsonSchema | undefined {\n if (ref === \"#\") return root;\n if (!ref.startsWith(\"#/\")) return undefined;\n\n let current: unknown = root;\n for (const raw of ref.slice(2).split(\"/\")) {\n let segment = raw;\n try {\n segment = decodeURIComponent(raw);\n } catch {\n // A malformed escape is taken literally.\n }\n segment = segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n if (!isObject(current) || !Object.hasOwn(current, segment)) return undefined;\n current = current[segment];\n }\n return isObject(current) ? current : undefined;\n}\n\n/**\n * Lay `over` on `base`: `over`'s keywords win, except that where both describe an object\n * the two are combined instead of one replacing the other.\n *\n * `properties` keep `over`'s keys first (an internally tagged variant's discriminator reads\n * first) and then `base`'s; a key in both has its two schemas merged the same way. `required`\n * is the union, `over`'s entries first.\n */\nfunction mergeOver(base: JsonSchema, over: JsonSchema): JsonSchema {\n const merged: JsonSchema = { ...base, ...over };\n if (base.properties !== undefined && over.properties !== undefined) {\n const properties: Record<string, JsonSchema> = {};\n for (const [key, own] of Object.entries(over.properties)) {\n const inherited = Object.hasOwn(base.properties, key) ? base.properties[key] : undefined;\n properties[key] = inherited === undefined ? own : mergeOver(inherited, own);\n }\n for (const [key, inherited] of Object.entries(base.properties)) {\n if (!Object.hasOwn(properties, key)) properties[key] = inherited;\n }\n merged.properties = properties;\n }\n if (base.required !== undefined && over.required !== undefined) {\n merged.required = [...new Set([...over.required, ...base.required])];\n }\n return merged;\n}\n\n/**\n * Follow one `$ref`, keeping what the field says about itself.\n *\n * The merge order matters and is the opposite of the obvious one. schemars and pydantic\n * write the field's `default` and `description` *beside* the `$ref`, while the target\n * carries the type's own `title` and docstring. The field's statement about itself wins;\n * the type's is the fallback.\n *\n * `properties` and `required` written beside the `$ref` are the exception: in draft 2020-12\n * both the target and the siblings apply, and ringgrid writes a tagged variant as\n * `{ \"$ref\": \"#/$defs/HexGeometry\", \"properties\": { \"kind\": { \"const\": \"hex\" } } }`. They are\n * merged, not replaced: the sibling's properties first (the discriminator leads), then the\n * target's; a property in both is merged with the sibling's keywords winning; `required` is\n * the union.\n *\n * @param node - A node that may carry a `$ref`.\n * @param root - The document holding `$defs`.\n * @returns The node merged over its target, or `node` itself when there is nothing to\n * follow (no `$ref`, or one that points at nothing).\n */\nexport function derefNode<T extends JsonSchema>(node: T, root: JsonSchema): T {\n if (node.$ref === undefined) return node;\n const target = resolveRef(node.$ref, root);\n if (target === undefined) return node;\n\n const rest: JsonSchema = { ...node };\n delete rest.$ref;\n // The merge of a schema over a schema is a schema of the same family as `node`.\n return mergeOver(target, rest) as T;\n}\n\nfunction isNullSchema(branch: JsonSchema): boolean {\n return branch.type === \"null\" || (Object.hasOwn(branch, \"const\") && branch.const === null);\n}\n\n/**\n * Look through the \"or null\" encodings: `type: [\"T\", \"null\"]`, an `enum` that lists `null`,\n * and an `anyOf` / `oneOf` with a `{ type: \"null\" }` branch.\n *\n * An optional string arrives as `anyOf: [{type: \"string\"}, {type: \"null\"}]`; treating that\n * as an unrecognised node would give every nullable option a JSON textarea. When exactly\n * one branch is left it is merged into the node (the node's own siblings win); when several\n * are, they stay as the node's `anyOf` / `oneOf`.\n *\n * @param node - The node to look through.\n * @returns The node without its null alternative, and whether it had one.\n */\nexport function stripNullable<T extends JsonSchema>(node: T): ResolvedSchema<T> {\n let out: JsonSchema = node;\n let nullable = false;\n\n if (Array.isArray(out.type) && out.type.includes(\"null\")) {\n const rest = out.type.filter((type) => type !== \"null\");\n const [only] = rest;\n if (only !== undefined) {\n out = { ...out, type: rest.length === 1 ? only : rest };\n nullable = true;\n }\n }\n\n if (out.enum?.includes(null) === true) {\n out = { ...out, enum: out.enum.filter((entry) => entry !== null) };\n nullable = true;\n }\n\n for (const key of [\"anyOf\", \"oneOf\"] as const) {\n const branches = out[key];\n if (branches === undefined || !branches.some(isNullSchema)) continue;\n const remaining = branches.filter((branch) => !isNullSchema(branch));\n const [only] = remaining;\n if (only === undefined) continue;\n nullable = true;\n if (remaining.length === 1) {\n const rest: JsonSchema = { ...out };\n delete rest[key];\n out = { ...only, ...rest };\n } else {\n out = { ...out, [key]: remaining };\n }\n }\n\n // Unchanged stays identical, so a caller can tell whether anything happened.\n return { schema: (nullable ? out : node) as T, nullable };\n}\n\n/** `allOf: [X]` is how older schemars wrapped a `$ref` that needed siblings. */\nfunction unwrapAllOf<T extends JsonSchema>(node: T): T {\n const [only] = node.allOf ?? [];\n if (only === undefined || node.allOf?.length !== 1) return node;\n const rest: JsonSchema = { ...node };\n delete rest.allOf;\n return mergeOver(only, rest) as T;\n}\n\n/**\n * The node that says what a field *is*: `$ref` followed, `allOf: [X]` unwrapped and the\n * \"or null\" encoding looked through, repeatedly, because each can hide the next (a `$ref`\n * to an enum inside `anyOf: [{$ref}, null]`).\n *\n * @param node - A property or item schema as written.\n * @param root - The document holding `$defs` (defaults to `node`, for a root schema).\n * @returns The resolved node and whether `null` was among its accepted values. The field's\n * own `default` and `description`, written beside a `$ref`, are kept.\n */\nexport function resolveSchema<T extends JsonSchema>(node: T, root: JsonSchema = node): ResolvedSchema<T> {\n let current = node;\n let nullable = false;\n\n for (let hop = 0; hop < MAX_HOPS; hop++) {\n const followed = unwrapAllOf(derefNode(current, root));\n const stripped = stripNullable(followed);\n nullable ||= stripped.nullable;\n const done = stripped.schema === current;\n current = stripped.schema;\n if (done) break;\n }\n return { schema: current, nullable };\n}\n\n/**\n * Humanise `normal_dirs` into `Normal dirs`, and use a title only when a human chose it.\n *\n * pydantic emits a `title` for every field whether or not anyone wrote one, and its\n * generated form is Title Case — `Csv Path`, `Defect Type From Dir` — which reads like a\n * spreadsheet header rather than a form label. So a title is used only when it is *not*\n * the one pydantic would have generated, which is exactly when a human chose it.\n *\n * Read from the *unresolved* node on purpose. Dereferencing pulls in the type's own title,\n * so a resolved `color` field would be labelled \"ColorMode\".\n *\n * @param name - The property key.\n * @param node - The property's schema as written (not resolved).\n * @returns The label.\n */\nexport function labelFor(name: string, node: JsonSchema): string {\n const words = name.split(\"_\");\n const generated = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(\" \");\n if (node.title && node.title !== generated) return node.title;\n\n const spaced = words.join(\" \");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n","/**\n * Turning a JSON Schema into a form, and a form back into options.\n *\n * An options model — a plugin's config, an algorithm's parameters — is meant to *drive*\n * the UI form rather than have the form hardcoded and the schema's defaults merely hoped\n * to agree with it. That stops being survivable the moment an option is *required* and\n * nobody can type it.\n *\n * The logic lives here rather than in the component because it is where the decisions\n * are: what control a schema node deserves, what an empty box means, and when a value is\n * worth sending at all. Rendering is the easy half.\n *\n * Only the shapes pydantic (or an equivalent JSON Schema generator) actually emits are\n * handled. A node this does not recognise becomes a JSON textarea rather than\n * disappearing — a caller can always express what the model accepts, even where the form\n * has nothing prettier to offer.\n *\n * ## Two things worth reading before touching `kindOf`\n *\n * `enum` has to be tested *before* `type`: `Literal[\"small\", \"medium\"]` emits `enum`\n * *alongside* `type: \"string\"`, and testing type first turns a closed set into a free text\n * box whose placeholder is the only hint of what is accepted. A `StrEnum` is worse —\n * pydantic emits it as `{\"$ref\": \"#/$defs/ColorMode\"}` with the default and description as\n * siblings, and `$ref` is not in the type at all, so it falls through every branch to a\n * JSON textarea unless `$defs` is resolved first.\n *\n * Numeric bounds are the same story: a field can carry `minimum`/`maximum` in the schema,\n * and a control that ignores them turns an out-of-range value into a backend rejection\n * reported nowhere near the field that caused it.\n */\n\nimport { labelFor, resolveSchema } from \"./schemaNode\";\n\n/** The subset of JSON Schema that pydantic (or an equivalent generator) emits for an options model. */\nexport type SchemaNode = {\n type?: string;\n title?: string;\n description?: string;\n default?: unknown;\n items?: SchemaNode;\n anyOf?: SchemaNode[];\n additionalProperties?: SchemaNode | boolean;\n /** A nested model's own fields. Recognised only so such a node is not mistaken for one\n * of the shapes above; it still renders as a JSON textarea. */\n properties?: Record<string, SchemaNode>;\n enum?: unknown[];\n $ref?: string;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n multipleOf?: number;\n /** The schema's own answer to \"does the caller have to think about this?\" — pydantic's\n * `json_schema_extra={\"x-primary\": True}`. Overrides the default-based guess in both\n * directions; a required field is primary regardless. */\n \"x-primary\"?: boolean;\n};\n\n/**\n * An options model's JSON Schema, as pydantic or schemars emits it for a whole model: the\n * top-level object whose `properties` become the form's fields.\n */\nexport type OptionsSchema = {\n properties?: Record<string, SchemaNode>;\n required?: string[];\n /** Where an `Enum` or a nested model lands. Pydantic never inlines those. */\n $defs?: Record<string, SchemaNode>;\n};\n\n/** Which control a field is rendered as — decided from its schema node by `describeFields`. */\nexport type FieldKind =\n | \"text\"\n | \"number\"\n | \"boolean\"\n | \"string-list\"\n | \"json\"\n /** A closed set, few enough to show all at once. */\n | \"choice-inline\"\n /** A closed set, too many to show at once. */\n | \"choice\";\n\n/** One entry of a closed set: the value as sent (stringified) and the label as shown. */\nexport type ChoiceOption = { value: string; label: string };\n\n/**\n * Everything the form needs to render one field, derived once from the schema by\n * `describeFields` so the component makes no decisions of its own.\n */\nexport type FieldSpec = {\n name: string;\n label: string;\n description: string | null;\n kind: FieldKind;\n required: boolean;\n /** Rendered into the empty control as a hint, never submitted on the caller's behalf. */\n placeholder: string;\n /** What applies when the field is left empty. Shown, not sent. */\n fallback: unknown;\n /** Behind a disclosure: there is already a working answer for this one. */\n advanced: boolean;\n /** The closed set, in schema order. Empty for every kind but the two choices. */\n options: ChoiceOption[];\n /** True when a choice's values are numbers, so the chosen one is sent as one. */\n numeric: boolean;\n /** Bounds the control can enforce. `\"any\"` step frees a float from the default of 1. */\n min?: number;\n max?: number;\n step?: number | \"any\" | undefined;\n /** The bounds as a reader should see them, exclusive ones included. */\n range: string | null;\n};\n\n/**\n * The node that says what this field *is*, looked through `$ref` and \"or null\" encodings\n * by the same resolver `SchemaValueForm` reads schemas with (see `schemaNode.ts`).\n *\n * Both sides of the null-unwrap can hold the `$ref`: a plain `ColorMode` is a bare\n * `$ref`, while an `Optional[ColorMode]` hides one inside `anyOf`.\n */\nfunction resolve(node: SchemaNode, root: OptionsSchema): SchemaNode {\n return resolveSchema(node, root).schema;\n}\n\nfunction kindOf(resolved: SchemaNode, root: OptionsSchema): FieldKind {\n // Before `type`, always: a `Literal` carries both, and the closed set is the stronger\n // statement of the two.\n if (Array.isArray(resolved.enum) && resolved.enum.length > 0) {\n return resolved.enum.length <= 3 ? \"choice-inline\" : \"choice\";\n }\n if (resolved.type === \"boolean\") return \"boolean\";\n if (resolved.type === \"integer\" || resolved.type === \"number\") return \"number\";\n if (resolved.type === \"string\") return \"text\";\n if (resolved.type === \"array\" && resolve(resolved.items ?? {}, root).type === \"string\") {\n return \"string-list\";\n }\n return \"json\";\n}\n\n/**\n * Which options a caller has to think about, and which already have an answer.\n *\n * The schema says this without anyone maintaining a second list: a field whose default is\n * *empty* — `[]`, `null`, `\"\"`, or absent entirely — is one nothing can do anything useful\n * with until it is filled in. A field with a real default already works, and someone\n * filling in the form should not have to read past nine vocabulary options to answer the\n * question that actually needs an answer.\n */\nfunction isAdvanced(node: SchemaNode): boolean {\n const fallback = node.default;\n if (fallback === undefined || fallback === null) return false;\n if (Array.isArray(fallback)) return fallback.length > 0;\n if (fallback === \"\") return false;\n if (typeof fallback === \"object\") return Object.keys(fallback).length > 0;\n return true;\n}\n\n/**\n * A schema that marks its decisions says so with `x-primary`; one that does not is read by\n * its defaults. The guess works for an adapter, whose open questions have empty defaults,\n * and fails for a model's hyperparameters, where *every* field has a working default and the\n * two that matter are indistinguishable from the fifteen that do not.\n *\n * Read from the raw node first: a `$ref` field carries its extras beside the reference.\n */\nfunction isPrimary(node: SchemaNode, resolved: SchemaNode): boolean {\n const hint = node[\"x-primary\"] ?? resolved[\"x-primary\"];\n if (hint !== undefined) return hint;\n return !isAdvanced(resolved);\n}\n\n/** Raw control state: what the operator chose, not what will be sent. */\nexport type RawValues = Record<string, string | boolean>;\n\n/**\n * A value as a person reads it: scalars as themselves, anything structured as JSON rather\n * than `[object Object]`.\n */\nexport function displayValue(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return value.toString();\n return JSON.stringify(value) ?? \"\";\n}\n\nfunction placeholderFor(kind: FieldKind, fallback: unknown): string {\n if (kind === \"string-list\") {\n return Array.isArray(fallback) && fallback.length > 0 ? fallback.join(\", \") : \"a, b, c\";\n }\n if (kind === \"json\") return \"{}\";\n return displayValue(fallback);\n}\n\n/** `rgb` reads better as `Rgb` in a picker, but `bilinear` must not become `Bi Linear`. */\nfunction optionLabel(value: unknown): string {\n const text = String(value);\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\nfunction optionsFor(resolved: SchemaNode, kind: FieldKind): ChoiceOption[] {\n if (kind !== \"choice\" && kind !== \"choice-inline\") return [];\n return (resolved.enum ?? []).map((value) => ({\n value: String(value),\n label: optionLabel(value),\n }));\n}\n\n/** The bounds as prose, keeping the distinction the HTML control cannot express. */\nfunction rangeOf(resolved: SchemaNode): string | null {\n const parts: string[] = [];\n if (resolved.minimum !== undefined) parts.push(`≥ ${resolved.minimum}`);\n else if (resolved.exclusiveMinimum !== undefined) parts.push(`> ${resolved.exclusiveMinimum}`);\n if (resolved.maximum !== undefined) parts.push(`≤ ${resolved.maximum}`);\n else if (resolved.exclusiveMaximum !== undefined) parts.push(`< ${resolved.exclusiveMaximum}`);\n return parts.length > 0 ? parts.join(\", \") : null;\n}\n\nfunction stepOf(resolved: SchemaNode): number | \"any\" | undefined {\n if (resolved.multipleOf !== undefined) return resolved.multipleOf;\n if (resolved.type === \"integer\") return 1;\n // A number input steps by 1 unless told otherwise, which marks a learning rate of 0.0001\n // invalid and refuses to submit it.\n return \"any\";\n}\n\n/**\n * Derive the form's fields from an options schema, in schema order.\n *\n * Resolves `$ref`s into `$defs`, looks through `anyOf: [T, null]`, picks a control per node\n * (see `FieldKind`), and folds a field under \"Advanced\" when it is optional and its default\n * already works — unless the schema says otherwise with `\"x-primary\"`.\n *\n * @param schema - The model's JSON Schema (draft 2020-12, as pydantic or schemars emit it).\n * @returns One `FieldSpec` per property; empty for a model with no options.\n */\nexport function describeFields(schema: OptionsSchema): FieldSpec[] {\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties ?? {}).map(([name, node]) => {\n const resolved = resolve(node, schema);\n const kind = kindOf(resolved, schema);\n const numeric = (kind === \"choice\" || kind === \"choice-inline\") && (resolved.type === \"integer\" || resolved.type === \"number\");\n\n return {\n name,\n // From the raw node: the resolved one carries the enum type's title, not the field's.\n label: labelFor(name, node),\n description: node.description ?? resolved.description ?? null,\n kind,\n required: required.has(name),\n fallback: resolved.default,\n placeholder: placeholderFor(kind, resolved.default),\n advanced: !required.has(name) && !isPrimary(node, resolved),\n options: optionsFor(resolved, kind),\n numeric,\n ...(kind === \"number\"\n ? {\n min: resolved.minimum ?? resolved.exclusiveMinimum,\n max: resolved.maximum ?? resolved.exclusiveMaximum,\n step: stepOf(resolved),\n }\n : {}),\n range: kind === \"number\" ? rangeOf(resolved) : null,\n };\n });\n}\n\n/**\n * The controls' starting state.\n *\n * Text, list and choice controls start **empty even when the schema has a default**, and\n * that is deliberate: a pre-filled box says \"this is your value\" when what is true is \"this\n * is what happens if you say nothing\". Pre-filling would also mean every run sent every\n * default back, so a later change to a default would silently not reach anyone who had\n * once opened the form. The default is shown as the placeholder instead — and for a\n * segmented control, as the segment already highlighted.\n *\n * Booleans are the exception — a checkbox has no empty state, so it starts at the\n * default and is always sent.\n */\nexport function initialValues(fields: FieldSpec[]): RawValues {\n const values: RawValues = {};\n for (const field of fields) {\n values[field.name] = field.kind === \"boolean\" ? field.fallback === true : \"\";\n }\n return values;\n}\n\n/**\n * Build the options object to send.\n *\n * An untouched control contributes **nothing**, so the receiving side's own default\n * applies and stays the single definition of it. That is what keeps a default from\n * existing twice, once here and once wherever it is enforced, with the two free to drift.\n */\nexport function toOptions(fields: FieldSpec[], values: RawValues): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n for (const field of fields) {\n const raw = values[field.name];\n\n if (field.kind === \"boolean\") {\n // Always sent: a checkbox cannot express \"unset\", so leaving it out would make its\n // rendered state and the value in force disagree whenever the default is `true`.\n options[field.name] = raw === true;\n continue;\n }\n\n const text = typeof raw === \"string\" ? raw.trim() : \"\";\n if (text === \"\") continue;\n\n switch (field.kind) {\n case \"string-list\":\n options[field.name] = text\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n break;\n case \"number\": {\n const parsed = Number(text);\n if (Number.isFinite(parsed)) options[field.name] = parsed;\n break;\n }\n case \"choice\":\n case \"choice-inline\": {\n // `Literal[1, 2, 3]` is a closed set whose members are numbers; the control can\n // only hand back a string, so the schema's own type decides what is sent.\n if (!field.numeric) {\n options[field.name] = text;\n break;\n }\n const parsed = Number(text);\n if (Number.isFinite(parsed)) options[field.name] = parsed;\n break;\n }\n case \"json\":\n try {\n options[field.name] = JSON.parse(text);\n } catch {\n // Left out rather than sent as a string: the receiving side would reject it with\n // a less useful message than the one `jsonErrors` puts next to the field.\n }\n break;\n default:\n options[field.name] = text;\n }\n }\n\n return options;\n}\n\n/** How many options the operator has actually changed, for the tab that hides them. */\nexport function overrideCount(fields: FieldSpec[], values: RawValues): number {\n const initial = initialValues(fields);\n return fields.filter((field) => values[field.name] !== initial[field.name]).length;\n}\n\n/** Which JSON fields do not parse, so the form can say so before the run starts. */\nexport function jsonErrors(fields: FieldSpec[], values: RawValues): string[] {\n return fields\n .filter((field) => field.kind === \"json\")\n .filter((field) => {\n const raw = values[field.name];\n if (typeof raw !== \"string\" || raw.trim() === \"\") return false;\n try {\n JSON.parse(raw);\n return false;\n } catch {\n return true;\n }\n })\n .map((field) => field.label);\n}\n\n/** Required fields the operator has not filled in. Blocks the run. */\nexport function missingRequired(fields: FieldSpec[], values: RawValues): string[] {\n return fields\n .filter((field) => field.required)\n .filter((field) => {\n const raw = values[field.name];\n if (typeof raw === \"boolean\") return false;\n return (raw ?? \"\").trim() === \"\";\n })\n .map((field) => field.label);\n}\n\n/**\n * Fields whose typed value is outside the bounds the schema states.\n *\n * Native `min`/`max` stop the spinner and mark the input invalid, but nothing stops a\n * paste, so the check is repeated here where it can block the button.\n */\nexport function outOfRange(fields: FieldSpec[], values: RawValues): string[] {\n return fields\n .filter((field) => field.kind === \"number\")\n .filter((field) => {\n const raw = values[field.name];\n if (typeof raw !== \"string\" || raw.trim() === \"\") return false;\n const parsed = Number(raw);\n if (!Number.isFinite(parsed)) return true;\n if (field.min !== undefined && parsed < field.min) return true;\n if (field.max !== undefined && parsed > field.max) return true;\n return false;\n })\n .map((field) => field.label);\n}\n","/**\n * An options form, generated from a JSON Schema.\n *\n * Adding an adapter, a model, or a measurement method costs a config module and a registry\n * entry, and *nothing here* — that is the point of generating the form from the schema\n * instead of hardcoding it. Every decision about which control a field deserves lives in\n * `api/schemaForm.ts`; this file only renders.\n *\n * Two behaviours are worth knowing while reading the markup:\n *\n * * An empty control means **unset**, and the caller's own default applies. The default\n * is shown — as a placeholder, as the pre-highlighted segment, or as the picker's\n * leading entry — so a reader can see what happens if they say nothing, without that\n * value being claimed as their choice.\n * * A field the schema requires is marked, and the caller blocks the run on it.\n *\n * The layout is a two-column grid: a form of eight numeric parameters, each a full-width\n * control over a full-width description, runs to screens of scrolling for a form that\n * often needs nothing touched at all. Fields whose value is genuinely wide — a list, a\n * JSON object, a statement with a switch — still span both columns.\n */\n\nimport { Disclosure, Field, NumberInput, SegmentedControl, Select, Switch, Textarea, Input } from \"@vitavision/ui\";\nimport { displayValue, type FieldSpec, type RawValues } from \"../api/schemaForm\";\n\n/**\n * Which kinds are worth a full row. Everything else pairs up.\n *\n * A JSON object needs the width to be editable at all, and a switch reads as a sentence\n * with its explanation beside it. A comma-separated list does *not* qualify: three of them\n * in a row can run as tall as the layout this rule exists to avoid.\n */\nconst WIDE: ReadonlySet<FieldSpec[\"kind\"]> = new Set([\"json\", \"boolean\"]);\n\n/**\n * An options form rendered from `describeFields(schema)`: primary fields first, the rest\n * folded under \"Advanced\", each with the control its schema node calls for.\n *\n * Controlled: `values` holds the raw control values (strings, or booleans for switches),\n * and an empty string means \"unset — the schema's default applies\". Turn them into the\n * options to send with `toOptions`, and gate a run on `missingRequired`, `outOfRange` and\n * `jsonErrors`.\n */\nexport function SchemaForm({ fields, values, onChange }: { fields: FieldSpec[]; values: RawValues; onChange: (next: RawValues) => void }) {\n if (fields.length === 0) {\n return <p className=\"text-sm text-fg-muted\">This plugin takes no options.</p>;\n }\n\n const set = (name: string, value: string | boolean) => onChange({ ...values, [name]: value });\n const render = (field: FieldSpec) => (\n <SchemaField key={field.name} field={field} value={values[field.name] ?? \"\"} onChange={(value) => set(field.name, value)} />\n );\n\n const primary = fields.filter((field) => !field.advanced);\n const advanced = fields.filter((field) => field.advanced);\n\n // Where nothing is required — the normal shape of a model's own hyperparameters, as\n // against an adapter's \"which folder holds the good images\" — there is nothing to fold\n // away from. Hiding every field behind a disclosure would leave a box containing only a\n // disclosure, so they simply render.\n if (primary.length === 0) {\n return <Grid>{advanced.map(render)}</Grid>;\n }\n\n return (\n <div className=\"flex flex-col gap-4\">\n <Grid>{primary.map(render)}</Grid>\n {advanced.length > 0 && (\n <Disclosure summary=\"Advanced\" count={advanced.length}>\n <Grid>{advanced.map(render)}</Grid>\n </Disclosure>\n )}\n </div>\n );\n}\n\nfunction Grid({ children }: { children: React.ReactNode }) {\n return <div className=\"grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2\">{children}</div>;\n}\n\nfunction SchemaField({\n field,\n value,\n onChange,\n}: {\n field: FieldSpec;\n value: string | boolean;\n onChange: (value: string | boolean) => void;\n}) {\n const span = WIDE.has(field.kind) ? \"sm:col-span-2\" : undefined;\n\n // A switch reads as a statement and carries its own label, rather than sitting under one.\n // It is also the one control with no \"unset\" position.\n if (field.kind === \"boolean\") {\n return (\n <div className={span}>\n <Switch checked={value === true} onCheckedChange={onChange} label={field.label} description={field.description} />\n </div>\n );\n }\n\n const text = typeof value === \"string\" ? value : \"\";\n const fallback = field.fallback === undefined || field.fallback === null ? undefined : displayValue(field.fallback);\n\n if (field.kind === \"choice-inline\") {\n return (\n <Field as=\"group\" label={field.label} description={field.description} required={field.required} className={span}>\n <SegmentedControl aria-label={field.label} value={text} defaultValue={fallback} options={field.options} onValueChange={onChange} />\n </Field>\n );\n }\n\n if (field.kind === \"choice\") {\n return (\n <Field as=\"group\" label={field.label} description={field.description} required={field.required} className={span}>\n <Select\n aria-label={field.label}\n value={text}\n onValueChange={onChange}\n options={field.options}\n placeholder={fallback === undefined ? \"Choose…\" : `Default · ${fallback}`}\n unsetLabel={fallback === undefined ? undefined : `Default · ${fallback}`}\n />\n </Field>\n );\n }\n\n return (\n <Field\n label={field.label}\n description={field.kind === \"string-list\" ? [field.description, \"Comma-separated.\"].filter(Boolean).join(\" \") : field.description}\n required={field.required}\n annotation={field.range}\n className={span}\n >\n {field.kind === \"json\" ? (\n <Textarea\n mono\n rows={2}\n aria-label={field.label}\n placeholder={field.placeholder}\n value={text}\n onChange={(event) => onChange(event.target.value)}\n />\n ) : field.kind === \"number\" ? (\n <NumberInput\n aria-label={field.label}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n step={field.step}\n value={text}\n onChange={(event) => onChange(event.target.value)}\n />\n ) : (\n <Input\n className=\"font-mono\"\n aria-label={field.label}\n placeholder={field.placeholder}\n value={text}\n onChange={(event) => onChange(event.target.value)}\n />\n )}\n </Field>\n );\n}\n","/**\n * Reading and writing a JSON value by dot path, without mutating it.\n *\n * A form edits one leaf of a value it does not own: the caller holds the value, the form\n * reports the next one. So an edit must produce a new root that shares every untouched\n * subtree with the old one (cheap to compare, safe to hold in state) and must leave the old\n * root exactly as it was.\n *\n * A path is dot-separated keys, with array indices as numbers: `solver.max_iters`,\n * `cameras.0.id`. A key that itself contains a dot cannot be addressed; the Rust and\n * Python configs these forms are for do not have them.\n */\n\nconst INDEX = /^(0|[1-9]\\d*)$/;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Split a dot path into its segments.\n *\n * @param path - `a.b.0`, or `\"\"` for the root.\n * @returns `[\"a\", \"b\", \"0\"]`, or `[]` for the root.\n */\nexport function splitPath(path: string): string[] {\n return path === \"\" ? [] : path.split(\".\");\n}\n\n/**\n * Join a parent path and a key.\n *\n * @param parent - A dot path; `\"\"` is the root.\n * @param key - A property key or an array index.\n * @returns The child's path.\n */\nexport function joinPath(parent: string, key: string): string {\n return parent === \"\" ? key : `${parent}.${key}`;\n}\n\n/**\n * Read the value at a path.\n *\n * @param value - The root value.\n * @param path - Dot path; `\"\"` is the root itself.\n * @returns What is there, or `undefined` where any step of the path is missing.\n */\nexport function getAtPath(value: unknown, path: string): unknown {\n let current = value;\n for (const segment of splitPath(path)) {\n if (Array.isArray(current)) {\n current = INDEX.test(segment) ? (current as unknown[])[Number(segment)] : undefined;\n } else if (isRecord(current) && Object.hasOwn(current, segment)) {\n current = current[segment];\n } else {\n return undefined;\n }\n }\n return current;\n}\n\nfunction setIn(value: unknown, segments: readonly string[], depth: number, next: unknown): unknown {\n const segment = segments[depth];\n if (segment === undefined) return next;\n\n const isIndex = INDEX.test(segment);\n if (Array.isArray(value) || (!isRecord(value) && isIndex)) {\n if (!isIndex) return value;\n const list = Array.isArray(value) ? (value as unknown[]) : [];\n const index = Number(segment);\n const updated = setIn(list[index], segments, depth + 1, next);\n if (updated === undefined) {\n // Removing an element; setting a hole is not JSON.\n return index < list.length ? list.filter((_, i) => i !== index) : value;\n }\n if (Object.is(updated, list[index])) return value;\n const copy = list.slice();\n copy[index] = updated;\n return copy;\n }\n\n const record = isRecord(value) ? value : {};\n const has = Object.hasOwn(record, segment);\n const updated = setIn(has ? record[segment] : undefined, segments, depth + 1, next);\n if (updated === undefined) {\n if (!has) return value;\n const copy = { ...record };\n delete copy[segment];\n return copy;\n }\n if (has && Object.is(updated, record[segment])) return value;\n return { ...record, [segment]: updated };\n}\n\n/**\n * Write a value at a path, immutably.\n *\n * Every subtree off the path is shared with the input, the input is never touched, and\n * setting what is already there returns the input itself. Containers that do not exist are\n * created (an array before an index, an object before a key). Keys the path does not\n * mention — including ones a schema does not know about — are kept.\n *\n * @param value - The root value.\n * @param path - Dot path; `\"\"` replaces the root.\n * @param next - The new value. `undefined` removes the key (or array element) instead.\n * @returns The new root.\n */\nexport function setAtPath(value: unknown, path: string, next: unknown): unknown {\n return setIn(value, splitPath(path), 0, next);\n}\n","/**\n * Reading a schema as the shape of a *value*: what a node is, which fields it has, and\n * what a fresh one looks like.\n *\n * `SchemaForm` asks \"which control does this option deserve?\". `SchemaValueForm` asks the\n * deeper question — \"what can this value be, all the way down?\" — and the answer has to\n * cover what Rust's serde does to enums:\n *\n * - a **plain enum** is `oneOf` of `{ const }`, or `enum`;\n * - an **externally tagged** enum is `\"None\"` for a unit variant and `{ \"Huber\": { … } }`\n * (or `{ \"Fixed\": 2 }`, a newtype) for a variant that carries data;\n * - an **internally tagged** enum is an object whose `kind` (or any property that is a\n * `const` in every variant) names the variant.\n *\n * Everything here is pure: the component only renders what these functions decide.\n */\n\nimport { getAtPath, splitPath } from \"./valuePath\";\nimport { resolveSchema, type JsonSchema } from \"./schemaNode\";\n\n/** A primitive an enum can hold. */\nexport type EnumValue = string | number | boolean;\n\n/** One value of a closed set. */\nexport interface EnumOption {\n /** The value as stored. */\n value: EnumValue;\n /** The label as shown: the variant's `title`, else the value. */\n label: string;\n /** The variant's own description (a `oneOf` entry's), if it has one. */\n description?: string | undefined;\n}\n\n/** One field of an object: its key, its schema as written, and whether it must be present. */\nexport interface FieldInfo {\n /** The property key. */\n key: string;\n /** The property's schema as written (a `$ref` is not followed). */\n schema: JsonSchema;\n /** Whether the object's `required` lists the key. */\n required: boolean;\n}\n\n/** A variant of an internally tagged enum. */\nexport interface TaggedVariant {\n /** The discriminator's value for this variant. */\n tag: string;\n /** The variant's `title`, else the tag. */\n label: string;\n /** The variant's description. */\n description?: string | undefined;\n /** The variant's object schema, resolved. */\n schema: JsonSchema;\n /** The variant's fields, without the discriminator. */\n fields: FieldInfo[];\n}\n\n/** A variant of an externally tagged enum. */\nexport interface ExternalVariant {\n /** The variant name: the string for a unit variant, the sole key for one with data. */\n tag: string;\n /** The variant's `title`, else the tag. */\n label: string;\n /** The variant's description. */\n description?: string | undefined;\n /** What the variant carries (a struct's fields, or a newtype's one value); none for a unit variant. */\n payload: JsonSchema | undefined;\n}\n\n/** What a schema node is, as far as a form is concerned. */\nexport type SchemaShape =\n /** A struct: its fields in schema order. */\n | { kind: \"object\"; fields: FieldInfo[] }\n | { kind: \"string\" }\n | { kind: \"integer\" }\n | { kind: \"number\" }\n | { kind: \"boolean\" }\n /** A closed set of primitives: `enum`, `const`, or `oneOf` of `{ const }`. */\n | { kind: \"enum\"; options: EnumOption[] }\n /** An enum whose variants are objects named by a shared `const` property. */\n | { kind: \"tagged\"; discriminator: string; variants: TaggedVariant[] }\n /** A serde externally tagged enum. */\n | { kind: \"external\"; variants: ExternalVariant[] }\n /** An array of plain strings. */\n | { kind: \"string-list\"; item: JsonSchema }\n /** A fixed-length array: `prefixItems`, or `minItems === maxItems` of numbers or objects. */\n | { kind: \"tuple\"; items: JsonSchema[] }\n /** Anything else: edited as JSON. */\n | { kind: \"json\" };\n\ntype TaggedShape = Extract<SchemaShape, { kind: \"tagged\" }>;\ntype ExternalShape = Extract<SchemaShape, { kind: \"external\" }>;\n\n/** The longest fixed-length array shown as a row of cells rather than as JSON. */\nconst MAX_TUPLE = 32;\n/** Discriminator names tried first; any other shared `const` property works too. */\nconst PREFERRED_DISCRIMINATORS = [\"kind\", \"type\", \"tag\", \"variant\"];\n/** Recursion limit for seeding a value from a self-referential schema. */\nconst MAX_DEPTH = 8;\n\nfunction isPrimitive(value: unknown): value is EnumValue {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction fieldsOf(schema: JsonSchema, omit?: string): FieldInfo[] {\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties ?? {})\n .filter(([key]) => key !== omit)\n .map(([key, property]) => ({ key, schema: property, required: required.has(key) }));\n}\n\n/** The primitives a `const` / `enum` variant fixes, or `undefined` if it is not one. */\nfunction constValues(variant: JsonSchema): EnumValue[] | undefined {\n if (variant.properties !== undefined) return undefined;\n if (Object.hasOwn(variant, \"const\")) return isPrimitive(variant.const) ? [variant.const] : undefined;\n if (Array.isArray(variant.enum) && variant.enum.length > 0 && variant.enum.every(isPrimitive)) {\n return variant.enum;\n }\n return undefined;\n}\n\nfunction constString(property: JsonSchema | undefined, root: JsonSchema): string | undefined {\n if (property === undefined) return undefined;\n const [value] = constValues(resolveSchema(property, root).schema) ?? [];\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction classifyTagged(variants: JsonSchema[], root: JsonSchema): TaggedShape | undefined {\n if (!variants.every((variant) => variant.properties !== undefined)) return undefined;\n const [first] = variants;\n const keys = Object.keys(first?.properties ?? {});\n const candidates = [\n ...PREFERRED_DISCRIMINATORS.filter((key) => keys.includes(key)),\n ...keys.filter((key) => !PREFERRED_DISCRIMINATORS.includes(key)),\n ];\n\n for (const discriminator of candidates) {\n const tags = variants.map((variant) => constString(variant.properties?.[discriminator], root));\n if (!tags.every((tag): tag is string => tag !== undefined)) continue;\n if (new Set(tags).size !== tags.length) continue;\n return {\n kind: \"tagged\",\n discriminator,\n variants: variants.map((variant, index) => ({\n tag: tags[index] ?? \"\",\n label: variant.title ?? tags[index] ?? \"\",\n description: variant.description,\n schema: variant,\n fields: fieldsOf(variant, discriminator),\n })),\n };\n }\n return undefined;\n}\n\nfunction classifyExternal(variants: JsonSchema[]): ExternalShape | undefined {\n const out: ExternalVariant[] = [];\n for (const variant of variants) {\n const units = constValues(variant);\n if (units !== undefined) {\n if (!units.every((unit) => typeof unit === \"string\")) return undefined;\n for (const unit of units) {\n out.push({ tag: String(unit), label: variant.title ?? String(unit), description: variant.description, payload: undefined });\n }\n continue;\n }\n const keys = Object.keys(variant.properties ?? {});\n const [tag] = keys;\n const payload = tag === undefined ? undefined : variant.properties?.[tag];\n if (keys.length !== 1 || tag === undefined || payload === undefined || variant.additionalProperties === true) {\n return undefined;\n }\n out.push({ tag, label: variant.title ?? tag, description: variant.description, payload });\n }\n return new Set(out.map((variant) => variant.tag)).size === out.length ? { kind: \"external\", variants: out } : undefined;\n}\n\nfunction classifyUnion(branches: JsonSchema[], root: JsonSchema): SchemaShape {\n const variants = branches.map((branch) => resolveSchema(branch, root).schema);\n\n const options: EnumOption[] = [];\n for (const variant of variants) {\n for (const value of constValues(variant) ?? []) {\n options.push({ value, label: variant.title ?? String(value), description: variant.description });\n }\n }\n if (variants.every((variant) => constValues(variant) !== undefined)) return { kind: \"enum\", options };\n\n return classifyTagged(variants, root) ?? classifyExternal(variants) ?? { kind: \"json\" };\n}\n\nfunction classifyArray(schema: JsonSchema, root: JsonSchema): SchemaShape {\n if (schema.prefixItems !== undefined && schema.prefixItems.length > 0) {\n return { kind: \"tuple\", items: schema.prefixItems };\n }\n const items = typeof schema.items === \"object\" ? schema.items : undefined;\n if (items === undefined) return { kind: \"json\" };\n\n const item = resolveSchema(items, root).schema;\n const itemShape = classify(item, root);\n if (itemShape.kind === \"string\") return { kind: \"string-list\", item: items };\n\n const count = schema.minItems;\n const fixed = count !== undefined && count === schema.maxItems && count >= 1 && count <= MAX_TUPLE;\n if (fixed && (itemShape.kind === \"number\" || itemShape.kind === \"integer\" || itemShape.kind === \"object\")) {\n return { kind: \"tuple\", items: Array.from({ length: count }, () => items) };\n }\n return { kind: \"json\" };\n}\n\nfunction classify(schema: JsonSchema, root: JsonSchema): SchemaShape {\n if (Array.isArray(schema.enum) && schema.enum.length > 0) {\n return schema.enum.every(isPrimitive)\n ? { kind: \"enum\", options: schema.enum.map((value) => ({ value, label: String(value) })) }\n : { kind: \"json\" };\n }\n if (Object.hasOwn(schema, \"const\")) {\n return isPrimitive(schema.const) ? { kind: \"enum\", options: [{ value: schema.const, label: String(schema.const) }] } : { kind: \"json\" };\n }\n\n const branches = schema.oneOf ?? schema.anyOf;\n if (branches !== undefined && branches.length > 0) return classifyUnion(branches, root);\n\n if (schema.properties !== undefined) {\n const fields = fieldsOf(schema);\n // `{}` closed is a unit struct; `{}` open is a map the form cannot enumerate.\n return fields.length > 0 || schema.additionalProperties === false ? { kind: \"object\", fields } : { kind: \"json\" };\n }\n\n switch (schema.type) {\n case \"string\":\n return { kind: \"string\" };\n case \"integer\":\n return { kind: \"integer\" };\n case \"number\":\n return { kind: \"number\" };\n case \"boolean\":\n return { kind: \"boolean\" };\n case \"array\":\n return classifyArray(schema, root);\n default:\n return { kind: \"json\" };\n }\n}\n\n/**\n * What a schema node is.\n *\n * Looks through `$ref` and the \"or null\" encodings first (see `resolveSchema`), then\n * decides among the shapes of `SchemaShape`. A node it does not recognise is `json`, never\n * an error: a caller can always express what the model accepts.\n *\n * @param node - A schema node as written.\n * @param root - The document holding `$defs` (defaults to `node`).\n * @returns The shape.\n */\nexport function shapeOf(node: JsonSchema, root: JsonSchema = node): SchemaShape {\n return classify(resolveSchema(node, root).schema, root);\n}\n\n/**\n * The variant an internally tagged value is on.\n *\n * @param shape - A `tagged` shape.\n * @param value - The current value.\n * @returns The variant whose tag is in the value's discriminator, or `undefined` for a\n * value that names none (absent, not an object, an unknown tag).\n */\nexport function activeTagged(shape: TaggedShape, value: unknown): TaggedVariant | undefined {\n const tag = isRecord(value) ? value[shape.discriminator] : undefined;\n return typeof tag === \"string\" ? shape.variants.find((variant) => variant.tag === tag) : undefined;\n}\n\n/**\n * The variant an externally tagged value is on.\n *\n * @param shape - An `external` shape.\n * @param value - The current value: the string of a unit variant, or an object with the\n * variant's name as its key.\n * @returns The variant, or `undefined` for a value that names none.\n */\nexport function activeExternal(shape: ExternalShape, value: unknown): ExternalVariant | undefined {\n if (typeof value === \"string\") {\n return shape.variants.find((variant) => variant.payload === undefined && variant.tag === value);\n }\n if (!isRecord(value)) return undefined;\n return shape.variants.find((variant) => variant.payload !== undefined && Object.hasOwn(value, variant.tag));\n}\n\nfunction seedOf(schema: JsonSchema, root: JsonSchema, depth: number, notNull: boolean): unknown {\n const { schema: s, nullable } = resolveSchema(schema, root);\n if (s.default !== undefined && !(notNull && s.default === null)) return s.default;\n if (nullable && !notNull) return null;\n if (depth > MAX_DEPTH) return null;\n\n const shape = classify(s, root);\n switch (shape.kind) {\n case \"enum\":\n return shape.options[0]?.value ?? null;\n case \"string\":\n return \"\";\n case \"boolean\":\n return false;\n case \"integer\":\n case \"number\":\n return seedNumber(s, shape.kind === \"integer\");\n case \"object\": {\n const out: Record<string, unknown> = {};\n for (const field of shape.fields) {\n const hasDefault = resolveSchema(field.schema, root).schema.default !== undefined;\n if (field.required || hasDefault) out[field.key] = seedOf(field.schema, root, depth + 1, false);\n }\n return out;\n }\n case \"tagged\": {\n const [variant] = shape.variants;\n return variant === undefined ? null : seedTagged(shape, variant, root, depth);\n }\n case \"external\": {\n const [variant] = shape.variants;\n return variant === undefined ? null : seedExternal(variant, root, depth);\n }\n case \"tuple\":\n return shape.items.map((item) => seedOf(item, root, depth + 1, false));\n case \"string-list\":\n return [];\n case \"json\": {\n const [first] = s.oneOf ?? s.anyOf ?? [];\n if (first !== undefined) return seedOf(first, root, depth + 1, false);\n if (s.type === \"array\") return [];\n return s.type === \"object\" ? {} : null;\n }\n }\n}\n\nfunction seedNumber(schema: JsonSchema, integer: boolean): number {\n const lower = schema.minimum ?? (schema.format?.startsWith(\"uint\") === true ? 0 : undefined);\n const exclusiveLower = schema.exclusiveMinimum;\n const upper = schema.maximum ?? schema.exclusiveMaximum;\n\n let value = 0;\n if (lower !== undefined && value < lower) value = lower;\n if (exclusiveLower !== undefined && value <= exclusiveLower) {\n value = integer ? exclusiveLower + 1 : upper !== undefined ? (exclusiveLower + upper) / 2 : exclusiveLower + 1;\n }\n if (upper !== undefined && value > upper) value = lower ?? upper;\n return integer ? Math.ceil(value) : value;\n}\n\nfunction seedTagged(shape: TaggedShape, variant: TaggedVariant, root: JsonSchema, depth: number): unknown {\n const body = seedOf(variant.schema, root, depth + 1, false);\n return { ...(isRecord(body) ? body : {}), [shape.discriminator]: variant.tag };\n}\n\nfunction seedExternal(variant: ExternalVariant, root: JsonSchema, depth: number): unknown {\n return variant.payload === undefined ? variant.tag : { [variant.tag]: seedOf(variant.payload, root, depth + 1, false) };\n}\n\n/**\n * A fresh value for a schema.\n *\n * Takes the `default` when there is one (a `default` written beside a `$ref` wins over the\n * target's), `null` for a nullable node, and otherwise builds the value from the shape:\n * an object gets its required fields and the fields that have a default, an enum its first\n * value, a union its first variant, a number the nearest legal value to 0, a string `\"\"`.\n * The result is JSON, and for a schema this package can read, valid against it.\n *\n * @param schema - A schema node.\n * @param root - The document holding `$defs` (defaults to `schema`).\n * @returns The seed value.\n */\nexport function defaultValueForSchema(schema: JsonSchema, root: JsonSchema = schema): unknown {\n return seedOf(schema, root, 0, false);\n}\n\n/**\n * The seed for a node that is switched on from `null`: its default, unless that default is\n * itself `null`, in which case the value the shape implies.\n *\n * @param schema - A schema node.\n * @param root - The document holding `$defs`.\n * @returns A value that is not `null` (for a node that can hold anything else).\n */\nexport function seedNotNull(schema: JsonSchema, root: JsonSchema): unknown {\n return seedOf(schema, root, 0, true);\n}\n\n/**\n * The value for a union after the user picks a variant: the variant's own seed, with its\n * tag in place.\n *\n * @param shape - A `tagged` or `external` shape.\n * @param tag - The chosen variant's tag.\n * @param root - The document holding `$defs`.\n * @returns The new value, or `undefined` if the shape has no such variant.\n */\nexport function seedVariant(shape: TaggedShape | ExternalShape, tag: string, root: JsonSchema): unknown {\n if (shape.kind === \"tagged\") {\n const variant = shape.variants.find((candidate) => candidate.tag === tag);\n return variant === undefined ? undefined : seedTagged(shape, variant, root, 0);\n }\n const variant = shape.variants.find((candidate) => candidate.tag === tag);\n return variant === undefined ? undefined : seedExternal(variant, root, 0);\n}\n\n/** The fields of the shape for the value as it stands (the active variant, for a union). */\nfunction childrenOf(shape: SchemaShape, value: unknown): FieldInfo[] {\n switch (shape.kind) {\n case \"object\":\n return shape.fields;\n case \"tagged\":\n return (activeTagged(shape, value) ?? shape.variants[0])?.fields ?? [];\n case \"external\": {\n const variant = activeExternal(shape, value);\n return variant?.payload === undefined ? [] : [{ key: variant.tag, schema: variant.payload, required: true }];\n }\n case \"tuple\":\n return shape.items.map((schema, index) => ({ key: String(index), schema, required: true }));\n case \"string-list\":\n return Array.isArray(value) ? value.map((_, index) => ({ key: String(index), schema: shape.item, required: true })) : [];\n default:\n return [];\n }\n}\n\n/** The child called `segment`, wherever it is — the active variant first, then any. */\nfunction findChild(shape: SchemaShape, segment: string, value: unknown): FieldInfo | undefined {\n switch (shape.kind) {\n case \"tagged\": {\n const active = activeTagged(shape, value);\n const variants = active === undefined ? shape.variants : [active, ...shape.variants];\n for (const variant of variants) {\n const field = variant.fields.find((candidate) => candidate.key === segment);\n if (field !== undefined) return field;\n }\n return undefined;\n }\n case \"external\": {\n const variant = shape.variants.find((candidate) => candidate.payload !== undefined && candidate.tag === segment);\n return variant?.payload === undefined ? undefined : { key: segment, schema: variant.payload, required: true };\n }\n case \"tuple\": {\n const schema = shape.items[Number(segment)];\n return schema === undefined ? undefined : { key: segment, schema, required: true };\n }\n case \"string-list\":\n return /^\\d+$/.test(segment) ? { key: segment, schema: shape.item, required: true } : undefined;\n default:\n return childrenOf(shape, value).find((candidate) => candidate.key === segment);\n }\n}\n\n/**\n * The field at a dot path.\n *\n * Walks the schema, not the value: a path through a union resolves in the variant the\n * `value` is on if it has the field, else in whichever variant does, so a `UiSchema` path\n * can name a field that is not showing right now.\n *\n * @param schema - The root schema.\n * @param path - Dot path from the root (`solver.robust_loss.Huber.scale`); `\"\"` is the root.\n * @param root - The document holding `$defs` (defaults to `schema`).\n * @param value - The current value, to choose between a union's variants.\n * @returns The field (its schema as written, and whether it is required), or `undefined`\n * where the path leaves the schema.\n */\nexport function fieldAt(schema: JsonSchema, path: string, root: JsonSchema = schema, value?: unknown): FieldInfo | undefined {\n let info: FieldInfo = { key: \"\", schema, required: true };\n let current = value;\n for (const segment of splitPath(path)) {\n const next = findChild(shapeOf(info.schema, root), segment, current);\n if (next === undefined) return undefined;\n info = next;\n current = getAtPath(current, segment);\n }\n return info;\n}\n\n/**\n * The fields that are editable at a path, as the form would list them: an object's fields\n * in schema order, the active variant's fields (without the discriminator) for an internally\n * tagged union, the variant's payload for an externally tagged one, a tuple's positions.\n *\n * @param schema - The root schema.\n * @param path - Dot path from the root; `\"\"` for the root.\n * @param root - The document holding `$defs` (defaults to `schema`).\n * @param value - The current root value, to choose between a union's variants (the first\n * variant when absent).\n * @returns The fields; empty for a leaf or a path outside the schema.\n */\nexport function fieldsAt(schema: JsonSchema, path: string, root: JsonSchema = schema, value?: unknown): FieldInfo[] {\n const info = fieldAt(schema, path, root, value);\n return info === undefined ? [] : childrenOf(shapeOf(info.schema, root), getAtPath(value, path));\n}\n","/**\n * What an app says about a form that the schema cannot: which fields go together, what to\n * call them, and when a different control is wanted.\n *\n * A schema describes the *data*. It rarely knows that `roi_xywh` is four pixels, that three\n * fields belong under \"Detection\", or that `refinement` reads better as a strip of\n * segments than a drop-down. That is layout, and it belongs to the app, not to the Rust\n * struct, so it travels beside the schema as a `UiSchema` instead of inside it.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport type { JsonSchema } from \"./schemaNode\";\n\n/** A titled set of fields, rendered together. */\nexport interface UiGroup {\n /** Stable id, used for keys and test hooks. */\n id: string;\n /** The heading. */\n title: string;\n /**\n * The fields in the group, as dot paths from the form's root: `threshold`, `solver`,\n * `solver.max_iters`. A path to an object brings its whole subtree; a path to a leaf\n * brings only that leaf, and the object's other fields stay in the ungrouped remainder.\n */\n fields: string[];\n /** Fold the group away behind a `Disclosure`. Otherwise it is a `Section`. */\n collapsible?: boolean | undefined;\n /** Whether a collapsible group starts open. Defaults to closed. */\n defaultOpen?: boolean | undefined;\n /** A line of explanation under the heading. */\n hint?: ReactNode;\n}\n\n/** The widgets a field can be forced into with `FieldUi.widget`. */\nexport type FieldWidget = \"number\" | \"text\" | \"select\" | \"segmented\" | \"checkbox\" | \"switch\" | \"json\" | \"tuple-row\" | \"string-list\";\n\n/** Per-field presentation, looked up by the field's dot path. */\nexport interface FieldUi {\n /** The label, instead of the schema's `title` or the humanised key. */\n label?: string | undefined;\n /** Explanation shown in place of the schema's description. */\n hint?: ReactNode;\n /** Do not render the field. Its value is kept as it is. */\n hidden?: boolean | undefined;\n /**\n * The control, instead of the one the schema's shape calls for. A widget that does not\n * fit the field (`segmented` on a number) is ignored.\n */\n widget?: FieldWidget | undefined;\n /** The unit written in the field, instead of the schema's `x-unit`. */\n unit?: string | undefined;\n /** Lower bound the control enforces, instead of the schema's `minimum`. */\n min?: number | undefined;\n /** Upper bound the control enforces, instead of the schema's `maximum`. */\n max?: number | undefined;\n /** Arrow-key step, instead of the schema's `multipleOf` (or 1 for an integer). */\n step?: number | undefined;\n /**\n * Labels for an enum's values and a union's variants, by value or tag:\n * `{ brown_conrady5: \"Brown-Conrady\" }`.\n */\n enumLabels?: Record<string, string> | undefined;\n /** Columns the field takes in the grid. Containers and lists default to the full row. */\n span?: 1 | 2 | undefined;\n /**\n * Where the description goes: `hint` (the default) is an `InfoHint` beside the label,\n * `inline` is a line under the control, `none` drops it.\n */\n descriptionAs?: \"hint\" | \"inline\" | \"none\" | undefined;\n /**\n * Clearing a number input puts the default back (the default, `true`): the schema's\n * non-null `default`, else the nearest legal value for a required field, else — for an\n * optional field with no usable default — nothing, which removes the key (the schema\n * default then applies). With `false` the field is left empty where it can be (an\n * optional field loses its key) and keeps its value where it cannot (a required,\n * non-nullable one). A required nullable field is set to `null`. An optional field is\n * never set to `null` unless `clearTo` says so.\n */\n restoreDefaultOnClear?: boolean | undefined;\n /**\n * For a nullable field, what clearing writes. `\"null\"` writes `null` even when the key is\n * optional — the way to let a user choose `None` for an `Option<T>` whose default is\n * `Some(…)`, since for a serde `#[serde(default)]` field an absent key means the default\n * and `null` means `None`. Left out, clearing an optional field removes the key and\n * clearing a required nullable one writes `null` (see `restoreDefaultOnClear`). It has no\n * effect on a field that is not nullable.\n */\n clearTo?: \"null\" | undefined;\n}\n\n/**\n * App-supplied layout for a `SchemaValueForm`.\n *\n * Paths are dot paths from the root of the *value*: `solver.max_iters`, `sensor.kind`.\n * An array element is its index (`cameras.0.id`), and `*` stands for any index\n * (`cameras.*.id`). For a serde externally-tagged enum the tag is a path segment\n * (`solver.robust_loss.Huber.scale`).\n */\nexport interface UiSchema {\n /**\n * Groups, in order. Fields in a group render under its heading; every visible field not\n * claimed by a group renders after the groups, in schema order.\n */\n groups?: UiGroup[] | undefined;\n /** Per-field presentation, by dot path. */\n fields?: Record<string, FieldUi> | undefined;\n}\n\n/** What `renderField` is given for a field. */\nexport interface RenderFieldContext {\n /** The field's dot path from the root. */\n path: string;\n /** The field's schema with `$ref` and \"or null\" looked through. */\n schema: JsonSchema;\n /** The field's current value; `undefined` where the key is absent. */\n value: unknown;\n /** Replace the field's value (`undefined` removes the key). */\n onChange: (next: unknown) => void;\n /** Whether the whole form is disabled. */\n disabled: boolean;\n}\n\n/**\n * Take over a field. Return `undefined` to let the form's own control render, anything else\n * to render in its place (and in its grid cell, with the field's span).\n */\nexport type RenderField = (context: RenderFieldContext) => ReactNode;\n\nconst NO_UI: FieldUi = {};\n\n/**\n * The presentation for a path: the exact entry, merged over the wildcard entry\n * (`cameras.*.id`) when the path has array indices.\n *\n * @param ui - The app's `UiSchema`, if any.\n * @param path - The field's dot path.\n * @returns The presentation; `{}` where the app said nothing.\n */\nexport function fieldUiAt(ui: UiSchema | undefined, path: string): FieldUi {\n const table = ui?.fields;\n if (table === undefined) return NO_UI;\n const wildcard = path.replaceAll(/(^|\\.)\\d+(?=\\.|$)/g, \"$1*\");\n const general = wildcard === path ? undefined : table[wildcard];\n const exact = table[path];\n if (general === undefined) return exact ?? NO_UI;\n return exact === undefined ? general : { ...general, ...exact };\n}\n","/**\n * Descriptions are Markdown (Rustdoc comments, docstrings) and the form shows them as plain\n * text in a hint. This is the conversion.\n */\n\n/** Text and a URL: `[text](url)` shows as `text`. */\nconst LINK = /\\[([^\\]]+)\\]\\([^)]*\\)/g;\n/** Rustdoc intra-doc link: ``[`Foo::bar`]`` shows as `Foo::bar`. */\nconst CODE_LINK = /\\[(`+)([^`]+)\\1\\]/g;\nconst AUTOLINK = /<(https?:\\/\\/[^>\\s]+)>/g;\nconst CODE = /(`+)([^`]+?)\\1/g;\nconst BOLD = /(\\*\\*|__)(?=\\S)(.+?)(?<=\\S)\\1/g;\n/** `*em*`; a lone `*` between spaces (a product) is not emphasis. */\nconst STAR = /(?<![\\\\*])\\*(?=\\S)([^*]+?)(?<=\\S)\\*(?!\\*)/g;\n/** `_em_`, but never inside a word: `snake_case_name` is not emphasis. */\nconst UNDERSCORE = /(?<![\\w\\\\])_(?=\\S)([^_]+?)(?<=\\S)_(?!\\w)/g;\nconst ESCAPE = /\\\\([\\\\`*_{}[\\]()#+\\-.!|<>~])/g;\n\n/**\n * The first paragraph of a Markdown description as plain text, for a one-line hint.\n *\n * Strips emphasis, inline code, links (text kept, URL dropped), Rustdoc intra-doc links and\n * backslash escapes, and joins the paragraph's lines with spaces. `snake_case` and a lone\n * `*` are left alone. Later paragraphs — a Rustdoc `# Example` section, say — are dropped.\n *\n * @param description - A schema `description`, or nothing.\n * @returns Plain text; `\"\"` for no description.\n */\nexport function firstParagraph(description: string | null | undefined): string {\n if (!description) return \"\";\n const [paragraph = \"\"] = description.trim().split(/\\n[ \\t]*\\n/);\n return paragraph\n .replaceAll(/\\s*\\n\\s*/g, \" \")\n .replaceAll(CODE_LINK, \"$2\")\n .replaceAll(LINK, \"$1\")\n .replaceAll(AUTOLINK, \"$1\")\n .replaceAll(CODE, \"$2\")\n .replaceAll(BOLD, \"$2\")\n .replaceAll(STAR, \"$1\")\n .replaceAll(UNDERSCORE, \"$1\")\n .replaceAll(ESCAPE, \"$1\")\n .replaceAll(/\\s+/g, \" \")\n .trim();\n}\n","/**\n * What every node of a `SchemaValueForm` shares: the schema, the value, how to edit it, and\n * the app's layout. One context rather than props threaded through every container, because\n * a field is addressed by its path — it reads its own value and writes its own leaf, and\n * the containers in between need not know.\n */\n\nimport { createContext, use } from \"react\";\n\nimport type { JsonSchema } from \"../../api/schemaNode\";\nimport type { RenderField, UiSchema } from \"../../api/uiSchema\";\n\n/** The form's state, for the nodes below it. */\nexport interface FormState {\n /** The root schema, which also holds `$defs`. */\n schema: JsonSchema;\n /** The current root value. */\n value: unknown;\n /** Replace the value at a dot path; `undefined` removes the key. */\n setValue: (path: string, next: unknown) => void;\n /** The app's layout. */\n ui: UiSchema;\n /** Whether every control is disabled. */\n disabled: boolean;\n /** One column, or two on `sm:` and up. */\n columns: 1 | 2;\n /** The app's escape hatch. */\n renderField: RenderField | undefined;\n /** Paths a group has claimed, so the ungrouped remainder skips them. */\n claimed: ReadonlySet<string>;\n}\n\n/** `null` outside a form. */\nexport const FormContext = createContext<FormState | null>(null);\n\n/**\n * True inside a tuple row: cells drop their descriptions and range notes and sit in an\n * auto-fit grid, because a row of four numbers cannot afford a hint line each.\n */\nexport const DenseContext = createContext(false);\n\n/** The enclosing form's state. */\nexport function useForm(): FormState {\n const state = use(FormContext);\n if (state === null) throw new Error(\"A SchemaValueForm field was rendered outside its form.\");\n return state;\n}\n","/**\n * The furniture around a field: the grid it sits in, the cell it takes, and the hint and\n * range note beside its label. Shared by every control so that \"where does the description\n * go\" is decided once.\n */\n\nimport { InfoHint, byDensity, cn, useDensity } from \"@vitavision/ui\";\nimport { use, type ReactNode } from \"react\";\n\nimport { firstParagraph } from \"../../api/firstParagraph\";\nimport type { JsonSchema } from \"../../api/schemaNode\";\nimport type { FieldUi } from \"../../api/uiSchema\";\nimport { DenseContext, useForm } from \"./context\";\n\n/** Everything a control needs to know about its field. */\nexport interface FieldMeta {\n /** The field's dot path from the root. */\n path: string;\n /** The label shown. */\n label: string;\n /** Whether the parent object requires the key. */\n required: boolean;\n /** The schema as written. */\n node: JsonSchema;\n /** The schema with `$ref` and \"or null\" looked through. */\n schema: JsonSchema;\n /** Whether `null` is accepted. */\n nullable: boolean;\n /** The app's presentation for the field. */\n ui: FieldUi;\n}\n\n/**\n * The grid cell a field takes: the full row (`sm:col-span-2`) where it has two columns to\n * span, nothing otherwise.\n *\n * @param columns - The form's column count.\n * @param ui - The field's presentation (its `span` wins).\n * @param fallback - The span for a field the app said nothing about.\n * @returns A Tailwind class, or `undefined`.\n */\nexport function spanClass(columns: 1 | 2, ui: FieldUi, fallback: 1 | 2): string | undefined {\n return columns === 2 && (ui.span ?? fallback) === 2 ? \"sm:col-span-2\" : undefined;\n}\n\n/** The field grid: two columns on `sm:` (or one), or an auto-fit row inside a tuple. */\nexport function Grid({ children }: { children: ReactNode }) {\n const { columns } = useForm();\n const dense = use(DenseContext);\n const density = useDensity();\n return (\n <div\n className={cn(\n \"grid min-w-0\",\n dense\n ? \"grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] gap-2\"\n : cn(byDensity(density, \"gap-x-5 gap-y-4\", \"gap-x-4 gap-y-2.5\"), columns === 2 ? \"grid-cols-1 sm:grid-cols-2\" : \"grid-cols-1\"),\n )}\n >\n {children}\n </div>\n );\n}\n\nfunction present(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n\n/**\n * What a field shows besides its label: the description as an `InfoHint` or as an inline\n * line (or not at all), and the range note, together as the `Field` annotation.\n *\n * @param meta - The field.\n * @param range - The bounds as text, for a number.\n * @returns The hint (for a control that has no annotation slot), the inline description,\n * and the annotation.\n */\nexport function useChrome(\n meta: FieldMeta,\n range: string | null = null,\n): { hint: ReactNode; description: ReactNode; annotation: ReactNode } {\n const dense = use(DenseContext);\n const mode = meta.ui.descriptionAs ?? \"hint\";\n const text: ReactNode = meta.ui.hint ?? firstParagraph(meta.schema.description);\n const shown = !dense && present(text);\n\n const hint = shown && mode === \"hint\" ? <InfoHint label={`About ${meta.label}`}>{text}</InfoHint> : null;\n const description = shown && mode === \"inline\" ? text : undefined;\n const note = dense ? null : range;\n const annotation =\n note !== null || hint !== null ? (\n <span className=\"inline-flex items-center gap-1.5\">\n {note}\n {hint}\n </span>\n ) : undefined;\n return { hint, description, annotation };\n}\n","/**\n * What a number field accepts: the schema's bounds, a `uint` format's implied floor, and\n * the app's own overrides, in one place so the control and its error message cannot\n * disagree.\n */\n\nimport type { JsonSchema } from \"./schemaNode\";\nimport type { FieldUi } from \"./uiSchema\";\n\n/** The rules for one number field. */\nexport interface NumberSpec {\n /** Whole numbers only (`type: \"integer\"`): `2.5` is rejected, never rounded. */\n integer: boolean;\n /** Inclusive lower bound. */\n min?: number | undefined;\n /** Inclusive upper bound. */\n max?: number | undefined;\n /** Exclusive lower bound. */\n exclusiveMin?: number | undefined;\n /** Exclusive upper bound. */\n exclusiveMax?: number | undefined;\n /** Arrow-key step: the schema's `multipleOf`, 1 for an integer, otherwise `\"any\"`. */\n step: number | \"any\";\n /** The unit shown in the field. */\n unit?: string | undefined;\n}\n\n/**\n * Collect a number field's rules.\n *\n * `format: uint…` (Rust's unsigned widths) means \"at least 0\" even where the schema says\n * nothing else. A bound in `ui` replaces the schema's bound of that side, exclusive form\n * included.\n *\n * @param schema - The field's resolved schema.\n * @param ui - The app's presentation for the field.\n * @returns The rules.\n */\nexport function numberSpec(schema: JsonSchema, ui: FieldUi = {}): NumberSpec {\n const integer = schema.type === \"integer\";\n const floor = schema.format?.startsWith(\"uint\") === true ? 0 : undefined;\n return {\n integer,\n min: ui.min ?? schema.minimum ?? floor,\n max: ui.max ?? schema.maximum,\n exclusiveMin: ui.min === undefined ? schema.exclusiveMinimum : undefined,\n exclusiveMax: ui.max === undefined ? schema.exclusiveMaximum : undefined,\n step: ui.step ?? schema.multipleOf ?? (integer ? 1 : \"any\"),\n unit: ui.unit ?? schema[\"x-unit\"],\n };\n}\n\n/**\n * Why a number is not acceptable.\n *\n * @param spec - The field's rules.\n * @param value - The parsed number.\n * @returns A short sentence for the field's error line, or `undefined` when it is fine.\n */\nexport function checkNumber(spec: NumberSpec, value: number): string | undefined {\n if (!Number.isFinite(value)) return \"Enter a number\";\n if (spec.integer && !Number.isInteger(value)) return \"Must be a whole number\";\n if (spec.min !== undefined && value < spec.min) return `Must be ≥ ${spec.min}`;\n if (spec.exclusiveMin !== undefined && value <= spec.exclusiveMin) return `Must be > ${spec.exclusiveMin}`;\n if (spec.max !== undefined && value > spec.max) return `Must be ≤ ${spec.max}`;\n if (spec.exclusiveMax !== undefined && value >= spec.exclusiveMax) return `Must be < ${spec.exclusiveMax}`;\n return undefined;\n}\n\n/**\n * The bounds as a reader should see them, exclusive ones included.\n *\n * @param spec - The field's rules.\n * @returns `\"≥ 2, ≤ 64\"`, or `null` for an unbounded field.\n */\nexport function rangeText(spec: NumberSpec): string | null {\n const parts: string[] = [];\n if (spec.min !== undefined) parts.push(`≥ ${spec.min}`);\n else if (spec.exclusiveMin !== undefined) parts.push(`> ${spec.exclusiveMin}`);\n if (spec.max !== undefined) parts.push(`≤ ${spec.max}`);\n else if (spec.exclusiveMax !== undefined) parts.push(`< ${spec.exclusiveMax}`);\n return parts.length > 0 ? parts.join(\", \") : null;\n}\n","/**\n * The controls of a `SchemaValueForm`: one per kind of leaf value. Each reads its own value\n * from the form by path and writes its own leaf back; none knows its neighbours.\n */\n\nimport {\n Button,\n Checkbox,\n Field,\n Input,\n NumberInput,\n SegmentedControl,\n Select,\n Switch,\n Textarea,\n byDensity,\n cn,\n parseNumber,\n useDensity,\n} from \"@vitavision/ui\";\nimport { use, useState, type ChangeEvent, type ReactNode } from \"react\";\n\nimport { firstParagraph } from \"../../api/firstParagraph\";\nimport { checkNumber, numberSpec, rangeText } from \"../../api/numberSpec\";\nimport { displayValue } from \"../../api/schemaForm\";\nimport type { EnumOption } from \"../../api/schemaValue\";\nimport { defaultValueForSchema } from \"../../api/schemaValue\";\nimport { getAtPath } from \"../../api/valuePath\";\nimport type { FieldWidget } from \"../../api/uiSchema\";\nimport { useChrome, spanClass, type FieldMeta } from \"./chrome\";\nimport { DenseContext, useForm } from \"./context\";\n\n/** `required` as the marker shows it: a nullable field is never mandatory. */\nfunction marked(meta: FieldMeta): boolean {\n return meta.required && !meta.nullable;\n}\n\n/** Where `null` is a legal value, an empty control says so. */\nconst NULL_PLACEHOLDER = \"none\";\n\n/**\n * What an empty control shows: the schema default while the key is absent (that is the\n * value the consumer will use), `none` for an explicit `null` or a nullable field with no\n * non-null default.\n */\nfunction placeholderFor(meta: FieldMeta, value: unknown, fallback: string | undefined): string | undefined {\n if (value === null) return meta.nullable ? NULL_PLACEHOLDER : fallback;\n return fallback ?? (meta.nullable ? NULL_PLACEHOLDER : undefined);\n}\n\n/** A number field: bounds, unit and a verdict on what was typed. */\nexport function NumberLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const spec = numberSpec(meta.schema, meta.ui);\n const chrome = useChrome(meta, rangeText(spec));\n const [error, setError] = useState<string | undefined>();\n\n const fallback = meta.schema.default;\n const restore = meta.ui.restoreDefaultOnClear ?? true;\n let onClear: (() => void) | undefined;\n if (meta.nullable && meta.ui.clearTo === \"null\") onClear = () => form.setValue(meta.path, null);\n else if (!meta.required) {\n onClear = () => form.setValue(meta.path, restore && typeof fallback === \"number\" ? fallback : undefined);\n } else if (meta.nullable) onClear = () => form.setValue(meta.path, null);\n else if (restore && typeof fallback === \"number\") onClear = () => form.setValue(meta.path, fallback);\n else if (restore) onClear = () => form.setValue(meta.path, defaultValueForSchema(meta.schema, form.schema));\n\n const judge = (event: ChangeEvent<HTMLInputElement>) => {\n const text = event.currentTarget.value;\n const parsed = parseNumber(text);\n if (text.trim() === \"\") setError(undefined);\n else setError(parsed === null ? \"Enter a number\" : checkNumber(spec, parsed));\n };\n\n return (\n <Field\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={chrome.description}\n error={error}\n className={spanClass(form.columns, meta.ui, 1)}\n >\n <NumberInput\n aria-label={meta.label}\n disabled={form.disabled}\n placeholder={placeholderFor(meta, value, typeof fallback === \"number\" ? String(fallback) : undefined)}\n value={typeof value === \"number\" ? value : null}\n min={spec.min}\n max={spec.max}\n step={spec.step}\n unit={spec.unit}\n onChange={judge}\n onBlur={() => setError(undefined)}\n onValueChange={(next) => {\n // The control already holds back what is out of `[min, max]`; the integer rule and\n // the exclusive bounds are ours.\n if (checkNumber(spec, next) === undefined) form.setValue(meta.path, next);\n }}\n onClear={onClear}\n />\n </Field>\n );\n}\n\n/**\n * A string field. Emptying a nullable one removes an optional key (the schema default\n * applies) and writes `null` for a required key or under `clearTo: \"null\"`; a field that\n * cannot be `null` keeps `\"\"`.\n */\nexport function TextLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const fallback = meta.schema.default;\n\n return (\n <Field\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={chrome.description}\n className={spanClass(form.columns, meta.ui, 1)}\n >\n <Input\n className=\"font-mono\"\n autoComplete=\"off\"\n spellCheck={false}\n aria-label={meta.label}\n disabled={form.disabled}\n placeholder={placeholderFor(meta, value, typeof fallback === \"string\" ? fallback : undefined)}\n value={typeof value === \"string\" ? value : \"\"}\n onChange={(event) => {\n const text = event.currentTarget.value;\n if (text !== \"\" || !meta.nullable) form.setValue(meta.path, text);\n else if (meta.ui.clearTo === \"null\" || meta.required) form.setValue(meta.path, null);\n else form.setValue(meta.path, undefined);\n }}\n />\n </Field>\n );\n}\n\n/** A choice among a few values (all shown) or many (a picker). */\nexport function Chooser({\n label,\n options,\n value,\n onChoose,\n unsetLabel,\n widget,\n disabled,\n}: {\n label: string;\n options: { value: string; label: string }[];\n /** The chosen option's value, or `\"\"`. */\n value: string;\n onChoose: (value: string) => void;\n /** Adds an entry that returns the field to unset (a nullable value). */\n unsetLabel?: string | undefined;\n widget?: FieldWidget | undefined;\n disabled: boolean;\n}) {\n const size = byDensity(useDensity(), \"md\", \"sm\");\n const strip = widget === \"segmented\" || (widget !== \"select\" && options.length <= 3 && unsetLabel === undefined);\n return strip ? (\n <SegmentedControl aria-label={label} size={size} disabled={disabled} value={value} options={options} onValueChange={onChoose} />\n ) : (\n <Select\n aria-label={label}\n disabled={disabled}\n value={value}\n options={options}\n placeholder={unsetLabel ?? \"Choose…\"}\n unsetLabel={unsetLabel}\n onValueChange={onChoose}\n />\n );\n}\n\n/** A closed set of primitives: `enum`, `const`, or `oneOf` of `{ const }`. */\nexport function EnumLeaf({ meta, options }: { meta: FieldMeta; options: EnumOption[] }) {\n const form = useForm();\n const dense = use(DenseContext);\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n\n const shown = options.map((option) => ({\n value: String(option.value),\n label: meta.ui.enumLabels?.[String(option.value)] ?? option.label,\n }));\n // An absent key is its schema default, so that is the option shown as chosen.\n const selected = options.find((option) => option.value === (value === undefined ? meta.schema.default : value));\n // The chosen variant's own sentence (\"No distortion; no parameter block.\") under the strip.\n const explained = !dense && meta.ui.descriptionAs !== \"none\" ? firstParagraph(selected?.description) : \"\";\n const description: ReactNode =\n explained !== \"\" && chrome.description !== undefined ? (\n <>\n {chrome.description} {explained}\n </>\n ) : explained !== \"\" ? (\n explained\n ) : (\n chrome.description\n );\n\n return (\n <Field\n as=\"group\"\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={description}\n className={spanClass(form.columns, meta.ui, 1)}\n >\n <Chooser\n label={meta.label}\n options={shown}\n value={selected === undefined ? \"\" : String(selected.value)}\n widget={meta.ui.widget}\n disabled={form.disabled}\n unsetLabel={meta.nullable ? \"None\" : undefined}\n onChoose={(chosen) => {\n if (chosen === \"\") {\n if (meta.nullable) form.setValue(meta.path, null);\n return;\n }\n const option = options.find((candidate) => String(candidate.value) === chosen);\n if (option !== undefined) form.setValue(meta.path, option.value);\n }}\n />\n </Field>\n );\n}\n\n/** A boolean: a switch (the default) or a checkbox. */\nexport function BooleanLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const props = {\n checked: value === true,\n onCheckedChange: (next: boolean) => form.setValue(meta.path, next),\n label: meta.label,\n description: chrome.description,\n disabled: form.disabled,\n };\n\n return (\n <div className={cn(\"flex min-w-0 items-start gap-1.5\", spanClass(form.columns, meta.ui, 1))}>\n {meta.ui.widget === \"checkbox\" ? <Checkbox {...props} /> : <Switch {...props} />}\n {chrome.hint !== null && <span className=\"mt-0.5\">{chrome.hint}</span>}\n </div>\n );\n}\n\nfunction pretty(value: unknown): string {\n return value === undefined ? \"\" : JSON.stringify(value, null, 2);\n}\n\n/**\n * Anything the form has no control for, as JSON.\n *\n * What is typed is kept as typed. A valid edit goes to the form; an invalid one shows its\n * parse error and leaves the last good value where it was. The text only resets when the\n * value changes from outside.\n */\nexport function JsonLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const canonical = JSON.stringify(value) ?? \"\";\n const [draft, setDraft] = useState<{ text: string; error: string | undefined; base: string }>(() => ({\n text: pretty(value),\n error: undefined,\n base: canonical,\n }));\n if (draft.base !== canonical) setDraft({ text: pretty(value), error: undefined, base: canonical });\n\n const edit = (text: string) => {\n if (text.trim() === \"\") {\n if (meta.required) {\n setDraft({ text, error: \"Enter a JSON value\", base: draft.base });\n } else {\n setDraft({ text, error: undefined, base: \"\" });\n form.setValue(meta.path, undefined);\n }\n return;\n }\n try {\n const parsed: unknown = JSON.parse(text);\n setDraft({ text, error: undefined, base: JSON.stringify(parsed) });\n form.setValue(meta.path, parsed);\n } catch (problem) {\n setDraft({ text, error: `Invalid JSON: ${problem instanceof Error ? problem.message : String(problem)}`, base: draft.base });\n }\n };\n\n return (\n <Field\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={chrome.description}\n error={draft.error}\n className={spanClass(form.columns, meta.ui, 2)}\n >\n <Textarea\n mono\n rows={Math.min(Math.max(draft.text.split(\"\\n\").length, 3), 12)}\n spellCheck={false}\n aria-label={meta.label}\n disabled={form.disabled}\n value={draft.text}\n onChange={(event) => edit(event.currentTarget.value)}\n />\n </Field>\n );\n}\n\ninterface RowIds {\n ids: number[];\n next: number;\n}\n\n/** Grow or shrink the row ids to `length`, keeping the ids of the rows that stay. */\nfunction syncIds(rows: RowIds, length: number): RowIds {\n if (rows.ids.length === length) return rows;\n const ids = rows.ids.slice(0, length);\n let next = rows.next;\n while (ids.length < length) ids.push(next++);\n return { ids, next };\n}\n\n/**\n * An array of strings as a list: one input per entry, add and remove.\n *\n * Each row has an id of its own, so removing the second of three keeps the focus and the\n * cursor of the others instead of re-keying them by position.\n */\nexport function StringListLeaf({\n meta,\n minItems,\n maxItems,\n}: {\n meta: FieldMeta;\n minItems?: number | undefined;\n maxItems?: number | undefined;\n}) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const raw: unknown[] = Array.isArray(value) ? (value as unknown[]) : [];\n const [rows, setRows] = useState<RowIds>(() => syncIds({ ids: [], next: 0 }, raw.length));\n const synced = syncIds(rows, raw.length);\n if (synced !== rows) setRows(synced);\n\n const write = (list: unknown[]) => form.setValue(meta.path, list);\n const canRemove = minItems === undefined || raw.length > minItems;\n const canAdd = maxItems === undefined || raw.length < maxItems;\n\n return (\n <Field\n as=\"group\"\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={chrome.description}\n className={spanClass(form.columns, meta.ui, 2)}\n >\n <div className=\"flex flex-col gap-1.5\">\n {raw.map((entry, index) => (\n <div key={synced.ids[index]} className=\"flex gap-1.5\">\n <Input\n className=\"min-w-0 flex-1 font-mono\"\n autoComplete=\"off\"\n spellCheck={false}\n aria-label={`${meta.label} ${index + 1}`}\n disabled={form.disabled}\n value={displayValue(entry)}\n onChange={(event) => {\n const copy = raw.slice();\n copy[index] = event.currentTarget.value;\n write(copy);\n }}\n />\n <Button\n variant=\"ghost\"\n aria-label={`Remove ${meta.label} ${index + 1}`}\n disabled={form.disabled || !canRemove}\n onClick={() => {\n setRows({ ids: synced.ids.filter((_, i) => i !== index), next: synced.next });\n write(raw.filter((_, i) => i !== index));\n }}\n >\n ×\n </Button>\n </div>\n ))}\n <Button\n className=\"self-start\"\n aria-label={`Add ${meta.label}`}\n disabled={form.disabled || !canAdd}\n onClick={() => {\n setRows({ ids: [...synced.ids, synced.next], next: synced.next + 1 });\n write([...raw, \"\"]);\n }}\n >\n Add\n </Button>\n </div>\n </Field>\n );\n}\n","/**\n * The tree of a `SchemaValueForm`: a field dispatcher and the containers that nest it.\n *\n * A node is addressed by its dot path. It reads its value from the form, writes it back by\n * path, and renders whatever its schema's shape calls for: a control for a leaf, a\n * fieldset for an object, a variant selector for a union, a row for a tuple, a switch for\n * a nullable composite.\n */\n\nimport { Checkbox, Switch, byDensity, cn, useDensity } from \"@vitavision/ui\";\nimport { use, type ReactNode } from \"react\";\n\nimport { firstParagraph } from \"../../api/firstParagraph\";\nimport { labelFor, resolveSchema, type JsonSchema } from \"../../api/schemaNode\";\nimport { activeExternal, activeTagged, seedNotNull, seedVariant, shapeOf, type FieldInfo, type SchemaShape } from \"../../api/schemaValue\";\nimport { fieldUiAt } from \"../../api/uiSchema\";\nimport { getAtPath, joinPath } from \"../../api/valuePath\";\nimport { Grid, spanClass, useChrome, type FieldMeta } from \"./chrome\";\nimport { Chooser, BooleanLeaf, EnumLeaf, JsonLeaf, NumberLeaf, StringListLeaf, TextLeaf } from \"./leaves\";\nimport { DenseContext, useForm } from \"./context\";\n\ntype TaggedShape = Extract<SchemaShape, { kind: \"tagged\" }>;\ntype ExternalShape = Extract<SchemaShape, { kind: \"external\" }>;\ntype TupleShape = Extract<SchemaShape, { kind: \"tuple\" }>;\n\nconst BOOLEANS = [\n { value: true, label: \"true\" },\n { value: false, label: \"false\" },\n];\n\n/** Shapes that are a block of their own, so a nullable one gets a switch rather than an empty box. */\nfunction isComposite(shape: SchemaShape): boolean {\n return (\n shape.kind === \"object\" ||\n shape.kind === \"tagged\" ||\n shape.kind === \"external\" ||\n shape.kind === \"tuple\" ||\n shape.kind === \"string-list\"\n );\n}\n\n/** `ui.widget` can change what an array or any value is edited as. */\nfunction applyWidget(shape: SchemaShape, meta: FieldMeta, value: unknown): SchemaShape {\n const items = typeof meta.schema.items === \"object\" ? meta.schema.items : undefined;\n switch (meta.ui.widget) {\n case \"json\":\n return { kind: \"json\" };\n case \"string-list\":\n return meta.schema.type === \"array\" ? { kind: \"string-list\", item: items ?? { type: \"string\" } } : shape;\n case \"tuple-row\":\n return items !== undefined && Array.isArray(value) ? { kind: \"tuple\", items: (value as unknown[]).map(() => items) } : shape;\n default:\n return shape;\n }\n}\n\n/**\n * One field of the form, at a path.\n *\n * Honours the app's `hidden` and `renderField`, then renders the control or container its\n * schema's shape calls for. A nullable composite (an object that may be `null`) gets a\n * switch; a nullable leaf is an empty control.\n */\nexport function FieldNode({\n path,\n name,\n node,\n required,\n bare = false,\n}: {\n path: string;\n /** The key (or index) the field has in its parent, for the default label. */\n name: string;\n /** The schema as written. */\n node: JsonSchema;\n required: boolean;\n /** Without the container's own chrome (legend, border): the root, and a switched-on nullable. */\n bare?: boolean;\n}) {\n const form = useForm();\n const ui = fieldUiAt(form.ui, path);\n if (ui.hidden === true) return null;\n\n const { schema, nullable } = resolveSchema(node, form.schema);\n const value = getAtPath(form.value, path);\n const meta: FieldMeta = { path, label: ui.label ?? labelFor(name, node), required, node, schema, nullable, ui };\n const shape = applyWidget(shapeOf(schema, form.schema), meta, value);\n\n if (form.renderField !== undefined) {\n const custom = form.renderField({\n path,\n schema,\n value,\n onChange: (next) => form.setValue(path, next),\n disabled: form.disabled,\n });\n if (custom !== undefined) {\n return <div className={spanClass(form.columns, ui, isComposite(shape) ? 2 : 1)}>{custom}</div>;\n }\n }\n\n if (nullable && isComposite(shape)) return <NullableNode meta={meta} shape={shape} />;\n return <ShapeNode meta={meta} shape={shape} bare={bare} />;\n}\n\n/** Render a resolved shape. */\nfunction ShapeNode({ meta, shape, bare }: { meta: FieldMeta; shape: SchemaShape; bare: boolean }) {\n switch (shape.kind) {\n case \"integer\":\n case \"number\":\n return <NumberLeaf meta={meta} />;\n case \"string\":\n return <TextLeaf meta={meta} />;\n case \"boolean\":\n return meta.nullable ? <EnumLeaf meta={meta} options={BOOLEANS} /> : <BooleanLeaf meta={meta} />;\n case \"enum\":\n return <EnumLeaf meta={meta} options={shape.options} />;\n case \"string-list\":\n return <StringListLeaf meta={meta} minItems={meta.schema.minItems} maxItems={meta.schema.maxItems} />;\n case \"json\":\n return <JsonLeaf meta={meta} />;\n case \"object\":\n return <ObjectNode meta={meta} fields={shape.fields} bare={bare} />;\n case \"tagged\":\n case \"external\":\n return <UnionNode meta={meta} shape={shape} bare={bare} />;\n case \"tuple\":\n return <TupleNode meta={meta} shape={shape} bare={bare} />;\n }\n}\n\n/** The fields of an object that are neither hidden by the app nor claimed by a group. */\nfunction useVisible(path: string, fields: FieldInfo[]): FieldInfo[] {\n const form = useForm();\n return fields.filter((field) => {\n const child = joinPath(path, field.key);\n return !form.claimed.has(child) && fieldUiAt(form.ui, child).hidden !== true;\n });\n}\n\n/**\n * The fields of an object, each as a node, skipping hidden ones and ones a group has claimed.\n * Renders nothing when none is left.\n */\nexport function ObjectBody({ path, fields }: { path: string; fields: FieldInfo[] }) {\n const visible = useVisible(path, fields);\n if (visible.length === 0) return null;\n\n return (\n <Grid>\n {visible.map((field) => (\n <FieldNode key={field.key} path={joinPath(path, field.key)} name={field.key} node={field.schema} required={field.required} />\n ))}\n </Grid>\n );\n}\n\n/** The frame of a composite field: its label and hint over its content. `bare` drops the frame. */\nfunction Frame({ meta, bare, children }: { meta: FieldMeta; bare: boolean; children: ReactNode }) {\n const form = useForm();\n const dense = use(DenseContext);\n const density = useDensity();\n const chrome = useChrome(meta);\n if (bare) return <div className=\"flex min-w-0 flex-col gap-3\">{children}</div>;\n\n return (\n <fieldset\n className={cn(\n \"flex min-w-0 flex-col gap-3 rounded-panel border border-line\",\n byDensity(density, \"p-3\", \"p-2\"),\n !dense && spanClass(form.columns, meta.ui, 2),\n )}\n >\n <legend className=\"px-1\">\n <span className=\"inline-flex items-center gap-1.5 text-xs font-semibold text-fg\">\n {meta.label}\n {chrome.hint}\n </span>\n </legend>\n {chrome.description !== undefined && <p className=\"text-xs leading-snug text-fg-muted\">{chrome.description}</p>}\n {children}\n </fieldset>\n );\n}\n\nfunction ObjectNode({ meta, fields, bare }: { meta: FieldMeta; fields: FieldInfo[]; bare: boolean }) {\n if (useVisible(meta.path, fields).length === 0) return null;\n return (\n <Frame meta={meta} bare={bare}>\n <ObjectBody path={meta.path} fields={fields} />\n </Frame>\n );\n}\n\n/** A union: the variant selector, the variant's description, and the variant's fields. */\nfunction UnionNode({ meta, shape, bare }: { meta: FieldMeta; shape: TaggedShape | ExternalShape; bare: boolean }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const active = shape.kind === \"tagged\" ? activeTagged(shape, value) : activeExternal(shape, value);\n const options = shape.variants.map((variant) => ({\n value: variant.tag,\n label: meta.ui.enumLabels?.[variant.tag] ?? variant.label,\n }));\n const explained = meta.ui.descriptionAs === \"none\" ? \"\" : firstParagraph(active?.description);\n\n let body: ReactNode = null;\n if (shape.kind === \"tagged\") {\n const variant = activeTagged(shape, value);\n if (variant !== undefined) body = <ObjectBody path={meta.path} fields={variant.fields} />;\n } else {\n const variant = activeExternal(shape, value);\n if (variant?.payload !== undefined) {\n const inner = joinPath(meta.path, variant.tag);\n const payload = shapeOf(variant.payload, form.schema);\n body =\n payload.kind === \"object\" ? (\n <ObjectBody path={inner} fields={payload.fields} />\n ) : (\n <Grid>\n <FieldNode path={inner} name={variant.tag} node={variant.payload} required />\n </Grid>\n );\n }\n }\n\n return (\n <Frame meta={meta} bare={bare}>\n <Chooser\n label={meta.label}\n options={options}\n value={active?.tag ?? \"\"}\n widget={meta.ui.widget}\n disabled={form.disabled}\n onChoose={(tag) => {\n const next = seedVariant(shape, tag, form.schema);\n if (next !== undefined) form.setValue(meta.path, next);\n }}\n />\n {explained !== \"\" && <p className=\"text-xs leading-snug text-fg-muted\">{explained}</p>}\n {body}\n </Frame>\n );\n}\n\n/**\n * A fixed-length array as a compact row: one cell per position (a row of numbers), or one\n * row per position when the positions are objects (a list of points).\n */\nfunction TupleNode({ meta, shape, bare }: { meta: FieldMeta; shape: TupleShape; bare: boolean }) {\n const form = useForm();\n const cells = shape.items.map((item, index) => {\n const name = String(index);\n return { name, item, resolved: shapeOf(item, form.schema), path: joinPath(meta.path, name) };\n });\n const rows = cells.some((cell) => cell.resolved.kind === \"object\");\n\n return (\n <Frame meta={meta} bare={bare}>\n <DenseContext value>\n {rows ? (\n <div className=\"flex flex-col gap-2\">\n {cells.map((cell) => (\n <div key={cell.name} role=\"group\" aria-label={`${meta.label} ${cell.name}`} className=\"flex items-start gap-2\">\n <span className=\"w-4 shrink-0 pt-1.5 font-mono text-xs text-fg-subtle\" aria-hidden>\n {cell.name}\n </span>\n <div className=\"min-w-0 flex-1\">\n {cell.resolved.kind === \"object\" ? (\n <ObjectBody path={cell.path} fields={cell.resolved.fields} />\n ) : (\n <Grid>\n <FieldNode path={cell.path} name={cell.name} node={cell.item} required />\n </Grid>\n )}\n </div>\n </div>\n ))}\n </div>\n ) : (\n <Grid>\n {cells.map((cell) => (\n <FieldNode key={cell.name} path={cell.path} name={cell.name} node={cell.item} required />\n ))}\n </Grid>\n )}\n </DenseContext>\n </Frame>\n );\n}\n\n/**\n * A composite that may be `null`: a switch for \"set / unset\", and the content only while set.\n * Switching it on seeds the content from the schema's defaults.\n */\nfunction NullableNode({ meta, shape }: { meta: FieldMeta; shape: SchemaShape }) {\n const form = useForm();\n const chrome = useChrome(meta);\n const value = getAtPath(form.value, meta.path);\n const set = value !== null && value !== undefined;\n const props = {\n checked: set,\n label: meta.label,\n description: chrome.description,\n disabled: form.disabled,\n onCheckedChange: (next: boolean) => form.setValue(meta.path, next ? seedNotNull(meta.node, form.schema) : null),\n };\n\n return (\n <div className={cn(\"flex min-w-0 flex-col gap-3\", spanClass(form.columns, meta.ui, 2))}>\n <div className=\"flex items-start gap-1.5\">\n {meta.ui.widget === \"checkbox\" ? <Checkbox {...props} /> : <Switch {...props} />}\n {chrome.hint !== null && <span className=\"mt-0.5\">{chrome.hint}</span>}\n </div>\n {set && (\n <div className=\"min-w-0 border-l border-line pl-3\">\n <ShapeNode meta={meta} shape={shape} bare />\n </div>\n )}\n </div>\n );\n}\n","/**\n * A form that edits a whole JSON value, generated from the value's JSON Schema.\n *\n * `SchemaForm` is for *options*: every field starts unset and only what the operator\n * touches is sent. This is for *configs*: the value is complete — a calibration's settings,\n * a detector's parameters — and the form edits it in place, down to a nested struct, a\n * serde enum's data, a nullable block or a tuple of points, handing back the whole next\n * value on each edit. What the schema cannot say (grouping, labels, units, a different\n * control) the app says in a `UiSchema`.\n */\n\nimport { Disclosure, Section, TooltipProvider, cn } from \"@vitavision/ui\";\nimport { useMemo, useState, type Ref } from \"react\";\n\nimport type { JsonSchema } from \"../api/schemaNode\";\nimport { defaultValueForSchema, fieldAt, shapeOf } from \"../api/schemaValue\";\nimport { fieldUiAt, type RenderField, type UiGroup, type UiSchema } from \"../api/uiSchema\";\nimport { setAtPath } from \"../api/valuePath\";\nimport { Grid } from \"./valueForm/chrome\";\nimport { FormContext, useForm, type FormState } from \"./valueForm/context\";\nimport { FieldNode, ObjectBody } from \"./valueForm/nodes\";\n\nconst NO_UI: UiSchema = {};\n\n/** Props of `SchemaValueForm`. */\nexport interface SchemaValueFormProps {\n /**\n * The value's JSON Schema (draft 2020-12, as schemars emits it), `$defs` included. Not\n * watched for change in the uncontrolled mode: give the form a `key` per schema.\n */\n schema: JsonSchema;\n /** The value, for a controlled form. Complete: the form edits it, it does not complete it. */\n value?: unknown;\n /**\n * The starting value, for an uncontrolled form. Without either, the form starts from\n * `defaultValueForSchema(schema)`.\n */\n defaultValue?: unknown;\n /**\n * Called with the whole next value on each edit. The previous value is never mutated;\n * untouched subtrees are shared with it, and keys the schema does not know are kept.\n */\n onValueChange?: ((next: unknown) => void) | undefined;\n /** Layout the schema cannot carry: groups, labels, units, widgets. */\n ui?: UiSchema | undefined;\n /** `2` (the default) puts fields side by side from `sm:` up; `1` is one column, for a narrow rail. */\n columns?: 1 | 2 | undefined;\n /** Blocks every control. The value is still shown. */\n disabled?: boolean | undefined;\n /**\n * Take over a field. Called for every field before the form's own control; return\n * `undefined` to let the form render it. The result is placed in the field's grid cell\n * as it is, so wrap it in a `Field` if it should look like its neighbours.\n */\n renderField?: RenderField | undefined;\n /** Merged with the form's own classes through `cn`. */\n className?: string | undefined;\n /** The root element. */\n ref?: Ref<HTMLDivElement> | undefined;\n}\n\n/** Controlled when `value` is given, otherwise the form keeps the value itself. */\nfunction useValue(\n value: unknown,\n seed: () => unknown,\n onValueChange: ((next: unknown) => void) | undefined,\n): [unknown, (next: unknown) => void] {\n const [inner, setInner] = useState(seed);\n const controlled = value !== undefined;\n return [\n controlled ? value : inner,\n (next) => {\n if (!controlled) setInner(next);\n onValueChange?.(next);\n },\n ];\n}\n\n/**\n * Edit a JSON value through its schema.\n *\n * Renders by the schema's shape: a number is a `NumberInput` (with its bounds, unit and an\n * integer-only rule), a string an `Input`, a boolean a `Switch`, a closed set a\n * `SegmentedControl` or a `Select`, a struct a nested fieldset, a serde enum a variant\n * selector with the variant's fields (switching seeds them from the schema's defaults), a\n * `null`-able block a switch that sets and unsets it, a list of strings an editable list, a\n * fixed-length array a row of cells, and anything else a JSON textarea that keeps the last\n * valid value while showing the parse error.\n *\n * The first paragraph of a field's description is its `InfoHint`. Round-trips: a value in,\n * no edits, the same value out — the form never normalises on mount, and an edit changes\n * only the leaf touched.\n *\n * The root is a `div` carrying `data-columns` and, while disabled, `data-disabled`. Wraps itself in a\n * `TooltipProvider`, so it needs none above it.\n */\nexport function SchemaValueForm({\n schema,\n value,\n defaultValue,\n onValueChange,\n ui = NO_UI,\n columns = 2,\n disabled = false,\n renderField,\n className,\n ref,\n}: SchemaValueFormProps) {\n const [current, commit] = useValue(\n value,\n () => (defaultValue !== undefined ? defaultValue : defaultValueForSchema(schema)),\n onValueChange,\n );\n const claimed = useMemo(() => new Set((ui.groups ?? []).flatMap((group) => group.fields)), [ui.groups]);\n\n const state: FormState = {\n schema,\n value: current,\n setValue: (path, next) => {\n const updated = setAtPath(current, path, next);\n // Setting what is already there hands back the same value: nothing to report.\n if (!Object.is(updated, current)) commit(updated);\n },\n ui,\n disabled,\n columns,\n renderField,\n claimed,\n };\n\n const root = shapeOf(schema, schema);\n\n return (\n <TooltipProvider>\n <FormContext value={state}>\n <div\n ref={ref}\n data-columns={columns}\n data-disabled={disabled ? \"\" : undefined}\n className={cn(\"flex min-w-0 flex-col gap-5\", className)}\n >\n {root.kind === \"object\" && (ui.groups ?? []).map((group) => <GroupBlock key={group.id} group={group} />)}\n {root.kind === \"object\" ? (\n <ObjectBody path=\"\" fields={root.fields} />\n ) : (\n <FieldNode path=\"\" name={schema.title ?? \"value\"} node={schema} required bare />\n )}\n </div>\n </FormContext>\n </TooltipProvider>\n );\n}\n\n/** A `UiGroup`: its fields under a heading, folded away if the app said so. */\nfunction GroupBlock({ group }: { group: UiGroup }) {\n const { schema, value, ui } = useForm();\n const fields = group.fields.flatMap((path) => {\n const info = fieldAt(schema, path, schema, value);\n if (info === undefined || fieldUiAt(ui, path).hidden === true) return [];\n return [{ path, info }];\n });\n if (fields.length === 0) return null;\n\n const body = (\n <Grid>\n {fields.map(({ path, info }) => (\n <FieldNode key={path} path={path} name={path.split(\".\").at(-1) ?? path} node={info.schema} required={info.required} />\n ))}\n </Grid>\n );\n\n if (group.collapsible === true) {\n return (\n <Disclosure summary={group.title} count={fields.length} defaultOpen={group.defaultOpen ?? false}>\n {group.hint !== undefined && <p className=\"mb-3 text-xs text-fg-muted\">{group.hint}</p>}\n {body}\n </Disclosure>\n );\n }\n return (\n <Section title={group.title} hint={group.hint}>\n {body}\n </Section>\n );\n}\n"],"mappings":";;;;;AAqFA,MAAM,WAAW;AAEjB,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;;;;;;;AAUA,SAAgB,WAAW,KAAa,MAA0C;CAChF,IAAI,QAAQ,KAAK,OAAO;CACxB,IAAI,CAAC,IAAI,WAAW,IAAI,GAAG,OAAO,KAAA;CAElC,IAAI,UAAmB;CACvB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG;EACzC,IAAI,UAAU;EACd,IAAI;GACF,UAAU,mBAAmB,GAAG;EAClC,QAAQ,CAER;EACA,UAAU,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG;EAC5D,IAAI,CAAC,SAAS,OAAO,KAAK,CAAC,OAAO,OAAO,SAAS,OAAO,GAAG,OAAO,KAAA;EACnE,UAAU,QAAQ;CACpB;CACA,OAAO,SAAS,OAAO,IAAI,UAAU,KAAA;AACvC;;;;;;;;;AAUA,SAAS,UAAU,MAAkB,MAA8B;CACjE,MAAM,SAAqB;EAAE,GAAG;EAAM,GAAG;CAAK;CAC9C,IAAI,KAAK,eAAe,KAAA,KAAa,KAAK,eAAe,KAAA,GAAW;EAClE,MAAM,aAAyC,CAAC;EAChD,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,KAAK,UAAU,GAAG;GACxD,MAAM,YAAY,OAAO,OAAO,KAAK,YAAY,GAAG,IAAI,KAAK,WAAW,OAAO,KAAA;GAC/E,WAAW,OAAO,cAAc,KAAA,IAAY,MAAM,UAAU,WAAW,GAAG;EAC5E;EACA,KAAK,MA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,oBAAC,WAAD;IAAW,MAAK;IAAG,MAAM,OAAO,SAAS;IAAS,MAAM;IAAQ,UAAA;IAAS,MAAA;GAAM,CAAA,CAE9E;;CACM,CAAA,EACE,CAAA;AAErB;;AAGA,SAAS,WAAW,EAAE,SAA6B;CACjD,MAAM,EAAE,QAAQ,OAAO,OAAO,QAAQ;CACtC,MAAM,SAAS,MAAM,OAAO,SAAS,SAAS;EAC5C,MAAM,OAAO,QAAQ,QAAQ,MAAM,QAAQ,KAAK;EAChD,IAAI,SAAS,KAAA,KAAa,UAAU,IAAI,IAAI,CAAC,CAAC,WAAW,MAAM,OAAO,CAAC;EACvE,OAAO,CAAC;GAAE;GAAM;EAAK,CAAC;CACxB,CAAC;CACD,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,MAAM,OACJ,oBAAC,MAAD,EAAA,UACG,OAAO,KAAK,EAAE,MAAM,WACnB,oBAAC,WAAD;EAA4B;EAAM,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;EAAM,MAAM,KAAK;EAAQ,UAAU,KAAK;CAAW,GAArG,IAAqG,CACtH,EACG,CAAA;CAGR,IAAI,MAAM,gBAAgB,MACxB,OACE,qBAAC,YAAD;EAAY,SAAS,MAAM;EAAO,OAAO,OAAO;EAAQ,aAAa,MAAM,eAAe;EAA1F,UAAA,CACG,MAAM,SAAS,KAAA,KAAa,oBAAC,KAAD;GAAG,WAAU;GAA8B,UAAA,MAAM;EAAQ,CAAA,GACrF,IACS;;CAGhB,OACE,oBAAC,SAAD;EAAS,OAAO,MAAM;EAAO,MAAM,MAAM;EACtC,UAAA;CACM,CAAA;AAEb"}
1
+ {"version":3,"file":"index.js","names":["placeholderFor","Grid","isRecord","isRecord","NO_UI"],"sources":["../src/api/schemaNode.ts","../src/api/schemaForm.ts","../src/components/SchemaForm.tsx","../src/api/valuePath.ts","../src/api/schemaValue.ts","../src/api/uiSchema.ts","../src/api/valueDiff.ts","../src/api/firstParagraph.ts","../src/components/valueForm/context.ts","../src/components/valueForm/chrome.tsx","../src/components/valueForm/changes.tsx","../src/api/numberSpec.ts","../src/components/valueForm/leaves.tsx","../src/components/valueForm/nodes.tsx","../src/components/SchemaValueForm.tsx"],"sourcesContent":["/**\n * The schema-normalisation both forms stand on: follow a `$ref`, look through the\n * \"or null\" encodings, and name a field.\n *\n * `SchemaForm` (a flat \"unset vs override\" form) and `SchemaValueForm` (a full-value\n * editor) differ in what they do with a schema, not in how they read one. Every shape that\n * needs a decision — pydantic's `anyOf: [T, null]`, schemars' `type: [\"T\", \"null\"]`, a\n * `$ref` with the field's own `default` and `description` written beside it — is decided\n * here, once, so the two forms cannot drift into disagreeing about what a node *is*.\n */\n\n/**\n * The subset of JSON Schema (draft 2020-12, as schemars and pydantic emit it) the forms\n * read. Keywords the forms do not read are simply absent: a real schema carries `$schema`,\n * `title` and `format` on the root and the form ignores what it does not know.\n *\n * A schema imported from a `.json` file is assignable as it is; a loosely typed one needs\n * a cast (`as unknown as JsonSchema`).\n */\nexport interface JsonSchema {\n /** A reference, normally into `$defs` (`#/$defs/Name`). */\n $ref?: string | undefined;\n /** Where a nested struct or an enum lands: schemars and pydantic never inline those. */\n $defs?: Record<string, JsonSchema> | undefined;\n /** The draft-07 spelling of `$defs`. */\n definitions?: Record<string, JsonSchema> | undefined;\n /** One type, or several (`[\"integer\", \"null\"]` is a nullable integer). */\n type?: string | string[] | undefined;\n /** A human name. On a field it is a label; on a `$defs` entry it is a type name. */\n title?: string | undefined;\n /** Rustdoc or a docstring: Markdown, possibly several paragraphs. */\n description?: string | undefined;\n /** What applies when the field is absent. */\n default?: unknown;\n /** The one value allowed. */\n const?: unknown;\n /** The closed set of values allowed. */\n enum?: unknown[] | undefined;\n /** Rust integer and float widths: `uint`, `uint32`, `double`, … */\n format?: string | undefined;\n /** An object's fields, in schema order. */\n properties?: Record<string, JsonSchema> | undefined;\n /** The fields that must be present. */\n required?: string[] | undefined;\n /** `false` closes an object; a schema types a map's values. */\n additionalProperties?: JsonSchema | boolean | undefined;\n /** An array's element schema. */\n items?: JsonSchema | boolean | undefined;\n /** A tuple's per-position schemas. */\n prefixItems?: JsonSchema[] | undefined;\n /** The fewest elements. */\n minItems?: number | undefined;\n /** The most elements. */\n maxItems?: number | undefined;\n /** Exactly one of these (serde enums). */\n oneOf?: JsonSchema[] | undefined;\n /** At least one of these (`Option<T>` is `[T, null]`). */\n anyOf?: JsonSchema[] | undefined;\n /** All of these; the forms read only the one-entry form older schemars wrapped a `$ref` in. */\n allOf?: JsonSchema[] | undefined;\n /** Inclusive lower bound. */\n minimum?: number | undefined;\n /** Inclusive upper bound. */\n maximum?: number | undefined;\n /** Exclusive lower bound. */\n exclusiveMinimum?: number | undefined;\n /** Exclusive upper bound. */\n exclusiveMaximum?: number | undefined;\n /** The step a number moves in. */\n multipleOf?: number | undefined;\n /** The quantity's unit (`px`, `mm`): a vitavision extension, written by the Rust configs. */\n \"x-unit\"?: string | undefined;\n /** The schema's own answer to \"does the caller have to think about this?\" (`SchemaForm`). */\n \"x-primary\"?: boolean | undefined;\n}\n\n/** A node after its `$ref` and its \"or null\" encoding have been looked through. */\nexport interface ResolvedSchema<T extends JsonSchema = JsonSchema> {\n /** The node that says what the value *is*: no `$ref`, and no null branch left to see. */\n schema: T;\n /** True when `null` was an accepted value of the node as written. */\n nullable: boolean;\n}\n\n/** Enough hops for any real schema; a `$ref` cycle ends here instead of looping. */\nconst MAX_HOPS = 16;\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Follow a JSON Pointer `$ref` (`#`, `#/$defs/Name`, `#/definitions/Name`) from the root.\n *\n * @param ref - The `$ref` string. Only same-document references (`#…`) resolve.\n * @param root - The document the pointer starts from.\n * @returns The schema it points at, or `undefined` for an external reference, a path that\n * does not exist, or a target that is not a schema object.\n */\nexport function resolveRef(ref: string, root: JsonSchema): JsonSchema | undefined {\n if (ref === \"#\") return root;\n if (!ref.startsWith(\"#/\")) return undefined;\n\n let current: unknown = root;\n for (const raw of ref.slice(2).split(\"/\")) {\n let segment = raw;\n try {\n segment = decodeURIComponent(raw);\n } catch {\n // A malformed escape is taken literally.\n }\n segment = segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n if (!isObject(current) || !Object.hasOwn(current, segment)) return undefined;\n current = current[segment];\n }\n return isObject(current) ? current : undefined;\n}\n\n/**\n * Lay `over` on `base`: `over`'s keywords win, except that where both describe an object\n * the two are combined instead of one replacing the other.\n *\n * `properties` keep `over`'s keys first (an internally tagged variant's discriminator reads\n * first) and then `base`'s; a key in both has its two schemas merged the same way. `required`\n * is the union, `over`'s entries first.\n */\nfunction mergeOver(base: JsonSchema, over: JsonSchema): JsonSchema {\n const merged: JsonSchema = { ...base, ...over };\n if (base.properties !== undefined && over.properties !== undefined) {\n const properties: Record<string, JsonSchema> = {};\n for (const [key, own] of Object.entries(over.properties)) {\n const inherited = Object.hasOwn(base.properties, key) ? base.properties[key] : undefined;\n properties[key] = inherited === undefined ? own : mergeOver(inherited, own);\n }\n for (const [key, inherited] of Object.entries(base.properties)) {\n if (!Object.hasOwn(properties, key)) properties[key] = inherited;\n }\n merged.properties = properties;\n }\n if (base.required !== undefined && over.required !== undefined) {\n merged.required = [...new Set([...over.required, ...base.required])];\n }\n return merged;\n}\n\n/**\n * Follow one `$ref`, keeping what the field says about itself.\n *\n * The merge order matters and is the opposite of the obvious one. schemars and pydantic\n * write the field's `default` and `description` *beside* the `$ref`, while the target\n * carries the type's own `title` and docstring. The field's statement about itself wins;\n * the type's is the fallback.\n *\n * `properties` and `required` written beside the `$ref` are the exception: in draft 2020-12\n * both the target and the siblings apply, and ringgrid writes a tagged variant as\n * `{ \"$ref\": \"#/$defs/HexGeometry\", \"properties\": { \"kind\": { \"const\": \"hex\" } } }`. They are\n * merged, not replaced: the sibling's properties first (the discriminator leads), then the\n * target's; a property in both is merged with the sibling's keywords winning; `required` is\n * the union.\n *\n * @param node - A node that may carry a `$ref`.\n * @param root - The document holding `$defs`.\n * @returns The node merged over its target, or `node` itself when there is nothing to\n * follow (no `$ref`, or one that points at nothing).\n */\nexport function derefNode<T extends JsonSchema>(node: T, root: JsonSchema): T {\n if (node.$ref === undefined) return node;\n const target = resolveRef(node.$ref, root);\n if (target === undefined) return node;\n\n const rest: JsonSchema = { ...node };\n delete rest.$ref;\n // The merge of a schema over a schema is a schema of the same family as `node`.\n return mergeOver(target, rest) as T;\n}\n\nfunction isNullSchema(branch: JsonSchema): boolean {\n return branch.type === \"null\" || (Object.hasOwn(branch, \"const\") && branch.const === null);\n}\n\n/**\n * Look through the \"or null\" encodings: `type: [\"T\", \"null\"]`, an `enum` that lists `null`,\n * and an `anyOf` / `oneOf` with a `{ type: \"null\" }` branch.\n *\n * An optional string arrives as `anyOf: [{type: \"string\"}, {type: \"null\"}]`; treating that\n * as an unrecognised node would give every nullable option a JSON textarea. When exactly\n * one branch is left it is merged into the node (the node's own siblings win); when several\n * are, they stay as the node's `anyOf` / `oneOf`.\n *\n * @param node - The node to look through.\n * @returns The node without its null alternative, and whether it had one.\n */\nexport function stripNullable<T extends JsonSchema>(node: T): ResolvedSchema<T> {\n let out: JsonSchema = node;\n let nullable = false;\n\n if (Array.isArray(out.type) && out.type.includes(\"null\")) {\n const rest = out.type.filter((type) => type !== \"null\");\n const [only] = rest;\n if (only !== undefined) {\n out = { ...out, type: rest.length === 1 ? only : rest };\n nullable = true;\n }\n }\n\n if (out.enum?.includes(null) === true) {\n out = { ...out, enum: out.enum.filter((entry) => entry !== null) };\n nullable = true;\n }\n\n for (const key of [\"anyOf\", \"oneOf\"] as const) {\n const branches = out[key];\n if (branches === undefined || !branches.some(isNullSchema)) continue;\n const remaining = branches.filter((branch) => !isNullSchema(branch));\n const [only] = remaining;\n if (only === undefined) continue;\n nullable = true;\n if (remaining.length === 1) {\n const rest: JsonSchema = { ...out };\n delete rest[key];\n out = { ...only, ...rest };\n } else {\n out = { ...out, [key]: remaining };\n }\n }\n\n // Unchanged stays identical, so a caller can tell whether anything happened.\n return { schema: (nullable ? out : node) as T, nullable };\n}\n\n/** `allOf: [X]` is how older schemars wrapped a `$ref` that needed siblings. */\nfunction unwrapAllOf<T extends JsonSchema>(node: T): T {\n const [only] = node.allOf ?? [];\n if (only === undefined || node.allOf?.length !== 1) return node;\n const rest: JsonSchema = { ...node };\n delete rest.allOf;\n return mergeOver(only, rest) as T;\n}\n\n/**\n * The node that says what a field *is*: `$ref` followed, `allOf: [X]` unwrapped and the\n * \"or null\" encoding looked through, repeatedly, because each can hide the next (a `$ref`\n * to an enum inside `anyOf: [{$ref}, null]`).\n *\n * @param node - A property or item schema as written.\n * @param root - The document holding `$defs` (defaults to `node`, for a root schema).\n * @returns The resolved node and whether `null` was among its accepted values. The field's\n * own `default` and `description`, written beside a `$ref`, are kept.\n */\nexport function resolveSchema<T extends JsonSchema>(node: T, root: JsonSchema = node): ResolvedSchema<T> {\n let current = node;\n let nullable = false;\n\n for (let hop = 0; hop < MAX_HOPS; hop++) {\n const followed = unwrapAllOf(derefNode(current, root));\n const stripped = stripNullable(followed);\n nullable ||= stripped.nullable;\n const done = stripped.schema === current;\n current = stripped.schema;\n if (done) break;\n }\n return { schema: current, nullable };\n}\n\n/**\n * Humanise `normal_dirs` into `Normal dirs`, and use a title only when a human chose it.\n *\n * pydantic emits a `title` for every field whether or not anyone wrote one, and its\n * generated form is Title Case — `Csv Path`, `Defect Type From Dir` — which reads like a\n * spreadsheet header rather than a form label. So a title is used only when it is *not*\n * the one pydantic would have generated, which is exactly when a human chose it.\n *\n * Read from the *unresolved* node on purpose. Dereferencing pulls in the type's own title,\n * so a resolved `color` field would be labelled \"ColorMode\".\n *\n * @param name - The property key.\n * @param node - The property's schema as written (not resolved).\n * @returns The label.\n */\nexport function labelFor(name: string, node: JsonSchema): string {\n const words = name.split(\"_\");\n const generated = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(\" \");\n if (node.title && node.title !== generated) return node.title;\n\n const spaced = words.join(\" \");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n","/**\n * Turning a JSON Schema into a form, and a form back into options.\n *\n * An options model — a plugin's config, an algorithm's parameters — is meant to *drive*\n * the UI form rather than have the form hardcoded and the schema's defaults merely hoped\n * to agree with it. That stops being survivable the moment an option is *required* and\n * nobody can type it.\n *\n * The logic lives here rather than in the component because it is where the decisions\n * are: what control a schema node deserves, what an empty box means, and when a value is\n * worth sending at all. Rendering is the easy half.\n *\n * Only the shapes pydantic (or an equivalent JSON Schema generator) actually emits are\n * handled. A node this does not recognise becomes a JSON textarea rather than\n * disappearing — a caller can always express what the model accepts, even where the form\n * has nothing prettier to offer.\n *\n * ## Two things worth reading before touching `kindOf`\n *\n * `enum` has to be tested *before* `type`: `Literal[\"small\", \"medium\"]` emits `enum`\n * *alongside* `type: \"string\"`, and testing type first turns a closed set into a free text\n * box whose placeholder is the only hint of what is accepted. A `StrEnum` is worse —\n * pydantic emits it as `{\"$ref\": \"#/$defs/ColorMode\"}` with the default and description as\n * siblings, and `$ref` is not in the type at all, so it falls through every branch to a\n * JSON textarea unless `$defs` is resolved first.\n *\n * Numeric bounds are the same story: a field can carry `minimum`/`maximum` in the schema,\n * and a control that ignores them turns an out-of-range value into a backend rejection\n * reported nowhere near the field that caused it.\n */\n\nimport { labelFor, resolveSchema } from \"./schemaNode\";\n\n/** The subset of JSON Schema that pydantic (or an equivalent generator) emits for an options model. */\nexport type SchemaNode = {\n type?: string;\n title?: string;\n description?: string;\n default?: unknown;\n items?: SchemaNode;\n anyOf?: SchemaNode[];\n additionalProperties?: SchemaNode | boolean;\n /** A nested model's own fields. Recognised only so such a node is not mistaken for one\n * of the shapes above; it still renders as a JSON textarea. */\n properties?: Record<string, SchemaNode>;\n enum?: unknown[];\n $ref?: string;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n multipleOf?: number;\n /** The schema's own answer to \"does the caller have to think about this?\" — pydantic's\n * `json_schema_extra={\"x-primary\": True}`. Overrides the default-based guess in both\n * directions; a required field is primary regardless. */\n \"x-primary\"?: boolean;\n};\n\n/**\n * An options model's JSON Schema, as pydantic or schemars emits it for a whole model: the\n * top-level object whose `properties` become the form's fields.\n */\nexport type OptionsSchema = {\n properties?: Record<string, SchemaNode>;\n required?: string[];\n /** Where an `Enum` or a nested model lands. Pydantic never inlines those. */\n $defs?: Record<string, SchemaNode>;\n};\n\n/** Which control a field is rendered as — decided from its schema node by `describeFields`. */\nexport type FieldKind =\n | \"text\"\n | \"number\"\n | \"boolean\"\n | \"string-list\"\n | \"json\"\n /** A closed set, few enough to show all at once. */\n | \"choice-inline\"\n /** A closed set, too many to show at once. */\n | \"choice\";\n\n/** One entry of a closed set: the value as sent (stringified) and the label as shown. */\nexport type ChoiceOption = { value: string; label: string };\n\n/**\n * Everything the form needs to render one field, derived once from the schema by\n * `describeFields` so the component makes no decisions of its own.\n */\nexport type FieldSpec = {\n name: string;\n label: string;\n description: string | null;\n kind: FieldKind;\n required: boolean;\n /** Rendered into the empty control as a hint, never submitted on the caller's behalf. */\n placeholder: string;\n /** What applies when the field is left empty. Shown, not sent. */\n fallback: unknown;\n /** Behind a disclosure: there is already a working answer for this one. */\n advanced: boolean;\n /** The closed set, in schema order. Empty for every kind but the two choices. */\n options: ChoiceOption[];\n /** True when a choice's values are numbers, so the chosen one is sent as one. */\n numeric: boolean;\n /** Bounds the control can enforce. `\"any\"` step frees a float from the default of 1. */\n min?: number;\n max?: number;\n step?: number | \"any\" | undefined;\n /** The bounds as a reader should see them, exclusive ones included. */\n range: string | null;\n};\n\n/**\n * The node that says what this field *is*, looked through `$ref` and \"or null\" encodings\n * by the same resolver `SchemaValueForm` reads schemas with (see `schemaNode.ts`).\n *\n * Both sides of the null-unwrap can hold the `$ref`: a plain `ColorMode` is a bare\n * `$ref`, while an `Optional[ColorMode]` hides one inside `anyOf`.\n */\nfunction resolve(node: SchemaNode, root: OptionsSchema): SchemaNode {\n return resolveSchema(node, root).schema;\n}\n\nfunction kindOf(resolved: SchemaNode, root: OptionsSchema): FieldKind {\n // Before `type`, always: a `Literal` carries both, and the closed set is the stronger\n // statement of the two.\n if (Array.isArray(resolved.enum) && resolved.enum.length > 0) {\n return resolved.enum.length <= 3 ? \"choice-inline\" : \"choice\";\n }\n if (resolved.type === \"boolean\") return \"boolean\";\n if (resolved.type === \"integer\" || resolved.type === \"number\") return \"number\";\n if (resolved.type === \"string\") return \"text\";\n if (resolved.type === \"array\" && resolve(resolved.items ?? {}, root).type === \"string\") {\n return \"string-list\";\n }\n return \"json\";\n}\n\n/**\n * Which options a caller has to think about, and which already have an answer.\n *\n * The schema says this without anyone maintaining a second list: a field whose default is\n * *empty* — `[]`, `null`, `\"\"`, or absent entirely — is one nothing can do anything useful\n * with until it is filled in. A field with a real default already works, and someone\n * filling in the form should not have to read past nine vocabulary options to answer the\n * question that actually needs an answer.\n */\nfunction isAdvanced(node: SchemaNode): boolean {\n const fallback = node.default;\n if (fallback === undefined || fallback === null) return false;\n if (Array.isArray(fallback)) return fallback.length > 0;\n if (fallback === \"\") return false;\n if (typeof fallback === \"object\") return Object.keys(fallback).length > 0;\n return true;\n}\n\n/**\n * A schema that marks its decisions says so with `x-primary`; one that does not is read by\n * its defaults. The guess works for an adapter, whose open questions have empty defaults,\n * and fails for a model's hyperparameters, where *every* field has a working default and the\n * two that matter are indistinguishable from the fifteen that do not.\n *\n * Read from the raw node first: a `$ref` field carries its extras beside the reference.\n */\nfunction isPrimary(node: SchemaNode, resolved: SchemaNode): boolean {\n const hint = node[\"x-primary\"] ?? resolved[\"x-primary\"];\n if (hint !== undefined) return hint;\n return !isAdvanced(resolved);\n}\n\n/** Raw control state: what the operator chose, not what will be sent. */\nexport type RawValues = Record<string, string | boolean>;\n\n/**\n * A value as a person reads it: scalars as themselves, anything structured as JSON rather\n * than `[object Object]`.\n */\nexport function displayValue(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return value.toString();\n return JSON.stringify(value) ?? \"\";\n}\n\nfunction placeholderFor(kind: FieldKind, fallback: unknown): string {\n if (kind === \"string-list\") {\n return Array.isArray(fallback) && fallback.length > 0 ? fallback.join(\", \") : \"a, b, c\";\n }\n if (kind === \"json\") return \"{}\";\n return displayValue(fallback);\n}\n\n/** `rgb` reads better as `Rgb` in a picker, but `bilinear` must not become `Bi Linear`. */\nfunction optionLabel(value: unknown): string {\n const text = String(value);\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\nfunction optionsFor(resolved: SchemaNode, kind: FieldKind): ChoiceOption[] {\n if (kind !== \"choice\" && kind !== \"choice-inline\") return [];\n return (resolved.enum ?? []).map((value) => ({\n value: String(value),\n label: optionLabel(value),\n }));\n}\n\n/** The bounds as prose, keeping the distinction the HTML control cannot express. */\nfunction rangeOf(resolved: SchemaNode): string | null {\n const parts: string[] = [];\n if (resolved.minimum !== undefined) parts.push(`≥ ${resolved.minimum}`);\n else if (resolved.exclusiveMinimum !== undefined) parts.push(`> ${resolved.exclusiveMinimum}`);\n if (resolved.maximum !== undefined) parts.push(`≤ ${resolved.maximum}`);\n else if (resolved.exclusiveMaximum !== undefined) parts.push(`< ${resolved.exclusiveMaximum}`);\n return parts.length > 0 ? parts.join(\", \") : null;\n}\n\nfunction stepOf(resolved: SchemaNode): number | \"any\" | undefined {\n if (resolved.multipleOf !== undefined) return resolved.multipleOf;\n if (resolved.type === \"integer\") return 1;\n // A number input steps by 1 unless told otherwise, which marks a learning rate of 0.0001\n // invalid and refuses to submit it.\n return \"any\";\n}\n\n/**\n * Derive the form's fields from an options schema, in schema order.\n *\n * Resolves `$ref`s into `$defs`, looks through `anyOf: [T, null]`, picks a control per node\n * (see `FieldKind`), and folds a field under \"Advanced\" when it is optional and its default\n * already works — unless the schema says otherwise with `\"x-primary\"`.\n *\n * @param schema - The model's JSON Schema (draft 2020-12, as pydantic or schemars emit it).\n * @returns One `FieldSpec` per property; empty for a model with no options.\n */\nexport function describeFields(schema: OptionsSchema): FieldSpec[] {\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties ?? {}).map(([name, node]) => {\n const resolved = resolve(node, schema);\n const kind = kindOf(resolved, schema);\n const numeric = (kind === \"choice\" || kind === \"choice-inline\") && (resolved.type === \"integer\" || resolved.type === \"number\");\n\n return {\n name,\n // From the raw node: the resolved one carries the enum type's title, not the field's.\n label: labelFor(name, node),\n description: node.description ?? resolved.description ?? null,\n kind,\n required: required.has(name),\n fallback: resolved.default,\n placeholder: placeholderFor(kind, resolved.default),\n advanced: !required.has(name) && !isPrimary(node, resolved),\n options: optionsFor(resolved, kind),\n numeric,\n ...(kind === \"number\"\n ? {\n min: resolved.minimum ?? resolved.exclusiveMinimum,\n max: resolved.maximum ?? resolved.exclusiveMaximum,\n step: stepOf(resolved),\n }\n : {}),\n range: kind === \"number\" ? rangeOf(resolved) : null,\n };\n });\n}\n\n/**\n * The controls' starting state.\n *\n * Text, list and choice controls start **empty even when the schema has a default**, and\n * that is deliberate: a pre-filled box says \"this is your value\" when what is true is \"this\n * is what happens if you say nothing\". Pre-filling would also mean every run sent every\n * default back, so a later change to a default would silently not reach anyone who had\n * once opened the form. The default is shown as the placeholder instead — and for a\n * segmented control, as the segment already highlighted.\n *\n * Booleans are the exception — a checkbox has no empty state, so it starts at the\n * default and is always sent.\n */\nexport function initialValues(fields: FieldSpec[]): RawValues {\n const values: RawValues = {};\n for (const field of fields) {\n values[field.name] = field.kind === \"boolean\" ? field.fallback === true : \"\";\n }\n return values;\n}\n\n/**\n * Build the options object to send.\n *\n * An untouched control contributes **nothing**, so the receiving side's own default\n * applies and stays the single definition of it. That is what keeps a default from\n * existing twice, once here and once wherever it is enforced, with the two free to drift.\n */\nexport function toOptions(fields: FieldSpec[], values: RawValues): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n for (const field of fields) {\n const raw = values[field.name];\n\n if (field.kind === \"boolean\") {\n // Always sent: a checkbox cannot express \"unset\", so leaving it out would make its\n // rendered state and the value in force disagree whenever the default is `true`.\n options[field.name] = raw === true;\n continue;\n }\n\n const text = typeof raw === \"string\" ? raw.trim() : \"\";\n if (text === \"\") continue;\n\n switch (field.kind) {\n case \"string-list\":\n options[field.name] = text\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n break;\n case \"number\": {\n const parsed = Number(text);\n if (Number.isFinite(parsed)) options[field.name] = parsed;\n break;\n }\n case \"choice\":\n case \"choice-inline\": {\n // `Literal[1, 2, 3]` is a closed set whose members are numbers; the control can\n // only hand back a string, so the schema's own type decides what is sent.\n if (!field.numeric) {\n options[field.name] = text;\n break;\n }\n const parsed = Number(text);\n if (Number.isFinite(parsed)) options[field.name] = parsed;\n break;\n }\n case \"json\":\n try {\n options[field.name] = JSON.parse(text);\n } catch {\n // Left out rather than sent as a string: the receiving side would reject it with\n // a less useful message than the one `jsonErrors` puts next to the field.\n }\n break;\n default:\n options[field.name] = text;\n }\n }\n\n return options;\n}\n\n/** How many options the operator has actually changed, for the tab that hides them. */\nexport function overrideCount(fields: FieldSpec[], values: RawValues): number {\n const initial = initialValues(fields);\n return fields.filter((field) => values[field.name] !== initial[field.name]).length;\n}\n\n/** Which JSON fields do not parse, so the form can say so before the run starts. */\nexport function jsonErrors(fields: FieldSpec[], values: RawValues): string[] {\n return fields\n .filter((field) => field.kind === \"json\")\n .filter((field) => {\n const raw = values[field.name];\n if (typeof raw !== \"string\" || raw.trim() === \"\") return false;\n try {\n JSON.parse(raw);\n return false;\n } catch {\n return true;\n }\n })\n .map((field) => field.label);\n}\n\n/** Required fields the operator has not filled in. Blocks the run. */\nexport function missingRequired(fields: FieldSpec[], values: RawValues): string[] {\n return fields\n .filter((field) => field.required)\n .filter((field) => {\n const raw = values[field.name];\n if (typeof raw === \"boolean\") return false;\n return (raw ?? \"\").trim() === \"\";\n })\n .map((field) => field.label);\n}\n\n/**\n * Fields whose typed value is outside the bounds the schema states.\n *\n * Native `min`/`max` stop the spinner and mark the input invalid, but nothing stops a\n * paste, so the check is repeated here where it can block the button.\n */\nexport function outOfRange(fields: FieldSpec[], values: RawValues): string[] {\n return fields\n .filter((field) => field.kind === \"number\")\n .filter((field) => {\n const raw = values[field.name];\n if (typeof raw !== \"string\" || raw.trim() === \"\") return false;\n const parsed = Number(raw);\n if (!Number.isFinite(parsed)) return true;\n if (field.min !== undefined && parsed < field.min) return true;\n if (field.max !== undefined && parsed > field.max) return true;\n return false;\n })\n .map((field) => field.label);\n}\n","/**\n * An options form, generated from a JSON Schema.\n *\n * Adding an adapter, a model, or a measurement method costs a config module and a registry\n * entry, and *nothing here* — that is the point of generating the form from the schema\n * instead of hardcoding it. Every decision about which control a field deserves lives in\n * `api/schemaForm.ts`; this file only renders.\n *\n * Two behaviours are worth knowing while reading the markup:\n *\n * * An empty control means **unset**, and the caller's own default applies. The default\n * is shown — as a placeholder, as the pre-highlighted segment, or as the picker's\n * leading entry — so a reader can see what happens if they say nothing, without that\n * value being claimed as their choice.\n * * A field the schema requires is marked, and the caller blocks the run on it.\n *\n * The layout is a two-column grid: a form of eight numeric parameters, each a full-width\n * control over a full-width description, runs to screens of scrolling for a form that\n * often needs nothing touched at all. Fields whose value is genuinely wide — a list, a\n * JSON object, a statement with a switch — still span both columns.\n */\n\nimport { Disclosure, Field, NumberInput, SegmentedControl, Select, Switch, Textarea, Input } from \"@vitavision/ui\";\nimport { displayValue, type FieldSpec, type RawValues } from \"../api/schemaForm\";\n\n/**\n * Which kinds are worth a full row. Everything else pairs up.\n *\n * A JSON object needs the width to be editable at all, and a switch reads as a sentence\n * with its explanation beside it. A comma-separated list does *not* qualify: three of them\n * in a row can run as tall as the layout this rule exists to avoid.\n */\nconst WIDE: ReadonlySet<FieldSpec[\"kind\"]> = new Set([\"json\", \"boolean\"]);\n\n/**\n * An options form rendered from `describeFields(schema)`: primary fields first, the rest\n * folded under \"Advanced\", each with the control its schema node calls for.\n *\n * Controlled: `values` holds the raw control values (strings, or booleans for switches),\n * and an empty string means \"unset — the schema's default applies\". Turn them into the\n * options to send with `toOptions`, and gate a run on `missingRequired`, `outOfRange` and\n * `jsonErrors`.\n */\nexport function SchemaForm({ fields, values, onChange }: { fields: FieldSpec[]; values: RawValues; onChange: (next: RawValues) => void }) {\n if (fields.length === 0) {\n return <p className=\"text-sm text-fg-muted\">This plugin takes no options.</p>;\n }\n\n const set = (name: string, value: string | boolean) => onChange({ ...values, [name]: value });\n const render = (field: FieldSpec) => (\n <SchemaField key={field.name} field={field} value={values[field.name] ?? \"\"} onChange={(value) => set(field.name, value)} />\n );\n\n const primary = fields.filter((field) => !field.advanced);\n const advanced = fields.filter((field) => field.advanced);\n\n // Where nothing is required — the normal shape of a model's own hyperparameters, as\n // against an adapter's \"which folder holds the good images\" — there is nothing to fold\n // away from. Hiding every field behind a disclosure would leave a box containing only a\n // disclosure, so they simply render.\n if (primary.length === 0) {\n return <Grid>{advanced.map(render)}</Grid>;\n }\n\n return (\n <div className=\"flex flex-col gap-4\">\n <Grid>{primary.map(render)}</Grid>\n {advanced.length > 0 && (\n <Disclosure summary=\"Advanced\" count={advanced.length}>\n <Grid>{advanced.map(render)}</Grid>\n </Disclosure>\n )}\n </div>\n );\n}\n\nfunction Grid({ children }: { children: React.ReactNode }) {\n return <div className=\"grid grid-cols-1 gap-x-5 gap-y-4 sm:grid-cols-2\">{children}</div>;\n}\n\nfunction SchemaField({\n field,\n value,\n onChange,\n}: {\n field: FieldSpec;\n value: string | boolean;\n onChange: (value: string | boolean) => void;\n}) {\n const span = WIDE.has(field.kind) ? \"sm:col-span-2\" : undefined;\n\n // A switch reads as a statement and carries its own label, rather than sitting under one.\n // It is also the one control with no \"unset\" position.\n if (field.kind === \"boolean\") {\n return (\n <div className={span}>\n <Switch checked={value === true} onCheckedChange={onChange} label={field.label} description={field.description} />\n </div>\n );\n }\n\n const text = typeof value === \"string\" ? value : \"\";\n const fallback = field.fallback === undefined || field.fallback === null ? undefined : displayValue(field.fallback);\n\n if (field.kind === \"choice-inline\") {\n return (\n <Field as=\"group\" label={field.label} description={field.description} required={field.required} className={span}>\n <SegmentedControl aria-label={field.label} value={text} defaultValue={fallback} options={field.options} onValueChange={onChange} />\n </Field>\n );\n }\n\n if (field.kind === \"choice\") {\n return (\n <Field as=\"group\" label={field.label} description={field.description} required={field.required} className={span}>\n <Select\n aria-label={field.label}\n value={text}\n onValueChange={onChange}\n options={field.options}\n placeholder={fallback === undefined ? \"Choose…\" : `Default · ${fallback}`}\n unsetLabel={fallback === undefined ? undefined : `Default · ${fallback}`}\n />\n </Field>\n );\n }\n\n return (\n <Field\n label={field.label}\n description={field.kind === \"string-list\" ? [field.description, \"Comma-separated.\"].filter(Boolean).join(\" \") : field.description}\n required={field.required}\n annotation={field.range}\n className={span}\n >\n {field.kind === \"json\" ? (\n <Textarea\n mono\n rows={2}\n aria-label={field.label}\n placeholder={field.placeholder}\n value={text}\n onChange={(event) => onChange(event.target.value)}\n />\n ) : field.kind === \"number\" ? (\n <NumberInput\n aria-label={field.label}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n step={field.step}\n value={text}\n onChange={(event) => onChange(event.target.value)}\n />\n ) : (\n <Input\n className=\"font-mono\"\n aria-label={field.label}\n placeholder={field.placeholder}\n value={text}\n onChange={(event) => onChange(event.target.value)}\n />\n )}\n </Field>\n );\n}\n","/**\n * Reading and writing a JSON value by dot path, without mutating it.\n *\n * A form edits one leaf of a value it does not own: the caller holds the value, the form\n * reports the next one. So an edit must produce a new root that shares every untouched\n * subtree with the old one (cheap to compare, safe to hold in state) and must leave the old\n * root exactly as it was.\n *\n * A path is dot-separated keys, with array indices as numbers: `solver.max_iters`,\n * `cameras.0.id`. A key that itself contains a dot cannot be addressed; the Rust and\n * Python configs these forms are for do not have them.\n */\n\nconst INDEX = /^(0|[1-9]\\d*)$/;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Split a dot path into its segments.\n *\n * @param path - `a.b.0`, or `\"\"` for the root.\n * @returns `[\"a\", \"b\", \"0\"]`, or `[]` for the root.\n */\nexport function splitPath(path: string): string[] {\n return path === \"\" ? [] : path.split(\".\");\n}\n\n/**\n * Join a parent path and a key.\n *\n * @param parent - A dot path; `\"\"` is the root.\n * @param key - A property key or an array index.\n * @returns The child's path.\n */\nexport function joinPath(parent: string, key: string): string {\n return parent === \"\" ? key : `${parent}.${key}`;\n}\n\n/**\n * Read the value at a path.\n *\n * @param value - The root value.\n * @param path - Dot path; `\"\"` is the root itself.\n * @returns What is there, or `undefined` where any step of the path is missing.\n */\nexport function getAtPath(value: unknown, path: string): unknown {\n let current = value;\n for (const segment of splitPath(path)) {\n if (Array.isArray(current)) {\n current = INDEX.test(segment) ? (current as unknown[])[Number(segment)] : undefined;\n } else if (isRecord(current) && Object.hasOwn(current, segment)) {\n current = current[segment];\n } else {\n return undefined;\n }\n }\n return current;\n}\n\nfunction setIn(value: unknown, segments: readonly string[], depth: number, next: unknown): unknown {\n const segment = segments[depth];\n if (segment === undefined) return next;\n\n const isIndex = INDEX.test(segment);\n if (Array.isArray(value) || (!isRecord(value) && isIndex)) {\n if (!isIndex) return value;\n const list = Array.isArray(value) ? (value as unknown[]) : [];\n const index = Number(segment);\n const updated = setIn(list[index], segments, depth + 1, next);\n if (updated === undefined) {\n // Removing an element; setting a hole is not JSON.\n return index < list.length ? list.filter((_, i) => i !== index) : value;\n }\n if (Object.is(updated, list[index])) return value;\n const copy = list.slice();\n copy[index] = updated;\n return copy;\n }\n\n const record = isRecord(value) ? value : {};\n const has = Object.hasOwn(record, segment);\n const updated = setIn(has ? record[segment] : undefined, segments, depth + 1, next);\n if (updated === undefined) {\n if (!has) return value;\n const copy = { ...record };\n delete copy[segment];\n return copy;\n }\n if (has && Object.is(updated, record[segment])) return value;\n return { ...record, [segment]: updated };\n}\n\n/**\n * Write a value at a path, immutably.\n *\n * Every subtree off the path is shared with the input, the input is never touched, and\n * setting what is already there returns the input itself. Containers that do not exist are\n * created (an array before an index, an object before a key). Keys the path does not\n * mention — including ones a schema does not know about — are kept.\n *\n * @param value - The root value.\n * @param path - Dot path; `\"\"` replaces the root.\n * @param next - The new value. `undefined` removes the key (or array element) instead.\n * @returns The new root.\n */\nexport function setAtPath(value: unknown, path: string, next: unknown): unknown {\n return setIn(value, splitPath(path), 0, next);\n}\n","/**\n * Reading a schema as the shape of a *value*: what a node is, which fields it has, and\n * what a fresh one looks like.\n *\n * `SchemaForm` asks \"which control does this option deserve?\". `SchemaValueForm` asks the\n * deeper question — \"what can this value be, all the way down?\" — and the answer has to\n * cover what Rust's serde does to enums:\n *\n * - a **plain enum** is `oneOf` of `{ const }`, or `enum`;\n * - an **externally tagged** enum is `\"None\"` for a unit variant and `{ \"Huber\": { … } }`\n * (or `{ \"Fixed\": 2 }`, a newtype) for a variant that carries data;\n * - an **internally tagged** enum is an object whose `kind` (or any property that is a\n * `const` in every variant) names the variant.\n *\n * Everything here is pure: the component only renders what these functions decide.\n */\n\nimport { getAtPath, splitPath } from \"./valuePath\";\nimport { resolveSchema, type JsonSchema } from \"./schemaNode\";\n\n/** A primitive an enum can hold. */\nexport type EnumValue = string | number | boolean;\n\n/** One value of a closed set. */\nexport interface EnumOption {\n /** The value as stored. */\n value: EnumValue;\n /** The label as shown: the variant's `title`, else the value. */\n label: string;\n /** The variant's own description (a `oneOf` entry's), if it has one. */\n description?: string | undefined;\n}\n\n/** One field of an object: its key, its schema as written, and whether it must be present. */\nexport interface FieldInfo {\n /** The property key. */\n key: string;\n /** The property's schema as written (a `$ref` is not followed). */\n schema: JsonSchema;\n /** Whether the object's `required` lists the key. */\n required: boolean;\n}\n\n/** A variant of an internally tagged enum. */\nexport interface TaggedVariant {\n /** The discriminator's value for this variant. */\n tag: string;\n /** The variant's `title`, else the tag. */\n label: string;\n /** The variant's description. */\n description?: string | undefined;\n /** The variant's object schema, resolved. */\n schema: JsonSchema;\n /** The variant's fields, without the discriminator. */\n fields: FieldInfo[];\n}\n\n/** A variant of an externally tagged enum. */\nexport interface ExternalVariant {\n /** The variant name: the string for a unit variant, the sole key for one with data. */\n tag: string;\n /** The variant's `title`, else the tag. */\n label: string;\n /** The variant's description. */\n description?: string | undefined;\n /** What the variant carries (a struct's fields, or a newtype's one value); none for a unit variant. */\n payload: JsonSchema | undefined;\n}\n\n/** What a schema node is, as far as a form is concerned. */\nexport type SchemaShape =\n /** A struct: its fields in schema order. */\n | { kind: \"object\"; fields: FieldInfo[] }\n | { kind: \"string\" }\n | { kind: \"integer\" }\n | { kind: \"number\" }\n | { kind: \"boolean\" }\n /** A closed set of primitives: `enum`, `const`, or `oneOf` of `{ const }`. */\n | { kind: \"enum\"; options: EnumOption[] }\n /** An enum whose variants are objects named by a shared `const` property. */\n | { kind: \"tagged\"; discriminator: string; variants: TaggedVariant[] }\n /** A serde externally tagged enum. */\n | { kind: \"external\"; variants: ExternalVariant[] }\n /** An array of plain strings. */\n | { kind: \"string-list\"; item: JsonSchema }\n /** A fixed-length array: `prefixItems`, or `minItems === maxItems` of numbers or objects. */\n | { kind: \"tuple\"; items: JsonSchema[] }\n /** Anything else: edited as JSON. */\n | { kind: \"json\" };\n\ntype TaggedShape = Extract<SchemaShape, { kind: \"tagged\" }>;\ntype ExternalShape = Extract<SchemaShape, { kind: \"external\" }>;\n\n/** The longest fixed-length array shown as a row of cells rather than as JSON. */\nconst MAX_TUPLE = 32;\n/** Discriminator names tried first; any other shared `const` property works too. */\nconst PREFERRED_DISCRIMINATORS = [\"kind\", \"type\", \"tag\", \"variant\"];\n/** Recursion limit for seeding a value from a self-referential schema. */\nconst MAX_DEPTH = 8;\n\nfunction isPrimitive(value: unknown): value is EnumValue {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction fieldsOf(schema: JsonSchema, omit?: string): FieldInfo[] {\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties ?? {})\n .filter(([key]) => key !== omit)\n .map(([key, property]) => ({ key, schema: property, required: required.has(key) }));\n}\n\n/** The primitives a `const` / `enum` variant fixes, or `undefined` if it is not one. */\nfunction constValues(variant: JsonSchema): EnumValue[] | undefined {\n if (variant.properties !== undefined) return undefined;\n if (Object.hasOwn(variant, \"const\")) return isPrimitive(variant.const) ? [variant.const] : undefined;\n if (Array.isArray(variant.enum) && variant.enum.length > 0 && variant.enum.every(isPrimitive)) {\n return variant.enum;\n }\n return undefined;\n}\n\nfunction constString(property: JsonSchema | undefined, root: JsonSchema): string | undefined {\n if (property === undefined) return undefined;\n const [value] = constValues(resolveSchema(property, root).schema) ?? [];\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction classifyTagged(variants: JsonSchema[], root: JsonSchema): TaggedShape | undefined {\n if (!variants.every((variant) => variant.properties !== undefined)) return undefined;\n const [first] = variants;\n const keys = Object.keys(first?.properties ?? {});\n const candidates = [\n ...PREFERRED_DISCRIMINATORS.filter((key) => keys.includes(key)),\n ...keys.filter((key) => !PREFERRED_DISCRIMINATORS.includes(key)),\n ];\n\n for (const discriminator of candidates) {\n const tags = variants.map((variant) => constString(variant.properties?.[discriminator], root));\n if (!tags.every((tag): tag is string => tag !== undefined)) continue;\n if (new Set(tags).size !== tags.length) continue;\n return {\n kind: \"tagged\",\n discriminator,\n variants: variants.map((variant, index) => ({\n tag: tags[index] ?? \"\",\n label: variant.title ?? tags[index] ?? \"\",\n description: variant.description,\n schema: variant,\n fields: fieldsOf(variant, discriminator),\n })),\n };\n }\n return undefined;\n}\n\nfunction classifyExternal(variants: JsonSchema[]): ExternalShape | undefined {\n const out: ExternalVariant[] = [];\n for (const variant of variants) {\n const units = constValues(variant);\n if (units !== undefined) {\n if (!units.every((unit) => typeof unit === \"string\")) return undefined;\n for (const unit of units) {\n out.push({ tag: String(unit), label: variant.title ?? String(unit), description: variant.description, payload: undefined });\n }\n continue;\n }\n const keys = Object.keys(variant.properties ?? {});\n const [tag] = keys;\n const payload = tag === undefined ? undefined : variant.properties?.[tag];\n if (keys.length !== 1 || tag === undefined || payload === undefined || variant.additionalProperties === true) {\n return undefined;\n }\n out.push({ tag, label: variant.title ?? tag, description: variant.description, payload });\n }\n return new Set(out.map((variant) => variant.tag)).size === out.length ? { kind: \"external\", variants: out } : undefined;\n}\n\nfunction classifyUnion(branches: JsonSchema[], root: JsonSchema): SchemaShape {\n const variants = branches.map((branch) => resolveSchema(branch, root).schema);\n\n const options: EnumOption[] = [];\n for (const variant of variants) {\n for (const value of constValues(variant) ?? []) {\n options.push({ value, label: variant.title ?? String(value), description: variant.description });\n }\n }\n if (variants.every((variant) => constValues(variant) !== undefined)) return { kind: \"enum\", options };\n\n return classifyTagged(variants, root) ?? classifyExternal(variants) ?? { kind: \"json\" };\n}\n\nfunction classifyArray(schema: JsonSchema, root: JsonSchema): SchemaShape {\n if (schema.prefixItems !== undefined && schema.prefixItems.length > 0) {\n return { kind: \"tuple\", items: schema.prefixItems };\n }\n const items = typeof schema.items === \"object\" ? schema.items : undefined;\n if (items === undefined) return { kind: \"json\" };\n\n const item = resolveSchema(items, root).schema;\n const itemShape = classify(item, root);\n if (itemShape.kind === \"string\") return { kind: \"string-list\", item: items };\n\n const count = schema.minItems;\n const fixed = count !== undefined && count === schema.maxItems && count >= 1 && count <= MAX_TUPLE;\n if (fixed && (itemShape.kind === \"number\" || itemShape.kind === \"integer\" || itemShape.kind === \"object\")) {\n return { kind: \"tuple\", items: Array.from({ length: count }, () => items) };\n }\n return { kind: \"json\" };\n}\n\nfunction classify(schema: JsonSchema, root: JsonSchema): SchemaShape {\n if (Array.isArray(schema.enum) && schema.enum.length > 0) {\n return schema.enum.every(isPrimitive)\n ? { kind: \"enum\", options: schema.enum.map((value) => ({ value, label: String(value) })) }\n : { kind: \"json\" };\n }\n if (Object.hasOwn(schema, \"const\")) {\n return isPrimitive(schema.const) ? { kind: \"enum\", options: [{ value: schema.const, label: String(schema.const) }] } : { kind: \"json\" };\n }\n\n const branches = schema.oneOf ?? schema.anyOf;\n if (branches !== undefined && branches.length > 0) return classifyUnion(branches, root);\n\n if (schema.properties !== undefined) {\n const fields = fieldsOf(schema);\n // `{}` closed is a unit struct; `{}` open is a map the form cannot enumerate.\n return fields.length > 0 || schema.additionalProperties === false ? { kind: \"object\", fields } : { kind: \"json\" };\n }\n\n switch (schema.type) {\n case \"string\":\n return { kind: \"string\" };\n case \"integer\":\n return { kind: \"integer\" };\n case \"number\":\n return { kind: \"number\" };\n case \"boolean\":\n return { kind: \"boolean\" };\n case \"array\":\n return classifyArray(schema, root);\n default:\n return { kind: \"json\" };\n }\n}\n\n/**\n * What a schema node is.\n *\n * Looks through `$ref` and the \"or null\" encodings first (see `resolveSchema`), then\n * decides among the shapes of `SchemaShape`. A node it does not recognise is `json`, never\n * an error: a caller can always express what the model accepts.\n *\n * @param node - A schema node as written.\n * @param root - The document holding `$defs` (defaults to `node`).\n * @returns The shape.\n */\nexport function shapeOf(node: JsonSchema, root: JsonSchema = node): SchemaShape {\n return classify(resolveSchema(node, root).schema, root);\n}\n\n/**\n * The variant an internally tagged value is on.\n *\n * @param shape - A `tagged` shape.\n * @param value - The current value.\n * @returns The variant whose tag is in the value's discriminator, or `undefined` for a\n * value that names none (absent, not an object, an unknown tag).\n */\nexport function activeTagged(shape: TaggedShape, value: unknown): TaggedVariant | undefined {\n const tag = isRecord(value) ? value[shape.discriminator] : undefined;\n return typeof tag === \"string\" ? shape.variants.find((variant) => variant.tag === tag) : undefined;\n}\n\n/**\n * The variant an externally tagged value is on.\n *\n * @param shape - An `external` shape.\n * @param value - The current value: the string of a unit variant, or an object with the\n * variant's name as its key.\n * @returns The variant, or `undefined` for a value that names none.\n */\nexport function activeExternal(shape: ExternalShape, value: unknown): ExternalVariant | undefined {\n if (typeof value === \"string\") {\n return shape.variants.find((variant) => variant.payload === undefined && variant.tag === value);\n }\n if (!isRecord(value)) return undefined;\n return shape.variants.find((variant) => variant.payload !== undefined && Object.hasOwn(value, variant.tag));\n}\n\nfunction seedOf(schema: JsonSchema, root: JsonSchema, depth: number, notNull: boolean): unknown {\n const { schema: s, nullable } = resolveSchema(schema, root);\n if (s.default !== undefined && !(notNull && s.default === null)) return s.default;\n if (nullable && !notNull) return null;\n if (depth > MAX_DEPTH) return null;\n\n const shape = classify(s, root);\n switch (shape.kind) {\n case \"enum\":\n return shape.options[0]?.value ?? null;\n case \"string\":\n return \"\";\n case \"boolean\":\n return false;\n case \"integer\":\n case \"number\":\n return seedNumber(s, shape.kind === \"integer\");\n case \"object\": {\n const out: Record<string, unknown> = {};\n for (const field of shape.fields) {\n const hasDefault = resolveSchema(field.schema, root).schema.default !== undefined;\n if (field.required || hasDefault) out[field.key] = seedOf(field.schema, root, depth + 1, false);\n }\n return out;\n }\n case \"tagged\": {\n const [variant] = shape.variants;\n return variant === undefined ? null : seedTagged(shape, variant, root, depth);\n }\n case \"external\": {\n const [variant] = shape.variants;\n return variant === undefined ? null : seedExternal(variant, root, depth);\n }\n case \"tuple\":\n return shape.items.map((item) => seedOf(item, root, depth + 1, false));\n case \"string-list\":\n return [];\n case \"json\": {\n const [first] = s.oneOf ?? s.anyOf ?? [];\n if (first !== undefined) return seedOf(first, root, depth + 1, false);\n if (s.type === \"array\") return [];\n return s.type === \"object\" ? {} : null;\n }\n }\n}\n\nfunction seedNumber(schema: JsonSchema, integer: boolean): number {\n const lower = schema.minimum ?? (schema.format?.startsWith(\"uint\") === true ? 0 : undefined);\n const exclusiveLower = schema.exclusiveMinimum;\n const upper = schema.maximum ?? schema.exclusiveMaximum;\n\n let value = 0;\n if (lower !== undefined && value < lower) value = lower;\n if (exclusiveLower !== undefined && value <= exclusiveLower) {\n value = integer ? exclusiveLower + 1 : upper !== undefined ? (exclusiveLower + upper) / 2 : exclusiveLower + 1;\n }\n if (upper !== undefined && value > upper) value = lower ?? upper;\n return integer ? Math.ceil(value) : value;\n}\n\nfunction seedTagged(shape: TaggedShape, variant: TaggedVariant, root: JsonSchema, depth: number): unknown {\n const body = seedOf(variant.schema, root, depth + 1, false);\n return { ...(isRecord(body) ? body : {}), [shape.discriminator]: variant.tag };\n}\n\nfunction seedExternal(variant: ExternalVariant, root: JsonSchema, depth: number): unknown {\n return variant.payload === undefined ? variant.tag : { [variant.tag]: seedOf(variant.payload, root, depth + 1, false) };\n}\n\n/**\n * A fresh value for a schema.\n *\n * Takes the `default` when there is one (a `default` written beside a `$ref` wins over the\n * target's), `null` for a nullable node, and otherwise builds the value from the shape:\n * an object gets its required fields and the fields that have a default, an enum its first\n * value, a union its first variant, a number the nearest legal value to 0, a string `\"\"`.\n * The result is JSON, and for a schema this package can read, valid against it.\n *\n * @param schema - A schema node.\n * @param root - The document holding `$defs` (defaults to `schema`).\n * @returns The seed value.\n */\nexport function defaultValueForSchema(schema: JsonSchema, root: JsonSchema = schema): unknown {\n return seedOf(schema, root, 0, false);\n}\n\n/**\n * The seed for a node that is switched on from `null`: its default, unless that default is\n * itself `null`, in which case the value the shape implies.\n *\n * @param schema - A schema node.\n * @param root - The document holding `$defs`.\n * @returns A value that is not `null` (for a node that can hold anything else).\n */\nexport function seedNotNull(schema: JsonSchema, root: JsonSchema): unknown {\n return seedOf(schema, root, 0, true);\n}\n\n/**\n * The value for a union after the user picks a variant: the variant's own seed, with its\n * tag in place.\n *\n * @param shape - A `tagged` or `external` shape.\n * @param tag - The chosen variant's tag.\n * @param root - The document holding `$defs`.\n * @returns The new value, or `undefined` if the shape has no such variant.\n */\nexport function seedVariant(shape: TaggedShape | ExternalShape, tag: string, root: JsonSchema): unknown {\n if (shape.kind === \"tagged\") {\n const variant = shape.variants.find((candidate) => candidate.tag === tag);\n return variant === undefined ? undefined : seedTagged(shape, variant, root, 0);\n }\n const variant = shape.variants.find((candidate) => candidate.tag === tag);\n return variant === undefined ? undefined : seedExternal(variant, root, 0);\n}\n\n/** The fields of the shape for the value as it stands (the active variant, for a union). */\nfunction childrenOf(shape: SchemaShape, value: unknown): FieldInfo[] {\n switch (shape.kind) {\n case \"object\":\n return shape.fields;\n case \"tagged\":\n return (activeTagged(shape, value) ?? shape.variants[0])?.fields ?? [];\n case \"external\": {\n const variant = activeExternal(shape, value);\n return variant?.payload === undefined ? [] : [{ key: variant.tag, schema: variant.payload, required: true }];\n }\n case \"tuple\":\n return shape.items.map((schema, index) => ({ key: String(index), schema, required: true }));\n case \"string-list\":\n return Array.isArray(value) ? value.map((_, index) => ({ key: String(index), schema: shape.item, required: true })) : [];\n default:\n return [];\n }\n}\n\n/** The child called `segment`, wherever it is — the active variant first, then any. */\nfunction findChild(shape: SchemaShape, segment: string, value: unknown): FieldInfo | undefined {\n switch (shape.kind) {\n case \"tagged\": {\n const active = activeTagged(shape, value);\n const variants = active === undefined ? shape.variants : [active, ...shape.variants];\n for (const variant of variants) {\n const field = variant.fields.find((candidate) => candidate.key === segment);\n if (field !== undefined) return field;\n }\n return undefined;\n }\n case \"external\": {\n const variant = shape.variants.find((candidate) => candidate.payload !== undefined && candidate.tag === segment);\n return variant?.payload === undefined ? undefined : { key: segment, schema: variant.payload, required: true };\n }\n case \"tuple\": {\n const schema = shape.items[Number(segment)];\n return schema === undefined ? undefined : { key: segment, schema, required: true };\n }\n case \"string-list\":\n return /^\\d+$/.test(segment) ? { key: segment, schema: shape.item, required: true } : undefined;\n default:\n return childrenOf(shape, value).find((candidate) => candidate.key === segment);\n }\n}\n\n/**\n * The field at a dot path.\n *\n * Walks the schema, not the value: a path through a union resolves in the variant the\n * `value` is on if it has the field, else in whichever variant does, so a `UiSchema` path\n * can name a field that is not showing right now.\n *\n * @param schema - The root schema.\n * @param path - Dot path from the root (`solver.robust_loss.Huber.scale`); `\"\"` is the root.\n * @param root - The document holding `$defs` (defaults to `schema`).\n * @param value - The current value, to choose between a union's variants.\n * @returns The field (its schema as written, and whether it is required), or `undefined`\n * where the path leaves the schema.\n */\nexport function fieldAt(schema: JsonSchema, path: string, root: JsonSchema = schema, value?: unknown): FieldInfo | undefined {\n let info: FieldInfo = { key: \"\", schema, required: true };\n let current = value;\n for (const segment of splitPath(path)) {\n const next = findChild(shapeOf(info.schema, root), segment, current);\n if (next === undefined) return undefined;\n info = next;\n current = getAtPath(current, segment);\n }\n return info;\n}\n\n/**\n * The fields that are editable at a path, as the form would list them: an object's fields\n * in schema order, the active variant's fields (without the discriminator) for an internally\n * tagged union, the variant's payload for an externally tagged one, a tuple's positions.\n *\n * @param schema - The root schema.\n * @param path - Dot path from the root; `\"\"` for the root.\n * @param root - The document holding `$defs` (defaults to `schema`).\n * @param value - The current root value, to choose between a union's variants (the first\n * variant when absent).\n * @returns The fields; empty for a leaf or a path outside the schema.\n */\nexport function fieldsAt(schema: JsonSchema, path: string, root: JsonSchema = schema, value?: unknown): FieldInfo[] {\n const info = fieldAt(schema, path, root, value);\n return info === undefined ? [] : childrenOf(shapeOf(info.schema, root), getAtPath(value, path));\n}\n","/**\n * What an app says about a form that the schema cannot: which fields go together, what to\n * call them, and when a different control is wanted.\n *\n * A schema describes the *data*. It rarely knows that `roi_xywh` is four pixels, that three\n * fields belong under \"Detection\", or that `refinement` reads better as a strip of\n * segments than a drop-down. That is layout, and it belongs to the app, not to the Rust\n * struct, so it travels beside the schema as a `UiSchema` instead of inside it.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport type { JsonSchema } from \"./schemaNode\";\n\n/** A titled set of fields, rendered together. */\nexport interface UiGroup {\n /** Stable id, used for keys and test hooks. */\n id: string;\n /** The heading. */\n title: string;\n /**\n * The fields in the group, as dot paths from the form's root: `threshold`, `solver`,\n * `solver.max_iters`. A path to an object brings its whole subtree; a path to a leaf\n * brings only that leaf, and the object's other fields stay in the ungrouped remainder.\n */\n fields: string[];\n /** Fold the group away behind a `Disclosure`. Otherwise it is a `Section`. */\n collapsible?: boolean | undefined;\n /** Whether a collapsible group starts open. Defaults to closed. */\n defaultOpen?: boolean | undefined;\n /** A line of explanation under the heading. */\n hint?: ReactNode;\n}\n\n/** The widgets a field can be forced into with `FieldUi.widget`. */\nexport type FieldWidget = \"number\" | \"text\" | \"select\" | \"segmented\" | \"checkbox\" | \"switch\" | \"json\" | \"tuple-row\" | \"string-list\";\n\n/** Per-field presentation, looked up by the field's dot path. */\nexport interface FieldUi {\n /** The label, instead of the schema's `title` or the humanised key. */\n label?: string | undefined;\n /** Explanation shown in place of the schema's description. */\n hint?: ReactNode;\n /** Do not render the field. Its value is kept as it is. */\n hidden?: boolean | undefined;\n /**\n * The control, instead of the one the schema's shape calls for. A widget that does not\n * fit the field (`segmented` on a number) is ignored.\n */\n widget?: FieldWidget | undefined;\n /** The unit written in the field, instead of the schema's `x-unit`. */\n unit?: string | undefined;\n /** Lower bound the control enforces, instead of the schema's `minimum`. */\n min?: number | undefined;\n /** Upper bound the control enforces, instead of the schema's `maximum`. */\n max?: number | undefined;\n /** Arrow-key step, instead of the schema's `multipleOf` (or 1 for an integer). */\n step?: number | undefined;\n /**\n * Labels for an enum's values and a union's variants, by value or tag:\n * `{ brown_conrady5: \"Brown-Conrady\" }`.\n */\n enumLabels?: Record<string, string> | undefined;\n /** Columns the field takes in the grid. Containers and lists default to the full row. */\n span?: 1 | 2 | undefined;\n /**\n * Where the description goes: `hint` (the default) is an `InfoHint` beside the label,\n * `inline` is a line under the control, `none` drops it.\n */\n descriptionAs?: \"hint\" | \"inline\" | \"none\" | undefined;\n /**\n * Clearing a number input puts the default back (the default, `true`): the schema's\n * non-null `default`, else the nearest legal value for a required field, else — for an\n * optional field with no usable default — nothing, which removes the key (the schema\n * default then applies). With `false` the field is left empty where it can be (an\n * optional field loses its key) and keeps its value where it cannot (a required,\n * non-nullable one). A required nullable field is set to `null`. An optional field is\n * never set to `null` unless `clearTo` says so.\n */\n restoreDefaultOnClear?: boolean | undefined;\n /**\n * For a nullable field, what clearing writes. `\"null\"` writes `null` even when the key is\n * optional — the way to let a user choose `None` for an `Option<T>` whose default is\n * `Some(…)`, since for a serde `#[serde(default)]` field an absent key means the default\n * and `null` means `None`. Left out, clearing an optional field removes the key and\n * clearing a required nullable one writes `null` (see `restoreDefaultOnClear`). It has no\n * effect on a field that is not nullable.\n */\n clearTo?: \"null\" | undefined;\n}\n\n/**\n * App-supplied layout for a `SchemaValueForm`.\n *\n * Paths are dot paths from the root of the *value*: `solver.max_iters`, `sensor.kind`.\n * An array element is its index (`cameras.0.id`), and `*` stands for any index\n * (`cameras.*.id`). For a serde externally-tagged enum the tag is a path segment\n * (`solver.robust_loss.Huber.scale`).\n */\nexport interface UiSchema {\n /**\n * Groups, in order. Fields in a group render under its heading; every visible field not\n * claimed by a group renders after the groups, in schema order.\n */\n groups?: UiGroup[] | undefined;\n /** Per-field presentation, by dot path. */\n fields?: Record<string, FieldUi> | undefined;\n}\n\n/** What `renderField` is given for a field. */\nexport interface RenderFieldContext {\n /** The field's dot path from the root. */\n path: string;\n /** The field's schema with `$ref` and \"or null\" looked through. */\n schema: JsonSchema;\n /** The field's current value; `undefined` where the key is absent. */\n value: unknown;\n /** Replace the field's value (`undefined` removes the key). */\n onChange: (next: unknown) => void;\n /** Whether the whole form is disabled. */\n disabled: boolean;\n}\n\n/**\n * Take over a field. Return `undefined` to let the form's own control render, anything else\n * to render in its place (and in its grid cell, with the field's span).\n */\nexport type RenderField = (context: RenderFieldContext) => ReactNode;\n\nconst NO_UI: FieldUi = {};\n\n/**\n * The presentation for a path: the exact entry, merged over the wildcard entry\n * (`cameras.*.id`) when the path has array indices.\n *\n * @param ui - The app's `UiSchema`, if any.\n * @param path - The field's dot path.\n * @returns The presentation; `{}` where the app said nothing.\n */\nexport function fieldUiAt(ui: UiSchema | undefined, path: string): FieldUi {\n const table = ui?.fields;\n if (table === undefined) return NO_UI;\n const wildcard = path.replaceAll(/(^|\\.)\\d+(?=\\.|$)/g, \"$1*\");\n const general = wildcard === path ? undefined : table[wildcard];\n const exact = table[path];\n if (general === undefined) return exact ?? NO_UI;\n return exact === undefined ? general : { ...general, ...exact };\n}\n","/**\n * Where one JSON value differs from another, by dot path: what a form marks as \"changed from\n * the baseline\".\n *\n * Paths are the ones `getAtPath` reads. A value and its baseline are compared structurally:\n * objects by key (a key missing on one side differs from a key present on the other, even\n * if the present value is `null`), arrays by index when they have the same length, and by\n * the array as a whole when they do not (its elements have no shared identity to match).\n */\n\nimport { joinPath } from \"./valuePath\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The paths at which `current` differs from `baseline`, deepest first-found, in key order.\n *\n * @param current - The value.\n * @param baseline - What it is compared with.\n * @param path - The path of both, for a recursive call; `\"\"` is the root.\n * @returns Each differing path once; `[\"\"]` when the roots are different kinds of value.\n * Empty when the values are equal.\n */\nexport function diffPaths(current: unknown, baseline: unknown, path = \"\"): string[] {\n if (Object.is(current, baseline)) return [];\n if (isRecord(current) && isRecord(baseline)) {\n const keys = [...new Set([...Object.keys(current), ...Object.keys(baseline)])];\n return keys.flatMap((key) => {\n const inCurrent = Object.hasOwn(current, key);\n const inBaseline = Object.hasOwn(baseline, key);\n const child = joinPath(path, key);\n return inCurrent && inBaseline ? diffPaths(current[key], baseline[key], child) : [child];\n });\n }\n if (Array.isArray(current) && Array.isArray(baseline) && current.length === baseline.length) {\n return current.flatMap((entry, index) => diffPaths(entry, baseline[index], joinPath(path, String(index))));\n }\n return [path];\n}\n\n/**\n * How many differing leaves lie at or under each path.\n *\n * @param paths - From `diffPaths`.\n * @returns A map from a path, and each of its ancestors (the root as `\"\"`), to the count of\n * differing paths at or beneath it.\n */\nexport function changeCounts(paths: readonly string[]): Map<string, number> {\n const counts = new Map<string, number>();\n for (const path of paths) {\n let at = path;\n for (;;) {\n counts.set(at, (counts.get(at) ?? 0) + 1);\n if (at === \"\") break;\n const cut = at.lastIndexOf(\".\");\n at = cut < 0 ? \"\" : at.slice(0, cut);\n }\n }\n return counts;\n}\n\n/**\n * A value as the \"was ...\" note shows it: short, one line.\n *\n * @param value - The baseline's value at a field.\n * @param limit - The longest text, in characters; a longer one is cut with an ellipsis. Defaults to 40.\n * @returns `unset` for `undefined`, `none` for `null`, `\"\"` quoted, else the value or its JSON.\n */\nexport function describeValue(value: unknown, limit = 40): string {\n let text: string;\n if (value === undefined) text = \"unset\";\n else if (value === null) text = \"none\";\n else if (typeof value === \"string\") text = value === \"\" ? '\"\"' : value;\n else if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") text = value.toString();\n else text = JSON.stringify(value) ?? \"\";\n return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;\n}\n","/**\n * Descriptions are Markdown (Rustdoc comments, docstrings) and the form shows them as plain\n * text in a hint. This is the conversion.\n */\n\n/** Text and a URL: `[text](url)` shows as `text`. */\nconst LINK = /\\[([^\\]]+)\\]\\([^)]*\\)/g;\n/** Rustdoc intra-doc link: ``[`Foo::bar`]`` shows as `Foo::bar`. */\nconst CODE_LINK = /\\[(`+)([^`]+)\\1\\]/g;\nconst AUTOLINK = /<(https?:\\/\\/[^>\\s]+)>/g;\nconst CODE = /(`+)([^`]+?)\\1/g;\nconst BOLD = /(\\*\\*|__)(?=\\S)(.+?)(?<=\\S)\\1/g;\n/** `*em*`; a lone `*` between spaces (a product) is not emphasis. */\nconst STAR = /(?<![\\\\*])\\*(?=\\S)([^*]+?)(?<=\\S)\\*(?!\\*)/g;\n/** `_em_`, but never inside a word: `snake_case_name` is not emphasis. */\nconst UNDERSCORE = /(?<![\\w\\\\])_(?=\\S)([^_]+?)(?<=\\S)_(?!\\w)/g;\nconst ESCAPE = /\\\\([\\\\`*_{}[\\]()#+\\-.!|<>~])/g;\n\n/**\n * The first paragraph of a Markdown description as plain text, for a one-line hint.\n *\n * Strips emphasis, inline code, links (text kept, URL dropped), Rustdoc intra-doc links and\n * backslash escapes, and joins the paragraph's lines with spaces. `snake_case` and a lone\n * `*` are left alone. Later paragraphs — a Rustdoc `# Example` section, say — are dropped.\n *\n * @param description - A schema `description`, or nothing.\n * @returns Plain text; `\"\"` for no description.\n */\nexport function firstParagraph(description: string | null | undefined): string {\n if (!description) return \"\";\n const [paragraph = \"\"] = description.trim().split(/\\n[ \\t]*\\n/);\n return paragraph\n .replaceAll(/\\s*\\n\\s*/g, \" \")\n .replaceAll(CODE_LINK, \"$2\")\n .replaceAll(LINK, \"$1\")\n .replaceAll(AUTOLINK, \"$1\")\n .replaceAll(CODE, \"$2\")\n .replaceAll(BOLD, \"$2\")\n .replaceAll(STAR, \"$1\")\n .replaceAll(UNDERSCORE, \"$1\")\n .replaceAll(ESCAPE, \"$1\")\n .replaceAll(/\\s+/g, \" \")\n .trim();\n}\n","/**\n * What every node of a `SchemaValueForm` shares: the schema, the value, how to edit it, and\n * the app's layout. One context rather than props threaded through every container, because\n * a field is addressed by its path — it reads its own value and writes its own leaf, and\n * the containers in between need not know.\n */\n\nimport { createContext, use } from \"react\";\n\nimport type { JsonSchema } from \"../../api/schemaNode\";\nimport type { RenderField, UiSchema } from \"../../api/uiSchema\";\n\n/** A message the app attaches to a field, such as a backend's verdict on a value. */\nexport interface FieldMessage {\n /** `error` is announced as an alert and marks the control invalid; `warning` is shown without blocking. */\n severity: \"error\" | \"warning\";\n /** What to tell the person. */\n text: string;\n}\n\n/** The form's comparison with its baseline, computed once per value. */\nexport interface BaselineState {\n /** The value the form compares with. */\n value: unknown;\n /** How many differing leaves lie at or under each path (see `changeCounts`). */\n counts: ReadonlyMap<string, number>;\n}\n\n/** The form's state, for the nodes below it. */\nexport interface FormState {\n /** The root schema, which also holds `$defs`. */\n schema: JsonSchema;\n /** The current root value. */\n value: unknown;\n /** Replace the value at a dot path; `undefined` removes the key. */\n setValue: (path: string, next: unknown) => void;\n /** The app's layout. */\n ui: UiSchema;\n /** Whether every control is disabled. */\n disabled: boolean;\n /** One column, or two on `sm:` and up. */\n columns: 1 | 2;\n /** The app's escape hatch. */\n renderField: RenderField | undefined;\n /** The comparison with the baseline, or `null` when the form has none. */\n baseline: BaselineState | null;\n /** The app's messages, by dot path (`\"\"` is the form as a whole). */\n messages: Readonly<Record<string, FieldMessage | string>> | undefined;\n /** Paths a group has claimed, so the ungrouped remainder skips them. */\n claimed: ReadonlySet<string>;\n}\n\n/** `null` outside a form. */\nexport const FormContext = createContext<FormState | null>(null);\n\n/**\n * True inside a tuple row: cells drop their descriptions and range notes and sit in an\n * auto-fit grid, because a row of four numbers cannot afford a hint line each.\n */\nexport const DenseContext = createContext(false);\n\n/** The enclosing form's state. */\nexport function useForm(): FormState {\n const state = use(FormContext);\n if (state === null) throw new Error(\"A SchemaValueForm field was rendered outside its form.\");\n return state;\n}\n","/**\n * The furniture around a field: the grid it sits in, the cell it takes, and the hint and\n * range note beside its label. Shared by every control so that \"where does the description\n * go\" is decided once.\n */\n\nimport { InfoHint, byDensity, cn, useDensity } from \"@vitavision/ui\";\nimport { use, type ReactNode } from \"react\";\n\nimport { firstParagraph } from \"../../api/firstParagraph\";\nimport type { JsonSchema } from \"../../api/schemaNode\";\nimport type { FieldUi } from \"../../api/uiSchema\";\nimport { DenseContext, useForm } from \"./context\";\n\n/** Everything a control needs to know about its field. */\nexport interface FieldMeta {\n /** The field's dot path from the root. */\n path: string;\n /** The label shown. */\n label: string;\n /** Whether the parent object requires the key. */\n required: boolean;\n /** The schema as written. */\n node: JsonSchema;\n /** The schema with `$ref` and \"or null\" looked through. */\n schema: JsonSchema;\n /** Whether `null` is accepted. */\n nullable: boolean;\n /** The app's presentation for the field. */\n ui: FieldUi;\n}\n\n/**\n * The grid cell a field takes: the full row (`sm:col-span-2`) where it has two columns to\n * span, nothing otherwise.\n *\n * @param columns - The form's column count.\n * @param ui - The field's presentation (its `span` wins).\n * @param fallback - The span for a field the app said nothing about.\n * @returns A Tailwind class, or `undefined`.\n */\nexport function spanClass(columns: 1 | 2, ui: FieldUi, fallback: 1 | 2): string | undefined {\n return columns === 2 && (ui.span ?? fallback) === 2 ? \"sm:col-span-2\" : undefined;\n}\n\n/** The field grid: two columns on `sm:` (or one), or an auto-fit row inside a tuple. */\nexport function Grid({ children }: { children: ReactNode }) {\n const { columns } = useForm();\n const dense = use(DenseContext);\n const density = useDensity();\n return (\n <div\n className={cn(\n \"grid min-w-0\",\n dense\n ? \"grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] gap-2\"\n : cn(byDensity(density, \"gap-x-5 gap-y-4\", \"gap-x-4 gap-y-2.5\"), columns === 2 ? \"grid-cols-1 sm:grid-cols-2\" : \"grid-cols-1\"),\n )}\n >\n {children}\n </div>\n );\n}\n\nfunction present(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n\n/**\n * What a field shows besides its label: the description as an `InfoHint` or as an inline\n * line (or not at all), and the range note, together as the `Field` annotation.\n *\n * @param meta - The field.\n * @param range - The bounds as text, for a number.\n * @returns The hint (for a control that has no annotation slot), the inline description,\n * and the annotation.\n */\nexport function useChrome(\n meta: FieldMeta,\n range: string | null = null,\n): { hint: ReactNode; description: ReactNode; annotation: ReactNode } {\n const dense = use(DenseContext);\n const mode = meta.ui.descriptionAs ?? \"hint\";\n const text: ReactNode = meta.ui.hint ?? firstParagraph(meta.schema.description);\n const shown = !dense && present(text);\n\n const hint = shown && mode === \"hint\" ? <InfoHint label={`About ${meta.label}`}>{text}</InfoHint> : null;\n const description = shown && mode === \"inline\" ? text : undefined;\n const note = dense ? null : range;\n const annotation =\n note !== null || hint !== null ? (\n <span className=\"inline-flex items-center gap-1.5\">\n {note}\n {hint}\n </span>\n ) : undefined;\n return { hint, description, annotation };\n}\n","/**\n * What a field shows beyond its control: whether it differs from the form's baseline (a rule\n * at its edge, a \"changed\" note that says what it was, and a reset), and the app's message\n * for it.\n *\n * The note sits under the control, outside the field's `<label>`: a button inside a label\n * would be part of the control's name. It is the field's description, so a reader hears it\n * with the control.\n */\n\nimport { cn, focusRing } from \"@vitavision/ui\";\nimport { use, type ReactNode } from \"react\";\n\nimport { describeValue } from \"../../api/valueDiff\";\nimport { getAtPath } from \"../../api/valuePath\";\nimport type { FieldMeta } from \"./chrome\";\nimport { DenseContext, useForm, type FieldMessage } from \"./context\";\n\n/** A thin rule in the gutter beside a changed field: a scan cue that is not the only one, since the note says it in words. */\nconst CHANGED_RULE =\n \"relative before:absolute before:-left-2.5 before:top-0.5 before:bottom-0.5 before:w-0.5 before:rounded-full before:bg-signal\";\n\n/** A message as `{ severity, text }`: a bare string is an error. */\nfunction normalise(message: FieldMessage | string | undefined): FieldMessage | undefined {\n if (message === undefined) return undefined;\n return typeof message === \"string\" ? { severity: \"error\", text: message } : message;\n}\n\n/** What a field adds to its `Field` or switch. */\nexport interface FieldExtras {\n /** Classes for the field's root: the rule beside a changed field. */\n className: string | undefined;\n /** Whether the field, or anything under it, differs from the baseline. */\n changed: boolean;\n /** The app's error message for the field. */\n error: string | undefined;\n /** The changed note and the app's warning, to follow the field's description. */\n notes: ReactNode;\n}\n\n/**\n * The baseline comparison and the app's message for one field.\n *\n * @param meta - The field.\n * @returns Its extras; all empty for a form with no baseline and no message.\n */\nexport function useFieldExtras(meta: FieldMeta): FieldExtras {\n const form = useForm();\n // A cell of a tuple row has no room for a note of its own: the rule marks it, and the row's frame carries the reset.\n const dense = use(DenseContext);\n const changes = form.baseline?.counts.get(meta.path) ?? 0;\n const message = normalise(form.messages?.[meta.path]);\n const warning = message?.severity === \"warning\" ? message.text : undefined;\n const notes =\n (changes > 0 && !dense) || warning !== undefined ? (\n <>\n {warning !== undefined && (\n <span data-message=\"warning\" className=\"mt-0.5 block text-warn\">\n {warning}\n </span>\n )}\n {changes > 0 && !dense && <ChangeNote meta={meta} count={changes} />}\n </>\n ) : undefined;\n return {\n className: changes > 0 ? CHANGED_RULE : undefined,\n changed: changes > 0,\n error: message?.severity === \"error\" ? message.text : undefined,\n notes,\n };\n}\n\n/** An error message where the control has no error slot of its own (a switch). */\nexport function ErrorText({ text }: { text: string }) {\n return (\n <span role=\"alert\" data-message=\"error\" className=\"block text-defect\">\n {text}\n </span>\n );\n}\n\n/** A description and the extras' notes, as one `Field` description (`undefined` when both are empty). */\nexport function withNotes(description: ReactNode, notes: ReactNode): ReactNode {\n const has = description !== undefined && description !== null && description !== false && description !== \"\";\n if (!has) return notes;\n return notes === undefined ? (\n description\n ) : (\n <>\n {description}\n {notes}\n </>\n );\n}\n\n/** The \"changed\" marker with what the baseline had, and the button that puts it back. */\nexport function ChangeNote({ meta, count }: { meta: FieldMeta; count: number }) {\n const form = useForm();\n const was = getAtPath(form.baseline?.value, meta.path);\n const composite = typeof was === \"object\" && was !== null;\n return (\n <span data-change-note=\"\" className=\"mt-0.5 flex min-w-0 items-center gap-2 text-[11px] leading-snug\">\n <span className=\"inline-flex shrink-0 items-center gap-1 font-medium text-signal\">\n <span aria-hidden className=\"size-1.5 rounded-full bg-signal\" />\n {composite && count > 1 ? `${count} changed` : \"changed\"}\n </span>\n {!composite && (\n <span className=\"min-w-0 truncate text-fg-muted\">\n was <span className=\"font-mono\">{describeValue(was)}</span>\n </span>\n )}\n <ResetButton meta={meta} />\n </span>\n );\n}\n\n/** Puts a field (or a whole block) back to the baseline's value. */\nexport function ResetButton({ meta, className }: { meta: FieldMeta; className?: string | undefined }) {\n const form = useForm();\n return (\n <button\n type=\"button\"\n data-reset=\"\"\n aria-label={`Reset ${meta.label} to baseline`}\n disabled={form.disabled}\n onClick={() => form.setValue(meta.path, getAtPath(form.baseline?.value, meta.path))}\n className={cn(\n \"-my-1 ml-auto shrink-0 cursor-pointer rounded-control px-1 py-1 font-medium text-fg-muted transition-colors\",\n \"hover:text-fg disabled:cursor-not-allowed disabled:opacity-50\",\n focusRing,\n className,\n )}\n >\n Reset\n </button>\n );\n}\n","/**\n * What a number field accepts: the schema's bounds, a `uint` format's implied floor, and\n * the app's own overrides, in one place so the control and its error message cannot\n * disagree.\n */\n\nimport type { JsonSchema } from \"./schemaNode\";\nimport type { FieldUi } from \"./uiSchema\";\n\n/** The rules for one number field. */\nexport interface NumberSpec {\n /** Whole numbers only (`type: \"integer\"`): `2.5` is rejected, never rounded. */\n integer: boolean;\n /** Inclusive lower bound. */\n min?: number | undefined;\n /** Inclusive upper bound. */\n max?: number | undefined;\n /** Exclusive lower bound. */\n exclusiveMin?: number | undefined;\n /** Exclusive upper bound. */\n exclusiveMax?: number | undefined;\n /** Arrow-key step: the schema's `multipleOf`, 1 for an integer, otherwise `\"any\"`. */\n step: number | \"any\";\n /** The unit shown in the field. */\n unit?: string | undefined;\n}\n\n/**\n * Collect a number field's rules.\n *\n * `format: uint…` (Rust's unsigned widths) means \"at least 0\" even where the schema says\n * nothing else. A bound in `ui` replaces the schema's bound of that side, exclusive form\n * included.\n *\n * @param schema - The field's resolved schema.\n * @param ui - The app's presentation for the field.\n * @returns The rules.\n */\nexport function numberSpec(schema: JsonSchema, ui: FieldUi = {}): NumberSpec {\n const integer = schema.type === \"integer\";\n const floor = schema.format?.startsWith(\"uint\") === true ? 0 : undefined;\n return {\n integer,\n min: ui.min ?? schema.minimum ?? floor,\n max: ui.max ?? schema.maximum,\n exclusiveMin: ui.min === undefined ? schema.exclusiveMinimum : undefined,\n exclusiveMax: ui.max === undefined ? schema.exclusiveMaximum : undefined,\n step: ui.step ?? schema.multipleOf ?? (integer ? 1 : \"any\"),\n unit: ui.unit ?? schema[\"x-unit\"],\n };\n}\n\n/**\n * Why a number is not acceptable.\n *\n * @param spec - The field's rules.\n * @param value - The parsed number.\n * @returns A short sentence for the field's error line, or `undefined` when it is fine.\n */\nexport function checkNumber(spec: NumberSpec, value: number): string | undefined {\n if (!Number.isFinite(value)) return \"Enter a number\";\n if (spec.integer && !Number.isInteger(value)) return \"Must be a whole number\";\n if (spec.min !== undefined && value < spec.min) return `Must be ≥ ${spec.min}`;\n if (spec.exclusiveMin !== undefined && value <= spec.exclusiveMin) return `Must be > ${spec.exclusiveMin}`;\n if (spec.max !== undefined && value > spec.max) return `Must be ≤ ${spec.max}`;\n if (spec.exclusiveMax !== undefined && value >= spec.exclusiveMax) return `Must be < ${spec.exclusiveMax}`;\n return undefined;\n}\n\n/**\n * The bounds as a reader should see them, exclusive ones included.\n *\n * @param spec - The field's rules.\n * @returns `\"≥ 2, ≤ 64\"`, or `null` for an unbounded field.\n */\nexport function rangeText(spec: NumberSpec): string | null {\n const parts: string[] = [];\n if (spec.min !== undefined) parts.push(`≥ ${spec.min}`);\n else if (spec.exclusiveMin !== undefined) parts.push(`> ${spec.exclusiveMin}`);\n if (spec.max !== undefined) parts.push(`≤ ${spec.max}`);\n else if (spec.exclusiveMax !== undefined) parts.push(`< ${spec.exclusiveMax}`);\n return parts.length > 0 ? parts.join(\", \") : null;\n}\n","/**\n * The controls of a `SchemaValueForm`: one per kind of leaf value. Each reads its own value\n * from the form by path and writes its own leaf back; none knows its neighbours.\n */\n\nimport {\n Button,\n Checkbox,\n Field,\n Input,\n NumberInput,\n SegmentedControl,\n Select,\n Switch,\n Textarea,\n byDensity,\n cn,\n parseNumber,\n useDensity,\n} from \"@vitavision/ui\";\nimport { use, useState, type ChangeEvent, type ReactNode } from \"react\";\n\nimport { firstParagraph } from \"../../api/firstParagraph\";\nimport { checkNumber, numberSpec, rangeText } from \"../../api/numberSpec\";\nimport { displayValue } from \"../../api/schemaForm\";\nimport type { EnumOption } from \"../../api/schemaValue\";\nimport { defaultValueForSchema } from \"../../api/schemaValue\";\nimport { getAtPath } from \"../../api/valuePath\";\nimport type { FieldWidget } from \"../../api/uiSchema\";\nimport { useChrome, spanClass, type FieldMeta } from \"./chrome\";\nimport { ErrorText, useFieldExtras, withNotes } from \"./changes\";\nimport { DenseContext, useForm } from \"./context\";\n\n/** `required` as the marker shows it: a nullable field is never mandatory. */\nfunction marked(meta: FieldMeta): boolean {\n return meta.required && !meta.nullable;\n}\n\n/** Where `null` is a legal value, an empty control says so. */\nconst NULL_PLACEHOLDER = \"none\";\n\n/**\n * What an empty control shows: the schema default while the key is absent (that is the\n * value the consumer will use), `none` for an explicit `null` or a nullable field with no\n * non-null default.\n */\nfunction placeholderFor(meta: FieldMeta, value: unknown, fallback: string | undefined): string | undefined {\n if (value === null) return meta.nullable ? NULL_PLACEHOLDER : fallback;\n return fallback ?? (meta.nullable ? NULL_PLACEHOLDER : undefined);\n}\n\n/** A number field: bounds, unit and a verdict on what was typed. */\nexport function NumberLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const spec = numberSpec(meta.schema, meta.ui);\n const chrome = useChrome(meta, rangeText(spec));\n const extras = useFieldExtras(meta);\n const [error, setError] = useState<string | undefined>();\n\n const fallback = meta.schema.default;\n const restore = meta.ui.restoreDefaultOnClear ?? true;\n let onClear: (() => void) | undefined;\n if (meta.nullable && meta.ui.clearTo === \"null\") onClear = () => form.setValue(meta.path, null);\n else if (!meta.required) {\n onClear = () => form.setValue(meta.path, restore && typeof fallback === \"number\" ? fallback : undefined);\n } else if (meta.nullable) onClear = () => form.setValue(meta.path, null);\n else if (restore && typeof fallback === \"number\") onClear = () => form.setValue(meta.path, fallback);\n else if (restore) onClear = () => form.setValue(meta.path, defaultValueForSchema(meta.schema, form.schema));\n\n const judge = (event: ChangeEvent<HTMLInputElement>) => {\n const text = event.currentTarget.value;\n const parsed = parseNumber(text);\n if (text.trim() === \"\") setError(undefined);\n else setError(parsed === null ? \"Enter a number\" : checkNumber(spec, parsed));\n };\n\n return (\n <Field\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={withNotes(chrome.description, extras.notes)}\n error={error ?? extras.error}\n className={cn(spanClass(form.columns, meta.ui, 1), extras.className)}\n >\n <NumberInput\n aria-label={meta.label}\n disabled={form.disabled}\n placeholder={placeholderFor(meta, value, typeof fallback === \"number\" ? String(fallback) : undefined)}\n value={typeof value === \"number\" ? value : null}\n min={spec.min}\n max={spec.max}\n step={spec.step}\n unit={spec.unit}\n onChange={judge}\n onBlur={() => setError(undefined)}\n onValueChange={(next) => {\n // The control already holds back what is out of `[min, max]`; the integer rule and\n // the exclusive bounds are ours.\n if (checkNumber(spec, next) === undefined) form.setValue(meta.path, next);\n }}\n onClear={onClear}\n />\n </Field>\n );\n}\n\n/**\n * A string field. Emptying a nullable one removes an optional key (the schema default\n * applies) and writes `null` for a required key or under `clearTo: \"null\"`; a field that\n * cannot be `null` keeps `\"\"`.\n */\nexport function TextLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const extras = useFieldExtras(meta);\n const fallback = meta.schema.default;\n\n return (\n <Field\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={withNotes(chrome.description, extras.notes)}\n error={extras.error}\n className={cn(spanClass(form.columns, meta.ui, 1), extras.className)}\n >\n <Input\n className=\"font-mono\"\n autoComplete=\"off\"\n spellCheck={false}\n aria-label={meta.label}\n disabled={form.disabled}\n placeholder={placeholderFor(meta, value, typeof fallback === \"string\" ? fallback : undefined)}\n value={typeof value === \"string\" ? value : \"\"}\n onChange={(event) => {\n const text = event.currentTarget.value;\n if (text !== \"\" || !meta.nullable) form.setValue(meta.path, text);\n else if (meta.ui.clearTo === \"null\" || meta.required) form.setValue(meta.path, null);\n else form.setValue(meta.path, undefined);\n }}\n />\n </Field>\n );\n}\n\n/** A choice among a few values (all shown) or many (a picker). */\nexport function Chooser({\n label,\n options,\n value,\n onChoose,\n unsetLabel,\n widget,\n disabled,\n}: {\n label: string;\n options: { value: string; label: string }[];\n /** The chosen option's value, or `\"\"`. */\n value: string;\n onChoose: (value: string) => void;\n /** Adds an entry that returns the field to unset (a nullable value). */\n unsetLabel?: string | undefined;\n widget?: FieldWidget | undefined;\n disabled: boolean;\n}) {\n const size = byDensity(useDensity(), \"md\", \"sm\");\n const strip = widget === \"segmented\" || (widget !== \"select\" && options.length <= 3 && unsetLabel === undefined);\n return strip ? (\n <SegmentedControl aria-label={label} size={size} disabled={disabled} value={value} options={options} onValueChange={onChoose} />\n ) : (\n <Select\n aria-label={label}\n disabled={disabled}\n value={value}\n options={options}\n placeholder={unsetLabel ?? \"Choose…\"}\n unsetLabel={unsetLabel}\n onValueChange={onChoose}\n />\n );\n}\n\n/** A closed set of primitives: `enum`, `const`, or `oneOf` of `{ const }`. */\nexport function EnumLeaf({ meta, options }: { meta: FieldMeta; options: EnumOption[] }) {\n const form = useForm();\n const dense = use(DenseContext);\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const extras = useFieldExtras(meta);\n\n const shown = options.map((option) => ({\n value: String(option.value),\n label: meta.ui.enumLabels?.[String(option.value)] ?? option.label,\n }));\n // An absent key is its schema default, so that is the option shown as chosen.\n const selected = options.find((option) => option.value === (value === undefined ? meta.schema.default : value));\n // The chosen variant's own sentence (\"No distortion; no parameter block.\") under the strip.\n const explained = !dense && meta.ui.descriptionAs !== \"none\" ? firstParagraph(selected?.description) : \"\";\n const description: ReactNode =\n explained !== \"\" && chrome.description !== undefined ? (\n <>\n {chrome.description} {explained}\n </>\n ) : explained !== \"\" ? (\n explained\n ) : (\n chrome.description\n );\n\n return (\n <Field\n as=\"group\"\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={withNotes(description, extras.notes)}\n error={extras.error}\n className={cn(spanClass(form.columns, meta.ui, 1), extras.className)}\n >\n <Chooser\n label={meta.label}\n options={shown}\n value={selected === undefined ? \"\" : String(selected.value)}\n widget={meta.ui.widget}\n disabled={form.disabled}\n unsetLabel={meta.nullable ? \"None\" : undefined}\n onChoose={(chosen) => {\n if (chosen === \"\") {\n if (meta.nullable) form.setValue(meta.path, null);\n return;\n }\n const option = options.find((candidate) => String(candidate.value) === chosen);\n if (option !== undefined) form.setValue(meta.path, option.value);\n }}\n />\n </Field>\n );\n}\n\n/** A boolean: a switch (the default) or a checkbox. */\nexport function BooleanLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const extras = useFieldExtras(meta);\n const props = {\n checked: value === true,\n onCheckedChange: (next: boolean) => form.setValue(meta.path, next),\n label: meta.label,\n description: withNotes(withNotes(chrome.description, extras.error ? <ErrorText text={extras.error} /> : undefined), extras.notes),\n disabled: form.disabled,\n };\n\n return (\n <div className={cn(\"flex min-w-0 items-start gap-1.5\", spanClass(form.columns, meta.ui, 1), extras.className)}>\n {meta.ui.widget === \"checkbox\" ? <Checkbox {...props} /> : <Switch {...props} />}\n {chrome.hint !== null && <span className=\"mt-0.5\">{chrome.hint}</span>}\n </div>\n );\n}\n\nfunction pretty(value: unknown): string {\n return value === undefined ? \"\" : JSON.stringify(value, null, 2);\n}\n\n/**\n * Anything the form has no control for, as JSON.\n *\n * What is typed is kept as typed. A valid edit goes to the form; an invalid one shows its\n * parse error and leaves the last good value where it was. The text only resets when the\n * value changes from outside.\n */\nexport function JsonLeaf({ meta }: { meta: FieldMeta }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const extras = useFieldExtras(meta);\n const canonical = JSON.stringify(value) ?? \"\";\n const [draft, setDraft] = useState<{ text: string; error: string | undefined; base: string }>(() => ({\n text: pretty(value),\n error: undefined,\n base: canonical,\n }));\n if (draft.base !== canonical) setDraft({ text: pretty(value), error: undefined, base: canonical });\n\n const edit = (text: string) => {\n if (text.trim() === \"\") {\n if (meta.required) {\n setDraft({ text, error: \"Enter a JSON value\", base: draft.base });\n } else {\n setDraft({ text, error: undefined, base: \"\" });\n form.setValue(meta.path, undefined);\n }\n return;\n }\n try {\n const parsed: unknown = JSON.parse(text);\n setDraft({ text, error: undefined, base: JSON.stringify(parsed) });\n form.setValue(meta.path, parsed);\n } catch (problem) {\n setDraft({ text, error: `Invalid JSON: ${problem instanceof Error ? problem.message : String(problem)}`, base: draft.base });\n }\n };\n\n return (\n <Field\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={withNotes(chrome.description, extras.notes)}\n error={draft.error ?? extras.error}\n className={cn(spanClass(form.columns, meta.ui, 2), extras.className)}\n >\n <Textarea\n mono\n rows={Math.min(Math.max(draft.text.split(\"\\n\").length, 3), 12)}\n spellCheck={false}\n aria-label={meta.label}\n disabled={form.disabled}\n value={draft.text}\n onChange={(event) => edit(event.currentTarget.value)}\n />\n </Field>\n );\n}\n\ninterface RowIds {\n ids: number[];\n next: number;\n}\n\n/** Grow or shrink the row ids to `length`, keeping the ids of the rows that stay. */\nfunction syncIds(rows: RowIds, length: number): RowIds {\n if (rows.ids.length === length) return rows;\n const ids = rows.ids.slice(0, length);\n let next = rows.next;\n while (ids.length < length) ids.push(next++);\n return { ids, next };\n}\n\n/**\n * An array of strings as a list: one input per entry, add and remove.\n *\n * Each row has an id of its own, so removing the second of three keeps the focus and the\n * cursor of the others instead of re-keying them by position.\n */\nexport function StringListLeaf({\n meta,\n minItems,\n maxItems,\n}: {\n meta: FieldMeta;\n minItems?: number | undefined;\n maxItems?: number | undefined;\n}) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const chrome = useChrome(meta);\n const extras = useFieldExtras(meta);\n const raw: unknown[] = Array.isArray(value) ? (value as unknown[]) : [];\n const [rows, setRows] = useState<RowIds>(() => syncIds({ ids: [], next: 0 }, raw.length));\n const synced = syncIds(rows, raw.length);\n if (synced !== rows) setRows(synced);\n\n const write = (list: unknown[]) => form.setValue(meta.path, list);\n const canRemove = minItems === undefined || raw.length > minItems;\n const canAdd = maxItems === undefined || raw.length < maxItems;\n\n return (\n <Field\n as=\"group\"\n label={meta.label}\n required={marked(meta)}\n annotation={chrome.annotation}\n description={withNotes(chrome.description, extras.notes)}\n error={extras.error}\n className={cn(spanClass(form.columns, meta.ui, 2), extras.className)}\n >\n <div className=\"flex flex-col gap-1.5\">\n {raw.map((entry, index) => (\n <div key={synced.ids[index]} className=\"flex gap-1.5\">\n <Input\n className=\"min-w-0 flex-1 font-mono\"\n autoComplete=\"off\"\n spellCheck={false}\n aria-label={`${meta.label} ${index + 1}`}\n disabled={form.disabled}\n value={displayValue(entry)}\n onChange={(event) => {\n const copy = raw.slice();\n copy[index] = event.currentTarget.value;\n write(copy);\n }}\n />\n <Button\n variant=\"ghost\"\n aria-label={`Remove ${meta.label} ${index + 1}`}\n disabled={form.disabled || !canRemove}\n onClick={() => {\n setRows({ ids: synced.ids.filter((_, i) => i !== index), next: synced.next });\n write(raw.filter((_, i) => i !== index));\n }}\n >\n ×\n </Button>\n </div>\n ))}\n <Button\n className=\"self-start\"\n aria-label={`Add ${meta.label}`}\n disabled={form.disabled || !canAdd}\n onClick={() => {\n setRows({ ids: [...synced.ids, synced.next], next: synced.next + 1 });\n write([...raw, \"\"]);\n }}\n >\n Add\n </Button>\n </div>\n </Field>\n );\n}\n","/**\n * The tree of a `SchemaValueForm`: a field dispatcher and the containers that nest it.\n *\n * A node is addressed by its dot path. It reads its value from the form, writes it back by\n * path, and renders whatever its schema's shape calls for: a control for a leaf, a\n * fieldset for an object, a variant selector for a union, a row for a tuple, a switch for\n * a nullable composite.\n */\n\nimport { Checkbox, Switch, byDensity, cn, useDensity } from \"@vitavision/ui\";\nimport { use, type ReactNode } from \"react\";\n\nimport { firstParagraph } from \"../../api/firstParagraph\";\nimport { labelFor, resolveSchema, type JsonSchema } from \"../../api/schemaNode\";\nimport { activeExternal, activeTagged, seedNotNull, seedVariant, shapeOf, type FieldInfo, type SchemaShape } from \"../../api/schemaValue\";\nimport { fieldUiAt } from \"../../api/uiSchema\";\nimport { getAtPath, joinPath } from \"../../api/valuePath\";\nimport { Grid, spanClass, useChrome, type FieldMeta } from \"./chrome\";\nimport { ErrorText, useFieldExtras, withNotes } from \"./changes\";\nimport { Chooser, BooleanLeaf, EnumLeaf, JsonLeaf, NumberLeaf, StringListLeaf, TextLeaf } from \"./leaves\";\nimport { DenseContext, useForm } from \"./context\";\n\ntype TaggedShape = Extract<SchemaShape, { kind: \"tagged\" }>;\ntype ExternalShape = Extract<SchemaShape, { kind: \"external\" }>;\ntype TupleShape = Extract<SchemaShape, { kind: \"tuple\" }>;\n\nconst BOOLEANS = [\n { value: true, label: \"true\" },\n { value: false, label: \"false\" },\n];\n\n/** Shapes that are a block of their own, so a nullable one gets a switch rather than an empty box. */\nfunction isComposite(shape: SchemaShape): boolean {\n return (\n shape.kind === \"object\" ||\n shape.kind === \"tagged\" ||\n shape.kind === \"external\" ||\n shape.kind === \"tuple\" ||\n shape.kind === \"string-list\"\n );\n}\n\n/** `ui.widget` can change what an array or any value is edited as. */\nfunction applyWidget(shape: SchemaShape, meta: FieldMeta, value: unknown): SchemaShape {\n const items = typeof meta.schema.items === \"object\" ? meta.schema.items : undefined;\n switch (meta.ui.widget) {\n case \"json\":\n return { kind: \"json\" };\n case \"string-list\":\n return meta.schema.type === \"array\" ? { kind: \"string-list\", item: items ?? { type: \"string\" } } : shape;\n case \"tuple-row\":\n return items !== undefined && Array.isArray(value) ? { kind: \"tuple\", items: (value as unknown[]).map(() => items) } : shape;\n default:\n return shape;\n }\n}\n\n/**\n * One field of the form, at a path.\n *\n * Honours the app's `hidden` and `renderField`, then renders the control or container its\n * schema's shape calls for. A nullable composite (an object that may be `null`) gets a\n * switch; a nullable leaf is an empty control.\n */\nexport function FieldNode({\n path,\n name,\n node,\n required,\n bare = false,\n}: {\n path: string;\n /** The key (or index) the field has in its parent, for the default label. */\n name: string;\n /** The schema as written. */\n node: JsonSchema;\n required: boolean;\n /** Without the container's own chrome (legend, border): the root, and a switched-on nullable. */\n bare?: boolean;\n}) {\n const form = useForm();\n const ui = fieldUiAt(form.ui, path);\n if (ui.hidden === true) return null;\n\n const { schema, nullable } = resolveSchema(node, form.schema);\n const value = getAtPath(form.value, path);\n const meta: FieldMeta = { path, label: ui.label ?? labelFor(name, node), required, node, schema, nullable, ui };\n const shape = applyWidget(shapeOf(schema, form.schema), meta, value);\n\n if (form.renderField !== undefined) {\n const custom = form.renderField({\n path,\n schema,\n value,\n onChange: (next) => form.setValue(path, next),\n disabled: form.disabled,\n });\n if (custom !== undefined) {\n return <div className={spanClass(form.columns, ui, isComposite(shape) ? 2 : 1)}>{custom}</div>;\n }\n }\n\n if (nullable && isComposite(shape)) return <NullableNode meta={meta} shape={shape} />;\n return <ShapeNode meta={meta} shape={shape} bare={bare} />;\n}\n\n/** Render a resolved shape. */\nfunction ShapeNode({ meta, shape, bare }: { meta: FieldMeta; shape: SchemaShape; bare: boolean }) {\n switch (shape.kind) {\n case \"integer\":\n case \"number\":\n return <NumberLeaf meta={meta} />;\n case \"string\":\n return <TextLeaf meta={meta} />;\n case \"boolean\":\n return meta.nullable ? <EnumLeaf meta={meta} options={BOOLEANS} /> : <BooleanLeaf meta={meta} />;\n case \"enum\":\n return <EnumLeaf meta={meta} options={shape.options} />;\n case \"string-list\":\n return <StringListLeaf meta={meta} minItems={meta.schema.minItems} maxItems={meta.schema.maxItems} />;\n case \"json\":\n return <JsonLeaf meta={meta} />;\n case \"object\":\n return <ObjectNode meta={meta} fields={shape.fields} bare={bare} />;\n case \"tagged\":\n case \"external\":\n return <UnionNode meta={meta} shape={shape} bare={bare} />;\n case \"tuple\":\n return <TupleNode meta={meta} shape={shape} bare={bare} />;\n }\n}\n\n/** The fields of an object that are neither hidden by the app nor claimed by a group. */\nfunction useVisible(path: string, fields: FieldInfo[]): FieldInfo[] {\n const form = useForm();\n return fields.filter((field) => {\n const child = joinPath(path, field.key);\n return !form.claimed.has(child) && fieldUiAt(form.ui, child).hidden !== true;\n });\n}\n\n/**\n * The fields of an object, each as a node, skipping hidden ones and ones a group has claimed.\n * Renders nothing when none is left.\n */\nexport function ObjectBody({ path, fields }: { path: string; fields: FieldInfo[] }) {\n const visible = useVisible(path, fields);\n if (visible.length === 0) return null;\n\n return (\n <Grid>\n {visible.map((field) => (\n <FieldNode key={field.key} path={joinPath(path, field.key)} name={field.key} node={field.schema} required={field.required} />\n ))}\n </Grid>\n );\n}\n\n/** The frame of a composite field: its label and hint over its content. `bare` drops the frame. */\nfunction Frame({ meta, bare, children }: { meta: FieldMeta; bare: boolean; children: ReactNode }) {\n const form = useForm();\n const dense = use(DenseContext);\n const density = useDensity();\n const chrome = useChrome(meta);\n const extras = useFieldExtras(meta);\n if (bare) return <div className=\"flex min-w-0 flex-col gap-3\">{children}</div>;\n\n return (\n <fieldset\n data-changed={extras.changed ? \"\" : undefined}\n className={cn(\n \"flex min-w-0 flex-col gap-3 rounded-panel border border-line\",\n byDensity(density, \"p-3\", \"p-2\"),\n !dense && spanClass(form.columns, meta.ui, 2),\n extras.className,\n )}\n >\n <legend className=\"px-1\">\n <span className=\"inline-flex items-center gap-1.5 text-xs font-semibold text-fg\">\n {meta.label}\n {chrome.hint}\n </span>\n </legend>\n {chrome.description !== undefined && <p className=\"text-xs leading-snug text-fg-muted\">{chrome.description}</p>}\n {extras.error !== undefined && <ErrorText text={extras.error} />}\n {extras.notes !== undefined && <div className=\"text-xs\">{extras.notes}</div>}\n {children}\n </fieldset>\n );\n}\n\nfunction ObjectNode({ meta, fields, bare }: { meta: FieldMeta; fields: FieldInfo[]; bare: boolean }) {\n if (useVisible(meta.path, fields).length === 0) return null;\n return (\n <Frame meta={meta} bare={bare}>\n <ObjectBody path={meta.path} fields={fields} />\n </Frame>\n );\n}\n\n/** A union: the variant selector, the variant's description, and the variant's fields. */\nfunction UnionNode({ meta, shape, bare }: { meta: FieldMeta; shape: TaggedShape | ExternalShape; bare: boolean }) {\n const form = useForm();\n const value = getAtPath(form.value, meta.path);\n const active = shape.kind === \"tagged\" ? activeTagged(shape, value) : activeExternal(shape, value);\n const options = shape.variants.map((variant) => ({\n value: variant.tag,\n label: meta.ui.enumLabels?.[variant.tag] ?? variant.label,\n }));\n const explained = meta.ui.descriptionAs === \"none\" ? \"\" : firstParagraph(active?.description);\n\n let body: ReactNode = null;\n if (shape.kind === \"tagged\") {\n const variant = activeTagged(shape, value);\n if (variant !== undefined) body = <ObjectBody path={meta.path} fields={variant.fields} />;\n } else {\n const variant = activeExternal(shape, value);\n if (variant?.payload !== undefined) {\n const inner = joinPath(meta.path, variant.tag);\n const payload = shapeOf(variant.payload, form.schema);\n body =\n payload.kind === \"object\" ? (\n <ObjectBody path={inner} fields={payload.fields} />\n ) : (\n <Grid>\n <FieldNode path={inner} name={variant.tag} node={variant.payload} required />\n </Grid>\n );\n }\n }\n\n return (\n <Frame meta={meta} bare={bare}>\n <Chooser\n label={meta.label}\n options={options}\n value={active?.tag ?? \"\"}\n widget={meta.ui.widget}\n disabled={form.disabled}\n onChoose={(tag) => {\n const next = seedVariant(shape, tag, form.schema);\n if (next !== undefined) form.setValue(meta.path, next);\n }}\n />\n {explained !== \"\" && <p className=\"text-xs leading-snug text-fg-muted\">{explained}</p>}\n {body}\n </Frame>\n );\n}\n\n/**\n * A fixed-length array as a compact row: one cell per position (a row of numbers), or one\n * row per position when the positions are objects (a list of points).\n */\nfunction TupleNode({ meta, shape, bare }: { meta: FieldMeta; shape: TupleShape; bare: boolean }) {\n const form = useForm();\n const cells = shape.items.map((item, index) => {\n const name = String(index);\n return { name, item, resolved: shapeOf(item, form.schema), path: joinPath(meta.path, name) };\n });\n const rows = cells.some((cell) => cell.resolved.kind === \"object\");\n\n return (\n <Frame meta={meta} bare={bare}>\n <DenseContext value>\n {rows ? (\n <div className=\"flex flex-col gap-2\">\n {cells.map((cell) => (\n <div key={cell.name} role=\"group\" aria-label={`${meta.label} ${cell.name}`} className=\"flex items-start gap-2\">\n <span className=\"w-4 shrink-0 pt-1.5 font-mono text-xs text-fg-subtle\" aria-hidden>\n {cell.name}\n </span>\n <div className=\"min-w-0 flex-1\">\n {cell.resolved.kind === \"object\" ? (\n <ObjectBody path={cell.path} fields={cell.resolved.fields} />\n ) : (\n <Grid>\n <FieldNode path={cell.path} name={cell.name} node={cell.item} required />\n </Grid>\n )}\n </div>\n </div>\n ))}\n </div>\n ) : (\n <Grid>\n {cells.map((cell) => (\n <FieldNode key={cell.name} path={cell.path} name={cell.name} node={cell.item} required />\n ))}\n </Grid>\n )}\n </DenseContext>\n </Frame>\n );\n}\n\n/**\n * A composite that may be `null`: a switch for \"set / unset\", and the content only while set.\n * Switching it on seeds the content from the schema's defaults.\n */\nfunction NullableNode({ meta, shape }: { meta: FieldMeta; shape: SchemaShape }) {\n const form = useForm();\n const chrome = useChrome(meta);\n const extras = useFieldExtras(meta);\n const value = getAtPath(form.value, meta.path);\n const set = value !== null && value !== undefined;\n const props = {\n checked: set,\n label: meta.label,\n description: withNotes(withNotes(chrome.description, extras.error ? <ErrorText text={extras.error} /> : undefined), extras.notes),\n disabled: form.disabled,\n onCheckedChange: (next: boolean) => form.setValue(meta.path, next ? seedNotNull(meta.node, form.schema) : null),\n };\n\n return (\n <div className={cn(\"flex min-w-0 flex-col gap-3\", spanClass(form.columns, meta.ui, 2), extras.className)}>\n <div className=\"flex items-start gap-1.5\">\n {meta.ui.widget === \"checkbox\" ? <Checkbox {...props} /> : <Switch {...props} />}\n {chrome.hint !== null && <span className=\"mt-0.5\">{chrome.hint}</span>}\n </div>\n {set && (\n <div className=\"min-w-0 border-l border-line pl-3\">\n <ShapeNode meta={meta} shape={shape} bare />\n </div>\n )}\n </div>\n );\n}\n","/**\n * A form that edits a whole JSON value, generated from the value's JSON Schema.\n *\n * `SchemaForm` is for *options*: every field starts unset and only what the operator\n * touches is sent. This is for *configs*: the value is complete — a calibration's settings,\n * a detector's parameters — and the form edits it in place, down to a nested struct, a\n * serde enum's data, a nullable block or a tuple of points, handing back the whole next\n * value on each edit. What the schema cannot say (grouping, labels, units, a different\n * control) the app says in a `UiSchema`.\n */\n\nimport { Disclosure, Section, TooltipProvider, cn } from \"@vitavision/ui\";\nimport { useMemo, useState, type Ref } from \"react\";\n\nimport type { JsonSchema } from \"../api/schemaNode\";\nimport { defaultValueForSchema, fieldAt, shapeOf } from \"../api/schemaValue\";\nimport { fieldUiAt, type RenderField, type UiGroup, type UiSchema } from \"../api/uiSchema\";\nimport { changeCounts, diffPaths } from \"../api/valueDiff\";\nimport { setAtPath } from \"../api/valuePath\";\nimport { Grid } from \"./valueForm/chrome\";\nimport { FormContext, useForm, type FieldMessage, type FormState } from \"./valueForm/context\";\nimport { FieldNode, ObjectBody } from \"./valueForm/nodes\";\n\nconst NO_UI: UiSchema = {};\n\n/** Messages from the app, by dot path (`\"\"` is the form as a whole). A bare string is an error. */\nexport type FieldMessages = Readonly<Record<string, FieldMessage | string>>;\n\nexport type { FieldMessage };\n\n/** Props of `SchemaValueForm`. */\nexport interface SchemaValueFormProps {\n /**\n * The value's JSON Schema (draft 2020-12, as schemars emits it), `$defs` included. Not\n * watched for change in the uncontrolled mode: give the form a `key` per schema.\n */\n schema: JsonSchema;\n /** The value, for a controlled form. Complete: the form edits it, it does not complete it. */\n value?: unknown;\n /**\n * The starting value, for an uncontrolled form. Without either, the form starts from\n * `defaultValueForSchema(schema)`.\n */\n defaultValue?: unknown;\n /**\n * Called with the whole next value on each edit. The previous value is never mutated;\n * untouched subtrees are shared with it, and keys the schema does not know are kept.\n */\n onValueChange?: ((next: unknown) => void) | undefined;\n /** Layout the schema cannot carry: groups, labels, units, widgets. */\n ui?: UiSchema | undefined;\n /**\n * The value to compare with, such as the defaults or a previous run. A field whose value\n * differs from it is marked \"changed\" (a rule in the gutter and a note under the control\n * saying what it was), with a Reset that writes the baseline's value back through\n * `onValueChange`; a struct, a variant or a tuple shows how many leaves under it changed\n * and one Reset for them all. A key missing on one side differs from a key present on the\n * other; arrays of equal length compare by index, others as a whole. Without it, nothing is marked.\n */\n baseline?: unknown;\n /**\n * Messages to show on fields, by dot path (`solver.max_iters`, `cameras.0.id`, the paths\n * `getAtPath` reads), for validation that comes from elsewhere, such as a backend. An `error`\n * (or a bare string) is announced as an alert and marks the control invalid; a `warning`\n * is shown under it without blocking. A path of `\"\"` shows above the form. A path that no\n * visible field has shows nowhere: list those yourself.\n */\n messages?: FieldMessages | undefined;\n /** `2` (the default) puts fields side by side from `sm:` up; `1` is one column, for a narrow rail. */\n columns?: 1 | 2 | undefined;\n /** Blocks every control. The value is still shown. */\n disabled?: boolean | undefined;\n /**\n * Take over a field. Called for every field before the form's own control; return\n * `undefined` to let the form render it. The result is placed in the field's grid cell\n * as it is, so wrap it in a `Field` if it should look like its neighbours.\n */\n renderField?: RenderField | undefined;\n /** Merged with the form's own classes through `cn`. */\n className?: string | undefined;\n /** The root element. */\n ref?: Ref<HTMLDivElement> | undefined;\n}\n\n/** Controlled when `value` is given, otherwise the form keeps the value itself. */\nfunction useValue(\n value: unknown,\n seed: () => unknown,\n onValueChange: ((next: unknown) => void) | undefined,\n): [unknown, (next: unknown) => void] {\n const [inner, setInner] = useState(seed);\n const controlled = value !== undefined;\n return [\n controlled ? value : inner,\n (next) => {\n if (!controlled) setInner(next);\n onValueChange?.(next);\n },\n ];\n}\n\n/**\n * Edit a JSON value through its schema.\n *\n * Renders by the schema's shape: a number is a `NumberInput` (with its bounds, unit and an\n * integer-only rule), a string an `Input`, a boolean a `Switch`, a closed set a\n * `SegmentedControl` or a `Select`, a struct a nested fieldset, a serde enum a variant\n * selector with the variant's fields (switching seeds them from the schema's defaults), a\n * `null`-able block a switch that sets and unsets it, a list of strings an editable list, a\n * fixed-length array a row of cells, and anything else a JSON textarea that keeps the last\n * valid value while showing the parse error.\n *\n * The first paragraph of a field's description is its `InfoHint`. Round-trips: a value in,\n * no edits, the same value out — the form never normalises on mount, and an edit changes\n * only the leaf touched.\n *\n * The root is a `div` carrying `data-columns` and, while disabled, `data-disabled`. Wraps itself in a\n * `TooltipProvider`, so it needs none above it.\n */\nexport function SchemaValueForm({\n schema,\n value,\n defaultValue,\n onValueChange,\n baseline,\n messages,\n ui = NO_UI,\n columns = 2,\n disabled = false,\n renderField,\n className,\n ref,\n}: SchemaValueFormProps) {\n const [current, commit] = useValue(\n value,\n () => (defaultValue !== undefined ? defaultValue : defaultValueForSchema(schema)),\n onValueChange,\n );\n const compared = useMemo(\n () => (baseline === undefined ? null : { value: baseline, counts: changeCounts(diffPaths(current, baseline)) }),\n [current, baseline],\n );\n const claimed = useMemo(() => new Set((ui.groups ?? []).flatMap((group) => group.fields)), [ui.groups]);\n\n const state: FormState = {\n schema,\n value: current,\n setValue: (path, next) => {\n const updated = setAtPath(current, path, next);\n // Setting what is already there hands back the same value: nothing to report.\n if (!Object.is(updated, current)) commit(updated);\n },\n ui,\n disabled,\n columns,\n renderField,\n claimed,\n baseline: compared,\n messages,\n };\n\n const root = shapeOf(schema, schema);\n const raw = messages?.[\"\"];\n const formMessage: FieldMessage | undefined = typeof raw === \"string\" ? { severity: \"error\", text: raw } : raw;\n\n return (\n <TooltipProvider>\n <FormContext value={state}>\n <div\n ref={ref}\n data-columns={columns}\n data-disabled={disabled ? \"\" : undefined}\n className={cn(\"flex min-w-0 flex-col gap-5\", className)}\n >\n {formMessage !== undefined && (\n <p\n role={formMessage.severity === \"error\" ? \"alert\" : undefined}\n data-message={formMessage.severity}\n className={cn(\"text-xs leading-snug\", formMessage.severity === \"error\" ? \"text-defect\" : \"text-warn\")}\n >\n {formMessage.text}\n </p>\n )}\n {root.kind === \"object\" && (ui.groups ?? []).map((group) => <GroupBlock key={group.id} group={group} />)}\n {root.kind === \"object\" ? (\n <ObjectBody path=\"\" fields={root.fields} />\n ) : (\n <FieldNode path=\"\" name={schema.title ?? \"value\"} node={schema} required bare />\n )}\n </div>\n </FormContext>\n </TooltipProvider>\n );\n}\n\n/** A `UiGroup`: its fields under a heading, folded away if the app said so. */\nfunction GroupBlock({ group }: { group: UiGroup }) {\n const { schema, value, ui } = useForm();\n const fields = group.fields.flatMap((path) => {\n const info = fieldAt(schema, path, schema, value);\n if (info === undefined || fieldUiAt(ui, path).hidden === true) return [];\n return [{ path, info }];\n });\n if (fields.length === 0) return null;\n\n const body = (\n <Grid>\n {fields.map(({ path, info }) => (\n <FieldNode key={path} path={path} name={path.split(\".\").at(-1) ?? path} node={info.schema} required={info.required} />\n ))}\n </Grid>\n );\n\n if (group.collapsible === true) {\n return (\n <Disclosure summary={group.title} count={fields.length} defaultOpen={group.defaultOpen ?? false}>\n {group.hint !== undefined && <p className=\"mb-3 text-xs text-fg-muted\">{group.hint}</p>}\n {body}\n </Disclosure>\n );\n }\n return (\n <Section title={group.title} hint={group.hint}>\n {body}\n </Section>\n );\n}\n"],"mappings":";;;;;AAqFA,MAAM,WAAW;AAEjB,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;;;;;;;AAUA,SAAgB,WAAW,KAAa,MAA0C;C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