@twinfinity/printing 6.1.0-beta → 6.1.2-ci.30738-beta

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 (157) hide show
  1. package/dist/BuildInfo.js +3 -3
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/layout/analyzeTemplate.d.ts +4 -4
  7. package/dist/layout/analyzeTemplate.d.ts.map +1 -1
  8. package/dist/layout/analyzeTemplate.js +18 -16
  9. package/dist/layout/analyzeTemplate.js.map +1 -1
  10. package/dist/layout/classClosure.d.ts +41 -0
  11. package/dist/layout/classClosure.d.ts.map +1 -0
  12. package/dist/layout/classClosure.js +143 -0
  13. package/dist/layout/classClosure.js.map +1 -0
  14. package/dist/layout/clipUtils.d.ts +11 -0
  15. package/dist/layout/clipUtils.d.ts.map +1 -1
  16. package/dist/layout/clipUtils.js +67 -6
  17. package/dist/layout/clipUtils.js.map +1 -1
  18. package/dist/layout/filters.d.ts +14 -8
  19. package/dist/layout/filters.d.ts.map +1 -1
  20. package/dist/layout/filters.js +28 -3
  21. package/dist/layout/filters.js.map +1 -1
  22. package/dist/layout/index.d.ts +24 -57
  23. package/dist/layout/index.d.ts.map +1 -1
  24. package/dist/layout/index.js +20 -337
  25. package/dist/layout/index.js.map +1 -1
  26. package/dist/layout/itemBuilders.d.ts +11 -0
  27. package/dist/layout/itemBuilders.d.ts.map +1 -1
  28. package/dist/layout/itemBuilders.js +17 -3
  29. package/dist/layout/itemBuilders.js.map +1 -1
  30. package/dist/layout/labelsRender.d.ts.map +1 -1
  31. package/dist/layout/labelsRender.js +15 -27
  32. package/dist/layout/labelsRender.js.map +1 -1
  33. package/dist/layout/legendRender.d.ts +18 -6
  34. package/dist/layout/legendRender.d.ts.map +1 -1
  35. package/dist/layout/legendRender.js +49 -79
  36. package/dist/layout/legendRender.js.map +1 -1
  37. package/dist/layout/metadata.d.ts.map +1 -1
  38. package/dist/layout/metadata.js +26 -5
  39. package/dist/layout/metadata.js.map +1 -1
  40. package/dist/layout/model.d.ts +4 -3
  41. package/dist/layout/model.d.ts.map +1 -1
  42. package/dist/layout/model.js +17 -57
  43. package/dist/layout/model.js.map +1 -1
  44. package/dist/layout/options.d.ts +1 -2
  45. package/dist/layout/options.d.ts.map +1 -1
  46. package/dist/layout/options.js.map +1 -1
  47. package/dist/layout/preflight.d.ts +32 -0
  48. package/dist/layout/preflight.d.ts.map +1 -0
  49. package/dist/layout/preflight.js +69 -0
  50. package/dist/layout/preflight.js.map +1 -0
  51. package/dist/layout/qrRender.d.ts.map +1 -1
  52. package/dist/layout/qrRender.js +11 -10
  53. package/dist/layout/qrRender.js.map +1 -1
  54. package/dist/layout/renderDrawing.d.ts +28 -17
  55. package/dist/layout/renderDrawing.d.ts.map +1 -1
  56. package/dist/layout/renderDrawing.js +107 -88
  57. package/dist/layout/renderDrawing.js.map +1 -1
  58. package/dist/layout/renderLayout.d.ts +25 -0
  59. package/dist/layout/renderLayout.d.ts.map +1 -0
  60. package/dist/layout/renderLayout.js +315 -0
  61. package/dist/layout/renderLayout.js.map +1 -0
  62. package/dist/layout/renderTemplateSheet.d.ts +99 -0
  63. package/dist/layout/renderTemplateSheet.d.ts.map +1 -0
  64. package/dist/layout/renderTemplateSheet.js +296 -0
  65. package/dist/layout/renderTemplateSheet.js.map +1 -0
  66. package/dist/layout/renderUtils.d.ts +19 -0
  67. package/dist/layout/renderUtils.d.ts.map +1 -1
  68. package/dist/layout/renderUtils.js +47 -4
  69. package/dist/layout/renderUtils.js.map +1 -1
  70. package/dist/layout/sectionDefs.d.ts +65 -0
  71. package/dist/layout/sectionDefs.d.ts.map +1 -0
  72. package/dist/layout/sectionDefs.js +88 -0
  73. package/dist/layout/sectionDefs.js.map +1 -0
  74. package/dist/layout/slabModelView.d.ts +34 -0
  75. package/dist/layout/slabModelView.d.ts.map +1 -0
  76. package/dist/layout/slabModelView.js +175 -0
  77. package/dist/layout/slabModelView.js.map +1 -0
  78. package/dist/layout/templateVariables.d.ts +1 -1
  79. package/dist/layout/templateVariables.d.ts.map +1 -1
  80. package/dist/layout/templateVariables.js +21 -9
  81. package/dist/layout/templateVariables.js.map +1 -1
  82. package/dist/layout/types.d.ts +164 -83
  83. package/dist/layout/types.d.ts.map +1 -1
  84. package/dist/layout/types.js.map +1 -1
  85. package/dist/layout/validation.d.ts.map +1 -1
  86. package/dist/layout/validation.js +78 -33
  87. package/dist/layout/validation.js.map +1 -1
  88. package/dist/layout/viewportPrep.d.ts +8 -6
  89. package/dist/layout/viewportPrep.d.ts.map +1 -1
  90. package/dist/layout/viewportPrep.js +35 -23
  91. package/dist/layout/viewportPrep.js.map +1 -1
  92. package/dist/layout/viewportRender.d.ts +9 -7
  93. package/dist/layout/viewportRender.d.ts.map +1 -1
  94. package/dist/layout/viewportRender.js +93 -126
  95. package/dist/layout/viewportRender.js.map +1 -1
  96. package/dist/layout/viewportUtils.d.ts +20 -0
  97. package/dist/layout/viewportUtils.d.ts.map +1 -1
  98. package/dist/layout/viewportUtils.js +107 -4
  99. package/dist/layout/viewportUtils.js.map +1 -1
  100. package/dist/printToPdf.d.ts +7 -1
  101. package/dist/printToPdf.d.ts.map +1 -1
  102. package/dist/printToPdf.js +81 -14
  103. package/dist/printToPdf.js.map +1 -1
  104. package/dist/printToSvg.d.ts.map +1 -1
  105. package/dist/printToSvg.js +7 -3
  106. package/dist/printToSvg.js.map +1 -1
  107. package/dist/schemaUtils.d.ts +9 -0
  108. package/dist/schemaUtils.d.ts.map +1 -0
  109. package/dist/schemaUtils.js +14 -0
  110. package/dist/schemaUtils.js.map +1 -0
  111. package/dist/templates/default-template.json +30 -8
  112. package/dist/types.d.ts +2 -1
  113. package/dist/types.d.ts.map +1 -1
  114. package/dist/types.js +10 -1
  115. package/dist/types.js.map +1 -1
  116. package/package.json +8 -3
  117. package/src/index.ts +4 -0
  118. package/src/layout/analyzeTemplate.ts +21 -19
  119. package/src/layout/classClosure.ts +142 -0
  120. package/src/layout/clipUtils.ts +65 -6
  121. package/src/layout/filters.ts +31 -3
  122. package/src/layout/index.ts +61 -571
  123. package/src/layout/itemBuilders.ts +20 -5
  124. package/src/layout/labelsRender.ts +23 -40
  125. package/src/layout/legendRender.ts +64 -84
  126. package/src/layout/metadata.ts +26 -5
  127. package/src/layout/model.ts +21 -66
  128. package/src/layout/options.ts +1 -2
  129. package/src/layout/preflight.ts +96 -0
  130. package/src/layout/qrRender.ts +11 -10
  131. package/src/layout/renderDrawing.ts +132 -110
  132. package/src/layout/renderLayout.ts +483 -0
  133. package/src/layout/renderTemplateSheet.ts +435 -0
  134. package/src/layout/renderUtils.ts +53 -4
  135. package/src/layout/sectionDefs.ts +131 -0
  136. package/src/layout/slabModelView.ts +196 -0
  137. package/src/layout/templateVariables.ts +25 -9
  138. package/src/layout/types.ts +160 -70
  139. package/src/layout/validation.ts +98 -32
  140. package/src/layout/viewportPrep.ts +47 -29
  141. package/src/layout/viewportRender.ts +114 -141
  142. package/src/layout/viewportUtils.ts +118 -5
  143. package/src/printToPdf.ts +84 -15
  144. package/src/printToSvg.ts +7 -3
  145. package/src/schemaUtils.ts +13 -0
  146. package/src/templates/default-template.json +30 -8
  147. package/src/types.ts +12 -2
  148. package/templates/default-a0-landscape.json +171 -66
  149. package/templates/default-a0-portrait.json +159 -60
  150. package/templates/default-a1-landscape.json +135 -48
  151. package/templates/default-a1-portrait.json +123 -42
  152. package/templates/default-a3-landscape.json +87 -24
  153. package/templates/default-a3-portrait.json +99 -30
  154. package/templates/default-a4-landscape.json +75 -18
  155. package/templates/default-a4-portrait.json +75 -18
  156. package/templates/llm-authoring-guide.md +247 -0
  157. package/templates/template-schema.json +295 -120
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["layout/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SectionPath, SectionLabel } from '@twinfinity/geometry';\n\nexport type PagePresetKey = 'a1' | 'a3' | 'a4';\nexport type PageOrientation = 'portrait' | 'landscape';\n\nexport interface PageSpec {\n widthMm: number;\n heightMm: number;\n marginMm?: number;\n backgroundColor?: string;\n}\n\nexport interface TextStyle {\n fontFamily: string;\n fontSizeMm: number;\n fontWeight?: 'normal' | 'bold' | 'lighter' | 'bolder' | string;\n color?: string;\n letterSpacingMm?: number;\n lineHeightMm?: number;\n}\n\nexport interface StyleMap {\n [styleName: string]: TextStyle;\n}\n\nexport interface AssetSpec {\n id: string;\n src?: string;\n content?: string;\n}\n\nexport type WhereCondition = Record<string, string | number | boolean | Array<string | number>>;\n\nexport interface ClipConfig {\n class?: string | string[];\n where: WhereCondition;\n expandByM?: number;\n clipLabels?: boolean;\n stroke?: string;\n strokeWidthMm?: number;\n strokeOpacity?: number;\n fill?: string;\n fillOpacity?: number;\n}\n\n/**\n * Template-driven fill rule for a viewport.\n *\n * Fill rules control which products get filled polygons in the drawing.\n * When no `fills` array is present on a viewport, no fills are rendered.\n *\n * Example:\n * ```json\n * { \"class\": \"space\", \"fill\": \"sample\", \"fillOpacity\": 0.35 }\n * { \"class\": \"walls\", \"fill\": \"#cccccc\", \"fillOpacity\": 0.5 }\n * ```\n */\nexport interface FillRule {\n /** IFC class filter (e.g. \"space\", \"walls\"). Matches ifcClass or ifcClassId. */\n class?: string | string[];\n /** Property-based filter (same as highlight/clip `where`). */\n where?: WhereCondition;\n /** Fill color: CSS hex (e.g. \"#80c8b4\"), \"sample\" to read from 3D model material, or \"legend\" to use colors assigned by legend. */\n fill: string;\n /** Fill opacity (0–1). Default: 0.35. */\n fillOpacity?: number;\n /** When true, only apply fill to items whose centroid is spatially inside the clip polygon.\n * Useful when expandByM reveals adjacent spaces that shouldn't be filled.\n * @default false */\n matchClipFilter?: boolean;\n}\n\nexport interface HighlightConfig {\n class?: string | string[];\n where: WhereCondition;\n /** Only highlight items that also appear in the referenced viewport (i.e., intersect both planes). */\n intersectsViewport?: string;\n stroke?: string;\n strokeWidthMm?: number;\n strokeOpacity?: number;\n fill?: string;\n fillOpacity?: number;\n}\n\nexport type LayoutElement =\n | ViewportElement\n | TextElement\n | ImageElement\n | LineElement\n | RectElement\n | CircleElement\n | PolylineElement\n | PolygonElement\n | ScaleBarElement\n | QrElement\n | LabelsElement\n | LegendElement\n | GroupElement;\n\nexport interface BaseElement {\n kind: LayoutElement['kind'];\n id: string;\n zIndex?: number;\n}\n\n/** Style for a single line category in a viewport. */\nexport interface ViewportLineStyle {\n /** Line width in mm. */\n widthMm?: number;\n /** Line color (CSS color string). */\n color?: string;\n /** SVG dash array (e.g. \"4 2\"). */\n dash?: string;\n /** Whether this category is rendered. Default: true. */\n enabled?: boolean;\n}\n\n/**\n * Per-category line styles for a viewport.\n *\n * Resolution order: category-specific → `default` → built-in defaults.\n *\n * Example:\n * ```json\n * {\n * \"default\": { \"widthMm\": 0.01, \"color\": \"#1f2937\" },\n * \"cutLines\": { \"widthMm\": 0.02, \"color\": \"#000000\" },\n * \"hiddenLines\": { \"widthMm\": 0.005, \"color\": \"#9ca3af\", \"dash\": \"4 2\" }\n * }\n * ```\n */\nexport interface ViewportLineStyles {\n /** Fallback style for any category not explicitly listed. */\n default?: ViewportLineStyle;\n cutLines?: ViewportLineStyle;\n visibleLines?: ViewportLineStyle;\n hiddenLines?: ViewportLineStyle;\n silhouettes?: ViewportLineStyle;\n featureEdges?: ViewportLineStyle;\n stairArrows?: ViewportLineStyle;\n outlineVisible?: ViewportLineStyle;\n outlineHidden?: ViewportLineStyle;\n}\n\n/**\n * Include filter for viewport geometry.\n *\n * Can be:\n * - String or string array: class names only\n * - Object with class + where: property-based filtering\n * - Preset reference: { preset: \"presetName\" }\n *\n * Examples:\n * ```json\n * \"includeClasses\": [\"space\", \"walls\"]\n * \"includeClasses\": [{ \"class\": \"space\", \"where\": { \"BIP.spacetype\": \"ROOM\" } }]\n * \"includeClasses\": { \"preset\": \"defaultBuilding\" }\n * ```\n */\nexport type IncludeClassesFilter =\n | string\n | string[]\n | { class?: string | string[]; where?: WhereCondition }\n | { preset: string };\n\n/**\n * Resolved include filter (after preset expansion).\n * Either a simple class name or a class+where filter.\n */\nexport type ResolvedIncludeFilter = string | { class?: string | string[]; where: WhereCondition };\n\nexport interface ViewportElement extends BaseElement {\n kind: 'viewport';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n scaleMode?: 'fit' | 'fitAndRound' | 'fixed';\n fixedScaleDenom?: number;\n preferredScales?: number[];\n scalePreset?: string;\n align?: 'center' | 'topLeft';\n rotationDeg?: number;\n includeClasses?: IncludeClassesFilter | IncludeClassesFilter[];\n /**\n * Per-category line styles. When set, overrides `lineWidthMm`/`lineColor`.\n * Use `lineStyles.default` for a single style across all categories,\n * or specify individual categories (cutLines, hiddenLines, etc.).\n */\n lineStyles?: ViewportLineStyles;\n /** Simple shorthand: default line width for all categories. Overridden by `lineStyles`. */\n lineWidthMm?: number;\n /** Simple shorthand: default line color for all categories. Overridden by `lineStyles`. */\n lineColor?: string;\n /**\n * Fill rules controlling which products get filled polygons.\n * When absent, no fills are rendered (default: no fill).\n */\n fills?: FillRule[];\n northArrow?: { assetId: string; sizeMm?: number; offsetXMm?: number; offsetYMm?: number; rotationDeg?: number };\n border?: { stroke?: string; strokeWidthMm?: number; dashed?: boolean };\n clip?: ClipConfig;\n highlight?: HighlightConfig;\n\n // Section configuration (overrides app defaults if specified)\n /**\n * Override cutting plane height for horizontal plans (Y coordinate).\n * If omitted, uses app default. Shorthand for planeNormal=[0,1,0], planePosition=cutHeight.\n */\n cutHeight?: number;\n /**\n * Override depth above/below cutting plane. If omitted, uses app default.\n * Only applicable for SLAB mode (PLANE mode doesn't use depth).\n */\n depth?: { above?: number; below?: number };\n /**\n * Plane normal vector [x, y, z]. Automatically normalized.\n * Takes precedence over cutHeight if both are specified.\n * Examples:\n * - [1, 0, 0] = vertical section perpendicular to X axis\n * - [0, 1, 0] = horizontal plan (same as using cutHeight)\n * - [0, 0, 1] = vertical section perpendicular to Z axis\n * - [1, 0, 1] = diagonal section (will be normalized)\n */\n planeNormal?: [number, number, number];\n /**\n * Distance from origin along the (normalized) plane normal.\n * Used with planeNormal to define the cutting plane.\n * The plane passes through the point: normalize(planeNormal) * planePosition.\n */\n planePosition?: number;\n /**\n * Section computation mode: 'slab' or 'plane'.\n * - 'slab': Optimized for horizontal floor plans. Uses depth above/below to include geometry.\n * - 'plane': Arbitrary plane cuts (vertical sections, diagonal sections). Computes exact intersection.\n *\n * If omitted, mode is auto-detected from plane orientation:\n * - Horizontal planes (planeNormal ≈ Y-axis) → 'slab'\n * - Vertical or diagonal planes → 'plane'\n */\n mode?: 'slab' | 'plane';\n}\n\nexport interface TextElement extends BaseElement {\n kind: 'text';\n xMm: number;\n yMm: number;\n textStyle?: string;\n text: string;\n maxWidthMm?: number;\n align?: 'left' | 'center' | 'right';\n}\n\nexport interface ImageElement extends BaseElement {\n kind: 'image';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n assetId: string;\n fit?: 'contain' | 'cover' | 'stretch';\n}\n\nexport interface LineElement extends BaseElement {\n kind: 'line';\n x1Mm: number;\n y1Mm: number;\n x2Mm: number;\n y2Mm: number;\n stroke?: string;\n strokeWidthMm?: number;\n dashed?: boolean;\n}\n\nexport interface RectElement extends BaseElement {\n kind: 'rect';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n stroke?: string;\n strokeWidthMm?: number;\n fill?: string;\n dashed?: boolean;\n}\n\nexport interface CircleElement extends BaseElement {\n kind: 'circle';\n cxMm: number;\n cyMm: number;\n rMm: number;\n stroke?: string;\n strokeWidthMm?: number;\n fill?: string;\n dashed?: boolean;\n}\n\nexport interface PointMm {\n xMm: number;\n yMm: number;\n}\n\nexport interface PolylineElement extends BaseElement {\n kind: 'polyline';\n points: PointMm[];\n stroke: string;\n strokeWidthMm: number;\n dashed?: boolean;\n}\n\nexport interface PolygonElement extends BaseElement {\n kind: 'polygon';\n points: PointMm[];\n stroke?: string;\n strokeWidthMm?: number;\n fill?: string;\n dashed?: boolean;\n}\n\nexport interface ScaleBarElement extends BaseElement {\n kind: 'scaleBar';\n xMm: number;\n yMm: number;\n maxLengthMm: number;\n unit?: string;\n segments?: number;\n labelEvery?: number;\n stroke?: string;\n strokeWidthMm?: number;\n textStyle?: string;\n viewport?: string;\n}\n\nexport interface QrElement extends BaseElement {\n kind: 'qr';\n xMm: number;\n yMm: number;\n sizeMm: number;\n role?: 'main' | 'anchor' | 'custom';\n anchorCorner?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';\n viewport?: string;\n dataTemplate?: string;\n}\n\nexport interface LabelsElement extends BaseElement {\n kind: 'labels';\n viewport: string;\n class?: string | string[];\n where?: WhereCondition;\n text: string;\n textStyle?: string;\n align?: 'left' | 'center' | 'right';\n maxWidthMm?: number;\n /** When true, only show labels for items whose position is spatially inside the clip polygon.\n * @default false */\n matchClipFilter?: boolean;\n}\n\nexport type LegendAnchor = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';\n\nexport interface LegendColumn {\n id: string;\n label: string;\n property: string;\n format?: { digits?: number; prefix?: string; suffix?: string };\n align?: 'left' | 'center' | 'right';\n minWidthMm?: number;\n maxWidthMm?: number;\n /**\n * Enable summary (total) calculation for this column.\n * When true, the summary row will show the sum of all values in this column.\n * Only works for numerical columns.\n * @default false\n */\n summary?: boolean;\n}\n\nexport interface LegendElement extends BaseElement {\n kind: 'legend';\n viewport: string;\n class?: string | string[];\n where?: WhereCondition;\n clipToViewport?: boolean;\n anchor?: LegendAnchor;\n anchorPositionMm?: { xMm: number; yMm: number };\n marginMm?: number;\n textStyle?: string;\n showColorColumn?: boolean;\n colorColumnWidthMm?: number;\n cellPaddingMm?: number;\n borderStrokeWidthMm?: number;\n borderStrokeColor?: string;\n gridStrokeWidthMm?: number;\n gridStrokeColor?: string;\n headerStrokeWidthMm?: number;\n headerStrokeColor?: string;\n columns: LegendColumn[];\n /**\n * Summary row configuration.\n * Displays a totals row at the bottom of the legend.\n * Columns with `summary: true` will show their sum in the summary row.\n *\n * @example\n * ```json\n * {\n * \"summary\": {\n * \"enabled\": true,\n * \"label\": \"Total\"\n * },\n * \"columns\": [\n * { \"id\": \"name\", \"label\": \"Room\", \"property\": \"BIP.spacename\" },\n * { \"id\": \"area\", \"label\": \"Area\", \"property\": \"BIP.area\", \"summary\": true }\n * ]\n * }\n * ```\n */\n summary?: {\n /** Enable summary row. */\n enabled: boolean;\n /** Label for first column in summary row. Defaults to \"Total\". */\n label?: string;\n };\n /**\n * Group legend rows by a specific column property.\n * When enabled, rows with identical values in the groupBy column are consolidated into a single row.\n * Numerical columns are summed across grouped rows; non-numerical columns take the first value.\n *\n * @example\n * ```json\n * {\n * \"groupBy\": \"BIP.spacename\",\n * \"columns\": [\n * { \"id\": \"name\", \"label\": \"Room\", \"property\": \"BIP.spacename\" },\n * { \"id\": \"area\", \"label\": \"Area\", \"property\": \"BIP.area\", \"format\": { \"digits\": 2 } }\n * ]\n * }\n * ```\n * This groups all rooms with the same name and sums their areas.\n */\n groupBy?: string;\n /**\n * Assign colors to legend rows and apply them to the referenced viewport.\n * When enabled, generates colors for each legend row (or group if groupBy is used).\n * The viewport can use these colors by setting fill: \"legend\" in its fill rules.\n *\n * @example\n * ```json\n * {\n * \"assignColors\": {\n * \"enabled\": true,\n * \"palette\": \"auto\"\n * },\n * \"groupBy\": \"BIP.spacename\"\n * }\n * ```\n * Generates distinct colors for each room type, applied to matching spaces in viewport.\n */\n assignColors?: {\n /** Enable color assignment to viewport items. */\n enabled: boolean;\n /** Color palette: \"auto\" for auto-generated colors, or array of hex colors. */\n palette?: 'auto' | string[];\n };\n}\n\nexport interface GroupTransform {\n translateXMm?: number;\n translateYMm?: number;\n rotateDeg?: number;\n scaleX?: number;\n scaleY?: number;\n}\n\nexport interface GroupClipRect {\n type: 'rect';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n}\n\nexport interface GroupElement extends BaseElement {\n kind: 'group';\n opacity?: number;\n transform?: GroupTransform;\n clip?: GroupClipRect;\n children: LayoutElement[];\n}\n\n/**\n * Template variable definition.\n *\n * Variables allow templates to be parameterized and reused with different values.\n * All variables MUST have a default value to ensure templates work without user input.\n *\n * Variables are referenced in templates using {{vars.variableName}} syntax.\n *\n * Example:\n * ```json\n * {\n * \"variables\": {\n * \"hyresobjektsnummer\": {\n * \"type\": \"string\",\n * \"default\": \"2022-F2008\",\n * \"label\": \"Hyresobjekt Number\",\n * \"description\": \"The rental object identifier\"\n * }\n * },\n * \"elements\": [\n * {\n * \"kind\": \"text\",\n * \"text\": \"Hyresobjekt: {{vars.hyresobjektsnummer}}\"\n * }\n * ]\n * }\n * ```\n */\nexport interface TemplateVariableDef {\n /** Variable type. Determines validation and UI control type. */\n type: 'string' | 'number' | 'boolean' | 'array';\n\n /**\n * Default value for this variable.\n * REQUIRED - ensures template always works even without user input.\n * Must match the specified type.\n */\n default: any;\n\n /** Human-readable label for UI generation. Defaults to variable name. */\n label?: string;\n\n /** Description/help text for UI generation. */\n description?: string;\n\n /**\n * Semantic format hint for UI generation.\n * Provides additional context for rendering appropriate controls.\n *\n * - `color`: Renders color picker (for type: 'string')\n * - `email`: Renders email input with validation (for type: 'string')\n * - `url`: Renders URL input with validation (for type: 'string')\n * - `date`: Renders date picker (for type: 'string')\n *\n * @example\n * ```json\n * {\n * \"lineColor\": {\n * \"type\": \"string\",\n * \"format\": \"color\",\n * \"default\": \"#1f2937\"\n * }\n * }\n * ```\n */\n format?: 'color' | 'email' | 'url' | 'date';\n\n // String validation\n /** Minimum string length (for type: 'string'). */\n minLength?: number;\n /** Maximum string length (for type: 'string'). */\n maxLength?: number;\n /** Regex pattern for validation (for type: 'string'). */\n pattern?: string;\n /** Allowed values (dropdown options). */\n enum?: string[];\n\n // Number validation\n /** Minimum value (for type: 'number'). */\n min?: number;\n /** Maximum value (for type: 'number'). */\n max?: number;\n /** Step size for UI controls (for type: 'number'). */\n step?: number;\n\n // Array validation\n /** Array item specification (for type: 'array'). */\n items?: {\n type: 'string' | 'number';\n enum?: any[];\n };\n}\n\n/**\n * Variable information extracted from template for UI generation.\n */\nexport interface TemplateVariableInfo {\n name: string;\n type: 'string' | 'number' | 'boolean' | 'array';\n default: any;\n label: string;\n description?: string;\n format?: 'color' | 'email' | 'url' | 'date';\n min?: number;\n max?: number;\n step?: number;\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n enum?: any[];\n items?: {\n type: 'string' | 'number';\n enum?: any[];\n };\n}\n\nexport interface LayoutTemplate {\n /** JSON Schema reference for editor autocompletion. Ignored at runtime. */\n $schema?: string;\n id?: string;\n\n /**\n * Template variables for parameterization.\n *\n * Variables allow templates to be reused with different values.\n * All variables MUST have defaults - templates work without user input.\n * Reference variables in template using {{vars.variableName}} syntax.\n *\n * Optional - templates without variables work as before (backward compatible).\n */\n variables?: Record<string, TemplateVariableDef>;\n\n page: PageSpec;\n styles?: StyleMap;\n assets?: AssetSpec[];\n elements: LayoutElement[];\n presets?: {\n includeClasses?: Record<string, string[]>;\n scales?: Record<string, { preferredScales?: number[] }>;\n };\n /** Allow fetching remote assets (images, fonts). Default: false. */\n allowRemoteAssets?: boolean;\n}\n\nexport interface ModelMetadataEntry {\n productId?: string;\n ifcClass?: string;\n properties?: any;\n [key: string]: any;\n}\n\nexport type ModelMetadata = Record<string, ModelMetadataEntry>;\n\nexport interface ProductFieldPaths {\n idPath?: string;\n namePath?: string;\n areaPath?: string;\n classPath?: string;\n}\n\nexport interface NormalizedProductItem {\n gid?: string;\n /** IfcClassType category (e.g. \"space\", \"walls\"). Used for template class filters. */\n ifcClass?: string | null;\n /** PredefinedIfcClassId (e.g. \"IfcSpace\", \"IfcWall\"). Used as fallback for class matching. */\n ifcClassId?: string | null;\n propertySets: Record<string, Record<string, { value: any; unit?: string; type?: string }>>;\n productId: string;\n productName: string;\n area: number | null;\n x?: number | null;\n z?: number | null;\n polylines?: Array<{ points?: Array<{ x: number; z: number }> }>;\n [key: string]: any;\n}\n\nexport type SectionStateValidationResult =\n | { ok: true }\n | {\n ok: false;\n errors: string[];\n };\n\nexport interface LabelStyle {\n /** Text fill color. Default: \"#374151\" */\n fill?: string;\n /** Font family. Default: '\"Segoe UI\", \"Helvetica Neue\", Arial, sans-serif' */\n fontFamily?: string;\n /** Font weight. Default: \"300\" */\n fontWeight?: string;\n}\n\nexport interface SvgModelView {\n groupSvg: string;\n widthModel: number;\n heightModel: number;\n geometryTransform?: string;\n transform?: {\n viewMinX: number;\n viewMaxX: number;\n viewMinZ: number;\n viewMaxZ: number;\n viewWidth: number;\n viewHeight: number;\n };\n rawPaths?: SectionPath[];\n rawLabels?: SectionLabel[];\n labelStyle?: LabelStyle;\n}\n\nexport type ModelContext = Record<string, SvgModelView>;\nexport type LayoutData = Record<string, any>;\nexport type ViewportItemsMap = Record<string, { items: NormalizedProductItem[] }>;\nexport type LayoutDataViewports = { viewports: ViewportItemsMap } & Record<string, any>;\n\nexport interface ValidationOptions {\n allowRemoteAssets?: boolean;\n allowDataUrls?: boolean;\n maxViewports?: number;\n}\n\nexport interface ValidationIssue {\n path: string;\n message: string;\n}\n\nexport type ValidationResult = { ok: true; template: any } | { ok: false; errors: ValidationIssue[] };\n\nexport interface ComputedViewportScale {\n denom: number;\n mmPerModelUnit: number;\n fits: boolean;\n}\n\nexport interface SectionResult {\n perProduct: Array<{\n product: any;\n segments: Array<[any, any]>;\n polylines: Array<{ points: any[]; closed: boolean }>;\n }>;\n}\n\nexport interface RenderDrawingInput {\n template: LayoutTemplate;\n /**\n * Section geometry to render.\n *\n * - Pass a single `SectionResult` to use the same geometry for every viewport.\n * - Pass a `Record<string, SectionResult>` keyed by viewport ID for per-viewport control.\n *\n * Either `sections` or `models` must be provided. When `models` is provided,\n * `sections` is ignored and the pre-built SvgModelViews are used directly.\n */\n sections?: SectionResult | Record<string, SectionResult>;\n /**\n * Pre-built model views keyed by viewport ID.\n *\n * Use this when geometry comes from a source other than `computePlaneSection`\n * (e.g. SlabSection). The caller is responsible for producing `SvgModelView`\n * objects; `renderDrawing` will pass them straight to `renderLayout`.\n */\n models?: ModelContext;\n options?: {\n allowRemoteAssets?: boolean;\n qrContext?: {\n host?: string | null;\n containerName?: string | null;\n floorName?: string | null;\n planeHeight?: number | null;\n };\n /**\n * Embed room labels directly in the section SVG.\n *\n * Only use this when the template does NOT have its own `labels` elements,\n * otherwise you will get duplicate labels. When omitted, renderDrawing\n * auto-detects template `labels` elements and skips embedding.\n */\n roomLabels?: {\n /** Dot-separated path to the label text under product.properties.data. */\n labelPath: string;\n /** IFC class name filter (e.g. \"space\"). If omitted, all entries are included. */\n classFilter?: string;\n };\n /**\n * Raw per-product entries for automatic item building when using `models`.\n *\n * Each entry needs a `product` (BIM object with gid, name, class, properties)\n * and `polylines` (for centroid computation and fill polygon rendering).\n *\n * When provided, renderDrawing builds NormalizedProductItems per viewport,\n * resolving fill colors from each viewport's fill rules. This replaces\n * manual item construction in consumer code.\n *\n * Ignored when `viewportItems` is also provided (explicit items take priority).\n */\n productEntries?: Array<{\n product: unknown;\n polylines: Array<{ points: Array<{ x: number; z: number }> }>;\n }>;\n /**\n * Pre-built product items when `models` is provided directly.\n * Keyed by viewport ID, each containing an array of NormalizedProductItems.\n * Used for legends, labels, and other template elements that need item data.\n *\n * Takes priority over `productEntries` when both are provided.\n */\n viewportItems?: Record<string, { items: NormalizedProductItem[] }>;\n /**\n * App default section settings. Used as fallback when viewports don't specify\n * their own cutHeight/depth configuration.\n */\n sectionDefaults?: {\n cutHeight?: number;\n depth?: { above?: number; below?: number };\n };\n /**\n * Template variable values.\n *\n * When template defines `variables`, provide values here to customize the output.\n * Missing values automatically use defaults from template (fail-safe).\n * Invalid values fall back to defaults with warnings.\n *\n * Optional - if not provided, all template defaults are used.\n *\n * @example\n * ```typescript\n * await renderDrawing({\n * template,\n * models,\n * options: {\n * variables: {\n * hyresobjektsnummer: '2022-F2009',\n * showLegend: true\n * }\n * }\n * });\n * ```\n */\n variables?: Record<string, any>;\n };\n}\n\nexport interface RenderDrawingResult {\n svg: string;\n warnings: string[];\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["layout/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ClassBehaviorRule, SectionPath, SectionLabel } from '@twinfinity/geometry';\n\nexport type PagePresetKey = 'a1' | 'a3' | 'a4';\nexport type PageOrientation = 'portrait' | 'landscape';\n\nexport interface PageSpec {\n widthMm: number;\n heightMm: number;\n marginMm?: number;\n backgroundColor?: string;\n}\n\nexport interface TextStyle {\n fontFamily: string;\n fontSizeMm: number;\n fontWeight?: 'normal' | 'bold' | 'lighter' | 'bolder' | string;\n color?: string;\n letterSpacingMm?: number;\n lineHeightMm?: number;\n}\n\nexport interface StyleMap {\n [styleName: string]: TextStyle;\n}\n\nexport interface ResourceSpec {\n id: string;\n src?: string;\n content?: string;\n}\n\n/**\n * Property-value filter narrowing a set of items *within* a class — the `where`\n * of an include filter, a fill rule or a legend query. Templates use it to pick\n * out \"the IfcSpaces that are apartments\" rather than all IfcSpaces.\n *\n * Each key is a short property path resolved against the item's property sets\n * (e.g. `\"BIP.spacetype\"`; see `resolveProperty`). Each value is either a scalar,\n * matched for equality, or an array, matched as any-of. Multiple keys are ANDed.\n *\n * String comparison on both sides is lowercased and trimmed, so `\"Apartment\"`,\n * `\"apartment\"` and `\" APARTMENT \"` are the same condition. Numbers and booleans\n * compare strictly — a property holding the string `\"3\"` does not match `3`.\n *\n * A key whose path resolves to nothing simply fails to match; it is not an error,\n * so a typo'd path silently selects zero items rather than reporting itself.\n */\nexport type WhereCondition = Record<string, string | number | boolean | Array<string | number>>;\n\n/**\n * A whole-value variable binding, e.g. `\"{{vars.cutHeight}}\"`. On numeric\n * fields that accept it, substitution preserves the variable's type (a\n * number variable produces a number, not a string) — this is how template\n * variables drive section placement.\n */\nexport type VariableBinding = `{{vars.${string}}}`;\n\nexport interface ClipConfig {\n class?: string | string[];\n where: WhereCondition;\n expandBy?: number;\n clipLabels?: boolean;\n /** Outline colour (same vocabulary as viewport lineStyles). */\n color?: string;\n /** Outline width in mm. */\n widthMm?: number;\n /** Outline opacity (0..1). */\n opacity?: number;\n /** SVG stroke-dasharray for the clip outline (e.g. '4 2'). */\n dash?: string;\n fill?: string;\n fillOpacity?: number;\n}\n\n/**\n * Template-driven fill rule for a viewport.\n *\n * Fill rules control which products get filled polygons in the drawing.\n * When no `fills` array is present on a viewport, no fills are rendered.\n *\n * Example:\n * ```json\n * { \"class\": \"space\", \"fill\": \"sample\", \"fillOpacity\": 0.35 }\n * { \"class\": \"walls\", \"fill\": \"#cccccc\", \"fillOpacity\": 0.5 }\n * ```\n */\nexport interface FillRule {\n /** IFC class filter (e.g. \"space\", \"walls\"). Matches ifcClass or ifcClassId. */\n class?: string | string[];\n /** Property-based filter (same as highlight/clip `where`). */\n where?: WhereCondition;\n /** Fill color: CSS hex (e.g. \"#80c8b4\"), \"sample\" to read from 3D model material, or \"legend\" to use colors assigned by legend. */\n fill: string;\n /** Fill opacity (0–1). Default: 0.35. */\n fillOpacity?: number;\n /** When true, only apply fill to items whose centroid is spatially inside the clip polygon.\n * Useful when expandBy reveals adjacent spaces that shouldn't be filled.\n * @default false */\n matchClipFilter?: boolean;\n}\n\nexport interface HighlightConfig {\n class?: string | string[];\n where: WhereCondition;\n /** Only highlight items that also appear in the referenced viewport (i.e., intersect both planes). */\n intersectsViewport?: string;\n /** Outline colour (same vocabulary as viewport lineStyles). */\n color?: string;\n /** Outline width in mm. */\n widthMm?: number;\n /** Outline opacity (0..1). */\n opacity?: number;\n /** SVG stroke-dasharray for highlighted outlines (e.g. '4 2'). */\n dash?: string;\n fill?: string;\n fillOpacity?: number;\n}\n\nexport type LayoutElement =\n | ViewportElement\n | TextElement\n | ImageElement\n | LineElement\n | RectElement\n | CircleElement\n | PolylineElement\n | PolygonElement\n | ScaleBarElement\n | QrElement\n | LabelsElement\n | LegendElement\n | GroupElement;\n\nexport interface BaseElement {\n kind: LayoutElement['kind'];\n id: string;\n zIndex?: number;\n}\n\n/** Style for a single line category in a viewport. */\nexport interface ViewportLineStyle {\n /** Line width in mm. */\n widthMm?: number;\n /** Line color (CSS color string). */\n color?: string;\n /** SVG dash array (e.g. \"4 2\"). */\n dash?: string;\n /** Whether this category is rendered. Default: true. */\n enabled?: boolean;\n}\n\n/**\n * Per-category line styles for a viewport.\n *\n * Resolution order: category-specific → `defaultVisibleLines`/`defaultHiddenLines`\n * (by the category's visibility group) → built-in category defaults → `default`\n * → built-in defaults.\n *\n * Visibility groups: `defaultVisibleLines` covers cutLines, visibleLines,\n * silhouettesVisible, featureEdges and outlineVisible; `defaultHiddenLines`\n * covers hiddenLines, silhouettesHidden and outlineHidden. `stairArrows` is an\n * annotation and belongs to neither group.\n *\n * Example:\n * ```json\n * {\n * \"default\": { \"widthMm\": 0.01, \"color\": \"#1f2937\" },\n * \"defaultVisibleLines\": { \"widthMm\": 0.1, \"color\": \"#000000\" },\n * \"defaultHiddenLines\": { \"widthMm\": 0.05, \"color\": \"#9ca3af\", \"dash\": \"4 2\" },\n * \"cutLines\": { \"widthMm\": 0.2 }\n * }\n * ```\n */\nexport interface ViewportLineStyles {\n /** Fallback style for any category not explicitly listed. */\n default?: ViewportLineStyle;\n /** Group default for all visible-class categories (cutLines, visibleLines, silhouettesVisible, featureEdges, outlineVisible). */\n defaultVisibleLines?: ViewportLineStyle;\n /** Group default for all hidden-class categories (hiddenLines, silhouettesHidden, outlineHidden). */\n defaultHiddenLines?: ViewportLineStyle;\n cutLines?: ViewportLineStyle;\n visibleLines?: ViewportLineStyle;\n hiddenLines?: ViewportLineStyle;\n /** Visible silhouette / apparent-contour traces. */\n silhouettesVisible?: ViewportLineStyle;\n /** Occluded silhouette traces — inherits the hiddenLines group style (dashed). */\n silhouettesHidden?: ViewportLineStyle;\n featureEdges?: ViewportLineStyle;\n stairArrows?: ViewportLineStyle;\n outlineVisible?: ViewportLineStyle;\n outlineHidden?: ViewportLineStyle;\n}\n\n/**\n * Include filter for viewport geometry.\n *\n * Can be:\n * - String or string array: class names only\n * - Object with class + where: property-based filtering, optionally carrying the\n * per-class drawing-generation flags of {@link ClassBehaviorRule} (occludes/classify)\n * - Preset reference: { preset: \"presetName\" }\n *\n * Examples:\n * ```json\n * \"includeClasses\": [\"space\", \"walls\"]\n * \"includeClasses\": [{ \"class\": \"space\", \"where\": { \"BIP.spacetype\": \"ROOM\" } }]\n * \"includeClasses\": { \"preset\": \"defaultBuilding\" }\n * ```\n */\nexport type IncludeClassesFilter =\n | string\n | string[]\n | (Partial<ClassBehaviorRule> & { where?: WhereCondition })\n | { preset: string };\n\n/**\n * Resolved include filter (after preset expansion).\n * Either a simple class name or a class+where filter carrying the per-class\n * drawing-generation flags of {@link ClassBehaviorRule}: `occludes: false` — the\n * class's geometry hides nothing; `classify: false` — its lines skip hidden-line\n * testing and draw as-is. Both default true; the flags a template carries and the\n * flags SlabSection evaluates are the same declaration.\n */\nexport type ResolvedIncludeFilter = string | (Partial<ClassBehaviorRule> & { where?: WhereCondition });\n\nexport interface ViewportElement extends BaseElement {\n kind: 'viewport';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n scaleMode?: 'fit' | 'fitAndRound' | 'fixed';\n fixedScaleDenom?: number;\n preferredScales?: number[];\n scalePreset?: string;\n align?: 'center' | 'topLeft';\n rotationDeg?: number;\n includeClasses?: IncludeClassesFilter | IncludeClassesFilter[];\n /**\n * Per-category line styles. Use `lineStyles.default` for a single style\n * across all categories, or specify individual categories\n * (cutLines, hiddenLines, etc.).\n */\n lineStyles?: ViewportLineStyles;\n /**\n * Fill rules controlling which products get filled polygons.\n * When absent, no fills are rendered (default: no fill).\n */\n fills?: FillRule[];\n northArrow?: { resourceId: string; sizeMm?: number; offsetXMm?: number; offsetYMm?: number; rotationDeg?: number };\n border?: { stroke?: string; strokeWidthMm?: number; dash?: string };\n clip?: ClipConfig;\n highlight?: HighlightConfig;\n\n // Section configuration (overrides app defaults if specified)\n /**\n * Override cutting plane height for horizontal plans (Y coordinate,\n * metres). Shorthand for planeNormal=[0,1,0], planePosition=cutHeight.\n * May be a variable binding (\"{{vars.cutHeight}}\" with a number\n * variable) so end users control the cut through the variables UI.\n */\n cutHeight?: number | VariableBinding;\n /**\n * Override depth above/below cutting plane. If omitted, uses app default.\n * Only applicable for SLAB mode (PLANE mode doesn't use depth).\n */\n depth?: { above?: number; below?: number };\n /**\n * Plane normal vector [x, y, z]. Automatically normalized.\n * Takes precedence over cutHeight if both are specified.\n * Examples:\n * - [1, 0, 0] = vertical section perpendicular to X axis\n * - [0, 1, 0] = horizontal plan (same as using cutHeight)\n * - [0, 0, 1] = vertical section perpendicular to Z axis\n * - [1, 0, 1] = diagonal section (will be normalized)\n */\n planeNormal?: [number, number, number];\n /**\n * Distance from origin along the (normalized) plane normal (metres).\n * Used with planeNormal to define the cutting plane.\n * The plane passes through the point: normalize(planeNormal) * planePosition.\n * May be a variable binding like cutHeight.\n */\n planePosition?: number | VariableBinding;\n /**\n * Stair-arrow geometry options for plan viewports (marker shapes and run\n * sizing). These shape the GENERATED arrow geometry — stroke/color/width\n * and hiding stay with `lineStyles.stairArrows`. Ignored in PLANE mode\n * (elevations generate no stair arrows).\n */\n stairArrows?: ViewportStairArrowOptions;\n}\n\n/**\n * Template surface for `SlabSectionStairArrowOptions` (product-geometry) —\n * kept as its own type so the template schema and the geometry package can\n * evolve independently; renderTemplateSheet forwards field-by-field.\n */\nexport interface ViewportStairArrowOptions {\n /** Marker at the run's bottom end (drawing-convention circle). Default 'filled'. */\n startMarker?: 'filled' | 'open' | 'none';\n /** Arrowhead at the run's top end. Default 'filled' (solid triangle). */\n arrowhead?: 'filled' | 'outline' | 'open';\n /** Fraction of the flight length the arrow occupies. */\n lengthScale?: number;\n /** Minimum arrow length in metres. */\n minLength?: number;\n /** Maximum arrow length in metres. */\n maxLength?: number;\n /** How far the walking line extends onto an un-anchored landing (metres). */\n landingExtension?: number;\n}\n\nexport interface TextElement extends BaseElement {\n kind: 'text';\n xMm: number;\n yMm: number;\n textStyle?: string;\n text: string;\n align?: 'left' | 'center' | 'right';\n}\n\nexport interface ImageElement extends BaseElement {\n kind: 'image';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n resourceId: string;\n fit?: 'contain' | 'cover' | 'stretch';\n}\n\nexport interface LineElement extends BaseElement {\n kind: 'line';\n x1Mm: number;\n y1Mm: number;\n x2Mm: number;\n y2Mm: number;\n stroke?: string;\n strokeWidthMm?: number;\n /** SVG stroke-dasharray in mm, e.g. \"4 2\". */\n dash?: string;\n}\n\nexport interface RectElement extends BaseElement {\n kind: 'rect';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n stroke?: string;\n strokeWidthMm?: number;\n fill?: string;\n /** SVG stroke-dasharray in mm, e.g. \"4 2\". */\n dash?: string;\n}\n\nexport interface CircleElement extends BaseElement {\n kind: 'circle';\n cxMm: number;\n cyMm: number;\n rMm: number;\n stroke?: string;\n strokeWidthMm?: number;\n fill?: string;\n /** SVG stroke-dasharray in mm, e.g. \"4 2\". */\n dash?: string;\n}\n\nexport interface PointMm {\n xMm: number;\n yMm: number;\n}\n\nexport interface PolylineElement extends BaseElement {\n kind: 'polyline';\n points: PointMm[];\n stroke: string;\n strokeWidthMm: number;\n /** SVG stroke-dasharray in mm, e.g. \"4 2\". */\n dash?: string;\n}\n\nexport interface PolygonElement extends BaseElement {\n kind: 'polygon';\n points: PointMm[];\n stroke?: string;\n strokeWidthMm?: number;\n fill?: string;\n /** SVG stroke-dasharray in mm, e.g. \"4 2\". */\n dash?: string;\n}\n\nexport interface ScaleBarElement extends BaseElement {\n kind: 'scaleBar';\n xMm: number;\n yMm: number;\n maxLengthMm: number;\n unit?: string;\n segments?: number;\n labelEvery?: number;\n stroke?: string;\n strokeWidthMm?: number;\n textStyle?: string;\n viewport?: string;\n}\n\nexport interface QrElement extends BaseElement {\n kind: 'qr';\n xMm: number;\n yMm: number;\n sizeMm: number;\n role?: 'main' | 'anchor' | 'custom';\n anchorCorner?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';\n viewport?: string;\n dataTemplate?: string;\n}\n\nexport interface LabelsElement extends BaseElement {\n kind: 'labels';\n viewport: string;\n class?: string | string[];\n where?: WhereCondition;\n text: string;\n textStyle?: string;\n align?: 'left' | 'center' | 'right';\n /** When true, only show labels for items whose position is spatially inside the clip polygon.\n * @default false */\n matchClipFilter?: boolean;\n}\n\nexport type LegendAnchor = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';\n\n/** Table line style — same stroke vocabulary as shape elements. */\nexport interface LegendLineStyle {\n stroke?: string;\n strokeWidthMm?: number;\n}\n\nexport interface LegendColumn {\n id: string;\n label: string;\n property: string;\n format?: { digits?: number; prefix?: string; suffix?: string };\n align?: 'left' | 'center' | 'right';\n minWidthMm?: number;\n maxWidthMm?: number;\n /**\n * Enable summary (total) calculation for this column.\n * When true, the summary row will show the sum of all values in this column.\n * Only works for numerical columns.\n * @default false\n */\n summary?: boolean;\n}\n\nexport interface LegendElement extends BaseElement {\n kind: 'legend';\n viewport: string;\n class?: string | string[];\n where?: WhereCondition;\n clipToViewport?: boolean;\n anchor?: LegendAnchor;\n anchorPositionMm?: { xMm: number; yMm: number };\n marginMm?: number;\n textStyle?: string;\n showColorColumn?: boolean;\n colorColumnWidthMm?: number;\n cellPaddingMm?: number;\n /** Outer table border — same vocabulary as the viewport border. */\n border?: LegendLineStyle;\n /** Inner grid lines between rows/columns. */\n grid?: LegendLineStyle;\n /** Header separator (and summary separator) line. */\n header?: LegendLineStyle;\n columns: LegendColumn[];\n /**\n * Summary row configuration.\n * Displays a totals row at the bottom of the legend.\n * Columns with `summary: true` will show their sum in the summary row.\n *\n * @example\n * ```json\n * {\n * \"summary\": {\n * \"enabled\": true,\n * \"label\": \"Total\"\n * },\n * \"columns\": [\n * { \"id\": \"name\", \"label\": \"Room\", \"property\": \"BIP.spacename\" },\n * { \"id\": \"area\", \"label\": \"Area\", \"property\": \"BIP.area\", \"summary\": true }\n * ]\n * }\n * ```\n */\n summary?: {\n /** Enable summary row. */\n enabled: boolean;\n /** Label for first column in summary row. Defaults to \"Total\". */\n label?: string;\n };\n /**\n * Group legend rows by a specific column property.\n * When enabled, rows with identical values in the groupBy column are consolidated into a single row.\n * Numerical columns are summed across grouped rows; non-numerical columns take the first value.\n *\n * @example\n * ```json\n * {\n * \"groupBy\": \"BIP.spacename\",\n * \"columns\": [\n * { \"id\": \"name\", \"label\": \"Room\", \"property\": \"BIP.spacename\" },\n * { \"id\": \"area\", \"label\": \"Area\", \"property\": \"BIP.area\", \"format\": { \"digits\": 2 } }\n * ]\n * }\n * ```\n * This groups all rooms with the same name and sums their areas.\n */\n groupBy?: string;\n /**\n * Assign colors to legend rows and apply them to the referenced viewport.\n * When enabled, generates colors for each legend row (or group if groupBy is used).\n * The viewport can use these colors by setting fill: \"legend\" in its fill rules.\n *\n * @example\n * ```json\n * {\n * \"assignColors\": {\n * \"enabled\": true,\n * \"palette\": \"auto\"\n * },\n * \"groupBy\": \"BIP.spacename\"\n * }\n * ```\n * Generates distinct colors for each room type, applied to matching spaces in viewport.\n */\n assignColors?: {\n /** Enable color assignment to viewport items. */\n enabled: boolean;\n /** Color palette: \"auto\" for auto-generated colors, or array of hex colors. */\n palette?: 'auto' | string[];\n };\n}\n\nexport interface GroupTransform {\n translateXMm?: number;\n translateYMm?: number;\n rotateDeg?: number;\n scaleX?: number;\n scaleY?: number;\n}\n\nexport interface GroupClipRect {\n type: 'rect';\n xMm: number;\n yMm: number;\n widthMm: number;\n heightMm: number;\n}\n\nexport interface GroupElement extends BaseElement {\n kind: 'group';\n opacity?: number;\n transform?: GroupTransform;\n clip?: GroupClipRect;\n children: LayoutElement[];\n}\n\n/**\n * Template variable definition.\n *\n * Variables allow templates to be parameterized and reused with different values.\n * All variables MUST have a default value to ensure templates work without user input.\n *\n * Variables are referenced in templates using {{vars.variableName}} syntax.\n *\n * Example:\n * ```json\n * {\n * \"variables\": {\n * \"hyresobjektsnummer\": {\n * \"type\": \"string\",\n * \"default\": \"2022-F2008\",\n * \"label\": \"Hyresobjekt Number\",\n * \"description\": \"The rental object identifier\"\n * }\n * },\n * \"elements\": [\n * {\n * \"kind\": \"text\",\n * \"text\": \"Hyresobjekt: {{vars.hyresobjektsnummer}}\"\n * }\n * ]\n * }\n * ```\n */\nexport interface TemplateVariableDef {\n /** Variable type. Determines validation and UI control type. */\n type: 'string' | 'number' | 'boolean' | 'array';\n\n /**\n * Default value for this variable.\n * REQUIRED - ensures template always works even without user input.\n * Must match the specified type.\n */\n default: any;\n\n /** Human-readable label for UI generation. Defaults to variable name. */\n label?: string;\n\n /** Description/help text for UI generation. */\n description?: string;\n\n /**\n * Semantic format hint for UI generation.\n * Provides additional context for rendering appropriate controls.\n *\n * - `color`: Renders color picker (for type: 'string')\n * - `email`: Renders email input with validation (for type: 'string')\n * - `url`: Renders URL input with validation (for type: 'string')\n * - `date`: Renders date picker (for type: 'string')\n *\n * @example\n * ```json\n * {\n * \"lineColor\": {\n * \"type\": \"string\",\n * \"format\": \"color\",\n * \"default\": \"#1f2937\"\n * }\n * }\n * ```\n */\n format?: 'color' | 'email' | 'url' | 'date';\n\n // String validation\n /** Minimum string length (for type: 'string'). */\n minLength?: number;\n /** Maximum string length (for type: 'string'). */\n maxLength?: number;\n /** Regex pattern for validation (for type: 'string'). */\n pattern?: string;\n /** Allowed values (dropdown options). */\n enum?: string[];\n\n // Number validation\n /** Minimum value (for type: 'number'). */\n min?: number;\n /** Maximum value (for type: 'number'). */\n max?: number;\n /** Step size for UI controls (for type: 'number'). */\n step?: number;\n\n // Array validation\n /** Array item specification (for type: 'array'). */\n items?: {\n type: 'string' | 'number';\n enum?: any[];\n };\n}\n\n/**\n * Variable information extracted from template for UI generation.\n */\nexport interface TemplateVariableInfo {\n name: string;\n type: 'string' | 'number' | 'boolean' | 'array';\n default: any;\n label: string;\n description?: string;\n format?: 'color' | 'email' | 'url' | 'date';\n min?: number;\n max?: number;\n step?: number;\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n enum?: any[];\n items?: {\n type: 'string' | 'number';\n enum?: any[];\n };\n}\n\nexport interface LayoutTemplate {\n /** JSON Schema reference for editor autocompletion. Ignored at runtime. */\n $schema?: string;\n id?: string;\n\n /**\n * Template variables for parameterization.\n *\n * Variables allow templates to be reused with different values.\n * All variables MUST have defaults - templates work without user input.\n * Reference variables in template using {{vars.variableName}} syntax.\n *\n * Optional - templates without variables work as before (backward compatible).\n */\n variables?: Record<string, TemplateVariableDef>;\n\n page: PageSpec;\n styles?: StyleMap;\n resources?: ResourceSpec[];\n elements: LayoutElement[];\n presets?: {\n includeClasses?: Record<string, string[]>;\n scales?: Record<string, { preferredScales?: number[] }>;\n };\n /** Allow fetching remote resources (images, fonts). Default: false. */\n allowRemoteResources?: boolean;\n}\n\nexport interface ModelMetadataEntry {\n productId?: string;\n ifcClass?: string;\n properties?: any;\n [key: string]: any;\n}\n\nexport type ModelMetadata = Record<string, ModelMetadataEntry>;\n\nexport interface ProductFieldPaths {\n idPath?: string;\n namePath?: string;\n areaPath?: string;\n classPath?: string;\n}\n\nexport interface NormalizedProductItem {\n gid?: string;\n /** IfcClassType category (e.g. \"space\", \"walls\"). Used for template class filters. */\n ifcClass?: string | null;\n /** PredefinedIfcClassId (e.g. \"IfcSpace\", \"IfcWall\"). Used as fallback for class matching. */\n ifcClassId?: string | null;\n propertySets: Record<string, Record<string, { value: any; unit?: string; type?: string }>>;\n productId: string;\n productName: string;\n area: number | null;\n x?: number | null;\n z?: number | null;\n polylines?: Array<{ points?: Array<{ x: number; z: number }> }>;\n [key: string]: any;\n}\n\nexport type SectionStateValidationResult =\n | { ok: true }\n | {\n ok: false;\n errors: string[];\n };\n\nexport interface LabelStyle {\n /** Text fill color. Default: \"#374151\" */\n fill?: string;\n /** Font family. Default: '\"Segoe UI\", \"Helvetica Neue\", Arial, sans-serif' */\n fontFamily?: string;\n /** Font weight. Default: \"300\" */\n fontWeight?: string;\n}\n\nexport interface SvgModelView {\n groupSvg: string;\n widthModel: number;\n heightModel: number;\n geometryTransform?: string;\n transform?: {\n viewMinX: number;\n viewMaxX: number;\n viewMinZ: number;\n viewMaxZ: number;\n viewWidth: number;\n viewHeight: number;\n };\n rawPaths?: SectionPath[];\n rawLabels?: SectionLabel[];\n labelStyle?: LabelStyle;\n}\n\nexport type ModelContext = Record<string, SvgModelView>;\nexport type LayoutData = Record<string, any>;\nexport type ViewportItemsMap = Record<string, { items: NormalizedProductItem[] }>;\nexport type LayoutDataViewports = { viewports: ViewportItemsMap } & Record<string, any>;\n\nexport interface ValidationOptions {\n allowRemoteResources?: boolean;\n allowDataUrls?: boolean;\n maxViewports?: number;\n /**\n * Treat an `image.resourceId` that names no declared resource as an error. Off by default:\n * `renderLayout` throws on validation errors, so switching this on mid-render turns one missing\n * logo into no print at all. Authoring tools want it on; rendering paths do not.\n */\n strictResourceRefs?: boolean;\n}\n\nexport interface ValidationIssue {\n path: string;\n message: string;\n}\n\nexport type ValidationResult = { ok: true; template: any } | { ok: false; errors: ValidationIssue[] };\n\nexport interface ComputedViewportScale {\n denom: number;\n mmPerModelUnit: number;\n fits: boolean;\n}\n\nexport interface SectionResult {\n perProduct: Array<{\n product: any;\n segments: Array<[any, any]>;\n polylines: Array<{ points: any[]; closed: boolean }>;\n }>;\n}\n\nexport interface RenderDrawingInput {\n template: LayoutTemplate;\n /**\n * Section geometry to render.\n *\n * - Pass a single `SectionResult` to use the same geometry for every viewport.\n * - Pass a `Record<string, SectionResult>` keyed by viewport ID for per-viewport control.\n *\n * Either `sections` or `models` must be provided. When `models` is provided,\n * `sections` is ignored and the pre-built SvgModelViews are used directly.\n */\n sections?: SectionResult | Record<string, SectionResult>;\n /**\n * Pre-built model views keyed by viewport ID.\n *\n * Use this when geometry comes from a source other than `computePlaneSection`\n * (e.g. SlabSection). The caller is responsible for producing `SvgModelView`\n * objects; `renderDrawing` will pass them straight to `renderLayout`.\n */\n models?: ModelContext;\n options?: {\n allowRemoteResources?: boolean;\n qrContext?: {\n host?: string | null;\n containerName?: string | null;\n floorName?: string | null;\n planeHeight?: number | null;\n };\n /**\n * Embed room labels directly in the section SVG.\n *\n * Only use this when the template does NOT have its own `labels` elements,\n * otherwise you will get duplicate labels. When omitted, renderDrawing\n * auto-detects template `labels` elements and skips embedding.\n */\n roomLabels?: {\n /** Dot-separated path to the label text under product.properties.data. */\n labelPath: string;\n /** IFC class name filter (e.g. \"space\"). If omitted, all entries are included. */\n classFilter?: string;\n };\n /**\n * Raw per-product entries for automatic item building when using `models`.\n *\n * Each entry needs a `product` (BIM object with gid, name, class, properties)\n * and `polylines` (for centroid computation and fill polygon rendering).\n * Either one flat list applied to every viewport, or a record keyed by\n * viewport id when viewports show different cuts.\n *\n * When provided, renderDrawing builds NormalizedProductItems per viewport,\n * resolving fill colors from each viewport's fill rules. This replaces\n * manual item construction in consumer code.\n *\n * Ignored when `viewportItems` is also provided (explicit items take priority).\n */\n productEntries?: ProductPolylineEntry[] | Record<string, ProductPolylineEntry[]>;\n /**\n * Pre-built product items when `models` is provided directly.\n * Keyed by viewport ID, each containing an array of NormalizedProductItems.\n * Used for legends, labels, and other template elements that need item data.\n *\n * Takes priority over `productEntries` when both are provided.\n */\n viewportItems?: Record<string, { items: NormalizedProductItem[] }>;\n /**\n * gid → class/property metadata for products beyond the entry lists. Entries\n * only cover cut-bearing products, but render-time includeClasses filtering\n * must classify every product with drawable lines — without this map, products\n * whose geometry never crosses the cut (furniture below a plan cut) lose their\n * visible/hidden lines. Entry-derived metadata overrides on shared gids.\n */\n metadataById?: ModelMetadata;\n /**\n * Template variable values.\n *\n * When template defines `variables`, provide values here to customize the output.\n * Missing values automatically use defaults from template (fail-safe).\n * Invalid values fall back to defaults with warnings.\n *\n * Optional - if not provided, all template defaults are used.\n *\n * @example\n * ```typescript\n * await renderDrawing({\n * template,\n * models,\n * options: {\n * variables: {\n * hyresobjektsnummer: '2022-F2009',\n * showLegend: true\n * }\n * }\n * });\n * ```\n */\n variables?: Record<string, any>;\n };\n}\n\n/** Raw per-product item-data entry: the product plus its cut polylines in world x/z. */\nexport interface ProductPolylineEntry {\n product: unknown;\n polylines: Array<{ points: Array<{ x: number; z: number }> }>;\n}\n\nexport interface RenderDrawingResult {\n svg: string;\n warnings: string[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"/","sources":["layout/validation.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpF,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAErE;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAkXvG"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"/","sources":["layout/validation.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpF,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAErE;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAibvG"}
@@ -1,18 +1,22 @@
1
1
  import { isNonEmptyString, isPositiveNumber, isRemoteUrl, isDataUrl } from './validationUtils';
2
2
  import { isRecord, getProp } from './validationHelpers';
3
- import { ELEMENT_KIND_VIEWPORT, ELEMENT_KIND_TEXT, ELEMENT_KIND_IMAGE, ELEMENT_KIND_LINE, ELEMENT_KIND_RECT, ELEMENT_KIND_SCALE_BAR, ELEMENT_KIND_QR, ELEMENT_KIND_LABELS, ELEMENT_KIND_LEGEND, ELEMENT_KIND_GROUP } from './elementKinds';
3
+ import { ELEMENT_KIND_VIEWPORT, ELEMENT_KIND_TEXT, ELEMENT_KIND_IMAGE, ELEMENT_KIND_LINE, ELEMENT_KIND_RECT, ELEMENT_KIND_CIRCLE, ELEMENT_KIND_POLYLINE, ELEMENT_KIND_POLYGON, ELEMENT_KIND_SCALE_BAR, ELEMENT_KIND_QR, ELEMENT_KIND_LABELS, ELEMENT_KIND_LEGEND, ELEMENT_KIND_GROUP } from './elementKinds';
4
4
  /**
5
5
  * Lightweight template validation (structure only) for v2 schema.
6
6
  */
7
7
  export function validateLayoutTemplate(template, options) {
8
- const allowRemoteAssets = options?.allowRemoteAssets ?? true;
9
8
  const allowDataUrls = options?.allowDataUrls ?? true;
10
- const maxViewports = options?.maxViewports ?? 3;
9
+ const maxViewports = options?.maxViewports ?? 8;
10
+ const strictResourceRefs = options?.strictResourceRefs ?? false;
11
11
  const errors = [];
12
12
  if (!isRecord(template)) {
13
13
  return { ok: false, errors: [{ path: '', message: 'Template must be an object.' }] };
14
14
  }
15
15
  const t = template;
16
+ // Remote resources are opt-in (matches the schema default and the
17
+ // renderer's warnings): explicit option wins, else the template's own
18
+ // root flag, else disallowed.
19
+ const allowRemoteResources = options?.allowRemoteResources ?? getProp(t, 'allowRemoteResources') === true;
16
20
  const page = getProp(t, 'page');
17
21
  if (!isRecord(page)) {
18
22
  errors.push({ path: 'page', message: 'Page definition is required.' });
@@ -27,41 +31,47 @@ export function validateLayoutTemplate(template, options) {
27
31
  errors.push({ path: 'page.marginMm', message: 'marginMm must be a number when provided.' });
28
32
  }
29
33
  }
30
- const assetIds = new Set();
31
- const assets = getProp(t, 'assets');
32
- if (Array.isArray(assets)) {
33
- assets.forEach((asset, index) => {
34
- if (!isRecord(asset)) {
35
- errors.push({ path: `assets[${index}]`, message: 'Asset must be an object.' });
34
+ const resourceIds = new Set();
35
+ const resources = getProp(t, 'resources');
36
+ if (Array.isArray(resources)) {
37
+ resources.forEach((resource, index) => {
38
+ if (!isRecord(resource)) {
39
+ errors.push({ path: `resources[${index}]`, message: 'Resource must be an object.' });
36
40
  return;
37
41
  }
38
- const id = getProp(asset, 'id');
42
+ const id = getProp(resource, 'id');
39
43
  if (!isNonEmptyString(id)) {
40
- errors.push({ path: `assets[${index}].id`, message: 'Asset id is required.' });
44
+ errors.push({ path: `resources[${index}].id`, message: 'Resource id is required.' });
41
45
  }
42
- else if (assetIds.has(id)) {
43
- errors.push({ path: `assets[${index}].id`, message: 'Duplicate asset id.' });
46
+ else if (resourceIds.has(id)) {
47
+ errors.push({ path: `resources[${index}].id`, message: 'Duplicate resource id.' });
44
48
  }
45
49
  else {
46
- assetIds.add(id);
50
+ resourceIds.add(id);
47
51
  }
48
- const src = getProp(asset, 'src');
49
- const content = getProp(asset, 'content');
52
+ const src = getProp(resource, 'src');
53
+ const content = getProp(resource, 'content');
50
54
  if (!isNonEmptyString(src) && !isNonEmptyString(content)) {
51
- errors.push({ path: `assets[${index}]`, message: 'Asset must have either src or content.' });
55
+ errors.push({ path: `resources[${index}]`, message: 'Resource must have either src or content.' });
52
56
  }
53
57
  if (isNonEmptyString(src)) {
54
- if (isRemoteUrl(src) && !allowRemoteAssets) {
55
- errors.push({ path: `assets[${index}].src`, message: 'Remote URLs are not allowed for assets.' });
58
+ if (isRemoteUrl(src) && !allowRemoteResources) {
59
+ errors.push({
60
+ path: `resources[${index}].src`,
61
+ message: 'Remote URLs are not allowed for resources.'
62
+ });
56
63
  }
57
64
  else if (isDataUrl(src) && !allowDataUrls) {
58
- errors.push({ path: `assets[${index}].src`, message: 'Data URLs are not allowed for assets.' });
65
+ errors.push({
66
+ path: `resources[${index}].src`,
67
+ message: 'Data URLs are not allowed for resources.'
68
+ });
59
69
  }
60
70
  }
61
71
  });
62
72
  }
63
- else if (assets !== undefined) {
64
- errors.push({ path: 'assets', message: 'Assets must be an array when provided.' });
73
+ else if (resources !== undefined) {
74
+ errors.push({ path: 'resources', message: 'Resources must be an array when provided.' });
65
75
  }
66
76
  const styleNames = new Set();
67
77
  const styles = getProp(t, 'styles');
@@ -110,8 +120,8 @@ export function validateLayoutTemplate(template, options) {
110
120
  ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');
111
121
  const xMm = getProp(el, 'xMm');
112
122
  const yMm = getProp(el, 'yMm');
113
- ensure(isPositiveNumber(xMm) || xMm === 0, `${path}.xMm`, 'xMm is required.');
114
- ensure(isPositiveNumber(yMm) || yMm === 0, `${path}.yMm`, 'yMm is required.');
123
+ ensure(typeof xMm === 'number' && Number.isFinite(xMm), `${path}.xMm`, 'xMm is required.');
124
+ ensure(typeof yMm === 'number' && Number.isFinite(yMm), `${path}.yMm`, 'yMm is required.');
115
125
  const border = getProp(el, 'border');
116
126
  if (border) {
117
127
  // border.stroke and border.strokeWidthMm are optional in v2
@@ -140,8 +150,8 @@ export function validateLayoutTemplate(template, options) {
140
150
  else if (kind === ELEMENT_KIND_TEXT) {
141
151
  const xMm = getProp(el, 'xMm');
142
152
  const yMm = getProp(el, 'yMm');
143
- ensure(isPositiveNumber(xMm) || xMm === 0, `${path}.xMm`, 'xMm is required.');
144
- ensure(isPositiveNumber(yMm) || yMm === 0, `${path}.yMm`, 'yMm is required.');
153
+ ensure(typeof xMm === 'number' && Number.isFinite(xMm), `${path}.xMm`, 'xMm is required.');
154
+ ensure(typeof yMm === 'number' && Number.isFinite(yMm), `${path}.yMm`, 'yMm is required.');
145
155
  const textStyle = getProp(el, 'textStyle');
146
156
  if (textStyle !== undefined) {
147
157
  if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {
@@ -156,7 +166,16 @@ export function validateLayoutTemplate(template, options) {
156
166
  else if (kind === ELEMENT_KIND_IMAGE) {
157
167
  ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');
158
168
  ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');
159
- ensure(isNonEmptyString(getProp(el, 'assetId')), `${path}.assetId`, 'assetId is required.');
169
+ const resourceId = getProp(el, 'resourceId');
170
+ ensure(isNonEmptyString(resourceId), `${path}.resourceId`, 'resourceId is required.');
171
+ // Opt-in only. `renderLayout` throws on any validation error, so treating a dangling
172
+ // reference as one turns a template that used to print without a single logo into a
173
+ // template that does not print at all — the renderer already warns and skips that
174
+ // element, which is the better outcome mid-print. Authoring tools that want the typo
175
+ // caught up front can ask for it.
176
+ if (strictResourceRefs && isNonEmptyString(resourceId) && !resourceIds.has(resourceId)) {
177
+ ensure(false, `${path}.resourceId`, `No resource is declared with id '${resourceId}'.`);
178
+ }
160
179
  }
161
180
  else if (kind === ELEMENT_KIND_LINE) {
162
181
  // stroke and strokeWidthMm optional in v2
@@ -165,6 +184,23 @@ export function validateLayoutTemplate(template, options) {
165
184
  ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');
166
185
  ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');
167
186
  }
187
+ else if (kind === ELEMENT_KIND_CIRCLE) {
188
+ ensure(isPositiveNumber(getProp(el, 'rMm')), `${path}.rMm`, 'rMm must be > 0.');
189
+ const cxMm = getProp(el, 'cxMm');
190
+ const cyMm = getProp(el, 'cyMm');
191
+ ensure(typeof cxMm === 'number' && Number.isFinite(cxMm), `${path}.cxMm`, 'cxMm is required.');
192
+ ensure(typeof cyMm === 'number' && Number.isFinite(cyMm), `${path}.cyMm`, 'cyMm is required.');
193
+ }
194
+ else if (kind === ELEMENT_KIND_POLYLINE) {
195
+ const points = getProp(el, 'points');
196
+ ensure(Array.isArray(points) && points.length >= 2, `${path}.points`, 'points is required (at least 2 points).');
197
+ ensure(isNonEmptyString(getProp(el, 'stroke')), `${path}.stroke`, 'stroke is required.');
198
+ ensure(isPositiveNumber(getProp(el, 'strokeWidthMm')), `${path}.strokeWidthMm`, 'strokeWidthMm must be > 0.');
199
+ }
200
+ else if (kind === ELEMENT_KIND_POLYGON) {
201
+ const points = getProp(el, 'points');
202
+ ensure(Array.isArray(points) && points.length >= 3, `${path}.points`, 'points is required (at least 3 points).');
203
+ }
168
204
  else if (kind === ELEMENT_KIND_SCALE_BAR) {
169
205
  ensure(isPositiveNumber(getProp(el, 'maxLengthMm')), `${path}.maxLengthMm`, 'maxLengthMm must be > 0.');
170
206
  const textStyle = getProp(el, 'textStyle');
@@ -181,8 +217,8 @@ export function validateLayoutTemplate(template, options) {
181
217
  ensure(isPositiveNumber(getProp(el, 'sizeMm')), `${path}.sizeMm`, 'sizeMm must be > 0.');
182
218
  const xMm = getProp(el, 'xMm');
183
219
  const yMm = getProp(el, 'yMm');
184
- ensure(isPositiveNumber(xMm) || xMm === 0, `${path}.xMm`, 'xMm is required.');
185
- ensure(isPositiveNumber(yMm) || yMm === 0, `${path}.yMm`, 'yMm is required.');
220
+ ensure(typeof xMm === 'number' && Number.isFinite(xMm), `${path}.xMm`, 'xMm is required.');
221
+ ensure(typeof yMm === 'number' && Number.isFinite(yMm), `${path}.yMm`, 'yMm is required.');
186
222
  }
187
223
  else if (kind === ELEMENT_KIND_LABELS) {
188
224
  ensure(isNonEmptyString(getProp(el, 'viewport')), `${path}.viewport`, 'viewport is required.');
@@ -250,8 +286,8 @@ export function validateLayoutTemplate(template, options) {
250
286
  ensure(isPositiveNumber(getProp(clip, 'heightMm')), `${path}.clip.heightMm`, 'clip.heightMm must be > 0.');
251
287
  const clipXMm = getProp(clip, 'xMm');
252
288
  const clipYMm = getProp(clip, 'yMm');
253
- ensure(isPositiveNumber(clipXMm) || clipXMm === 0, `${path}.clip.xMm`, 'clip.xMm is required.');
254
- ensure(isPositiveNumber(clipYMm) || clipYMm === 0, `${path}.clip.yMm`, 'clip.yMm is required.');
289
+ ensure(typeof clipXMm === 'number' && Number.isFinite(clipXMm), `${path}.clip.xMm`, 'clip.xMm is required.');
290
+ ensure(typeof clipYMm === 'number' && Number.isFinite(clipYMm), `${path}.clip.yMm`, 'clip.yMm is required.');
255
291
  }
256
292
  const children = getProp(el, 'children');
257
293
  if (Array.isArray(children)) {
@@ -266,8 +302,8 @@ export function validateLayoutTemplate(template, options) {
266
302
  if (Array.isArray(elements)) {
267
303
  elements.forEach((el, index) => validateElement(el, `elements[${index}]`));
268
304
  }
269
- else if (elements !== undefined) {
270
- errors.push({ path: 'elements', message: 'Elements must be an array.' });
305
+ else {
306
+ errors.push({ path: 'elements', message: 'elements is required and must be an array.' });
271
307
  }
272
308
  // Validate template variables (if present)
273
309
  const variables = getProp(t, 'variables');
@@ -279,6 +315,15 @@ export function validateLayoutTemplate(template, options) {
279
315
  // Validate each variable definition
280
316
  for (const [varName, varDef] of Object.entries(variables)) {
281
317
  const varPath = `variables.${varName}`;
318
+ // Names are referenced as {{vars.<name>}} — non-identifier
319
+ // names (dashes, dots, spaces) collide with the placeholder
320
+ // syntax and are silently never substituted.
321
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(varName)) {
322
+ errors.push({
323
+ path: varPath,
324
+ message: 'Variable names must be simple identifiers ([A-Za-z_][A-Za-z0-9_]*).'
325
+ });
326
+ }
282
327
  if (!isRecord(varDef)) {
283
328
  errors.push({ path: varPath, message: 'Variable definition must be an object.' });
284
329
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"/","sources":["layout/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACH,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EACrB,MAAM,gBAAgB,CAAC;AAKxB;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAiB,EAAE,OAA2B;IACjF,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,IAAI,CAAC;IAC7D,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,IAAI,CAAC;IACrD,MAAM,YAAY,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CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBACnC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBACnC,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;wBAC/C,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,CAAC;oBAC9E,CAAC;oBACD,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;wBAC/C,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,CAAC;oBAC9E,CAAC;oBACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;wBAClE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC,CAAC;oBACpF,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { isNonEmptyString, isPositiveNumber, isRemoteUrl, isDataUrl } from './validationUtils';\nimport { isRecord, getProp } from './validationHelpers';\nimport {\n ELEMENT_KIND_VIEWPORT,\n ELEMENT_KIND_TEXT,\n ELEMENT_KIND_IMAGE,\n ELEMENT_KIND_LINE,\n ELEMENT_KIND_RECT,\n ELEMENT_KIND_SCALE_BAR,\n ELEMENT_KIND_QR,\n ELEMENT_KIND_LABELS,\n ELEMENT_KIND_LEGEND,\n ELEMENT_KIND_GROUP\n} from './elementKinds';\n\nimport type { ValidationOptions, ValidationIssue, ValidationResult } from './types';\nexport type { ValidationOptions, ValidationIssue, ValidationResult };\n\n/**\n * Lightweight template validation (structure only) for v2 schema.\n */\nexport function validateLayoutTemplate(template: unknown, options?: ValidationOptions): ValidationResult {\n const allowRemoteAssets = options?.allowRemoteAssets ?? true;\n const allowDataUrls = options?.allowDataUrls ?? true;\n const maxViewports = options?.maxViewports ?? 3;\n const errors: ValidationIssue[] = [];\n\n if (!isRecord(template)) {\n return { ok: false, errors: [{ path: '', message: 'Template must be an object.' }] };\n }\n\n const t = template;\n\n const page = getProp(t, 'page');\n if (!isRecord(page)) {\n errors.push({ path: 'page', message: 'Page definition is required.' });\n } else {\n if (!isPositiveNumber(getProp(page, 'widthMm')))\n errors.push({ path: 'page.widthMm', message: 'widthMm must be > 0.' });\n if (!isPositiveNumber(getProp(page, 'heightMm')))\n errors.push({ path: 'page.heightMm', message: 'heightMm must be > 0.' });\n const marginMm = getProp(page, 'marginMm');\n if (marginMm !== undefined && typeof marginMm !== 'number') {\n errors.push({ path: 'page.marginMm', message: 'marginMm must be a number when provided.' });\n }\n }\n\n const assetIds = new Set<string>();\n const assets = getProp(t, 'assets');\n if (Array.isArray(assets)) {\n assets.forEach((asset: unknown, index: number) => {\n if (!isRecord(asset)) {\n errors.push({ path: `assets[${index}]`, message: 'Asset must be an object.' });\n return;\n }\n const id = getProp(asset, 'id');\n if (!isNonEmptyString(id)) {\n errors.push({ path: `assets[${index}].id`, message: 'Asset id is required.' });\n } else if (assetIds.has(id as string)) {\n errors.push({ path: `assets[${index}].id`, message: 'Duplicate asset id.' });\n } else {\n assetIds.add(id as string);\n }\n\n const src = getProp(asset, 'src');\n const content = getProp(asset, 'content');\n if (!isNonEmptyString(src) && !isNonEmptyString(content)) {\n errors.push({ path: `assets[${index}]`, message: 'Asset must have either src or content.' });\n }\n\n if (isNonEmptyString(src)) {\n if (isRemoteUrl(src as string) && !allowRemoteAssets) {\n errors.push({ path: `assets[${index}].src`, message: 'Remote URLs are not allowed for assets.' });\n } else if (isDataUrl(src as string) && !allowDataUrls) {\n errors.push({ path: `assets[${index}].src`, message: 'Data URLs are not allowed for assets.' });\n }\n }\n });\n } else if (assets !== undefined) {\n errors.push({ path: 'assets', message: 'Assets must be an array when provided.' });\n }\n\n const styleNames = new Set<string>();\n const styles = getProp(t, 'styles');\n if (styles !== undefined) {\n if (!isRecord(styles)) {\n errors.push({ path: 'styles', message: 'Styles must be an object map.' });\n } else {\n Object.entries(styles).forEach(([name, style]) => {\n styleNames.add(name);\n if (!isRecord(style)) {\n errors.push({ path: `styles.${name}`, message: 'Style must be an object.' });\n return;\n }\n if (!isNonEmptyString(getProp(style, 'fontFamily'))) {\n errors.push({ path: `styles.${name}.fontFamily`, message: 'fontFamily is required.' });\n }\n if (!isPositiveNumber(getProp(style, 'fontSizeMm'))) {\n errors.push({ path: `styles.${name}.fontSizeMm`, message: 'fontSizeMm must be > 0.' });\n }\n });\n }\n }\n\n let viewportCount = 0;\n\n const validateElement = (el: unknown, path: string): void => {\n if (!isRecord(el)) {\n errors.push({ path, message: 'Element must be an object.' });\n return;\n }\n const kind = getProp(el, 'kind');\n if (!kind || typeof kind !== 'string') {\n errors.push({ path: `${path}.kind`, message: 'Element kind is required.' });\n return;\n }\n\n const ensure = (condition: boolean, subPath: string, message: string): void => {\n if (!condition) errors.push({ path: subPath, message });\n };\n\n ensure(isNonEmptyString(getProp(el, 'id')), `${path}.id`, 'Element id is required.');\n\n if (kind === ELEMENT_KIND_VIEWPORT) {\n viewportCount++;\n if (viewportCount > maxViewports) {\n errors.push({ path, message: 'Too many viewports.' });\n }\n ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');\n ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');\n const xMm = getProp(el, 'xMm');\n const yMm = getProp(el, 'yMm');\n ensure(isPositiveNumber(xMm) || xMm === 0, `${path}.xMm`, 'xMm is required.');\n ensure(isPositiveNumber(yMm) || yMm === 0, `${path}.yMm`, 'yMm is required.');\n const border = getProp(el, 'border');\n if (border) {\n // border.stroke and border.strokeWidthMm are optional in v2\n }\n const clip = getProp(el, 'clip');\n if (clip && isRecord(clip)) {\n const where = getProp(clip, 'where');\n if (!isRecord(where)) {\n errors.push({\n path: `${path}.clip.where`,\n message: 'clip.where is required and must be an object.'\n });\n }\n }\n const highlight = getProp(el, 'highlight');\n if (highlight && isRecord(highlight)) {\n const where = getProp(highlight, 'where');\n if (!isRecord(where)) {\n errors.push({\n path: `${path}.highlight.where`,\n message: 'highlight.where is required and must be an object.'\n });\n }\n }\n } else if (kind === ELEMENT_KIND_TEXT) {\n const xMm = getProp(el, 'xMm');\n const yMm = getProp(el, 'yMm');\n ensure(isPositiveNumber(xMm) || xMm === 0, `${path}.xMm`, 'xMm is required.');\n ensure(isPositiveNumber(yMm) || yMm === 0, `${path}.yMm`, 'yMm is required.');\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n ensure(isNonEmptyString(getProp(el, 'text')), `${path}.text`, 'text is required.');\n } else if (kind === ELEMENT_KIND_IMAGE) {\n ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');\n ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');\n ensure(isNonEmptyString(getProp(el, 'assetId')), `${path}.assetId`, 'assetId is required.');\n } else if (kind === ELEMENT_KIND_LINE) {\n // stroke and strokeWidthMm optional in v2\n } else if (kind === ELEMENT_KIND_RECT) {\n ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');\n ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');\n } else if (kind === ELEMENT_KIND_SCALE_BAR) {\n ensure(isPositiveNumber(getProp(el, 'maxLengthMm')), `${path}.maxLengthMm`, 'maxLengthMm must be > 0.');\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n } else if (kind === ELEMENT_KIND_QR) {\n ensure(isPositiveNumber(getProp(el, 'sizeMm')), `${path}.sizeMm`, 'sizeMm must be > 0.');\n const xMm = getProp(el, 'xMm');\n const yMm = getProp(el, 'yMm');\n ensure(isPositiveNumber(xMm) || xMm === 0, `${path}.xMm`, 'xMm is required.');\n ensure(isPositiveNumber(yMm) || yMm === 0, `${path}.yMm`, 'yMm is required.');\n } else if (kind === ELEMENT_KIND_LABELS) {\n ensure(isNonEmptyString(getProp(el, 'viewport')), `${path}.viewport`, 'viewport is required.');\n ensure(isNonEmptyString(getProp(el, 'text')), `${path}.text`, 'text is required.');\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n } else if (kind === ELEMENT_KIND_LEGEND) {\n ensure(isNonEmptyString(getProp(el, 'viewport')), `${path}.viewport`, 'viewport is required.');\n const columns = getProp(el, 'columns');\n if (!Array.isArray(columns) || !columns.length) {\n errors.push({ path: `${path}.columns`, message: 'columns is required and must be a non-empty array.' });\n } else {\n columns.forEach((col: unknown, idx: number) => {\n if (!isRecord(col)) {\n errors.push({ path: `${path}.columns[${idx}]`, message: 'Column must be an object.' });\n return;\n }\n ensure(\n isNonEmptyString(getProp(col, 'id')),\n `${path}.columns[${idx}].id`,\n 'Column id is required.'\n );\n ensure(\n isNonEmptyString(getProp(col, 'label')),\n `${path}.columns[${idx}].label`,\n 'Column label is required.'\n );\n ensure(\n isNonEmptyString(getProp(col, 'property')),\n `${path}.columns[${idx}].property`,\n 'Column property is required.'\n );\n });\n }\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n const clipToViewport = getProp(el, 'clipToViewport');\n if (clipToViewport !== undefined && typeof clipToViewport !== 'boolean') {\n errors.push({\n path: `${path}.clipToViewport`,\n message: 'clipToViewport must be a boolean when provided.'\n });\n }\n } else if (kind === ELEMENT_KIND_GROUP) {\n const opacity = getProp(el, 'opacity');\n if (opacity !== undefined) {\n ensure(\n typeof opacity === 'number' && opacity >= 0 && opacity <= 1,\n `${path}.opacity`,\n 'opacity must be between 0 and 1.'\n );\n }\n const transform = getProp(el, 'transform');\n if (transform) {\n const scaleX = getProp(transform, 'scaleX');\n const scaleY = getProp(transform, 'scaleY');\n ensure(\n scaleX === undefined || typeof scaleX === 'number',\n `${path}.transform.scaleX`,\n 'scaleX must be a number'\n );\n ensure(\n scaleY === undefined || typeof scaleY === 'number',\n `${path}.transform.scaleY`,\n 'scaleY must be a number'\n );\n }\n const clip = getProp(el, 'clip');\n if (clip) {\n ensure(getProp(clip, 'type') === 'rect', `${path}.clip.type`, \"clip.type must be 'rect'.\");\n ensure(isPositiveNumber(getProp(clip, 'widthMm')), `${path}.clip.widthMm`, 'clip.widthMm must be > 0.');\n ensure(\n isPositiveNumber(getProp(clip, 'heightMm')),\n `${path}.clip.heightMm`,\n 'clip.heightMm must be > 0.'\n );\n const clipXMm = getProp(clip, 'xMm');\n const clipYMm = getProp(clip, 'yMm');\n ensure(isPositiveNumber(clipXMm) || clipXMm === 0, `${path}.clip.xMm`, 'clip.xMm is required.');\n ensure(isPositiveNumber(clipYMm) || clipYMm === 0, `${path}.clip.yMm`, 'clip.yMm is required.');\n }\n const children = getProp(el, 'children');\n if (Array.isArray(children)) {\n children.forEach((child: unknown, childIdx: number) =>\n validateElement(child, `${path}.children[${childIdx}]`)\n );\n }\n } else {\n errors.push({ path, message: `Unknown element kind '${kind}'.` });\n }\n };\n\n const elements = getProp(t, 'elements');\n if (Array.isArray(elements)) {\n elements.forEach((el: unknown, index: number) => validateElement(el, `elements[${index}]`));\n } else if (elements !== undefined) {\n errors.push({ path: 'elements', message: 'Elements must be an array.' });\n }\n\n // Validate template variables (if present)\n const variables = getProp(t, 'variables');\n if (variables !== undefined) {\n if (!isRecord(variables)) {\n errors.push({ path: 'variables', message: 'Variables must be an object.' });\n } else {\n // Validate each variable definition\n for (const [varName, varDef] of Object.entries(variables)) {\n const varPath = `variables.${varName}`;\n\n if (!isRecord(varDef)) {\n errors.push({ path: varPath, message: 'Variable definition must be an object.' });\n continue;\n }\n\n // Validate type\n const varType = getProp(varDef, 'type');\n if (!['string', 'number', 'boolean', 'array'].includes(varType as string)) {\n errors.push({\n path: `${varPath}.type`,\n message: `Type must be 'string', 'number', 'boolean', or 'array' (got '${varType}').`\n });\n }\n\n // Enforce default value (CRITICAL for fail-safe operation)\n const defaultValue = getProp(varDef, 'default');\n if (defaultValue === undefined || defaultValue === null) {\n errors.push({\n path: `${varPath}.default`,\n message: 'Variable must have a default value (required for fail-safe operation).'\n });\n } else {\n // Validate default value matches declared type\n const actualType = Array.isArray(defaultValue) ? 'array' : typeof defaultValue;\n if (varType === 'number' && actualType !== 'number') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be a number (got ${actualType}).`\n });\n } else if (varType === 'string' && actualType !== 'string') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be a string (got ${actualType}).`\n });\n } else if (varType === 'boolean' && actualType !== 'boolean') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be a boolean (got ${actualType}).`\n });\n } else if (varType === 'array' && actualType !== 'array') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be an array (got ${actualType}).`\n });\n }\n }\n\n // Validate numeric constraints (if present)\n if (varType === 'number') {\n const min = getProp(varDef, 'min');\n const max = getProp(varDef, 'max');\n if (min !== undefined && typeof min !== 'number') {\n errors.push({ path: `${varPath}.min`, message: 'min must be a number.' });\n }\n if (max !== undefined && typeof max !== 'number') {\n errors.push({ path: `${varPath}.max`, message: 'max must be a number.' });\n }\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n errors.push({ path: `${varPath}`, message: 'min cannot be greater than max.' });\n }\n }\n }\n }\n }\n\n if (errors.length) {\n return { ok: false, errors };\n }\n\n return { ok: true, template };\n}\n"]}
1
+ {"version":3,"file":"validation.js","sourceRoot":"/","sources":["layout/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACH,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EACrB,MAAM,gBAAgB,CAAC;AAKxB;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAiB,EAAE,OAA2B;IACjF,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,IAAI,CAAC;IACrD,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;IAChD,MAAM,kBAAkB,GAAG,OAAO,EAAE,kBAAkB,IAAI,KAAK,CAAC;IAChE,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtB,OAAO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AAE,IAAI,EAAE,GAAG,OAAO,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,CAAC;oBAC9E,CAAC;oBACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;wBAClE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC,CAAC;oBACpF,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { isNonEmptyString, isPositiveNumber, isRemoteUrl, isDataUrl } from './validationUtils';\nimport { isRecord, getProp } from './validationHelpers';\nimport {\n ELEMENT_KIND_VIEWPORT,\n ELEMENT_KIND_TEXT,\n ELEMENT_KIND_IMAGE,\n ELEMENT_KIND_LINE,\n ELEMENT_KIND_RECT,\n ELEMENT_KIND_CIRCLE,\n ELEMENT_KIND_POLYLINE,\n ELEMENT_KIND_POLYGON,\n ELEMENT_KIND_SCALE_BAR,\n ELEMENT_KIND_QR,\n ELEMENT_KIND_LABELS,\n ELEMENT_KIND_LEGEND,\n ELEMENT_KIND_GROUP\n} from './elementKinds';\n\nimport type { ValidationOptions, ValidationIssue, ValidationResult } from './types';\nexport type { ValidationOptions, ValidationIssue, ValidationResult };\n\n/**\n * Lightweight template validation (structure only) for v2 schema.\n */\nexport function validateLayoutTemplate(template: unknown, options?: ValidationOptions): ValidationResult {\n const allowDataUrls = options?.allowDataUrls ?? true;\n const maxViewports = options?.maxViewports ?? 8;\n const strictResourceRefs = options?.strictResourceRefs ?? false;\n const errors: ValidationIssue[] = [];\n\n if (!isRecord(template)) {\n return { ok: false, errors: [{ path: '', message: 'Template must be an object.' }] };\n }\n\n const t = template;\n // Remote resources are opt-in (matches the schema default and the\n // renderer's warnings): explicit option wins, else the template's own\n // root flag, else disallowed.\n const allowRemoteResources = options?.allowRemoteResources ?? getProp(t, 'allowRemoteResources') === true;\n\n const page = getProp(t, 'page');\n if (!isRecord(page)) {\n errors.push({ path: 'page', message: 'Page definition is required.' });\n } else {\n if (!isPositiveNumber(getProp(page, 'widthMm')))\n errors.push({ path: 'page.widthMm', message: 'widthMm must be > 0.' });\n if (!isPositiveNumber(getProp(page, 'heightMm')))\n errors.push({ path: 'page.heightMm', message: 'heightMm must be > 0.' });\n const marginMm = getProp(page, 'marginMm');\n if (marginMm !== undefined && typeof marginMm !== 'number') {\n errors.push({ path: 'page.marginMm', message: 'marginMm must be a number when provided.' });\n }\n }\n\n const resourceIds = new Set<string>();\n const resources = getProp(t, 'resources');\n if (Array.isArray(resources)) {\n resources.forEach((resource: unknown, index: number) => {\n if (!isRecord(resource)) {\n errors.push({ path: `resources[${index}]`, message: 'Resource must be an object.' });\n return;\n }\n const id = getProp(resource, 'id');\n if (!isNonEmptyString(id)) {\n errors.push({ path: `resources[${index}].id`, message: 'Resource id is required.' });\n } else if (resourceIds.has(id as string)) {\n errors.push({ path: `resources[${index}].id`, message: 'Duplicate resource id.' });\n } else {\n resourceIds.add(id as string);\n }\n\n const src = getProp(resource, 'src');\n const content = getProp(resource, 'content');\n if (!isNonEmptyString(src) && !isNonEmptyString(content)) {\n errors.push({ path: `resources[${index}]`, message: 'Resource must have either src or content.' });\n }\n\n if (isNonEmptyString(src)) {\n if (isRemoteUrl(src as string) && !allowRemoteResources) {\n errors.push({\n path: `resources[${index}].src`,\n message: 'Remote URLs are not allowed for resources.'\n });\n } else if (isDataUrl(src as string) && !allowDataUrls) {\n errors.push({\n path: `resources[${index}].src`,\n message: 'Data URLs are not allowed for resources.'\n });\n }\n }\n });\n } else if (resources !== undefined) {\n errors.push({ path: 'resources', message: 'Resources must be an array when provided.' });\n }\n\n const styleNames = new Set<string>();\n const styles = getProp(t, 'styles');\n if (styles !== undefined) {\n if (!isRecord(styles)) {\n errors.push({ path: 'styles', message: 'Styles must be an object map.' });\n } else {\n Object.entries(styles).forEach(([name, style]) => {\n styleNames.add(name);\n if (!isRecord(style)) {\n errors.push({ path: `styles.${name}`, message: 'Style must be an object.' });\n return;\n }\n if (!isNonEmptyString(getProp(style, 'fontFamily'))) {\n errors.push({ path: `styles.${name}.fontFamily`, message: 'fontFamily is required.' });\n }\n if (!isPositiveNumber(getProp(style, 'fontSizeMm'))) {\n errors.push({ path: `styles.${name}.fontSizeMm`, message: 'fontSizeMm must be > 0.' });\n }\n });\n }\n }\n\n let viewportCount = 0;\n\n const validateElement = (el: unknown, path: string): void => {\n if (!isRecord(el)) {\n errors.push({ path, message: 'Element must be an object.' });\n return;\n }\n const kind = getProp(el, 'kind');\n if (!kind || typeof kind !== 'string') {\n errors.push({ path: `${path}.kind`, message: 'Element kind is required.' });\n return;\n }\n\n const ensure = (condition: boolean, subPath: string, message: string): void => {\n if (!condition) errors.push({ path: subPath, message });\n };\n\n ensure(isNonEmptyString(getProp(el, 'id')), `${path}.id`, 'Element id is required.');\n\n if (kind === ELEMENT_KIND_VIEWPORT) {\n viewportCount++;\n if (viewportCount > maxViewports) {\n errors.push({ path, message: 'Too many viewports.' });\n }\n ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');\n ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');\n const xMm = getProp(el, 'xMm');\n const yMm = getProp(el, 'yMm');\n ensure(typeof xMm === 'number' && Number.isFinite(xMm), `${path}.xMm`, 'xMm is required.');\n ensure(typeof yMm === 'number' && Number.isFinite(yMm), `${path}.yMm`, 'yMm is required.');\n const border = getProp(el, 'border');\n if (border) {\n // border.stroke and border.strokeWidthMm are optional in v2\n }\n const clip = getProp(el, 'clip');\n if (clip && isRecord(clip)) {\n const where = getProp(clip, 'where');\n if (!isRecord(where)) {\n errors.push({\n path: `${path}.clip.where`,\n message: 'clip.where is required and must be an object.'\n });\n }\n }\n const highlight = getProp(el, 'highlight');\n if (highlight && isRecord(highlight)) {\n const where = getProp(highlight, 'where');\n if (!isRecord(where)) {\n errors.push({\n path: `${path}.highlight.where`,\n message: 'highlight.where is required and must be an object.'\n });\n }\n }\n } else if (kind === ELEMENT_KIND_TEXT) {\n const xMm = getProp(el, 'xMm');\n const yMm = getProp(el, 'yMm');\n ensure(typeof xMm === 'number' && Number.isFinite(xMm), `${path}.xMm`, 'xMm is required.');\n ensure(typeof yMm === 'number' && Number.isFinite(yMm), `${path}.yMm`, 'yMm is required.');\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n ensure(isNonEmptyString(getProp(el, 'text')), `${path}.text`, 'text is required.');\n } else if (kind === ELEMENT_KIND_IMAGE) {\n ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');\n ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');\n const resourceId = getProp(el, 'resourceId');\n ensure(isNonEmptyString(resourceId), `${path}.resourceId`, 'resourceId is required.');\n // Opt-in only. `renderLayout` throws on any validation error, so treating a dangling\n // reference as one turns a template that used to print without a single logo into a\n // template that does not print at all — the renderer already warns and skips that\n // element, which is the better outcome mid-print. Authoring tools that want the typo\n // caught up front can ask for it.\n if (strictResourceRefs && isNonEmptyString(resourceId) && !resourceIds.has(resourceId)) {\n ensure(false, `${path}.resourceId`, `No resource is declared with id '${resourceId}'.`);\n }\n } else if (kind === ELEMENT_KIND_LINE) {\n // stroke and strokeWidthMm optional in v2\n } else if (kind === ELEMENT_KIND_RECT) {\n ensure(isPositiveNumber(getProp(el, 'widthMm')), `${path}.widthMm`, 'widthMm must be > 0.');\n ensure(isPositiveNumber(getProp(el, 'heightMm')), `${path}.heightMm`, 'heightMm must be > 0.');\n } else if (kind === ELEMENT_KIND_CIRCLE) {\n ensure(isPositiveNumber(getProp(el, 'rMm')), `${path}.rMm`, 'rMm must be > 0.');\n const cxMm = getProp(el, 'cxMm');\n const cyMm = getProp(el, 'cyMm');\n ensure(typeof cxMm === 'number' && Number.isFinite(cxMm), `${path}.cxMm`, 'cxMm is required.');\n ensure(typeof cyMm === 'number' && Number.isFinite(cyMm), `${path}.cyMm`, 'cyMm is required.');\n } else if (kind === ELEMENT_KIND_POLYLINE) {\n const points = getProp(el, 'points');\n ensure(\n Array.isArray(points) && points.length >= 2,\n `${path}.points`,\n 'points is required (at least 2 points).'\n );\n ensure(isNonEmptyString(getProp(el, 'stroke')), `${path}.stroke`, 'stroke is required.');\n ensure(\n isPositiveNumber(getProp(el, 'strokeWidthMm')),\n `${path}.strokeWidthMm`,\n 'strokeWidthMm must be > 0.'\n );\n } else if (kind === ELEMENT_KIND_POLYGON) {\n const points = getProp(el, 'points');\n ensure(\n Array.isArray(points) && points.length >= 3,\n `${path}.points`,\n 'points is required (at least 3 points).'\n );\n } else if (kind === ELEMENT_KIND_SCALE_BAR) {\n ensure(isPositiveNumber(getProp(el, 'maxLengthMm')), `${path}.maxLengthMm`, 'maxLengthMm must be > 0.');\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n } else if (kind === ELEMENT_KIND_QR) {\n ensure(isPositiveNumber(getProp(el, 'sizeMm')), `${path}.sizeMm`, 'sizeMm must be > 0.');\n const xMm = getProp(el, 'xMm');\n const yMm = getProp(el, 'yMm');\n ensure(typeof xMm === 'number' && Number.isFinite(xMm), `${path}.xMm`, 'xMm is required.');\n ensure(typeof yMm === 'number' && Number.isFinite(yMm), `${path}.yMm`, 'yMm is required.');\n } else if (kind === ELEMENT_KIND_LABELS) {\n ensure(isNonEmptyString(getProp(el, 'viewport')), `${path}.viewport`, 'viewport is required.');\n ensure(isNonEmptyString(getProp(el, 'text')), `${path}.text`, 'text is required.');\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n } else if (kind === ELEMENT_KIND_LEGEND) {\n ensure(isNonEmptyString(getProp(el, 'viewport')), `${path}.viewport`, 'viewport is required.');\n const columns = getProp(el, 'columns');\n if (!Array.isArray(columns) || !columns.length) {\n errors.push({ path: `${path}.columns`, message: 'columns is required and must be a non-empty array.' });\n } else {\n columns.forEach((col: unknown, idx: number) => {\n if (!isRecord(col)) {\n errors.push({ path: `${path}.columns[${idx}]`, message: 'Column must be an object.' });\n return;\n }\n ensure(\n isNonEmptyString(getProp(col, 'id')),\n `${path}.columns[${idx}].id`,\n 'Column id is required.'\n );\n ensure(\n isNonEmptyString(getProp(col, 'label')),\n `${path}.columns[${idx}].label`,\n 'Column label is required.'\n );\n ensure(\n isNonEmptyString(getProp(col, 'property')),\n `${path}.columns[${idx}].property`,\n 'Column property is required.'\n );\n });\n }\n const textStyle = getProp(el, 'textStyle');\n if (textStyle !== undefined) {\n if (typeof textStyle === 'string' && styleNames.size > 0 && !styleNames.has(textStyle)) {\n errors.push({\n path: `${path}.textStyle`,\n message: `Style '${textStyle}' is not defined in styles.`\n });\n }\n }\n const clipToViewport = getProp(el, 'clipToViewport');\n if (clipToViewport !== undefined && typeof clipToViewport !== 'boolean') {\n errors.push({\n path: `${path}.clipToViewport`,\n message: 'clipToViewport must be a boolean when provided.'\n });\n }\n } else if (kind === ELEMENT_KIND_GROUP) {\n const opacity = getProp(el, 'opacity');\n if (opacity !== undefined) {\n ensure(\n typeof opacity === 'number' && opacity >= 0 && opacity <= 1,\n `${path}.opacity`,\n 'opacity must be between 0 and 1.'\n );\n }\n const transform = getProp(el, 'transform');\n if (transform) {\n const scaleX = getProp(transform, 'scaleX');\n const scaleY = getProp(transform, 'scaleY');\n ensure(\n scaleX === undefined || typeof scaleX === 'number',\n `${path}.transform.scaleX`,\n 'scaleX must be a number'\n );\n ensure(\n scaleY === undefined || typeof scaleY === 'number',\n `${path}.transform.scaleY`,\n 'scaleY must be a number'\n );\n }\n const clip = getProp(el, 'clip');\n if (clip) {\n ensure(getProp(clip, 'type') === 'rect', `${path}.clip.type`, \"clip.type must be 'rect'.\");\n ensure(isPositiveNumber(getProp(clip, 'widthMm')), `${path}.clip.widthMm`, 'clip.widthMm must be > 0.');\n ensure(\n isPositiveNumber(getProp(clip, 'heightMm')),\n `${path}.clip.heightMm`,\n 'clip.heightMm must be > 0.'\n );\n const clipXMm = getProp(clip, 'xMm');\n const clipYMm = getProp(clip, 'yMm');\n ensure(\n typeof clipXMm === 'number' && Number.isFinite(clipXMm),\n `${path}.clip.xMm`,\n 'clip.xMm is required.'\n );\n ensure(\n typeof clipYMm === 'number' && Number.isFinite(clipYMm),\n `${path}.clip.yMm`,\n 'clip.yMm is required.'\n );\n }\n const children = getProp(el, 'children');\n if (Array.isArray(children)) {\n children.forEach((child: unknown, childIdx: number) =>\n validateElement(child, `${path}.children[${childIdx}]`)\n );\n }\n } else {\n errors.push({ path, message: `Unknown element kind '${kind}'.` });\n }\n };\n\n const elements = getProp(t, 'elements');\n if (Array.isArray(elements)) {\n elements.forEach((el: unknown, index: number) => validateElement(el, `elements[${index}]`));\n } else {\n errors.push({ path: 'elements', message: 'elements is required and must be an array.' });\n }\n\n // Validate template variables (if present)\n const variables = getProp(t, 'variables');\n if (variables !== undefined) {\n if (!isRecord(variables)) {\n errors.push({ path: 'variables', message: 'Variables must be an object.' });\n } else {\n // Validate each variable definition\n for (const [varName, varDef] of Object.entries(variables)) {\n const varPath = `variables.${varName}`;\n\n // Names are referenced as {{vars.<name>}} — non-identifier\n // names (dashes, dots, spaces) collide with the placeholder\n // syntax and are silently never substituted.\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(varName)) {\n errors.push({\n path: varPath,\n message: 'Variable names must be simple identifiers ([A-Za-z_][A-Za-z0-9_]*).'\n });\n }\n\n if (!isRecord(varDef)) {\n errors.push({ path: varPath, message: 'Variable definition must be an object.' });\n continue;\n }\n\n // Validate type\n const varType = getProp(varDef, 'type');\n if (!['string', 'number', 'boolean', 'array'].includes(varType as string)) {\n errors.push({\n path: `${varPath}.type`,\n message: `Type must be 'string', 'number', 'boolean', or 'array' (got '${varType}').`\n });\n }\n\n // Enforce default value (CRITICAL for fail-safe operation)\n const defaultValue = getProp(varDef, 'default');\n if (defaultValue === undefined || defaultValue === null) {\n errors.push({\n path: `${varPath}.default`,\n message: 'Variable must have a default value (required for fail-safe operation).'\n });\n } else {\n // Validate default value matches declared type\n const actualType = Array.isArray(defaultValue) ? 'array' : typeof defaultValue;\n if (varType === 'number' && actualType !== 'number') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be a number (got ${actualType}).`\n });\n } else if (varType === 'string' && actualType !== 'string') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be a string (got ${actualType}).`\n });\n } else if (varType === 'boolean' && actualType !== 'boolean') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be a boolean (got ${actualType}).`\n });\n } else if (varType === 'array' && actualType !== 'array') {\n errors.push({\n path: `${varPath}.default`,\n message: `Default value must be an array (got ${actualType}).`\n });\n }\n }\n\n // Validate numeric constraints (if present)\n if (varType === 'number') {\n const min = getProp(varDef, 'min');\n const max = getProp(varDef, 'max');\n if (min !== undefined && typeof min !== 'number') {\n errors.push({ path: `${varPath}.min`, message: 'min must be a number.' });\n }\n if (max !== undefined && typeof max !== 'number') {\n errors.push({ path: `${varPath}.max`, message: 'max must be a number.' });\n }\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n errors.push({ path: `${varPath}`, message: 'min cannot be greater than max.' });\n }\n }\n }\n }\n }\n\n if (errors.length) {\n return { ok: false, errors };\n }\n\n return { ok: true, template };\n}\n"]}
@@ -20,9 +20,10 @@ export interface ViewportPrepResult {
20
20
  }>;
21
21
  viewportClipLabels: Record<string, boolean>;
22
22
  viewportClipStyles: Record<string, {
23
- stroke?: string;
24
- strokeWidthMm?: number;
25
- strokeOpacity?: number;
23
+ color?: string;
24
+ widthMm?: number;
25
+ opacity?: number;
26
+ dash?: string;
26
27
  fill?: string;
27
28
  fillOpacity?: number;
28
29
  }>;
@@ -30,9 +31,10 @@ export interface ViewportPrepResult {
30
31
  viewportHighlight: Record<string, {
31
32
  gids: Set<string> | null;
32
33
  styles: {
33
- stroke?: string;
34
- strokeWidthMm?: number;
35
- strokeOpacity?: number;
34
+ color?: string;
35
+ widthMm?: number;
36
+ opacity?: number;
37
+ dash?: string;
36
38
  fill?: string;
37
39
  fillOpacity?: number;
38
40
  };
@@ -1 +1 @@
1
- {"version":3,"file":"viewportPrep.d.ts","sourceRoot":"/","sources":["layout/viewportPrep.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAMjD,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACtD,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC,CAAC;IAClF,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EA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