@cascivo/render 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -1
- package/dist/a2ui-v0_9.d.ts +200 -0
- package/dist/a2ui-v0_9.js +2 -0
- package/dist/cascivo-view-4DY6JqQA.js +2 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +1 -1
- package/dist/node-props-LGzuaTTg.js +1 -0
- package/dist/prop-schemas-7gVWDISz.js +1 -0
- package/dist/validate.d.ts +11 -2
- package/dist/validate.js +1 -1
- package/dist/view-text.d.ts +22 -0
- package/dist/view-text.js +1 -1
- package/package.json +14 -6
- package/readme.body.md +85 -1
- package/schema/a2ui/v0_9/catalog.json +5008 -0
- package/schema/catalog.v1.json +4751 -0
- package/schema/view.v1.json +16246 -2187
- package/dist/cascivo-view-B9JrFIno.js +0 -2
- package/dist/validate-C49ddSx2.js +0 -1
package/README.md
CHANGED
|
@@ -62,7 +62,19 @@ export function App() {
|
|
|
62
62
|
|
|
63
63
|
The JSON stays fully serializable: live values come from the host via `bind` (`"$data.users.active"` resolves a dot-path into the `data` prop) and handlers via `events` (`"$actions.invite"` looks up the `actions` prop) — never from the config itself. Strings can be i18n refs (`{ "$t": "catalog.key" }`), resolved through `@cascivo/i18n`. `config` also accepts a `Signal<ViewConfig>`, so a view can be swapped live.
|
|
64
64
|
|
|
65
|
-
Nodes resolve against a built-in component map of
|
|
65
|
+
Nodes resolve against a built-in component map of 74 cascivo components (Button, Card, Badge, Input, Select, Modal, Tabs, DataTable, Form, …) — see `component-map.ts` for the full list.
|
|
66
|
+
|
|
67
|
+
### Your own components, and charts
|
|
68
|
+
|
|
69
|
+
Pass `components` to render names beyond the built-in set: charts, or your app's own components. They are looked up before the built-ins, the validator accepts them, and their props are passed through unchecked:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { Kpi, LineChart } from '@cascivo/charts'
|
|
73
|
+
|
|
74
|
+
;<CascivoView config={view} data={data} components={{ Kpi, LineChart }} />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`@cascivo/render` does not depend on `@cascivo/charts`, so only an app that renders charts installs it. Validate such a view with the same names: `validateView(view, { components: ['Kpi', 'LineChart'] })`, and read it as Markdown with `viewToMarkdown(view, { components: { Kpi, LineChart } })`.
|
|
66
78
|
|
|
67
79
|
## Validation
|
|
68
80
|
|
|
@@ -89,6 +101,78 @@ const { valid, errors } = validateView(modelOutput)
|
|
|
89
101
|
|
|
90
102
|
Pair it with the MCP server's bound-vocabulary grammar (`get_view_grammar`) and `scaffold_view` for the full anti-hallucination loop: the model can only emit components and props that exist, and `validateView` is the enforcement backstop. `cascivo generate <config.json>` converts a validated `ViewConfig` into owned TSX when you want to graduate from JSON to source.
|
|
91
103
|
|
|
104
|
+
## Component catalog
|
|
105
|
+
|
|
106
|
+
The renderable vocabulary is also published as data, generated from the same manifests the validator uses, so other tools can target cascivo without importing React:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import catalog from '@cascivo/render/schema/catalog.v1.json' with { type: 'json' }
|
|
110
|
+
import a2ui from '@cascivo/render/schema/a2ui/v0_9/catalog.json' with { type: 'json' }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- `schema/catalog.v1.json` is the protocol-neutral catalog: one entry per renderable component.
|
|
114
|
+
- `schema/a2ui/v0_9/catalog.json` is the same catalog as an [A2UI](https://a2ui.org) v0.9 custom catalog. Its `catalogId` is `https://cascivo.com/a2ui/v0_9/catalog.json`, and the file is served there.
|
|
115
|
+
|
|
116
|
+
Every prop of a component is sorted into one of four kinds:
|
|
117
|
+
|
|
118
|
+
| Kind | Meaning |
|
|
119
|
+
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
120
|
+
| `props` | Data props, each with a JSON Schema |
|
|
121
|
+
| `slots` | Child content, with arity `one` or `many` (`text: true` when it also takes a string, as `children` does; `implicit: true` when inferred from source) |
|
|
122
|
+
| `events` | Callbacks an agent can wire to an action |
|
|
123
|
+
| `omitted` | Props that cannot cross the wire (functions, DOM refs), with the reason |
|
|
124
|
+
|
|
125
|
+
`validateView` also checks the shape of object and array props, such as `DataTable` `columns`: nested fields by presence and type, so an unknown nested field is allowed.
|
|
126
|
+
|
|
127
|
+
Regenerate both files with `pnpm regen` (or `pnpm schema:generate && vp check --fix`); CI fails when the committed files drift from the manifests. `pnpm schema:check` runs the generator unit tests.
|
|
128
|
+
|
|
129
|
+
## Render A2UI
|
|
130
|
+
|
|
131
|
+
`@cascivo/render/a2ui/v0_9` renders [A2UI](https://a2ui.org) v0.9 messages with cascivo components. It is our own renderer, not `@a2ui/react`: that package brings lit, zod, a second signals store and custom elements. The store holds messages as signals, so a data change re-renders only the nodes bound to it.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import {
|
|
135
|
+
A2uiSurface,
|
|
136
|
+
createA2uiStore,
|
|
137
|
+
defaultCatalogs,
|
|
138
|
+
defaultCatalogSpecs,
|
|
139
|
+
} from '@cascivo/render/a2ui/v0_9'
|
|
140
|
+
|
|
141
|
+
const store = createA2uiStore({ catalogs: defaultCatalogSpecs })
|
|
142
|
+
|
|
143
|
+
// Feed it each message the agent sends, already parsed from JSON. `apply` never throws and
|
|
144
|
+
// returns the errors to send back to the agent.
|
|
145
|
+
export const feed = (raw: unknown) => store.apply(raw)
|
|
146
|
+
|
|
147
|
+
export function Agent({ send }: { send: (action: unknown) => void }) {
|
|
148
|
+
return <A2uiSurface store={store} surfaceId="main" catalogs={defaultCatalogs} onAction={send} />
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The entry has no `'use client'`; in React Server Components apps import `A2uiSurface` from a client module.
|
|
153
|
+
|
|
154
|
+
### Catalogs
|
|
155
|
+
|
|
156
|
+
- The **cascivo catalog** (`cascivoCatalog`, spec `cascivoCatalogSpec`, id `A2UI_CATALOG_ID`) lets an agent target real cascivo components, the same vocabulary `validateView` checks.
|
|
157
|
+
- The **basic catalog** (`basicCatalog`, spec `basicCatalogSpec`, id `BASIC_CATALOG_ID`) is A2UI's standard set, drawn with cascivo components.
|
|
158
|
+
|
|
159
|
+
A surface uses the catalog its `createSurface` message names; the store only knows the catalogs passed to `createA2uiStore`, so inline catalogs are refused.
|
|
160
|
+
|
|
161
|
+
### Security and limits
|
|
162
|
+
|
|
163
|
+
- Every message is validated against the catalog spec before it reaches state; a bad one becomes an `A2uiErrorMessage`, never an exception.
|
|
164
|
+
- URLs that reach `href`, `src` or `window.open` are checked, and unsafe ones are dropped.
|
|
165
|
+
- A value bound in from the data model, or computed by a function, is checked against the prop's schema when it renders; one that does not fit is dropped and reported as `RENDER_ERROR`. `{$t}` translation refs are refused: an agent cannot know the host's i18n keys.
|
|
166
|
+
- `openUrl` runs only as an action's top-level `functionCall`, and only when its handler gets a trusted click, key or pointerup event on the control (and, where the browser has `navigator.userActivation`, while it is active). An action the agent triggers, such as closing a Modal by writing its `open`, cannot open a page, and nor can an `openUrl` nested in another call or an event's context; the spec refuses it anywhere else. A custom adapter passes `action(prop)` as the handler itself, so the event reaches it.
|
|
167
|
+
- Each component renders inside an error boundary: one that throws (an adapter of your own too) renders nothing and reports `RENDER_ERROR` once, and the rest of the surface and the host keep rendering. The next data-model write retries it. A cascivo component whose required prop has no data yet renders a Skeleton until it arrives.
|
|
168
|
+
- An action's `a2uiClientDataModel` carries only the acting surface's data model, never another agent's.
|
|
169
|
+
- `createA2uiStore({ limits })` overrides `DEFAULT_A2UI_LIMITS`: surfaces, components, id length, data nodes, render depth and `maxRenderNodes` (default 20000, so shared ids cannot fan a tree out exponentially).
|
|
170
|
+
- The `regex` function refuses patterns with more than 2 quantifiers (an exact `{n}` does not count), repeat counts above 99, backreferences, nested quantifiers, and values over 256 characters.
|
|
171
|
+
|
|
172
|
+
### Custom adapters
|
|
173
|
+
|
|
174
|
+
An `A2uiAdapter` receives an `AdapterInput` (`component`, `prop`, `slot`, `children`, `resolve`, `typeOf`, `componentOf`, `writer`, `action`, `failingChecks`, `report`). Call `slot()` and `children()` at most once each, synchronously while the adapter runs, and place each returned node once. Later calls render nothing, because the render-node budget counts every node.
|
|
175
|
+
|
|
92
176
|
## Install
|
|
93
177
|
|
|
94
178
|
```sh
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { ReadonlySignal } from "@cascivo/core";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare const A2UI_VERSION = "v0.9";
|
|
4
|
+
export declare const BASIC_CATALOG_ID = "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json";
|
|
5
|
+
export declare const A2UI_CATALOG_ID = "https://cascivo.com/a2ui/v0_9/catalog.json";
|
|
6
|
+
interface A2uiComponent {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly component: string;
|
|
9
|
+
/** Every key except `id` and `component`. */
|
|
10
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
11
|
+
}
|
|
12
|
+
type A2uiServerMessage = {
|
|
13
|
+
kind: 'createSurface';
|
|
14
|
+
surfaceId: string;
|
|
15
|
+
catalogId: string;
|
|
16
|
+
theme?: Readonly<Record<string, unknown>>;
|
|
17
|
+
sendDataModel: boolean;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'updateComponents';
|
|
20
|
+
surfaceId: string;
|
|
21
|
+
components: readonly unknown[];
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'updateDataModel';
|
|
24
|
+
surfaceId: string;
|
|
25
|
+
path: string;
|
|
26
|
+
value: unknown;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'deleteSurface';
|
|
29
|
+
surfaceId: string;
|
|
30
|
+
};
|
|
31
|
+
interface A2uiErrorMessage {
|
|
32
|
+
version: 'v0.9';
|
|
33
|
+
error: {
|
|
34
|
+
code: string;
|
|
35
|
+
surfaceId: string;
|
|
36
|
+
message: string;
|
|
37
|
+
path?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface A2uiActionMessage {
|
|
41
|
+
version: 'v0.9';
|
|
42
|
+
action: {
|
|
43
|
+
name: string;
|
|
44
|
+
surfaceId: string;
|
|
45
|
+
sourceComponentId: string;
|
|
46
|
+
timestamp: string;
|
|
47
|
+
context: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
type Parsed = {
|
|
51
|
+
ok: true;
|
|
52
|
+
message: A2uiServerMessage;
|
|
53
|
+
} | {
|
|
54
|
+
ok: false;
|
|
55
|
+
error: A2uiErrorMessage;
|
|
56
|
+
};
|
|
57
|
+
export declare function parseServerMessage(raw: unknown): Parsed;
|
|
58
|
+
/** One problem with a component; `prop` is '' when it concerns the component as a whole. */
|
|
59
|
+
interface A2uiIssue {
|
|
60
|
+
readonly prop: string;
|
|
61
|
+
readonly message: string;
|
|
62
|
+
}
|
|
63
|
+
interface A2uiCatalogSpec {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
has(component: string): boolean;
|
|
66
|
+
validate(c: A2uiComponent): readonly A2uiIssue[];
|
|
67
|
+
}
|
|
68
|
+
export declare const cascivoCatalogSpec: A2uiCatalogSpec;
|
|
69
|
+
interface DataModel {
|
|
70
|
+
readonly root: ReadonlySignal<unknown>;
|
|
71
|
+
/** Absolute path only; one cached computed per path. */
|
|
72
|
+
read(path: string): ReadonlySignal<unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* `undefined` and `null` delete; `''` or `'/'` replace the whole model with an object.
|
|
75
|
+
* Throws `A2uiPathError` for a bad path, `A2uiDataError` for a value it refuses.
|
|
76
|
+
*/
|
|
77
|
+
write(path: string, value: unknown): void;
|
|
78
|
+
/** The whole model; `{}` while it is empty. */
|
|
79
|
+
snapshot(): unknown;
|
|
80
|
+
}
|
|
81
|
+
interface A2uiLimits {
|
|
82
|
+
maxSurfaces: number;
|
|
83
|
+
maxComponents: number;
|
|
84
|
+
maxIdLength: number;
|
|
85
|
+
maxDataNodes: number;
|
|
86
|
+
maxRenderDepth: number;
|
|
87
|
+
/** Nodes one surface may render; a tree of shared ids can otherwise fan out exponentially. */
|
|
88
|
+
maxRenderNodes: number;
|
|
89
|
+
}
|
|
90
|
+
export declare const DEFAULT_A2UI_LIMITS: Readonly<A2uiLimits>;
|
|
91
|
+
interface A2uiSurfaceState {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly catalogId: string;
|
|
94
|
+
readonly sendDataModel: boolean;
|
|
95
|
+
readonly theme: Readonly<Record<string, unknown>> | undefined;
|
|
96
|
+
readonly data: DataModel;
|
|
97
|
+
/** One stable signal per id, so a renderer can subscribe before the component arrives. */
|
|
98
|
+
component(id: string): ReadonlySignal<A2uiComponent | undefined>;
|
|
99
|
+
readonly hasRoot: ReadonlySignal<boolean>;
|
|
100
|
+
}
|
|
101
|
+
interface A2uiStore {
|
|
102
|
+
/** Applies one server message. Never throws; returns the errors to report, in input order. */
|
|
103
|
+
apply(raw: unknown): A2uiErrorMessage[];
|
|
104
|
+
readonly surfaceIds: ReadonlySignal<readonly string[]>;
|
|
105
|
+
surface(id: string): A2uiSurfaceState | undefined;
|
|
106
|
+
capabilities(): {
|
|
107
|
+
'v0.9': {
|
|
108
|
+
supportedCatalogIds: string[];
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The data models to send with an action: of `surfaceId` alone when given (the spec sends a
|
|
113
|
+
* model only to the server that created its surface), else of every sendDataModel surface.
|
|
114
|
+
* `undefined` when none qualifies.
|
|
115
|
+
*/
|
|
116
|
+
clientDataModel(surfaceId?: string): {
|
|
117
|
+
version: 'v0.9';
|
|
118
|
+
surfaces: Record<string, unknown>;
|
|
119
|
+
} | undefined;
|
|
120
|
+
readonly limits: A2uiLimits;
|
|
121
|
+
}
|
|
122
|
+
export declare function createA2uiStore(options: {
|
|
123
|
+
catalogs: readonly A2uiCatalogSpec[];
|
|
124
|
+
limits?: Partial<A2uiLimits>;
|
|
125
|
+
}): A2uiStore;
|
|
126
|
+
interface AdapterInput {
|
|
127
|
+
readonly component: A2uiComponent;
|
|
128
|
+
/** The resolved value; a URL key that fails `isSafeUrl` is `undefined`. */
|
|
129
|
+
prop(name: string): unknown;
|
|
130
|
+
/**
|
|
131
|
+
* Renders other nodes, a Skeleton for each id that has not arrived. Call it at most once, while
|
|
132
|
+
* the adapter runs, with every id the adapter needs; place each returned node once. A second or
|
|
133
|
+
* later call renders nothing (see `split`).
|
|
134
|
+
*/
|
|
135
|
+
children(ids: readonly string[]): ReactNode[];
|
|
136
|
+
/**
|
|
137
|
+
* A child list, a component id or text, by the shape of the slot's value. Call it at most once
|
|
138
|
+
* per name, while the adapter runs; place each returned node once (see `split`).
|
|
139
|
+
*/
|
|
140
|
+
slot(name: string): ReactNode;
|
|
141
|
+
/**
|
|
142
|
+
* Resolves a dynamic value nested inside a prop (a `{path}` binding or a function call, such as
|
|
143
|
+
* a Tabs title), as `prop` does for a top-level one; errors are reported once per surface.
|
|
144
|
+
* It does NOT URL-check: use it only for values rendered as text, and `prop()` or
|
|
145
|
+
* `isSafeUrl` for anything that reaches a URL sink (href, src, window.open).
|
|
146
|
+
*/
|
|
147
|
+
resolve(value: unknown): unknown;
|
|
148
|
+
/** The `component` type of node `id`, or undefined until it arrives; reactive. */
|
|
149
|
+
typeOf(id: string): string | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Node `id` as the agent sent it (validated by the store), or undefined until it arrives;
|
|
152
|
+
* reactive. Its values are raw: read them through `resolve`.
|
|
153
|
+
*/
|
|
154
|
+
componentOf(id: string): A2uiComponent | undefined;
|
|
155
|
+
/** Set only when `prop` is a `{path}` binding: writes to the bound path. */
|
|
156
|
+
writer(prop: string): ((value: unknown) => void) | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* Set only when `prop` holds an Action: dispatches it. Hand it the event that triggered it
|
|
159
|
+
* (pass it as the handler itself): an action whose functionCall is `openUrl` opens only for
|
|
160
|
+
* a trusted click, key or pointerup event.
|
|
161
|
+
*/
|
|
162
|
+
action(prop: string): ((event?: unknown) => void) | undefined;
|
|
163
|
+
/** Messages of the `checks` whose condition is not true. */
|
|
164
|
+
failingChecks(): readonly string[];
|
|
165
|
+
/**
|
|
166
|
+
* Reports an error, once per code and message for the surface; put the component id in
|
|
167
|
+
* `message` for one report per component.
|
|
168
|
+
*/
|
|
169
|
+
report(code: string, message: string): void;
|
|
170
|
+
}
|
|
171
|
+
type A2uiAdapter = (input: AdapterInput) => ReactNode;
|
|
172
|
+
interface A2uiRenderCatalog {
|
|
173
|
+
readonly id: string;
|
|
174
|
+
adapter(component: string): A2uiAdapter | undefined;
|
|
175
|
+
}
|
|
176
|
+
interface A2uiSurfaceProps {
|
|
177
|
+
store: A2uiStore;
|
|
178
|
+
surfaceId: string;
|
|
179
|
+
catalogs: readonly A2uiRenderCatalog[];
|
|
180
|
+
onAction?: (message: A2uiActionMessage, metadata: {
|
|
181
|
+
a2uiClientDataModel?: ReturnType<A2uiStore['clientDataModel']>;
|
|
182
|
+
}) => void;
|
|
183
|
+
onError?: (message: A2uiErrorMessage) => void;
|
|
184
|
+
openUrl?: (url: string) => void;
|
|
185
|
+
locale?: string;
|
|
186
|
+
fallback?: ReactNode;
|
|
187
|
+
}
|
|
188
|
+
/** Renders the surface `surfaceId` of `store`, drawing components through `catalogs`. */
|
|
189
|
+
export declare function A2uiSurface({ store, surfaceId, catalogs, onAction, onError, openUrl, locale, fallback }: A2uiSurfaceProps): ReactNode;
|
|
190
|
+
/** Draws every cascivo component through its manifest: data props, slots, events, checks. */
|
|
191
|
+
export declare const cascivoCatalog: A2uiRenderCatalog;
|
|
192
|
+
/** The A2UI v0.9 basic catalog, every component drawn with its cascivo counterpart. */
|
|
193
|
+
export declare const basicCatalog: A2uiRenderCatalog;
|
|
194
|
+
export declare const basicCatalogSpec: A2uiCatalogSpec;
|
|
195
|
+
/** Render catalogs for `<A2uiSurface catalogs>`, in the order the store's specs are given. */
|
|
196
|
+
export declare const defaultCatalogs: readonly [A2uiRenderCatalog, A2uiRenderCatalog];
|
|
197
|
+
/** Specs for `createA2uiStore({ catalogs })`; pairs with `defaultCatalogs`. */
|
|
198
|
+
export declare const defaultCatalogSpecs: readonly [A2uiCatalogSpec, A2uiCatalogSpec];
|
|
199
|
+
export type { A2uiActionMessage, A2uiAdapter, A2uiCatalogSpec, A2uiComponent, A2uiErrorMessage, A2uiLimits, A2uiRenderCatalog, A2uiStore, A2uiSurfaceProps, A2uiSurfaceState, AdapterInput };
|
|
200
|
+
//# sourceMappingURL=a2ui-v0_9.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,c as t,i as n,n as r,o as i,r as a,t as o}from"./prop-schemas-7gVWDISz.js";import{a as s,t as c}from"./node-props-LGzuaTTg.js";import{batch as l,computed as u,signal as d,useId as f,useSignal as p,useSignals as m}from"@cascivo/core";import{builtin as h,currentLocale as g,t as _}from"@cascivo/i18n";import v from"react";import{Button as y,Card as b,Checkbox as x,DatePicker as S,Flex as C,Heading as ee,Image as te,Input as w,Link as ne,Modal as T,NumberInput as E,Select as D,Separator as re,Skeleton as O,Slider as k,Tabs as ie,TabsContent as ae,TabsList as oe,TabsTrigger as se,Text as A,Textarea as j,TimePicker as ce,VisuallyHidden as le}from"@cascivo/react";import{Fragment as ue,jsx as M,jsxs as N}from"react/jsx-runtime";var P=`v0.9`,F=`https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json`,I=`https://cascivo.com/a2ui/v0_9/catalog.json`,de=/* @__PURE__ */ new Set([`v0.9`,`v0.9.1`]);function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function errorMessage(e,t,n,r){return{version:P,error:r===void 0?{code:e,surfaceId:t,message:n}:{code:e,surfaceId:t,message:n,path:r}}}function actionMessage(e){return{version:P,action:{name:e.name,surfaceId:e.surfaceId,sourceComponentId:e.sourceComponentId,timestamp:(e.now??/* @__PURE__ */ new Date).toISOString(),context:e.context??{}}}}var L=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`];function unknownKey(e,t){return Object.keys(e).find(e=>!t.includes(e))}function parseServerMessage(e){let t=``,fail=e=>({ok:!1,error:errorMessage(`INVALID_MESSAGE`,t,e)});if(!isRecord(e))return fail(`A2UI message must be a JSON object.`);let n=L.filter(t=>Object.hasOwn(e,t)),r=n.length===1?e[n[0]]:void 0;isRecord(r)&&typeof r.surfaceId==`string`&&(t=r.surfaceId);let i=e.version;if(typeof i!=`string`||!de.has(i))return fail(`Unsupported or missing "version"; expected "${P}".`);let a=unknownKey(e,[`version`,...L]);if(a!==void 0)return fail(`Unknown envelope key "${a}".`);if(n.length!==1)return fail(`Expected exactly one of ${L.join(`, `)}; got ${n.length}.`);let o=n[0];if(!isRecord(r))return fail(`"${o}" must be an object.`);if(typeof r.surfaceId!=`string`||r.surfaceId===``)return fail(`"${o}.surfaceId" must be a non-empty string.`);let s=r.surfaceId;switch(o){case`createSurface`:{let e=unknownKey(r,[`surfaceId`,`catalogId`,`theme`,`sendDataModel`]);if(e!==void 0)return fail(`Unknown key "${e}" in createSurface.`);let t=r.catalogId;if(typeof t!=`string`||t===``)return fail(`"createSurface.catalogId" must be a non-empty string.`);let n=r.theme;if(n!==void 0&&!isRecord(n))return fail(`"createSurface.theme" must be an object.`);let i=r.sendDataModel;return i!==void 0&&typeof i!=`boolean`?fail(`"createSurface.sendDataModel" must be a boolean.`):{ok:!0,message:{kind:o,surfaceId:s,catalogId:t,...n===void 0?{}:{theme:n},sendDataModel:i===!0}}}case`updateComponents`:{let e=unknownKey(r,[`surfaceId`,`components`]);if(e!==void 0)return fail(`Unknown key "${e}" in updateComponents.`);let t=r.components;return!Array.isArray(t)||t.length===0?fail(`"updateComponents.components" must be a non-empty array.`):{ok:!0,message:{kind:o,surfaceId:s,components:t}}}case`updateDataModel`:{let e=unknownKey(r,[`surfaceId`,`path`,`value`]);if(e!==void 0)return fail(`Unknown key "${e}" in updateDataModel.`);let t=r.path;return t!==void 0&&typeof t!=`string`?fail(`"updateDataModel.path" must be a string.`):{ok:!0,message:{kind:o,surfaceId:s,path:t??`/`,value:r.value}}}default:{let e=unknownKey(r,[`surfaceId`]);return e===void 0?{ok:!0,message:{kind:`deleteSurface`,surfaceId:s}}:fail(`Unknown key "${e}" in deleteSurface.`)}}}function parseComponent(e,t,n,r){let fail=(e,r)=>({ok:!1,error:errorMessage(`VALIDATION_FAILED`,n,r,`/components/${t}/${e}`)});if(!isRecord(e))return fail(`id`,`Component ${t} must be an object.`);let{id:i,component:a,...o}=e;return typeof i!=`string`||i===``||i.length>r?fail(`id`,`Component ${t} needs a non-empty string "id" of at most ${r} characters.`):typeof a!=`string`||a===``?fail(`component`,`Component "${i}" needs a string "component" name.`):{ok:!0,component:{id:i,component:a,props:o}}}var hasOwn$2=(e,t)=>Object.hasOwn(e,t);function lookup(e,t){return typeof t==`string`&&hasOwn$2(e,t)?e[t]:void 0}function str(e){return typeof e==`string`?e:typeof e==`number`?String(e):void 0}function urlOf(e){let t=e.prop(`url`);return typeof t==`string`&&i(t)?t:void 0}function idOf(e,t){let n=e.component.props[t];return typeof n==`string`?[n]:[]}function opt(e,t){return t===void 0?{}:{[e]:t}}var fe={h1:1,h2:2,h3:3,h4:4,h5:5},text=e=>{let t=str(e.prop(`text`))??``,n=e.prop(`variant`),r=lookup(fe,n);return r===void 0?n===`caption`?/* @__PURE__ */ M(A,{size:`sm`,muted:!0,children:t}):/* @__PURE__ */ M(A,{children:t}):/* @__PURE__ */ M(ee,{level:r,children:t})};function a11yLabel(e){let t=e.prop(`accessibility`);return isRecord(t)?str(t.label):void 0}var image=e=>{let t=urlOf(e);return t===void 0?null:/* @__PURE__ */ M(te,{src:t,alt:a11yLabel(e)??str(e.prop(`description`))??``})},icon=e=>(e.report(`UNSUPPORTED_COMPONENT`,`Icon is not supported by the cascivo renderer; Icons are not rendered.`),null),media=e=>{let t=urlOf(e);return t===void 0?null:/* @__PURE__ */ M(ne,{href:t,external:!0,children:str(e.prop(`description`))??_(h.a2ui.openMedia)})},pe={start:`start`,center:`center`,end:`end`,spaceBetween:`between`,spaceAround:`between`,spaceEvenly:`between`,stretch:`start`},me={start:`start`,center:`center`,end:`end`,stretch:`stretch`};function flex(e,t){return/* @__PURE__ */ M(C,{direction:t,...opt(`justify`,lookup(pe,e.prop(`justify`))),...opt(`align`,lookup(me,e.prop(`align`))),children:e.slot(`children`)})}var row$1=e=>flex(e,`horizontal`),column=e=>flex(e,`vertical`),list=e=>flex(e,e.prop(`direction`)===`horizontal`?`horizontal`:`vertical`),card=e=>/* @__PURE__ */ M(b,{children:e.children(idOf(e,`child`))}),tabs=e=>{let t=e.component.props.tabs,n=Array.isArray(t)?t.filter(isRecord):[],r=e.children(n.map(e=>typeof e.child==`string`?e.child:``));return/* @__PURE__ */ N(ie,{defaultValue:`tab-0`,children:[/* @__PURE__ */ M(oe,{children:n.map((t,n)=>/* @__PURE__ */ M(se,{value:`tab-${n}`,children:str(e.resolve(t.title))??``},n))}),r.map((e,t)=>/* @__PURE__ */ M(ae,{value:`tab-${t}`,children:e},t))]})};function ModalAdapter(e){let t=p(!1),n=idOf(e,`trigger`),[r,i]=e.children([...n,...idOf(e,`content`)]),a=a11yLabel(e)??_(h.a2ui.dialog),show=()=>{t.value=!0},o=n[0]!==void 0&&e.typeOf(n[0])===`Button`;return/* @__PURE__ */ N(ue,{children:[o?/* @__PURE__ */ M(`div`,{style:{display:`contents`},onClick:show,children:r}):/* @__PURE__ */ M(`div`,{role:`button`,tabIndex:0,"aria-haspopup":`dialog`,onClick:show,onKeyDown:e=>{e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),show())},children:r}),/* @__PURE__ */ M(T,{open:t.value,onClose:()=>{t.value=!1},title:a,children:i})]})}var divider=e=>/* @__PURE__ */ M(re,{orientation:e.prop(`axis`)===`vertical`?`vertical`:`horizontal`}),R={primary:`primary`,default:`secondary`,borderless:`ghost`};function iconName(e,t){if(t!==void 0&&e.typeOf(t)===`Icon`)return str(e.resolve(e.componentOf(t)?.props.name))?.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).toLowerCase()}var button=e=>{let t=idOf(e,`child`),[n]=e.children(t),r=a11yLabel(e),i=r===void 0?iconName(e,t[0]):void 0;return/* @__PURE__ */ N(y,{variant:lookup(R,e.prop(`variant`))??`secondary`,disabled:e.failingChecks().length>0,...opt(`aria-label`,r),...opt(`onClick`,e.action(`action`)),children:[n,i!==void 0&&/* @__PURE__ */ M(le,{children:i})]})};function fieldError(e,t){let n=e.failingChecks()[0];if(n!==void 0)return n;let r=e.component.props.validationRegexp;if(typeof r==`string`&&t!==``)return e.resolve({call:`regex`,args:{value:t,pattern:r}})===!0?void 0:_(h.a2ui.invalid)}var textField=e=>{let t=str(e.prop(`label`)),n=str(e.prop(`value`))??``,r=e.writer(`value`),i=e.prop(`variant`),a={...opt(`label`,t),...opt(`error`,fieldError(e,n))};if(i===`number`){let e=n.trim()===``?null:Number(n),t=e!==null&&Number.isFinite(e)?e:null;return r===void 0?/* @__PURE__ */ M(E,{...a,...opt(`defaultValue`,t??void 0)}):/* @__PURE__ */ M(E,{...a,value:t,onValueChange:e=>r(e===null?``:String(e))})}if(i===`longText`)return r===void 0?/* @__PURE__ */ M(j,{...a,defaultValue:n}):/* @__PURE__ */ M(j,{...a,value:n,onChange:e=>r(e.currentTarget.value)});let o=i===`obscured`?`password`:`text`;return r===void 0?/* @__PURE__ */ M(w,{...a,type:o,defaultValue:n}):/* @__PURE__ */ M(w,{...a,type:o,value:n,onChange:e=>r(e.currentTarget.value)})},checkBox=e=>{let t=str(e.prop(`label`)),n=e.prop(`value`)===!0,r=e.writer(`value`);return r===void 0?/* @__PURE__ */ M(x,{...opt(`label`,t),defaultChecked:n}):/* @__PURE__ */ M(x,{...opt(`label`,t),checked:n,onChange:e=>r(e.currentTarget.checked)})};function ChoicePickerAdapter(e){let t=f(`cascivo-a2ui-choice`),n=str(e.prop(`label`)),r=e.component.props.options,i=(Array.isArray(r)?r.filter(isRecord):[]).map(t=>{let n=typeof t.value==`string`?t.value:``;return{value:n,label:str(e.resolve(t.label))??n}}),a=e.prop(`value`),o=Array.isArray(a)?a.filter(e=>typeof e==`string`):[],s=e.writer(`value`),c=e.failingChecks()[0];if(e.prop(`variant`)===`multipleSelection`)return/* @__PURE__ */ N(C,{direction:`vertical`,role:`group`,...opt(`aria-labelledby`,n?t:void 0),...opt(`aria-describedby`,c===void 0?void 0:`${t}-error`),children:[n!==void 0&&/* @__PURE__ */ M(A,{as:`span`,id:t,children:n}),i.map((e,t)=>{let n=o.includes(e.value);return s===void 0?/* @__PURE__ */ M(x,{label:e.label,defaultChecked:n},t):/* @__PURE__ */ M(x,{label:e.label,checked:n,onChange:t=>{let n=o.filter(t=>t!==e.value);s(t.currentTarget.checked?[...n,e.value]:n)}},t)}),c!==void 0&&/* @__PURE__ */ M(A,{as:`span`,size:`sm`,role:`alert`,id:`${t}-error`,children:c})]});let l={...opt(`label`,n),...opt(`error`,c),...opt(`placeholder`,o[0]===void 0?_(h.a2ui.choose):void 0),options:i};return s===void 0?/* @__PURE__ */ M(D,{...l,defaultValue:o[0]??``}):/* @__PURE__ */ M(D,{...l,value:o[0]??``,onChange:e=>s([e.currentTarget.value])})}var slider=e=>{let t=e.prop(`value`),n=e.prop(`min`),r=e.prop(`max`),i={...opt(`label`,str(e.prop(`label`))),...opt(`min`,typeof n==`number`?n:void 0),...opt(`max`,typeof r==`number`?r:void 0)},a=typeof t==`number`?t:typeof n==`number`?n:0,o=e.writer(`value`);return o===void 0?/* @__PURE__ */ M(k,{...i,defaultValue:a}):/* @__PURE__ */ M(k,{...i,value:a,onChange:e=>o(Number(e.currentTarget.value))})},he=/^(\d{4}-\d{2}-\d{2})/,z=/(?:^|T)(\d{2}:\d{2})/;function parts(e){return typeof e==`string`?{...opt(`date`,he.exec(e)?.[1]),...opt(`time`,z.exec(e)?.[1])}:{}}function combine(e,t){return e&&t?`${e}T${t}`:e||t||``}var ge={Text:text,Image:image,Icon:icon,Video:media,AudioPlayer:media,Row:row$1,Column:column,List:list,Card:card,Tabs:tabs,Modal:ModalAdapter,Divider:divider,Button:button,TextField:textField,CheckBox:checkBox,ChoicePicker:ChoicePickerAdapter,Slider:slider,DateTimeInput:e=>{let t=str(e.prop(`label`)),{date:n,time:r}=parts(e.prop(`value`)),i=parts(e.prop(`min`)),a=parts(e.prop(`max`)),o=e.writer(`value`),s=e.failingChecks()[0],c=e.prop(`enableTime`)===!0,l=e.prop(`enableDate`)===!0||!c,u=/* @__PURE__ */ M(S,{...opt(`label`,t),...opt(`error`,s),...opt(`min`,i.date),...opt(`max`,a.date),...o===void 0?opt(`defaultValue`,n):{value:n??``,onValueChange:e=>o(combine(e,c?r:void 0))}}),d=/* @__PURE__ */ M(ce,{...l?opt(`ariaLabel`,t===void 0?_(h.a2ui.time):`${t}, ${_(h.a2ui.time)}`):opt(`label`,t),...l?{}:opt(`error`,s),...opt(`min`,i.time),...opt(`max`,a.time),...o===void 0?opt(`defaultValue`,r):{value:r??``,onValueChange:e=>o(combine(l?n:void 0,e||void 0))}});return l&&c?/* @__PURE__ */ N(C,{direction:`horizontal`,wrap:!0,children:[u,d]}):c?d:u}},B={id:F,adapter:e=>lookup(ge,e)},V={Accordion:{slots:{children:{arity:`many`,text:!0}},events:[`onValueChange`]},Alert:{slots:{children:{arity:`many`,text:!0},icon:{arity:`one`}},events:[`onDismiss`]},AutoGrid:{slots:{children:{arity:`many`,text:!0}},events:[]},Avatar:{slots:{},events:[]},AvatarGroup:{slots:{children:{arity:`many`,text:!0}},events:[]},Badge:{slots:{children:{arity:`many`,text:!0}},events:[]},Blockquote:{slots:{children:{arity:`many`,text:!0}},events:[]},Breadcrumb:{slots:{},events:[]},Button:{slots:{children:{arity:`many`,text:!0}},events:[`onClick`]},Card:{slots:{actions:{arity:`one`},children:{arity:`many`,text:!0}},events:[]},CardContent:{slots:{children:{arity:`many`,text:!0}},events:[]},CardFooter:{slots:{children:{arity:`many`,text:!0}},events:[]},CardHeader:{slots:{children:{arity:`many`,text:!0}},events:[]},CardTitle:{slots:{children:{arity:`many`,text:!0}},events:[]},Center:{slots:{children:{arity:`many`,text:!0}},events:[]},Checkbox:{slots:{},events:[`onChange`]},CheckboxCard:{slots:{description:{arity:`one`},title:{arity:`one`}},events:[`onCheckedChange`]},Code:{slots:{children:{arity:`many`,text:!0}},events:[]},Columns:{slots:{children:{arity:`many`,text:!0}},events:[]},Combobox:{slots:{},events:[`onCreate`,`onOpenChange`,`onSearchChange`,`onValueChange`]},CommandMenu:{slots:{},events:[`onOpenChange`,`onQueryChange`]},DataTable:{slots:{emptyState:{arity:`one`},noResultsState:{arity:`one`},toolbar:{arity:`one`}},events:[`onCellEdit`,`onColumnStateChange`,`onFiltersChange`,`onSortChange`]},DatePicker:{slots:{},events:[`onOpenChange`,`onValueChange`]},Dropdown:{slots:{trigger:{arity:`one`}},events:[`onOpenChange`,`onSelect`]},EmptyState:{slots:{action:{arity:`one`},icon:{arity:`one`}},events:[]},FileUploader:{slots:{},events:[`onFilesAdded`,`onRejected`,`onRemove`]},Flex:{slots:{children:{arity:`many`,text:!0}},events:[]},Form:{slots:{children:{arity:`many`,text:!0}},events:[`onValid`]},Grid:{slots:{children:{arity:`many`,text:!0}},events:[]},GridItem:{slots:{children:{arity:`many`,text:!0}},events:[]},Header:{slots:{actions:{arity:`one`},brand:{arity:`one`}},events:[]},HeaderPanel:{slots:{children:{arity:`many`,text:!0}},events:[`onClose`]},Heading:{slots:{children:{arity:`many`,text:!0}},events:[]},Image:{slots:{},events:[]},Input:{slots:{},events:[`onChange`]},InputGroup:{slots:{children:{arity:`many`,text:!0},prefix:{arity:`one`},suffix:{arity:`one`}},events:[]},Kbd:{slots:{children:{arity:`many`,text:!0}},events:[]},LargeTitleHeader:{slots:{actions:{arity:`one`},children:{arity:`many`,text:!0},leading:{arity:`one`}},events:[]},Link:{slots:{children:{arity:`many`,text:!0}},events:[]},List:{slots:{children:{arity:`many`,text:!0}},events:[]},ListItem:{slots:{children:{arity:`many`,text:!0}},events:[]},Modal:{slots:{children:{arity:`many`,text:!0},footer:{arity:`one`}},events:[`onClose`]},NumberInput:{slots:{},events:[`onValueChange`]},OverflowMenu:{slots:{},events:[`onSelect`]},PageHeader:{slots:{actions:{arity:`one`},breadcrumb:{arity:`one`},description:{arity:`one`},title:{arity:`one`}},events:[]},Pagination:{slots:{},events:[`onPageChange`,`onPageSizeChange`]},Progress:{slots:{},events:[]},ProgressBar:{slots:{},events:[]},ProgressIndicator:{slots:{},events:[]},Radio:{slots:{},events:[]},RadioCard:{slots:{description:{arity:`one`},title:{arity:`one`}},events:[`onValueChange`]},RadioCardGroup:{slots:{children:{arity:`many`,text:!0}},events:[`onValueChange`]},Search:{slots:{},events:[`onSearch`,`onValueChange`]},Select:{slots:{},events:[`onChange`]},Separator:{slots:{},events:[]},ShellHeader:{slots:{brand:{arity:`one`},center:{arity:`one`},end:{arity:`one`}},events:[`onMenuClick`]},SideNav:{slots:{footer:{arity:`one`},header:{arity:`one`}},events:[`onCollapsedChange`]},Skeleton:{slots:{},events:[]},Slider:{slots:{},events:[`onChange`]},Spacer:{slots:{},events:[]},Spinner:{slots:{},events:[]},Stat:{slots:{visual:{arity:`one`}},events:[]},Status:{slots:{children:{arity:`many`,text:!0}},events:[]},Steps:{slots:{},events:[]},Switcher:{slots:{},events:[]},Tabs:{slots:{children:{arity:`many`,text:!0}},events:[`onValueChange`]},Tag:{slots:{children:{arity:`many`,text:!0}},events:[`onDismiss`]},Text:{slots:{children:{arity:`many`,text:!0}},events:[]},Textarea:{slots:{},events:[`onChange`]},TimePicker:{slots:{},events:[`onValueChange`]},Timeline:{slots:{},events:[]},Toast:{slots:{},events:[]},Toggle:{slots:{},events:[`onValueChange`]},Tooltip:{slots:{children:{arity:`many`,text:!0},content:{arity:`one`}},events:[]}},_e=[`string`,`number`,`boolean`,`array`,`object`,`any`,`void`];function isBinding(e){if(!isRecord(e))return!1;let t=Object.keys(e);return t.length===1&&t[0]===`path`&&typeof e.path==`string`}function isFunctionCall(e){if(!isRecord(e)||typeof e.call!=`string`)return!1;for(let[t,n]of Object.entries(e))if(t!==`call`&&!(t===`args`&&isRecord(n))&&!(t===`returnType`&&typeof n==`string`&&_e.includes(n)))return!1;return!0}function hasTranslationRef(e){let t=[e];for(;t.length>0;){let e=t.pop();if(typeof e==`object`&&e){if(!Array.isArray(e)&&Object.hasOwn(e,`$t`))return!0;for(let n of Object.values(e))t.push(n)}}return!1}var ve=/\$\{\s*openUrl\s*\(/,hidesOpenUrl=e=>ve.test(e.replaceAll(`\\`,``));function checkOpenUrl(e,t){let n=e;if(t&&isRecord(e)&&isRecord(e.functionCall)){let t=e.functionCall;t.call===`openUrl`&&(n=t.args)}let r=[n];for(;r.length>0;){let e=r.pop();if(typeof e==`string`&&hidesOpenUrl(e))return`openUrl may only be the functionCall of an action`;if(typeof e==`object`&&e){if(isRecord(e)&&e.call===`openUrl`)return`openUrl may only be the functionCall of an action`;for(let t of Object.values(e))r.push(t)}}}var isDynamicRef=e=>isBinding(e)||isFunctionCall(e);function checkDynamic(e,t,n){return t(e)||isDynamicRef(e)?void 0:`expected ${n}, a {path} binding or a {call} function call`}var checkDynString=e=>checkDynamic(e,e=>typeof e==`string`,`a string`),checkDynNumber=e=>checkDynamic(e,e=>typeof e==`number`&&Number.isFinite(e),`a number`),checkDynBool=e=>checkDynamic(e,e=>typeof e==`boolean`,`a boolean`),checkDynStringList=e=>checkDynamic(e,e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),`a string array`);function checkChildList(e){if(Array.isArray(e))return e.every(e=>typeof e==`string`&&e!==``)?void 0:`expected an array of component ids`;if(!(isRecord(e)&&Object.keys(e).length===2&&typeof e.componentId==`string`&&typeof e.path==`string`))return`expected an array of component ids or {componentId, path}`}function checkComponentId(e){return typeof e==`string`&&e!==``?void 0:`expected a component id string`}function checkAction(e){if(isRecord(e)){let t=Object.keys(e);if(t.length===1&&t[0]===`event`){let t=e.event;if(isRecord(t)&&typeof t.name==`string`&&t.name!==``&&Object.keys(t).every(e=>e===`name`||e===`context`)&&(t.context===void 0||isRecord(t.context)))return}if(t.length===1&&t[0]===`functionCall`&&isFunctionCall(e.functionCall))return}return`expected {event: {name, context?}} or {functionCall: {call, args?}}`}var checkTextSlot=e=>checkChildList(e)===void 0||checkDynString(e)===void 0?void 0:`expected text, a child id list, a {path} binding or a {call} function call`;function checkChecks(e){if(!Array.isArray(e))return`expected an array of {condition, message}`;for(let t of e)if(!isRecord(t)||typeof t.message!=`string`||!Object.hasOwn(t,`condition`)||Object.keys(t).some(e=>e!==`condition`&&e!==`message`)||checkDynBool(t.condition)!==void 0)return`each check must be {condition: boolean | binding | call, message: string}`}function checkAccessibility(e){if(!(isRecord(e)&&Object.entries(e).every(([e,t])=>(e===`label`||e===`description`)&&checkDynString(t)===void 0)))return`expected {label?, description?} dynamic strings`}function checkCommonKey(e,t,n){if(e===`accessibility`)return checkAccessibility(t)??null;if(e===`checks`)return n.checks?checkChecks(t)??null:`only Checkable components accept "checks"`;if(e===`weight`&&n.weight)return typeof t==`number`&&Number.isFinite(t)?null:`expected a number`}function unknownProperty(t,n){let r=e(t,[...n]);return{prop:t,message:`Unknown property "${t}".${r===void 0?``:` Did you mean "${r}"?`}`}}var unknownComponent=e=>({prop:``,message:`Unknown component "${e}".`}),hasOwn$1=(e,t)=>Object.hasOwn(e,t),H={id:I,has:e=>t.has(e),validate(e){if(!t.has(e.component))return[unknownComponent(e.component)];let r=[],i=hasOwn$1(o,e.component)?o[e.component]??[]:[],s=hasOwn$1(V,e.component)?V[e.component]:void 0,c=s?.slots??{},l=s?.events??[],u=[...i.map(e=>e.name),...Object.keys(c),...l,`accessibility`,`checks`];for(let[t,o]of Object.entries(e.props)){let e=checkOpenUrl(o,l.includes(t)&&!hasOwn$1(c,t));if(e!==void 0){r.push({prop:t,message:`Invalid "${t}": ${e}.`});continue}let s=checkCommonKey(t,o,{checks:!0,weight:!1});if(s!==void 0){s!==null&&r.push({prop:t,message:`Invalid "${t}": ${s}.`});continue}if(hasOwn$1(c,t)){let e=c[t],n=e?.text===!0?checkTextSlot(o):e?.arity===`one`?checkComponentId(o):checkChildList(o);n!==void 0&&r.push({prop:t,message:`Invalid "${t}": ${n}.`});continue}if(l.includes(t)){let e=checkAction(o);e!==void 0&&r.push({prop:t,message:`Invalid "${t}": ${e}.`});continue}let d=i.find(e=>e.name===t);if(d!==void 0){if(isDynamicRef(o))continue;if(hasTranslationRef(o)){r.push({prop:t,message:`Invalid "${t}": a {$t} translation ref names a host i18n key; send the text itself.`});continue}let e=[];a(d,o,t,t,e),n(o,t,t,e);for(let n of e)r.push({prop:t,message:n.message});continue}r.push(unknownProperty(t,u))}for(let t of i)t.required&&!Object.hasOwn(e.props,t.name)&&r.push({prop:t.name,message:`Missing required property "${t.name}".`});return r}},row=(e,t=[],n=!1)=>({props:e,required:t,checkable:n}),U=`enum:start,center,end,stretch`,W=`enum:start,center,end,spaceBetween,spaceAround,spaceEvenly,stretch`,G={Text:row({text:`dynString`,variant:`enum:h1,h2,h3,h4,h5,caption,body`},[`text`]),Image:row({url:`dynString`,description:`dynString`,fit:`enum:contain,cover,fill,none,scaleDown`,variant:`enum:icon,avatar,smallFeature,mediumFeature,largeFeature,header`},[`url`]),Icon:row({name:`dynString`},[`name`]),Video:row({url:`dynString`},[`url`]),AudioPlayer:row({url:`dynString`,description:`dynString`},[`url`]),Row:row({children:`childList`,justify:W,align:U},[`children`]),Column:row({children:`childList`,justify:W,align:U},[`children`]),List:row({children:`childList`,direction:`enum:vertical,horizontal`,align:U},[`children`]),Card:row({child:`componentId`},[`child`]),Tabs:row({tabs:`tabs`},[`tabs`]),Modal:row({trigger:`componentId`,content:`componentId`},[`trigger`,`content`]),Divider:row({axis:`enum:horizontal,vertical`}),Button:row({child:`componentId`,variant:`enum:default,primary,borderless`,action:`action`},[`child`,`action`],!0),TextField:row({label:`dynString`,value:`dynString`,variant:`enum:longText,number,shortText,obscured`,validationRegexp:`literal:string`},[`label`],!0),CheckBox:row({label:`dynString`,value:`dynBool`},[`label`,`value`],!0),ChoicePicker:row({label:`dynString`,variant:`enum:multipleSelection,mutuallyExclusive`,options:`options`,value:`dynStringList`,displayStyle:`enum:checkbox,chips`,filterable:`literal:boolean`},[`options`,`value`],!0),Slider:row({label:`dynString`,min:`literal:number`,max:`literal:number`,value:`dynNumber`},[`value`,`max`],!0),DateTimeInput:row({value:`dynString`,enableDate:`literal:boolean`,enableTime:`literal:boolean`,min:`dynString`,max:`dynString`,label:`dynString`},[`value`],!0)};function checkTabs(e){return Array.isArray(e)&&e.length>0&&e.every(e=>isRecord(e)&&Object.keys(e).every(e=>e===`title`||e===`child`)&&checkDynString(e.title)===void 0&&Object.hasOwn(e,`title`)&&checkComponentId(e.child)===void 0)?void 0:`expected a non-empty array of {title, child}`}function checkOptions(e){return Array.isArray(e)&&e.every(e=>isRecord(e)&&Object.keys(e).every(e=>e===`label`||e===`value`)&&Object.hasOwn(e,`label`)&&checkDynString(e.label)===void 0&&typeof e.value==`string`)?void 0:`expected an array of {label, value}`}function checkKind(e,t){if(e.startsWith(`enum:`)){let n=e.slice(5).split(`,`);return typeof t==`string`&&n.includes(t)?void 0:`expected one of: ${n.join(`, `)}`}if(e.startsWith(`literal:`)){let n=e.slice(8);return typeof t===n&&(n!==`number`||Number.isFinite(t))?void 0:`expected a ${n}`}switch(e){case`dynString`:return checkDynString(t);case`dynNumber`:return checkDynNumber(t);case`dynBool`:return checkDynBool(t);case`dynStringList`:return checkDynStringList(t);case`childList`:return checkChildList(t);case`componentId`:return checkComponentId(t);case`action`:return checkAction(t);case`tabs`:return checkTabs(t);default:return checkOptions(t)}}var K={id:F,has:e=>Object.hasOwn(G,e),validate(e){let t=Object.hasOwn(G,e.component)?G[e.component]:void 0;if(t===void 0)return[unknownComponent(e.component)];let r=[],i=[...Object.keys(t.props),`accessibility`,`weight`];t.checkable&&i.push(`checks`);for(let[a,o]of Object.entries(e.props)){let e=checkOpenUrl(o,Object.hasOwn(t.props,a)&&t.props[a]===`action`);if(e!==void 0){r.push({prop:a,message:`Invalid "${a}": ${e}.`});continue}let s=checkCommonKey(a,o,{checks:t.checkable,weight:!0});if(s!==void 0){s!==null&&r.push({prop:a,message:`Invalid "${a}": ${s}.`});continue}let c=Object.hasOwn(t.props,a)?t.props[a]:void 0;if(c===void 0){r.push(unknownProperty(a,i));continue}let l=checkKind(c,o);if(l!==void 0){r.push({prop:a,message:`Invalid "${a}": ${l}.`});continue}if(typeof o==`string`){let e=[];n(o,a,a,e);for(let t of e)r.push({prop:a,message:t.message})}}for(let n of t.required)Object.hasOwn(e.props,n)||r.push({prop:n,message:`Missing required property "${n}".`});return r}},A2uiPathError=class extends Error{constructor(e){super(e),this.name=`A2uiPathError`}},ye=/* @__PURE__ */ new Set([`__proto__`,`prototype`,`constructor`]),q=/^(0|[1-9]\d*)$/;function resolvePath(e,t){if(e===``||e.startsWith(`/`))return e;if(t===``||t===`/`)throw new A2uiPathError(`relative path "${e}" outside a template scope`);return`${t.replace(/\/$/,``)}/${e}`}function assertSafe(e){if(ye.has(e))throw new A2uiPathError(`forbidden path segment "${e}"`)}function parsePointer(e){if(e===``||e===`/`)return[];if(!e.startsWith(`/`))throw new A2uiPathError(`path "${e}" is not absolute`);return e.slice(1).split(`/`).map(e=>{let t=e.replace(/~1/g,`/`).replace(/~0/g,`~`);return assertSafe(t),t})}var isContainer=e=>typeof e==`object`&&!!e;function getAt(e,t){let n=e;for(let e of t){if(!isContainer(n))return;if(Array.isArray(n)){if(!q.test(e))return;n=n[Number(e)]}else{if(!Object.hasOwn(n,e))return;n=n[e]}}return n}function setAt(e,t,n){let[r,...i]=t;if(r===void 0)return n;if(assertSafe(r),Array.isArray(e)){if(!q.test(r))throw new A2uiPathError(`"${r}" is not an array index`);let t=Number(r);if(t>e.length)throw new A2uiPathError(`index ${t} is past the end of the array`);if(n===void 0&&t===e.length)return e;let a=setAt(e[t],i,n);if(a===e[t]&&t<e.length)return e;let o=e.slice();return o[t]=a,o}let a=isContainer(e)?e:{},o=Object.hasOwn(a,r);if(n===void 0&&!o)return e;let s=setAt(o?a[r]:void 0,i,n);if(o&&s===a[r])return e;let c={...a};return i.length===0&&n===void 0?delete c[r]:c[r]=s,c}var be=1e4,A2uiDataError=class extends Error{code;constructor(e,t){super(t),this.name=`A2uiDataError`,this.code=e}},isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function countNodes(e,t){let n=0,r=[e];for(;r.length>0;){let e=r.pop();if(++n>t)return n;if(typeof e==`object`&&e)for(let t of Object.values(e))r.push(t)}return n}function createDataModel(e,t){let n=t?.maxNodes??be,r=d(e),i=/* @__PURE__ */ new Map,absolute=e=>{if(e!==``&&!e.startsWith(`/`))throw new A2uiPathError(`path "${e}" must be absolute`);return parsePointer(e)};return{root:r,read(e){let t=i.get(e);if(t)return t;let n=absolute(e),a=u(()=>getAt(r.value,n));return i.set(e,a),a},write(e,t){let i=absolute(e),a=t===null?void 0:t;if(i.length===0&&a!==void 0&&!isObject(a))throw new A2uiDataError(`INVALID_VALUE`,`The data model root must be an object.`);if(countNodes(a,n)>n)throw new A2uiDataError(`LIMIT_EXCEEDED`,`At most ${n} JSON nodes per value.`);l(()=>{r.value=setAt(r.peek(),i,a)})},snapshot(){return r.peek()??{}}}}var xe=/* @__PURE__ */ new Set([`click`,`keydown`,`keyup`,`pointerup`]);function isTrustedGesture(e){if(typeof e!=`object`||!e)return!1;let t=`nativeEvent`in e?e.nativeEvent:e;return typeof t!=`object`||!t||!(`isTrusted`in t)||t.isTrusted!==!0?!1:`type`in t&&typeof t.type==`string`&&xe.has(t.type)}var Se=16,Ce=256,J=256,we=2,Y=1e4;function isSafeRegexPattern(e){if(e.length>Ce)return!1;let t=[],n=!1,r=0,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=i;if(i=!1,o===`\\`){let t=e[a+1];if(!n&&t!==void 0&&(t>=`1`&&t<=`9`||t===`k`)&&(t!==`k`||e[a+2]===`<`))return!1;a++;continue}if(n){o===`]`&&(n=!1);continue}if(o===`[`){n=!0;continue}if(o===`(`){t.push(!1),e[a+1]===`?`&&a++;continue}if(o===`|`){t.length>0&&(t[t.length-1]=!0);continue}let c=!1,l=!1;if(o===`*`||o===`+`||o===`?`&&!s)c=!0;else if(o===`{`){let t=/^\{\d+(?:,\d*)?\}/.exec(e.slice(a,a+24));if(t!==null){if(/\d{4,}|[1-9]\d{2,}/.test(t[0]))return!1;c=!0,l=!t[0].includes(`,`),a+=t[0].length-1}}if(c){if(!l&&++r>we)return!1;i=!0,t.length>0&&(t[t.length-1]=!0);continue}if(o===`)`&&(t.pop()??!1)){let n=e[a+1];if(n===`+`||n===`*`||n===`{`)return!1;t.length>0&&(t[t.length-1]=!0)}}return!0}var Te=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,localeOf=e=>e.locale===``?g():e.locale;function toNumber(e){let t=typeof e==`number`?e:typeof e==`string`&&e.trim()!==``?Number(e):NaN;return Number.isFinite(t)?t:void 0}var optInt=e=>{let t=toNumber(e);return t===void 0?void 0:Math.min(20,Math.max(0,Math.trunc(t)))};function formatNumeric(e,t,n){let r=toNumber(e.value);if(r===void 0)return``;let i=optInt(e.decimals),a=e.currency;try{return new Intl.NumberFormat(localeOf(t),{...n?{style:`currency`,currency:typeof a==`string`?a:``}:{},...i===void 0?{}:{minimumFractionDigits:i,maximumFractionDigits:i},useGrouping:e.grouping!==!1}).format(r)}catch{return String(r)}}function formatDate(e,t,n){let r=e instanceof Date?e:new Date(typeof e==`number`?e:String(e));if(Number.isNaN(r.getTime()))return``;let i=localeOf(n),a=n.timeZone===void 0?{}:{timeZone:n.timeZone};try{let part=(e,t,n=!1)=>new Intl.DateTimeFormat(i,{...a,...e,...n?{numberingSystem:`latn`}:{}}).formatToParts(r).find(e=>e.type===t)?.value??``,num=(e,t)=>Number(part({...e,hourCycle:`h23`},t,!0)),e=num({year:`numeric`},`year`),n=num({month:`numeric`},`month`),o=num({day:`numeric`},`day`),s=num({hour:`numeric`},`hour`),c=num({minute:`numeric`},`minute`),l=num({second:`numeric`},`second`),pad=e=>String(e).padStart(2,`0`),u=s%12==0?12:s%12,token=(t,r)=>{switch(t.repeat(r)){case`yy`:return pad(e%100);case`yyyy`:return String(e).padStart(4,`0`);case`M`:return String(n);case`MM`:return pad(n);case`MMM`:return part({month:`short`},`month`);case`MMMM`:return part({month:`long`},`month`);case`d`:return String(o);case`dd`:return pad(o);case`E`:return part({weekday:`short`},`weekday`);case`EEEE`:return part({weekday:`long`},`weekday`);case`h`:return String(u);case`hh`:return pad(u);case`H`:return String(s);case`HH`:return pad(s);case`mm`:return pad(c);case`ss`:return pad(l);case`a`:return part({hour:`numeric`,hour12:!0},`dayPeriod`);default:return}},d=``;for(let e=0;e<t.length;){let n=t[e];if(n===`'`){if(t[e+1]===`'`){d+=`'`,e+=2;continue}let n=e+1;for(;n<t.length;){if(t[n]===`'`){if(t[n+1]===`'`){d+=`'`,n+=2;continue}break}d+=t[n],n++}e=n+1;continue}if(/[A-Za-z]/.test(n)){let r=e;for(;t[r]===n;)r++;d+=token(n,r-e)??t.slice(e,r),e=r;continue}d+=n,e++}return d}catch{return``}}var bool=e=>e===!0;function callFunction(e,t,n){let invalid=e=>n.report(errorMessage(`FUNCTION_ERROR`,n.surfaceId,e));switch(e){case`required`:{let e=t.value;return!(e==null||e===``||Array.isArray(e)&&e.length===0)}case`regex`:{let{value:e,pattern:n}=t;if(typeof n!=`string`||!isSafeRegexPattern(n))return invalid(`Regex pattern refused: missing, too long, a backreference, a nested quantifier, more than 2 non-exact quantifiers, or a repeat count above 99.`),!1;if(typeof e!=`string`)return!1;if(e.length>J)return invalid(`Regex input exceeds ${J} characters.`),!1;try{return new RegExp(n,`u`).test(e)}catch{return invalid(`Regex pattern is invalid.`),!1}}case`length`:{let{value:e}=t,n=toNumber(t.min),r=toNumber(t.max);return typeof e!=`string`||n===void 0&&r===void 0?!1:(n===void 0||e.length>=n)&&(r===void 0||e.length<=r)}case`numeric`:{let e=t.value;if(typeof e!=`number`||!Number.isFinite(e))return!1;let n=toNumber(t.min),r=toNumber(t.max);return(n===void 0||e>=n)&&(r===void 0||e<=r)}case`email`:{let e=t.value;return typeof e==`string`&&e.length<=254&&Te.test(e)}case`and`:{let e=t.values;return Array.isArray(e)&&e.length>0&&e.every(bool)}case`or`:{let e=t.values;return Array.isArray(e)&&e.some(bool)}case`not`:return t.value!==!0;case`formatString`:{let e=t.value;return typeof e==`string`?formatString(e,n):``}case`formatNumber`:return formatNumeric(t,n,!1);case`formatCurrency`:return formatNumeric(t,n,!0);case`formatDate`:{let e=t.format;return formatDate(t.value,typeof e==`string`?e:`yyyy-MM-dd`,n)}case`pluralize`:{let e=t.other;if(typeof e!=`string`)return invalid(`pluralize requires an "other" form.`),``;let r=toNumber(t.value);if(r===void 0)return e;let i=`other`;try{i=new Intl.PluralRules(localeOf(n)).select(r)}catch{}let a=i===`other`?void 0:t[i];return typeof a==`string`?a:e}case`openUrl`:{let e=t.url;typeof e==`string`&&/(^|[^\\])\$\{/.test(e)?invalid('openUrl refused a URL holding an unresolved "${"; pass a {path} binding instead.'):typeof e==`string`&&i(e)?n.openUrl(e):invalid(`openUrl refused a missing or unsafe URL.`);return}default:n.report(errorMessage(`UNKNOWN_FUNCTION`,n.surfaceId,`Unknown function "${e}".`));return}}function resolveAt(e,t,n){if(isBinding(e)&&isRecord(e)){let n=e.path;try{return t.data.read(resolvePath(n,t.scope)).value}catch(e){if(e instanceof A2uiPathError){t.report(errorMessage(`INVALID_PATH`,t.surfaceId,e.message,n));return}throw e}}if(isFunctionCall(e)&&isRecord(e)){if(n>=Se){t.report(errorMessage(`FUNCTION_ERROR`,t.surfaceId,`Function calls nest too deeply.`));return}let r=isRecord(e.args)?e.args:{},i={};for(let[e,a]of Object.entries(r))i[e]=Array.isArray(a)?a.map(e=>resolveAt(e,t,n+1)):resolveAt(a,t,n+1);return callFunction(e.call,i,t)}return e}function resolveDynamic(e,t){return resolveAt(e,t,0)}function nextIndex(e,t){let n=new Int32Array(e.length+1);n[e.length]=e.length;for(let r=e.length-1;r>=0;r--)n[r]=t.includes(e[r])?r:n[r+1];return n}var isIdent=e=>e!==void 0&&/[A-Za-z0-9_]/.test(e),skipWs=(e,t)=>{for(;e[t]===` `||e[t]===` `||e[t]===`
|
|
2
|
+
`;)t++;return t};function parseInterpolation(e,t,n,r,i){if(r>8)return null;let a=skipWs(e,t),o=i.open[a];if(o>=e.length)return null;if(e[o]===`}`)return{value:resolveDynamic({path:e.slice(a,o).trim()},n),end:o+1};let s=e.slice(a,o).trim();if(s===``||![...s].every(isIdent))return null;let c={};for(a=o+1;;){if(a=skipWs(e,a),e[a]===`)`){a++;break}let t=a;for(;isIdent(e[t]);)t++;if(t===a)return null;let o=e.slice(a,t);if(t=skipWs(e,t),e[t]!==`:`)return null;t=skipWs(e,t+1);let s=parseArg(e,t,n,r,i);if(s===null)return null;if(c[o]=s.value,a=skipWs(e,s.end),e[a]===`,`)a++;else if(e[a]!==`)`)return null}return a=skipWs(e,a),e[a]===`}`?{value:callFunction(s,c,n),end:a+1}:null}function parseArg(e,t,n,r,i){let a=e[t];if(a===`$`&&e[t+1]===`{`)return parseInterpolation(e,t+2,n,r+1,i);if(a===`'`||a===`"`){let n=``;for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`\\`&&r+1<e.length)n+=e[r+1],r++;else if(t===a)return{value:n,end:r+1};else n+=t}return null}let o=i.arg[t];if(o>=e.length)return null;let s=e.slice(t,o).trim();if(s===`true`)return{value:!0,end:o};if(s===`false`)return{value:!1,end:o};let c=Number(s);return s!==``&&Number.isFinite(c)?{value:c,end:o}:null}function stringify(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return``}return String(e)}function formatString(e,t){if(e.length>Y)return t.report(errorMessage(`FUNCTION_ERROR`,t.surfaceId,`formatString template exceeds ${Y} characters.`)),e;let n={open:nextIndex(e,`}(`),arg:nextIndex(e,`,)`)},r=``,i=0;for(;i<e.length;)if(e[i]===`\\`&&e[i+1]===`$`&&e[i+2]===`{`)r+="${",i+=3;else if(e[i]===`$`&&e[i+1]===`{`){let a=parseInterpolation(e,i+2,t,0,n);a===null?(r+="${",i+=2):(r+=stringify(a.value),i=a.end)}else r+=e[i],i++;return r}var X={Input:{prop:`value`,event:`onChange`},Textarea:{prop:`value`,event:`onChange`},Select:{prop:`value`,event:`onChange`},Slider:{prop:`value`,event:`onChange`},Checkbox:{prop:`checked`,event:`onChange`},Toggle:{prop:`checked`,event:`onValueChange`},DatePicker:{prop:`value`,event:`onValueChange`},TimePicker:{prop:`value`,event:`onValueChange`},NumberInput:{prop:`value`,event:`onValueChange`},Tabs:{prop:`value`,event:`onValueChange`},Search:{prop:`value`,event:`onValueChange`},Combobox:{prop:`value`,event:`onValueChange`},Accordion:{prop:`value`,event:`onValueChange`},RadioCardGroup:{prop:`value`,event:`onValueChange`},CheckboxCard:{prop:`checked`,event:`onCheckedChange`},Pagination:{prop:`page`,event:`onPageChange`},Modal:{prop:`open`,event:`onClose`}};function twoWayValue(e,t){if(e===`Modal`)return!1;let n=c(t);return e===`Slider`?Number(n):n}var Ee=/* @__PURE__ */ new Set([`Input`,`Textarea`,`Select`,`TimePicker`,`Search`,`Tabs`,`Accordion`,`RadioCardGroup`]),De=/* @__PURE__ */ new Set([`Checkbox`,`Toggle`,`CheckboxCard`,`Modal`]);function twoWayEmpty(e,t){if(Ee.has(e))return``;if(De.has(e))return!1;if(e===`Slider`)return typeof t.min==`number`?t.min:0;if(e===`Pagination`)return 1}var Z=/* @__PURE__ */ new WeakMap,errorKey=(e,t)=>`${e.error.code}|${t}|${e.error.path??e.error.message}`;function defaultOpenUrl(e){i(e)&&window.open(e,`_blank`,`noopener,noreferrer`)}var hasOwn=(e,t)=>Object.hasOwn(e,t);function hasUserActivation(){return typeof navigator<`u`&&navigator.userActivation?navigator.userActivation.isActive:!0}function isTemplate(e){return isRecord(e)&&typeof e.componentId==`string`&&typeof e.path==`string`}function split(e,t,n){return Math.floor(e/t)+ +(n<e%t)}function makeInput(e,t,s,c,l){let{data:u,id:d}=c.surface,reportOnce=t=>c.reportOnce(errorKey(t,e.id),t),f={data:u,scope:t,locale:c.locale,openUrl:c.openUrl,surfaceId:d},p={...f,openUrl:()=>reportOnce(errorMessage(`FUNCTION_ERROR`,d,`openUrl only runs from an action.`)),report:reportOnce},m={...f,openUrl:()=>reportOnce(errorMessage(`FUNCTION_ERROR`,d,`openUrl only runs as an action's top-level functionCall.`)),report:c.report},openerCtx=e=>({...f,openUrl:t=>{let n=isTrustedGesture(e)?hasUserActivation()?void 0:`openUrl needs a user gesture.`:`openUrl needs a user gesture on the control.`;if(n===void 0)return c.openUrl(t);reportOnce(errorMessage(`FUNCTION_ERROR`,d,n))},report:c.report}),raw=t=>hasOwn(e.props,t)?e.props[t]:void 0,resolve=e=>resolveDynamic(e,p),resolveNow=e=>resolveDynamic(e,m),pathError=(e,t,n)=>{if(e instanceof A2uiDataError)return n(errorMessage(e.code,d,e.message));if(!(e instanceof A2uiPathError))throw e;n(errorMessage(`INVALID_PATH`,d,e.message,t))},h=hasOwn(V,e.component)?V[e.component]:void 0,g=c.surface.catalogId===`https://cascivo.com/a2ui/v0_9/catalog.json`&&hasOwn(o,e.component)?o[e.component]??[]:[],boundMismatch=(e,t)=>{if(h!==void 0&&(hasOwn(h.slots,e)||h.events.includes(e)))return;let n=g.find(t=>t.name===e);if(n===void 0)return;if(hasTranslationRef(t))return`Invalid value for "${e}": a {$t} translation ref is not resolved from data.`;if(n.enum===void 0&&n.primitives===void 0&&n.shape===void 0)return typeof t==`string`||typeof t==`number`?void 0:`Invalid type for "${e}" — expected string | number, got ${t===null?`null`:Array.isArray(t)?`array`:typeof t}.`;let r=[];return a(n,t,e,e,r),r[0]?.message},arityOf=e=>h!==void 0&&hasOwn(h.slots,e)?h.slots[e]?.arity:void 0,holdsChildren=(e,t)=>Array.isArray(t)||isTemplate(t)||typeof t==`string`&&arityOf(e)===`one`,_=Object.keys(e.props).filter(t=>holdsChildren(t,e.props[t])),v=l-1,y=/* @__PURE__ */ new Set,b=!1,x=!1,S,shareOf=e=>(x=!0,S??=[..._.filter(e=>y.has(e)),...b?[null]:[]],split(v,S.length,S.indexOf(e))),refuse=(t,n)=>c.reportOnce(`RENDER_ERROR|#${t}`,errorMessage(`RENDER_ERROR`,d,`Component "${e.id}": ${n}`)),take=(e,t)=>x?(refuse(`late:${e}`,`${e} must be called while the adapter renders.`),!1):!t||(refuse(`once:${e}`,`${e} may be called once per render; the second call renders nothing.`),!1),child=(e,n,r)=>/* @__PURE__ */ M(A2uiNode,{id:e,scope:t,ancestors:s,env:c,budget:r},`${e}#${n}`),template=(e,n,r)=>{let i,a;try{i=resolvePath(n,t),a=u.read(i).value}catch(e){return pathError(e,n,reportOnce),null}if(!Array.isArray(a))return null;let o=i.replace(/\/$/,``);return a.map((t,n)=>/* @__PURE__ */ M(A2uiNode,{id:e,scope:`${o}/${n}`,ancestors:s,env:c,budget:()=>split(r(),a.length,n)},`${e}#${n}`))};return{input:{component:e,prop(t){let a=raw(t);if(t===`accessibility`&&isRecord(a))return Object.fromEntries(Object.entries(a).map(([e,t])=>[e,resolve(t)]));let o=resolve(a);if(r.has(t))return typeof o==`string`&&i(o)?o:void 0;if(!isDynamicRef(a)||o===void 0)return o;if(typeof o==`object`&&o){let e=[];if(n(o,t,t,e),e.length>0)return}let s=boundMismatch(t,o);if(s===void 0)return o;reportOnce(errorMessage(`RENDER_ERROR`,d,`Component "${e.id}": bound value dropped. ${s}`))},children(e){return take(`children()`,b)?(b=!0,e.map((t,n)=>child(t,n,()=>split(shareOf(null),e.length,n)))):e.map(()=>null)},resolve(e){return resolve(e)},typeOf(e){return c.surface.component(e).value?.component},componentOf(e){return c.surface.component(e).value},slot(e){let t=raw(e);if(t===void 0)return;if(holdsChildren(e,t)){if(!take(`slot("${e}")`,y.has(e)))return null;y.add(e);let share=()=>shareOf(e);if(isTemplate(t))return template(t.componentId,t.path,share);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);return e.map((t,n)=>child(t,n,()=>split(share(),e.length,n)))}return typeof t==`string`?child(t,0,share):null}let n=resolve(t);return typeof n==`string`||typeof n==`number`?n:void 0},writer(e){let n=raw(e);if(!isBinding(n)||!isRecord(n))return;let r=n.path;if(typeof r==`string`)return e=>{try{u.write(resolvePath(r,t),e)}catch(e){pathError(e,r,c.report)}}},action(t){let n=raw(t);if(!isRecord(n))return;let r=n.event;if(isRecord(r)&&typeof r.name==`string`){let t=r.name,n=isRecord(r.context)?r.context:{};return()=>{let r=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,resolveNow(t)])),i=actionMessage({name:t,surfaceId:d,sourceComponentId:e.id,context:r}),a=c.surface.sendDataModel?c.store.clientDataModel(d):void 0;c.onAction?.(i,a===void 0?{}:{a2uiClientDataModel:a})}}let i=n.functionCall;if(isFunctionCall(i)&&isRecord(i)){if(i.call===`openUrl`){let e=isRecord(i.args)?i.args:{};return t=>{callFunction(`openUrl`,{url:resolveNow(e.url)},openerCtx(t))}}return()=>void resolveNow(i)}},failingChecks(){let e=raw(`checks`);return Array.isArray(e)?e.flatMap(e=>isRecord(e)&&typeof e.message==`string`&&resolve(e.condition)!==!0?[e.message]:[]):[]},report(e,t){c.reportOnce(`${e}|#report|${t}`,errorMessage(e,d,t))}},seal(){x=!0}}}function isCycle(e,t,n){for(let r=n.length-1;r>=0;r--){let i=n[r];if(i.id===e)return!(i.scope===``?t!==``:t.startsWith(`${i.scope}/`))}return!1}function A2uiNode({id:e,scope:t,ancestors:n,env:r,budget:i}){if(m(),isCycle(e,t,n))return r.renderError(e,`Component "${e}" is its own ancestor; the cycle is not rendered.`),null;let a=r.store.limits.maxRenderDepth;if(n.length>=a)return r.renderError(e,`Component "${e}" is nested deeper than maxRenderDepth (${a}).`),null;let o=i();if(o<1){let e=r.store.limits.maxRenderNodes;return r.reportOnce(`RENDER_ERROR|#maxRenderNodes`,errorMessage(`RENDER_ERROR`,r.surface.id,`The surface exceeds the render-node limit (maxRenderNodes ${e}); the rest is not rendered.`)),null}let s=r.surface.component(e).value;return s===void 0?/* @__PURE__ */ M(O,{}):/* @__PURE__ */ M(A2uiBoundary,{component:s,env:r,children:/* @__PURE__ */ M(A2uiBody,{component:s,scope:t,path:[...n,{id:e,scope:t}],env:r,budget:o})},`${e}:${s.component}`)}var A2uiBoundary=class extends v.Component{state={failed:!1,of:this.props.component};unwatch;componentDidUpdate(){this.state.failed||this.unwatch===void 0||(this.unwatch(),this.unwatch=void 0)}componentWillUnmount(){this.unwatch?.(),this.unwatch=void 0}static getDerivedStateFromError(){return{failed:!0}}static getDerivedStateFromProps(e,t){return t.of===e.component?null:{failed:!1,of:e.component}}componentDidCatch(e){let{component:t,env:n}=this.props;this.unwatch?.();let r=n.surface.data.root,i=r.peek();this.unwatch=r.subscribe(e=>{e!==i&&(this.unwatch?.(),this.unwatch=void 0,this.setState({failed:!1}))});let a=`unexpected error`;try{e instanceof Error&&typeof e.message==`string`&&(a=e.message)}catch{}n.reportOnce(`RENDER_ERROR|${t.id}|#crash`,errorMessage(`RENDER_ERROR`,n.surface.id,`Component "${t.id}" failed to render: ${a}`))}render(){return this.state.failed?null:this.props.children}};function A2uiBody({component:e,scope:t,path:n,env:r,budget:i}){m();let a=r.catalog.adapter(e.component);if(a===void 0)return r.renderError(e.id,`Catalog "${r.catalog.id}" cannot render "${e.component}" (component "${e.id}").`),null;let{input:o,seal:s}=makeInput(e,t,n,r,i),c=a(o);return s(),c}function A2uiSurface({store:e,surfaceId:t,catalogs:n,onAction:r,onError:i,openUrl:a,locale:o=``,fallback:s}){m(),e.surfaceIds.value;let c=e.surface(t);if(c===void 0||!c.hasRoot.value)return s??null;let report=e=>{i!==void 0&&queueMicrotask(()=>i(e))},reportOnce=(e,t)=>{let n=Z.get(c);n===void 0&&(n=/* @__PURE__ */ new Set,Z.set(c,n)),!n.has(e)&&(n.add(e),report(t))},renderError=(e,t)=>reportOnce(`RENDER_ERROR|${e}`,errorMessage(`RENDER_ERROR`,c.id,t)),l=n.find(e=>e.id===c.catalogId);return l===void 0?(renderError(``,`No render catalog for "${c.catalogId}".`),s??null):/* @__PURE__ */ M(A2uiNode,{id:`root`,scope:``,ancestors:[],env:{store:e,surface:c,catalog:l,locale:o,onAction:r,openUrl:a??defaultOpenUrl,report,reportOnce,renderError},budget:()=>e.limits.maxRenderNodes})}function renderGeneric(e,t,n){let r=hasOwn(V,e)?V[e]:void 0,i=r?.slots??{},a=r?.events??[],s=hasOwn(o,e)?o[e]??[]:[],declares=e=>s.some(t=>t.name===e),c=hasOwn(X,e)?X[e]:void 0,l=c===void 0?void 0:n.writer(c.prop),u=/* @__PURE__ */ new Map;for(let e of s){if(!e.required||hasOwn(i,e.name)||a.includes(e.name)||c!==void 0&&l!==void 0&&e.name===c.prop)continue;let t=n.prop(e.name);if(t===void 0)return/* @__PURE__ */ M(O,{});u.set(e.name,t)}let d={};for(let e of Object.keys(n.component.props))if(e!==`checks`&&e!==`accessibility`){if(hasOwn(i,e))d[e]=n.slot(e);else if(a.includes(e)){let t=n.action(e);t!==void 0&&(d[e]=t)}else declares(e)&&(d[e]=u.has(e)?u.get(e):n.prop(e))}if(c!==void 0&&l!==void 0){d[c.prop]===void 0&&(d[c.prop]=twoWayEmpty(e,d));let t=n.action(c.event);d[c.event]=n=>{l(twoWayValue(e,n)),t?.()}}let f=n.failingChecks()[0];f!==void 0&&(e===`Button`&&(d.disabled=!0),declares(`error`)&&(d.error===void 0||d.error===``)&&(d.error=f));let p=n.prop(`accessibility`);return isRecord(p)&&typeof p.label==`string`&&declares(`ariaLabel`)&&d.ariaLabel===void 0&&(d.ariaLabel=p.label),v.createElement(t,d)}var Q={id:I,adapter(e){let t=hasOwn(s,e)?s[e]:void 0;if(t!==void 0)return n=>renderGeneric(e,t,n)}},$=Object.freeze({maxSurfaces:16,maxComponents:1e3,maxIdLength:256,maxDataNodes:1e4,maxRenderDepth:64,maxRenderNodes:2e4});function createA2uiStore(e){let t={...$,...e.limits},n=/* @__PURE__ */ new Map,r=d([]);function makeSurface(e){let n=u(()=>void 0),r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=d(0),slot=e=>{let t=r.get(e);if(t)return t;let n=d(void 0);return r.set(e,n),n},view=e=>{let t=i.get(e);if(t)return t;let n=slot(e),r=u(()=>n.value);return i.set(e,r),r},o=slot(`root`);return{id:e.id,catalogId:e.catalog.id,catalog:e.catalog,sendDataModel:e.sendDataModel,theme:e.theme,data:createDataModel(void 0,{maxNodes:t.maxDataNodes}),component:e=>i.get(e)||(e.length>t.maxIdLength?n:r.size>=t.maxComponents*2?u(()=>(a.value,r.get(e)?.value)):view(e)),hasRoot:u(()=>o.value!==void 0),stored:/* @__PURE__ */ new Set,set(e){let t=!r.get(e.id)?.peek();slot(e.id).value=e,t&&a.value++}}}let i=``;function applyMessage(a){let o=parseServerMessage(a);if(!o.ok)return[o.error];let s=o.message,c=s.surfaceId;if(i=c,s.kind===`createSurface`){if(n.has(c))return[errorMessage(`SURFACE_EXISTS`,c,`Surface "${c}" already exists.`)];let i=e.catalogs.find(e=>e.id===s.catalogId);return i===void 0?[errorMessage(`UNSUPPORTED_CATALOG`,c,`Catalog "${s.catalogId}" is not supported.`)]:n.size>=t.maxSurfaces?[errorMessage(`LIMIT_EXCEEDED`,c,`At most ${t.maxSurfaces} surfaces are allowed.`)]:(n.set(c,makeSurface({id:c,catalog:i,sendDataModel:s.sendDataModel,theme:s.theme})),r.value=[...r.peek(),c],[])}let u=n.get(c);if(u===void 0)return[errorMessage(`SURFACE_NOT_FOUND`,c,`Surface "${c}" does not exist.`)];if(s.kind===`deleteSurface`)return n.delete(c),r.value=r.peek().filter(e=>e!==c),[];if(s.kind===`updateDataModel`){try{u.data.write(s.path,s.value)}catch(e){if(e instanceof A2uiPathError)return[errorMessage(`INVALID_PATH`,c,e.message)];if(e instanceof A2uiDataError)return[errorMessage(e.code,c,e.message)];throw e}return[]}let d=[];return l(()=>{for(let[e,n]of s.components.entries()){let r=parseComponent(n,e,c,t.maxIdLength);if(!r.ok){d.push(r.error);continue}let i=r.component,a=u.catalog.validate(i);if(a.length>0){for(let t of a){let n=t.prop===``?`/components/${e}`:`/components/${e}/${t.prop}`;d.push(errorMessage(`VALIDATION_FAILED`,c,t.message,n))}continue}if(!u.stored.has(i.id)&&u.stored.size>=t.maxComponents){d.push(errorMessage(`LIMIT_EXCEEDED`,c,`At most ${t.maxComponents} components are allowed per surface.`));break}u.stored.add(i.id),u.set(i)}}),d}return{apply(e){i=``;try{return applyMessage(e)}catch(e){let t=`unexpected error`;try{e instanceof Error&&typeof e.message==`string`&&(t=e.message)}catch{}return[errorMessage(`INVALID_MESSAGE`,i,`Could not apply message: ${t}`)]}},surfaceIds:r,surface:e=>n.get(e),capabilities:()=>({[P]:{supportedCatalogIds:e.catalogs.map(e=>e.id)}}),clientDataModel(e){let t={},r=!1;for(let[i,a]of n)!a.sendDataModel||e!==void 0&&i!==e||(t[i]=a.data.snapshot(),r=!0);return r?{version:P,surfaces:t}:void 0},limits:t}}var Oe=[Q,B],ke=[H,K];export{I as A2UI_CATALOG_ID,P as A2UI_VERSION,A2uiSurface,F as BASIC_CATALOG_ID,$ as DEFAULT_A2UI_LIMITS,B as basicCatalog,K as basicCatalogSpec,Q as cascivoCatalog,H as cascivoCatalogSpec,createA2uiStore,ke as defaultCatalogSpecs,Oe as defaultCatalogs,parseServerMessage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{validateView as e}from"./validate.js";import{a as t,i as n,n as r,r as i,t as a}from"./node-props-LGzuaTTg.js";import{signal as o,useSignals as s}from"@cascivo/core";import{translateKey as c}from"@cascivo/i18n";import l from"react";import{jsx as u}from"react/jsx-runtime";function isSignal(e){return typeof e==`object`&&!!e&&`value`in e&&`peek`in e}function renderNode(e,o,s,u,d,f){let p=f?.[e.component]??t[e.component];if(!p)return null;let m={};if(e.props)for(let[t,r]of Object.entries(e.props))m[t]=n(r);if(e.bind)for(let[t,n]of Object.entries(e.bind))if(n.startsWith(`$state.`)){let e=u.get(n.slice(7));e&&(m[t]=e.value)}else o&&(m[t]=r(o,n.replace(/^\$data\./,``)));if(e.events){for(let[t,n]of Object.entries(e.events))if(n.startsWith(`$state.set.`)){let e=u.get(n.slice(11));e&&(m[t]=t=>e.value=a(t))}else if(n.startsWith(`$state.toggle.`)){let e=u.get(n.slice(14));e&&(m[t]=()=>e.value=!e.value)}else if(s){let e=s[n.replace(/^\$actions\./,``)];e&&(m[t]=e)}}let h;return e.children!==void 0&&(typeof e.children==`string`?h=e.children:i(e.children)?h=c(e.children.$t,e.children.params):Array.isArray(e.children)&&(h=e.children.map((e,t)=>renderNode(e,o,s,u,`${d}-${t}`,f)))),l.createElement(p,{...m,key:d},h)}function CascivoView({config:t,data:n,actions:r,onInvalid:i=`throw`,components:a}){s();let c=isSignal(t)?t.value:t,d=l.useRef(null);if(!d.current||d.current.config!==c){let e=/* @__PURE__ */ new Map;for(let[t,n]of Object.entries(c.state??{}))e.set(t,o(n));d.current={config:c,signals:e}}let f=d.current.signals,{valid:p,errors:m}=e(c,a?{components:Object.keys(a)}:void 0);if(!p){let e=m.map(e=>`${e.path}: ${e.message}`).join(`
|
|
2
|
+
`);if(i===`render`)return/* @__PURE__ */ u(`div`,{role:`alert`,style:{color:`red`,whiteSpace:`pre`},children:e});throw Error(`CascivoView: invalid config\n${e}`)}let{regions:h}=c.view;return/* @__PURE__ */ u(`div`,{className:`cascivo-view`,children:Object.entries(h).map(([e,t])=>/* @__PURE__ */ u(`div`,{className:`cascade-region cascade-region--${e}`,children:t.map((t,i)=>renderNode(t,n,r,f,`${e}-${i}`,a))},e))})}var d=CascivoView;export{CascivoView as n,d as t};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ComponentType } from "react";
|
|
2
2
|
import { Signal } from "@preact/signals-react";
|
|
3
3
|
/** A reference into the host-provided data context: "$data.users" → context.data.users */
|
|
4
4
|
type DataRef = `$data.${string}`;
|
|
@@ -42,7 +42,15 @@ interface ValidationError {
|
|
|
42
42
|
path: string;
|
|
43
43
|
message: string;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
/** Options for {@link validateView}. */
|
|
46
|
+
interface ValidateViewOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Component names the view may use beyond the built-in set: the keys of the `components` a
|
|
49
|
+
* host passes to `<CascivoView>`. Their props are not checked against a schema.
|
|
50
|
+
*/
|
|
51
|
+
components?: Iterable<string>;
|
|
52
|
+
}
|
|
53
|
+
export declare function validateView(config: unknown, options?: ValidateViewOptions): {
|
|
46
54
|
valid: boolean;
|
|
47
55
|
errors: ValidationError[];
|
|
48
56
|
};
|
|
@@ -56,6 +64,13 @@ interface CascivoViewProps {
|
|
|
56
64
|
actions?: Record<string, (...args: unknown[]) => unknown>;
|
|
57
65
|
/** 'throw' (default) | 'render' — render mode shows errors inline for the playground. */
|
|
58
66
|
onInvalid?: 'throw' | 'render';
|
|
67
|
+
/**
|
|
68
|
+
* Components the view may name beyond the built-in set, keyed by the name a node uses, e.g.
|
|
69
|
+
* `{ Kpi, LineChart }` from `@cascivo/charts`. Looked up before the built-ins, and accepted by
|
|
70
|
+
* the validator; their props are passed through unchecked, since no manifest schema covers them.
|
|
71
|
+
* This is how a host renders charts without `@cascivo/render` depending on `@cascivo/charts`.
|
|
72
|
+
*/
|
|
73
|
+
components?: Record<string, ComponentType<never>>;
|
|
59
74
|
}
|
|
60
75
|
/**
|
|
61
76
|
* Render a JSON {@link ViewConfig} with real cascivo components.
|
|
@@ -63,7 +78,7 @@ interface CascivoViewProps {
|
|
|
63
78
|
* The config is validated first (see `validateView`); an invalid config throws, or — with
|
|
64
79
|
* `onInvalid="render"` — renders its errors inline.
|
|
65
80
|
*/
|
|
66
|
-
export declare function CascivoView({ config, data, actions, onInvalid }: CascivoViewProps): React.ReactElement | null;
|
|
81
|
+
export declare function CascivoView({ config, data, actions, onInvalid, components }: CascivoViewProps): React.ReactElement | null;
|
|
67
82
|
/**
|
|
68
83
|
* @deprecated Renamed to {@link CascivoView}; this alias is removed in 2.0.0.
|
|
69
84
|
*/
|
|
@@ -72,5 +87,5 @@ export declare const CascadeView: typeof CascivoView;
|
|
|
72
87
|
* @deprecated Renamed to {@link CascivoViewProps}; this alias is removed in 2.0.0.
|
|
73
88
|
*/
|
|
74
89
|
type CascadeViewProps = CascivoViewProps;
|
|
75
|
-
export type { ActionRef, CascadeViewProps, CascivoViewProps, ComponentNode, DataRef, PropValue, TranslationRef, ValidationError, ViewConfig };
|
|
90
|
+
export type { ActionRef, CascadeViewProps, CascivoViewProps, ComponentNode, DataRef, PropValue, TranslationRef, ValidateViewOptions, ValidationError, ViewConfig };
|
|
76
91
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{validateView as e}from"./validate.js";import{n as t,t as n}from"./cascivo-view-4DY6JqQA.js";export{n as CascadeView,t as CascivoView,e as validateView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{translateKey as e}from"@cascivo/i18n";import{Accordion as t,Alert as n,AutoGrid as r,Avatar as i,AvatarGroup as a,Badge as o,Blockquote as s,Breadcrumb as c,Button as l,Card as u,CardContent as d,CardFooter as f,CardHeader as p,CardTitle as m,Center as h,Checkbox as g,CheckboxCard as _,Code as v,Columns as y,Combobox as b,CommandMenu as x,DataTable as S,DatePicker as C,Dropdown as w,EmptyState as T,FileUploader as E,Flex as D,Form as O,Grid as k,GridItem as A,Header as j,HeaderPanel as M,Heading as N,Image as P,Input as F,InputGroup as I,Kbd as L,LargeTitleHeader as R,Link as z,List as B,ListItem as ee,Modal as V,NumberInput as H,OverflowMenu as U,PageHeader as W,Pagination as G,Progress as K,ProgressBar as q,ProgressIndicator as J,Radio as Y,RadioCard as X,RadioCardGroup as Z,Search as Q,Select as $,Separator as te,ShellHeader as ne,SideNav as re,Skeleton as ie,Slider as ae,Spacer as oe,Spinner as se,Stat as ce,Status as le,Steps as ue,Switcher as de,Tabs as fe,Tag as pe,Text as me,Textarea as he,TimePicker as ge,Timeline as _e,ToastProvider as ve,Toggle as ye,Tooltip as be}from"@cascivo/react";var cast=e=>e,xe={Accordion:cast(t),Alert:cast(n),AutoGrid:cast(r),Avatar:cast(i),AvatarGroup:cast(a),Badge:cast(o),Blockquote:cast(s),Breadcrumb:cast(c),Button:cast(l),Card:cast(u),CardContent:cast(d),CardFooter:cast(f),CardHeader:cast(p),CardTitle:cast(m),Center:cast(h),Checkbox:cast(g),CheckboxCard:cast(_),Code:cast(v),Columns:cast(y),Combobox:cast(b),CommandMenu:cast(x),DataTable:cast(S),DatePicker:cast(C),Dropdown:cast(w),EmptyState:cast(T),FileUploader:cast(E),Flex:cast(D),Form:cast(O),Grid:cast(k),GridItem:cast(A),Header:cast(j),HeaderPanel:cast(M),Heading:cast(N),Image:cast(P),Input:cast(F),InputGroup:cast(I),Kbd:cast(L),LargeTitleHeader:cast(R),Link:cast(z),List:cast(B),ListItem:cast(ee),Modal:cast(V),NumberInput:cast(H),OverflowMenu:cast(U),PageHeader:cast(W),Pagination:cast(G),Progress:cast(K),ProgressBar:cast(q),ProgressIndicator:cast(J),Radio:cast(Y),RadioCard:cast(X),RadioCardGroup:cast(Z),Search:cast(Q),Select:cast($),Separator:cast(te),ShellHeader:cast(ne),SideNav:cast(re),Skeleton:cast(ie),Slider:cast(ae),Spacer:cast(oe),Spinner:cast(se),Stat:cast(ce),Status:cast(le),Steps:cast(ue),Switcher:cast(de),Tabs:cast(fe),Tag:cast(pe),Text:cast(me),Textarea:cast(he),TimePicker:cast(ge),Timeline:cast(_e),Toast:cast(ve),Toggle:cast(ye),Tooltip:cast(be)};function coerceEventValue(e){if(e&&typeof e==`object`&&`target`in e){let t=e.target;if(t&&typeof t==`object`){let e=t;if(e.type===`checkbox`||e.type===`radio`)return e.checked;if(`value`in e)return e.value}}return e}function isTranslationRef(e){return typeof e==`object`&&!!e&&`$t`in e&&typeof e.$t==`string`}function getPath(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r}function resolvePropValue(t){return isTranslationRef(t)?e(t.$t,t.params):Array.isArray(t)?t.map(e=>resolvePropValue(e)):typeof t==`object`&&t?Object.fromEntries(Object.entries(t).map(([e,t])=>[e,resolvePropValue(t)])):t}export{xe as a,resolvePropValue as i,getPath as n,isTranslationRef as r,coerceEventValue as t};
|