semiotic 3.10.3 → 3.10.4

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 (81) hide show
  1. package/README.md +17 -18
  2. package/ai/artifact-surface-inventory.json +1 -1
  3. package/ai/behaviorContracts.cjs +14 -4
  4. package/ai/behaviorContracts.d.cts +3 -0
  5. package/ai/cli.js +17 -166
  6. package/ai/componentMetadata.cjs +68 -15
  7. package/ai/componentMetadata.d.cts +3 -0
  8. package/ai/dist/diagnose-operation.js +3 -0
  9. package/ai/dist/mcp-server.js +59 -59
  10. package/ai/reference.md +3 -3
  11. package/ai/schema.json +1 -1
  12. package/ai/surface-manifest.json +1 -1
  13. package/ai/system-prompt.md +1 -1
  14. package/ai/task-packets/compare-category-totals.json +7 -7
  15. package/ai/task-packets/compare-category-totals.md +3 -3
  16. package/ai/task-packets/correct-published-chart.json +7 -7
  17. package/ai/task-packets/correct-published-chart.md +3 -3
  18. package/ai/task-packets/index.json +6 -6
  19. package/ai/task-packets/update-live-chart.json +7 -7
  20. package/ai/task-packets/update-live-chart.md +3 -3
  21. package/dist/{c-FHNY57SO.min.js → c-2MHSD3TN.min.js} +46 -46
  22. package/dist/{c-5PIKBUMF.min.js → c-6XGGN5OS.min.js} +1 -1
  23. package/dist/c-EK6XI2U7.min.js +26 -0
  24. package/dist/{c-4XLHPQTP.min.js → c-JBWPJNTJ.min.js} +1 -1
  25. package/dist/c-KWP4QTCM.min.js +4 -0
  26. package/dist/c-LRV7PO45.min.js +393 -0
  27. package/dist/c-LVHJJUOF.min.js +1 -0
  28. package/dist/c-NUBZ63VU.min.js +1 -0
  29. package/dist/{c-ZVOFLE2P.min.js → c-RWHLEUX6.min.js} +6 -6
  30. package/dist/{c-4JKDJUYD.min.js → c-S746GRV4.min.js} +1 -1
  31. package/dist/{c-ISA6IJ6V.min.js → c-UQBWSYKI.min.js} +5 -5
  32. package/dist/components/ai/chartClinic.d.ts +1 -1
  33. package/dist/components/ai/chartClinicMetadata.generated.d.ts +2 -2
  34. package/dist/components/charts/shared/{chartDefinitionPilot.d.ts → chartDefinition.d.ts} +30 -34
  35. package/dist/components/charts/shared/chartDefinitions.d.ts +10 -0
  36. package/dist/components/charts/shared/chartDefinitionsNetwork.d.ts +17 -0
  37. package/dist/components/charts/shared/chartDefinitionsOrdinal.d.ts +23 -0
  38. package/dist/components/charts/shared/chartDefinitionsPhysics.d.ts +17 -0
  39. package/dist/components/charts/shared/chartDefinitionsRealtime.d.ts +12 -0
  40. package/dist/components/charts/shared/chartDefinitionsXY.d.ts +26 -0
  41. package/dist/components/server/serverChartConfigs.d.ts +36 -36
  42. package/dist/components/server/serverChartConfigsNetwork.generated.d.ts +17 -0
  43. package/dist/components/server/serverChartConfigsOrdinal.generated.d.ts +23 -0
  44. package/dist/components/server/serverChartConfigsPhysics.generated.d.ts +17 -0
  45. package/dist/components/server/serverChartConfigsRealtime.generated.d.ts +13 -0
  46. package/dist/components/server/serverChartConfigsXY.generated.d.ts +22 -0
  47. package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +5 -0
  48. package/dist/network.module.min.js +1 -1
  49. package/dist/physics-matter.min.js +4 -1
  50. package/dist/physics-matter.module.min.js +1 -1
  51. package/dist/physics-rapier.min.js +4 -1
  52. package/dist/physics-rapier.module.min.js +1 -1
  53. package/dist/physics.module.min.js +1 -1
  54. package/dist/semiotic-ai-core.min.js +3 -3
  55. package/dist/semiotic-ai-core.module.min.js +3 -3
  56. package/dist/semiotic-ai.module.min.js +2 -2
  57. package/dist/semiotic-artifact.min.js +1 -1
  58. package/dist/semiotic-artifact.module.min.js +1 -1
  59. package/dist/semiotic-client-cjs-shared.min.js +4 -4
  60. package/dist/semiotic-experimental-auxiliary.module.min.js +1 -1
  61. package/dist/semiotic-experimental-node-auxiliary.module.min.js +1 -1
  62. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  63. package/dist/semiotic-realtime-core.module.min.js +1 -1
  64. package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
  65. package/dist/semiotic-recipes-core.module.min.js +13 -13
  66. package/dist/semiotic-server-edge-node.module.min.js +393 -391
  67. package/dist/semiotic-server-edge.min.js +393 -391
  68. package/dist/semiotic-server-edge.module.min.js +374 -372
  69. package/dist/semiotic-server-node.min.js +393 -391
  70. package/dist/semiotic-server-node.module.min.js +1 -1
  71. package/dist/semiotic-utils-core.min.js +1 -1
  72. package/dist/semiotic-utils-core.module.min.js +1 -1
  73. package/dist/semiotic.module.min.js +9 -9
  74. package/dist/server.min.js +393 -391
  75. package/dist/server.module.min.js +1 -1
  76. package/package.json +8 -4
  77. package/dist/c-3OFVBWQY.min.js +0 -1
  78. package/dist/c-43XNOQNQ.min.js +0 -391
  79. package/dist/c-6IVBV5NO.min.js +0 -1
  80. package/dist/c-KXH7LFIL.min.js +0 -26
  81. package/dist/c-UBHICVSC.min.js +0 -1
@@ -1,4 +1,4 @@
1
- function e(e){return Object.prototype.hasOwnProperty.call(Gs,e)?Gs[e]:void 0}function t(e){const t={"--semiotic-bg":e.colors.background,"--semiotic-text":e.colors.text,"--semiotic-text-secondary":e.colors.textSecondary,"--semiotic-grid":e.colors.grid,"--semiotic-border":e.colors.border,"--semiotic-cell-border":e.colors.cellBorder||e.colors.border,"--semiotic-primary":e.colors.primary,"--semiotic-font-family":e.typography.fontFamily,"--semiotic-secondary":e.colors.secondary||e.colors.primary,"--semiotic-surface":e.colors.surface||e.colors.background};e.colors.categorical.forEach((e,r)=>{t["--semiotic-category-"+(r+1)]=e}),e.colors.focus&&(t["--semiotic-focus"]=e.colors.focus),e.colors.selection&&(t["--semiotic-selection-color"]=e.colors.selection),null!=e.colors.selectionOpacity&&(t["--semiotic-selection-opacity"]=e.colors.selectionOpacity+""),e.colors.diverging&&(t["--semiotic-diverging"]=e.colors.diverging),e.colors.annotation&&(t["--semiotic-annotation-color"]=e.colors.annotation),e.colors.success&&(t["--semiotic-success"]=e.colors.success),e.colors.danger&&(t["--semiotic-danger"]=e.colors.danger),e.colors.warning&&(t["--semiotic-warning"]=e.colors.warning),e.colors.error&&(t["--semiotic-error"]=e.colors.error),e.colors.info&&(t["--semiotic-info"]=e.colors.info),e.tooltip?.background&&(t["--semiotic-tooltip-bg"]=e.tooltip.background),e.tooltip?.text&&(t["--semiotic-tooltip-text"]=e.tooltip.text),e.tooltip?.borderRadius&&(t["--semiotic-tooltip-radius"]=e.tooltip.borderRadius),e.tooltip?.fontSize&&(t["--semiotic-tooltip-font-size"]=e.tooltip.fontSize),e.tooltip?.shadow&&(t["--semiotic-tooltip-shadow"]=e.tooltip.shadow),e.borderRadius&&(t["--semiotic-border-radius"]=e.borderRadius);const r=e.typography.legendSize??e.typography.labelSize;null!=r&&(t["--semiotic-legend-font-size"]=r+"px"),null!=e.typography.legendFontFamily&&(t["--semiotic-legend-font-family"]=e.typography.legendFontFamily),null!=e.typography.legendFontWeight&&(t["--semiotic-legend-font-weight"]=e.typography.legendFontWeight+"");const a=e.typography.titleFontSize??e.typography.titleSize;return null!=a&&(t["--semiotic-title-font-size"]=a+"px"),null!=e.typography.titleFontFamily&&(t["--semiotic-title-font-family"]=e.typography.titleFontFamily),null!=e.typography.titleFontWeight&&(t["--semiotic-title-font-weight"]=e.typography.titleFontWeight+""),null!=e.typography.tickFontFamily&&(t["--semiotic-tick-font-family"]=e.typography.tickFontFamily),null!=e.typography.tickSize&&(t["--semiotic-tick-font-size"]=e.typography.tickSize+"px"),null!=e.typography.labelSize&&(t["--semiotic-axis-label-font-size"]=e.typography.labelSize+"px"),t}function r(e,r=":root"){return`${r} {\n${Object.entries(t(e)).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`}function a(e){return{semiotic:{bg:{$value:e.colors.background,$type:"color"},text:{$value:e.colors.text,$type:"color"},"text-secondary":{$value:e.colors.textSecondary,$type:"color"},grid:{$value:e.colors.grid,$type:"color"},border:{$value:e.colors.border,$type:"color"},primary:{$value:e.colors.primary,$type:"color"},focus:{$value:e.colors.focus||e.colors.primary,$type:"color"},"font-family":{$value:e.typography.fontFamily,$type:"fontFamily"},"border-radius":{$value:e.borderRadius||"8px",$type:"dimension"},tooltip:{bg:{$value:e.tooltip?.background||e.colors.background,$type:"color"},text:{$value:e.tooltip?.text||e.colors.text,$type:"color"},radius:{$value:e.tooltip?.borderRadius||"6px",$type:"dimension"},"font-size":{$value:e.tooltip?.fontSize||"14px",$type:"dimension"},shadow:{$value:e.tooltip?.shadow||"0 2px 8px rgba(0,0,0,0.15)",$type:"shadow"}},selection:{color:{$value:e.colors.selection||e.colors.primary,$type:"color"},opacity:{$value:e.colors.selectionOpacity??.2,$type:"number"}},categorical:{$value:e.colors.categorical,$type:"color",$description:"Categorical color palette"},sequential:{$value:e.colors.sequential,$type:"string",$description:"d3-scale-chromatic sequential scheme name"},...e.aesthetics?{aesthetics:{...e.aesthetics.name?{profile:{$value:e.aesthetics.name,$type:"string"}}:{},...null!=e.aesthetics.minimumScore?{"minimum-score":{$value:e.aesthetics.minimumScore,$type:"number"}}:{},weights:Object.fromEntries(Object.entries(e.aesthetics.weights??{}).map(([e,t])=>[e,{$value:t,$type:"number"}])),thresholds:Object.fromEntries(Object.entries(e.aesthetics.thresholds??{}).map(([e,t])=>[e,{$value:t,$type:"number"}])),rationales:Object.fromEntries(Object.entries(e.aesthetics.rationales??{}).map(([e,t])=>[e,{$value:t,$type:"string"}]))}}:{},...e.colors.diverging?{diverging:{$value:e.colors.diverging,$type:"string",$description:"d3-scale-chromatic diverging scheme name"}}:{},...e.colors.annotation?{"annotation-color":{$value:e.colors.annotation,$type:"color"}}:{},...null!=e.typography.legendSize?{"legend-font-size":{$value:e.typography.legendSize+"px",$type:"dimension"}}:{},...null!=e.typography.legendFontFamily?{"legend-font-family":{$value:e.typography.legendFontFamily,$type:"fontFamily"}}:{},...null!=e.typography.legendFontWeight?{"legend-font-weight":{$value:e.typography.legendFontWeight,$type:"fontWeight"}}:{},"title-font-size":{$value:(e.typography.titleFontSize??e.typography.titleSize)+"px",$type:"dimension"},...null!=e.typography.titleFontFamily?{"title-font-family":{$value:e.typography.titleFontFamily,$type:"fontFamily"}}:{},...null!=e.typography.titleFontWeight?{"title-font-weight":{$value:e.typography.titleFontWeight,$type:"fontWeight"}}:{},...null!=e.typography.tickFontFamily?{"tick-font-family":{$value:e.typography.tickFontFamily,$type:"fontFamily"}}:{},...null!=e.typography.tickSize?{"tick-font-size":{$value:e.typography.tickSize+"px",$type:"dimension"}}:{},...null!=e.typography.labelSize?{"axis-label-font-size":{$value:e.typography.labelSize+"px",$type:"dimension"}}:{},secondary:{$value:e.colors.secondary||e.colors.primary,$type:"color"},surface:{$value:e.colors.surface||e.colors.background,$type:"color"},...e.colors.success?{success:{$value:e.colors.success,$type:"color"}}:{},...e.colors.danger?{danger:{$value:e.colors.danger,$type:"color"}}:{},...e.colors.warning?{warning:{$value:e.colors.warning,$type:"color"}}:{},...e.colors.error?{error:{$value:e.colors.error,$type:"color"}}:{},...e.colors.info?{info:{$value:e.colors.info,$type:"color"}}:{}}}}function o(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>s(t(e))}function n(e,t){const r=o(e),a=o(t);return(e,t)=>{const o=a(e);return{value:o,x:r(e),y:o,category:t}}}function i(e,t){const r=o(t??"value"),a=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=a?a(e):void 0;return{value:r(e),category:null==t?void 0:t+""}}}function s(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function c(e,t,r){const a=null!=e.axis?r[e.axis]:null!=e.field?t[e.field]:r.value;if(void 0!==e.eq&&a!==e.eq)return!1;if(void 0!==e.ne&&a===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(a))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=s(a);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,r]=e.within;if(t>o||o>r)return!1}if(void 0!==e.outside){const[t,r]=e.outside;if(o>=t&&r>=o)return!1}return!0}function l(e,t,r){const a=e.when;return void 0===a||!0===a||!1!==a&&("function"==typeof a?a(t,r):c(a,t,r))}function u(e,t,r){if(!t||0===t.length)return{};let a={};for(const o of t){if(!l(o,e,r))continue;const t="function"==typeof o.style?o.style(e,r):o.style;t&&(a={...a,...t})}return a}function d(e,t,r,a=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,n)=>{const i=a(e),s={...o(e,n)};return Object.assign(s,u(i,t,r(i,n))),s}:o}function h(e,t,r){return e&&0!==e.length?(a,o)=>{const n=u(a,e,t(a,o)),i=r?r(a,o):void 0;return i?{...n,...i}:n}:r}function p(e){let t=e.replace(/^#/,"");/^[a-f\d]{3}$/i.test(t)&&(t=t.split("").map(e=>e+e).join(""));const r=t.match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!r)return null;const[a,o,n]=[parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(a)+.7152*i(o)+.0722*i(n)}function f(e,t){const r=p(e),a=p(t);return null===r||null===a?null:(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function m(e){return Math.min(255,Math.max(0,Math.round(e)))}function g(e){if("string"!=typeof e)return null;const t=e.trim().toLowerCase(),r=t.match(/^#([a-f\d]{3,4}|[a-f\d]{6}|[a-f\d]{8})$/i)?.[1];if(r){const e=r.length>4?r:r.split("").map(e=>`${e}${e}`).join("");return{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16),a:8===e.length?Number.parseInt(e.slice(6,8),16)/255:1}}const a=t.match(/^rgba?\(\s*(-?(?:\d+|\d*\.\d+))\s*,\s*(-?(?:\d+|\d*\.\d+))\s*,\s*(-?(?:\d+|\d*\.\d+))(?:\s*,\s*(-?(?:\d+|\d*\.\d+)))?\s*\)$/);if(!a)return null;const o=[Number(a[1]),Number(a[2]),Number(a[3])],n=void 0===a[4]?1:Number(a[4]);return o.some(e=>!Number.isFinite(e)||0>e||e>255)||!Number.isFinite(n)||0>n||n>1?null:{r:o[0],g:o[1],b:o[2],a:n}}function y(e,t){return 1>t.a?null:{r:m(e.r*e.a+t.r*(1-e.a)),g:m(e.g*e.a+t.g*(1-e.a)),b:m(e.b*e.a+t.b*(1-e.a)),a:1}}function b(e){return 1>e.a?null:"#"+[e.r,e.g,e.b].map(e=>m(e).toString(16).padStart(2,"0")).join("")}function v(e){if("string"!=typeof e||""===e.trim())return;const t=g(e);return t?b(t)??`rgba(${m(t.r)},${m(t.g)},${m(t.b)},${t.a})`:e.trim().toLowerCase()}function w(e,t,r){const a=g(e),o=g(t);if(!a||!o)return null;const n=y({...a,a:a.a*Math.min(1,Math.max(0,r))},o);return n?b(n):null}function A(e){const t=g(e.backgroundColor),r=t?b(t):null,a=w(e.scaffoldColor,e.backgroundColor,e.scaffoldOpacity??1),o=a&&r?f(a,r):null,n=e.dataColors.map(t=>w(t,e.backgroundColor,1)).map(e=>e&&r?f(e,r):null).filter(e=>null!==e);if(null===o||n.length!==e.dataColors.length||0===n.length)return{ok:!0,status:"manual",method:"mark-to-scaffold-contrast",finding:{code:"VISUAL_HIERARCHY_MANUAL",status:"manual",message:"Visual hierarchy could not be computed from the supplied colors.",fix:"Resolve CSS variables, gradients, or named colors to solid colors and run the audit again."}};const i=Math.min(...n),s=i/o,c={weakestDataContrast:i,scaffoldContrast:o,hierarchyRatio:s},l=Math.max(1,e.minimumScaffoldContrast??1.1);return l>o?{ok:!1,status:"warn",method:"mark-to-scaffold-contrast",evidence:c,finding:{code:"SCAFFOLD_VISIBILITY",status:"warn",message:"Reference scaffolding may be too faint to remain useful.",fix:"Increase grid or guide contrast while keeping it below the primary data marks."}}:3>i||o>Math.max(l,e.maximumScaffoldContrast??2)||Math.max(1,e.minimumHierarchyRatio??2)>s?{ok:!1,status:"warn",method:"mark-to-scaffold-contrast",evidence:c,finding:{code:"SCAFFOLD_DOMINANCE",status:"warn",message:"Reference scaffolding competes with the primary data marks.",fix:"Increase mark contrast or lighten grid and guide colors until marks have at least twice the scaffold contrast."}}:{ok:!0,status:"pass",method:"mark-to-scaffold-contrast",evidence:c,finding:{code:"SCAFFOLD_DOMINANCE",status:"pass",message:"Primary data marks lead while reference scaffolding remains visible and subordinate."}}}function x(e){return Math.min(1,Math.max(0,e))}function $(e,t){return Number.isFinite(e)?e:t}function C(e){const t=e.thresholds??{},r=Math.max(1,$(t.scaffoldContrastMin,Hs.scaffoldContrastMin)),a=x($(t.emphasisRatioMin,Hs.emphasisRatioMin));return{hierarchyRatio:Math.max(1,$(t.hierarchyRatio,Hs.hierarchyRatio)),scaffoldContrastMin:r,scaffoldContrastMax:Math.max(r,$(t.scaffoldContrastMax,Hs.scaffoldContrastMax)),titleScaleRatio:Math.max(1.01,$(t.titleScaleRatio,Hs.titleScaleRatio)),categoricalColorMax:Math.max(1,Math.round($(t.categoricalColorMax,Hs.categoricalColorMax))),emphasisRatioMin:a,emphasisRatioMax:Math.max(a,x($(t.emphasisRatioMax,Hs.emphasisRatioMax)))}}function S(e){return v(e)}function k(e){return(Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[e]).map(S).filter(e=>!!e)}function R(e){return Array.isArray(e)||e&&"object"==typeof e?k(e):[]}function P(e){return e.length>=4&&Ks.some(t=>e.length===t.length&&e.every((e,r)=>e===t[r]))}function I(e){const t=e.frameProps&&"object"==typeof e.frameProps&&e.frameProps.pieceStyle&&"object"==typeof e.frameProps.pieceStyle?e.frameProps.pieceStyle:void 0,r=[...R(e.colorScheme),...k(e.color),...k(e.fill),...k(e.stroke),...k(t?.fill),...k(t?.stroke)],a=Array.isArray(e.styleRules)?e.styleRules:[];for(const e of a)e.style&&"function"!=typeof e.style&&r.push(...k(e.style.fill),...k(e.style.stroke));return Array.from(new Set(r))}function E(e){const t=e.frameProps&&"object"==typeof e.frameProps&&e.frameProps.pieceStyle&&"object"==typeof e.frameProps.pieceStyle?e.frameProps.pieceStyle:void 0,r=[...R(e.colorScheme),...k(e.color),...k(e.fill),...k(t?.fill)],a=Array.isArray(e.styleRules)?e.styleRules:[];for(const e of a)e.style&&"function"!=typeof e.style&&r.push(...k(e.style.fill));return Array.from(new Set(r))}function N(e,t){const r=Array.isArray(e.data)?e.data:[];return"string"==typeof t?Array.from(new Set(r.map(e=>e[t]+""))):"function"==typeof t?Array.from(new Set(r.map((e,r)=>t(e,r)+""))):[]}function T(e){const t=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.styleRules)?e.styleRules:[],a="string"==typeof e.valueAccessor?e.valueAccessor:"string"==typeof e.yAccessor?e.yAccessor:"value",o="string"==typeof e.categoryAccessor?e.categoryAccessor:"category",n=[];for(const e of r)e.style&&"function"!=typeof e.style&&t.some((t,r)=>l(e,t,{value:Number(t[a]),category:(t[o]??"")+"",index:r}))&&n.push(...k(e.style.fill));return Array.from(new Set(n))}function M(e,t,r){const a=R(t.colorScheme),o=k(t.color),n=N(t,t.colorBy),i=Xs.has(e)?N(t,t.categoryAccessor??"category"):[],s=t.colorScheme&&"object"==typeof t.colorScheme&&!Array.isArray(t.colorScheme)?t.colorScheme:void 0,c=(e,t)=>e.map((e,a)=>S(s?.[e])??("gray"===t?"#999999":r.colors.categorical.length>0?r.colors.categorical[a%r.colors.categorical.length]:"#007bff")),l=n.length>0?s?c(n,"gray"):a.length>0?a:r.colors.categorical:o.length>0?o:i.length>0&&s?c(i,"theme"):a.length>0&&!s?a:r.colors.categorical,u=l.slice(0,n.length>0||i.length>0?Math.min(l.length,Math.max(1,n.length||i.length||1)):1),d=T(t).filter(e=>!u.includes(e));return Array.from(/* @__PURE__ */new Set([...u,...d]))}function O(e){const t=e.colors.surface??e.colors.background,r=g(t),a=g(e.colors.background);if(!r)return t;if(1===r.a)return b(r)??t;if(!a)return t;const o=y(r,a);return o?b(o)??t:t}function F(e,t){if(!e.evidence)return.5;const{weakestDataContrast:r,scaffoldContrast:a,hierarchyRatio:o}=e.evidence;return Math.min(x(r/3),x(a/t.scaffoldContrastMin),x(t.scaffoldContrastMax/a),x(o/t.hierarchyRatio))}function j(e,t,r,a,o,n,i){const s=r[e];return{id:e,label:Zs[e],status:0===s?"disabled":i??(.8>t?"warn":"pass"),score:t,weight:s,contribution:t*s,message:a,...n?.[e]?{rationale:n[e]}:{},evidence:o}}function z(e){return Math.max(1,e.length)}function B(e){const t=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.styleRules)?e.styleRules:[];if(0===t.length||0===r.length)return{ratio:0,authored:!1};const a="string"==typeof e.valueAccessor?e.valueAccessor:"string"==typeof e.yAccessor?e.yAccessor:"value",o="string"==typeof e.categoryAccessor?e.categoryAccessor:"category";return{ratio:t.filter((e,t)=>r.some(r=>l(r,e,{value:Number(e[a]),category:(e[o]??"")+"",index:t}))).length/t.length,authored:!0}}function L(e,t,r={}){const a=r.theme??Ls,o=r.profile??a.aesthetics??Ws,n={...qs,...o.weights??{}};for(const e of Object.keys(n)){const t=n[e];n[e]=Number.isFinite(t)?Math.max(0,t):0}const i=C(o),s=M(e,t,a),c=A({backgroundColor:O(a),dataColors:s,scaffoldColor:a.colors.grid,minimumHierarchyRatio:i.hierarchyRatio,minimumScaffoldContrast:i.scaffoldContrastMin,maximumScaffoldContrast:i.scaffoldContrastMax}),l=I(t),u=P(a.colors.categorical.map(S).filter(e=>!!e)),d=E(t),h="string"==typeof t.colorScheme?t.colorScheme.trim().toLowerCase():void 0,p=d.length>0||h?"chart":"theme",f="chart"===p?P(d)||!!h&&Js.has(h):u,m=f?.2:"chart"===p?1:.8,g=z(s),y=g>i.categoricalColorMax?x(1-(g-i.categoricalColorMax)/i.categoricalColorMax):1,b=a.typography.titleFontSize??a.typography.titleSize,v=Math.max(a.typography.tickSize,a.typography.labelSize),w=v>0?b/v:1,k=x((w-1)/(i.titleScaleRatio-1)),R=new Set([...a.colors.categorical,a.colors.primary,a.colors.secondary,a.colors.background,a.colors.surface,a.colors.text,a.colors.textSecondary,a.colors.grid,a.colors.border,a.colors.annotation].map(S).filter(e=>!!e)),N=l.filter(e=>!R.has(e)).length,T=0===l.length?1:x(1-N/l.length),L=B(t),_=L.authored?i.emphasisRatioMin>L.ratio?x(L.ratio/i.emphasisRatioMin):L.ratio>i.emphasisRatioMax?x(i.emphasisRatioMax/L.ratio):1:.35,D=[j("mark-scaffold-hierarchy",F(c,i),n,c.finding.message,{hierarchyRatio:c.evidence?.hierarchyRatio??0,markContrast:c.evidence?.weakestDataContrast??0,scaffoldContrast:c.evidence?.scaffoldContrast??0},o.rationales,c.status),j("palette-authorship",m,n,f?"theme"===p?"The chart inherits a ubiquitous categorical default without an organizational palette decision.":"The chart explicitly selects a ubiquitous categorical palette.":"The effective palette records an authored choice beyond the ubiquitous defaults.",{paletteSource:p,ubiquitousDefault:f,colorCount:s.length},o.rationales),j("palette-economy",y,n,`${g} color role(s) are used against a policy ceiling of ${i.categoricalColorMax}.`,{colorRoles:g,maximum:i.categoricalColorMax},o.rationales),j("typographic-hierarchy",k,n,`Title-to-supporting-type scale is ${w.toFixed(2)}×.`,{titleSize:b,supportingSize:v,ratio:w},o.rationales),j("theme-coherence",T,n,`${N} of ${l.length} explicit chart color(s) fall outside the theme vocabulary.`,{explicitColors:l.length,outsideTheme:N},o.rationales),j("editorial-emphasis",_,n,L.authored?Math.round(100*L.ratio)+"% of marks receive authored emphasis.":"No machine-visible editorial emphasis rule is declared.",{authored:L.authored,emphasizedRatio:L.ratio},o.rationales)],U=D.reduce((e,t)=>e+t.weight,0),V=D.reduce((e,t)=>e+t.contribution,0),G=0===U?null:V/U*100,q=100*x($(o.minimumScore,Ws.minimumScore??70)/100);return{component:e,profile:o.name??"Unnamed aesthetic profile",ok:null===G||G>=q,score:G,minimumScore:q,weightedPoints:V,totalWeight:U,features:D,method:"weighted-machine-visible-features"}}function _(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),r=Math.abs(t);return 1e9>r?1e6>r?1e4>r?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"}function D(e){if(2>e.length)return"days";const t=[];for(let r=1;e.length>r;r++)t.push(e[r]-e[r-1]);t.sort((e,t)=>e-t);const r=t[Math.floor(t.length/2)];return 2*Qs>r?"seconds":2*ec>r?"minutes":2*tc>r?"hours":60*tc>r?"days":400*tc>r?"months":"years"}function U(e){return 10>e?"0"+e:e+""}function V(e={}){const t=e.timeZone;return"UTC"===t?{kind:"utc"}:"local"===t?{kind:"local"}:"string"==typeof t&&t.length>0?{kind:"iana",id:t}:!1===e.utc?{kind:"local"}:{kind:"utc"}}function G(e,t){return t?{month:e.getUTCMonth(),day:e.getUTCDate(),year:e.getUTCFullYear(),hours:e.getUTCHours(),minutes:e.getUTCMinutes(),seconds:e.getUTCSeconds()}:{month:e.getMonth(),day:e.getDate(),year:e.getFullYear(),hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()}}function q(e){let t;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hourCycle:"h23"})}catch{return e=>G(e,!0)}return e=>{const r={};for(const a of t.formatToParts(e))"literal"!==a.type&&(r[a.type]=a.value);return{month:Math.max(0,(Number(r.month)||1)-1),day:Number(r.day)||1,year:Number(r.year)||1970,hours:Number(r.hour)||0,minutes:Number(r.minute)||0,seconds:Number(r.second)||0}}}function H(e,t,r){const{month:a,day:o,year:n,hours:i,minutes:s,seconds:c}=r(e),l=rc[a],u=U(i),d=U(s),h=U(c);switch(t){case"seconds":return`${l} ${o}, ${n} ${u}:${d}:${h}`;case"minutes":case"hours":return`${l} ${o}, ${n} ${u}:${d}`;case"days":return`${l} ${o}, ${n}`;case"months":return`${l} ${n}`;case"years":return""+n}}function W(e,t,r,a){const o=a(e),n=a(t),i=o.year!==n.year,s=i||o.month!==n.month,c=s||o.day!==n.day,l=c||o.hours!==n.hours,u=l||o.minutes!==n.minutes,d=rc[o.month],{day:h,year:p}=o,f=U(o.hours),m=U(o.minutes),g=U(o.seconds);switch(r){case"seconds":return i?`${d} ${h}, ${p} ${f}:${m}:${g}`:c?`${d} ${h} ${f}:${m}:${g}`:l?`${f}:${m}:${g}`:u?`${m}:${g}`:":"+g;case"minutes":return i?`${d} ${h}, ${p} ${f}:${m}`:c?`${d} ${h} ${f}:${m}`:l?`${f}:${m}`:":"+m;case"hours":return i?`${d} ${h}, ${p} ${f}:00`:s?`${d} ${h} ${f}:${m}`:c?`${d} ${h} ${f}:00`:f+":00";case"days":return i?`${d} ${h}, ${p}`:s?`${d} ${h}`:""+h;case"months":return i?`${d} ${p}`:""+d;case"years":return""+p}}function Y(e,t={}){let r,a=e;const o="utc"===(n=V(t)).kind?e=>G(e,!0):"local"===n.kind?e=>G(e,!1):q(n.id);var n;return(t,n,i)=>{const s=t instanceof Date?t:new Date(t);e||!i||2>i.length||i===r||(r=i,a=D(i));const c=a||"days";return null!=n&&0!==n&&i&&0!==i.length?W(s,new Date(i[n-1]),c,o):H(s,c,o)}}function K(e,t=0,r=1/0,a=0){const o=Number.isFinite(t)?t:0,n=Number.isFinite(r)?Math.max(o,r):1/0,i=Number.isFinite(e)?Math.floor(e):o,s=Math.max(o,Math.min(n,i));return a>0&&Number.isFinite(a)?Math.max(o,Math.min(n,Math.round(s/a)*a)):s}function J(e,t=.5){const r=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!r)return e;const a=Math.round(parseInt(r[1],16)*(1-t)),o=Math.round(parseInt(r[2],16)*(1-t)),n=Math.round(parseInt(r[3],16)*(1-t));return`#${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function X(e,t=.5){const r=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!r)return e;const a=Math.round(parseInt(r[1],16)+(255-parseInt(r[1],16))*t),o=Math.round(parseInt(r[2],16)+(255-parseInt(r[2],16))*t),n=Math.round(parseInt(r[3],16)+(255-parseInt(r[3],16))*t);return`#${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Z(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}function Q(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(ac||(ac=document.createElement("canvas")),ac.width=e,ac.height=e,ac)}function ee(e={},t){const{background:r="transparent",stroke:a="#000",lineWidth:o=1.5,spacing:n=6,angle:i=45}=e,s={background:r,stroke:a,lineWidth:o,spacing:n,angle:i},c=Math.max(8,Math.ceil(2*n));let l;try{l=Q(c)}catch{return Z(s)}const u=l.getContext("2d");if(!u)return Z(s);r&&"transparent"!==r?(u.fillStyle=r,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=a,u.lineWidth=o,u.lineCap="square";const d=i*Math.PI/180;if(45===i||-45===i){const e=i>0?1:-1;for(let t=-c;2*c>=t;t+=n)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);const e=2*c;for(let t=-e;e>=t;t+=n)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(l,"repeat")}function te(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function re(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function ae(e,t){let r=2166136261;const a=re(t);for(let e=0;a.length>e;e++)r^=a.charCodeAt(e),r=Math.imul(r,16777619);return`${e}-hatch-${(r>>>0).toString(36)}`}function oe(e,t){const r=e.length,a=t.length,o=Array(a+1);for(let e=0;a>=e;e++)o[e]=e;for(let n=1;r>=n;n++){let r=o[0];o[0]=n;for(let i=1;a>=i;i++){const a=o[i];o[i]=e[n-1]===t[i-1]?r:1+Math.min(r,o[i],o[i-1]),r=a}}return o[a]}function ne(e,t,r=3){let a,o=r+1;for(const r of t){const t=oe(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,a=r)}return o>r?void 0:a}function ie(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function se(e,t){if(0===t.length)return null;const r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||(ne(e,t,3)??null)}function ce(e){return` Or use a function: ${e}={d => d.myValue}.`}function le({componentName:e,data:t,accessors:r,requiredProps:a}){if(a)for(const[t,r]of Object.entries(a))if(null==r)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)&&"object"==typeof t)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(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(r){const a=ie(t).find(e=>e&&"object"==typeof e);if(a){const t=Object.keys(a);for(const[o,n]of Object.entries(r))if(n&&"string"==typeof n&&!(n in a)){const r=se(n,t),a=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${n}" not found in data. Available fields: ${t.join(", ")}.${a}`+ce(o)}}}return null}function ue({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} 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 de({componentName:e,nodes:t,edges:r,nodesRequired:a=!1,edgesRequired:o=!0,accessors:n}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(a&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(n&&t&&t.length>0){const r=ie(t).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[a,o]of Object.entries(n))if(o&&"string"==typeof o&&!(o in r)){const r=se(o,t),n=r?` Try ${a}="${r}".`:"";return`${e}: ${a} "${o}" not found in node data. Available fields: ${t.join(", ")}.${n}`+ce(a)}}}return null}function he(e){return nc.has(e)}function pe(e){const[t,r]=Array.isArray(e)?e:[e,void 0],a=sc[t],o=Array.isArray(a)?[...a]:a;return void 0===r?{type:o}:{type:o,enum:[...cc[r]]}}function fe(){return Object.fromEntries(uc.map(([e,t,r,a,o],n)=>[oc[n],{required:[...e],dataShape:t,dataAccessors:[...r],props:Object.fromEntries(Object.entries(Object.assign({},...a.map(e=>lc[e]),o)).map(([e,t])=>[e,pe(t)]))}]))}function me(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function ge(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"UnitPileChart"===e)}function ye(e){if(!Array.isArray(e.thresholds))return[];const t=[];return 0===e.thresholds.length&&t.push('"thresholds" for GaugeChart must contain at least one { value, color, label? } object.'),e.thresholds.forEach((e,r)=>{if(!e||"object"!=typeof e||Array.isArray(e))return void t.push(`"thresholds[${r}]" for GaugeChart should be an object with numeric "value" and string "color".`);const a=e;"number"==typeof a.value&&Number.isFinite(a.value)||t.push(`"thresholds[${r}].value" is required for GaugeChart and must be a finite number. BigNumber's "at" threshold key is not supported here.`),"string"==typeof a.color&&0!==a.color.length||t.push(`"thresholds[${r}].color" is required for GaugeChart and must be a non-empty string.`),void 0!==a.label&&"string"!=typeof a.label&&t.push(`"thresholds[${r}].label" for GaugeChart should be a string.`);const o=Object.keys(a).filter(e=>"value"!==e&&"color"!==e&&"label"!==e);o.length>0&&t.push(`"thresholds[${r}]" has unsupported GaugeChart key(s): ${o.join(", ")}. Use { value, color, label? }; { at, level } belongs to BigNumber.`)}),t}function be(e){const t=e.frameProps;if(null==t||"object"!=typeof t||Array.isArray(t))return[];const r=t.legendLayout;if(null==r||"object"!=typeof r||Array.isArray(r))return null==r?[]:['"frameProps.legendLayout" should be object, got '+(Array.isArray(r)?"array":typeof r)+"."];const a=[],o=r,n=/* @__PURE__ */new Set(["align",...Object.keys(pc)]);for(const e of Object.keys(o))n.has(e)||a.push(`Unknown "frameProps.legendLayout" key "${e}". Valid keys: ${[...n].join(", ")}.`);void 0!==o.align&&"string"!=typeof o.align?a.push(`"frameProps.legendLayout.align" should be string, got ${Array.isArray(o.align)?"array":typeof o.align}.`):"string"!=typeof o.align||hc.has(o.align)||a.push(`"frameProps.legendLayout.align" value "${o.align}" is not valid. Expected one of: ${[...hc].join(", ")}.`);for(const[e,t]of Object.entries(pc)){const r=o[e];void 0!==r&&("number"==typeof r&&Number.isFinite(r)?t.minimum>r&&a.push(`"frameProps.legendLayout.${e}" should be ${t.label} (minimum ${t.minimum}), got ${r}.`):a.push(`"frameProps.legendLayout.${e}" should be ${t.label}, got ${Array.isArray(r)?"array":typeof r}.`))}return a}function ve(e,t){const r=[];null!=t&&"object"==typeof t||(t={});const a=dc[e];if(!a)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(dc).join(", ")}`]};for(const o of a.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);"array"!==a.dataShape||!Object.prototype.hasOwnProperty.call(a.props,"data")||a.required.includes("data")||ge(e,t)||null!=t.data||r.push(`"data" is required for ${e}.`);for(const[e,o]of Object.entries(t)){if(null==o)continue;const t=a.props[e];if(t){if(!me(o,t.type)){const a=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${a}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const o=Object.keys(a.props),n=new Set(o);for(const a of Object.keys(t))if(void 0!==t[a]&&!n.has(a)){const t=ne(a,o),n=t?`Unknown prop "${a}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${a}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(n)}if("array"===a.dataShape){const o=t.data,n={};for(const e of a.dataAccessors){const r=t[e];"string"==typeof r&&(n[e]=r)}const i=le({componentName:e,data:o,accessors:Object.keys(n).length>0?n:void 0});i&&r.push(i)}else if("object"===a.dataShape){const a=ue({componentName:e,data:t.data});a&&r.push(a)}else if("network"===a.dataShape){const o=t.nodeIdAccessor??t.nodeIDAccessor??"id",n="string"==typeof o?{nodeIdAccessor:o}:void 0,i=de({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:a.required.includes("nodes"),edgesRequired:a.required.includes("edges"),accessors:n});i&&r.push(i)}return"GaugeChart"===e&&r.push(...ye(t)),"ScatterplotMatrix"===e&&null!=t.frameProps&&r.push('"frameProps" is not supported for ScatterplotMatrix; configure its matrix props directly.'),r.push(...be(t)),{valid:0===r.length,errors:r}}function we(e){return null==e?null:e.data??e.datum??e}function Ae(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function xe(e,t={}){const r=[],a=e.tokenSemantics,o=e.countStrategy,n=t.maxRecommendedTokens??("fixed-denominator"!==o||Ae(e.denominator)>mc?fc:mc);return a||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),o||r.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||r.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>n&&r.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==a||"icon"!==e.tokenType&&"glyph"!==e.tokenType||r.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===a&&o&&"unitized"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===a&&o&&"fixed-denominator"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==a&&"posterior-sample"!==a&&"hypothetical-case"!==a||!o||"quantile"===o||"sample"===o||"posterior-sample"===o||"random-sample"===o||r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===a&&"unitized"===o&&null==e.unitValue&&null==e.unit&&r.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==a||"unitized"!==o||e.unitMeaning||r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function $e(e){return"string"==typeof e?.type?e.type:""}function Ce(e){return!!e&&"object"==typeof e&&zc.has($e(e))}function Se(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}function ke(e){return Bc.has($e(e))&&!Se(e)}function Re(e,t,r={}){return"number"==typeof r.maxAnnotations&&Number.isFinite(r.maxAnnotations)?Math.max(0,Math.floor(r.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(r.areaPerAnnotation&&r.areaPerAnnotation>0?r.areaPerAnnotation:Lc))):1/0}function Pe(e){const t=e.provenance,r=e.id??e.stableId??t?.stableId;return null==r||""===r?void 0:r+""}function Ie(e,t,r){const a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(const e of a)e&&"object"==typeof e&&"widget"===$e(e)&&null!=e.content&&!Pe(e)&&r.push({severity:"warning",code:"ANNOTATION_INTERACTIVE_ID",message:"An interactive widget annotation has no stable id, so its activation cannot be normalized or replayed reliably.",fix:"Add id, stableId, or provenance.stableId to the widget annotation. Do not identify interactive annotations by array index."})}function Ee(e,t,r){const a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(const e of a){if(!e||"object"!=typeof e)continue;const t=$e(e);if(!Ce(e)||"widget"===t)continue;const a=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,n=ke(e);!n&&a>_c?r.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${o}" sits ~${Math.round(a)}px from its anchor with no connector — a reader can't tell what it refers to.`,fix:'Add a connector (connector: { end: "arrow" }, the label/callout default) or place the note adjacent to its target (smaller dx/dy).'}):n&&a>Dc&&r.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${o}" uses a very long connector (~${Math.round(a)}px); prefer placing the note adjacent to its target when space allows.`,fix:"Reduce dx/dy so the note sits near its target, or keep the long connector only if proximity is genuinely infeasible."})}}function Ne(e,t,r){const a=Array.isArray(t.annotations)?t.annotations:null;if(!a)return;const o=a.filter(Ce).length;if(0===o)return;const n="number"==typeof t.width?t.width:600,i="number"==typeof t.height?t.height:400,s=Re(n,i);Number.isFinite(s)&&o>s&&r.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${o} note annotations on a ${n}×${i} chart exceed the ~${s} notes the plot area carries comfortably — the chart may read as cluttered.`,fix:'Mark the essential notes emphasis: "primary" and let density management shed the rest (autoPlaceAnnotations: { density: true }), enable progressive disclosure to reveal secondary notes on hover, or give the chart more room.'})}function Te(e,t,r){for(const e of Uc){const a=t[e];if(!Array.isArray(a)||2>a.length)continue;const[o,n]=a;"number"==typeof o&&"number"==typeof n&&o>n&&r.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${o}, ${n}] is descending — the axis renders inverted, so "up" reads as less. Inverted axes are a classic misleading-design pattern unless the inversion is the point.`,fix:`Order the extent ascending (${e}={[${n}, ${o}]}). If the inversion is deliberate (e.g. rank #1 at top), say so in the title or an annotation so readers aren't misled.`})}}function Me(e,t,r){if("MultiAxisLineChart"!==e)return;const a=t.series;if(!Array.isArray(a)||2!==a.length)return;const o=a.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);o.length>0&&r.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${o.length} unlabeled series. Two y-scales invite false equivalence between the lines; without per-series labels a reader can't tell which scale is whose.`,fix:'Give every series a label: series={[{ yAccessor: "a", label: "Revenue ($)" }, { yAccessor: "b", label: "Users" }]} — and consider whether two separate charts read more honestly.'})}function Oe(e,t,r){if(!vc.has(e))return;const a=t.xExtent;if(!Array.isArray(a)||2>a.length)return;const[o,n]=a;if("number"!=typeof o||"number"!=typeof n||o>=n)return;const i=t.data;if(!i||!Array.isArray(i)||4>i.length)return;const s=t.xAccessor??"x";if("string"!=typeof s)return;let c=1/0,l=-1/0;for(const e of i){const t=e?.[s];"number"==typeof t&&Number.isFinite(t)&&(c>t&&(c=t),t>l&&(l=t))}if(!Number.isFinite(c)||!Number.isFinite(l)||c>=l)return;const u=l-c,d=Math.max(0,Math.min(n,l)-Math.max(o,c))/u;.7>d&&r.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${o}, ${n}] shows only ~${Math.round(100*d)}% of the data's x range [${c}, ${l}] — a trend cropped to a favorable window is a classic misleading-design pattern.`,fix:'Widen xExtent to cover the data, filter the data itself so the chart shows what it has, or annotate the visible window ("Q4 only") so the cropping is explicit.'})}function Fe(e,t,r){const a=$c[e],o=Sc[e];if(!a&&!o)return;if(o&&!t.normalize)return;const n=a??o,i=t[n],s="string"==typeof i?i:"yAccessor"===n?"y":"value",c=t.data;if(!c||!Array.isArray(c)||0===c.length)return;const l=c.filter(e=>{const t=e?.[s];return"number"==typeof t&&0>t});l.length>0&&r.push({severity:a?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${l.length} negative value(s) in "${s}" — a part-to-whole encoding cannot represent negative parts${a?"; slice angles/areas for negatives are meaningless":"; normalized shares distort when parts are negative"}.`,fix:a?"Filter or transform negative values first, or switch to a BarChart/WaterfallChart, which encode signed values honestly.":"Drop normalize for signed data, or use a diverging BarChart so negative contributions read as negative."})}function je(e,t,r){Ac.has(e)&&"basis"===t.curve&&r.push({severity:"warning",code:"NON_PASSING_CURVE",message:'curve="basis" draws a B-spline that does NOT pass through your data points — rendered values differ from actual values everywhere except the endpoints.',fix:'Use curve="monotoneX" or curve="catmullRom" (both interpolate through every point), or keep "basis" only for deliberately schematic, clearly-labeled smoothing.'})}function ze(e,t,r){if("LineChart"!==e&&"AreaChart"!==e)return;if("sparkline"===t.mode)return;if(t.responsiveWidth||t.responsiveHeight)return;const a="number"==typeof t.width?t.width:600,o="number"==typeof t.height?t.height:400;if(0>=a||0>=o)return;const n=a/o;if(n>8||.25>n){const e=n>8?"flattens":"exaggerates";r.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${a}×${o} (${n.toFixed(1)}:1) is an extreme aspect ratio that ${e} the slopes a reader perceives — aspect-ratio distortion is a documented misleading-design pattern.`,fix:n>8?'Use a more balanced aspect (e.g. width/height between 1 and 3), or set mode="sparkline" if this is genuinely a sparkline strip.':"Use a more balanced aspect (e.g. width/height between 1 and 3); very tall trend charts overstate every change."})}}function Be(e,t,r){if(!xc.has(e))return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=t.categoryAccessor,n="string"==typeof o?o:"category",i=/* @__PURE__ */new Set;for(const e of a){const t=e?.[n];null!=t&&i.add(t)}i.size>Vc&&r.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:`${i.size} slices — angle judgments degrade rapidly past ~${Vc} categories (Cleveland & McGill), and thin slices become unreadable and unlabelable.`,fix:`Use a BarChart or DotPlot for ${i.size} categories, or group the long tail into an "Other" slice before charting.`})}function Le(e,t,r){return"function"==typeof r?r(e,t):e[r]}function _e(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function De(e,t){const r=_e(e);return null!=r&&r>0?r:t}function Ue(e){if(!e)return;const t=_e(e[0]),r=_e(e[1]);return null!=t&&null!=r?t>r?[r,t]:[t,r]:void 0}function Ve(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Ge(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),r=t.length?t:["Intake"],a=Math.max(r.length,Math.round(e.count??Math.max(48,12*r.length))),o=De(e.unitValue,1),n=Ve(e.seed??1),i=e.idPrefix??"mechanical-pile",s=r.map(()=>.65+.9*n()),c=s.reduce((e,t)=>e+t,0)||1,l=a-r.length,u=s.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=a-d.reduce((e,t)=>e+t,0);const p=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%p.length)d[p[e].index]+=1,h-=1;return r.map((e,t)=>({id:`${i}-${t}`,category:e,value:d[t]*o,mechanical:!0,unitCount:d[t],unitValue:o,share:d[t]/a}))}function qe(e,t){const r=e/t,a=Math.round(r);return Math.ceil(a>0&&Number.EPSILON*r*4>=Math.abs(r-a)?a:r)}function He(e,t,r=0){const a=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),o=/* @__PURE__ */new Map;for(const n of e){let e=null==n.id?`${t}-${r++}`:n.id+"";for(;null==n.id&&a.has(e);)e=`${t}-${r++}`;a.add(e),o.set(e,null==n.id?{...n,id:e}:n)}return{seed:e,rows:Array.from(o.values()),nextId:r}}function We(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function Ye(e,t,r){if("function"==typeof t)return t(e);const a="string"==typeof t?t:r;return e?.[a]}function Ke(e,t,r){if(Tc.has(e)){if("GaltonBoardChart"===e){const e=t.bins;"number"==typeof e&&2>e&&r.push({severity:"error",code:"PHYSICS_BAD_BINS",message:`bins=${e} leaves no meaningful settled projection for a Galton board.`,fix:"Use at least two bins; 8-24 bins is a practical range for physics distributions."});const a=We(t.branchProbability);null!=t.branchProbability&&(null==a||0>a||a>1)&&r.push({severity:"error",code:"PHYSICS_BAD_BRANCH_PROBABILITY",message:`branchProbability=${t.branchProbability+""} must be between 0 and 1.`,fix:"Use branchProbability={0.5} for a balanced Galton board, or bias it within the [0, 1] range."});const o=We(t.mechanicalCount);null==t.mechanicalCount||null!=o&&o>0||r.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical Galton board.`,fix:"Use a positive mechanicalCount, for example 96."})}if("EventDropChart"===e){const e=t.windows,a=e&&"object"==typeof e?We(e.size):null;null==a||a>0||r.push({severity:"error",code:"PHYSICS_BAD_WINDOW_SIZE",message:`windows.size=${a} cannot form event-time barriers.`,fix:"Set windows={{ size: positiveNumber }} so each event can settle into a real time window."}),"number"!=typeof t.timeScale||t.timeScale>0||r.push({severity:"error",code:"PHYSICS_BAD_TIME_SCALE",message:`timeScale=${t.timeScale} prevents arrival replay from advancing.`,fix:"Use a positive timeScale, or omit it for the default pace."});const o=Array.isArray(t.data)?t.data:[];if(o.length>0){const e=t.timeAccessor||"time",a=t.arrivalAccessor||"arrivalTime";o.some(t=>{const r=We(Ye(t,e,"time")),o=We(Ye(t,a,"arrivalTime"));return null!=r&&null!=o&&r!==o})||r.push({severity:"warning",code:"PHYSICS_EVENTDROP_NO_ARRIVAL_SPREAD",message:"EventDropChart data does not show distinct arrival times, so the physics replay collapses to event order.",fix:"Provide an arrivalAccessor field with event-arrival times when demonstrating lateness, watermarks, or out-of-order streams."})}}if("UnitPileChart"===e){const e="mechanical"===(t.simulationMode??t.mode),a=We(t.mechanicalCount);null==t.mechanicalCount||null!=a&&a>0||r.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical pile chart.`,fix:"Use a positive mechanicalCount, for example 80."}),e&&Array.isArray(t.mechanicalCategories)&&0===t.mechanicalCategories.length&&r.push({severity:"error",code:"PHYSICS_EMPTY_MECHANICAL_CATEGORIES",message:"mechanicalCategories=[] leaves no containers for the generated unit pile.",fix:"Provide at least one category label, or omit mechanicalCategories for the default set."});const o=_e(t.unitValue??1);if(null==o||0>=o)return void r.push({severity:"error",code:"PHYSICS_BAD_UNIT_VALUE",message:`unitValue=${t.unitValue} cannot unitize values into physical bodies.`,fix:"Set unitValue to a positive number represented by one body."});const n=e?Ge({count:a??void 0,categories:Array.isArray(t.mechanicalCategories)?t.mechanicalCategories:void 0,seed:_e(t.seed)??1,unitValue:o}):Array.isArray(t.data)?t.data:[],{rows:i}=He(n,"pile"),s=t.valueAccessor??(e?"value":void 0),c=i.reduce((e,t,r)=>{const a="function"==typeof s?s(t,r):"string"==typeof s&&s?t[s]:1;return e+qe(Math.max(0,_e(a)??0),o)},0);c>1500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`UnitPileChart would create about ${c} live bodies; motion may dominate the chart and stress the frame budget.`,fix:"Sample or aggregate source records, or use a bounded window with sediment. A larger unitValue reduces full circles but still leaves at least one body per positive source record."})}if("CollisionSwarmChart"===e){if((We(t.pointRadius??5)??5)>0||r.push({severity:"error",code:"PHYSICS_BAD_POINT_RADIUS",message:`pointRadius=${t.pointRadius} cannot produce collision bodies.`,fix:"Use a positive pointRadius, for example 5."}),(We(t.collisionIterations??6)??6)>0||r.push({severity:"error",code:"PHYSICS_BAD_COLLISION_ITERATIONS",message:`collisionIterations=${t.collisionIterations} disables collision relaxation.`,fix:"Use at least one collision iteration; 4-8 is a practical range for swarms."}),null!=t.xExtent){const e=Array.isArray(t.xExtent)?t.xExtent:[],a=We(e[0]),o=We(e[1]);(2>e.length||null==a||null==o)&&r.push({severity:"error",code:"PHYSICS_BAD_X_EXTENT",message:"xExtent must be a numeric [min, max] pair for CollisionSwarmChart.",fix:"Pass xExtent={[min, max]} or omit it so the chart infers the domain from data."})}const e=Array.isArray(t.data)?t.data:[];e.length>1200&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`CollisionSwarmChart would create ${e.length} live bodies; collision relaxation may dominate the frame budget.`,fix:"Sample, aggregate, reduce point radius, or move to a static SwarmPlot when every row does not need a physical body."});const a=t.groupAccessor;if(e.length>0&&a){const t=/* @__PURE__ */new Set;for(const r of e){const e=Ye(r,a,"group");null!=e&&t.add(e)}t.size>12&&r.push({severity:"warning",code:"PHYSICS_TOO_MANY_SWARM_LANES",message:`CollisionSwarmChart has ${t.size} group lanes, which leaves little vertical room for collision separation.`,fix:"Facet or filter groups, or use an ordinary SwarmPlot/BoxPlot for dense grouped comparison."})}}if("GaltonBoardChart"!==e&&"UnitPileChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e&&"EventDropChart"!==e||(null!=t.massBy||null!=t.massAccessor||t.frameProps&&"object"==typeof t.frameProps&&null!=t.frameProps.bodyMassBy)&&r.push({severity:"warning",code:"PHYSICS_DATA_IN_DYNAMICS",message:e+" appears to map a data field to mass/dynamics. Mass is not a readable quantitative channel.",fix:"Encode quantities in spawn position, bin, size, color, or glyph — keep mass/friction/restitution as process texture. Use showProjection for the truth layer."}),"UnitPileChart"!==e&&"GaltonBoardChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e&&"CrucibleChart"!==e||!1!==t.showProjection||r.push({severity:"warning",code:"PHYSICS_NO_PROJECTION",message:e+" has showProjection={false}. Without a settled projection, motion is easy to over-read as data.",fix:"Keep showProjection enabled (default) so the chart collapses to a legible static reading, or document why the process alone is the claim."}),"ProcessFlowChart"===e){const e=Array.isArray(t.stages)?t.stages:[];if(0===e.length)r.push({severity:"error",code:"PROCESS_FLOW_MISSING_STAGES",message:"ProcessFlowChart requires a non-empty stages array.",fix:'Provide stages={[{ id: "coding", force: 12 }, { id: "merged", absorb: true }]}.'});else{e.some(e=>!e||null==e.id||""===(e.id+"").trim())&&r.push({severity:"error",code:"PROCESS_FLOW_BAD_STAGE",message:"Every ProcessFlowChart stage needs a stable id.",fix:'Use stages like { id: "review", label: "Review", capacity: { unitsPerSecond: 4 } }.'});const a=e.filter(e=>e?.absorb).length;t.groupBy&&0===a&&r.push({severity:"warning",code:"PROCESS_FLOW_GROUP_NO_ABSORB",message:"groupBy is set but no stage has absorb: true, so all-members completion cannot resolve.",fix:'Mark a terminal stage with absorb: true (e.g. merged), or set groupCompletion="none".'})}}if("GauntletChart"===e&&(Array.isArray(t.negativeProperties)||r.push({severity:"warning",code:"GAUNTLET_MISSING_NEGATIVE_PROPERTIES",message:"GauntletChart usually needs negativeProperties for drag/cost bodies (empty array is ok if intentional).",fix:'Provide negativeProperties={[{ id: "cost", label: "Cost", load: 1 }]} or explicitly pass [].'})),"CrucibleChart"===e){const e=Array.isArray(t.phases)?t.phases:[],a=Array.isArray(t.products)?t.products:[],o=Array.isArray(t.events)?t.events:[],n=Array.isArray(t.outlets)?t.outlets:[];0===e.length?r.push({severity:"error",code:"CRUCIBLE_MISSING_PHASES",message:"CrucibleChart requires an authored, non-empty phases array; a treatment program cannot be inferred from flat data.",fix:'Provide phases={[{ id: "charge", label: "Charge", duration: 1, motion: "charge" }]}.'}):e.some(e=>!e||null==e.id||""===(e.id+"").trim()||null==We(e.duration)||0>=Number(e.duration))&&r.push({severity:"error",code:"CRUCIBLE_BAD_PHASE",message:"Every CrucibleChart phase needs a stable id and a positive finite duration.",fix:'Use phases like { id: "assay", label: "Assay", duration: 2, motion: "mix" }.'}),0===a.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_PRODUCTS",message:"CrucibleChart has no declared product molds. Products are never discovered from collisions or source fields.",fix:'Declare products={[{ id: "accepted", label: "Accepted", outletId: "product" }]} when the treatment forms an output.'}),0===o.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_EVENTS",message:"CrucibleChart has no authored events, so its phases cannot transform, combine, split, or route the charge.",fix:"Supply an explicit events array; do not ask the chart or an AI layer to infer a treatment from the rows."}),Array.isArray(t.outlets)||r.push({severity:"warning",code:"CRUCIBLE_IMPLICIT_OUTLETS",message:"CrucibleChart is using generic default outlets rather than domain-specific destinations.",fix:"Provide reason-labelled outlets and reference their ids from products, complete-product, and eject effects."});const i=new Set(a.map(e=>e?.id).filter(e=>null!=e).map(String)),s=/* @__PURE__ */new Set(["product","retained","residue","failed","recovered",...n.map(e=>e?.id).filter(e=>null!=e).map(String)]),c=/* @__PURE__ */new Set,l=/* @__PURE__ */new Set;for(const e of o)if(e&&Array.isArray(e.effects))for(const t of e.effects){if(!t||"object"!=typeof t)continue;const e=t.type;if("combine"!==e&&"contribute"!==e&&"complete-product"!==e||null==t.productId||i.has(t.productId+"")||c.add(t.productId+""),"split"===e&&Array.isArray(t.products))for(const e of t.products)null==e?.productId||i.has(e.productId+"")||c.add(e.productId+"");null==t.outletId||s.has(t.outletId+"")||l.add(t.outletId+"")}c.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_PRODUCT",message:`CrucibleChart events reference undeclared product molds: ${[...c].sort().join(", ")}.`,fix:"Declare every referenced product id in products; do not create product definitions implicitly inside events."}),l.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_OUTLET",message:`CrucibleChart events reference undeclared outlets: ${[...l].sort().join(", ")}.`,fix:"Declare every domain outlet in outlets and reuse its stable id in authored effects."});const u=We(t.playbackRate);null==t.playbackRate||null!=u&&u>0||r.push({severity:"error",code:"CRUCIBLE_BAD_PLAYBACK_RATE",message:`playbackRate=${t.playbackRate+""} cannot advance the authored CrucibleChart tape.`,fix:"Use a positive playbackRate such as 0.5 for half speed or 2 for double speed."});const d=We(t.rerunMS);null==t.rerunMS||null!=d&&d>=0||r.push({severity:"error",code:"CRUCIBLE_BAD_RERUN_MS",message:`rerunMS=${t.rerunMS+""} must be a finite non-negative delay or null.`,fix:"Use rerunMS={3000}, rerunMS={0}, or omit the prop for a single run."})}if("GaltonBoardChart"===e||"CollisionSwarmChart"===e||"ProcessFlowChart"===e||"EventDropChart"===e||"CrucibleChart"===e){const a=Array.isArray(t.data)?t.data:[],o=We(t.mechanicalCount)??0,n=a.length>0?a.length:o;n>2500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(n)} live bodies, which can overwhelm the simulation loop.`,fix:"Lower mechanicalCount / unitize with a larger unitValue, enable sediment/windowSize, or sample the data before spawn."})}}}function Je(e){const t=[],r=e.domain;null==r?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):Array.isArray(r)&&2===r.length&&Number.isFinite(Number(r[0]))&&Number.isFinite(Number(r[1]))||t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});const a=e.edges;if(Array.isArray(a)&&a.length>0){const e=a[0];null!=e.startTime&&null!=e.endTime||t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}const o=e.nodes,n=Array.isArray(o)?o.length:0;return!0!==e.showLabels||24>n||t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${n} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),80>(Array.isArray(a)?a.length:0)||null!=e.layoutExecution||"off"===e.packing||t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}function Xe(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const r=Gc.test(t)?t+"-01":t;if(r===t&&10>t.length)return NaN;const a=Date.parse(r);return Number.isFinite(a)?a:NaN}function Ze(e,t){const r=e.nestedDataAccessorProp?t[e.nestedDataAccessorProp]:void 0;return"string"==typeof r?r:e.defaultNestedDataAccessor}function Qe(e,t,r){const a=e.dataProp??"data",o=t[a],n=r??(Array.isArray(o)?o:[]),i=Ze(e,t);if(!i)return{dataProp:a,rows:n};const s=[];let c=!1;for(const e of n){const t=e?.[i];if(Array.isArray(t)){c=!0;for(const e of t)e&&"object"==typeof e&&s.push(e)}}return{dataProp:a,rows:c?s:n}}function et(e,t,r){const a=/* @__PURE__ */new Set;for(const o of e.fields){const e=o.dataProp??"data",n=r??t[e];if(!Array.isArray(n))continue;if(0===n.length){a.add(e);continue}const i=Ze(o,t);if(!i)continue;const s=n.map(e=>e?.[i]).filter(Array.isArray);s.length>0&&s.every(e=>0===e.length)&&a.add(`${e}.${i}`)}return[...a]}function tt(){const e=globalThis;return e[nl]??(e[nl]={contracts:/* @__PURE__ */new Map}),e[nl]}function rt(e){return tt().contracts.get(e)??ol[e]}function at(e,t,r){const a={numbers:r?[]:void 0,finite:0,min:1/0,max:-1/0,missing:0,nonFinite:0,nonNumeric:0,zero:0,negative:0,fractional:0};for(const r of e){const e=r?.[t];if(null==e||""===e){a.missing++;continue}let o;if("number"==typeof e)o=e;else if("string"==typeof e){const t=e.trim();if(""===t){a.missing++;continue}const r=Number(t);Number.isNaN(r)?/^[+-]?nan$/i.test(t)&&(o=r):o=r}void 0!==o?Number.isFinite(o)?(a.numbers?.push(o),a.finite++,a.min>o&&(a.min=o),o>a.max&&(a.max=o),0===o&&a.zero++,0>o&&a.negative++,Number.isInteger(o)||a.fractional++):a.nonFinite++:a.nonNumeric++}return a}function ot(e,t){if(0===e.length)return;const r=(e.length-1)*t,a=Math.floor(r),o=Math.ceil(r);if(a===o)return e[a];const n=r-a;return e[a]*(1-n)+e[o]*n}function nt(e,t={}){if(!Array.isArray(e)||0===e.length)return{};const r=/* @__PURE__ */new Set;for(const t of e)if(t&&"object"==typeof t)for(const e of Object.keys(t))r.add(e);const a={};for(const o of r){const r=at(e,o,!1!==t.quantiles),n=r.numbers?.sort((e,t)=>e-t);a[o]={field:o,observedCount:e.length-r.missing,finiteCount:r.finite,missingCount:r.missing,nonFiniteCount:r.nonFinite,nonNumericCount:r.nonNumeric,zeroCount:r.zero,negativeCount:r.negative,fractionalCount:r.fractional,...r.finite>0?{min:r.min,...n?{q1:ot(n,.25),median:ot(n,.5),q3:ot(n,.75)}:{},max:r.max}:{}}}return a}function it(e){const t=[`${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 r of e.diagnoses)t.push(`${"error"===r.severity?"ERROR":"WARN"} ${r.code}${r.field?` [${r.field}]`:""}: ${r.message}`),r.fix&&t.push(" Fix: "+r.fix);return t.join("\n")}function st(e){return e.code.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function ct(e,t={}){const r=Number.isFinite(t.max)?Math.max(0,Math.floor(t.max)):6,a=e.diagnoses.map((e,t)=>({item:e,diagnosisIndex:t})).filter(({item:e})=>!t.errorsOnly||"error"===e.severity),o=a.slice(0,r).map(({item:e,diagnosisIndex:t})=>({id:`data-audit:${e.code}:${e.role??"chart"}:${e.field??"chart"}:${t}`,level:e.severity,title:e.field?`${st(e)} · ${e.field}`:st(e),message:e.fix?`${e.message} ${e.fix}`:e.message,source:"Semiotic data audit",dismissible:!0}));return a.length>r&&o.push({id:"data-audit:overflow:chart",level:a.slice(r).some(({item:e})=>"error"===e.severity)?"error":"warning",title:`${a.length-r} more numeric finding${a.length-r===1?"":"s"}`,message:"Run auditData() or diagnoseConfig() to inspect the complete report.",source:"Semiotic data audit",dismissible:!0}),o}function lt(e){const t=[];for(const[r,a]of Object.entries(sl))"string"!=typeof e[r]&&"function"!=typeof e[r]||t.push({role:a,accessor:r,..."size"===a?{requirements:["finite","non-negative"]}:{},..."x"===a||"y"===a?{domain:!0}:{}});return t.length>0?{fields:t}:void 0}function ut(e,t,r){return"function"==typeof e?e(t,r):t[e]}function dt(e,t){if("number"==typeof e)return Number.isFinite(e)?e:null;if(e instanceof Date){const r=e.getTime();return t&&Number.isFinite(r)?r:null}if("string"==typeof e){const r=e.trim(),a=Number(r);if(r&&Number.isFinite(a))return a;if("date-like"===t){const e=Xe(r);return Number.isFinite(e)?e:null}}return null}function ht(e){return"number"==typeof e&&!Number.isFinite(e)}function pt(e,t,r,a,o){const n={field:r,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let r=0;e.length>r;r++){let i;try{i=ut(t,e[r],r)}catch{n.accessorErrorRows.push(r);continue}if(null==i||""===i){if(void 0!==o){n.numbers.push(o),n.finiteRows.push(r),0===o&&n.zeroRows.push(r),0>o&&n.negativeRows.push(r),Number.isInteger(o)||n.fractionalRows.push(r);continue}n.missingRows.push(r);continue}const s=dt(i,a);null!=s?(n.numbers.push(s),n.finiteRows.push(r),0===s&&n.zeroRows.push(r),0>s&&n.negativeRows.push(r),Number.isInteger(s)||n.fractionalRows.push(r)):ht(i)?n.nonFiniteRows.push(r):n.nonNumericRows.push(r)}return n}function ft(e,t){const r=new Set(e.requirements??["finite"]);return r.add("finite"),("x"===e.role&&"log"===t.xScaleType||"y"===e.role&&"log"===t.yScaleType)&&r.add("positive"),[...r]}function mt(e){let t=1/0,r=-1/0;for(const a of e)t>a&&(t=a),a>r&&(r=a);return[t,r]}function gt(e,t,r){const a=[],o=/* @__PURE__ */new Set;for(const n of e.fields){if(n.whenProps?.some(e=>null==t[e]))continue;const e=t[n.accessor],i="string"==typeof e||"function"==typeof e?e:n.defaultAccessor;if("string"!=typeof i&&"function"!=typeof i)continue;const{dataProp:s,rows:c}=Qe(n,t,r);if(0===c.length)continue;const l="string"==typeof i?i:n.accessor+"()",u=`${s}:${n.role}:${l}`;if(o.has(u))continue;o.add(u);const d=n.temporalValues??("time"===n.role||"x"===n.role&&"time"===t.xScaleType?"date-like":void 0),h="x"===n.role&&"log"===t.xScaleType||"y"===n.role&&"log"===t.yScaleType,p=ft(n,t);a.push({contract:n,accessor:i,accessorLabel:l,dataProp:s,rows:c,requirements:p,logScale:h,observation:pt(c,i,l,d,n.missingValue)})}return a}function yt(e){return e.slice(0,il)}function bt(e){return{domain:"data",...e}}function vt(e){const t=e.observation.numbers.map((t,r)=>({value:t,row:e.observation.finiteRows[r]})).sort((e,t)=>e.value-t.value);if(8>t.length)return[];const r=t.map(e=>e.value),a=ot(r,.25),o=ot(r,.75),n=ot(r,.5),i=o-a;if(i>0){const e=a-10*i,r=o+10*i;return t.filter(t=>e>t.value||t.value>r).map(e=>e.row)}const s=100*Math.max(1,Math.abs(n));return t.filter(e=>Math.abs(e.value-n)>s).map(e=>e.row)}function wt(e,t){const r=[],{observation:a,contract:o,accessorLabel:n,requirements:i}=e,s={field:n,role:o.role},c=[...a.nonFiniteRows,...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(0===a.numbers.length)return r.push(bt({severity:"error",code:"DEGENERATE_EXTENT",message:`${o.accessor}="${n}" produces no finite numeric values; the chart cannot resolve its ${o.role} input.`,fix:`Ensure ${n} contains finite numbers${"x"===o.role?" (or valid dates for a time scale)":""}.`,...s,...c.length>0?{rows:yt(c),count:c.length}:{}})),r;a.nonFiniteRows.length>0&&r.push(bt({severity:"error",code:"NON_FINITE_VALUE",message:`${n} contains ${a.nonFiniteRows.length} NaN or infinite value${1===a.nonFiniteRows.length?"":"s"}; scale and layout math require finite numbers.`,fix:`Filter or replace NaN/Infinity in ${n} before rendering.`,...s,rows:yt(a.nonFiniteRows),count:a.nonFiniteRows.length})),!o.allowMissing&&a.missingRows.length>0&&r.push(bt({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${n} is missing for ${a.missingRows.length} row${1===a.missingRows.length?"":"s"}; the ${o.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${n} values before rendering.`,...s,rows:yt(a.missingRows),count:a.missingRows.length}));const l=[...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(l.length>0&&r.push(bt({severity:"error",code:"NON_NUMERIC_VALUE",message:`${n} produces ${l.length} non-numeric value${1===l.length?"":"s"} for the ${o.role} role.`,fix:`Bind ${o.accessor} to a numeric field or return finite numbers from the accessor.`,...s,rows:yt(l),count:l.length})),o.domain&&a.numbers.length>=2){const[e,t]=mt(a.numbers);e===t&&r.push(bt({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${n} is constant at ${e}; its ${o.role} scale has a zero-span data domain.`,fix:`Provide varying ${o.role} values, set an explicit extent around ${e}, or use a single-value display.`,...s,rows:yt(a.finiteRows),count:a.finiteRows.length}))}if(i.includes("positive")){const t=a.numbers.map((e,t)=>({number:e,row:a.finiteRows[t]})).filter(({number:e})=>0>=e).map(({row:e})=>e);if(t.length>0){const a=e.logScale;r.push(bt({severity:"error",code:a?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${n} contains ${t.length} non-positive value${1===t.length?"":"s"}, which ${a?"cannot be represented on a log scale":"violate the positive-value contract"}.`,fix:a?"Remove or transform values ≤ 0, or use a linear/symlog scale.":"Provide values greater than zero.",...s,rows:yt(t),count:t.length}))}}if(i.includes("non-negative")&&a.negativeRows.length>0&&r.push(bt({severity:"error",code:"size"===o.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${n} contains ${a.negativeRows.length} negative ${o.role} value${1===a.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.",...s,rows:yt(a.negativeRows),count:a.negativeRows.length})),i.includes("integer")){const e=[.../* @__PURE__ */new Set([...a.negativeRows,...a.zeroRows,...a.fractionalRows])].sort((e,t)=>e-t);e.length>0&&r.push(bt({severity:"error",code:"INVALID_COUNT",message:`${n} 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.",...s,rows:yt(e),count:e.length}))}if(i.includes("unit-interval")){const e=a.numbers.map((e,t)=>({number:e,row:a.finiteRows[t]})).filter(({number:e})=>0>e||e>1).map(({row:e})=>e);e.length>0&&r.push(bt({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${n} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${n} to [0, 1] before using it as ${o.role}.`,...s,rows:yt(e),count:e.length}))}if(t&&o.domain){const t=vt(e);t.length>0&&r.push(bt({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${n} has ${t.length} extreme value${1===t.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.",...s,rows:yt(t),count:t.length}))}return r}function At(e,t,r){if(!e)return"__all__";try{return ut(e,t,r)+""}catch{return"__accessor_error__"}}function xt(e,t,r){if(e.whenProp&&!0!==r[e.whenProp])return[];const a=t.find(t=>t.contract.role===e.role);if(!a||0===a.observation.numbers.length)return[];const o=e.groupAccessor?r[e.groupAccessor]:void 0,n="string"==typeof o||"function"==typeof o?o:e.defaultGroupAccessor,i=/* @__PURE__ */new Map;for(let e=0;a.rows.length>e;e++){let t;try{t=ut(a.accessor,a.rows[e],e)}catch{continue}const r=dt(t,void 0);if(null==r)continue;const o=At(n,a.rows[e],e),s=i.get(o)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};s.sum+=r,s.magnitude+=Math.abs(r),s.positive||(s.positive=r>0),s.negative||(s.negative=0>r),s.rows.push(e),0>r&&s.negativeRows.push(e),i.set(o,s)}const s=[],c=[],l=[],u=[],d=[],h=[];for(const[t,r]of i)("positive-total"===e.kind&&0>=r.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,r.magnitude)*10>=Math.abs(r.sum))&&(s.push(t),u.push(...r.rows)),"normalized-total"===e.kind&&r.positive&&r.negative&&(c.push(t),d.push(...r.rows)),"normalized-total"===e.kind&&r.negative&&(l.push(t),h.push(...r.negativeRows));const p=[];return s.length>0&&p.push(bt({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${s.length} normalization group${1===s.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:a.accessorLabel,role:e.role,rows:yt([...new Set(u)].sort((e,t)=>e-t)),count:s.length})),l.length>0&&p.push(bt({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:a.accessorLabel,role:e.role,rows:yt([...new Set(h)].sort((e,t)=>e-t)),count:h.length})),c.length>0&&p.push(bt({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:a.accessorLabel,role:e.role,rows:yt([...new Set(d)].sort((e,t)=>e-t)),count:c.length})),p}function $t(e,t,r,a={}){const o=a.contracts??rt(e)??lt(t);if(!o)return{component:e,ok:!0,rowCount:r?.length??(Array.isArray(t.data)?t.data.length:0),summary:{fieldsChecked:0,errors:0,warnings:0},contracts:[],diagnoses:[]};const n=gt(o,t,r),i=[],s=!1!==a.checkOutliers;for(const e of et(o,t,r))i.push(bt({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 c=new Set(n.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(const e of c)i.push(bt({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 n)i.push(...wt(e,s));for(const e of o.aggregates??[])i.push(...xt(e,n,t));const l=i.filter(e=>"error"===e.severity).length,u=i.length-l;return{component:e,ok:0===l,rowCount:n.reduce((e,t)=>Math.max(e,t.rows.length),r?.length??(Array.isArray(t.data)?t.data.length:0)),summary:{fieldsChecked:n.length,errors:l,warnings:u},contracts:n.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}}function Ct(e,t,r){const a=dc[e];if(a){if("array"===a.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&r.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===a.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&r.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}function St(e,t){for(const[r,a]of[["width",600],["height",400]]){const o=e[r];void 0===o||"number"==typeof o&&o>0||t.push({severity:"error",code:"width"===r?"BAD_WIDTH":"BAD_HEIGHT",message:`${r}=${JSON.stringify(o)} — chart needs a positive number.`,fix:`Set ${r}={${a}}.`})}if(e.size&&Array.isArray(e.size)){const[r,a]=e.size;(null!=r&&0>=r||null!=a&&0>=a)&&t.push({severity:"error",code:"BAD_SIZE",message:`size=[${r}, ${a}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}function kt(e,t,r){const a=dc[e];if(!a||"array"!==a.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const n=o[0];if(!n||"object"!=typeof n)return;const i=Object.keys(n);for(const e of a.dataAccessors){const a=t[e];"string"==typeof a&&(a in n||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${a}" not found in data. Available fields: ${i.join(", ")}.`,fix:`Change ${e} to one of: ${i.map(e=>`"${e}"`).join(", ")}, or use a function: ${e}={d => d.myValue}.`}))}}function Rt(e,t,r){gc.has(e)&&Array.isArray(t.data)&&r.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}function Pt(e,t,r){yc.has(e)&&(t.edges||t.data||r.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}function It(e,t,r){const a=dc[e];if(!a||"array"!==a.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const n=o[0];if(!n||"object"!=typeof n)return;const i=t.xAccessor;"string"==typeof i&&n[i]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${i}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}function Et(e,t,r){t.linkedHover&&!t.selection&&r.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}function Nt(e,t,r){if(!vc.has(e))return;if(t.gapStrategy)return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=t.yAccessor||"y";"string"==typeof o&&a.some(e=>{const t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}function Tt(e,t,r){if(!bc.has(e))return;const a=t.rExtent||t.yExtent||t.valueExtent;a&&Array.isArray(a)&&a.length>=1&&null!=a[0]&&0!==a[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${a[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${a[1]??"auto"}]}. For trend-focused charts, use LineChart instead.`})}function Mt(e,t,r){if(!wc.has(e))return;const a=t.barPadding;"number"==typeof a&&10>a&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${a} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}function Ot(e,t,r){if("Heatmap"!==e)return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=a[0];if(o&&"object"==typeof o)for(const e of["xAccessor","yAccessor"]){const a=t[e];if("string"!=typeof a)continue;const n=o[a];"string"==typeof n&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${a}" resolves to string values (e.g. "${n}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}function Ft(e,t,r){const a=t.colorScheme;if(!a||!Array.isArray(a))return;const o="string"==typeof t.background?t.background:"#ffffff";if(!o.startsWith("#"))return;const n=[];for(const e of a){if("string"!=typeof e||!e.startsWith("#"))continue;const t=f(e,o);null!==t&&3>t&&n.push(`${e} (${t.toFixed(1)}:1)`)}n.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${n.length} color(s) in colorScheme have < 3:1 contrast against background "${o}": ${n.join(", ")}. Data marks may be hard to see.`,fix:"Choose colors with at least 3:1 contrast against the chart background."})}function jt(e,t){const r=e.width??600,a=e.height??400,o=e.margin;if(!o||"object"!=typeof o)return;const n=(o.left||0)+(o.right||0),i=(o.top||0)+(o.bottom||0);r>n||t.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${n}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>i||t.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${i}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}function zt(e,t,r){const a=dc[e]?.props,o=e=>!!a?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,n=o("title"),i=o("description"),s=o("summary");n||i||s||r.push({severity:"warning",code:"MISSING_DESCRIPTION",message:"No title, description, or summary provided. Screen readers will fall back to a generic chart-type label.",fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}function Bt(e,t,r){const a=t.colorScheme;if("string"!=typeof a)return;const o=dc[e];o?.props?.colorScheme?.enum||cl.has(a)||r.push({severity:"warning",code:"UNKNOWN_COLOR_SCHEME",message:`colorScheme "${a}" is not a recognized named scheme — the chart will fall back to the default palette.`,fix:`Use a known scheme name (${[...cl].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}function Lt(e,t,r){const a=t.colorScheme;if(!a||!Array.isArray(a)||2>a.length)return;const o=a.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;const n=[];for(let e=0;o.length-1>e;e++){const t=f(o[e],o[e+1]);null!==t&&1.5>t&&n.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}n.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${n.length} adjacent color pair(s) in colorScheme have very similar luminance: ${n.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}function _t(e,t,r){const a=[];for(const e of ll)"function"==typeof t[e]&&a.push(e);a.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${a.length>1?"s":""} detected: ${a.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference; closures over changing values can force unnecessary scene rebuilds on resize/rotation.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}function Dt(e,t,r){const a=t.hoverRadius;"number"==typeof a&&a>0&&24>a&&!1!==t.enableHover&&(!1!==t.hoverAnnotation||t.tooltip||t.customHoverBehavior||t.customClickBehavior||t.onClick)&&r.push({severity:"warning",code:"TOUCH_TARGET_SMALL",message:`hoverRadius=${a}px is below the ~24px radius needed for reliable 48px touch targets on mobile screens.`,fix:"Use hoverRadius={24} or larger for touch-heavy views. Semiotic floors touch pointer hit testing to 24px, but explicit desktop-only radii should be documented."})}function Ut(e,t,r){!0===t.responsiveWidth&&!0===t.responsiveHeight&&r.push({severity:"warning",code:"RESPONSIVE_BOTH_AXES",message:"responsiveWidth and responsiveHeight are both true. On mobile this can create resize feedback loops when the parent height depends on chart content.",fix:"Prefer responsiveWidth={true} with a fixed parent height or size={[width, fixedHeight]}; use a ResizeObserver outside the chart if the height must follow aspect ratio."})}function Vt(e,t,r){if(!0!==t.showParticles)return;const a=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},o="number"==typeof a.maxPerLine?a.maxPerLine:void 0,n="number"==typeof a.spawnRate?a.spawnRate:void 0;("number"==typeof o&&o>20||"number"==typeof n&&n>.08)&&r.push({severity:"warning",code:"GEO_PARTICLE_MOBILE_COST",message:"Animated geo particles run a continuous canvas loop that can drain battery and trigger thermal throttling on mobile GPUs.",fix:"Set particleStyle={{ maxPerLine: 12, spawnRate: 0.06 }} for mobile-heavy views, or disable showParticles when reduced-motion or low-power modes are active."})}function Gt(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function qt(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function Ht(e,t){const r=qt(e.visibleTokens);if(null!=r)return r;const a=qt(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=a)return a;const o=qt(t.tokenCount),n=qt(t.maxTokens);return null!=o&&null!=n?Math.min(o,n):o??a??n}function Wt(e,t,r){const a=[];Gt(t.tokenEncoding)&&a.push({source:"tokenEncoding",encoding:t.tokenEncoding}),Gt(t.encoding)&&a.push({source:"encoding",encoding:t.encoding});for(const{source:e,encoding:o}of a){const a=Ht(t,o);for(const t of xe(o,{visibleTokens:a}))r.push({severity:"warning",code:"TOKEN_"+t.code,message:t.message,fix:"MISSING_UNIT_VALUE"===t.code?`Set ${e}.unitValue to the value represented by one full token.`:"MISSING_UNIT_MEANING"===t.code?`Set ${e}.unitMeaning so readers know what one full token represents.`:"MISSING_COUNT_STRATEGY"===t.code?`Set ${e}.countStrategy to actual, unitized, fixed-denominator, quantile, sample, posterior-sample, or random-sample.`:"TOKEN_SEMANTICS_UNCLEAR"===t.code?`Set ${e}.tokenSemantics to observed-unit, unitized-measure, risk-case, possible-outcome, posterior-sample, hypothetical-case, topic-anchor, or decorative.`:`Adjust ${e} so its semantics, strategy, labels, and visible token count match the task.`})}}function Yt(e){const t={...e};return delete t.tokenEncoding,delete t.visibleTokens,Gt(t.encoding)&&delete t.encoding,t}function Kt(e,t){const r=t.match(/^Unknown prop "([^"]+)"/);if(r)return`Remove \`${r[1]}\` or replace it with a documented ${e} prop.`;const a=t.match(/^"([^"]+)" is required for .+\.$/i)??t.match(/(?:Missing|required) prop "?([^". ]+)/i);return a?`Add the required \`${a[1]}\` prop using the ${e} schema and example.`:t.startsWith("Unknown component")?"Choose a component returned by getSchema() or check the component name for a typo.":`Correct this ${e} prop configuration to match its schema: ${t}`}function Jt(e,t){void 0!==e.accessibleTable&&t.push({severity:"error",code:"BIGNUMBER_ACCESSIBLE_TABLE",message:"BigNumber is a value component and does not support accessibleTable.",fix:"Remove accessibleTable. Use label, description, and summary to provide BigNumber's accessible text."})}function Xt(e,t){const r=[],a=()=>({ok:r.every(e=>"warning"===e.severity),diagnoses:r}),o=/^(XY|Ordinal|Network|Physics|Geo)CustomChart$/.test(e),n=o?[]:ve(e,Yt(t)).errors;if(o){"function"!=typeof t.layout&&n.push("Provide a layout function.");const r="NetworkCustomChart"===e?["nodes","edges"]:"GeoCustomChart"===e?["points","areas","lines"]:["data"];for(const e of r)null==t[e]||Array.isArray(t[e])||n.push(`Provide an array for ${e}.`)}for(const a of n)"BigNumber"===e&&void 0!==t.accessibleTable&&a.startsWith('Unknown prop "accessibleTable"')||r.push({severity:"error",code:"VALIDATION",message:a,fix:o?a:Kt(e,a)});if("BigNumber"===e&&Jt(t,r),(o||dc[e])&&(St(t,r),jt(t,r),Ie(0,t,r)),!dc[e])return a();Ct(e,t,r),kt(e,t,r),Rt(e,t,r),Pt(e,t,r),It(e,t,r),Et(0,t,r),Tt(e,t,r),Nt(e,t,r);const i=$t(e,t,void 0,{checkOutliers:!1}).diagnoses;for(const e of i)"EMPTY_DATA"===e.code&&r.some(e=>"EMPTY_DATA"===e.code||"EMPTY_EDGES"===e.code)||r.push(e);if(Mt(e,t,r),Ot(e,t,r),Ft(0,t,r),Lt(0,t,r),Bt(e,t,r),zt(e,t,r),_t(0,t,r),Dt(0,t,r),Ut(0,t,r),Vt(0,t,r),Wt(0,t,r),Ee(0,t,r),Ne(0,t,r),Te(0,t,r),Me(e,t,r),Oe(e,t,r),r.some(e=>"NEGATIVE_VALUE"===e.code||"NEGATIVE_NORMALIZED_VALUE"===e.code)||Fe(e,t,r),je(e,t,r),ze(e,t,r),Be(e,t,r),Ke(e,t,r),"ProcessSankey"===e)for(const e of Je(t))r.push(e);return a()}function Zt(e){return"string"==typeof e&&e.trim().length>0}function Qt(e,t,r){const a=dl.has(e)||void 0!==r&&hl.has(r),o=t=>{return o=t,he(r=e)&&!ic[o].includes(r)||a;var r,o},n=ul.filter(e=>Zt(t[e])&&!o(e));return{hasTitle:o("title")&&Zt(t.title),hasDescription:o("description")&&Zt(t.description),hasSummary:o("summary")&&Zt(t.summary),unsupportedFinding:n.length>0?{id:"understandable.unsupported-description-prop",principle:"understandable",heuristic:"Descriptive text is connected to the rendered chart",critical:!0,status:"warn",message:`Useful ${n.join(" and ")} text was supplied, but ${1===n.length?"that prop is":"those props are"} not supported by ${e}'s declared chart API and cannot be credited as rendered accessibility text.`,fix:"Use the component's declared title, description, and summary props when available; for richer generated description or navigation, use ChartContainer with chartConfig plus describe and/or navigable."}:void 0}}function er(e){return!!Array.isArray(e.styleRules)&&e.styleRules.some(e=>{if("object"!=typeof e||null===e)return!1;const t=e.style;if("object"!=typeof t||null===t||Array.isArray(t))return!1;const r=t.fill;return"object"==typeof r&&null!==r&&"hatch"===r.type})}function tr(e){if(!Array.isArray(e))return!1;const t=e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase());return t.length>0&&t.every(e=>pl.has(e))}function rr(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function ar(e,t){return`${e}[Symbol(${t.description??""})]`}function or(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function nr(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function ir(e,t,r,a){const o=nr(e,t);return o&&"value"in o&&o.enumerable?sr(o.value,r,a):[r]}function sr(e,t="$",r=/* @__PURE__ */new Set){if(null===e||"string"==typeof e||"boolean"==typeof e)return[];if("number"==typeof e)return Number.isFinite(e)&&!Object.is(e,-0)?[]:[t];if("object"!=typeof e)return[t];if(r.has(e))return[t];let a,o,n;try{n=Array.isArray(e),a=Object.getPrototypeOf(e),o=Reflect.ownKeys(e)}catch{return[t]}if(a!==(n?Array.prototype:Object.prototype)&&null!==a)return[t];r.add(e);const i=[];try{if(n){const a=nr(e,"length")?.value;if(!Number.isSafeInteger(a)||0>a)return[rr(t,"length")];for(const e of o)"length"===e||"string"==typeof e&&or(e,a)||i.push("symbol"==typeof e?ar(t,e):rr(t,e));for(let o=0;a>o;o+=1)i.push(...ir(e,o+"",rr(t,o),r))}else for(const a of o)"symbol"!=typeof a?i.push(...ir(e,a,rr(t,a),r)):i.push(ar(t,a));return i}catch{return[t]}finally{r.delete(e)}}function cr(){const e=globalThis;return e[fl]||(e[fl]={recipes:/* @__PURE__ */new Map,capabilities:/* @__PURE__ */new Map,layouts:/* @__PURE__ */new Map}),e[fl]}function lr(e){return cr().recipes.get(e)}function ur(e){return cr().layouts.get(e)?.layout}function dr(e){const t=cr().layouts.get(e)?.identity;return t?{...t}:void 0}function hr(e){return"string"==typeof e?lr(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function pr(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?t:null}function fr(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis||null!=pr(e)}function mr(e){const t=e.split(/[.!?]+/).map(e=>e.trim()).filter(Boolean),r=e.trim().split(/\s+/).filter(Boolean);if(0===r.length||0===t.length)return null;let a=0;for(const e of r)a+=gr(e);return r.length/t.length*.39+a/r.length*11.8-15.59}function gr(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;const r=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return r?r.length:1}function yr(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}function br(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function vr(e){const t=br(e),r=e.controls&&"object"==typeof e.controls?e.controls:{};return!0===e.pauseControl||!0===t.pauseControl||!0===r.pause||"function"==typeof r.pause}function wr(e){const t=br(e);return!0===e.settledProjection||!0===t.settledProjection}function Ar(e){const t=br(e);return!0===e.reducedMotionSettle||"settle"===e.reducedMotion||!0===t.reducedMotionSettle||"settle"===t.reducedMotion}function xr(e){const t={id:"perceivable.low-contrast",principle:"perceivable",heuristic:"Low contrast",critical:!0},r=e.colorScheme,a="string"==typeof e.background?e.background:null;if(a&&!a.startsWith("#"))return{...t,status:"manual",message:`Background "${a}" isn't a hex literal (theme/CSS variable) — contrast can't be verified statically.`,fix:'Pass a hex `background` (e.g. "#ffffff"/"#000000"), or verify contrast manually once the theme resolves.'};const o=a??"#ffffff";if(!Array.isArray(r))return{...t,status:"manual",message:"Mark colors come from the theme/CSS variables — contrast can't be verified statically.",fix:"Confirm geometries/large text have ≥ 3:1 and regular text ≥ 4.5:1 contrast against the background."};const n=[];let i=0;for(const e of r){if("string"!=typeof e||!e.startsWith("#"))continue;const t=f(e,o);null!=t&&(i++,3>t&&n.push(`${e} (${t.toFixed(1)}:1)`))}return 0===i?{...t,status:"manual",message:"colorScheme has no parseable hex colors to check.",fix:"Verify contrast manually for non-hex colors."}:n.length>0?{...t,status:"fail",message:`${n.length} color(s) fall below 3:1 contrast vs ${o}: ${n.join(", ")}.`,fix:"Darken (light background) or lighten (dark background) those colors, or use COLOR_BLIND_SAFE_CATEGORICAL."}:{...t,status:"pass",message:`All ${i} checked colorScheme color(s) meet ≥ 3:1 contrast vs ${o}.`}}function $r(e,t,r={}){const a=[],o=lr(e),n=Ic.has(e),i=he(e)||!!o||n,s=!0===r.inChartContainer,c=!0===r.describe,l=!0===r.navigable,u=kc.has(e),d=gc.has(e),{hasTitle:h,hasDescription:p,hasSummary:f,unsupportedFinding:m}=Qt(e,t,o?.frameFamily),g=!1!==t.accessibleTable&&!u,y=h||p||f,b=yr(t),v=vr(t),w=n,A=wr(t)||Nc.has(e)&&g,x=Ar(t)||w,$=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],C=i?"pass":"manual",S=i?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(m&&a.push(m),a.push(xr(t)),a.push({id:"perceivable.content-only-visual",principle:"perceivable",heuristic:"Content is only visual",critical:!0,...u?{status:"pass",message:"BigNumber renders its value as real text with an ARIA label — available without vision."}:g?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:p&&f?{status:"manual",message:"accessibleTable is off; a description + summary are present. Verify they convey everything the chart shows.",fix:"Re-enable accessibleTable, or confirm via screen reader that the text alternative is complete."}:{status:"fail",message:"accessibleTable is disabled and there's no full text alternative — the data is only available visually.",fix:"Remove accessibleTable={false}, or provide a complete description/summary plus a data table."}}),a.push({id:"perceivable.small-text",principle:"perceivable",heuristic:"Small text size",critical:!0,status:"pass",message:"Semiotic's default tick and axis-label fonts are 12px, meeting Chartability's 9pt/12px floor.",fix:"If a theme or override lowers --semiotic-tick-font-size below 12px, raise it back for low-vision audiences."}),a.push({id:"perceivable.seizure-risk",principle:"perceivable",heuristic:"Visual presents seizure risk",critical:!0,...null!=t.pulse||Ec.has(e)?{status:"manual",message:"Pulse/continuous animation is in use. Confirm nothing flashes more than 3×/sec, especially saturated red.",fix:"Avoid red flashes and rapid (>3 Hz) flicker; reduced-motion is auto-honored, but verify the default presentation."}:{status:"manual",message:"No flashing detected statically. Confirm no element flashes more than 3×/sec.",fix:"Manual check — most static charts pass trivially."}}),null!=t.colorBy){const e=!0===t.directLabel||!0===t.showLabels,r=er(t);a.push({id:"perceivable.color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...e?{status:"pass",message:"Categories are encoded by color (colorBy) and also directly labeled, so color isn't the only channel."}:{status:"warn",message:r?"Categories use colorBy and this config authors a HatchFill through styleRules, but a static audit cannot prove those rules give every category a distinct non-color cue. Semiotic does not automatically assign per-category textures.":"Categories are encoded by color (colorBy) with no declared redundant channel. Semiotic supports author-supplied HatchFill patterns through styleRules, but this config has no statically visible HatchFill descriptor and there is no automatic per-category texture assignment.",fix:r?"Verify every category remains distinguishable with color removed; add direct labels where hatching is incomplete, keep categories ≤ ~7, and use a CVD-safe palette.":"Add direct labels (directLabel on LineChart/AreaChart, showLabels on network/hierarchy) or category-targeted styleRules with distinct HatchFill descriptors; keep categories ≤ ~7 and use a CVD-safe palette."}});const o=tr(t.colorScheme);a.push({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1,...o?{status:"pass",message:"colorScheme uses Semiotic's Wong colorblind-safe palette."}:{status:"manual",message:"Color encodes meaning; statically we can't confirm the palette is colorblind-safe.",fix:'Use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic", or test your scheme with Viz Palette / Chroma.'}}),a.push({id:"flexible.textures-adjustable",principle:"flexible",heuristic:"Contrast and textures cannot be adjusted",critical:!1,status:"warn",message:r?"This config uses an author-supplied HatchFill through styleRules, but Semiotic has no automatic, theme-aware per-category texture channel or user-facing texture toggle.":"Semiotic supports author-supplied HatchFill patterns through styleRules, but this config has no statically visible HatchFill descriptor; there is no automatic, theme-aware per-category texture channel or user-facing texture toggle.",fix:r?"Verify the authored hatches cover every meaningful category and remain legible in the active theme; pair them with direct labels and a CVD-safe palette.":"Use category-targeted styleRules with distinct HatchFill descriptors or direct labels so the encoding survives color removal. Contrast itself is themeable via CSS variables."})}{const e=$.filter(Ce);if(e.length>0){const r=t.autoPlaceAnnotations,o="object"==typeof r&&null!==r&&!0===r.redundantCues,n=e.filter(e=>{if("string"!=typeof e.color)return!1;const t=$e(e),r=o&&"text"===t;return!(ke(e)||r)});a.push({id:"perceivable.annotation-association",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...0===n.length?{status:"pass",message:"No annotation relies on color alone to indicate its target — wherever color is used, a connector, enclosure, or reference-line cue is present too."}:{status:"warn",message:`${n.length} of ${e.length} annotation(s) carry a color but no connector, enclosure, or reference-line cue, so a color-blind or non-visual reader can't tie them to their target (the correspondence problem).`,fix:"Add a connector (the label/callout default), place the note adjacent to its target, enclose the target, or enable autoPlaceAnnotations: { redundantCues: true } to give colored text notes a leader line — don't rely on color matching alone."}})}}a.push({id:"operable.single-input-modality",principle:"operable",heuristic:"Interaction modality only has one input type",critical:!0,...i?{status:"pass",message:"Built-in keyboard navigation (arrows/Home/End/PageUp-Down/Enter) mirrors mouse hover."}:{status:"manual",message:`Can't confirm keyboard support for "${e}".`,fix:"Verify Tab + arrow-key operation."}});{const e=[];null==t.brush&&null==t.onBrush||e.push("brushing"),!0===t.zoomable&&e.push("zoom/pan"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||e.push("legend filtering"),e.length>0&&a.push({id:"operable.complex-action-alternatives",principle:"operable",heuristic:"Complex actions have no alternatives",critical:!1,status:"warn",message:`Mouse-driven ${e.join(", ")} ${e.length>1?"have":"has"} no built-in keyboard/standard-UI equivalent.`,fix:"Pair the complex interaction with a standard control (range inputs for a brush, buttons for zoom, a checkbox list for legend filtering) operable by keyboard and screen reader."})}{const r=jc[e];if(r&&b){const e=t[r];"number"==typeof e&&e>0&&24>2*e&&a.push({id:"operable.target-size",principle:"operable",heuristic:"Target pointer interaction size is too small",critical:!1,status:"warn",message:`${r}=${e} gives a ~${2*e}px hit target, below the 24×24px minimum for pointer interaction.`,fix:"Increase the radius, or rely on the chart's hoverRadius / keyboard navigation as the alternative for precise selection."})}}a.push({id:"operable.tab-stops",principle:"operable",heuristic:"Inappropriate tab stops",critical:!1,status:C,message:`The chart takes a single tab stop and navigates data with arrow keys${S} — the recommended pattern for dense charts (no per-datum tab stops to wade through).`}),a.push({id:"operable.interaction-cues",principle:"operable",heuristic:"No interaction cues or instructions",critical:!0,...b?f||p?{status:"manual",message:"Chart is interactive and has descriptive text. Confirm that text explains how to interact (keyboard + pointer).",fix:'State the interaction model in summary, e.g. "Use arrow keys to move between points."'}:{status:"warn",message:"Chart is interactive but nothing explains how to use it.",fix:"Describe the interaction in a summary or nearby text (keyboard navigation, what hover/click reveals)."}:{status:"not-applicable",message:"No interactive behavior detected."}}),a.push({id:"operable.controls-override-at",principle:"operable",heuristic:"Controls override AT controls",critical:!0,status:C,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${S}.`}),a.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:C,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${S}.`,fix:i?"Ensure --semiotic-focus keeps ≥ 3:1 contrast against your background.":void 0}),a.push({id:"understandable.title-summary-caption",principle:"understandable",heuristic:"No title, summary, or caption",critical:!0,...y?{status:"pass",message:`Provided: ${[h&&"title",p&&"description",f&&"summary"].filter(Boolean).join(", ")}.`}:s?{status:"manual",message:"No title/description/summary on the chart. If the wrapping ChartContainer supplies a title/subtitle, this is covered at that layer — verify it does.",fix:"Give the ChartContainer a title (and optionally enable describe), or set title/description/summary on the chart."}:{status:"fail",message:"No title, description, or summary — the screen reader falls back to a generic label.",fix:"Add title/description/summary on the chart, or wrap it in a ChartContainer (the opt-in layer for title/caption/description chrome)."}}),a.push({id:"understandable.explain-purpose",principle:"understandable",heuristic:"No explanation for purpose or for how to read",critical:!0,...p||f?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:c?{status:"manual",message:"ChartContainer's describe option explains how to read the chart (type, stats, trend). Confirm the domain purpose — why this chart exists — is also conveyed (title/subtitle).",fix:"Give the ChartContainer a title/subtitle stating the purpose; describe() covers the how-to-read half."}:h?{status:"warn",message:"Only a title is set — a label, not an explanation of purpose or how to read the chart.",fix:"Add a summary, or enable ChartContainer's describe option for an auto-generated how-to-read description."}:{status:"fail",message:"Nothing explains the chart's purpose or how to read it.",fix:"Add a summary/description, or wrap in a ChartContainer with a title and the describe option (the opt-in full-accessibility layer)."}});{const e=[t.description,t.summary].filter(Zt).join(". "),r=e?mr(e):null;a.push({id:"understandable.reading-level",principle:"understandable",heuristic:"Reading level inappropriate",critical:!0,...null==r?{status:"not-applicable",message:"No description/summary text to grade."}:r>9?{status:"warn",message:`Description/summary reads at ~grade ${r.toFixed(0)}; Chartability targets grade 9 or lower.`,fix:"Shorten sentences and prefer common words."}:{status:"pass",message:`Description/summary reads at ~grade ${Math.max(0,Math.round(r))} (≤ 9).`}})}if(Rc.has(e)){const e=Zt(t.xLabel),r=Zt(t.yLabel);a.push({id:"understandable.axis-labels",principle:"understandable",heuristic:"Axis labels are unclear or missing",critical:!1,...e&&r?{status:"pass",message:"Both axes are labeled (xLabel, yLabel)."}:{status:"warn",message:`Missing axis label: ${[!e&&"xLabel",!r&&"yLabel"].filter(Boolean).join(", ")}. Ticks alone may not name the variable.`,fix:"Set xLabel and yLabel to name each axis's variable and units."}})}if(Oc.has(e)&&a.push({id:"understandable.information-complexity",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,status:"warn",message:"Dual-axis chart: two y-scales are hard to read accurately and notoriously easy to misinterpret (the crossover point is arbitrary).",fix:"Confirm the second axis is necessary; consider two aligned charts (small multiples) or indexing both series to a common baseline. Label each axis and its series unambiguously."}),$.length>1){const e=$.filter(fr).length;a.push({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,...e===$.length?{status:"pass",message:`All ${$.length} annotation(s) declare hierarchy through emphasis or provenance confidence, so the renderer can resolve reading order and visual priority.`}:0===e?{status:"warn",message:$.length+" annotations are present with no emphasis or provenance confidence; readers may not know which note is primary.",fix:'Mark the main annotation with emphasis="primary", set supporting notes to emphasis="secondary", or provide provenance.confidence so Semiotic can infer order.'}:{status:"warn",message:`${$.length-e} of ${$.length} annotation(s) have no emphasis or provenance confidence; readers may not know which note is primary among the unordered notes.`,fix:"Set emphasis on each annotation (primary/secondary), or provide provenance.confidence on all annotations so Semiotic can infer order."}})}(null!=t.forecast||null!=t.anomaly||null!=t.band||null!=t.regression)&&a.push({id:"understandable.uncertainty",principle:"understandable",heuristic:"Statistical uncertainty isn't clearly communicated",critical:!1,status:"manual",message:"The chart shows a forecast/regression/band/anomaly overlay. Confirm the uncertainty it represents is explained in text, not just drawn.",fix:"State the confidence interval / method in the summary, and label the band so it isn't mistaken for data."}),null!=t.animate&&!1!==t.animate&&a.push({id:"understandable.changes-followable",principle:"understandable",heuristic:"Changes are not easy to follow",critical:!1,status:C,message:`Transitions animate with object constancy and data changes are mirrored to the live region${S}.`,fix:i?"Keep transition durations in the 250ms–2s range so changes are followable but not slow.":void 0}),a.push({id:"robust.conforms-to-standards",principle:"robust",heuristic:"Does not conform to standards",critical:!1,status:"manual",message:"WCAG 2.1 / Section 508 conformance can't be settled from config alone.",fix:"Run an automated checker (axe) on the rendered output and test with real assistive tech."}),a.push({id:"robust.semantically-valid",principle:"robust",heuristic:"Semantically invalid",critical:!1,status:"manual",message:"Whether interactive elements expose correct roles/names is a render-time, screen-reader question.",fix:"Verify with a screen reader that buttons read as buttons, the chart as an image/group, etc."}),a.push({id:"robust.fragile-technology-support",principle:"robust",heuristic:"Fragile technology support",critical:!1,status:C,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${S}.`,fix:i?"Still test across NVDA+Firefox, JAWS+Chrome, and VoiceOver+Safari — AT support varies.":void 0}),a.push({id:"compromising.table",principle:"compromising",heuristic:"No table",critical:!0,...u?{status:"not-applicable",message:"Single-value display — a table isn't meaningful."}:g?{status:"pass",message:"A human-readable data table is provided (accessibleTable)."}:{status:"fail",message:"accessibleTable is disabled — no human-readable table of the underlying data.",fix:"Remove accessibleTable={false} (unless title/summary/annotations already convey all the data)."}}),u||a.push({id:"compromising.table-static",principle:"compromising",heuristic:"Table/data is static",critical:!1,...s?{status:"manual",message:"Rendered in a ChartContainer. If a data-download action is enabled, the data is exportable.",fix:"Enable the ChartContainer data-download action so users can save the underlying data (keep it opt-in)."}:{status:"warn",message:"The data table is read-only — not downloadable, sortable, or filterable.",fix:"Wrap the chart in a ChartContainer and enable its data-download action (opt-in, so deployments can withhold it where export isn't allowed)."}}),a.push({id:"compromising.shareable-state",principle:"compromising",heuristic:"State is not easy to share and reproduce",critical:!1,status:i?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${i?"":S}.`,fix:i?"Expose it to users via the ChartContainer copyConfig action or a shareable URL.":void 0}),a.push({id:"compromising.navigable-structure",principle:"compromising",heuristic:"Information cannot be navigated according to narrative or structure",critical:!1,...l?d?{status:"pass",message:"ChartContainer's navigable option mounts a structured navigation tree, including hierarchy/network branches and their data items."}:{status:"pass",message:"ChartContainer's navigable option mounts a structured tree (chart → axes/series → data points) that screen readers can traverse."}:d?{status:"warn",message:"Hierarchical chart: built-in keyboard navigation is largely flat — it doesn't descend the tree structure.",fix:"Enable ChartContainer's navigable option for a structured navigation tree, or lean on the data table and a summary that conveys the hierarchy."}:{status:C,message:`Keyboard navigation steps through points and switches series/groups${S}.`,fix:i?"For deeper structure (axis → series → datum), enable ChartContainer's navigable option.":void 0}});{const r=Array.isArray(t.data)?t.data:null,o=Array.isArray(t.nodes)?t.nodes:null,n={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};let i;i=Cc.has(e)&&r&&r.length>7?{...n,status:"warn",message:r.length+" slices in a part-to-whole chart. Chartability suggests ≤ 5 categories; many thin slices are hard to perceive and to describe.",fix:'Group small slices into an "Other" category, or switch to a ranked bar chart.'}:o&&o.length>200?{...n,status:"warn",message:o.length+" nodes. A network this size is hard to navigate non-visually node by node.",fix:"Provide a summary of structure (clusters, hubs, components) and consider filtering or aggregating the graph."}:r&&r.length>5e3?{...n,status:"warn",message:r.length+" data points. Canvas renders this fine, but the non-visual table/navigation become unwieldy.",fix:"Aggregate or bin for the accessible representation, or expose summary statistics rather than every row."}:r?{...n,status:"pass",message:r.length+" data points — a reasonable density for non-visual consumption."}:o?{...n,status:"pass",message:o.length+" nodes — a reasonable density for non-visual consumption."}:{...n,status:"manual",message:"Data not provided inline (push mode); verify density at runtime."},a.push(i)}{const e=Array.isArray(t.data)?t.data:null,r=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]);let o=!1;if(e&&!r)for(const t of e.slice(0,50))if(t&&"object"==typeof t){for(const e of Object.values(t))if("number"==typeof e&&Number.isFinite(e)&&Math.abs(e)>=1e5){o=!0;break}if(o)break}o&&a.push({id:"assistive.human-readable-numbers",principle:"assistive",heuristic:"Data in text is not human-readable",critical:!1,status:"warn",message:'Data includes large numbers (≥ 100,000) and no value/tick formatter — screen readers will read every digit (e.g. "six hundred fifty thousand…").',fix:'Pass valueFormat / yFormat (e.g. a compact formatter so 6,500,000 reads as "6.5M"); the formatter flows to ticks, tooltips, and the data table.'})}a.push({id:"assistive.features-described",principle:"assistive",heuristic:"Visually apparent features and relationships are not described",critical:!1,...c?{status:"pass",message:"ChartContainer's describe option auto-generates an L1–L3 description (chart type, statistics, and trend) via describeChart()."}:f?{status:"manual",message:"A summary is present. Confirm it describes trends, extrema, clusters, and outliers — not just what the chart is.",fix:"Cover the L2/L3 content blind readers value most: direction of trend, peak/trough, notable outliers."}:{status:"warn",message:"No text describes the visually apparent trends, extrema, or outliers.",fix:"Enable ChartContainer's describe option (auto-generates via describeChart()), or write a summary covering the key trend and notable points."}}),a.push({id:"assistive.skippable-navigation",principle:"assistive",heuristic:"Navigation and interaction is tedious",critical:!0,...u?{status:"not-applicable",message:"Single value — nothing to skip."}:g?{status:"pass",message:'A "Skip to data table" link lets screen-reader users bypass point-by-point navigation.'}:{status:"warn",message:"accessibleTable is off, removing the skip-to-table affordance.",fix:"Keep accessibleTable enabled so users can skip past dense point navigation."}}),a.push({id:"flexible.user-style-respected",principle:"flexible",heuristic:"User style change not respected",critical:!0,status:C,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${S}.`,fix:i?"Avoid hardcoding colors via frameProps style fns that bypass theme variables.":void 0}),a.push({id:"flexible.reduced-motion",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...Ec.has(e)||Mc.has(e)?v?{status:"pass",message:e+" animates continuously and declares an in-chart pause/stop control."}:{status:"warn",message:e+" animates continuously. prefers-reduced-motion is auto-honored, but there's no in-chart pause/stop control for users who don't set that preference.",fix:"Offer a pause/stop control for looping/streaming motion (Chartability requires it for animation > 2s)."}:{status:C,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${S}.`}}),n&&(a.push({id:"flexible.sim-pause-control",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...v?{status:"pass",message:"Physics simulation exposes a pause/stop control for users who need to stop motion."}:{status:"warn",message:"Physics simulation has no declared pause/stop control.",fix:"Provide a visible pause control and set physics.pauseControl=true (or pauseControl=true) so the contract is auditable."}}),a.push({id:"flexible.settled-projection",principle:"flexible",heuristic:"User style change not respected",critical:!1,...A?{status:"pass",message:"A settled-projection table is declared, so non-visual readers get aggregate chart semantics instead of trajectories."}:{status:"warn",message:"Physics chart does not declare a settled projection for its accessible table.",fix:"Provide aggregate rows from the settled projection and set physics.settledProjection=true."}}),a.push({id:"flexible.reduced-motion-settle",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...x?{status:"pass",message:"Reduced-motion mode settles the simulation to a static chart state instead of freezing bodies mid-flight."}:{status:"warn",message:"Physics chart does not declare reduced-motion synchronous settle behavior.",fix:"In reduced motion, run the world to its settled projection and paint once; set physics.reducedMotionSettle=true."}}));{const r=!0===t.responsiveWidth||!0===t.responsiveHeight,o=Fc.has(e)&&!0===t.zoomable;a.push({id:"flexible.zoom-reflow",principle:"flexible",heuristic:"Zoom and reflow are not supported",critical:!1,...r?{status:"pass",message:`Chart reflows to its container (${[!0===t.responsiveWidth&&"responsiveWidth",!0===t.responsiveHeight&&"responsiveHeight"].filter(Boolean).join(", ")}), so page zoom doesn't clip it.`}:o?{status:"pass",message:"Geo chart is zoomable/pannable."}:{status:"manual",message:"Fixed width/height — verify the chart survives browser zoom and reflow without clipping or loss of function.",fix:"Use responsiveWidth/responsiveHeight so the chart reflows to its container."}})}if(o){const e=o.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));e&&a.push({id:"perceivable.recipe-color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,status:"warn",message:o.name+" declares a color encoding without a redundant cue.",fix:"Add shape, label, position, texture, or a textual category summary to the recipe encoding."}),"required"!==o.accessibility.description||p||a.push({id:"understandable.recipe-description",principle:"understandable",heuristic:"Features are not described",critical:!1,status:"fail",message:o.name+" requires a recipe-aware description, but none is attached.",fix:"Call describeChart with recipeId/recipe metadata and attach the returned text as description."}),o.accessibility.fallbackTable&&!1===t.accessibleTable&&a.push({id:"compromising.recipe-fallback",principle:"compromising",heuristic:"No data table is provided",critical:!0,status:"fail",message:o.name+" requires a fallback table, but accessibleTable is disabled.",fix:"Enable accessibleTable and preserve recipe-declared table fields on scene nodes."})}const k=a.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),R={criticalsPassed:k.filter(e=>"pass"===e.status).length,criticalsEvaluated:k.length,fails:a.filter(e=>"fail"===e.status).length,warnings:a.filter(e=>"warn"===e.status).length,manual:a.filter(e=>"manual"===e.status).length,passes:a.filter(e=>"pass"===e.status).length};return{component:e,ok:!k.some(e=>"fail"===e.status),summary:R,findings:a,reference:ml}}function Cr(e,{onlyCritical:t=!1}={}){const r=[];for(const a of e.findings)"fail"!==a.status&&"warn"!==a.status||t&&!a.critical||r.push(a.message);return r}function Sr(e){const t=[],r=e.summary,a=e.ok?`${r.criticalsPassed}/${r.criticalsEvaluated} critical heuristics pass`:`${r.fails} blocking failure(s) — ${r.criticalsPassed}/${r.criticalsEvaluated} critical heuristics pass`;t.push(`${e.ok?"✓":"✗"} ${e.component}: accessibility audit (Chartability POUR-CAF)`),t.push(` ${a} · ${r.warnings} warning(s) · ${r.manual} to verify manually`);for(const r of yl){const a=e.findings.filter(e=>e.principle===r&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+r.toUpperCase());for(const e of a)t.push(` ${gl[e.status]} ${e.id}${e.critical?" [critical]":""}: ${e.message}`),!e.fix||"fail"!==e.status&&"warn"!==e.status&&"manual"!==e.status||t.push(" → "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function kr(e){return e.semanticDiagnostics?.length?e.semanticDiagnostics:"degenerate"===e.semanticStatus?[bl]:[]}function Rr(e){const{contract:t,transfer:r,binding:a}=e;if(void 0===t&&void 0===r&&void 0===a)return[];const o=[],n=Array.isArray(a?.mismatchPaths)?a.mismatchPaths.filter(e=>"string"==typeof e):[];return r&&"preserved"!==r.status&&"excluded"!==r.status?o.push({id:"artifact.transfer-invalid",status:"fail",message:`The attached artifact transfer is ${r.status}; its contract cannot be relied on for publication.`}):r&&void 0!==t||o.push({id:"artifact.transfer-unknown",status:"unknown",message:"The attached artifact lacks a contract or a transfer report."}),"mismatch"===a?.status||n.length>0?o.push({id:"artifact.identity-mismatch",status:"fail",message:"The attached artifact does not identify this chart input"+(n.length?": "+n.join(", "):".")}):"match"===a?.status&&Array.isArray(a.mismatchPaths)&&Array.isArray(a.unknownPaths)&&0>=a.mismatchPaths.length&&0>=a.unknownPaths.length||o.push({id:"artifact.identity-unknown",status:"unknown",message:"The attached artifact identity has not been fully verified."}),o}function Pr(e){return e.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Ir(e,t,r){return{id:`${t}.${e.code.toLowerCase()}.${r+1}`,stage:t,severity:e.severity,code:e.code,message:e.message,...e.fix?{fix:e.fix}:{},source:"data"===t?"auditData":"diagnoseConfig",...e.field?{field:e.field}:{},...e.role?{role:e.role}:{},...e.rows?{rows:e.rows}:{},...void 0!==e.count?{count:e.count}:{}}}function Er(e,t){return{id:e.id||"accessibility."+(t+1),stage:"accessibility",severity:"fail"===e.status?"error":"warn"===e.status?"warning":"manual",code:e.id,message:e.message,...e.fix?{fix:e.fix}:{},source:"auditAccessibility",critical:e.critical,principle:e.principle,heuristic:e.heuristic}}function Nr(e){return e.map((e,t)=>({finding:e,index:t})).sort((e,t)=>{const r=vl[e.finding.severity]-vl[t.finding.severity];if(0!==r)return r;const a=!0===e.finding.critical;if(a!==(!0===t.finding.critical))return a?-1:1;const o=wl[e.finding.stage]-wl[t.finding.stage];return 0!==o?o:e.index-t.index}).map(({finding:e},t)=>({...e,rank:t+1}))}function Tr(e,t){const r=[];e.component!==t&&r.push({id:"render.component-mismatch",stage:"render",severity:"error",code:"RENDER_COMPONENT_MISMATCH",message:"The render evidence names a different chart component.",source:"renderChartWithEvidence"});for(const t of Rr({contract:e.artifactContract,transfer:e.artifactTransfer,binding:e.artifactBinding}))r.push({id:"render."+t.id,stage:"render",severity:"fail"===t.status?"error":"manual",code:t.id.toUpperCase().replace(/[.-]/g,"_"),message:t.message,source:"artifactAttachmentIssues"});e.empty&&r.push({id:"render.empty-scene",stage:"render",severity:"error",code:"EMPTY_SCENE",message:"The renderer produced no data marks.",fix:"Check the data shape, accessors, scales, and filters against the rendered evidence.",source:"renderChartWithEvidence"});const a=/* @__PURE__ */new Set;for(const t of kr(e))a.add(t.code),r.push({id:"render."+t.code.toLowerCase(),stage:"render",severity:t.severity,code:t.code,message:t.message,...t.fix?{fix:t.fix}:{},source:"capability.semanticViability"});for(const t of e.warnings)a.has(t)||r.push({id:"render."+t.toLowerCase(),stage:"render",severity:"warning",code:t,message:`The renderer reported ${Pr(t).toLowerCase()}.`,fix:"Inspect the render evidence and resolve the warning before relying on the chart.",source:"renderChartWithEvidence"});return r}function Mr(e,t){const r=e.filter(e=>"manual"!==e.severity),a=r.slice(0,t).map(e=>({id:"chart-evaluation-"+e.id,level:"error"===e.severity?"error":"warning",title:`${e.stage}: ${Pr(e.code)}`,message:e.fix?`${e.message} ${e.fix}`:e.message,source:"Semiotic chart evaluation",dismissible:!0}));return r.length>t&&a.push({id:"chart-evaluation-overflow",level:"warning",title:"Additional chart evaluation findings",message:r.length-t+" additional finding(s) are available in the ranked evaluation result.",source:"Semiotic chart evaluation",dismissible:!0}),a}function Or(e){const t=[`${e.component}: ${e.ok?"PASS":"ISSUES FOUND"}`,`${e.summary.errors} error(s) · ${e.summary.warnings} warning(s) · ${e.summary.manual} manual check(s)`];for(const r of e.findings)t.push(`${r.rank}. [${r.stage}/${r.code}] ${r.message}`),r.fix&&t.push(" Fix: "+r.fix);return t.join("\n")}function Fr(e,t={},r,a={}){const o=void 0===r?t:{...t,data:r},n=ve(e,o),i=$t(e,o,r,a.dataAudit),s=Xt(e,o).diagnoses.filter(e=>"data"!==e.domain&&"VALIDATION"!==e.code),c=$r(e,o,{inChartContainer:a.inChartContainer,describe:a.describe,navigable:a.navigable}),l=[];for(const[e,t]of n.errors.entries())l.push({id:"validation."+(e+1),stage:"deception",severity:"error",code:"VALIDATION",message:t,fix:"Correct the component name, required props, prop types, and data shape.",source:"validateProps"});let u;i.diagnoses.forEach((e,t)=>{l.push(Ir(e,"data",t))}),s.forEach((e,t)=>{l.push(Ir(e,"deception",t))}),c.findings.filter(e=>"pass"!==e.status&&"not-applicable"!==e.status).forEach((e,t)=>{l.push(Er(e,t))});const d=l.some(e=>"error"===e.severity&&"accessibility"!==e.stage);if(a.render&&n.valid&&!d)try{u=a.render(e,o).evidence,l.push(...Tr(u,e))}catch{l.push({id:"render.failed",stage:"render",severity:"error",code:"RENDER_FAILED",message:"The injected renderer failed before producing render evidence.",fix:"Check the chart configuration and renderer-specific requirements.",source:"renderChartWithEvidence"})}const h=Nr(l),p=h.filter(e=>"error"===e.severity).length,f=h.filter(e=>"warning"===e.severity).length,m=h.filter(e=>"manual"===e.severity).length,g=Mr(h,Math.max(0,Math.floor(a.notificationMax??8)));return{component:e,validation:n,data:i,deception:s,accessibility:c,...u?{evidence:u}:{},ok:0===p,summary:{errors:p,warnings:f,manual:m,findings:h.length,notifications:g.length},findings:h,notifications:g}}function jr(e,t=8){return Mr(e,Math.max(0,Math.floor(t)))}function zr(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Br(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}function Lr(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}function _r(e,t){const{when:r}=e,a=t.width,o=t.height,n=Lr(t),i=Br(t);return!("number"==typeof r.minWidth&&r.minWidth>a||"number"==typeof r.maxWidth&&a>r.maxWidth||"number"==typeof r.minHeight&&("number"!=typeof o||r.minHeight>o)||"number"==typeof r.maxHeight&&("number"!=typeof o||o>r.maxHeight)||"number"==typeof r.minAspectRatio&&("number"!=typeof n||r.minAspectRatio>n)||"number"==typeof r.maxAspectRatio&&("number"!=typeof n||n>r.maxAspectRatio)||r.orientation&&i!==r.orientation)}function Dr(e,t){const r={...e,...t};for(const a of["margin","frameProps","mobileSemantics","style"])zr(e[a])&&zr(t[a])&&(r[a]={...e[a],...t[a]});return"string"==typeof e.className&&"string"==typeof t.className&&(r.className=`${e.className} ${t.className}`),r}function Ur(e,t,r=e.responsiveRules){if(!Array.isArray(r)||0===r.length)return{props:e,matches:[]};const a=r.map((e,t)=>({rule:e,index:t})).filter(e=>_r(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:a.reduce((e,t)=>Dr(e,t.rule.transform),e),matches:a}}function Vr(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Gr(e){return"string"==typeof e&&e.trim().length>0}function qr(e){const t=Vr(e.capability)?e.capability:null,r=Vr(e.recipe)?e.recipe:null,a=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,r?.mobile];for(const e of a)if(Vr(e))return e;return null}function Hr(e,t){return e.includes("CustomChart")||e.includes("Custom")||null!=t.recipeId||null!=t.mobileSemantics}function Wr(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 Yr(e){return Wr(e.size)||Wr(Vr(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function Kr(e){const t=qr(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}function Jr(e){const t=qr(e),r=Vr(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===r?.tapToSelect||!0===r?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||Gr(t?.interaction?.hoverFallback)}function Xr(e,t){const r=qr(e),a=Vr(e.mobileInteraction)?e.mobileInteraction:null,o=a?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(r?.interaction?.alternatives)&&r.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))}function Zr(e){const t=Vr(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!Jr(e)}function Qr(e){const t=[e.data,e.points,e.lines,e.nodes,e.edges,e.areas,Vr(e.frameProps)?e.frameProps.data:void 0];let r=0;for(const e of t)Array.isArray(e)&&(r+=e.length);return r}function ea(e){const t=[e.tickValues,e.xTickValues,e.yTickValues,e.rTickValues,e.oTickValues];let r=0;for(const e of t)Array.isArray(e)&&(r+=e.length);return r>0?r:null}function ta(e,t){const r=$l[e];if(!r)return null;let a=r.includes("hoverRadius")?30:null;for(const e of r){const r=t[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(a=null==a?r:Math.max(a,r))}return null==a?null:2*a}function ra(e,t){e.push({...t,status:"pass"})}function aa(e,t){e.push({...t,status:"warn"})}function oa(e,t){e.push({...t,status:"manual"})}function na(e,t={},r={}){const a=r.viewportWidth??390,o=r.targetSize??44,n=Yr(t),i=Ur(t,{width:a,height:n?.[1]}),s=[],c=Yr(t=i.props),l=qr(t),u=Hr(e,t),d=Kr(t),h=!0===r.inChartContainer,p=Gr(t.title)||Gr(t.summary)||Gr(t.description)||!0===l?.summary||Gr(l?.summary);if(i.matches.length>0&&ra(s,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${i.matches.length} responsive rule(s) applied for the ${a}px mobile audit.`}),c){const[t,r]=c;t>a&&!d?aa(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${a}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."}):ra(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof l?.minViewportWidth&&l.minViewportWidth>a&&aa(s,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${l.minViewportWidth}px minimum, wider than the audited ${a}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,r);430>=a&&o>2.4&&"BigNumber"!==e&&aa(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>r&&"BigNumber"!==e&&aa(s,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${r}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 oa(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=Qr(t);f>0&&(f>("number"==typeof l?.maxMarks?l.maxMarks:xl.has(e)?1.25*a:Pc.has(e)?Math.max(8,Math.floor(a/34)):a)?aa(s,{id:"density.mark-budget",category:"density",impact:xl.has(e)?"medium":"high",message:`${f} data item(s) exceed the rough mobile density budget for ${e} at ${a}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):ra(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 m=ea(t),g=!1!==t.showAxes&&!1!==t.axis;if(g&&null!=m){const e=Math.max(3,Math.floor(a/58));m>e&&aa(s,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${m} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${a}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else g&&(xl.has(e)||Pc.has(e))&&oa(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."});Zr(t)?aa(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."}):ra(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."});const y=ta(e,t),b=Vr(t.mobileInteraction)?t.mobileInteraction:null,v=y??("number"==typeof b?.targetSize?b.targetSize:!0===t.mobileInteraction?44:"number"==typeof l?.minimumHitTarget?l.minimumHitTarget:"number"==typeof l?.interaction?.targetSize?l.interaction.targetSize:null);null!=v&&(24>v?aa(s,{id:"interaction.target-size-minimum",category:"interaction",impact:"high",message:`Small interactive marks expose an estimated ${v}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>v?aa(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}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."}):ra(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}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&&!Xr(t,w)&&aa(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"===l?.labels?.strategy||"inline"===l?.labels?.strategy||"external"===l?.labels?.strategy||a>430||aa(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 A=Array.isArray(t.annotations)?t.annotations.filter(e=>Vr(e)):[];if(A.length>("number"==typeof l?.maxAnnotations?l.maxAnnotations:3)&&430>=a&&aa(s,{id:"annotation.mobile-density",category:"annotation",impact:"medium",message:A.length+" annotation(s) compete for phone plot space.",fix:"Assign annotation priority, collapse secondary notes into a callout list, or provide shorter mobileText."}),A.length>0){const e=A.filter(e=>!Gr(e.mobileText)&&!Gr(e.shortText)&&!Gr(e.label));e.length>0&&oa(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."})}d||"BigNumber"===e||oa(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."}),u&&(l?(ra(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===l.custom?.dataBearingSceneNodes?aa(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!==l.custom?.dataBearingSceneNodes&&oa(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."})):oa(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."})),p||h||aa(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 x=s.filter(e=>"warn"===e.status),$={highRisk:x.filter(e=>"high"===e.impact).length,warnings:x.length,manual:s.filter(e=>"manual"===e.status).length,passes:s.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:a,ok:0===$.highRisk,summary:$,findings:s,reference:Al}}function ia(e){const t=[],r=e.summary,a=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${r.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${a} - ${r.warnings} warning(s) - ${r.manual} manual check(s)`);for(const r of Sl){const a=e.findings.filter(e=>e.category===r&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+r.toUpperCase());for(const e of a)t.push(` ${Cl[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 sa(){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."]}function ca(e,t){if("function"==typeof e)return t=>+e(t);const r=e||t;return e=>+e[r]}function la(e,t){if("function"==typeof e)return e;const r=e||t;return e=>e[r]}function ua(){const e=globalThis;return e[kl]??(e[kl]={intents:/* @__PURE__ */new Map}),e[kl]}function da(e,t){return Pl.has(e)||Il.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 ha(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const r=e[t];if("string"==typeof r&&r)return r}}function pa(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function fa(e,t={}){const r=!0===t.showRetractedAnnotations,a=!0===t.showSupersededAnnotations,o=/* @__PURE__ */new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!r)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!a)})}function ma(e){return"string"==typeof e?e:e.id??e.name}function ga(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function ya(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 ba(e,t,r){return r??hr(t.recipe)??hr(t.recipeId)??lr(e)}function va(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 o=r.find(e=>e&&"object"==typeof e);if(!o)return;const n=Object.entries(o).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?n.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in o):n.find(([,e])=>"string"==typeof e)?.[0]}function wa(e,t){return e.dataRoles.find(e=>e.role===t)}function Aa(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function xa(e,t,r,a,o,n={}){const i={...n};if(t)for(const[e,r]of Object.entries(t))i[e]=r;for(const e of r.dataRoles){const r=va(e,a,o),n=t&&r?t[r]:r;void 0!==n&&(i[e.role]=n)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const r=i[t];return null==r?`{${t}}`:r+""})}function $a(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})}}}function Ca(e,t,r,a){const o=Aa(e,["nominal","ordinal"]),n=Aa(e,["quantitative"]),i=o?va(o,r,t):void 0,s=n?va(n,r,t):void 0,c=o?.role??i??"category",l=n?.role??s??"value",u=e.encodings??[],d=u.length?u.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${c} and ${l} are mapped through the recipe's declared visual semantics`,{number:h,percent:p}=$a(a),f=/* @__PURE__ */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],v=g>0?((y?.[1]??0)+(b?.[1]??0))/g:0,w=e.intents.map(e=>({id:ma(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,A=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${c} and ${l}. ${x=d,x?x.charAt(0).toUpperCase()+x.slice(1):x}.`,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>v?`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(v)}.`,l4:`The chart is intended for ${w??"explanation"}${A?` with a ${A} audience`:""}: ${e.designContract.whyCustom}`};var x}function Sa(e,t,r={}){const a=ya(t),o=ga(t),n=r.locale??"en",i="function"==typeof e.description?e.description({data:a,config:o,locale:n}):void 0,s=i?.levels??Ca(e,a,o,n),c=r.levels??["l1","l2","l3","l4"],l={};for(const e of c)s[e]&&(l[e]=s[e]);const u=["l1","l2","l3","l4"].map(e=>l[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:l,...d?.length?{caveats:d}:{}}}function ka(e){const t=Math.max(2,Math.round(e.bins)),r=Math.max(1,Math.round(e.pegRows??t-1)),a=Math.max(1,Math.round(e.count??Math.max(64,4*t))),o=(n=Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,Math.max(0,Math.min(1,n)));var n;const i=Ve(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:a},(e,t)=>{let a=0;for(let e=0;r>e;e+=1)i()<o&&(a+=1);const n=r/2;return{id:`${s}-${t}`,value:a,mechanical:!0,pegRows:r,branchProbability:o,pathRights:a,side:n>a?"left":a>n?"right":"center"}})}function Ra(e){const{windowSize:t,watermark:r,watermarkAtArrivalAccessor:a}=e;if(!Number.isFinite(t)||0>=t)throw new RangeError("EventDrop windows.size must be a finite positive number");const{rows:o}=He(e.data,"event"),n=o.flatMap((t,r)=>{const a=_e(Le(t,r,e.timeAccessor));return null==a?[]:[{datum:t,index:r,eventTime:a,arrivalTime:_e(Le(t,r,e.arrivalAccessor))??a,watermarkAtArrival:0,late:!1}]}),i="function"==typeof r?null:_e(r?.value),s="function"==typeof r?t:_e(r?.delay)??t;let c=-1/0,l=-1/0;for(const e of n.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){c=Math.max(c,e.eventTime);const o="function"==typeof r?_e(r(c)):c-s;l=i??Math.max(l,o??c-t);const n=a?_e(Le(e.datum,e.index,a)):null;e.watermarkAtArrival=n??l,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:n,watermarkValue:n.length?l:i??-s}}function Pa(e,t){const r="mechanical"===(t.simulationMode??t.mode)&&("GaltonBoardChart"===e||"UnitPileChart"===e);if(!Array.isArray(t.data)&&!r)return null;let a=Array.isArray(t.data)?t.data:[];const o=Math.max(2,Math.round(_e(t.bins)??21)),n=Math.max(1,Math.round(_e(t.pegRows)??o-1));if(r&&(a="GaltonBoardChart"===e?ka({bins:o,count:t.mechanicalCount,pegRows:n,branchProbability:t.branchProbability,seed:t.seed}):Ge({count:t.mechanicalCount,categories:t.mechanicalCategories,unitValue:t.unitValue,seed:t.seed})),a=He(a,"UnitPileChart"===e?"pile":"GaltonBoardChart"===e?"galton":"EventDropChart"===e?"event":"collision-swarm").rows,"UnitPileChart"===e){const e=/* @__PURE__ */new Map,o=t.valueAccessor??(r?"value":void 0);return a.forEach((r,a)=>{const n=(Le(r,a,t.categoryAccessor??"category")??"unknown")+"",i=o?_e(Le(r,a,o)):1;e.set(n,(e.get(n)??0)+Math.max(0,i??0))}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("GaltonBoardChart"===e){const e=a.map((e,r)=>_e(Le(e,r,t.valueAccessor??"value"))).filter(e=>null!=e),i=r?[0,n]:Ue(t.valueExtent),s=i?.[0]??(e.length?Math.min(...e):0),c=i?.[1]??(e.length?Math.max(...e):1),l=s===c?1:c-s,u=Array.from({length:o},(e,t)=>({label:t+1+"",value:0}));for(const t of e)u[Math.max(0,Math.min(o-1,Math.floor((t-s)/l*o)))].value+=1;return{generated:r,rows:u}}if("CollisionSwarmChart"===e){const e=/* @__PURE__ */new Map;return a.forEach((r,a)=>{if(null==_e(Le(r,a,t.xAccessor??"x")))return;const o=t.groupAccessor?(Le(r,a,t.groupAccessor)??"All")+"":"All";e.set(o,(e.get(o)??0)+1)}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("EventDropChart"===e){const e=_e(t.windows?.size??10);if(null==e||0>=e)return null;const{events:o}=Ra({data:a,timeAccessor:t.timeAccessor??"time",arrivalAccessor:t.arrivalAccessor??"arrivalTime",windowSize:e,watermark:t.watermark,watermarkAtArrivalAccessor:t.watermarkAtArrivalAccessor}),n=o.map(e=>e.eventTime),i=n.length?Math.min(...n):0,s=n.length?Math.max(...n):i+e,c=Math.min(_e(t.timeExtent?.[0])??i,i),l=Math.max(_e(t.timeExtent?.[1])??s,s),u=Math.floor(c/e)*e,d=Math.max(1,Math.ceil((l-u+e)/e)),h=Array.from({length:d},(t,r)=>({label:`${u+r*e}-${u+(r+1)*e}`,value:0,secondary:0,secondaryLabel:"late"}));for(const t of o){const r=h[Math.max(0,Math.min(d-1,Math.floor((t.eventTime-u)/e)))];t.late?r.secondary+=1:r.value+=1}return{generated:r,rows:h}}return null}function Ia(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}function Ea(e,t){const r=e.physics&&"object"==typeof e.physics?e.physics:null,a=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,o=[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(o)?o.map((e,r)=>{if(!e||"object"!=typeof e)return null;const a=e,o=Ia(a.count??a.value??a.total??a.bodies??a.events);if(null==o)return null;const n=a.label??a.id??a.name??"container "+(r+1),i=Ia(a.secondary??a.secondaryCount),s=Ia(a.observed??a.observedCount);return{label:pa(n,t),count:o,...null!=i?{secondary:i}:{},..."string"==typeof a.secondaryLabel&&a.secondaryLabel?{secondaryLabel:a.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}function Na(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}function Ta(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"UnitPileChart"===e?"unit":"body"}function Ma(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.`}function Oa(e,t){if(0>=t)return"0%";const r=e/t*100;return(10>r?Math.round(10*r)/10:Math.round(r))+"%"}function Fa(e,t,r,a,o,n,i=null){const s=Na(e),c=i&&"EventDropChart"===e?"accepted event":Ta(e),l=i?i.generated?"The generated sample projection":"The source projection":"The settled projection";if(o.has("l1")&&(a.l1=Ma(e,t)),!o.has("l2")&&!o.has("l3"))return;if(!r||0===r.length)return void(o.has("l2")&&(a.l2=i?"No valid source records are available.":"No settled projection is loaded yet."));const u=r.reduce((e,t)=>e+t.count,0),d=r.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),h=d[0]??r.slice().sort((e,t)=>t.count-e.count)[0];if(!h)return;const p=r.reduce((e,t)=>e+(t.secondary??0),0),f=r.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(o.has("l2"))if(i&&"EventDropChart"===e)a.l2=`${l} classifies ${n(u+p)} ${ja(u+p,"event")} across ${r.length} ${ja(r.length,s)}: ${n(u)} accepted and ${n(p)} late.`;else if(0===d.length)a.l2=`${l} contains ${n(u)} ${ja(u,c)} across ${r.length} ${ja(r.length,s)}; no ${ja(2,s)} are non-empty yet.`;else{const e=p>0?` ${n(p)} ${ja(p,c)} ${1===p?"is":"are"} marked ${f}.`:"";a.l2=`${l} contains ${n(u)} ${ja(u,c)} across ${r.length} ${ja(r.length,s)}; ${d.length} ${ja(d.length,s)} ${1===d.length?"is":"are"} non-empty. The largest ${s} is ${h.label} with ${n(h.count)} ${ja(h.count,c)}.${e}`}if(o.has("l3")&&u>0&&d.length>0){const e=d.find(e=>e!==h),t=Oa(h.count,u);a.l3=e?`${l} is most concentrated in ${h.label}, which holds ${n(h.count)} ${ja(h.count,c)} (${t}); ${e.label} follows with ${n(e.count)} ${ja(e.count,c)}.`:`${l} is concentrated in ${h.label}, which holds all ${n(h.count)} ${ja(h.count,c)}.`}}function ja(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function za(e){return Nl[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function Ba(e){const t=/* @__PURE__ */new Set,r=e=>{const a=Fl[e];if(a)return a;if(t.has(e))return;const o=ua().intents.get(e);if(!o?.composes?.length)return;t.add(e);const n=[...o.composes].sort((e,t)=>{const r=e=>{const t=zl.indexOf(e);return 0>t?zl.length:t};return(o.weights?.[t]??1)-(o.weights?.[e]??1)||r(e)-r(t)});for(const a of n){const o=r(a);if(o)return t.delete(e),o}t.delete(e)};return r(e)}function La(e){let t,r=0;for(const[a,o]of Object.entries(e))if("number"==typeof o&&o>0)if(o>r)t=a,r=o;else if(o===r&&void 0!==t){const e=zl.indexOf(a),r=zl.indexOf(t);-1===e||-1!==r&&e>=r||(t=a)}return t}function _a(e){return"BumpChart"===e?"ranking":Il.has(e)||"StackedAreaChart"===e?"apportioning":Ol.has(e)?"relating":Pl.has(e)?"comparing":El.has(e)?"characterizing":Rl.has(e)?"tracking":Tl.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}function Da(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}}function Ua(e,t){const r=Da(t);if(r?.act)return r.act;if(r?.intentScores){const e=La(r.intentScores);if(e&&Fl[e]&&(r.intentScores[e]??0)>=3)return Fl[e]}return r?.family?jl[r.family]:_a(e)}function Va(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||!Ll.has(t.type))return!1;const r=t.provenance;return!(!r||"object"!=typeof r)&&(_l.has(r.authorKind)||Dl.has(r.source)||Ul.has(r.basis))})}function Ga(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+""}function qa(e,t,r,a){let o=0,n=0,i=1/0,s=-1/0,c=null,l=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===o&&(f=e,h=r),m=e,p=r,i>e&&(i=e,c=r,u=o),e>s&&(s=e,l=r,d=o),o++,n+=e)}return 0===o?null:{count:o,min:i,max:s,mean:n/o,minLabel:pa(null!=c?r(c):null,a),maxLabel:pa(null!=l?r(l):null,a),first:f,last:m,firstLabel:pa(null!=h?r(h):null,a),lastLabel:pa(null!=p?r(p):null,a),minIndex:u,maxIndex:d}}function Ha(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]??""}function Wa(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 ":""}function Ya(e){const t=Vl["string"==typeof e.type?e.type:"annotation"]||"an annotation",r=Wa(e),a=r?r+t.replace(/^an? /,""):t,o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return o?`${a} labeled "${o}"`:a}function Ka(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const r=fa(t.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return;const a=r.map(Ya),o=a.slice(0,5),n=a.length-o.length,i=Ha(o)+(n>0?`, and ${n} more`:""),s=r.length;return`The author has marked ${1===s?"one feature":s+" features"} on this chart: ${i}.`}function Ja(e,t,r={}){const a=void 0!==r.levels,o=new Set(r.levels??["l1","l2","l3"]);a||!r.capability&&!Va(t)||o.add("l4");const n=ba(e,t,r.recipe);if(n){const e=["l1","l2","l3","l4"].filter(e=>o.has(e));a||e.includes("l4")||e.push("l4");const i=Sa(n,t,{levels:e,locale:r.locale,audience:r.audience,includeCaveats:r.includeCaveats}),s=Ka(t);return{...i,text:s?`${s} ${i.text}`.trim():i.text,...s?{annotations:s}:{}}}const i=Ga(r.locale??"en"),s=za(e),c=Array.isArray(t.data)?t.data:null,l=ha(t),u=Ml.has(e)?Ea(t,i):null,d=Ml.has(e)&&null===u?Pa(e,t):null,{measure:h,measureFallback:p,dimension:f,dimensionFallback:m}=da(e,t),g="string"==typeof h&&h?h:p,y="string"==typeof f&&f?f:m,b={};if(Ml.has(e)&&Fa(e,s,u??(d?Ea({projectionRows:d.rows},i):null),b,o,i,d),o.has("l1")&&!Ml.has(e))if("BumpChart"===e)b.l1=`A ${s} ranking ${l??"series"} by ${g} across ${y}.`;else if(Rl.has(e)||Pl.has(e))b.l1=`A ${s} of ${g} by ${y}`+(l?`, split by ${l}.`:".");else if(Il.has(e))b.l1=`A ${s} showing ${g} across ${y} categories.`;else if(El.has(e))b.l1=`A ${s} of the distribution of ${g}`+(l?` by ${l}.`:".");else if(Tl.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,r=Array.isArray(t.edges)?t.edges.length:void 0,a=[null!=e?`${e} ${no(e,"node")}`:null,null!=r?`${r} ${no(r,"edge")}`:null].filter(Boolean);b.l1=`A ${s}${a.length?" with "+a.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:g;b.l1=`A single value${e?" for "+e:""}.`}else b.l1=`A ${s}.`;const v=Rl.has(e)||"BumpChart"===e||Pl.has(e)||Il.has(e)||El.has(e);let w=null;if((o.has("l2")||o.has("l3")||o.has("l4"))&&v&&c&&c.length>0&&(w=qa(c,ca(h,p),la(f,m),i)),o.has("l2")&&v&&(c&&0!==c.length?w&&(b.l2=Il.has(e)?`${w.count} segments totaling ${i(Xa(w))}. Largest is ${w.maxLabel} at ${i(w.max)}; smallest is ${w.minLabel} at ${i(w.min)}.`:`${g} ranges from ${i(w.min)} (${w.minLabel}) to ${i(w.max)} (${w.maxLabel}), with a mean of ${i(w.mean)} across ${w.count} points.`):b.l2="No data is loaded yet."),o.has("l3")&&w&&!l&&Rl.has(e)?b.l3=Za(w,g,i):o.has("l3")&&w&&!l&&Pl.has(e)&&(b.l3=`The highest ${y} is ${w.maxLabel} and the lowest is ${w.minLabel}.`),o.has("l4")){const a=Va(t)?"alerting":Ua(e,r.capability);a&&(b.l4=Qa(a,e,t,l?null:w,g,y,i,r.audience))}const A=["l1","l2","l3","l4"].filter(e=>o.has(e)&&b[e]).map(e=>b[e]).join(" "),x=Ka(t);return{text:x?`${x} ${A}`.trim():A,levels:b,...x?{annotations:x}:{}}}function Xa(e){return e.mean*e.count}function Za(e,t,r){const{first:a,last:o,min:n,max:i,maxLabel:s,minLabel:c,firstLabel:l,lastLabel:u,minIndex:d,maxIndex:h,count:p}=e,f=i-n,m=o-a;if(0===f)return`${oo(t)} is constant at ${r(a)} across the series.`;if(.04>f/(Math.abs(e.mean)||1))return`${oo(t)} ends roughly where it started (${r(a)} at ${l} to ${r(o)} at ${u}), ranging between ${r(n)} and ${r(i)}.`;const g=h>0&&p-1>h,y=d>0&&p-1>d,b=(i-Math.max(a,o))/f,v=(Math.min(a,o)-n)/f;return g&&b>.15?`Overall ${t} climbs to a peak of ${r(i)} (${s}), then falls to ${r(o)} (${u}).`:y&&v>.15?`Overall ${t} drops to a low of ${r(n)} (${c}), then recovers to ${r(o)} (${u}).`:.05>Math.abs(m)/f?`${oo(t)} ends roughly where it started (${r(a)} at ${l} to ${r(o)} at ${u}), ranging between ${r(n)} and ${r(i)}.`:m>0?h===p-1?`Overall ${t} rises from ${r(a)} (${l}) to a peak of ${r(o)} (${u}).`:`Overall ${t} rises from ${r(a)} (${l}) to ${r(o)} (${u}), after peaking at ${r(i)} (${s}).`:d===p-1?`Overall ${t} falls from ${r(a)} (${l}) to a low of ${r(o)} (${u}).`:`Overall ${t} falls from ${r(a)} (${l}) to ${r(o)} (${u}), after dipping to ${r(n)} (${c}).`}function Qa(e,t,r,a,o,n,i,s){const c=Bl[e],l=/^[aeiou]/i.test(c)?"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:o} as the headline number`;break;case"tracing":u=`This is ${l} ${c} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${l} ${c} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${l} ${c} chart`,d=`read it for whether ${n} and ${o} move together`;break;default:u=`This is ${l} ${c} chart`,d=eo(e,a,o,n,i,t)}return`${u}; ${d}.${ao(t,s)}`}function eo(e,t,r,a,o,n){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 to(t,o,n);case"tracking":return`read it for the trajectory of ${r}, which ${ro(t)} from ${o(t.first)} (${t.firstLabel}) to ${o(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${r} across ${a}; ${t.maxLabel} leads at ${o(t.max)}`;case"ranking":return`read it top to bottom by ${r}; ${t.maxLabel} ranks highest at ${o(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 ${o(e)} total; ${t.maxLabel} is the largest at ${o(t.max)}${null!=r?` (${r}%)`:""}`}case"characterizing":return`read it for the spread of ${r}, from ${o(t.min)} to ${o(t.max)}`;default:return"read the highlighted features"}}function to(e,t,r){if(Pl.has(r)||Il.has(r))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:a,last:o,min:n,max:i,minLabel:s,maxLabel:c,lastLabel:l,minIndex:u,maxIndex:d,count:h}=e,p=i-n;if(p>0){const e=d>0&&h-1>d,r=u>0&&h-1>u,f=(i-Math.max(a,o))/p,m=(Math.min(a,o)-n)/p;if(e&&f>.15)return`the peak of ${t(i)} at ${c} is the point to investigate`;if(r&&m>.15)return`the dip to ${t(n)} at ${s} is the point to investigate`;if(o>=i)return`the climb to ${t(o)} at ${l} warrants a closer look`;if(n>=o)return`the drop to ${t(o)} at ${l} warrants a closer look`}return`the extremes — ${c} (${t(i)}) and ${s} (${t(n)}) — are the points to check`}function ro(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"}function ao(e,t){if(!t)return"";const r=t.familiarity?.[e];return"number"!=typeof r||r>2?"":` This ${za(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}function oo(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function no(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function io(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function so(e,t,r,a){const o=Aa(t,["nominal","ordinal"]),n=t.dataRoles.filter(e=>"quantitative"===e.semanticType),i=o?va(o,r,a):void 0,s=[];i&&null!=e[i]&&s.push(e[i]+"");for(const t of n){const o=va(t,r,a);o&&null!=e[o]&&s.push(`${t.role}: ${e[o]+""}`)}return s.length>0?s.join(", "):"Data item"}function co(e,t,r={}){const a=ya(t),o=ga(t),n=Math.max(1,r.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:a,config:o,locale:r.locale??"en"});const i=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const c=(i?.groupByRole?wa(e,i.groupByRole):void 0)??(i?.groupBy?.[0]?wa(e,i.groupBy[0])??e.dataRoles.find(e=>e.field===i.groupBy?.[0]):void 0)??Aa(e,["nominal","ordinal"]),l=c?va(c,o,a):void 0,u=(i?.idRole?wa(e,i.idRole):void 0)??Aa(e,["identifier"]),d=u?va(u,o,a):void 0,h={id:"root",role:"chart",label:i?.summaryTemplate?xa(i.summaryTemplate,void 0,e,o,a,{count:a.length}):`${e.name}: ${a.length} ${1===a.length?"item":"items"} represented.`,level:1,children:[]};let p=0;const f=(t,r,n)=>{const s=d?t[d]:void 0,c=i?.itemLabelTemplate?xa(i.itemLabelTemplate,t,e,o,a,{count:a.length}):so(t,e,o,a);return{id:"datum-"+io(s??r),role:"datum",label:c,level:n,datum:t}};if(l){const e=/* @__PURE__ */new Map;for(const t of a){const r=(t[l]??"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,n-p));p+=a.length;const o=a.map((e,t)=>f(e,1e5*r+t,3));return t.length>a.length&&o.push({id:"more-"+io(e),role:"datum",label:`…and ${t.length-a.length} more items`,level:3}),{id:"group-"+io(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:o}})}else{const e=a.slice(0,n);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 lo(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function uo(e,t="—"){return null==e||""===e?t:"object"==typeof e?uo(e.id??e.name??e.label,t):e+""}function ho(e){if(null==e||""===e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function po(e){return uo(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function fo(e,t){const r=lo(e,t,"children");return Array.isArray(r)?r:[]}function mo(e,t,r){return`${e} ${1===e?t:r}`}function go(e,t){return 0===e.numericLeaves?"":e.numericLeaves===e.leaves?", leaf total "+t(e.leafTotal):`, known leaf total ${t(e.leafTotal)} across ${mo(e.numericLeaves,"valued leaf","valued leaves")}`}function yo(e){return"TreeDiagram"===e?"tree":"Treemap"===e?"treemap":"CirclePack"===e?"circle-packing":"orbit"}function bo(e,t,r,a){const o=t.data&&"object"==typeof t.data?t.data:null,n=t.childrenAccessor??"children",i=t.valueAccessor??"value",s=t.nodeLabel??t.nodeIdAccessor,c=/* @__PURE__ */new WeakMap,l=/* @__PURE__ */new WeakSet,u=e=>{const t=c.get(e);if(t)return t;if(l.has(e))return{descendants:0,depth:0,leaves:0,numericLeaves:0,leafTotal:0};l.add(e);const r=fo(e,n);let a;if(0===r.length){const t=ho(lo(e,i,"value"));a={descendants:0,depth:1,leaves:1,numericLeaves:null==t?0:1,leafTotal:t??0}}else a=r.reduce((e,t)=>{const r=u(t);return{descendants:e.descendants+1+r.descendants,depth:Math.max(e.depth,r.depth+1),leaves:e.leaves+r.leaves,numericLeaves:e.numericLeaves+r.numericLeaves,leafTotal:e.leafTotal+r.leafTotal}},{descendants:0,depth:1,leaves:0,numericLeaves:0,leafTotal:0});return l.delete(e),c.set(e,a),a};let d=0;const h=(e,t,o,c)=>{const l=uo(lo(e,s,"name"),"item "+o);if(c.has(e))return{id:`hierarchy-${po(o)}-cycle`,role:"datum",level:t,label:`Repeated hierarchy reference to ${l}; branch omitted.`};const p=fo(e,n),f=u(e);if(0===p.length){if(d>=r)return null;d+=1;const n=ho(lo(e,i,"value"));return{id:`hierarchy-${po(o)}-${po(l)}`,role:"datum",level:t,label:`${l}${null==n?"":": "+a(n)}.`,...null==n?{}:{value:n},datum:e}}const m=new Set(c);m.add(e);const g=[];let y=0;for(const[e,a]of p.entries()){if(d>=r){y+=u(a).leaves;continue}const n=h(a,t+1,`${o}-${e}`,m);n&&g.push(n)}return y>0&&g.push({id:`hierarchy-${po(o)}-more`,role:"datum",level:t+1,label:`${mo(y,"more leaf","more leaves")} in ${l} not shown; navigation is capped at ${r}.`}),{id:`hierarchy-${po(o)}-${po(l)}`,role:"series",level:t,label:`${l}: ${mo(p.length,"direct child","direct children")}, ${mo(f.descendants,"total descendant","total descendants")}, ${mo(f.leaves,"leaf","leaves")}${go(f,a)}.`,datum:e,children:g}},p=o?u(o):null,f={id:"root",role:"chart",level:1,label:o?`A ${yo(e)} chart with ${mo(p.leaves,"leaf","leaves")} and ${mo(p.descendants,"total descendant","total descendants")} across ${mo(p.depth,"hierarchy level","hierarchy levels")}${go(p,a)}.`:"A hierarchy chart with no hierarchy data loaded.",children:[]};if(o){const e=h(o,2,"root",/* @__PURE__ */new Set);if(e){const t=uo(lo(o,s,"name"),"");f.children="series"===e.role&&""===t?e.children:[e]}}return f}function vo(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function wo(e,t="—"){return null==e||""===e?t:"object"==typeof e?wo(e.id??e.name??e.label,t):e+""}function Ao(e){if(null==e||""===e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function xo(e){return wo(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function $o(e){const t=[];return(e.linkedHover||e.selection||e.linkedBrush)&&t.push("Use linked highlighting to compare related locations."),(e.enableHover||e.tooltip)&&t.push("Hover or focus a mark for its details."),t.length>0?" "+t.join(" "):""}function Co(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];const t=e;return Array.isArray(t.features)?t.features:"Feature"===t.type?[t]:[]}function So(e,t,r){const a=vo(e,t,r);if(void 0!==a)return a;const o=e.properties;return o&&"object"==typeof o?vo(o,t,r):void 0}function ko(e,t,r){return wo(So(e,t,"id")??So(e,"name","name")??So(e,"NAME","NAME")??So(e,"label","label"),r)}function Ro(e){let t=0,r=1/0,a=-1/0,o=0;for(const n of e)null!=n.value&&(t+=1,r=Math.min(r,n.value),a=Math.max(a,n.value),o+=n.value);return 0===t?null:{count:t,min:r,max:a,total:o,average:o/t}}function Po(e,t){const r=Ro(e);return r?`range ${t(r.min)} to ${t(r.max)}, average ${t(r.average)}, total ${t(r.total)}`:"no numeric values"}function Io(e){const t=e.filter(e=>null!=e.value),r=e.filter(e=>null==e.value),a=[],o=Ro(t);if(o)if(o.min===o.max)a.push({id:"equal",label:"Equal values",rows:t});else{const e=o.min+(o.max-o.min)/3,r=o.min+2*(o.max-o.min)/3,n=t.filter(e=>e.value>=r),i=t.filter(t=>t.value>=e&&r>t.value),s=t.filter(t=>e>t.value);n.length>0&&a.push({id:"highest",label:"Highest values",rows:n}),i.length>0&&a.push({id:"middle",label:"Middle values",rows:i}),s.length>0&&a.push({id:"lowest",label:"Lowest values",rows:s})}return r.length>0&&a.push({id:"missing",label:"No numeric value",rows:r}),a}function Eo(e,t,r){const a=e.filter(e=>null!=e.value).sort((e,t)=>t.value-e.value||e.index-t.index),o=/* @__PURE__ */new Map;let n,i=0;for(const[e,t]of a.entries())n!==t.value&&(i=e+1,n=t.value),o.set(t.index,i);let s=0;return Io(e).map(e=>{const n=e.rows.slice(0,Math.max(0,t-s));s+=n.length;const i=n.map(e=>{const t=o.get(e.index),n=null==t||2>a.length?"":`, rank ${t} of ${a.length}`;return{id:`geo-${xo(e.label)}-${e.index}`,role:"datum",level:3,label:null==e.value?e.label+": no numeric value.":`${e.label}: ${r(e.value)}${n}.`,...null==e.value?{}:{value:e.value},datum:e.datum}}),c=e.rows.length-n.length;return c>0&&i.push({id:`geo-${e.id}-more`,role:"datum",level:3,label:`${c} more ${1===c?"region":"regions"} in ${e.label.toLowerCase()} not shown; navigation is capped at ${t}.`}),{id:"regions-"+e.id,role:"series",level:2,label:`${e.label}: ${e.rows.length} ${1===e.rows.length?"region":"regions"}, ${Po(e.rows,r)}.`,children:i}})}function No(e,t,r,a){const o=Co(t.areas),n="FlowMap"===e&&Array.isArray(t.nodes)?t.nodes:Array.isArray(t.points)?t.points:[],i=Array.isArray(t.flows)?t.flows:[],s=Array.isArray(t.lines)?t.lines:[],c=t.valueAccessor??t.sizeBy??t.costAccessor??"value",l=t.pointIdAccessor??t.nodeIdAccessor??"id",u=("ChoroplethMap"===e?o:n).map((r,a)=>({datum:r,index:a,label:ko(r,"ChoroplethMap"===e?t.idAccessor:l,`${"ChoroplethMap"===e?"region":"location"} ${a+1}`),value:Ao(So(r,c,"value"))})),d=u.filter(e=>null!=e.value),h={id:"root",role:"chart",level:1,label:`${"ChoroplethMap"===e?`A choropleth map with ${o.length} regions.${d.length>0?` Values are available for ${d.length} of ${o.length} regions; ${Po(d,a)}.`:" No regions have numeric values."}`:"FlowMap"===e?`A flow map with ${i.length} flows and ${n.length} locations.`:"DistanceCartogram"===e?`A distance cartogram with ${n.length} locations and ${s.length} routes.`:`A proportional-symbol map with ${n.length} locations.`}${$o(t)}`,children:[]};if("ChoroplethMap"===e)h.children=Eo(u,r,a);else if(u.length>0){const e=u.slice(0,r).map(e=>({id:`geo-${xo(e.label)}-${e.index}`,role:"datum",level:3,label:`${e.label}${null==e.value?"":": "+a(e.value)}.`,...null==e.value?{}:{value:e.value},datum:e.datum}));u.length>r&&e.push({id:"geo-more",role:"datum",level:3,label:`…and ${u.length-r} more locations.`}),h.children?.push({id:"locations",role:"series",level:2,label:`Locations: ${u.length} marks.`,children:e})}const p="FlowMap"===e?i:s;if(p.length>0){const e=p.slice(0,r).map((e,t)=>{const r=wo(e.source,"unknown"),o=wo(e.target,"unknown"),n=Ao(vo(e,c,"value"));return{id:`route-${xo(r)}-${xo(o)}-${t}`,role:"datum",level:3,label:`${r} to ${o}${null==n?"":": "+a(n)}.`,...null==n?{}:{value:n},datum:e}});h.children?.push({id:"routes",role:"series",level:2,label:`Routes: ${p.length} ${1===p.length?"route":"routes"}.`,children:e})}return h}function To(e,t={},r={}){return!!ba(e,t,r.recipe)||Gl.has(e)||ql.has(e)||Hl.has(e)||Rl.has(e)||Pl.has(e)||Il.has(e)||El.has(e)}function Mo(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function Oo(e,t="—"){return null==e||""===e?t:"object"==typeof e?Oo(e.id??e.name??e.label,t):e+""}function Fo(e){if(null==e||""===e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function jo(e){return Oo(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function zo(e,t){const r=[];return(e.linkedHover||e.selection||e.linkedBrush)&&r.push("network"===t?"Use linked highlighting to trace related marks.":"Use linked highlighting to compare related locations."),(e.enableHover||e.tooltip)&&r.push("Hover or focus a mark for its details."),r.length>0?" "+r.join(" "):""}function Bo(e,t){t&&e.children?.push(t)}function Lo(e,t,r,a){const o=Array.isArray(t.nodes)?t.nodes:[],n=Array.isArray(t.edges)?t.edges:Array.isArray(t.flows)?t.flows:[],i=t.nodeIdAccessor??t.nodeIDAccessor,s=t.sourceAccessor??"source",c=t.targetAccessor??"target",l=t.valueAccessor??"value",u=e=>Oo(Mo(e,i,"id"),"unknown"),d=(e,t)=>Oo(Mo(e,t,""),"unknown"),h=/* @__PURE__ */new Set;for(const e of n)h.add(d(e,s)),h.add(d(e,c));const p=o.length>0?o:[...h].map(e=>({id:e})),f=/* @__PURE__ */new Map;for(const e of p)f.set(u(e),{links:0,value:0});for(const e of n){const t=d(e,s),r=d(e,c),a=Fo(Mo(e,l,"value"))??0;for(const e of[t,r]){const t=f.get(e)??{links:0,value:0};t.links+=1,t.value+=a,f.set(e,t)}}const m={id:"root",role:"chart",level:1,label:`A ${"SankeyDiagram"===e||"ProcessSankey"===e?"flow diagram":"ChordDiagram"===e?"chord diagram":"network graph"} with ${p.length} nodes and ${n.length} links.${zo(t,"network")}`,children:[]};let g=0;const y=/* @__PURE__ */new Map,b=t.colorBy??"group";for(const e of p){const t=Oo(Mo(e,b,"group"),"Ungrouped"),r=y.get(t);r?r.push(e):y.set(t,[e])}const v=[...y].map(([e,t],o)=>{const n=[];for(const[e,i]of t.entries()){if(g>=r)break;g+=1;const t=u(i),s=f.get(t)??{links:0,value:0},c=s.value>0?`, ${a(s.value)} total flow`:"";n.push({id:`node-${o}-${e}-${jo(t)}`,role:"datum",level:3,label:`${t}: ${s.links} ${1===s.links?"link":"links"}${c}.`,value:s.value>0?s.value:void 0,datum:i})}return{id:`nodes-${o}-${jo(e)}`,role:"series",level:2,label:`${e}: ${t.length} ${1===t.length?"node":"nodes"}.`,children:n}});v.length>0&&m.children?.push(...v);const w=n.slice(0,r).map((e,t)=>{const r=d(e,s),o=d(e,c),n=Fo(Mo(e,l,"value"));return{id:`link-${jo(r)}-${jo(o)}-${t}`,role:"datum",level:3,label:`${r} to ${o}${null==n?"":": "+a(n)}.`,value:n,datum:e}});return n.length>r&&w.push({id:"links-more",role:"datum",level:3,label:`…and ${n.length-r} more links.`,value:void 0}),w.length>0&&m.children?.push({id:"links",role:"series",level:2,label:`Links: ${n.length} ${1===n.length?"connection":"connections"}.`,children:w}),m}function _o(e,t){const r=Array.isArray(e.annotations)?e.annotations:null;if(!r)return null;const a=fa(r.filter(e=>!!e&&"object"==typeof e));if(0===a.length)return null;let o=0;const n=a.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=Ya(e),a?a.charAt(0).toUpperCase()+a.slice(1):a}${r}.`,datum:e};var a});a.length>t&&n.push({id:"annotation-"+o++,role:"annotation",level:3,label:`…and ${a.length-t} more annotations.`});const i=a.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===i?"one marked feature":i+" marked features"}.`,children:n}}function Do(e,t,r={}){const a=r.locale??"en",o=Math.max(1,r.maxLeaves??200),n=Ga(a),i=ba(e,t,r.recipe);if(i)return co(i,t,{maxLeaves:o,locale:a});const s={id:"root",role:"chart",label:Ja(e,t,{locale:a}).text||"Chart.",level:1,children:[]},c=_o(t,o);if(Gl.has(e)){const r=Lo(e,t,o,n);return Bo(r,c),r}if(ql.has(e)){const r=bo(e,t,o,n);return Bo(r,c),r}if(Hl.has(e)){const r=No(e,t,o,n);return Bo(r,c),r}const l=Array.isArray(t.data)?t.data:null,u=To(e,t,r);if(!l||0===l.length||!u)return c&&(s.children=[c]),s;const{measure:d,measureFallback:h,dimension:p,dimensionFallback:f}=da(e,t),m=ca(d,h),g=la(p,f),y="string"==typeof d&&d?d:h,b="string"==typeof p&&p?p:f,v=ha(t);let w=0;const A=e=>`${e}-${w++}`,x=(e,t)=>{const r=m(e),a=pa(g(e),n);return{id:A("datum"),role:"datum",level:t,label:`${a}: ${Number.isFinite(r)?n(r):"—"}`,value:Number.isFinite(r)?r:void 0,datum:e}},$=(e,t)=>{const r=e.slice(0,o).map(e=>x(e,t));return e.length>o&&r.push({id:A("more"),role:"datum",level:t,label:`…and ${e.length-o} more points`}),r},C=[];if(Rl.has(e)||Pl.has(e)){let t=1/0,r=-1/0,a=1/0,o=-1/0;const i=[];let s=!0;for(const e of l){const n=m(e);Number.isFinite(n)&&(t>n&&(t=n),n>r&&(r=n));const c=g(e);i.push(c),"number"==typeof c&&Number.isFinite(c)?(a>c&&(a=c),c>o&&(o=c)):s=!1}const c=/* @__PURE__ */new Set,u=[];for(const e of i){const t=e+"";c.has(t)||(c.add(t),u.push(e))}const d=s?`${n(a)} to ${n(o)}`:`${pa(u[0],n)} to ${pa(u[u.length-1],n)} (${Pl.has(e)?u.length+" categories":l.length+" points"})`;C.push({id:A("axis"),role:"axis",level:2,label:`${Pl.has(e)?"Category axis":"X axis"}: ${b}, ${d}.`}),t>r||C.push({id:A("axis"),role:"axis",level:2,label:`Value axis: ${y}, ${n(t)} to ${n(r)}.`})}if(v){const r=la(v,v),o=/* @__PURE__ */new Map;for(const e of l){const t=(r(e)??"—")+"",a=o.get(t);a?a.push(e):o.set(t,[e])}const n=[];for(const[r,i]of o){const o=Ja(e,{...t,data:i},{levels:["l2","l3"],locale:a}).text;n.push({id:A("series"),role:"series",level:2,label:`Series ${r}: ${o}`,children:$(i,3)})}s.children=[...C,...n]}else s.children=[...C,...$(l,2)];return c&&s.children.push(c),s}function Uo(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 Vo(e){let t=1;if(e.children)for(const r of e.children)t+=Vo(r);return t}function Go(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function qo(e){return Go(e)?e:void 0}function Ho(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function Wo(e){const t=Ho(e);return null==t?void 0:Math.max(0,Math.floor(t))}function Yo(...e){return e.map(qo).find(Boolean)}function Ko(...e){return e.find(Array.isArray)}function Jo(e){const t={};for(const[r,a]of Object.entries(e))void 0!==a&&(t[r]=a);return t}function Xo(e,t,r){return e["string"==typeof t&&t?t:r]}function Zo(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function Qo(e,t,r){const a=[];if("GaugeChart"===e){"number"==typeof t.value&&Number.isFinite(t.value)&&a.push(`Current value is ${Zo(t.value)}.`);const e="number"==typeof t.min&&Number.isFinite(t.min)?t.min:0,r="number"==typeof t.max&&Number.isFinite(t.max)?t.max:100;a.push(`The gauge scale runs from ${Zo(e)} to ${Zo(r)}.`)}if("SankeyDiagram"===e||"ProcessSankey"===e){const o=Array.isArray(t.edges)?t.edges:[];if("ProcessSankey"===e&&Array.isArray(t.domain)&&2===t.domain.length&&a.push(`The ProcessSankey time domain runs from ${Zo(t.domain[0])} to ${Zo(t.domain[1])}.`),o.length>0){a.push(`${o.length} source flow${1===o.length?"":"s"} are supplied.`);for(const n of o.slice(0,r)){const r=Xo(n,t.sourceAccessor,"source"),o=Xo(n,t.targetAccessor,"target"),i=Xo(n,t.valueAccessor,"value");a.push("ProcessSankey"!==e||null==n.startTime&&null==n.endTime?`${Zo(r)} to ${Zo(o)} has value ${Zo(i)}.`:`${Zo(r)} to ${Zo(o)} has value ${Zo(i)} over ${Zo(n.startTime)}–${Zo(n.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){const e=qo(t.data),o="string"==typeof t.childrenAccessor&&t.childrenAccessor?t.childrenAccessor:"children",n="string"==typeof t.valueAccessor&&t.valueAccessor?t.valueAccessor:"value",i="string"==typeof t.nodeIdAccessor&&t.nodeIdAccessor?t.nodeIdAccessor:"string"==typeof t.nodeIDAccessor&&t.nodeIDAccessor?t.nodeIDAccessor:"name",s=[],c=e=>{const t=Array.isArray(e[o])?e[o]:[];if(0!==t.length)for(const e of t){const t=qo(e);t&&c(t)}else s.push(e)};if(e&&c(e),s.length>0){a.push(s.length+" hierarchy leaves are supplied.");for(const e of s.slice(0,r))a.push(`${Zo(e[i])} has value ${Zo(e[n])}.`)}}if(Wl.has(e)&&Array.isArray(t.data)){const r=t.data;a.push(`${r.length} observed source row${1===r.length?"":"s"} are supplied.`);const o="CollisionSwarmChart"===e?t.xAccessor:t.valueAccessor,n="CollisionSwarmChart"===e?"x":"value",i=r.map(e=>Ho(Xo(e,o,n))).filter(e=>null!=e);i.length>0&&a.push(`Observed ${"string"==typeof o?o:n} ranges from ${Zo(Math.min(...i))} to ${Zo(Math.max(...i))}.`)}if(0!==a.length)return{source:"chart-props",statements:a,text:"Exact chart-prop facts: "+a.join(" ")}}function en(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function tn(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function rn(e,t,r,a){const o=qo(e.settledProjection),n=qo(t?.settledProjection);return Ko(r?.projectionRows,r?.aggregates,e.settledProjectionRows,e.projectionRows,o?.rows,t?.settledProjectionRows,t?.projectionRows,n?.rows,a?.binCounts)}function an(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const r=qo(e);if(!r)return;const a=Ho(r.count??r.value??r.total??r.bodies??r.events);if(null==a)return;const o=(r.label??r.id??r.name??"container "+(t+1))+"",n=null==r.id?void 0:r.id+"",i=Ho(r.secondary??r.secondaryCount),s=Ho(r.observed??r.observedCount);return Jo({id:n,label:o,count:a,secondary:i,secondaryLabel:"string"==typeof r.secondaryLabel?r.secondaryLabel:void 0,observed:s})}).filter(e=>null!=e);if(0===t.length)return;const r=t.reduce((e,t)=>e+t.count,0),a=t.filter(e=>e.count>0).length,o=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:r,populatedCount:a,...o?{leader:o}:{}}}function on(e,t){const r=e?.map((e,t)=>{const r=qo(e);if(!r)return;const a=Ho(r.count)??0,o=Ho(r.total),n={label:(r.label??r.id??"sediment "+(t+1))+"",count:a};return null!=r.id&&(n.id=r.id+""),null!=o&&(n.total=o),n}).filter(e=>null!=e),a=Wo(t?.bins)??r?.length??0,o=Ho(t?.count)??r?.reduce((e,t)=>e+t.count,0)??0,n=Ho(t?.total)??r?.reduce((e,t)=>e+(t.total??0),0),i=r?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==a||0!==o||n)return{bins:a,count:o,...null!=n&&n>0?{total:n}:{},...i?{leader:i}:{}}}function nn(e){const t=qo(e);return!!t&&(Go(t.world)||"simulationState"in t||"liveBodyOrder"in t)}function sn(e){if(e)return e.filter(e=>!0===qo(e)?.sleeping).length}function cn(e,t,r){const a=e?.filter(e=>!0===qo(e)?.sensor).length,o=qo(t?.observation),n=qo(o?.sensors),i=Ko(r?.activeSensors);return Math.max(a??0,n?Object.keys(n).length:0,i?.length??0)||void 0}function ln(e){const t=[],r=e.simulation,a=[r.state??(r.settled?"settled":void 0),null!=r.liveBodies?`${r.liveBodies} live ${en(r.liveBodies,"body")}`:void 0,null!=r.sleepingBodies?r.sleepingBodies+" sleeping":void 0,null!=r.queued?r.queued+" queued":void 0,null!=r.seed?"seed "+tn(r.seed):void 0,r.gravity?`gravity (${tn(r.gravity.x)}, ${tn(r.gravity.y)})`:void 0,null!=r.fixedDt?`fixed step ${tn(r.fixedDt)}s`:void 0,null!=r.timeScale?tn(r.timeScale)+"x time":void 0].filter(Boolean);a.length>0&&t.push(`Physics simulation: ${a.join("; ")}.`);const o=e.geometry;if(o){const e=[null!=o.colliders?`${o.colliders} ${en(o.colliders,"collider")}`:void 0,null!=o.sensors?`${o.sensors} ${en(o.sensors,"sensor")}`:void 0,null!=o.springs?`${o.springs} ${en(o.springs,"spring")}`:void 0,null!=o.activeSensorPairs?`${o.activeSensorPairs} active sensor ${en(o.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}const n=e.aggregates;if(n){const e=n.leader,r=e?` Largest is ${e.label} with ${tn(e.count)}.`:"";t.push(`Physics aggregates: ${tn(n.totalCount)} settled ${en(n.totalCount,"body")} across ${n.rows.length} ${en(n.rows.length,"container")}; ${n.populatedCount} populated.${r}`)}const i=e.sediment;if(i){const e=null!=i.total?", value total "+tn(i.total):"",r=i.leader?`; largest sediment bin is ${i.leader.label} with ${tn(i.leader.count)}`:"";t.push(`Physics sediment: ${i.count} retained ${en(i.count,"body")} in ${i.bins} ${en(i.bins,"bin")}${e}${r}.`)}return t.join(" ")}function un(e,t,r){if(!1===r)return;const a=Go(r)?r:void 0,o=qo(t.physics),n=Yo(a?.snapshot,o?.snapshot,t.physicsSnapshot,nn(t.snapshot)?t.snapshot:void 0),i=Yo(a?.evidence,o?.evidence,t.physicsEvidence,t.settledEvidence),s=Yo(a?.config,o?.config,n?.config,t.config),c=Yo(qo(n?.world),qo(o?.world)),l=Yo(qo(s?.kernel),qo(c?.options)),u=Ko(c?.bodies),d=Ko(c?.colliders,s?.colliders),h=Ko(n?.queue,o?.queue),p=Ko(n?.liveBodyOrder),f=Ko(c?.springs),m=Ko(n?.activeSensorPairs),g=an(rn(t,o,a,i)),y=on(Ko(a?.sediment,o?.sediment,n?.sediment),Yo(a?.sedimentTotals,o?.sedimentTotals)),b=p?.length??u?.length??Wo(i?.bodyCount),v=sn(u)??Wo(i?.sleepingCount),w=h?.length,A="string"==typeof n?.simulationState?n.simulationState:void 0,x="boolean"==typeof i?.settled?i.settled:A?"settled"===A:null!=b||null!=v||null!=w?null!=b&&v===b&&0===(w??0):void 0,$=qo(l?.gravity),C=Ho($?.x),S=Ho($?.y),k=Jo({state:A,settled:x,elapsedSeconds:Ho(n?.elapsedSeconds),paused:"boolean"==typeof n?.paused?n.paused:void 0,visible:"boolean"==typeof n?.visible?n.visible:void 0,seed:Ho(l?.seed),gravity:null!=C&&null!=S?{x:C,y:S}:void 0,fixedDt:Ho(s?.fixedDt??l?.fixedDt),timeScale:Ho(s?.timeScale),maxSubsteps:Wo(s?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:w,bodyLimit:Ho(s?.bodyLimit),eviction:"string"==typeof s?.eviction?s.eviction:void 0}),R=Jo({colliders:d?.length,sensors:cn(d,s,c),springs:f?.length,activeSensorPairs:m?.length}),P=Object.keys(R).length>0,I=Wl.has(e);if(!(Object.keys(k).length>0||P||g||y)||!I&&null==r)return;const E={simulation:k,...P?{geometry:R}:{},...g?{aggregates:g}:{},...y?{sediment:y}:{}},N=ln(E);return{...E,text:N}}function dn(e,t,r={}){const{capability:a,audience:o,locale:n}=r,i=r.levels??["l1","l2","l3"],s=!1!==r.includeStructure,c=Ua(e,a),l=Ja(e,t,{levels:c?[...i,"l4"]:i,locale:n,capability:a,audience:o}),{l4:u,...d}=l.levels,h=["l1","l2","l3"].map(e=>l.levels[e]).filter(Boolean).join(" "),p={levels:d,text:l.annotations?`${l.annotations} ${h}`.trim():h,...l.annotations?{annotations:l.annotations}:{}};let f;if(c&&u){const e=(m=a)?"fits"in m||"buildProps"in m?{family:m.family}:{family:m.family,intentScores:m.intentScores}:{};f={act:c,sentence:u,family:e.family,intentScores:e.intentScores}}var m;const g=s?Do(e,t,{maxLeaves:r.maxLeaves,locale:n}):void 0,y=un(e,t,r.physics),b=Qo(e,t,Math.max(1,r.maxLeaves??200)),v=[p.text,f?.sentence,y?.text,b?.text].filter(Boolean).join(" ");return{component:e,description:p,intent:f,structure:g,physics:y,facts:b,text:v}}function hn(e,t=30){return Math.max((e??4)+5,12,t)}function pn(e,t){return Yl.has(e)&&!("reading"===e&&"string"==typeof t)}function fn(e){const t=[...Xl],r=Array.from((new TextEncoder).encode(e)),a=8*r.length;for(r.push(128);r.length%64!=56;)r.push(0);const o=Math.floor(a/4294967296),n=a>>>0;r.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o,n>>>24&255,n>>>16&255,n>>>8&255,255&n);const i=[];for(let e=0;r.length>e;e+=4)i.push((r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0);for(let e=0;i.length>e;e+=16){const r=[...i.slice(e,e+16)];for(let e=16;64>e;e+=1){const t=Kl(r[e-15],7)^Kl(r[e-15],18)^r[e-15]>>>3,a=Kl(r[e-2],17)^Kl(r[e-2],19)^r[e-2]>>>10;r[e]=r[e-16]+t+r[e-7]+a>>>0}let[a,o,n,s,c,l,u,d]=t;for(let e=0;64>e;e+=1){const t=d+(Kl(c,6)^Kl(c,11)^Kl(c,25))+(c&l^~c&u)+Zl[e]+r[e]>>>0,i=a&o^a&n^o&n;d=u,u=l,l=c,c=s+t>>>0,s=n,n=o,o=a,a=t+((Kl(a,2)^Kl(a,13)^Kl(a,22))+i>>>0)>>>0}const h=[a,o,n,s,c,l,u,d];for(let e=0;8>e;e+=1)t[e]=t[e]+h[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function mn(e,t){return`${e}[Symbol(${t.description??""})]`}function gn(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function yn(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function bn(e){return e.sort((e,t)=>{const r=JSON.stringify(e),a=JSON.stringify(t);return a>r?-1:r>a?1:0})}function vn(e,t,r){if(null===e)return null;if(e instanceof Date){const a=e.getTime();return Number.isFinite(a)?{$type:"date",value:e.toISOString()}:void r.excluded.push(t)}switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isNaN(e)?{$type:"number",value:"NaN"}:e===1/0?{$type:"number",value:"Infinity"}:e===-1/0?{$type:"number",value:"-Infinity"}:Object.is(e,-0)?{$type:"number",value:"-0"}:e;case"bigint":return{$type:"bigint",value:""+e};case"undefined":case"function":case"symbol":return void r.excluded.push(t);case"object":{const a=e;if(r.ancestors.has(a))return void r.excluded.push(t);r.ancestors.add(a);try{if(Array.isArray(e)){for(const a of Reflect.ownKeys(e))"length"===a||"string"==typeof a&&gn(a,e.length)||r.excluded.push("symbol"==typeof a?mn(t,a):yn(t,a));return Array.from({length:e.length},(a,o)=>{const n=yn(t,o),i=Object.getOwnPropertyDescriptor(e,o+"");if(!i||!("value"in i)||!i.enumerable)return r.excluded.push(n),null;const s=vn(i.value,n,r);return void 0===s?null:s})}const a={},o=Object.getPrototypeOf(e);if(o!==Object.prototype&&null!==o)return void r.excluded.push(t);const n=[];for(const a of Reflect.ownKeys(e)){if("symbol"==typeof a){r.excluded.push(mn(t,a));continue}const o=Object.getOwnPropertyDescriptor(e,a);o&&"value"in o&&o.enumerable?n.push(a):r.excluded.push(yn(t,a))}for(const o of n.sort()){const n=Object.getOwnPropertyDescriptor(e,o),i=vn(n&&"value"in n?n.value:void 0,yn(t,o),r);void 0!==i&&Object.defineProperty(a,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}return a}finally{r.ancestors.delete(a)}}default:return void r.excluded.push(t)}}function wn(e,t=/* @__PURE__ */new Set){if(null===e)return["null"];if(e instanceof Date)return Number.isFinite(e.getTime())?["date",e.toISOString()]:["excluded"];switch(typeof e){case"string":return["string",e];case"boolean":return["boolean",e];case"number":return["number",Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Object.is(e,-0)?"-0":e+""];case"bigint":return["bigint",""+e];case"undefined":case"function":case"symbol":return["excluded"];case"object":if(t.has(e))return["excluded"];t.add(e);try{const r=r=>{const a="symbol"==typeof r?["symbol-key",r.description??""]:["string-key",r],o=Object.getOwnPropertyDescriptor(e,r);return o?"value"in o?[a,"data",!!o.enumerable,wn(o.value,t)]:[a,"accessor",!!o.enumerable,!!o.get,!!o.set]:[a,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,a)=>{const o=a+"";return Object.prototype.hasOwnProperty.call(e,o)?r(o):["hole"]}),bn(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&gn(t,e.length))).map(r))];const a=Object.getPrototypeOf(e);return[a!==Object.prototype&&null!==a?"non-json-object":"object",bn(Reflect.ownKeys(e).map(r))]}finally{t.delete(e)}default:return["excluded"]}}function An(e){const t={excluded:[],ancestors:/* @__PURE__ */new Set},r=vn(e,"$",t)??null;return{value:r,text:JSON.stringify(r),excludedPaths:t.excluded}}function xn(e){const t=An(e),r=fn(JSON.stringify(["semiotic-value-fingerprint","v2",wn(e)]));return{...t,algorithm:"sha256",digest:r,fingerprint:"sha256:"+r}}function $n(e,t,r,a){En(e,Object.keys(t),r,a);for(const[o,n]of Object.entries(t))n.values?(n.required||void 0!==e[o])&&Tn(e,o,r,n.values,a):n.required?Nn(e,o,r,a):zn(e,o,r,a)}function Cn(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Sn(e,t,r,a){void 0===e[t]||"number"==typeof e[t]&&Number.isFinite(e[t])||a.push({path:`${r}.${t}`,message:"Expected a finite number."})}function kn(e,t,r,a){void 0!==e[t]&&"boolean"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a boolean."})}function Rn(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(Rn):Cn(e)&&Object.values(e).every(Rn))}function Pn(e,t,r,a){void 0===e[t]||Cn(e[t])&&Rn(e[t])||a.push({path:`${r}.${t}`,message:"Expected a JSON object."})}function In(e){return e.every(Rn)}function En(e,t,r,a){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||a.push({path:`${r}.${t}`,message:"Unexpected property."})}function Nn(e,t,r,a){"string"==typeof e[t]&&e[t]||a.push({path:`${r}.${t}`,message:"Expected a non-empty string."})}function Tn(e,t,r,a,o){"string"==typeof e[t]&&a.includes(e[t])||o.push({path:`${r}.${t}`,message:`Expected one of: ${a.join(", ")}.`})}function Mn(e,t,r,a){const o=e[t];if(void 0!==o){if(Cn(o))return o;a.push({path:`${r}.${t}`,message:"Expected an object."})}}function On(e,t,r,a){const o=e[t];if(void 0!==o){if(Array.isArray(o))return o;a.push({path:`${r}.${t}`,message:"Expected an array."})}}function Fn(e,t,r){e?.some(e=>"string"!=typeof e||!e)&&r.push({path:t,message:"Expected non-empty string values."})}function jn(e,t,r,a,o){void 0!==e[t]&&Tn(e,t,r,a,o)}function zn(e,t,r,a){void 0!==e[t]&&"string"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a string."})}function Bn(e,t,r){Cn(e)?(En(e,["id","name","kind"],t,r),Nn(e,"kind",t,r),zn(e,"id",t,r),zn(e,"name",t,r)):r.push({path:t,message:"Expected an actor object."})}function Ln(e,t){const r=Mn(e,"reception","$",t);if(!r)return;En(r,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);const a=On(r,"channels","$.reception",t);a||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),a?.forEach((e,r)=>{const a=`$.reception.channels[${r}]`;Cn(e)?(En(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],a,t),Tn(e,"channel",a,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),jn(e,"disclosure",a,["summary","standard","detailed"],t),jn(e,"rawData",a,["deny","bounded","allow"],t),kn(e,"navigation",a,t),kn(e,"interactionInstructions",a,t),Sn(e,"tokenBudget",a,t),Fn(On(e,"privacyNotes",a,t),a+".privacyNotes",t)):t.push({path:a,message:"Expected a channel object."})});for(const e of["strengths","risks","scaffolds","manualChecks"])Fn(On(r,e,"$.reception",t),"$.reception."+e,t);zn(r,"audience","$.reception",t),zn(r,"description","$.reception",t),kn(r,"dataFallback","$.reception",t)}function _n(e,t){const r=Mn(e,"form","$",t);r&&(En(r,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),zn(r,"chartFamily","$.form",t),zn(r,"whyThisForm","$.form",t),Fn(On(r,"risks","$.form",t),"$.form.risks",t),Fn(On(r,"misuse","$.form",t),"$.form.misuse",t),On(r,"rejectedAlternatives","$.form",t)?.forEach((e,r)=>{const a=`$.form.rejectedAlternatives[${r}]`;Cn(e)?(En(e,["representation","reason"],a,t),Nn(e,"representation",a,t),Nn(e,"reason",a,t)):t.push({path:a,message:"Expected an alternative object."})}))}function Dn(e,t){const r=Mn(e,"contestability","$",t);r&&(En(r,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),kn(r,"sourceRequestsAllowed","$.contestability",t),On(r,"challenges","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.challenges[${r}]`;if(Cn(e)){En(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],a,t),Nn(e,"id",a,t),Nn(e,"claimId",a,t),Nn(e,"reason",a,t),Tn(e,"status",a,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&Bn(e.raisedBy,a+".raisedBy",t);for(const r of["raisedAt","counterclaimId","resolution"])zn(e,r,a,t)}else t.push({path:a,message:"Expected a challenge object."})}),On(r,"corrections","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.corrections[${r}]`;if(!Cn(e))return void t.push({path:a,message:"Expected a correction object."});En(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],a,t),Nn(e,"id",a,t),Nn(e,"reason",a,t);const o=On(e,"affectedClaimIds",a,t);o||t.push({path:a+".affectedClaimIds",message:"Expected an affected-claim array."}),Fn(o,a+".affectedClaimIds",t),Fn(On(e,"replacementClaimIds",a,t),a+".replacementClaimIds",t),zn(e,"createdAt",a,t),void 0!==e.createdBy&&Bn(e.createdBy,a+".createdBy",t)}),On(r,"alternativeViews","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.alternativeViews[${r}]`;Cn(e)?(En(e,["id","label","rationale"],a,t),Nn(e,"id",a,t),Nn(e,"label",a,t),zn(e,"rationale",a,t)):t.push({path:a,message:"Expected an alternative-view object."})}),On(r,"editorialExceptions","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.editorialExceptions[${r}]`;Cn(e)?(En(e,["ruleId","rationale","owner","reviewAt"],a,t),Nn(e,"ruleId",a,t),Nn(e,"rationale",a,t),zn(e,"owner",a,t),zn(e,"reviewAt",a,t)):t.push({path:a,message:"Expected an editorial-exception object."})}))}function Un(e,t){const r=Mn(e,"accountability","$",t);r&&(En(r,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),On(r,"authors","$.accountability",t)?.forEach((e,r)=>Bn(e,`$.accountability.authors[${r}]`,t)),Fn(On(r,"dataSources","$.accountability",t),"$.accountability.dataSources",t),zn(r,"generatedBy","$.accountability",t),zn(r,"codeRef","$.accountability",t),On(r,"reviews","$.accountability",t)?.forEach((e,r)=>{const a=`$.accountability.reviews[${r}]`;if(Cn(e)){En(e,["id","status","reviewer","reviewedAt","rationale","policyId"],a,t),Nn(e,"id",a,t),Tn(e,"status",a,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&Bn(e.reviewer,a+".reviewer",t);for(const r of["reviewedAt","rationale","policyId"])zn(e,r,a,t)}else t.push({path:a,message:"Expected a review object."})}),On(r,"actions","$.accountability",t)?.forEach((e,r)=>{const a=`$.accountability.actions[${r}]`;if(!Cn(e))return void t.push({path:a,message:"Expected an action object."});En(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],a,t),Nn(e,"id",a,t),Nn(e,"action",a,t);const o=On(e,"claimIds",a,t);o||t.push({path:a+".claimIds",message:"Expected a claim identifier array."}),Fn(o,a+".claimIds",t),void 0!==e.actor&&Bn(e.actor,a+".actor",t);for(const r of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])zn(e,r,a,t);jn(e,"status",a,["proposed","taken","reversed","invalidated"],t)}))}function Vn(e,t){const r=Mn(e,"inheritance","$",t);if(r){En(r,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(const e of["requiredPaths","prohibitedExports","sourceArtifactIds"])Fn(On(r,e,"$.inheritance",t),"$.inheritance."+e,t);jn(r,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),jn(r,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),jn(r,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function Gn(e,t){Ln(e,t),_n(e,t),Dn(e,t),Un(e,t),Vn(e,t)}function qn(e){for(const t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function Hn(e,t){if(void 0===e||Cn(e)){if(Cn(e))for(const[r,a]of Object.entries(e)){const e="$.fieldStatus."+r;if(!Cn(a)||"string"!=typeof a.status){t.push({path:e,message:"Expected a field state with a status."});continue}En(a,["status","reason","suppliedBy","derived","reviewedBy"],e,t),["known","unknown","manual","not-applicable"].includes(a.status)||t.push({path:e+".status",message:"Expected one of: known, unknown, manual, not-applicable."}),void 0===a.suppliedBy||"string"==typeof a.suppliedBy&&["author","system","model-proposal","import"].includes(a.suppliedBy)||t.push({path:e+".suppliedBy",message:"Expected one of: author, system, model-proposal, import."}),zn(a,"reason",e,t),zn(a,"reviewedBy",e,t),kn(a,"derived",e,t);const o=Object.prototype.hasOwnProperty.call(eu,r)?eu[r]:void 0,n="model-proposal"===a.suppliedBy,i=n&&!0===o?.modelMayPropose&&"known"!==a.status;o&&"known"===a.status&&"string"!=typeof a.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${r}" must identify an allowed supplier.`}),!o||"string"!=typeof a.suppliedBy||i||o.suppliedBy.includes(a.suppliedBy)||t.push({path:e+".suppliedBy",message:`Field "${r}" cannot be supplied by ${a.suppliedBy}.`}),o&&!0===a.derived&&!o.derivable&&t.push({path:e+".derived",message:`Field "${r}" cannot be marked as derived.`}),!o||!n||o.modelMayPropose&&"known"!==a.status||t.push({path:e+".suppliedBy",message:"known"===a.status?`A model proposal cannot finalize field "${r}" as known.`:`Field "${r}" does not accept model proposals.`}),"required"!==o?.humanReview||"known"!==a.status||"string"==typeof a.reviewedBy&&a.reviewedBy.trim()||t.push({path:e+".reviewedBy",message:`Known field "${r}" requires an attributable human review.`})}}else t.push({path:"$.fieldStatus",message:"Expected a field-state object."})}function Wn(e,t){const r="$.time";En(e,[...au,...Object.keys(ou),"sources"],r,t);for(const a of au)zn(e,a,r,t);for(const[a,o]of Object.entries(ou)){const n=Mn(e,a,r,t);n&&$n(n,o,`${r}.${a}`,t)}On(e,"sources",r,t)?.forEach((e,a)=>{const o=`${r}.sources[${a}]`;Cn(e)?$n(e,nu,o,t):t.push({path:o,message:"Expected a source object."})})}function Yn(e){try{return Kn(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function Kn(e){const t=[],r=[];if(!Cn(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:r};const a=sr(e);if(a.length>0)return{valid:!1,errors:a.map(e=>({path:e,message:"Expected a JSON-compatible value that survives serialization unchanged."})),warnings:r};if(En(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),e.contractVersion!==Ql&&t.push({path:"$.contractVersion",message:`Expected contract version ${Ql}.`}),Cn(e.artifact)){En(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),Nn(e.artifact,"id","$.artifact",t),Tn(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(const r of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])zn(e.artifact,r,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(Cn(e.purpose))if(Array.isArray(e.purpose.intents)){En(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,r)=>{Cn(e)&&"string"==typeof e.id&&e.id||t.push({path:`$.purpose.intents[${r}].id`,message:"Expected a non-empty intent identifier."}),Cn(e)&&En(e,["id","strength","source","rationale"],`$.purpose.intents[${r}]`,t),Cn(e)&&void 0!==e.strength&&Tn(e,"strength",`$.purpose.intents[${r}]`,["primary","secondary"],t),Cn(e)&&(jn(e,"source",`$.purpose.intents[${r}]`,["author","derived","model-proposal","import"],t),zn(e,"rationale",`$.purpose.intents[${r}]`,t))});for(const r of["allowedUses","prohibitedUses"])Fn(On(e.purpose,r,"$.purpose",t),"$.purpose."+r,t);jn(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),zn(e.purpose,"communicativeAct","$.purpose",t),zn(e.purpose,"decisionContext","$.purpose",t)}else t.push({path:"$.purpose.intents",message:"Expected an intent array."});else t.push({path:"$.purpose",message:"Expected a purpose object."});Array.isArray(e.claims)?e.claims.forEach((e,r)=>{if(!Cn(e))return void t.push({path:`$.claims[${r}]`,message:"Expected a claim object."});En(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${r}]`,t),Nn(e,"id",`$.claims[${r}]`,t),Tn(e,"kind",`$.claims[${r}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),Tn(e,"status",`$.claims[${r}]`,["supported","provisional","disputed","superseded","retracted","unsupported","unknown"],t),Array.isArray(e.evidenceIds)?e.evidenceIds.some(e=>"string"!=typeof e||!e)&&t.push({path:`$.claims[${r}].evidenceIds`,message:"Expected non-empty string evidence identifiers."}):t.push({path:`$.claims[${r}].evidenceIds`,message:"Expected an evidence identifier array."}),Fn(On(e,"supersedes",`$.claims[${r}]`,t),`$.claims[${r}].supersedes`,t),zn(e,"text",`$.claims[${r}]`,t),zn(e,"asOf",`$.claims[${r}]`,t),Pn(e,"scope",`$.claims[${r}]`,t),Fn(On(e,"tags",`$.claims[${r}]`,t),`$.claims[${r}].tags`,t),void 0!==e.authoredBy&&Bn(e.authoredBy,`$.claims[${r}].authoredBy`,t);const a=Mn(e,"review",`$.claims[${r}]`,t);a&&(En(a,["status","reviewer","reviewedAt","rationale"],`$.claims[${r}].review`,t),Tn(a,"status",`$.claims[${r}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==a.reviewer&&Bn(a.reviewer,`$.claims[${r}].review.reviewer`,t),zn(a,"reviewedAt",`$.claims[${r}].review`,t),zn(a,"rationale",`$.claims[${r}].review`,t));const o=Mn(e,"uncertainty",`$.claims[${r}]`,t);if(o){En(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${r}].uncertainty`,t),Tn(o,"kind",`$.claims[${r}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(const e of["lower","upper","confidence"])Sn(o,e,`$.claims[${r}].uncertainty`,t);zn(o,"unit",`$.claims[${r}].uncertainty`,t),zn(o,"description",`$.claims[${r}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,r)=>{if(!Cn(e))return void t.push({path:`$.evidence[${r}]`,message:"Expected an evidence object."});En(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${r}]`,t),Nn(e,"id",`$.evidence[${r}]`,t),Tn(e,"role",`$.evidence[${r}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(const a of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])zn(e,a,`$.evidence[${r}]`,t);Pn(e,"scope",`$.evidence[${r}]`,t);const a=Mn(e,"source",`$.evidence[${r}]`,t);if(a){En(a,["name","uri","version","retrievedAt","publisher"],`$.evidence[${r}].source`,t);for(const e of["name","uri","version","retrievedAt","publisher"])zn(a,e,`$.evidence[${r}].source`,t)}const o=Mn(e,"transformation",`$.evidence[${r}]`,t);if(o){En(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${r}].transformation`,t),Nn(o,"id",`$.evidence[${r}].transformation`,t),Tn(o,"kind",`$.evidence[${r}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);const e=On(o,"inputEvidenceIds",`$.evidence[${r}].transformation`,t);e?Fn(e,`$.evidence[${r}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${r}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),Fn(On(o,"assumptions",`$.evidence[${r}].transformation`,t),`$.evidence[${r}].transformation.assumptions`,t),zn(o,"description",`$.evidence[${r}].transformation`,t),zn(o,"implementation",`$.evidence[${r}].transformation`,t),zn(o,"performedAt",`$.evidence[${r}].transformation`,t),Pn(o,"parameters",`$.evidence[${r}].transformation`,t),void 0!==o.performedBy&&Bn(o.performedBy,`$.evidence[${r}].transformation.performedBy`,t)}const n=Mn(e,"sample",`$.evidence[${r}]`,t);if(n){En(n,["rowCount","fields","values","truncated"],`$.evidence[${r}].sample`,t),Fn(On(n,"fields",`$.evidence[${r}].sample`,t),`$.evidence[${r}].sample.fields`,t);const e=On(n,"values",`$.evidence[${r}].sample`,t);e&&!In(e)&&t.push({path:`$.evidence[${r}].sample.values`,message:"Expected JSON values."}),Sn(n,"rowCount",`$.evidence[${r}].sample`,t),kn(n,"truncated",`$.evidence[${r}].sample`,t)}jn(e,"relationship",`$.evidence[${r}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),Hn(e.fieldStatus,t);const o=Mn(e,"time","$",t);return o&&Wn(o,t),Gn(e,t),Pn(e,"extensions","$",t),Array.isArray(e.claims)&&0===e.claims.length&&r.push({path:"$.claims",message:"The contract declares no claims."}),Array.isArray(e.evidence)&&0===e.evidence.length&&r.push({path:"$.evidence",message:"The contract declares no evidence."}),{valid:0===t.length,errors:t,warnings:r}}function Jn(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Xn(e,t){if(!t||!Jn(e)||!Array.isArray(e.evidence))return[];const r=[];return e.evidence.forEach((e,t)=>{Jn(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,r.push(`$.evidence[${t}].sample`))}),r}function Zn(e,t={}){try{return Qn(e,t)}catch{const t=sr(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function Qn(e,t){if(!Jn(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};const r=An(e),a=[.../* @__PURE__ */new Set([...r.excludedPaths,...sr(e)])].sort(),o=r.value,n=Xn(o,t.excludeEvidenceSamples),i=n.length?["Bounded evidence samples were excluded by the transfer policy."]:[],s=o?.contractVersion;if("string"!=typeof s||!s)return{contract:o,transfer:{status:"invalid",omittedPaths:[...a,...n],warnings:["Artifact contract is missing a string contractVersion.",...i]}};if(s!==Ql)return{contract:o,transfer:{status:a.length>0?"invalid":"unsupported-version",omittedPaths:[...a,...n],warnings:[`Contract version ${s} is not interpreted by this runtime.`,...a.length>0?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...i]}};const c=Yn(o),l=[...c.errors.map(({path:e,message:t})=>`${e}: ${t}`),...c.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...a.length?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...i];return{contract:o,transfer:{status:!c.valid||a.length>0?"invalid":n.length>0?"excluded":"preserved",omittedPaths:[...a,...n],warnings:l}}}function ei(e){const t=Zn(e);if(!t.contract||"preserved"!==t.transfer.status)throw new TypeError(t.transfer.warnings.join(" ")||"Artifact contract could not be serialized without loss.");return t}function ti(e){const t=Object.entries(e).filter(([e,t])=>pn(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function ri(e,t=[]){if(void 0===e)return;const r=t.filter(e=>!!e.transformation).map(({id:e,transformation:t})=>({evidenceId:e,transformation:t})).sort(({evidenceId:e},{evidenceId:t})=>t>e?-1:e>t?1:0);return xn(r.length>0?{data:e,transformations:r}:e).fingerprint}function ai(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!pn(e,t)&&"recipeId"!==e))}function oi(e,t,r,a=ti(t)){const o=ai(t),n=0===sr(o).length?xn(o).fingerprint:void 0,i=void 0!==a&&0===sr(a).length?ri(a,e.evidence):void 0,s="ChartRecipe"===r&&"string"==typeof t.recipeId?t.recipeId:r,c=[],l=[];return void 0!==s&&(void 0===e.artifact.component?l.push("artifact.component"):e.artifact.component!==s&&c.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===n?l.push("artifact.configFingerprint"):e.artifact.configFingerprint!==n&&c.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&i?e.artifact.dataFingerprint!==i&&c.push("artifact.dataFingerprint"):l.push("artifact.dataFingerprint"),{status:c.length>0?"mismatch":l.length>0?"unknown":"match",mismatchPaths:c,unknownPaths:l}}function ni(e,t,r){const a=oi(e,t,r);return{mismatchPaths:[...a.mismatchPaths,...void 0!==r&&a.unknownPaths.includes("artifact.component")?["artifact.component"]:[]]}}function ii(e,t){return[.../* @__PURE__ */new Set([...Object.keys(e),...Object.keys(t)])].filter(r=>{if(Object.prototype.hasOwnProperty.call(e,r)!==Object.prototype.hasOwnProperty.call(t,r))return!0;const a=xn(e[r]),o=xn(t[r]);return a.excludedPaths.length>0||a.fingerprint!==o.fingerprint}).map(e=>"props."+e).sort()}function si(e){if(e.startsWith("props."))return e.slice(6).split(/[.[\]]/,1)[0]}function ci(e,t){const r=t.map(si).filter(e=>void 0!==e);return"artifact.dataFingerprint"===e?r.some(e=>Yl.has(e)):"artifact.configFingerprint"===e&&r.some(e=>!Yl.has(e))}function li(e){if(!e||"object"!=typeof e)return!1;const t=e,r=t.serializedDataFingerprint;return"string"==typeof t.status&&iu.has(t.status)&&Array.isArray(t.omittedPaths)&&t.omittedPaths.every(e=>"string"==typeof e)&&Array.isArray(t.warnings)&&t.warnings.every(e=>"string"==typeof e)&&(void 0===t.serializedConfigFingerprint||"string"==typeof t.serializedConfigFingerprint)&&(null==r||"string"==typeof r)&&(void 0===t.transferFingerprint||"string"==typeof t.transferFingerprint)}function ui(e,t,r,a){return xn({component:t,version:a.version,createdAt:a.createdAt,...void 0!==a.recipeId?{recipeId:a.recipeId}:{},...void 0!==a.portable?{portable:a.portable}:{},...void 0!==a.manifest?{manifest:a.manifest}:{},...void 0!==a.reason?{reason:a.reason}:{},...void 0!==a.warnings?{warnings:a.warnings}:{},...void 0!==a.selections?{selections:a.selections}:{},artifactContract:r,status:e.status,omittedPaths:e.omittedPaths,warnings:e.warnings,...void 0!==e.serializedConfigFingerprint?{serializedConfigFingerprint:e.serializedConfigFingerprint}:{},...Object.prototype.hasOwnProperty.call(e,"serializedDataFingerprint")?{serializedDataFingerprint:e.serializedDataFingerprint}:{}}).fingerprint}function di(e,t,r,a,o){const n=ti(r),i={...e,serializedConfigFingerprint:xn(ai(r)).fingerprint,serializedDataFingerprint:void 0===n?null:xn(n).fingerprint};return{...i,transferFingerprint:ui(i,t,a,o)}}function hi(e,t){const r=[],a=xn(ai(t.props)).fingerprint,o=ti(t.props),n=void 0===o?null:xn(o).fingerprint;return void 0!==e.transferFingerprint&&e.transferFingerprint!==ui(e,t.component,t.artifactContract,t)&&r.push("artifactTransfer.transferFingerprint"),void 0!==e.serializedConfigFingerprint&&e.serializedConfigFingerprint!==a&&r.push("artifactTransfer.serializedConfigFingerprint"),Object.prototype.hasOwnProperty.call(e,"serializedDataFingerprint")&&e.serializedDataFingerprint!==n&&r.push("artifactTransfer.serializedDataFingerprint"),r}function pi(e,t){if("artifactContract"===t||"$.artifactContract"===t)return void 0!==e.artifactContract;let r,a;if("props"===t||t.startsWith("props.")?(r=e,a=t):(r=e.artifactContract,a=t.startsWith("$.")?t.slice(2):t),"$"===a||""===a)return void 0!==r;const o=[...a.matchAll(/(?:^|\.)([^.[\]]+)|\[(\d+)\]/g)].map(e=>e[1]??Number(e[2]));if(0===o.length)return!1;for(const e of o){if(null===r||"object"!=typeof r||!Object.prototype.hasOwnProperty.call(r,e))return!1;r=r[e]}return!0}function fi(e,t,r,a,o){if(!t)return{};const n=ei(t),i=o.recipeId??e,s=ni(t,r,i),c=ii(r,a),l=ni(t,a,i);return s.mismatchPaths.length>0?{artifactContract:n.contract,artifactTransfer:di({status:"invalid",omittedPaths:s.mismatchPaths,warnings:["The artifact contract fingerprints do not match the supplied chart props or data."]},e,a,n.contract,o)}:c.length>0?{artifactContract:n.contract,artifactTransfer:di({status:"excluded",omittedPaths:c,warnings:["Chart props or data were excluded from the serialized configuration."]},e,a,n.contract,o)}:l.mismatchPaths.length>0?{artifactContract:n.contract,artifactTransfer:di({status:"invalid",omittedPaths:l.mismatchPaths,warnings:["Serialized chart props or data differ from the values bound to the artifact contract."]},e,a,n.contract,o)}:{artifactContract:n.contract,artifactTransfer:di(n.transfer,e,a,n.contract,o)}}function mi(e){if(!e.artifactContract){if(!e.artifactTransfer)return{};if(li(e.artifactTransfer)&&"excluded"===e.artifactTransfer.status&&e.artifactTransfer.omittedPaths.includes("artifactContract")){const t=e.artifactTransfer.omittedPaths.filter(t=>"artifactContract"!==t&&pi(e,t));return 0===t.length?{artifactTransfer:su(e.artifactTransfer)}:{artifactTransfer:{status:"invalid",omittedPaths:[...e.artifactTransfer.omittedPaths],warnings:[`The declared omitted path is still present: ${t.join(", ")}.`]}}}return{artifactTransfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["An artifact transfer report cannot claim preservation without an artifact contract."]}}}const t=Zn(e.artifactContract),r=e.artifactTransfer,a=t.transfer;let o=(()=>{if(!r)return{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...a.omittedPaths,"artifactTransfer"])],warnings:[...a.warnings,"The artifact contract has no transfer report, so its transport history cannot be verified."]};if(!li(r))return{status:"invalid",omittedPaths:a.omittedPaths,warnings:[...a.warnings,"The declared artifact transfer report is malformed."]};const t="excluded"===r.status||"unsupported-version"===r.status?r.omittedPaths.filter(t=>pi(e,t)):[];return t.length>0?{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...r.omittedPaths,...a.omittedPaths])],warnings:[...a.warnings,`The declared omitted path is still present: ${t.join(", ")}.`]}:"preserved"===r.status&&r.omittedPaths.length>0||"excluded"===r.status&&0===r.omittedPaths.length?{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...r.omittedPaths,...a.omittedPaths])],warnings:[...a.warnings,"The declared artifact transfer status contradicts its omitted paths."]}:r.status===a.status?su(r):"preserved"!==a.status||"excluded"!==r.status&&"invalid"!==r.status||0>=r.omittedPaths.length?{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...r.omittedPaths,...a.omittedPaths])],warnings:[.../* @__PURE__ */new Set([...r.warnings,...a.warnings,`Declared artifact transfer status ${r.status} does not match the restored contract status ${a.status}.`])]}:su(r)})();if(r&&li(r)){const t=hi(r,e),a="invalid"!==r.status,n=[...a&&void 0===r.serializedConfigFingerprint?["artifactTransfer.serializedConfigFingerprint"]:[],...a&&!Object.prototype.hasOwnProperty.call(r,"serializedDataFingerprint")?["artifactTransfer.serializedDataFingerprint"]:[],...a&&void 0===r.transferFingerprint?["artifactTransfer.transferFingerprint"]:[]];(t.length>0||n.length>0)&&(o={status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...o.omittedPaths,...t,...n])],warnings:[.../* @__PURE__ */new Set([...o.warnings,t.length>0?"The serialized chart payload no longer matches its transfer fingerprints.":"The declared chart transfer cannot be verified without serialized transfer fingerprints."])]})}if("preserved"===t.transfer.status&&t.contract?.contractVersion===Ql){const r=ni(t.contract,e.props,e.recipeId??e.component).mismatchPaths.filter(e=>!ci(e,o.omittedPaths));r.length>0&&(o={status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...o.omittedPaths,...r])],warnings:[.../* @__PURE__ */new Set([...o.warnings,"Restored chart props or data do not match the artifact contract fingerprints."])]})}return{...t.contract?{artifactContract:t.contract}:{},artifactTransfer:o}}function gi(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function yi(e,t){return!!pn(e,t)&&("areas"!==e||"string"!=typeof t)}function bi(e,t,r){if(r?.selections&&sr(r.selections).length>0)throw new TypeError("Serialized selection state must contain only values that survive JSON serialization unchanged.");const a=lr(e)??hr(t.recipe)??hr(t.recipeId);if(a)return wi(a,t,r);if(!he(e))throw Error(`Unknown component "${e}". Known components: ${oc.join(", ")}`);const o=!1!==r?.includeData,n={};for(const[e,r]of Object.entries(t))if(null!=r&&!lu.has(e)&&(o||!yi(e,r))&&"function"!=typeof r&&0>=sr(r).length)try{gi(n,e,uu(r))}catch{}const i=/* @__PURE__ */(new Date).toISOString(),s={version:cu,createdAt:i,...r?.selections?{selections:r.selections}:{}};return{component:e,props:n,version:cu,createdAt:i,...fi(e,r?.artifactContract,t,n,s),...r?.selections?{selections:r.selections}:{}}}function vi(e,t,r){const a={};for(const[o,n]of Object.entries(e))if(null!=n&&!lu.has(o)&&"recipeId"!==o&&(t||!yi(o,n)))if("function"!=typeof n)if(sr(n).length>0){if(r)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`)}else gi(a,o,uu(n));else if(r)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`);return a}function wi(e,t,r){const a=!1!==r?.includeData,o=sr(e);if("portable"===e.portability&&o.length>0)throw Error(`Portable recipe "${e.id}" has non-JSON definition values at: ${o.join(", ")}.`);const n=vi(t,a,"portable"===e.portability),i=e.intents.map(ma).filter(e=>!!e),s=e.layout&&"object"==typeof e.layout&&"string"==typeof e.layout.id?e.layout.id:void 0,c=s?dr(s):void 0,l=e.layout&&"object"==typeof e.layout&&"string"==typeof e.layout.version&&e.layout.version?{version:e.layout.version,...e.layout.fingerprint?{fingerprint:e.layout.fingerprint}:{}}:void 0;if(c&&l&&(c.version!==l.version||c.fingerprint!==l.fingerprint))throw Error(`Recipe layout "${s}" registry identity does not match its portable declaration.`);const u=c??l;if("portable"===e.portability&&s&&!u)throw Error(`Portable recipe layout "${s}" must be registered with an explicit version identity.`);const d={name:e.name,intents:i,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily,...e.version?{recipeVersion:e.version}:{},...0===o.length?{definitionFingerprint:xn(e).fingerprint}:{},...s?{layoutId:s}:{},...u?{layoutVersion:u.version}:{},...u?.fingerprint?{layoutFingerprint:u.fingerprint}:{}},h=/* @__PURE__ */(new Date).toISOString();if("portable"===e.portability){if(sr(n).length>0)throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);const a={version:cu,createdAt:h,recipeId:e.id,portable:!0,manifest:d,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:n,manifest:d,version:cu,createdAt:h,...fi("ChartRecipe",r?.artifactContract,t,n,a),...r?.selections?{selections:r.selections}:{}}}const p="Recipe contains or may depend on non-serializable local layout callbacks.",f=["This config is inspectable but cannot be rendered remotely by CLI or MCP."],m={version:cu,createdAt:h,recipeId:e.id,portable:!1,manifest:d,reason:p,warnings:f,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:p,warnings:f,props:n,manifest:d,version:cu,createdAt:h,...fi("ChartRecipe",r?.artifactContract,t,n,m),...r?.selections?{selections:r.selections}:{}}}function Ai(e){try{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}catch{return!1}}function xi(e){if(!Ai(e))throw Error("Invalid chart config: expected a plain object");const t=sr(e);if(t.length>0)throw new TypeError(`Chart config contains values that cannot survive JSON serialization at: ${t.join(", ")}.`);if(e.version!==cu)throw Error(`Unsupported chart config version ${e.version+""}; expected ${cu}.`);if("string"!=typeof e.component||!e.component.trim())throw Error("Invalid chart config: missing component");if(!Ai(e.props))throw Error("Invalid chart config: props must be a plain object");if("string"!=typeof e.createdAt||!Number.isFinite(Date.parse(e.createdAt)))throw Error("Invalid chart config: createdAt must be a valid timestamp");if(void 0!==e.recipeId&&("string"!=typeof e.recipeId||!e.recipeId.trim()))throw Error("Invalid chart config: recipeId must be a non-empty string");if(void 0!==e.portable&&"boolean"!=typeof e.portable)throw Error("Invalid chart config: portable must be a boolean");if(void 0!==e.selections&&!Ai(e.selections))throw Error("Invalid chart config: selections must be a plain object");if(void 0!==e.manifest){if(!Ai(e.manifest))throw Error("Invalid chart config: manifest must be a plain object");if("string"!=typeof e.manifest.name||!e.manifest.name.trim()||"string"!=typeof e.manifest.frameFamily||!e.manifest.frameFamily.trim()||!Array.isArray(e.manifest.intents)||e.manifest.intents.some(e=>"string"!=typeof e||!e.trim())||void 0!==e.manifest.audience&&(!Array.isArray(e.manifest.audience)||e.manifest.audience.some(e=>"string"!=typeof e||!e.trim()))||void 0!==e.manifest.recipeVersion&&("string"!=typeof e.manifest.recipeVersion||!e.manifest.recipeVersion.trim())||void 0!==e.manifest.definitionFingerprint&&("string"!=typeof e.manifest.definitionFingerprint||!e.manifest.definitionFingerprint.trim())||void 0!==e.manifest.layoutId&&("string"!=typeof e.manifest.layoutId||!e.manifest.layoutId.trim())||void 0!==e.manifest.layoutVersion&&("string"!=typeof e.manifest.layoutVersion||!e.manifest.layoutVersion.trim())||void 0!==e.manifest.layoutFingerprint&&("string"!=typeof e.manifest.layoutFingerprint||!e.manifest.layoutFingerprint.trim())||void 0!==e.manifest.layoutVersion&&void 0===e.manifest.layoutId||void 0!==e.manifest.layoutFingerprint&&void 0===e.manifest.layoutVersion)throw Error("Invalid chart config: malformed recipe manifest")}}function $i(e){if(xi(e),"ChartRecipe"===e.component||"LocalChartRecipe"===e.component){if(!e.recipeId)throw Error("Invalid chart recipe config: missing recipeId");const t=lr(e.recipeId);if(!t)throw Error(`Unknown chart recipe "${e.recipeId}". Register it before deserializing this config.`);if(e.manifest?.definitionFingerprint&&e.manifest.definitionFingerprint!==xn(t).fingerprint)throw Error(`Chart recipe "${e.recipeId}" no longer matches the serialized definition.`);if(void 0!==e.manifest?.recipeVersion&&e.manifest.recipeVersion!==t.version)throw Error(`Chart recipe "${e.recipeId}" version does not match the serialized config.`);if(e.manifest?.layoutVersion){const r=e.manifest.layoutId,a=r?ur(r):void 0,o=r?dr(r):void 0,n=a?o:o??(t.layout&&"object"==typeof t.layout&&t.layout.id===r&&t.layout.version?{version:t.layout.version,fingerprint:t.layout.fingerprint}:void 0);if(!n||n.version!==e.manifest.layoutVersion||n.fingerprint!==e.manifest.layoutFingerprint)throw Error(`Chart recipe "${e.recipeId}" layout implementation no longer matches the serialized 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:{...uu(e.props),recipeId:e.recipeId},...mi(e)}}if(!he(e.component))throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:uu(e.props),...mi(e)}}function Ci(e,t={}){xi(e);const r=JSON.stringify(e),a="sc="+btoa(unescape(encodeURIComponent(r))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");if(void 0!==t.maxLength&&a.length>Math.max(0,Math.floor(t.maxLength)))throw new RangeError(`Serialized chart config is ${a.length} characters; the declared URL limit is ${t.maxLength}. Use a file or sidecar export instead.`);return a}function Si(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))),o=JSON.parse(a);return xi(o),o}async function ki(e,t="json"){const r="jsx"===t?Ri(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 Ri(e){xi(e);const{props:t}=e,r="LocalChartRecipe"===e.component?"ChartRecipe":e.component;if("ChartRecipe"!==r&&!he(r))throw Error(`Cannot project unknown component "${r}" to JSX.`);const a=["<"+r];e.recipeId&&a.push(` recipeId={${Ii(e.recipeId)}}`);for(const[e,r]of Object.entries(t)){if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)){const t={};Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),a.push(` {...${Ii(t)}}`);continue}if("string"==typeof r)a.push(Pi(r)?` ${e}="${r}"`:` ${e}={${Ii(r)}}`);else if("boolean"==typeof r&&!0===r)a.push(" "+e);else if("boolean"==typeof r&&!1===r)a.push(` ${e}={false}`);else if("number"==typeof r)a.push(` ${e}={${r}}`);else{const t=Ii(r);a.push(80>t.length?` ${e}={${t}}`:` ${e}={${Ii(r,2)}}`)}}return a.push("/>"),a.join("\n")}function Pi(e){return!/["&<>{}\r\n\u2028\u2029]/.test(e)}function Ii(e,t){return JSON.stringify(e,null,t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Ei(e){const t=[...e.artifactContract?["artifactContract"]:[],...e.artifactTransfer?["artifactTransfer"]:[],...e.selections?["selections"]:[]];return{jsx:Ri(e),omittedPaths:t,warnings:t.length?["JSX represents the chart props only. Preserve the reported top-level fields as a separate artifact packet."]:[]}}function Ni(e){const t=/* @__PURE__ */Object.create(null);for(const[r,a]of e){const e=[];for(const[,t]of a.clauses){const r=/* @__PURE__ */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 Ti(e){const t=/* @__PURE__ */new Map;for(const[r,a]of Object.entries(e)){const e=/* @__PURE__ */new Map;for(const t of a.clauses){const r=/* @__PURE__ */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}async function Mi(e,t){const{format:r="png",filename:a="chart",scale:o=2,background:n="white"}=t||{},i=e.querySelector('svg[role="img"]')||e.querySelector("svg");if(!i)throw Error("No SVG element found in the container");const s=i.cloneNode(!0),c=i.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",c.width+""),s.getAttribute("height")||s.setAttribute("height",c.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),Oi(i,s),"svg"===r){const e=(new XMLSerializer).serializeToString(s);Fi(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),a+".svg")}else{const t=c.width*o,r=c.height*o,i=document.createElement("canvas");i.width=t,i.height=r;const l=i.getContext("2d");l.fillStyle=n,l.fillRect(0,0,t,r),l.scale(o,o);const u=e.querySelector("canvas");u&&l.drawImage(u,0,0,c.width,c.height);const d=(new XMLSerializer).serializeToString(s),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),p=URL.createObjectURL(h),f=new Image;f.width=c.width,f.height=c.height,await new Promise((e,t)=>{f.onload=()=>{l.drawImage(f,0,0),i.toBlob(r=>{r?(Fi(r,a+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(p)},f.onerror=()=>{URL.revokeObjectURL(p),t(Error("Failed to load SVG image"))},f.src=p})}}function Oi(e,t){const r=e.children,a=t.children,o=window.getComputedStyle(e),n=["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 n){const r=o.getPropertyValue(e);r&&"none"!==r&&""!==r&&t.style?.setProperty(e,r)}for(let e=0;Math.min(r.length,a.length)>e;e++)Oi(r[e],a[e])}function Fi(e,t){const r=URL.createObjectURL(e),a=document.createElement("a");a.href=r,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}function ji(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[r,a]of Object.entries(e))r.startsWith("_")||null!=a&&""!==a&&("number"==typeof a?Number.isFinite(a)&&(t[r]=a):"string"==typeof a?t[r]=a:"boolean"==typeof a?t[r]=a+"":a instanceof Date&&(t[r]=a.toISOString().slice(0,10)));return t}function zi(e){return e&&"object"==typeof e?e:{}}function Bi(e){return zi(e.accessibility).tableFields??e.accessibleDatum??e.datum}function Li(e){const t=[];if(!Array.isArray(e))return t;const r=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const a of e)if(a&&"object"==typeof a&&null!==a.datum)try{switch(a.type){case"point":if(r)break;t.push({label:"Point",values:ji(Bi(a))});break;case"line":case"area":{const e=Bi(a),r=Array.isArray(e)?e:[],o="line"===a.type?"Line point":"Area point";for(const e of r)t.push({label:o,values:ji(e)});break}case"rect":{const e=Bi(a),r=null!=e&&"object"==typeof e?e:{},o=r.category??a.group??"",n=r.value??r.__aggregateValue??r.total,i=ji(r);null==i.category&&""!==o&&(i.category=o+""),null==i.value&&null!=n&&(i.value="number"==typeof n||"string"==typeof n?n:n+""),t.push({label:"Bar",values:i});break}case"heatcell":{const e=ji(Bi(a));null==e.value&&"number"==typeof a.value&&Number.isFinite(a.value)&&(e.value=a.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Bi(a),r=ji(e);if(null==r.category){const t=zi(e),a=t.category??t.label;null!=a&&(r.category=a+"")}t.push({label:"Wedge",values:r});break}case"circle":t.push({label:"Node",values:ji(Bi(a))});break;case"arc":t.push({label:"Arc",values:ji(Bi(a))});break;case"candlestick":t.push({label:"Candlestick",values:ji(Bi(a))});break;case"geoarea":{const e=zi(Bi(a)),r=ji(e);if(null==r.name){const t=zi(e.properties).name??e.name;null!=t&&(r.name=t+"")}t.push({label:"Region",values:r});break}}}catch{}return t}function _i(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}function Di(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function Ui(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function Vi(e){return"number"==typeof e&&Number.isFinite(e)}function Gi(e){if(Vi(e.x)&&Vi(e.y)&&Vi(e.w)&&Vi(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(Vi(e.x)&&Vi(e.y)&&Vi(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(Vi(e.cx)&&Vi(e.cy)&&Vi(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(Vi(e.cx)&&Vi(e.cy)&&Vi(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&Vi(e[0])&&Vi(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function qi(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}function Hi(e,t){const r=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),a=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return a>0?r/a:0}function Wi(e,t,r,a,o){if(e===t)return!0;const n=r.dataRoles.map(e=>va(e,a,o)).filter(e=>!!e).filter(r=>null!=e[r]&&null!=t[r]);return n.length>0&&n.every(r=>e[r]+""==t[r]+"")}function Yi(e,t,r,a,o,n="warn",i){return{id:e,category:t,status:r?"pass":n,message:r?a:o,...i?{evidence:i}:{}}}function Ki(e){const{recipe:t}=e,r=_i(e.scene),a=e.layoutConfig??ga({layoutConfig:e.layoutConfig}),o=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},n=o.x??0,i=o.y??0,s=[],c=r.filter(e=>null!=Ui(e)),l=r.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||qi(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));s.push(Yi("geometry.finite","geometry",0===l.length,"All emitted geometry is finite.",l.length+" marks contain non-finite geometry.","fail",{count:l.length}));const u=r.map(Gi),d=u.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;s.push(Yi("geometry.nonzero-area","geometry",0===d,"All bounded marks have positive area.",d+" marks have zero or negative area.","warn",{count:d}));const h=u.filter(e=>e&&(n>e.x0||i>e.y0||e.x1>n+o.width||e.y1>i+o.height)).length;s.push(Yi("geometry.bounds","geometry",0===h,"All bounded marks stay inside the plot.",h+" marks extend outside the plot bounds.","warn",{count:h}));const p=t.audit?.minimumHitTargetSize??t.accessibility.minimumHitTarget??24,m=u.filter(e=>!!e&&(p>e.x1-e.x0||p>e.y1-e.y0)).length;s.push(Yi("interaction.target-size","interaction",0===m,`All bounded targets meet the declared ${p}px minimum.`,`${m} targets are smaller than ${p}px in at least one dimension.`,"warn",{count:m,minimumTarget:p}));const g=c.map(Di),y=g.filter(e=>!e).length,b=/* @__PURE__ */new Set,v=g.filter(e=>!(!e||!b.has(e)&&(b.add(e),1)));s.push(Yi("identity.stable-ids","identity",0===y,"Every data-bearing mark exposes a stable id.",y+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:y})),s.push(Yi("identity.unique-ids","identity",0===v.length,"Stable mark ids are unique.",v.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set(v)].slice(0,10)}));const w=g.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;w>0&&s.push({id:"identity.index-pattern",category:"identity",status:"warn",message:w+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const A=/* @__PURE__ */new Set;let x=0;const $=e.inputData;for(const e of c){const r=Ui(e),o=Array.isArray(r)?r:[r];let n=!1;for(const e of o)if(e&&"object"==typeof e)for(let r=0;$.length>r;r+=1)Wi(e,$[r],t,a,$)&&(A.add(r),n=!0);n||(x+=1)}const C=Math.max(0,$.length-A.size);s.push(Yi("coverage.input-data","coverage",0===C,"Every input datum is represented by the observed scene.",C+" input data items have no matching scene mark.",t.audit?.requireDatumCoverage?"fail":"warn",{represented:A.size,input:$.length})),s.push(Yi("coverage.scene-data","coverage",0===x,"Every data-bearing scene mark maps back to input data.",x+" scene marks do not map back to an input datum.","warn",{count:x}));const S=t.encodings?.some(e=>"count"===e.channel);!S&&c.length>A.size&&A.size>0&&s.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const k=c.filter(e=>!1===e.interactive).length;s.push(Yi("interaction.hit-targets","interaction",0===k&&c.length>0,"Every observed data-bearing scene node participates in hit testing.",0===c.length?"No data-bearing scene nodes were emitted for interaction.":k+" data-bearing marks explicitly disable interaction.","fail"));const R=(e.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),P=R.filter(e=>!b.has(e));s.push(Yi("coverage.annotation-anchors","coverage",0===P.length,R.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",P.length+" annotations point to missing scene ids.","fail",{unresolved:P}));const I=(e.chart?.selectedIds??[]).filter(e=>!b.has(e));e.chart?.selectedIds&&s.push(Yi("interaction.selection-reachability","interaction",0===I.length,"Selected/highlighted states resolve to observed marks.",I.length+" selected ids are not reachable in the scene.","fail",{missing:I}));const E=Li(r),N=(t.accessibility.tableFields??t.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const r=e.role?t.dataRoles.find(t=>t.role===e.role):void 0;return r?va(r,a,$):void 0}).filter(e=>!!e),T=new Set(E.flatMap(e=>Object.keys(e.values))),M=N.filter(e=>!T.has(e));s.push(Yi("accessibility.table-fields","accessibility",0===M.length,N.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${M.join(", ")}.`,"fail",{expectedFields:N,observedFields:[...T]})),new Set($.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=T.size&&[...T].every(e=>"category"===e||"value"===e)&&s.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const O=(t.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);s.push(Yi("accessibility.color-only","accessibility",0===O.length,"Every declared color encoding names a redundant cue.",O.length+" color encodings have no declared redundant cue.","warn"));const F=e.chart;if(F){for(const[e,r]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])r&&s.push(Yi("accessibility."+e,"accessibility","string"==typeof F[e]&&F[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(t.accessibility.requiresAccessibleTable||"required"===t.accessibility.accessibleTable||t.accessibility.fallbackTable)&&s.push(Yi("accessibility.fallback-table","accessibility",!1!==F.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),F.navigationTree&&s.push(Yi("accessibility.navigation-depth","accessibility",(F.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const j=e.theme?.background??"#ffffff",z=r.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!j.startsWith("#"))return!1;const r=f(t,j);return null!=r&&3>r}).length;s.push(Yi("visual.contrast","visual",0===z,"All statically checkable mark fills meet 3:1 contrast.",z+" marks have fill contrast below 3:1.","warn",{background:j}));let B=0;const L=u.filter(e=>!!e).slice(0,500);for(let e=0;L.length>e;e+=1)for(let t=e+1;L.length>t;t+=1).8>Hi(L[e],L[t])||(B+=1);B>L.length&&s.push({id:"visual.overlap-density",category:"visual",status:"warn",message:B+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const _=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),D={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map(ma).filter(e=>!!e),accessibilityExpectations:[...t.accessibility.requirements??[],...t.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===t.accessibility.fallbackTable||"required"===t.accessibility.accessibleTable||!0===t.accessibility.requiresAccessibleTable,designContractDeclared:!!t.designContract?.whyCustom},U=[...s,..._],V=s.filter(e=>"fail"===e.status).length;return{recipeId:t.id,ok:0===V,summary:{marks:r.length,passes:U.filter(e=>"pass"===e.status).length,warnings:U.filter(e=>"warn"===e.status).length,failures:V,manual:U.filter(e=>"manual"===e.status).length},declaredSemantics:D,observedSceneEvidence:s,manualATChecks:_}}function Ji(e){let t=1/0,r=-1/0;for(const a of e)t>a&&(t=a),a>r&&(r=a);return[t,r]}function Xi(e,t){const{groupBy:r,value:a,agg:o="sum"}=t,n=/* @__PURE__ */new Map,i="min"===o?1/0:"max"===o?-1/0:0;for(const t of e){const e=t[r]+"";let s=n.get(e);s||(s={total:i,count:0},n.set(e,s));const c=Number(t[a]);switch(s.count++,o){case"count":break;case"min":s.total>c&&(s.total=c);break;case"max":c>s.total&&(s.total=c);break;default:s.total+=c}}const s=[];for(const[e,t]of n){const a="count"===o?t.count:"mean"===o?t.total/t.count:t.total;s.push({[r]:e,value:a})}return s}function Zi(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 Qi(e){if(e)return"string"==typeof e?e:e.text}function es(e){return"nominal"===e||"ordinal"===e}function ts(e){return"quantitative"===e||"temporal"===e}function rs(e){return e.usermeta?.idid}function as(e){return"annotation-layer"===e.usermeta?.idid?.role}function os(e){if(!rs(e)||!Array.isArray(e.layer))return e;const t=e.layer.filter(e=>!as(e));if(1!==t.length)return e;const{layer:r,...a}=e,{usermeta:o,...n}=t[0];return{...a,...n}}function ns(e){e=os(e);const t=[],{type:r,markProps:a}=Zi(e.mark),o=e.encoding||{},n=o.x,i=o.y,s=o.color,c=o.size,l=o.theta,u=o.opacity;let d;e.data?.values?d=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 h={};e.width&&(h.width=e.width),e.height&&(h.height=e.height);const p=Qi(e.title);if(p&&(h.title=p),s?.field&&(h.colorBy=s.field,s.scale?.scheme)){const e=du[s.scale.scheme];e&&(h.colorScheme=e)}void 0!==u?.value&&(h.pointOpacity=u.value);const f=n?.aggregate,m=i?.aggregate;if(d&&(f||m)){const e=m?i:n,t=m?n:i,r=pu[e.aggregate];if(r&&t?.field&&e.field)d=Xi(d,{groupBy:t.field,value:e.field,agg:r});else if(("count"===r||"count"===e.aggregate)&&t?.field&&d){const e=/* @__PURE__ */new Map;for(const r of d){const a=r[t.field]+"";e.set(a,(e.get(a)||0)+1)}d=Array.from(e,([e,r])=>({[t.field]:e,value:r}))}}if(n?.bin||i?.bin){const e="Histogram";d&&(h.data=d),n?.bin?(h.valueAccessor=n.field,i?.field&&(h.categoryAccessor=i.field),n.axis?.title&&(h.valueLabel=n.axis.title)):i?.bin&&(h.valueAccessor=i.field,n?.field&&(h.categoryAccessor=n.field),i.axis?.title&&(h.valueLabel=i.axis.title));const r=n?.bin||i?.bin,a="object"==typeof r?r.maxbins:void 0;return a&&(h.bins=a),cs(e,h,t)}let g;switch(r){case"bar":g=is(n,i,s,h,d,f,m);break;case"line":if(g="LineChart",ss(n,i,h,f,m),s?.field&&(h.lineBy=s.field),a.interpolate){const e=hu[a.interpolate];e&&(h.curve=e)}!0===a.point&&(h.showPoints=!0),d&&(h.data=d);break;case"area":if(s?.field?(g="StackedAreaChart",h.areaBy=s.field):g="AreaChart",ss(n,i,h,f,m),a.interpolate){const e=hu[a.interpolate];e&&(h.curve=e)}void 0!==a.opacity&&(h.areaOpacity=a.opacity),d&&(h.data=d);break;case"point":case"circle":case"square":c?.field?(g="BubbleChart",h.sizeBy=c.field,c.scale?.range&&(h.sizeRange=c.scale.range)):g="Scatterplot",ss(n,i,h,f,m),d&&(h.data=d);break;case"rect":g="Heatmap",n?.field&&(h.xAccessor=n.field),i?.field&&(h.yAccessor=i.field),s?.field&&(h.valueAccessor=s.field,delete h.colorBy),n?.axis?.title&&(h.xLabel=n.axis.title),i?.axis?.title&&(h.yLabel=i.axis.title),d&&(h.data=d);break;case"arc":a.innerRadius&&a.innerRadius>0?(g="DonutChart",h.innerRadius=a.innerRadius):g="PieChart",l?.field?h.valueAccessor=l.field:i?.field&&(h.valueAccessor=m?"value":i.field),s?.field&&(h.categoryAccessor=s.field),n?.field&&!l?.field&&(h.categoryAccessor=n.field),d&&(h.data=d);break;case"tick":g="DotPlot",es(n?.type)?(h.categoryAccessor=n.field,i?.field&&(h.valueAccessor=m?"value":i.field),n?.axis?.title&&(h.categoryLabel=n.axis.title),i?.axis?.title&&(h.valueLabel=i.axis.title)):es(i?.type)?(h.categoryAccessor=i.field,n?.field&&(h.valueAccessor=f?"value":n.field),h.orientation="horizontal",i?.axis?.title&&(h.categoryLabel=i.axis.title),n?.axis?.title&&(h.valueLabel=n.axis.title)):(n?.field&&(h.categoryAccessor=n.field),i?.field&&(h.valueAccessor=m?"value":i.field)),d&&(h.data=d);break;default:t.push(`Unsupported mark type "${r}". Defaulting to Scatterplot.`),g="Scatterplot",ss(n,i,h,f,m),d&&(h.data=d)}return cs(g,h,t)}function is(e,t,r,a,o,n,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",es(e?.type)&&ts(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)):ts(e?.type)&&es(t?.type)?(a.categoryAccessor=t.field,a.valueAccessor=n?"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)),o&&(a.data=o),s}function ss(e,t,r,a,o){e?.field&&(r.xAccessor=a?"value":e.field),t?.field&&(r.yAccessor=o?"value":t.field),e?.axis?.title&&(r.xLabel=e.axis.title),t?.axis?.title&&(r.yLabel=t.axis.title)}function cs(e,t,r){const a={component:e,props:t,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString()};if(r.length>0){a.warnings=r;for(const e of r)console.warn("[semiotic/fromVegaLite] "+e)}return a}function ls(e,t){for(const r of t){const t=e.find(e=>e.lower===r);if(t)return t}}function us(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const r=t.maxEntries??6,a=!1!==t.skipPositional,o=[];for(const[t,r]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;const e=t.toLowerCase();if(a&&vu.has(e))continue;if(null==r)continue;const n=typeof r;("string"===n||"number"===n||"boolean"===n||r instanceof Date)&&o.push({key:t,lower:e,value:r})}if(0===o.length)return{entries:[]};let n=o.findIndex(e=>gu.includes(e.lower));const i=n>=0;0>n&&(n=o.findIndex(e=>"id"===e.lower)),0>n&&(n=o.findIndex(e=>"string"==typeof e.value));const s=0>n?void 0:o[n],c=o.filter((e,t)=>t!==n&&(!i||"id"!==e.lower)),l=ls(c,yu),u=ls(c,bu),d=[];l&&d.push({key:l.key,value:l.value}),u&&d.push({key:u.key,value:u.value});for(const e of c){if(d.length>=r)break;yu.includes(e.lower)||bu.includes(e.lower)||d.push({key:e.key,value:e.value})}return{titleKey:s?.key,title:s?.value,entries:d}}function ds({chrome:e="default",className:t="",style:r,children:a,...o}){const n="default"===e?{...xu,...r}:r;/* @__PURE__ */ /* @__PURE__ */
1
+ function e(e){return Object.prototype.hasOwnProperty.call(Gs,e)?Gs[e]:void 0}function t(e){const t={"--semiotic-bg":e.colors.background,"--semiotic-text":e.colors.text,"--semiotic-text-secondary":e.colors.textSecondary,"--semiotic-grid":e.colors.grid,"--semiotic-border":e.colors.border,"--semiotic-cell-border":e.colors.cellBorder||e.colors.border,"--semiotic-primary":e.colors.primary,"--semiotic-font-family":e.typography.fontFamily,"--semiotic-secondary":e.colors.secondary||e.colors.primary,"--semiotic-surface":e.colors.surface||e.colors.background};e.colors.categorical.forEach((e,r)=>{t["--semiotic-category-"+(r+1)]=e}),e.colors.focus&&(t["--semiotic-focus"]=e.colors.focus),e.colors.selection&&(t["--semiotic-selection-color"]=e.colors.selection),null!=e.colors.selectionOpacity&&(t["--semiotic-selection-opacity"]=e.colors.selectionOpacity+""),e.colors.diverging&&(t["--semiotic-diverging"]=e.colors.diverging),e.colors.annotation&&(t["--semiotic-annotation-color"]=e.colors.annotation),e.colors.success&&(t["--semiotic-success"]=e.colors.success),e.colors.danger&&(t["--semiotic-danger"]=e.colors.danger),e.colors.warning&&(t["--semiotic-warning"]=e.colors.warning),e.colors.error&&(t["--semiotic-error"]=e.colors.error),e.colors.info&&(t["--semiotic-info"]=e.colors.info),e.tooltip?.background&&(t["--semiotic-tooltip-bg"]=e.tooltip.background),e.tooltip?.text&&(t["--semiotic-tooltip-text"]=e.tooltip.text),e.tooltip?.borderRadius&&(t["--semiotic-tooltip-radius"]=e.tooltip.borderRadius),e.tooltip?.fontSize&&(t["--semiotic-tooltip-font-size"]=e.tooltip.fontSize),e.tooltip?.shadow&&(t["--semiotic-tooltip-shadow"]=e.tooltip.shadow),e.borderRadius&&(t["--semiotic-border-radius"]=e.borderRadius);const r=e.typography.legendSize??e.typography.labelSize;null!=r&&(t["--semiotic-legend-font-size"]=r+"px"),null!=e.typography.legendFontFamily&&(t["--semiotic-legend-font-family"]=e.typography.legendFontFamily),null!=e.typography.legendFontWeight&&(t["--semiotic-legend-font-weight"]=e.typography.legendFontWeight+"");const a=e.typography.titleFontSize??e.typography.titleSize;return null!=a&&(t["--semiotic-title-font-size"]=a+"px"),null!=e.typography.titleFontFamily&&(t["--semiotic-title-font-family"]=e.typography.titleFontFamily),null!=e.typography.titleFontWeight&&(t["--semiotic-title-font-weight"]=e.typography.titleFontWeight+""),null!=e.typography.tickFontFamily&&(t["--semiotic-tick-font-family"]=e.typography.tickFontFamily),null!=e.typography.tickSize&&(t["--semiotic-tick-font-size"]=e.typography.tickSize+"px"),null!=e.typography.labelSize&&(t["--semiotic-axis-label-font-size"]=e.typography.labelSize+"px"),t}function r(e,r=":root"){return`${r} {\n${Object.entries(t(e)).map(([e,t])=>` ${e}: ${t};`).join("\n")}\n}`}function a(e){return{semiotic:{bg:{$value:e.colors.background,$type:"color"},text:{$value:e.colors.text,$type:"color"},"text-secondary":{$value:e.colors.textSecondary,$type:"color"},grid:{$value:e.colors.grid,$type:"color"},border:{$value:e.colors.border,$type:"color"},primary:{$value:e.colors.primary,$type:"color"},focus:{$value:e.colors.focus||e.colors.primary,$type:"color"},"font-family":{$value:e.typography.fontFamily,$type:"fontFamily"},"border-radius":{$value:e.borderRadius||"8px",$type:"dimension"},tooltip:{bg:{$value:e.tooltip?.background||e.colors.background,$type:"color"},text:{$value:e.tooltip?.text||e.colors.text,$type:"color"},radius:{$value:e.tooltip?.borderRadius||"6px",$type:"dimension"},"font-size":{$value:e.tooltip?.fontSize||"14px",$type:"dimension"},shadow:{$value:e.tooltip?.shadow||"0 2px 8px rgba(0,0,0,0.15)",$type:"shadow"}},selection:{color:{$value:e.colors.selection||e.colors.primary,$type:"color"},opacity:{$value:e.colors.selectionOpacity??.2,$type:"number"}},categorical:{$value:e.colors.categorical,$type:"color",$description:"Categorical color palette"},sequential:{$value:e.colors.sequential,$type:"string",$description:"d3-scale-chromatic sequential scheme name"},...e.aesthetics?{aesthetics:{...e.aesthetics.name?{profile:{$value:e.aesthetics.name,$type:"string"}}:{},...null!=e.aesthetics.minimumScore?{"minimum-score":{$value:e.aesthetics.minimumScore,$type:"number"}}:{},weights:Object.fromEntries(Object.entries(e.aesthetics.weights??{}).map(([e,t])=>[e,{$value:t,$type:"number"}])),thresholds:Object.fromEntries(Object.entries(e.aesthetics.thresholds??{}).map(([e,t])=>[e,{$value:t,$type:"number"}])),rationales:Object.fromEntries(Object.entries(e.aesthetics.rationales??{}).map(([e,t])=>[e,{$value:t,$type:"string"}]))}}:{},...e.colors.diverging?{diverging:{$value:e.colors.diverging,$type:"string",$description:"d3-scale-chromatic diverging scheme name"}}:{},...e.colors.annotation?{"annotation-color":{$value:e.colors.annotation,$type:"color"}}:{},...null!=e.typography.legendSize?{"legend-font-size":{$value:e.typography.legendSize+"px",$type:"dimension"}}:{},...null!=e.typography.legendFontFamily?{"legend-font-family":{$value:e.typography.legendFontFamily,$type:"fontFamily"}}:{},...null!=e.typography.legendFontWeight?{"legend-font-weight":{$value:e.typography.legendFontWeight,$type:"fontWeight"}}:{},"title-font-size":{$value:(e.typography.titleFontSize??e.typography.titleSize)+"px",$type:"dimension"},...null!=e.typography.titleFontFamily?{"title-font-family":{$value:e.typography.titleFontFamily,$type:"fontFamily"}}:{},...null!=e.typography.titleFontWeight?{"title-font-weight":{$value:e.typography.titleFontWeight,$type:"fontWeight"}}:{},...null!=e.typography.tickFontFamily?{"tick-font-family":{$value:e.typography.tickFontFamily,$type:"fontFamily"}}:{},...null!=e.typography.tickSize?{"tick-font-size":{$value:e.typography.tickSize+"px",$type:"dimension"}}:{},...null!=e.typography.labelSize?{"axis-label-font-size":{$value:e.typography.labelSize+"px",$type:"dimension"}}:{},secondary:{$value:e.colors.secondary||e.colors.primary,$type:"color"},surface:{$value:e.colors.surface||e.colors.background,$type:"color"},...e.colors.success?{success:{$value:e.colors.success,$type:"color"}}:{},...e.colors.danger?{danger:{$value:e.colors.danger,$type:"color"}}:{},...e.colors.warning?{warning:{$value:e.colors.warning,$type:"color"}}:{},...e.colors.error?{error:{$value:e.colors.error,$type:"color"}}:{},...e.colors.info?{info:{$value:e.colors.info,$type:"color"}}:{}}}}function o(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>s(t(e))}function n(e,t){const r=o(e),a=o(t);return(e,t)=>{const o=a(e);return{value:o,x:r(e),y:o,category:t}}}function i(e,t){const r=o(t??"value"),a=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=a?a(e):void 0;return{value:r(e),category:null==t?void 0:t+""}}}function s(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function c(e,t,r){const a=null!=e.axis?r[e.axis]:null!=e.field?t[e.field]:r.value;if(void 0!==e.eq&&a!==e.eq)return!1;if(void 0!==e.ne&&a===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(a))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=s(a);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,r]=e.within;if(t>o||o>r)return!1}if(void 0!==e.outside){const[t,r]=e.outside;if(o>=t&&r>=o)return!1}return!0}function l(e,t,r){const a=e.when;return void 0===a||!0===a||!1!==a&&("function"==typeof a?a(t,r):c(a,t,r))}function u(e,t,r){if(!t||0===t.length)return{};let a={};for(const o of t){if(!l(o,e,r))continue;const t="function"==typeof o.style?o.style(e,r):o.style;t&&(a={...a,...t})}return a}function d(e,t,r,a=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,n)=>{const i=a(e),s={...o(e,n)};return Object.assign(s,u(i,t,r(i,n))),s}:o}function h(e,t,r){return e&&0!==e.length?(a,o)=>{const n=u(a,e,t(a,o)),i=r?r(a,o):void 0;return i?{...n,...i}:n}:r}function p(e){let t=e.replace(/^#/,"");/^[a-f\d]{3}$/i.test(t)&&(t=t.split("").map(e=>e+e).join(""));const r=t.match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!r)return null;const[a,o,n]=[parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(a)+.7152*i(o)+.0722*i(n)}function f(e,t){const r=p(e),a=p(t);return null===r||null===a?null:(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function m(e){return Math.min(255,Math.max(0,Math.round(e)))}function g(e){if("string"!=typeof e)return null;const t=e.trim().toLowerCase(),r=t.match(/^#([a-f\d]{3,4}|[a-f\d]{6}|[a-f\d]{8})$/i)?.[1];if(r){const e=r.length>4?r:r.split("").map(e=>`${e}${e}`).join("");return{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16),a:8===e.length?Number.parseInt(e.slice(6,8),16)/255:1}}const a=t.match(/^rgba?\(\s*(-?(?:\d+|\d*\.\d+))\s*,\s*(-?(?:\d+|\d*\.\d+))\s*,\s*(-?(?:\d+|\d*\.\d+))(?:\s*,\s*(-?(?:\d+|\d*\.\d+)))?\s*\)$/);if(!a)return null;const o=[Number(a[1]),Number(a[2]),Number(a[3])],n=void 0===a[4]?1:Number(a[4]);return o.some(e=>!Number.isFinite(e)||0>e||e>255)||!Number.isFinite(n)||0>n||n>1?null:{r:o[0],g:o[1],b:o[2],a:n}}function y(e,t){return 1>t.a?null:{r:m(e.r*e.a+t.r*(1-e.a)),g:m(e.g*e.a+t.g*(1-e.a)),b:m(e.b*e.a+t.b*(1-e.a)),a:1}}function b(e){return 1>e.a?null:"#"+[e.r,e.g,e.b].map(e=>m(e).toString(16).padStart(2,"0")).join("")}function v(e){if("string"!=typeof e||""===e.trim())return;const t=g(e);return t?b(t)??`rgba(${m(t.r)},${m(t.g)},${m(t.b)},${t.a})`:e.trim().toLowerCase()}function w(e,t,r){const a=g(e),o=g(t);if(!a||!o)return null;const n=y({...a,a:a.a*Math.min(1,Math.max(0,r))},o);return n?b(n):null}function A(e){const t=g(e.backgroundColor),r=t?b(t):null,a=w(e.scaffoldColor,e.backgroundColor,e.scaffoldOpacity??1),o=a&&r?f(a,r):null,n=e.dataColors.map(t=>w(t,e.backgroundColor,1)).map(e=>e&&r?f(e,r):null).filter(e=>null!==e);if(null===o||n.length!==e.dataColors.length||0===n.length)return{ok:!0,status:"manual",method:"mark-to-scaffold-contrast",finding:{code:"VISUAL_HIERARCHY_MANUAL",status:"manual",message:"Visual hierarchy could not be computed from the supplied colors.",fix:"Resolve CSS variables, gradients, or named colors to solid colors and run the audit again."}};const i=Math.min(...n),s=i/o,c={weakestDataContrast:i,scaffoldContrast:o,hierarchyRatio:s},l=Math.max(1,e.minimumScaffoldContrast??1.1);return l>o?{ok:!1,status:"warn",method:"mark-to-scaffold-contrast",evidence:c,finding:{code:"SCAFFOLD_VISIBILITY",status:"warn",message:"Reference scaffolding may be too faint to remain useful.",fix:"Increase grid or guide contrast while keeping it below the primary data marks."}}:3>i||o>Math.max(l,e.maximumScaffoldContrast??2)||Math.max(1,e.minimumHierarchyRatio??2)>s?{ok:!1,status:"warn",method:"mark-to-scaffold-contrast",evidence:c,finding:{code:"SCAFFOLD_DOMINANCE",status:"warn",message:"Reference scaffolding competes with the primary data marks.",fix:"Increase mark contrast or lighten grid and guide colors until marks have at least twice the scaffold contrast."}}:{ok:!0,status:"pass",method:"mark-to-scaffold-contrast",evidence:c,finding:{code:"SCAFFOLD_DOMINANCE",status:"pass",message:"Primary data marks lead while reference scaffolding remains visible and subordinate."}}}function x(e){return Math.min(1,Math.max(0,e))}function $(e,t){return Number.isFinite(e)?e:t}function C(e){const t=e.thresholds??{},r=Math.max(1,$(t.scaffoldContrastMin,Hs.scaffoldContrastMin)),a=x($(t.emphasisRatioMin,Hs.emphasisRatioMin));return{hierarchyRatio:Math.max(1,$(t.hierarchyRatio,Hs.hierarchyRatio)),scaffoldContrastMin:r,scaffoldContrastMax:Math.max(r,$(t.scaffoldContrastMax,Hs.scaffoldContrastMax)),titleScaleRatio:Math.max(1.01,$(t.titleScaleRatio,Hs.titleScaleRatio)),categoricalColorMax:Math.max(1,Math.round($(t.categoricalColorMax,Hs.categoricalColorMax))),emphasisRatioMin:a,emphasisRatioMax:Math.max(a,x($(t.emphasisRatioMax,Hs.emphasisRatioMax)))}}function S(e){return v(e)}function k(e){return(Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[e]).map(S).filter(e=>!!e)}function R(e){return Array.isArray(e)||e&&"object"==typeof e?k(e):[]}function P(e){return e.length>=4&&Ks.some(t=>e.length===t.length&&e.every((e,r)=>e===t[r]))}function I(e){const t=e.frameProps&&"object"==typeof e.frameProps&&e.frameProps.pieceStyle&&"object"==typeof e.frameProps.pieceStyle?e.frameProps.pieceStyle:void 0,r=[...R(e.colorScheme),...k(e.color),...k(e.fill),...k(e.stroke),...k(t?.fill),...k(t?.stroke)],a=Array.isArray(e.styleRules)?e.styleRules:[];for(const e of a)e.style&&"function"!=typeof e.style&&r.push(...k(e.style.fill),...k(e.style.stroke));return Array.from(new Set(r))}function E(e){const t=e.frameProps&&"object"==typeof e.frameProps&&e.frameProps.pieceStyle&&"object"==typeof e.frameProps.pieceStyle?e.frameProps.pieceStyle:void 0,r=[...R(e.colorScheme),...k(e.color),...k(e.fill),...k(t?.fill)],a=Array.isArray(e.styleRules)?e.styleRules:[];for(const e of a)e.style&&"function"!=typeof e.style&&r.push(...k(e.style.fill));return Array.from(new Set(r))}function N(e,t){const r=Array.isArray(e.data)?e.data:[];return"string"==typeof t?Array.from(new Set(r.map(e=>e[t]+""))):"function"==typeof t?Array.from(new Set(r.map((e,r)=>t(e,r)+""))):[]}function T(e){const t=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.styleRules)?e.styleRules:[],a="string"==typeof e.valueAccessor?e.valueAccessor:"string"==typeof e.yAccessor?e.yAccessor:"value",o="string"==typeof e.categoryAccessor?e.categoryAccessor:"category",n=[];for(const e of r)e.style&&"function"!=typeof e.style&&t.some((t,r)=>l(e,t,{value:Number(t[a]),category:(t[o]??"")+"",index:r}))&&n.push(...k(e.style.fill));return Array.from(new Set(n))}function M(e,t,r){const a=R(t.colorScheme),o=k(t.color),n=N(t,t.colorBy),i=Xs.has(e)?N(t,t.categoryAccessor??"category"):[],s=t.colorScheme&&"object"==typeof t.colorScheme&&!Array.isArray(t.colorScheme)?t.colorScheme:void 0,c=(e,t)=>e.map((e,a)=>S(s?.[e])??("gray"===t?"#999999":r.colors.categorical.length>0?r.colors.categorical[a%r.colors.categorical.length]:"#007bff")),l=n.length>0?s?c(n,"gray"):a.length>0?a:r.colors.categorical:o.length>0?o:i.length>0&&s?c(i,"theme"):a.length>0&&!s?a:r.colors.categorical,u=l.slice(0,n.length>0||i.length>0?Math.min(l.length,Math.max(1,n.length||i.length||1)):1),d=T(t).filter(e=>!u.includes(e));return Array.from(/* @__PURE__ */new Set([...u,...d]))}function O(e){const t=e.colors.surface??e.colors.background,r=g(t),a=g(e.colors.background);if(!r)return t;if(1===r.a)return b(r)??t;if(!a)return t;const o=y(r,a);return o?b(o)??t:t}function F(e,t){if(!e.evidence)return.5;const{weakestDataContrast:r,scaffoldContrast:a,hierarchyRatio:o}=e.evidence;return Math.min(x(r/3),x(a/t.scaffoldContrastMin),x(t.scaffoldContrastMax/a),x(o/t.hierarchyRatio))}function j(e,t,r,a,o,n,i){const s=r[e];return{id:e,label:Zs[e],status:0===s?"disabled":i??(.8>t?"warn":"pass"),score:t,weight:s,contribution:t*s,message:a,...n?.[e]?{rationale:n[e]}:{},evidence:o}}function z(e){return Math.max(1,e.length)}function B(e){const t=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.styleRules)?e.styleRules:[];if(0===t.length||0===r.length)return{ratio:0,authored:!1};const a="string"==typeof e.valueAccessor?e.valueAccessor:"string"==typeof e.yAccessor?e.yAccessor:"value",o="string"==typeof e.categoryAccessor?e.categoryAccessor:"category";return{ratio:t.filter((e,t)=>r.some(r=>l(r,e,{value:Number(e[a]),category:(e[o]??"")+"",index:t}))).length/t.length,authored:!0}}function L(e,t,r={}){const a=r.theme??Ls,o=r.profile??a.aesthetics??Ws,n={...qs,...o.weights??{}};for(const e of Object.keys(n)){const t=n[e];n[e]=Number.isFinite(t)?Math.max(0,t):0}const i=C(o),s=M(e,t,a),c=A({backgroundColor:O(a),dataColors:s,scaffoldColor:a.colors.grid,minimumHierarchyRatio:i.hierarchyRatio,minimumScaffoldContrast:i.scaffoldContrastMin,maximumScaffoldContrast:i.scaffoldContrastMax}),l=I(t),u=P(a.colors.categorical.map(S).filter(e=>!!e)),d=E(t),h="string"==typeof t.colorScheme?t.colorScheme.trim().toLowerCase():void 0,p=d.length>0||h?"chart":"theme",f="chart"===p?P(d)||!!h&&Js.has(h):u,m=f?.2:"chart"===p?1:.8,g=z(s),y=g>i.categoricalColorMax?x(1-(g-i.categoricalColorMax)/i.categoricalColorMax):1,b=a.typography.titleFontSize??a.typography.titleSize,v=Math.max(a.typography.tickSize,a.typography.labelSize),w=v>0?b/v:1,k=x((w-1)/(i.titleScaleRatio-1)),R=new Set([...a.colors.categorical,a.colors.primary,a.colors.secondary,a.colors.background,a.colors.surface,a.colors.text,a.colors.textSecondary,a.colors.grid,a.colors.border,a.colors.annotation].map(S).filter(e=>!!e)),N=l.filter(e=>!R.has(e)).length,T=0===l.length?1:x(1-N/l.length),L=B(t),_=L.authored?i.emphasisRatioMin>L.ratio?x(L.ratio/i.emphasisRatioMin):L.ratio>i.emphasisRatioMax?x(i.emphasisRatioMax/L.ratio):1:.35,D=[j("mark-scaffold-hierarchy",F(c,i),n,c.finding.message,{hierarchyRatio:c.evidence?.hierarchyRatio??0,markContrast:c.evidence?.weakestDataContrast??0,scaffoldContrast:c.evidence?.scaffoldContrast??0},o.rationales,c.status),j("palette-authorship",m,n,f?"theme"===p?"The chart inherits a ubiquitous categorical default without an organizational palette decision.":"The chart explicitly selects a ubiquitous categorical palette.":"The effective palette records an authored choice beyond the ubiquitous defaults.",{paletteSource:p,ubiquitousDefault:f,colorCount:s.length},o.rationales),j("palette-economy",y,n,`${g} color role(s) are used against a policy ceiling of ${i.categoricalColorMax}.`,{colorRoles:g,maximum:i.categoricalColorMax},o.rationales),j("typographic-hierarchy",k,n,`Title-to-supporting-type scale is ${w.toFixed(2)}×.`,{titleSize:b,supportingSize:v,ratio:w},o.rationales),j("theme-coherence",T,n,`${N} of ${l.length} explicit chart color(s) fall outside the theme vocabulary.`,{explicitColors:l.length,outsideTheme:N},o.rationales),j("editorial-emphasis",_,n,L.authored?Math.round(100*L.ratio)+"% of marks receive authored emphasis.":"No machine-visible editorial emphasis rule is declared.",{authored:L.authored,emphasizedRatio:L.ratio},o.rationales)],U=D.reduce((e,t)=>e+t.weight,0),V=D.reduce((e,t)=>e+t.contribution,0),G=0===U?null:V/U*100,q=100*x($(o.minimumScore,Ws.minimumScore??70)/100);return{component:e,profile:o.name??"Unnamed aesthetic profile",ok:null===G||G>=q,score:G,minimumScore:q,weightedPoints:V,totalWeight:U,features:D,method:"weighted-machine-visible-features"}}function _(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),r=Math.abs(t);return 1e9>r?1e6>r?1e4>r?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"}function D(e){if(2>e.length)return"days";const t=[];for(let r=1;e.length>r;r++)t.push(e[r]-e[r-1]);t.sort((e,t)=>e-t);const r=t[Math.floor(t.length/2)];return 2*Qs>r?"seconds":2*ec>r?"minutes":2*tc>r?"hours":60*tc>r?"days":400*tc>r?"months":"years"}function U(e){return 10>e?"0"+e:e+""}function V(e={}){const t=e.timeZone;return"UTC"===t?{kind:"utc"}:"local"===t?{kind:"local"}:"string"==typeof t&&t.length>0?{kind:"iana",id:t}:!1===e.utc?{kind:"local"}:{kind:"utc"}}function G(e,t){return t?{month:e.getUTCMonth(),day:e.getUTCDate(),year:e.getUTCFullYear(),hours:e.getUTCHours(),minutes:e.getUTCMinutes(),seconds:e.getUTCSeconds()}:{month:e.getMonth(),day:e.getDate(),year:e.getFullYear(),hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()}}function q(e){let t;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hourCycle:"h23"})}catch{return e=>G(e,!0)}return e=>{const r={};for(const a of t.formatToParts(e))"literal"!==a.type&&(r[a.type]=a.value);return{month:Math.max(0,(Number(r.month)||1)-1),day:Number(r.day)||1,year:Number(r.year)||1970,hours:Number(r.hour)||0,minutes:Number(r.minute)||0,seconds:Number(r.second)||0}}}function H(e,t,r){const{month:a,day:o,year:n,hours:i,minutes:s,seconds:c}=r(e),l=rc[a],u=U(i),d=U(s),h=U(c);switch(t){case"seconds":return`${l} ${o}, ${n} ${u}:${d}:${h}`;case"minutes":case"hours":return`${l} ${o}, ${n} ${u}:${d}`;case"days":return`${l} ${o}, ${n}`;case"months":return`${l} ${n}`;case"years":return""+n}}function W(e,t,r,a){const o=a(e),n=a(t),i=o.year!==n.year,s=i||o.month!==n.month,c=s||o.day!==n.day,l=c||o.hours!==n.hours,u=l||o.minutes!==n.minutes,d=rc[o.month],{day:h,year:p}=o,f=U(o.hours),m=U(o.minutes),g=U(o.seconds);switch(r){case"seconds":return i?`${d} ${h}, ${p} ${f}:${m}:${g}`:c?`${d} ${h} ${f}:${m}:${g}`:l?`${f}:${m}:${g}`:u?`${m}:${g}`:":"+g;case"minutes":return i?`${d} ${h}, ${p} ${f}:${m}`:c?`${d} ${h} ${f}:${m}`:l?`${f}:${m}`:":"+m;case"hours":return i?`${d} ${h}, ${p} ${f}:00`:s?`${d} ${h} ${f}:${m}`:c?`${d} ${h} ${f}:00`:f+":00";case"days":return i?`${d} ${h}, ${p}`:s?`${d} ${h}`:""+h;case"months":return i?`${d} ${p}`:""+d;case"years":return""+p}}function Y(e,t={}){let r,a=e;const o="utc"===(n=V(t)).kind?e=>G(e,!0):"local"===n.kind?e=>G(e,!1):q(n.id);var n;return(t,n,i)=>{const s=t instanceof Date?t:new Date(t);e||!i||2>i.length||i===r||(r=i,a=D(i));const c=a||"days";return null!=n&&0!==n&&i&&0!==i.length?W(s,new Date(i[n-1]),c,o):H(s,c,o)}}function K(e,t=0,r=1/0,a=0){const o=Number.isFinite(t)?t:0,n=Number.isFinite(r)?Math.max(o,r):1/0,i=Number.isFinite(e)?Math.floor(e):o,s=Math.max(o,Math.min(n,i));return a>0&&Number.isFinite(a)?Math.max(o,Math.min(n,Math.round(s/a)*a)):s}function J(e,t=.5){const r=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!r)return e;const a=Math.round(parseInt(r[1],16)*(1-t)),o=Math.round(parseInt(r[2],16)*(1-t)),n=Math.round(parseInt(r[3],16)*(1-t));return`#${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function X(e,t=.5){const r=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!r)return e;const a=Math.round(parseInt(r[1],16)+(255-parseInt(r[1],16))*t),o=Math.round(parseInt(r[2],16)+(255-parseInt(r[2],16))*t),n=Math.round(parseInt(r[3],16)+(255-parseInt(r[3],16))*t);return`#${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Z(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}function Q(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(ac||(ac=document.createElement("canvas")),ac.width=e,ac.height=e,ac)}function ee(e={},t){const{background:r="transparent",stroke:a="#000",lineWidth:o=1.5,spacing:n=6,angle:i=45}=e,s={background:r,stroke:a,lineWidth:o,spacing:n,angle:i},c=Math.max(8,Math.ceil(2*n));let l;try{l=Q(c)}catch{return Z(s)}const u=l.getContext("2d");if(!u)return Z(s);r&&"transparent"!==r?(u.fillStyle=r,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=a,u.lineWidth=o,u.lineCap="square";const d=i*Math.PI/180;if(45===i||-45===i){const e=i>0?1:-1;for(let t=-c;2*c>=t;t+=n)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);const e=2*c;for(let t=-e;e>=t;t+=n)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(l,"repeat")}function te(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function re(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function ae(e,t){let r=2166136261;const a=re(t);for(let e=0;a.length>e;e++)r^=a.charCodeAt(e),r=Math.imul(r,16777619);return`${e}-hatch-${(r>>>0).toString(36)}`}function oe(e,t){const r=e.length,a=t.length,o=Array(a+1);for(let e=0;a>=e;e++)o[e]=e;for(let n=1;r>=n;n++){let r=o[0];o[0]=n;for(let i=1;a>=i;i++){const a=o[i];o[i]=e[n-1]===t[i-1]?r:1+Math.min(r,o[i],o[i-1]),r=a}}return o[a]}function ne(e,t,r=3){let a,o=r+1;for(const r of t){const t=oe(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,a=r)}return o>r?void 0:a}function ie(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function se(e,t){if(0===t.length)return null;const r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||(ne(e,t,3)??null)}function ce(e){return` Or use a function: ${e}={d => d.myValue}.`}function le({componentName:e,data:t,accessors:r,requiredProps:a}){if(a)for(const[t,r]of Object.entries(a))if(null==r)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)&&"object"==typeof t)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(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(r){const a=ie(t).find(e=>e&&"object"==typeof e);if(a){const t=Object.keys(a);for(const[o,n]of Object.entries(r))if(n&&"string"==typeof n&&!(n in a)){const r=se(n,t),a=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${n}" not found in data. Available fields: ${t.join(", ")}.${a}`+ce(o)}}}return null}function ue({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} 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 de({componentName:e,nodes:t,edges:r,nodesRequired:a=!1,edgesRequired:o=!0,accessors:n}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(a&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(n&&t&&t.length>0){const r=ie(t).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[a,o]of Object.entries(n))if(o&&"string"==typeof o&&!(o in r)){const r=se(o,t),n=r?` Try ${a}="${r}".`:"";return`${e}: ${a} "${o}" not found in node data. Available fields: ${t.join(", ")}.${n}`+ce(a)}}}return null}function he(e){return nc.has(e)}function pe(e){const[t,r]=Array.isArray(e)?e:[e,void 0],a=sc[t],o=Array.isArray(a)?[...a]:a;return void 0===r?{type:o}:{type:o,enum:[...cc[r]]}}function fe(){return Object.fromEntries(uc.map(([e,t,r,a,o],n)=>[oc[n],{required:[...e],dataShape:t,dataAccessors:[...r],props:Object.fromEntries(Object.entries(Object.assign({},...a.map(e=>lc[e]),o)).map(([e,t])=>[e,pe(t)]))}]))}function me(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function ge(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"UnitPileChart"===e)}function ye(e){if(!Array.isArray(e.thresholds))return[];const t=[];return 0===e.thresholds.length&&t.push('"thresholds" for GaugeChart must contain at least one { value, color, label? } object.'),e.thresholds.forEach((e,r)=>{if(!e||"object"!=typeof e||Array.isArray(e))return void t.push(`"thresholds[${r}]" for GaugeChart should be an object with numeric "value" and string "color".`);const a=e;"number"==typeof a.value&&Number.isFinite(a.value)||t.push(`"thresholds[${r}].value" is required for GaugeChart and must be a finite number. BigNumber's "at" threshold key is not supported here.`),"string"==typeof a.color&&0!==a.color.length||t.push(`"thresholds[${r}].color" is required for GaugeChart and must be a non-empty string.`),void 0!==a.label&&"string"!=typeof a.label&&t.push(`"thresholds[${r}].label" for GaugeChart should be a string.`);const o=Object.keys(a).filter(e=>"value"!==e&&"color"!==e&&"label"!==e);o.length>0&&t.push(`"thresholds[${r}]" has unsupported GaugeChart key(s): ${o.join(", ")}. Use { value, color, label? }; { at, level } belongs to BigNumber.`)}),t}function be(e){const t=e.frameProps;if(null==t||"object"!=typeof t||Array.isArray(t))return[];const r=t.legendLayout;if(null==r||"object"!=typeof r||Array.isArray(r))return null==r?[]:['"frameProps.legendLayout" should be object, got '+(Array.isArray(r)?"array":typeof r)+"."];const a=[],o=r,n=/* @__PURE__ */new Set(["align",...Object.keys(pc)]);for(const e of Object.keys(o))n.has(e)||a.push(`Unknown "frameProps.legendLayout" key "${e}". Valid keys: ${[...n].join(", ")}.`);void 0!==o.align&&"string"!=typeof o.align?a.push(`"frameProps.legendLayout.align" should be string, got ${Array.isArray(o.align)?"array":typeof o.align}.`):"string"!=typeof o.align||hc.has(o.align)||a.push(`"frameProps.legendLayout.align" value "${o.align}" is not valid. Expected one of: ${[...hc].join(", ")}.`);for(const[e,t]of Object.entries(pc)){const r=o[e];void 0!==r&&("number"==typeof r&&Number.isFinite(r)?t.minimum>r&&a.push(`"frameProps.legendLayout.${e}" should be ${t.label} (minimum ${t.minimum}), got ${r}.`):a.push(`"frameProps.legendLayout.${e}" should be ${t.label}, got ${Array.isArray(r)?"array":typeof r}.`))}return a}function ve(e,t){const r=[];null!=t&&"object"==typeof t||(t={});const a=dc[e];if(!a)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(dc).join(", ")}`]};for(const o of a.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);"array"!==a.dataShape||!Object.prototype.hasOwnProperty.call(a.props,"data")||a.required.includes("data")||ge(e,t)||null!=t.data||r.push(`"data" is required for ${e}.`);for(const[e,o]of Object.entries(t)){if(null==o)continue;const t=a.props[e];if(t){if(!me(o,t.type)){const a=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${a}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const o=Object.keys(a.props),n=new Set(o);for(const a of Object.keys(t))if(void 0!==t[a]&&!n.has(a)){const t=ne(a,o),n=t?`Unknown prop "${a}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${a}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(n)}if("array"===a.dataShape){const o=t.data,n={};for(const e of a.dataAccessors){const r=t[e];"string"==typeof r&&(n[e]=r)}const i=le({componentName:e,data:o,accessors:Object.keys(n).length>0?n:void 0});i&&r.push(i)}else if("object"===a.dataShape){const a=ue({componentName:e,data:t.data});a&&r.push(a)}else if("network"===a.dataShape){const o=t.nodeIdAccessor??t.nodeIDAccessor??"id",n="string"==typeof o?{nodeIdAccessor:o}:void 0,i=de({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:a.required.includes("nodes"),edgesRequired:a.required.includes("edges"),accessors:n});i&&r.push(i)}return"GaugeChart"===e&&r.push(...ye(t)),"ScatterplotMatrix"===e&&null!=t.frameProps&&r.push('"frameProps" is not supported for ScatterplotMatrix; configure its matrix props directly.'),r.push(...be(t)),{valid:0===r.length,errors:r}}function we(e){return null==e?null:e.data??e.datum??e}function Ae(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function xe(e,t={}){const r=[],a=e.tokenSemantics,o=e.countStrategy,n=t.maxRecommendedTokens??("fixed-denominator"!==o||Ae(e.denominator)>mc?fc:mc);return a||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),o||r.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||r.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>n&&r.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==a||"icon"!==e.tokenType&&"glyph"!==e.tokenType||r.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===a&&o&&"unitized"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===a&&o&&"fixed-denominator"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==a&&"posterior-sample"!==a&&"hypothetical-case"!==a||!o||"quantile"===o||"sample"===o||"posterior-sample"===o||"random-sample"===o||r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===a&&"unitized"===o&&null==e.unitValue&&null==e.unit&&r.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==a||"unitized"!==o||e.unitMeaning||r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function $e(e){return"string"==typeof e?.type?e.type:""}function Ce(e){return!!e&&"object"==typeof e&&zc.has($e(e))}function Se(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}function ke(e){return Bc.has($e(e))&&!Se(e)}function Re(e,t,r={}){return"number"==typeof r.maxAnnotations&&Number.isFinite(r.maxAnnotations)?Math.max(0,Math.floor(r.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(r.areaPerAnnotation&&r.areaPerAnnotation>0?r.areaPerAnnotation:Lc))):1/0}function Pe(e){const t=e.provenance,r=e.id??e.stableId??t?.stableId;return null==r||""===r?void 0:r+""}function Ie(e,t,r){const a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(const e of a)e&&"object"==typeof e&&"widget"===$e(e)&&null!=e.content&&!Pe(e)&&r.push({severity:"warning",code:"ANNOTATION_INTERACTIVE_ID",message:"An interactive widget annotation has no stable id, so its activation cannot be normalized or replayed reliably.",fix:"Add id, stableId, or provenance.stableId to the widget annotation. Do not identify interactive annotations by array index."})}function Ee(e,t,r){const a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(const e of a){if(!e||"object"!=typeof e)continue;const t=$e(e);if(!Ce(e)||"widget"===t)continue;const a=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,n=ke(e);!n&&a>_c?r.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${o}" sits ~${Math.round(a)}px from its anchor with no connector — a reader can't tell what it refers to.`,fix:'Add a connector (connector: { end: "arrow" }, the label/callout default) or place the note adjacent to its target (smaller dx/dy).'}):n&&a>Dc&&r.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${o}" uses a very long connector (~${Math.round(a)}px); prefer placing the note adjacent to its target when space allows.`,fix:"Reduce dx/dy so the note sits near its target, or keep the long connector only if proximity is genuinely infeasible."})}}function Ne(e,t,r){const a=Array.isArray(t.annotations)?t.annotations:null;if(!a)return;const o=a.filter(Ce).length;if(0===o)return;const n="number"==typeof t.width?t.width:600,i="number"==typeof t.height?t.height:400,s=Re(n,i);Number.isFinite(s)&&o>s&&r.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${o} note annotations on a ${n}×${i} chart exceed the ~${s} notes the plot area carries comfortably — the chart may read as cluttered.`,fix:'Mark the essential notes emphasis: "primary" and let density management shed the rest (autoPlaceAnnotations: { density: true }), enable progressive disclosure to reveal secondary notes on hover, or give the chart more room.'})}function Te(e,t,r){for(const e of Uc){const a=t[e];if(!Array.isArray(a)||2>a.length)continue;const[o,n]=a;"number"==typeof o&&"number"==typeof n&&o>n&&r.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${o}, ${n}] is descending — the axis renders inverted, so "up" reads as less. Inverted axes are a classic misleading-design pattern unless the inversion is the point.`,fix:`Order the extent ascending (${e}={[${n}, ${o}]}). If the inversion is deliberate (e.g. rank #1 at top), say so in the title or an annotation so readers aren't misled.`})}}function Me(e,t,r){if("MultiAxisLineChart"!==e)return;const a=t.series;if(!Array.isArray(a)||2!==a.length)return;const o=a.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);o.length>0&&r.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${o.length} unlabeled series. Two y-scales invite false equivalence between the lines; without per-series labels a reader can't tell which scale is whose.`,fix:'Give every series a label: series={[{ yAccessor: "a", label: "Revenue ($)" }, { yAccessor: "b", label: "Users" }]} — and consider whether two separate charts read more honestly.'})}function Oe(e,t,r){if(!vc.has(e))return;const a=t.xExtent;if(!Array.isArray(a)||2>a.length)return;const[o,n]=a;if("number"!=typeof o||"number"!=typeof n||o>=n)return;const i=t.data;if(!i||!Array.isArray(i)||4>i.length)return;const s=t.xAccessor??"x";if("string"!=typeof s)return;let c=1/0,l=-1/0;for(const e of i){const t=e?.[s];"number"==typeof t&&Number.isFinite(t)&&(c>t&&(c=t),t>l&&(l=t))}if(!Number.isFinite(c)||!Number.isFinite(l)||c>=l)return;const u=l-c,d=Math.max(0,Math.min(n,l)-Math.max(o,c))/u;.7>d&&r.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${o}, ${n}] shows only ~${Math.round(100*d)}% of the data's x range [${c}, ${l}] — a trend cropped to a favorable window is a classic misleading-design pattern.`,fix:'Widen xExtent to cover the data, filter the data itself so the chart shows what it has, or annotate the visible window ("Q4 only") so the cropping is explicit.'})}function Fe(e,t,r){const a=$c[e],o=Sc[e];if(!a&&!o)return;if(o&&!t.normalize)return;const n=a??o,i=t[n],s="string"==typeof i?i:"yAccessor"===n?"y":"value",c=t.data;if(!c||!Array.isArray(c)||0===c.length)return;const l=c.filter(e=>{const t=e?.[s];return"number"==typeof t&&0>t});l.length>0&&r.push({severity:a?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${l.length} negative value(s) in "${s}" — a part-to-whole encoding cannot represent negative parts${a?"; slice angles/areas for negatives are meaningless":"; normalized shares distort when parts are negative"}.`,fix:a?"Filter or transform negative values first, or switch to a BarChart/WaterfallChart, which encode signed values honestly.":"Drop normalize for signed data, or use a diverging BarChart so negative contributions read as negative."})}function je(e,t,r){Ac.has(e)&&"basis"===t.curve&&r.push({severity:"warning",code:"NON_PASSING_CURVE",message:'curve="basis" draws a B-spline that does NOT pass through your data points — rendered values differ from actual values everywhere except the endpoints.',fix:'Use curve="monotoneX" or curve="catmullRom" (both interpolate through every point), or keep "basis" only for deliberately schematic, clearly-labeled smoothing.'})}function ze(e,t,r){if("LineChart"!==e&&"AreaChart"!==e)return;if("sparkline"===t.mode)return;if(t.responsiveWidth||t.responsiveHeight)return;const a="number"==typeof t.width?t.width:600,o="number"==typeof t.height?t.height:400;if(0>=a||0>=o)return;const n=a/o;if(n>8||.25>n){const e=n>8?"flattens":"exaggerates";r.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${a}×${o} (${n.toFixed(1)}:1) is an extreme aspect ratio that ${e} the slopes a reader perceives — aspect-ratio distortion is a documented misleading-design pattern.`,fix:n>8?'Use a more balanced aspect (e.g. width/height between 1 and 3), or set mode="sparkline" if this is genuinely a sparkline strip.':"Use a more balanced aspect (e.g. width/height between 1 and 3); very tall trend charts overstate every change."})}}function Be(e,t,r){if(!xc.has(e))return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=t.categoryAccessor,n="string"==typeof o?o:"category",i=/* @__PURE__ */new Set;for(const e of a){const t=e?.[n];null!=t&&i.add(t)}i.size>Vc&&r.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:`${i.size} slices — angle judgments degrade rapidly past ~${Vc} categories (Cleveland & McGill), and thin slices become unreadable and unlabelable.`,fix:`Use a BarChart or DotPlot for ${i.size} categories, or group the long tail into an "Other" slice before charting.`})}function Le(e,t,r){return"function"==typeof r?r(e,t):e[r]}function _e(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function De(e,t){const r=_e(e);return null!=r&&r>0?r:t}function Ue(e){if(!e)return;const t=_e(e[0]),r=_e(e[1]);return null!=t&&null!=r?t>r?[r,t]:[t,r]:void 0}function Ve(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Ge(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),r=t.length?t:["Intake"],a=Math.max(r.length,Math.round(e.count??Math.max(48,12*r.length))),o=De(e.unitValue,1),n=Ve(e.seed??1),i=e.idPrefix??"mechanical-pile",s=r.map(()=>.65+.9*n()),c=s.reduce((e,t)=>e+t,0)||1,l=a-r.length,u=s.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=a-d.reduce((e,t)=>e+t,0);const p=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%p.length)d[p[e].index]+=1,h-=1;return r.map((e,t)=>({id:`${i}-${t}`,category:e,value:d[t]*o,mechanical:!0,unitCount:d[t],unitValue:o,share:d[t]/a}))}function qe(e,t){const r=e/t,a=Math.round(r);return Math.ceil(a>0&&Number.EPSILON*r*4>=Math.abs(r-a)?a:r)}function He(e,t,r=0){const a=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),o=/* @__PURE__ */new Map;for(const n of e){let e=null==n.id?`${t}-${r++}`:n.id+"";for(;null==n.id&&a.has(e);)e=`${t}-${r++}`;a.add(e),o.set(e,null==n.id?{...n,id:e}:n)}return{seed:e,rows:Array.from(o.values()),nextId:r}}function We(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function Ye(e,t,r){if("function"==typeof t)return t(e);const a="string"==typeof t?t:r;return e?.[a]}function Ke(e,t,r){if(Tc.has(e)){if("GaltonBoardChart"===e){const e=t.bins;"number"==typeof e&&2>e&&r.push({severity:"error",code:"PHYSICS_BAD_BINS",message:`bins=${e} leaves no meaningful settled projection for a Galton board.`,fix:"Use at least two bins; 8-24 bins is a practical range for physics distributions."});const a=We(t.branchProbability);null!=t.branchProbability&&(null==a||0>a||a>1)&&r.push({severity:"error",code:"PHYSICS_BAD_BRANCH_PROBABILITY",message:`branchProbability=${t.branchProbability+""} must be between 0 and 1.`,fix:"Use branchProbability={0.5} for a balanced Galton board, or bias it within the [0, 1] range."});const o=We(t.mechanicalCount);null==t.mechanicalCount||null!=o&&o>0||r.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical Galton board.`,fix:"Use a positive mechanicalCount, for example 96."})}if("EventDropChart"===e){const e=t.windows,a=e&&"object"==typeof e?We(e.size):null;null==a||a>0||r.push({severity:"error",code:"PHYSICS_BAD_WINDOW_SIZE",message:`windows.size=${a} cannot form event-time barriers.`,fix:"Set windows={{ size: positiveNumber }} so each event can settle into a real time window."}),"number"!=typeof t.timeScale||t.timeScale>0||r.push({severity:"error",code:"PHYSICS_BAD_TIME_SCALE",message:`timeScale=${t.timeScale} prevents arrival replay from advancing.`,fix:"Use a positive timeScale, or omit it for the default pace."});const o=Array.isArray(t.data)?t.data:[];if(o.length>0){const e=t.timeAccessor||"time",a=t.arrivalAccessor||"arrivalTime";o.some(t=>{const r=We(Ye(t,e,"time")),o=We(Ye(t,a,"arrivalTime"));return null!=r&&null!=o&&r!==o})||r.push({severity:"warning",code:"PHYSICS_EVENTDROP_NO_ARRIVAL_SPREAD",message:"EventDropChart data does not show distinct arrival times, so the physics replay collapses to event order.",fix:"Provide an arrivalAccessor field with event-arrival times when demonstrating lateness, watermarks, or out-of-order streams."})}}if("UnitPileChart"===e){const e="mechanical"===(t.simulationMode??t.mode),a=We(t.mechanicalCount);null==t.mechanicalCount||null!=a&&a>0||r.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical pile chart.`,fix:"Use a positive mechanicalCount, for example 80."}),e&&Array.isArray(t.mechanicalCategories)&&0===t.mechanicalCategories.length&&r.push({severity:"error",code:"PHYSICS_EMPTY_MECHANICAL_CATEGORIES",message:"mechanicalCategories=[] leaves no containers for the generated unit pile.",fix:"Provide at least one category label, or omit mechanicalCategories for the default set."});const o=_e(t.unitValue??1);if(null==o||0>=o)return void r.push({severity:"error",code:"PHYSICS_BAD_UNIT_VALUE",message:`unitValue=${t.unitValue} cannot unitize values into physical bodies.`,fix:"Set unitValue to a positive number represented by one body."});const n=e?Ge({count:a??void 0,categories:Array.isArray(t.mechanicalCategories)?t.mechanicalCategories:void 0,seed:_e(t.seed)??1,unitValue:o}):Array.isArray(t.data)?t.data:[],{rows:i}=He(n,"pile"),s=t.valueAccessor??(e?"value":void 0),c=i.reduce((e,t,r)=>{const a="function"==typeof s?s(t,r):"string"==typeof s&&s?t[s]:1;return e+qe(Math.max(0,_e(a)??0),o)},0);c>1500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`UnitPileChart would create about ${c} live bodies; motion may dominate the chart and stress the frame budget.`,fix:"Sample or aggregate source records, or use a bounded window with sediment. A larger unitValue reduces full circles but still leaves at least one body per positive source record."})}if("CollisionSwarmChart"===e){if((We(t.pointRadius??5)??5)>0||r.push({severity:"error",code:"PHYSICS_BAD_POINT_RADIUS",message:`pointRadius=${t.pointRadius} cannot produce collision bodies.`,fix:"Use a positive pointRadius, for example 5."}),(We(t.collisionIterations??6)??6)>0||r.push({severity:"error",code:"PHYSICS_BAD_COLLISION_ITERATIONS",message:`collisionIterations=${t.collisionIterations} disables collision relaxation.`,fix:"Use at least one collision iteration; 4-8 is a practical range for swarms."}),null!=t.xExtent){const e=Array.isArray(t.xExtent)?t.xExtent:[],a=We(e[0]),o=We(e[1]);(2>e.length||null==a||null==o)&&r.push({severity:"error",code:"PHYSICS_BAD_X_EXTENT",message:"xExtent must be a numeric [min, max] pair for CollisionSwarmChart.",fix:"Pass xExtent={[min, max]} or omit it so the chart infers the domain from data."})}const e=Array.isArray(t.data)?t.data:[];e.length>1200&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`CollisionSwarmChart would create ${e.length} live bodies; collision relaxation may dominate the frame budget.`,fix:"Sample, aggregate, reduce point radius, or move to a static SwarmPlot when every row does not need a physical body."});const a=t.groupAccessor;if(e.length>0&&a){const t=/* @__PURE__ */new Set;for(const r of e){const e=Ye(r,a,"group");null!=e&&t.add(e)}t.size>12&&r.push({severity:"warning",code:"PHYSICS_TOO_MANY_SWARM_LANES",message:`CollisionSwarmChart has ${t.size} group lanes, which leaves little vertical room for collision separation.`,fix:"Facet or filter groups, or use an ordinary SwarmPlot/BoxPlot for dense grouped comparison."})}}if("GaltonBoardChart"!==e&&"UnitPileChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e&&"EventDropChart"!==e||(null!=t.massBy||null!=t.massAccessor||t.frameProps&&"object"==typeof t.frameProps&&null!=t.frameProps.bodyMassBy)&&r.push({severity:"warning",code:"PHYSICS_DATA_IN_DYNAMICS",message:e+" appears to map a data field to mass/dynamics. Mass is not a readable quantitative channel.",fix:"Encode quantities in spawn position, bin, size, color, or glyph — keep mass/friction/restitution as process texture. Use showProjection for the truth layer."}),"UnitPileChart"!==e&&"GaltonBoardChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e&&"CrucibleChart"!==e||!1!==t.showProjection||r.push({severity:"warning",code:"PHYSICS_NO_PROJECTION",message:e+" has showProjection={false}. Without a settled projection, motion is easy to over-read as data.",fix:"Keep showProjection enabled (default) so the chart collapses to a legible static reading, or document why the process alone is the claim."}),"ProcessFlowChart"===e){const e=Array.isArray(t.stages)?t.stages:[];if(0===e.length)r.push({severity:"error",code:"PROCESS_FLOW_MISSING_STAGES",message:"ProcessFlowChart requires a non-empty stages array.",fix:'Provide stages={[{ id: "coding", force: 12 }, { id: "merged", absorb: true }]}.'});else{e.some(e=>!e||null==e.id||""===(e.id+"").trim())&&r.push({severity:"error",code:"PROCESS_FLOW_BAD_STAGE",message:"Every ProcessFlowChart stage needs a stable id.",fix:'Use stages like { id: "review", label: "Review", capacity: { unitsPerSecond: 4 } }.'});const a=e.filter(e=>e?.absorb).length;t.groupBy&&0===a&&r.push({severity:"warning",code:"PROCESS_FLOW_GROUP_NO_ABSORB",message:"groupBy is set but no stage has absorb: true, so all-members completion cannot resolve.",fix:'Mark a terminal stage with absorb: true (e.g. merged), or set groupCompletion="none".'})}}if("GauntletChart"===e&&(Array.isArray(t.negativeProperties)||r.push({severity:"warning",code:"GAUNTLET_MISSING_NEGATIVE_PROPERTIES",message:"GauntletChart usually needs negativeProperties for drag/cost bodies (empty array is ok if intentional).",fix:'Provide negativeProperties={[{ id: "cost", label: "Cost", load: 1 }]} or explicitly pass [].'})),"CrucibleChart"===e){const e=Array.isArray(t.phases)?t.phases:[],a=Array.isArray(t.products)?t.products:[],o=Array.isArray(t.events)?t.events:[],n=Array.isArray(t.outlets)?t.outlets:[];0===e.length?r.push({severity:"error",code:"CRUCIBLE_MISSING_PHASES",message:"CrucibleChart requires an authored, non-empty phases array; a treatment program cannot be inferred from flat data.",fix:'Provide phases={[{ id: "charge", label: "Charge", duration: 1, motion: "charge" }]}.'}):e.some(e=>!e||null==e.id||""===(e.id+"").trim()||null==We(e.duration)||0>=Number(e.duration))&&r.push({severity:"error",code:"CRUCIBLE_BAD_PHASE",message:"Every CrucibleChart phase needs a stable id and a positive finite duration.",fix:'Use phases like { id: "assay", label: "Assay", duration: 2, motion: "mix" }.'}),0===a.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_PRODUCTS",message:"CrucibleChart has no declared product molds. Products are never discovered from collisions or source fields.",fix:'Declare products={[{ id: "accepted", label: "Accepted", outletId: "product" }]} when the treatment forms an output.'}),0===o.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_EVENTS",message:"CrucibleChart has no authored events, so its phases cannot transform, combine, split, or route the charge.",fix:"Supply an explicit events array; do not ask the chart or an AI layer to infer a treatment from the rows."}),Array.isArray(t.outlets)||r.push({severity:"warning",code:"CRUCIBLE_IMPLICIT_OUTLETS",message:"CrucibleChart is using generic default outlets rather than domain-specific destinations.",fix:"Provide reason-labelled outlets and reference their ids from products, complete-product, and eject effects."});const i=new Set(a.map(e=>e?.id).filter(e=>null!=e).map(String)),s=/* @__PURE__ */new Set(["product","retained","residue","failed","recovered",...n.map(e=>e?.id).filter(e=>null!=e).map(String)]),c=/* @__PURE__ */new Set,l=/* @__PURE__ */new Set;for(const e of o)if(e&&Array.isArray(e.effects))for(const t of e.effects){if(!t||"object"!=typeof t)continue;const e=t.type;if("combine"!==e&&"contribute"!==e&&"complete-product"!==e||null==t.productId||i.has(t.productId+"")||c.add(t.productId+""),"split"===e&&Array.isArray(t.products))for(const e of t.products)null==e?.productId||i.has(e.productId+"")||c.add(e.productId+"");null==t.outletId||s.has(t.outletId+"")||l.add(t.outletId+"")}c.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_PRODUCT",message:`CrucibleChart events reference undeclared product molds: ${[...c].sort().join(", ")}.`,fix:"Declare every referenced product id in products; do not create product definitions implicitly inside events."}),l.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_OUTLET",message:`CrucibleChart events reference undeclared outlets: ${[...l].sort().join(", ")}.`,fix:"Declare every domain outlet in outlets and reuse its stable id in authored effects."});const u=We(t.playbackRate);null==t.playbackRate||null!=u&&u>0||r.push({severity:"error",code:"CRUCIBLE_BAD_PLAYBACK_RATE",message:`playbackRate=${t.playbackRate+""} cannot advance the authored CrucibleChart tape.`,fix:"Use a positive playbackRate such as 0.5 for half speed or 2 for double speed."});const d=We(t.rerunMS);null==t.rerunMS||null!=d&&d>=0||r.push({severity:"error",code:"CRUCIBLE_BAD_RERUN_MS",message:`rerunMS=${t.rerunMS+""} must be a finite non-negative delay or null.`,fix:"Use rerunMS={3000}, rerunMS={0}, or omit the prop for a single run."})}if("GaltonBoardChart"===e||"CollisionSwarmChart"===e||"ProcessFlowChart"===e||"EventDropChart"===e||"CrucibleChart"===e){const a=Array.isArray(t.data)?t.data:[],o=We(t.mechanicalCount)??0,n=a.length>0?a.length:o;n>2500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(n)} live bodies, which can overwhelm the simulation loop.`,fix:"Lower mechanicalCount / unitize with a larger unitValue, enable sediment/windowSize, or sample the data before spawn."})}}}function Je(e){const t=[],r=e.domain;null==r?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):Array.isArray(r)&&2===r.length&&Number.isFinite(Number(r[0]))&&Number.isFinite(Number(r[1]))||t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});const a=e.edges;if(Array.isArray(a)&&a.length>0){const e=a[0];null!=e.startTime&&null!=e.endTime||t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}const o=e.nodes,n=Array.isArray(o)?o.length:0;return!0!==e.showLabels||24>n||t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${n} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),80>(Array.isArray(a)?a.length:0)||null!=e.layoutExecution||"off"===e.packing||t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}function Xe(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const r=Gc.test(t)?t+"-01":t;if(r===t&&10>t.length)return NaN;const a=Date.parse(r);return Number.isFinite(a)?a:NaN}function Ze(e,t){const r=e.nestedDataAccessorProp?t[e.nestedDataAccessorProp]:void 0;return"string"==typeof r?r:e.defaultNestedDataAccessor}function Qe(e,t,r){const a=e.dataProp??"data",o=t[a],n=r??(Array.isArray(o)?o:[]),i=Ze(e,t);if(!i)return{dataProp:a,rows:n};const s=[];let c=!1;for(const e of n){const t=e?.[i];if(Array.isArray(t)){c=!0;for(const e of t)e&&"object"==typeof e&&s.push(e)}}return{dataProp:a,rows:c?s:n}}function et(e,t,r){const a=/* @__PURE__ */new Set;for(const o of e.fields){const e=o.dataProp??"data",n=r??t[e];if(!Array.isArray(n))continue;if(0===n.length){a.add(e);continue}const i=Ze(o,t);if(!i)continue;const s=n.map(e=>e?.[i]).filter(Array.isArray);s.length>0&&s.every(e=>0===e.length)&&a.add(`${e}.${i}`)}return[...a]}function tt(){const e=globalThis;return e[nl]??(e[nl]={contracts:/* @__PURE__ */new Map}),e[nl]}function rt(e){return tt().contracts.get(e)??ol[e]}function at(e,t,r){const a={numbers:r?[]:void 0,finite:0,min:1/0,max:-1/0,missing:0,nonFinite:0,nonNumeric:0,zero:0,negative:0,fractional:0};for(const r of e){const e=r?.[t];if(null==e||""===e){a.missing++;continue}let o;if("number"==typeof e)o=e;else if("string"==typeof e){const t=e.trim();if(""===t){a.missing++;continue}const r=Number(t);Number.isNaN(r)?/^[+-]?nan$/i.test(t)&&(o=r):o=r}void 0!==o?Number.isFinite(o)?(a.numbers?.push(o),a.finite++,a.min>o&&(a.min=o),o>a.max&&(a.max=o),0===o&&a.zero++,0>o&&a.negative++,Number.isInteger(o)||a.fractional++):a.nonFinite++:a.nonNumeric++}return a}function ot(e,t){if(0===e.length)return;const r=(e.length-1)*t,a=Math.floor(r),o=Math.ceil(r);if(a===o)return e[a];const n=r-a;return e[a]*(1-n)+e[o]*n}function nt(e,t={}){if(!Array.isArray(e)||0===e.length)return{};const r=/* @__PURE__ */new Set;for(const t of e)if(t&&"object"==typeof t)for(const e of Object.keys(t))r.add(e);const a={};for(const o of r){const r=at(e,o,!1!==t.quantiles),n=r.numbers?.sort((e,t)=>e-t);a[o]={field:o,observedCount:e.length-r.missing,finiteCount:r.finite,missingCount:r.missing,nonFiniteCount:r.nonFinite,nonNumericCount:r.nonNumeric,zeroCount:r.zero,negativeCount:r.negative,fractionalCount:r.fractional,...r.finite>0?{min:r.min,...n?{q1:ot(n,.25),median:ot(n,.5),q3:ot(n,.75)}:{},max:r.max}:{}}}return a}function it(e){const t=[`${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 r of e.diagnoses)t.push(`${"error"===r.severity?"ERROR":"WARN"} ${r.code}${r.field?` [${r.field}]`:""}: ${r.message}`),r.fix&&t.push(" Fix: "+r.fix);return t.join("\n")}function st(e){return e.code.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function ct(e,t={}){const r=Number.isFinite(t.max)?Math.max(0,Math.floor(t.max)):6,a=e.diagnoses.map((e,t)=>({item:e,diagnosisIndex:t})).filter(({item:e})=>!t.errorsOnly||"error"===e.severity),o=a.slice(0,r).map(({item:e,diagnosisIndex:t})=>({id:`data-audit:${e.code}:${e.role??"chart"}:${e.field??"chart"}:${t}`,level:e.severity,title:e.field?`${st(e)} · ${e.field}`:st(e),message:e.fix?`${e.message} ${e.fix}`:e.message,source:"Semiotic data audit",dismissible:!0}));return a.length>r&&o.push({id:"data-audit:overflow:chart",level:a.slice(r).some(({item:e})=>"error"===e.severity)?"error":"warning",title:`${a.length-r} more numeric finding${a.length-r===1?"":"s"}`,message:"Run auditData() or diagnoseConfig() to inspect the complete report.",source:"Semiotic data audit",dismissible:!0}),o}function lt(e){const t=[];for(const[r,a]of Object.entries(sl))"string"!=typeof e[r]&&"function"!=typeof e[r]||t.push({role:a,accessor:r,..."size"===a?{requirements:["finite","non-negative"]}:{},..."x"===a||"y"===a?{domain:!0}:{}});return t.length>0?{fields:t}:void 0}function ut(e,t,r){return"function"==typeof e?e(t,r):t[e]}function dt(e,t){if("number"==typeof e)return Number.isFinite(e)?e:null;if(e instanceof Date){const r=e.getTime();return t&&Number.isFinite(r)?r:null}if("string"==typeof e){const r=e.trim(),a=Number(r);if(r&&Number.isFinite(a))return a;if("date-like"===t){const e=Xe(r);return Number.isFinite(e)?e:null}}return null}function ht(e){return"number"==typeof e&&!Number.isFinite(e)}function pt(e,t,r,a,o){const n={field:r,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let r=0;e.length>r;r++){let i;try{i=ut(t,e[r],r)}catch{n.accessorErrorRows.push(r);continue}if(null==i||""===i){if(void 0!==o){n.numbers.push(o),n.finiteRows.push(r),0===o&&n.zeroRows.push(r),0>o&&n.negativeRows.push(r),Number.isInteger(o)||n.fractionalRows.push(r);continue}n.missingRows.push(r);continue}const s=dt(i,a);null!=s?(n.numbers.push(s),n.finiteRows.push(r),0===s&&n.zeroRows.push(r),0>s&&n.negativeRows.push(r),Number.isInteger(s)||n.fractionalRows.push(r)):ht(i)?n.nonFiniteRows.push(r):n.nonNumericRows.push(r)}return n}function ft(e,t){const r=new Set(e.requirements??["finite"]);return r.add("finite"),("x"===e.role&&"log"===t.xScaleType||"y"===e.role&&"log"===t.yScaleType)&&r.add("positive"),[...r]}function mt(e){let t=1/0,r=-1/0;for(const a of e)t>a&&(t=a),a>r&&(r=a);return[t,r]}function gt(e,t,r){const a=[],o=/* @__PURE__ */new Set;for(const n of e.fields){if(n.whenProps?.some(e=>null==t[e]))continue;const e=t[n.accessor],i="string"==typeof e||"function"==typeof e?e:n.defaultAccessor;if("string"!=typeof i&&"function"!=typeof i)continue;const{dataProp:s,rows:c}=Qe(n,t,r);if(0===c.length)continue;const l="string"==typeof i?i:n.accessor+"()",u=`${s}:${n.role}:${l}`;if(o.has(u))continue;o.add(u);const d=n.temporalValues??("time"===n.role||"x"===n.role&&"time"===t.xScaleType?"date-like":void 0),h="x"===n.role&&"log"===t.xScaleType||"y"===n.role&&"log"===t.yScaleType,p=ft(n,t);a.push({contract:n,accessor:i,accessorLabel:l,dataProp:s,rows:c,requirements:p,logScale:h,observation:pt(c,i,l,d,n.missingValue)})}return a}function yt(e){return e.slice(0,il)}function bt(e){return{domain:"data",...e}}function vt(e){const t=e.observation.numbers.map((t,r)=>({value:t,row:e.observation.finiteRows[r]})).sort((e,t)=>e.value-t.value);if(8>t.length)return[];const r=t.map(e=>e.value),a=ot(r,.25),o=ot(r,.75),n=ot(r,.5),i=o-a;if(i>0){const e=a-10*i,r=o+10*i;return t.filter(t=>e>t.value||t.value>r).map(e=>e.row)}const s=100*Math.max(1,Math.abs(n));return t.filter(e=>Math.abs(e.value-n)>s).map(e=>e.row)}function wt(e,t){const r=[],{observation:a,contract:o,accessorLabel:n,requirements:i}=e,s={field:n,role:o.role},c=[...a.nonFiniteRows,...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(0===a.numbers.length)return r.push(bt({severity:"error",code:"DEGENERATE_EXTENT",message:`${o.accessor}="${n}" produces no finite numeric values; the chart cannot resolve its ${o.role} input.`,fix:`Ensure ${n} contains finite numbers${"x"===o.role?" (or valid dates for a time scale)":""}.`,...s,...c.length>0?{rows:yt(c),count:c.length}:{}})),r;a.nonFiniteRows.length>0&&r.push(bt({severity:"error",code:"NON_FINITE_VALUE",message:`${n} contains ${a.nonFiniteRows.length} NaN or infinite value${1===a.nonFiniteRows.length?"":"s"}; scale and layout math require finite numbers.`,fix:`Filter or replace NaN/Infinity in ${n} before rendering.`,...s,rows:yt(a.nonFiniteRows),count:a.nonFiniteRows.length})),!o.allowMissing&&a.missingRows.length>0&&r.push(bt({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${n} is missing for ${a.missingRows.length} row${1===a.missingRows.length?"":"s"}; the ${o.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${n} values before rendering.`,...s,rows:yt(a.missingRows),count:a.missingRows.length}));const l=[...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(l.length>0&&r.push(bt({severity:"error",code:"NON_NUMERIC_VALUE",message:`${n} produces ${l.length} non-numeric value${1===l.length?"":"s"} for the ${o.role} role.`,fix:`Bind ${o.accessor} to a numeric field or return finite numbers from the accessor.`,...s,rows:yt(l),count:l.length})),o.domain&&a.numbers.length>=2){const[e,t]=mt(a.numbers);e===t&&r.push(bt({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${n} is constant at ${e}; its ${o.role} scale has a zero-span data domain.`,fix:`Provide varying ${o.role} values, set an explicit extent around ${e}, or use a single-value display.`,...s,rows:yt(a.finiteRows),count:a.finiteRows.length}))}if(i.includes("positive")){const t=a.numbers.map((e,t)=>({number:e,row:a.finiteRows[t]})).filter(({number:e})=>0>=e).map(({row:e})=>e);if(t.length>0){const a=e.logScale;r.push(bt({severity:"error",code:a?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${n} contains ${t.length} non-positive value${1===t.length?"":"s"}, which ${a?"cannot be represented on a log scale":"violate the positive-value contract"}.`,fix:a?"Remove or transform values ≤ 0, or use a linear/symlog scale.":"Provide values greater than zero.",...s,rows:yt(t),count:t.length}))}}if(i.includes("non-negative")&&a.negativeRows.length>0&&r.push(bt({severity:"error",code:"size"===o.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${n} contains ${a.negativeRows.length} negative ${o.role} value${1===a.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.",...s,rows:yt(a.negativeRows),count:a.negativeRows.length})),i.includes("integer")){const e=[.../* @__PURE__ */new Set([...a.negativeRows,...a.zeroRows,...a.fractionalRows])].sort((e,t)=>e-t);e.length>0&&r.push(bt({severity:"error",code:"INVALID_COUNT",message:`${n} 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.",...s,rows:yt(e),count:e.length}))}if(i.includes("unit-interval")){const e=a.numbers.map((e,t)=>({number:e,row:a.finiteRows[t]})).filter(({number:e})=>0>e||e>1).map(({row:e})=>e);e.length>0&&r.push(bt({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${n} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${n} to [0, 1] before using it as ${o.role}.`,...s,rows:yt(e),count:e.length}))}if(t&&o.domain){const t=vt(e);t.length>0&&r.push(bt({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${n} has ${t.length} extreme value${1===t.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.",...s,rows:yt(t),count:t.length}))}return r}function At(e,t,r){if(!e)return"__all__";try{return ut(e,t,r)+""}catch{return"__accessor_error__"}}function xt(e,t,r){if(e.whenProp&&!0!==r[e.whenProp])return[];const a=t.find(t=>t.contract.role===e.role);if(!a||0===a.observation.numbers.length)return[];const o=e.groupAccessor?r[e.groupAccessor]:void 0,n="string"==typeof o||"function"==typeof o?o:e.defaultGroupAccessor,i=/* @__PURE__ */new Map;for(let e=0;a.rows.length>e;e++){let t;try{t=ut(a.accessor,a.rows[e],e)}catch{continue}const r=dt(t,void 0);if(null==r)continue;const o=At(n,a.rows[e],e),s=i.get(o)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};s.sum+=r,s.magnitude+=Math.abs(r),s.positive||(s.positive=r>0),s.negative||(s.negative=0>r),s.rows.push(e),0>r&&s.negativeRows.push(e),i.set(o,s)}const s=[],c=[],l=[],u=[],d=[],h=[];for(const[t,r]of i)("positive-total"===e.kind&&0>=r.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,r.magnitude)*10>=Math.abs(r.sum))&&(s.push(t),u.push(...r.rows)),"normalized-total"===e.kind&&r.positive&&r.negative&&(c.push(t),d.push(...r.rows)),"normalized-total"===e.kind&&r.negative&&(l.push(t),h.push(...r.negativeRows));const p=[];return s.length>0&&p.push(bt({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${s.length} normalization group${1===s.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:a.accessorLabel,role:e.role,rows:yt([...new Set(u)].sort((e,t)=>e-t)),count:s.length})),l.length>0&&p.push(bt({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:a.accessorLabel,role:e.role,rows:yt([...new Set(h)].sort((e,t)=>e-t)),count:h.length})),c.length>0&&p.push(bt({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:a.accessorLabel,role:e.role,rows:yt([...new Set(d)].sort((e,t)=>e-t)),count:c.length})),p}function $t(e,t,r,a={}){const o=a.contracts??rt(e)??lt(t);if(!o)return{component:e,ok:!0,rowCount:r?.length??(Array.isArray(t.data)?t.data.length:0),summary:{fieldsChecked:0,errors:0,warnings:0},contracts:[],diagnoses:[]};const n=gt(o,t,r),i=[],s=!1!==a.checkOutliers;for(const e of et(o,t,r))i.push(bt({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 c=new Set(n.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(const e of c)i.push(bt({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 n)i.push(...wt(e,s));for(const e of o.aggregates??[])i.push(...xt(e,n,t));const l=i.filter(e=>"error"===e.severity).length,u=i.length-l;return{component:e,ok:0===l,rowCount:n.reduce((e,t)=>Math.max(e,t.rows.length),r?.length??(Array.isArray(t.data)?t.data.length:0)),summary:{fieldsChecked:n.length,errors:l,warnings:u},contracts:n.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}}function Ct(e,t,r){const a=dc[e];if(a){if("array"===a.dataShape||"realtime"===a.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&r.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"realtime"===a.dataShape?"Provide at least one observation: data={[{ time: 0, value: 1 }]}, or omit data for React ref push mode.":"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===a.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&r.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}function St(e,t){for(const[r,a]of[["width",600],["height",400]]){const o=e[r];void 0===o||"number"==typeof o&&o>0||t.push({severity:"error",code:"width"===r?"BAD_WIDTH":"BAD_HEIGHT",message:`${r}=${JSON.stringify(o)} — chart needs a positive number.`,fix:`Set ${r}={${a}}.`})}if(e.size&&Array.isArray(e.size)){const[r,a]=e.size;(null!=r&&0>=r||null!=a&&0>=a)&&t.push({severity:"error",code:"BAD_SIZE",message:`size=[${r}, ${a}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}function kt(e,t,r){const a=dc[e];if(!a||"array"!==a.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const n=o[0];if(!n||"object"!=typeof n)return;const i=Object.keys(n);for(const e of a.dataAccessors){const a=t[e];"string"==typeof a&&(a in n||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${a}" not found in data. Available fields: ${i.join(", ")}.`,fix:`Change ${e} to one of: ${i.map(e=>`"${e}"`).join(", ")}, or use a function: ${e}={d => d.myValue}.`}))}}function Rt(e,t,r){gc.has(e)&&Array.isArray(t.data)&&r.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}function Pt(e,t,r){yc.has(e)&&(t.edges||t.data||r.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}function It(e,t,r){const a=dc[e];if(!a||"array"!==a.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const n=o[0];if(!n||"object"!=typeof n)return;const i=t.xAccessor;"string"==typeof i&&n[i]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${i}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}function Et(e,t,r){t.linkedHover&&!t.selection&&r.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}function Nt(e,t,r){if(!vc.has(e))return;if(t.gapStrategy)return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=t.yAccessor||"y";"string"==typeof o&&a.some(e=>{const t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}function Tt(e,t,r){if(!bc.has(e))return;const a=t.rExtent||t.yExtent||t.valueExtent;a&&Array.isArray(a)&&a.length>=1&&null!=a[0]&&0!==a[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${a[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${a[1]??"auto"}]}. For trend-focused charts, use LineChart instead.`})}function Mt(e,t,r){if(!wc.has(e))return;const a=t.barPadding;"number"==typeof a&&10>a&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${a} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}function Ot(e,t,r){if("Heatmap"!==e)return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=a[0];if(o&&"object"==typeof o)for(const e of["xAccessor","yAccessor"]){const a=t[e];if("string"!=typeof a)continue;const n=o[a];"string"==typeof n&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${a}" resolves to string values (e.g. "${n}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}function Ft(e,t,r){const a=t.colorScheme;if(!a||!Array.isArray(a))return;const o="string"==typeof t.background?t.background:"#ffffff";if(!o.startsWith("#"))return;const n=[];for(const e of a){if("string"!=typeof e||!e.startsWith("#"))continue;const t=f(e,o);null!==t&&3>t&&n.push(`${e} (${t.toFixed(1)}:1)`)}n.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${n.length} color(s) in colorScheme have < 3:1 contrast against background "${o}": ${n.join(", ")}. Data marks may be hard to see.`,fix:"Choose colors with at least 3:1 contrast against the chart background."})}function jt(e,t){const r=e.width??600,a=e.height??400,o=e.margin;if(!o||"object"!=typeof o)return;const n=(o.left||0)+(o.right||0),i=(o.top||0)+(o.bottom||0);r>n||t.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${n}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>i||t.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${i}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}function zt(e,t,r){const a=dc[e]?.props,o=e=>!!a?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,n=o("title"),i=o("description"),s=o("summary");n||i||s||r.push({severity:"warning",code:"MISSING_DESCRIPTION",message:"No title, description, or summary provided. Screen readers will fall back to a generic chart-type label.",fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}function Bt(e,t,r){const a=t.colorScheme;if("string"!=typeof a)return;const o=dc[e];o?.props?.colorScheme?.enum||cl.has(a)||r.push({severity:"warning",code:"UNKNOWN_COLOR_SCHEME",message:`colorScheme "${a}" is not a recognized named scheme — the chart will fall back to the default palette.`,fix:`Use a known scheme name (${[...cl].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}function Lt(e,t,r){const a=t.colorScheme;if(!a||!Array.isArray(a)||2>a.length)return;const o=a.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;const n=[];for(let e=0;o.length-1>e;e++){const t=f(o[e],o[e+1]);null!==t&&1.5>t&&n.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}n.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${n.length} adjacent color pair(s) in colorScheme have very similar luminance: ${n.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}function _t(e,t,r){const a=[];for(const e of ll)"function"==typeof t[e]&&a.push(e);a.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${a.length>1?"s":""} detected: ${a.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference; closures over changing values can force unnecessary scene rebuilds on resize/rotation.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}function Dt(e,t,r){const a=t.hoverRadius;"number"==typeof a&&a>0&&24>a&&!1!==t.enableHover&&(!1!==t.hoverAnnotation||t.tooltip||t.customHoverBehavior||t.customClickBehavior||t.onClick)&&r.push({severity:"warning",code:"TOUCH_TARGET_SMALL",message:`hoverRadius=${a}px is below the ~24px radius needed for reliable 48px touch targets on mobile screens.`,fix:"Use hoverRadius={24} or larger for touch-heavy views. Semiotic floors touch pointer hit testing to 24px, but explicit desktop-only radii should be documented."})}function Ut(e,t,r){!0===t.responsiveWidth&&!0===t.responsiveHeight&&r.push({severity:"warning",code:"RESPONSIVE_BOTH_AXES",message:"responsiveWidth and responsiveHeight are both true. On mobile this can create resize feedback loops when the parent height depends on chart content.",fix:"Prefer responsiveWidth={true} with a fixed parent height or size={[width, fixedHeight]}; use a ResizeObserver outside the chart if the height must follow aspect ratio."})}function Vt(e,t,r){if(!0!==t.showParticles)return;const a=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},o="number"==typeof a.maxPerLine?a.maxPerLine:void 0,n="number"==typeof a.spawnRate?a.spawnRate:void 0;("number"==typeof o&&o>20||"number"==typeof n&&n>.08)&&r.push({severity:"warning",code:"GEO_PARTICLE_MOBILE_COST",message:"Animated geo particles run a continuous canvas loop that can drain battery and trigger thermal throttling on mobile GPUs.",fix:"Set particleStyle={{ maxPerLine: 12, spawnRate: 0.06 }} for mobile-heavy views, or disable showParticles when reduced-motion or low-power modes are active."})}function Gt(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function qt(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function Ht(e,t){const r=qt(e.visibleTokens);if(null!=r)return r;const a=qt(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=a)return a;const o=qt(t.tokenCount),n=qt(t.maxTokens);return null!=o&&null!=n?Math.min(o,n):o??a??n}function Wt(e,t,r){const a=[];Gt(t.tokenEncoding)&&a.push({source:"tokenEncoding",encoding:t.tokenEncoding}),Gt(t.encoding)&&a.push({source:"encoding",encoding:t.encoding});for(const{source:e,encoding:o}of a){const a=Ht(t,o);for(const t of xe(o,{visibleTokens:a}))r.push({severity:"warning",code:"TOKEN_"+t.code,message:t.message,fix:"MISSING_UNIT_VALUE"===t.code?`Set ${e}.unitValue to the value represented by one full token.`:"MISSING_UNIT_MEANING"===t.code?`Set ${e}.unitMeaning so readers know what one full token represents.`:"MISSING_COUNT_STRATEGY"===t.code?`Set ${e}.countStrategy to actual, unitized, fixed-denominator, quantile, sample, posterior-sample, or random-sample.`:"TOKEN_SEMANTICS_UNCLEAR"===t.code?`Set ${e}.tokenSemantics to observed-unit, unitized-measure, risk-case, possible-outcome, posterior-sample, hypothetical-case, topic-anchor, or decorative.`:`Adjust ${e} so its semantics, strategy, labels, and visible token count match the task.`})}}function Yt(e){const t={...e};return delete t.tokenEncoding,delete t.visibleTokens,Gt(t.encoding)&&delete t.encoding,t}function Kt(e,t){const r=t.match(/^Unknown prop "([^"]+)"/);if(r)return`Remove \`${r[1]}\` or replace it with a documented ${e} prop.`;const a=t.match(/^"([^"]+)" is required for .+\.$/i)??t.match(/(?:Missing|required) prop "?([^". ]+)/i);return a?`Add the required \`${a[1]}\` prop using the ${e} schema and example.`:t.startsWith("Unknown component")?"Choose a component returned by getSchema() or check the component name for a typo.":`Correct this ${e} prop configuration to match its schema: ${t}`}function Jt(e,t){void 0!==e.accessibleTable&&t.push({severity:"error",code:"BIGNUMBER_ACCESSIBLE_TABLE",message:"BigNumber is a value component and does not support accessibleTable.",fix:"Remove accessibleTable. Use label, description, and summary to provide BigNumber's accessible text."})}function Xt(e,t){const r=[],a=()=>({ok:r.every(e=>"warning"===e.severity),diagnoses:r}),o=/^(XY|Ordinal|Network|Physics|Geo)CustomChart$/.test(e),n=o?[]:ve(e,Yt(t)).errors;if(o){"function"!=typeof t.layout&&n.push("Provide a layout function.");const r="NetworkCustomChart"===e?["nodes","edges"]:"GeoCustomChart"===e?["points","areas","lines"]:["data"];for(const e of r)null==t[e]||Array.isArray(t[e])||n.push(`Provide an array for ${e}.`)}for(const a of n)"BigNumber"===e&&void 0!==t.accessibleTable&&a.startsWith('Unknown prop "accessibleTable"')||r.push({severity:"error",code:"VALIDATION",message:a,fix:o?a:Kt(e,a)});if("BigNumber"===e&&Jt(t,r),(o||dc[e])&&(St(t,r),jt(t,r),Ie(0,t,r)),!dc[e])return a();Ct(e,t,r),kt(e,t,r),Rt(e,t,r),Pt(e,t,r),It(e,t,r),Et(0,t,r),Tt(e,t,r),Nt(e,t,r);const i=$t(e,t,void 0,{checkOutliers:!1}).diagnoses;for(const e of i)"EMPTY_DATA"===e.code&&r.some(e=>"EMPTY_DATA"===e.code||"EMPTY_EDGES"===e.code)||r.push(e);if(Mt(e,t,r),Ot(e,t,r),Ft(0,t,r),Lt(0,t,r),Bt(e,t,r),zt(e,t,r),_t(0,t,r),Dt(0,t,r),Ut(0,t,r),Vt(0,t,r),Wt(0,t,r),Ee(0,t,r),Ne(0,t,r),Te(0,t,r),Me(e,t,r),Oe(e,t,r),r.some(e=>"NEGATIVE_VALUE"===e.code||"NEGATIVE_NORMALIZED_VALUE"===e.code)||Fe(e,t,r),je(e,t,r),ze(e,t,r),Be(e,t,r),Ke(e,t,r),"ProcessSankey"===e)for(const e of Je(t))r.push(e);return a()}function Zt(e){return"string"==typeof e&&e.trim().length>0}function Qt(e,t,r){const a=dl.has(e)||void 0!==r&&hl.has(r),o=t=>{return o=t,he(r=e)&&!ic[o].includes(r)||a;var r,o},n=ul.filter(e=>Zt(t[e])&&!o(e));return{hasTitle:o("title")&&Zt(t.title),hasDescription:o("description")&&Zt(t.description),hasSummary:o("summary")&&Zt(t.summary),unsupportedFinding:n.length>0?{id:"understandable.unsupported-description-prop",principle:"understandable",heuristic:"Descriptive text is connected to the rendered chart",critical:!0,status:"warn",message:`Useful ${n.join(" and ")} text was supplied, but ${1===n.length?"that prop is":"those props are"} not supported by ${e}'s declared chart API and cannot be credited as rendered accessibility text.`,fix:"Use the component's declared title, description, and summary props when available; for richer generated description or navigation, use ChartContainer with chartConfig plus describe and/or navigable."}:void 0}}function er(e){return!!Array.isArray(e.styleRules)&&e.styleRules.some(e=>{if("object"!=typeof e||null===e)return!1;const t=e.style;if("object"!=typeof t||null===t||Array.isArray(t))return!1;const r=t.fill;return"object"==typeof r&&null!==r&&"hatch"===r.type})}function tr(e){if(!Array.isArray(e))return!1;const t=e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase());return t.length>0&&t.every(e=>pl.has(e))}function rr(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function ar(e,t){return`${e}[Symbol(${t.description??""})]`}function or(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function nr(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function ir(e,t,r,a){const o=nr(e,t);return o&&"value"in o&&o.enumerable?sr(o.value,r,a):[r]}function sr(e,t="$",r=/* @__PURE__ */new Set){if(null===e||"string"==typeof e||"boolean"==typeof e)return[];if("number"==typeof e)return Number.isFinite(e)&&!Object.is(e,-0)?[]:[t];if("object"!=typeof e)return[t];if(r.has(e))return[t];let a,o,n;try{n=Array.isArray(e),a=Object.getPrototypeOf(e),o=Reflect.ownKeys(e)}catch{return[t]}if(a!==(n?Array.prototype:Object.prototype)&&null!==a)return[t];r.add(e);const i=[];try{if(n){const a=nr(e,"length")?.value;if(!Number.isSafeInteger(a)||0>a)return[rr(t,"length")];for(const e of o)"length"===e||"string"==typeof e&&or(e,a)||i.push("symbol"==typeof e?ar(t,e):rr(t,e));for(let o=0;a>o;o+=1)i.push(...ir(e,o+"",rr(t,o),r))}else for(const a of o)"symbol"!=typeof a?i.push(...ir(e,a,rr(t,a),r)):i.push(ar(t,a));return i}catch{return[t]}finally{r.delete(e)}}function cr(){const e=globalThis;return e[fl]||(e[fl]={recipes:/* @__PURE__ */new Map,capabilities:/* @__PURE__ */new Map,layouts:/* @__PURE__ */new Map}),e[fl]}function lr(e){return cr().recipes.get(e)}function ur(e){return cr().layouts.get(e)?.layout}function dr(e){const t=cr().layouts.get(e)?.identity;return t?{...t}:void 0}function hr(e){return"string"==typeof e?lr(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function pr(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?t:null}function fr(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis||null!=pr(e)}function mr(e){const t=e.split(/[.!?]+/).map(e=>e.trim()).filter(Boolean),r=e.trim().split(/\s+/).filter(Boolean);if(0===r.length||0===t.length)return null;let a=0;for(const e of r)a+=gr(e);return r.length/t.length*.39+a/r.length*11.8-15.59}function gr(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;const r=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return r?r.length:1}function yr(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}function br(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function vr(e){const t=br(e),r=e.controls&&"object"==typeof e.controls?e.controls:{};return!0===e.pauseControl||!0===t.pauseControl||!0===r.pause||"function"==typeof r.pause}function wr(e){const t=br(e);return!0===e.settledProjection||!0===t.settledProjection}function Ar(e){const t=br(e);return!0===e.reducedMotionSettle||"settle"===e.reducedMotion||!0===t.reducedMotionSettle||"settle"===t.reducedMotion}function xr(e){const t={id:"perceivable.low-contrast",principle:"perceivable",heuristic:"Low contrast",critical:!0},r=e.colorScheme,a="string"==typeof e.background?e.background:null;if(a&&!a.startsWith("#"))return{...t,status:"manual",message:`Background "${a}" isn't a hex literal (theme/CSS variable) — contrast can't be verified statically.`,fix:'Pass a hex `background` (e.g. "#ffffff"/"#000000"), or verify contrast manually once the theme resolves.'};const o=a??"#ffffff";if(!Array.isArray(r))return{...t,status:"manual",message:"Mark colors come from the theme/CSS variables — contrast can't be verified statically.",fix:"Confirm geometries/large text have ≥ 3:1 and regular text ≥ 4.5:1 contrast against the background."};const n=[];let i=0;for(const e of r){if("string"!=typeof e||!e.startsWith("#"))continue;const t=f(e,o);null!=t&&(i++,3>t&&n.push(`${e} (${t.toFixed(1)}:1)`))}return 0===i?{...t,status:"manual",message:"colorScheme has no parseable hex colors to check.",fix:"Verify contrast manually for non-hex colors."}:n.length>0?{...t,status:"fail",message:`${n.length} color(s) fall below 3:1 contrast vs ${o}: ${n.join(", ")}.`,fix:"Darken (light background) or lighten (dark background) those colors, or use COLOR_BLIND_SAFE_CATEGORICAL."}:{...t,status:"pass",message:`All ${i} checked colorScheme color(s) meet ≥ 3:1 contrast vs ${o}.`}}function $r(e,t,r={}){const a=[],o=lr(e),n=Ic.has(e),i=he(e)||!!o||n,s=!0===r.inChartContainer,c=!0===r.describe,l=!0===r.navigable,u=kc.has(e),d=gc.has(e),{hasTitle:h,hasDescription:p,hasSummary:f,unsupportedFinding:m}=Qt(e,t,o?.frameFamily),g=!1!==t.accessibleTable&&!u,y=h||p||f,b=yr(t),v=vr(t),w=n,A=wr(t)||Nc.has(e)&&g,x=Ar(t)||w,$=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],C=i?"pass":"manual",S=i?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(m&&a.push(m),a.push(xr(t)),a.push({id:"perceivable.content-only-visual",principle:"perceivable",heuristic:"Content is only visual",critical:!0,...u?{status:"pass",message:"BigNumber renders its value as real text with an ARIA label — available without vision."}:g?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:p&&f?{status:"manual",message:"accessibleTable is off; a description + summary are present. Verify they convey everything the chart shows.",fix:"Re-enable accessibleTable, or confirm via screen reader that the text alternative is complete."}:{status:"fail",message:"accessibleTable is disabled and there's no full text alternative — the data is only available visually.",fix:"Remove accessibleTable={false}, or provide a complete description/summary plus a data table."}}),a.push({id:"perceivable.small-text",principle:"perceivable",heuristic:"Small text size",critical:!0,status:"pass",message:"Semiotic's default tick and axis-label fonts are 12px, meeting Chartability's 9pt/12px floor.",fix:"If a theme or override lowers --semiotic-tick-font-size below 12px, raise it back for low-vision audiences."}),a.push({id:"perceivable.seizure-risk",principle:"perceivable",heuristic:"Visual presents seizure risk",critical:!0,...null!=t.pulse||Ec.has(e)?{status:"manual",message:"Pulse/continuous animation is in use. Confirm nothing flashes more than 3×/sec, especially saturated red.",fix:"Avoid red flashes and rapid (>3 Hz) flicker; reduced-motion is auto-honored, but verify the default presentation."}:{status:"manual",message:"No flashing detected statically. Confirm no element flashes more than 3×/sec.",fix:"Manual check — most static charts pass trivially."}}),null!=t.colorBy){const e=!0===t.directLabel||!0===t.showLabels,r=er(t);a.push({id:"perceivable.color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...e?{status:"pass",message:"Categories are encoded by color (colorBy) and also directly labeled, so color isn't the only channel."}:{status:"warn",message:r?"Categories use colorBy and this config authors a HatchFill through styleRules, but a static audit cannot prove those rules give every category a distinct non-color cue. Semiotic does not automatically assign per-category textures.":"Categories are encoded by color (colorBy) with no declared redundant channel. Semiotic supports author-supplied HatchFill patterns through styleRules, but this config has no statically visible HatchFill descriptor and there is no automatic per-category texture assignment.",fix:r?"Verify every category remains distinguishable with color removed; add direct labels where hatching is incomplete, keep categories ≤ ~7, and use a CVD-safe palette.":"Add direct labels (directLabel on LineChart/AreaChart, showLabels on network/hierarchy) or category-targeted styleRules with distinct HatchFill descriptors; keep categories ≤ ~7 and use a CVD-safe palette."}});const o=tr(t.colorScheme);a.push({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1,...o?{status:"pass",message:"colorScheme uses Semiotic's Wong colorblind-safe palette."}:{status:"manual",message:"Color encodes meaning; statically we can't confirm the palette is colorblind-safe.",fix:'Use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic", or test your scheme with Viz Palette / Chroma.'}}),a.push({id:"flexible.textures-adjustable",principle:"flexible",heuristic:"Contrast and textures cannot be adjusted",critical:!1,status:"warn",message:r?"This config uses an author-supplied HatchFill through styleRules, but Semiotic has no automatic, theme-aware per-category texture channel or user-facing texture toggle.":"Semiotic supports author-supplied HatchFill patterns through styleRules, but this config has no statically visible HatchFill descriptor; there is no automatic, theme-aware per-category texture channel or user-facing texture toggle.",fix:r?"Verify the authored hatches cover every meaningful category and remain legible in the active theme; pair them with direct labels and a CVD-safe palette.":"Use category-targeted styleRules with distinct HatchFill descriptors or direct labels so the encoding survives color removal. Contrast itself is themeable via CSS variables."})}{const e=$.filter(Ce);if(e.length>0){const r=t.autoPlaceAnnotations,o="object"==typeof r&&null!==r&&!0===r.redundantCues,n=e.filter(e=>{if("string"!=typeof e.color)return!1;const t=$e(e),r=o&&"text"===t;return!(ke(e)||r)});a.push({id:"perceivable.annotation-association",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...0===n.length?{status:"pass",message:"No annotation relies on color alone to indicate its target — wherever color is used, a connector, enclosure, or reference-line cue is present too."}:{status:"warn",message:`${n.length} of ${e.length} annotation(s) carry a color but no connector, enclosure, or reference-line cue, so a color-blind or non-visual reader can't tie them to their target (the correspondence problem).`,fix:"Add a connector (the label/callout default), place the note adjacent to its target, enclose the target, or enable autoPlaceAnnotations: { redundantCues: true } to give colored text notes a leader line — don't rely on color matching alone."}})}}a.push({id:"operable.single-input-modality",principle:"operable",heuristic:"Interaction modality only has one input type",critical:!0,...i?{status:"pass",message:"Built-in keyboard navigation (arrows/Home/End/PageUp-Down/Enter) mirrors mouse hover."}:{status:"manual",message:`Can't confirm keyboard support for "${e}".`,fix:"Verify Tab + arrow-key operation."}});{const e=[];null==t.brush&&null==t.onBrush||e.push("brushing"),!0===t.zoomable&&e.push("zoom/pan"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||e.push("legend filtering"),e.length>0&&a.push({id:"operable.complex-action-alternatives",principle:"operable",heuristic:"Complex actions have no alternatives",critical:!1,status:"warn",message:`Mouse-driven ${e.join(", ")} ${e.length>1?"have":"has"} no built-in keyboard/standard-UI equivalent.`,fix:"Pair the complex interaction with a standard control (range inputs for a brush, buttons for zoom, a checkbox list for legend filtering) operable by keyboard and screen reader."})}{const r=jc[e];if(r&&b){const e=t[r];"number"==typeof e&&e>0&&24>2*e&&a.push({id:"operable.target-size",principle:"operable",heuristic:"Target pointer interaction size is too small",critical:!1,status:"warn",message:`${r}=${e} gives a ~${2*e}px hit target, below the 24×24px minimum for pointer interaction.`,fix:"Increase the radius, or rely on the chart's hoverRadius / keyboard navigation as the alternative for precise selection."})}}a.push({id:"operable.tab-stops",principle:"operable",heuristic:"Inappropriate tab stops",critical:!1,status:C,message:`The chart takes a single tab stop and navigates data with arrow keys${S} — the recommended pattern for dense charts (no per-datum tab stops to wade through).`}),a.push({id:"operable.interaction-cues",principle:"operable",heuristic:"No interaction cues or instructions",critical:!0,...b?f||p?{status:"manual",message:"Chart is interactive and has descriptive text. Confirm that text explains how to interact (keyboard + pointer).",fix:'State the interaction model in summary, e.g. "Use arrow keys to move between points."'}:{status:"warn",message:"Chart is interactive but nothing explains how to use it.",fix:"Describe the interaction in a summary or nearby text (keyboard navigation, what hover/click reveals)."}:{status:"not-applicable",message:"No interactive behavior detected."}}),a.push({id:"operable.controls-override-at",principle:"operable",heuristic:"Controls override AT controls",critical:!0,status:C,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${S}.`}),a.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:C,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${S}.`,fix:i?"Ensure --semiotic-focus keeps ≥ 3:1 contrast against your background.":void 0}),a.push({id:"understandable.title-summary-caption",principle:"understandable",heuristic:"No title, summary, or caption",critical:!0,...y?{status:"pass",message:`Provided: ${[h&&"title",p&&"description",f&&"summary"].filter(Boolean).join(", ")}.`}:s?{status:"manual",message:"No title/description/summary on the chart. If the wrapping ChartContainer supplies a title/subtitle, this is covered at that layer — verify it does.",fix:"Give the ChartContainer a title (and optionally enable describe), or set title/description/summary on the chart."}:{status:"fail",message:"No title, description, or summary — the screen reader falls back to a generic label.",fix:"Add title/description/summary on the chart, or wrap it in a ChartContainer (the opt-in layer for title/caption/description chrome)."}}),a.push({id:"understandable.explain-purpose",principle:"understandable",heuristic:"No explanation for purpose or for how to read",critical:!0,...p||f?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:c?{status:"manual",message:"ChartContainer's describe option explains how to read the chart (type, stats, trend). Confirm the domain purpose — why this chart exists — is also conveyed (title/subtitle).",fix:"Give the ChartContainer a title/subtitle stating the purpose; describe() covers the how-to-read half."}:h?{status:"warn",message:"Only a title is set — a label, not an explanation of purpose or how to read the chart.",fix:"Add a summary, or enable ChartContainer's describe option for an auto-generated how-to-read description."}:{status:"fail",message:"Nothing explains the chart's purpose or how to read it.",fix:"Add a summary/description, or wrap in a ChartContainer with a title and the describe option (the opt-in full-accessibility layer)."}});{const e=[t.description,t.summary].filter(Zt).join(". "),r=e?mr(e):null;a.push({id:"understandable.reading-level",principle:"understandable",heuristic:"Reading level inappropriate",critical:!0,...null==r?{status:"not-applicable",message:"No description/summary text to grade."}:r>9?{status:"warn",message:`Description/summary reads at ~grade ${r.toFixed(0)}; Chartability targets grade 9 or lower.`,fix:"Shorten sentences and prefer common words."}:{status:"pass",message:`Description/summary reads at ~grade ${Math.max(0,Math.round(r))} (≤ 9).`}})}if(Rc.has(e)){const e=Zt(t.xLabel),r=Zt(t.yLabel);a.push({id:"understandable.axis-labels",principle:"understandable",heuristic:"Axis labels are unclear or missing",critical:!1,...e&&r?{status:"pass",message:"Both axes are labeled (xLabel, yLabel)."}:{status:"warn",message:`Missing axis label: ${[!e&&"xLabel",!r&&"yLabel"].filter(Boolean).join(", ")}. Ticks alone may not name the variable.`,fix:"Set xLabel and yLabel to name each axis's variable and units."}})}if(Oc.has(e)&&a.push({id:"understandable.information-complexity",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,status:"warn",message:"Dual-axis chart: two y-scales are hard to read accurately and notoriously easy to misinterpret (the crossover point is arbitrary).",fix:"Confirm the second axis is necessary; consider two aligned charts (small multiples) or indexing both series to a common baseline. Label each axis and its series unambiguously."}),$.length>1){const e=$.filter(fr).length;a.push({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,...e===$.length?{status:"pass",message:`All ${$.length} annotation(s) declare hierarchy through emphasis or provenance confidence, so the renderer can resolve reading order and visual priority.`}:0===e?{status:"warn",message:$.length+" annotations are present with no emphasis or provenance confidence; readers may not know which note is primary.",fix:'Mark the main annotation with emphasis="primary", set supporting notes to emphasis="secondary", or provide provenance.confidence so Semiotic can infer order.'}:{status:"warn",message:`${$.length-e} of ${$.length} annotation(s) have no emphasis or provenance confidence; readers may not know which note is primary among the unordered notes.`,fix:"Set emphasis on each annotation (primary/secondary), or provide provenance.confidence on all annotations so Semiotic can infer order."}})}(null!=t.forecast||null!=t.anomaly||null!=t.band||null!=t.regression)&&a.push({id:"understandable.uncertainty",principle:"understandable",heuristic:"Statistical uncertainty isn't clearly communicated",critical:!1,status:"manual",message:"The chart shows a forecast/regression/band/anomaly overlay. Confirm the uncertainty it represents is explained in text, not just drawn.",fix:"State the confidence interval / method in the summary, and label the band so it isn't mistaken for data."}),null!=t.animate&&!1!==t.animate&&a.push({id:"understandable.changes-followable",principle:"understandable",heuristic:"Changes are not easy to follow",critical:!1,status:C,message:`Transitions animate with object constancy and data changes are mirrored to the live region${S}.`,fix:i?"Keep transition durations in the 250ms–2s range so changes are followable but not slow.":void 0}),a.push({id:"robust.conforms-to-standards",principle:"robust",heuristic:"Does not conform to standards",critical:!1,status:"manual",message:"WCAG 2.1 / Section 508 conformance can't be settled from config alone.",fix:"Run an automated checker (axe) on the rendered output and test with real assistive tech."}),a.push({id:"robust.semantically-valid",principle:"robust",heuristic:"Semantically invalid",critical:!1,status:"manual",message:"Whether interactive elements expose correct roles/names is a render-time, screen-reader question.",fix:"Verify with a screen reader that buttons read as buttons, the chart as an image/group, etc."}),a.push({id:"robust.fragile-technology-support",principle:"robust",heuristic:"Fragile technology support",critical:!1,status:C,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${S}.`,fix:i?"Still test across NVDA+Firefox, JAWS+Chrome, and VoiceOver+Safari — AT support varies.":void 0}),a.push({id:"compromising.table",principle:"compromising",heuristic:"No table",critical:!0,...u?{status:"not-applicable",message:"Single-value display — a table isn't meaningful."}:g?{status:"pass",message:"A human-readable data table is provided (accessibleTable)."}:{status:"fail",message:"accessibleTable is disabled — no human-readable table of the underlying data.",fix:"Remove accessibleTable={false} (unless title/summary/annotations already convey all the data)."}}),u||a.push({id:"compromising.table-static",principle:"compromising",heuristic:"Table/data is static",critical:!1,...s?{status:"manual",message:"Rendered in a ChartContainer. If a data-download action is enabled, the data is exportable.",fix:"Enable the ChartContainer data-download action so users can save the underlying data (keep it opt-in)."}:{status:"warn",message:"The data table is read-only — not downloadable, sortable, or filterable.",fix:"Wrap the chart in a ChartContainer and enable its data-download action (opt-in, so deployments can withhold it where export isn't allowed)."}}),a.push({id:"compromising.shareable-state",principle:"compromising",heuristic:"State is not easy to share and reproduce",critical:!1,status:i?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${i?"":S}.`,fix:i?"Expose it to users via the ChartContainer copyConfig action or a shareable URL.":void 0}),a.push({id:"compromising.navigable-structure",principle:"compromising",heuristic:"Information cannot be navigated according to narrative or structure",critical:!1,...l?d?{status:"pass",message:"ChartContainer's navigable option mounts a structured navigation tree, including hierarchy/network branches and their data items."}:{status:"pass",message:"ChartContainer's navigable option mounts a structured tree (chart → axes/series → data points) that screen readers can traverse."}:d?{status:"warn",message:"Hierarchical chart: built-in keyboard navigation is largely flat — it doesn't descend the tree structure.",fix:"Enable ChartContainer's navigable option for a structured navigation tree, or lean on the data table and a summary that conveys the hierarchy."}:{status:C,message:`Keyboard navigation steps through points and switches series/groups${S}.`,fix:i?"For deeper structure (axis → series → datum), enable ChartContainer's navigable option.":void 0}});{const r=Array.isArray(t.data)?t.data:null,o=Array.isArray(t.nodes)?t.nodes:null,n={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};let i;i=Cc.has(e)&&r&&r.length>7?{...n,status:"warn",message:r.length+" slices in a part-to-whole chart. Chartability suggests ≤ 5 categories; many thin slices are hard to perceive and to describe.",fix:'Group small slices into an "Other" category, or switch to a ranked bar chart.'}:o&&o.length>200?{...n,status:"warn",message:o.length+" nodes. A network this size is hard to navigate non-visually node by node.",fix:"Provide a summary of structure (clusters, hubs, components) and consider filtering or aggregating the graph."}:r&&r.length>5e3?{...n,status:"warn",message:r.length+" data points. Canvas renders this fine, but the non-visual table/navigation become unwieldy.",fix:"Aggregate or bin for the accessible representation, or expose summary statistics rather than every row."}:r?{...n,status:"pass",message:r.length+" data points — a reasonable density for non-visual consumption."}:o?{...n,status:"pass",message:o.length+" nodes — a reasonable density for non-visual consumption."}:{...n,status:"manual",message:"Data not provided inline (push mode); verify density at runtime."},a.push(i)}{const e=Array.isArray(t.data)?t.data:null,r=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]);let o=!1;if(e&&!r)for(const t of e.slice(0,50))if(t&&"object"==typeof t){for(const e of Object.values(t))if("number"==typeof e&&Number.isFinite(e)&&Math.abs(e)>=1e5){o=!0;break}if(o)break}o&&a.push({id:"assistive.human-readable-numbers",principle:"assistive",heuristic:"Data in text is not human-readable",critical:!1,status:"warn",message:'Data includes large numbers (≥ 100,000) and no value/tick formatter — screen readers will read every digit (e.g. "six hundred fifty thousand…").',fix:'Pass valueFormat / yFormat (e.g. a compact formatter so 6,500,000 reads as "6.5M"); the formatter flows to ticks, tooltips, and the data table.'})}a.push({id:"assistive.features-described",principle:"assistive",heuristic:"Visually apparent features and relationships are not described",critical:!1,...c?{status:"pass",message:"ChartContainer's describe option auto-generates an L1–L3 description (chart type, statistics, and trend) via describeChart()."}:f?{status:"manual",message:"A summary is present. Confirm it describes trends, extrema, clusters, and outliers — not just what the chart is.",fix:"Cover the L2/L3 content blind readers value most: direction of trend, peak/trough, notable outliers."}:{status:"warn",message:"No text describes the visually apparent trends, extrema, or outliers.",fix:"Enable ChartContainer's describe option (auto-generates via describeChart()), or write a summary covering the key trend and notable points."}}),a.push({id:"assistive.skippable-navigation",principle:"assistive",heuristic:"Navigation and interaction is tedious",critical:!0,...u?{status:"not-applicable",message:"Single value — nothing to skip."}:g?{status:"pass",message:'A "Skip to data table" link lets screen-reader users bypass point-by-point navigation.'}:{status:"warn",message:"accessibleTable is off, removing the skip-to-table affordance.",fix:"Keep accessibleTable enabled so users can skip past dense point navigation."}}),a.push({id:"flexible.user-style-respected",principle:"flexible",heuristic:"User style change not respected",critical:!0,status:C,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${S}.`,fix:i?"Avoid hardcoding colors via frameProps style fns that bypass theme variables.":void 0}),a.push({id:"flexible.reduced-motion",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...Ec.has(e)||Mc.has(e)?v?{status:"pass",message:e+" animates continuously and declares an in-chart pause/stop control."}:{status:"warn",message:e+" animates continuously. prefers-reduced-motion is auto-honored, but there's no in-chart pause/stop control for users who don't set that preference.",fix:"Offer a pause/stop control for looping/streaming motion (Chartability requires it for animation > 2s)."}:{status:C,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${S}.`}}),n&&(a.push({id:"flexible.sim-pause-control",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...v?{status:"pass",message:"Physics simulation exposes a pause/stop control for users who need to stop motion."}:{status:"warn",message:"Physics simulation has no declared pause/stop control.",fix:"Provide a visible pause control and set physics.pauseControl=true (or pauseControl=true) so the contract is auditable."}}),a.push({id:"flexible.settled-projection",principle:"flexible",heuristic:"User style change not respected",critical:!1,...A?{status:"pass",message:"A settled-projection table is declared, so non-visual readers get aggregate chart semantics instead of trajectories."}:{status:"warn",message:"Physics chart does not declare a settled projection for its accessible table.",fix:"Provide aggregate rows from the settled projection and set physics.settledProjection=true."}}),a.push({id:"flexible.reduced-motion-settle",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...x?{status:"pass",message:"Reduced-motion mode settles the simulation to a static chart state instead of freezing bodies mid-flight."}:{status:"warn",message:"Physics chart does not declare reduced-motion synchronous settle behavior.",fix:"In reduced motion, run the world to its settled projection and paint once; set physics.reducedMotionSettle=true."}}));{const r=!0===t.responsiveWidth||!0===t.responsiveHeight,o=Fc.has(e)&&!0===t.zoomable;a.push({id:"flexible.zoom-reflow",principle:"flexible",heuristic:"Zoom and reflow are not supported",critical:!1,...r?{status:"pass",message:`Chart reflows to its container (${[!0===t.responsiveWidth&&"responsiveWidth",!0===t.responsiveHeight&&"responsiveHeight"].filter(Boolean).join(", ")}), so page zoom doesn't clip it.`}:o?{status:"pass",message:"Geo chart is zoomable/pannable."}:{status:"manual",message:"Fixed width/height — verify the chart survives browser zoom and reflow without clipping or loss of function.",fix:"Use responsiveWidth/responsiveHeight so the chart reflows to its container."}})}if(o){const e=o.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));e&&a.push({id:"perceivable.recipe-color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,status:"warn",message:o.name+" declares a color encoding without a redundant cue.",fix:"Add shape, label, position, texture, or a textual category summary to the recipe encoding."}),"required"!==o.accessibility.description||p||a.push({id:"understandable.recipe-description",principle:"understandable",heuristic:"Features are not described",critical:!1,status:"fail",message:o.name+" requires a recipe-aware description, but none is attached.",fix:"Call describeChart with recipeId/recipe metadata and attach the returned text as description."}),o.accessibility.fallbackTable&&!1===t.accessibleTable&&a.push({id:"compromising.recipe-fallback",principle:"compromising",heuristic:"No data table is provided",critical:!0,status:"fail",message:o.name+" requires a fallback table, but accessibleTable is disabled.",fix:"Enable accessibleTable and preserve recipe-declared table fields on scene nodes."})}const k=a.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),R={criticalsPassed:k.filter(e=>"pass"===e.status).length,criticalsEvaluated:k.length,fails:a.filter(e=>"fail"===e.status).length,warnings:a.filter(e=>"warn"===e.status).length,manual:a.filter(e=>"manual"===e.status).length,passes:a.filter(e=>"pass"===e.status).length};return{component:e,ok:!k.some(e=>"fail"===e.status),summary:R,findings:a,reference:ml}}function Cr(e,{onlyCritical:t=!1}={}){const r=[];for(const a of e.findings)"fail"!==a.status&&"warn"!==a.status||t&&!a.critical||r.push(a.message);return r}function Sr(e){const t=[],r=e.summary,a=e.ok?`${r.criticalsPassed}/${r.criticalsEvaluated} critical heuristics pass`:`${r.fails} blocking failure(s) — ${r.criticalsPassed}/${r.criticalsEvaluated} critical heuristics pass`;t.push(`${e.ok?"✓":"✗"} ${e.component}: accessibility audit (Chartability POUR-CAF)`),t.push(` ${a} · ${r.warnings} warning(s) · ${r.manual} to verify manually`);for(const r of yl){const a=e.findings.filter(e=>e.principle===r&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+r.toUpperCase());for(const e of a)t.push(` ${gl[e.status]} ${e.id}${e.critical?" [critical]":""}: ${e.message}`),!e.fix||"fail"!==e.status&&"warn"!==e.status&&"manual"!==e.status||t.push(" → "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function kr(e){return e.semanticDiagnostics?.length?e.semanticDiagnostics:"degenerate"===e.semanticStatus?[bl]:[]}function Rr(e){const{contract:t,transfer:r,binding:a}=e;if(void 0===t&&void 0===r&&void 0===a)return[];const o=[],n=Array.isArray(a?.mismatchPaths)?a.mismatchPaths.filter(e=>"string"==typeof e):[];return r&&"preserved"!==r.status&&"excluded"!==r.status?o.push({id:"artifact.transfer-invalid",status:"fail",message:`The attached artifact transfer is ${r.status}; its contract cannot be relied on for publication.`}):r&&void 0!==t||o.push({id:"artifact.transfer-unknown",status:"unknown",message:"The attached artifact lacks a contract or a transfer report."}),"mismatch"===a?.status||n.length>0?o.push({id:"artifact.identity-mismatch",status:"fail",message:"The attached artifact does not identify this chart input"+(n.length?": "+n.join(", "):".")}):"match"===a?.status&&Array.isArray(a.mismatchPaths)&&Array.isArray(a.unknownPaths)&&0>=a.mismatchPaths.length&&0>=a.unknownPaths.length||o.push({id:"artifact.identity-unknown",status:"unknown",message:"The attached artifact identity has not been fully verified."}),o}function Pr(e){return e.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Ir(e,t,r){return{id:`${t}.${e.code.toLowerCase()}.${r+1}`,stage:t,severity:e.severity,code:e.code,message:e.message,...e.fix?{fix:e.fix}:{},source:"data"===t?"auditData":"diagnoseConfig",...e.field?{field:e.field}:{},...e.role?{role:e.role}:{},...e.rows?{rows:e.rows}:{},...void 0!==e.count?{count:e.count}:{}}}function Er(e,t){return{id:e.id||"accessibility."+(t+1),stage:"accessibility",severity:"fail"===e.status?"error":"warn"===e.status?"warning":"manual",code:e.id,message:e.message,...e.fix?{fix:e.fix}:{},source:"auditAccessibility",critical:e.critical,principle:e.principle,heuristic:e.heuristic}}function Nr(e){return e.map((e,t)=>({finding:e,index:t})).sort((e,t)=>{const r=vl[e.finding.severity]-vl[t.finding.severity];if(0!==r)return r;const a=!0===e.finding.critical;if(a!==(!0===t.finding.critical))return a?-1:1;const o=wl[e.finding.stage]-wl[t.finding.stage];return 0!==o?o:e.index-t.index}).map(({finding:e},t)=>({...e,rank:t+1}))}function Tr(e,t){const r=[];e.component!==t&&r.push({id:"render.component-mismatch",stage:"render",severity:"error",code:"RENDER_COMPONENT_MISMATCH",message:"The render evidence names a different chart component.",source:"renderChartWithEvidence"});for(const t of Rr({contract:e.artifactContract,transfer:e.artifactTransfer,binding:e.artifactBinding}))r.push({id:"render."+t.id,stage:"render",severity:"fail"===t.status?"error":"manual",code:t.id.toUpperCase().replace(/[.-]/g,"_"),message:t.message,source:"artifactAttachmentIssues"});e.empty&&r.push({id:"render.empty-scene",stage:"render",severity:"error",code:"EMPTY_SCENE",message:"The renderer produced no data marks.",fix:"Check the data shape, accessors, scales, and filters against the rendered evidence.",source:"renderChartWithEvidence"});const a=/* @__PURE__ */new Set;for(const t of kr(e))a.add(t.code),r.push({id:"render."+t.code.toLowerCase(),stage:"render",severity:t.severity,code:t.code,message:t.message,...t.fix?{fix:t.fix}:{},source:"capability.semanticViability"});for(const t of e.warnings)a.has(t)||r.push({id:"render."+t.toLowerCase(),stage:"render",severity:"warning",code:t,message:`The renderer reported ${Pr(t).toLowerCase()}.`,fix:"Inspect the render evidence and resolve the warning before relying on the chart.",source:"renderChartWithEvidence"});return r}function Mr(e,t){const r=e.filter(e=>"manual"!==e.severity),a=r.slice(0,t).map(e=>({id:"chart-evaluation-"+e.id,level:"error"===e.severity?"error":"warning",title:`${e.stage}: ${Pr(e.code)}`,message:e.fix?`${e.message} ${e.fix}`:e.message,source:"Semiotic chart evaluation",dismissible:!0}));return r.length>t&&a.push({id:"chart-evaluation-overflow",level:"warning",title:"Additional chart evaluation findings",message:r.length-t+" additional finding(s) are available in the ranked evaluation result.",source:"Semiotic chart evaluation",dismissible:!0}),a}function Or(e){const t=[`${e.component}: ${e.ok?"PASS":"ISSUES FOUND"}`,`${e.summary.errors} error(s) · ${e.summary.warnings} warning(s) · ${e.summary.manual} manual check(s)`];for(const r of e.findings)t.push(`${r.rank}. [${r.stage}/${r.code}] ${r.message}`),r.fix&&t.push(" Fix: "+r.fix);return t.join("\n")}function Fr(e,t={},r,a={}){const o=void 0===r?t:{...t,data:r},n=ve(e,o),i=$t(e,o,r,a.dataAudit),s=Xt(e,o).diagnoses.filter(e=>"data"!==e.domain&&"VALIDATION"!==e.code),c=$r(e,o,{inChartContainer:a.inChartContainer,describe:a.describe,navigable:a.navigable}),l=[];for(const[e,t]of n.errors.entries())l.push({id:"validation."+(e+1),stage:"deception",severity:"error",code:"VALIDATION",message:t,fix:"Correct the component name, required props, prop types, and data shape.",source:"validateProps"});let u;i.diagnoses.forEach((e,t)=>{l.push(Ir(e,"data",t))}),s.forEach((e,t)=>{l.push(Ir(e,"deception",t))}),c.findings.filter(e=>"pass"!==e.status&&"not-applicable"!==e.status).forEach((e,t)=>{l.push(Er(e,t))});const d=l.some(e=>"error"===e.severity&&"accessibility"!==e.stage);if(a.render&&n.valid&&!d)try{u=a.render(e,o).evidence,l.push(...Tr(u,e))}catch{l.push({id:"render.failed",stage:"render",severity:"error",code:"RENDER_FAILED",message:"The injected renderer failed before producing render evidence.",fix:"Check the chart configuration and renderer-specific requirements.",source:"renderChartWithEvidence"})}const h=Nr(l),p=h.filter(e=>"error"===e.severity).length,f=h.filter(e=>"warning"===e.severity).length,m=h.filter(e=>"manual"===e.severity).length,g=Mr(h,Math.max(0,Math.floor(a.notificationMax??8)));return{component:e,validation:n,data:i,deception:s,accessibility:c,...u?{evidence:u}:{},ok:0===p,summary:{errors:p,warnings:f,manual:m,findings:h.length,notifications:g.length},findings:h,notifications:g}}function jr(e,t=8){return Mr(e,Math.max(0,Math.floor(t)))}function zr(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Br(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}function Lr(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}function _r(e,t){const{when:r}=e,a=t.width,o=t.height,n=Lr(t),i=Br(t);return!("number"==typeof r.minWidth&&r.minWidth>a||"number"==typeof r.maxWidth&&a>r.maxWidth||"number"==typeof r.minHeight&&("number"!=typeof o||r.minHeight>o)||"number"==typeof r.maxHeight&&("number"!=typeof o||o>r.maxHeight)||"number"==typeof r.minAspectRatio&&("number"!=typeof n||r.minAspectRatio>n)||"number"==typeof r.maxAspectRatio&&("number"!=typeof n||n>r.maxAspectRatio)||r.orientation&&i!==r.orientation)}function Dr(e,t){const r={...e,...t};for(const a of["margin","frameProps","mobileSemantics","style"])zr(e[a])&&zr(t[a])&&(r[a]={...e[a],...t[a]});return"string"==typeof e.className&&"string"==typeof t.className&&(r.className=`${e.className} ${t.className}`),r}function Ur(e,t,r=e.responsiveRules){if(!Array.isArray(r)||0===r.length)return{props:e,matches:[]};const a=r.map((e,t)=>({rule:e,index:t})).filter(e=>_r(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:a.reduce((e,t)=>Dr(e,t.rule.transform),e),matches:a}}function Vr(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Gr(e){return"string"==typeof e&&e.trim().length>0}function qr(e){const t=Vr(e.capability)?e.capability:null,r=Vr(e.recipe)?e.recipe:null,a=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,r?.mobile];for(const e of a)if(Vr(e))return e;return null}function Hr(e,t){return e.includes("CustomChart")||e.includes("Custom")||null!=t.recipeId||null!=t.mobileSemantics}function Wr(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 Yr(e){return Wr(e.size)||Wr(Vr(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function Kr(e){const t=qr(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}function Jr(e){const t=qr(e),r=Vr(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===r?.tapToSelect||!0===r?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||Gr(t?.interaction?.hoverFallback)}function Xr(e,t){const r=qr(e),a=Vr(e.mobileInteraction)?e.mobileInteraction:null,o=a?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(r?.interaction?.alternatives)&&r.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))}function Zr(e){const t=Vr(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!Jr(e)}function Qr(e){const t=[e.data,e.points,e.lines,e.nodes,e.edges,e.areas,Vr(e.frameProps)?e.frameProps.data:void 0];let r=0;for(const e of t)Array.isArray(e)&&(r+=e.length);return r}function ea(e){const t=[e.tickValues,e.xTickValues,e.yTickValues,e.rTickValues,e.oTickValues];let r=0;for(const e of t)Array.isArray(e)&&(r+=e.length);return r>0?r:null}function ta(e,t){const r=$l[e];if(!r)return null;let a=r.includes("hoverRadius")?30:null;for(const e of r){const r=t[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(a=null==a?r:Math.max(a,r))}return null==a?null:2*a}function ra(e,t){e.push({...t,status:"pass"})}function aa(e,t){e.push({...t,status:"warn"})}function oa(e,t){e.push({...t,status:"manual"})}function na(e,t={},r={}){const a=r.viewportWidth??390,o=r.targetSize??44,n=Yr(t),i=Ur(t,{width:a,height:n?.[1]}),s=[],c=Yr(t=i.props),l=qr(t),u=Hr(e,t),d=Kr(t),h=!0===r.inChartContainer,p=Gr(t.title)||Gr(t.summary)||Gr(t.description)||!0===l?.summary||Gr(l?.summary);if(i.matches.length>0&&ra(s,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${i.matches.length} responsive rule(s) applied for the ${a}px mobile audit.`}),c){const[t,r]=c;t>a&&!d?aa(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${a}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."}):ra(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof l?.minViewportWidth&&l.minViewportWidth>a&&aa(s,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${l.minViewportWidth}px minimum, wider than the audited ${a}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,r);430>=a&&o>2.4&&"BigNumber"!==e&&aa(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>r&&"BigNumber"!==e&&aa(s,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${r}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 oa(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=Qr(t);f>0&&(f>("number"==typeof l?.maxMarks?l.maxMarks:xl.has(e)?1.25*a:Pc.has(e)?Math.max(8,Math.floor(a/34)):a)?aa(s,{id:"density.mark-budget",category:"density",impact:xl.has(e)?"medium":"high",message:`${f} data item(s) exceed the rough mobile density budget for ${e} at ${a}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):ra(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 m=ea(t),g=!1!==t.showAxes&&!1!==t.axis;if(g&&null!=m){const e=Math.max(3,Math.floor(a/58));m>e&&aa(s,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${m} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${a}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else g&&(xl.has(e)||Pc.has(e))&&oa(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."});Zr(t)?aa(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."}):ra(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."});const y=ta(e,t),b=Vr(t.mobileInteraction)?t.mobileInteraction:null,v=y??("number"==typeof b?.targetSize?b.targetSize:!0===t.mobileInteraction?44:"number"==typeof l?.minimumHitTarget?l.minimumHitTarget:"number"==typeof l?.interaction?.targetSize?l.interaction.targetSize:null);null!=v&&(24>v?aa(s,{id:"interaction.target-size-minimum",category:"interaction",impact:"high",message:`Small interactive marks expose an estimated ${v}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>v?aa(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}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."}):ra(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}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&&!Xr(t,w)&&aa(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"===l?.labels?.strategy||"inline"===l?.labels?.strategy||"external"===l?.labels?.strategy||a>430||aa(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 A=Array.isArray(t.annotations)?t.annotations.filter(e=>Vr(e)):[];if(A.length>("number"==typeof l?.maxAnnotations?l.maxAnnotations:3)&&430>=a&&aa(s,{id:"annotation.mobile-density",category:"annotation",impact:"medium",message:A.length+" annotation(s) compete for phone plot space.",fix:"Assign annotation priority, collapse secondary notes into a callout list, or provide shorter mobileText."}),A.length>0){const e=A.filter(e=>!Gr(e.mobileText)&&!Gr(e.shortText)&&!Gr(e.label));e.length>0&&oa(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."})}d||"BigNumber"===e||oa(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."}),u&&(l?(ra(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===l.custom?.dataBearingSceneNodes?aa(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!==l.custom?.dataBearingSceneNodes&&oa(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."})):oa(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."})),p||h||aa(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 x=s.filter(e=>"warn"===e.status),$={highRisk:x.filter(e=>"high"===e.impact).length,warnings:x.length,manual:s.filter(e=>"manual"===e.status).length,passes:s.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:a,ok:0===$.highRisk,summary:$,findings:s,reference:Al}}function ia(e){const t=[],r=e.summary,a=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${r.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${a} - ${r.warnings} warning(s) - ${r.manual} manual check(s)`);for(const r of Sl){const a=e.findings.filter(e=>e.category===r&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+r.toUpperCase());for(const e of a)t.push(` ${Cl[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 sa(){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."]}function ca(e,t){if("function"==typeof e)return t=>+e(t);const r=e||t;return e=>+e[r]}function la(e,t){if("function"==typeof e)return e;const r=e||t;return e=>e[r]}function ua(){const e=globalThis;return e[kl]??(e[kl]={intents:/* @__PURE__ */new Map}),e[kl]}function da(e,t){return Pl.has(e)||Il.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 ha(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const r=e[t];if("string"==typeof r&&r)return r}}function pa(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function fa(e,t={}){const r=!0===t.showRetractedAnnotations,a=!0===t.showSupersededAnnotations,o=/* @__PURE__ */new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!r)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!a)})}function ma(e){return"string"==typeof e?e:e.id??e.name}function ga(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function ya(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 ba(e,t,r){return r??hr(t.recipe)??hr(t.recipeId)??lr(e)}function va(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 o=r.find(e=>e&&"object"==typeof e);if(!o)return;const n=Object.entries(o).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?n.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in o):n.find(([,e])=>"string"==typeof e)?.[0]}function wa(e,t){return e.dataRoles.find(e=>e.role===t)}function Aa(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function xa(e,t,r,a,o,n={}){const i={...n};if(t)for(const[e,r]of Object.entries(t))i[e]=r;for(const e of r.dataRoles){const r=va(e,a,o),n=t&&r?t[r]:r;void 0!==n&&(i[e.role]=n)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const r=i[t];return null==r?`{${t}}`:r+""})}function $a(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})}}}function Ca(e,t,r,a){const o=Aa(e,["nominal","ordinal"]),n=Aa(e,["quantitative"]),i=o?va(o,r,t):void 0,s=n?va(n,r,t):void 0,c=o?.role??i??"category",l=n?.role??s??"value",u=e.encodings??[],d=u.length?u.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${c} and ${l} are mapped through the recipe's declared visual semantics`,{number:h,percent:p}=$a(a),f=/* @__PURE__ */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],v=g>0?((y?.[1]??0)+(b?.[1]??0))/g:0,w=e.intents.map(e=>({id:ma(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,A=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${c} and ${l}. ${x=d,x?x.charAt(0).toUpperCase()+x.slice(1):x}.`,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>v?`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(v)}.`,l4:`The chart is intended for ${w??"explanation"}${A?` with a ${A} audience`:""}: ${e.designContract.whyCustom}`};var x}function Sa(e,t,r={}){const a=ya(t),o=ga(t),n=r.locale??"en",i="function"==typeof e.description?e.description({data:a,config:o,locale:n}):void 0,s=i?.levels??Ca(e,a,o,n),c=r.levels??["l1","l2","l3","l4"],l={};for(const e of c)s[e]&&(l[e]=s[e]);const u=["l1","l2","l3","l4"].map(e=>l[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:l,...d?.length?{caveats:d}:{}}}function ka(e){const t=Math.max(2,Math.round(e.bins)),r=Math.max(1,Math.round(e.pegRows??t-1)),a=Math.max(1,Math.round(e.count??Math.max(64,4*t))),o=(n=Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,Math.max(0,Math.min(1,n)));var n;const i=Ve(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:a},(e,t)=>{let a=0;for(let e=0;r>e;e+=1)i()<o&&(a+=1);const n=r/2;return{id:`${s}-${t}`,value:a,mechanical:!0,pegRows:r,branchProbability:o,pathRights:a,side:n>a?"left":a>n?"right":"center"}})}function Ra(e){const{windowSize:t,watermark:r,watermarkAtArrivalAccessor:a}=e;if(!Number.isFinite(t)||0>=t)throw new RangeError("EventDrop windows.size must be a finite positive number");const{rows:o}=He(e.data,"event"),n=o.flatMap((t,r)=>{const a=_e(Le(t,r,e.timeAccessor));return null==a?[]:[{datum:t,index:r,eventTime:a,arrivalTime:_e(Le(t,r,e.arrivalAccessor))??a,watermarkAtArrival:0,late:!1}]}),i="function"==typeof r?null:_e(r?.value),s="function"==typeof r?t:_e(r?.delay)??t;let c=-1/0,l=-1/0;for(const e of n.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){c=Math.max(c,e.eventTime);const o="function"==typeof r?_e(r(c)):c-s;l=i??Math.max(l,o??c-t);const n=a?_e(Le(e.datum,e.index,a)):null;e.watermarkAtArrival=n??l,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:n,watermarkValue:n.length?l:i??-s}}function Pa(e,t){const r="mechanical"===(t.simulationMode??t.mode)&&("GaltonBoardChart"===e||"UnitPileChart"===e);if(!Array.isArray(t.data)&&!r)return null;let a=Array.isArray(t.data)?t.data:[];const o=Math.max(2,Math.round(_e(t.bins)??21)),n=Math.max(1,Math.round(_e(t.pegRows)??o-1));if(r&&(a="GaltonBoardChart"===e?ka({bins:o,count:t.mechanicalCount,pegRows:n,branchProbability:t.branchProbability,seed:t.seed}):Ge({count:t.mechanicalCount,categories:t.mechanicalCategories,unitValue:t.unitValue,seed:t.seed})),a=He(a,"UnitPileChart"===e?"pile":"GaltonBoardChart"===e?"galton":"EventDropChart"===e?"event":"collision-swarm").rows,"UnitPileChart"===e){const e=/* @__PURE__ */new Map,o=t.valueAccessor??(r?"value":void 0);return a.forEach((r,a)=>{const n=(Le(r,a,t.categoryAccessor??"category")??"unknown")+"",i=o?_e(Le(r,a,o)):1;e.set(n,(e.get(n)??0)+Math.max(0,i??0))}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("GaltonBoardChart"===e){const e=a.map((e,r)=>_e(Le(e,r,t.valueAccessor??"value"))).filter(e=>null!=e),i=r?[0,n]:Ue(t.valueExtent),s=i?.[0]??(e.length?Math.min(...e):0),c=i?.[1]??(e.length?Math.max(...e):1),l=s===c?1:c-s,u=Array.from({length:o},(e,t)=>({label:t+1+"",value:0}));for(const t of e)u[Math.max(0,Math.min(o-1,Math.floor((t-s)/l*o)))].value+=1;return{generated:r,rows:u}}if("CollisionSwarmChart"===e){const e=/* @__PURE__ */new Map;return a.forEach((r,a)=>{if(null==_e(Le(r,a,t.xAccessor??"x")))return;const o=t.groupAccessor?(Le(r,a,t.groupAccessor)??"All")+"":"All";e.set(o,(e.get(o)??0)+1)}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("EventDropChart"===e){const e=_e(t.windows?.size??10);if(null==e||0>=e)return null;const{events:o}=Ra({data:a,timeAccessor:t.timeAccessor??"time",arrivalAccessor:t.arrivalAccessor??"arrivalTime",windowSize:e,watermark:t.watermark,watermarkAtArrivalAccessor:t.watermarkAtArrivalAccessor}),n=o.map(e=>e.eventTime),i=n.length?Math.min(...n):0,s=n.length?Math.max(...n):i+e,c=Math.min(_e(t.timeExtent?.[0])??i,i),l=Math.max(_e(t.timeExtent?.[1])??s,s),u=Math.floor(c/e)*e,d=Math.max(1,Math.ceil((l-u+e)/e)),h=Array.from({length:d},(t,r)=>({label:`${u+r*e}-${u+(r+1)*e}`,value:0,secondary:0,secondaryLabel:"late"}));for(const t of o){const r=h[Math.max(0,Math.min(d-1,Math.floor((t.eventTime-u)/e)))];t.late?r.secondary+=1:r.value+=1}return{generated:r,rows:h}}return null}function Ia(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}function Ea(e,t){const r=e.physics&&"object"==typeof e.physics?e.physics:null,a=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,o=[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(o)?o.map((e,r)=>{if(!e||"object"!=typeof e)return null;const a=e,o=Ia(a.count??a.value??a.total??a.bodies??a.events);if(null==o)return null;const n=a.label??a.id??a.name??"container "+(r+1),i=Ia(a.secondary??a.secondaryCount),s=Ia(a.observed??a.observedCount);return{label:pa(n,t),count:o,...null!=i?{secondary:i}:{},..."string"==typeof a.secondaryLabel&&a.secondaryLabel?{secondaryLabel:a.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}function Na(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}function Ta(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"UnitPileChart"===e?"unit":"body"}function Ma(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.`}function Oa(e,t){if(0>=t)return"0%";const r=e/t*100;return(10>r?Math.round(10*r)/10:Math.round(r))+"%"}function Fa(e,t,r,a,o,n,i=null){const s=Na(e),c=i&&"EventDropChart"===e?"accepted event":Ta(e),l=i?i.generated?"The generated sample projection":"The source projection":"The settled projection";if(o.has("l1")&&(a.l1=Ma(e,t)),!o.has("l2")&&!o.has("l3"))return;if(!r||0===r.length)return void(o.has("l2")&&(a.l2=i?"No valid source records are available.":"No settled projection is loaded yet."));const u=r.reduce((e,t)=>e+t.count,0),d=r.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),h=d[0]??r.slice().sort((e,t)=>t.count-e.count)[0];if(!h)return;const p=r.reduce((e,t)=>e+(t.secondary??0),0),f=r.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(o.has("l2"))if(i&&"EventDropChart"===e)a.l2=`${l} classifies ${n(u+p)} ${ja(u+p,"event")} across ${r.length} ${ja(r.length,s)}: ${n(u)} accepted and ${n(p)} late.`;else if(0===d.length)a.l2=`${l} contains ${n(u)} ${ja(u,c)} across ${r.length} ${ja(r.length,s)}; no ${ja(2,s)} are non-empty yet.`;else{const e=p>0?` ${n(p)} ${ja(p,c)} ${1===p?"is":"are"} marked ${f}.`:"";a.l2=`${l} contains ${n(u)} ${ja(u,c)} across ${r.length} ${ja(r.length,s)}; ${d.length} ${ja(d.length,s)} ${1===d.length?"is":"are"} non-empty. The largest ${s} is ${h.label} with ${n(h.count)} ${ja(h.count,c)}.${e}`}if(o.has("l3")&&u>0&&d.length>0){const e=d.find(e=>e!==h),t=Oa(h.count,u);a.l3=e?`${l} is most concentrated in ${h.label}, which holds ${n(h.count)} ${ja(h.count,c)} (${t}); ${e.label} follows with ${n(e.count)} ${ja(e.count,c)}.`:`${l} is concentrated in ${h.label}, which holds all ${n(h.count)} ${ja(h.count,c)}.`}}function ja(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function za(e){return Nl[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function Ba(e){const t=/* @__PURE__ */new Set,r=e=>{const a=Fl[e];if(a)return a;if(t.has(e))return;const o=ua().intents.get(e);if(!o?.composes?.length)return;t.add(e);const n=[...o.composes].sort((e,t)=>{const r=e=>{const t=zl.indexOf(e);return 0>t?zl.length:t};return(o.weights?.[t]??1)-(o.weights?.[e]??1)||r(e)-r(t)});for(const a of n){const o=r(a);if(o)return t.delete(e),o}t.delete(e)};return r(e)}function La(e){let t,r=0;for(const[a,o]of Object.entries(e))if("number"==typeof o&&o>0)if(o>r)t=a,r=o;else if(o===r&&void 0!==t){const e=zl.indexOf(a),r=zl.indexOf(t);-1===e||-1!==r&&e>=r||(t=a)}return t}function _a(e){return"BumpChart"===e?"ranking":Il.has(e)||"StackedAreaChart"===e?"apportioning":Ol.has(e)?"relating":Pl.has(e)?"comparing":El.has(e)?"characterizing":Rl.has(e)?"tracking":Tl.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}function Da(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}}function Ua(e,t){const r=Da(t);if(r?.act)return r.act;if(r?.intentScores){const e=La(r.intentScores);if(e&&Fl[e]&&(r.intentScores[e]??0)>=3)return Fl[e]}return r?.family?jl[r.family]:_a(e)}function Va(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||!Ll.has(t.type))return!1;const r=t.provenance;return!(!r||"object"!=typeof r)&&(_l.has(r.authorKind)||Dl.has(r.source)||Ul.has(r.basis))})}function Ga(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+""}function qa(e,t,r,a){let o=0,n=0,i=1/0,s=-1/0,c=null,l=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===o&&(f=e,h=r),m=e,p=r,i>e&&(i=e,c=r,u=o),e>s&&(s=e,l=r,d=o),o++,n+=e)}return 0===o?null:{count:o,min:i,max:s,mean:n/o,minLabel:pa(null!=c?r(c):null,a),maxLabel:pa(null!=l?r(l):null,a),first:f,last:m,firstLabel:pa(null!=h?r(h):null,a),lastLabel:pa(null!=p?r(p):null,a),minIndex:u,maxIndex:d}}function Ha(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]??""}function Wa(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 ":""}function Ya(e){const t=Vl["string"==typeof e.type?e.type:"annotation"]||"an annotation",r=Wa(e),a=r?r+t.replace(/^an? /,""):t,o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return o?`${a} labeled "${o}"`:a}function Ka(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const r=fa(t.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return;const a=r.map(Ya),o=a.slice(0,5),n=a.length-o.length,i=Ha(o)+(n>0?`, and ${n} more`:""),s=r.length;return`The author has marked ${1===s?"one feature":s+" features"} on this chart: ${i}.`}function Ja(e,t,r={}){const a=void 0!==r.levels,o=new Set(r.levels??["l1","l2","l3"]);a||!r.capability&&!Va(t)||o.add("l4");const n=ba(e,t,r.recipe);if(n){const e=["l1","l2","l3","l4"].filter(e=>o.has(e));a||e.includes("l4")||e.push("l4");const i=Sa(n,t,{levels:e,locale:r.locale,audience:r.audience,includeCaveats:r.includeCaveats}),s=Ka(t);return{...i,text:s?`${s} ${i.text}`.trim():i.text,...s?{annotations:s}:{}}}const i=Ga(r.locale??"en"),s=za(e),c=Array.isArray(t.data)?t.data:null,l=ha(t),u=Ml.has(e)?Ea(t,i):null,d=Ml.has(e)&&null===u?Pa(e,t):null,{measure:h,measureFallback:p,dimension:f,dimensionFallback:m}=da(e,t),g="string"==typeof h&&h?h:p,y="string"==typeof f&&f?f:m,b={};if(Ml.has(e)&&Fa(e,s,u??(d?Ea({projectionRows:d.rows},i):null),b,o,i,d),o.has("l1")&&!Ml.has(e))if("BumpChart"===e)b.l1=`A ${s} ranking ${l??"series"} by ${g} across ${y}.`;else if(Rl.has(e)||Pl.has(e))b.l1=`A ${s} of ${g} by ${y}`+(l?`, split by ${l}.`:".");else if(Il.has(e))b.l1=`A ${s} showing ${g} across ${y} categories.`;else if(El.has(e))b.l1=`A ${s} of the distribution of ${g}`+(l?` by ${l}.`:".");else if(Tl.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,r=Array.isArray(t.edges)?t.edges.length:void 0,a=[null!=e?`${e} ${no(e,"node")}`:null,null!=r?`${r} ${no(r,"edge")}`:null].filter(Boolean);b.l1=`A ${s}${a.length?" with "+a.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:g;b.l1=`A single value${e?" for "+e:""}.`}else b.l1=`A ${s}.`;const v=Rl.has(e)||"BumpChart"===e||Pl.has(e)||Il.has(e)||El.has(e);let w=null;if((o.has("l2")||o.has("l3")||o.has("l4"))&&v&&c&&c.length>0&&(w=qa(c,ca(h,p),la(f,m),i)),o.has("l2")&&v&&(c&&0!==c.length?w&&(b.l2=Il.has(e)?`${w.count} segments totaling ${i(Xa(w))}. Largest is ${w.maxLabel} at ${i(w.max)}; smallest is ${w.minLabel} at ${i(w.min)}.`:`${g} ranges from ${i(w.min)} (${w.minLabel}) to ${i(w.max)} (${w.maxLabel}), with a mean of ${i(w.mean)} across ${w.count} points.`):b.l2="No data is loaded yet."),o.has("l3")&&w&&!l&&Rl.has(e)?b.l3=Za(w,g,i):o.has("l3")&&w&&!l&&Pl.has(e)&&(b.l3=`The highest ${y} is ${w.maxLabel} and the lowest is ${w.minLabel}.`),o.has("l4")){const a=Va(t)?"alerting":Ua(e,r.capability);a&&(b.l4=Qa(a,e,t,l?null:w,g,y,i,r.audience))}const A=["l1","l2","l3","l4"].filter(e=>o.has(e)&&b[e]).map(e=>b[e]).join(" "),x=Ka(t);return{text:x?`${x} ${A}`.trim():A,levels:b,...x?{annotations:x}:{}}}function Xa(e){return e.mean*e.count}function Za(e,t,r){const{first:a,last:o,min:n,max:i,maxLabel:s,minLabel:c,firstLabel:l,lastLabel:u,minIndex:d,maxIndex:h,count:p}=e,f=i-n,m=o-a;if(0===f)return`${oo(t)} is constant at ${r(a)} across the series.`;if(.04>f/(Math.abs(e.mean)||1))return`${oo(t)} ends roughly where it started (${r(a)} at ${l} to ${r(o)} at ${u}), ranging between ${r(n)} and ${r(i)}.`;const g=h>0&&p-1>h,y=d>0&&p-1>d,b=(i-Math.max(a,o))/f,v=(Math.min(a,o)-n)/f;return g&&b>.15?`Overall ${t} climbs to a peak of ${r(i)} (${s}), then falls to ${r(o)} (${u}).`:y&&v>.15?`Overall ${t} drops to a low of ${r(n)} (${c}), then recovers to ${r(o)} (${u}).`:.05>Math.abs(m)/f?`${oo(t)} ends roughly where it started (${r(a)} at ${l} to ${r(o)} at ${u}), ranging between ${r(n)} and ${r(i)}.`:m>0?h===p-1?`Overall ${t} rises from ${r(a)} (${l}) to a peak of ${r(o)} (${u}).`:`Overall ${t} rises from ${r(a)} (${l}) to ${r(o)} (${u}), after peaking at ${r(i)} (${s}).`:d===p-1?`Overall ${t} falls from ${r(a)} (${l}) to a low of ${r(o)} (${u}).`:`Overall ${t} falls from ${r(a)} (${l}) to ${r(o)} (${u}), after dipping to ${r(n)} (${c}).`}function Qa(e,t,r,a,o,n,i,s){const c=Bl[e],l=/^[aeiou]/i.test(c)?"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:o} as the headline number`;break;case"tracing":u=`This is ${l} ${c} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${l} ${c} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${l} ${c} chart`,d=`read it for whether ${n} and ${o} move together`;break;default:u=`This is ${l} ${c} chart`,d=eo(e,a,o,n,i,t)}return`${u}; ${d}.${ao(t,s)}`}function eo(e,t,r,a,o,n){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 to(t,o,n);case"tracking":return`read it for the trajectory of ${r}, which ${ro(t)} from ${o(t.first)} (${t.firstLabel}) to ${o(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${r} across ${a}; ${t.maxLabel} leads at ${o(t.max)}`;case"ranking":return`read it top to bottom by ${r}; ${t.maxLabel} ranks highest at ${o(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 ${o(e)} total; ${t.maxLabel} is the largest at ${o(t.max)}${null!=r?` (${r}%)`:""}`}case"characterizing":return`read it for the spread of ${r}, from ${o(t.min)} to ${o(t.max)}`;default:return"read the highlighted features"}}function to(e,t,r){if(Pl.has(r)||Il.has(r))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:a,last:o,min:n,max:i,minLabel:s,maxLabel:c,lastLabel:l,minIndex:u,maxIndex:d,count:h}=e,p=i-n;if(p>0){const e=d>0&&h-1>d,r=u>0&&h-1>u,f=(i-Math.max(a,o))/p,m=(Math.min(a,o)-n)/p;if(e&&f>.15)return`the peak of ${t(i)} at ${c} is the point to investigate`;if(r&&m>.15)return`the dip to ${t(n)} at ${s} is the point to investigate`;if(o>=i)return`the climb to ${t(o)} at ${l} warrants a closer look`;if(n>=o)return`the drop to ${t(o)} at ${l} warrants a closer look`}return`the extremes — ${c} (${t(i)}) and ${s} (${t(n)}) — are the points to check`}function ro(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"}function ao(e,t){if(!t)return"";const r=t.familiarity?.[e];return"number"!=typeof r||r>2?"":` This ${za(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}function oo(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function no(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function io(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function so(e,t,r,a){const o=Aa(t,["nominal","ordinal"]),n=t.dataRoles.filter(e=>"quantitative"===e.semanticType),i=o?va(o,r,a):void 0,s=[];i&&null!=e[i]&&s.push(e[i]+"");for(const t of n){const o=va(t,r,a);o&&null!=e[o]&&s.push(`${t.role}: ${e[o]+""}`)}return s.length>0?s.join(", "):"Data item"}function co(e,t,r={}){const a=ya(t),o=ga(t),n=Math.max(1,r.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:a,config:o,locale:r.locale??"en"});const i=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const c=(i?.groupByRole?wa(e,i.groupByRole):void 0)??(i?.groupBy?.[0]?wa(e,i.groupBy[0])??e.dataRoles.find(e=>e.field===i.groupBy?.[0]):void 0)??Aa(e,["nominal","ordinal"]),l=c?va(c,o,a):void 0,u=(i?.idRole?wa(e,i.idRole):void 0)??Aa(e,["identifier"]),d=u?va(u,o,a):void 0,h={id:"root",role:"chart",label:i?.summaryTemplate?xa(i.summaryTemplate,void 0,e,o,a,{count:a.length}):`${e.name}: ${a.length} ${1===a.length?"item":"items"} represented.`,level:1,children:[]};let p=0;const f=(t,r,n)=>{const s=d?t[d]:void 0,c=i?.itemLabelTemplate?xa(i.itemLabelTemplate,t,e,o,a,{count:a.length}):so(t,e,o,a);return{id:"datum-"+io(s??r),role:"datum",label:c,level:n,datum:t}};if(l){const e=/* @__PURE__ */new Map;for(const t of a){const r=(t[l]??"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,n-p));p+=a.length;const o=a.map((e,t)=>f(e,1e5*r+t,3));return t.length>a.length&&o.push({id:"more-"+io(e),role:"datum",label:`…and ${t.length-a.length} more items`,level:3}),{id:"group-"+io(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:o}})}else{const e=a.slice(0,n);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 lo(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function uo(e,t="—"){return null==e||""===e?t:"object"==typeof e?uo(e.id??e.name??e.label,t):e+""}function ho(e){if(null==e||""===e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function po(e){return uo(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function fo(e,t){const r=lo(e,t,"children");return Array.isArray(r)?r:[]}function mo(e,t,r){return`${e} ${1===e?t:r}`}function go(e,t){return 0===e.numericLeaves?"":e.numericLeaves===e.leaves?", leaf total "+t(e.leafTotal):`, known leaf total ${t(e.leafTotal)} across ${mo(e.numericLeaves,"valued leaf","valued leaves")}`}function yo(e){return"TreeDiagram"===e?"tree":"Treemap"===e?"treemap":"CirclePack"===e?"circle-packing":"orbit"}function bo(e,t,r,a){const o=t.data&&"object"==typeof t.data?t.data:null,n=t.childrenAccessor??"children",i=t.valueAccessor??"value",s=t.nodeLabel??t.nodeIdAccessor,c=/* @__PURE__ */new WeakMap,l=/* @__PURE__ */new WeakSet,u=e=>{const t=c.get(e);if(t)return t;if(l.has(e))return{descendants:0,depth:0,leaves:0,numericLeaves:0,leafTotal:0};l.add(e);const r=fo(e,n);let a;if(0===r.length){const t=ho(lo(e,i,"value"));a={descendants:0,depth:1,leaves:1,numericLeaves:null==t?0:1,leafTotal:t??0}}else a=r.reduce((e,t)=>{const r=u(t);return{descendants:e.descendants+1+r.descendants,depth:Math.max(e.depth,r.depth+1),leaves:e.leaves+r.leaves,numericLeaves:e.numericLeaves+r.numericLeaves,leafTotal:e.leafTotal+r.leafTotal}},{descendants:0,depth:1,leaves:0,numericLeaves:0,leafTotal:0});return l.delete(e),c.set(e,a),a};let d=0;const h=(e,t,o,c)=>{const l=uo(lo(e,s,"name"),"item "+o);if(c.has(e))return{id:`hierarchy-${po(o)}-cycle`,role:"datum",level:t,label:`Repeated hierarchy reference to ${l}; branch omitted.`};const p=fo(e,n),f=u(e);if(0===p.length){if(d>=r)return null;d+=1;const n=ho(lo(e,i,"value"));return{id:`hierarchy-${po(o)}-${po(l)}`,role:"datum",level:t,label:`${l}${null==n?"":": "+a(n)}.`,...null==n?{}:{value:n},datum:e}}const m=new Set(c);m.add(e);const g=[];let y=0;for(const[e,a]of p.entries()){if(d>=r){y+=u(a).leaves;continue}const n=h(a,t+1,`${o}-${e}`,m);n&&g.push(n)}return y>0&&g.push({id:`hierarchy-${po(o)}-more`,role:"datum",level:t+1,label:`${mo(y,"more leaf","more leaves")} in ${l} not shown; navigation is capped at ${r}.`}),{id:`hierarchy-${po(o)}-${po(l)}`,role:"series",level:t,label:`${l}: ${mo(p.length,"direct child","direct children")}, ${mo(f.descendants,"total descendant","total descendants")}, ${mo(f.leaves,"leaf","leaves")}${go(f,a)}.`,datum:e,children:g}},p=o?u(o):null,f={id:"root",role:"chart",level:1,label:o?`A ${yo(e)} chart with ${mo(p.leaves,"leaf","leaves")} and ${mo(p.descendants,"total descendant","total descendants")} across ${mo(p.depth,"hierarchy level","hierarchy levels")}${go(p,a)}.`:"A hierarchy chart with no hierarchy data loaded.",children:[]};if(o){const e=h(o,2,"root",/* @__PURE__ */new Set);if(e){const t=uo(lo(o,s,"name"),"");f.children="series"===e.role&&""===t?e.children:[e]}}return f}function vo(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function wo(e,t="—"){return null==e||""===e?t:"object"==typeof e?wo(e.id??e.name??e.label,t):e+""}function Ao(e){if(null==e||""===e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function xo(e){return wo(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function $o(e){const t=[];return(e.linkedHover||e.selection||e.linkedBrush)&&t.push("Use linked highlighting to compare related locations."),(e.enableHover||e.tooltip)&&t.push("Hover or focus a mark for its details."),t.length>0?" "+t.join(" "):""}function Co(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];const t=e;return Array.isArray(t.features)?t.features:"Feature"===t.type?[t]:[]}function So(e,t,r){const a=vo(e,t,r);if(void 0!==a)return a;const o=e.properties;return o&&"object"==typeof o?vo(o,t,r):void 0}function ko(e,t,r){return wo(So(e,t,"id")??So(e,"name","name")??So(e,"NAME","NAME")??So(e,"label","label"),r)}function Ro(e){let t=0,r=1/0,a=-1/0,o=0;for(const n of e)null!=n.value&&(t+=1,r=Math.min(r,n.value),a=Math.max(a,n.value),o+=n.value);return 0===t?null:{count:t,min:r,max:a,total:o,average:o/t}}function Po(e,t){const r=Ro(e);return r?`range ${t(r.min)} to ${t(r.max)}, average ${t(r.average)}, total ${t(r.total)}`:"no numeric values"}function Io(e){const t=e.filter(e=>null!=e.value),r=e.filter(e=>null==e.value),a=[],o=Ro(t);if(o)if(o.min===o.max)a.push({id:"equal",label:"Equal values",rows:t});else{const e=o.min+(o.max-o.min)/3,r=o.min+2*(o.max-o.min)/3,n=t.filter(e=>e.value>=r),i=t.filter(t=>t.value>=e&&r>t.value),s=t.filter(t=>e>t.value);n.length>0&&a.push({id:"highest",label:"Highest values",rows:n}),i.length>0&&a.push({id:"middle",label:"Middle values",rows:i}),s.length>0&&a.push({id:"lowest",label:"Lowest values",rows:s})}return r.length>0&&a.push({id:"missing",label:"No numeric value",rows:r}),a}function Eo(e,t,r){const a=e.filter(e=>null!=e.value).sort((e,t)=>t.value-e.value||e.index-t.index),o=/* @__PURE__ */new Map;let n,i=0;for(const[e,t]of a.entries())n!==t.value&&(i=e+1,n=t.value),o.set(t.index,i);let s=0;return Io(e).map(e=>{const n=e.rows.slice(0,Math.max(0,t-s));s+=n.length;const i=n.map(e=>{const t=o.get(e.index),n=null==t||2>a.length?"":`, rank ${t} of ${a.length}`;return{id:`geo-${xo(e.label)}-${e.index}`,role:"datum",level:3,label:null==e.value?e.label+": no numeric value.":`${e.label}: ${r(e.value)}${n}.`,...null==e.value?{}:{value:e.value},datum:e.datum}}),c=e.rows.length-n.length;return c>0&&i.push({id:`geo-${e.id}-more`,role:"datum",level:3,label:`${c} more ${1===c?"region":"regions"} in ${e.label.toLowerCase()} not shown; navigation is capped at ${t}.`}),{id:"regions-"+e.id,role:"series",level:2,label:`${e.label}: ${e.rows.length} ${1===e.rows.length?"region":"regions"}, ${Po(e.rows,r)}.`,children:i}})}function No(e,t,r,a){const o=Co(t.areas),n="FlowMap"===e&&Array.isArray(t.nodes)?t.nodes:Array.isArray(t.points)?t.points:[],i=Array.isArray(t.flows)?t.flows:[],s=Array.isArray(t.lines)?t.lines:[],c=t.valueAccessor??t.sizeBy??t.costAccessor??"value",l=t.pointIdAccessor??t.nodeIdAccessor??"id",u=("ChoroplethMap"===e?o:n).map((r,a)=>({datum:r,index:a,label:ko(r,"ChoroplethMap"===e?t.idAccessor:l,`${"ChoroplethMap"===e?"region":"location"} ${a+1}`),value:Ao(So(r,c,"value"))})),d=u.filter(e=>null!=e.value),h={id:"root",role:"chart",level:1,label:`${"ChoroplethMap"===e?`A choropleth map with ${o.length} regions.${d.length>0?` Values are available for ${d.length} of ${o.length} regions; ${Po(d,a)}.`:" No regions have numeric values."}`:"FlowMap"===e?`A flow map with ${i.length} flows and ${n.length} locations.`:"DistanceCartogram"===e?`A distance cartogram with ${n.length} locations and ${s.length} routes.`:`A proportional-symbol map with ${n.length} locations.`}${$o(t)}`,children:[]};if("ChoroplethMap"===e)h.children=Eo(u,r,a);else if(u.length>0){const e=u.slice(0,r).map(e=>({id:`geo-${xo(e.label)}-${e.index}`,role:"datum",level:3,label:`${e.label}${null==e.value?"":": "+a(e.value)}.`,...null==e.value?{}:{value:e.value},datum:e.datum}));u.length>r&&e.push({id:"geo-more",role:"datum",level:3,label:`…and ${u.length-r} more locations.`}),h.children?.push({id:"locations",role:"series",level:2,label:`Locations: ${u.length} marks.`,children:e})}const p="FlowMap"===e?i:s;if(p.length>0){const e=p.slice(0,r).map((e,t)=>{const r=wo(e.source,"unknown"),o=wo(e.target,"unknown"),n=Ao(vo(e,c,"value"));return{id:`route-${xo(r)}-${xo(o)}-${t}`,role:"datum",level:3,label:`${r} to ${o}${null==n?"":": "+a(n)}.`,...null==n?{}:{value:n},datum:e}});h.children?.push({id:"routes",role:"series",level:2,label:`Routes: ${p.length} ${1===p.length?"route":"routes"}.`,children:e})}return h}function To(e,t={},r={}){return!!ba(e,t,r.recipe)||Gl.has(e)||ql.has(e)||Hl.has(e)||Rl.has(e)||Pl.has(e)||Il.has(e)||El.has(e)}function Mo(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function Oo(e,t="—"){return null==e||""===e?t:"object"==typeof e?Oo(e.id??e.name??e.label,t):e+""}function Fo(e){if(null==e||""===e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function jo(e){return Oo(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function zo(e,t){const r=[];return(e.linkedHover||e.selection||e.linkedBrush)&&r.push("network"===t?"Use linked highlighting to trace related marks.":"Use linked highlighting to compare related locations."),(e.enableHover||e.tooltip)&&r.push("Hover or focus a mark for its details."),r.length>0?" "+r.join(" "):""}function Bo(e,t){t&&e.children?.push(t)}function Lo(e,t,r,a){const o=Array.isArray(t.nodes)?t.nodes:[],n=Array.isArray(t.edges)?t.edges:Array.isArray(t.flows)?t.flows:[],i=t.nodeIdAccessor??t.nodeIDAccessor,s=t.sourceAccessor??"source",c=t.targetAccessor??"target",l=t.valueAccessor??"value",u=e=>Oo(Mo(e,i,"id"),"unknown"),d=(e,t)=>Oo(Mo(e,t,""),"unknown"),h=/* @__PURE__ */new Set;for(const e of n)h.add(d(e,s)),h.add(d(e,c));const p=o.length>0?o:[...h].map(e=>({id:e})),f=/* @__PURE__ */new Map;for(const e of p)f.set(u(e),{links:0,value:0});for(const e of n){const t=d(e,s),r=d(e,c),a=Fo(Mo(e,l,"value"))??0;for(const e of[t,r]){const t=f.get(e)??{links:0,value:0};t.links+=1,t.value+=a,f.set(e,t)}}const m={id:"root",role:"chart",level:1,label:`A ${"SankeyDiagram"===e||"ProcessSankey"===e?"flow diagram":"ChordDiagram"===e?"chord diagram":"network graph"} with ${p.length} nodes and ${n.length} links.${zo(t,"network")}`,children:[]};let g=0;const y=/* @__PURE__ */new Map,b=t.colorBy??"group";for(const e of p){const t=Oo(Mo(e,b,"group"),"Ungrouped"),r=y.get(t);r?r.push(e):y.set(t,[e])}const v=[...y].map(([e,t],o)=>{const n=[];for(const[e,i]of t.entries()){if(g>=r)break;g+=1;const t=u(i),s=f.get(t)??{links:0,value:0},c=s.value>0?`, ${a(s.value)} total flow`:"";n.push({id:`node-${o}-${e}-${jo(t)}`,role:"datum",level:3,label:`${t}: ${s.links} ${1===s.links?"link":"links"}${c}.`,value:s.value>0?s.value:void 0,datum:i})}return{id:`nodes-${o}-${jo(e)}`,role:"series",level:2,label:`${e}: ${t.length} ${1===t.length?"node":"nodes"}.`,children:n}});v.length>0&&m.children?.push(...v);const w=n.slice(0,r).map((e,t)=>{const r=d(e,s),o=d(e,c),n=Fo(Mo(e,l,"value"));return{id:`link-${jo(r)}-${jo(o)}-${t}`,role:"datum",level:3,label:`${r} to ${o}${null==n?"":": "+a(n)}.`,value:n,datum:e}});return n.length>r&&w.push({id:"links-more",role:"datum",level:3,label:`…and ${n.length-r} more links.`,value:void 0}),w.length>0&&m.children?.push({id:"links",role:"series",level:2,label:`Links: ${n.length} ${1===n.length?"connection":"connections"}.`,children:w}),m}function _o(e,t){const r=Array.isArray(e.annotations)?e.annotations:null;if(!r)return null;const a=fa(r.filter(e=>!!e&&"object"==typeof e));if(0===a.length)return null;let o=0;const n=a.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=Ya(e),a?a.charAt(0).toUpperCase()+a.slice(1):a}${r}.`,datum:e};var a});a.length>t&&n.push({id:"annotation-"+o++,role:"annotation",level:3,label:`…and ${a.length-t} more annotations.`});const i=a.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===i?"one marked feature":i+" marked features"}.`,children:n}}function Do(e,t,r={}){const a=r.locale??"en",o=Math.max(1,r.maxLeaves??200),n=Ga(a),i=ba(e,t,r.recipe);if(i)return co(i,t,{maxLeaves:o,locale:a});const s={id:"root",role:"chart",label:Ja(e,t,{locale:a}).text||"Chart.",level:1,children:[]},c=_o(t,o);if(Gl.has(e)){const r=Lo(e,t,o,n);return Bo(r,c),r}if(ql.has(e)){const r=bo(e,t,o,n);return Bo(r,c),r}if(Hl.has(e)){const r=No(e,t,o,n);return Bo(r,c),r}const l=Array.isArray(t.data)?t.data:null,u=To(e,t,r);if(!l||0===l.length||!u)return c&&(s.children=[c]),s;const{measure:d,measureFallback:h,dimension:p,dimensionFallback:f}=da(e,t),m=ca(d,h),g=la(p,f),y="string"==typeof d&&d?d:h,b="string"==typeof p&&p?p:f,v=ha(t);let w=0;const A=e=>`${e}-${w++}`,x=(e,t)=>{const r=m(e),a=pa(g(e),n);return{id:A("datum"),role:"datum",level:t,label:`${a}: ${Number.isFinite(r)?n(r):"—"}`,value:Number.isFinite(r)?r:void 0,datum:e}},$=(e,t)=>{const r=e.slice(0,o).map(e=>x(e,t));return e.length>o&&r.push({id:A("more"),role:"datum",level:t,label:`…and ${e.length-o} more points`}),r},C=[];if(Rl.has(e)||Pl.has(e)){let t=1/0,r=-1/0,a=1/0,o=-1/0;const i=[];let s=!0;for(const e of l){const n=m(e);Number.isFinite(n)&&(t>n&&(t=n),n>r&&(r=n));const c=g(e);i.push(c),"number"==typeof c&&Number.isFinite(c)?(a>c&&(a=c),c>o&&(o=c)):s=!1}const c=/* @__PURE__ */new Set,u=[];for(const e of i){const t=e+"";c.has(t)||(c.add(t),u.push(e))}const d=s?`${n(a)} to ${n(o)}`:`${pa(u[0],n)} to ${pa(u[u.length-1],n)} (${Pl.has(e)?u.length+" categories":l.length+" points"})`;C.push({id:A("axis"),role:"axis",level:2,label:`${Pl.has(e)?"Category axis":"X axis"}: ${b}, ${d}.`}),t>r||C.push({id:A("axis"),role:"axis",level:2,label:`Value axis: ${y}, ${n(t)} to ${n(r)}.`})}if(v){const r=la(v,v),o=/* @__PURE__ */new Map;for(const e of l){const t=(r(e)??"—")+"",a=o.get(t);a?a.push(e):o.set(t,[e])}const n=[];for(const[r,i]of o){const o=Ja(e,{...t,data:i},{levels:["l2","l3"],locale:a}).text;n.push({id:A("series"),role:"series",level:2,label:`Series ${r}: ${o}`,children:$(i,3)})}s.children=[...C,...n]}else s.children=[...C,...$(l,2)];return c&&s.children.push(c),s}function Uo(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 Vo(e){let t=1;if(e.children)for(const r of e.children)t+=Vo(r);return t}function Go(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function qo(e){return Go(e)?e:void 0}function Ho(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function Wo(e){const t=Ho(e);return null==t?void 0:Math.max(0,Math.floor(t))}function Yo(...e){return e.map(qo).find(Boolean)}function Ko(...e){return e.find(Array.isArray)}function Jo(e){const t={};for(const[r,a]of Object.entries(e))void 0!==a&&(t[r]=a);return t}function Xo(e,t,r){return e["string"==typeof t&&t?t:r]}function Zo(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function Qo(e,t,r){const a=[];if("GaugeChart"===e){"number"==typeof t.value&&Number.isFinite(t.value)&&a.push(`Current value is ${Zo(t.value)}.`);const e="number"==typeof t.min&&Number.isFinite(t.min)?t.min:0,r="number"==typeof t.max&&Number.isFinite(t.max)?t.max:100;a.push(`The gauge scale runs from ${Zo(e)} to ${Zo(r)}.`)}if("SankeyDiagram"===e||"ProcessSankey"===e){const o=Array.isArray(t.edges)?t.edges:[];if("ProcessSankey"===e&&Array.isArray(t.domain)&&2===t.domain.length&&a.push(`The ProcessSankey time domain runs from ${Zo(t.domain[0])} to ${Zo(t.domain[1])}.`),o.length>0){a.push(`${o.length} source flow${1===o.length?"":"s"} are supplied.`);for(const n of o.slice(0,r)){const r=Xo(n,t.sourceAccessor,"source"),o=Xo(n,t.targetAccessor,"target"),i=Xo(n,t.valueAccessor,"value");a.push("ProcessSankey"!==e||null==n.startTime&&null==n.endTime?`${Zo(r)} to ${Zo(o)} has value ${Zo(i)}.`:`${Zo(r)} to ${Zo(o)} has value ${Zo(i)} over ${Zo(n.startTime)}–${Zo(n.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){const e=qo(t.data),o="string"==typeof t.childrenAccessor&&t.childrenAccessor?t.childrenAccessor:"children",n="string"==typeof t.valueAccessor&&t.valueAccessor?t.valueAccessor:"value",i="string"==typeof t.nodeIdAccessor&&t.nodeIdAccessor?t.nodeIdAccessor:"string"==typeof t.nodeIDAccessor&&t.nodeIDAccessor?t.nodeIDAccessor:"name",s=[],c=e=>{const t=Array.isArray(e[o])?e[o]:[];if(0!==t.length)for(const e of t){const t=qo(e);t&&c(t)}else s.push(e)};if(e&&c(e),s.length>0){a.push(s.length+" hierarchy leaves are supplied.");for(const e of s.slice(0,r))a.push(`${Zo(e[i])} has value ${Zo(e[n])}.`)}}if(Wl.has(e)&&Array.isArray(t.data)){const r=t.data;a.push(`${r.length} observed source row${1===r.length?"":"s"} are supplied.`);const o="CollisionSwarmChart"===e?t.xAccessor:t.valueAccessor,n="CollisionSwarmChart"===e?"x":"value",i=r.map(e=>Ho(Xo(e,o,n))).filter(e=>null!=e);i.length>0&&a.push(`Observed ${"string"==typeof o?o:n} ranges from ${Zo(Math.min(...i))} to ${Zo(Math.max(...i))}.`)}if(0!==a.length)return{source:"chart-props",statements:a,text:"Exact chart-prop facts: "+a.join(" ")}}function en(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function tn(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function rn(e,t,r,a){const o=qo(e.settledProjection),n=qo(t?.settledProjection);return Ko(r?.projectionRows,r?.aggregates,e.settledProjectionRows,e.projectionRows,o?.rows,t?.settledProjectionRows,t?.projectionRows,n?.rows,a?.binCounts)}function an(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const r=qo(e);if(!r)return;const a=Ho(r.count??r.value??r.total??r.bodies??r.events);if(null==a)return;const o=(r.label??r.id??r.name??"container "+(t+1))+"",n=null==r.id?void 0:r.id+"",i=Ho(r.secondary??r.secondaryCount),s=Ho(r.observed??r.observedCount);return Jo({id:n,label:o,count:a,secondary:i,secondaryLabel:"string"==typeof r.secondaryLabel?r.secondaryLabel:void 0,observed:s})}).filter(e=>null!=e);if(0===t.length)return;const r=t.reduce((e,t)=>e+t.count,0),a=t.filter(e=>e.count>0).length,o=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:r,populatedCount:a,...o?{leader:o}:{}}}function on(e,t){const r=e?.map((e,t)=>{const r=qo(e);if(!r)return;const a=Ho(r.count)??0,o=Ho(r.total),n={label:(r.label??r.id??"sediment "+(t+1))+"",count:a};return null!=r.id&&(n.id=r.id+""),null!=o&&(n.total=o),n}).filter(e=>null!=e),a=Wo(t?.bins)??r?.length??0,o=Ho(t?.count)??r?.reduce((e,t)=>e+t.count,0)??0,n=Ho(t?.total)??r?.reduce((e,t)=>e+(t.total??0),0),i=r?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==a||0!==o||n)return{bins:a,count:o,...null!=n&&n>0?{total:n}:{},...i?{leader:i}:{}}}function nn(e){const t=qo(e);return!!t&&(Go(t.world)||"simulationState"in t||"liveBodyOrder"in t)}function sn(e){if(e)return e.filter(e=>!0===qo(e)?.sleeping).length}function cn(e,t,r){const a=e?.filter(e=>!0===qo(e)?.sensor).length,o=qo(t?.observation),n=qo(o?.sensors),i=Ko(r?.activeSensors);return Math.max(a??0,n?Object.keys(n).length:0,i?.length??0)||void 0}function ln(e){const t=[],r=e.simulation,a=[r.state??(r.settled?"settled":void 0),null!=r.liveBodies?`${r.liveBodies} live ${en(r.liveBodies,"body")}`:void 0,null!=r.sleepingBodies?r.sleepingBodies+" sleeping":void 0,null!=r.queued?r.queued+" queued":void 0,null!=r.seed?"seed "+tn(r.seed):void 0,r.gravity?`gravity (${tn(r.gravity.x)}, ${tn(r.gravity.y)})`:void 0,null!=r.fixedDt?`fixed step ${tn(r.fixedDt)}s`:void 0,null!=r.timeScale?tn(r.timeScale)+"x time":void 0].filter(Boolean);a.length>0&&t.push(`Physics simulation: ${a.join("; ")}.`);const o=e.geometry;if(o){const e=[null!=o.colliders?`${o.colliders} ${en(o.colliders,"collider")}`:void 0,null!=o.sensors?`${o.sensors} ${en(o.sensors,"sensor")}`:void 0,null!=o.springs?`${o.springs} ${en(o.springs,"spring")}`:void 0,null!=o.activeSensorPairs?`${o.activeSensorPairs} active sensor ${en(o.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}const n=e.aggregates;if(n){const e=n.leader,r=e?` Largest is ${e.label} with ${tn(e.count)}.`:"";t.push(`Physics aggregates: ${tn(n.totalCount)} settled ${en(n.totalCount,"body")} across ${n.rows.length} ${en(n.rows.length,"container")}; ${n.populatedCount} populated.${r}`)}const i=e.sediment;if(i){const e=null!=i.total?", value total "+tn(i.total):"",r=i.leader?`; largest sediment bin is ${i.leader.label} with ${tn(i.leader.count)}`:"";t.push(`Physics sediment: ${i.count} retained ${en(i.count,"body")} in ${i.bins} ${en(i.bins,"bin")}${e}${r}.`)}return t.join(" ")}function un(e,t,r){if(!1===r)return;const a=Go(r)?r:void 0,o=qo(t.physics),n=Yo(a?.snapshot,o?.snapshot,t.physicsSnapshot,nn(t.snapshot)?t.snapshot:void 0),i=Yo(a?.evidence,o?.evidence,t.physicsEvidence,t.settledEvidence),s=Yo(a?.config,o?.config,n?.config,t.config),c=Yo(qo(n?.world),qo(o?.world)),l=Yo(qo(s?.kernel),qo(c?.options)),u=Ko(c?.bodies),d=Ko(c?.colliders,s?.colliders),h=Ko(n?.queue,o?.queue),p=Ko(n?.liveBodyOrder),f=Ko(c?.springs),m=Ko(n?.activeSensorPairs),g=an(rn(t,o,a,i)),y=on(Ko(a?.sediment,o?.sediment,n?.sediment),Yo(a?.sedimentTotals,o?.sedimentTotals)),b=p?.length??u?.length??Wo(i?.bodyCount),v=sn(u)??Wo(i?.sleepingCount),w=h?.length,A="string"==typeof n?.simulationState?n.simulationState:void 0,x="boolean"==typeof i?.settled?i.settled:A?"settled"===A:null!=b||null!=v||null!=w?null!=b&&v===b&&0===(w??0):void 0,$=qo(l?.gravity),C=Ho($?.x),S=Ho($?.y),k=Jo({state:A,settled:x,elapsedSeconds:Ho(n?.elapsedSeconds),paused:"boolean"==typeof n?.paused?n.paused:void 0,visible:"boolean"==typeof n?.visible?n.visible:void 0,seed:Ho(l?.seed),gravity:null!=C&&null!=S?{x:C,y:S}:void 0,fixedDt:Ho(s?.fixedDt??l?.fixedDt),timeScale:Ho(s?.timeScale),maxSubsteps:Wo(s?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:w,bodyLimit:Ho(s?.bodyLimit),eviction:"string"==typeof s?.eviction?s.eviction:void 0}),R=Jo({colliders:d?.length,sensors:cn(d,s,c),springs:f?.length,activeSensorPairs:m?.length}),P=Object.keys(R).length>0,I=Wl.has(e);if(!(Object.keys(k).length>0||P||g||y)||!I&&null==r)return;const E={simulation:k,...P?{geometry:R}:{},...g?{aggregates:g}:{},...y?{sediment:y}:{}},N=ln(E);return{...E,text:N}}function dn(e,t,r={}){const{capability:a,audience:o,locale:n}=r,i=r.levels??["l1","l2","l3"],s=!1!==r.includeStructure,c=Ua(e,a),l=Ja(e,t,{levels:c?[...i,"l4"]:i,locale:n,capability:a,audience:o}),{l4:u,...d}=l.levels,h=["l1","l2","l3"].map(e=>l.levels[e]).filter(Boolean).join(" "),p={levels:d,text:l.annotations?`${l.annotations} ${h}`.trim():h,...l.annotations?{annotations:l.annotations}:{}};let f;if(c&&u){const e=(m=a)?"fits"in m||"buildProps"in m?{family:m.family}:{family:m.family,intentScores:m.intentScores}:{};f={act:c,sentence:u,family:e.family,intentScores:e.intentScores}}var m;const g=s?Do(e,t,{maxLeaves:r.maxLeaves,locale:n}):void 0,y=un(e,t,r.physics),b=Qo(e,t,Math.max(1,r.maxLeaves??200)),v=[p.text,f?.sentence,y?.text,b?.text].filter(Boolean).join(" ");return{component:e,description:p,intent:f,structure:g,physics:y,facts:b,text:v}}function hn(e,t=30){return Math.max((e??4)+5,12,t)}function pn(e,t){return Yl.has(e)&&!("reading"===e&&"string"==typeof t)}function fn(e){const t=[...Xl],r=Array.from((new TextEncoder).encode(e)),a=8*r.length;for(r.push(128);r.length%64!=56;)r.push(0);const o=Math.floor(a/4294967296),n=a>>>0;r.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o,n>>>24&255,n>>>16&255,n>>>8&255,255&n);const i=[];for(let e=0;r.length>e;e+=4)i.push((r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0);for(let e=0;i.length>e;e+=16){const r=[...i.slice(e,e+16)];for(let e=16;64>e;e+=1){const t=Kl(r[e-15],7)^Kl(r[e-15],18)^r[e-15]>>>3,a=Kl(r[e-2],17)^Kl(r[e-2],19)^r[e-2]>>>10;r[e]=r[e-16]+t+r[e-7]+a>>>0}let[a,o,n,s,c,l,u,d]=t;for(let e=0;64>e;e+=1){const t=d+(Kl(c,6)^Kl(c,11)^Kl(c,25))+(c&l^~c&u)+Zl[e]+r[e]>>>0,i=a&o^a&n^o&n;d=u,u=l,l=c,c=s+t>>>0,s=n,n=o,o=a,a=t+((Kl(a,2)^Kl(a,13)^Kl(a,22))+i>>>0)>>>0}const h=[a,o,n,s,c,l,u,d];for(let e=0;8>e;e+=1)t[e]=t[e]+h[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function mn(e,t){return`${e}[Symbol(${t.description??""})]`}function gn(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function yn(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function bn(e){return e.sort((e,t)=>{const r=JSON.stringify(e),a=JSON.stringify(t);return a>r?-1:r>a?1:0})}function vn(e,t,r){if(null===e)return null;if(e instanceof Date){const a=e.getTime();return Number.isFinite(a)?{$type:"date",value:e.toISOString()}:void r.excluded.push(t)}switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isNaN(e)?{$type:"number",value:"NaN"}:e===1/0?{$type:"number",value:"Infinity"}:e===-1/0?{$type:"number",value:"-Infinity"}:Object.is(e,-0)?{$type:"number",value:"-0"}:e;case"bigint":return{$type:"bigint",value:""+e};case"undefined":case"function":case"symbol":return void r.excluded.push(t);case"object":{const a=e;if(r.ancestors.has(a))return void r.excluded.push(t);r.ancestors.add(a);try{if(Array.isArray(e)){for(const a of Reflect.ownKeys(e))"length"===a||"string"==typeof a&&gn(a,e.length)||r.excluded.push("symbol"==typeof a?mn(t,a):yn(t,a));return Array.from({length:e.length},(a,o)=>{const n=yn(t,o),i=Object.getOwnPropertyDescriptor(e,o+"");if(!i||!("value"in i)||!i.enumerable)return r.excluded.push(n),null;const s=vn(i.value,n,r);return void 0===s?null:s})}const a={},o=Object.getPrototypeOf(e);if(o!==Object.prototype&&null!==o)return void r.excluded.push(t);const n=[];for(const a of Reflect.ownKeys(e)){if("symbol"==typeof a){r.excluded.push(mn(t,a));continue}const o=Object.getOwnPropertyDescriptor(e,a);o&&"value"in o&&o.enumerable?n.push(a):r.excluded.push(yn(t,a))}for(const o of n.sort()){const n=Object.getOwnPropertyDescriptor(e,o),i=vn(n&&"value"in n?n.value:void 0,yn(t,o),r);void 0!==i&&Object.defineProperty(a,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}return a}finally{r.ancestors.delete(a)}}default:return void r.excluded.push(t)}}function wn(e,t=/* @__PURE__ */new Set){if(null===e)return["null"];if(e instanceof Date)return Number.isFinite(e.getTime())?["date",e.toISOString()]:["excluded"];switch(typeof e){case"string":return["string",e];case"boolean":return["boolean",e];case"number":return["number",Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Object.is(e,-0)?"-0":e+""];case"bigint":return["bigint",""+e];case"undefined":case"function":case"symbol":return["excluded"];case"object":if(t.has(e))return["excluded"];t.add(e);try{const r=r=>{const a="symbol"==typeof r?["symbol-key",r.description??""]:["string-key",r],o=Object.getOwnPropertyDescriptor(e,r);return o?"value"in o?[a,"data",!!o.enumerable,wn(o.value,t)]:[a,"accessor",!!o.enumerable,!!o.get,!!o.set]:[a,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,a)=>{const o=a+"";return Object.prototype.hasOwnProperty.call(e,o)?r(o):["hole"]}),bn(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&gn(t,e.length))).map(r))];const a=Object.getPrototypeOf(e);return[a!==Object.prototype&&null!==a?"non-json-object":"object",bn(Reflect.ownKeys(e).map(r))]}finally{t.delete(e)}default:return["excluded"]}}function An(e){const t={excluded:[],ancestors:/* @__PURE__ */new Set},r=vn(e,"$",t)??null;return{value:r,text:JSON.stringify(r),excludedPaths:t.excluded}}function xn(e){const t=An(e),r=fn(JSON.stringify(["semiotic-value-fingerprint","v2",wn(e)]));return{...t,algorithm:"sha256",digest:r,fingerprint:"sha256:"+r}}function $n(e,t,r,a){En(e,Object.keys(t),r,a);for(const[o,n]of Object.entries(t))n.values?(n.required||void 0!==e[o])&&Tn(e,o,r,n.values,a):n.required?Nn(e,o,r,a):zn(e,o,r,a)}function Cn(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Sn(e,t,r,a){void 0===e[t]||"number"==typeof e[t]&&Number.isFinite(e[t])||a.push({path:`${r}.${t}`,message:"Expected a finite number."})}function kn(e,t,r,a){void 0!==e[t]&&"boolean"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a boolean."})}function Rn(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(Rn):Cn(e)&&Object.values(e).every(Rn))}function Pn(e,t,r,a){void 0===e[t]||Cn(e[t])&&Rn(e[t])||a.push({path:`${r}.${t}`,message:"Expected a JSON object."})}function In(e){return e.every(Rn)}function En(e,t,r,a){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||a.push({path:`${r}.${t}`,message:"Unexpected property."})}function Nn(e,t,r,a){"string"==typeof e[t]&&e[t]||a.push({path:`${r}.${t}`,message:"Expected a non-empty string."})}function Tn(e,t,r,a,o){"string"==typeof e[t]&&a.includes(e[t])||o.push({path:`${r}.${t}`,message:`Expected one of: ${a.join(", ")}.`})}function Mn(e,t,r,a){const o=e[t];if(void 0!==o){if(Cn(o))return o;a.push({path:`${r}.${t}`,message:"Expected an object."})}}function On(e,t,r,a){const o=e[t];if(void 0!==o){if(Array.isArray(o))return o;a.push({path:`${r}.${t}`,message:"Expected an array."})}}function Fn(e,t,r){e?.some(e=>"string"!=typeof e||!e)&&r.push({path:t,message:"Expected non-empty string values."})}function jn(e,t,r,a,o){void 0!==e[t]&&Tn(e,t,r,a,o)}function zn(e,t,r,a){void 0!==e[t]&&"string"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a string."})}function Bn(e,t,r){Cn(e)?(En(e,["id","name","kind"],t,r),Nn(e,"kind",t,r),zn(e,"id",t,r),zn(e,"name",t,r)):r.push({path:t,message:"Expected an actor object."})}function Ln(e,t){const r=Mn(e,"reception","$",t);if(!r)return;En(r,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);const a=On(r,"channels","$.reception",t);a||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),a?.forEach((e,r)=>{const a=`$.reception.channels[${r}]`;Cn(e)?(En(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],a,t),Tn(e,"channel",a,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),jn(e,"disclosure",a,["summary","standard","detailed"],t),jn(e,"rawData",a,["deny","bounded","allow"],t),kn(e,"navigation",a,t),kn(e,"interactionInstructions",a,t),Sn(e,"tokenBudget",a,t),Fn(On(e,"privacyNotes",a,t),a+".privacyNotes",t)):t.push({path:a,message:"Expected a channel object."})});for(const e of["strengths","risks","scaffolds","manualChecks"])Fn(On(r,e,"$.reception",t),"$.reception."+e,t);zn(r,"audience","$.reception",t),zn(r,"description","$.reception",t),kn(r,"dataFallback","$.reception",t)}function _n(e,t){const r=Mn(e,"form","$",t);r&&(En(r,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),zn(r,"chartFamily","$.form",t),zn(r,"whyThisForm","$.form",t),Fn(On(r,"risks","$.form",t),"$.form.risks",t),Fn(On(r,"misuse","$.form",t),"$.form.misuse",t),On(r,"rejectedAlternatives","$.form",t)?.forEach((e,r)=>{const a=`$.form.rejectedAlternatives[${r}]`;Cn(e)?(En(e,["representation","reason"],a,t),Nn(e,"representation",a,t),Nn(e,"reason",a,t)):t.push({path:a,message:"Expected an alternative object."})}))}function Dn(e,t){const r=Mn(e,"contestability","$",t);r&&(En(r,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),kn(r,"sourceRequestsAllowed","$.contestability",t),On(r,"challenges","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.challenges[${r}]`;if(Cn(e)){En(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],a,t),Nn(e,"id",a,t),Nn(e,"claimId",a,t),Nn(e,"reason",a,t),Tn(e,"status",a,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&Bn(e.raisedBy,a+".raisedBy",t);for(const r of["raisedAt","counterclaimId","resolution"])zn(e,r,a,t)}else t.push({path:a,message:"Expected a challenge object."})}),On(r,"corrections","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.corrections[${r}]`;if(!Cn(e))return void t.push({path:a,message:"Expected a correction object."});En(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],a,t),Nn(e,"id",a,t),Nn(e,"reason",a,t);const o=On(e,"affectedClaimIds",a,t);o||t.push({path:a+".affectedClaimIds",message:"Expected an affected-claim array."}),Fn(o,a+".affectedClaimIds",t),Fn(On(e,"replacementClaimIds",a,t),a+".replacementClaimIds",t),zn(e,"createdAt",a,t),void 0!==e.createdBy&&Bn(e.createdBy,a+".createdBy",t)}),On(r,"alternativeViews","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.alternativeViews[${r}]`;Cn(e)?(En(e,["id","label","rationale"],a,t),Nn(e,"id",a,t),Nn(e,"label",a,t),zn(e,"rationale",a,t)):t.push({path:a,message:"Expected an alternative-view object."})}),On(r,"editorialExceptions","$.contestability",t)?.forEach((e,r)=>{const a=`$.contestability.editorialExceptions[${r}]`;Cn(e)?(En(e,["ruleId","rationale","owner","reviewAt"],a,t),Nn(e,"ruleId",a,t),Nn(e,"rationale",a,t),zn(e,"owner",a,t),zn(e,"reviewAt",a,t)):t.push({path:a,message:"Expected an editorial-exception object."})}))}function Un(e,t){const r=Mn(e,"accountability","$",t);r&&(En(r,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),On(r,"authors","$.accountability",t)?.forEach((e,r)=>Bn(e,`$.accountability.authors[${r}]`,t)),Fn(On(r,"dataSources","$.accountability",t),"$.accountability.dataSources",t),zn(r,"generatedBy","$.accountability",t),zn(r,"codeRef","$.accountability",t),On(r,"reviews","$.accountability",t)?.forEach((e,r)=>{const a=`$.accountability.reviews[${r}]`;if(Cn(e)){En(e,["id","status","reviewer","reviewedAt","rationale","policyId"],a,t),Nn(e,"id",a,t),Tn(e,"status",a,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&Bn(e.reviewer,a+".reviewer",t);for(const r of["reviewedAt","rationale","policyId"])zn(e,r,a,t)}else t.push({path:a,message:"Expected a review object."})}),On(r,"actions","$.accountability",t)?.forEach((e,r)=>{const a=`$.accountability.actions[${r}]`;if(!Cn(e))return void t.push({path:a,message:"Expected an action object."});En(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],a,t),Nn(e,"id",a,t),Nn(e,"action",a,t);const o=On(e,"claimIds",a,t);o||t.push({path:a+".claimIds",message:"Expected a claim identifier array."}),Fn(o,a+".claimIds",t),void 0!==e.actor&&Bn(e.actor,a+".actor",t);for(const r of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])zn(e,r,a,t);jn(e,"status",a,["proposed","taken","reversed","invalidated"],t)}))}function Vn(e,t){const r=Mn(e,"inheritance","$",t);if(r){En(r,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(const e of["requiredPaths","prohibitedExports","sourceArtifactIds"])Fn(On(r,e,"$.inheritance",t),"$.inheritance."+e,t);jn(r,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),jn(r,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),jn(r,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function Gn(e,t){Ln(e,t),_n(e,t),Dn(e,t),Un(e,t),Vn(e,t)}function qn(e){for(const t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function Hn(e,t){if(void 0===e||Cn(e)){if(Cn(e))for(const[r,a]of Object.entries(e)){const e="$.fieldStatus."+r;if(!Cn(a)||"string"!=typeof a.status){t.push({path:e,message:"Expected a field state with a status."});continue}En(a,["status","reason","suppliedBy","derived","reviewedBy"],e,t),["known","unknown","manual","not-applicable"].includes(a.status)||t.push({path:e+".status",message:"Expected one of: known, unknown, manual, not-applicable."}),void 0===a.suppliedBy||"string"==typeof a.suppliedBy&&["author","system","model-proposal","import"].includes(a.suppliedBy)||t.push({path:e+".suppliedBy",message:"Expected one of: author, system, model-proposal, import."}),zn(a,"reason",e,t),zn(a,"reviewedBy",e,t),kn(a,"derived",e,t);const o=Object.prototype.hasOwnProperty.call(eu,r)?eu[r]:void 0,n="model-proposal"===a.suppliedBy,i=n&&!0===o?.modelMayPropose&&"known"!==a.status;o&&"known"===a.status&&"string"!=typeof a.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${r}" must identify an allowed supplier.`}),!o||"string"!=typeof a.suppliedBy||i||o.suppliedBy.includes(a.suppliedBy)||t.push({path:e+".suppliedBy",message:`Field "${r}" cannot be supplied by ${a.suppliedBy}.`}),o&&!0===a.derived&&!o.derivable&&t.push({path:e+".derived",message:`Field "${r}" cannot be marked as derived.`}),!o||!n||o.modelMayPropose&&"known"!==a.status||t.push({path:e+".suppliedBy",message:"known"===a.status?`A model proposal cannot finalize field "${r}" as known.`:`Field "${r}" does not accept model proposals.`}),"required"!==o?.humanReview||"known"!==a.status||"string"==typeof a.reviewedBy&&a.reviewedBy.trim()||t.push({path:e+".reviewedBy",message:`Known field "${r}" requires an attributable human review.`})}}else t.push({path:"$.fieldStatus",message:"Expected a field-state object."})}function Wn(e,t){const r="$.time";En(e,[...au,...Object.keys(ou),"sources"],r,t);for(const a of au)zn(e,a,r,t);for(const[a,o]of Object.entries(ou)){const n=Mn(e,a,r,t);n&&$n(n,o,`${r}.${a}`,t)}On(e,"sources",r,t)?.forEach((e,a)=>{const o=`${r}.sources[${a}]`;Cn(e)?$n(e,nu,o,t):t.push({path:o,message:"Expected a source object."})})}function Yn(e){try{return Kn(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function Kn(e){const t=[],r=[];if(!Cn(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:r};const a=sr(e);if(a.length>0)return{valid:!1,errors:a.map(e=>({path:e,message:"Expected a JSON-compatible value that survives serialization unchanged."})),warnings:r};if(En(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),e.contractVersion!==Ql&&t.push({path:"$.contractVersion",message:`Expected contract version ${Ql}.`}),Cn(e.artifact)){En(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),Nn(e.artifact,"id","$.artifact",t),Tn(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(const r of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])zn(e.artifact,r,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(Cn(e.purpose))if(Array.isArray(e.purpose.intents)){En(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,r)=>{Cn(e)&&"string"==typeof e.id&&e.id||t.push({path:`$.purpose.intents[${r}].id`,message:"Expected a non-empty intent identifier."}),Cn(e)&&En(e,["id","strength","source","rationale"],`$.purpose.intents[${r}]`,t),Cn(e)&&void 0!==e.strength&&Tn(e,"strength",`$.purpose.intents[${r}]`,["primary","secondary"],t),Cn(e)&&(jn(e,"source",`$.purpose.intents[${r}]`,["author","derived","model-proposal","import"],t),zn(e,"rationale",`$.purpose.intents[${r}]`,t))});for(const r of["allowedUses","prohibitedUses"])Fn(On(e.purpose,r,"$.purpose",t),"$.purpose."+r,t);jn(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),zn(e.purpose,"communicativeAct","$.purpose",t),zn(e.purpose,"decisionContext","$.purpose",t)}else t.push({path:"$.purpose.intents",message:"Expected an intent array."});else t.push({path:"$.purpose",message:"Expected a purpose object."});Array.isArray(e.claims)?e.claims.forEach((e,r)=>{if(!Cn(e))return void t.push({path:`$.claims[${r}]`,message:"Expected a claim object."});En(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${r}]`,t),Nn(e,"id",`$.claims[${r}]`,t),Tn(e,"kind",`$.claims[${r}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),Tn(e,"status",`$.claims[${r}]`,["supported","provisional","disputed","superseded","retracted","unsupported","unknown"],t),Array.isArray(e.evidenceIds)?e.evidenceIds.some(e=>"string"!=typeof e||!e)&&t.push({path:`$.claims[${r}].evidenceIds`,message:"Expected non-empty string evidence identifiers."}):t.push({path:`$.claims[${r}].evidenceIds`,message:"Expected an evidence identifier array."}),Fn(On(e,"supersedes",`$.claims[${r}]`,t),`$.claims[${r}].supersedes`,t),zn(e,"text",`$.claims[${r}]`,t),zn(e,"asOf",`$.claims[${r}]`,t),Pn(e,"scope",`$.claims[${r}]`,t),Fn(On(e,"tags",`$.claims[${r}]`,t),`$.claims[${r}].tags`,t),void 0!==e.authoredBy&&Bn(e.authoredBy,`$.claims[${r}].authoredBy`,t);const a=Mn(e,"review",`$.claims[${r}]`,t);a&&(En(a,["status","reviewer","reviewedAt","rationale"],`$.claims[${r}].review`,t),Tn(a,"status",`$.claims[${r}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==a.reviewer&&Bn(a.reviewer,`$.claims[${r}].review.reviewer`,t),zn(a,"reviewedAt",`$.claims[${r}].review`,t),zn(a,"rationale",`$.claims[${r}].review`,t));const o=Mn(e,"uncertainty",`$.claims[${r}]`,t);if(o){En(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${r}].uncertainty`,t),Tn(o,"kind",`$.claims[${r}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(const e of["lower","upper","confidence"])Sn(o,e,`$.claims[${r}].uncertainty`,t);zn(o,"unit",`$.claims[${r}].uncertainty`,t),zn(o,"description",`$.claims[${r}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,r)=>{if(!Cn(e))return void t.push({path:`$.evidence[${r}]`,message:"Expected an evidence object."});En(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${r}]`,t),Nn(e,"id",`$.evidence[${r}]`,t),Tn(e,"role",`$.evidence[${r}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(const a of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])zn(e,a,`$.evidence[${r}]`,t);Pn(e,"scope",`$.evidence[${r}]`,t);const a=Mn(e,"source",`$.evidence[${r}]`,t);if(a){En(a,["name","uri","version","retrievedAt","publisher"],`$.evidence[${r}].source`,t);for(const e of["name","uri","version","retrievedAt","publisher"])zn(a,e,`$.evidence[${r}].source`,t)}const o=Mn(e,"transformation",`$.evidence[${r}]`,t);if(o){En(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${r}].transformation`,t),Nn(o,"id",`$.evidence[${r}].transformation`,t),Tn(o,"kind",`$.evidence[${r}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);const e=On(o,"inputEvidenceIds",`$.evidence[${r}].transformation`,t);e?Fn(e,`$.evidence[${r}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${r}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),Fn(On(o,"assumptions",`$.evidence[${r}].transformation`,t),`$.evidence[${r}].transformation.assumptions`,t),zn(o,"description",`$.evidence[${r}].transformation`,t),zn(o,"implementation",`$.evidence[${r}].transformation`,t),zn(o,"performedAt",`$.evidence[${r}].transformation`,t),Pn(o,"parameters",`$.evidence[${r}].transformation`,t),void 0!==o.performedBy&&Bn(o.performedBy,`$.evidence[${r}].transformation.performedBy`,t)}const n=Mn(e,"sample",`$.evidence[${r}]`,t);if(n){En(n,["rowCount","fields","values","truncated"],`$.evidence[${r}].sample`,t),Fn(On(n,"fields",`$.evidence[${r}].sample`,t),`$.evidence[${r}].sample.fields`,t);const e=On(n,"values",`$.evidence[${r}].sample`,t);e&&!In(e)&&t.push({path:`$.evidence[${r}].sample.values`,message:"Expected JSON values."}),Sn(n,"rowCount",`$.evidence[${r}].sample`,t),kn(n,"truncated",`$.evidence[${r}].sample`,t)}jn(e,"relationship",`$.evidence[${r}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),Hn(e.fieldStatus,t);const o=Mn(e,"time","$",t);return o&&Wn(o,t),Gn(e,t),Pn(e,"extensions","$",t),Array.isArray(e.claims)&&0===e.claims.length&&r.push({path:"$.claims",message:"The contract declares no claims."}),Array.isArray(e.evidence)&&0===e.evidence.length&&r.push({path:"$.evidence",message:"The contract declares no evidence."}),{valid:0===t.length,errors:t,warnings:r}}function Jn(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Xn(e,t){if(!t||!Jn(e)||!Array.isArray(e.evidence))return[];const r=[];return e.evidence.forEach((e,t)=>{Jn(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,r.push(`$.evidence[${t}].sample`))}),r}function Zn(e,t={}){try{return Qn(e,t)}catch{const t=sr(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function Qn(e,t){if(!Jn(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};const r=An(e),a=[.../* @__PURE__ */new Set([...r.excludedPaths,...sr(e)])].sort(),o=r.value,n=Xn(o,t.excludeEvidenceSamples),i=n.length?["Bounded evidence samples were excluded by the transfer policy."]:[],s=o?.contractVersion;if("string"!=typeof s||!s)return{contract:o,transfer:{status:"invalid",omittedPaths:[...a,...n],warnings:["Artifact contract is missing a string contractVersion.",...i]}};if(s!==Ql)return{contract:o,transfer:{status:a.length>0?"invalid":"unsupported-version",omittedPaths:[...a,...n],warnings:[`Contract version ${s} is not interpreted by this runtime.`,...a.length>0?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...i]}};const c=Yn(o),l=[...c.errors.map(({path:e,message:t})=>`${e}: ${t}`),...c.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...a.length?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...i];return{contract:o,transfer:{status:!c.valid||a.length>0?"invalid":n.length>0?"excluded":"preserved",omittedPaths:[...a,...n],warnings:l}}}function ei(e){const t=Zn(e);if(!t.contract||"preserved"!==t.transfer.status)throw new TypeError(t.transfer.warnings.join(" ")||"Artifact contract could not be serialized without loss.");return t}function ti(e){const t=Object.entries(e).filter(([e,t])=>pn(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function ri(e,t=[]){if(void 0===e)return;const r=t.filter(e=>!!e.transformation).map(({id:e,transformation:t})=>({evidenceId:e,transformation:t})).sort(({evidenceId:e},{evidenceId:t})=>t>e?-1:e>t?1:0);return xn(r.length>0?{data:e,transformations:r}:e).fingerprint}function ai(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!pn(e,t)&&"recipeId"!==e))}function oi(e,t,r,a=ti(t)){const o=ai(t),n=0===sr(o).length?xn(o).fingerprint:void 0,i=void 0!==a&&0===sr(a).length?ri(a,e.evidence):void 0,s="ChartRecipe"===r&&"string"==typeof t.recipeId?t.recipeId:r,c=[],l=[];return void 0!==s&&(void 0===e.artifact.component?l.push("artifact.component"):e.artifact.component!==s&&c.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===n?l.push("artifact.configFingerprint"):e.artifact.configFingerprint!==n&&c.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&i?e.artifact.dataFingerprint!==i&&c.push("artifact.dataFingerprint"):l.push("artifact.dataFingerprint"),{status:c.length>0?"mismatch":l.length>0?"unknown":"match",mismatchPaths:c,unknownPaths:l}}function ni(e,t,r){const a=oi(e,t,r);return{mismatchPaths:[...a.mismatchPaths,...void 0!==r&&a.unknownPaths.includes("artifact.component")?["artifact.component"]:[]]}}function ii(e,t){return[.../* @__PURE__ */new Set([...Object.keys(e),...Object.keys(t)])].filter(r=>{if(Object.prototype.hasOwnProperty.call(e,r)!==Object.prototype.hasOwnProperty.call(t,r))return!0;const a=xn(e[r]),o=xn(t[r]);return a.excludedPaths.length>0||a.fingerprint!==o.fingerprint}).map(e=>"props."+e).sort()}function si(e){if(e.startsWith("props."))return e.slice(6).split(/[.[\]]/,1)[0]}function ci(e,t){const r=t.map(si).filter(e=>void 0!==e);return"artifact.dataFingerprint"===e?r.some(e=>Yl.has(e)):"artifact.configFingerprint"===e&&r.some(e=>!Yl.has(e))}function li(e){if(!e||"object"!=typeof e)return!1;const t=e,r=t.serializedDataFingerprint;return"string"==typeof t.status&&iu.has(t.status)&&Array.isArray(t.omittedPaths)&&t.omittedPaths.every(e=>"string"==typeof e)&&Array.isArray(t.warnings)&&t.warnings.every(e=>"string"==typeof e)&&(void 0===t.serializedConfigFingerprint||"string"==typeof t.serializedConfigFingerprint)&&(null==r||"string"==typeof r)&&(void 0===t.transferFingerprint||"string"==typeof t.transferFingerprint)}function ui(e,t,r,a){return xn({component:t,version:a.version,createdAt:a.createdAt,...void 0!==a.recipeId?{recipeId:a.recipeId}:{},...void 0!==a.portable?{portable:a.portable}:{},...void 0!==a.manifest?{manifest:a.manifest}:{},...void 0!==a.reason?{reason:a.reason}:{},...void 0!==a.warnings?{warnings:a.warnings}:{},...void 0!==a.selections?{selections:a.selections}:{},artifactContract:r,status:e.status,omittedPaths:e.omittedPaths,warnings:e.warnings,...void 0!==e.serializedConfigFingerprint?{serializedConfigFingerprint:e.serializedConfigFingerprint}:{},...Object.prototype.hasOwnProperty.call(e,"serializedDataFingerprint")?{serializedDataFingerprint:e.serializedDataFingerprint}:{}}).fingerprint}function di(e,t,r,a,o){const n=ti(r),i={...e,serializedConfigFingerprint:xn(ai(r)).fingerprint,serializedDataFingerprint:void 0===n?null:xn(n).fingerprint};return{...i,transferFingerprint:ui(i,t,a,o)}}function hi(e,t){const r=[],a=xn(ai(t.props)).fingerprint,o=ti(t.props),n=void 0===o?null:xn(o).fingerprint;return void 0!==e.transferFingerprint&&e.transferFingerprint!==ui(e,t.component,t.artifactContract,t)&&r.push("artifactTransfer.transferFingerprint"),void 0!==e.serializedConfigFingerprint&&e.serializedConfigFingerprint!==a&&r.push("artifactTransfer.serializedConfigFingerprint"),Object.prototype.hasOwnProperty.call(e,"serializedDataFingerprint")&&e.serializedDataFingerprint!==n&&r.push("artifactTransfer.serializedDataFingerprint"),r}function pi(e,t){if("artifactContract"===t||"$.artifactContract"===t)return void 0!==e.artifactContract;let r,a;if("props"===t||t.startsWith("props.")?(r=e,a=t):(r=e.artifactContract,a=t.startsWith("$.")?t.slice(2):t),"$"===a||""===a)return void 0!==r;const o=[...a.matchAll(/(?:^|\.)([^.[\]]+)|\[(\d+)\]/g)].map(e=>e[1]??Number(e[2]));if(0===o.length)return!1;for(const e of o){if(null===r||"object"!=typeof r||!Object.prototype.hasOwnProperty.call(r,e))return!1;r=r[e]}return!0}function fi(e,t,r,a,o){if(!t)return{};const n=ei(t),i=o.recipeId??e,s=ni(t,r,i),c=ii(r,a),l=ni(t,a,i);return s.mismatchPaths.length>0?{artifactContract:n.contract,artifactTransfer:di({status:"invalid",omittedPaths:s.mismatchPaths,warnings:["The artifact contract fingerprints do not match the supplied chart props or data."]},e,a,n.contract,o)}:c.length>0?{artifactContract:n.contract,artifactTransfer:di({status:"excluded",omittedPaths:c,warnings:["Chart props or data were excluded from the serialized configuration."]},e,a,n.contract,o)}:l.mismatchPaths.length>0?{artifactContract:n.contract,artifactTransfer:di({status:"invalid",omittedPaths:l.mismatchPaths,warnings:["Serialized chart props or data differ from the values bound to the artifact contract."]},e,a,n.contract,o)}:{artifactContract:n.contract,artifactTransfer:di(n.transfer,e,a,n.contract,o)}}function mi(e){if(!e.artifactContract){if(!e.artifactTransfer)return{};if(li(e.artifactTransfer)&&"excluded"===e.artifactTransfer.status&&e.artifactTransfer.omittedPaths.includes("artifactContract")){const t=e.artifactTransfer.omittedPaths.filter(t=>"artifactContract"!==t&&pi(e,t));return 0===t.length?{artifactTransfer:su(e.artifactTransfer)}:{artifactTransfer:{status:"invalid",omittedPaths:[...e.artifactTransfer.omittedPaths],warnings:[`The declared omitted path is still present: ${t.join(", ")}.`]}}}return{artifactTransfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["An artifact transfer report cannot claim preservation without an artifact contract."]}}}const t=Zn(e.artifactContract),r=e.artifactTransfer,a=t.transfer;let o=(()=>{if(!r)return{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...a.omittedPaths,"artifactTransfer"])],warnings:[...a.warnings,"The artifact contract has no transfer report, so its transport history cannot be verified."]};if(!li(r))return{status:"invalid",omittedPaths:a.omittedPaths,warnings:[...a.warnings,"The declared artifact transfer report is malformed."]};const t="excluded"===r.status||"unsupported-version"===r.status?r.omittedPaths.filter(t=>pi(e,t)):[];return t.length>0?{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...r.omittedPaths,...a.omittedPaths])],warnings:[...a.warnings,`The declared omitted path is still present: ${t.join(", ")}.`]}:"preserved"===r.status&&r.omittedPaths.length>0||"excluded"===r.status&&0===r.omittedPaths.length?{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...r.omittedPaths,...a.omittedPaths])],warnings:[...a.warnings,"The declared artifact transfer status contradicts its omitted paths."]}:r.status===a.status?su(r):"preserved"!==a.status||"excluded"!==r.status&&"invalid"!==r.status||0>=r.omittedPaths.length?{status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...r.omittedPaths,...a.omittedPaths])],warnings:[.../* @__PURE__ */new Set([...r.warnings,...a.warnings,`Declared artifact transfer status ${r.status} does not match the restored contract status ${a.status}.`])]}:su(r)})();if(r&&li(r)){const t=hi(r,e),a="invalid"!==r.status,n=[...a&&void 0===r.serializedConfigFingerprint?["artifactTransfer.serializedConfigFingerprint"]:[],...a&&!Object.prototype.hasOwnProperty.call(r,"serializedDataFingerprint")?["artifactTransfer.serializedDataFingerprint"]:[],...a&&void 0===r.transferFingerprint?["artifactTransfer.transferFingerprint"]:[]];(t.length>0||n.length>0)&&(o={status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...o.omittedPaths,...t,...n])],warnings:[.../* @__PURE__ */new Set([...o.warnings,t.length>0?"The serialized chart payload no longer matches its transfer fingerprints.":"The declared chart transfer cannot be verified without serialized transfer fingerprints."])]})}if("preserved"===t.transfer.status&&t.contract?.contractVersion===Ql){const r=ni(t.contract,e.props,e.recipeId??e.component).mismatchPaths.filter(e=>!ci(e,o.omittedPaths));r.length>0&&(o={status:"invalid",omittedPaths:[.../* @__PURE__ */new Set([...o.omittedPaths,...r])],warnings:[.../* @__PURE__ */new Set([...o.warnings,"Restored chart props or data do not match the artifact contract fingerprints."])]})}return{...t.contract?{artifactContract:t.contract}:{},artifactTransfer:o}}function gi(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function yi(e,t){return!!pn(e,t)&&("areas"!==e||"string"!=typeof t)}function bi(e,t,r){if(r?.selections&&sr(r.selections).length>0)throw new TypeError("Serialized selection state must contain only values that survive JSON serialization unchanged.");const a=lr(e)??hr(t.recipe)??hr(t.recipeId);if(a)return wi(a,t,r);if(!he(e))throw Error(`Unknown component "${e}". Known components: ${oc.join(", ")}`);const o=!1!==r?.includeData,n={};for(const[e,r]of Object.entries(t))if(null!=r&&!lu.has(e)&&(o||!yi(e,r))&&"function"!=typeof r&&0>=sr(r).length)try{gi(n,e,uu(r))}catch{}const i=/* @__PURE__ */(new Date).toISOString(),s={version:cu,createdAt:i,...r?.selections?{selections:r.selections}:{}};return{component:e,props:n,version:cu,createdAt:i,...fi(e,r?.artifactContract,t,n,s),...r?.selections?{selections:r.selections}:{}}}function vi(e,t,r){const a={};for(const[o,n]of Object.entries(e))if(null!=n&&!lu.has(o)&&"recipeId"!==o&&(t||!yi(o,n)))if("function"!=typeof n)if(sr(n).length>0){if(r)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`)}else gi(a,o,uu(n));else if(r)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`);return a}function wi(e,t,r){const a=!1!==r?.includeData,o=sr(e);if("portable"===e.portability&&o.length>0)throw Error(`Portable recipe "${e.id}" has non-JSON definition values at: ${o.join(", ")}.`);const n=vi(t,a,"portable"===e.portability),i=e.intents.map(ma).filter(e=>!!e),s=e.layout&&"object"==typeof e.layout&&"string"==typeof e.layout.id?e.layout.id:void 0,c=s?dr(s):void 0,l=e.layout&&"object"==typeof e.layout&&"string"==typeof e.layout.version&&e.layout.version?{version:e.layout.version,...e.layout.fingerprint?{fingerprint:e.layout.fingerprint}:{}}:void 0;if(c&&l&&(c.version!==l.version||c.fingerprint!==l.fingerprint))throw Error(`Recipe layout "${s}" registry identity does not match its portable declaration.`);const u=c??l;if("portable"===e.portability&&s&&!u)throw Error(`Portable recipe layout "${s}" must be registered with an explicit version identity.`);const d={name:e.name,intents:i,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily,...e.version?{recipeVersion:e.version}:{},...0===o.length?{definitionFingerprint:xn(e).fingerprint}:{},...s?{layoutId:s}:{},...u?{layoutVersion:u.version}:{},...u?.fingerprint?{layoutFingerprint:u.fingerprint}:{}},h=/* @__PURE__ */(new Date).toISOString();if("portable"===e.portability){if(sr(n).length>0)throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);const a={version:cu,createdAt:h,recipeId:e.id,portable:!0,manifest:d,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:n,manifest:d,version:cu,createdAt:h,...fi("ChartRecipe",r?.artifactContract,t,n,a),...r?.selections?{selections:r.selections}:{}}}const p="Recipe contains or may depend on non-serializable local layout callbacks.",f=["This config is inspectable but cannot be rendered remotely by CLI or MCP."],m={version:cu,createdAt:h,recipeId:e.id,portable:!1,manifest:d,reason:p,warnings:f,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:p,warnings:f,props:n,manifest:d,version:cu,createdAt:h,...fi("ChartRecipe",r?.artifactContract,t,n,m),...r?.selections?{selections:r.selections}:{}}}function Ai(e){try{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}catch{return!1}}function xi(e){if(!Ai(e))throw Error("Invalid chart config: expected a plain object");const t=sr(e);if(t.length>0)throw new TypeError(`Chart config contains values that cannot survive JSON serialization at: ${t.join(", ")}.`);if(e.version!==cu)throw Error(`Unsupported chart config version ${e.version+""}; expected ${cu}.`);if("string"!=typeof e.component||!e.component.trim())throw Error("Invalid chart config: missing component");if(!Ai(e.props))throw Error("Invalid chart config: props must be a plain object");if("string"!=typeof e.createdAt||!Number.isFinite(Date.parse(e.createdAt)))throw Error("Invalid chart config: createdAt must be a valid timestamp");if(void 0!==e.recipeId&&("string"!=typeof e.recipeId||!e.recipeId.trim()))throw Error("Invalid chart config: recipeId must be a non-empty string");if(void 0!==e.portable&&"boolean"!=typeof e.portable)throw Error("Invalid chart config: portable must be a boolean");if(void 0!==e.selections&&!Ai(e.selections))throw Error("Invalid chart config: selections must be a plain object");if(void 0!==e.manifest){if(!Ai(e.manifest))throw Error("Invalid chart config: manifest must be a plain object");if("string"!=typeof e.manifest.name||!e.manifest.name.trim()||"string"!=typeof e.manifest.frameFamily||!e.manifest.frameFamily.trim()||!Array.isArray(e.manifest.intents)||e.manifest.intents.some(e=>"string"!=typeof e||!e.trim())||void 0!==e.manifest.audience&&(!Array.isArray(e.manifest.audience)||e.manifest.audience.some(e=>"string"!=typeof e||!e.trim()))||void 0!==e.manifest.recipeVersion&&("string"!=typeof e.manifest.recipeVersion||!e.manifest.recipeVersion.trim())||void 0!==e.manifest.definitionFingerprint&&("string"!=typeof e.manifest.definitionFingerprint||!e.manifest.definitionFingerprint.trim())||void 0!==e.manifest.layoutId&&("string"!=typeof e.manifest.layoutId||!e.manifest.layoutId.trim())||void 0!==e.manifest.layoutVersion&&("string"!=typeof e.manifest.layoutVersion||!e.manifest.layoutVersion.trim())||void 0!==e.manifest.layoutFingerprint&&("string"!=typeof e.manifest.layoutFingerprint||!e.manifest.layoutFingerprint.trim())||void 0!==e.manifest.layoutVersion&&void 0===e.manifest.layoutId||void 0!==e.manifest.layoutFingerprint&&void 0===e.manifest.layoutVersion)throw Error("Invalid chart config: malformed recipe manifest")}}function $i(e){if(xi(e),"ChartRecipe"===e.component||"LocalChartRecipe"===e.component){if(!e.recipeId)throw Error("Invalid chart recipe config: missing recipeId");const t=lr(e.recipeId);if(!t)throw Error(`Unknown chart recipe "${e.recipeId}". Register it before deserializing this config.`);if(e.manifest?.definitionFingerprint&&e.manifest.definitionFingerprint!==xn(t).fingerprint)throw Error(`Chart recipe "${e.recipeId}" no longer matches the serialized definition.`);if(void 0!==e.manifest?.recipeVersion&&e.manifest.recipeVersion!==t.version)throw Error(`Chart recipe "${e.recipeId}" version does not match the serialized config.`);if(e.manifest?.layoutVersion){const r=e.manifest.layoutId,a=r?ur(r):void 0,o=r?dr(r):void 0,n=a?o:o??(t.layout&&"object"==typeof t.layout&&t.layout.id===r&&t.layout.version?{version:t.layout.version,fingerprint:t.layout.fingerprint}:void 0);if(!n||n.version!==e.manifest.layoutVersion||n.fingerprint!==e.manifest.layoutFingerprint)throw Error(`Chart recipe "${e.recipeId}" layout implementation no longer matches the serialized 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:{...uu(e.props),recipeId:e.recipeId},...mi(e)}}if(!he(e.component))throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:uu(e.props),...mi(e)}}function Ci(e,t={}){xi(e);const r=JSON.stringify(e),a="sc="+btoa(unescape(encodeURIComponent(r))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");if(void 0!==t.maxLength&&a.length>Math.max(0,Math.floor(t.maxLength)))throw new RangeError(`Serialized chart config is ${a.length} characters; the declared URL limit is ${t.maxLength}. Use a file or sidecar export instead.`);return a}function Si(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))),o=JSON.parse(a);return xi(o),o}async function ki(e,t="json"){const r="jsx"===t?Ri(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 Ri(e){xi(e);const{props:t}=e,r="LocalChartRecipe"===e.component?"ChartRecipe":e.component;if("ChartRecipe"!==r&&!he(r))throw Error(`Cannot project unknown component "${r}" to JSX.`);const a=["<"+r];e.recipeId&&a.push(` recipeId={${Ii(e.recipeId)}}`);for(const[e,r]of Object.entries(t)){if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)){const t={};Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),a.push(` {...${Ii(t)}}`);continue}if("string"==typeof r)a.push(Pi(r)?` ${e}="${r}"`:` ${e}={${Ii(r)}}`);else if("boolean"==typeof r&&!0===r)a.push(" "+e);else if("boolean"==typeof r&&!1===r)a.push(` ${e}={false}`);else if("number"==typeof r)a.push(` ${e}={${r}}`);else{const t=Ii(r);a.push(80>t.length?` ${e}={${t}}`:` ${e}={${Ii(r,2)}}`)}}return a.push("/>"),a.join("\n")}function Pi(e){return!/["&<>{}\r\n\u2028\u2029]/.test(e)}function Ii(e,t){return JSON.stringify(e,null,t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Ei(e){const t=[...e.artifactContract?["artifactContract"]:[],...e.artifactTransfer?["artifactTransfer"]:[],...e.selections?["selections"]:[]];return{jsx:Ri(e),omittedPaths:t,warnings:t.length?["JSX represents the chart props only. Preserve the reported top-level fields as a separate artifact packet."]:[]}}function Ni(e){const t=/* @__PURE__ */Object.create(null);for(const[r,a]of e){const e=[];for(const[,t]of a.clauses){const r=/* @__PURE__ */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 Ti(e){const t=/* @__PURE__ */new Map;for(const[r,a]of Object.entries(e)){const e=/* @__PURE__ */new Map;for(const t of a.clauses){const r=/* @__PURE__ */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}async function Mi(e,t){const{format:r="png",filename:a="chart",scale:o=2,background:n="white"}=t||{},i=e.querySelector('svg[role="img"]')||e.querySelector("svg");if(!i)throw Error("No SVG element found in the container");const s=i.cloneNode(!0),c=i.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",c.width+""),s.getAttribute("height")||s.setAttribute("height",c.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),Oi(i,s),"svg"===r){const e=(new XMLSerializer).serializeToString(s);Fi(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),a+".svg")}else{const t=c.width*o,r=c.height*o,i=document.createElement("canvas");i.width=t,i.height=r;const l=i.getContext("2d");l.fillStyle=n,l.fillRect(0,0,t,r),l.scale(o,o);const u=e.querySelector("canvas");u&&l.drawImage(u,0,0,c.width,c.height);const d=(new XMLSerializer).serializeToString(s),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),p=URL.createObjectURL(h),f=new Image;f.width=c.width,f.height=c.height,await new Promise((e,t)=>{f.onload=()=>{l.drawImage(f,0,0),i.toBlob(r=>{r?(Fi(r,a+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(p)},f.onerror=()=>{URL.revokeObjectURL(p),t(Error("Failed to load SVG image"))},f.src=p})}}function Oi(e,t){const r=e.children,a=t.children,o=window.getComputedStyle(e),n=["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 n){const r=o.getPropertyValue(e);r&&"none"!==r&&""!==r&&t.style?.setProperty(e,r)}for(let e=0;Math.min(r.length,a.length)>e;e++)Oi(r[e],a[e])}function Fi(e,t){const r=URL.createObjectURL(e),a=document.createElement("a");a.href=r,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}function ji(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[r,a]of Object.entries(e))r.startsWith("_")||null!=a&&""!==a&&("number"==typeof a?Number.isFinite(a)&&(t[r]=a):"string"==typeof a?t[r]=a:"boolean"==typeof a?t[r]=a+"":a instanceof Date&&(t[r]=a.toISOString().slice(0,10)));return t}function zi(e){return e&&"object"==typeof e?e:{}}function Bi(e){return zi(e.accessibility).tableFields??e.accessibleDatum??e.datum}function Li(e){const t=[];if(!Array.isArray(e))return t;const r=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const a of e)if(a&&"object"==typeof a&&null!==a.datum)try{switch(a.type){case"point":if(r)break;t.push({label:"Point",values:ji(Bi(a))});break;case"line":case"area":{const e=Bi(a),r=Array.isArray(e)?e:[],o="line"===a.type?"Line point":"Area point";for(const e of r)t.push({label:o,values:ji(e)});break}case"rect":{const e=Bi(a),r=null!=e&&"object"==typeof e?e:{},o=r.category??a.group??"",n=r.value??r.__aggregateValue??r.total,i=ji(r);null==i.category&&""!==o&&(i.category=o+""),null==i.value&&null!=n&&(i.value="number"==typeof n||"string"==typeof n?n:n+""),t.push({label:"Bar",values:i});break}case"heatcell":{const e=ji(Bi(a));null==e.value&&"number"==typeof a.value&&Number.isFinite(a.value)&&(e.value=a.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Bi(a),r=ji(e);if(null==r.category){const t=zi(e),a=t.category??t.label;null!=a&&(r.category=a+"")}t.push({label:"Wedge",values:r});break}case"circle":t.push({label:"Node",values:ji(Bi(a))});break;case"arc":t.push({label:"Arc",values:ji(Bi(a))});break;case"candlestick":t.push({label:"Candlestick",values:ji(Bi(a))});break;case"geoarea":{const e=zi(Bi(a)),r=ji(e);if(null==r.name){const t=zi(e.properties).name??e.name;null!=t&&(r.name=t+"")}t.push({label:"Region",values:r});break}}}catch{}return t}function _i(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}function Di(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function Ui(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function Vi(e){return"number"==typeof e&&Number.isFinite(e)}function Gi(e){if(Vi(e.x)&&Vi(e.y)&&Vi(e.w)&&Vi(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(Vi(e.x)&&Vi(e.y)&&Vi(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(Vi(e.cx)&&Vi(e.cy)&&Vi(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(Vi(e.cx)&&Vi(e.cy)&&Vi(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&Vi(e[0])&&Vi(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function qi(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}function Hi(e,t){const r=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),a=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return a>0?r/a:0}function Wi(e,t,r,a,o){if(e===t)return!0;const n=r.dataRoles.map(e=>va(e,a,o)).filter(e=>!!e).filter(r=>null!=e[r]&&null!=t[r]);return n.length>0&&n.every(r=>e[r]+""==t[r]+"")}function Yi(e,t,r,a,o,n="warn",i){return{id:e,category:t,status:r?"pass":n,message:r?a:o,...i?{evidence:i}:{}}}function Ki(e){const{recipe:t}=e,r=_i(e.scene),a=e.layoutConfig??ga({layoutConfig:e.layoutConfig}),o=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},n=o.x??0,i=o.y??0,s=[],c=r.filter(e=>null!=Ui(e)),l=r.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||qi(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));s.push(Yi("geometry.finite","geometry",0===l.length,"All emitted geometry is finite.",l.length+" marks contain non-finite geometry.","fail",{count:l.length}));const u=r.map(Gi),d=u.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;s.push(Yi("geometry.nonzero-area","geometry",0===d,"All bounded marks have positive area.",d+" marks have zero or negative area.","warn",{count:d}));const h=u.filter(e=>e&&(n>e.x0||i>e.y0||e.x1>n+o.width||e.y1>i+o.height)).length;s.push(Yi("geometry.bounds","geometry",0===h,"All bounded marks stay inside the plot.",h+" marks extend outside the plot bounds.","warn",{count:h}));const p=t.audit?.minimumHitTargetSize??t.accessibility.minimumHitTarget??24,m=u.filter(e=>!!e&&(p>e.x1-e.x0||p>e.y1-e.y0)).length;s.push(Yi("interaction.target-size","interaction",0===m,`All bounded targets meet the declared ${p}px minimum.`,`${m} targets are smaller than ${p}px in at least one dimension.`,"warn",{count:m,minimumTarget:p}));const g=c.map(Di),y=g.filter(e=>!e).length,b=/* @__PURE__ */new Set,v=g.filter(e=>!(!e||!b.has(e)&&(b.add(e),1)));s.push(Yi("identity.stable-ids","identity",0===y,"Every data-bearing mark exposes a stable id.",y+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:y})),s.push(Yi("identity.unique-ids","identity",0===v.length,"Stable mark ids are unique.",v.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set(v)].slice(0,10)}));const w=g.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;w>0&&s.push({id:"identity.index-pattern",category:"identity",status:"warn",message:w+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const A=/* @__PURE__ */new Set;let x=0;const $=e.inputData;for(const e of c){const r=Ui(e),o=Array.isArray(r)?r:[r];let n=!1;for(const e of o)if(e&&"object"==typeof e)for(let r=0;$.length>r;r+=1)Wi(e,$[r],t,a,$)&&(A.add(r),n=!0);n||(x+=1)}const C=Math.max(0,$.length-A.size);s.push(Yi("coverage.input-data","coverage",0===C,"Every input datum is represented by the observed scene.",C+" input data items have no matching scene mark.",t.audit?.requireDatumCoverage?"fail":"warn",{represented:A.size,input:$.length})),s.push(Yi("coverage.scene-data","coverage",0===x,"Every data-bearing scene mark maps back to input data.",x+" scene marks do not map back to an input datum.","warn",{count:x}));const S=t.encodings?.some(e=>"count"===e.channel);!S&&c.length>A.size&&A.size>0&&s.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const k=c.filter(e=>!1===e.interactive).length;s.push(Yi("interaction.hit-targets","interaction",0===k&&c.length>0,"Every observed data-bearing scene node participates in hit testing.",0===c.length?"No data-bearing scene nodes were emitted for interaction.":k+" data-bearing marks explicitly disable interaction.","fail"));const R=(e.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),P=R.filter(e=>!b.has(e));s.push(Yi("coverage.annotation-anchors","coverage",0===P.length,R.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",P.length+" annotations point to missing scene ids.","fail",{unresolved:P}));const I=(e.chart?.selectedIds??[]).filter(e=>!b.has(e));e.chart?.selectedIds&&s.push(Yi("interaction.selection-reachability","interaction",0===I.length,"Selected/highlighted states resolve to observed marks.",I.length+" selected ids are not reachable in the scene.","fail",{missing:I}));const E=Li(r),N=(t.accessibility.tableFields??t.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const r=e.role?t.dataRoles.find(t=>t.role===e.role):void 0;return r?va(r,a,$):void 0}).filter(e=>!!e),T=new Set(E.flatMap(e=>Object.keys(e.values))),M=N.filter(e=>!T.has(e));s.push(Yi("accessibility.table-fields","accessibility",0===M.length,N.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${M.join(", ")}.`,"fail",{expectedFields:N,observedFields:[...T]})),new Set($.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=T.size&&[...T].every(e=>"category"===e||"value"===e)&&s.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const O=(t.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);s.push(Yi("accessibility.color-only","accessibility",0===O.length,"Every declared color encoding names a redundant cue.",O.length+" color encodings have no declared redundant cue.","warn"));const F=e.chart;if(F){for(const[e,r]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])r&&s.push(Yi("accessibility."+e,"accessibility","string"==typeof F[e]&&F[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(t.accessibility.requiresAccessibleTable||"required"===t.accessibility.accessibleTable||t.accessibility.fallbackTable)&&s.push(Yi("accessibility.fallback-table","accessibility",!1!==F.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),F.navigationTree&&s.push(Yi("accessibility.navigation-depth","accessibility",(F.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const j=e.theme?.background??"#ffffff",z=r.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!j.startsWith("#"))return!1;const r=f(t,j);return null!=r&&3>r}).length;s.push(Yi("visual.contrast","visual",0===z,"All statically checkable mark fills meet 3:1 contrast.",z+" marks have fill contrast below 3:1.","warn",{background:j}));let B=0;const L=u.filter(e=>!!e).slice(0,500);for(let e=0;L.length>e;e+=1)for(let t=e+1;L.length>t;t+=1).8>Hi(L[e],L[t])||(B+=1);B>L.length&&s.push({id:"visual.overlap-density",category:"visual",status:"warn",message:B+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const _=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),D={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map(ma).filter(e=>!!e),accessibilityExpectations:[...t.accessibility.requirements??[],...t.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===t.accessibility.fallbackTable||"required"===t.accessibility.accessibleTable||!0===t.accessibility.requiresAccessibleTable,designContractDeclared:!!t.designContract?.whyCustom},U=[...s,..._],V=s.filter(e=>"fail"===e.status).length;return{recipeId:t.id,ok:0===V,summary:{marks:r.length,passes:U.filter(e=>"pass"===e.status).length,warnings:U.filter(e=>"warn"===e.status).length,failures:V,manual:U.filter(e=>"manual"===e.status).length},declaredSemantics:D,observedSceneEvidence:s,manualATChecks:_}}function Ji(e){let t=1/0,r=-1/0;for(const a of e)t>a&&(t=a),a>r&&(r=a);return[t,r]}function Xi(e,t){const{groupBy:r,value:a,agg:o="sum"}=t,n=/* @__PURE__ */new Map,i="min"===o?1/0:"max"===o?-1/0:0;for(const t of e){const e=t[r]+"";let s=n.get(e);s||(s={total:i,count:0},n.set(e,s));const c=Number(t[a]);switch(s.count++,o){case"count":break;case"min":s.total>c&&(s.total=c);break;case"max":c>s.total&&(s.total=c);break;default:s.total+=c}}const s=[];for(const[e,t]of n){const a="count"===o?t.count:"mean"===o?t.total/t.count:t.total;s.push({[r]:e,value:a})}return s}function Zi(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 Qi(e){if(e)return"string"==typeof e?e:e.text}function es(e){return"nominal"===e||"ordinal"===e}function ts(e){return"quantitative"===e||"temporal"===e}function rs(e){return e.usermeta?.idid}function as(e){return"annotation-layer"===e.usermeta?.idid?.role}function os(e){if(!rs(e)||!Array.isArray(e.layer))return e;const t=e.layer.filter(e=>!as(e));if(1!==t.length)return e;const{layer:r,...a}=e,{usermeta:o,...n}=t[0];return{...a,...n}}function ns(e){e=os(e);const t=[],{type:r,markProps:a}=Zi(e.mark),o=e.encoding||{},n=o.x,i=o.y,s=o.color,c=o.size,l=o.theta,u=o.opacity;let d;e.data?.values?d=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 h={};e.width&&(h.width=e.width),e.height&&(h.height=e.height);const p=Qi(e.title);if(p&&(h.title=p),s?.field&&(h.colorBy=s.field,s.scale?.scheme)){const e=du[s.scale.scheme];e&&(h.colorScheme=e)}void 0!==u?.value&&(h.pointOpacity=u.value);const f=n?.aggregate,m=i?.aggregate;if(d&&(f||m)){const e=m?i:n,t=m?n:i,r=pu[e.aggregate];if(r&&t?.field&&e.field)d=Xi(d,{groupBy:t.field,value:e.field,agg:r});else if(("count"===r||"count"===e.aggregate)&&t?.field&&d){const e=/* @__PURE__ */new Map;for(const r of d){const a=r[t.field]+"";e.set(a,(e.get(a)||0)+1)}d=Array.from(e,([e,r])=>({[t.field]:e,value:r}))}}if(n?.bin||i?.bin){const e="Histogram";d&&(h.data=d),n?.bin?(h.valueAccessor=n.field,i?.field&&(h.categoryAccessor=i.field),n.axis?.title&&(h.valueLabel=n.axis.title)):i?.bin&&(h.valueAccessor=i.field,n?.field&&(h.categoryAccessor=n.field),i.axis?.title&&(h.valueLabel=i.axis.title));const r=n?.bin||i?.bin,a="object"==typeof r?r.maxbins:void 0;return a&&(h.bins=a),cs(e,h,t)}let g;switch(r){case"bar":g=is(n,i,s,h,d,f,m);break;case"line":if(g="LineChart",ss(n,i,h,f,m),s?.field&&(h.lineBy=s.field),a.interpolate){const e=hu[a.interpolate];e&&(h.curve=e)}!0===a.point&&(h.showPoints=!0),d&&(h.data=d);break;case"area":if(s?.field?(g="StackedAreaChart",h.areaBy=s.field):g="AreaChart",ss(n,i,h,f,m),a.interpolate){const e=hu[a.interpolate];e&&(h.curve=e)}void 0!==a.opacity&&(h.areaOpacity=a.opacity),d&&(h.data=d);break;case"point":case"circle":case"square":c?.field?(g="BubbleChart",h.sizeBy=c.field,c.scale?.range&&(h.sizeRange=c.scale.range)):g="Scatterplot",ss(n,i,h,f,m),d&&(h.data=d);break;case"rect":g="Heatmap",n?.field&&(h.xAccessor=n.field),i?.field&&(h.yAccessor=i.field),s?.field&&(h.valueAccessor=s.field,delete h.colorBy),n?.axis?.title&&(h.xLabel=n.axis.title),i?.axis?.title&&(h.yLabel=i.axis.title),d&&(h.data=d);break;case"arc":a.innerRadius&&a.innerRadius>0?(g="DonutChart",h.innerRadius=a.innerRadius):g="PieChart",l?.field?h.valueAccessor=l.field:i?.field&&(h.valueAccessor=m?"value":i.field),s?.field&&(h.categoryAccessor=s.field),n?.field&&!l?.field&&(h.categoryAccessor=n.field),d&&(h.data=d);break;case"tick":g="DotPlot",es(n?.type)?(h.categoryAccessor=n.field,i?.field&&(h.valueAccessor=m?"value":i.field),n?.axis?.title&&(h.categoryLabel=n.axis.title),i?.axis?.title&&(h.valueLabel=i.axis.title)):es(i?.type)?(h.categoryAccessor=i.field,n?.field&&(h.valueAccessor=f?"value":n.field),h.orientation="horizontal",i?.axis?.title&&(h.categoryLabel=i.axis.title),n?.axis?.title&&(h.valueLabel=n.axis.title)):(n?.field&&(h.categoryAccessor=n.field),i?.field&&(h.valueAccessor=m?"value":i.field)),d&&(h.data=d);break;default:t.push(`Unsupported mark type "${r}". Defaulting to Scatterplot.`),g="Scatterplot",ss(n,i,h,f,m),d&&(h.data=d)}return cs(g,h,t)}function is(e,t,r,a,o,n,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",es(e?.type)&&ts(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)):ts(e?.type)&&es(t?.type)?(a.categoryAccessor=t.field,a.valueAccessor=n?"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)),o&&(a.data=o),s}function ss(e,t,r,a,o){e?.field&&(r.xAccessor=a?"value":e.field),t?.field&&(r.yAccessor=o?"value":t.field),e?.axis?.title&&(r.xLabel=e.axis.title),t?.axis?.title&&(r.yLabel=t.axis.title)}function cs(e,t,r){const a={component:e,props:t,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString()};if(r.length>0){a.warnings=r;for(const e of r)console.warn("[semiotic/fromVegaLite] "+e)}return a}function ls(e,t){for(const r of t){const t=e.find(e=>e.lower===r);if(t)return t}}function us(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const r=t.maxEntries??6,a=!1!==t.skipPositional,o=[];for(const[t,r]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;const e=t.toLowerCase();if(a&&vu.has(e))continue;if(null==r)continue;const n=typeof r;("string"===n||"number"===n||"boolean"===n||r instanceof Date)&&o.push({key:t,lower:e,value:r})}if(0===o.length)return{entries:[]};let n=o.findIndex(e=>gu.includes(e.lower));const i=n>=0;0>n&&(n=o.findIndex(e=>"id"===e.lower)),0>n&&(n=o.findIndex(e=>"string"==typeof e.value));const s=0>n?void 0:o[n],c=o.filter((e,t)=>t!==n&&(!i||"id"!==e.lower)),l=ls(c,yu),u=ls(c,bu),d=[];l&&d.push({key:l.key,value:l.value}),u&&d.push({key:u.key,value:u.value});for(const e of c){if(d.length>=r)break;yu.includes(e.lower)||bu.includes(e.lower)||d.push({key:e.key,value:e.value})}return{titleKey:s?.key,title:s?.value,entries:d}}function ds({chrome:e="default",className:t="",style:r,children:a,...o}){const n="default"===e?{...xu,...r}:r;/* @__PURE__ */ /* @__PURE__ */
2
2
  return(0,Au.jsx)("div",{...o,"data-semiotic-tooltip-chrome":!0,className:("semiotic-tooltip "+t).trim(),style:n,children:a})}function hs(e){return e.ownsChrome=!0,e}function ps(e){if("string"!=typeof e)return null!=e;const t=e.trim().toLowerCase();return!(!t||"transparent"===t||/^rgba\([^)]*,\s*0(?:\.0+)?\s*\)$/.test(t)||/^hsla\([^)]*,\s*0(?:\.0+)?\s*\)$/.test(t))}function fs(e){if(!wu.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const r=e.props,a=r["data-semiotic-tooltip-chrome"];if(null!=a&&!1!==a&&"false"!==a)return!0;const o=r.style;if(o&&"object"==typeof o){if(ps(o.background))return!0;if(ps(o.backgroundColor))return!0}return!1}function ms(e,t){return"function"==typeof t?t(e):e[t]}function gs(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}if(e instanceof Date)return e.toLocaleDateString();if("object"==typeof e&&null!==e){if(void 0!==e.id)return e.id+"";if(void 0!==e.name)return e.name+"";try{return JSON.stringify(e)}catch{return Array.isArray(e)?`[Array(${e.length})]`:"[Object]"}}return e+""}function ys(e={}){const{fields:t,title:r,format:a,style:o={},className:n=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let i;const s=[];if(r){const t=ms(e,r);i=gs(t,a)}if(t&&t.length>0)t.forEach(t=>{let r,o,n;"string"==typeof t?(r=t,o=t,n=a):(r=t.label,o=t.accessor||t.key||"",n=t.format||a);const i=ms(e,o);s.push({label:r,value:gs(i,n)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){i=gs(e[r],a);break}if(!i){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(i=gs(e[t[0]],a))}}/* @__PURE__ */ /* @__PURE__ */
3
3
  return(0,$u.jsxs)(ds,{className:n,style:o,children:[i&&/* @__PURE__ */ /* @__PURE__ */(0,$u.jsx)("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:i}),s.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,$u.jsxs)("div",{style:{marginTop:0===t&&i?"4px":0},children:[e.label&&/* @__PURE__ */ /* @__PURE__ */(0,$u.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function bs(e={}){const{fields:t=[],title:r,format:a,style:o={},className:n="",showLabels:i=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const c=[];if(r){const t=ms(e,r);c.push({value:gs(t,a)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let r,o,n;"string"==typeof t?(r=t,o=t,n=a):(r=t.label,o=t.accessor||t.key||"",n=t.format||a);const s=gs(ms(e,o),n);c.push({label:i?r:void 0,value:s})});else{const t=us(e,{skipPositional:!1});null!=t.title&&c.push({label:void 0,value:gs(t.title,a),bold:!0}),t.entries.forEach(e=>{c.push({label:i?e.key:void 0,value:gs(e.value,a)})})}return Array.isArray(c)&&0!==c.length?/* @__PURE__ */ /* @__PURE__ */(0,$u.jsx)(ds,{className:("semiotic-tooltip-multiline "+n).trim(),style:o,children:c.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,$u.jsxs)("div",{style:{marginBottom:c.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&/* @__PURE__ */ /* @__PURE__ */(0,$u.jsxs)("strong",{children:[e.label,s]}),e.value]},t))}):null}}function vs(e){return"multi"===e||ws(e)}function ws(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&"mode"in e&&"multi"===e.mode}function As(e){const{tooltip:t,defaultTooltipContent:r,multiDefaultContent:a=$s(),customFunctionContext:o="datum"}=e,n=t;return!1===t?{tooltipContent:()=>null}:vs(n)?{tooltipContent:(ws(n)&&"function"==typeof n.content?Cs(n.content):void 0)||a,tooltipMode:"multi"}:"hover"===o&&"function"==typeof t?{tooltipContent:t}:{tooltipContent:Cs(n)||r}}function xs(e){const{tooltip:t,defaultTooltipContent:r,customFunctionContext:a="datum"}=e;return!1===t?{tooltipContent:()=>null}:"hover"===a&&"function"==typeof t?{tooltipContent:t}:{tooltipContent:Cs(t)||r}}function $s(){return e=>{const t=e.allSeries;if(!t||0===t.length)/* @__PURE__ */ /* @__PURE__ */
4
4
  return(0,$u.jsx)(ds,{children:/* @__PURE__ */ /* @__PURE__ */(0,$u.jsx)("div",{children:gs(e.data?.value??e.data?.y)})});const r=e.xValue??e.data?.time??e.data?.x;/* @__PURE__ */ /* @__PURE__ */