semiotic 3.8.6 → 3.8.7

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 (213) hide show
  1. package/CLAUDE.md +33 -7
  2. package/README.md +82 -55
  3. package/ai/behaviorContracts.cjs +86 -1
  4. package/ai/componentMetadata.cjs +4 -9
  5. package/ai/dist/mcp-server.js +97 -10
  6. package/ai/examples.md +154 -7
  7. package/ai/schema.json +1611 -145
  8. package/ai/surface-manifest.json +12 -10
  9. package/ai/system-prompt.md +9 -3
  10. package/dist/{chunk-chartContainerDataAudit-FEOD5GTQ.module.min.js → chunk-chartContainerDataAudit-JDSVSKGM.module.min.js} +1 -1
  11. package/dist/chunk-chunk-2YAZHXL4.module.min.js +2 -0
  12. package/dist/{chunk-chunk-G7WFWHAD.module.min.js → chunk-chunk-4ITOQRXM.module.min.js} +1 -1
  13. package/dist/chunk-chunk-5SD6BHVW.module.min.js +2 -0
  14. package/dist/chunk-chunk-6V5VQVCT.module.min.js +2 -0
  15. package/dist/chunk-chunk-7TTBHSAG.module.min.js +2 -0
  16. package/dist/chunk-chunk-7ZDJSYKI.module.min.js +2 -0
  17. package/dist/chunk-chunk-BGHPD3RA.module.min.js +1 -0
  18. package/dist/chunk-chunk-BMRZ2SPU.module.min.js +2 -0
  19. package/dist/chunk-chunk-BNGBEY7N.module.min.js +2 -0
  20. package/dist/chunk-chunk-C7APLVQD.module.min.js +2 -0
  21. package/dist/chunk-chunk-DGWFBOGB.module.min.js +1 -0
  22. package/dist/{chunk-chunk-Q2BS46W2.module.min.js → chunk-chunk-DIVE2DRA.module.min.js} +1 -1
  23. package/dist/chunk-chunk-FBUNUIPV.module.min.js +2 -0
  24. package/dist/chunk-chunk-FQPKOAIH.module.min.js +2 -0
  25. package/dist/chunk-chunk-FRO4TRXK.module.min.js +2 -0
  26. package/dist/chunk-chunk-G7QVPZUD.module.min.js +2 -0
  27. package/dist/chunk-chunk-GBPYV4FP.module.min.js +2 -0
  28. package/dist/chunk-chunk-GU2EJIDJ.module.min.js +2 -0
  29. package/dist/chunk-chunk-J5QD4RAM.module.min.js +2 -0
  30. package/dist/{chunk-chunk-RA7JCG7D.module.min.js → chunk-chunk-JWXLNZSM.module.min.js} +1 -1
  31. package/dist/chunk-chunk-KXAFCCDB.module.min.js +2 -0
  32. package/dist/chunk-chunk-LG7YKJAK.module.min.js +2 -0
  33. package/dist/{chunk-chunk-XP3OHHFX.module.min.js → chunk-chunk-LVHDZAT3.module.min.js} +1 -1
  34. package/dist/chunk-chunk-LWITSR2O.module.min.js +2 -0
  35. package/dist/{chunk-chunk-SMVD3EQJ.module.min.js → chunk-chunk-MX35T6RX.module.min.js} +1 -1
  36. package/dist/chunk-chunk-NH4MEAKP.module.min.js +2 -0
  37. package/dist/chunk-chunk-NJETWX42.module.min.js +2 -0
  38. package/dist/chunk-chunk-NW25WGLS.module.min.js +2 -0
  39. package/dist/{chunk-chunk-GFTVACTO.module.min.js → chunk-chunk-OI7R7EJB.module.min.js} +1 -1
  40. package/dist/{chunk-chunk-OM6NWS4H.module.min.js → chunk-chunk-ONMLEXHR.module.min.js} +1 -1
  41. package/dist/chunk-chunk-OY66GCE6.module.min.js +1 -0
  42. package/dist/chunk-chunk-PZFT457G.module.min.js +1 -0
  43. package/dist/chunk-chunk-Q3WW6JGR.module.min.js +1 -0
  44. package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +1 -0
  45. package/dist/chunk-chunk-RJRM2E6P.module.min.js +1 -0
  46. package/dist/chunk-chunk-RPL7WYXI.module.min.js +1 -0
  47. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  48. package/dist/chunk-chunk-TSCFL235.module.min.js +1 -0
  49. package/dist/chunk-chunk-UOQRPGPK.module.min.js +2 -0
  50. package/dist/chunk-chunk-V3OAKG32.module.min.js +1 -0
  51. package/dist/chunk-chunk-WLOIUMWG.module.min.js +2 -0
  52. package/dist/chunk-chunk-XEGXX4F7.module.min.js +1 -0
  53. package/dist/chunk-chunk-XFRBLXYM.module.min.js +1 -0
  54. package/dist/chunk-chunk-Z2AJERX5.module.min.js +2 -0
  55. package/dist/chunk-chunk-ZXYDYAB7.module.min.js +2 -0
  56. package/dist/components/ai/SemioticVACPBridge.d.ts +22 -0
  57. package/dist/components/ai/chartCapabilities.d.ts +4 -3
  58. package/dist/components/ai/conversationArc.d.ts +2 -176
  59. package/dist/components/ai/conversationArcTypes.d.ts +202 -0
  60. package/dist/components/ai/readerGrounding.d.ts +12 -0
  61. package/dist/components/ai/vacpAdapter.d.ts +13 -0
  62. package/dist/components/ai/vacpAdapterActions.d.ts +2 -0
  63. package/dist/components/ai/vacpAdapterModel.d.ts +7 -0
  64. package/dist/components/ai/vacpAdapterRuntime.d.ts +26 -0
  65. package/dist/components/ai/vacpAdapterState.d.ts +3 -0
  66. package/dist/components/ai/vacpAdapterTypes.d.ts +169 -0
  67. package/dist/components/ai/vacpTypes.d.ts +160 -0
  68. package/dist/components/charts/index.d.ts +4 -4
  69. package/dist/components/charts/physics/ChainReactionChart.capability.d.ts +9 -0
  70. package/dist/components/charts/physics/ChainReactionChart.d.ts +29 -0
  71. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
  72. package/dist/components/charts/physics/EventDropChart.d.ts +7 -2
  73. package/dist/components/charts/physics/GaltonBoardChart.d.ts +1 -1
  74. package/dist/components/charts/physics/{PhysicsPileChart.capability.d.ts → PacketFlowChart.capability.d.ts} +1 -1
  75. package/dist/components/charts/physics/{PhysicalFlowChart.d.ts → PacketFlowChart.d.ts} +22 -6
  76. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +1 -1
  77. package/dist/components/charts/physics/ProcessFlowChart.d.ts +7 -4
  78. package/dist/components/charts/physics/{PhysicalFlowChart.capability.d.ts → UnitPileChart.capability.d.ts} +1 -1
  79. package/dist/components/charts/physics/{PhysicsPileChart.d.ts → UnitPileChart.d.ts} +19 -6
  80. package/dist/components/charts/physics/crucibleChartProps.d.ts +1 -1
  81. package/dist/components/charts/physics/crucibleChartUtils.d.ts +9 -0
  82. package/dist/components/charts/physics/gauntletChartProps.d.ts +6 -1
  83. package/dist/components/charts/physics/gauntletTerminal.d.ts +61 -0
  84. package/dist/components/charts/physics/packetFlowSemantics.d.ts +6 -0
  85. package/dist/components/charts/physics/physicsHocUtils.d.ts +45 -2
  86. package/dist/components/charts/shared/auditAccessibilityStyles.d.ts +9 -0
  87. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  88. package/dist/components/charts/shared/useChartLegend.d.ts +8 -1
  89. package/dist/components/charts/shared/useChartSetup.d.ts +7 -0
  90. package/dist/components/data/portability/capabilityBinding.d.ts +41 -0
  91. package/dist/components/data/portability/index.d.ts +2 -0
  92. package/dist/components/legendLayout.d.ts +56 -0
  93. package/dist/components/recipes/geographicDotGrid.d.ts +82 -0
  94. package/dist/components/recipes/geographicGrid.d.ts +100 -0
  95. package/dist/components/recipes/physics.d.ts +2 -0
  96. package/dist/components/recipes/physicsStageGeography.d.ts +137 -0
  97. package/dist/components/semiotic-ai.d.ts +4 -3
  98. package/dist/components/semiotic-experimental-vacp.d.ts +11 -0
  99. package/dist/components/semiotic-experimental.d.ts +6 -3
  100. package/dist/components/semiotic-geo.d.ts +4 -0
  101. package/dist/components/semiotic-physics.d.ts +9 -6
  102. package/dist/components/semiotic-recipes-core.d.ts +6 -1
  103. package/dist/components/server/renderEvidence.d.ts +1 -1
  104. package/dist/components/server/renderToStaticSVG.d.ts +2 -1
  105. package/dist/components/server/serverChartConfigHeatmap.d.ts +6 -0
  106. package/dist/components/server/serverChartConfigNetworkStyles.d.ts +12 -0
  107. package/dist/components/server/serverChartConfigShared.d.ts +16 -0
  108. package/dist/components/server/serverChartConfigs.d.ts +2 -2
  109. package/dist/components/server/serverChartConfigsPhysics.d.ts +2 -2
  110. package/dist/components/server/serverChartConfigsXY.d.ts +0 -1
  111. package/dist/components/server/staticLegend.d.ts +6 -0
  112. package/dist/components/server/staticSVGChrome.d.ts +10 -2
  113. package/dist/components/server/staticValue.d.ts +8 -0
  114. package/dist/components/stream/geoPipelineConfig.d.ts +10 -0
  115. package/dist/components/stream/legendRenderer.d.ts +8 -0
  116. package/dist/components/stream/physics/PhysicsEvidence.d.ts +37 -0
  117. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +9 -0
  118. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +5 -0
  119. package/dist/components/stream/physics/physicsFramePipelineConfig.d.ts +19 -0
  120. package/dist/components/stream/physics/physicsPipelineSettle.d.ts +52 -0
  121. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +23 -0
  122. package/dist/components/stream/types.d.ts +2 -0
  123. package/dist/components/types/legendTypes.d.ts +17 -1
  124. package/dist/controls.min.js +1 -1
  125. package/dist/controls.module.min.js +1 -1
  126. package/dist/geo.min.js +1 -1
  127. package/dist/geo.module.min.js +1 -1
  128. package/dist/network.min.js +1 -1
  129. package/dist/network.module.min.js +1 -1
  130. package/dist/ordinal.min.js +1 -1
  131. package/dist/ordinal.module.min.js +1 -1
  132. package/dist/physics.min.js +1 -1
  133. package/dist/physics.module.min.js +1 -1
  134. package/dist/physicsWorker.js +1 -1
  135. package/dist/realtime.min.js +1 -1
  136. package/dist/realtime.module.min.js +1 -1
  137. package/dist/semiotic-ai-core.min.js +1 -1
  138. package/dist/semiotic-ai-core.module.min.js +1 -1
  139. package/dist/semiotic-ai.d.ts +4 -3
  140. package/dist/semiotic-ai.min.js +1 -1
  141. package/dist/semiotic-ai.module.min.js +1 -1
  142. package/dist/semiotic-data.module.min.js +1 -1
  143. package/dist/semiotic-experimental-vacp.d.ts +11 -0
  144. package/dist/semiotic-experimental-vacp.min.js +1 -0
  145. package/dist/semiotic-experimental-vacp.module.min.js +1 -0
  146. package/dist/semiotic-experimental.d.ts +6 -3
  147. package/dist/semiotic-experimental.min.js +2 -1
  148. package/dist/semiotic-experimental.module.min.js +2 -1
  149. package/dist/semiotic-geo.d.ts +4 -0
  150. package/dist/semiotic-physics.d.ts +9 -6
  151. package/dist/semiotic-realtime-core.min.js +1 -1
  152. package/dist/semiotic-realtime-core.module.min.js +1 -1
  153. package/dist/semiotic-recipes-core.d.ts +6 -1
  154. package/dist/semiotic-recipes-core.min.js +1 -1
  155. package/dist/semiotic-recipes-core.module.min.js +1 -1
  156. package/dist/semiotic-recipes.min.js +1 -1
  157. package/dist/semiotic-recipes.module.min.js +1 -1
  158. package/dist/semiotic-server-edge.min.js +1 -1
  159. package/dist/semiotic-server-edge.module.min.js +1 -1
  160. package/dist/semiotic-server-node.min.js +1 -1
  161. package/dist/semiotic-server-node.module.min.js +1 -1
  162. package/dist/semiotic-utils-core.min.js +1 -1
  163. package/dist/semiotic-utils-core.module.min.js +1 -1
  164. package/dist/semiotic-utils.min.js +1 -1
  165. package/dist/semiotic-utils.module.min.js +1 -1
  166. package/dist/semiotic.min.js +1 -1
  167. package/dist/semiotic.module.min.js +1 -1
  168. package/dist/server.min.js +1 -1
  169. package/dist/server.module.min.js +1 -1
  170. package/dist/xy.min.js +1 -1
  171. package/dist/xy.module.min.js +1 -1
  172. package/package.json +18 -2
  173. package/spec/README.md +94 -2
  174. package/spec/bindings/README.md +14 -3
  175. package/spec/v0.1/examples/annotation-provenance-reviewed-revision.json +27 -0
  176. package/spec/v0.1/examples/annotation-provenance-watcher-threshold.json +21 -0
  177. package/spec/v0.1/examples/audience-profile-executive-review.json +24 -0
  178. package/spec/v0.1/examples/audience-profile-incident-operators.json +42 -0
  179. package/spec/v0.1/examples/chart-capability-bar-comparison.json +48 -0
  180. package/spec/v0.1/examples/chart-capability-service-flow.json +54 -0
  181. package/dist/chunk-chunk-2CHN2TA3.module.min.js +0 -1
  182. package/dist/chunk-chunk-3SHB24AG.module.min.js +0 -1
  183. package/dist/chunk-chunk-4MMOOYTX.module.min.js +0 -2
  184. package/dist/chunk-chunk-5RKXZQ2P.module.min.js +0 -1
  185. package/dist/chunk-chunk-75OTQSXS.module.min.js +0 -1
  186. package/dist/chunk-chunk-7ALTGHK6.module.min.js +0 -1
  187. package/dist/chunk-chunk-A5GRQUOF.module.min.js +0 -1
  188. package/dist/chunk-chunk-AAF5LZAU.module.min.js +0 -2
  189. package/dist/chunk-chunk-ARZGA4LJ.module.min.js +0 -2
  190. package/dist/chunk-chunk-C4YA6TDR.module.min.js +0 -1
  191. package/dist/chunk-chunk-CAFLML4L.module.min.js +0 -2
  192. package/dist/chunk-chunk-CO5KQMGH.module.min.js +0 -1
  193. package/dist/chunk-chunk-FHBN7OEB.module.min.js +0 -2
  194. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +0 -1
  195. package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
  196. package/dist/chunk-chunk-ITDWLZXV.module.min.js +0 -2
  197. package/dist/chunk-chunk-JCG72SGW.module.min.js +0 -2
  198. package/dist/chunk-chunk-LPSPATPC.module.min.js +0 -1
  199. package/dist/chunk-chunk-PX5YQGDP.module.min.js +0 -2
  200. package/dist/chunk-chunk-QSQVBIJA.module.min.js +0 -1
  201. package/dist/chunk-chunk-RCF52Z42.module.min.js +0 -2
  202. package/dist/chunk-chunk-RNUHEXZA.module.min.js +0 -2
  203. package/dist/chunk-chunk-ROZWKEUG.module.min.js +0 -1
  204. package/dist/chunk-chunk-T2FKJD4O.module.min.js +0 -2
  205. package/dist/chunk-chunk-UDREYOLV.module.min.js +0 -1
  206. package/dist/chunk-chunk-VOWE3SAP.module.min.js +0 -2
  207. package/dist/chunk-chunk-VQPNBUSW.module.min.js +0 -2
  208. package/dist/chunk-chunk-WAWCIHFJ.module.min.js +0 -1
  209. package/dist/chunk-chunk-WYARAXHR.module.min.js +0 -2
  210. package/dist/chunk-chunk-XV3KGYTR.module.min.js +0 -2
  211. package/dist/chunk-chunk-YC2IVEPX.module.min.js +0 -1
  212. package/dist/chunk-chunk-ZOAQDIJO.module.min.js +0 -1
  213. package/dist/chunk-chunk-ZXIXAPRE.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{parseDateLikeString as e}from"./chunk-chunk-ZXIXAPRE.module.min.js";function o(e,o){const n={numbers:[],missing:0,nonFinite:0,nonNumeric:0,zero:0,negative:0,fractional:0};for(const s of e){const e=s?.[o];if(null==e||""===e){n.missing++;continue}let t;if("number"==typeof e)t=e;else if("string"==typeof e){const o=e.trim();if(""===o){n.missing++;continue}const s=Number(o);Number.isNaN(s)?/^[+-]?nan$/i.test(o)&&(t=s):t=s}void 0!==t?Number.isFinite(t)?(n.numbers.push(t),0===t&&n.zero++,0>t&&n.negative++,Number.isInteger(t)||n.fractional++):n.nonFinite++:n.nonNumeric++}return n}function n(e,o){if(0===e.length)return;const n=(e.length-1)*o,s=Math.floor(n),t=Math.ceil(n);if(s===t)return e[s];const r=n-s;return e[s]*(1-r)+e[t]*r}function s(e,s={}){if(!Array.isArray(e)||0===e.length)return{};const t=new Set;for(const o of e)if(o&&"object"==typeof o)for(const e of Object.keys(o))t.add(e);const r={};for(const i of t){const t=o(e,i);let a=1/0,c=-1/0;for(const e of t.numbers)a>e&&(a=e),e>c&&(c=e);const l=!1===s.quantiles?void 0:[...t.numbers].sort((e,o)=>e-o);r[i]={field:i,observedCount:e.length-t.missing,finiteCount:t.numbers.length,missingCount:t.missing,nonFiniteCount:t.nonFinite,nonNumericCount:t.nonNumeric,zeroCount:t.zero,negativeCount:t.negative,fractionalCount:t.fractional,...t.numbers.length>0?{min:a,...l?{q1:n(l,.25),median:n(l,.5),q3:n(l,.75)}:{},max:c}:{}}}return r}function t(e){const o=[`${e.component}: ${e.ok?"✓ numerically safe":"✗ numeric hazards found"}`,`${e.rowCount} rows · ${e.summary.fieldsChecked} numeric fields · ${e.summary.errors} errors · ${e.summary.warnings} warnings`];for(const n of e.diagnoses)o.push(`${"error"===n.severity?"ERROR":"WARN"} ${n.code}${n.field?` [${n.field}]`:""}: ${n.message}`),n.fix&&o.push(" Fix: "+n.fix);return o.join("\n")}function r(e){return e.code.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function i(e,o={}){const n=Number.isFinite(o.max)?Math.max(0,Math.floor(o.max)):6,s=e.diagnoses.map((e,o)=>({item:e,diagnosisIndex:o})).filter(({item:e})=>!o.errorsOnly||"error"===e.severity),t=s.slice(0,n).map(({item:e,diagnosisIndex:o})=>({id:`data-audit:${e.code}:${e.role??"chart"}:${e.field??"chart"}:${o}`,level:e.severity,title:e.field?`${r(e)} · ${e.field}`:r(e),message:e.fix?`${e.message} ${e.fix}`:e.message,source:"Semiotic data audit",dismissible:!0}));return s.length>n&&t.push({id:"data-audit:overflow:chart",level:s.slice(n).some(({item:e})=>"error"===e.severity)?"error":"warning",title:`${s.length-n} more numeric finding${s.length-n===1?"":"s"}`,message:"Run auditData() or diagnoseConfig() to inspect the complete report.",source:"Semiotic data audit",dismissible:!0}),t}function a(e,o){const n=e.nestedDataAccessorProp?o[e.nestedDataAccessorProp]:void 0;return"string"==typeof n?n:e.defaultNestedDataAccessor}function c(e,o,n){const s=e.dataProp??"data",t=o[s],r=n??(Array.isArray(t)?t:[]),i=a(e,o);if(!i)return{dataProp:s,rows:r};const c=[];let l=!1;for(const e of r){const o=e?.[i];if(Array.isArray(o)){l=!0;for(const e of o)e&&"object"==typeof e&&c.push(e)}}return{dataProp:s,rows:l?c:r}}var l=[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date-like",domain:!0},{role:"y",accessor:"yAccessor",defaultAccessor:"y",domain:!0}],u={fields:l},f=[{...l[0],nestedDataAccessorProp:"lineDataAccessor",defaultNestedDataAccessor:"coordinates"},{...l[1],nestedDataAccessorProp:"lineDataAccessor",defaultNestedDataAccessor:"coordinates",allowMissing:!0}],g={fields:f},d={role:"value",accessor:"valueAccessor",defaultAccessor:"value"},m={...d,domain:!0},h={fields:[{...d,requirements:["finite","non-negative"]}],aggregates:[{kind:"positive-total",role:"value"}]},p={fields:[d],aggregates:[{kind:"normalized-total",role:"value",groupAccessor:"categoryAccessor",defaultGroupAccessor:"category",whenProp:"normalize"}]},v={fields:f,aggregates:[{kind:"normalized-total",role:"y",groupAccessor:"xAccessor",defaultGroupAccessor:"x",whenProp:"normalize"}]},w={fields:[...l,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},y={fields:[...l,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},A={fields:[d]},b={fields:[{...d,dataProp:"edges",requirements:["finite","non-negative"],missingValue:1}]},$={LineChart:g,AreaChart:g,BumpChart:g,Scatterplot:y,ConnectedScatterplot:u,QuadrantChart:y,MinimapChart:g,BubbleChart:w,StackedAreaChart:v,DifferenceChart:{fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date",domain:!0},{role:"value",accessor:"seriesAAccessor",defaultAccessor:"a"},{role:"value",accessor:"seriesBAccessor",defaultAccessor:"b"}]},CandlestickChart:{fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date-like",domain:!0},{role:"high",accessor:"highAccessor",defaultAccessor:"high",requirements:["finite"]},{role:"low",accessor:"lowAccessor",defaultAccessor:"low",requirements:["finite"]},{role:"open",accessor:"openAccessor",whenProps:["openAccessor","closeAccessor"],requirements:["finite"]},{role:"close",accessor:"closeAccessor",whenProps:["openAccessor","closeAccessor"],requirements:["finite"]}]},Heatmap:A,BarChart:{fields:[d]},GroupedBarChart:{fields:[d]},StackedBarChart:p,DotPlot:{fields:[m]},Histogram:{fields:[m]},BoxPlot:{fields:[m]},SwarmPlot:{fields:[m,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},ViolinPlot:{fields:[m]},RidgelinePlot:{fields:[m]},PieChart:h,DonutChart:h,FunnelChart:h,SankeyDiagram:b,ChordDiagram:b,ProportionalSymbolMap:{fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"lon",dataProp:"points",requirements:["finite"]},{role:"y",accessor:"yAccessor",defaultAccessor:"lat",dataProp:"points",requirements:["finite"]},{role:"size",accessor:"sizeBy",dataProp:"points",requirements:["finite","non-negative"]}]}},R=Symbol.for("semiotic.numericContractRegistry");function N(){const e=globalThis;return e[R]??(e[R]={contracts:new Map}),e[R]}function x(e,o){o?N().contracts.set(e,o):N().contracts.delete(e)}function z(e){N().contracts.delete(e)}var E={xAccessor:"x",yAccessor:"y",valueAccessor:"value",sizeBy:"size",sizeAccessor:"size",radiusAccessor:"size",countAccessor:"count",amountAccessor:"value",highAccessor:"high",lowAccessor:"low",openAccessor:"open",closeAccessor:"close",lowerAccessor:"lower",upperAccessor:"upper",positiveAccessor:"value",negativeAccessor:"value",progressAccessor:"value",confidenceAccessor:"value",costAccessor:"value",throughputAccessor:"value"};function P(e,o,n){return"function"==typeof e?e(o,n):o[e]}function I(o,n){if("number"==typeof o)return Number.isFinite(o)?o:null;if(o instanceof Date){const e=o.getTime();return n&&Number.isFinite(e)?e:null}if("string"==typeof o){const s=o.trim(),t=Number(s);if(s&&Number.isFinite(t))return t;if("date-like"===n){const o=e(s);return Number.isFinite(o)?o:null}}return null}function _(e){return"number"==typeof e&&!Number.isFinite(e)}function C(e,o,n,s,t){const r={field:n,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let n=0;e.length>n;n++){let i;try{i=P(o,e[n],n)}catch{r.accessorErrorRows.push(n);continue}if(null==i||""===i){if(void 0!==t){r.numbers.push(t),r.finiteRows.push(n),0===t&&r.zeroRows.push(n),0>t&&r.negativeRows.push(n),Number.isInteger(t)||r.fractionalRows.push(n);continue}r.missingRows.push(n);continue}const a=I(i,s);null!=a?(r.numbers.push(a),r.finiteRows.push(n),0===a&&r.zeroRows.push(n),0>a&&r.negativeRows.push(n),Number.isInteger(a)||r.fractionalRows.push(n)):_(i)?r.nonFiniteRows.push(n):r.nonNumericRows.push(n)}return r}function S(e,o){if(0===e.length)return;const n=(e.length-1)*o,s=Math.floor(n),t=Math.ceil(n);if(s===t)return e[s];const r=n-s;return e[s]*(1-r)+e[t]*r}function M(e,o){const n=new Set(e.requirements??["finite"]);return n.add("finite"),("x"===e.role&&"log"===o.xScaleType||"y"===e.role&&"log"===o.yScaleType)&&n.add("positive"),[...n]}function O(e){return e.slice(0,5)}function T(e){return{domain:"data",...e}}function k(e,o){const n=[],{observation:s,contract:t,accessorLabel:r,requirements:i}=e,a={field:r,role:t.role},c=[...s.nonFiniteRows,...s.nonNumericRows,...s.accessorErrorRows].sort((e,o)=>e-o);if(0===s.numbers.length)return n.push(T({severity:"error",code:"DEGENERATE_EXTENT",message:`${t.accessor}="${r}" produces no finite numeric values; the chart cannot resolve its ${t.role} input.`,fix:`Ensure ${r} contains finite numbers${"x"===t.role?" (or valid dates for a time scale)":""}.`,...a,...c.length>0?{rows:O(c),count:c.length}:{}})),n;s.nonFiniteRows.length>0&&n.push(T({severity:"error",code:"NON_FINITE_VALUE",message:`${r} contains ${s.nonFiniteRows.length} NaN or infinite value${1===s.nonFiniteRows.length?"":"s"}; scale and layout math require finite numbers.`,fix:`Filter or replace NaN/Infinity in ${r} before rendering.`,...a,rows:O(s.nonFiniteRows),count:s.nonFiniteRows.length})),!t.allowMissing&&s.missingRows.length>0&&n.push(T({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${r} is missing for ${s.missingRows.length} row${1===s.missingRows.length?"":"s"}; the ${t.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${r} values before rendering.`,...a,rows:O(s.missingRows),count:s.missingRows.length}));const l=[...s.nonNumericRows,...s.accessorErrorRows].sort((e,o)=>e-o);if(l.length>0&&n.push(T({severity:"error",code:"NON_NUMERIC_VALUE",message:`${r} produces ${l.length} non-numeric value${1===l.length?"":"s"} for the ${t.role} role.`,fix:`Bind ${t.accessor} to a numeric field or return finite numbers from the accessor.`,...a,rows:O(l),count:l.length})),t.domain&&s.numbers.length>=2){const[e,o]=function(e){let o=1/0,n=-1/0;for(const s of e)o>s&&(o=s),s>n&&(n=s);return[o,n]}(s.numbers);e===o&&n.push(T({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${r} is constant at ${e}; its ${t.role} scale has a zero-span data domain.`,fix:`Provide varying ${t.role} values, set an explicit extent around ${e}, or use a single-value display.`,...a,rows:O(s.finiteRows),count:s.finiteRows.length}))}if(i.includes("positive")){const o=s.numbers.map((e,o)=>({number:e,row:s.finiteRows[o]})).filter(({number:e})=>0>=e).map(({row:e})=>e);if(o.length>0){const s=e.logScale;n.push(T({severity:"error",code:s?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${r} contains ${o.length} non-positive value${1===o.length?"":"s"}, which ${s?"cannot be represented on a log scale":"violate the positive-value contract"}.`,fix:s?"Remove or transform values ≤ 0, or use a linear/symlog scale.":"Provide values greater than zero.",...a,rows:O(o),count:o.length}))}}if(i.includes("non-negative")&&s.negativeRows.length>0&&n.push(T({severity:"error",code:"size"===t.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${r} contains ${s.negativeRows.length} negative ${t.role} value${1===s.negativeRows.length?"":"s"}; the chart maps this role to non-negative geometry.`,fix:"Use a non-negative measure, clamp intentionally, or encode sign with position/color instead.",...a,rows:O(s.negativeRows),count:s.negativeRows.length})),i.includes("integer")){const e=[...new Set([...s.negativeRows,...s.zeroRows,...s.fractionalRows])].sort((e,o)=>e-o);e.length>0&&n.push(T({severity:"error",code:"INVALID_COUNT",message:`${r} contains ${e.length} value${1===e.length?"":"s"} that are not positive integers.`,fix:"Counts must be integers ≥ 1; aggregate, round intentionally, or use a continuous-value encoding.",...a,rows:O(e),count:e.length}))}if(i.includes("unit-interval")){const e=s.numbers.map((e,o)=>({number:e,row:s.finiteRows[o]})).filter(({number:e})=>0>e||e>1).map(({row:e})=>e);e.length>0&&n.push(T({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${r} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${r} to [0, 1] before using it as ${t.role}.`,...a,rows:O(e),count:e.length}))}if(o&&t.domain){const o=function(e){const o=e.observation.numbers.map((o,n)=>({value:o,row:e.observation.finiteRows[n]})).sort((e,o)=>e.value-o.value);if(8>o.length)return[];const n=o.map(e=>e.value),s=S(n,.25),t=S(n,.75),r=S(n,.5),i=t-s;if(i>0){const e=s-10*i,n=t+10*i;return o.filter(o=>e>o.value||o.value>n).map(e=>e.row)}const a=100*Math.max(1,Math.abs(r));return o.filter(e=>Math.abs(e.value-r)>a).map(e=>e.row)}(e);o.length>0&&n.push(T({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${r} has ${o.length} extreme value${1===o.length?"":"s"} beyond the 10×IQR guardrail; the main distribution may collapse visually.`,fix:"Verify the extreme values, then consider a log scale, robust extent, inset, or explicit annotation rather than silently clipping them.",...a,rows:O(o),count:o.length}))}return n}function D(e,o,n){if(!e)return"__all__";try{return P(e,o,n)+""}catch{return"__accessor_error__"}}function L(e,o,n){if(e.whenProp&&!0!==n[e.whenProp])return[];const s=o.find(o=>o.contract.role===e.role);if(!s||0===s.observation.numbers.length)return[];const t=e.groupAccessor?n[e.groupAccessor]:void 0,r="string"==typeof t||"function"==typeof t?t:e.defaultGroupAccessor,i=new Map;for(let e=0;s.rows.length>e;e++){let o;try{o=P(s.accessor,s.rows[e],e)}catch{continue}const n=I(o,void 0);if(null==n)continue;const t=D(r,s.rows[e],e),a=i.get(t)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};a.sum+=n,a.magnitude+=Math.abs(n),a.positive||(a.positive=n>0),a.negative||(a.negative=0>n),a.rows.push(e),0>n&&a.negativeRows.push(e),i.set(t,a)}const a=[],c=[],l=[],u=[],f=[],g=[];for(const[o,n]of i)("positive-total"===e.kind&&0>=n.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,n.magnitude)*10>=Math.abs(n.sum))&&(a.push(o),u.push(...n.rows)),"normalized-total"===e.kind&&n.positive&&n.negative&&(c.push(o),f.push(...n.rows)),"normalized-total"===e.kind&&n.negative&&(l.push(o),g.push(...n.negativeRows));const d=[];return a.length>0&&d.push(T({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${a.length} normalization group${1===a.length?" has":"s have"} a zero total, so division would be undefined.`:"The part-to-whole total is not positive, so meaningful shares cannot be computed.",fix:"normalized-total"===e.kind?"Remove empty/zero-sum groups or disable normalization.":"Provide at least one positive value and ensure the total is greater than zero.",field:s.accessorLabel,role:e.role,rows:O([...new Set(u)].sort((e,o)=>e-o)),count:a.length})),l.length>0&&d.push(T({severity:"error",code:"NEGATIVE_NORMALIZED_VALUE",message:`${l.length} normalization group${1===l.length?" contains":"s contain"} negative contributions, so conventional percentage shares are not defined.`,fix:"Use non-negative contributions, a diverging stack, or disable normalization.",field:s.accessorLabel,role:e.role,rows:O([...new Set(g)].sort((e,o)=>e-o)),count:g.length})),c.length>0&&d.push(T({severity:"warning",code:"MIXED_SIGN_NORMALIZATION",message:`${c.length} normalization group${1===c.length?" mixes":"s mix"} positive and negative contributions; percentage shares may be unstable or misleading.`,fix:"Separate positive and negative contributions, use diverging stacks, or disable normalization.",field:s.accessorLabel,role:e.role,rows:O([...new Set(f)].sort((e,o)=>e-o)),count:c.length})),d}function V(e,o,n,s={}){const t=s.contracts??function(e){return N().contracts.get(e)??$[e]}(e)??function(e){const o=[];for(const[n,s]of Object.entries(E))"string"!=typeof e[n]&&"function"!=typeof e[n]||o.push({role:s,accessor:n,..."size"===s?{requirements:["finite","non-negative"]}:{},..."x"===s||"y"===s?{domain:!0}:{}});return o.length>0?{fields:o}:void 0}(o);if(!t)return{component:e,ok:!0,rowCount:n?.length??(Array.isArray(o.data)?o.data.length:0),summary:{fieldsChecked:0,errors:0,warnings:0},contracts:[],diagnoses:[]};const r=function(e,o,n){const s=[],t=new Set;for(const r of e.fields){if(r.whenProps?.some(e=>null==o[e]))continue;const e=o[r.accessor],i="string"==typeof e||"function"==typeof e?e:r.defaultAccessor;if("string"!=typeof i&&"function"!=typeof i)continue;const{dataProp:a,rows:l}=c(r,o,n);if(0===l.length)continue;const u="string"==typeof i?i:r.accessor+"()",f=`${a}:${r.role}:${u}`;if(t.has(f))continue;t.add(f);const g=r.temporalValues??("time"===r.role||"x"===r.role&&"time"===o.xScaleType?"date-like":void 0),d="x"===r.role&&"log"===o.xScaleType||"y"===r.role&&"log"===o.yScaleType,m=M(r,o);s.push({contract:r,accessor:i,accessorLabel:u,dataProp:a,rows:l,requirements:m,logScale:d,observation:C(l,i,u,g,r.missingValue)})}return s}(t,o,n),i=[],l=!1!==s.checkOutliers;for(const e of function(e,o,n){const s=new Set;for(const t of e.fields){const e=t.dataProp??"data",r=n??o[e];if(!Array.isArray(r))continue;if(0===r.length){s.add(e);continue}const i=a(t,o);if(!i)continue;const c=r.map(e=>e?.[i]).filter(Array.isArray);c.length>0&&c.every(e=>0===e.length)&&s.add(`${e}.${i}`)}return[...s]}(t,o,n))i.push(T({severity:"error",code:"EMPTY_DATA",message:e+" is an explicitly empty array; there are no numeric inputs to render.",fix:`Provide at least one valid row, render an intentional empty state, or omit ${e} when using the ref push API.`,count:0,rows:[]}));const u=new Set(r.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(const e of u)i.push(T({severity:"warning",code:"SINGLE_ROW_DOMAIN",message:e+" has one row; a quantitative scale cannot establish variation from a single observation.",fix:"Provide at least two observations or use a single-value display such as BigNumber.",count:1,rows:[0]}));for(const e of r)i.push(...k(e,l));for(const e of t.aggregates??[])i.push(...L(e,r,o));const f=i.filter(e=>"error"===e.severity).length,g=i.length-f;return{component:e,ok:0===f,rowCount:r.reduce((e,o)=>Math.max(e,o.rows.length),n?.length??(Array.isArray(o.data)?o.data.length:0)),summary:{fieldsChecked:r.length,errors:f,warnings:g},contracts:r.map(e=>({role:e.contract.role,accessor:e.accessorLabel,dataProp:e.dataProp,requirements:e.requirements,allowMissing:!0===e.contract.allowMissing,...void 0!==e.contract.missingValue?{missingValue:e.contract.missingValue}:{},domain:!0===e.contract.domain})),diagnoses:i}}export{$ as BUILT_IN_NUMERIC_CONTRACTS,x as registerNumericContracts,z as unregisterNumericContracts,s as profileNumericFields,t as formatDataAudit,i as toDataAuditNotifications,V as auditData};
2
+ import{parseDateLikeString as e}from"./chunk-chunk-6V5VQVCT.module.min.js";function o(e,o){const n={numbers:[],missing:0,nonFinite:0,nonNumeric:0,zero:0,negative:0,fractional:0};for(const s of e){const e=s?.[o];if(null==e||""===e){n.missing++;continue}let t;if("number"==typeof e)t=e;else if("string"==typeof e){const o=e.trim();if(""===o){n.missing++;continue}const s=Number(o);Number.isNaN(s)?/^[+-]?nan$/i.test(o)&&(t=s):t=s}void 0!==t?Number.isFinite(t)?(n.numbers.push(t),0===t&&n.zero++,0>t&&n.negative++,Number.isInteger(t)||n.fractional++):n.nonFinite++:n.nonNumeric++}return n}function n(e,o){if(0===e.length)return;const n=(e.length-1)*o,s=Math.floor(n),t=Math.ceil(n);if(s===t)return e[s];const r=n-s;return e[s]*(1-r)+e[t]*r}function s(e,s={}){if(!Array.isArray(e)||0===e.length)return{};const t=new Set;for(const o of e)if(o&&"object"==typeof o)for(const e of Object.keys(o))t.add(e);const r={};for(const i of t){const t=o(e,i);let a=1/0,c=-1/0;for(const e of t.numbers)a>e&&(a=e),e>c&&(c=e);const l=!1===s.quantiles?void 0:[...t.numbers].sort((e,o)=>e-o);r[i]={field:i,observedCount:e.length-t.missing,finiteCount:t.numbers.length,missingCount:t.missing,nonFiniteCount:t.nonFinite,nonNumericCount:t.nonNumeric,zeroCount:t.zero,negativeCount:t.negative,fractionalCount:t.fractional,...t.numbers.length>0?{min:a,...l?{q1:n(l,.25),median:n(l,.5),q3:n(l,.75)}:{},max:c}:{}}}return r}function t(e){const o=[`${e.component}: ${e.ok?"✓ numerically safe":"✗ numeric hazards found"}`,`${e.rowCount} rows · ${e.summary.fieldsChecked} numeric fields · ${e.summary.errors} errors · ${e.summary.warnings} warnings`];for(const n of e.diagnoses)o.push(`${"error"===n.severity?"ERROR":"WARN"} ${n.code}${n.field?` [${n.field}]`:""}: ${n.message}`),n.fix&&o.push(" Fix: "+n.fix);return o.join("\n")}function r(e){return e.code.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function i(e,o={}){const n=Number.isFinite(o.max)?Math.max(0,Math.floor(o.max)):6,s=e.diagnoses.map((e,o)=>({item:e,diagnosisIndex:o})).filter(({item:e})=>!o.errorsOnly||"error"===e.severity),t=s.slice(0,n).map(({item:e,diagnosisIndex:o})=>({id:`data-audit:${e.code}:${e.role??"chart"}:${e.field??"chart"}:${o}`,level:e.severity,title:e.field?`${r(e)} · ${e.field}`:r(e),message:e.fix?`${e.message} ${e.fix}`:e.message,source:"Semiotic data audit",dismissible:!0}));return s.length>n&&t.push({id:"data-audit:overflow:chart",level:s.slice(n).some(({item:e})=>"error"===e.severity)?"error":"warning",title:`${s.length-n} more numeric finding${s.length-n===1?"":"s"}`,message:"Run auditData() or diagnoseConfig() to inspect the complete report.",source:"Semiotic data audit",dismissible:!0}),t}function a(e,o){const n=e.nestedDataAccessorProp?o[e.nestedDataAccessorProp]:void 0;return"string"==typeof n?n:e.defaultNestedDataAccessor}function c(e,o,n){const s=e.dataProp??"data",t=o[s],r=n??(Array.isArray(t)?t:[]),i=a(e,o);if(!i)return{dataProp:s,rows:r};const c=[];let l=!1;for(const e of r){const o=e?.[i];if(Array.isArray(o)){l=!0;for(const e of o)e&&"object"==typeof e&&c.push(e)}}return{dataProp:s,rows:l?c:r}}var l=[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date-like",domain:!0},{role:"y",accessor:"yAccessor",defaultAccessor:"y",domain:!0}],u={fields:l},f=[{...l[0],nestedDataAccessorProp:"lineDataAccessor",defaultNestedDataAccessor:"coordinates"},{...l[1],nestedDataAccessorProp:"lineDataAccessor",defaultNestedDataAccessor:"coordinates",allowMissing:!0}],g={fields:f},d={role:"value",accessor:"valueAccessor",defaultAccessor:"value"},m={...d,domain:!0},h={fields:[{...d,requirements:["finite","non-negative"]}],aggregates:[{kind:"positive-total",role:"value"}]},p={fields:[d],aggregates:[{kind:"normalized-total",role:"value",groupAccessor:"categoryAccessor",defaultGroupAccessor:"category",whenProp:"normalize"}]},v={fields:f,aggregates:[{kind:"normalized-total",role:"y",groupAccessor:"xAccessor",defaultGroupAccessor:"x",whenProp:"normalize"}]},w={fields:[...l,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},y={fields:[...l,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},A={fields:[d]},b={fields:[{...d,dataProp:"edges",requirements:["finite","non-negative"],missingValue:1}]},$={LineChart:g,AreaChart:g,BumpChart:g,Scatterplot:y,ConnectedScatterplot:u,QuadrantChart:y,MinimapChart:g,BubbleChart:w,StackedAreaChart:v,DifferenceChart:{fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date",domain:!0},{role:"value",accessor:"seriesAAccessor",defaultAccessor:"a"},{role:"value",accessor:"seriesBAccessor",defaultAccessor:"b"}]},CandlestickChart:{fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date-like",domain:!0},{role:"high",accessor:"highAccessor",defaultAccessor:"high",requirements:["finite"]},{role:"low",accessor:"lowAccessor",defaultAccessor:"low",requirements:["finite"]},{role:"open",accessor:"openAccessor",whenProps:["openAccessor","closeAccessor"],requirements:["finite"]},{role:"close",accessor:"closeAccessor",whenProps:["openAccessor","closeAccessor"],requirements:["finite"]}]},Heatmap:A,BarChart:{fields:[d]},GroupedBarChart:{fields:[d]},StackedBarChart:p,DotPlot:{fields:[m]},Histogram:{fields:[m]},BoxPlot:{fields:[m]},SwarmPlot:{fields:[m,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},ViolinPlot:{fields:[m]},RidgelinePlot:{fields:[m]},PieChart:h,DonutChart:h,FunnelChart:h,SankeyDiagram:b,ChordDiagram:b,ProportionalSymbolMap:{fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"lon",dataProp:"points",requirements:["finite"]},{role:"y",accessor:"yAccessor",defaultAccessor:"lat",dataProp:"points",requirements:["finite"]},{role:"size",accessor:"sizeBy",dataProp:"points",requirements:["finite","non-negative"]}]}},R=Symbol.for("semiotic.numericContractRegistry");function N(){const e=globalThis;return e[R]??(e[R]={contracts:new Map}),e[R]}function x(e,o){o?N().contracts.set(e,o):N().contracts.delete(e)}function z(e){N().contracts.delete(e)}var E={xAccessor:"x",yAccessor:"y",valueAccessor:"value",sizeBy:"size",sizeAccessor:"size",radiusAccessor:"size",countAccessor:"count",amountAccessor:"value",highAccessor:"high",lowAccessor:"low",openAccessor:"open",closeAccessor:"close",lowerAccessor:"lower",upperAccessor:"upper",positiveAccessor:"value",negativeAccessor:"value",progressAccessor:"value",confidenceAccessor:"value",costAccessor:"value",throughputAccessor:"value"};function P(e,o,n){return"function"==typeof e?e(o,n):o[e]}function I(o,n){if("number"==typeof o)return Number.isFinite(o)?o:null;if(o instanceof Date){const e=o.getTime();return n&&Number.isFinite(e)?e:null}if("string"==typeof o){const s=o.trim(),t=Number(s);if(s&&Number.isFinite(t))return t;if("date-like"===n){const o=e(s);return Number.isFinite(o)?o:null}}return null}function C(e){return"number"==typeof e&&!Number.isFinite(e)}function _(e,o,n,s,t){const r={field:n,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let n=0;e.length>n;n++){let i;try{i=P(o,e[n],n)}catch{r.accessorErrorRows.push(n);continue}if(null==i||""===i){if(void 0!==t){r.numbers.push(t),r.finiteRows.push(n),0===t&&r.zeroRows.push(n),0>t&&r.negativeRows.push(n),Number.isInteger(t)||r.fractionalRows.push(n);continue}r.missingRows.push(n);continue}const a=I(i,s);null!=a?(r.numbers.push(a),r.finiteRows.push(n),0===a&&r.zeroRows.push(n),0>a&&r.negativeRows.push(n),Number.isInteger(a)||r.fractionalRows.push(n)):C(i)?r.nonFiniteRows.push(n):r.nonNumericRows.push(n)}return r}function S(e,o){if(0===e.length)return;const n=(e.length-1)*o,s=Math.floor(n),t=Math.ceil(n);if(s===t)return e[s];const r=n-s;return e[s]*(1-r)+e[t]*r}function M(e,o){const n=new Set(e.requirements??["finite"]);return n.add("finite"),("x"===e.role&&"log"===o.xScaleType||"y"===e.role&&"log"===o.yScaleType)&&n.add("positive"),[...n]}function T(e){return e.slice(0,5)}function O(e){return{domain:"data",...e}}function k(e,o){const n=[],{observation:s,contract:t,accessorLabel:r,requirements:i}=e,a={field:r,role:t.role},c=[...s.nonFiniteRows,...s.nonNumericRows,...s.accessorErrorRows].sort((e,o)=>e-o);if(0===s.numbers.length)return n.push(O({severity:"error",code:"DEGENERATE_EXTENT",message:`${t.accessor}="${r}" produces no finite numeric values; the chart cannot resolve its ${t.role} input.`,fix:`Ensure ${r} contains finite numbers${"x"===t.role?" (or valid dates for a time scale)":""}.`,...a,...c.length>0?{rows:T(c),count:c.length}:{}})),n;s.nonFiniteRows.length>0&&n.push(O({severity:"error",code:"NON_FINITE_VALUE",message:`${r} contains ${s.nonFiniteRows.length} NaN or infinite value${1===s.nonFiniteRows.length?"":"s"}; scale and layout math require finite numbers.`,fix:`Filter or replace NaN/Infinity in ${r} before rendering.`,...a,rows:T(s.nonFiniteRows),count:s.nonFiniteRows.length})),!t.allowMissing&&s.missingRows.length>0&&n.push(O({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${r} is missing for ${s.missingRows.length} row${1===s.missingRows.length?"":"s"}; the ${t.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${r} values before rendering.`,...a,rows:T(s.missingRows),count:s.missingRows.length}));const l=[...s.nonNumericRows,...s.accessorErrorRows].sort((e,o)=>e-o);if(l.length>0&&n.push(O({severity:"error",code:"NON_NUMERIC_VALUE",message:`${r} produces ${l.length} non-numeric value${1===l.length?"":"s"} for the ${t.role} role.`,fix:`Bind ${t.accessor} to a numeric field or return finite numbers from the accessor.`,...a,rows:T(l),count:l.length})),t.domain&&s.numbers.length>=2){const[e,o]=function(e){let o=1/0,n=-1/0;for(const s of e)o>s&&(o=s),s>n&&(n=s);return[o,n]}(s.numbers);e===o&&n.push(O({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${r} is constant at ${e}; its ${t.role} scale has a zero-span data domain.`,fix:`Provide varying ${t.role} values, set an explicit extent around ${e}, or use a single-value display.`,...a,rows:T(s.finiteRows),count:s.finiteRows.length}))}if(i.includes("positive")){const o=s.numbers.map((e,o)=>({number:e,row:s.finiteRows[o]})).filter(({number:e})=>0>=e).map(({row:e})=>e);if(o.length>0){const s=e.logScale;n.push(O({severity:"error",code:s?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${r} contains ${o.length} non-positive value${1===o.length?"":"s"}, which ${s?"cannot be represented on a log scale":"violate the positive-value contract"}.`,fix:s?"Remove or transform values ≤ 0, or use a linear/symlog scale.":"Provide values greater than zero.",...a,rows:T(o),count:o.length}))}}if(i.includes("non-negative")&&s.negativeRows.length>0&&n.push(O({severity:"error",code:"size"===t.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${r} contains ${s.negativeRows.length} negative ${t.role} value${1===s.negativeRows.length?"":"s"}; the chart maps this role to non-negative geometry.`,fix:"Use a non-negative measure, clamp intentionally, or encode sign with position/color instead.",...a,rows:T(s.negativeRows),count:s.negativeRows.length})),i.includes("integer")){const e=[...new Set([...s.negativeRows,...s.zeroRows,...s.fractionalRows])].sort((e,o)=>e-o);e.length>0&&n.push(O({severity:"error",code:"INVALID_COUNT",message:`${r} contains ${e.length} value${1===e.length?"":"s"} that are not positive integers.`,fix:"Counts must be integers ≥ 1; aggregate, round intentionally, or use a continuous-value encoding.",...a,rows:T(e),count:e.length}))}if(i.includes("unit-interval")){const e=s.numbers.map((e,o)=>({number:e,row:s.finiteRows[o]})).filter(({number:e})=>0>e||e>1).map(({row:e})=>e);e.length>0&&n.push(O({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${r} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${r} to [0, 1] before using it as ${t.role}.`,...a,rows:T(e),count:e.length}))}if(o&&t.domain){const o=function(e){const o=e.observation.numbers.map((o,n)=>({value:o,row:e.observation.finiteRows[n]})).sort((e,o)=>e.value-o.value);if(8>o.length)return[];const n=o.map(e=>e.value),s=S(n,.25),t=S(n,.75),r=S(n,.5),i=t-s;if(i>0){const e=s-10*i,n=t+10*i;return o.filter(o=>e>o.value||o.value>n).map(e=>e.row)}const a=100*Math.max(1,Math.abs(r));return o.filter(e=>Math.abs(e.value-r)>a).map(e=>e.row)}(e);o.length>0&&n.push(O({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${r} has ${o.length} extreme value${1===o.length?"":"s"} beyond the 10×IQR guardrail; the main distribution may collapse visually.`,fix:"Verify the extreme values, then consider a log scale, robust extent, inset, or explicit annotation rather than silently clipping them.",...a,rows:T(o),count:o.length}))}return n}function D(e,o,n){if(!e)return"__all__";try{return P(e,o,n)+""}catch{return"__accessor_error__"}}function V(e,o,n){if(e.whenProp&&!0!==n[e.whenProp])return[];const s=o.find(o=>o.contract.role===e.role);if(!s||0===s.observation.numbers.length)return[];const t=e.groupAccessor?n[e.groupAccessor]:void 0,r="string"==typeof t||"function"==typeof t?t:e.defaultGroupAccessor,i=new Map;for(let e=0;s.rows.length>e;e++){let o;try{o=P(s.accessor,s.rows[e],e)}catch{continue}const n=I(o,void 0);if(null==n)continue;const t=D(r,s.rows[e],e),a=i.get(t)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};a.sum+=n,a.magnitude+=Math.abs(n),a.positive||(a.positive=n>0),a.negative||(a.negative=0>n),a.rows.push(e),0>n&&a.negativeRows.push(e),i.set(t,a)}const a=[],c=[],l=[],u=[],f=[],g=[];for(const[o,n]of i)("positive-total"===e.kind&&0>=n.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,n.magnitude)*10>=Math.abs(n.sum))&&(a.push(o),u.push(...n.rows)),"normalized-total"===e.kind&&n.positive&&n.negative&&(c.push(o),f.push(...n.rows)),"normalized-total"===e.kind&&n.negative&&(l.push(o),g.push(...n.negativeRows));const d=[];return a.length>0&&d.push(O({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${a.length} normalization group${1===a.length?" has":"s have"} a zero total, so division would be undefined.`:"The part-to-whole total is not positive, so meaningful shares cannot be computed.",fix:"normalized-total"===e.kind?"Remove empty/zero-sum groups or disable normalization.":"Provide at least one positive value and ensure the total is greater than zero.",field:s.accessorLabel,role:e.role,rows:T([...new Set(u)].sort((e,o)=>e-o)),count:a.length})),l.length>0&&d.push(O({severity:"error",code:"NEGATIVE_NORMALIZED_VALUE",message:`${l.length} normalization group${1===l.length?" contains":"s contain"} negative contributions, so conventional percentage shares are not defined.`,fix:"Use non-negative contributions, a diverging stack, or disable normalization.",field:s.accessorLabel,role:e.role,rows:T([...new Set(g)].sort((e,o)=>e-o)),count:g.length})),c.length>0&&d.push(O({severity:"warning",code:"MIXED_SIGN_NORMALIZATION",message:`${c.length} normalization group${1===c.length?" mixes":"s mix"} positive and negative contributions; percentage shares may be unstable or misleading.`,fix:"Separate positive and negative contributions, use diverging stacks, or disable normalization.",field:s.accessorLabel,role:e.role,rows:T([...new Set(f)].sort((e,o)=>e-o)),count:c.length})),d}function L(e,o,n,s={}){const t=s.contracts??function(e){return N().contracts.get(e)??$[e]}(e)??function(e){const o=[];for(const[n,s]of Object.entries(E))"string"!=typeof e[n]&&"function"!=typeof e[n]||o.push({role:s,accessor:n,..."size"===s?{requirements:["finite","non-negative"]}:{},..."x"===s||"y"===s?{domain:!0}:{}});return o.length>0?{fields:o}:void 0}(o);if(!t)return{component:e,ok:!0,rowCount:n?.length??(Array.isArray(o.data)?o.data.length:0),summary:{fieldsChecked:0,errors:0,warnings:0},contracts:[],diagnoses:[]};const r=function(e,o,n){const s=[],t=new Set;for(const r of e.fields){if(r.whenProps?.some(e=>null==o[e]))continue;const e=o[r.accessor],i="string"==typeof e||"function"==typeof e?e:r.defaultAccessor;if("string"!=typeof i&&"function"!=typeof i)continue;const{dataProp:a,rows:l}=c(r,o,n);if(0===l.length)continue;const u="string"==typeof i?i:r.accessor+"()",f=`${a}:${r.role}:${u}`;if(t.has(f))continue;t.add(f);const g=r.temporalValues??("time"===r.role||"x"===r.role&&"time"===o.xScaleType?"date-like":void 0),d="x"===r.role&&"log"===o.xScaleType||"y"===r.role&&"log"===o.yScaleType,m=M(r,o);s.push({contract:r,accessor:i,accessorLabel:u,dataProp:a,rows:l,requirements:m,logScale:d,observation:_(l,i,u,g,r.missingValue)})}return s}(t,o,n),i=[],l=!1!==s.checkOutliers;for(const e of function(e,o,n){const s=new Set;for(const t of e.fields){const e=t.dataProp??"data",r=n??o[e];if(!Array.isArray(r))continue;if(0===r.length){s.add(e);continue}const i=a(t,o);if(!i)continue;const c=r.map(e=>e?.[i]).filter(Array.isArray);c.length>0&&c.every(e=>0===e.length)&&s.add(`${e}.${i}`)}return[...s]}(t,o,n))i.push(O({severity:"error",code:"EMPTY_DATA",message:e+" is an explicitly empty array; there are no numeric inputs to render.",fix:`Provide at least one valid row, render an intentional empty state, or omit ${e} when using the ref push API.`,count:0,rows:[]}));const u=new Set(r.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(const e of u)i.push(O({severity:"warning",code:"SINGLE_ROW_DOMAIN",message:e+" has one row; a quantitative scale cannot establish variation from a single observation.",fix:"Provide at least two observations or use a single-value display such as BigNumber.",count:1,rows:[0]}));for(const e of r)i.push(...k(e,l));for(const e of t.aggregates??[])i.push(...V(e,r,o));const f=i.filter(e=>"error"===e.severity).length,g=i.length-f;return{component:e,ok:0===f,rowCount:r.reduce((e,o)=>Math.max(e,o.rows.length),n?.length??(Array.isArray(o.data)?o.data.length:0)),summary:{fieldsChecked:r.length,errors:f,warnings:g},contracts:r.map(e=>({role:e.contract.role,accessor:e.accessorLabel,dataProp:e.dataProp,requirements:e.requirements,allowMissing:!0===e.contract.allowMissing,...void 0!==e.contract.missingValue?{missingValue:e.contract.missingValue}:{},domain:!0===e.contract.domain})),diagnoses:i}}export{$ as BUILT_IN_NUMERIC_CONTRACTS,x as registerNumericContracts,z as unregisterNumericContracts,s as profileNumericFields,t as formatDataAudit,i as toDataAuditNotifications,L as auditData};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{STREAMING_PALETTE as e,createColorScale as t,filterSparseArray as r,getCrosshairProps as o,resolveMobileInteraction as n,useCategoryColors as a,useChartLegendAndMargin as i,useChartMode as l,useChartSelection as c,useColorScale as u,useLegendInteraction as s,useThemeCategorical as g}from"./chunk-chunk-7ZDJSYKI.module.min.js";import{useThemeSelector as d}from"./chunk-chunk-WCX6U47H.module.min.js";import{renderEmptyState as h,renderLoadingState as m}from"./chunk-chunk-ACLDBMRH.module.min.js";import{useMemo as y}from"react";function p(e){const t=d(e=>e.theme.colors.selectionOpacity);return y(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}import{useCallback as f,useMemo as v,useState as L}from"react";function b(l){const{data:d,rawData:y,colorBy:b,colorScheme:k,legendInteraction:C,legendPosition:H,selection:S,linkedHover:w,fallbackFields:D,unwrapData:B=!1,onObservation:I,chartType:M,chartId:R,showLegend:F,legend:P,legendLayout:A,userMargin:T,marginDefaults:x,onClick:O,hoverHighlight:W,mobileInteraction:j,mobileSemantics:z,loading:G,loadingContent:N,emptyContent:_,width:J,height:K,hasTitle:U,axisChrome:V}=l,X=void 0===y,Y=v(()=>r(d),[d]),[Z,q]=L([]),E=f(e=>{q(t=>t.length===e.length&&t.every((t,r)=>t===e[r])?t:e)},[]),Q="string"==typeof l.colorBy?l.colorBy:void 0,$=v(()=>n(j,{width:J,mobileSemantics:z}),[j,J,z]),{activeSelectionHook:ee,hoverSelectionHook:te,customHoverBehavior:re,customClickBehavior:oe,crosshairSourceId:ne}=c({selection:S,linkedHover:w,fallbackFields:D,unwrapData:B,onObservation:I,chartType:M,chartId:R,onClick:O,hoverHighlight:W,colorByField:Q,mobileInteraction:$}),ae=o(w,ne),ie=u(Y,b,k),le=v(()=>{if(!b)return[];const e=new Set;for(const t of Y){const r="function"==typeof b?b(t):t[b];null!=r&&e.add(r+"")}return Array.from(e)},[Y,b]),ce=v(()=>X&&Z.length>0?Z:le,[X,Z,le]),ue=s(C,b,ce),se=v(()=>te||(ue.legendSelectionHook?ue.legendSelectionHook:ee),[te,ue.legendSelectionHook,ee]),ge=p(S),de=g(),he=a(),me=v(()=>{if(ie)return ie;if(!b||0===ce.length)return;const r=Array.isArray(k)&&k.length>0||"string"==typeof k&&k.length>0?k:de&&de.length>0?de:e,o="__streamCat",n=ce.map(e=>({[o]:e})),a=t(n,o,r);return e=>he?.[e]||a(e)||"#999"},[ie,b,ce,k,de,he]),{legend:ye,margin:pe,legendPosition:fe}=i({data:Y,colorBy:b,colorScale:me,showLegend:F,legendPosition:H,userMargin:T,defaults:x,categories:ce,additionalLegend:P,chartWidth:J,legendLayout:A,hasTitle:U,axisChrome:V}),ve=v(()=>{const e={};return ye&&(e.legend=ye,e.legendPosition=fe,A&&(e.legendLayout=A)),C&&"none"!==C&&(e.legendHoverBehavior=ue.onLegendHover,e.legendClickBehavior=ue.onLegendClick,e.legendHighlightedCategory=ue.highlightedCategory,e.legendIsolatedCategories=ue.isolatedCategories),X&&b&&(e.legendCategoryAccessor=b,e.onCategoriesChange=E),e},[ye,fe,A,C,ue.onLegendHover,ue.onLegendClick,ue.highlightedCategory,ue.isolatedCategories,X,b,E]),Le=Array.isArray(y)?r(y):y,be=m(G,J,K,N),ke=be?null:h(Le,J,K,_);return{data:Y,colorScale:ie,allCategories:ce,legendState:ue,effectiveSelectionHook:se,activeSelectionHook:ee,customHoverBehavior:re,customClickBehavior:oe,mobileInteraction:$,legend:ye,margin:pe,legendPosition:fe,earlyReturn:be||ke||null,legendBehaviorProps:ve,crosshairProps:ae,resolvedSelection:ge}}import{useImperativeHandle as k,useRef as C}from"react";function H(e,t){const{variant:r,frameRef:o,overrides:n}=t,a=C(n);a.current=n,k(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,r)=>e.current?.update(t,r)??[],replace:t=>e.current?.replace?.(t),clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const r=Array.isArray(t)?t:[t],o=e.current?.getTopology()?.nodes??[],n=[];for(const t of r){const r=o.find(e=>e.id===t);r&&n.push({...r.data??{},id:t}),e.current?.removeNode(t)}return n},update:(t,r)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const o=e.current?.updateNode(t,r);return o?[{...o,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,r)=>{const o=e.current?.removePoint(t)??[];for(const t of o)e.current?.push(r(t));return o},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const r=t;return{push:e=>r.current?.pushLine(e),pushMany:e=>r.current?.pushManyLines(e),remove:e=>r.current?.removeLine(e)??[],update:(e,t)=>{const o=r.current?.removeLine(e)??[];for(const e of o)r.current?.pushLine(t(e));return o},clear:()=>r.current?.clear(),getData:()=>r.current?.getLines()??[],getCustomLayout:()=>r.current?.getCustomLayout?.()??null,getLayoutFailure:()=>r.current?.getLayoutFailure?.()??null}}(r,o);return new Proxy(e,{get(e,t,r){if("string"==typeof t){const e=a.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,r)},has:(e,t)=>!("string"!=typeof t||!a.current||!(t in a.current))||Reflect.has(e,t)})},[])}function S(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const r={};return void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...r}):(...e)=>({...r})}function w(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}import{useMemo as D,useRef as B}from"react";function I(e){const t=B(null);return H(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:l(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:D(()=>w(e.margin),[e.margin])}}function M(e){const t=I(e),{resolved:r,normalizedMargin:o}=t,n=b({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,selection:e.selection,linkedHover:e.linkedHover,hoverHighlight:e.hoverHighlight,fallbackFields:"string"==typeof e.colorBy?[e.colorBy]:[],unwrapData:e.unwrapData,onObservation:e.onObservation,onClick:e.onClick,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:e.chartTypeLabel,chartId:e.chartId,showLegend:r.showLegend,legend:e.legend,userMargin:o,marginDefaults:r.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:r.width,height:r.height});return{...t,safeData:n.data,setup:n,earlyReturn:n.earlyReturn}}export{p as useResolvedSelection,b as useChartSetup,H as useFrameImperativeHandle,S as mergeShapeStyle,w as normalizePartialMargin,I as useCustomChartScaffold,M as useCustomChartSetup};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ var e=["value","threshold","partition-boundary","time-window","range-boundary"];function t({controlType:e,controlId:t,chartId:a,chartType:o="VisualizationControl",onObservation:n}){return(r,i,s)=>{n?.({type:r,controlType:e,value:i,chartType:o,timestamp:Date.now(),...t?{controlId:t}:{},...a?{chartId:a}:{},...s?{source:s}:{}})}}function a(e,t,a,o,n){return{id:e,...t?{controlId:t}:{},status:a,message:o,...n?{remediation:n}:{}}}function o({controls:t=[],minimumTargetSize:o=24}){const n=[],r=new Set;for(const i of t){const t=i?.id,s="controls."+(t||"unknown"),l=i?.domain,u=Array.isArray(l)&&2===l.length&&Number.isFinite(l[0])&&Number.isFinite(l[1])&&l[1]>l[0],d=e.includes(i?.type),c="string"==typeof i?.target&&i.target.trim().length>0,p=["slider","buttons","native-range"].includes(i?.keyboard??""),m=i?.minimumTargetSize;n.push(a(s+".semantic-type",t,d?"pass":"fail",d?`Control uses the semantic type "${i.type}".`:"Control has no recognized semantic type.","Use one of VISUALIZATION_CONTROL_TYPES.")),n.push(a(s+".state-binding",t,c?"pass":"fail",c?`Control is bound to "${i.target}".`:"Control has no declarative state binding.","Declare the controlled state key with target.")),n.push(a(s+".domain",t,u?"pass":"fail",u?"Control has a finite ordered value domain.":"Control has no finite ordered value domain.","Declare domain as [minimum, maximum].")),n.push(a(s+".keyboard",t,p?"pass":"fail",p?`Control declares a ${i.keyboard} keyboard path.`:"Control does not declare a keyboard path.","Declare slider, buttons, or native-range keyboard interaction.")),n.push(a(s+".value-text",t,"string"==typeof i?.valueText&&i.valueText.trim().length>0?"pass":"fail","string"==typeof i?.valueText&&i.valueText.trim().length>0?"Control declares human-readable value text.":"Control does not declare human-readable value text.","Provide valueText, typically with a {value} placeholder.")),n.push(a(s+".target-size",t,"number"!=typeof m||o>m?"fail":"pass","number"!=typeof m||o>m?`Control target is below the ${o}px minimum or undeclared.`:`Control declares a ${m}px target.`,`Declare minimumTargetSize of at least ${o}.`)),null!=i?.step&&n.push(a(s+".step",t,Number.isFinite(i.step)&&i.step>0?"pass":"fail",Number.isFinite(i.step)&&i.step>0?"Control has a positive quantization step.":"Control step must be a positive finite number.","Use a positive finite step.")),i?.observations?.length&&n.push(a(s+".observations",t,i.observations.includes("control-change")?"pass":"warn",i.observations.includes("control-change")?"Control declares control-change observation coverage.":"Control declares observations but omits control-change.","Include control-change so observable state changes are represented.")),t&&!r.has(t)||n.push(a(s+".identity",t,"fail",t?"Control id is duplicated.":"Control id is missing.","Use a unique stable control id.")),t&&r.add(t)}return{ok:n.every(e=>"fail"!==e.status),findings:n}}export{e as VISUALIZATION_CONTROL_TYPES,t as createControlObservationAdapter,o as auditVisualizationControls};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{StreamPhysicsFrame_default as e}from"./chunk-chunk-NW25WGLS.module.min.js";import{resolveMotionAccessor as t}from"./chunk-chunk-5SD6BHVW.module.min.js";function n(e,t,n={}){const s=new Set,o=[...e.get(t)??[]];let i=0;for(;o.length>i;){const t=o[i];if(i+=1,!s.has(t)){s.add(t);for(const n of e.get(t)??[])o.push(n)}}return n.includeStart&&s.add(t),s}function s(e,n,s){return t(s,e,n)}function o(e,t){return t>e?-1:e>t?1:0}function i(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function r(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function a(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function c(e){const t=[],n=new Map,c=[],d=new Set;e.data.forEach((i,r)=>{const l=(s(i,r,e.taskIDAccessor)??"")+"";if(!l)return void t.push({code:"duplicate-task-id",message:`Task row ${r} has an empty id.`,taskIDs:[]});if(n.has(l))return void t.push({code:"duplicate-task-id",message:`Task id "${l}" occurs more than once.`,taskIDs:[l]});const h=(s(i,r,e.laneAccessor)??"Unassigned")+"";d.has(h)||(d.add(h),c.push(h));const m=s(i,r,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(m,e=>e+""))).sort(o),p=s(i,r,e.blockerAccessor),g=s(i,r,e.statusAccessor)??(p?"blocked":"waiting");n.set(l,{id:l,label:(s(i,r,e.labelAccessor)??l)+"",lane:h,laneIndex:0,level:0,index:r,datum:i,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:s(i,r,e.startAccessor),end:s(i,r,e.endAccessor),progress:a(s(i,r,e.progressAccessor)),status:g,completionTime:s(i,r,e.completionTimeAccessor),blockerReason:p||void 0,milestone:!!s(i,r,e.milestoneAccessor)})});const l=e.laneOrder?[...e.laneOrder,...c.filter(t=>!e.laneOrder?.includes(t))]:c,h=new Map(l.map((e,t)=>[e,t]));for(const e of n.values())e.laneIndex=h.get(e.lane)??0;const m=new Map,u=new Map;for(const e of n.keys())m.set(e,[]),u.set(e,[]);const p=[],g=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of g)e.dependencyIDs.forEach((s,o)=>{const a=n.get(s);if(!a)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${s}".`,taskIDs:[e.id,s]});const c={id:i(s,e.id),sourceID:s,targetID:e.id,sourceIndex:a.index,targetIndex:e.index,socketID:r(e.id,o),socketIndex:o};p.push(c),m.get(e.id)?.push(c),u.get(s)?.push(c),e.incomingEdgeIDs.push(c.id),e.socketIDs.push(c.socketID),a.outgoingEdgeIDs.push(c.id)});for(const e of m.values())e.sort((e,t)=>o(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=r(e.targetID,t)});for(const e of u.values())e.sort((e,t)=>o(e.targetID,t.targetID));for(const e of n.values()){const t=m.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(u.get(e.id)??[]).map(e=>e.id)}const f=new Map,y=new Map;for(const e of n.keys())f.set(e,m.get(e)?.length??0),y.set(e,0);const k=[...n.keys()].filter(e=>0===f.get(e)).sort(o);let I=0;for(;k.length;){const e=k.shift();I+=1;for(const t of u.get(e)??[]){const n=Math.max(y.get(t.targetID)??0,(y.get(e)??0)+1);y.set(t.targetID,n);const s=(f.get(t.targetID)??0)-1;if(f.set(t.targetID,s),0===s){const e=k.findIndex(e=>e>t.targetID);0>e?k.push(t.targetID):k.splice(e,0,t.targetID)}}}if(I!==n.size){const e=[...n.keys()].filter(e=>(f.get(e)??0)>0).sort(o);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let x=0;const D=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of D)e.level=y.get(e.id)??0,x=Math.max(x,e.level);return{nodes:D,edges:p,byID:n,incoming:m,outgoing:u,lanes:l,maxLevel:x,diagnostics:t,valid:0===t.length}}function d(e,t,n={}){const s=Math.max(240,t.width),i=Math.max(220,t.height),r=t.paddingX??48,a=t.paddingTop??48,c=t.paddingBottom??44,d=Math.max(70,(s-2*r)/Math.max(1,e.lanes.length)),l=Math.max(76,(i-a-c)/Math.max(1,e.maxLevel+1)),h=Math.min(n.taskWidth??112,Math.max(58,.78*d)),m=Math.min(n.taskHeight??58,.64*l),u=n.socketRadius??5,p=Math.max(1,Math.round(n.gutterCount??3)),g=new Map;for(const t of e.nodes){const e=`${t.laneIndex}:${t.level}`,n=g.get(e)??[];n.push(t),g.set(e,n)}for(const e of g.values())e.sort((e,t)=>o(e.id,t.id));const f=.86*l,y=e.nodes.map(e=>{const t=g.get(`${e.laneIndex}:${e.level}`)??[e],n=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,s=(o=t.length)>1?Math.max(22,Math.min(m,(f-4*(o-1))/o)):m;var o;return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:r+d*(e.laneIndex+.5),y:a+l*(e.level+.5)+n*(s+4),width:h,height:s}}),k=new Map(y.map(e=>[e.taskID,e])),I=[],x=[];e.edges.forEach((t,n)=>{const s=k.get(t.sourceID),o=k.get(t.targetID);if(!s||!o)return;const i=e.incoming.get(t.targetID)??[],r=Math.min(.72*o.width,14*Math.max(1,i.length-1)),a=i.length>1?o.x-r/2+r*t.socketIndex/(i.length-1):o.x,c=o.y-o.height/2-u-2;I.push({id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:a,y:c,radius:u});const d={x:s.x,y:s.y+s.height/2+3},l=Math.min(c-10,d.y+.48*Math.max(18,c-d.y)+7*(n%p-(p-1)/2));var h;x.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(h=[d,{x:d.x,y:l},{x:a,y:l},{x:a,y:c}],h.filter((e,t)=>{const n=h[t-1];return!n||n.x!==e.x||n.y!==e.y}))})});const D=new Map(I.map(e=>[e.id,e])),v=new Map(x.map(e=>[e.edgeID,e]));return{tasks:y,sockets:I,routes:x,taskByID:k,socketByID:D,routeByEdgeID:v}}function l(e,t,n="all"){const s=Array.from(new Set(t)).sort(o),i=new Set,r=()=>s.every(e=>i.has(e));return{taskID:e,mode:n,incomingEdgeIDs:s,deliver:e=>s.includes(e)?(i.add(e),r()):r(),reset:(e=[])=>{i.clear();for(const t of e)s.includes(t)&&i.add(t)},isSatisfied:r,getSnapshot:()=>({taskID:e,mode:n,incomingEdgeIDs:[...s],deliveredEdgeIDs:[...i].sort(o),satisfied:r()})}}function h(e){return e instanceof Date?e.getTime():Number(e)}function m(e,t){const n=h("object"!=typeof t||t instanceof Date?t:t.currentTime),s=e.map((e,t)=>({event:e,index:t,time:h(e.at)})).filter(e=>Number.isFinite(e.time)&&n>=e.time).sort((e,t)=>e.time-t.time||e.index-t.index),o=new Set,i=new Map,r=new Set,a=new Set;for(const{event:e}of s)"task-completed"===e.type?(o.add(e.taskID),i.delete(e.taskID)):"task-blocked"===e.type?i.set(e.taskID,e.reason):"task-unblocked"===e.type?i.delete(e.taskID):"dependency-delivered"===e.type?r.add(e.edgeID):"task-armed"===e.type&&a.add(e.taskID);return{currentTime:n,appliedEvents:s.map(e=>e.event),completedTaskIDs:o,blockedByTaskID:i,deliveredEdgeIDs:r,armedTaskIDs:a}}function u(e,t,s={}){const o=new Set(s.completedTaskIDs??[]),i=[...n(function(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target);return n}(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(s.isComplete?s.isComplete(e):o.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),r=Array.from(new Set(i.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:i.length,affectedLaneCount:r.length,downstreamTaskIDs:i.map(e=>e.id),affectedLanes:r}}import{forwardRef as p,useCallback as g,useEffect as f,useImperativeHandle as y,useMemo as k,useRef as I,useState as x}from"react";var D=[];function v(e,t=0){if(e instanceof Date)return e.getTime();const n=Number(e);return Number.isFinite(n)?n:t}function b(e){if(null==e.completionTime)return null;const t=v(e.completionTime,NaN);return Number.isFinite(t)?t:null}function w(e,t,n,s){const o=new Set;for(const i of e.nodes){const r=e.incoming.get(i.id)??[];(s.has(i.id)||!n.has(i.id)&&r.every(e=>t.has(e.id)))&&o.add(i.id)}return o}function T(e,t,n,s){const o=e.nodes.map(b).filter(e=>null!=e),i=o.length?Math.min(...o)-1:0,r="replay"!==t||s?n:i,a=new Set,c=new Map;for(const n of e.nodes){const e=b(n);(null!=e&&r>=e||"done"===n.status&&"replay"!==t)&&a.add(n.id),n.blockerReason&&!a.has(n.id)&&c.set(n.id,n.blockerReason)}const d=new Set;if("replay"!==t||s)for(const t of e.edges)a.has(t.sourceID)&&d.add(t.id);return{currentTime:r,playing:!1,completed:a,delivered:d,inFlight:new Set,armed:w(e,d,c,a),blockers:c,previewTaskID:null}}function M(e){return{...e,completed:new Set(e.completed),delivered:new Set(e.delivered),inFlight:new Set(e.inFlight),armed:new Set(e.armed),blockers:new Map(e.blockers)}}function S(e){const t=e.datum;return"dependency-ball"===t?.kind&&Array.isArray(t.route)?t:null}function A(e){const t=S(e.body);if(!t||2>t.route.length)return null;const n=function(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}(t.route),s=function(e,t){let n=1/0,s=0,o=0;for(let i=1;t.length>i;i+=1){const r=t[i-1],a=t[i],c=a.x-r.x,d=a.y-r.y,l=c*c+d*d,h=Math.sqrt(l);if(0>=h)continue;const m=Math.max(0,Math.min(1,((e.x-r.x)*c+(e.y-r.y)*d)/l)),u=Math.hypot(e.x-(r.x+c*m),e.y-(r.y+d*m));n>u&&(n=u,s=o+m*h),o+=h}return s}(e.body,t.route),o=function(e,t){if(2>e.length)return{point:e[0]??{x:0,y:0},tangent:{x:0,y:1}};let n=0;for(let s=1;e.length>s;s+=1){const o=e[s-1],i=e[s],r=i.x-o.x,a=i.y-o.y,c=Math.hypot(r,a);if(c>0){if(n+c>=t){const e=Math.max(0,Math.min(1,(t-n)/c));return{point:{x:o.x+r*e,y:o.y+a*e},tangent:{x:r/c,y:a/c}}}n+=c}}const s=e[e.length-2],o=e[e.length-1],i=o.x-s.x,r=o.y-s.y,a=Math.hypot(i,r)||1;return{point:o,tangent:{x:i/a,y:r/a}}}(t.route,Math.min(n,s+22));return{x:2.5*(78*o.tangent.x-e.body.vx)+8*(o.point.x-e.body.x),y:2.5*(78*o.tangent.y-e.body.vy)+8*(o.point.y-e.body.y)}}function C(e,t){const n=t.points[0]??{x:0,y:0},s=t.points[1]??n,o=s.x-n.x,i=s.y-n.y,r=Math.hypot(o,i)||1;return{id:"dependency-ball:"+e.id,x:n.x,y:n.y,vx:o/r*42,vy:i/r*42,mass:.7,restitution:.02,friction:.12,bodyCollisions:!1,shape:{type:"circle",radius:5},datum:{kind:"dependency-ball",edgeID:e.id,sourceID:e.sourceID,targetID:e.targetID,route:t.points}}}import{jsx as $,jsxs as L}from"react/jsx-runtime";function E({machine:e,layout:t,runtime:n,downstreamSet:s,selectedSet:o,width:i,height:r,seed:a,reduced:c,onSelectTask:d}){const l=t.tasks.length?Math.min(...t.tasks.map(e=>e.y-e.height/2)):60,h=Math.max(20,l-12),m=Math.max(26,l-6);return L("svg",{"aria-hidden":"true",width:i,height:r,viewBox:`0 0 ${i} ${r}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[$("defs",{children:$("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:$("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,n)=>{const s=t.tasks.filter(e=>e.laneIndex===n),o=s[0]?.x??0;return L("g",{children:[$("line",{x1:o,x2:o,y1:m,y2:r-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),$("text",{x:o,y:h,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{const t=n.delivered.has(e.edgeID),o=n.inFlight.has(e.edgeID),i=s.has(e.targetID)||s.has(e.sourceID),r=e.points.map(e=>`${e.x},${e.y}`).join(" ");return $("polyline",{points:r,fill:"none",stroke:i?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:i?4:o?3:2,strokeOpacity:t||o||i?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{const t=n.delivered.has(e.edgeID);return L("g",{children:[$("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&$("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{const i=t.taskByID.get(e.id);if(!i)return null;const r=n.completed.has(e.id),l=n.blockers.has(e.id),h=n.previewTaskID===e.id,m=o.has(e.id)||h,u=s.has(e.id),p=function(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}(e,n),g=i.x-i.width/2,f=i.y-i.height/2,y=Math.max(2,i.height*e.progress);return L("g",{children:[L("g",{style:{transform:`rotate(${r?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:c?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+a+")"},children:[$("rect",{x:g,y:f,width:i.width,height:i.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:m||u?"var(--semiotic-selection-color, #e08a1e)":p,strokeWidth:m?4:u?3:2}),$("rect",{x:g+3,y:f+i.height-y+1,width:i.width-6,height:Math.max(0,y-4),rx:2,fill:p,opacity:r?.86:.46})]}),l&&L("g",{opacity:h?.28:1,children:[$("line",{x1:g-8,x2:g+14,y1:i.y+9,y2:i.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),$("circle",{cx:g-8,cy:i.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),L("g",{onPointerDown:()=>d(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[$("rect",{x:g,y:f,width:i.width,height:i.height,fill:"transparent"}),$("text",{x:i.x,y:i.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),L("text",{x:i.x,y:i.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",r?"done":l?"blocked":n.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}import{jsx as W,jsxs as N}from"react/jsx-runtime";var B={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},F=p(function(t,n){const{data:s,taskIDAccessor:o,labelAccessor:i,laneAccessor:r,dependencyAccessor:a,startAccessor:l,endAccessor:h,progressAccessor:m,statusAccessor:p,completionTimeAccessor:$,blockerAccessor:L,milestoneAccessor:F,mode:j="snapshot",insight:R="blocker-amplification",currentTime:z,controls:O=!1,selectedTaskIDs:H,onSelectionChange:P,onObservation:U,reducedMotion:q,seed:G=31,width:V=920,height:X=620,responsiveWidth:J,responsiveHeight:K,title:Q="Dependency chain reaction",description:Y,className:Z,accessibleTable:_=!0,enableHover:ee=!0}=t,te=I(null),[ne,se]=x([]),oe=H?Array.from(H):ne,ie=k(()=>new Set(oe),[oe]),re=v(z,1/0),ae="settle"===q,ce=k(()=>c({data:s,taskIDAccessor:o,labelAccessor:i,laneAccessor:r,dependencyAccessor:a,startAccessor:l,endAccessor:h,progressAccessor:m,statusAccessor:p,completionTimeAccessor:$,blockerAccessor:L,milestoneAccessor:F}),[s,o,i,r,a,l,h,m,p,$,L,F]),de=k(()=>d(ce,{width:V,height:X}),[ce,V,X]),[le,he]=x(()=>T(ce,j,re,ae)),me=I(le),ue=g(e=>{me.current=e,he(e)},[]),pe=g(e=>U?.(e),[U]);f(()=>{const e=T(ce,j,re,ae);te.current?.clear(),me.current=e,he(e)},[ce,j,re,ae]);const ge=g(e=>{const t=ie.has(e)?oe.filter(t=>t!==e):[e];H||se(t),P?.(t)},[H,P,ie,oe]),fe=g(e=>{if(ae)return;const t=M(me.current),n=[];for(const s of ce.outgoing.get(e)??[]){if(t.delivered.has(s.id)||t.inFlight.has(s.id))continue;const e=de.routeByEdgeID.get(s.id);e&&(t.inFlight.add(s.id),n.push(C(s,e)))}n.length&&(ue(t),te.current?.pushMany(n,{pacing:{ratePerSec:8}}))},[ue,de,ce,ae]),ye=g((e,t)=>{const n=ce.byID.get(e),s=me.current;if(!n||s.completed.has(e))return;const o=M(s);o.completed.add(e),o.blockers.delete(e),o.armed.add(e),null!=t&&(o.currentTime=t),ue(o),pe({type:"task-completed",taskID:e,datum:n.datum}),fe(e)},[ue,pe,ce,fe]),ke=g(e=>{const t=M(me.current),n=[],s=[];for(const s of e){if(t.delivered.has(s))continue;const e=ce.edges.find(e=>e.id===s);e&&(t.delivered.add(s),t.inFlight.delete(s),n.push(e))}for(const e of n){const n=ce.byID.get(e.targetID);!n||t.blockers.has(n.id)||t.armed.has(n.id)||(ce.incoming.get(n.id)??[]).every(e=>t.delivered.has(e.id))&&(t.armed.add(n.id),s.push(n.id))}if(n.length){ue(t);for(const e of n)pe({type:"dependency-delivered",sourceID:e.sourceID,targetID:e.targetID});for(const e of s)pe({type:"task-armed",taskID:e})}},[ue,pe,ce]),Ie=g((e,t)=>{const n=[],s=[];for(const e of t.readBodies()){const t=S(e);if(!t||me.current.delivered.has(t.edgeID))continue;const o=t.route[t.route.length-1];o&&9>=Math.hypot(e.x-o.x,e.y-o.y)&&(n.push(t.edgeID),s.push(e.id))}s.length&&t.remove(s),n.length&&ke(n)},[ke]),xe=g(()=>{const e=M(me.current);for(const t of ce.edges)e.completed.has(t.sourceID)&&e.delivered.add(t.id);e.inFlight.clear(),e.armed=w(ce,e.delivered,e.blockers,e.completed),e.playing=!1,te.current?.settle(),ue(e),pe({type:"machine-settled"})},[ue,pe,ce]),De=g(()=>{const e=M(me.current);e.playing=!1,ue(e)},[ue]),ve=g(()=>{const e=me.current,t=ce.nodes.map(e=>({node:e,time:b(e)})).filter(t=>null!=t.time&&t.time>e.currentTime&&!e.completed.has(t.node.id)).sort((e,t)=>e.time-t.time||e.node.index-t.node.index)[0];if(t)return void ye(t.node.id,t.time);De();const n=[...e.blockers.keys()].map(t=>u(ce,t,{completedTaskIDs:e.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);n[0]&&pe({type:"machine-stalled",blockerID:n[0].blockerID,downstreamTaskCount:n[0].downstreamTaskCount,affectedLaneCount:n[0].affectedLaneCount})},[pe,ce,De,ye]),be=g(()=>{if(ae)return void xe();const e=M(me.current);e.playing=!0,ue(e)},[ue,ae,xe]);f(()=>{if(!le.playing||"replay"!==j||ae)return;const e=window.setInterval(ve,760);return()=>window.clearInterval(e)},[j,ae,le.playing,ve]);const we=g(()=>{te.current?.clear(),ue(T(ce,j,re,ae))},[ue,ce,j,re,ae]),Te=g(e=>{if(!ce.byID.has(e))return;const t=M(me.current);t.previewTaskID=e,ue(t);const n=u(ce,e,{completedTaskIDs:t.completed});pe({type:"blocker-previewed",blockerID:e,downstreamTaskIDs:n.downstreamTaskIDs})},[ue,pe,ce]),Me=g(()=>{const e=M(me.current);e.previewTaskID=null,ue(e)},[ue]),Se=g((e,t)=>{if(!ce.byID.has(e))return;const n=M(me.current);n.blockers.set(e,t),n.armed.delete(e),ue(n)},[ue,ce]),Ae=g(e=>{if(!ce.byID.has(e))return;const t=M(me.current);t.blockers.delete(e),(ce.incoming.get(e)??[]).every(e=>t.delivered.has(e.id))&&t.armed.add(e),ue(t)},[ue,ce]),Ce=g(e=>u(ce,e,{completedTaskIDs:me.current.completed}),[ce]),$e=g(()=>{const e=me.current;return{currentTime:e.currentTime,playing:e.playing,previewTaskID:e.previewTaskID,selectedTaskIDs:[...oe],tasks:ce.nodes.map(t=>({taskID:t.id,completed:e.completed.has(t.id),armed:e.armed.has(t.id),blocked:e.blockers.has(t.id),blockerReason:e.blockers.get(t.id)})),dependencies:ce.edges.map(t=>({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,state:e.delivered.has(t.id)?"delivered":e.inFlight.has(t.id)?"in-flight":"waiting"}))}},[ce,oe]);y(n,()=>({play:be,pause:De,step:ve,reset:we,settle:xe,previewResolve:Te,clearPreview:Me,completeTask:ye,blockTask:Se,unblockTask:Ae,getAmplification:Ce,getMachineState:$e}),[Se,Me,Ce,$e,De,ye,be,Te,we,xe,ve,Ae]);const Le=le.previewTaskID??oe[0]??null,Ee=Le?u(ce,Le,{completedTaskIDs:le.completed}):null,We=k(()=>new Set(Ee?.downstreamTaskIDs??[]),[Ee?.downstreamTaskIDs]),Ne=k(()=>function(e,t,n){return e.nodes.flatMap(s=>{const o=t.taskByID.get(s.id);if(!o)return[];const i=e.incoming.get(s.id)??[],r=i.filter(e=>n.delivered.has(e.id)).length,a=n.blockers.get(s.id),c=n.completed.has(s.id)?"completed":a?"blocked: "+a:n.armed.has(s.id)?"armed":"waiting";return[{id:s.id,label:`${s.label}, ${s.lane}, ${Math.round(100*s.progress)}%, ${c}`,description:`${r} of ${i.length} prerequisites delivered.`,datum:s.datum,x:o.x,y:o.y,width:o.width,height:o.height,shape:"rect",group:s.lane}]})}(ce,de,le),[de,ce,le]),Be=k(()=>W(E,{machine:ce,layout:de,runtime:le,downstreamSet:We,selectedSet:ie,width:V,height:X,seed:G,reduced:ae,onSelectTask:ge}),[We,X,de,ce,ae,le,G,ge,ie,V]),Fe=k(()=>{const e=[...le.blockers.keys()].map(e=>u(ce,e,{completedTaskIDs:le.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);return e.length?e.map(e=>`${ce.byID.get(e.blockerID)?.label??e.blockerID} affects ${e.downstreamTaskCount} unfinished tasks across ${e.affectedLaneCount} lanes.`).join(" "):"No explicit blockers are active."},[ce,le.blockers,le.completed]),je=k(()=>[{id:"chain-left",shape:{type:"segment",x1:2,y1:0,x2:2,y2:X,thickness:4}},{id:"chain-right",shape:{type:"segment",x1:V-2,y1:0,x2:V-2,y2:X,thickness:4}},{id:"chain-top",shape:{type:"segment",x1:0,y1:2,x2:V,y2:2,thickness:4}},{id:"chain-bottom",shape:{type:"segment",x1:0,y1:X-2,x2:V,y2:X-2,thickness:4}}],[X,V]),Re=!0===O?["play","pause","step","reset","settle"]:O||[];return N("div",ce.valid?{className:Z,style:{width:V,maxWidth:"100%",position:"relative"},children:[Re.length>0&&W("div",{"aria-label":"Chain reaction replay controls",style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:Re.map(e=>W("button",{type:"button",onClick:"play"===e?be:"pause"===e?De:"step"===e?ve:"reset"===e?we:xe,"aria-pressed":"play"===e?le.playing:void 0,children:e[0].toUpperCase()+e.slice(1)},e))}),W(e,{ref:te,size:[V,X],responsiveWidth:J,responsiveHeight:K,title:Q,description:Y??"Tasks are arranged by workstream and dependency depth. Balls represent satisfied prerequisites; task completion remains an explicit data event.",summary:`${Fe}${Ee&&"blocker-amplification"===R?` Selected task reaches ${Ee.downstreamTaskCount} unfinished tasks across ${Ee.affectedLaneCount} lanes.`:""}`,accessibleTable:!1,enableHover:ee,initialSpawns:D,bodyForces:A,bodyStyle:{fill:"var(--semiotic-primary, #f0a329)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.25},bodySemanticItems:!1,semanticItems:Ne,onSemanticItemActivate:e=>e.id&&ge(e.id),foregroundGraphics:()=>Be,paused:ae,continuous:le.inFlight.size>0,onTick:Ie,config:{bodyLimit:Math.max(16,ce.edges.length+4),colliders:je,settleStepLimit:2200,kernel:{seed:G,gravity:{x:0,y:7},fixedDt:1/60,cellSize:28,collisionIterations:2,velocityDamping:.992,restitution:.02,friction:.12,maxVelocity:150,sleepSpeed:1.1,sleepAfter:.8},observation:{chartType:"ChainReactionChart"}}}),_&&N("table",{style:B,children:[W("caption",{children:Fe}),W("thead",{children:N("tr",{children:[W("th",{children:"Task"}),W("th",{children:"Lane"}),W("th",{children:"Progress"}),W("th",{children:"State"}),W("th",{children:"Waiting on"}),W("th",{children:"Downstream reach"})]})}),W("tbody",{children:ce.nodes.map(e=>{const t=u(ce,e.id,{completedTaskIDs:le.completed});return N("tr",{children:[W("th",{scope:"row",children:e.label}),W("td",{children:e.lane}),N("td",{children:[Math.round(100*e.progress),"%"]}),W("td",{children:le.completed.has(e.id)?"Completed":le.blockers.has(e.id)?"Blocked":le.armed.has(e.id)?"Armed":"Waiting"}),W("td",{children:le.blockers.get(e.id)??(e.dependencyIDs.filter(e=>!le.completed.has(e)).join(", ")||"None")}),N("td",{children:[t.downstreamTaskCount," tasks / ",t.affectedLaneCount," lanes"]})]},e.id)})})]})]}:{className:Z,role:"alert",style:{width:V,maxWidth:"100%"},children:[W("strong",{children:"ChainReactionChart could not compile this dependency graph."}),W("ul",{children:ce.diagnostics.map((e,t)=>W("li",{children:e.message},`${e.code}-${t}`))})]})});F.displayName="ChainReactionChart";export{c as compileDependencyMachine,d as routeDependencyTracks,l as createLogicalJoin,m as replayStateTransitions,u as calculateBlockerAmplification,F as ChainReactionChart};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{mulberry32 as t}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{forceCenter as e,forceCollide as r,forceLink as o,forceManyBody as n,forceSimulation as s,forceX as c,forceY as a}from"d3-force";function i(i,g,f={}){const d=f.iterations??260,h=f.repulsion??5200,u=f.linkDistance??165,m=f.linkStrength??.045,p=f.centerStrength??.018,l=f.damping??.84,y=f.nodeRadius??12,x=f.nodePadding??3,M=f.inset??.06,k=t(f.seed??1),S=new Map;for(const t of i)S.set(t.id,0);for(const t of g)S.set(t.source,(S.get(t.source)??0)+1),S.set(t.target,(S.get(t.target)??0)+1);const D=500,w=i.map(t=>({id:t.id,data:t,x:200+600*k(),y:200+600*k()})),q=new Set(i.map(t=>t.id)),I=g.filter(t=>q.has(t.source)&&q.has(t.target)).map(t=>({source:t.source,target:t.target}));if(d>0){const t=s(w).randomSource(k).alphaDecay(1-Math.pow(.001,1/d)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",n().strength(t=>{const e=S.get(t.id)??0;return 2.5*-Math.sqrt(h)*Math.sqrt(e+1)})).force("collide",r(t=>(t=>"function"==typeof y?y(t.data):y)(t)+x).strength(.9).iterations(2)).force("center",e(D,D).strength(.8)).force("x",c(D).strength(p)).force("y",a(D).strength(p));I.length>0&&t.force("link",o(I).id(t=>t.id).distance(u).strength(t=>{const e="string"==typeof t.target?t.target:t.target.id,r=Math.max(1,Math.min(S.get("string"==typeof t.source?t.source:t.source.id)??1,S.get(e)??1));return m/.045/r})),t.stop();for(let e=0;d>e;e+=1)t.tick()}let R=1/0,j=1/0,v=-1/0,J=-1/0;for(const t of w){const e=t.x??D,r=t.y??D;R>e&&(R=e),j>r&&(j=r),e>v&&(v=e),r>J&&(J=r)}const P=v-R,Y=J-j,b={};for(const t of w)b[t.id]={x:0===P?.5:M+((t.x??D)-R)/P*(1-2*M),y:0===Y?.5:M+((t.y??D)-j)/Y*(1-2*M)};return b}export{i as forceLayout};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{MobileStandardControls as e}from"./chunk-chunk-UOQRPGPK.module.min.js";import{buildNavigationTree as t,copyConfig as i,describeChart as n,flattenVisible as o}from"./chunk-chunk-GU2EJIDJ.module.min.js";import{DataSummaryProvider as r,LinkedCharts as a,annotationStableId as s,resolveResponsiveRules as l,useChartObserver as c,useDataSummaryToggle as d,useLinkedChartsActive as m,useObservationSelector as u,useSelection as p}from"./chunk-chunk-7ZDJSYKI.module.min.js";import{ChartErrorBoundary as h}from"./chunk-chunk-ACLDBMRH.module.min.js";async function f(e,t){const{format:i="png",filename:n="chart",scale:o=2,background:r="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),g(a,s),"svg"===i){const e=(new XMLSerializer).serializeToString(s);b(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n+".svg")}else{const t=l.width*o,i=l.height*o,a=document.createElement("canvas");a.width=t,a.height=i;const c=a.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,i),c.scale(o,o);const d=e.querySelector("canvas");d&&c.drawImage(d,0,0,l.width,l.height);const m=(new XMLSerializer).serializeToString(s),u=new Blob([m],{type:"image/svg+xml;charset=utf-8"}),p=URL.createObjectURL(u),h=new Image;h.width=l.width,h.height=l.height,await new Promise((e,t)=>{h.onload=()=>{c.drawImage(h,0,0),a.toBlob(i=>{i?(b(i,n+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(p)},h.onerror=()=>{URL.revokeObjectURL(p),t(Error("Failed to load SVG image"))},h.src=p})}}function g(e,t){const i=e.children,n=t.children,o=window.getComputedStyle(e),r=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of r){const i=o.getPropertyValue(e);i&&"none"!==i&&""!==i&&t.style?.setProperty(e,i)}for(let e=0;Math.min(i.length,n.length)>e;e++)g(i[e],n[e])}function b(e,t){const i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(i)}var y=null,v=new Set,x=new Set,w=1e3;function k(e,t,i){const n=e??t;if(!Number.isFinite(n)||0>=n)throw new RangeError(`${i} must be a positive number, got ${n+""}`);return Math.floor(n)}function S(e,t){void 0!==console&&console.warn(`[conversationArc] ${e} failed:`,t)}function C(e,t){try{const i=t();i&&"function"==typeof i.then&&Promise.resolve(i).catch(t=>S(e,t))}catch(t){S(e,t)}}function N(e){if(e)return e;try{return globalThis.localStorage??null}catch{return null}}function A(e,t){if(!e)return[];try{return function(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(e){return S("localStorage load",e),[]}}(e.getItem(t))}catch(e){return S("localStorage read",e),[]}}var I=Object.freeze([]),j=I,z=!1;function $(){return z?(j=y?Object.freeze(y.buffer.slice()):I,z=!1,j):j}function M(){z=!0}var R=new Set;function T(){for(const e of R)try{e()}catch(e){void 0!==console&&console.warn("[conversationArc] change subscriber threw:",e)}}function B(e){return R.add(e),()=>{R.delete(e)}}function E(e){if(!e||"object"!=typeof e)throw new TypeError("registerConversationArcSink: sink must be an object");return x.add(e),()=>{x.delete(e)}}function L(e={}){const t=e.key??"semiotic:conversation-arc",i=k(e.maxEvents,w,"createLocalStorageConversationArcSink: maxEvents");return{record(n){const o=N(e.storage),r=A(o,t);r.push(n),function(e,t,i,n){if(e)try{e.setItem(t,JSON.stringify(i.slice(-n)))}catch(e){S("localStorage write",e)}}(o,t,r,i)},clear(){const i=N(e.storage);if(i)try{i.removeItem(t)}catch(e){S("localStorage clear",e)}},load:()=>A(N(e.storage),t)}}function D(e={}){const t=e.dbName??"semiotic-conversation-arc",i=e.storeName??"events",n=k(e.maxEvents,w,"createIndexedDBConversationArcSink: maxEvents");let o=null;const r=()=>(o??(o=function(e,t,i){const n=function(e){if(e)return e;try{return globalThis.indexedDB??null}catch{return null}}(i);return n?new Promise(i=>{let o;try{o=n.open(e,1)}catch(e){return S("IndexedDB open",e),void i(null)}o.onupgradeneeded=()=>{const e=o.result;e.objectStoreNames.contains(t)||e.createObjectStore(t,{keyPath:"id",autoIncrement:!0})},o.onsuccess=()=>i(o.result),o.onerror=()=>{S("IndexedDB open",o.error),i(null)},o.onblocked=()=>{S("IndexedDB open",Error("upgrade blocked")),i(null)}}):Promise.resolve(null)}(t,i,e.indexedDB)),o);return{async record(e){const t=await r();t&&(await new Promise(n=>{try{const o=t.transaction(i,"readwrite");o.objectStore(i).add({event:e}),o.oncomplete=()=>n(),o.onerror=()=>{S("IndexedDB record",o.error),n()}}catch(e){S("IndexedDB record",e),n()}}),await function(e,t,i){return e?new Promise(n=>{try{const o=e.transaction(t,"readwrite"),r=o.objectStore(t),a=r.getAll();a.onsuccess=()=>{const e=Array.isArray(a.result)?a.result:[],t=e.length-i;if(t>0)for(const i of e.slice(0,t))null!=i.id&&r.delete(i.id)},a.onerror=()=>S("IndexedDB trim",a.error),o.oncomplete=()=>n(),o.onerror=()=>{S("IndexedDB trim",o.error),n()}}catch(e){S("IndexedDB trim",e),n()}}):Promise.resolve()}(t,i,n))},async clear(){const e=await r();e&&await new Promise(t=>{try{const n=e.transaction(i,"readwrite");n.objectStore(i).clear(),n.oncomplete=()=>t(),n.onerror=()=>{S("IndexedDB clear",n.error),t()}}catch(e){S("IndexedDB clear",e),t()}})},load:async()=>function(e,t){return e?new Promise(i=>{try{const n=e.transaction(t,"readonly").objectStore(t).getAll();n.onsuccess=()=>{i((Array.isArray(n.result)?n.result:[]).map(e=>e.event).filter(Boolean))},n.onerror=()=>{S("IndexedDB load",n.error),i([])}}catch(e){S("IndexedDB load",e),i([])}}):Promise.resolve([])}(await r(),i)}}function P(e){if(!e.url)throw new TypeError("createWebhookConversationArcSink: url is required");const t=e.method??"POST";return{record(i){const n=e.fetch??globalThis.fetch;if(!n)return;const o=e.mapEvent?e.mapEvent(i):i;return n(e.url,{method:t,headers:{"Content-Type":"application/json",...e.headers},body:JSON.stringify(o)}).then(()=>{})}}}function H(e,t={}){const i=Array.isArray(e)?e.slice():[],n=k(t.capacity,Math.max(y?.capacity??w,i.length,1),"loadConversationArc: capacity"),o=t.sessionId??i[0]?.sessionId??y?.sessionId??V();for(y?(y.enabled=t.enabled??!1,y.sessionId=o,y.capacity=n):y={enabled:t.enabled??!1,sessionId:o,capacity:n,buffer:[]},t.append||(y.buffer=[]),y.buffer.push(...i);y.buffer.length>y.capacity;)y.buffer.shift();return M(),T(),$()}function W(e,t={}){return H(e,t)}function F(e,t,i){return _.record({type:"audience-set",audience:e,previous:t??void 0,...i})}function O(e,t){return _.record({type:"annotation-status-changed",toStatus:e,annotationId:t?.annotationId,fromStatus:t?.fromStatus,chartId:t?.chartId,arcId:t?.arcId,meta:t?.meta})}function V(){return`arc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function U(){return y}function q(e={}){const t=e.capacity??1e3;if(!Number.isFinite(t)||0>=t)throw new RangeError("enableConversationArc: capacity must be a positive number, got "+t);if(y){if(y.enabled=!0,e.sessionId&&(y.sessionId=e.sessionId),null!=e.capacity){for(y.capacity=t;y.buffer.length>y.capacity;)y.buffer.shift();M()}}else y={enabled:!0,sessionId:e.sessionId??V(),capacity:t,buffer:[]},M();return T(),_}function G(){y&&(y.enabled=!1,T())}function J(){return _}var _={get enabled(){return y?.enabled??!1},get sessionId(){return y?.sessionId??null},get capacity(){return y?.capacity??0},record(e){const t=U();if(!t||!t.enabled)return null;const i={...e,timestamp:e.timestamp??Date.now(),sessionId:e.sessionId??t.sessionId};for(t.buffer.push(i);t.buffer.length>t.capacity;)t.buffer.shift();M(),T();for(const e of v)try{e(i)}catch(e){void 0!==console&&console.warn("[conversationArc] subscriber threw:",e)}return function(e){for(const t of x)t.record&&C("sink record",()=>t.record?.(e))}(i),i},flush(){const e=U();if(!e)return[];const t=e.buffer.slice();return e.buffer=[],M(),T(),function(e){for(const t of x)t.flush&&C("sink flush",()=>t.flush?.(e))}(t),t},getEvents:()=>$(),subscribe:e=>(v.add(e),()=>{v.delete(e)}),clear(){const e=U();e&&(e.buffer=[],M(),T()),function(){for(const e of x)e.clear&&C("sink clear",()=>e.clear?.())}()},reset(){if(v.clear(),x.clear(),j=I,z=!1,!y)return T(),void R.clear();y.buffer=[],y.enabled=!1,y=null,T(),R.clear()}};import*as Z from"react";import{jsx as K,jsxs as X}from"react/jsx-runtime";var Y={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function Q({tree:e,label:t,visible:i=!1,className:n,onActiveChange:r,activeId:a,chartId:l,onObservation:c,onAnnotationActivate:d}){const[m,p]=Z.useState(()=>new Set([e.id])),[h,f]=Z.useState(e.id),g=void 0!==a,b=g?a:h,y=Z.useRef(null),v=Z.useRef(new Map),x=u(e=>e.pushObservation),w=Z.useCallback(e=>{c?.(e),x?.(e)},[c,x]),k=Z.useMemo(()=>function(e){const t=new Map,i=e=>{for(const n of e.children??[])t.set(n.id,e),i(n)};return i(e),t}(e),[e]),S=Z.useMemo(()=>o(e,m),[e,m]);Z.useEffect(()=>{g||S.some(e=>e.id===h)||f(e.id)},[S,h,e.id,g]),Z.useEffect(()=>{const e=[];let t=k.get(b);for(;t;)e.push(t.id),t=k.get(t.id);e.length>0&&p(t=>{if(e.every(e=>t.has(e)))return t;const i=new Set(t);for(const t of e)i.add(t);return i})},[b,k]),Z.useEffect(()=>{y.current?.contains(document.activeElement)&&v.current.get(b)?.focus()},[b]);const C=Z.useCallback((e,t,i)=>{const n=J();n.enabled&&n.record("focus"===t?{type:"nav-node-focused",chartId:l,nodeId:e.id,role:e.role,level:e.level,label:e.label.length>200?e.label.slice(0,200):e.label}:{type:"nav-branch-expanded",chartId:l,nodeId:e.id,role:e.role,level:e.level,expanded:!!i})},[l]),N=Z.useCallback(e=>{e.id!==b&&(g||f(e.id),r?.(e),C(e,"focus"),e.datum&&w({type:"focus",datum:e.datum,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:l}))},[r,g,C,b,w,l]),A=Z.useCallback(e=>{if(e.datum){if("annotation"===e.role){const t=s(e.datum);return d?.({annotation:e.datum,annotationId:t,chartId:l,inputType:"navigation-tree"}),void(t&&w({type:"annotation-activate",annotationId:t,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:l}))}w({type:"activate",datum:e.datum,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:l})}},[l,w,d]),I=e=>{p(t=>new Set(t).add(e.id)),C(e,"toggle",!0)},j=e=>{p(t=>{const i=new Set(t);return i.delete(e.id),i}),C(e,"toggle",!1)},z=(e,t,n)=>{const o=!!e.children&&e.children.length>0,r=m.has(e.id);return X("li",{role:"treeitem","aria-label":e.label,"aria-level":e.level,"aria-posinset":t,"aria-setsize":n,"aria-expanded":o?r:void 0,"aria-selected":e.id===b,tabIndex:e.id===b?0:-1,ref:t=>{v.current.set(e.id,t)},onClick:t=>{t.stopPropagation(),N(e),o?(r?j:I)(e):A(e)},style:i?{listStyle:"none",padding:"2px 6px",paddingLeft:6+16*(e.level-1),cursor:o?"pointer":"default",fontSize:13,color:"var(--semiotic-text, currentColor)",background:e.id===b?"var(--semiotic-surface, var(--semiotic-grid, var(--semiotic-bg, #f0f4f8)))":"transparent",outline:"none"}:void 0,children:[X("span",{className:"semiotic-nav-tree-label semiotic-nav-tree-"+e.role,children:[i&&o?r?"▾ ":"▸ ":"",e.label]}),o&&r&&K("ul",{role:"group",style:i?{margin:0,padding:0}:void 0,children:e.children.map((t,i)=>z(t,i+1,e.children.length))})]},e.id)};return K("div",{ref:y,className:"semiotic-nav-tree"+(n?" "+n:""),style:i?void 0:Y,onKeyDown:e=>{const t=S.findIndex(e=>e.id===b);if(-1===t)return;const i=S[t],n=!!i.children&&i.children.length>0,o=m.has(i.id);let r=!0;switch(e.key){case"ArrowDown":N(S[Math.min(t+1,S.length-1)]);break;case"ArrowUp":N(S[Math.max(t-1,0)]);break;case"Home":N(S[0]);break;case"End":N(S[S.length-1]);break;case"ArrowRight":n&&!o?I(i):n&&o?N(i.children[0]):r=!1;break;case"ArrowLeft":if(n&&o)j(i);else{const e=k.get(i.id);e?N(e):r=!1}break;case"Enter":case" ":n?(o?j:I)(i):A(i);break;default:r=!1}r&&(e.preventDefault(),e.stopPropagation())},children:K("ul",{role:"tree","aria-label":t||"Chart navigation",style:i?{margin:0,padding:0}:void 0,children:z(e,1,1)})})}var ee=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart","RealtimeLineChart","RealtimeHeatmap"]),te=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),ie={Scatterplot:["pointRadius","hoverRadius"],BubbleChart:["pointRadius","hoverRadius"],ConnectedScatterplot:["pointRadius","hoverRadius"],QuadrantChart:["pointRadius","hoverRadius"],SwarmPlot:["pointRadius","hoverRadius"],DotPlot:["dotRadius","hoverRadius"]};function ne(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function oe(e){return"string"==typeof e&&e.trim().length>0}function re(e){const t=ne(e.capability)?e.capability:null,i=ne(e.recipe)?e.recipe:null,n=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,i?.mobile];for(const e of n)if(ne(e))return e;return null}function ae(e){return Array.isArray(e)&&e.length>=2&&"number"==typeof e[0]&&"number"==typeof e[1]&&Number.isFinite(e[0])&&Number.isFinite(e[1])?[e[0],e[1]]:null}function se(e){return ae(e.size)||ae(ne(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function le(e,t){e.push({...t,status:"pass"})}function ce(e,t){e.push({...t,status:"warn"})}function de(e,t){e.push({...t,status:"manual"})}function me(e,t={},i={}){const n=i.viewportWidth??390,o=i.targetSize??44,r=se(t),a=l(t,{width:n,height:r?.[1]}),s=[],c=se(t=a.props),d=re(t),m=function(e,t){return e.includes("CustomChart")||e.includes("Custom")||null!=t.recipeId||null!=t.mobileSemantics}(e,t),u=function(e){const t=re(e);return!0===e.responsive||!0===e.mobile||!0===t?.responsive||!0===t?.supportsResponsiveLayout||Array.isArray(t?.breakpoints)||"number"==typeof t?.minViewportWidth||"responsive"===t?.strategy||"small-multiples"===t?.strategy||"summary-cards"===t?.strategy||null!=e.mobileLayout||null!=e.responsiveRules||"mobile-readable"===e.density}(t),p=!0===i.inChartContainer,h=oe(t.title)||oe(t.summary)||oe(t.description)||!0===d?.summary||oe(d?.summary);if(a.matches.length>0&&le(s,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${a.matches.length} responsive rule(s) applied for the ${n}px mobile audit.`}),c){const[t,i]=c;t>n&&!u?ce(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${n}px mobile viewport with no responsive/mobile transform hint.`,fix:"Use responsive sizing, responsiveRules/mobileLayout, or an explicit mobile variant that preserves the task instead of clipping the desktop chart."}):le(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof d?.minViewportWidth&&d.minViewportWidth>n&&ce(s,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${d.minViewportWidth}px minimum, wider than the audited ${n}px viewport.`,fix:"Add a narrower breakpoint, summary-card fallback, or explicit horizontal-scroll affordance with a non-visual equivalent."});const o=t/Math.max(1,i);430>=n&&o>2.4&&"BigNumber"!==e&&ce(s,{id:"layout.wide-aspect-ratio",category:"layout",impact:"medium",message:`Chart aspect ratio is ${o.toFixed(1)}:1, which tends to compress phone charts vertically.`,fix:"Prefer stacked sections, small multiples, cards plus a sparkline, or a taller mobile-specific chart ratio."}),160>i&&"BigNumber"!==e&&ce(s,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${i}px; most phone charts need enough vertical room for marks plus readable labels.`,fix:"Reserve more vertical space, remove nonessential axes, or switch to a card/sparkline pattern with external labels."})}else de(s,{id:"layout.unknown-size",category:"layout",impact:"medium",message:"No explicit size is available to audit. This may be responsive, but static mobile overflow cannot be checked.",fix:"Audit rendered widths at 320, 360, 390, and 430px, or pass size/responsiveRules metadata into the config."});const f=function(e){const t=[e.data,e.points,e.lines,e.nodes,e.edges,e.areas,ne(e.frameProps)?e.frameProps.data:void 0];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i}(t);f>0&&(f>("number"==typeof d?.maxMarks?d.maxMarks:ee.has(e)?1.25*n:te.has(e)?Math.max(8,Math.floor(n/34)):n)?ce(s,{id:"density.mark-budget",category:"density",impact:ee.has(e)?"medium":"high",message:`${f} data item(s) exceed the rough mobile density budget for ${e} at ${n}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):le(s,{id:"density.mark-budget",category:"density",impact:"medium",message:f+" data item(s) are within the rough mobile density budget for this component."}));const g=function(e){const t=[e.tickValues,e.xTickValues,e.yTickValues,e.rTickValues,e.oTickValues];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i>0?i:null}(t),b=!1!==t.showAxes&&!1!==t.axis;if(b&&null!=g){const e=Math.max(3,Math.floor(n/58));g>e&&ce(s,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${g} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${n}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else b&&(ee.has(e)||te.has(e))&&de(s,{id:"density.axis-label-collision",category:"density",impact:"medium",message:"Axes are enabled, but label collision depends on rendered tick text and cannot be checked statically.",fix:"Verify tick labels at phone widths or provide explicit mobile tick density."});!function(e){const t=ne(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=re(e),i=ne(e.mobileInteraction)?e.mobileInteraction:null;return null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||null!=e.selection||null!=e.onClick||null!=e.onSelect||!0===e.mobileInteraction||!0===i?.tapToSelect||!0===i?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||oe(t?.interaction?.hoverFallback)}(e)}(t)?le(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):ce(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"The chart exposes tooltip/hover detail without an obvious tap, selection, or control alternative.",fix:"Enable tap-to-select, a persistent details panel, visible segment buttons, or another non-hover path for the same information."});const y=function(e,t){const i=ie[e];if(!i)return null;let n=i.includes("hoverRadius")?30:null;for(const e of i){const i=t[e];"number"==typeof i&&Number.isFinite(i)&&i>0&&(n=null==n?i:Math.max(n,i))}return null==n?null:2*n}(e,t),v=ne(t.mobileInteraction)?t.mobileInteraction:null,x=y??("number"==typeof v?.targetSize?v.targetSize:!0===t.mobileInteraction?44:"number"==typeof d?.minimumHitTarget?d.minimumHitTarget:"number"==typeof d?.interaction?.targetSize?d.interaction.targetSize:null);null!=x&&(24>x?ce(s,{id:"interaction.target-size-minimum",category:"interaction",impact:"high",message:`Small interactive marks expose an estimated ${x}px pointer target, below WCAG's 24px minimum.`,fix:"Increase mark radius/hoverRadius, add tap snapping to nearest datum, or provide larger external controls."}):o>x?ce(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${x}px, above 24px but below the ${o}px comfortable phone target.`,fix:"Use hoverRadius/tapRadius near 44px while keeping the visible mark small if needed."}):le(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${x}px, meeting the configured ${o}px target.`}));const w=[];null==t.brush&&null==t.onBrush||w.push("brush"),!0===t.zoomable&&w.push("pan/zoom"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||w.push("legend filtering"),w.length>0&&!function(e,t){const i=re(e),n=ne(e.mobileInteraction)?e.mobileInteraction:null,o=n?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(i?.interaction?.alternatives)&&i.interaction.alternatives.length>0)||!0===o||"all"===o||t.every(e=>"brush"===e?Array.isArray(o)?o.includes("brush"):"brush"===o:"pan/zoom"===e?Array.isArray(o)?o.includes("zoom"):"zoom"===o:"legend filtering"===e&&(Array.isArray(o)?o.includes("legend"):"legend"===o))}(t,w)&&ce(s,{id:"interaction.complex-gesture-alternative",category:"interaction",impact:"high",message:`Mobile-hostile complex interaction detected: ${w.join(", ")} without standard control alternatives.`,fix:"Pair gestures with buttons, range inputs, chips, or a details panel that works with touch and keyboard."}),!1===t.showLegend||!1===t.legend||!0!==t.showLegend&&!0!==t.legend&&null==t.colorBy&&null==t.groupBy&&null==t.lineBy&&null==t.areaBy&&null==t.stackBy||!0===t.directLabel||!0===t.showLabels||"direct"===t.labelStrategy||"direct-end"===t.labelStrategy||"direct"===d?.labels?.strategy||"inline"===d?.labels?.strategy||"external"===d?.labels?.strategy||n>430||ce(s,{id:"semantics.legend-over-direct-labels",category:"semantics",impact:"medium",message:"The chart appears to rely on a legend instead of direct labels at phone width.",fix:"Prefer direct end labels, inline labels, or a compact chip selector so readers do not bounce between plot and legend."});const k=Array.isArray(t.annotations)?t.annotations.filter(e=>ne(e)):[];if(k.length>("number"==typeof d?.maxAnnotations?d.maxAnnotations:3)&&430>=n&&ce(s,{id:"annotation.mobile-density",category:"annotation",impact:"medium",message:k.length+" annotation(s) compete for phone plot space.",fix:"Assign annotation priority, collapse secondary notes into a callout list, or provide shorter mobileText."}),k.length>0){const e=k.filter(e=>!oe(e.mobileText)&&!oe(e.shortText)&&!oe(e.label));e.length>0&&de(s,{id:"annotation.mobile-copy",category:"annotation",impact:"low",message:e.length+" annotation(s) lack explicit short/mobile copy.",fix:"Add mobileText or shortText for notes that need to survive narrow layouts."})}u||"BigNumber"===e||de(s,{id:"layout.no-responsive-transform",category:"layout",impact:"low",message:"No explicit responsive transformation hint is present.",fix:"Declare responsiveRules/mobileLayout or a density/label strategy so the mobile version is a designed transformation, not an accidental resize."}),m&&(d?(le(s,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart/recipe provides a mobileSemantics/mobile contract, so the audit can inspect its authored phone behavior."}),!1===d.custom?.dataBearingSceneNodes?ce(s,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"medium",message:"Custom mobile contract says emitted scene nodes are not data-bearing.",fix:"Preserve datum references, semantic roles, or accessible-table fields so intelligence, navigation, and tap details can recover the chart's meaning."}):!0!==d.custom?.dataBearingSceneNodes&&de(s,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"low",message:"Custom chart mobile contract does not state whether scene nodes are data-bearing.",fix:"Set mobile.custom.dataBearingSceneNodes and mobile.custom.navigationGranularity for custom layouts and interoperability adapters."})):de(s,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart layout is opaque to static mobile analysis because no mobileSemantics/mobile contract is present.",fix:"Declare mobileSemantics with strategy, breakpoints, mark budgets, touch target size, interaction alternatives, and custom scene semantics."})),h||p||ce(s,{id:"semantics.no-mobile-summary",category:"semantics",impact:"medium",message:"No title, summary, description, or ChartContainer context is visible from the config.",fix:"Add title/summary text or wrap in ChartContainer so the small-screen reader gets the task before the chart."});const S=s.filter(e=>"warn"===e.status),C={highRisk:S.filter(e=>"high"===e.impact).length,warnings:S.length,manual:s.filter(e=>"manual"===e.status).length,passes:s.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:n,ok:0===C.highRisk,summary:C,findings:s,reference:"Mobile visualization audit: informed by MobileVisFixer, mobile exploratory interaction research, small-multiple mobile studies, responsive visualization grammars, constraint-based breakpoints, and WCAG 2.2 input modalities."}}var ue={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},pe=["layout","density","interaction","annotation","semantics"];function he(e){const t=[],i=e.summary,n=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${i.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${n} - ${i.warnings} warning(s) - ${i.manual} manual check(s)`);for(const i of pe){const n=e.findings.filter(e=>e.category===i&&"not-applicable"!==e.status);if(0!==n.length){t.push(""),t.push(" "+i.toUpperCase());for(const e of n)t.push(` ${ue[e.status]} [${e.impact}] ${e.id}: ${e.message}`),!e.fix||"warn"!==e.status&&"manual"!==e.status||t.push(" -> "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function fe(){return["Static audit only: rendered label collision, CSS-resolved type size, and actual touch behavior still require viewport testing.","Use multiple widths, usually 320, 360, 390, 430, and 768 CSS pixels.","A mobile pass means no high-risk static warnings, not that the chart is perceptually or ergonomically optimal."]}import*as ge from"react";import*as be from"react";var ye,ve=[];function xe(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function we(e){return e&&"object"==typeof e&&"number"==typeof e.targetSize?e.targetSize:void 0}function ke(e){return Array.isArray(e)?e.length>0:!!e}import{Fragment as Se,jsx as Ce,jsxs as Ne}from"react/jsx-runtime";var Ae={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function Ie(){const e=d();return e?Ce("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:De,children:Ne("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[Ce("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),Ce("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),Ce("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}var je={info:"var(--semiotic-info, #2563eb)",success:"var(--semiotic-success, #16a34a)",warning:"var(--semiotic-warning, #d97706)",error:"var(--semiotic-error, var(--semiotic-danger, #dc2626))",neutral:"var(--semiotic-text-secondary, #6b7280)"},ze={error:4,warning:3,info:2,success:1,neutral:0};function $e({level:e}){const t={width:15,height:15,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};switch(e){case"error":case"warning":return Ne("svg",{...t,children:[Ce("path",{d:"M8 1.8 15 14H1L8 1.8Z"}),Ce("path",{d:"M8 6.4v3.4"}),Ce("circle",{cx:"8",cy:"11.8",r:"0.5",fill:"currentColor",stroke:"none"})]});case"success":return Ne("svg",{...t,children:[Ce("circle",{cx:"8",cy:"8",r:"6.4"}),Ce("path",{d:"M5 8.2 7 10.2 11 5.8"})]});case"info":return Ne("svg",{...t,children:[Ce("circle",{cx:"8",cy:"8",r:"6.4"}),Ce("path",{d:"M8 7.4V11"}),Ce("circle",{cx:"8",cy:"5",r:"0.5",fill:"currentColor",stroke:"none"})]});default:return Ne("svg",{...t,children:[Ce("path",{d:"M8 2a3.5 3.5 0 0 0-3.5 3.5c0 4-1.5 5-1.5 5h10s-1.5-1-1.5-5A3.5 3.5 0 0 0 8 2Z"}),Ce("path",{d:"M6.5 13a1.5 1.5 0 0 0 3 0"})]})}}function Me({notification:e,level:t,onDismiss:i}){const n=je[t]??je.info,o=!1!==e.dismissible;return Ne("div",{className:"semiotic-chart-notification semiotic-chart-notification--"+t,style:{display:"flex",alignItems:"flex-start",gap:8,padding:"6px 10px",borderRadius:4,borderLeft:"3px solid "+n,background:"var(--semiotic-surface, rgba(127, 127, 127, 0.08))"},children:[Ne("div",{style:{flex:1,minWidth:0},children:[e.source&&Ce("div",{className:"semiotic-chart-notification-source",style:{fontSize:9,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #666)"},children:e.source}),e.title&&Ce("div",{className:"semiotic-chart-notification-title",style:{fontSize:12,fontWeight:600,color:n},children:e.title}),Ce("div",{className:"semiotic-chart-notification-message",style:{fontSize:12,lineHeight:1.45,color:"var(--semiotic-text, #333)"},children:e.message})]}),o&&Ce("button",{className:"semiotic-chart-notification-dismiss","aria-label":e.title?"Dismiss notification: "+e.title:"Dismiss notification",title:"Dismiss",onClick:i,style:{...De,width:18,height:18,fontSize:13,lineHeight:1,flex:"none"},children:"×"})]})}function Re({visible:e,onDismiss:t}){const[i,n]=ge.useState(!1),o=ge.useRef(null),r=ge.useRef(null);if(ge.useEffect(()=>{0===e.length&&i&&n(!1)},[e.length,i]),ge.useEffect(()=>{if(!i)return;const e=e=>{o.current&&!o.current.contains(e.target)&&n(!1)},t=e=>{"Escape"===e.key&&(n(!1),r.current?.focus())};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[i]),0===e.length)return null;const a=e.reduce((e,t)=>ze[t.level]>ze[e]?t.level:e,e[0].level),s=je[a]??je.info,l=e.length,c=`${l} chart notification${1===l?"":"s"}, most severe: ${a}`;return Ne("div",{ref:o,className:"semiotic-chart-notifications",style:{position:"relative",display:"inline-flex"},children:[Ce("span",{style:Ae,role:"status","aria-live":"polite",children:c}),Ne("button",{ref:r,className:"semiotic-chart-action semiotic-chart-notifications-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${c}. ${i?"Hide":"Show"} notifications`,title:c,onClick:()=>n(e=>!e),style:{...De,color:s,position:"relative"},children:[Ce($e,{level:a}),Ce("span",{className:"semiotic-chart-notifications-badge","aria-hidden":"true",style:{position:"absolute",top:-3,right:-3,minWidth:15,height:15,padding:"0 3px",boxSizing:"border-box",borderRadius:8,background:s,color:"#fff",fontSize:9,fontWeight:700,lineHeight:"15px",textAlign:"center"},children:l>99?"99+":l})]}),i&&Ce("div",{className:"semiotic-chart-notifications-popover",role:"dialog","aria-label":"Chart notifications",style:{position:"absolute",top:"calc(100% + 6px)",right:0,zIndex:20,width:320,maxWidth:"min(360px, 90vw)",maxHeight:320,overflowY:"auto",display:"flex",flexDirection:"column",gap:6,padding:10,textAlign:"left",background:"var(--semiotic-bg, #fff)",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:6,boxShadow:"0 6px 24px rgba(0, 0, 0, 0.16)"},children:e.map(e=>Ce(Me,{notification:e.notification,level:e.level,onDismiss:()=>t(e)},e.key))})]})}var Te={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Be({height:e}){return Ce("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function Ee({error:e}){return Ce("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:Ce("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:e})})}var Le=ge.forwardRef(function({title:o,subtitle:a,children:s,width:l="100%",height:c=400,actions:d,chartConfig:m,describe:u,navigable:p,controls:g,banner:b,notifications:y,dataAudit:v,onNotificationDismiss:x,loading:w=!1,error:k,errorBoundary:S=!1,status:C,detailsPanel:N,mobile:A,mobileAudit:I,className:j,style:z},$){const M=ge.useRef(null),R=ge.useRef(null),[T,B]=ge.useState(!1),E=function(e,t){const[i,n]=be.useState(ve),o=e?.component,r=e?.props,a=!!t,s="object"==typeof t?t.checkOutliers:void 0,l="object"==typeof t?t.errorsOnly:void 0,c="object"==typeof t?t.max:void 0;return be.useEffect(()=>{let e=!0;return a&&o&&r?((ye??(ye=import("./chunk-chartContainerDataAudit-JDSVSKGM.module.min.js").catch(e=>{throw ye=void 0,e})),ye).then(({buildChartDataAuditNotifications:t})=>{e&&n(t({component:o,props:r},{checkOutliers:s,errorsOnly:l,max:c}))}).catch(()=>{e&&n(ve)}),()=>{e=!1}):(n(e=>0===e.length?e:ve),()=>{e=!1})},[s,o,a,l,c,r]),i}(m,v),L=ge.useMemo(()=>[...y??[],...E],[y,E]),[D,P]=ge.useState(()=>new Set);ge.useEffect(()=>{P(e=>{if(0===e.size)return e;const t=new Set(L.map((e,t)=>e.id??t+""));let i=!1;const n=new Set;for(const o of e)t.has(o)?n.add(o):i=!0;return i?n:e})},[L]);const H=ge.useMemo(()=>L.map((e,t)=>({notification:e,index:t,key:e.id??t+"",level:e.level??"info"})).filter(({key:e})=>!D.has(e)),[L,D]),W=ge.useCallback(e=>{P(t=>new Set(t).add(e.key)),x?.(e.notification,e.index)},[x]),F=!1!==d?.export&&void 0!==d?.export,O=!1!==d?.fullscreen&&void 0!==d?.fullscreen,V=!1!==d?.copyConfig&&void 0!==d?.copyConfig&&m,U=!0===d?.dataSummary,q=ge.useMemo(()=>{if(!u||!m?.component||!m?.props)return"";const e="object"==typeof u?u.levels:void 0;try{return n(m.component,m.props,e?{levels:e}:{}).text}catch{return""}},[u,m]),G="object"==typeof u&&!0===u.visible,J=ge.useMemo(()=>{if(!p||!m?.component||!m?.props)return null;const e="object"==typeof p?p.maxLeaves:void 0;try{return t(m.component,m.props,e?{maxLeaves:e}:{})}catch{return null}},[p,m]),_="object"==typeof p&&!0===p.visible,Z=ge.useMemo(()=>"object"==typeof d?.export?d.export:{},[d?.export]),K="object"==typeof d?.copyConfig?d.copyConfig.format:"json",X=ge.useCallback(async e=>{R.current&&await f(R.current,{...Z,...e})},[Z]),Y=ge.useCallback(()=>{M.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):M.current.requestFullscreen().catch(()=>{}))},[]),ee=ge.useCallback(async e=>{m&&await i({...m,version:m.version??"1",createdAt:m.createdAt??(new Date).toISOString()},e||K||"json")},[m,K]);ge.useEffect(()=>{const e=()=>{B(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),ge.useImperativeHandle($,()=>({export:X,toggleFullscreen:Y,copyConfig:ee,element:M.current}),[X,Y,ee]);const te=!0===A?{}:A&&"object"==typeof A?A:null,ie=!!A,ne=te?.breakpoint??480,oe=void 0===te?.chartMode?"mobile":te.chartMode,re=te?.semantics,ae=te?.mobileInteraction??(!!ie||void 0),se=te?.standardControls,le=xe(se)?se:null,ce=le?.controls??(xe(se)?void 0:se)??function(e){return e&&"object"==typeof e?e.standardControls:void 0}(ae),de=ge.useMemo(()=>function(e,t){return ke(t)?e&&"object"==typeof e?{...e,standardControls:t}:!1===e||null==e?e:{standardControls:t}:e}(ae,ce),[ae,ce]),ue=ie&&ke(ce)?Ce(e,{controls:ce,targetSize:le?.targetSize??we(ae)??44,compact:le?.compact??!0,className:le?.className,style:le?.style,ariaLabel:le?.ariaLabel,brush:le?.brush,zoom:le?.zoom,legend:le?.legend}):null,pe=te?.summary,he=!0===te?.allowHorizontalScroll,fe=!0===te?.hideToolbar,je=ge.useMemo(()=>{if(!I||!m?.component||!m?.props)return null;const e="object"==typeof I?I:{},t=m.props;try{return me(m.component,{...t,mobileSemantics:t.mobileSemantics??re,mobileInteraction:t.mobileInteraction??de},{viewportWidth:e.viewportWidth??390,targetSize:e.targetSize??44,inChartContainer:!0})}catch{return null}},[I,m,re,de]);ge.useEffect(()=>{if(!je||je.ok)return;const e=je.findings.filter(e=>"pass"!==e.status).slice(0,5);console.warn(`[Semiotic mobile audit] ${m?.component}: ${je.summary.highRisk} high-risk mobile finding(s), ${je.summary.warnings} warning(s).`,e)},[je,m?.component]);const ze=je&&!je.ok&&"object"==typeof I&&!0===I.visible?Ne("div",{className:"semiotic-chart-mobile-audit",role:"status",style:{padding:"8px 12px",fontSize:12,lineHeight:1.45,color:"var(--semiotic-warning, #6b3f00)",background:"color-mix(in srgb, var(--semiotic-warning, #d97706) 14%, var(--semiotic-bg, #fff))",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:["Mobile audit: ",je.summary.highRisk," high-risk finding",1===je.summary.highRisk?"":"s"," and"," ",je.summary.warnings," warning",1===je.summary.warnings?"":"s"," at"," ",("object"==typeof I?I.viewportWidth:void 0)??390,"px."]}):null,$e=H.length>0,Me=o||a||g||F||O||V||U||C||$e,Le=ge.useMemo(()=>{if(!ie||!ge.isValidElement(s))return s;if(!function(e){const t=e.type;return"function"==typeof t||"object"==typeof t&&null!==t}(s))return s;const e=s.props,t={};return oe&&null==e.mode&&(t.mode=oe),re&&null==e.mobileSemantics&&(t.mobileSemantics=re),void 0!==de&&null==e.mobileInteraction&&(t.mobileInteraction=de),Object.keys(t).length>0?ge.cloneElement(s,t):s},[s,ie,oe,re,de]),Pe=w?Ce(Be,{height:c}):k?Ce(Ee,{error:k}):S?Ce(h,{children:Le}):Le;return He=Ne(Se,{children:[Ce("style",{dangerouslySetInnerHTML:{__html:`@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n@media (max-width: ${ne}px) {\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-header {\n padding: 10px 12px !important;\n gap: 10px !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-title-area {\n flex-basis: 100% !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-toolbar {\n width: 100% !important;\n margin-left: 0 !important;\n justify-content: flex-start !important;\n overflow-x: auto !important;\n -webkit-overflow-scrolling: touch;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"][data-semiotic-mobile-hide-toolbar="true"] .semiotic-chart-toolbar {\n display: none !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-action {\n min-width: 32px !important;\n min-height: 32px !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-mobile-summary {\n display: block !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-mobile-standard-controls {\n display: block !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"][data-semiotic-mobile-scroll="true"] .semiotic-chart-body {\n overflow-x: auto !important;\n justify-content: flex-start !important;\n -webkit-overflow-scrolling: touch;\n }\n}`}}),Ne("div",{ref:M,className:"semiotic-chart-container"+(j?" "+j:""),"data-semiotic-mobile":ie?"true":void 0,"data-semiotic-mobile-scroll":he?"true":void 0,"data-semiotic-mobile-hide-toolbar":fe?"true":void 0,style:{width:l,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative",...T?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{},...z},children:[Me&&Ne("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:8,borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:[Ne("div",{className:"semiotic-chart-title-area",style:{minWidth:0,flex:"1 1 200px"},children:[o&&Ce("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:o}),a&&Ce("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:o?2:0},children:a})]}),Ne("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[g,$e&&Ce(Re,{visible:H,onDismiss:W}),F&&Ce("button",{className:"semiotic-chart-action",onClick:()=>X(),title:"Export chart","aria-label":"Export chart",style:De,children:Ne("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[Ce("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),Ce("path",{d:"M2 12h10"})]})}),U&&Ce(Ie,{}),O&&Ce("button",{className:"semiotic-chart-action",onClick:Y,title:T?"Exit fullscreen":"Fullscreen","aria-label":T?"Exit fullscreen":"Enter fullscreen",style:De,children:Ce("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:Ne(Se,T?{children:[Ce("path",{d:"M9 1v4h4"}),Ce("path",{d:"M5 13V9H1"}),Ce("path",{d:"M13 5H9V1"}),Ce("path",{d:"M1 9h4v4"})]}:{children:[Ce("path",{d:"M1 5V1h4"}),Ce("path",{d:"M13 9v4H9"}),Ce("path",{d:"M9 1h4v4"}),Ce("path",{d:"M5 13H1V9"})]})})}),V&&Ce("button",{className:"semiotic-chart-action",onClick:()=>ee(),title:"Copy config","aria-label":"Copy chart configuration",style:De,children:Ne("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[Ce("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),Ce("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),C&&Ce("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:Te[C].bg,color:Te[C].color,lineHeight:"18px"},children:C})]})]}),b&&Ce("div",{className:"semiotic-chart-banner",children:b}),ze,pe&&Ce("div",{className:"semiotic-chart-mobile-summary",style:{display:"none",padding:"8px 12px",fontSize:12,lineHeight:1.45,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:pe}),ue&&Ce("div",{className:"semiotic-chart-mobile-standard-controls",style:{display:"none",padding:"10px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-surface, var(--semiotic-bg, #f6f8fa))"},children:ue}),q&&Ce("div",{className:"semiotic-chart-description",role:"note",style:G?{padding:"8px 16px",fontSize:12,lineHeight:1.5,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}:Ae,children:q}),J&&Ce("div",{className:"semiotic-chart-nav",style:_?{padding:"8px 8px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",maxHeight:240,overflow:"auto"}:void 0,children:Ce(Q,{tree:J,label:"string"==typeof o&&o?o+" — navigable structure":"Chart navigable structure",visible:_,chartId:"string"==typeof m?.props?.chartId?m.props.chartId:void 0})}),Ne("div",{className:"semiotic-chart-body",ref:R,style:{position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",...T?{flex:1}:{height:c}},children:[Pe,N]})]})]}),U?Ce(r,{children:He}):He;var He}),De={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};import*as Pe from"react";import{jsx as He,jsxs as We}from"react/jsx-runtime";function Fe({children:e,controls:t,mobile:i,breakpoint:n=480,chartMode:o="mobile",mobileInteraction:r=!0,mobileSemantics:a,mobileSummary:s,chips:l=[],activeChip:c,onChipChange:d,detail:m,detailTitle:u="Details",detailMode:p="sheet",initialDetailOpen:h=!1,allowHorizontalScroll:f=!1,hideToolbar:g=!1,chartDefaults:b,...y}){const[v,x]=Pe.useState(()=>c??l.find(e=>!e.disabled)?.id),[w,k]=Pe.useState(h);Pe.useEffect(()=>{void 0===c&&(l.length?l.some(e=>e.id===v&&!e.disabled)||x(l.find(e=>!e.disabled)?.id):x(void 0))},[c,l,v]);const S=c??v,C=Pe.useCallback(e=>{e.disabled||(void 0===c&&x(e.id),d?.(e))},[c,d]),N=l.length?He("div",{className:"semiotic-mobile-chip-row",role:"list","aria-label":"Mobile chart controls",children:l.map(e=>We("button",{type:"button",className:"semiotic-mobile-chip","aria-pressed":e.id===S,disabled:e.disabled,onClick:()=>C(e),title:"string"==typeof e.description?e.description:void 0,children:[He("span",{children:e.label}),e.description&&He("small",{className:"semiotic-mobile-chip-description",children:e.description})]},e.id))}):null,A=s||N?We("div",{className:"semiotic-mobile-summary-card",children:[s&&He("div",{className:"semiotic-mobile-summary-copy",children:s}),N]}):i?.summary,I={breakpoint:n,chartMode:o,mobileInteraction:r,semantics:a,allowHorizontalScroll:f,hideToolbar:g,...i,summary:A},j=Pe.useMemo(()=>{if(!b||!Pe.isValidElement(e))return e;const t=e.props,i={};for(const[e,n]of Object.entries(b))null==t[e]&&(i[e]=n);return Object.keys(i).length>0?Pe.cloneElement(e,i):e},[e,b]),z=!!m&&"sheet"===p,$=!!m&&"inline"===p||z&&w,M=z?He("button",{type:"button",className:"semiotic-mobile-detail-toggle","aria-expanded":w,onClick:()=>k(e=>!e),children:w?"Hide details":"Show details"}):null,R=t||M?We("div",{className:"semiotic-mobile-control-stack",children:[t,M]}):void 0;return We("div",{className:"semiotic-mobile-chart-shell",children:[He("style",{children:`\n .semiotic-mobile-chart-shell {\n display: grid;\n gap: 10px;\n width: 100%;\n }\n .semiotic-mobile-summary-card {\n display: grid;\n gap: 10px;\n }\n .semiotic-mobile-summary-copy {\n font-size: 13px;\n line-height: 1.45;\n }\n .semiotic-mobile-chip-row {\n display: flex;\n gap: 8px;\n overflow-x: auto;\n padding-bottom: 2px;\n -webkit-overflow-scrolling: touch;\n }\n .semiotic-mobile-chip {\n display: inline-flex;\n flex: 0 0 auto;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n min-height: 40px;\n min-width: 44px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 999px;\n padding: 7px 12px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n font: inherit;\n font-size: 12px;\n font-weight: 700;\n cursor: pointer;\n }\n .semiotic-mobile-chip[aria-pressed="true"] {\n border-color: var(--semiotic-primary, #1f7a6d);\n background: color-mix(in srgb, var(--semiotic-primary, #1f7a6d) 14%, transparent);\n }\n .semiotic-mobile-chip:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n }\n .semiotic-mobile-chip-description {\n display: block;\n max-width: 160px;\n margin-top: 2px;\n color: var(--semiotic-text-secondary, #666);\n font-size: 10px;\n font-weight: 500;\n line-height: 1.2;\n }\n .semiotic-mobile-control-stack {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n }\n .semiotic-mobile-detail-toggle {\n min-height: 32px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 999px;\n padding: 5px 10px;\n background: transparent;\n color: var(--semiotic-text, #222);\n font: inherit;\n font-size: 12px;\n font-weight: 700;\n cursor: pointer;\n }\n .semiotic-mobile-detail-panel {\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 16px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n box-shadow: 0 18px 48px rgba(0, 0, 0, 0.16);\n overflow: hidden;\n }\n .semiotic-mobile-detail-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 10px 12px;\n border-bottom: 1px solid var(--semiotic-border, #d8d8d8);\n font-size: 13px;\n font-weight: 800;\n }\n .semiotic-mobile-detail-body {\n padding: 12px;\n font-size: 13px;\n line-height: 1.5;\n }\n @media (max-width: ${n}px) {\n .semiotic-mobile-detail-panel[data-mode="sheet"] {\n position: sticky;\n bottom: 8px;\n z-index: 2;\n max-height: min(55vh, 420px);\n overflow: auto;\n }\n }\n `}),He(Le,{...y,controls:R,mobile:I,children:j}),$&&We("section",{className:"semiotic-mobile-detail-panel","data-mode":p,"aria-label":"string"==typeof u?u:"Chart details",children:[We("div",{className:"semiotic-mobile-detail-header",children:[He("span",{children:u}),z&&He("button",{type:"button",className:"semiotic-mobile-detail-toggle",onClick:()=>k(!1),children:"Close"})]}),He("div",{className:"semiotic-mobile-detail-body",children:m})]})]})}import*as Oe from"react";import{jsx as Ve,jsxs as Ue}from"react/jsx-runtime";function qe(e,t){if(t)return"function"==typeof t?t(e):e?.[t]}function Ge(e,t){const i="function"==typeof t?t(e):e[t];return Array.isArray(i)?i:[]}function Je(e){return{strategy:"small-multiples",responsive:!0,supportsResponsiveLayout:!0,summary:`${e} vertically stacked small multiple panel${1===e?"":"s"} with shared scale guidance.`,interaction:{primary:"tap",alternatives:["panel summary","linked selection"],hoverFallback:"tap-to-lock",targetSize:44},labels:{strategy:"external",minFontSize:12}}}function _e(e,t){if(!Oe.isValidElement(e))return e;const i=e.props,n={};for(const[e,o]of Object.entries(t))void 0!==o&&null==i[e]&&(n[e]=o);return Object.keys(n).length>0?Oe.cloneElement(e,n):e}function Ze({items:e,children:t,columns:i=3,tabletColumns:n=2,mobileColumns:o=1,mobileBreakpoint:r=480,tabletBreakpoint:s=860,gap:l=12,mode:c="mobile",chartHeight:d=220,sharedExtent:u=!0,valueAccessor:p,dataAccessor:h="data",extentProps:f=["yExtent","valueExtent"],linkedHover:g,selection:b,linkedBy:y,linkProvider:v="auto",selections:x,showLegend:w=!1,legendPosition:k,legendInteraction:S,legendSelectionName:C,legendField:N,mobileInteraction:A=!0,mobileSemantics:I,labelMode:j="panel",chartDefaults:z,className:$,style:M}){const R=m(),T=e||"function"==typeof t?[]:Oe.Children.toArray(t),B=e??T.map((e,t)=>({id:"panel-"+(t+1)})),E=B.length,L=Oe.useMemo(()=>function(e,t,i,n){if(t&&"object"==typeof t)return t;if(!1===t)return{};const o=[],r=[];for(const t of e)if(t.extent&&o.push(t.extent[0],t.extent[1]),n)for(const e of Ge(t,i))r.push(qe(e,n));const a=function(e){let t=1/0,i=-1/0;for(const n of e){const e=Number(n);Number.isFinite(e)&&(t>e&&(t=e),e>i&&(i=e))}if(Number.isFinite(t)&&Number.isFinite(i))return t===i?[t-1,i+1]:[t,i]}(r.length?r:o);return a?{yExtent:a,valueExtent:a}:{}}(B,u,h,p),[B,u,h,p]),D=Oe.useMemo(()=>{if(!y)return{name:void 0,fields:void 0,linkedHover:g,selection:b};const e=Array.isArray(y)?"small-multiples":y.name||"small-multiples",t=Array.isArray(y)?y:y.fields||[];return{name:e,fields:t,linkedHover:g??{name:e,fields:t},selection:b??{name:e}}},[y,g,b]),P=Oe.useMemo(()=>({linkedHover:D.linkedHover,selection:D.selection}),[D.linkedHover,D.selection]),H=Oe.useMemo(()=>{const e={mode:c,height:d,responsiveWidth:!0,mobileInteraction:A,mobileSemantics:I??Je(E),...P,...z};"legend"!==j&&(e.showLegend=!1),"direct"===j&&(e.directLabel=!0);for(const t of f)t in L&&(e[t]=L[t]);return e},[c,d,A,I,E,P,z,j,f,L]),W=Ue("section",{className:["semiotic-small-multiple-chart",$].filter(Boolean).join(" "),style:M,"data-semiotic-small-multiple":"true",children:[Ve("style",{children:`\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${i};\n --semiotic-small-multiple-gap: ${l}px;\n display: grid;\n grid-template-columns: repeat(var(--semiotic-small-multiple-columns), minmax(0, 1fr));\n gap: var(--semiotic-small-multiple-gap);\n width: 100%;\n }\n .semiotic-small-multiple-panel {\n min-width: 0;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 16px;\n background: var(--semiotic-bg, #fff);\n overflow: hidden;\n }\n .semiotic-small-multiple-heading {\n display: grid;\n gap: 3px;\n padding: 10px 12px 0;\n }\n .semiotic-small-multiple-title {\n margin: 0;\n color: var(--semiotic-text, #222);\n font-size: 13px;\n font-weight: 800;\n line-height: 1.25;\n }\n .semiotic-small-multiple-subtitle,\n .semiotic-small-multiple-summary {\n margin: 0;\n color: var(--semiotic-text-secondary, #666);\n font-size: 11px;\n line-height: 1.35;\n }\n .semiotic-small-multiple-plot {\n min-width: 0;\n padding: 4px 6px 8px;\n overflow: hidden;\n }\n @media (max-width: ${s}px) {\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${n};\n }\n }\n @media (max-width: ${r}px) {\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${o};\n }\n .semiotic-small-multiple-panel {\n border-radius: 14px;\n }\n .semiotic-small-multiple-heading {\n padding: 9px 10px 0;\n }\n }\n `}),B.map((e,i)=>{const n={...H},o="function"==typeof t?t(e,{item:e,index:i,count:E,chartProps:n,sharedExtent:L}):T[i];return Ue("article",{className:"semiotic-small-multiple-panel","aria-label":"string"==typeof e.title?e.title:void 0,children:[(e.title||e.subtitle||e.summary)&&Ue("header",{className:"semiotic-small-multiple-heading",children:[e.title&&Ve("h3",{className:"semiotic-small-multiple-title",children:e.title}),e.subtitle&&Ve("p",{className:"semiotic-small-multiple-subtitle",children:e.subtitle}),e.summary&&Ve("p",{className:"semiotic-small-multiple-summary",children:e.summary})]}),Ve("div",{className:"semiotic-small-multiple-plot",children:_e(o,n)})]},e.id??i)})]});return!0===v||"auto"===v&&(y||g||b||x||!0===w)&&!R?Ve(a,{selections:x,showLegend:w,legendPosition:k,legendInteraction:S,legendSelectionName:C??D.name??"small-multiples",legendField:N??D.fields?.[0]??"category",children:W}):W}import*as Ke from"react";import{Fragment as Xe,jsx as Ye,jsxs as Qe}from"react/jsx-runtime";function et({children:e,columns:t="auto",minCellWidth:i=300,gap:n=16,tabletColumns:o,mobileColumns:r=1,mobileBreakpoint:a=480,tabletBreakpoint:s=860,chartDefaults:l,className:c,style:d}){const m="semiotic-chart-grid-"+Ke.useId().replace(/[^a-zA-Z0-9_-]/g,""),u="number"==typeof t?t:void 0,p="auto"===t?`repeat(auto-fill, minmax(${i}px, 1fr))`:`repeat(${t}, 1fr)`,h=["semiotic-chart-grid",m,c].filter(Boolean).join(" ");return Qe(Xe,{children:[Ye("style",{children:`\n ${o?`\n @media (max-width: ${s}px) {\n .${m} {\n grid-template-columns: repeat(${o}, minmax(0, 1fr)) !important;\n }\n }`:""}\n @media (max-width: ${a}px) {\n .${m} {\n grid-template-columns: repeat(${r}, minmax(0, 1fr)) !important;\n }\n .${m} > [data-semiotic-chart-grid-primary="true"] {\n grid-column: span ${r} !important;\n }\n }\n `}),Ye("div",{className:h,style:{display:"grid",gridTemplateColumns:p,gap:n,width:"100%",...d},children:Ke.Children.map(e,e=>{if(!Ke.isValidElement(e))return e;const t=e.props,i={};if(l)for(const[e,n]of Object.entries(l))null==t[e]&&(i[e]=n);const n=Object.keys(i).length>0?Ke.cloneElement(e,i):e;return"primary"!==e.props.emphasis||void 0!==u&&2>u?n:Ye("div",{"data-semiotic-chart-grid-primary":"true",style:{gridColumn:"span 2",minWidth:0},children:n})})})]})}et.displayName="ChartGrid";import*as tt from"react";import{Fragment as it,jsx as nt,jsxs as ot}from"react/jsx-runtime";function rt({children:e,context:t,position:i="right",contextSize:n=250,mobilePosition:o="bottom",mobileBreakpoint:r=480,gap:a=12,className:s,style:l}){const c="semiotic-context-layout-"+tt.useId().replace(/[^a-zA-Z0-9_-]/g,""),d="left"===i||"right"===i,m="left"===i||"top"===i,u={display:"flex",flexDirection:d?m?"row-reverse":"row":m?"column-reverse":"column",gap:a,width:"100%",...l},p=d?{flex:`0 0 ${n}px`,width:n,minHeight:0}:{flex:`0 0 ${n}px`,height:n,minWidth:0};return ot(it,{children:[nt("style",{children:`\n @media (max-width: ${r}px) {\n .${c}[data-mobile-position="bottom"] {\n flex-direction: column !important;\n }\n .${c}[data-mobile-position="top"] {\n flex-direction: column-reverse !important;\n }\n .${c}[data-mobile-position="bottom"] > .semiotic-context-panel,\n .${c}[data-mobile-position="top"] > .semiotic-context-panel {\n flex: 0 0 auto !important;\n width: 100% !important;\n height: auto !important;\n }\n }\n `}),ot("div",{className:["semiotic-context-layout",c,s].filter(Boolean).join(" "),"data-mobile-position":o,style:u,children:[nt("div",{className:"semiotic-context-primary",style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:e}),nt("div",{className:"semiotic-context-panel",style:p,children:t})]})]})}rt.displayName="ContextLayout";import{useState as at,useEffect as st,useRef as lt,useCallback as ct}from"react";import{jsx as dt,jsxs as mt}from"react/jsx-runtime";function ut({children:e,position:t="right",size:i=300,trigger:n="click",chartId:o,observation:r,dismissOnEmpty:a=!0,showClose:s=!0,onToggle:l,className:d,style:m}){const[u,p]=at(null),[h,f]=at(null),[g,b]=at(!1),[y,v]=at(!1),x=lt(null),w=lt(void 0),k="click"===n?["click","click-end"]:["hover","hover-end"],{latest:S}=c({types:k,chartId:o,limit:1}),C=void 0!==r?r:S,N=ct(()=>{v(!0),b(!1),clearTimeout(w.current),w.current=setTimeout(()=>{v(!1),p(null),f(null)},200)},[]);if(st(()=>{if(C)if("click"===C.type||"hover"===C.type){const e=C;p(e.datum),f(e),b(e=>(e||(v(!0),clearTimeout(w.current),w.current=setTimeout(()=>v(!1),200)),!0))}else!a||"click-end"!==C.type&&"hover-end"!==C.type||N()},[a,N,C]),st(()=>{l?.(g)},[g,l]),st(()=>()=>clearTimeout(w.current),[]),!u&&!y)return null;const A=u&&h?e(u,h):null;if(null===A&&!y)return null;const I=function(e,t,i,n){const o={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:n?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return"right"===e?{...o,top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:i?"translateX(0)":`translateX(${t}px)`,opacity:i?1:0}:"bottom"===e?{...o,bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:i?"translateY(0)":`translateY(${t}px)`,opacity:i?1:0}:{...o,top:"50%",left:"50%",transform:i?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:i?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"}}(t,i,g,y);return mt("div",{ref:x,className:`semiotic-details-panel semiotic-details-${t}${d?" "+d:""}`,style:{...I,...m},children:[s&&dt("button",{className:"semiotic-details-close",onClick:N,"aria-label":"Close details",style:pt,children:dt("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:dt("path",{d:"M2 2l8 8M10 2l-8 8"})})}),dt("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:A})]})}var pt={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};function ht(e){const t=e.designContract?.chartFamily??e.title??"chart",i=e.audience?.primary?" for "+e.audience.primary:"",n=e.designContract?.whyThisForm;return`${t}: ${e.intent.primary}${i}${n?". "+n:""}`}function ft(e,t){const i=e.intents.map(e=>"string"==typeof e?e:e.id??e.name).filter(e=>!!e),n=e.intents.find(e=>"string"!=typeof e&&"primary"===e.strength),o=("object"==typeof n?n.id??n.name:void 0)??i[0]??"explanation";return{ididVersion:"0.1",chartId:t.chartId,title:t.title??e.name,intent:{primary:o,secondary:i.filter(e=>e!==o)},audience:{primary:e.audience?.primary,familiarityAssumptions:Object.fromEntries(Object.entries(e.audience?.familiarity??{}).map(([e,t])=>[e,t+""])),literacyTargets:e.audience?.literacyTargets?.map(e=>({feature:e.concept,rationale:e.rationale}))},reception:e.reception?{channels:e.reception.channels,strengths:e.reception.strengths,risks:e.reception.risks,scaffolds:e.reception.scaffolds,memorableForm:e.reception.memorableForm}:void 0,designContract:{chartFamily:e.frameFamily,whyThisForm:e.designContract.whyThisForm??e.designContract.whyCustom,whyNotDefault:e.designContract.whyNotDefault,risks:e.reception?.risks,misuse:e.designContract.misuse},accessibility:{description:t.description,navigation:"required"===e.accessibility.keyboardNavigation||null!=e.navigation,dataFallback:!0===e.accessibility.fallbackTable||"required"===e.accessibility.accessibleTable||!0===e.accessibility.requiresAccessibleTable,manualChecks:["real screen-reader behavior","keyboard order quality","custom metaphor comprehension","animation distraction"]},provenance:t.dataSources||t.reviewStatus?{dataSources:t.dataSources,reviewStatus:t.reviewStatus,generatedBy:"Semiotic recipe intelligence"}:void 0}}ut.displayName="DetailsPanel";import*as gt from"react";import{jsx as bt,jsxs as yt}from"react/jsx-runtime";function vt({manifest:e,label:t="Intent Mark",className:i,showSummary:n=!0}){const[o,r]=gt.useState(!1),a=gt.useMemo(()=>JSON.stringify(e,null,2),[e]),s=gt.useCallback(async()=>{"undefined"!=typeof navigator&&navigator.clipboard&&(await navigator.clipboard.writeText(a),r(!0),window.setTimeout(()=>r(!1),1200))},[a]);return yt("details",{className:i?"semiotic-intent-mark "+i:"semiotic-intent-mark",style:{border:"1px solid var(--semiotic-border, #c8c8c8)",borderRadius:6,background:"var(--semiotic-surface, #fff)",color:"var(--semiotic-text, #222)",fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[yt("summary",{style:{cursor:"pointer",padding:"7px 10px",fontSize:12,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase"},children:[t," · ",e.intent.primary]}),yt("div",{style:{padding:"0 10px 10px"},children:[n&&bt("p",{style:{margin:"4px 0 10px",fontSize:13,lineHeight:1.45},children:ht(e)}),bt("button",{type:"button",onClick:s,style:{border:"1px solid currentColor",borderRadius:4,background:"transparent",color:"inherit",padding:"4px 8px",font:"inherit",fontSize:12,cursor:"pointer"},children:o?"Copied":"Copy manifest"}),bt("pre",{style:{maxHeight:280,overflow:"auto",margin:"10px 0 0",padding:10,background:"var(--semiotic-bg, #f5f5f5)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap"},children:a})]})]})}import{useCallback as xt,useEffect as wt,useMemo as kt,useRef as St,useState as Ct}from"react";var Nt=["hover","click","focus","activate"];function At(e){if("datum"===e.role&&e.datum)return e.datum;for(const t of e.children??[]){const e=At(t);if(e)return e}return null}function It(e,t){return e?t.map(t=>e[t]+"").join(""):""}function jt(e,t){if(e.id===t)return e;for(const i of e.children??[]){const e=jt(i,t);if(e)return e}return null}function zt(e){const{tree:t,chartId:i,observe:n=Nt}=e,o=e.selectionName??"__semiotic-nav-sync"+(i?":"+i:""),r=kt(()=>{if(e.matchFields)return e.matchFields;const i=At(t);return i?Object.keys(i).filter(e=>{return!e.startsWith("_")&&(null==(t=i[e])||"string"==typeof t||"number"==typeof t||"boolean"==typeof t);var t}):[]},[e.matchFields,t]),a=kt(()=>{const e=new Map,i=t=>{if("datum"===t.role&&t.datum){const i=It(t.datum,r);e.has(i)||e.set(i,t.id)}for(const e of t.children??[])i(e)};return i(t),e},[t,r]),{selectPoints:s,clear:l}=p({name:o,fields:r}),d=kt(()=>[...n,"hover-end"],[n]),{latest:m}=c({chartId:i,types:d,limit:1}),[u,h]=Ct(t.id),f=St(u);f.current=u;const g=St(t);wt(()=>{const e=g.current;g.current=t;const i=jt(e,f.current),n=jt(t,f.current);"datum"===i?.role&&"datum"===n?.role&&i.datum&&n.datum&&r.length>0&&It(i.datum,r)===It(n.datum,r)||i&&n&&"datum"!==i.role&&"datum"!==n.role||(h(t.id),l())},[t,l,r]);const b=xt(e=>{if(h(e.id),"datum"===e.role&&e.datum&&r.length>0){const t={};for(const i of r)t[i]=[e.datum[i]];s(t)}else l()},[r,s,l]),y=e.annotations,v=kt(()=>{const e=new Set;if(0===r.length||!y)return e;for(const t of y){const i=a.get(It(t,r));i&&e.add(i)}return e},[y,a,r]),x=xt(e=>{const t="number"==typeof e?y?.[e]:e;if(!t||0===r.length)return!1;const i=a.get(It(t,r));if(!i)return!1;h(i);const n={};for(const e of r)n[e]=[t[e]];return s(n),!0},[y,a,r,s]),w=St(null),k=xt(e=>{if(i&&e.chartId!==i)return;if("hover-end"===e.type){if(e===w.current)return;return void(w.current=e)}if(!function(e){return"hover"===e.type||"click"===e.type||"focus"===e.type||"activate"===e.type}(e))return;if(!n.includes(e.type))return;if(e===w.current)return;if(w.current=e,0===r.length)return;const t=function(e){const t=e,i=t.data;if(!i||"object"!=typeof i||Array.isArray(i))return e;const n=e=>e.every(e=>"number"==typeof t[e]),o=n(["x0","x1","y0","y1","width","height","value"]),r=n(["y0","y1","sankeyWidth","value"])&&"source"in t&&"target"in t;return o||r?i:e}(e.datum),o=a.get(It(t,r));o&&h(e=>e===o?e:o)},[i,n,a,r]),S=St(null);return wt(()=>{m&&m!==S.current&&(S.current=m,k(m))},[m,k]),{activeId:u,onActiveChange:b,selection:{name:o},onObservation:k,handleObservation:k,annotatedIds:v,focusAnnotation:x}}import{Fragment as $t,jsx as Mt,jsxs as Rt}from"react/jsx-runtime";function Tt({items:e,title:t="Additional notes",empty:i=null,ordered:n=!0,renderItem:o,className:r,style:a}){if(!e.length)return i?Mt($t,{children:i}):null;const s=n?"ol":"ul";return Rt("section",{className:["semiotic-mobile-annotation-callouts",r].filter(Boolean).join(" "),style:a,children:[Mt("style",{children:"\n .semiotic-mobile-annotation-callouts {\n display: grid;\n gap: 8px;\n padding: 10px 12px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 14px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n }\n .semiotic-mobile-annotation-callouts h3 {\n margin: 0;\n font-size: 13px;\n font-weight: 800;\n line-height: 1.25;\n }\n .semiotic-mobile-annotation-callouts ol,\n .semiotic-mobile-annotation-callouts ul {\n display: grid;\n gap: 8px;\n margin: 0;\n padding-left: 18px;\n }\n .semiotic-mobile-annotation-callouts li {\n font-size: 13px;\n line-height: 1.45;\n }\n .semiotic-mobile-annotation-callouts small {\n display: block;\n margin-top: 2px;\n color: var(--semiotic-text-secondary, #666);\n font-size: 11px;\n line-height: 1.3;\n }\n "}),t&&Mt("h3",{children:t}),Mt(s,{children:e.map((e,t)=>Mt("li",{children:o?o(e,t):Rt($t,{children:[Mt("span",{children:e.label}),(e.source||e.emphasis)&&Mt("small",{children:[e.emphasis,e.source].filter(Boolean).join(" - ")})]})},e.id))})]})}export{f as exportChart,B as subscribeToConversationArcChange,E as registerConversationArcSink,L as createLocalStorageConversationArcSink,D as createIndexedDBConversationArcSink,P as createWebhookConversationArcSink,H as loadConversationArc,W as replayConversationArc,F as recordAudienceChange,O as recordAnnotationStatusChange,q as enableConversationArc,G as disableConversationArc,J as getConversationArcStore,Q as AccessibleNavTree,me as auditMobileVisualization,he as formatMobileVisualizationAudit,fe as mobileVisualizationCaveats,Le as ChartContainer,Fe as MobileChartContainer,Ze as SmallMultipleChart,et as ChartGrid,rt as ContextLayout,ut as DetailsPanel,ht as summarizeIntentManifest,ft as intentManifestFromRecipe,vt as IntentMark,zt as useNavigationSync,Tt as MobileAnnotationCalloutList};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{auditVisualizationControls as e}from"./chunk-chunk-FQPKOAIH.module.min.js";import{resolveAccessor as t,resolveRawAccessor as r}from"./chunk-chunk-NJETWX42.module.min.js";import{filterAnnotationsByStatus as a}from"./chunk-chunk-BNGBEY7N.module.min.js";import{getMinMax as n}from"./chunk-chunk-JJ2OOIET.module.min.js";function o(e){return i(e),e}function i(t){if(!t||"object"!=typeof t)throw Error("Chart recipe must be an object.");if("string"!=typeof t.id||""===t.id.trim())throw Error("Chart recipe requires a non-empty id.");if("string"!=typeof t.name||""===t.name.trim())throw Error(`Chart recipe "${t.id}" requires a non-empty name.`);if(!Array.isArray(t.dataRoles)||0===t.dataRoles.length)throw Error(`Chart recipe "${t.id}" requires at least one data role.`);if(!Array.isArray(t.intents)||0===t.intents.length)throw Error(`Chart recipe "${t.id}" requires at least one intent.`);for(const e of t.intents)if("string"!=typeof e&&(!e||"string"!=typeof e.id&&"string"!=typeof e.name))throw Error(`Chart recipe "${t.id}" has an intent without an id or name.`);if(!t.designContract?.whyCustom)throw Error(`Chart recipe "${t.id}" requires designContract.whyCustom.`);if(!t.accessibility||"object"!=typeof t.accessibility)throw Error(`Chart recipe "${t.id}" requires accessibility expectations.`);if(void 0!==t.controls){const r=e({controls:t.controls}).findings.filter(e=>"fail"===e.status);if(r.length>0)throw Error(`Chart recipe "${t.id}" has invalid controls: ${r.map(e=>e.message).join(" ")}`)}if("portable"===t.portability){if(!s(t.layout))throw Error(`Portable chart recipe "${t.id}" must reference a registered layout by id.`);const e=t.layoutConfigSchema??t.portabilityConfig?.schema;if(!e)throw Error(`Portable chart recipe "${t.id}" requires a serializable layout config schema.`);if(!l(e))throw Error(`Portable chart recipe "${t.id}" has a layout config schema that is not JSON-safe.`)}}function s(e){return!!e&&"object"==typeof e&&"string"==typeof e.id}function l(e,t=new Set){if(null===e)return!0;const r=typeof e;if("string"===r||"boolean"===r)return!0;if("number"===r)return Number.isFinite(e);if("object"!==r)return!1;if(t.has(e))return!1;t.add(e);const a=Array.isArray(e)?e.every(e=>l(e,t)):Object.entries(e).every(([,e])=>l(e,t));return t.delete(e),a}function c(e){return"string"==typeof e?e:e.id??e.name}function u(e){return"string"==typeof e?3:"number"==typeof e.score&&Number.isFinite(e.score)?Math.max(0,Math.min(5,e.score>1?e.score:5*e.score)):"primary"===e.strength?5:"secondary"===e.strength?3:"supporting"===e.strength?2:3}function d(e){const t=new Set(e.intents.map(c));return t.has("geo")?"geo":t.has("hierarchy")?"hierarchy":t.has("flow")?"flow":t.has("relationship")?"network":t.has("distribution")?"distribution":t.has("correlation")?"relationship":t.has("trend")||t.has("composition-over-time")?"time-series":t.has("compare-categories")||t.has("rank")||t.has("part-to-whole")?"categorical":"custom"}function h(e){const t=Object.values(e.audience?.familiarity??{}),r=t.find(e=>"number"==typeof e);if(void 0!==r)return Math.max(1,Math.min(5,Math.round(r)));const a=t.filter(e=>"string"==typeof e);return a.includes("high")?4:a.includes("medium")?3:a.includes("low")?2:e.reception?.memorableForm?3:2}function p(e,t){return"nodes"===t?e.network?.nodes??[]:"edges"===t?e.network?.edges??[]:"areas"===t?e.geo?.features??[]:"points"===t?e.geo?.points??[]:"lines"===t?e.geo?.flows??[]:e.data}function f(e,t,r){return p(e,t.source).some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,r))}function m(e,t,r){if(t.field&&f(r,t,t.field))return t.field;if("nodes"===t.source||"edges"===t.source){const e="node-id"===t.role?"id":"edge-source"===t.role?"source":"edge-target"===t.role?"target":void 0;if(e&&f(r,t,e))return e}switch(t.semanticType){case"quantitative":return r.primary.y??r.primary.size??r.primary.x;case"temporal":return r.primary.time??r.primary.x;case"nominal":case"ordinal":return r.primary.category??r.primary.series;case"identifier":{const e=p(r,t.source);return["id","key","name"].find(t=>e.some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,t)))}case"geographic":return r.hasGeo?t.field:void 0;default:return t.field}}function g(e){const t={},r=[];for(const a of e.intents){const e=c(a);e&&(t[e]=u(a),"string"!=typeof a&&a.rationale&&r.push(a.rationale))}r.push(...(e.reception?.strengths??[]).map(e=>"Reception strength: "+e));const a=e.reception?.risks??[],n=e.designContract.misuse??[],o=[...e.designContract.caveats??[],...e.caveats??[]];return{component:e.id,displayName:e.name,candidateKind:"recipe",family:d(e),renderingFamily:e.frameFamily,importPath:"semiotic/ai",rubric:{familiarity:h(e),accuracy:4,precision:a.some(e=>/precis|comparison/i.test(e))?2:3},fits:t=>function(e,t){for(const r of e.dataRoles)if(!1!==r.required&&!m(0,r,t))return`needs data role "${r.role}" (${r.semanticType})`;const r=e.audit?.maxCategories;return"number"==typeof r&&"number"==typeof t.categoryCount&&t.categoryCount>r?`${t.categoryCount} categories exceeds this recipe's declared maximum of ${r}`:null}(e,t),intentScores:t,caveats:()=>[...a,...n,...o],buildProps:t=>function(e,t){const r={};for(const a of e.dataRoles){const e=m(0,a,t);e&&a.accessor&&(r[a.accessor]=e)}const a={recipeId:e.id,layoutConfig:r};e.frameFamily.startsWith("Network")?(a.nodes=t.network?.nodes??t.data,a.edges=t.network?.edges??[]):e.frameFamily.startsWith("Geo")?(a.areas=t.geo?.features??[],a.points=t.geo?.points??t.data,a.lines=t.geo?.flows??[]):a.data=t.data;const n=e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0);return n&&(a.mobileSemantics=n),a}(e,t),mobile:e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0),recipe:e,positiveRationale:r,whyCustom:{defaultAlternative:e.designContract.defaultAlternative,reason:e.designContract.whyNotDefault??e.designContract.whyCustom,tradeoff:e.designContract.tradeoff??(a.length>0?a[0]:void 0)}}}var y=Symbol.for("semiotic.chartRecipeRegistry");function b(){const e=globalThis;return e[y]||(e[y]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[y]}function $(e){i(e),b().recipes.set(e.id,e),b().capabilities.set(e.id,g(e))}function v(e){b().recipes.delete(e),b().capabilities.delete(e)}function w(e){return b().recipes.get(e)}function C(){return Array.from(b().recipes.values())}function k(){return Array.from(b().capabilities.values())}function x(){return b().capabilities.size>0}function A(e,t){if(!e)throw Error("Recipe layout requires a non-empty id.");if("function"!=typeof t)throw Error(`Recipe layout "${e}" must be a function.`);b().layouts.set(e,t)}function S(e){b().layouts.delete(e)}function P(e){return b().layouts.get(e)}function L(e){return"string"==typeof e?w(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}var j=["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","RidgelinePlot","DotPlot","PieChart","DonutChart","GaugeChart","FunnelChart","SwimlaneChart","LikertChart","LineChart","BumpChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","BubbleChart","Heatmap","QuadrantChart","MultiAxisLineChart","CandlestickChart","ConnectedScatterplot","ScatterplotMatrix","MinimapChart","ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram","TreeDiagram","Treemap","CirclePack","OrbitDiagram","ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram","RealtimeLineChart","RealtimeHistogram","TemporalHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","GauntletChart","CrucibleChart","ProcessFlowChart","PacketFlowChart","ChainReactionChart","BigNumber"],F=new Set(j);function R(e){return F.has(e)}function N(e){return"string"==typeof e?e:e.id??e.name}function O(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function D(e){return Array.isArray(e.data)?e.data:Array.isArray(e.nodes)?e.nodes:Array.isArray(e.points)?e.points:Array.isArray(e.areas)?e.areas:[]}function I(e,t,r){return r??L(t.recipe)??L(t.recipeId)??w(e)}function T(e,t,r=[]){const a=e.accessor?t[e.accessor]:void 0;if("string"==typeof a&&a)return a;if(e.field)return e.field;const n=r.find(e=>e&&"object"==typeof e);if(!n)return;const o=Object.entries(n).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?o.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in n):o.find(([,e])=>"string"==typeof e)?.[0]}function B(e,t){return e.dataRoles.find(e=>e.role===t)}function M(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function E(e,t,r,a,n,o={}){const i={...o};if(t)for(const[e,r]of Object.entries(t))i[e]=r;for(const e of r.dataRoles){const r=T(e,a,n),o=t&&r?t[r]:r;void 0!==o&&(i[e.role]=o)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const r=i[t];return null==r?`{${t}}`:r+""})}var U=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend","recipe","layout"]),G=new Set(["data","nodes","edges","points","areas","lines","flows"]);function q(e){if(null==e)return e;if("function"==typeof e)return;if("object"!=typeof e)return e;if(e.$$typeof)return;if(Array.isArray(e))return e.map(q).filter(e=>void 0!==e);if(e instanceof Date)return e;const t={};for(const[r,a]of Object.entries(e)){if("function"==typeof a)continue;if(a&&"object"==typeof a&&a.$$typeof)continue;const e=q(a);void 0!==e&&(t[r]=e)}return t}function z(e,t){return!!G.has(e)&&("areas"!==e||"string"!=typeof t)}var H="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function V(e,t,r){const a=w(e)??L(t.recipe)??L(t.recipeId);if(a)return function(e,t,r){const a=function(e,t,r){const a={};for(const[n,o]of Object.entries(e))if(null!=o&&!U.has(n)&&"recipeId"!==n&&(t||!z(n,o)))if("function"==typeof o||o?.$$typeof){if(r)throw Error(`Portable recipe prop "${n}" is not JSON-safe.`)}else if(l(o))a[n]=H(o);else if(r)throw Error(`Portable recipe prop "${n}" is not JSON-safe.`);return a}(t,!1!==r?.includeData,"portable"===e.portability),n=e.intents.map(N).filter(e=>!!e),o={name:e.name,intents:n,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!l(a))throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:a,manifest:o,version:"1",createdAt:(new Date).toISOString(),...r?.selections?{selections:r.selections}:{}}}return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:"Recipe contains or may depend on non-serializable local layout callbacks.",warnings:["This config is inspectable but cannot be rendered remotely by CLI or MCP."],props:a,manifest:o,version:"1",createdAt:(new Date).toISOString(),...r?.selections?{selections:r.selections}:{}}}(a,t,r);if(!R(e))throw Error(`Unknown component "${e}". Known components: ${j.join(", ")}`);const n=!1!==r?.includeData,o={};for(const[e,r]of Object.entries(t))if(null!=r&&!U.has(e)&&(n||!z(e,r))&&"function"!=typeof r&&!r?.$$typeof)try{o[e]=H(q(r))}catch{}return{component:e,props:o,version:"1",createdAt:(new Date).toISOString(),...r?.selections?{selections:r.selections}:{}}}function J(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if("ChartRecipe"===e.component||"LocalChartRecipe"===e.component){if(!e.recipeId)throw Error("Invalid chart recipe config: missing recipeId");const t=w(e.recipeId);if(!t)throw Error(`Unknown chart recipe "${e.recipeId}". Register it before deserializing this config.`);if("LocalChartRecipe"!==e.component&&!1!==e.portable&&"portable"!==t.portability)throw Error(`Chart recipe "${e.recipeId}" is registered as local, not portable.`);return{componentName:"ChartRecipe",props:{...H(e.props),recipeId:e.recipeId}}}if(!R(e.component))throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:H(e.props)}}function _(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function K(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const r=t.replace(/-/g,"+").replace(/_/g,"/"),a=decodeURIComponent(escape(atob(r)));return JSON.parse(a)}async function W(e,t="json"){const r="jsx"===t?Q(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");await navigator.clipboard.writeText(r)}function Q(e){const{props:t}=e,r=["<"+("LocalChartRecipe"===e.component?"ChartRecipe":e.component)];e.recipeId&&r.push(` recipeId="${e.recipeId}"`);for(const[e,a]of Object.entries(t))if("string"==typeof a)r.push(` ${e}="${a}"`);else if("boolean"==typeof a&&!0===a)r.push(" "+e);else if("boolean"==typeof a&&!1===a)r.push(` ${e}={false}`);else if("number"==typeof a)r.push(` ${e}={${a}}`);else{const t=JSON.stringify(a);r.push(80>t.length?` ${e}={${t}}`:` ${e}={${JSON.stringify(a,null,2)}}`)}return r.push("/>"),r.join("\n")}function X(e){const t=Object.create(null);for(const[r,a]of e){const e=[];for(const[,t]of a.clauses){const r=Object.create(null);for(const[e,a]of Object.entries(t.fields))r[e]="point"===a.type?{type:"point",values:Array.from(a.values)}:{type:"interval",range:a.range};e.push({clientId:t.clientId,type:t.type,fields:r})}t[r]={name:a.name,resolution:a.resolution,clauses:e}}return t}function Y(e){const t=new Map;for(const[r,a]of Object.entries(e)){const e=new Map;for(const t of a.clauses){const r=Object.create(null);for(const[e,a]of Object.entries(t.fields))r[e]="point"===a.type?{type:"point",values:new Set(a.values)}:{type:"interval",range:a.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:r})}t.set(r,{name:a.name,resolution:a.resolution,clauses:e})}return t}function Z(e){if(!e)return{type:"",markProps:{}};if("string"==typeof e)return{type:e,markProps:{}};const{type:t,...r}=e;return{type:t,markProps:r}}function ee(e){return"nominal"===e||"ordinal"===e}function te(e){return"quantitative"===e||"temporal"===e}function re(e){return e.usermeta?.idid}function ae(e){if(!re(e)||!Array.isArray(e.layer))return e;const t=e.layer.filter(e=>!function(e){return"annotation-layer"===e.usermeta?.idid?.role}(e));if(1!==t.length)return e;const{layer:r,...a}=e,{usermeta:n,...o}=t[0];return{...a,...o}}var ne={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},oe={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},ie={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function se(e){e=ae(e);const t=[],{type:r,markProps:a}=Z(e.mark),o=e.encoding||{},i=o.x,s=o.y,l=o.color,c=o.size,u=o.theta,d=o.opacity;let h;e.data?.values?h=e.data.values:e.data?.url&&t.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&t.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&t.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&t.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||o.facet||o.row||o.column)&&t.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&t.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&t.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const p={};e.width&&(p.width=e.width),e.height&&(p.height=e.height);const f=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(f&&(p.title=f),l?.field&&(p.colorBy=l.field,l.scale?.scheme)){const e=ne[l.scale.scheme];e&&(p.colorScheme=e)}void 0!==d?.value&&(p.pointOpacity=d.value);const m=i?.aggregate,g=s?.aggregate;if(h&&(m||g)){const e=g?s:i,t=g?i:s,r=ie[e.aggregate];if(r&&t?.field&&e.field)h=function(e,t){const{groupBy:r,value:a,agg:o="sum"}=t,i=new Map;for(const t of e){const e=t[r]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[a]))}const s=[];for(const[e,t]of i){let a;switch(o){case"count":a=t.length;break;case"mean":a=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":a=n(t)[0];break;case"max":a=n(t)[1];break;default:a=t.reduce((e,t)=>e+t,0)}s.push({[r]:e,value:a})}return s}(h,{groupBy:t.field,value:e.field,agg:r});else if(("count"===r||"count"===e.aggregate)&&t?.field&&h){const e=new Map;for(const r of h){const a=r[t.field]+"";e.set(a,(e.get(a)||0)+1)}h=Array.from(e,([e,r])=>({[t.field]:e,value:r}))}}if(i?.bin||s?.bin){const e="Histogram";h&&(p.data=h),i?.bin?(p.valueAccessor=i.field,s?.field&&(p.categoryAccessor=s.field),i.axis?.title&&(p.valueLabel=i.axis.title)):s?.bin&&(p.valueAccessor=s.field,i?.field&&(p.categoryAccessor=i.field),s.axis?.title&&(p.valueLabel=s.axis.title));const r=i?.bin||s?.bin,a="object"==typeof r?r.maxbins:void 0;return a&&(p.bins=a),ue(e,p,t)}let y;switch(r){case"bar":y=function(e,t,r,a,n,o,i){let s;return r?.field&&!1!==e?.stack&&!1!==t?.stack&&null!==e?.stack&&null!==t?.stack?(s="StackedBarChart",a.stackBy=r.field):s="BarChart",ee(e?.type)&&te(t?.type)?(a.categoryAccessor=e.field,a.valueAccessor=i?"value":t.field,e?.axis?.title&&(a.categoryLabel=e.axis.title),t?.axis?.title&&(a.valueLabel=t.axis.title)):te(e?.type)&&ee(t?.type)?(a.categoryAccessor=t.field,a.valueAccessor=o?"value":e.field,a.orientation="horizontal",t?.axis?.title&&(a.categoryLabel=t.axis.title),e?.axis?.title&&(a.valueLabel=e.axis.title)):(e?.field&&(a.categoryAccessor=e.field),t?.field&&(a.valueAccessor=i?"value":t.field),e?.axis?.title&&(a.categoryLabel=e.axis.title),t?.axis?.title&&(a.valueLabel=t.axis.title)),n&&(a.data=n),s}(i,s,l,p,h,m,g);break;case"line":if(y="LineChart",ce(i,s,p,m,g),l?.field&&(p.lineBy=l.field),a.interpolate){const e=oe[a.interpolate];e&&(p.curve=e)}!0===a.point&&(p.showPoints=!0),h&&(p.data=h);break;case"area":if(l?.field?(y="StackedAreaChart",p.areaBy=l.field):y="AreaChart",ce(i,s,p,m,g),a.interpolate){const e=oe[a.interpolate];e&&(p.curve=e)}void 0!==a.opacity&&(p.areaOpacity=a.opacity),h&&(p.data=h);break;case"point":case"circle":case"square":c?.field?(y="BubbleChart",p.sizeBy=c.field,c.scale?.range&&(p.sizeRange=c.scale.range)):y="Scatterplot",ce(i,s,p,m,g),h&&(p.data=h);break;case"rect":y="Heatmap",i?.field&&(p.xAccessor=i.field),s?.field&&(p.yAccessor=s.field),l?.field&&(p.valueAccessor=l.field,delete p.colorBy),i?.axis?.title&&(p.xLabel=i.axis.title),s?.axis?.title&&(p.yLabel=s.axis.title),h&&(p.data=h);break;case"arc":a.innerRadius&&a.innerRadius>0?(y="DonutChart",p.innerRadius=a.innerRadius):y="PieChart",u?.field?p.valueAccessor=u.field:s?.field&&(p.valueAccessor=g?"value":s.field),l?.field&&(p.categoryAccessor=l.field),i?.field&&!u?.field&&(p.categoryAccessor=i.field),h&&(p.data=h);break;case"tick":y="DotPlot",ee(i?.type)?(p.categoryAccessor=i.field,s?.field&&(p.valueAccessor=g?"value":s.field),i?.axis?.title&&(p.categoryLabel=i.axis.title),s?.axis?.title&&(p.valueLabel=s.axis.title)):ee(s?.type)?(p.categoryAccessor=s.field,i?.field&&(p.valueAccessor=m?"value":i.field),p.orientation="horizontal",s?.axis?.title&&(p.categoryLabel=s.axis.title),i?.axis?.title&&(p.valueLabel=i.axis.title)):(i?.field&&(p.categoryAccessor=i.field),s?.field&&(p.valueAccessor=g?"value":s.field)),h&&(p.data=h);break;default:t.push(`Unsupported mark type "${r}". Defaulting to Scatterplot.`),y="Scatterplot",ce(i,s,p,m,g),h&&(p.data=h)}return ue(y,p,t)}function le(e,t={}){const r=function(e){const t=e,r=ae(e),a=r,n=[];if(Array.isArray(t.layer)&&r===e&&n.push({code:"UNSUPPORTED_COMPOSITION",severity:"error",path:"/layer",message:"Only the single base view in an IDID-enriched annotation layer can be imported."}),void 0===a.mark)n.push({code:"MISSING_MARK",severity:"error",path:"/mark",message:"A Vega-Lite spec needs a supported single-view mark."});else{const{type:e}=Z(a.mark);new Set(["bar","line","area","point","circle","square","rect","arc","tick"]).has(e)||n.push({code:"UNSUPPORTED_MARK",severity:"error",path:"/mark",message:`Vega-Lite mark "${e||"(missing)"}" has no supported Semiotic translation.`})}Array.isArray(a.transform)&&a.transform.length>0&&n.push({code:"UNSUPPORTED_TRANSFORM",severity:"error",path:"/transform",message:"Vega-Lite transforms must be materialized before strict import."});for(const e of["hconcat","vconcat","concat","facet","repeat","params","selection"])void 0!==a[e]&&n.push({code:"UNSUPPORTED_COMPOSITION",severity:"error",path:"/"+e,message:`Vega-Lite "${e}" is not part of the supported single-view import subset.`});return"string"==typeof a.data?.url&&n.push({code:"UNSUPPORTED_DATA_URL",severity:"error",path:"/data/url",message:"Strict import accepts inline data.values only; load URL data before importing."}),n}(e),a=r.filter(e=>"error"===e.severity),n=re(e),o={adapter:"semiotic/vega-lite",direction:"import",sourceFormat:"vega-lite",targetFormat:"semiotic-chart-config",..."string"==typeof n?.specVersion?{specVersion:n.specVersion}:{},...n?{metadata:{idid:n}}:{}};if(a.length>0&&"lossy"!==t.mode)return{status:"refused",diagnostics:r,lossReport:a.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:o};const i=se(e),s=(i.warnings||[]).map(e=>({code:"LEGACY_TRANSLATION_WARNING",severity:"warning",message:e})),l=a.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),c="lossy"===t.mode?r.map(e=>"error"===e.severity?{...e,severity:"warning"}:e):r;return{status:l.length>0?"lossy":"success",config:i,diagnostics:[...c,...s],lossReport:l,provenance:o}}function ce(e,t,r,a,n){e?.field&&(r.xAccessor=a?"value":e.field),t?.field&&(r.yAccessor=n?"value":t.field),e?.axis?.title&&(r.xLabel=e.axis.title),t?.axis?.title&&(r.yLabel=t.axis.title)}function ue(e,t,r){const a={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(r.length>0){a.warnings=r;for(const e of r)console.warn("[semiotic/fromVegaLite] "+e)}return a}function de(e,t,r={}){const a=D(t),n=O(t),o=r.locale??"en",i="function"==typeof e.description?e.description({data:a,config:n,locale:o}):void 0,s=i?.levels??function(e,t,r,a){const n=M(e,["nominal","ordinal"]),o=M(e,["quantitative"]),i=n?T(n,r,t):void 0,s=o?T(o,r,t):void 0,l=n?.role??i??"category",c=o?.role??s??"value",u=e.encodings??[],d=u.length?u.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${l} and ${c} are mapped through the recipe's declared visual semantics`,{number:h,percent:p}=function(e){try{return{number:new Intl.NumberFormat(e,{maximumFractionDigits:2}),percent:new Intl.NumberFormat(e,{style:"percent",maximumFractionDigits:1})}}catch{return{number:new Intl.NumberFormat("en",{maximumFractionDigits:2}),percent:new Intl.NumberFormat("en",{style:"percent",maximumFractionDigits:1})}}}(a),f=new Map;if(i&&s)for(const e of t){const t=(e[i]??"Uncategorized")+"",r=Number(e[s]);Number.isFinite(r)&&f.set(t,(f.get(t)??0)+r)}const m=[...f].sort((e,t)=>t[1]-e[1]),g=m.reduce((e,[,t])=>e+t,0),y=m[0],b=m[1],$=g>0?((y?.[1]??0)+(b?.[1]??0))/g:0,v=e.intents.map(e=>({id:N(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,w=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${l} and ${c}. ${C=d,C?C.charAt(0).toUpperCase()+C.slice(1):C}.`,l2:m.length>0?`${m.length} categories total ${h.format(g)}. ${y[0]} accounts for ${h.format(y[1])}${g>0?` (${p.format(y[1]/g)})`:""}${b?`, followed by ${b[0]} at ${h.format(b[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>m.length?y?y[0]+" is the only represented category.":"No quantitative pattern can be derived from the available data.":.5>$?`The total is distributed across ${m.length} categories without the first two forming a majority.`:`Most of the total is concentrated in ${y[0]} and ${b[0]}, which together account for ${p.format($)}.`,l4:`The chart is intended for ${v??"explanation"}${w?` with a ${w} audience`:""}: ${e.designContract.whyCustom}`};var C}(e,a,n,o),l=r.levels??["l1","l2","l3","l4"],c={};for(const e of l)s[e]&&(c[e]=s[e]);const u=["l1","l2","l3","l4"].map(e=>c[e]).filter(e=>!!e).join(" "),d=r.includeCaveats?[...e.reception?.risks??[],...e.caveats??[],...(e.designContract.misuse??[]).map(e=>"Misuse: "+e)]:void 0;return{text:u,levels:c,...d?.length?{caveats:d}:{}}}var he=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),pe=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),fe=new Set(["PieChart","DonutChart","FunnelChart"]),me=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function ge(e,t){return pe.has(e)||fe.has(e)||"SwimlaneChart"===e||"GaugeChart"===e?{measure:t.valueAccessor,measureFallback:"value",dimension:t.categoryAccessor??t.stepAccessor,dimensionFallback:"category"}:{measure:t.yAccessor??t.valueAccessor,measureFallback:"y",dimension:t.xAccessor,dimensionFallback:"x"}}function ye(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const r=e[t];if("string"==typeof r&&r)return r}}function be(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}var $e={LineChart:"line chart",AreaChart:"area chart",StackedAreaChart:"stacked area chart",DifferenceChart:"difference chart",Scatterplot:"scatter plot",BubbleChart:"bubble chart",ConnectedScatterplot:"connected scatter plot",QuadrantChart:"quadrant chart",MultiAxisLineChart:"dual-axis line chart",CandlestickChart:"candlestick chart",Heatmap:"heatmap",MinimapChart:"line chart",BarChart:"bar chart",StackedBarChart:"stacked bar chart",GroupedBarChart:"grouped bar chart",DotPlot:"dot plot",Histogram:"histogram",BoxPlot:"box plot",ViolinPlot:"violin plot",RidgelinePlot:"ridgeline plot",SwarmPlot:"swarm plot",PieChart:"pie chart",DonutChart:"donut chart",FunnelChart:"funnel chart",GaugeChart:"gauge",LikertChart:"Likert chart",SwimlaneChart:"swimlane chart",ForceDirectedGraph:"network graph",SankeyDiagram:"Sankey diagram",ProcessSankey:"temporal Sankey diagram",ChordDiagram:"chord diagram",TreeDiagram:"tree diagram",Treemap:"treemap",CirclePack:"circle-packing chart",OrbitDiagram:"orbit diagram",ChoroplethMap:"choropleth map",ProportionalSymbolMap:"proportional-symbol map",FlowMap:"flow map",DistanceCartogram:"distance cartogram",BigNumber:"single value",StreamPhysicsFrame:"physics stream frame",EventDropChart:"event-drop physics chart",GaltonBoardChart:"Galton board chart",UnitPileChart:"physics pile chart",CollisionSwarmChart:"collision swarm chart",PacketFlowChart:"physical flow chart",ProcessFlowChart:"process flow physics chart",CrucibleChart:"crucible physics chart",PhysicsCustomChart:"custom physics chart"},ve=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),we=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]);function Ce(e){return $e[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function ke(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var xe=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),Ae={"outlier-detection":"alerting","change-detection":"alerting",trend:"tracking","composition-over-time":"apportioning","compare-series":"comparing","compare-categories":"comparing",rank:"ranking","part-to-whole":"apportioning",distribution:"characterizing",correlation:"relating",flow:"tracing",hierarchy:"nesting",geo:"locating"},Se={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},Pe=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],Le={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function je(e){return Ae[e]}function Fe(e,t){const r=function(e){if(e){if("fits"in e||"buildProps"in e){const t=e,r={};for(const[e,a]of Object.entries(t.intentScores))"number"==typeof a&&Number.isFinite(a)&&(r[e]=a);return{family:t.family,intentScores:Object.keys(r).length?r:void 0}}return e}}(t);if(r?.act)return r.act;if(r?.intentScores){const e=function(e){let t,r=0;for(const[a,n]of Object.entries(e))if("number"==typeof n&&n>0)if(n>r)t=a,r=n;else if(n===r&&void 0!==t){const e=Pe.indexOf(a),r=Pe.indexOf(t);-1===e||-1!==r&&e>=r||(t=a)}return t}(r.intentScores);if(e&&Ae[e]&&(r.intentScores[e]??0)>=3)return Ae[e]}return r?.family?Se[r.family]:function(e){return fe.has(e)||"StackedAreaChart"===e?"apportioning":xe.has(e)?"relating":pe.has(e)?"comparing":me.has(e)?"characterizing":he.has(e)?"tracking":ve.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var Re=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),Ne=new Set(["system","agent","watcher"]),Oe=new Set(["ai","agent","system","computed","dbt","great-expectations"]),De=new Set(["rule","statistical-test","llm-inference","computed"]);function Ie(e){const t=e.annotations;return!!Array.isArray(t)&&t.some(e=>{if(!e||"object"!=typeof e)return!1;const t=e;if("string"!=typeof t.type||!Re.has(t.type))return!1;const r=t.provenance;return!(!r||"object"!=typeof r)&&(Ne.has(r.authorKind)||Oe.has(r.source)||De.has(r.basis))})}function Te(e="en"){let t,r;try{t=new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}),r=new Intl.NumberFormat(e,{maximumFractionDigits:2})}catch{t=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}),r=new Intl.NumberFormat("en",{maximumFractionDigits:2})}return e=>Number.isFinite(e)?1e4>Math.abs(e)?r.format(e):t.format(e):e+""}var Be={"y-threshold":"a threshold line","x-threshold":"a threshold line",band:"a highlighted band","x-band":"a highlighted band",label:"a label",callout:"a callout","callout-circle":"a callout","callout-rect":"a callout",text:"a text note",bracket:"a bracket",enclose:"an enclosure","rect-enclose":"an enclosure",highlight:"a highlight",widget:"a widget",trend:"a trend line",envelope:"an envelope","anomaly-band":"an anomaly band",forecast:"a forecast","category-highlight":"a category highlight"};function Me(e){const t=Be["string"==typeof e.type?e.type:"annotation"]||"an annotation",r=function(e){const t=e.provenance&&"object"==typeof e.provenance?e.provenance:null,r=t?.authorKind??t?.source??t?.basis;return"watcher"===r?"a watcher-flagged ":"agent"===r||"ai"===r||"llm-inference"===r?"an AI-suggested ":""}(e),a=r?r+t.replace(/^an? /,""):t,n="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return n?`${a} labeled "${n}"`:a}function Ee(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const r=a(t.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return;const n=r.map(Me),o=n.slice(0,5),i=n.length-o.length,s=function(e){return e.length>1?2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`:e[0]??""}(o)+(i>0?`, and ${i} more`:""),l=r.length;return`The author has marked ${1===l?"one feature":l+" features"} on this chart: ${s}.`}function Ue(e,a,n={}){const o=void 0!==n.levels,i=new Set(n.levels??["l1","l2","l3"]);o||!n.capability&&!Ie(a)||i.add("l4");const s=I(e,a,n.recipe);if(s){const e=["l1","l2","l3","l4"].filter(e=>i.has(e));o||e.includes("l4")||e.push("l4");const t=de(s,a,{levels:e,locale:n.locale,audience:n.audience,includeCaveats:n.includeCaveats}),r=Ee(a);return{...t,text:r?`${r} ${t.text}`.trim():t.text,...r?{annotations:r}:{}}}const l=Te(n.locale??"en"),c=Ce(e),u=Array.isArray(a.data)?a.data:null,d=ye(a),h=we.has(e)?function(e,t){const r=e.physics&&"object"==typeof e.physics?e.physics:null,a=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,n=[e.settledProjectionRows,e.projectionRows,a?.rows,r?.settledProjectionRows,r?.projectionRows,r?.settledProjection&&"object"==typeof r.settledProjection?r.settledProjection.rows:void 0].find(e=>Array.isArray(e));return Array.isArray(n)?n.map((e,r)=>{if(!e||"object"!=typeof e)return null;const a=e,n=ke(a.count??a.value??a.total??a.bodies??a.events);if(null==n)return null;const o=a.label??a.id??a.name??"container "+(r+1),i=ke(a.secondary??a.secondaryCount),s=ke(a.observed??a.observedCount);return{label:be(o,t),count:n,...null!=i?{secondary:i}:{},..."string"==typeof a.secondaryLabel&&a.secondaryLabel?{secondaryLabel:a.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}(a,l):null,{measure:p,measureFallback:f,dimension:m,dimensionFallback:g}=ge(e,a),y="string"==typeof p&&p?p:f,b="string"==typeof m&&m?m:g,$={};if(we.has(e)&&function(e,t,r,a,n,o){const i=function(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}(e),s=function(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"body"}(e);if(n.has("l1")&&(a.l1=function(e,t){return"EventDropChart"===e?"An event-drop physics chart that collapses moving events into a settled projection by event-time window.":"GaltonBoardChart"===e?"A Galton board chart that collapses falling samples into a settled histogram projection.":"UnitPileChart"===e?"A physics pile chart that collapses moving bodies into a settled bar-style projection by container.":"CollisionSwarmChart"===e?"A collision swarm chart that separates overlapping points while preserving their quantitative axis position.":"PacketFlowChart"===e?"A physical flow chart that keeps authored routes visible while packet bodies show throughput and proximity events.":"CrucibleChart"===e?"A crucible physics chart that replays authored phases and events into declared products and outlets; the settled ledger, not collisions, determines the result.":`A ${t} whose accessible reading is the settled projection rather than individual trajectories.`}(e,t)),!n.has("l2")&&!n.has("l3"))return;if(!r||0===r.length)return void(n.has("l2")&&(a.l2="No settled projection is loaded yet."));const l=r.reduce((e,t)=>e+t.count,0),c=r.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),u=c[0]??r.slice().sort((e,t)=>t.count-e.count)[0];if(!u)return;const d=r.reduce((e,t)=>e+(t.secondary??0),0),h=r.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(n.has("l2"))if(0===c.length)a.l2=`The settled projection contains ${o(l)} ${qe(l,s)} across ${r.length} ${qe(r.length,i)}; no ${qe(2,i)} are non-empty yet.`;else{const e=d>0?` ${o(d)} ${qe(d,s)} ${1===d?"is":"are"} marked ${h}.`:"";a.l2=`The settled projection contains ${o(l)} ${qe(l,s)} across ${r.length} ${qe(r.length,i)}; ${c.length} ${qe(c.length,i)} ${1===c.length?"is":"are"} non-empty. The largest ${i} is ${u.label} with ${o(u.count)} ${qe(u.count,s)}.${e}`}if(n.has("l3")&&l>0&&c.length>0){const e=c.find(e=>e!==u),t=function(e,t){if(0>=t)return"0%";const r=e/t*100;return(10>r?Math.round(10*r)/10:Math.round(r))+"%"}(u.count,l);a.l3=e?`The settled projection is most concentrated in ${u.label}, which holds ${o(u.count)} ${qe(u.count,s)} (${t}); ${e.label} follows with ${o(e.count)} ${qe(e.count,s)}.`:`The settled projection is concentrated in ${u.label}, which holds all ${o(u.count)} ${qe(u.count,s)}.`}}(e,c,h,$,i,l),i.has("l1")&&!we.has(e))if(he.has(e)||pe.has(e))$.l1=`A ${c} of ${y} by ${b}`+(d?`, split by ${d}.`:".");else if(fe.has(e))$.l1=`A ${c} showing ${y} across ${b} categories.`;else if(me.has(e))$.l1=`A ${c} of the distribution of ${y}`+(d?` by ${d}.`:".");else if(ve.has(e)){const e=Array.isArray(a.nodes)?a.nodes.length:void 0,t=Array.isArray(a.edges)?a.edges.length:void 0,r=[null!=e?`${e} ${qe(e,"node")}`:null,null!=t?`${t} ${qe(t,"edge")}`:null].filter(Boolean);$.l1=`A ${c}${r.length?" with "+r.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof a.label?a.label:y;$.l1=`A single value${e?" for "+e:""}.`}else $.l1=`A ${c}.`;const v=he.has(e)||pe.has(e)||fe.has(e)||me.has(e);let w=null;if((i.has("l2")||i.has("l3")||i.has("l4"))&&v&&u&&u.length>0&&(w=function(e,t,r,a){let n=0,o=0,i=1/0,s=-1/0,l=null,c=null,u=0,d=0,h=null,p=null,f=NaN,m=NaN;for(const r of e){const e=t(r);Number.isFinite(e)&&(0===n&&(f=e,h=r),m=e,p=r,i>e&&(i=e,l=r,u=n),e>s&&(s=e,c=r,d=n),n++,o+=e)}return 0===n?null:{count:n,min:i,max:s,mean:o/n,minLabel:be(null!=l?r(l):null,a),maxLabel:be(null!=c?r(c):null,a),first:f,last:m,firstLabel:be(null!=h?r(h):null,a),lastLabel:be(null!=p?r(p):null,a),minIndex:u,maxIndex:d}}(u,t(p,f),r(m,g),l)),i.has("l2")&&v&&(u&&0!==u.length?w&&($.l2=fe.has(e)?`${w.count} segments totaling ${l(function(e){return e.mean*e.count}(w))}. Largest is ${w.maxLabel} at ${l(w.max)}; smallest is ${w.minLabel} at ${l(w.min)}.`:`${y} ranges from ${l(w.min)} (${w.minLabel}) to ${l(w.max)} (${w.maxLabel}), with a mean of ${l(w.mean)} across ${w.count} points.`):$.l2="No data is loaded yet."),i.has("l3")&&w&&!d&&he.has(e)?$.l3=function(e,t,r){const{first:a,last:n,min:o,max:i,maxLabel:s,minLabel:l,firstLabel:c,lastLabel:u,minIndex:d,maxIndex:h,count:p}=e,f=i-o,m=n-a;if(0===f)return`${Ge(t)} is constant at ${r(a)} across the series.`;if(.04>f/(Math.abs(e.mean)||1))return`${Ge(t)} ends roughly where it started (${r(a)} at ${c} to ${r(n)} at ${u}), ranging between ${r(o)} and ${r(i)}.`;const g=h>0&&p-1>h,y=d>0&&p-1>d,b=(i-Math.max(a,n))/f,$=(Math.min(a,n)-o)/f;return g&&b>.15?`Overall ${t} climbs to a peak of ${r(i)} (${s}), then falls to ${r(n)} (${u}).`:y&&$>.15?`Overall ${t} drops to a low of ${r(o)} (${l}), then recovers to ${r(n)} (${u}).`:.05>Math.abs(m)/f?`${Ge(t)} ends roughly where it started (${r(a)} at ${c} to ${r(n)} at ${u}), ranging between ${r(o)} and ${r(i)}.`:m>0?h===p-1?`Overall ${t} rises from ${r(a)} (${c}) to a peak of ${r(n)} (${u}).`:`Overall ${t} rises from ${r(a)} (${c}) to ${r(n)} (${u}), after peaking at ${r(i)} (${s}).`:d===p-1?`Overall ${t} falls from ${r(a)} (${c}) to a low of ${r(n)} (${u}).`:`Overall ${t} falls from ${r(a)} (${c}) to ${r(n)} (${u}), after dipping to ${r(o)} (${l}).`}(w,y,l):i.has("l3")&&w&&!d&&pe.has(e)&&($.l3=`The highest ${b} is ${w.maxLabel} and the lowest is ${w.minLabel}.`),i.has("l4")){const t=Ie(a)?"alerting":Fe(e,n.capability);t&&($.l4=function(e,t,r,a,n,o,i,s){const l=Le[e],c=/^[aeiou]/i.test(l)?"an":"a";let u,d;switch(e){case"locating":u="This is a map",d="read values by location";break;case"presenting":u="This is a single-value display",d=`read ${"string"==typeof r.label&&r.label?r.label:n} as the headline number`;break;case"tracing":u=`This is ${c} ${l} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${c} ${l} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${c} ${l} chart`,d=`read it for whether ${o} and ${n} move together`;break;default:u=`This is ${c} ${l} chart`,d=function(e,t,r,a,n,o){if(!t)switch(e){case"alerting":return"watch for points that break from the rest";case"tracking":return"read it for the overall direction of "+r;case"comparing":return`compare ${r} across ${a}`;case"ranking":return"read it top to bottom by "+r;case"apportioning":return`read each ${a}'s share of the whole`;case"characterizing":return"read it for the spread and shape of "+r;default:return"read the highlighted features"}switch(e){case"alerting":return function(e,t,r){if(pe.has(r)||fe.has(r))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:a,last:n,min:o,max:i,minLabel:s,maxLabel:l,lastLabel:c,minIndex:u,maxIndex:d,count:h}=e,p=i-o;if(p>0){const e=d>0&&h-1>d,r=u>0&&h-1>u,f=(i-Math.max(a,n))/p,m=(Math.min(a,n)-o)/p;if(e&&f>.15)return`the peak of ${t(i)} at ${l} is the point to investigate`;if(r&&m>.15)return`the dip to ${t(o)} at ${s} is the point to investigate`;if(n>=i)return`the climb to ${t(n)} at ${c} warrants a closer look`;if(o>=n)return`the drop to ${t(n)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(i)}) and ${s} (${t(o)}) — are the points to check`}(t,n,o);case"tracking":return`read it for the trajectory of ${r}, which ${function(e){const t=e.max-e.min,r=e.last-e.first;return 0===t||.05>Math.abs(r)/t?"holds roughly steady":r>0?"rises":"falls"}(t)} from ${n(t.first)} (${t.firstLabel}) to ${n(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${r} across ${a}; ${t.maxLabel} leads at ${n(t.max)}`;case"ranking":return`read it top to bottom by ${r}; ${t.maxLabel} ranks highest at ${n(t.max)}`;case"apportioning":{const e=t.mean*t.count,r=e>0?Math.round(t.max/e*100):null;return`read each ${a}'s share of the ${n(e)} total; ${t.maxLabel} is the largest at ${n(t.max)}${null!=r?` (${r}%)`:""}`}case"characterizing":return`read it for the spread of ${r}, from ${n(t.min)} to ${n(t.max)}`;default:return"read the highlighted features"}}(e,a,n,o,i,t)}return`${u}; ${d}.${function(e,t){if(!t)return"";const r=t.familiarity?.[e];return"number"!=typeof r||r>2?"":` This ${Ce(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,s)}`}(t,e,a,d?null:w,y,b,l,n.audience))}const C=["l1","l2","l3","l4"].filter(e=>i.has(e)&&$[e]).map(e=>$[e]).join(" "),k=Ee(a);return{text:k?`${k} ${C}`.trim():C,levels:$,...k?{annotations:k}:{}}}function Ge(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function qe(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function ze(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function He(e,t,r={}){const a=D(t),n=O(t),o=Math.max(1,r.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:a,config:n,locale:r.locale??"en"});const i=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const l=(i?.groupByRole?B(e,i.groupByRole):void 0)??(i?.groupBy?.[0]?B(e,i.groupBy[0])??e.dataRoles.find(e=>e.field===i.groupBy?.[0]):void 0)??M(e,["nominal","ordinal"]),c=l?T(l,n,a):void 0,u=(i?.idRole?B(e,i.idRole):void 0)??M(e,["identifier"]),d=u?T(u,n,a):void 0,h={id:"root",role:"chart",label:i?.summaryTemplate?E(i.summaryTemplate,void 0,e,n,a,{count:a.length}):`${e.name}: ${a.length} ${1===a.length?"item":"items"} represented.`,level:1,children:[]};let p=0;const f=(t,r,o)=>{const s=d?t[d]:void 0,l=i?.itemLabelTemplate?E(i.itemLabelTemplate,t,e,n,a,{count:a.length}):function(e,t,r,a){const n=M(t,["nominal","ordinal"]),o=t.dataRoles.filter(e=>"quantitative"===e.semanticType),i=n?T(n,r,a):void 0,s=[];i&&null!=e[i]&&s.push(e[i]+"");for(const t of o){const n=T(t,r,a);n&&null!=e[n]&&s.push(`${t.role}: ${e[n]+""}`)}return s.length>0?s.join(", "):"Data item"}(t,e,n,a);return{id:"datum-"+ze(s??r),role:"datum",label:l,level:o,datum:t}};if(c){const e=new Map;for(const t of a){const r=(t[c]??"Uncategorized")+"",a=e.get(r);a?a.push(t):e.set(r,[t])}h.children=[...e].map(([e,t],r)=>{const a=t.slice(0,Math.max(0,o-p));p+=a.length;const n=a.map((e,t)=>f(e,1e5*r+t,3));return t.length>a.length&&n.push({id:"more-"+ze(e),role:"datum",label:`…and ${t.length-a.length} more items`,level:3}),{id:"group-"+ze(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:n}})}else{const e=a.slice(0,o);h.children=e.map((e,t)=>f(e,t,2)),a.length>e.length&&h.children.push({id:"more",role:"datum",label:`…and ${a.length-e.length} more items`,level:2})}return h}function Ve(e,n,o={}){const i=o.locale??"en",s=Math.max(1,o.maxLeaves??200),l=Te(i),c=I(e,n,o.recipe);if(c)return He(c,n,{maxLeaves:s,locale:i});const u={id:"root",role:"chart",label:Ue(e,n,{locale:i}).text||"Chart.",level:1,children:[]},d=function(e,t){const r=Array.isArray(e.annotations)?e.annotations:null;if(!r)return null;const n=a(r.filter(e=>!!e&&"object"==typeof e));if(0===n.length)return null;let o=0;const i=n.slice(0,t).map(e=>{const t=e.lifecycle?.status,r=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+o++,role:"annotation",level:3,label:`${a=Me(e),a?a.charAt(0).toUpperCase()+a.slice(1):a}${r}.`,datum:e};var a});n.length>t&&i.push({id:"annotation-"+o++,role:"annotation",level:3,label:`…and ${n.length-t} more annotations.`});const s=n.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===s?"one marked feature":s+" marked features"}.`,children:i}}(n,s),h=Array.isArray(n.data)?n.data:null,p=he.has(e)||pe.has(e)||fe.has(e)||me.has(e);if(!h||0===h.length||!p)return d&&(u.children=[d]),u;const{measure:f,measureFallback:m,dimension:g,dimensionFallback:y}=ge(e,n),b=t(f,m),$=r(g,y),v="string"==typeof f&&f?f:m,w="string"==typeof g&&g?g:y,C=ye(n);let k=0;const x=e=>`${e}-${k++}`,A=(e,t)=>{const r=e.slice(0,s).map(e=>((e,t)=>{const r=b(e),a=be($(e),l);return{id:x("datum"),role:"datum",level:t,label:`${a}: ${Number.isFinite(r)?l(r):"—"}`,value:Number.isFinite(r)?r:void 0,datum:e}})(e,t));return e.length>s&&r.push({id:x("more"),role:"datum",level:t,label:`…and ${e.length-s} more points`}),r},S=[];if(he.has(e)||pe.has(e)){let t=1/0,r=-1/0,a=1/0,n=-1/0;const o=[];let i=!0;for(const e of h){const s=b(e);Number.isFinite(s)&&(t>s&&(t=s),s>r&&(r=s));const l=$(e);o.push(l),"number"==typeof l&&Number.isFinite(l)?(a>l&&(a=l),l>n&&(n=l)):i=!1}const s=new Set,c=[];for(const e of o){const t=e+"";s.has(t)||(s.add(t),c.push(e))}const u=i?`${l(a)} to ${l(n)}`:`${be(c[0],l)} to ${be(c[c.length-1],l)} (${pe.has(e)?c.length+" categories":h.length+" points"})`;S.push({id:x("axis"),role:"axis",level:2,label:`${pe.has(e)?"Category axis":"X axis"}: ${w}, ${u}.`}),t>r||S.push({id:x("axis"),role:"axis",level:2,label:`Value axis: ${v}, ${l(t)} to ${l(r)}.`})}if(C){const t=r(C,C),a=new Map;for(const e of h){const r=(t(e)??"—")+"",n=a.get(r);n?n.push(e):a.set(r,[e])}const o=[];for(const[t,r]of a){const a=Ue(e,{...n,data:r},{levels:["l2","l3"],locale:i}).text;o.push({id:x("series"),role:"series",level:2,label:`Series ${t}: ${a}`,children:A(r,3)})}u.children=[...S,...o]}else u.children=[...S,...A(h,2)];return d&&u.children.push(d),u}function Je(e,t){const r=[],a=e=>{if(r.push(e),e.children&&e.children.length>0&&t.has(e.id))for(const t of e.children)a(t)};return a(e),r}function _e(e){let t=1;if(e.children)for(const r of e.children)t+=_e(r);return t}export{o as defineChartRecipe,i as validateChartRecipe,s as isRegisteredRecipeLayout,l as isJsonSafe,m as resolveRecipeRoleField,g as recipeToChartCapability,$ as registerChartRecipe,v as unregisterChartRecipe,w as getChartRecipe,C as listChartRecipes,k as getRegisteredRecipeCapabilities,x as hasRegisteredRecipeCapabilities,A as registerRecipeLayout,S as unregisterRecipeLayout,P as getRecipeLayout,L as resolveChartRecipe,N as recipeIntentId,O as recipeConfig,T as fieldForRole,V as toConfig,J as fromConfig,_ as toURL,K as fromURL,W as copyConfig,Q as configToJSX,X as serializeSelections,Y as deserializeSelections,ae as unwrapIDIDEnrichedVegaLiteSpec,se as fromVegaLite,le as fromVegaLiteResult,de as describeRecipeChart,je as communicativeActForIntent,Fe as resolveCommunicativeAct,Ue as describeChart,He as buildRecipeNavigationTree,Ve as buildNavigationTree,Je as flattenVisible,_e as countNodes};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ function e(e,r){const n=e.length,t=r.length,o=Array(t+1);for(let e=0;t>=e;e++)o[e]=e;for(let a=1;n>=a;a++){let n=o[0];o[0]=a;for(let i=1;t>=i;i++){const t=o[i];o[i]=e[a-1]===r[i-1]?n:1+Math.min(n,o[i],o[i-1]),n=t}}return o[t]}function r(r,n,t=3){let o,a=t+1;for(const t of n){const n=e(r.toLowerCase(),t.toLowerCase());a>n&&(a=n,o=t)}return a>t?void 0:o}function n(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function t(e,n){if(0===n.length)return null;const t=e.toLowerCase();return n.find(e=>e.toLowerCase().includes(t)||t.includes(e.toLowerCase()))||(r(e,n,3)??null)}function o(e){return` Or use a function: ${e}={d => d.myValue}.`}function a({componentName:e,data:r,accessors:a,requiredProps:i}){if(i)for(const[r,n]of Object.entries(i))if(null==n)return`${e}: ${r} is required. Provide a field name or function.`;if(null==r)return null;if(!Array.isArray(r)&&"object"==typeof r)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(!Array.isArray(r)||0===r.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(a){const i=n(r).find(e=>e&&"object"==typeof e);if(i){const r=Object.keys(i);for(const[n,s]of Object.entries(a))if(s&&"string"==typeof s&&!(s in i)){const a=t(s,r),i=a?` Try ${n}="${a}".`:"";return`${e}: ${n} "${s}" not found in data. Available fields: ${r.join(", ")}.${i}`+o(n)}}}return null}function i({componentName:e,data:r,dataLabel:n="data"}){return null==r?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(r)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function s({componentName:e,nodes:r,edges:a,nodesRequired:i=!1,edgesRequired:s=!0,accessors:l}){if(null==r&&null==a)return null;if(s&&(!a||!Array.isArray(a)||0===a.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(i&&(!r||!Array.isArray(r)||0===r.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(l&&r&&r.length>0){const a=n(r).find(e=>e&&"object"==typeof e);if(a){const r=Object.keys(a);for(const[n,i]of Object.entries(l))if(i&&"string"==typeof i&&!(i in a)){const a=t(i,r),s=a?` Try ${n}="${a}".`:"";return`${e}: ${n} "${i}" not found in node data. Available fields: ${r.join(", ")}.${s}`+o(n)}}}return null}export{r as closestMatch,a as validateArrayData,i as validateObjectData,s as validateNetworkData};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{resolveCategoricalPalette as t,resolveExplicitColor as r}from"./chunk-chunk-PX5YQGDP.module.min.js";function e(r,e,n){return t(r,e,n)}function n(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&r(n,t)||"#4e79a7":e=>{if(n){const t=r(n,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}export{e as resolveCustomLayoutPalette,n as buildResolveColor};
2
+ import{resolveCategoricalPalette as t,resolveExplicitColor as r}from"./chunk-chunk-7ZDJSYKI.module.min.js";function e(r,e,n){return t(r,e,n)}function n(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&r(n,t)||"#4e79a7":e=>{if(n){const t=r(n,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}export{e as resolveCustomLayoutPalette,n as buildResolveColor};