typebars 1.0.2 → 1.0.3

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.
Files changed (40) hide show
  1. package/dist/analyzer.js +2 -2
  2. package/dist/analyzer.js.map +1 -1
  3. package/dist/{chunk-jms1ndxn.js → chunk-5znsrn10.js} +4 -4
  4. package/dist/{chunk-jms1ndxn.js.map → chunk-5znsrn10.js.map} +1 -1
  5. package/dist/{chunk-ecs3yth2.js → chunk-867xywnk.js} +4 -4
  6. package/dist/{chunk-ecs3yth2.js.map → chunk-867xywnk.js.map} +1 -1
  7. package/dist/{chunk-6955jpr7.js → chunk-8xza8tca.js} +3 -3
  8. package/dist/{chunk-6955jpr7.js.map → chunk-8xza8tca.js.map} +1 -1
  9. package/dist/{chunk-p5efqsxw.js → chunk-9jxzj2h4.js} +3 -3
  10. package/dist/{chunk-p5efqsxw.js.map → chunk-9jxzj2h4.js.map} +1 -1
  11. package/dist/chunk-dpffacsy.js +4 -0
  12. package/dist/{chunk-t6n956qz.js.map → chunk-dpffacsy.js.map} +2 -2
  13. package/dist/{chunk-zh1e0yhd.js → chunk-gayk9ew1.js} +3 -3
  14. package/dist/{chunk-zh1e0yhd.js.map → chunk-gayk9ew1.js.map} +1 -1
  15. package/dist/{chunk-rkrp4ysw.js → chunk-s96k41p3.js} +4 -4
  16. package/dist/{chunk-rkrp4ysw.js.map → chunk-s96k41p3.js.map} +1 -1
  17. package/dist/{chunk-efqd0598.js → chunk-wvnn9g55.js} +4 -4
  18. package/dist/{chunk-efqd0598.js.map → chunk-wvnn9g55.js.map} +1 -1
  19. package/dist/compiled-template.js +2 -2
  20. package/dist/compiled-template.js.map +1 -1
  21. package/dist/errors.js +2 -2
  22. package/dist/errors.js.map +1 -1
  23. package/dist/executor.js +2 -2
  24. package/dist/executor.js.map +1 -1
  25. package/dist/index.js +2 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/parser.js +2 -2
  28. package/dist/parser.js.map +1 -1
  29. package/dist/schema-resolver.js +2 -2
  30. package/dist/schema-resolver.js.map +1 -1
  31. package/dist/typebars.js +2 -2
  32. package/dist/typebars.js.map +8 -3
  33. package/dist/types.js +2 -2
  34. package/dist/types.js.map +1 -1
  35. package/dist/utils.js +2 -2
  36. package/dist/utils.js.map +1 -1
  37. package/package.json +2 -2
  38. package/dist/chunk-t6n956qz.js +0 -4
  39. package/dist/chunk-xd2vmd03.js +0 -5
  40. package/dist/chunk-xd2vmd03.js.map +0 -14
package/dist/analyzer.js CHANGED
@@ -1,4 +1,4 @@
1
- import{c as a,d as b,e as c}from"./chunk-t6n956qz.js";import"./chunk-6955jpr7.js";import"./chunk-rkrp4ysw.js";import"./chunk-jms1ndxn.js";import"./chunk-p5efqsxw.js";import"./chunk-zh1e0yhd.js";export{c as inferBlockType,b as analyzeFromAst,a as analyze};
1
+ import{b as a,c as b,d as c}from"./chunk-dpffacsy.js";import"./chunk-8xza8tca.js";import"./chunk-s96k41p3.js";import"./chunk-5znsrn10.js";import"./chunk-9jxzj2h4.js";import"./chunk-gayk9ew1.js";export{c as inferBlockType,b as analyzeFromAst,a as analyze};
2
2
 
3
- //# debugId=618AD80F85BF812A64756E2164756E21
3
+ //# debugId=417A4C32D75B517C64756E2164756E21
4
4
  //# sourceMappingURL=analyzer.js.map
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "618AD80F85BF812A64756E2164756E21",
7
+ "debugId": "417A4C32D75B517C64756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -1,5 +1,5 @@
1
- import{E as Q}from"./chunk-p5efqsxw.js";import{O as M}from"./chunk-zh1e0yhd.js";function L(z,B="",A=new Set){if(A.has(z))return;if(A.add(z),z.if!==void 0)throw new M("if/then/else",B||"/");if(z.then!==void 0)throw new M("if/then/else",B||"/");if(z.else!==void 0)throw new M("if/then/else",B||"/");if(z.properties){for(let[j,D]of Object.entries(z.properties))if(D&&typeof D!=="boolean")L(D,`${B}/properties/${j}`,A)}if(z.additionalProperties&&typeof z.additionalProperties==="object")L(z.additionalProperties,`${B}/additionalProperties`,A);if(z.items){if(Array.isArray(z.items))for(let j=0;j<z.items.length;j++){let D=z.items[j];if(D&&typeof D!=="boolean")L(D,`${B}/items/${j}`,A)}else if(typeof z.items!=="boolean")L(z.items,`${B}/items`,A)}for(let j of["allOf","anyOf","oneOf"]){let D=z[j];if(D)for(let F=0;F<D.length;F++){let G=D[F];if(G&&typeof G!=="boolean")L(G,`${B}/${j}/${F}`,A)}}if(z.not&&typeof z.not!=="boolean")L(z.not,`${B}/not`,A);for(let j of["definitions","$defs"]){let D=z[j];if(D){for(let[F,G]of Object.entries(D))if(G&&typeof G!=="boolean")L(G,`${B}/${j}/${F}`,A)}}}function H(z,B){if(!z.$ref)return z;let A=z.$ref,j=A.match(/^#\/(definitions|\$defs)\/(.+)$/);if(!j)throw Error(`Unsupported $ref format: "${A}". Only internal #/definitions/ references are supported.`);let D=j[1],F=j[2]??"",G=D==="definitions"?B.definitions:B.$defs;if(!G||!(F in G))throw Error(`Cannot resolve $ref "${A}": definition "${F}" not found.`);let J=G[F];if(!J||typeof J==="boolean")throw Error(`Cannot resolve $ref "${A}": definition "${F}" not found.`);return H(J,B)}function P(z,B,A){let j=H(z,A);if(j.properties&&B in j.properties){let J=j.properties[B];if(J&&typeof J!=="boolean")return H(J,A);if(J===!0)return{}}if(j.additionalProperties!==void 0&&j.additionalProperties!==!1){if(j.additionalProperties===!0)return{};return H(j.additionalProperties,A)}let D=j.type;if((D==="array"||Array.isArray(D)&&D.includes("array"))&&B==="length")return{type:"integer"};let G=V(j,B,A);if(G)return G;return}function V(z,B,A){if(z.allOf){let j=z.allOf.filter((D)=>typeof D!=="boolean").map((D)=>P(D,B,A)).filter((D)=>D!==void 0);if(j.length===1)return j[0];if(j.length>1)return{allOf:j}}for(let j of["anyOf","oneOf"]){if(!z[j])continue;let D=z[j].filter((F)=>typeof F!=="boolean").map((F)=>P(F,B,A)).filter((F)=>F!==void 0);if(D.length===1)return D[0];if(D.length>1)return{[j]:D}}return}function Y(z,B){if(B.length===0)return H(z,z);let A=H(z,z),j=z;for(let D of B){let F=P(A,D,j);if(F===void 0)return;A=F}return A}function Z(z,B){let A=H(z,B),j=A.type;if(!(j==="array"||Array.isArray(j)&&j.includes("array"))&&A.items===void 0)return;if(A.items===void 0)return{};if(typeof A.items==="boolean")return{};if(Array.isArray(A.items)){let F=A.items.filter((G)=>typeof G!=="boolean").map((G)=>H(G,B));if(F.length===0)return{};return{oneOf:F}}return H(A.items,B)}function O(z){for(let B of["oneOf","anyOf"]){let A=z[B];if(A&&A.length===1){let j=A[0];if(j!==void 0&&typeof j!=="boolean")return O(j)}}if(z.allOf&&z.allOf.length===1){let B=z.allOf[0];if(B!==void 0&&typeof B!=="boolean")return O(B)}for(let B of["oneOf","anyOf"]){let A=z[B];if(A&&A.length>1){let j=[];for(let D of A){if(typeof D==="boolean")continue;if(!j.some((G)=>Q(G,D)))j.push(O(D))}if(j.length===1)return j[0];return{...z,[B]:j}}}return z}
2
- export{L as z,H as A,Y as B,Z as C,O as D};
1
+ import{D as Q}from"./chunk-9jxzj2h4.js";import{N as M}from"./chunk-gayk9ew1.js";function L(z,B="",A=new Set){if(A.has(z))return;if(A.add(z),z.if!==void 0)throw new M("if/then/else",B||"/");if(z.then!==void 0)throw new M("if/then/else",B||"/");if(z.else!==void 0)throw new M("if/then/else",B||"/");if(z.properties){for(let[j,D]of Object.entries(z.properties))if(D&&typeof D!=="boolean")L(D,`${B}/properties/${j}`,A)}if(z.additionalProperties&&typeof z.additionalProperties==="object")L(z.additionalProperties,`${B}/additionalProperties`,A);if(z.items){if(Array.isArray(z.items))for(let j=0;j<z.items.length;j++){let D=z.items[j];if(D&&typeof D!=="boolean")L(D,`${B}/items/${j}`,A)}else if(typeof z.items!=="boolean")L(z.items,`${B}/items`,A)}for(let j of["allOf","anyOf","oneOf"]){let D=z[j];if(D)for(let F=0;F<D.length;F++){let G=D[F];if(G&&typeof G!=="boolean")L(G,`${B}/${j}/${F}`,A)}}if(z.not&&typeof z.not!=="boolean")L(z.not,`${B}/not`,A);for(let j of["definitions","$defs"]){let D=z[j];if(D){for(let[F,G]of Object.entries(D))if(G&&typeof G!=="boolean")L(G,`${B}/${j}/${F}`,A)}}}function H(z,B){if(!z.$ref)return z;let A=z.$ref,j=A.match(/^#\/(definitions|\$defs)\/(.+)$/);if(!j)throw Error(`Unsupported $ref format: "${A}". Only internal #/definitions/ references are supported.`);let D=j[1],F=j[2]??"",G=D==="definitions"?B.definitions:B.$defs;if(!G||!(F in G))throw Error(`Cannot resolve $ref "${A}": definition "${F}" not found.`);let J=G[F];if(!J||typeof J==="boolean")throw Error(`Cannot resolve $ref "${A}": definition "${F}" not found.`);return H(J,B)}function P(z,B,A){let j=H(z,A);if(j.properties&&B in j.properties){let J=j.properties[B];if(J&&typeof J!=="boolean")return H(J,A);if(J===!0)return{}}if(j.additionalProperties!==void 0&&j.additionalProperties!==!1){if(j.additionalProperties===!0)return{};return H(j.additionalProperties,A)}let D=j.type;if((D==="array"||Array.isArray(D)&&D.includes("array"))&&B==="length")return{type:"integer"};let G=V(j,B,A);if(G)return G;return}function V(z,B,A){if(z.allOf){let j=z.allOf.filter((D)=>typeof D!=="boolean").map((D)=>P(D,B,A)).filter((D)=>D!==void 0);if(j.length===1)return j[0];if(j.length>1)return{allOf:j}}for(let j of["anyOf","oneOf"]){if(!z[j])continue;let D=z[j].filter((F)=>typeof F!=="boolean").map((F)=>P(F,B,A)).filter((F)=>F!==void 0);if(D.length===1)return D[0];if(D.length>1)return{[j]:D}}return}function Y(z,B){if(B.length===0)return H(z,z);let A=H(z,z),j=z;for(let D of B){let F=P(A,D,j);if(F===void 0)return;A=F}return A}function Z(z,B){let A=H(z,B),j=A.type;if(!(j==="array"||Array.isArray(j)&&j.includes("array"))&&A.items===void 0)return;if(A.items===void 0)return{};if(typeof A.items==="boolean")return{};if(Array.isArray(A.items)){let F=A.items.filter((G)=>typeof G!=="boolean").map((G)=>H(G,B));if(F.length===0)return{};return{oneOf:F}}return H(A.items,B)}function O(z){for(let B of["oneOf","anyOf"]){let A=z[B];if(A&&A.length===1){let j=A[0];if(j!==void 0&&typeof j!=="boolean")return O(j)}}if(z.allOf&&z.allOf.length===1){let B=z.allOf[0];if(B!==void 0&&typeof B!=="boolean")return O(B)}for(let B of["oneOf","anyOf"]){let A=z[B];if(A&&A.length>1){let j=[];for(let D of A){if(typeof D==="boolean")continue;if(!j.some((G)=>Q(G,D)))j.push(O(D))}if(j.length===1)return j[0];return{...z,[B]:j}}}return z}
2
+ export{L as y,H as z,Y as A,Z as B,O as C};
3
3
 
4
- //# debugId=A260027DEA11137D64756E2164756E21
5
- //# sourceMappingURL=chunk-jms1ndxn.js.map
4
+ //# debugId=F89A6CEA5796209264756E2164756E21
5
+ //# sourceMappingURL=chunk-5znsrn10.js.map
@@ -5,6 +5,6 @@
5
5
  "import type { JSONSchema7 } from \"json-schema\";\nimport { UnsupportedSchemaError } from \"./errors.ts\";\nimport { deepEqual } from \"./utils.ts\";\n\n// ─── JSON Schema Resolver ────────────────────────────────────────────────────\n// Utility for navigating a JSON Schema Draft v7 by following a property path\n// (e.g. [\"user\", \"address\", \"city\"]).\n//\n// Handles:\n// - `$ref` resolution (internal references #/definitions/...)\n// - Navigation through `properties`\n// - Navigation through `items` (array elements)\n// - Combinators `allOf`, `anyOf`, `oneOf` (searches each branch)\n// - `additionalProperties` when the property is not explicitly declared\n//\n// Rejects:\n// - Conditional schemas (`if/then/else`) — non-resolvable without runtime data\n\n// ─── Conditional Schema Detection ────────────────────────────────────────────\n// JSON Schema Draft v7 introduced `if/then/else` conditional schemas.\n// These are fundamentally non-resolvable during static analysis because\n// they depend on runtime data values. Rather than silently ignoring them\n// (which would produce incorrect results — missing properties, wrong types),\n// we fail fast with a clear error pointing to the exact location in the schema.\n\n/**\n * Recursively validates that a JSON Schema does not contain `if/then/else`\n * conditional keywords. Throws an `UnsupportedSchemaError` if any are found.\n *\n * This check traverses the entire schema tree, including:\n * - `properties` values\n * - `additionalProperties` (when it's a schema)\n * - `items` (single schema or tuple)\n * - `allOf`, `anyOf`, `oneOf` branches\n * - `not`\n * - `definitions` / `$defs` values\n *\n * A `Set<object>` is used to track visited schemas and prevent infinite loops\n * from circular structures.\n *\n * @param schema - The JSON Schema to validate\n * @param path - The current JSON pointer path (for error reporting)\n * @param visited - Set of already-visited schema objects (cycle protection)\n *\n * @throws {UnsupportedSchemaError} if `if`, `then`, or `else` is found\n *\n * @example\n * ```\n * // Throws UnsupportedSchemaError:\n * assertNoConditionalSchema({\n * type: \"object\",\n * if: { properties: { kind: { const: \"a\" } } },\n * then: { properties: { a: { type: \"string\" } } },\n * });\n *\n * // OK — no conditional keywords:\n * assertNoConditionalSchema({\n * type: \"object\",\n * properties: { name: { type: \"string\" } },\n * });\n * ```\n */\nexport function assertNoConditionalSchema(\n\tschema: JSONSchema7,\n\tpath = \"\",\n\tvisited: Set<object> = new Set(),\n): void {\n\t// Cycle protection — avoid infinite loops on circular schema structures\n\tif (visited.has(schema)) return;\n\tvisited.add(schema);\n\n\t// ── Detect if/then/else at the current level ─────────────────────────\n\tif (schema.if !== undefined) {\n\t\tthrow new UnsupportedSchemaError(\"if/then/else\", path || \"/\");\n\t}\n\t// `then` or `else` without `if` is unusual but still unsupported\n\tif (schema.then !== undefined) {\n\t\tthrow new UnsupportedSchemaError(\"if/then/else\", path || \"/\");\n\t}\n\tif (schema.else !== undefined) {\n\t\tthrow new UnsupportedSchemaError(\"if/then/else\", path || \"/\");\n\t}\n\n\t// ── Recurse into properties ──────────────────────────────────────────\n\tif (schema.properties) {\n\t\tfor (const [key, prop] of Object.entries(schema.properties)) {\n\t\t\tif (prop && typeof prop !== \"boolean\") {\n\t\t\t\tassertNoConditionalSchema(prop, `${path}/properties/${key}`, visited);\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── Recurse into additionalProperties ────────────────────────────────\n\tif (\n\t\tschema.additionalProperties &&\n\t\ttypeof schema.additionalProperties === \"object\"\n\t) {\n\t\tassertNoConditionalSchema(\n\t\t\tschema.additionalProperties,\n\t\t\t`${path}/additionalProperties`,\n\t\t\tvisited,\n\t\t);\n\t}\n\n\t// ── Recurse into items ───────────────────────────────────────────────\n\tif (schema.items) {\n\t\tif (Array.isArray(schema.items)) {\n\t\t\tfor (let i = 0; i < schema.items.length; i++) {\n\t\t\t\tconst item = schema.items[i];\n\t\t\t\tif (item && typeof item !== \"boolean\") {\n\t\t\t\t\tassertNoConditionalSchema(item, `${path}/items/${i}`, visited);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeof schema.items !== \"boolean\") {\n\t\t\tassertNoConditionalSchema(schema.items, `${path}/items`, visited);\n\t\t}\n\t}\n\n\t// ── Recurse into combinators ─────────────────────────────────────────\n\tfor (const keyword of [\"allOf\", \"anyOf\", \"oneOf\"] as const) {\n\t\tconst branches = schema[keyword];\n\t\tif (branches) {\n\t\t\tfor (let i = 0; i < branches.length; i++) {\n\t\t\t\tconst branch = branches[i];\n\t\t\t\tif (branch && typeof branch !== \"boolean\") {\n\t\t\t\t\tassertNoConditionalSchema(branch, `${path}/${keyword}/${i}`, visited);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── Recurse into not ─────────────────────────────────────────────────\n\tif (schema.not && typeof schema.not !== \"boolean\") {\n\t\tassertNoConditionalSchema(schema.not, `${path}/not`, visited);\n\t}\n\n\t// ── Recurse into definitions / $defs ─────────────────────────────────\n\tfor (const defsKey of [\"definitions\", \"$defs\"] as const) {\n\t\tconst defs = schema[defsKey];\n\t\tif (defs) {\n\t\t\tfor (const [name, def] of Object.entries(defs)) {\n\t\t\t\tif (def && typeof def !== \"boolean\") {\n\t\t\t\t\tassertNoConditionalSchema(def, `${path}/${defsKey}/${name}`, visited);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// ─── $ref Resolution ─────────────────────────────────────────────────────────\n// Only supports internal references in the format `#/definitions/Foo`\n// or `#/$defs/Foo` (JSON Schema Draft 2019+). Remote $refs (URLs) are\n// not supported — that is outside the scope of a template engine.\n\n/**\n * Recursively resolves `$ref` in a schema using the root schema as the\n * source of definitions.\n */\nexport function resolveRef(\n\tschema: JSONSchema7,\n\troot: JSONSchema7,\n): JSONSchema7 {\n\tif (!schema.$ref) return schema;\n\n\tconst ref = schema.$ref;\n\n\t// Expected format: #/definitions/Name or #/$defs/Name\n\tconst match = ref.match(/^#\\/(definitions|\\$defs)\\/(.+)$/);\n\tif (!match) {\n\t\tthrow new Error(\n\t\t\t`Unsupported $ref format: \"${ref}\". Only internal #/definitions/ references are supported.`,\n\t\t);\n\t}\n\n\tconst defsKey = match[1] as \"definitions\" | \"$defs\";\n\tconst name = match[2] ?? \"\";\n\n\tconst defs = defsKey === \"definitions\" ? root.definitions : root.$defs;\n\n\tif (!defs || !(name in defs)) {\n\t\tthrow new Error(\n\t\t\t`Cannot resolve $ref \"${ref}\": definition \"${name}\" not found.`,\n\t\t);\n\t}\n\n\t// Recursive resolution in case the definition itself contains a $ref\n\tconst def = defs[name];\n\tif (!def || typeof def === \"boolean\") {\n\t\tthrow new Error(\n\t\t\t`Cannot resolve $ref \"${ref}\": definition \"${name}\" not found.`,\n\t\t);\n\t}\n\treturn resolveRef(def, root);\n}\n\n// ─── Single-Segment Path Navigation ─────────────────────────────────────────\n\n/**\n * Resolves a single path segment (a property name) within a schema.\n * Returns the corresponding sub-schema, or `undefined` if the path is invalid.\n *\n * @param schema - The current schema (already resolved, no $ref)\n * @param segment - The property name to resolve\n * @param root - The root schema (for resolving any internal $refs)\n */\nfunction resolveSegment(\n\tschema: JSONSchema7,\n\tsegment: string,\n\troot: JSONSchema7,\n): JSONSchema7 | undefined {\n\tconst resolved = resolveRef(schema, root);\n\n\t// 1. Explicit properties\n\tif (resolved.properties && segment in resolved.properties) {\n\t\tconst prop = resolved.properties[segment];\n\t\tif (prop && typeof prop !== \"boolean\") return resolveRef(prop, root);\n\t\tif (prop === true) return {};\n\t}\n\n\t// 2. additionalProperties (when the property is not declared)\n\tif (\n\t\tresolved.additionalProperties !== undefined &&\n\t\tresolved.additionalProperties !== false\n\t) {\n\t\tif (resolved.additionalProperties === true) {\n\t\t\t// additionalProperties: true → type is unknown\n\t\t\treturn {};\n\t\t}\n\t\treturn resolveRef(resolved.additionalProperties, root);\n\t}\n\n\t// 3. Intrinsic array properties (e.g. `.length`)\n\tconst schemaType = resolved.type;\n\tconst isArray =\n\t\tschemaType === \"array\" ||\n\t\t(Array.isArray(schemaType) && schemaType.includes(\"array\"));\n\n\tif (isArray && segment === \"length\") {\n\t\treturn { type: \"integer\" };\n\t}\n\n\t// 4. Combinators — search within each branch\n\tconst combinatorResult = resolveInCombinators(resolved, segment, root);\n\tif (combinatorResult) return combinatorResult;\n\n\treturn undefined;\n}\n\n/**\n * Searches for a segment within `allOf`, `anyOf`, `oneOf` branches.\n * Returns the first matching sub-schema, or `undefined`.\n * For `allOf`, found results are merged into a single `allOf`.\n */\nfunction resolveInCombinators(\n\tschema: JSONSchema7,\n\tsegment: string,\n\troot: JSONSchema7,\n): JSONSchema7 | undefined {\n\t// allOf: the property can be defined in any branch, and all constraints\n\t// apply simultaneously.\n\tif (schema.allOf) {\n\t\tconst matches = schema.allOf\n\t\t\t.filter((b): b is JSONSchema7 => typeof b !== \"boolean\")\n\t\t\t.map((branch) => resolveSegment(branch, segment, root))\n\t\t\t.filter((s): s is JSONSchema7 => s !== undefined);\n\n\t\tif (matches.length === 1) return matches[0] as JSONSchema7;\n\t\tif (matches.length > 1) return { allOf: matches };\n\t}\n\n\t// anyOf / oneOf: the property can come from any branch.\n\tfor (const key of [\"anyOf\", \"oneOf\"] as const) {\n\t\tif (!schema[key]) continue;\n\t\tconst matches = schema[key]\n\t\t\t.filter((b): b is JSONSchema7 => typeof b !== \"boolean\")\n\t\t\t.map((branch) => resolveSegment(branch, segment, root))\n\t\t\t.filter((s): s is JSONSchema7 => s !== undefined);\n\n\t\tif (matches.length === 1) return matches[0] as JSONSchema7;\n\t\tif (matches.length > 1) return { [key]: matches };\n\t}\n\n\treturn undefined;\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Resolves a full path (e.g. [\"user\", \"address\", \"city\"]) within a JSON\n * Schema and returns the corresponding sub-schema.\n *\n * @param schema - The root schema describing the template context\n * @param path - Array of segments (property names)\n * @returns The sub-schema at the end of the path, or `undefined` if the path\n * cannot be resolved.\n *\n * @example\n * ```\n * const schema = {\n * type: \"object\",\n * properties: {\n * user: {\n * type: \"object\",\n * properties: {\n * name: { type: \"string\" }\n * }\n * }\n * }\n * };\n * resolveSchemaPath(schema, [\"user\", \"name\"]);\n * // → { type: \"string\" }\n * ```\n */\nexport function resolveSchemaPath(\n\tschema: JSONSchema7,\n\tpath: string[],\n): JSONSchema7 | undefined {\n\tif (path.length === 0) return resolveRef(schema, schema);\n\n\tlet current: JSONSchema7 = resolveRef(schema, schema);\n\tconst root = schema;\n\n\tfor (const segment of path) {\n\t\tconst next = resolveSegment(current, segment, root);\n\t\tif (next === undefined) return undefined;\n\t\tcurrent = next;\n\t}\n\n\treturn current;\n}\n\n/**\n * Resolves the item schema of an array.\n * If the schema is not of type `array` or has no `items`, returns `undefined`.\n *\n * @param schema - The array schema\n * @param root - The root schema (for resolving $refs)\n */\nexport function resolveArrayItems(\n\tschema: JSONSchema7,\n\troot: JSONSchema7,\n): JSONSchema7 | undefined {\n\tconst resolved = resolveRef(schema, root);\n\n\t// Verify that it's actually an array\n\tconst schemaType = resolved.type;\n\tconst isArray =\n\t\tschemaType === \"array\" ||\n\t\t(Array.isArray(schemaType) && schemaType.includes(\"array\"));\n\n\tif (!isArray && resolved.items === undefined) {\n\t\treturn undefined;\n\t}\n\n\tif (resolved.items === undefined) {\n\t\t// array without items → element type is unknown\n\t\treturn {};\n\t}\n\n\t// items can be a boolean (true = anything, false = nothing)\n\tif (typeof resolved.items === \"boolean\") {\n\t\treturn {};\n\t}\n\n\t// items can be a single schema or a tuple (array of schemas).\n\t// For template loops, we handle the single-schema case.\n\tif (Array.isArray(resolved.items)) {\n\t\t// Tuple: create a oneOf of all possible types\n\t\tconst schemas = resolved.items\n\t\t\t.filter((item): item is JSONSchema7 => typeof item !== \"boolean\")\n\t\t\t.map((item) => resolveRef(item, root));\n\t\tif (schemas.length === 0) return {};\n\t\treturn { oneOf: schemas };\n\t}\n\n\treturn resolveRef(resolved.items, root);\n}\n\n/**\n * Simplifies an output schema to avoid unnecessarily complex constructs\n * (e.g. `oneOf` with a single element, duplicates, etc.).\n *\n * Uses `deepEqual` for deduplication — more robust and performant than\n * `JSON.stringify` (independent of key order, no intermediate string\n * allocations).\n */\nexport function simplifySchema(schema: JSONSchema7): JSONSchema7 {\n\t// oneOf / anyOf with a single element → unwrap\n\tfor (const key of [\"oneOf\", \"anyOf\"] as const) {\n\t\tconst arr = schema[key];\n\t\tif (arr && arr.length === 1) {\n\t\t\tconst first = arr[0];\n\t\t\tif (first !== undefined && typeof first !== \"boolean\")\n\t\t\t\treturn simplifySchema(first);\n\t\t}\n\t}\n\n\t// allOf with a single element → unwrap\n\tif (schema.allOf && schema.allOf.length === 1) {\n\t\tconst first = schema.allOf[0];\n\t\tif (first !== undefined && typeof first !== \"boolean\")\n\t\t\treturn simplifySchema(first);\n\t}\n\n\t// Deduplicate identical entries in oneOf/anyOf\n\tfor (const key of [\"oneOf\", \"anyOf\"] as const) {\n\t\tconst arr = schema[key];\n\t\tif (arr && arr.length > 1) {\n\t\t\tconst unique: JSONSchema7[] = [];\n\t\t\tfor (const entry of arr) {\n\t\t\t\tif (typeof entry === \"boolean\") continue;\n\t\t\t\t// Use deepEqual instead of JSON.stringify for structural\n\t\t\t\t// comparison — more robust (key order independent) and\n\t\t\t\t// more performant (no string allocations).\n\t\t\t\tconst isDuplicate = unique.some((existing) =>\n\t\t\t\t\tdeepEqual(existing, entry),\n\t\t\t\t);\n\t\t\t\tif (!isDuplicate) {\n\t\t\t\t\tunique.push(simplifySchema(entry));\n\t\t\t\t}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5796209264756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
- import{d as N}from"./chunk-t6n956qz.js";import{g as J}from"./chunk-efqd0598.js";import{l as I}from"./chunk-6955jpr7.js";import{I as L,J as M}from"./chunk-p5efqsxw.js";import{M as K}from"./chunk-zh1e0yhd.js";class H{state;options;hbsCompiled=null;get ast(){return this.state.kind==="template"?this.state.ast:null}get template(){return this.state.kind==="template"?this.state.source:""}constructor(w,q){this.state=w,this.options=q}static fromTemplate(w,q,B){return new H({kind:"template",ast:w,source:q},B)}static fromLiteral(w,q){return new H({kind:"literal",value:w},q)}static fromObject(w,q){return new H({kind:"object",children:w},q)}analyze(w,q){switch(this.state.kind){case"object":{let{children:B}=this.state;return L(Object.keys(B),(D)=>{let G=B[D];if(!G)throw Error(`unreachable: missing child "${D}"`);return G.analyze(w,q)})}case"literal":return{valid:!0,diagnostics:[],outputSchema:I(this.state.value)};case"template":return N(this.state.ast,this.state.source,w,{identifierSchemas:q,helpers:this.options.helpers})}}validate(w,q){let B=this.analyze(w,q);return{valid:B.valid,diagnostics:B.diagnostics}}execute(w,q){switch(this.state.kind){case"object":{let{children:B}=this.state,D={};for(let[G,Q]of Object.entries(B))D[G]=Q.execute(w,q);return D}case"literal":return this.state.value;case"template":{if(q?.schema){let B=this.analyze(q.schema,q.identifierSchemas);if(!B.valid)throw new K(B.diagnostics)}return J(this.state.ast,this.state.source,w,this.buildExecutorContext(q))}}}analyzeAndExecute(w,q,B){switch(this.state.kind){case"object":{let{children:D}=this.state;return M(Object.keys(D),(G)=>D[G].analyzeAndExecute(w,q,B))}case"literal":return{analysis:{valid:!0,diagnostics:[],outputSchema:I(this.state.value)},value:this.state.value};case"template":{let D=this.analyze(w,B?.identifierSchemas);if(!D.valid)return{analysis:D,value:void 0};let G=J(this.state.ast,this.state.source,q,this.buildExecutorContext({identifierData:B?.identifierData}));return{analysis:D,value:G}}}}buildExecutorContext(w){return{identifierData:w?.identifierData,compiledTemplate:this.getOrCompileHbs(),hbs:this.options.hbs,compilationCache:this.options.compilationCache}}getOrCompileHbs(){if(!this.hbsCompiled)this.hbsCompiled=this.options.hbs.compile(this.template,{noEscape:!0,strict:!1});return this.hbsCompiled}}
2
- export{H as b};
1
+ import{c as N}from"./chunk-dpffacsy.js";import{f as J}from"./chunk-wvnn9g55.js";import{k as I}from"./chunk-8xza8tca.js";import{H as L,I as M}from"./chunk-9jxzj2h4.js";import{L as K}from"./chunk-gayk9ew1.js";class H{state;options;hbsCompiled=null;get ast(){return this.state.kind==="template"?this.state.ast:null}get template(){return this.state.kind==="template"?this.state.source:""}constructor(w,q){this.state=w,this.options=q}static fromTemplate(w,q,B){return new H({kind:"template",ast:w,source:q},B)}static fromLiteral(w,q){return new H({kind:"literal",value:w},q)}static fromObject(w,q){return new H({kind:"object",children:w},q)}analyze(w,q){switch(this.state.kind){case"object":{let{children:B}=this.state;return L(Object.keys(B),(D)=>{let G=B[D];if(!G)throw Error(`unreachable: missing child "${D}"`);return G.analyze(w,q)})}case"literal":return{valid:!0,diagnostics:[],outputSchema:I(this.state.value)};case"template":return N(this.state.ast,this.state.source,w,{identifierSchemas:q,helpers:this.options.helpers})}}validate(w,q){let B=this.analyze(w,q);return{valid:B.valid,diagnostics:B.diagnostics}}execute(w,q){switch(this.state.kind){case"object":{let{children:B}=this.state,D={};for(let[G,Q]of Object.entries(B))D[G]=Q.execute(w,q);return D}case"literal":return this.state.value;case"template":{if(q?.schema){let B=this.analyze(q.schema,q.identifierSchemas);if(!B.valid)throw new K(B.diagnostics)}return J(this.state.ast,this.state.source,w,this.buildExecutorContext(q))}}}analyzeAndExecute(w,q,B){switch(this.state.kind){case"object":{let{children:D}=this.state;return M(Object.keys(D),(G)=>D[G].analyzeAndExecute(w,q,B))}case"literal":return{analysis:{valid:!0,diagnostics:[],outputSchema:I(this.state.value)},value:this.state.value};case"template":{let D=this.analyze(w,B?.identifierSchemas);if(!D.valid)return{analysis:D,value:void 0};let G=J(this.state.ast,this.state.source,q,this.buildExecutorContext({identifierData:B?.identifierData}));return{analysis:D,value:G}}}}buildExecutorContext(w){return{identifierData:w?.identifierData,compiledTemplate:this.getOrCompileHbs(),hbs:this.options.hbs,compilationCache:this.options.compilationCache}}getOrCompileHbs(){if(!this.hbsCompiled)this.hbsCompiled=this.options.hbs.compile(this.template,{noEscape:!0,strict:!1});return this.hbsCompiled}}
2
+ export{H as a};
3
3
 
4
- //# debugId=ADA0F28197C9A85E64756E2164756E21
5
- //# sourceMappingURL=chunk-ecs3yth2.js.map
4
+ //# debugId=C5C16B277901BD3E64756E2164756E21
5
+ //# sourceMappingURL=chunk-867xywnk.js.map
@@ -5,6 +5,6 @@
5
5
  "import type Handlebars from \"handlebars\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { analyzeFromAst } from \"./analyzer.ts\";\nimport { TemplateAnalysisError } from \"./errors.ts\";\nimport { type ExecutorContext, executeFromAst } from \"./executor.ts\";\nimport type {\n\tAnalysisResult,\n\tExecuteOptions,\n\tHelperDefinition,\n\tValidationResult,\n} from \"./types.ts\";\nimport { inferPrimitiveSchema } from \"./types.ts\";\nimport {\n\taggregateObjectAnalysis,\n\taggregateObjectAnalysisAndExecution,\n\ttype LRUCache,\n} from \"./utils.ts\";\n\n// ─── CompiledTemplate ────────────────────────────────────────────────────────\n// Pre-parsed template ready to be executed or analyzed without re-parsing.\n//\n// The compile-once / execute-many pattern avoids the cost of Handlebars\n// parsing on every call. The AST is parsed once at compile time, and the\n// Handlebars template is lazily compiled on the first `execute()`.\n//\n// Usage:\n// const tpl = engine.compile(\"Hello {{name}}\");\n// tpl.execute({ name: \"Alice\" }); // no re-parsing\n// tpl.execute({ name: \"Bob\" }); // no re-parsing or recompilation\n// tpl.analyze(schema); // no re-parsing\n//\n// ─── Internal State (TemplateState) ──────────────────────────────────────────\n// CompiledTemplate operates in 3 exclusive modes, modeled by a discriminated\n// union `TemplateState`:\n//\n// - `\"template\"` — parsed Handlebars template (AST + source string)\n// - `\"literal\"` — primitive passthrough value (number, boolean, null)\n// - `\"object\"` — object where each property is a child CompiledTemplate\n//\n// This design eliminates optional fields and `!` assertions in favor of\n// natural TypeScript narrowing via `switch (this.state.kind)`.\n//\n// ─── Advantages Over the Direct API ──────────────────────────────────────────\n// - **Performance**: parsing and compilation happen only once\n// - **Simplified API**: no need to re-pass the template string on each call\n// - **Consistency**: the same AST is used for both analysis and execution\n\n// ─── Internal Types ──────────────────────────────────────────────────────────\n\n/** Internal options passed by Typebars during compilation */\nexport interface CompiledTemplateOptions {\n\t/** Custom helpers registered on the engine */\n\thelpers: Map<string, HelperDefinition>;\n\t/** Isolated Handlebars environment (with registered helpers) */\n\thbs: typeof Handlebars;\n\t/** Compilation cache shared by the engine */\n\tcompilationCache: LRUCache<string, HandlebarsTemplateDelegate>;\n}\n\n/** Discriminated internal state of the CompiledTemplate */\ntype TemplateState =\n\t| {\n\t\t\treadonly kind: \"template\";\n\t\t\treadonly ast: hbs.AST.Program;\n\t\t\treadonly source: string;\n\t }\n\t| { readonly kind: \"literal\"; readonly value: number | boolean | null }\n\t| {\n\t\t\treadonly kind: \"object\";\n\t\t\treadonly children: Record<string, CompiledTemplate>;\n\t };\n\n// ─── Public Class ────────────────────────────────────────────────────────────\n\nexport class CompiledTemplate {\n\t/** Discriminated internal state */\n\tprivate readonly state: TemplateState;\n\n\t/** Options inherited from the parent Typebars instance */\n\tprivate readonly options: CompiledTemplateOptions;\n\n\t/** Compiled Handlebars template (lazy — created on the first `execute()` that needs it) */\n\tprivate hbsCompiled: HandlebarsTemplateDelegate | null = null;\n\n\t// ─── Public Accessors (backward-compatible) ──────────────────────────\n\n\t/** The pre-parsed Handlebars AST — `null` in literal or object mode */\n\tget ast(): hbs.AST.Program | null {\n\t\treturn this.state.kind === \"template\" ? this.state.ast : null;\n\t}\n\n\t/** The original template source — empty string in literal or object mode */\n\tget template(): string {\n\t\treturn this.state.kind === \"template\" ? this.state.source : \"\";\n\t}\n\n\t// ─── Construction ────────────────────────────────────────────────────\n\n\tprivate constructor(state: TemplateState, options: CompiledTemplateOptions) {\n\t\tthis.state = state;\n\t\tthis.options = options;\n\t}\n\n\t/**\n\t * Creates a CompiledTemplate for a parsed Handlebars template.\n\t *\n\t * @param ast - The pre-parsed Handlebars AST\n\t * @param source - The original template source\n\t * @param options - Options inherited from Typebars\n\t */\n\tstatic fromTemplate(\n\t\tast: hbs.AST.Program,\n\t\tsource: string,\n\t\toptions: CompiledTemplateOptions,\n\t): CompiledTemplate {\n\t\treturn new CompiledTemplate({ kind: \"template\", ast, source }, options);\n\t}\n\n\t/**\n\t * Creates a CompiledTemplate in passthrough mode for a literal value\n\t * (number, boolean, null). No parsing or compilation is performed.\n\t *\n\t * @param value - The primitive value\n\t * @param options - Options inherited from Typebars\n\t * @returns A CompiledTemplate that always returns `value`\n\t */\n\tstatic fromLiteral(\n\t\tvalue: number | boolean | null,\n\t\toptions: CompiledTemplateOptions,\n\t): CompiledTemplate {\n\t\treturn new CompiledTemplate({ kind: \"literal\", value }, options);\n\t}\n\n\t/**\n\t * Creates a CompiledTemplate in object mode, where each property is a\n\t * child CompiledTemplate. All operations are recursively delegated\n\t * to the children.\n\t *\n\t * @param children - The compiled child templates `{ [key]: CompiledTemplate }`\n\t * @param options - Options inherited from Typebars\n\t * @returns A CompiledTemplate that delegates to children\n\t */\n\tstatic fromObject(\n\t\tchildren: Record<string, CompiledTemplate>,\n\t\toptions: CompiledTemplateOptions,\n\t): CompiledTemplate {\n\t\treturn new CompiledTemplate({ kind: \"object\", children }, options);\n\t}\n\n\t// ─── Static Analysis ─────────────────────────────────────────────────\n\n\t/**\n\t * Statically analyzes this template against a JSON Schema v7.\n\t *\n\t * Returns an `AnalysisResult` containing:\n\t * - `valid` — `true` if no errors\n\t * - `diagnostics` — list of diagnostics (errors + warnings)\n\t * - `outputSchema` — JSON Schema describing the return type\n\t *\n\t * Since the AST is pre-parsed, this method never re-parses the template.\n\t *\n\t * @param inputSchema - JSON Schema describing the available variables\n\t * @param identifierSchemas - (optional) Schemas by identifier `{ [id]: JSONSchema7 }`\n\t */\n\tanalyze(\n\t\tinputSchema: JSONSchema7,\n\t\tidentifierSchemas?: Record<number, JSONSchema7>,\n\t): AnalysisResult {\n\t\tswitch (this.state.kind) {\n\t\t\tcase \"object\": {\n\t\t\t\tconst { children } = this.state;\n\t\t\t\treturn aggregateObjectAnalysis(Object.keys(children), (key) => {\n\t\t\t\t\tconst child = children[key];\n\t\t\t\t\tif (!child) throw new Error(`unreachable: missing child \"${key}\"`);\n\t\t\t\t\treturn child.analyze(inputSchema, identifierSchemas);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"literal\":\n\t\t\t\treturn {\n\t\t\t\t\tvalid: true,\n\t\t\t\t\tdiagnostics: [],\n\t\t\t\t\toutputSchema: inferPrimitiveSchema(this.state.value),\n\t\t\t\t};\n\n\t\t\tcase \"template\":\n\t\t\t\treturn analyzeFromAst(this.state.ast, this.state.source, inputSchema, {\n\t\t\t\t\tidentifierSchemas,\n\t\t\t\t\thelpers: this.options.helpers,\n\t\t\t\t});\n\t\t}\n\t}\n\n\t// ─── Validation ──────────────────────────────────────────────────────\n\n\t/**\n\t * Validates the template against a schema without returning the output type.\n\t *\n\t * This is an API shortcut for `analyze()` that only returns `valid` and\n\t * `diagnostics`, without `outputSchema`. The full analysis (including type\n\t * inference) is executed internally — this method provides no performance\n\t * gain, only a simplified API.\n\t *\n\t * @param inputSchema - JSON Schema describing the available variables\n\t * @param identifierSchemas - (optional) Schemas by identifier\n\t */\n\tvalidate(\n\t\tinputSchema: JSONSchema7,\n\t\tidentifierSchemas?: Record<number, JSONSchema7>,\n\t): ValidationResult {\n\t\tconst analysis = this.analyze(inputSchema, identifierSchemas);\n\t\treturn {\n\t\t\tvalid: analysis.valid,\n\t\t\tdiagnostics: analysis.diagnostics,\n\t\t};\n\t}\n\n\t// ─── Execution ───────────────────────────────────────────────────────\n\n\t/**\n\t * Executes this template with the provided data.\n\t *\n\t * The return type depends on the template structure:\n\t * - Single expression `{{expr}}` → raw value (number, boolean, object…)\n\t * - Mixed template or with blocks → `string`\n\t * - Primitive literal → the value as-is\n\t * - Object template → object with resolved values\n\t *\n\t * If a `schema` is provided in options, static analysis is performed\n\t * before execution. A `TemplateAnalysisError` is thrown on errors.\n\t *\n\t * @param data - The context data for rendering\n\t * @param options - Execution options (schema, identifierData, etc.)\n\t * @returns The execution result\n\t */\n\texecute(data: Record<string, unknown>, options?: ExecuteOptions): unknown {\n\t\tswitch (this.state.kind) {\n\t\t\tcase \"object\": {\n\t\t\t\tconst { children } = this.state;\n\t\t\t\tconst result: Record<string, unknown> = {};\n\t\t\t\tfor (const [key, child] of Object.entries(children)) {\n\t\t\t\t\tresult[key] = child.execute(data, options);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tcase \"literal\":\n\t\t\t\treturn this.state.value;\n\n\t\t\tcase \"template\": {\n\t\t\t\t// Pre-execution static validation if a schema is provided\n\t\t\t\tif (options?.schema) {\n\t\t\t\t\tconst analysis = this.analyze(\n\t\t\t\t\t\toptions.schema,\n\t\t\t\t\t\toptions.identifierSchemas,\n\t\t\t\t\t);\n\t\t\t\t\tif (!analysis.valid) {\n\t\t\t\t\t\tthrow new TemplateAnalysisError(analysis.diagnostics);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn executeFromAst(\n\t\t\t\t\tthis.state.ast,\n\t\t\t\t\tthis.state.source,\n\t\t\t\t\tdata,\n\t\t\t\t\tthis.buildExecutorContext(options),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// ─── Combined Shortcuts ──────────────────────────────────────────────\n\n\t/**\n\t * Analyzes and executes the template in a single call.\n\t *\n\t * Returns both the analysis result and the executed value.\n\t * If analysis fails, `value` is `undefined`.\n\t *\n\t * @param inputSchema - JSON Schema describing the available variables\n\t * @param data - The context data for rendering\n\t * @param options - Additional options\n\t * @returns `{ analysis, value }`\n\t */\n\tanalyzeAndExecute(\n\t\tinputSchema: JSONSchema7,\n\t\tdata: Record<string, unknown>,\n\t\toptions?: {\n\t\t\tidentifierSchemas?: Record<number, JSONSchema7>;\n\t\t\tidentifierData?: Record<number, Record<string, unknown>>;\n\t\t},\n\t): { analysis: AnalysisResult; value: unknown } {\n\t\tswitch (this.state.kind) {\n\t\t\tcase \"object\": {\n\t\t\t\tconst { children } = this.state;\n\t\t\t\treturn aggregateObjectAnalysisAndExecution(\n\t\t\t\t\tObject.keys(children),\n\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: key comes from Object.keys(children), access is guaranteed\n\t\t\t\t\t(key) => children[key]!.analyzeAndExecute(inputSchema, data, options),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcase \"literal\":\n\t\t\t\treturn {\n\t\t\t\t\tanalysis: {\n\t\t\t\t\t\tvalid: true,\n\t\t\t\t\t\tdiagnostics: [],\n\t\t\t\t\t\toutputSchema: inferPrimitiveSchema(this.state.value),\n\t\t\t\t\t},\n\t\t\t\t\tvalue: this.state.value,\n\t\t\t\t};\n\n\t\t\tcase \"template\": {\n\t\t\t\tconst analysis = this.analyze(inputSchema, options?.identifierSchemas);\n\n\t\t\t\tif (!analysis.valid) {\n\t\t\t\t\treturn { analysis, value: undefined };\n\t\t\t\t}\n\n\t\t\t\tconst value = executeFromAst(\n\t\t\t\t\tthis.state.ast,\n\t\t\t\t\tthis.state.source,\n\t\t\t\t\tdata,\n\t\t\t\t\tthis.buildExecutorContext({\n\t\t\t\t\t\tidentifierData: options?.identifierData,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\treturn { analysis, value };\n\t\t\t}\n\t\t}\n\t}\n\n\t// ─── Internals ───────────────────────────────────────────────────────\n\n\t/**\n\t * Builds the execution context for `executeFromAst`.\n\t *\n\t * Uses lazy Handlebars compilation: the template is only compiled\n\t * on the first call that needs it (not for single expressions).\n\t */\n\tprivate buildExecutorContext(options?: ExecuteOptions): ExecutorContext {\n\t\treturn {\n\t\t\tidentifierData: options?.identifierData,\n\t\t\tcompiledTemplate: this.getOrCompileHbs(),\n\t\t\thbs: this.options.hbs,\n\t\t\tcompilationCache: this.options.compilationCache,\n\t\t};\n\t}\n\n\t/**\n\t * Lazily compiles the Handlebars template and caches it.\n\t *\n\t * Compilation happens only once — subsequent calls return the\n\t * in-memory compiled template.\n\t *\n\t * Precondition: this method is only called from \"template\" mode.\n\t */\n\tprivate getOrCompileHbs(): HandlebarsTemplateDelegate {\n\t\tif (!this.hbsCompiled) {\n\t\t\t// In \"template\" mode, `this.template` returns the source string\n\t\t\tthis.hbsCompiled = this.options.hbs.compile(this.template, {\n\t\t\t\tnoEscape: true,\n\t\t\t\tstrict: false,\n\t\t\t});\n\t\t}\n\t\treturn this.hbsCompiled;\n\t}\n}\n"
6
6
  ],
7
7
  "mappings": "uOA0EO,AAAM,LAAiB,LAEZ,AAGA,QAGT,YAAiD,QAKrD,IAAG,EAA2B,CACjC,OAAO,KAAK,MAAM,OAAS,WAAa,KAAK,MAAM,IAAM,QAItD,SAAQ,EAAW,CACtB,OAAO,KAAK,MAAM,OAAS,WAAa,KAAK,MAAM,OAAS,GAKrD,WAAW,CAAC,EAAsB,EAAkC,CAC3E,KAAK,MAAQ,EACb,KAAK,QAAU,QAUT,aAAY,CAClB,EACA,EACA,EACmB,CACnB,OAAO,IAAI,EAAiB,CAAE,KAAM,WAAY,MAAK,QAAO,EAAG,CAAO,QAWhE,YAAW,CACjB,EACA,EACmB,CACnB,OAAO,IAAI,EAAiB,CAAE,KAAM,UAAW,OAAM,EAAG,CAAO,QAYzD,WAAU,CAChB,EACA,EACmB,CACnB,OAAO,IAAI,EAAiB,CAAE,KAAM,SAAU,UAAS,EAAG,CAAO,EAkBlE,OAAO,CACN,EACA,EACiB,CACjB,OAAQ,KAAK,MAAM,UACb,SAAU,CACd,IAAQ,YAAa,KAAK,MAC1B,OAAO,EAAwB,OAAO,KAAK,CAAQ,EAAG,CAAC,IAAQ,CAC9D,IAAM,EAAQ,EAAS,GACvB,GAAI,CAAC,EAA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EI,WAAY,CAChB,IAAM,EAAW,KAAK,QAAQ,EAAa,GAAS,iBAAiB,EAErE,GAAI,CAAC,EAAS,MACb,MAAO,CAAE,WAAU,MAAO,MAAU,EAGrC,IAAM,EAAQ,EACb,KAAK,MAAM,IACX,KAAK,MAAM,OACX,EACA,KAAK,qBAAqB,CACzB,eAAgB,GAAS,cAC1B,CAAC,CACF,EAEA,MAAO,CAAE,WAAU,OAAM,CAC1B,GAYM,oBAAoB,CAAC,EAA2C,CACvE,MAAO,CACN,eAAgB,GAAS,eACzB,iBAAkB,KAAK,gBAAgB,EACvC,IAAK,KAAK,QAAQ,IAClB,iBAAkB,KAAK,QAAQ,gBAChC,EAWO,eAAe,EAA+B,CACrD,GAAI,CAAC,KAAK,YAET,KAAK,YAAc,KAAK,QAAQ,IAAI,QAAQ,KAAK,SAAU,CAC1D,SAAU,GACV,OAAQ,EACT,CAAC,EAEF,OAAO,KAAK,YAEd",
8
- "debugId": "ADA0F28197C9A85E64756E2164756E21",
8
+ "debugId": "C5C16B277901BD3E64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  function k(j){return j===null||typeof j!=="string"&&typeof j!=="object"}function z(j){return j!==null&&typeof j==="object"}function A(j){if(j===null)return{type:"null"};if(typeof j==="boolean")return{type:"boolean"};if(typeof j==="number")return Number.isInteger(j)?{type:"integer"}:{type:"number"};return{type:"null"}}function B(j){return j}
2
- export{k as j,z as k,A as l,B as m};
2
+ export{k as i,z as j,A as k,B as l};
3
3
 
4
- //# debugId=ABFED878C9A1EDA264756E2164756E21
5
- //# sourceMappingURL=chunk-6955jpr7.js.map
4
+ //# debugId=6623216F1317FB4964756E2164756E21
5
+ //# sourceMappingURL=chunk-8xza8tca.js.map
@@ -5,6 +5,6 @@
5
5
  "import type { JSONSchema7 } from \"json-schema\";\nimport type { FromSchema, JSONSchema } from \"json-schema-to-ts\";\n\n// ─── Template Input ──────────────────────────────────────────────────────────\n// The engine accepts primitive values in addition to template strings.\n// When a non-string value is passed, it is treated as a literal passthrough:\n// analysis returns the inferred type, and execution returns the value as-is.\n\n/**\n * Object where each property is a `TemplateInput` (recursive).\n *\n * Allows passing an entire structure as a template:\n * ```\n * engine.analyze({\n * userName: \"{{name}}\",\n * userAge: \"{{age}}\",\n * nested: { x: \"{{foo}}\" },\n * }, inputSchema);\n * ```\n */\nexport interface TemplateInputObject {\n\t[key: string]: TemplateInput;\n}\n\n/**\n * Input type accepted by the template engine.\n *\n * - `string` → standard Handlebars template (parsed and executed)\n * - `number` → numeric literal (passthrough)\n * - `boolean` → boolean literal (passthrough)\n * - `null` → null literal (passthrough)\n * - `TemplateInputObject` → object where each property is a `TemplateInput`\n */\nexport type TemplateInput =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| TemplateInputObject;\n\n/**\n * Checks whether a value is a non-string primitive literal (number, boolean, null).\n * These values are treated as passthrough by the engine.\n *\n * Note: objects (`TemplateInputObject`) are NOT literals.\n */\nexport function isLiteralInput(\n\tinput: TemplateInput,\n): input is number | boolean | null {\n\treturn (\n\t\tinput === null || (typeof input !== \"string\" && typeof input !== \"object\")\n\t);\n}\n\n/**\n * Checks whether a value is a template object (`TemplateInputObject`).\n * Template objects are processed recursively by the engine:\n * each property is analyzed/executed individually.\n */\nexport function isObjectInput(\n\tinput: TemplateInput,\n): input is TemplateInputObject {\n\treturn input !== null && typeof input === \"object\";\n}\n\n/**\n * Infers the JSON Schema of a non-string primitive value.\n *\n * @param value - The primitive value (number, boolean, null)\n * @returns The corresponding JSON Schema\n *\n * @example\n * ```\n * inferPrimitiveSchema(42) // → { type: \"number\" }\n * inferPrimitiveSchema(true) // → { type: \"boolean\" }\n * inferPrimitiveSchema(null) // → { type: \"null\" }\n * ```\n */\nexport function inferPrimitiveSchema(\n\tvalue: number | boolean | null,\n): JSONSchema7 {\n\tif (value === null) return { type: \"null\" };\n\tif (typeof value === \"boolean\") return { type: \"boolean\" };\n\tif (typeof value === \"number\") {\n\t\treturn Number.isInteger(value) ? { type: \"integer\" } : { type: \"number\" };\n\t}\n\t// Exhaustiveness check — all branches are covered above.\n\t// If the type of `value` changes, TypeScript will raise an error here.\n\tvalue satisfies never;\n\treturn { type: \"null\" };\n}\n\n// ─── Diagnostic Codes ────────────────────────────────────────────────────────\n// Machine-readable codes for each error/warning type, enabling the frontend\n// to react programmatically without parsing the human-readable message.\n\nexport type DiagnosticCode =\n\t/** The referenced property does not exist in the context schema */\n\t| \"UNKNOWN_PROPERTY\"\n\t/** Type mismatch (e.g. #each on a non-array) */\n\t| \"TYPE_MISMATCH\"\n\t/** A block helper is used without a required argument */\n\t| \"MISSING_ARGUMENT\"\n\t/** Unknown block helper (neither built-in nor registered) */\n\t| \"UNKNOWN_HELPER\"\n\t/** The expression cannot be statically analyzed */\n\t| \"UNANALYZABLE\"\n\t/** The {{key:N}} syntax is used but no identifierSchemas were provided */\n\t| \"MISSING_IDENTIFIER_SCHEMAS\"\n\t/** The identifier N does not exist in the provided identifierSchemas */\n\t| \"UNKNOWN_IDENTIFIER\"\n\t/** The property does not exist in the identifier's schema */\n\t| \"IDENTIFIER_PROPERTY_NOT_FOUND\"\n\t/** Syntax error in the template */\n\t| \"PARSE_ERROR\";\n\n// ─── Diagnostic Details ──────────────────────────────────────────────────────\n// Supplementary information to understand the exact cause of the error.\n// Designed to be easily JSON-serializable and consumable by a frontend.\n\nexport interface DiagnosticDetails {\n\t/** Path of the expression that caused the error (e.g. `\"user.name.foo\"`) */\n\tpath?: string;\n\t/** Name of the helper involved (for helper-related errors) */\n\thelperName?: string;\n\t/** What was expected (e.g. `\"array\"`, `\"property to exist\"`) */\n\texpected?: string;\n\t/** What was found (e.g. `\"string\"`, `\"undefined\"`) */\n\tactual?: string;\n\t/** Available properties in the current schema (for suggestions) */\n\tavailableProperties?: string[];\n\t/** Template identifier number (for `{{key:N}}` errors) */\n\tidentifier?: number;\n}\n\n// ─── Static Analysis Result ──────────────────────────────────────────────────\n\n/** Diagnostic produced by the static analyzer */\nexport interface TemplateDiagnostic {\n\t/** \"error\" blocks execution, \"warning\" is informational */\n\tseverity: \"error\" | \"warning\";\n\n\t/** Machine-readable code identifying the error type */\n\tcode: DiagnosticCode;\n\n\t/** Human-readable message describing the problem */\n\tmessage: string;\n\n\t/** Position in the template source (if available from the AST) */\n\tloc?: {\n\t\tstart: { line: number; column: number };\n\t\tend: { line: number; column: number };\n\t};\n\n\t/** Fragment of the template source around the error */\n\tsource?: string;\n\n\t/** Structured information for debugging and frontend display */\n\tdetails?: DiagnosticDetails;\n}\n\n/** Complete result of the static analysis */\nexport interface AnalysisResult {\n\t/** true if no errors (warnings are tolerated) */\n\tvalid: boolean;\n\t/** List of diagnostics (errors + warnings) */\n\tdiagnostics: TemplateDiagnostic[];\n\t/** JSON Schema describing the template's return type */\n\toutputSchema: JSONSchema7;\n}\n\n/** Lightweight validation result (without output type inference) */\nexport interface ValidationResult {\n\t/** true if no errors (warnings are tolerated) */\n\tvalid: boolean;\n\t/** List of diagnostics (errors + warnings) */\n\tdiagnostics: TemplateDiagnostic[];\n}\n\n// ─── Public Engine Options ───────────────────────────────────────────────────\n\nexport interface TemplateEngineOptions {\n\t/**\n\t * Capacity of the parsed AST cache. Each parsed template is cached\n\t * to avoid costly re-parsing on repeated calls.\n\t * @default 256\n\t */\n\tastCacheSize?: number;\n\n\t/**\n\t * Capacity of the compiled Handlebars template cache.\n\t * @default 256\n\t */\n\tcompilationCacheSize?: number;\n\n\t/**\n\t * Custom helpers to register during engine construction.\n\t *\n\t * Each entry describes a helper with its name, implementation,\n\t * expected parameters, and return type.\n\t *\n\t * @example\n\t * ```\n\t * const engine = new Typebars({\n\t * helpers: [\n\t * {\n\t * name: \"uppercase\",\n\t * description: \"Converts a string to uppercase\",\n\t * fn: (value: string) => String(value).toUpperCase(),\n\t * params: [\n\t * { name: \"value\", type: { type: \"string\" }, description: \"The string to convert\" },\n\t * ],\n\t * returnType: { type: \"string\" },\n\t * },\n\t * ],\n\t * });\n\t * ```\n\t */\n\thelpers?: HelperConfig[];\n}\n\n// ─── Execution Options ───────────────────────────────────────────────────────\n// Optional options object for `execute()`, replacing multiple positional\n// parameters for better ergonomics.\n\nexport interface ExecuteOptions {\n\t/** JSON Schema for pre-execution static validation */\n\tschema?: JSONSchema7;\n\t/** Data by identifier `{ [id]: { key: value } }` */\n\tidentifierData?: Record<number, Record<string, unknown>>;\n\t/** Schemas by identifier (for static validation with identifiers) */\n\tidentifierSchemas?: Record<number, JSONSchema7>;\n}\n\n// ─── Combined Analyze-and-Execute Options ────────────────────────────────────\n// Optional options object for `analyzeAndExecute()`, grouping parameters\n// related to template identifiers.\n\nexport interface AnalyzeAndExecuteOptions {\n\t/** Schemas by identifier `{ [id]: JSONSchema7 }` for static analysis */\n\tidentifierSchemas?: Record<number, JSONSchema7>;\n\t/** Data by identifier `{ [id]: { key: value } }` for execution */\n\tidentifierData?: Record<number, Record<string, unknown>>;\n}\n\n// ─── Custom Helpers ──────────────────────────────────────────────────────────\n// Allows registering custom helpers with their type signature for static\n// analysis support.\n\n/** Describes a parameter expected by a helper */\nexport interface HelperParam {\n\t/** Parameter name (for documentation / introspection) */\n\tname: string;\n\n\t/**\n\t * JSON Schema describing the expected type for this parameter.\n\t * Used for documentation and static validation.\n\t */\n\ttype?: JSONSchema7;\n\n\t/** Human-readable description of the parameter */\n\tdescription?: string;\n\n\t/**\n\t * Whether the parameter is optional.\n\t * @default false\n\t */\n\toptional?: boolean;\n}\n\n/**\n * Definition of a helper registerable via `registerHelper()`.\n *\n * Contains the runtime implementation and typing metadata\n * for static analysis.\n */\nexport interface HelperDefinition {\n\t/**\n\t * Runtime implementation of the helper — will be registered with Handlebars.\n\t *\n\t * For an inline helper `{{uppercase name}}`:\n\t * `(value: string) => string`\n\t *\n\t * For a block helper `{{#repeat count}}...{{/repeat}}`:\n\t * `function(this: any, count: number, options: Handlebars.HelperOptions) { ... }`\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: Handlebars helper signatures are inherently dynamic\n\tfn: (...args: any[]) => unknown;\n\n\t/**\n\t * Parameters expected by the helper (for documentation and analysis).\n\t *\n\t * @example\n\t * ```\n\t * params: [\n\t * { name: \"value\", type: { type: \"number\" }, description: \"The value to round\" },\n\t * { name: \"precision\", type: { type: \"number\" }, description: \"Decimal places\", optional: true },\n\t * ]\n\t * ```\n\t */\n\tparams?: HelperParam[];\n\n\t/**\n\t * JSON Schema describing the helper's return type for static analysis.\n\t * @default { type: \"string\" }\n\t */\n\treturnType?: JSONSchema7;\n\n\t/** Human-readable description of the helper */\n\tdescription?: string;\n}\n\n/**\n * Full helper configuration for registration via the `Typebars({ helpers: [...] })`\n * constructor options.\n *\n * Extends `HelperDefinition` with a required `name`.\n *\n * @example\n * ```\n * const config: HelperConfig = {\n * name: \"round\",\n * description: \"Rounds a number to a given precision\",\n * fn: (value: number, precision?: number) => { ... },\n * params: [\n * { name: \"value\", type: { type: \"number\" } },\n * { name: \"precision\", type: { type: \"number\" }, optional: true },\n * ],\n * returnType: { type: \"number\" },\n * };\n * ```\n */\nexport interface HelperConfig extends HelperDefinition {\n\t/** Name of the helper as used in templates (e.g. `\"uppercase\"`) */\n\tname: string;\n}\n\n// ─── Automatic Type Inference via json-schema-to-ts ──────────────────────────\n// Allows `defineHelper()` to infer TypeScript types for `fn` arguments\n// from the JSON Schemas declared in `params`.\n\n/**\n * Param definition used for type inference.\n * Accepts `JSONSchema` from `json-schema-to-ts` to allow `FromSchema`\n * to resolve literal types.\n */\ntype TypedHelperParam = {\n\treadonly name: string;\n\treadonly type?: JSONSchema;\n\treadonly description?: string;\n\treadonly optional?: boolean;\n};\n\n/**\n * Infers the TypeScript type of a single parameter from its JSON Schema.\n * - If `optional: true`, the resolved type is unioned with `undefined`.\n * - If `type` is not provided, the type is `unknown`.\n */\ntype InferParamType<P> = P extends {\n\treadonly type: infer S extends JSONSchema;\n\treadonly optional: true;\n}\n\t? FromSchema<S> | undefined\n\t: P extends { readonly type: infer S extends JSONSchema }\n\t\t? FromSchema<S>\n\t\t: unknown;\n\n/**\n * Maps a tuple of `TypedHelperParam` to a tuple of inferred TypeScript types,\n * usable as the `fn` signature.\n *\n * @example\n * ```\n * type Args = InferArgs<readonly [\n * { name: \"a\"; type: { type: \"string\" } },\n * { name: \"b\"; type: { type: \"number\" }; optional: true },\n * ]>;\n * // => [string, number | undefined]\n * ```\n */\ntype InferArgs<P extends readonly TypedHelperParam[]> = {\n\t[K in keyof P]: InferParamType<P[K]>;\n};\n\n/**\n * Helper configuration with generic parameter inference.\n * Used exclusively by `defineHelper()`.\n */\ninterface TypedHelperConfig<P extends readonly TypedHelperParam[]> {\n\tname: string;\n\tdescription?: string;\n\tparams: P;\n\tfn: (...args: InferArgs<P>) => unknown;\n\treturnType?: JSONSchema;\n}\n\n/**\n * Creates a `HelperConfig` with automatic type inference for `fn` arguments\n * based on the JSON Schemas declared in `params`.\n *\n * The generic parameter `const P` preserves schema literal types\n * (equivalent of `as const`), enabling `FromSchema` to resolve the\n * corresponding TypeScript types.\n *\n * @example\n * ```\n * const helper = defineHelper({\n * name: \"concat\",\n * description: \"Concatenates two strings\",\n * params: [\n * { name: \"a\", type: { type: \"string\" }, description: \"First string\" },\n * { name: \"b\", type: { type: \"string\" }, description: \"Second string\" },\n * { name: \"sep\", type: { type: \"string\" }, description: \"Separator\", optional: true },\n * ],\n * fn: (a, b, sep) => {\n * // a: string, b: string, sep: string | undefined\n * const separator = sep ?? \"\";\n * return `${a}${separator}${b}`;\n * },\n * returnType: { type: \"string\" },\n * });\n * ```\n */\nexport function defineHelper<const P extends readonly TypedHelperParam[]>(\n\tconfig: TypedHelperConfig<P>,\n): HelperConfig {\n\treturn config as unknown as HelperConfig;\n}\n"
6
6
  ],
7
7
  "mappings": "AA8CO,SAAS,CAAc,CAC7B,EACmC,CACnC,OACC,IAAU,MAAS,OAAO,IAAU,UAAY,OAAO,IAAU,SAS5D,SAAS,CAAa,CAC5B,EAC+B,CAC/B,OAAO,IAAU,MAAQ,OAAO,IAAU,SAgBpC,SAAS,CAAoB,CACnC,EACc,CACd,GAAI,IAAU,KAAM,MAAO,CAAE,KAAM,MAAO,EAC1C,GAAI,OAAO,IAAU,UAAW,MAAO,CAAE,KAAM,SAAU,EACzD,GAAI,OAAO,IAAU,SACpB,OAAO,OAAO,UAAU,CAAK,EAAI,CAAE,KAAM,SAAU,EAAI,CAAE,KAAM,QAAS,EAKzE,MAAO,CAAE,KAAM,MAAO,EA8UhB,SAAS,CAAyD,CACxE,EACe,CACf,OAAO",
8
- "debugId": "ABFED878C9A1EDA264756E2164756E21",
8
+ "debugId": "6623216F1317FB4964756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,7 +1,7 @@
1
1
  function P(w,G){if(w===G)return!0;if(w===null||G===null)return!1;if(typeof w!==typeof G)return!1;if(Array.isArray(w)){if(!Array.isArray(G))return!1;if(w.length!==G.length)return!1;for(let F=0;F<w.length;F++)if(!P(w[F],G[F]))return!1;return!0}if(typeof w==="object"){let F=w,H=G,I=Object.keys(F),J=Object.keys(H);if(I.length!==J.length)return!1;for(let M of I)if(!(M in H)||!P(F[M],H[M]))return!1;return!0}return!1}class Q{capacity;cache=new Map;constructor(w){this.capacity=w;if(w<1)throw Error("LRUCache capacity must be at least 1")}get(w){if(!this.cache.has(w))return;let G=this.cache.get(w);return this.cache.delete(w),this.cache.set(w,G),G}set(w,G){if(this.cache.has(w))this.cache.delete(w);else if(this.cache.size>=this.capacity){let F=this.cache.keys().next().value;if(F!==void 0)this.cache.delete(F)}this.cache.set(w,G)}has(w){return this.cache.has(w)}delete(w){return this.cache.delete(w)}clear(){this.cache.clear()}get size(){return this.cache.size}}function S(w,G){let F=w.split(`
2
2
  `),H=G.start.line-1,I=G.end.line-1;if(H<0||H>=F.length)return"";if(H===I)return(F[H]??"").trim();let J=Math.min(I,F.length-1);return F.slice(H,J+1).map((M)=>M.trimEnd()).join(`
3
3
  `).trim()}function U(w){let G=new Set;if(w.properties)for(let F of Object.keys(w.properties))G.add(F);for(let F of["allOf","anyOf","oneOf"]){let H=w[F];if(H)for(let I of H){if(typeof I==="boolean")continue;if(I.properties)for(let J of Object.keys(I.properties))G.add(J)}}return Array.from(G).sort()}function W(w,G){let F=[],H={},I=!0;for(let J of w){let M=G(J);if(!M.valid)I=!1;F.push(...M.diagnostics),H[J]=M.outputSchema}return{valid:I,diagnostics:F,outputSchema:{type:"object",properties:H,required:w}}}function X(w,G){let F=[],H={},I={},J=!0;for(let O of w){let N=G(O);if(!N.analysis.valid)J=!1;F.push(...N.analysis.diagnostics),H[O]=N.analysis.outputSchema,I[O]=N.value}return{analysis:{valid:J,diagnostics:F,outputSchema:{type:"object",properties:H,required:w}},value:J?I:void 0}}
4
- export{P as E,Q as F,S as G,U as H,W as I,X as J};
4
+ export{P as D,Q as E,S as F,U as G,W as H,X as I};
5
5
 
6
- //# debugId=5B80D0A0D95DB3B764756E2164756E21
7
- //# sourceMappingURL=chunk-p5efqsxw.js.map
6
+ //# debugId=DA20CEFC32FCC07E64756E2164756E21
7
+ //# sourceMappingURL=chunk-9jxzj2h4.js.map
@@ -5,6 +5,6 @@
5
5
  "import type { JSONSchema7 } from \"json-schema\";\nimport type { AnalysisResult, TemplateDiagnostic } from \"./types.ts\";\n\n// ─── Utilities ───────────────────────────────────────────────────────────────\n// Shared utility functions and classes used across the different modules\n// of the template engine.\n\n// ─── Deep Equality ───────────────────────────────────────────────────────────\n// Deep structural comparison for JSON-compatible values.\n// More robust than `JSON.stringify` because it is independent of key order\n// and does not allocate intermediate strings.\n\n/**\n * Recursively compares two JSON-compatible values.\n *\n * @param a - First value\n * @param b - Second value\n * @returns `true` if the two values are structurally identical\n *\n * @example\n * ```\n * deepEqual({ a: 1, b: 2 }, { b: 2, a: 1 }) // → true\n * deepEqual([1, 2], [1, 2]) // → true\n * deepEqual({ a: 1 }, { a: 2 }) // → false\n * ```\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n\t// Strict identity (covers primitives, same ref; NaN !== NaN is intentional)\n\tif (a === b) return true;\n\n\t// null is typeof \"object\" in JS — handle it separately\n\tif (a === null || b === null) return false;\n\tif (typeof a !== typeof b) return false;\n\n\t// ── Arrays ───────────────────────────────────────────────────────────────\n\tif (Array.isArray(a)) {\n\t\tif (!Array.isArray(b)) return false;\n\t\tif (a.length !== b.length) return false;\n\t\tfor (let i = 0; i < a.length; i++) {\n\t\t\tif (!deepEqual(a[i], b[i])) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ── Objects ──────────────────────────────────────────────────────────────\n\tif (typeof a === \"object\") {\n\t\tconst objA = a as Record<string, unknown>;\n\t\tconst objB = b as Record<string, unknown>;\n\t\tconst keysA = Object.keys(objA);\n\t\tconst keysB = Object.keys(objB);\n\n\t\tif (keysA.length !== keysB.length) return false;\n\n\t\tfor (const key of keysA) {\n\t\t\tif (!(key in objB) || !deepEqual(objA[key], objB[key])) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Different primitives (already covered by a === b at the top)\n\treturn false;\n}\n\n// ─── LRU Cache ───────────────────────────────────────────────────────────────\n// Fixed-capacity cache with Least Recently Used (LRU) eviction.\n// Leverages `Map` insertion order to track access: the oldest entry\n// is always in the first position.\n\n/**\n * Simple fixed-capacity LRU cache.\n *\n * @example\n * ```\n * const cache = new LRUCache<string, number>(2);\n * cache.set(\"a\", 1);\n * cache.set(\"b\", 2);\n * cache.get(\"a\"); // → 1 (marks \"a\" as recently used)\n * cache.set(\"c\", 3); // evicts \"b\" (least recently used)\n * cache.get(\"b\"); // → undefined\n * ```\n */\nexport class LRUCache<K, V> {\n\tprivate readonly cache = new Map<K, V>();\n\n\tconstructor(private readonly capacity: number) {\n\t\tif (capacity < 1) {\n\t\t\tthrow new Error(\"LRUCache capacity must be at least 1\");\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves a value from the cache. Returns `undefined` if absent.\n\t * Marks the entry as recently used.\n\t */\n\tget(key: K): V | undefined {\n\t\tif (!this.cache.has(key)) return undefined;\n\n\t\t// Move to the end of the Map (= most recently used)\n\t\tconst value = this.cache.get(key) as V;\n\t\tthis.cache.delete(key);\n\t\tthis.cache.set(key, value);\n\t\treturn value;\n\t}\n\n\t/**\n\t * Inserts or updates a value in the cache.\n\t * If the cache is full, evicts the least recently used entry.\n\t */\n\tset(key: K, value: V): void {\n\t\tif (this.cache.has(key)) {\n\t\t\tthis.cache.delete(key);\n\t\t} else if (this.cache.size >= this.capacity) {\n\t\t\t// Evict the first entry (the oldest one)\n\t\t\tconst oldestKey = this.cache.keys().next().value;\n\t\t\tif (oldestKey !== undefined) {\n\t\t\t\tthis.cache.delete(oldestKey);\n\t\t\t}\n\t\t}\n\t\tthis.cache.set(key, value);\n\t}\n\n\t/**\n\t * Checks whether a key exists in the cache (without affecting LRU order).\n\t */\n\thas(key: K): boolean {\n\t\treturn this.cache.has(key);\n\t}\n\n\t/**\n\t * Removes an entry from the cache.\n\t * @returns `true` if the entry existed and was removed\n\t */\n\tdelete(key: K): boolean {\n\t\treturn this.cache.delete(key);\n\t}\n\n\t/** Clears the entire cache. */\n\tclear(): void {\n\t\tthis.cache.clear();\n\t}\n\n\t/** Number of entries currently in the cache. */\n\tget size(): number {\n\t\treturn this.cache.size;\n\t}\n}\n\n// ─── Source Snippet Extraction ────────────────────────────────────────────────\n// Used to enrich diagnostics with the template fragment that caused the error.\n\n/**\n * Extracts a template fragment around a given position.\n *\n * @param template - The full template source\n * @param loc - The position (line/column, 1-based) of the error\n * @returns The corresponding code fragment (trimmed)\n */\nexport function extractSourceSnippet(\n\ttemplate: string,\n\tloc: {\n\t\tstart: { line: number; column: number };\n\t\tend: { line: number; column: number };\n\t},\n): string {\n\tconst lines = template.split(\"\\n\");\n\tconst startLine = loc.start.line - 1; // 0-based\n\tconst endLine = loc.end.line - 1;\n\n\tif (startLine < 0 || startLine >= lines.length) return \"\";\n\n\tif (startLine === endLine) {\n\t\t// Same line — extract the portion between start.column and end.column\n\t\tconst line = lines[startLine] ?? \"\";\n\t\treturn line.trim();\n\t}\n\n\t// Multi-line — return the affected lines\n\tconst clampedEnd = Math.min(endLine, lines.length - 1);\n\treturn lines\n\t\t.slice(startLine, clampedEnd + 1)\n\t\t.map((l) => l.trimEnd())\n\t\t.join(\"\\n\")\n\t\t.trim();\n}\n\n// ─── Schema Properties ──────────────────────────────────────────────────────\n// Utility for listing available properties in a schema, used to enrich\n// error messages with suggestions.\n\n/**\n * Lists the declared property names in a JSON Schema.\n * Returns an empty array if the schema has no `properties`.\n */\nexport function getSchemaPropertyNames(schema: JSONSchema7): string[] {\n\tconst names = new Set<string>();\n\n\t// Direct properties\n\tif (schema.properties) {\n\t\tfor (const key of Object.keys(schema.properties)) {\n\t\t\tnames.add(key);\n\t\t}\n\t}\n\n\t// Properties within combinators\n\tfor (const combinator of [\"allOf\", \"anyOf\", \"oneOf\"] as const) {\n\t\tconst branches = schema[combinator];\n\t\tif (branches) {\n\t\t\tfor (const branch of branches) {\n\t\t\t\tif (typeof branch === \"boolean\") continue;\n\t\t\t\tif (branch.properties) {\n\t\t\t\t\tfor (const key of Object.keys(branch.properties)) {\n\t\t\t\t\t\tnames.add(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Array.from(names).sort();\n}\n\n// ─── Object Analysis Aggregation ─────────────────────────────────────────────\n// Factorizes the common recursion pattern over template objects:\n// iterate the keys, analyze each entry via a callback, accumulate\n// diagnostics, and build the output object schema.\n//\n// Used by:\n// - `analyzer.ts` (analyzeObjectTemplate)\n// - `Typebars.analyzeObject()` (typebars.ts)\n// - `CompiledTemplate.analyze()` in object mode (compiled-template.ts)\n\n/**\n * Aggregates analysis results from a set of named entries into a single\n * `AnalysisResult` with an object-typed `outputSchema`.\n *\n * @param keys - The keys of the object to analyze\n * @param analyzeEntry - Callback that analyzes an entry by its key\n * @returns An aggregated `AnalysisResult`\n *\n * @example\n * ```\n * aggregateObjectAnalysis(\n * Object.keys(template),\n * (key) => analyze(template[key], inputSchema),\n * );\n * ```\n */\nexport function aggregateObjectAnalysis(\n\tkeys: string[],\n\tanalyzeEntry: (key: string) => AnalysisResult,\n): AnalysisResult {\n\tconst allDiagnostics: TemplateDiagnostic[] = [];\n\tconst properties: Record<string, JSONSchema7> = {};\n\tlet allValid = true;\n\n\tfor (const key of keys) {\n\t\tconst child = analyzeEntry(key);\n\t\tif (!child.valid) allValid = false;\n\t\tallDiagnostics.push(...child.diagnostics);\n\t\tproperties[key] = child.outputSchema;\n\t}\n\n\treturn {\n\t\tvalid: allValid,\n\t\tdiagnostics: allDiagnostics,\n\t\toutputSchema: {\n\t\t\ttype: \"object\",\n\t\t\tproperties,\n\t\t\trequired: keys,\n\t\t},\n\t};\n}\n\n/**\n * Aggregates both analysis **and** execution results from a set of named\n * entries. Returns the aggregated `AnalysisResult` and the object of\n * executed values (or `undefined` if at least one entry is invalid).\n *\n * @param keys - The keys of the object\n * @param processEntry - Callback that analyzes and executes an entry by its key\n * @returns Aggregated `{ analysis, value }`\n */\nexport function aggregateObjectAnalysisAndExecution(\n\tkeys: string[],\n\tprocessEntry: (key: string) => { analysis: AnalysisResult; value: unknown },\n): { analysis: AnalysisResult; value: unknown } {\n\tconst allDiagnostics: TemplateDiagnostic[] = [];\n\tconst properties: Record<string, JSONSchema7> = {};\n\tconst resultValues: Record<string, unknown> = {};\n\tlet allValid = true;\n\n\tfor (const key of keys) {\n\t\tconst child = processEntry(key);\n\t\tif (!child.analysis.valid) allValid = false;\n\t\tallDiagnostics.push(...child.analysis.diagnostics);\n\t\tproperties[key] = child.analysis.outputSchema;\n\t\tresultValues[key] = child.value;\n\t}\n\n\tconst analysis: AnalysisResult = {\n\t\tvalid: allValid,\n\t\tdiagnostics: allDiagnostics,\n\t\toutputSchema: {\n\t\t\ttype: \"object\",\n\t\t\tproperties,\n\t\t\trequired: keys,\n\t\t},\n\t};\n\n\treturn {\n\t\tanalysis,\n\t\tvalue: allValid ? resultValues : undefined,\n\t};\n}\n"
6
6
  ],
7
7
  "mappings": "AA0BO,SAAS,CAAS,CAAC,EAAY,EAAqB,CAE1D,GAA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AAI,CAAC,EAAM,MAAO,EAAW,GAC7B,EAAe,KAAK,GAAG,EAAM,WAAW,EACxC,EAAW,GAAO,EAAM,aAGzB,MAAO,CACN,MAAO,EACP,YAAa,EACb,aAAc,CACb,KAAM,SACN,aACA,SAAU,CACX,CACD,EAYM,SAAS,CAAmC,CAClD,EACA,EAC+C,CAC/C,IAAM,EAAuC,CAAC,EACxC,EAA0C,CAAC,EAC3C,EAAwC,CAAC,EAC3C,EAAW,GAEf,QAAW,KAAO,EAAM,CACvB,IAAM,EAAQ,EAAa,CAAG,EAC9B,GAAI,CAAC,EAAM,SAAS,MAAO,EAAW,GACtC,EAAe,KAAK,GAAG,EAAM,SAAS,WAAW,EACjD,EAAW,GAAO,EAAM,SAAS,aACjC,EAAa,GAAO,EAAM,MAa3B,MAAO,CACN,SAXgC,CAChC,MAAO,EACP,YAAa,EACb,aAAc,CACb,KAAM,SACN,aACA,SAAU,CACX,CACD,EAIC,MAAO,EAAW,EAAe,MAClC",
8
- "debugId": "5B80D0A0D95DB3B764756E2164756E21",
8
+ "debugId": "DA20CEFC32FCC07E64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,4 @@
1
+ import{i as S,j as f,k as h}from"./chunk-8xza8tca.js";import{m as q,o as C,p as D,q as W,r as E,s as T,u as P,x as y}from"./chunk-s96k41p3.js";import{A as $,B as v,C as V,y as Y}from"./chunk-5znsrn10.js";import{D as u,F as N,G as _,H as g}from"./chunk-9jxzj2h4.js";import{O as B,P as M,Q as U,R as b,S as k}from"./chunk-gayk9ew1.js";function i(j,w,A){if(f(j))return p(j,w,A);if(S(j))return{valid:!0,diagnostics:[],outputSchema:h(j)};let F=q(j);return a(F,j,w,{identifierSchemas:A})}function p(j,w,A){return g(Object.keys(j),(F)=>i(j[F],w,A))}function a(j,w,A,F){if(Y(A),F?.identifierSchemas)for(let[G,J]of Object.entries(F.identifierSchemas))Y(J,`/identifierSchemas/${G}`);let z={root:A,current:A,diagnostics:[],template:w,identifierSchemas:F?.identifierSchemas,helpers:F?.helpers},H=K(j,z);return{valid:!z.diagnostics.some((G)=>G.severity==="error"),diagnostics:z.diagnostics,outputSchema:V(H)}}function x(j,w){switch(j.type){case"ContentStatement":case"CommentStatement":return;case"MustacheStatement":return d(j,w);case"BlockStatement":return Z(j,w);default:L(w,"UNANALYZABLE","warning",`Unsupported AST node type: "${j.type}"`,j);return}}function d(j,w){if(j.path.type==="SubExpression")return L(w,"UNANALYZABLE","warning","Sub-expressions are not statically analyzable",j),{};if(j.params.length>0||j.hash){let A=n(j.path),F=w.helpers?.get(A);if(F){let z=F.params;if(z){let H=z.filter((I)=>!I.optional).length;if(j.params.length<H)L(w,"MISSING_ARGUMENT","error",`Helper "${A}" expects at least ${H} argument(s), but got ${j.params.length}`,j,{helperName:A,expected:`${H} argument(s)`,actual:`${j.params.length} argument(s)`})}for(let H=0;H<j.params.length;H++){let I=R(j.params[H],w,j),G=z?.[H];if(I&&G?.type){let J=G.type;if(!o(I,J)){let O=G.name;L(w,"TYPE_MISMATCH","error",`Helper "${A}" parameter "${O}" expects ${Q(J)}, but got ${Q(I)}`,j,{helperName:A,expected:Q(J),actual:Q(I)})}}}return F.returnType??{type:"string"}}return L(w,"UNKNOWN_HELPER","warning",`Unknown inline helper "${A}" — cannot analyze statically`,j,{helperName:A}),{type:"string"}}return R(j.path,w,j)??{}}function o(j,w){if(!w.type||!j.type)return!0;let A=Array.isArray(w.type)?w.type:[w.type];return(Array.isArray(j.type)?j.type:[j.type]).some((z)=>A.some((H)=>z===H||H==="number"&&z==="integer"||H==="integer"&&z==="number"))}function K(j,w){let A=W(j);if(A.length===0)return{type:"string"};let F=T(j);if(F)return d(F,w);let z=E(j);if(z)return Z(z,w);if(A.every((G)=>G.type==="ContentStatement")){let G=A.map((O)=>O.value).join("").trim();if(G==="")return{type:"string"};let J=P(G);if(J)return{type:J}}if(A.every((G)=>G.type==="BlockStatement")){let G=[];for(let J of A){let O=Z(J,w);if(O)G.push(O)}if(G.length===1)return G[0];if(G.length>1)return V({oneOf:G});return{type:"string"}}for(let G of j.body)x(G,w);return{type:"string"}}function Z(j,w){let A=c(j);switch(A){case"if":case"unless":{let F=X(j);if(F)R(F,w,j);else L(w,"MISSING_ARGUMENT","error",U(A),j,{helperName:A});let z=K(j.program,w);if(j.inverse){let H=K(j.inverse,w);if(u(z,H))return z;return V({oneOf:[z,H]})}return z}case"each":{let F=X(j);if(!F){L(w,"MISSING_ARGUMENT","error",U("each"),j,{helperName:"each"});let G=w.current;if(w.current={},K(j.program,w),w.current=G,j.inverse)K(j.inverse,w);return{type:"string"}}let z=R(F,w,j);if(!z){let G=w.current;if(w.current={},K(j.program,w),w.current=G,j.inverse)K(j.inverse,w);return{type:"string"}}let H=v(z,w.root);if(!H){L(w,"TYPE_MISMATCH","error",M("each","an array",Q(z)),j,{helperName:"each",expected:"array",actual:Q(z)});let G=w.current;if(w.current={},K(j.program,w),w.current=G,j.inverse)K(j.inverse,w);return{type:"string"}}let I=w.current;if(w.current=H,K(j.program,w),w.current=I,j.inverse)K(j.inverse,w);return{type:"string"}}case"with":{let F=X(j);if(!F){L(w,"MISSING_ARGUMENT","error",U("with"),j,{helperName:"with"});let G=w.current;w.current={};let J=K(j.program,w);if(w.current=G,j.inverse)K(j.inverse,w);return J}let z=R(F,w,j),H=w.current;w.current=z??{};let I=K(j.program,w);if(w.current=H,j.inverse)K(j.inverse,w);return I}default:{let F=w.helpers?.get(A);if(F){for(let z of j.params)R(z,w,j);if(K(j.program,w),j.inverse)K(j.inverse,w);return F.returnType??{type:"string"}}if(L(w,"UNKNOWN_HELPER","warning",b(A),j,{helperName:A}),K(j.program,w),j.inverse)K(j.inverse,w);return{type:"string"}}}}function R(j,w,A){if(D(j))return w.current;if(j.type==="SubExpression")return m(j,w,A);let F=C(j);if(F.length===0){if(j.type==="StringLiteral")return{type:"string"};if(j.type==="NumberLiteral")return{type:"number"};if(j.type==="BooleanLiteral")return{type:"boolean"};if(j.type==="NullLiteral")return{type:"null"};if(j.type==="UndefinedLiteral")return{};L(w,"UNANALYZABLE","warning",k(j.type),A??j);return}let{cleanSegments:z,identifier:H}=y(F);if(H!==null)return r(z,H,w,A??j);let I=$(w.current,z);if(I===void 0){let G=z.join("."),J=_(w.current);L(w,"UNKNOWN_PROPERTY","error",B(G,J),A??j,{path:G,availableProperties:J});return}return I}function r(j,w,A,F){let z=j.join(".");if(!A.identifierSchemas){L(A,"MISSING_IDENTIFIER_SCHEMAS","error",`Property "${z}:${w}" uses an identifier but no identifier schemas were provided`,F,{path:`${z}:${w}`,identifier:w});return}let H=A.identifierSchemas[w];if(!H){L(A,"UNKNOWN_IDENTIFIER","error",`Property "${z}:${w}" references identifier ${w} but no schema exists for this identifier`,F,{path:`${z}:${w}`,identifier:w});return}let I=$(H,j);if(I===void 0){let G=_(H);L(A,"IDENTIFIER_PROPERTY_NOT_FOUND","error",`Property "${z}" does not exist in the schema for identifier ${w}`,F,{path:z,identifier:w,availableProperties:G});return}return I}function m(j,w,A){let F=n(j.path),z=w.helpers?.get(F);if(!z)return L(w,"UNKNOWN_HELPER","warning",`Unknown sub-expression helper "${F}" — cannot analyze statically`,A??j,{helperName:F}),{type:"string"};let H=z.params;if(H){let I=H.filter((G)=>!G.optional).length;if(j.params.length<I)L(w,"MISSING_ARGUMENT","error",`Helper "${F}" expects at least ${I} argument(s), but got ${j.params.length}`,A??j,{helperName:F,expected:`${I} argument(s)`,actual:`${j.params.length} argument(s)`})}for(let I=0;I<j.params.length;I++){let G=R(j.params[I],w,A??j),J=H?.[I];if(G&&J?.type){let O=J.type;if(!o(G,O)){let l=J.name;L(w,"TYPE_MISMATCH","error",`Helper "${F}" parameter "${l}" expects ${Q(O)}, but got ${Q(G)}`,A??j,{helperName:F,expected:Q(O),actual:Q(G)})}}}return z.returnType??{type:"string"}}function X(j){return j.params[0]}function c(j){if(j.path.type==="PathExpression")return j.path.original;return""}function n(j){if(j.type==="PathExpression")return j.original;return""}function L(j,w,A,F,z,H){let I={severity:A,code:w,message:F};if(z&&"loc"in z&&z.loc)I.loc={start:{line:z.loc.start.line,column:z.loc.start.column},end:{line:z.loc.end.line,column:z.loc.end.column}},I.source=N(j.template,I.loc);if(H)I.details=H;j.diagnostics.push(I)}function Q(j){if(j.type)return Array.isArray(j.type)?j.type.join(" | "):j.type;if(j.oneOf)return"oneOf(...)";if(j.anyOf)return"anyOf(...)";if(j.allOf)return"allOf(...)";if(j.enum)return"enum";return"unknown"}export{i as b,a as c,Z as d};
2
+
3
+ //# debugId=57C3498B4F6E645064756E2164756E21
4
+ //# sourceMappingURL=chunk-dpffacsy.js.map
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "import type { JSONSchema7 } from \"json-schema\";\nimport {\n\tcreateMissingArgumentMessage,\n\tcreatePropertyNotFoundMessage,\n\tcreateTypeMismatchMessage,\n\tcreateUnanalyzableMessage,\n\tcreateUnknownHelperMessage,\n} from \"./errors.ts\";\nimport {\n\tdetectLiteralType,\n\textractExpressionIdentifier,\n\textractPathSegments,\n\tgetEffectiveBody,\n\tgetEffectivelySingleBlock,\n\tgetEffectivelySingleExpression,\n\tisThisExpression,\n\tparse,\n} from \"./parser.ts\";\nimport {\n\tassertNoConditionalSchema,\n\tresolveArrayItems,\n\tresolveSchemaPath,\n\tsimplifySchema,\n} from \"./schema-resolver.ts\";\nimport type {\n\tAnalysisResult,\n\tDiagnosticCode,\n\tDiagnosticDetails,\n\tHelperDefinition,\n\tTemplateDiagnostic,\n\tTemplateInput,\n\tTemplateInputObject,\n} from \"./types.ts\";\nimport {\n\tinferPrimitiveSchema,\n\tisLiteralInput,\n\tisObjectInput,\n} from \"./types.ts\";\nimport {\n\taggregateObjectAnalysis,\n\tdeepEqual,\n\textractSourceSnippet,\n\tgetSchemaPropertyNames,\n} from \"./utils.ts\";\n\n// ─── Static Analyzer ─────────────────────────────────────────────────────────\n// Static analysis of a Handlebars template against a JSON Schema v7\n// describing the available context.\n//\n// Merged architecture (v2):\n// A single AST traversal performs both **validation** and **return type\n// inference** simultaneously. This eliminates duplication between the former\n// `validate*` and `infer*` functions and improves performance by avoiding\n// a double traversal.\n//\n// Context:\n// The analysis context uses a **save/restore** pattern instead of creating\n// new objects on each recursion (`{ ...ctx, current: X }`). This reduces\n// GC pressure for deeply nested templates.\n//\n// ─── Template Identifiers ────────────────────────────────────────────────────\n// The `{{key:N}}` syntax allows referencing a variable from a specific\n// schema, identified by an integer N. The optional `identifierSchemas`\n// parameter provides a mapping `{ [id]: JSONSchema7 }`.\n//\n// Resolution rules:\n// - `{{meetingId}}` → validated against `inputSchema` (standard behavior)\n// - `{{meetingId:1}}` → validated against `identifierSchemas[1]`\n// - `{{meetingId:1}}` without `identifierSchemas[1]` → error\n\n// ─── Internal Types ──────────────────────────────────────────────────────────\n\n/** Context passed recursively during AST traversal */\ninterface AnalysisContext {\n\t/** Root schema (for resolving $refs) */\n\troot: JSONSchema7;\n\t/** Current context schema (changes with #each, #with) — mutated via save/restore */\n\tcurrent: JSONSchema7;\n\t/** Diagnostics accumulator */\n\tdiagnostics: TemplateDiagnostic[];\n\t/** Full template source (for extracting error snippets) */\n\ttemplate: string;\n\t/** Schemas by template identifier (for the {{key:N}} syntax) */\n\tidentifierSchemas?: Record<number, JSONSchema7>;\n\t/** Registered custom helpers (for static analysis) */\n\thelpers?: Map<string, HelperDefinition>;\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Statically analyzes a template against a JSON Schema v7 describing the\n * available context.\n *\n * Backward-compatible version — parses the template internally.\n *\n * @param template - The template string (e.g. `\"Hello {{user.name}}\"`)\n * @param inputSchema - JSON Schema v7 describing the available variables\n * @param identifierSchemas - (optional) Schemas by identifier `{ [id]: JSONSchema7 }`\n * @returns An `AnalysisResult` containing validity, diagnostics, and the\n * inferred output schema.\n */\nexport function analyze(\n\ttemplate: TemplateInput,\n\tinputSchema: JSONSchema7,\n\tidentifierSchemas?: Record<number, JSONSchema7>,\n): AnalysisResult {\n\tif (isObjectInput(template)) {\n\t\treturn analyzeObjectTemplate(template, inputSchema, identifierSchemas);\n\t}\n\tif (isLiteralInput(template)) {\n\t\treturn {\n\t\t\tvalid: true,\n\t\t\tdiagnostics: [],\n\t\t\toutputSchema: inferPrimitiveSchema(template),\n\t\t};\n\t}\n\tconst ast = parse(template);\n\treturn analyzeFromAst(ast, template, inputSchema, { identifierSchemas });\n}\n\n/**\n * Analyzes an object template recursively (standalone version).\n * Each property is analyzed individually, diagnostics are merged,\n * and the `outputSchema` reflects the object structure.\n */\nfunction analyzeObjectTemplate(\n\ttemplate: TemplateInputObject,\n\tinputSchema: JSONSchema7,\n\tidentifierSchemas?: Record<number, JSONSchema7>,\n): AnalysisResult {\n\treturn aggregateObjectAnalysis(Object.keys(template), (key) =>\n\t\tanalyze(template[key] as TemplateInput, inputSchema, identifierSchemas),\n\t);\n}\n\n/**\n * Statically analyzes a template from an already-parsed AST.\n *\n * This is the internal function used by `Typebars.compile()` and\n * `CompiledTemplate.analyze()` to avoid costly re-parsing.\n *\n * @param ast - The already-parsed Handlebars AST\n * @param template - The template source (for error snippets)\n * @param inputSchema - JSON Schema v7 describing the available variables\n * @param options - Additional options\n * @returns An `AnalysisResult`\n */\nexport function analyzeFromAst(\n\tast: hbs.AST.Program,\n\ttemplate: string,\n\tinputSchema: JSONSchema7,\n\toptions?: {\n\t\tidentifierSchemas?: Record<number, JSONSchema7>;\n\t\thelpers?: Map<string, HelperDefinition>;\n\t},\n): AnalysisResult {\n\t// ── Reject unsupported schema features before analysis ────────────\n\t// Conditional schemas (if/then/else) are non-resolvable without runtime\n\t// data. Fail fast with a clear error rather than producing silently\n\t// incorrect results.\n\tassertNoConditionalSchema(inputSchema);\n\n\tif (options?.identifierSchemas) {\n\t\tfor (const [id, idSchema] of Object.entries(options.identifierSchemas)) {\n\t\t\tassertNoConditionalSchema(idSchema, `/identifierSchemas/${id}`);\n\t\t}\n\t}\n\n\tconst ctx: AnalysisContext = {\n\t\troot: inputSchema,\n\t\tcurrent: inputSchema,\n\t\tdiagnostics: [],\n\t\ttemplate,\n\t\tidentifierSchemas: options?.identifierSchemas,\n\t\thelpers: options?.helpers,\n\t};\n\n\t// Single pass: type inference + validation in one traversal.\n\tconst outputSchema = inferProgramType(ast, ctx);\n\n\tconst hasErrors = ctx.diagnostics.some((d) => d.severity === \"error\");\n\n\treturn {\n\t\tvalid: !hasErrors,\n\t\tdiagnostics: ctx.diagnostics,\n\t\toutputSchema: simplifySchema(outputSchema),\n\t};\n}\n\n// ─── Unified AST Traversal ───────────────────────────────────────────────────\n// A single set of functions handles both validation (emitting diagnostics)\n// and type inference (returning a JSONSchema7).\n//\n// Main functions:\n// - `inferProgramType` — entry point for a Program (template body or block)\n// - `processStatement` — dispatches a statement (validation side-effects)\n// - `processMustache` — handles a MustacheStatement (expression or inline helper)\n// - `inferBlockType` — handles a BlockStatement (if, each, with, custom…)\n\n/**\n * Dispatches the processing of an individual statement.\n *\n * Called by `inferProgramType` in the \"mixed template\" case to validate\n * each statement while ignoring the returned type (the result is always\n * `string` for a mixed template).\n *\n * @returns The inferred schema for this statement, or `undefined` for\n * statements with no semantics (ContentStatement, CommentStatement).\n */\nfunction processStatement(\n\tstmt: hbs.AST.Statement,\n\tctx: AnalysisContext,\n): JSONSchema7 | undefined {\n\tswitch (stmt.type) {\n\t\tcase \"ContentStatement\":\n\t\tcase \"CommentStatement\":\n\t\t\t// Static text or comment — nothing to validate, no type to infer\n\t\t\treturn undefined;\n\n\t\tcase \"MustacheStatement\":\n\t\t\treturn processMustache(stmt as hbs.AST.MustacheStatement, ctx);\n\n\t\tcase \"BlockStatement\":\n\t\t\treturn inferBlockType(stmt as hbs.AST.BlockStatement, ctx);\n\n\t\tdefault:\n\t\t\t// Unrecognized AST node — emit a warning rather than an error\n\t\t\t// to avoid blocking on future Handlebars extensions.\n\t\t\taddDiagnostic(\n\t\t\t\tctx,\n\t\t\t\t\"UNANALYZABLE\",\n\t\t\t\t\"warning\",\n\t\t\t\t`Unsupported AST node type: \"${stmt.type}\"`,\n\t\t\t\tstmt,\n\t\t\t);\n\t\t\treturn undefined;\n\t}\n}\n\n/**\n * Processes a MustacheStatement `{{expression}}` or `{{helper arg}}`.\n *\n * Distinguishes two cases:\n * 1. **Simple expression** (`{{name}}`, `{{user.age}}`) — resolution in the schema\n * 2. **Inline helper** (`{{uppercase name}}`) — params > 0 or hash present\n *\n * @returns The inferred schema for this expression\n */\nfunction processMustache(\n\tstmt: hbs.AST.MustacheStatement,\n\tctx: AnalysisContext,\n): JSONSchema7 {\n\t// Sub-expressions (nested helpers) are not supported for static\n\t// analysis — emit a warning.\n\tif (stmt.path.type === \"SubExpression\") {\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"UNANALYZABLE\",\n\t\t\t\"warning\",\n\t\t\t\"Sub-expressions are not statically analyzable\",\n\t\t\tstmt,\n\t\t);\n\t\treturn {};\n\t}\n\n\t// ── Inline helper detection ──────────────────────────────────────────────\n\t// If the MustacheStatement has parameters or a hash, it's a helper call\n\t// (e.g. `{{uppercase name}}`), not a simple expression.\n\tif (stmt.params.length > 0 || stmt.hash) {\n\t\tconst helperName = getExpressionName(stmt.path);\n\n\t\t// Check if the helper is registered\n\t\tconst helper = ctx.helpers?.get(helperName);\n\t\tif (helper) {\n\t\t\tconst helperParams = helper.params;\n\n\t\t\t// ── Check the number of required parameters ──────────────\n\t\t\tif (helperParams) {\n\t\t\t\tconst requiredCount = helperParams.filter((p) => !p.optional).length;\n\t\t\t\tif (stmt.params.length < requiredCount) {\n\t\t\t\t\taddDiagnostic(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\"MISSING_ARGUMENT\",\n\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t`Helper \"${helperName}\" expects at least ${requiredCount} argument(s), but got ${stmt.params.length}`,\n\t\t\t\t\t\tstmt,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thelperName,\n\t\t\t\t\t\t\texpected: `${requiredCount} argument(s)`,\n\t\t\t\t\t\t\tactual: `${stmt.params.length} argument(s)`,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ── Validate each parameter (existence + type) ───────────────\n\t\t\tfor (let i = 0; i < stmt.params.length; i++) {\n\t\t\t\tconst resolvedSchema = resolveExpressionWithDiagnostics(\n\t\t\t\t\tstmt.params[i] as hbs.AST.Expression,\n\t\t\t\t\tctx,\n\t\t\t\t\tstmt,\n\t\t\t\t);\n\n\t\t\t\t// Check type compatibility if the helper declares the\n\t\t\t\t// expected type for this parameter\n\t\t\t\tconst helperParam = helperParams?.[i];\n\t\t\t\tif (resolvedSchema && helperParam?.type) {\n\t\t\t\t\tconst expectedType = helperParam.type;\n\t\t\t\t\tif (!isParamTypeCompatible(resolvedSchema, expectedType)) {\n\t\t\t\t\t\tconst paramName = helperParam.name;\n\t\t\t\t\t\taddDiagnostic(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\"TYPE_MISMATCH\",\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t`Helper \"${helperName}\" parameter \"${paramName}\" expects ${schemaTypeLabel(expectedType)}, but got ${schemaTypeLabel(resolvedSchema)}`,\n\t\t\t\t\t\t\tstmt,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\thelperName,\n\t\t\t\t\t\t\t\texpected: schemaTypeLabel(expectedType),\n\t\t\t\t\t\t\t\tactual: schemaTypeLabel(resolvedSchema),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn helper.returnType ?? { type: \"string\" };\n\t\t}\n\n\t\t// Unknown inline helper — warning\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"UNKNOWN_HELPER\",\n\t\t\t\"warning\",\n\t\t\t`Unknown inline helper \"${helperName}\" — cannot analyze statically`,\n\t\t\tstmt,\n\t\t\t{ helperName },\n\t\t);\n\t\treturn { type: \"string\" };\n\t}\n\n\t// ── Simple expression ────────────────────────────────────────────────────\n\treturn resolveExpressionWithDiagnostics(stmt.path, ctx, stmt) ?? {};\n}\n\n/**\n * Checks whether a resolved type is compatible with the type expected\n * by a helper parameter.\n *\n * Compatibility rules:\n * - If either schema has no `type`, validation is not possible → compatible\n * - `integer` is compatible with `number` (integer ⊂ number)\n * - For multiple types (e.g. `[\"string\", \"number\"]`), at least one resolved\n * type must match one expected type\n */\nfunction isParamTypeCompatible(\n\tresolved: JSONSchema7,\n\texpected: JSONSchema7,\n): boolean {\n\t// If either has no type info, we cannot validate\n\tif (!expected.type || !resolved.type) return true;\n\n\tconst expectedTypes = Array.isArray(expected.type)\n\t\t? expected.type\n\t\t: [expected.type];\n\tconst resolvedTypes = Array.isArray(resolved.type)\n\t\t? resolved.type\n\t\t: [resolved.type];\n\n\t// At least one resolved type must be compatible with one expected type\n\treturn resolvedTypes.some((rt) =>\n\t\texpectedTypes.some(\n\t\t\t(et) =>\n\t\t\t\trt === et ||\n\t\t\t\t// integer is a subtype of number\n\t\t\t\t(et === \"number\" && rt === \"integer\") ||\n\t\t\t\t(et === \"integer\" && rt === \"number\"),\n\t\t),\n\t);\n}\n\n/**\n * Infers the output type of a `Program` (template body or block body).\n *\n * Handles 4 cases, from most specific to most general:\n *\n * 1. **Single expression** `{{expr}}` → type of the expression\n * 2. **Single block** `{{#if}}…{{/if}}` → type of the block\n * 3. **Pure text content** → literal detection (number, boolean, null)\n * 4. **Mixed template** → always `string` (concatenation)\n *\n * Validation is performed alongside inference: each expression and block\n * is validated during processing.\n */\nfunction inferProgramType(\n\tprogram: hbs.AST.Program,\n\tctx: AnalysisContext,\n): JSONSchema7 {\n\tconst effective = getEffectiveBody(program);\n\n\t// No significant statements → empty string\n\tif (effective.length === 0) {\n\t\treturn { type: \"string\" };\n\t}\n\n\t// ── Case 1: single expression {{expr}} ─────────────────────────────────\n\tconst singleExpr = getEffectivelySingleExpression(program);\n\tif (singleExpr) {\n\t\treturn processMustache(singleExpr, ctx);\n\t}\n\n\t// ── Case 2: single block {{#if}}, {{#each}}, {{#with}}, … ──────────────\n\tconst singleBlock = getEffectivelySingleBlock(program);\n\tif (singleBlock) {\n\t\treturn inferBlockType(singleBlock, ctx);\n\t}\n\n\t// ── Case 3: only ContentStatements (no expressions) ────────────────────\n\t// If the concatenated (trimmed) text is a typed literal (number, boolean,\n\t// null), we infer the corresponding type.\n\tconst allContent = effective.every((s) => s.type === \"ContentStatement\");\n\tif (allContent) {\n\t\tconst text = effective\n\t\t\t.map((s) => (s as hbs.AST.ContentStatement).value)\n\t\t\t.join(\"\")\n\t\t\t.trim();\n\n\t\tif (text === \"\") return { type: \"string\" };\n\n\t\tconst literalType = detectLiteralType(text);\n\t\tif (literalType) return { type: literalType };\n\t}\n\n\t// ── Case 4: multiple blocks only (no significant text between them) ────\n\t// When the effective body consists entirely of BlockStatements, collect\n\t// each block's inferred type and combine them via oneOf. This handles\n\t// templates like:\n\t// {{#if showName}}{{name}}{{/if}}\n\t// {{#if showAge}}{{age}}{{/if}}\n\t// where the output could be string OR number depending on which branch\n\t// is active.\n\tconst allBlocks = effective.every((s) => s.type === \"BlockStatement\");\n\tif (allBlocks) {\n\t\tconst types: JSONSchema7[] = [];\n\t\tfor (const stmt of effective) {\n\t\t\tconst t = inferBlockType(stmt as hbs.AST.BlockStatement, ctx);\n\t\t\tif (t) types.push(t);\n\t\t}\n\t\tif (types.length === 1) return types[0] as JSONSchema7;\n\t\tif (types.length > 1) return simplifySchema({ oneOf: types });\n\t\treturn { type: \"string\" };\n\t}\n\n\t// ── Case 5: mixed template (text + expressions, blocks…) ───────────────\n\t// Traverse all statements for validation (side-effects: diagnostics).\n\t// The result is always string (concatenation).\n\tfor (const stmt of program.body) {\n\t\tprocessStatement(stmt, ctx);\n\t}\n\treturn { type: \"string\" };\n}\n\n/**\n * Infers the output type of a BlockStatement and validates its content.\n *\n * Supports built-in helpers (`if`, `unless`, `each`, `with`) and custom\n * helpers registered via `Typebars.registerHelper()`.\n *\n * Uses the **save/restore** pattern for context: instead of creating a new\n * object `{ ...ctx, current: X }` on each recursion, we save `ctx.current`,\n * mutate it, process the body, then restore. This reduces GC pressure for\n * deeply nested templates.\n */\nfunction inferBlockType(\n\tstmt: hbs.AST.BlockStatement,\n\tctx: AnalysisContext,\n): JSONSchema7 {\n\tconst helperName = getBlockHelperName(stmt);\n\n\tswitch (helperName) {\n\t\t// ── if / unless ──────────────────────────────────────────────────────\n\t\t// Validate the condition argument, then infer types from both branches.\n\t\tcase \"if\":\n\t\tcase \"unless\": {\n\t\t\tconst arg = getBlockArgument(stmt);\n\t\t\tif (arg) {\n\t\t\t\tresolveExpressionWithDiagnostics(arg, ctx, stmt);\n\t\t\t} else {\n\t\t\t\taddDiagnostic(\n\t\t\t\t\tctx,\n\t\t\t\t\t\"MISSING_ARGUMENT\",\n\t\t\t\t\t\"error\",\n\t\t\t\t\tcreateMissingArgumentMessage(helperName),\n\t\t\t\t\tstmt,\n\t\t\t\t\t{ helperName },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Infer the type of the \"then\" branch\n\t\t\tconst thenType = inferProgramType(stmt.program, ctx);\n\n\t\t\tif (stmt.inverse) {\n\t\t\t\tconst elseType = inferProgramType(stmt.inverse, ctx);\n\t\t\t\t// If both branches have the same type → single type\n\t\t\t\tif (deepEqual(thenType, elseType)) return thenType;\n\t\t\t\t// Otherwise → union of both types\n\t\t\t\treturn simplifySchema({ oneOf: [thenType, elseType] });\n\t\t\t}\n\n\t\t\t// No else branch → the result is the type of the then branch\n\t\t\t// (conceptually optional, but Handlebars returns \"\" for falsy)\n\t\t\treturn thenType;\n\t\t}\n\n\t\t// ── each ─────────────────────────────────────────────────────────────\n\t\t// Resolve the collection schema, then validate the body with the item\n\t\t// schema as the new context.\n\t\tcase \"each\": {\n\t\t\tconst arg = getBlockArgument(stmt);\n\t\t\tif (!arg) {\n\t\t\t\taddDiagnostic(\n\t\t\t\t\tctx,\n\t\t\t\t\t\"MISSING_ARGUMENT\",\n\t\t\t\t\t\"error\",\n\t\t\t\t\tcreateMissingArgumentMessage(\"each\"),\n\t\t\t\t\tstmt,\n\t\t\t\t\t{ helperName: \"each\" },\n\t\t\t\t);\n\t\t\t\t// Validate the body with an empty context (best-effort)\n\t\t\t\tconst saved = ctx.current;\n\t\t\t\tctx.current = {};\n\t\t\t\tinferProgramType(stmt.program, ctx);\n\t\t\t\tctx.current = saved;\n\t\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\t\t\t\treturn { type: \"string\" };\n\t\t\t}\n\n\t\t\tconst collectionSchema = resolveExpressionWithDiagnostics(arg, ctx, stmt);\n\t\t\tif (!collectionSchema) {\n\t\t\t\t// The path could not be resolved — diagnostic already emitted.\n\t\t\t\tconst saved = ctx.current;\n\t\t\t\tctx.current = {};\n\t\t\t\tinferProgramType(stmt.program, ctx);\n\t\t\t\tctx.current = saved;\n\t\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\t\t\t\treturn { type: \"string\" };\n\t\t\t}\n\n\t\t\t// Resolve the schema of the array elements\n\t\t\tconst itemSchema = resolveArrayItems(collectionSchema, ctx.root);\n\t\t\tif (!itemSchema) {\n\t\t\t\taddDiagnostic(\n\t\t\t\t\tctx,\n\t\t\t\t\t\"TYPE_MISMATCH\",\n\t\t\t\t\t\"error\",\n\t\t\t\t\tcreateTypeMismatchMessage(\n\t\t\t\t\t\t\"each\",\n\t\t\t\t\t\t\"an array\",\n\t\t\t\t\t\tschemaTypeLabel(collectionSchema),\n\t\t\t\t\t),\n\t\t\t\t\tstmt,\n\t\t\t\t\t{\n\t\t\t\t\t\thelperName: \"each\",\n\t\t\t\t\t\texpected: \"array\",\n\t\t\t\t\t\tactual: schemaTypeLabel(collectionSchema),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\t// Validate the body with an empty context (best-effort)\n\t\t\t\tconst saved = ctx.current;\n\t\t\t\tctx.current = {};\n\t\t\t\tinferProgramType(stmt.program, ctx);\n\t\t\t\tctx.current = saved;\n\t\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\t\t\t\treturn { type: \"string\" };\n\t\t\t}\n\n\t\t\t// Validate the body with the item schema as the new context\n\t\t\tconst saved = ctx.current;\n\t\t\tctx.current = itemSchema;\n\t\t\tinferProgramType(stmt.program, ctx);\n\t\t\tctx.current = saved;\n\n\t\t\t// The inverse branch ({{else}}) keeps the parent context\n\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\n\t\t\t// An each concatenates renders → always string\n\t\t\treturn { type: \"string\" };\n\t\t}\n\n\t\t// ── with ─────────────────────────────────────────────────────────────\n\t\t// Resolve the inner schema, then validate the body with it as the\n\t\t// new context.\n\t\tcase \"with\": {\n\t\t\tconst arg = getBlockArgument(stmt);\n\t\t\tif (!arg) {\n\t\t\t\taddDiagnostic(\n\t\t\t\t\tctx,\n\t\t\t\t\t\"MISSING_ARGUMENT\",\n\t\t\t\t\t\"error\",\n\t\t\t\t\tcreateMissingArgumentMessage(\"with\"),\n\t\t\t\t\tstmt,\n\t\t\t\t\t{ helperName: \"with\" },\n\t\t\t\t);\n\t\t\t\t// Validate the body with an empty context\n\t\t\t\tconst saved = ctx.current;\n\t\t\t\tctx.current = {};\n\t\t\t\tconst result = inferProgramType(stmt.program, ctx);\n\t\t\t\tctx.current = saved;\n\t\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tconst innerSchema = resolveExpressionWithDiagnostics(arg, ctx, stmt);\n\n\t\t\tconst saved = ctx.current;\n\t\t\tctx.current = innerSchema ?? {};\n\t\t\tconst result = inferProgramType(stmt.program, ctx);\n\t\t\tctx.current = saved;\n\n\t\t\t// The inverse branch keeps the parent context\n\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\n\t\t\treturn result;\n\t\t}\n\n\t\t// ── Custom or unknown helper ─────────────────────────────────────────\n\t\tdefault: {\n\t\t\tconst helper = ctx.helpers?.get(helperName);\n\t\t\tif (helper) {\n\t\t\t\t// Registered custom helper — validate parameters\n\t\t\t\tfor (const param of stmt.params) {\n\t\t\t\t\tresolveExpressionWithDiagnostics(\n\t\t\t\t\t\tparam as hbs.AST.Expression,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tstmt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Validate the body with the current context\n\t\t\t\tinferProgramType(stmt.program, ctx);\n\t\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\t\t\t\treturn helper.returnType ?? { type: \"string\" };\n\t\t\t}\n\n\t\t\t// Unknown helper — warning\n\t\t\taddDiagnostic(\n\t\t\t\tctx,\n\t\t\t\t\"UNKNOWN_HELPER\",\n\t\t\t\t\"warning\",\n\t\t\t\tcreateUnknownHelperMessage(helperName),\n\t\t\t\tstmt,\n\t\t\t\t{ helperName },\n\t\t\t);\n\t\t\t// Still validate the body with the current context (best-effort)\n\t\t\tinferProgramType(stmt.program, ctx);\n\t\t\tif (stmt.inverse) inferProgramType(stmt.inverse, ctx);\n\t\t\treturn { type: \"string\" };\n\t\t}\n\t}\n}\n\n// ─── Expression Resolution ───────────────────────────────────────────────────\n\n/**\n * Resolves an AST expression to a sub-schema, emitting a diagnostic\n * if the path cannot be resolved.\n *\n * Handles the `{{key:N}}` syntax:\n * - If the expression has an identifier N → resolution in `identifierSchemas[N]`\n * - If identifier N has no associated schema → error\n * - If no identifier → resolution in `ctx.current` (standard behavior)\n *\n * @returns The resolved sub-schema, or `undefined` if the path is invalid.\n */\nfunction resolveExpressionWithDiagnostics(\n\texpr: hbs.AST.Expression,\n\tctx: AnalysisContext,\n\t/** Parent AST node (for diagnostic location) */\n\tparentNode?: hbs.AST.Node,\n): JSONSchema7 | undefined {\n\t// Handle `this` / `.` → return the current context\n\tif (isThisExpression(expr)) {\n\t\treturn ctx.current;\n\t}\n\n\t// ── SubExpression (nested helper call, e.g. `(lt account.balance 500)`) ──\n\tif (expr.type === \"SubExpression\") {\n\t\treturn resolveSubExpression(expr as hbs.AST.SubExpression, ctx, parentNode);\n\t}\n\n\tconst segments = extractPathSegments(expr);\n\tif (segments.length === 0) {\n\t\t// Expression that is not a PathExpression (e.g. literal)\n\t\tif (expr.type === \"StringLiteral\") return { type: \"string\" };\n\t\tif (expr.type === \"NumberLiteral\") return { type: \"number\" };\n\t\tif (expr.type === \"BooleanLiteral\") return { type: \"boolean\" };\n\t\tif (expr.type === \"NullLiteral\") return { type: \"null\" };\n\t\tif (expr.type === \"UndefinedLiteral\") return {};\n\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"UNANALYZABLE\",\n\t\t\t\"warning\",\n\t\t\tcreateUnanalyzableMessage(expr.type),\n\t\t\tparentNode ?? expr,\n\t\t);\n\t\treturn undefined;\n\t}\n\n\t// ── Identifier extraction ──────────────────────────────────────────────\n\tconst { cleanSegments, identifier } = extractExpressionIdentifier(segments);\n\n\tif (identifier !== null) {\n\t\t// The expression uses the {{key:N}} syntax — resolve from\n\t\t// the schema of identifier N.\n\t\treturn resolveWithIdentifier(\n\t\t\tcleanSegments,\n\t\t\tidentifier,\n\t\t\tctx,\n\t\t\tparentNode ?? expr,\n\t\t);\n\t}\n\n\t// ── Standard resolution (no identifier) ────────────────────────────────\n\tconst resolved = resolveSchemaPath(ctx.current, cleanSegments);\n\tif (resolved === undefined) {\n\t\tconst fullPath = cleanSegments.join(\".\");\n\t\tconst availableProperties = getSchemaPropertyNames(ctx.current);\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"UNKNOWN_PROPERTY\",\n\t\t\t\"error\",\n\t\t\tcreatePropertyNotFoundMessage(fullPath, availableProperties),\n\t\t\tparentNode ?? expr,\n\t\t\t{ path: fullPath, availableProperties },\n\t\t);\n\t\treturn undefined;\n\t}\n\n\treturn resolved;\n}\n\n/**\n * Resolves an expression with identifier `{{key:N}}` by looking up the\n * schema associated with identifier N.\n *\n * Emits an error diagnostic if:\n * - No `identifierSchemas` were provided\n * - Identifier N has no associated schema\n * - The property does not exist in the identifier's schema\n */\nfunction resolveWithIdentifier(\n\tcleanSegments: string[],\n\tidentifier: number,\n\tctx: AnalysisContext,\n\tnode: hbs.AST.Node,\n): JSONSchema7 | undefined {\n\tconst fullPath = cleanSegments.join(\".\");\n\n\t// No identifierSchemas provided at all\n\tif (!ctx.identifierSchemas) {\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"MISSING_IDENTIFIER_SCHEMAS\",\n\t\t\t\"error\",\n\t\t\t`Property \"${fullPath}:${identifier}\" uses an identifier but no identifier schemas were provided`,\n\t\t\tnode,\n\t\t\t{ path: `${fullPath}:${identifier}`, identifier },\n\t\t);\n\t\treturn undefined;\n\t}\n\n\t// The identifier does not exist in the provided schemas\n\tconst idSchema = ctx.identifierSchemas[identifier];\n\tif (!idSchema) {\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"UNKNOWN_IDENTIFIER\",\n\t\t\t\"error\",\n\t\t\t`Property \"${fullPath}:${identifier}\" references identifier ${identifier} but no schema exists for this identifier`,\n\t\t\tnode,\n\t\t\t{ path: `${fullPath}:${identifier}`, identifier },\n\t\t);\n\t\treturn undefined;\n\t}\n\n\t// Resolve the path within the identifier's schema\n\tconst resolved = resolveSchemaPath(idSchema, cleanSegments);\n\tif (resolved === undefined) {\n\t\tconst availableProperties = getSchemaPropertyNames(idSchema);\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"IDENTIFIER_PROPERTY_NOT_FOUND\",\n\t\t\t\"error\",\n\t\t\t`Property \"${fullPath}\" does not exist in the schema for identifier ${identifier}`,\n\t\t\tnode,\n\t\t\t{\n\t\t\t\tpath: fullPath,\n\t\t\t\tidentifier,\n\t\t\t\tavailableProperties,\n\t\t\t},\n\t\t);\n\t\treturn undefined;\n\t}\n\n\treturn resolved;\n}\n\n// ─── Utilities ───────────────────────────────────────────────────────────────\n\n/**\n * Extracts the first argument of a BlockStatement.\n *\n * In the Handlebars AST, for `{{#if active}}`:\n * - `stmt.path` → PathExpression(\"if\") ← the helper name\n * - `stmt.params[0]` → PathExpression(\"active\") ← the actual argument\n *\n * @returns The argument expression, or `undefined` if the block has no argument.\n */\n// ─── SubExpression Resolution ────────────────────────────────────────────────\n\n/**\n * Resolves a SubExpression (nested helper call) such as `(lt account.balance 500)`.\n *\n * This mirrors the helper-call logic in `processMustache` but applies to\n * expressions used as arguments (e.g. inside `{{#if (lt a b)}}`).\n *\n * Steps:\n * 1. Extract the helper name from the SubExpression's path.\n * 2. Look up the helper in `ctx.helpers`.\n * 3. Validate argument count and types.\n * 4. Return the helper's declared `returnType` (defaults to `{ type: \"string\" }`).\n */\nfunction resolveSubExpression(\n\texpr: hbs.AST.SubExpression,\n\tctx: AnalysisContext,\n\tparentNode?: hbs.AST.Node,\n): JSONSchema7 | undefined {\n\tconst helperName = getExpressionName(expr.path);\n\n\tconst helper = ctx.helpers?.get(helperName);\n\tif (!helper) {\n\t\taddDiagnostic(\n\t\t\tctx,\n\t\t\t\"UNKNOWN_HELPER\",\n\t\t\t\"warning\",\n\t\t\t`Unknown sub-expression helper \"${helperName}\" — cannot analyze statically`,\n\t\t\tparentNode ?? expr,\n\t\t\t{ helperName },\n\t\t);\n\t\treturn { type: \"string\" };\n\t}\n\n\tconst helperParams = helper.params;\n\n\t// ── Check the number of required parameters ──────────────────────\n\tif (helperParams) {\n\t\tconst requiredCount = helperParams.filter((p) => !p.optional).length;\n\t\tif (expr.params.length < requiredCount) {\n\t\t\taddDiagnostic(\n\t\t\t\tctx,\n\t\t\t\t\"MISSING_ARGUMENT\",\n\t\t\t\t\"error\",\n\t\t\t\t`Helper \"${helperName}\" expects at least ${requiredCount} argument(s), but got ${expr.params.length}`,\n\t\t\t\tparentNode ?? expr,\n\t\t\t\t{\n\t\t\t\t\thelperName,\n\t\t\t\t\texpected: `${requiredCount} argument(s)`,\n\t\t\t\t\tactual: `${expr.params.length} argument(s)`,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t// ── Validate each parameter (existence + type) ───────────────────\n\tfor (let i = 0; i < expr.params.length; i++) {\n\t\tconst resolvedSchema = resolveExpressionWithDiagnostics(\n\t\t\texpr.params[i] as hbs.AST.Expression,\n\t\t\tctx,\n\t\t\tparentNode ?? expr,\n\t\t);\n\n\t\tconst helperParam = helperParams?.[i];\n\t\tif (resolvedSchema && helperParam?.type) {\n\t\t\tconst expectedType = helperParam.type;\n\t\t\tif (!isParamTypeCompatible(resolvedSchema, expectedType)) {\n\t\t\t\tconst paramName = helperParam.name;\n\t\t\t\taddDiagnostic(\n\t\t\t\t\tctx,\n\t\t\t\t\t\"TYPE_MISMATCH\",\n\t\t\t\t\t\"error\",\n\t\t\t\t\t`Helper \"${helperName}\" parameter \"${paramName}\" expects ${schemaTypeLabel(expectedType)}, but got ${schemaTypeLabel(resolvedSchema)}`,\n\t\t\t\t\tparentNode ?? expr,\n\t\t\t\t\t{\n\t\t\t\t\t\thelperName,\n\t\t\t\t\t\texpected: schemaTypeLabel(expectedType),\n\t\t\t\t\t\tactual: schemaTypeLabel(resolvedSchema),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn helper.returnType ?? { type: \"string\" };\n}\n\nfunction getBlockArgument(\n\tstmt: hbs.AST.BlockStatement,\n): hbs.AST.Expression | undefined {\n\treturn stmt.params[0] as hbs.AST.Expression | undefined;\n}\n\n/**\n * Retrieves the helper name from a BlockStatement (e.g. \"if\", \"each\", \"with\").\n */\nfunction getBlockHelperName(stmt: hbs.AST.BlockStatement): string {\n\tif (stmt.path.type === \"PathExpression\") {\n\t\treturn (stmt.path as hbs.AST.PathExpression).original;\n\t}\n\treturn \"\";\n}\n\n/**\n * Retrieves the name of an expression (first segment of the PathExpression).\n * Used to identify inline helpers.\n */\nfunction getExpressionName(expr: hbs.AST.Expression): string {\n\tif (expr.type === \"PathExpression\") {\n\t\treturn (expr as hbs.AST.PathExpression).original;\n\t}\n\treturn \"\";\n}\n\n/**\n * Adds an enriched diagnostic to the analysis context.\n *\n * Each diagnostic includes:\n * - A machine-readable `code` for the frontend\n * - A human-readable `message` describing the problem\n * - A `source` snippet from the template (if the position is available)\n * - Structured `details` for debugging\n */\nfunction addDiagnostic(\n\tctx: AnalysisContext,\n\tcode: DiagnosticCode,\n\tseverity: \"error\" | \"warning\",\n\tmessage: string,\n\tnode?: hbs.AST.Node,\n\tdetails?: DiagnosticDetails,\n): void {\n\tconst diagnostic: TemplateDiagnostic = { severity, code, message };\n\n\t// Extract the position and source snippet if available\n\tif (node && \"loc\" in node && node.loc) {\n\t\tdiagnostic.loc = {\n\t\t\tstart: { line: node.loc.start.line, column: node.loc.start.column },\n\t\t\tend: { line: node.loc.end.line, column: node.loc.end.column },\n\t\t};\n\t\t// Extract the template fragment around the error\n\t\tdiagnostic.source = extractSourceSnippet(ctx.template, diagnostic.loc);\n\t}\n\n\tif (details) {\n\t\tdiagnostic.details = details;\n\t}\n\n\tctx.diagnostics.push(diagnostic);\n}\n\n/**\n * Returns a human-readable label for a schema's type (for error messages).\n */\nfunction schemaTypeLabel(schema: JSONSchema7): string {\n\tif (schema.type) {\n\t\treturn Array.isArray(schema.type) ? schema.type.join(\" | \") : schema.type;\n\t}\n\tif (schema.oneOf) return \"oneOf(...)\";\n\tif (schema.anyOf) return \"anyOf(...)\";\n\tif (schema.allOf) return \"allOf(...)\";\n\tif (schema.enum) return \"enum\";\n\treturn \"unknown\";\n}\n\n// ─── Export for Internal Use ─────────────────────────────────────────────────\n// `inferBlockType` is exported to allow targeted unit tests\n// on block type inference.\nexport { inferBlockType };\n"
6
6
  ],
7
- "mappings": "gWAsGO,GAAS,LAAO,LACtB,JACA,EACA,EACiB,CACjB,GAAI,EAAc,CAAQ,EACzB,OAAO,EAAsB,EAAU,EAAa,CAAiB,EAEtE,GAAI,EAAe,CAAQ,EAC1B,MAAO,CACN,MAAO,GACP,YAAa,CAAC,EACd,aAAc,EAAqB,CAAQ,CAC5C,EAED,IAAM,EAAM,EAAM,CAAQ,EAC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,EAAK,IAAI,IAAI,MAAO,CAC7D,EAEA,EAAW,OAAS,EAAqB,EAAI,SAAU,EAAW,GAAG,EAGtE,GAAI,EACH,EAAW,QAAU,EAGtB,EAAI,YAAY,KAAK,CAAU,EAMhC,SAAS,CAAe,CAAC,EAA6B,CACrD,GAAI,EAAO,KACV,OAAO,MAAM,QAAQ,EAAO,IAAI,EAAI,EAAO,KAAK,KAAK,KAAK,EAAI,EAAO,KAEtE,GAAI,EAAO,MAAO,MAAO,aACzB,GAAI,EAAO,MAAO,MAAO,aACzB,GAAI,EAAO,MAAO,MAAO,aACzB,GAAI,EAAO,KAAM,MAAO,OACxB,MAAO",
8
+ "debugId": "57C3498B4F6E645064756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,7 +1,7 @@
1
1
  class F extends Error{constructor(j){super(j);this.name="TemplateError"}toJSON(){return{name:this.name,message:this.message}}}class H extends F{loc;source;constructor(j,q,A){super(`Parse error: ${j}`);this.loc=q;this.source=A;this.name="TemplateParseError"}toJSON(){return{name:this.name,message:this.message,loc:this.loc,source:this.source}}}class I extends F{diagnostics;errors;warnings;errorCount;warningCount;constructor(j){let q=j.filter((B)=>B.severity==="error"),A=j.filter((B)=>B.severity==="warning"),G=q.map((B)=>M(B)).join(`
2
2
  `);super(`Static analysis failed with ${q.length} error(s):
3
3
  ${G}`);this.name="TemplateAnalysisError",this.diagnostics=j,this.errors=q,this.warnings=A,this.errorCount=q.length,this.warningCount=A.length}toJSON(){return{name:this.name,message:this.message,errorCount:this.errorCount,warningCount:this.warningCount,diagnostics:this.diagnostics}}}class J extends F{constructor(j){super(`Runtime error: ${j}`);this.name="TemplateRuntimeError"}}class K extends F{keyword;schemaPath;constructor(j,q){super(`Unsupported JSON Schema feature: "${j}" at "${q}". Conditional schemas (if/then/else) cannot be resolved during static analysis because they depend on runtime data. Consider using oneOf/anyOf combinators instead.`);this.keyword=j;this.schemaPath=q;this.name="UnsupportedSchemaError"}toJSON(){return{name:this.name,message:this.message,keyword:this.keyword,schemaPath:this.schemaPath}}}function M(j){let q=[` • [${j.code}] ${j.message}`];if(j.loc)q.push(`(at ${j.loc.start.line}:${j.loc.start.column})`);return q.join(" ")}function O(j,q){let A=`Property "${j}" does not exist in the context schema`;if(q.length===0)return A;return`${A}. Available properties: ${q.join(", ")}`}function Q(j,q,A){return`"{{#${j}}}" expects ${q}, but resolved schema has type "${A}"`}function R(j){return`"{{#${j}}}" requires an argument`}function S(j){return`Unknown block helper "{{#${j}}}" — cannot analyze statically`}function U(j){return`Expression of type "${j}" cannot be statically analyzed`}
4
- export{F as K,H as L,I as M,J as N,K as O,O as P,Q,R,S,U as T};
4
+ export{F as J,H as K,I as L,J as M,K as N,O,Q as P,R as Q,S as R,U as S};
5
5
 
6
- //# debugId=B837B229D55D66E864756E2164756E21
7
- //# sourceMappingURL=chunk-zh1e0yhd.js.map
6
+ //# debugId=31B30E119A9E4B5B64756E2164756E21
7
+ //# sourceMappingURL=chunk-gayk9ew1.js.map
@@ -5,6 +5,6 @@
5
5
  "import type { TemplateDiagnostic } from \"./types.ts\";\n\n// ─── Base Class ──────────────────────────────────────────────────────────────\n// All template engine errors extend this class, enabling targeted catch blocks:\n// `catch (e) { if (e instanceof TemplateError) … }`\n// Subclasses:\n// - `TemplateParseError` — invalid template syntax\n// - `TemplateAnalysisError` — static analysis failures (diagnostics)\n// - `TemplateRuntimeError` — execution failures\n// - `UnsupportedSchemaError` — schema uses unsupported JSON Schema features\n\nexport class TemplateError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"TemplateError\";\n\t}\n\n\t/**\n\t * Serializes the error into a JSON-compatible object, suitable for sending\n\t * to a frontend or a structured logging system.\n\t */\n\ttoJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t};\n\t}\n}\n\n// ─── Parse Error ─────────────────────────────────────────────────────────────\n// Thrown when Handlebars fails to parse the template (invalid syntax).\n\nexport class TemplateParseError extends TemplateError {\n\tconstructor(\n\t\tmessage: string,\n\t\t/** Approximate position of the error in the source */\n\t\tpublic readonly loc?: { line: number; column: number },\n\t\t/** Fragment of the template source around the error */\n\t\tpublic readonly source?: string,\n\t) {\n\t\tsuper(`Parse error: ${message}`);\n\t\tthis.name = \"TemplateParseError\";\n\t}\n\n\toverride toJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tloc: this.loc,\n\t\t\tsource: this.source,\n\t\t};\n\t}\n}\n\n// ─── Static Analysis Error ───────────────────────────────────────────────────\n// Thrown in strict mode when the analysis produces at least one error.\n// Contains the full list of diagnostics for detailed inspection.\n\nexport class TemplateAnalysisError extends TemplateError {\n\t/** Full list of diagnostics (errors + warnings) */\n\tpublic readonly diagnostics: TemplateDiagnostic[];\n\n\t/** Only diagnostics with \"error\" severity */\n\tpublic readonly errors: TemplateDiagnostic[];\n\n\t/** Only diagnostics with \"warning\" severity */\n\tpublic readonly warnings: TemplateDiagnostic[];\n\n\t/** Total number of errors */\n\tpublic readonly errorCount: number;\n\n\t/** Total number of warnings */\n\tpublic readonly warningCount: number;\n\n\tconstructor(diagnostics: TemplateDiagnostic[]) {\n\t\tconst errors = diagnostics.filter((d) => d.severity === \"error\");\n\t\tconst warnings = diagnostics.filter((d) => d.severity === \"warning\");\n\n\t\tconst summary = errors.map((d) => formatDiagnosticLine(d)).join(\"\\n\");\n\t\tsuper(`Static analysis failed with ${errors.length} error(s):\\n${summary}`);\n\n\t\tthis.name = \"TemplateAnalysisError\";\n\t\tthis.diagnostics = diagnostics;\n\t\tthis.errors = errors;\n\t\tthis.warnings = warnings;\n\t\tthis.errorCount = errors.length;\n\t\tthis.warningCount = warnings.length;\n\t}\n\n\t/**\n\t * Serializes the analysis error into a JSON-compatible object.\n\t *\n\t * Designed for direct use in API responses:\n\t * ```\n\t * res.status(400).json(error.toJSON());\n\t * ```\n\t *\n\t * Returned structure:\n\t * ```\n\t * {\n\t * name: \"TemplateAnalysisError\",\n\t * message: \"Static analysis failed with 2 error(s): ...\",\n\t * errorCount: 2,\n\t * warningCount: 0,\n\t * diagnostics: [\n\t * {\n\t * severity: \"error\",\n\t * code: \"UNKNOWN_PROPERTY\",\n\t * message: \"Property \\\"foo\\\" does not exist...\",\n\t * loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 7 } },\n\t * source: \"{{foo}}\",\n\t * details: { path: \"foo\", availableProperties: [\"name\", \"age\"] }\n\t * }\n\t * ]\n\t * }\n\t * ```\n\t */\n\toverride toJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\terrorCount: this.errorCount,\n\t\t\twarningCount: this.warningCount,\n\t\t\tdiagnostics: this.diagnostics,\n\t\t};\n\t}\n}\n\n// ─── Runtime Error ───────────────────────────────────────────────────────────\n// Thrown when template execution fails (accessing a non-existent property\n// in strict mode, unexpected type, etc.).\n\nexport class TemplateRuntimeError extends TemplateError {\n\tconstructor(message: string) {\n\t\tsuper(`Runtime error: ${message}`);\n\t\tthis.name = \"TemplateRuntimeError\";\n\t}\n}\n\n// ─── Unsupported Schema Error ────────────────────────────────────────────────\n// Thrown when the provided JSON Schema uses features that cannot be handled\n// by static analysis (e.g. `if/then/else` conditional schemas).\n//\n// These features are data-dependent and fundamentally non-resolvable without\n// runtime values. Rather than silently ignoring them (which would produce\n// incorrect analysis results), we fail fast with a clear error message.\n\nexport class UnsupportedSchemaError extends TemplateError {\n\tconstructor(\n\t\t/** The unsupported keyword(s) detected (e.g. `\"if/then/else\"`) */\n\t\tpublic readonly keyword: string,\n\t\t/** JSON pointer path to the location in the schema (e.g. `\"/properties/user\"`) */\n\t\tpublic readonly schemaPath: string,\n\t) {\n\t\tsuper(\n\t\t\t`Unsupported JSON Schema feature: \"${keyword}\" at \"${schemaPath}\". ` +\n\t\t\t\t\"Conditional schemas (if/then/else) cannot be resolved during static analysis \" +\n\t\t\t\t\"because they depend on runtime data. Consider using oneOf/anyOf combinators instead.\",\n\t\t);\n\t\tthis.name = \"UnsupportedSchemaError\";\n\t}\n\n\toverride toJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tkeyword: this.keyword,\n\t\t\tschemaPath: this.schemaPath,\n\t\t};\n\t}\n}\n\n// ─── Internal Utilities ──────────────────────────────────────────────────────\n\n/**\n * Formats a single diagnostic line for the summary message\n * of a `TemplateAnalysisError`.\n *\n * Produces a human-readable format:\n * ` • [UNKNOWN_PROPERTY] Property \"foo\" does not exist (at 1:0)`\n */\nfunction formatDiagnosticLine(diag: TemplateDiagnostic): string {\n\tconst parts: string[] = [` • [${diag.code}] ${diag.message}`];\n\n\tif (diag.loc) {\n\t\tparts.push(`(at ${diag.loc.start.line}:${diag.loc.start.column})`);\n\t}\n\n\treturn parts.join(\" \");\n}\n\n// ─── Common Error Factories ──────────────────────────────────────────────────\n// These functions simplify the creation of typed errors across the codebase.\n\n/**\n * Creates a structured diagnostic message for a missing property.\n * Used by the analyzer to produce enriched error messages with suggestions.\n */\nexport function createPropertyNotFoundMessage(\n\tpath: string,\n\tavailableProperties: string[],\n): string {\n\tconst base = `Property \"${path}\" does not exist in the context schema`;\n\tif (availableProperties.length === 0) return base;\n\treturn `${base}. Available properties: ${availableProperties.join(\", \")}`;\n}\n\n/**\n * Creates a message for a type mismatch on a block helper.\n */\nexport function createTypeMismatchMessage(\n\thelperName: string,\n\texpected: string,\n\tactual: string,\n): string {\n\treturn `\"{{#${helperName}}}\" expects ${expected}, but resolved schema has type \"${actual}\"`;\n}\n\n/**\n * Creates a message for a missing argument on a block helper.\n */\nexport function createMissingArgumentMessage(helperName: string): string {\n\treturn `\"{{#${helperName}}}\" requires an argument`;\n}\n\n/**\n * Creates a message for an unknown block helper.\n */\nexport function createUnknownHelperMessage(helperName: string): string {\n\treturn `Unknown block helper \"{{#${helperName}}}\" — cannot analyze statically`;\n}\n\n/**\n * Creates a message for an expression that cannot be statically analyzed.\n */\nexport function createUnanalyzableMessage(nodeType: string): string {\n\treturn `Expression of type \"${nodeType}\" cannot be statically analyzed`;\n}\n"
6
6
  ],
7
7
  "mappings": "AAWO,MAAM,UAAsB,KAAM,CACxC,WAAW,CAAC,EAAiB,CAC5B,MAAM,CAAO,EACb,KAAK,KAAO,gBAOb,MAAM,EAA4B,CACjC,MAAO,CACN,KAAM,KAAK,KACX,QAAS,KAAK,OACf,EAEF,CAKO,MAAM,UAA2B,CAAc,CAIpC,IAEA,OALjB,WAAW,CACV,EAEgB,EAEA,EACf,CACD,MAAM,gBAAgB,GAAS,EAJf,WAEA,cAGhB,KAAK,KAAO,qBAGJ,MAAM,EAA4B,CAC1C,MAAO,CACN,KAAM,KAAK,KACX,QAAS,KAAK,QACd,IAAK,KAAK,IACV,OAAQ,KAAK,MACd,EAEF,CAMO,MAAM,UAA8B,CAAc,CAExC,YAGA,OAGA,SAGA,WAGA,aAEhB,WAAW,CAAC,EAAmC,CAC9C,IAAM,EAAS,EAAY,OAAO,CAAC,IAAM,EAAE,WAAa,OAAO,EACzD,EAAW,EAAY,OAAO,CAAC,IAAM,EAAE,WAAa,SAAS,EAE7D,EAAU,EAAO,IAAI,CAAC,IAAM,EAAqB,CAAC,CAAC,EAAE,KAAK;AAAA,CAAI,EACpE,MAAM,+BAA+B,EAAO;AAAA,EAAqB,GAAS,EAE1E,KAAK,KAAO,wBACZ,KAAK,YAAc,EACnB,KAAK,OAAS,EACd,KAAK,SAAW,EAChB,KAAK,WAAa,EAAO,OACzB,KAAK,aAAe,EAAS,OA+BrB,MAAM,EAA4B,CAC1C,MAAO,CACN,KAAM,KAAK,KACX,QAAS,KAAK,QACd,WAAY,KAAK,WACjB,aAAc,KAAK,aACnB,YAAa,KAAK,WACnB,EAEF,CAMO,MAAM,UAA6B,CAAc,CACvD,WAAW,CAAC,EAAiB,CAC5B,MAAM,kBAAkB,GAAS,EACjC,KAAK,KAAO,uBAEd,CAUO,MAAM,UAA+B,CAAc,CAGxC,QAEA,WAJjB,WAAW,CAEM,EAEA,EACf,CACD,MACC,qCAAqC,UAAgB,uKAGtD,EARgB,eAEA,kBAOhB,KAAK,KAAO,yBAGJ,MAAM,EAA4B,CAC1C,MAAO,CACN,KAAM,KAAK,KACX,QAAS,KAAK,QACd,QAAS,KAAK,QACd,WAAY,KAAK,UAClB,EAEF,CAWA,SAAS,CAAoB,CAAC,EAAkC,CAC/D,IAAM,EAAkB,CAAC,QAAO,EAAK,SAAS,EAAK,SAAS,EAE5D,GAAI,EAAK,IACR,EAAM,KAAK,OAAO,EAAK,IAAI,MAAM,QAAQ,EAAK,IAAI,MAAM,SAAS,EAGlE,OAAO,EAAM,KAAK,GAAG,EAUf,SAAS,CAA6B,CAC5C,EACA,EACS,CACT,IAAM,EAAO,aAAa,0CAC1B,GAAI,EAAoB,SAAW,EAAG,OAAO,EAC7C,MAAO,GAAG,4BAA+B,EAAoB,KAAK,IAAI,IAMhE,SAAS,CAAyB,CACxC,EACA,EACA,EACS,CACT,MAAO,OAAO,gBAAyB,oCAA2C,KAM5E,SAAS,CAA4B,CAAC,EAA4B,CACxE,MAAO,OAAO,4BAMR,SAAS,CAA0B,CAAC,EAA4B,CACtE,MAAO,4BAA4B,mCAM7B,SAAS,CAAyB,CAAC,EAA0B,CACnE,MAAO,uBAAuB",
8
- "debugId": "B837B229D55D66E864756E2164756E21",
8
+ "debugId": "31B30E119A9E4B5B64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
- import{L as J}from"./chunk-zh1e0yhd.js";import Q from"handlebars";var V=/^(.+):(\d+)$/,W=/^-?\d+(\.\d+)?$/;function j(k){try{return Q.parse(k)}catch(q){let z=q instanceof Error?q.message:String(q),G=z.match(/line\s+(\d+).*?column\s+(\d+)/i),O=G?{line:parseInt(G[1]??"0",10),column:parseInt(G[2]??"0",10)}:void 0;throw new J(z,O)}}function C(k){let{body:q}=k;return q.length===1&&q[0]?.type==="MustacheStatement"}function D(k){if(k.type==="PathExpression")return k.parts;return[]}function F(k){if(k.type!=="PathExpression")return!1;let q=k;return q.original==="this"||q.original==="."}function K(k){return k.body.filter((q)=>!(q.type==="ContentStatement"&&q.value.trim()===""))}function P(k){let q=K(k);if(q.length===1&&q[0]?.type==="BlockStatement")return q[0];return null}function U(k){let q=K(k);if(q.length===1&&q[0]?.type==="MustacheStatement")return q[0];return null}function A(k){return k.body.every((q)=>q.type==="ContentStatement"||q.type==="MustacheStatement"&&q.params.length===0&&!q.hash)}function X(k){if(W.test(k))return"number";if(k==="true"||k==="false")return"boolean";if(k==="null")return"null";return null}function B(k){let q=k.trim(),z=X(q);if(z==="number")return Number(q);if(z==="boolean")return q==="true";if(z==="null")return null;return k}function Y(k){let q=k.match(V);if(q)return{key:q[1]??k,identifier:parseInt(q[2]??"0",10)};return{key:k,identifier:null}}function H(k){if(k.length===0)return{cleanSegments:[],identifier:null};let q=k[k.length-1],z=Y(q);if(z.identifier!==null)return{cleanSegments:[...k.slice(0,-1),z.key],identifier:z.identifier};return{cleanSegments:k,identifier:null}}
2
- export{j as n,C as o,D as p,F as q,K as r,P as s,U as t,A as u,X as v,B as w,Y as x,H as y};
1
+ import{K as J}from"./chunk-gayk9ew1.js";import Q from"handlebars";var V=/^(.+):(\d+)$/,W=/^-?\d+(\.\d+)?$/;function j(k){try{return Q.parse(k)}catch(q){let z=q instanceof Error?q.message:String(q),G=z.match(/line\s+(\d+).*?column\s+(\d+)/i),O=G?{line:parseInt(G[1]??"0",10),column:parseInt(G[2]??"0",10)}:void 0;throw new J(z,O)}}function C(k){let{body:q}=k;return q.length===1&&q[0]?.type==="MustacheStatement"}function D(k){if(k.type==="PathExpression")return k.parts;return[]}function F(k){if(k.type!=="PathExpression")return!1;let q=k;return q.original==="this"||q.original==="."}function K(k){return k.body.filter((q)=>!(q.type==="ContentStatement"&&q.value.trim()===""))}function P(k){let q=K(k);if(q.length===1&&q[0]?.type==="BlockStatement")return q[0];return null}function U(k){let q=K(k);if(q.length===1&&q[0]?.type==="MustacheStatement")return q[0];return null}function A(k){return k.body.every((q)=>q.type==="ContentStatement"||q.type==="MustacheStatement"&&q.params.length===0&&!q.hash)}function X(k){if(W.test(k))return"number";if(k==="true"||k==="false")return"boolean";if(k==="null")return"null";return null}function B(k){let q=k.trim(),z=X(q);if(z==="number")return Number(q);if(z==="boolean")return q==="true";if(z==="null")return null;return k}function Y(k){let q=k.match(V);if(q)return{key:q[1]??k,identifier:parseInt(q[2]??"0",10)};return{key:k,identifier:null}}function H(k){if(k.length===0)return{cleanSegments:[],identifier:null};let q=k[k.length-1],z=Y(q);if(z.identifier!==null)return{cleanSegments:[...k.slice(0,-1),z.key],identifier:z.identifier};return{cleanSegments:k,identifier:null}}
2
+ export{j as m,C as n,D as o,F as p,K as q,P as r,U as s,A as t,X as u,B as v,Y as w,H as x};
3
3
 
4
- //# debugId=F3976A234FF91EEE64756E2164756E21
5
- //# sourceMappingURL=chunk-rkrp4ysw.js.map
4
+ //# debugId=BFFDD3C444773EFF64756E2164756E21
5
+ //# sourceMappingURL=chunk-s96k41p3.js.map
@@ -5,6 +5,6 @@
5
5
  "import Handlebars from \"handlebars\";\nimport { TemplateParseError } from \"./errors.ts\";\n\n// ─── Regex for detecting a template identifier (e.g. \"meetingId:1\") ──────────\n// The identifier is always a positive integer or zero, separated from the\n// variable name by a `:`. The `:` and number are on the **last** segment\n// of the path (Handlebars splits on `.`).\nconst IDENTIFIER_RE = /^(.+):(\\d+)$/;\n\n// ─── Template Parser ─────────────────────────────────────────────────────────\n// Thin wrapper around the Handlebars parser. Centralizing the parser call\n// here allows us to:\n// 1. Wrap errors into our own hierarchy (`TemplateParseError`)\n// 2. Expose AST introspection helpers (e.g. `isSingleExpression`)\n// 3. Isolate the direct Handlebars dependency from the rest of the codebase\n//\n// AST caching is handled at the `Typebars` instance level (via its own\n// configurable LRU cache), not here. This module only parses and wraps errors.\n\n// ─── Regex for detecting a numeric literal (integer or decimal, signed) ──────\n// Intentionally conservative: no scientific notation (1e5), no hex (0xFF),\n// no separators (1_000). We only want to recognize what a human would write\n// as a numeric value in a template.\nconst NUMERIC_LITERAL_RE = /^-?\\d+(\\.\\d+)?$/;\n\n/**\n * Parses a template string and returns the Handlebars AST.\n *\n * This function does not cache results — caching is managed at the\n * `Typebars` instance level via its own configurable LRU cache.\n *\n * @param template - The template string to parse (e.g. `\"Hello {{name}}\"`)\n * @returns The root AST node (`hbs.AST.Program`)\n * @throws {TemplateParseError} if the template syntax is invalid\n */\nexport function parse(template: string): hbs.AST.Program {\n\ttry {\n\t\treturn Handlebars.parse(template);\n\t} catch (error: unknown) {\n\t\t// Handlebars throws a plain Error with a descriptive message.\n\t\t// We transform it into a TemplateParseError for uniform handling.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\n\t\t// Handlebars sometimes includes the position in the message —\n\t\t// attempt to extract it to enrich our error.\n\t\tconst locMatch = message.match(/line\\s+(\\d+).*?column\\s+(\\d+)/i);\n\t\tconst loc = locMatch\n\t\t\t? {\n\t\t\t\t\tline: parseInt(locMatch[1] ?? \"0\", 10),\n\t\t\t\t\tcolumn: parseInt(locMatch[2] ?? \"0\", 10),\n\t\t\t\t}\n\t\t\t: undefined;\n\n\t\tthrow new TemplateParseError(message, loc);\n\t}\n}\n\n/**\n * Determines whether the AST represents a template consisting of a single\n * expression `{{expression}}` with no text content around it.\n *\n * This matters for return type inference:\n * - Template `{{value}}` → returns the raw type of `value` (number, object…)\n * - Template `Hello {{name}}` → always returns `string` (concatenation)\n *\n * @param ast - The parsed AST of the template\n * @returns `true` if the template is a single expression\n */\nexport function isSingleExpression(ast: hbs.AST.Program): boolean {\n\tconst { body } = ast;\n\n\t// Exactly one node, and it's a MustacheStatement (not a block, not text)\n\treturn body.length === 1 && body[0]?.type === \"MustacheStatement\";\n}\n\n/**\n * Extracts the path segments from a Handlebars `PathExpression`.\n *\n * Handlebars decomposes `user.address.city` into `{ parts: [\"user\", \"address\", \"city\"] }`.\n * This function safely extracts those segments.\n *\n * @param expr - The expression to extract the path from\n * @returns The path segments, or an empty array if the expression is not\n * a `PathExpression`\n */\nexport function extractPathSegments(expr: hbs.AST.Expression): string[] {\n\tif (expr.type === \"PathExpression\") {\n\t\treturn (expr as hbs.AST.PathExpression).parts;\n\t}\n\treturn [];\n}\n\n/**\n * Checks whether an AST expression is a `PathExpression` pointing to `this`\n * (used inside `{{#each}}` blocks).\n */\nexport function isThisExpression(expr: hbs.AST.Expression): boolean {\n\tif (expr.type !== \"PathExpression\") return false;\n\tconst path = expr as hbs.AST.PathExpression;\n\treturn path.original === \"this\" || path.original === \".\";\n}\n\n// ─── Filtering Semantically Significant Nodes ───────────────────────────────\n// In a Handlebars AST, formatting (newlines, indentation) produces\n// `ContentStatement` nodes whose value is purely whitespace. These nodes\n// have no semantic impact and must be ignored during type inference to\n// correctly detect \"effectively a single block\" or \"effectively a single\n// expression\" cases.\n\n/**\n * Returns the semantically significant statements of a Program by\n * filtering out `ContentStatement` nodes that contain only whitespace.\n */\nexport function getEffectiveBody(\n\tprogram: hbs.AST.Program,\n): hbs.AST.Statement[] {\n\treturn program.body.filter(\n\t\t(s) =>\n\t\t\t!(\n\t\t\t\ts.type === \"ContentStatement\" &&\n\t\t\t\t(s as hbs.AST.ContentStatement).value.trim() === \"\"\n\t\t\t),\n\t);\n}\n\n/**\n * Determines whether a Program effectively consists of a single\n * `BlockStatement` (ignoring surrounding whitespace).\n *\n * Recognized examples:\n * ```\n * {{#if x}}...{{/if}}\n *\n * {{#each items}}...{{/each}}\n * ```\n *\n * @returns The single `BlockStatement`, or `null` if the program contains\n * other significant nodes.\n */\nexport function getEffectivelySingleBlock(\n\tprogram: hbs.AST.Program,\n): hbs.AST.BlockStatement | null {\n\tconst effective = getEffectiveBody(program);\n\tif (effective.length === 1 && effective[0]?.type === \"BlockStatement\") {\n\t\treturn effective[0] as hbs.AST.BlockStatement;\n\t}\n\treturn null;\n}\n\n/**\n * Determines whether a Program effectively consists of a single\n * `MustacheStatement` (ignoring surrounding whitespace).\n *\n * Example: ` {{age}} ` → true\n */\nexport function getEffectivelySingleExpression(\n\tprogram: hbs.AST.Program,\n): hbs.AST.MustacheStatement | null {\n\tconst effective = getEffectiveBody(program);\n\tif (effective.length === 1 && effective[0]?.type === \"MustacheStatement\") {\n\t\treturn effective[0] as hbs.AST.MustacheStatement;\n\t}\n\treturn null;\n}\n\n// ─── Fast-Path Detection ─────────────────────────────────────────────────────\n// For templates consisting only of text and simple expressions (no blocks,\n// no helpers with parameters), we can bypass Handlebars entirely and perform\n// a simple variable replacement via string concatenation.\n\n/**\n * Determines whether an AST can be executed via the fast-path (direct\n * concatenation without going through `Handlebars.compile()`).\n *\n * The fast-path is possible when the template only contains:\n * - `ContentStatement` nodes (static text)\n * - Simple `MustacheStatement` nodes (no params, no hash)\n *\n * This excludes:\n * - Block helpers (`{{#if}}`, `{{#each}}`, etc.)\n * - Inline helpers (`{{uppercase name}}`)\n * - Sub-expressions\n *\n * @param ast - The parsed AST of the template\n * @returns `true` if the template can use the fast-path\n */\nexport function canUseFastPath(ast: hbs.AST.Program): boolean {\n\treturn ast.body.every(\n\t\t(s) =>\n\t\t\ts.type === \"ContentStatement\" ||\n\t\t\t(s.type === \"MustacheStatement\" &&\n\t\t\t\t(s as hbs.AST.MustacheStatement).params.length === 0 &&\n\t\t\t\t!(s as hbs.AST.MustacheStatement).hash),\n\t);\n}\n\n// ─── Literal Detection in Text Content ───────────────────────────────────────\n// When a program contains only ContentStatements (no expressions), we try\n// to detect whether the concatenated and trimmed text is a typed literal\n// (number, boolean, null). This enables correct type inference for branches\n// like `{{#if x}} 42 {{/if}}`.\n\n/**\n * Attempts to detect the type of a raw text literal.\n *\n * @param text - The trimmed text from a ContentStatement or group of ContentStatements\n * @returns The detected JSON Schema type, or `null` if it's free-form text (string).\n */\nexport function detectLiteralType(\n\ttext: string,\n): \"number\" | \"boolean\" | \"null\" | null {\n\tif (NUMERIC_LITERAL_RE.test(text)) return \"number\";\n\tif (text === \"true\" || text === \"false\") return \"boolean\";\n\tif (text === \"null\") return \"null\";\n\treturn null;\n}\n\n/**\n * Coerces a raw string from Handlebars rendering to its actual type\n * if it represents a literal (number, boolean, null).\n * Returns the raw (untrimmed) string otherwise.\n */\nexport function coerceLiteral(raw: string): unknown {\n\tconst trimmed = raw.trim();\n\tconst type = detectLiteralType(trimmed);\n\tif (type === \"number\") return Number(trimmed);\n\tif (type === \"boolean\") return trimmed === \"true\";\n\tif (type === \"null\") return null;\n\t// Not a typed literal — return the raw string without trimming,\n\t// as whitespace may be significant (e.g. output of an #each block).\n\treturn raw;\n}\n\n// ─── Template Identifier Parsing ─────────────────────────────────────────────\n// Syntax `{{key:N}}` where N is a positive integer or zero.\n// The identifier allows resolving a variable from a specific data source\n// (e.g. a workflow node identified by its number).\n\n/** Result of parsing a path segment with a potential identifier */\nexport interface ParsedIdentifier {\n\t/** The variable name, without the `:N` suffix */\n\tkey: string;\n\t/** The numeric identifier, or `null` if absent */\n\tidentifier: number | null;\n}\n\n/**\n * Parses an individual path segment to extract the key and optional identifier.\n *\n * @param segment - A raw path segment (e.g. `\"meetingId:1\"` or `\"meetingId\"`)\n * @returns An object `{ key, identifier }`\n *\n * @example\n * ```\n * parseIdentifier(\"meetingId:1\") // → { key: \"meetingId\", identifier: 1 }\n * parseIdentifier(\"meetingId\") // → { key: \"meetingId\", identifier: null }\n * parseIdentifier(\"meetingId:0\") // → { key: \"meetingId\", identifier: 0 }\n * ```\n */\nexport function parseIdentifier(segment: string): ParsedIdentifier {\n\tconst match = segment.match(IDENTIFIER_RE);\n\tif (match) {\n\t\treturn {\n\t\t\tkey: match[1] ?? segment,\n\t\t\tidentifier: parseInt(match[2] ?? \"0\", 10),\n\t\t};\n\t}\n\treturn { key: segment, identifier: null };\n}\n\n/** Result of extracting the identifier from a complete expression */\nexport interface ExpressionIdentifier {\n\t/** Cleaned path segments (without the `:N` suffix on the last one) */\n\tcleanSegments: string[];\n\t/** The numeric identifier extracted from the last segment, or `null` */\n\tidentifier: number | null;\n}\n\n/**\n * Extracts the identifier from a complete expression (array of segments).\n *\n * The identifier is always on the **last** segment of the path, because\n * Handlebars splits on `.` before the `:`.\n *\n * @param segments - The raw path segments (e.g. `[\"user\", \"name:1\"]`)\n * @returns An object `{ cleanSegments, identifier }`\n *\n * @example\n * ```\n * extractExpressionIdentifier([\"meetingId:1\"])\n * // → { cleanSegments: [\"meetingId\"], identifier: 1 }\n *\n * extractExpressionIdentifier([\"user\", \"name:1\"])\n * // → { cleanSegments: [\"user\", \"name\"], identifier: 1 }\n *\n * extractExpressionIdentifier([\"meetingId\"])\n * // → { cleanSegments: [\"meetingId\"], identifier: null }\n * ```\n */\nexport function extractExpressionIdentifier(\n\tsegments: string[],\n): ExpressionIdentifier {\n\tif (segments.length === 0) {\n\t\treturn { cleanSegments: [], identifier: null };\n\t}\n\n\tconst lastSegment = segments[segments.length - 1] as string;\n\tconst parsed = parseIdentifier(lastSegment);\n\n\tif (parsed.identifier !== null) {\n\t\tconst cleanSegments = [...segments.slice(0, -1), parsed.key];\n\t\treturn { cleanSegments, identifier: parsed.identifier };\n\t}\n\n\treturn { cleanSegments: segments, identifier: null };\n}\n"
6
6
  ],
7
7
  "mappings": "wCAAA,0BAOA,IAAM,EAAgB,eAgBhB,EAAqB,kBAYpB,SAAS,CAAK,CAAC,EAAmC,CACxD,GAAI,CACH,OAAO,EAAW,MAAM,CAAQ,EAC/B,MAAO,EAAgB,CAGxB,IAAM,EAAU,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,EAI/D,EAAW,EAAQ,MAAM,gCAAgC,EACzD,EAAM,EACT,CACA,KAAM,SAAS,EAAS,IAAM,IAAK,EAAE,EACrC,OAAQ,SAAS,EAAS,IAAM,IAAK,EAAE,CACxC,EACC,OAEH,MAAM,IAAI,EAAmB,EAAS,CAAG,GAepC,SAAS,CAAkB,CAAC,EAA+B,CACjE,IAAQ,QAAS,EAGjB,OAAO,EAAK,SAAW,GAAK,EAAK,IAAI,OAAS,oBAaxC,SAAS,CAAmB,CAAC,EAAoC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MAAO,CACN,IAAK,EAAM,IAAM,EACjB,WAAY,SAAS,EAAM,IAAM,IAAK,EAAE,CACzC,EAED,MAAO,CAAE,IAAK,EAAS,WAAY,IAAK,EAgClC,SAAS,CAA2B,CAC1C,EACuB,CACvB,GAAI,EAAS,SAAW,EACvB,MAAO,CAAE,cAAe,CAAC,EAAG,WAAY,IAAK,EAG9C,IAAM,EAAc,EAAS,EAAS,OAAS,GACzC,EAAS,EAAgB,CAAW,EAE1C,GAAI,EAAO,aAAe,KAEzB,MAAO,CAAE,cADa,CAAC,GAAG,EAAS,MAAM,EAAG,EAAE,EAAG,EAAO,GAAG,EACnC,WAAY,EAAO,UAAW,EAGvD,MAAO,CAAE,cAAe,EAAU,WAAY,IAAK",
8
- "debugId": "F3976A234FF91EEE64756E2164756E21",
8
+ "debugId": "BFFDD3C444773EFF64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
- import{j as T,k as H}from"./chunk-6955jpr7.js";import{n as B,o as j,p as w,q as O,s as k,t as F,u as R,w as Z,y as U}from"./chunk-rkrp4ysw.js";import{F as L}from"./chunk-p5efqsxw.js";import{N as $}from"./chunk-zh1e0yhd.js";import C from"handlebars";var P=new L(128);function I(q,M,z){if(H(q))return S(q,M,z);if(T(q))return q;let G=B(q);return W(G,q,M,{identifierData:z})}function S(q,M,z){let G={};for(let[K,J]of Object.entries(q))G[K]=I(J,M,z);return G}function W(q,M,z,G){let K=G?.identifierData;if(j(q)){let N=q.body[0];if(N.params.length===0&&!N.hash)return _(N.path,z,K)}let J=F(q);if(J&&J.params.length===0&&!J.hash)return _(J.path,z,K);if(J&&(J.params.length>0||J.hash)){let N=X(z,K),V=Y(M,N,G);return Z(V)}if(R(q)&&q.body.length>1)return v(q,z,K);if(k(q)){let N=X(z,K),V=Y(M,N,G);return Z(V)}let y=X(z,K);return Y(M,y,G)}function v(q,M,z){let G="";for(let K of q.body)if(K.type==="ContentStatement")G+=K.value;else if(K.type==="MustacheStatement"){let J=_(K.path,M,z);if(J!=null)G+=String(J)}return G}function _(q,M,z){if(O(q))return M;if(q.type==="StringLiteral")return q.value;if(q.type==="NumberLiteral")return q.value;if(q.type==="BooleanLiteral")return q.value;if(q.type==="NullLiteral")return null;if(q.type==="UndefinedLiteral")return;let G=w(q);if(G.length===0)throw new $(`Cannot resolve expression of type "${q.type}"`);let{cleanSegments:K,identifier:J}=U(G);if(J!==null&&z){let Q=z[J];if(Q)return A(Q,K);return}if(J!==null&&!z)return;return A(M,K)}function A(q,M){let z=q;for(let G of M){if(z===null||z===void 0)return;if(typeof z!=="object")return;z=z[G]}return z}function X(q,M){if(!M)return q;let z={...q};for(let[G,K]of Object.entries(M))for(let[J,Q]of Object.entries(K))z[`${J}:${G}`]=Q;return z}function Y(q,M,z){try{if(z?.compiledTemplate)return z.compiledTemplate(M);let G=z?.compilationCache??P,K=z?.hbs??C,J=G.get(q);if(!J)J=K.compile(q,{noEscape:!0,strict:!1}),G.set(q,J);return J(M)}catch(G){let K=G instanceof Error?G.message:String(G);throw new $(K)}}function g(){P.clear()}
2
- export{I as f,W as g,A as h,g as i};
1
+ import{i as T,j as H}from"./chunk-8xza8tca.js";import{m as B,n as j,o as w,p as O,r as k,s as F,t as R,v as Z,x as U}from"./chunk-s96k41p3.js";import{E as L}from"./chunk-9jxzj2h4.js";import{M as $}from"./chunk-gayk9ew1.js";import C from"handlebars";var P=new L(128);function I(q,M,z){if(H(q))return S(q,M,z);if(T(q))return q;let G=B(q);return W(G,q,M,{identifierData:z})}function S(q,M,z){let G={};for(let[K,J]of Object.entries(q))G[K]=I(J,M,z);return G}function W(q,M,z,G){let K=G?.identifierData;if(j(q)){let N=q.body[0];if(N.params.length===0&&!N.hash)return _(N.path,z,K)}let J=F(q);if(J&&J.params.length===0&&!J.hash)return _(J.path,z,K);if(J&&(J.params.length>0||J.hash)){let N=X(z,K),V=Y(M,N,G);return Z(V)}if(R(q)&&q.body.length>1)return v(q,z,K);if(k(q)){let N=X(z,K),V=Y(M,N,G);return Z(V)}let y=X(z,K);return Y(M,y,G)}function v(q,M,z){let G="";for(let K of q.body)if(K.type==="ContentStatement")G+=K.value;else if(K.type==="MustacheStatement"){let J=_(K.path,M,z);if(J!=null)G+=String(J)}return G}function _(q,M,z){if(O(q))return M;if(q.type==="StringLiteral")return q.value;if(q.type==="NumberLiteral")return q.value;if(q.type==="BooleanLiteral")return q.value;if(q.type==="NullLiteral")return null;if(q.type==="UndefinedLiteral")return;let G=w(q);if(G.length===0)throw new $(`Cannot resolve expression of type "${q.type}"`);let{cleanSegments:K,identifier:J}=U(G);if(J!==null&&z){let Q=z[J];if(Q)return A(Q,K);return}if(J!==null&&!z)return;return A(M,K)}function A(q,M){let z=q;for(let G of M){if(z===null||z===void 0)return;if(typeof z!=="object")return;z=z[G]}return z}function X(q,M){if(!M)return q;let z={...q};for(let[G,K]of Object.entries(M))for(let[J,Q]of Object.entries(K))z[`${J}:${G}`]=Q;return z}function Y(q,M,z){try{if(z?.compiledTemplate)return z.compiledTemplate(M);let G=z?.compilationCache??P,K=z?.hbs??C,J=G.get(q);if(!J)J=K.compile(q,{noEscape:!0,strict:!1}),G.set(q,J);return J(M)}catch(G){let K=G instanceof Error?G.message:String(G);throw new $(K)}}function g(){P.clear()}
2
+ export{I as e,W as f,A as g,g as h};
3
3
 
4
- //# debugId=238A297F9D815C1664756E2164756E21
5
- //# sourceMappingURL=chunk-efqd0598.js.map
4
+ //# debugId=93ED260B549AAA3364756E2164756E21
5
+ //# sourceMappingURL=chunk-wvnn9g55.js.map