@aglyn/besigner-ui 1.23.0 → 1.24.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/package.json +17 -17
- package/src/lib/components/element-props-form.component.js +28 -5
- package/src/lib/components/element-props-form.component.js.map +1 -1
- package/src/lib/components/property-binding-field.component.d.ts +8 -0
- package/src/lib/components/property-binding-field.component.js +25 -9
- package/src/lib/components/property-binding-field.component.js.map +1 -1
- package/src/lib/hooks/use-insert-token-options.d.ts +22 -0
- package/src/lib/hooks/use-insert-token-options.js +24 -3
- package/src/lib/hooks/use-insert-token-options.js.map +1 -1
- package/src/lib/utils/docs-help.generated.d.ts +1 -1
- package/src/lib/utils/docs-help.generated.js +1 -0
- package/src/lib/utils/docs-help.generated.js.map +1 -1
- package/src/lib/utils/token-segments.d.ts +1 -1
- package/src/lib/utils/token-segments.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/token-segments.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n COLLECTION_TOKEN_CATALOG,\n ENTRY_TOKEN_CATALOG,\n hostTokenDefinition,\n} from '@aglyn/aglyn'\n\nimport type { BindingOption } from '../contexts/binding-picker-context'\n\n/**\n * Token-pill segment model (AGL-586). Stored prop strings keep the raw\n * id-based `{{...}}` grammar (AGL-100/185) — these helpers only SPLIT a\n * string into runs of plain text and atomic tokens so editors can render\n * the tokens as friendly, clickable pills. Serializing the segments always\n * reproduces the exact input string; nothing here ever rewrites a token.\n *\n * Offset model: editor carets address \"units\", where every plain-text\n * character is 1 unit and every token — however long its raw text — is 1\n * atomic unit. A caret can therefore sit before or after a pill but never\n * inside one, which is exactly how the pills behave in the DOM\n * (`contenteditable=\"false\"`).\n */\nexport interface TokenSegment {\n type: 'text' | 'token'\n /** The literal slice of the serialized string (raw `{{...}}` for tokens). */\n value: string\n /** Set on token segments: the raw token, identical to `value`. */\n token?: string\n}\n\n/**\n * Any `{{...}}` occurrence without nested braces — var:/fn:/entry./\n * collection./item.* AND unknown tokens alike. `{{a{{b}}` yields the text\n * `{{a` plus the token `{{b}}` (the opener without a closer is plain text).\n */\nexport const TOKEN_SEGMENT_PATTERN = /\\{\\{[^{}]*\\}\\}/g\n\n/** Drops empty text runs and merges adjacent text segments. */\nfunction normalizeSegments(segments: TokenSegment[]): TokenSegment[] {\n const out: TokenSegment[] = []\n for (const segment of segments) {\n if (segment.type === 'text' && !segment.value) continue\n const last = out[out.length - 1]\n if (segment.type === 'text' && last?.type === 'text') {\n last.value += segment.value\n } else {\n out.push({ ...segment })\n }\n }\n return out\n}\n\n/** Splits `text` on `{{...}}` occurrences into text/token segments. */\nexport function parseTokenSegments(text: string): TokenSegment[] {\n const segments: TokenSegment[] = []\n let cursor = 0\n const pattern = new RegExp(TOKEN_SEGMENT_PATTERN.source, 'g')\n for (let match = pattern.exec(text); match; match = pattern.exec(text)) {\n if (match.index > cursor) {\n segments.push({ type: 'text', value: text.slice(cursor, match.index) })\n }\n segments.push({ type: 'token', value: match[0], token: match[0] })\n cursor = match.index + match[0].length\n }\n if (cursor < text.length) {\n segments.push({ type: 'text', value: text.slice(cursor) })\n }\n return segments\n}\n\n/** Joins segments back to the exact stored string (lossless round-trip). */\nexport function serializeTokenSegments(segments: TokenSegment[]): string {\n return segments.map((segment) => segment.value).join('')\n}\n\n/** True when any text run still holds a complete raw `{{...}}` token. */\nexport function hasUnmaterializedTokens(segments: TokenSegment[]): boolean {\n const probe = new RegExp(TOKEN_SEGMENT_PATTERN.source)\n return segments.some(\n (segment) => segment.type === 'text' && probe.test(segment.value),\n )\n}\n\n/** Unit length of one segment: text = char count, token = 1 atomic unit. */\nexport function segmentUnitLength(segment: TokenSegment): number {\n return segment.type === 'token' ? 1 : segment.value.length\n}\n\n/** Total unit length of a segment list (pills count as 1 unit each). */\nexport function segmentsUnitLength(segments: TokenSegment[]): number {\n return segments.reduce((sum, segment) => sum + segmentUnitLength(segment), 0)\n}\n\n/**\n * Extracts [from, to) in unit offsets. Tokens are atomic: since a token is\n * exactly 1 unit, an integer range either includes it wholly or not at all\n * — a caret can never split a pill.\n */\nexport function sliceSegmentsByUnits(\n segments: TokenSegment[],\n from: number,\n to: number,\n): TokenSegment[] {\n const out: TokenSegment[] = []\n let position = 0\n for (const segment of segments) {\n const length = segmentUnitLength(segment)\n const start = Math.max(from, position)\n const stop = Math.min(to, position + length)\n if (stop > start) {\n if (segment.type === 'token') {\n out.push({ ...segment })\n } else {\n out.push({\n type: 'text',\n value: segment.value.slice(start - position, stop - position),\n })\n }\n }\n position += length\n }\n return normalizeSegments(out)\n}\n\n/**\n * Splices `replacement` into `segments` at the unit-offset selection,\n * replacing any selected range — the caret-preserving insert used by the\n * {x} picker (AGL-583 semantics, pill-aware). A null/undefined start means\n * \"no caret captured\": the replacement appends at the end. Returns the new\n * segment list and the caret unit just after the inserted content.\n */\nexport function spliceSegmentsAtUnits(\n segments: TokenSegment[],\n replacement: TokenSegment[],\n start?: number | null,\n end?: number | null,\n): { segments: TokenSegment[]; caretUnit: number } {\n const length = segmentsUnitLength(segments)\n const clamp = (value: number) => Math.min(Math.max(value, 0), length)\n const at = start == null ? length : clamp(start)\n const to = end == null ? at : Math.max(clamp(end), at)\n const next = normalizeSegments([\n ...sliceSegmentsByUnits(segments, 0, at),\n ...replacement,\n ...sliceSegmentsByUnits(segments, to, Infinity),\n ])\n return { segments: next, caretUnit: at + segmentsUnitLength(replacement) }\n}\n\n/** A single token segment for `spliceSegmentsAtUnits` insertion. */\nexport function tokenSegment(token: string): TokenSegment {\n return { type: 'token', value: token, token }\n}\n\n/** A single text segment for `spliceSegmentsAtUnits` insertion. */\nexport function textSegment(text: string): TokenSegment {\n return { type: 'text', value: text }\n}\n\n/** Which catalog family a token belongs to — drives the pill color. */\nexport type TokenGroup =\n | 'variable'\n | 'function'\n | 'entry'\n | 'collection'\n /** `{{item.*}}` — a field of the record a repeat is rendering. */\n | 'item'\n | 'property'\n | 'host'\n | 'unknown'\n\n/**\n * Display-name inputs for {@link resolveTokenLabel}: the picker options\n * (which already carry friendly labels for every insertable token), the\n * host's variable/function docs keyed by id (AGL-194), and the fields of\n * the entity the nearest ancestor repeat names (id → current display name).\n */\nexport interface TokenLabelContext {\n options?: BindingOption[]\n variables?: Record<string, { name?: string } | undefined>\n functions?: Record<string, { name?: string } | undefined>\n itemFields?: Array<{ id: string; label: string }>\n}\n\nexport interface ResolvedTokenLabel {\n /** Friendly display name (the CURRENT name — ids stay in storage). */\n label: string\n /** Family for the pill color; shape-derived, stable across renames. */\n group: TokenGroup\n /** False when the referent can't be resolved (warning-colored pill). */\n known: boolean\n}\n\nconst stripBraces = (token: string): string =>\n token.replace(/^\\{\\{\\s*/, '').replace(/\\s*\\}\\}$/, '')\n\n/** Whitespace-insensitive raw-token comparison (`{{ var:x }}` ≡ `{{var:x}}`). */\nconst canonical = (token: string): string => token.replace(/\\s+/g, '')\n\n/**\n * Resolves a raw token to its display name (AGL-586 requirement 2: users\n * see NAMES, storage keeps IDS). The group comes from the token's shape so\n * pills stay consistently colored even when the referent is missing;\n * `known: false` marks unresolvable tokens for warning styling with the\n * raw token surfaced as the tooltip.\n */\nexport function resolveTokenLabel(\n token: string,\n context: TokenLabelContext = {},\n): ResolvedTokenLabel {\n const inner = stripBraces(token).trim()\n const optionByToken = (candidate: string): BindingOption | undefined =>\n (context.options ?? []).find(\n (option) => canonical(option.token) === canonical(candidate),\n )\n\n const variableMatch = /^var:([^\\s(){}]+)$/.exec(inner)\n if (variableMatch) {\n const id = variableMatch[1] as string\n const name =\n context.variables?.[id]?.name ?? optionByToken(`{{var:${id}}}`)?.label\n return { label: name ?? id, group: 'variable', known: Boolean(name) }\n }\n\n const functionMatch = /^fn:([^(){}]+)\\(([^)]*)\\)$/.exec(inner)\n if (functionMatch) {\n const id = String(functionMatch[1]).trim()\n // A stored call's args differ from the picker's parameter template, so\n // options match on the `{{fn:id(` prefix rather than the whole token.\n const name =\n context.functions?.[id]?.name ??\n (context.options ?? []).find((option) =>\n canonical(option.token).startsWith(canonical(`{{fn:${id}(`)),\n )?.label\n return { label: name ?? id, group: 'function', known: Boolean(name) }\n }\n\n if (inner.startsWith('entry.')) {\n const entry = ENTRY_TOKEN_CATALOG.find(\n (candidate) => canonical(candidate.token) === canonical(`{{${inner}}}`),\n )\n return { label: entry?.label ?? inner, group: 'entry', known: Boolean(entry) }\n }\n\n // `{{pagination.*}}` (AGL-1386) resolves on the same collection list pages\n // and lives in the same catalog, so it shares the collection pill rather\n // than reading as an unresolvable token in warning colors.\n if (inner.startsWith('collection.') || inner.startsWith('pagination.')) {\n const entry = COLLECTION_TOKEN_CATALOG.find(\n (candidate) => canonical(candidate.token) === canonical(`{{${inner}}}`),\n )\n return {\n label: entry?.label ?? inner,\n group: 'collection',\n known: Boolean(entry),\n }\n }\n\n /*\n * A component's own property (AGL-1335), named the way the Attributes panel\n * names it. Known only where the picker offers it — inside the component\n * that declares it — because that is the only place the token substitutes:\n * the same pill on an ordinary screen, or naming a property since removed,\n * resolves to nothing on the page and says so in warning colors.\n */\n const propertyMatch = /^prop\\.([A-Za-z_][A-Za-z0-9_]*)$/.exec(inner)\n if (propertyMatch) {\n const option = optionByToken(`{{${inner}}}`)\n return {\n label: option?.label ?? (propertyMatch[1] as string),\n group: 'property',\n known: Boolean(option),\n }\n }\n\n /*\n * A host variable (AGL-1022), named from the registry that resolves it\n * (AGL-2881), so the pill reads \"Business name\" wherever the token sits and\n * every surface agrees on what exists. A name the registry does not declare\n * renders nothing on the page, and says so in warning colors.\n */\n const hostMatch = /^host\\.([a-zA-Z][a-zA-Z0-9_]*)$/.exec(inner)\n if (hostMatch) {\n const definition = hostTokenDefinition(hostMatch[1] as string)\n return {\n label: definition?.label ?? inner,\n group: 'host',\n known: Boolean(definition),\n }\n }\n\n const itemMatch = /^item\\.([^.\\s{}]+)(?:\\.([^.\\s{}]+))?$/.exec(inner)\n if (itemMatch) {\n const fieldId = itemMatch[1] as string\n const hopId = itemMatch[2]\n const field = (context.itemFields ?? []).find(\n (candidate) => candidate.id === fieldId,\n )\n const label = field\n ? hopId\n ? `${field.label} → ${humanizeFieldId(hopId)}`\n : field.label\n : inner\n return { label, group: 'item', known: Boolean(field) }\n }\n\n return { label: inner || token, group: 'unknown', known: false }\n}\n\n/**\n * A stored field id read as words, for a hop the canvas names without the\n * target's own label: \"roast_preference\" → \"Roast preference\".\n */\nfunction humanizeFieldId(id: string): string {\n const words = id.replace(/_/g, ' ').trim()\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : id\n}\n"],"names":["COLLECTION_TOKEN_CATALOG","ENTRY_TOKEN_CATALOG","hostTokenDefinition","TOKEN_SEGMENT_PATTERN","normalizeSegments","segments","out","segment","type","value","last","length","push","parseTokenSegments","text","cursor","pattern","RegExp","source","match","exec","index","slice","token","serializeTokenSegments","map","join","hasUnmaterializedTokens","probe","some","test","segmentUnitLength","segmentsUnitLength","reduce","sum","sliceSegmentsByUnits","from","to","position","start","Math","max","stop","min","spliceSegmentsAtUnits","replacement","end","clamp","at","next","Infinity","caretUnit","tokenSegment","textSegment","stripBraces","replace","canonical","resolveTokenLabel","context","inner","trim","optionByToken","candidate","options","find","option","variableMatch","id","name","variables","label","group","known","Boolean","functionMatch","String","functions","startsWith","entry","propertyMatch","hostMatch","definition","itemMatch","fieldId","hopId","field","itemFields","humanizeFieldId","words","charAt","toUpperCase"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,wBAAwB,EACxBC,mBAAmB,EACnBC,m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,MAAMf,KAAK,GACbX;QACJ,OAAO;YAAEW;YAAOC,OAAO;YAAQC,OAAOC,QAAQY;QAAO;IACvD;IAEA,OAAO;QAAEf,OAAOX,SAASpC;QAAOgD,OAAO;QAAWC,OAAO;IAAM;AACjE;AAEA;;;CAGC,GACD,SAASe,gBAAgBpB,EAAU;IACjC,MAAMqB,QAAQrB,GAAGZ,OAAO,CAAC,MAAM,KAAKK,IAAI;IACxC,OAAO4B,QAAQA,MAAMC,MAAM,CAAC,GAAGC,WAAW,KAAKF,MAAMlE,KAAK,CAAC,KAAK6C;AAClE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/token-segments.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n COLLECTION_TOKEN_CATALOG,\n ENTRY_TOKEN_CATALOG,\n hostTokenDefinition,\n} from '@aglyn/aglyn'\n\nimport type { BindingOption } from '../contexts/binding-picker-context'\n\n/**\n * Token-pill segment model (AGL-586). Stored prop strings keep the raw\n * id-based `{{...}}` grammar (AGL-100/185) — these helpers only SPLIT a\n * string into runs of plain text and atomic tokens so editors can render\n * the tokens as friendly, clickable pills. Serializing the segments always\n * reproduces the exact input string; nothing here ever rewrites a token.\n *\n * Offset model: editor carets address \"units\", where every plain-text\n * character is 1 unit and every token — however long its raw text — is 1\n * atomic unit. A caret can therefore sit before or after a pill but never\n * inside one, which is exactly how the pills behave in the DOM\n * (`contenteditable=\"false\"`).\n */\nexport interface TokenSegment {\n type: 'text' | 'token'\n /** The literal slice of the serialized string (raw `{{...}}` for tokens). */\n value: string\n /** Set on token segments: the raw token, identical to `value`. */\n token?: string\n}\n\n/**\n * Any `{{...}}` occurrence without nested braces — var:/fn:/entry./\n * collection./item.* AND unknown tokens alike. `{{a{{b}}` yields the text\n * `{{a` plus the token `{{b}}` (the opener without a closer is plain text).\n */\nexport const TOKEN_SEGMENT_PATTERN = /\\{\\{[^{}]*\\}\\}/g\n\n/** Drops empty text runs and merges adjacent text segments. */\nfunction normalizeSegments(segments: TokenSegment[]): TokenSegment[] {\n const out: TokenSegment[] = []\n for (const segment of segments) {\n if (segment.type === 'text' && !segment.value) continue\n const last = out[out.length - 1]\n if (segment.type === 'text' && last?.type === 'text') {\n last.value += segment.value\n } else {\n out.push({ ...segment })\n }\n }\n return out\n}\n\n/** Splits `text` on `{{...}}` occurrences into text/token segments. */\nexport function parseTokenSegments(text: string): TokenSegment[] {\n const segments: TokenSegment[] = []\n let cursor = 0\n const pattern = new RegExp(TOKEN_SEGMENT_PATTERN.source, 'g')\n for (let match = pattern.exec(text); match; match = pattern.exec(text)) {\n if (match.index > cursor) {\n segments.push({ type: 'text', value: text.slice(cursor, match.index) })\n }\n segments.push({ type: 'token', value: match[0], token: match[0] })\n cursor = match.index + match[0].length\n }\n if (cursor < text.length) {\n segments.push({ type: 'text', value: text.slice(cursor) })\n }\n return segments\n}\n\n/** Joins segments back to the exact stored string (lossless round-trip). */\nexport function serializeTokenSegments(segments: TokenSegment[]): string {\n return segments.map((segment) => segment.value).join('')\n}\n\n/** True when any text run still holds a complete raw `{{...}}` token. */\nexport function hasUnmaterializedTokens(segments: TokenSegment[]): boolean {\n const probe = new RegExp(TOKEN_SEGMENT_PATTERN.source)\n return segments.some(\n (segment) => segment.type === 'text' && probe.test(segment.value),\n )\n}\n\n/** Unit length of one segment: text = char count, token = 1 atomic unit. */\nexport function segmentUnitLength(segment: TokenSegment): number {\n return segment.type === 'token' ? 1 : segment.value.length\n}\n\n/** Total unit length of a segment list (pills count as 1 unit each). */\nexport function segmentsUnitLength(segments: TokenSegment[]): number {\n return segments.reduce((sum, segment) => sum + segmentUnitLength(segment), 0)\n}\n\n/**\n * Extracts [from, to) in unit offsets. Tokens are atomic: since a token is\n * exactly 1 unit, an integer range either includes it wholly or not at all\n * — a caret can never split a pill.\n */\nexport function sliceSegmentsByUnits(\n segments: TokenSegment[],\n from: number,\n to: number,\n): TokenSegment[] {\n const out: TokenSegment[] = []\n let position = 0\n for (const segment of segments) {\n const length = segmentUnitLength(segment)\n const start = Math.max(from, position)\n const stop = Math.min(to, position + length)\n if (stop > start) {\n if (segment.type === 'token') {\n out.push({ ...segment })\n } else {\n out.push({\n type: 'text',\n value: segment.value.slice(start - position, stop - position),\n })\n }\n }\n position += length\n }\n return normalizeSegments(out)\n}\n\n/**\n * Splices `replacement` into `segments` at the unit-offset selection,\n * replacing any selected range — the caret-preserving insert used by the\n * {x} picker (AGL-583 semantics, pill-aware). A null/undefined start means\n * \"no caret captured\": the replacement appends at the end. Returns the new\n * segment list and the caret unit just after the inserted content.\n */\nexport function spliceSegmentsAtUnits(\n segments: TokenSegment[],\n replacement: TokenSegment[],\n start?: number | null,\n end?: number | null,\n): { segments: TokenSegment[]; caretUnit: number } {\n const length = segmentsUnitLength(segments)\n const clamp = (value: number) => Math.min(Math.max(value, 0), length)\n const at = start == null ? length : clamp(start)\n const to = end == null ? at : Math.max(clamp(end), at)\n const next = normalizeSegments([\n ...sliceSegmentsByUnits(segments, 0, at),\n ...replacement,\n ...sliceSegmentsByUnits(segments, to, Infinity),\n ])\n return { segments: next, caretUnit: at + segmentsUnitLength(replacement) }\n}\n\n/** A single token segment for `spliceSegmentsAtUnits` insertion. */\nexport function tokenSegment(token: string): TokenSegment {\n return { type: 'token', value: token, token }\n}\n\n/** A single text segment for `spliceSegmentsAtUnits` insertion. */\nexport function textSegment(text: string): TokenSegment {\n return { type: 'text', value: text }\n}\n\n/** Which catalog family a token belongs to — drives the pill color. */\nexport type TokenGroup =\n | 'variable'\n | 'function'\n | 'entry'\n | 'collection'\n /** `{{item.*}}` — a field of the record a repeat is rendering. */\n | 'item'\n | 'property'\n | 'host'\n | 'unknown'\n\n/**\n * Display-name inputs for {@link resolveTokenLabel}: the picker options\n * (which already carry friendly labels for every insertable token), the\n * host's variable/function docs keyed by id (AGL-194), and the fields of\n * the entity the nearest ancestor repeat names (id → current display name).\n */\nexport interface TokenLabelContext {\n options?: BindingOption[]\n variables?: Record<string, { name?: string } | undefined>\n functions?: Record<string, { name?: string } | undefined>\n itemFields?: ReadonlyArray<{ id: string; label: string }>\n}\n\nexport interface ResolvedTokenLabel {\n /** Friendly display name (the CURRENT name — ids stay in storage). */\n label: string\n /** Family for the pill color; shape-derived, stable across renames. */\n group: TokenGroup\n /** False when the referent can't be resolved (warning-colored pill). */\n known: boolean\n}\n\nconst stripBraces = (token: string): string =>\n token.replace(/^\\{\\{\\s*/, '').replace(/\\s*\\}\\}$/, '')\n\n/** Whitespace-insensitive raw-token comparison (`{{ var:x }}` ≡ `{{var:x}}`). */\nconst canonical = (token: string): string => token.replace(/\\s+/g, '')\n\n/**\n * Resolves a raw token to its display name (AGL-586 requirement 2: users\n * see NAMES, storage keeps IDS). The group comes from the token's shape so\n * pills stay consistently colored even when the referent is missing;\n * `known: false` marks unresolvable tokens for warning styling with the\n * raw token surfaced as the tooltip.\n */\nexport function resolveTokenLabel(\n token: string,\n context: TokenLabelContext = {},\n): ResolvedTokenLabel {\n const inner = stripBraces(token).trim()\n const optionByToken = (candidate: string): BindingOption | undefined =>\n (context.options ?? []).find(\n (option) => canonical(option.token) === canonical(candidate),\n )\n\n const variableMatch = /^var:([^\\s(){}]+)$/.exec(inner)\n if (variableMatch) {\n const id = variableMatch[1] as string\n const name =\n context.variables?.[id]?.name ?? optionByToken(`{{var:${id}}}`)?.label\n return { label: name ?? id, group: 'variable', known: Boolean(name) }\n }\n\n const functionMatch = /^fn:([^(){}]+)\\(([^)]*)\\)$/.exec(inner)\n if (functionMatch) {\n const id = String(functionMatch[1]).trim()\n // A stored call's args differ from the picker's parameter template, so\n // options match on the `{{fn:id(` prefix rather than the whole token.\n const name =\n context.functions?.[id]?.name ??\n (context.options ?? []).find((option) =>\n canonical(option.token).startsWith(canonical(`{{fn:${id}(`)),\n )?.label\n return { label: name ?? id, group: 'function', known: Boolean(name) }\n }\n\n if (inner.startsWith('entry.')) {\n const entry = ENTRY_TOKEN_CATALOG.find(\n (candidate) => canonical(candidate.token) === canonical(`{{${inner}}}`),\n )\n return { label: entry?.label ?? inner, group: 'entry', known: Boolean(entry) }\n }\n\n // `{{pagination.*}}` (AGL-1386) resolves on the same collection list pages\n // and lives in the same catalog, so it shares the collection pill rather\n // than reading as an unresolvable token in warning colors.\n if (inner.startsWith('collection.') || inner.startsWith('pagination.')) {\n const entry = COLLECTION_TOKEN_CATALOG.find(\n (candidate) => canonical(candidate.token) === canonical(`{{${inner}}}`),\n )\n return {\n label: entry?.label ?? inner,\n group: 'collection',\n known: Boolean(entry),\n }\n }\n\n /*\n * A component's own property (AGL-1335), named the way the Attributes panel\n * names it. Known only where the picker offers it — inside the component\n * that declares it — because that is the only place the token substitutes:\n * the same pill on an ordinary screen, or naming a property since removed,\n * resolves to nothing on the page and says so in warning colors.\n */\n const propertyMatch = /^prop\\.([A-Za-z_][A-Za-z0-9_]*)$/.exec(inner)\n if (propertyMatch) {\n const option = optionByToken(`{{${inner}}}`)\n return {\n label: option?.label ?? (propertyMatch[1] as string),\n group: 'property',\n known: Boolean(option),\n }\n }\n\n /*\n * A host variable (AGL-1022), named from the registry that resolves it\n * (AGL-2881), so the pill reads \"Business name\" wherever the token sits and\n * every surface agrees on what exists. A name the registry does not declare\n * renders nothing on the page, and says so in warning colors.\n */\n const hostMatch = /^host\\.([a-zA-Z][a-zA-Z0-9_]*)$/.exec(inner)\n if (hostMatch) {\n const definition = hostTokenDefinition(hostMatch[1] as string)\n return {\n label: definition?.label ?? inner,\n group: 'host',\n known: Boolean(definition),\n }\n }\n\n const itemMatch = /^item\\.([^.\\s{}]+)(?:\\.([^.\\s{}]+))?$/.exec(inner)\n if (itemMatch) {\n const fieldId = itemMatch[1] as string\n const hopId = itemMatch[2]\n const field = (context.itemFields ?? []).find(\n (candidate) => candidate.id === fieldId,\n )\n const label = field\n ? hopId\n ? `${field.label} → ${humanizeFieldId(hopId)}`\n : field.label\n : inner\n return { label, group: 'item', known: Boolean(field) }\n }\n\n return { label: inner || token, group: 'unknown', known: false }\n}\n\n/**\n * A stored field id read as words, for a hop the canvas names without the\n * target's own label: \"roast_preference\" → \"Roast preference\".\n */\nfunction humanizeFieldId(id: string): string {\n const words = id.replace(/_/g, ' ').trim()\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : id\n}\n"],"names":["COLLECTION_TOKEN_CATALOG","ENTRY_TOKEN_CATALOG","hostTokenDefinition","TOKEN_SEGMENT_PATTERN","normalizeSegments","segments","out","segment","type","value","last","length","push","parseTokenSegments","text","cursor","pattern","RegExp","source","match","exec","index","slice","token","serializeTokenSegments","map","join","hasUnmaterializedTokens","probe","some","test","segmentUnitLength","segmentsUnitLength","reduce","sum","sliceSegmentsByUnits","from","to","position","start","Math","max","stop","min","spliceSegmentsAtUnits","replacement","end","clamp","at","next","Infinity","caretUnit","tokenSegment","textSegment","stripBraces","replace","canonical","resolveTokenLabel","context","inner","trim","optionByToken","candidate","options","find","option","variableMatch","id","name","variables","label","group","known","Boolean","functionMatch","String","functions","startsWith","entry","propertyMatch","hostMatch","definition","itemMatch","fieldId","hopId","field","itemFields","humanizeFieldId","words","charAt","toUpperCase"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,wBAAwB,EACxBC,mBAAmB,EACnBC,mBAAmB,QACd,eAAc;AAyBrB;;;;CAIC,GACD,OAAO,MAAMC,wBAAwB,kBAAiB;AAEtD,6DAA6D,GAC7D,SAASC,kBAAkBC,QAAwB;IACjD,MAAMC,MAAsB,EAAE;IAC9B,KAAK,MAAMC,WAAWF,SAAU;QAC9B,IAAIE,QAAQC,IAAI,KAAK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