import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement,type LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import'../../forms/select/select.class.js';import'../../forms/combobox/option.class.js';import'../../forms/input/number-input.class.js';import{type FormOwnerValue}from'../../../internal/form-associated.js'; /** The four leaf property types this flat-schema renderer understands. */ export type ToolParamFormPropertyType='string'|'number'|'integer'|'boolean';export type ToolParamFormPrimitive=string|number|boolean; /** * One `schema.properties` entry. Deliberately shallow — see the class doc for * the full scope limitation this type encodes. */ export interface ToolParamFormProperty{readonly type:ToolParamFormPropertyType; /** A closed set of string choices, rendered as a ``. Only meaningful when `type` is `'string'`. */ readonly enum?:readonly string[]; /** Helper text rendered under the field. */ readonly description?:string; /** Display label. Falls back to the property key itself when omitted. */ readonly title?:string; /** Pre-filled value used whenever `value` doesn't already have this key. */ readonly default?:unknown; /** Exact primitive value required when the property is present. */ readonly const?:ToolParamFormPrimitive; /** Native editing-assistance hints forwarded when this property renders a text input. */ readonly autocomplete?:string;readonly spellcheck?:boolean;readonly autocapitalize?:string;readonly autoCorrect?:string;readonly inputMode?:string;readonly enterKeyHint?:string;} /** * The (intentionally flat) JSON Schema subset this component can render: * a plain object whose every property is a string, number/integer, boolean, * or string enum. See the class doc for what's out of scope. */ export interface FlatToolParamSchema{readonly type:'object';readonly properties:Readonly>;readonly required?:readonly string[];}export type ToolParamFormValue=Readonly>;export interface LyraToolParamFormEventMap{'lr-invalid':CustomEvent;'lr-validity-change':CustomEvent>;}>>;'lr-input':CustomEvent>;blur:CustomEvent;focus:CustomEvent;} /** * `` — renders one form control per top-level property * of a JSON Schema object, for ad hoc tool invocation or approval-editing UIs * (e.g. "the agent wants to call `create_event(title, attendees, allDay)` — * let the user tweak the arguments before running it"). * * **Scope limitation (intentional, not accidental):** this renderer only * understands a *flat* object schema — every `properties` entry must be * `'string'`, `'number'`, `'integer'`, `'boolean'`, or a string `enum`; * primitive `const` is also enforced. Nested objects, arrays, * `oneOf`/`anyOf`/`allOf`, `$ref`, constraints such as `minLength`/`minimum`, * and schema-valued `additionalProperties` are not read. A full * JSON-Schema-to-form renderer is * out of scope for this component; a property whose `type` isn't one of the * four above renders a visible "Unsupported field type" note and marks the * form invalid instead of silently dropping it or throwing. * A schema is additionally bounded to 100 fields and 500 enum choices per field. Exceeding either * ceiling fails the form closed with a localized form-wide error while the bounded prefix remains * available for inspection; malformed null/array property definitions fail as schema errors rather * than being misreported as value-serialization failures. * * Fields render in `Object.keys(schema.properties)` order (insertion order, * which is reliable for a plain object's string keys). A field's label is * `title ?? ` the property key; `description` renders as helper text below * the control; a key listed in `required` gets a visible `*`. The outer component owns validation * because JSON Schema `required` means property presence, unlike HTML controls' nonempty/must-check * semantics. Boolean fields therefore expose explicit unset/true/false values instead of * conflating an absent property with `false`. * * Deliberately no top-level `label`/`hint`/`errorText` chrome (unlike * ``'s own trio, despite both being compound, multi-item * form controls): every field already carries its own per-field * `label`/`description`/`error` parts above, and this whole control is * meant to be composed inside a consumer's own dialog/section (e.g. "Approve * `create_event` call?") that already supplies the surrounding heading and * context — a second, redundant outer label here would just repeat it. A * form-wide validation summary is still available via the `error` part * (`class="form-error"`), driven by `reportValidity()`. * The `base` wrapper is always the accessible `role="group"`, so a native external `