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,5 +1,5 @@
1
1
  "use client";
2
- function e(e){if(!e)return{};let t={};return void 0!==e.fill&&(t.fill=e.fill),void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.strokeDasharray&&(t.strokeDasharray=e.strokeDasharray),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.fillOpacity&&(t.fillOpacity=e.fillOpacity),void 0!==e.filter&&(t.filter=e.filter),void 0!==e.mixBlendMode&&(t.style={mixBlendMode:e.mixBlendMode}),t}function t(e){let t=e.match(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi);if(!t||2>t.length)return null;let r=1/0,a=1/0,i=-1/0,s=-1/0;for(let e=0;t.length>e+1;e+=2){let o=parseFloat(t[e]),n=parseFloat(t[e+1]);Number.isFinite(o)&&(r=Math.min(r,o),i=Math.max(i,o)),Number.isFinite(n)&&(a=Math.min(a,n),s=Math.max(s,n))}return Number.isFinite(r)&&Number.isFinite(a)?{x:r,y:a,w:i-r,h:s-a}:null}function r(e){let t=e.fontSize??12,r=Math.max(1,(e.text+"").length*t*.6),a=e.textAnchor??"start";return{x:"middle"===a?e.x-r/2:"end"===a?e.x-r:e.x,y:e.y-t,w:r,h:1.2*t}}function a(e){switch(e.kind){case"rect":case"image":return{x:e.x,y:e.y,w:e.w,h:e.h};case"ellipse":return{x:e.cx-e.rx,y:e.cy-e.ry,w:2*e.rx,h:2*e.ry};case"path":return t(e.d);case"text":return r(e);case"composite":case"mask":return e.bbox;case"group":return null}}function i(e,t){return{x:e.x*t.sx+t.tx,y:e.y*t.sy+t.ty,w:e.w*t.sx,h:e.h*t.sy}}function s(e,t){let[r=0,a=0]=t.translate??[],[i=1,s=1]=t.scale??[];return{tx:e.tx+r*e.sx,ty:e.ty+a*e.sy,sx:e.sx*i,sy:e.sy*s}}function o(e){if(null!=e.datum)return e.datum;let t;if("group"===e.kind?t=e.children:"composite"===e.kind?t=[...e.source,...e.dest]:"mask"===e.kind&&(t=[...e.mask,...e.content]),t)for(let e of t){let t=o(e);if(null!=t)return t}}function n(e){return null==e?null:Array.isArray(e)?0===e.length?null:1===e.length?e[0]:{...e[0],_rows:e}:e}function l(t,r,a){let i=e(t.style);switch(t.kind){case"rect":return Un("rect",{key:r,x:t.x,y:t.y,width:t.w,height:t.h,...void 0!==t.rx?{rx:t.rx}:{},...void 0!==t.ry?{ry:t.ry}:{},...i});case"ellipse":return Un("ellipse",{key:r,cx:t.cx,cy:t.cy,rx:t.rx,ry:t.ry,...i});case"path":return Un("path",{key:r,d:t.d,...i});case"text":return Un("text",{key:r,x:t.x,y:t.y,...void 0!==t.fontSize?{fontSize:t.fontSize}:{},...void 0!==t.fontFamily?{fontFamily:t.fontFamily}:{},...void 0!==t.textAnchor?{textAnchor:t.textAnchor}:{},...void 0!==t.dominantBaseline?{dominantBaseline:t.dominantBaseline}:{},...void 0!==t.rotate?{transform:`rotate(${t.rotate} ${t.x} ${t.y})`}:{},...i},t.text);case"image":return Un("image",{key:r,x:t.x,y:t.y,width:t.w,height:t.h,href:t.href,...void 0!==t.preserveAspectRatio?{preserveAspectRatio:t.preserveAspectRatio}:{},...i});case"group":{let e=[];return t.transform.translate&&e.push(`translate(${t.transform.translate[0]} ${t.transform.translate[1]})`),t.transform.scale&&e.push(`scale(${t.transform.scale[0]} ${t.transform.scale[1]})`),Un("g",{key:r,...e.length?{transform:e.join(" ")}:{},...i},t.children.map((e,t)=>l(e,`${r}-${t}`,a)))}case"composite":case"mask":return c(t,r,a)}}function c(e,t,r){let a="gf-comp-"+r.compositeId++,i=a+"-source",s=a+"-destination";if("mask"===e.kind){let o=a+"-mask";return Un(Gn,{key:t},Un("defs",null,Un("g",{id:i},e.mask.map((e,t)=>l(e,`${o}-m-${t}`,r))),Un("g",{id:s},e.content.map((e,t)=>l(e,`${o}-c-${t}`,r))),Un("mask",{id:o,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse"},Un("use",{href:"#"+i}))),Un("use",{href:"#"+s,mask:`url(#${o})`}))}let{x:o,y:n,w:c,h:d}=e.bbox,u=`translate(${o} ${n})`,p=e.blendMode,f="atop"===e.operator||"in"===e.operator,h=a+"-desat",y=a+"-cov",m=e.source.map((e,t)=>l(e,`${a}-s-${t}`,r)),g=e.dest.map((e,t)=>l(e,`${a}-d-${t}`,r)),v=[];return p&&v.push(Un("filter",{key:"desat",id:h},Un("feColorMatrix",{type:"saturate",values:"0"}))),f&&v.push(Un("mask",{key:"cov",id:y,maskUnits:"userSpaceOnUse",x:o,y:n,width:c,height:d,style:{maskType:"alpha"}},Un("g",{transform:u},e.source.map((e,t)=>l(e,`${a}-m-${t}`,r))))),Un(Gn,{key:t},v.length?Un("defs",{key:"defs"},v):null,Un("g",{key:"g",...f?{mask:`url(#${y})`}:{}},Un("g",{transform:u,style:{isolation:"isolate"}},Un("g",p?{filter:`url(#${h})`}:null,m),Un("g",p?{style:{mixBlendMode:p}}:null,g))))}function d(e,t,r,l){for(let c of e){if("group"===c.kind){d(c.children,s(t,c.transform),r,l);continue}let e=c.role??"node",u=n(o(c));if("node"!==e||!u||"text"===c.kind)continue;let p=a(c);if(!p)continue;let f=i(p,t);f.w>0&&f.h>0&&(r.push({type:"rect",x:f.x,y:f.y,w:f.w,h:f.h,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:u,id:c.id??"gofish-node-"+l.n}),l.n+=1)}}function u(e,t){for(let r of e){if("group"===r.kind){u(r.children,t);continue}if("node"!==(r.role??"node")||"text"===r.kind)continue;let e=n(o(r));e&&t.push(e)}}function p(e){return t=>{let r=t.config?.displayList??e,a=[];d(r.items,qn,a,{n:0});let i={compositeId:0};return{sceneNodes:a,overlays:Un("g",{className:"semiotic-gofish-displaylist","data-gofish-ir":r.ir},r.items.map((e,t)=>l(e,"gf-"+t,i)))}}}function f(e,t={}){let r=[];(!e||"gofish-display-list"!==e.ir)&&r.push(`Expected a "gofish-display-list" document (the output of GoFish's toDisplayList) but got ir="${e?.ir}". This adapter consumes the baked render IR, not the source-level Frontend IR. Attempting best-effort translation.`),0!==e?.irVersion&&r.push(`This adapter targets GoFish DisplayList IR v0; document declares irVersion=${e?.irVersion}. Newer fields are ignored.`);let a=t.displayList??e,i=Array.isArray(a?.items)?a.items:[];0===i.length&&r.push("Display list carried no items; the chart will render empty.");let s=[];u(i,s);let o=a?.viewport??{w:0,h:0};return{family:"network",networkLayout:p(a),layoutConfig:{displayList:a},nodes:s,edges:[],width:o.w,height:o.h,irVersion:a?.irVersion??0,warnings:r.length?r:void 0}}function h(e){return ul.has(e)}function y(e,t){return h(e)&&!pl[t].includes(e)}function m(e){return"string"==typeof e&&e.trim().length>0}function g(e,t,r){let a=hl.has(e)||void 0!==r&&yl.has(r),i=t=>y(e,t)||a,s=fl.filter(e=>m(t[e])&&!i(e));return{hasTitle:i("title")&&m(t.title),hasDescription:i("description")&&m(t.description),hasSummary:i("summary")&&m(t.summary),unsupportedFinding:s.length>0?{id:"understandable.unsupported-description-prop",principle:"understandable",heuristic:"Descriptive text is connected to the rendered chart",critical:!0,status:"warn",message:`Useful ${s.join(" and ")} text was supplied, but ${1===s.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 v(e){return!!Array.isArray(e.styleRules)&&e.styleRules.some(e=>{if("object"!=typeof e||null===e)return!1;let t=e.style;if("object"!=typeof t||null===t||Array.isArray(t))return!1;let r=t.fill;return"object"==typeof r&&null!==r&&"hatch"===r.type})}function b(e){if(!Array.isArray(e))return!1;let t=e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase());return t.length>0&&t.every(e=>ml.has(e))}function k(e){let t=e.replace(/^#/,"");/^[a-f\d]{3}$/i.test(t)&&(t=t.split("").map(e=>e+e).join(""));let r=t.match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!r)return null;let[a,i,s]=[parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255],o=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*o(a)+.7152*o(i)+.0722*o(s)}function x(e,t){let r=k(e),a=k(t);return null===r||null===a?null:(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function C(e){return"string"==typeof e?.type?e.type:""}function A(e){return!!e&&"object"==typeof e&&gl.has(C(e))}function w(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}function $(e){return vl.has(C(e))&&!w(e)}function S(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function B(e,t){return`${e}[Symbol(${t.description??""})]`}function P(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function W(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function L(e,t,r,a){let i=W(e,t);return i&&"value"in i&&i.enumerable?M(i.value,r,a):[r]}function M(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,i,s;try{s=Array.isArray(e),a=Object.getPrototypeOf(e),i=Reflect.ownKeys(e)}catch{return[t]}if(a!==(s?Array.prototype:Object.prototype)&&null!==a)return[t];r.add(e);let o=[];try{if(s){let a=W(e,"length")?.value;if(!Number.isSafeInteger(a)||0>a)return[S(t,"length")];for(let e of i)"length"===e||"string"==typeof e&&P(e,a)||o.push("symbol"==typeof e?B(t,e):S(t,e));for(let i=0;a>i;i+=1)o.push(...L(e,i+"",S(t,i),r))}else for(let a of i)"symbol"!=typeof a?o.push(...L(e,a,S(t,a),r)):o.push(B(t,a));return o}catch{return[t]}finally{r.delete(e)}}function R(){let e=globalThis;return e[jl]||(e[jl]={recipes:/* @__PURE__ */new Map,capabilities:/* @__PURE__ */new Map,layouts:/* @__PURE__ */new Map}),e[jl]}function I(e){return R().recipes.get(e)}function E(e){let t=R().layouts.get(e)?.identity;return t?{...t}:void 0}function N(e){return"string"==typeof e?I(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function T(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?t:null}function F(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis||null!=T(e)}function O(e){let 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(let e of r)a+=j(e);return r.length/t.length*.39+a/r.length*11.8-15.59}function j(e){let t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;let r=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return r?r.length:1}function D(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}function _(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function z(e){let t=_(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 U(e){let t=_(e);return!0===e.settledProjection||!0===t.settledProjection}function G(e){let t=_(e);return!0===e.reducedMotionSettle||"settle"===e.reducedMotion||!0===t.reducedMotionSettle||"settle"===t.reducedMotion}function V(e){let 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.'};let i=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."};let s=[],o=0;for(let e of r){if("string"!=typeof e||!e.startsWith("#"))continue;let t=x(e,i);null!=t&&(o++,3>t&&s.push(`${e} (${t.toFixed(1)}:1)`))}return 0===o?{...t,status:"manual",message:"colorScheme has no parseable hex colors to check.",fix:"Verify contrast manually for non-hex colors."}:s.length>0?{...t,status:"fail",message:`${s.length} color(s) fall below 3:1 contrast vs ${i}: ${s.join(", ")}.`,fix:"Darken (light background) or lighten (dark background) those colors, or use COLOR_BLIND_SAFE_CATEGORICAL."}:{...t,status:"pass",message:`All ${o} checked colorScheme color(s) meet ≥ 3:1 contrast vs ${i}.`}}function q(e,t,r={}){let a=[],i=I(e),s=Ml.has(e),o=h(e)||!!i||s,n=!0===r.inChartContainer,l=!0===r.describe,c=!0===r.navigable,d=Wl.has(e),u=bl.has(e),{hasTitle:p,hasDescription:f,hasSummary:y,unsupportedFinding:k}=g(e,t,i?.frameFamily),x=!1!==t.accessibleTable&&!d,w=p||f||y,S=D(t),B=z(t),P=s,W=U(t)||Il.has(e)&&x,L=G(t)||P,M=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],R=o?"pass":"manual",E=o?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(k&&a.push(k),a.push(V(t)),a.push({id:"perceivable.content-only-visual",principle:"perceivable",heuristic:"Content is only visual",critical:!0,...d?{status:"pass",message:"BigNumber renders its value as real text with an ARIA label — available without vision."}:x?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:f&&y?{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||Rl.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){let e=!0===t.directLabel||!0===t.showLabels,r=v(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."}});let i=b(t.colorScheme);a.push({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1,...i?{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."})}{let e=M.filter(A);if(e.length>0){let r=t.autoPlaceAnnotations,i="object"==typeof r&&null!==r&&!0===r.redundantCues,s=e.filter(e=>{if("string"!=typeof e.color)return!1;let t=C(e),r=i&&"text"===t;return!($(e)||r)});a.push({id:"perceivable.annotation-association",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...0===s.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:`${s.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,...o?{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."}});{let 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."})}{let r=Ol[e];if(r&&S){let 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:R,message:`The chart takes a single tab stop and navigates data with arrow keys${E} — 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,...S?y||f?{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:R,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${E}.`}),a.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:R,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${E}.`,fix:o?"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,...w?{status:"pass",message:`Provided: ${[p&&"title",f&&"description",y&&"summary"].filter(Boolean).join(", ")}.`}:n?{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,...f||y?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:l?{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."}:p?{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)."}});{let e=[t.description,t.summary].filter(m).join(". "),r=e?O(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(Ll.has(e)){let e=m(t.xLabel),r=m(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(Tl.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."}),M.length>1){let e=M.filter(F).length;a.push({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,...e===M.length?{status:"pass",message:`All ${M.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:M.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:`${M.length-e} of ${M.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:R,message:`Transitions animate with object constancy and data changes are mirrored to the live region${E}.`,fix:o?"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:R,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${E}.`,fix:o?"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,...d?{status:"not-applicable",message:"Single-value display — a table isn't meaningful."}:x?{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)."}}),d||a.push({id:"compromising.table-static",principle:"compromising",heuristic:"Table/data is static",critical:!1,...n?{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:o?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${o?"":E}.`,fix:o?"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,...c?u?{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."}:u?{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:R,message:`Keyboard navigation steps through points and switches series/groups${E}.`,fix:o?"For deeper structure (axis → series → datum), enable ChartContainer's navigable option.":void 0}});{let r,i=Array.isArray(t.data)?t.data:null,s=Array.isArray(t.nodes)?t.nodes:null,o={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};r=Bl.has(e)&&i&&i.length>7?{...o,status:"warn",message:i.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.'}:s&&s.length>200?{...o,status:"warn",message:s.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."}:i&&i.length>5e3?{...o,status:"warn",message:i.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."}:i?{...o,status:"pass",message:i.length+" data points — a reasonable density for non-visual consumption."}:s?{...o,status:"pass",message:s.length+" nodes — a reasonable density for non-visual consumption."}:{...o,status:"manual",message:"Data not provided inline (push mode); verify density at runtime."},a.push(r)}{let e=Array.isArray(t.data)?t.data:null,r=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]),i=!1;if(e&&!r)for(let t of e.slice(0,50))if(t&&"object"==typeof t){for(let e of Object.values(t))if("number"==typeof e&&Number.isFinite(e)&&Math.abs(e)>=1e5){i=!0;break}if(i)break}i&&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,...l?{status:"pass",message:"ChartContainer's describe option auto-generates an L1–L3 description (chart type, statistics, and trend) via describeChart()."}:y?{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,...d?{status:"not-applicable",message:"Single value — nothing to skip."}:x?{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:R,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${E}.`,fix:o?"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,...Rl.has(e)||Nl.has(e)?B?{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:R,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${E}.`}}),s&&(a.push({id:"flexible.sim-pause-control",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...B?{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,...W?{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,...L?{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."}}));{let r=!0===t.responsiveWidth||!0===t.responsiveHeight,i=Fl.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.`}:i?{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."}})}i&&(i.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length))&&a.push({id:"perceivable.recipe-color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,status:"warn",message:i.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"===i.accessibility.description&&!f&&a.push({id:"understandable.recipe-description",principle:"understandable",heuristic:"Features are not described",critical:!1,status:"fail",message:i.name+" requires a recipe-aware description, but none is attached.",fix:"Call describeChart with recipeId/recipe metadata and attach the returned text as description."}),i.accessibility.fallbackTable&&!1===t.accessibleTable&&a.push({id:"compromising.recipe-fallback",principle:"compromising",heuristic:"No data table is provided",critical:!0,status:"fail",message:i.name+" requires a fallback table, but accessibleTable is disabled.",fix:"Enable accessibleTable and preserve recipe-declared table fields on scene nodes."}));let N=a.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),T={criticalsPassed:N.filter(e=>"pass"===e.status).length,criticalsEvaluated:N.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:!N.some(e=>"fail"===e.status),summary:T,findings:a,reference:"Chartability (POUR-CAF) — https://chartability.github.io/POUR-CAF/. Not a pass/fail cert; pair with manual screen-reader testing (NVDA+Firefox, JAWS+Chrome, VoiceOver+Safari)."}}function H(e){let 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(let r of _l){let a=e.findings.filter(e=>e.principle===r&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+r.toUpperCase());for(let e of a)t.push(` ${Dl[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 Y(e,t){let r=e.length,a=t.length,i=Array(a+1);for(let e=0;a>=e;e++)i[e]=e;for(let s=1;r>=s;s++){let r=i[0];i[0]=s;for(let o=1;a>=o;o++){let a=i[o];i[o]=e[s-1]===t[o-1]?r:1+Math.min(r,i[o],i[o-1]),r=a}}return i[a]}function Q(e,t,r=3){let a,i=r+1;for(let r of t){let t=Y(e.toLowerCase(),r.toLowerCase());i>t&&(i=t,a=r)}return i>r?void 0:a}function Z(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function K(e,t){if(0===t.length)return null;let r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||(Q(e,t,3)??null)}function X(e){return` Or use a function: ${e}={d => d.myValue}.`}function J({componentName:e,data:t,accessors:r,requiredProps:a}){if(a)for(let[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){let a=Z(t).find(e=>e&&"object"==typeof e);if(a){let t=Object.keys(a);for(let[i,s]of Object.entries(r))if(s&&"string"==typeof s&&!(s in a)){let r=K(s,t),a=r?` Try ${i}="${r}".`:"";return`${e}: ${i} "${s}" not found in data. Available fields: ${t.join(", ")}.${a}`+X(i)}}}return null}function ee({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 te({componentName:e,nodes:t,edges:r,nodesRequired:a=!1,edgesRequired:i=!0,accessors:s}){if(null==t&&null==r)return null;if(i&&(!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(s&&t&&t.length>0){let r=Z(t).find(e=>e&&"object"==typeof e);if(r){let t=Object.keys(r);for(let[a,i]of Object.entries(s))if(i&&"string"==typeof i&&!(i in r)){let r=K(i,t),s=r?` Try ${a}="${r}".`:"";return`${e}: ${a} "${i}" not found in node data. Available fields: ${t.join(", ")}.${s}`+X(a)}}}return null}function re(e){let[t,r]=Array.isArray(e)?e:[e,void 0],a=zl[t],i=Array.isArray(a)?[...a]:a;return void 0===r?{type:i}:{type:i,enum:[...Ul[r]]}}function ae(){return Object.fromEntries(Vl.map(([e,t,r,a,i],s)=>[dl[s],{required:[...e],dataShape:t,dataAccessors:[...r],props:Object.fromEntries(Object.entries(Object.assign({},...a.map(e=>Gl[e]),i)).map(([e,t])=>[e,re(t)]))}]))}function ie(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function se(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"UnitPileChart"===e)}function oe(e){if(!Array.isArray(e.thresholds))return[];let 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".`);let 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.`);let i=Object.keys(a).filter(e=>"value"!==e&&"color"!==e&&"label"!==e);i.length>0&&t.push(`"thresholds[${r}]" has unsupported GaugeChart key(s): ${i.join(", ")}. Use { value, color, label? }; { at, level } belongs to BigNumber.`)}),t}function ne(e){let t=e.frameProps;if(null==t||"object"!=typeof t||Array.isArray(t))return[];let 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)+"."];let a=[],i=r,s=/* @__PURE__ */new Set(["align",...Object.keys(Yl)]);for(let e of Object.keys(i))s.has(e)||a.push(`Unknown "frameProps.legendLayout" key "${e}". Valid keys: ${[...s].join(", ")}.`);void 0!==i.align&&"string"!=typeof i.align?a.push(`"frameProps.legendLayout.align" should be string, got ${Array.isArray(i.align)?"array":typeof i.align}.`):"string"==typeof i.align&&!Hl.has(i.align)&&a.push(`"frameProps.legendLayout.align" value "${i.align}" is not valid. Expected one of: ${[...Hl].join(", ")}.`);for(let[e,t]of Object.entries(Yl)){let r=i[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 le(e,t){let r=[];(null==t||"object"!=typeof t)&&(t={});let a=ql[e];if(!a)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(ql).join(", ")}`]};for(let i of a.required)null==t[i]&&r.push(`"${i}" is required for ${e}.`);"array"===a.dataShape&&Object.prototype.hasOwnProperty.call(a.props,"data")&&!a.required.includes("data")&&!se(e,t)&&null==t.data&&r.push(`"data" is required for ${e}.`);for(let[e,i]of Object.entries(t)){if(null==i)continue;let t=a.props[e];if(t){if(!ie(i,t.type)){let a=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${a}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&r.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}let i=Object.keys(a.props),s=new Set(i);for(let a of Object.keys(t))if(void 0!==t[a]&&!s.has(a)){let t=Q(a,i),s=t?`Unknown prop "${a}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${a}" for ${e}. Valid props: ${i.join(", ")}.`;r.push(s)}if("array"===a.dataShape){let i=t.data,s={};for(let e of a.dataAccessors){let r=t[e];"string"==typeof r&&(s[e]=r)}let o=J({componentName:e,data:i,accessors:Object.keys(s).length>0?s:void 0});o&&r.push(o)}else if("object"===a.dataShape){let a=ee({componentName:e,data:t.data});a&&r.push(a)}else if("network"===a.dataShape){let i=t.nodeIdAccessor??t.nodeIDAccessor??"id",s="string"==typeof i?{nodeIdAccessor:i}:void 0,o=te({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:a.required.includes("nodes"),edgesRequired:a.required.includes("edges"),accessors:s});o&&r.push(o)}return"GaugeChart"===e&&r.push(...oe(t)),"ScatterplotMatrix"===e&&null!=t.frameProps&&r.push('"frameProps" is not supported for ScatterplotMatrix; configure its matrix props directly.'),r.push(...ne(t)),{valid:0===r.length,errors:r}}function ce(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function de(e,t={}){let r=[],a=e.tokenSemantics,i=e.countStrategy,s=t.maxRecommendedTokens??("fixed-denominator"!==i||ce(e.denominator)>100?80:100);return a||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),i||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>s&&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&&i&&"unitized"!==i&&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&&i&&"fixed-denominator"!==i&&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)&&i&&"quantile"!==i&&"sample"!==i&&"posterior-sample"!==i&&"random-sample"!==i&&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"===i&&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"===i&&!e.unitMeaning&&r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function ue(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:2e4))):1/0}function pe(e){let t=e.provenance,r=e.id??e.stableId??t?.stableId;return null==r||""===r?void 0:r+""}function fe(e,t,r){let a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(let e of a)!e||"object"!=typeof e||"widget"!==C(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 he(e,t,r){let a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(let e of a){if(!e||"object"!=typeof e)continue;let t=C(e);if(!A(e)||"widget"===t)continue;let a=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),i="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,s=$(e);!s&&a>120?r.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${i}" 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).'}):s&&a>250&&r.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${i}" 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 ye(e,t,r){let a=Array.isArray(t.annotations)?t.annotations:null;if(!a)return;let i=a.filter(A).length;if(0===i)return;let s="number"==typeof t.width?t.width:600,o="number"==typeof t.height?t.height:400,n=ue(s,o);!Number.isFinite(n)||n>=i||r.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${i} note annotations on a ${s}×${o} chart exceed the ~${n} 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 me(e,t,r){for(let e of Zl){let a=t[e];if(!Array.isArray(a)||2>a.length)continue;let[i,s]=a;"number"!=typeof i||"number"!=typeof s||i>s&&r.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${i}, ${s}] 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}={[${s}, ${i}]}). 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 ge(e,t,r){if("MultiAxisLineChart"!==e)return;let a=t.series;if(!Array.isArray(a)||2!==a.length)return;let i=a.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);i.length>0&&r.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${i.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 ve(e,t,r){if(!Cl.has(e))return;let a=t.xExtent;if(!Array.isArray(a)||2>a.length)return;let[i,s]=a;if("number"!=typeof i||"number"!=typeof s||i>=s)return;let o=t.data;if(!o||!Array.isArray(o)||4>o.length)return;let n=t.xAccessor??"x";if("string"!=typeof n)return;let l=1/0,c=-1/0;for(let e of o){let t=e?.[n];"number"!=typeof t||!Number.isFinite(t)||(l>t&&(l=t),t>c&&(c=t))}if(!Number.isFinite(l)||!Number.isFinite(c)||l>=c)return;let d=c-l,u=Math.max(0,Math.min(s,c)-Math.max(i,l))/d;.7>u&&r.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${i}, ${s}] shows only ~${Math.round(100*u)}% of the data's x range [${l}, ${c}] — 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 be(e,t,r){let a=Sl[e],i=Pl[e];if(!a&&!i||i&&!t.normalize)return;let s=a??i,o=t[s],n="string"==typeof o?o:"yAccessor"===s?"y":"value",l=t.data;if(!l||!Array.isArray(l)||0===l.length)return;let c=l.filter(e=>{let t=e?.[n];return"number"==typeof t&&0>t});c.length>0&&r.push({severity:a?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${c.length} negative value(s) in "${n}" — 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 ke(e,t,r){wl.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 xe(e,t,r){if("LineChart"!==e&&"AreaChart"!==e||"sparkline"===t.mode||t.responsiveWidth||t.responsiveHeight)return;let a="number"==typeof t.width?t.width:600,i="number"==typeof t.height?t.height:400;if(0>=a||0>=i)return;let s=a/i;if(s>8||.25>s){let e=s>8?"flattens":"exaggerates";r.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${a}×${i} (${s.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:s>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 Ce(e,t,r){if(!$l.has(e))return;let a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;let i=t.categoryAccessor,s="string"==typeof i?i:"category",o=/* @__PURE__ */new Set;for(let e of a){let t=e?.[s];null!=t&&o.add(t)}o.size>8&&r.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:o.size+" slices — angle judgments degrade rapidly past ~8 categories (Cleveland & McGill), and thin slices become unreadable and unlabelable.",fix:`Use a BarChart or DotPlot for ${o.size} categories, or group the long tail into an "Other" slice before charting.`})}function Ae(e,t,r){return"function"==typeof r?r(e,t):e[r]}function we(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function $e(e,t,r){return Math.max(t,Math.min(r,e))}function Se(e,t){let r=we(e);return null!=r&&r>0?r:t}function Be(e){if(!e)return;let t=we(e[0]),r=we(e[1]);return null!=t&&null!=r?t>r?[r,t]:[t,r]:void 0}function Pe(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 We(e={}){let 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))),i=Se(e.unitValue,1),s=Pe(e.seed??1),o=e.idPrefix??"mechanical-pile",n=r.map(()=>.65+.9*s()),l=n.reduce((e,t)=>e+t,0)||1,c=a-r.length,d=n.map(e=>e/l*c),u=d.map(e=>1+Math.floor(e)),p=a-u.reduce((e,t)=>e+t,0),f=d.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;p>0;e=(e+1)%f.length)u[f[e].index]+=1,p-=1;return r.map((e,t)=>({id:`${o}-${t}`,category:e,value:u[t]*i,mechanical:!0,unitCount:u[t],unitValue:i,share:u[t]/a}))}function Le(e,t){let r=e/t,a=Math.round(r);return Math.ceil(a>0&&Number.EPSILON*r*4>=Math.abs(r-a)?a:r)}function Me(e,t,r=0){let a=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),i=/* @__PURE__ */new Map;for(let s of e){let e=null==s.id?`${t}-${r++}`:s.id+"";for(;null==s.id&&a.has(e);)e=`${t}-${r++}`;a.add(e),i.set(e,null==s.id?{...s,id:e}:s)}return{seed:e,rows:Array.from(i.values()),nextId:r}}function Re(e){let t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function Ie(e,t,r){return"function"==typeof t?t(e):e?.["string"==typeof t?t:r]}function Ee(e,t,r){if(El.has(e)){if("GaltonBoardChart"===e){let 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."});let a=Re(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."});let i=Re(t.mechanicalCount);null!=t.mechanicalCount&&(null==i||0>=i)&&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){let e=t.windows,a=e&&"object"==typeof e?Re(e.size):null;null!=a&&0>=a&&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&&0>=t.timeScale&&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."});let i=Array.isArray(t.data)?t.data:[];if(i.length>0){let e=t.timeAccessor||"time",a=t.arrivalAccessor||"arrivalTime";i.some(t=>{let r=Re(Ie(t,e,"time")),i=Re(Ie(t,a,"arrivalTime"));return null!=r&&null!=i&&r!==i})||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){let e="mechanical"===(t.simulationMode??t.mode),a=Re(t.mechanicalCount);null!=t.mechanicalCount&&(null==a||0>=a)&&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."});let i=we(t.unitValue??1);if(null==i||0>=i)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."});let s=e?We({count:a??void 0,categories:Array.isArray(t.mechanicalCategories)?t.mechanicalCategories:void 0,seed:we(t.seed)??1,unitValue:i}):Array.isArray(t.data)?t.data:[],{rows:o}=Me(s,"pile"),n=t.valueAccessor??(e?"value":void 0),l=o.reduce((e,t,r)=>{let a="function"==typeof n?n(t,r):"string"==typeof n&&n?t[n]:1;return e+Le(Math.max(0,we(a)??0),i)},0);l>1500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`UnitPileChart would create about ${l} 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(0>=(Re(t.pointRadius??5)??5)&&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."}),0>=(Re(t.collisionIterations??6)??6)&&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){let e=Array.isArray(t.xExtent)?t.xExtent:[],a=Re(e[0]),i=Re(e[1]);(2>e.length||null==a||null==i)&&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."})}let 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."});let a=t.groupAccessor;if(e.length>0&&a){let t=/* @__PURE__ */new Set;for(let r of e){let e=Ie(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){let 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 } }.'});let 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){let e=Array.isArray(t.phases)?t.phases:[],a=Array.isArray(t.products)?t.products:[],i=Array.isArray(t.events)?t.events:[],s=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==Re(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===i.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."});let o=new Set(a.map(e=>e?.id).filter(e=>null!=e).map(String)),n=/* @__PURE__ */new Set(["product","retained","residue","failed","recovered",...s.map(e=>e?.id).filter(e=>null!=e).map(String)]),l=/* @__PURE__ */new Set,c=/* @__PURE__ */new Set;for(let e of i)if(e&&Array.isArray(e.effects))for(let t of e.effects){if(!t||"object"!=typeof t)continue;let e=t.type;if(("combine"===e||"contribute"===e||"complete-product"===e)&&null!=t.productId&&!o.has(t.productId+"")&&l.add(t.productId+""),"split"===e&&Array.isArray(t.products))for(let e of t.products)null!=e?.productId&&!o.has(e.productId+"")&&l.add(e.productId+"");null!=t.outletId&&!n.has(t.outletId+"")&&c.add(t.outletId+"")}l.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_PRODUCT",message:`CrucibleChart events reference undeclared product molds: ${[...l].sort().join(", ")}.`,fix:"Declare every referenced product id in products; do not create product definitions implicitly inside events."}),c.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_OUTLET",message:`CrucibleChart events reference undeclared outlets: ${[...c].sort().join(", ")}.`,fix:"Declare every domain outlet in outlets and reuse its stable id in authored effects."});let d=Re(t.playbackRate);null!=t.playbackRate&&(null==d||0>=d)&&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."});let u=Re(t.rerunMS);null!=t.rerunMS&&(null==u||0>u)&&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){let a=Array.isArray(t.data)?t.data:[],i=Re(t.mechanicalCount)??0,s=a.length>0?a.length:i;s>2500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(s)} 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 Ne(e){let 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."});let a=e.edges;if(Array.isArray(a)&&a.length>0){let 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."})}let i=e.nodes,s=Array.isArray(i)?i.length:0;return!0===e.showLabels&&s>=24&&t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${s} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),(Array.isArray(a)?a.length:0)>=80&&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 Te(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let r=Kl.test(t)?t+"-01":t;if(r===t&&10>t.length)return NaN;let a=Date.parse(r);return Number.isFinite(a)?a:NaN}function Fe(e,t){if(!e||!t)return{data:e,failed:!1};let r=!1,a=!1,i=e.map(e=>{let i=e[t];if("string"!=typeof i)return e;let s=Te(i);return r=!0,Number.isFinite(s)?{...e,[t]:s}:(a=!0,{...e,[t]:NaN})});return{data:r?i:e,failed:a}}function Oe(e,t){let r=e.nestedDataAccessorProp?t[e.nestedDataAccessorProp]:void 0;return"string"==typeof r?r:e.defaultNestedDataAccessor}function je(e,t,r){let a=e.dataProp??"data",i=t[a],s=r??(Array.isArray(i)?i:[]),o=Oe(e,t);if(!o)return{dataProp:a,rows:s};let n=[],l=!1;for(let e of s){let t=e?.[o];if(Array.isArray(t)){l=!0;for(let e of t)e&&"object"==typeof e&&n.push(e)}}return{dataProp:a,rows:l?n:s}}function De(e,t,r){let a=/* @__PURE__ */new Set;for(let i of e.fields){let e=i.dataProp??"data",s=r??t[e];if(!Array.isArray(s))continue;if(0===s.length){a.add(e);continue}let o=Oe(i,t);if(!o)continue;let n=s.map(e=>e?.[o]).filter(Array.isArray);n.length>0&&n.every(e=>0===e.length)&&a.add(`${e}.${o}`)}return[...a]}function _e(){let e=globalThis;return e[pc]??(e[pc]={contracts:/* @__PURE__ */new Map}),e[pc]}function ze(e){return _e().contracts.get(e)??uc[e]}function Ue(e,t){if(0===e.length)return;let r=(e.length-1)*t,a=Math.floor(r),i=Math.ceil(r);if(a===i)return e[a];let s=r-a;return e[a]*(1-s)+e[i]*s}function Ge(e){let t=[];for(let[r,a]of Object.entries(fc))"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 Ve(e,t,r){return"function"==typeof e?e(t,r):t[e]}function qe(e,t){if("number"==typeof e)return Number.isFinite(e)?e:null;if(e instanceof Date){let r=e.getTime();return t&&Number.isFinite(r)?r:null}if("string"==typeof e){let r=e.trim(),a=Number(r);if(r&&Number.isFinite(a))return a;if("date-like"===t){let e=Te(r);return Number.isFinite(e)?e:null}}return null}function He(e){return"number"==typeof e&&!Number.isFinite(e)}function Ye(e,t,r,a,i){let s={field:r,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let r=0;e.length>r;r++){let o;try{o=Ve(t,e[r],r)}catch{s.accessorErrorRows.push(r);continue}if(null==o||""===o){if(void 0!==i){s.numbers.push(i),s.finiteRows.push(r),0===i&&s.zeroRows.push(r),0>i&&s.negativeRows.push(r),Number.isInteger(i)||s.fractionalRows.push(r);continue}s.missingRows.push(r);continue}let n=qe(o,a);null!=n?(s.numbers.push(n),s.finiteRows.push(r),0===n&&s.zeroRows.push(r),0>n&&s.negativeRows.push(r),Number.isInteger(n)||s.fractionalRows.push(r)):He(o)?s.nonFiniteRows.push(r):s.nonNumericRows.push(r)}return s}function Qe(e,t){let 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 Ze(e){let t=1/0,r=-1/0;for(let a of e)t>a&&(t=a),a>r&&(r=a);return[t,r]}function Ke(e,t,r){let a=[],i=/* @__PURE__ */new Set;for(let s of e.fields){if(s.whenProps?.some(e=>null==t[e]))continue;let e=t[s.accessor],o="string"==typeof e||"function"==typeof e?e:s.defaultAccessor;if("string"!=typeof o&&"function"!=typeof o)continue;let{dataProp:n,rows:l}=je(s,t,r);if(0===l.length)continue;let c="string"==typeof o?o:s.accessor+"()",d=`${n}:${s.role}:${c}`;if(i.has(d))continue;i.add(d);let u=s.temporalValues??("time"===s.role||"x"===s.role&&"time"===t.xScaleType?"date-like":void 0),p="x"===s.role&&"log"===t.xScaleType||"y"===s.role&&"log"===t.yScaleType,f=Qe(s,t);a.push({contract:s,accessor:o,accessorLabel:c,dataProp:n,rows:l,requirements:f,logScale:p,observation:Ye(l,o,c,u,s.missingValue)})}return a}function Xe(e){return e.slice(0,5)}function Je(e){return{domain:"data",...e}}function et(e){let 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[];let r=t.map(e=>e.value),a=Ue(r,.25),i=Ue(r,.75),s=Ue(r,.5),o=i-a;if(o>0){let e=a-10*o,r=i+10*o;return t.filter(t=>e>t.value||t.value>r).map(e=>e.row)}let n=100*Math.max(1,Math.abs(s));return t.filter(e=>Math.abs(e.value-s)>n).map(e=>e.row)}function tt(e,t){let r=[],{observation:a,contract:i,accessorLabel:s,requirements:o}=e,n={field:s,role:i.role},l=[...a.nonFiniteRows,...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(0===a.numbers.length)return r.push(Je({severity:"error",code:"DEGENERATE_EXTENT",message:`${i.accessor}="${s}" produces no finite numeric values; the chart cannot resolve its ${i.role} input.`,fix:`Ensure ${s} contains finite numbers${"x"===i.role?" (or valid dates for a time scale)":""}.`,...n,...l.length>0?{rows:Xe(l),count:l.length}:{}})),r;a.nonFiniteRows.length>0&&r.push(Je({severity:"error",code:"NON_FINITE_VALUE",message:`${s} 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 ${s} before rendering.`,...n,rows:Xe(a.nonFiniteRows),count:a.nonFiniteRows.length})),!i.allowMissing&&a.missingRows.length>0&&r.push(Je({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${s} is missing for ${a.missingRows.length} row${1===a.missingRows.length?"":"s"}; the ${i.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${s} values before rendering.`,...n,rows:Xe(a.missingRows),count:a.missingRows.length}));let c=[...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(c.length>0&&r.push(Je({severity:"error",code:"NON_NUMERIC_VALUE",message:`${s} produces ${c.length} non-numeric value${1===c.length?"":"s"} for the ${i.role} role.`,fix:`Bind ${i.accessor} to a numeric field or return finite numbers from the accessor.`,...n,rows:Xe(c),count:c.length})),i.domain&&a.numbers.length>=2){let[e,t]=Ze(a.numbers);e===t&&r.push(Je({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${s} is constant at ${e}; its ${i.role} scale has a zero-span data domain.`,fix:`Provide varying ${i.role} values, set an explicit extent around ${e}, or use a single-value display.`,...n,rows:Xe(a.finiteRows),count:a.finiteRows.length}))}if(o.includes("positive")){let 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){let a=e.logScale;r.push(Je({severity:"error",code:a?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${s} 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.",...n,rows:Xe(t),count:t.length}))}}if(o.includes("non-negative")&&a.negativeRows.length>0&&r.push(Je({severity:"error",code:"size"===i.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${s} contains ${a.negativeRows.length} negative ${i.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.",...n,rows:Xe(a.negativeRows),count:a.negativeRows.length})),o.includes("integer")){let e=[.../* @__PURE__ */new Set([...a.negativeRows,...a.zeroRows,...a.fractionalRows])].sort((e,t)=>e-t);e.length>0&&r.push(Je({severity:"error",code:"INVALID_COUNT",message:`${s} 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.",...n,rows:Xe(e),count:e.length}))}if(o.includes("unit-interval")){let 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(Je({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${s} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${s} to [0, 1] before using it as ${i.role}.`,...n,rows:Xe(e),count:e.length}))}if(t&&i.domain){let t=et(e);t.length>0&&r.push(Je({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${s} 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.",...n,rows:Xe(t),count:t.length}))}return r}function rt(e,t,r){if(!e)return"__all__";try{return Ve(e,t,r)+""}catch{return"__accessor_error__"}}function at(e,t,r){if(e.whenProp&&!0!==r[e.whenProp])return[];let a=t.find(t=>t.contract.role===e.role);if(!a||0===a.observation.numbers.length)return[];let i=e.groupAccessor?r[e.groupAccessor]:void 0,s="string"==typeof i||"function"==typeof i?i:e.defaultGroupAccessor,o=/* @__PURE__ */new Map;for(let e=0;a.rows.length>e;e++){let t;try{t=Ve(a.accessor,a.rows[e],e)}catch{continue}let r=qe(t,void 0);if(null==r)continue;let i=rt(s,a.rows[e],e),n=o.get(i)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};n.sum+=r,n.magnitude+=Math.abs(r),n.positive||(n.positive=r>0),n.negative||(n.negative=0>r),n.rows.push(e),0>r&&n.negativeRows.push(e),o.set(i,n)}let n=[],l=[],c=[],d=[],u=[],p=[];for(let[t,r]of o)("positive-total"===e.kind&&0>=r.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,r.magnitude)*10>=Math.abs(r.sum))&&(n.push(t),d.push(...r.rows)),"normalized-total"===e.kind&&r.positive&&r.negative&&(l.push(t),u.push(...r.rows)),"normalized-total"===e.kind&&r.negative&&(c.push(t),p.push(...r.negativeRows));let f=[];return n.length>0&&f.push(Je({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${n.length} normalization group${1===n.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:Xe([...new Set(d)].sort((e,t)=>e-t)),count:n.length})),c.length>0&&f.push(Je({severity:"error",code:"NEGATIVE_NORMALIZED_VALUE",message:`${c.length} normalization group${1===c.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:Xe([...new Set(p)].sort((e,t)=>e-t)),count:p.length})),l.length>0&&f.push(Je({severity:"warning",code:"MIXED_SIGN_NORMALIZATION",message:`${l.length} normalization group${1===l.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:Xe([...new Set(u)].sort((e,t)=>e-t)),count:l.length})),f}function it(e,t,r,a={}){let i=a.contracts??ze(e)??Ge(t);if(!i)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:[]};let s=Ke(i,t,r),o=[],n=!1!==a.checkOutliers;for(let e of De(i,t,r))o.push(Je({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:[]}));let l=new Set(s.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(let e of l)o.push(Je({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(let e of s)o.push(...tt(e,n));for(let e of i.aggregates??[])o.push(...at(e,s,t));let c=o.filter(e=>"error"===e.severity).length,d=o.length-c;return{component:e,ok:0===c,rowCount:s.reduce((e,t)=>Math.max(e,t.rows.length),r?.length??(Array.isArray(t.data)?t.data.length:0)),summary:{fieldsChecked:s.length,errors:c,warnings:d},contracts:s.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:o}}function st(e,t,r){let a=ql[e];if(a){if("array"===a.dataShape){let 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 ot(e,t){for(let[r,a]of[["width",600],["height",400]]){let i=e[r];void 0!==i&&("number"!=typeof i||0>=i)&&t.push({severity:"error",code:"width"===r?"BAD_WIDTH":"BAD_HEIGHT",message:`${r}=${JSON.stringify(i)} — chart needs a positive number.`,fix:`Set ${r}={${a}}.`})}if(e.size&&Array.isArray(e.size)){let[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 nt(e,t,r){let a=ql[e];if(!a||"array"!==a.dataShape)return;let i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;let s=i[0];if(!s||"object"!=typeof s)return;let o=Object.keys(s);for(let e of a.dataAccessors){let a=t[e];"string"==typeof a&&(a in s||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${a}" not found in data. Available fields: ${o.join(", ")}.`,fix:`Change ${e} to one of: ${o.map(e=>`"${e}"`).join(", ")}, or use a function: ${e}={d => d.myValue}.`}))}}function lt(e,t,r){bl.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 ct(e,t,r){kl.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 dt(e,t,r){let a=ql[e];if(!a||"array"!==a.dataShape)return;let i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;let s=i[0];if(!s||"object"!=typeof s)return;let o=t.xAccessor;"string"==typeof o&&s[o]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${o}" 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 ut(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 pt(e,t,r){if(!Cl.has(e)||t.gapStrategy)return;let a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;let i=t.yAccessor||"y";"string"==typeof i&&a.some(e=>{let t=e[i];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${i}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}function ft(e,t,r){if(!xl.has(e))return;let 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 ht(e,t,r){if(!Al.has(e))return;let 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 yt(e,t,r){if("Heatmap"!==e)return;let a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;let i=a[0];if(i&&"object"==typeof i)for(let e of["xAccessor","yAccessor"]){let a=t[e];if("string"!=typeof a)continue;let s=i[a];"string"==typeof s&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${a}" resolves to string values (e.g. "${s}"). 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 mt(e,t,r){let a=t.colorScheme;if(!a||!Array.isArray(a))return;let i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;let s=[];for(let e of a){if("string"!=typeof e||!e.startsWith("#"))continue;let t=x(e,i);null!==t&&3>t&&s.push(`${e} (${t.toFixed(1)}:1)`)}s.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${s.length} color(s) in colorScheme have < 3:1 contrast against background "${i}": ${s.join(", ")}. Data marks may be hard to see.`,fix:"Choose colors with at least 3:1 contrast against the chart background."})}function gt(e,t){let r=e.width??600,a=e.height??400,i=e.margin;if(!i||"object"!=typeof i)return;let s=(i.left||0)+(i.right||0),o=(i.top||0)+(i.bottom||0);s>=r&&t.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${s}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),o>=a&&t.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${o}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}function vt(e,t,r){let a=ql[e]?.props,i=e=>!!a?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,s=i("title"),o=i("description"),n=i("summary");!s&&!o&&!n&&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){let a=t.colorScheme;"string"!=typeof a||ql[e]?.props?.colorScheme?.enum||hc.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 (${[...hc].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}function kt(e,t,r){let a=t.colorScheme;if(!a||!Array.isArray(a)||2>a.length)return;let i=a.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>i.length)return;let s=[];for(let e=0;i.length-1>e;e++){let t=x(i[e],i[e+1]);null!==t&&1.5>t&&s.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}s.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${s.length} adjacent color pair(s) in colorScheme have very similar luminance: ${s.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 xt(e,t,r){let a=[];for(let e of yc)"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 Ct(e,t,r){let 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 At(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 wt(e,t,r){if(!0!==t.showParticles)return;let a=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},i="number"==typeof a.maxPerLine?a.maxPerLine:void 0,s="number"==typeof a.spawnRate?a.spawnRate:void 0;("number"==typeof i&&i>20||"number"==typeof s&&s>.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 $t(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function St(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function Bt(e,t){let r=St(e.visibleTokens);if(null!=r)return r;let a=St(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=a)return a;let i=St(t.tokenCount),s=St(t.maxTokens);return null!=i&&null!=s?Math.min(i,s):i??a??s}function Pt(e,t,r){let a=[];$t(t.tokenEncoding)&&a.push({source:"tokenEncoding",encoding:t.tokenEncoding}),$t(t.encoding)&&a.push({source:"encoding",encoding:t.encoding});for(let{source:e,encoding:i}of a){let a=Bt(t,i);for(let t of de(i,{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 Wt(e){let t={...e};return delete t.tokenEncoding,delete t.visibleTokens,$t(t.encoding)&&delete t.encoding,t}function Lt(e,t){let r=t.match(/^Unknown prop "([^"]+)"/);if(r)return`Remove \`${r[1]}\` or replace it with a documented ${e} prop.`;let 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 Mt(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 Rt(e,t){let r=[],a=()=>({ok:r.every(e=>"warning"===e.severity),diagnoses:r}),i=/^(XY|Ordinal|Network|Physics|Geo)CustomChart$/.test(e),s=i?[]:le(e,Wt(t)).errors;if(i){"function"!=typeof t.layout&&s.push("Provide a layout function.");let r="NetworkCustomChart"===e?["nodes","edges"]:"GeoCustomChart"===e?["points","areas","lines"]:["data"];for(let e of r)null!=t[e]&&!Array.isArray(t[e])&&s.push(`Provide an array for ${e}.`)}for(let a of s)"BigNumber"===e&&void 0!==t.accessibleTable&&a.startsWith('Unknown prop "accessibleTable"')||r.push({severity:"error",code:"VALIDATION",message:a,fix:i?a:Lt(e,a)});if("BigNumber"===e&&Mt(t,r),(i||ql[e])&&(ot(t,r),gt(t,r),fe(0,t,r)),!ql[e])return a();st(e,t,r),nt(e,t,r),lt(e,t,r),ct(e,t,r),dt(e,t,r),ut(0,t,r),ft(e,t,r),pt(e,t,r);let o=it(e,t,void 0,{checkOutliers:!1}).diagnoses;for(let e of o)"EMPTY_DATA"===e.code&&r.some(e=>"EMPTY_DATA"===e.code||"EMPTY_EDGES"===e.code)||r.push(e);if(ht(e,t,r),yt(e,t,r),mt(0,t,r),kt(0,t,r),bt(e,t,r),vt(e,t,r),xt(0,t,r),Ct(0,t,r),At(0,t,r),wt(0,t,r),Pt(0,t,r),he(0,t,r),ye(0,t,r),me(0,t,r),ge(e,t,r),ve(e,t,r),r.some(e=>"NEGATIVE_VALUE"===e.code||"NEGATIVE_NORMALIZED_VALUE"===e.code)||be(e,t,r),ke(e,t,r),xe(e,t,r),Ce(e,t,r),Ee(e,t,r),"ProcessSankey"===e)for(let e of Ne(t))r.push(e);return a()}function It(e,t){return mc.has(e)&&!("reading"===e&&"string"==typeof t)}function Et(e){return"string"==typeof e?e:e.id??e.name}function Nt(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function Tt(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 Ft(e,t,r){return r??N(t.recipe)??N(t.recipeId)??I(e)}function Ot(e,t,r=[]){let a=e.accessor?t[e.accessor]:void 0;if("string"==typeof a&&a)return a;if(e.field)return e.field;let i=r.find(e=>e&&"object"==typeof e);if(!i)return;let s=Object.entries(i).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?s.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in i):s.find(([,e])=>"string"==typeof e)?.[0]}function jt(e,t){return e.dataRoles.find(e=>e.role===t)}function Dt(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function _t(e,t,r,a,i,s={}){let o={...s};if(t)for(let[e,r]of Object.entries(t))o[e]=r;for(let e of r.dataRoles){let r=Ot(e,a,i),s=t&&r?t[r]:r;void 0!==s&&(o[e.role]=s)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{let r=o[t];return null==r?`{${t}}`:r+""})}function zt(e){let t=[...bc],r=Array.from((new TextEncoder).encode(e)),a=8*r.length;for(r.push(128);r.length%64!=56;)r.push(0);let i=Math.floor(a/4294967296),s=a>>>0;r.push(i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s);let o=[];for(let e=0;r.length>e;e+=4)o.push((r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0);for(let e=0;o.length>e;e+=16){let r=[...o.slice(e,e+16)];for(let e=16;64>e;e+=1){let t=gc(r[e-15],7)^gc(r[e-15],18)^r[e-15]>>>3,a=gc(r[e-2],17)^gc(r[e-2],19)^r[e-2]>>>10;r[e]=r[e-16]+t+r[e-7]+a>>>0}let[a,i,s,n,l,c,d,u]=t;for(let e=0;64>e;e+=1){let t=u+(gc(l,6)^gc(l,11)^gc(l,25))+(l&c^~l&d)+kc[e]+r[e]>>>0,o=a&i^a&s^i&s;u=d,d=c,c=l,l=n+t>>>0,n=s,s=i,i=a,a=t+((gc(a,2)^gc(a,13)^gc(a,22))+o>>>0)>>>0}let p=[a,i,s,n,l,c,d,u];for(let e=0;8>e;e+=1)t[e]=t[e]+p[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function Ut(e,t){return`${e}[Symbol(${t.description??""})]`}function Gt(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function Vt(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function qt(e){return e.sort((e,t)=>{let r=JSON.stringify(e),a=JSON.stringify(t);return a>r?-1:r>a?1:0})}function Ht(e,t,r){if(null===e)return null;if(e instanceof Date){let 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":{let a=e;if(r.ancestors.has(a))return void r.excluded.push(t);r.ancestors.add(a);try{if(Array.isArray(e)){for(let a of Reflect.ownKeys(e))"length"===a||"string"==typeof a&&Gt(a,e.length)||r.excluded.push("symbol"==typeof a?Ut(t,a):Vt(t,a));return Array.from({length:e.length},(a,i)=>{let s=Vt(t,i),o=Object.getOwnPropertyDescriptor(e,i+"");if(!o||!("value"in o)||!o.enumerable)return r.excluded.push(s),null;let n=Ht(o.value,s,r);return void 0===n?null:n})}let a={},i=Object.getPrototypeOf(e);if(i!==Object.prototype&&null!==i)return void r.excluded.push(t);let s=[];for(let a of Reflect.ownKeys(e)){if("symbol"==typeof a){r.excluded.push(Ut(t,a));continue}let i=Object.getOwnPropertyDescriptor(e,a);i&&"value"in i&&i.enumerable?s.push(a):r.excluded.push(Vt(t,a))}for(let i of s.sort()){let s=Object.getOwnPropertyDescriptor(e,i),o=Ht(s&&"value"in s?s.value:void 0,Vt(t,i),r);void 0!==o&&Object.defineProperty(a,i,{value:o,enumerable:!0,configurable:!0,writable:!0})}return a}finally{r.ancestors.delete(a)}}default:return void r.excluded.push(t)}}function Yt(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{let r=r=>{let a="symbol"==typeof r?["symbol-key",r.description??""]:["string-key",r],i=Object.getOwnPropertyDescriptor(e,r);return i?"value"in i?[a,"data",!!i.enumerable,Yt(i.value,t)]:[a,"accessor",!!i.enumerable,!!i.get,!!i.set]:[a,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,a)=>{let i=a+"";return Object.prototype.hasOwnProperty.call(e,i)?r(i):["hole"]}),qt(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&Gt(t,e.length))).map(r))];let a=Object.getPrototypeOf(e);return[a!==Object.prototype&&null!==a?"non-json-object":"object",qt(Reflect.ownKeys(e).map(r))]}finally{t.delete(e)}default:return["excluded"]}}function Qt(e){let t={excluded:[],ancestors:/* @__PURE__ */new Set},r=Ht(e,"$",t)??null;return{value:r,text:JSON.stringify(r),excludedPaths:t.excluded}}function Zt(e){let t=Qt(e),r=zt(JSON.stringify(["semiotic-value-fingerprint","v2",Yt(e)]));return{...t,algorithm:"sha256",digest:r,fingerprint:"sha256:"+r}}function Kt(e,t,r,a){ir(e,Object.keys(t),r,a);for(let[i,s]of Object.entries(t))s.values?(s.required||void 0!==e[i])&&or(e,i,r,s.values,a):s.required?sr(e,i,r,a):ur(e,i,r,a)}function Xt(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Jt(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 er(e,t,r,a){void 0!==e[t]&&"boolean"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a boolean."})}function tr(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(tr):Xt(e)&&Object.values(e).every(tr))}function rr(e,t,r,a){void 0!==e[t]&&(!Xt(e[t])||!tr(e[t]))&&a.push({path:`${r}.${t}`,message:"Expected a JSON object."})}function ar(e){return e.every(tr)}function ir(e,t,r,a){let i=new Set(t);for(let t of Object.keys(e))i.has(t)||a.push({path:`${r}.${t}`,message:"Unexpected property."})}function sr(e,t,r,a){("string"!=typeof e[t]||!e[t])&&a.push({path:`${r}.${t}`,message:"Expected a non-empty string."})}function or(e,t,r,a,i){("string"!=typeof e[t]||!a.includes(e[t]))&&i.push({path:`${r}.${t}`,message:`Expected one of: ${a.join(", ")}.`})}function nr(e,t,r,a){let i=e[t];if(void 0!==i)return Xt(i)?i:void a.push({path:`${r}.${t}`,message:"Expected an object."})}function lr(e,t,r,a){let i=e[t];if(void 0!==i)return Array.isArray(i)?i:void a.push({path:`${r}.${t}`,message:"Expected an array."})}function cr(e,t,r){e?.some(e=>"string"!=typeof e||!e)&&r.push({path:t,message:"Expected non-empty string values."})}function dr(e,t,r,a,i){void 0!==e[t]&&or(e,t,r,a,i)}function ur(e,t,r,a){void 0!==e[t]&&"string"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a string."})}function pr(e,t,r){Xt(e)?(ir(e,["id","name","kind"],t,r),sr(e,"kind",t,r),ur(e,"id",t,r),ur(e,"name",t,r)):r.push({path:t,message:"Expected an actor object."})}function fr(e,t){let r=nr(e,"reception","$",t);if(!r)return;ir(r,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);let a=lr(r,"channels","$.reception",t);a||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),a?.forEach((e,r)=>{let a=`$.reception.channels[${r}]`;Xt(e)?(ir(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],a,t),or(e,"channel",a,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),dr(e,"disclosure",a,["summary","standard","detailed"],t),dr(e,"rawData",a,["deny","bounded","allow"],t),er(e,"navigation",a,t),er(e,"interactionInstructions",a,t),Jt(e,"tokenBudget",a,t),cr(lr(e,"privacyNotes",a,t),a+".privacyNotes",t)):t.push({path:a,message:"Expected a channel object."})});for(let e of["strengths","risks","scaffolds","manualChecks"])cr(lr(r,e,"$.reception",t),"$.reception."+e,t);ur(r,"audience","$.reception",t),ur(r,"description","$.reception",t),er(r,"dataFallback","$.reception",t)}function hr(e,t){let r=nr(e,"form","$",t);r&&(ir(r,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),ur(r,"chartFamily","$.form",t),ur(r,"whyThisForm","$.form",t),cr(lr(r,"risks","$.form",t),"$.form.risks",t),cr(lr(r,"misuse","$.form",t),"$.form.misuse",t),lr(r,"rejectedAlternatives","$.form",t)?.forEach((e,r)=>{let a=`$.form.rejectedAlternatives[${r}]`;Xt(e)?(ir(e,["representation","reason"],a,t),sr(e,"representation",a,t),sr(e,"reason",a,t)):t.push({path:a,message:"Expected an alternative object."})}))}function yr(e,t){let r=nr(e,"contestability","$",t);r&&(ir(r,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),er(r,"sourceRequestsAllowed","$.contestability",t),lr(r,"challenges","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.challenges[${r}]`;if(Xt(e)){ir(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],a,t),sr(e,"id",a,t),sr(e,"claimId",a,t),sr(e,"reason",a,t),or(e,"status",a,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&pr(e.raisedBy,a+".raisedBy",t);for(let r of["raisedAt","counterclaimId","resolution"])ur(e,r,a,t)}else t.push({path:a,message:"Expected a challenge object."})}),lr(r,"corrections","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.corrections[${r}]`;if(!Xt(e))return void t.push({path:a,message:"Expected a correction object."});ir(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],a,t),sr(e,"id",a,t),sr(e,"reason",a,t);let i=lr(e,"affectedClaimIds",a,t);i||t.push({path:a+".affectedClaimIds",message:"Expected an affected-claim array."}),cr(i,a+".affectedClaimIds",t),cr(lr(e,"replacementClaimIds",a,t),a+".replacementClaimIds",t),ur(e,"createdAt",a,t),void 0!==e.createdBy&&pr(e.createdBy,a+".createdBy",t)}),lr(r,"alternativeViews","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.alternativeViews[${r}]`;Xt(e)?(ir(e,["id","label","rationale"],a,t),sr(e,"id",a,t),sr(e,"label",a,t),ur(e,"rationale",a,t)):t.push({path:a,message:"Expected an alternative-view object."})}),lr(r,"editorialExceptions","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.editorialExceptions[${r}]`;Xt(e)?(ir(e,["ruleId","rationale","owner","reviewAt"],a,t),sr(e,"ruleId",a,t),sr(e,"rationale",a,t),ur(e,"owner",a,t),ur(e,"reviewAt",a,t)):t.push({path:a,message:"Expected an editorial-exception object."})}))}function mr(e,t){let r=nr(e,"accountability","$",t);r&&(ir(r,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),lr(r,"authors","$.accountability",t)?.forEach((e,r)=>pr(e,`$.accountability.authors[${r}]`,t)),cr(lr(r,"dataSources","$.accountability",t),"$.accountability.dataSources",t),ur(r,"generatedBy","$.accountability",t),ur(r,"codeRef","$.accountability",t),lr(r,"reviews","$.accountability",t)?.forEach((e,r)=>{let a=`$.accountability.reviews[${r}]`;if(Xt(e)){ir(e,["id","status","reviewer","reviewedAt","rationale","policyId"],a,t),sr(e,"id",a,t),or(e,"status",a,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&pr(e.reviewer,a+".reviewer",t);for(let r of["reviewedAt","rationale","policyId"])ur(e,r,a,t)}else t.push({path:a,message:"Expected a review object."})}),lr(r,"actions","$.accountability",t)?.forEach((e,r)=>{let a=`$.accountability.actions[${r}]`;if(!Xt(e))return void t.push({path:a,message:"Expected an action object."});ir(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],a,t),sr(e,"id",a,t),sr(e,"action",a,t);let i=lr(e,"claimIds",a,t);i||t.push({path:a+".claimIds",message:"Expected a claim identifier array."}),cr(i,a+".claimIds",t),void 0!==e.actor&&pr(e.actor,a+".actor",t);for(let r of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])ur(e,r,a,t);dr(e,"status",a,["proposed","taken","reversed","invalidated"],t)}))}function gr(e,t){let r=nr(e,"inheritance","$",t);if(r){ir(r,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(let e of["requiredPaths","prohibitedExports","sourceArtifactIds"])cr(lr(r,e,"$.inheritance",t),"$.inheritance."+e,t);dr(r,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),dr(r,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),dr(r,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function vr(e,t){fr(e,t),hr(e,t),yr(e,t),mr(e,t),gr(e,t)}function br(e){for(let t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function kr(e,t){if(void 0===e||Xt(e)){if(Xt(e))for(let[r,a]of Object.entries(e)){let e="$.fieldStatus."+r;if(!Xt(a)||"string"!=typeof a.status){t.push({path:e,message:"Expected a field state with a status."});continue}ir(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."}),ur(a,"reason",e,t),ur(a,"reviewedBy",e,t),er(a,"derived",e,t);let i=Object.prototype.hasOwnProperty.call(xc,r)?xc[r]:void 0,s="model-proposal"===a.suppliedBy,o=s&&!0===i?.modelMayPropose&&"known"!==a.status;i&&"known"===a.status&&"string"!=typeof a.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${r}" must identify an allowed supplier.`}),i&&"string"==typeof a.suppliedBy&&!o&&!i.suppliedBy.includes(a.suppliedBy)&&t.push({path:e+".suppliedBy",message:`Field "${r}" cannot be supplied by ${a.suppliedBy}.`}),i&&!0===a.derived&&!i.derivable&&t.push({path:e+".derived",message:`Field "${r}" cannot be marked as derived.`}),i&&s&&(!i.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"===i?.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 xr(e,t){let r="$.time";ir(e,[...wc,...Object.keys($c),"sources"],r,t);for(let a of wc)ur(e,a,r,t);for(let[a,i]of Object.entries($c)){let s=nr(e,a,r,t);s&&Kt(s,i,`${r}.${a}`,t)}lr(e,"sources",r,t)?.forEach((e,a)=>{let i=`${r}.sources[${a}]`;Xt(e)?Kt(e,Sc,i,t):t.push({path:i,message:"Expected a source object."})})}function Cr(e){try{return Ar(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function Ar(e){let t=[],r=[];if(!Xt(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:r};let a=M(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(ir(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),"0.1"!==e.contractVersion&&t.push({path:"$.contractVersion",message:"Expected contract version 0.1."}),Xt(e.artifact)){ir(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),sr(e.artifact,"id","$.artifact",t),or(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(let r of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])ur(e.artifact,r,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(Xt(e.purpose))if(Array.isArray(e.purpose.intents)){ir(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,r)=>{(!Xt(e)||"string"!=typeof e.id||!e.id)&&t.push({path:`$.purpose.intents[${r}].id`,message:"Expected a non-empty intent identifier."}),Xt(e)&&ir(e,["id","strength","source","rationale"],`$.purpose.intents[${r}]`,t),Xt(e)&&void 0!==e.strength&&or(e,"strength",`$.purpose.intents[${r}]`,["primary","secondary"],t),Xt(e)&&(dr(e,"source",`$.purpose.intents[${r}]`,["author","derived","model-proposal","import"],t),ur(e,"rationale",`$.purpose.intents[${r}]`,t))});for(let r of["allowedUses","prohibitedUses"])cr(lr(e.purpose,r,"$.purpose",t),"$.purpose."+r,t);dr(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),ur(e.purpose,"communicativeAct","$.purpose",t),ur(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(!Xt(e))return void t.push({path:`$.claims[${r}]`,message:"Expected a claim object."});ir(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${r}]`,t),sr(e,"id",`$.claims[${r}]`,t),or(e,"kind",`$.claims[${r}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),or(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."}),cr(lr(e,"supersedes",`$.claims[${r}]`,t),`$.claims[${r}].supersedes`,t),ur(e,"text",`$.claims[${r}]`,t),ur(e,"asOf",`$.claims[${r}]`,t),rr(e,"scope",`$.claims[${r}]`,t),cr(lr(e,"tags",`$.claims[${r}]`,t),`$.claims[${r}].tags`,t),void 0!==e.authoredBy&&pr(e.authoredBy,`$.claims[${r}].authoredBy`,t);let a=nr(e,"review",`$.claims[${r}]`,t);a&&(ir(a,["status","reviewer","reviewedAt","rationale"],`$.claims[${r}].review`,t),or(a,"status",`$.claims[${r}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==a.reviewer&&pr(a.reviewer,`$.claims[${r}].review.reviewer`,t),ur(a,"reviewedAt",`$.claims[${r}].review`,t),ur(a,"rationale",`$.claims[${r}].review`,t));let i=nr(e,"uncertainty",`$.claims[${r}]`,t);if(i){ir(i,["kind","lower","upper","confidence","unit","description"],`$.claims[${r}].uncertainty`,t),or(i,"kind",`$.claims[${r}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(let e of["lower","upper","confidence"])Jt(i,e,`$.claims[${r}].uncertainty`,t);ur(i,"unit",`$.claims[${r}].uncertainty`,t),ur(i,"description",`$.claims[${r}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,r)=>{if(!Xt(e))return void t.push({path:`$.evidence[${r}]`,message:"Expected an evidence object."});ir(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${r}]`,t),sr(e,"id",`$.evidence[${r}]`,t),or(e,"role",`$.evidence[${r}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(let a of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])ur(e,a,`$.evidence[${r}]`,t);rr(e,"scope",`$.evidence[${r}]`,t);let a=nr(e,"source",`$.evidence[${r}]`,t);if(a){ir(a,["name","uri","version","retrievedAt","publisher"],`$.evidence[${r}].source`,t);for(let e of["name","uri","version","retrievedAt","publisher"])ur(a,e,`$.evidence[${r}].source`,t)}let i=nr(e,"transformation",`$.evidence[${r}]`,t);if(i){ir(i,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${r}].transformation`,t),sr(i,"id",`$.evidence[${r}].transformation`,t),or(i,"kind",`$.evidence[${r}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);let e=lr(i,"inputEvidenceIds",`$.evidence[${r}].transformation`,t);e?cr(e,`$.evidence[${r}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${r}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),cr(lr(i,"assumptions",`$.evidence[${r}].transformation`,t),`$.evidence[${r}].transformation.assumptions`,t),ur(i,"description",`$.evidence[${r}].transformation`,t),ur(i,"implementation",`$.evidence[${r}].transformation`,t),ur(i,"performedAt",`$.evidence[${r}].transformation`,t),rr(i,"parameters",`$.evidence[${r}].transformation`,t),void 0!==i.performedBy&&pr(i.performedBy,`$.evidence[${r}].transformation.performedBy`,t)}let s=nr(e,"sample",`$.evidence[${r}]`,t);if(s){ir(s,["rowCount","fields","values","truncated"],`$.evidence[${r}].sample`,t),cr(lr(s,"fields",`$.evidence[${r}].sample`,t),`$.evidence[${r}].sample.fields`,t);let e=lr(s,"values",`$.evidence[${r}].sample`,t);e&&!ar(e)&&t.push({path:`$.evidence[${r}].sample.values`,message:"Expected JSON values."}),Jt(s,"rowCount",`$.evidence[${r}].sample`,t),er(s,"truncated",`$.evidence[${r}].sample`,t)}dr(e,"relationship",`$.evidence[${r}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),kr(e.fieldStatus,t);let i=nr(e,"time","$",t);return i&&xr(i,t),vr(e,t),rr(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 wr(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function $r(e,t){if(!t||!wr(e)||!Array.isArray(e.evidence))return[];let r=[];return e.evidence.forEach((e,t)=>{wr(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,r.push(`$.evidence[${t}].sample`))}),r}function Sr(e,t={}){try{return Br(e,t)}catch{let t=M(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function Br(e,t){if(!wr(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};let r=Qt(e),a=[.../* @__PURE__ */new Set([...r.excludedPaths,...M(e)])].sort(),i=r.value,s=$r(i,t.excludeEvidenceSamples),o=s.length?["Bounded evidence samples were excluded by the transfer policy."]:[],n=i?.contractVersion;if("string"!=typeof n||!n)return{contract:i,transfer:{status:"invalid",omittedPaths:[...a,...s],warnings:["Artifact contract is missing a string contractVersion.",...o]}};if("0.1"!==n)return{contract:i,transfer:{status:a.length>0?"invalid":"unsupported-version",omittedPaths:[...a,...s],warnings:[`Contract version ${n} is not interpreted by this runtime.`,...a.length>0?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...o]}};let l=Cr(i),c=[...l.errors.map(({path:e,message:t})=>`${e}: ${t}`),...l.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...a.length?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...o];return{contract:i,transfer:{status:!l.valid||a.length>0?"invalid":s.length>0?"excluded":"preserved",omittedPaths:[...a,...s],warnings:c}}}function Pr(e){let t=Sr(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 Wr(e){let t=Object.entries(e).filter(([e,t])=>It(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function Lr(e,t=[]){if(void 0===e)return;let 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 Zt(r.length>0?{data:e,transformations:r}:e).fingerprint}function Mr(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!It(e,t)&&"recipeId"!==e))}function Rr(e,t,r,a=Wr(t)){let i=Mr(t),s=0===M(i).length?Zt(i).fingerprint:void 0,o=void 0!==a&&0===M(a).length?Lr(a,e.evidence):void 0,n="ChartRecipe"===r&&"string"==typeof t.recipeId?t.recipeId:r,l=[],c=[];return void 0!==n&&(void 0===e.artifact.component?c.push("artifact.component"):e.artifact.component!==n&&l.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===s?c.push("artifact.configFingerprint"):e.artifact.configFingerprint!==s&&l.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&o?e.artifact.dataFingerprint!==o&&l.push("artifact.dataFingerprint"):c.push("artifact.dataFingerprint"),{status:l.length>0?"mismatch":c.length>0?"unknown":"match",mismatchPaths:l,unknownPaths:c}}function Ir(e,t,r){let a=Rr(e,t,r);return{mismatchPaths:[...a.mismatchPaths,...void 0!==r&&a.unknownPaths.includes("artifact.component")?["artifact.component"]:[]]}}function Er(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;let a=Zt(e[r]),i=Zt(t[r]);return a.excludedPaths.length>0||a.fingerprint!==i.fingerprint}).map(e=>"props."+e).sort()}function Nr(e,t,r,a){return Zt({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 Tr(e,t,r,a,i){let s=Wr(r),o={...e,serializedConfigFingerprint:Zt(Mr(r)).fingerprint,serializedDataFingerprint:void 0===s?null:Zt(s).fingerprint};return{...o,transferFingerprint:Nr(o,t,a,i)}}function Fr(e,t,r,a,i){if(!t)return{};let s=Pr(t),o=i.recipeId??e,n=Ir(t,r,o),l=Er(r,a),c=Ir(t,a,o);return n.mismatchPaths.length>0?{artifactContract:s.contract,artifactTransfer:Tr({status:"invalid",omittedPaths:n.mismatchPaths,warnings:["The artifact contract fingerprints do not match the supplied chart props or data."]},e,a,s.contract,i)}:l.length>0?{artifactContract:s.contract,artifactTransfer:Tr({status:"excluded",omittedPaths:l,warnings:["Chart props or data were excluded from the serialized configuration."]},e,a,s.contract,i)}:c.mismatchPaths.length>0?{artifactContract:s.contract,artifactTransfer:Tr({status:"invalid",omittedPaths:c.mismatchPaths,warnings:["Serialized chart props or data differ from the values bound to the artifact contract."]},e,a,s.contract,i)}:{artifactContract:s.contract,artifactTransfer:Tr(s.transfer,e,a,s.contract,i)}}function Or(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function jr(e,t){return!(!It(e,t)||"areas"===e&&"string"==typeof t)}function Dr(e,t,r){if(r?.selections&&M(r.selections).length>0)throw new TypeError("Serialized selection state must contain only values that survive JSON serialization unchanged.");let a=I(e)??N(t.recipe)??N(t.recipeId);if(a)return zr(a,t,r);if(!h(e))throw Error(`Unknown component "${e}". Known components: ${dl.join(", ")}`);let i=!1!==r?.includeData,s={};for(let[e,r]of Object.entries(t))if(null!=r&&!Pc.has(e)&&(i||!jr(e,r))&&"function"!=typeof r&&0>=M(r).length)try{Or(s,e,Wc(r))}catch{}let o=/* @__PURE__ */(new Date).toISOString(),n={version:Bc,createdAt:o,...r?.selections?{selections:r.selections}:{}};return{component:e,props:s,version:Bc,createdAt:o,...Fr(e,r?.artifactContract,t,s,n),...r?.selections?{selections:r.selections}:{}}}function _r(e,t,r){let a={};for(let[i,s]of Object.entries(e))if(null!=s&&!Pc.has(i)&&"recipeId"!==i&&(t||!jr(i,s))){if("function"==typeof s){if(r)throw Error(`Portable recipe prop "${i}" is not JSON-safe.`);continue}if(M(s).length>0){if(r)throw Error(`Portable recipe prop "${i}" is not JSON-safe.`);continue}Or(a,i,Wc(s))}return a}function zr(e,t,r){let a=!1!==r?.includeData,i=M(e);if("portable"===e.portability&&i.length>0)throw Error(`Portable recipe "${e.id}" has non-JSON definition values at: ${i.join(", ")}.`);let s=_r(t,a,"portable"===e.portability),o=e.intents.map(Et).filter(e=>!!e),n=e.layout&&"object"==typeof e.layout&&"string"==typeof e.layout.id?e.layout.id:void 0,l=n?E(n):void 0,c=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(l&&c&&(l.version!==c.version||l.fingerprint!==c.fingerprint))throw Error(`Recipe layout "${n}" registry identity does not match its portable declaration.`);let d=l??c;if("portable"===e.portability&&n&&!d)throw Error(`Portable recipe layout "${n}" must be registered with an explicit version identity.`);let u={name:e.name,intents:o,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily,...e.version?{recipeVersion:e.version}:{},...0===i.length?{definitionFingerprint:Zt(e).fingerprint}:{},...n?{layoutId:n}:{},...d?{layoutVersion:d.version}:{},...d?.fingerprint?{layoutFingerprint:d.fingerprint}:{}},p=/* @__PURE__ */(new Date).toISOString();if("portable"===e.portability){if(M(s).length>0)throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);let a={version:Bc,createdAt:p,recipeId:e.id,portable:!0,manifest:u,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:s,manifest:u,version:Bc,createdAt:p,...Fr("ChartRecipe",r?.artifactContract,t,s,a),...r?.selections?{selections:r.selections}:{}}}let f="Recipe contains or may depend on non-serializable local layout callbacks.",h=["This config is inspectable but cannot be rendered remotely by CLI or MCP."],y={version:Bc,createdAt:p,recipeId:e.id,portable:!1,manifest:u,reason:f,warnings:h,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:f,warnings:h,props:s,manifest:u,version:Bc,createdAt:p,...Fr("ChartRecipe",r?.artifactContract,t,s,y),...r?.selections?{selections:r.selections}:{}}}function Ur(e){try{if(!e||"object"!=typeof e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}catch{return!1}}function Gr(e){if(!Ur(e))throw Error("Invalid chart config: expected a plain object");let t=M(e);if(t.length>0)throw new TypeError(`Chart config contains values that cannot survive JSON serialization at: ${t.join(", ")}.`);if(e.version!==Bc)throw Error(`Unsupported chart config version ${e.version+""}; expected ${Bc}.`);if("string"!=typeof e.component||!e.component.trim())throw Error("Invalid chart config: missing component");if(!Ur(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&&!Ur(e.selections))throw Error("Invalid chart config: selections must be a plain object");if(void 0!==e.manifest){if(!Ur(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 Vr(e){Gr(e);let{props:t}=e,r="LocalChartRecipe"===e.component?"ChartRecipe":e.component;if("ChartRecipe"!==r&&!h(r))throw Error(`Cannot project unknown component "${r}" to JSX.`);let a=["<"+r];e.recipeId&&a.push(` recipeId={${Hr(e.recipeId)}}`);for(let[e,r]of Object.entries(t)){if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)){let t={};Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),a.push(` {...${Hr(t)}}`);continue}if("string"==typeof r)a.push(qr(r)?` ${e}="${r}"`:` ${e}={${Hr(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{let t=Hr(r);a.push(80>t.length?` ${e}={${t}}`:` ${e}={${Hr(r,2)}}`)}}return a.push("/>"),a.join("\n")}function qr(e){return!/["&<>{}\r\n\u2028\u2029]/.test(e)}function Hr(e,t){return JSON.stringify(e,null,t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Yr(e,t){if("function"==typeof e)return t=>+e(t);let r=e||t;return e=>+e[r]}function Qr(e,t){if("function"==typeof e)return e;let r=e||t;return e=>e[r]}function Zr(e,t){return Mc.has(e)||Rc.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 Kr(e){for(let t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){let r=e[t];if("string"==typeof r&&r)return r}}function Xr(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function Jr(e,t={}){let r=!0===t.showRetractedAnnotations,a=!0===t.showSupersededAnnotations,i=/* @__PURE__ */new Set;for(let t of e){let e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&i.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!r)return!1;let t=e?.provenance?.stableId;return!(t&&i.has(t)&&!a)})}function ea(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function ta(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 ra(e,t,r,a){let i=Dt(e,["nominal","ordinal"]),s=Dt(e,["quantitative"]),o=i?Ot(i,r,t):void 0,n=s?Ot(s,r,t):void 0,l=i?.role??o??"category",c=s?.role??n??"value",d=e.encodings??[],u=d.length?d.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${l} and ${c} are mapped through the recipe's declared visual semantics`,{number:p,percent:f}=ta(a),h=/* @__PURE__ */new Map;if(o&&n)for(let e of t){let t=(e[o]??"Uncategorized")+"",r=Number(e[n]);Number.isFinite(r)&&h.set(t,(h.get(t)??0)+r)}let y=[...h].sort((e,t)=>t[1]-e[1]),m=y.reduce((e,[,t])=>e+t,0),g=y[0],v=y[1],b=m>0?((g?.[1]??0)+(v?.[1]??0))/m:0,k=e.intents.map(e=>({id:Et(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,x=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${l} and ${c}. ${ea(u)}.`,l2:y.length>0?`${y.length} categories total ${p.format(m)}. ${g[0]} accounts for ${p.format(g[1])}${m>0?` (${f.format(g[1]/m)})`:""}${v?`, followed by ${v[0]} at ${p.format(v[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>y.length?g?g[0]+" is the only represented category.":"No quantitative pattern can be derived from the available data.":.5>b?`The total is distributed across ${y.length} categories without the first two forming a majority.`:`Most of the total is concentrated in ${g[0]} and ${v[0]}, which together account for ${f.format(b)}.`,l4:`The chart is intended for ${k??"explanation"}${x?` with a ${x} audience`:""}: ${e.designContract.whyCustom}`}}function aa(e,t,r={}){let a=Tt(t),i=Nt(t),s=r.locale??"en",o=("function"==typeof e.description?e.description({data:a,config:i,locale:s}):void 0)?.levels??ra(e,a,i,s),n=r.levels??["l1","l2","l3","l4"],l={};for(let e of n)o[e]&&(l[e]=o[e]);let c=["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:c,levels:l,...d?.length?{caveats:d}:{}}}function ia(e){let 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))),i=$e(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),s=Pe(e.seed??1),o=e.idPrefix??"mechanical";return Array.from({length:a},(e,t)=>{let a=0;for(let e=0;r>e;e+=1)s()<i&&(a+=1);let n=r/2;return{id:`${o}-${t}`,value:a,mechanical:!0,pegRows:r,branchProbability:i,pathRights:a,side:n>a?"left":a>n?"right":"center"}})}function sa(e){let{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");let{rows:i}=Me(e.data,"event"),s=i.flatMap((t,r)=>{let a=we(Ae(t,r,e.timeAccessor));return null==a?[]:[{datum:t,index:r,eventTime:a,arrivalTime:we(Ae(t,r,e.arrivalAccessor))??a,watermarkAtArrival:0,late:!1}]}),o="function"==typeof r?null:we(r?.value),n="function"==typeof r?t:we(r?.delay)??t,l=-1/0,c=-1/0;for(let e of s.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){l=Math.max(l,e.eventTime);let i="function"==typeof r?we(r(l)):l-n;c=o??Math.max(c,i??l-t);let s=a?we(Ae(e.datum,e.index,a)):null;e.watermarkAtArrival=s??c,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:s,watermarkValue:s.length?c:o??-n}}function oa(e,t){let 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:[],i=Math.max(2,Math.round(we(t.bins)??21)),s=Math.max(1,Math.round(we(t.pegRows)??i-1));if(r&&(a="GaltonBoardChart"===e?ia({bins:i,count:t.mechanicalCount,pegRows:s,branchProbability:t.branchProbability,seed:t.seed}):We({count:t.mechanicalCount,categories:t.mechanicalCategories,unitValue:t.unitValue,seed:t.seed})),a=Me(a,"UnitPileChart"===e?"pile":"GaltonBoardChart"===e?"galton":"EventDropChart"===e?"event":"collision-swarm").rows,"UnitPileChart"===e){let e=/* @__PURE__ */new Map,i=t.valueAccessor??(r?"value":void 0);return a.forEach((r,a)=>{let s=(Ae(r,a,t.categoryAccessor??"category")??"unknown")+"",o=i?we(Ae(r,a,i)):1;e.set(s,(e.get(s)??0)+Math.max(0,o??0))}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("GaltonBoardChart"===e){let e=a.map((e,r)=>we(Ae(e,r,t.valueAccessor??"value"))).filter(e=>null!=e),o=r?[0,s]:Be(t.valueExtent),n=o?.[0]??(e.length?Math.min(...e):0),l=o?.[1]??(e.length?Math.max(...e):1),c=n===l?1:l-n,d=Array.from({length:i},(e,t)=>({label:t+1+"",value:0}));for(let t of e)d[Math.max(0,Math.min(i-1,Math.floor((t-n)/c*i)))].value+=1;return{generated:r,rows:d}}if("CollisionSwarmChart"===e){let e=/* @__PURE__ */new Map;return a.forEach((r,a)=>{if(null==we(Ae(r,a,t.xAccessor??"x")))return;let i=t.groupAccessor?(Ae(r,a,t.groupAccessor)??"All")+"":"All";e.set(i,(e.get(i)??0)+1)}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("EventDropChart"===e){let e=we(t.windows?.size??10);if(null==e||0>=e)return null;let{events:i}=sa({data:a,timeAccessor:t.timeAccessor??"time",arrivalAccessor:t.arrivalAccessor??"arrivalTime",windowSize:e,watermark:t.watermark,watermarkAtArrivalAccessor:t.watermarkAtArrivalAccessor}),s=i.map(e=>e.eventTime),o=s.length?Math.min(...s):0,n=s.length?Math.max(...s):o+e,l=Math.min(we(t.timeExtent?.[0])??o,o),c=Math.max(we(t.timeExtent?.[1])??n,n),d=Math.floor(l/e)*e,u=Math.max(1,Math.ceil((c-d+e)/e)),p=Array.from({length:u},(t,r)=>({label:`${d+r*e}-${d+(r+1)*e}`,value:0,secondary:0,secondaryLabel:"late"}));for(let t of i){let r=p[Math.max(0,Math.min(u-1,Math.floor((t.eventTime-d)/e)))];t.late?r.secondary+=1:r.value+=1}return{generated:r,rows:p}}return null}function na(e){let t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}function la(e,t){let r=e.physics&&"object"==typeof e.physics?e.physics:null,a=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,i=[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(i)?i.map((e,r)=>{if(!e||"object"!=typeof e)return null;let a=e,i=na(a.count??a.value??a.total??a.bodies??a.events);if(null==i)return null;let s=a.label??a.id??a.name??"container "+(r+1),o=na(a.secondary??a.secondaryCount),n=na(a.observed??a.observedCount);return{label:Xr(s,t),count:i,...null!=o?{secondary:o}:{},..."string"==typeof a.secondaryLabel&&a.secondaryLabel?{secondaryLabel:a.secondaryLabel}:{},...null!=n?{observed:n}:{}}}).filter(e=>null!=e):null}function ca(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}function da(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"UnitPileChart"===e?"unit":"body"}function ua(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 pa(e,t){if(0>=t)return"0%";let r=e/t*100;return(10>r?Math.round(10*r)/10:Math.round(r))+"%"}function fa(e,t,r,a,i,s,o=null){let n=ca(e),l=o&&"EventDropChart"===e?"accepted event":da(e),c=o?o.generated?"The generated sample projection":"The source projection":"The settled projection";if(i.has("l1")&&(a.l1=ua(e,t)),!i.has("l2")&&!i.has("l3"))return;if(!r||0===r.length)return void(i.has("l2")&&(a.l2=o?"No valid source records are available.":"No settled projection is loaded yet."));let d=r.reduce((e,t)=>e+t.count,0),u=r.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),p=u[0]??r.slice().sort((e,t)=>t.count-e.count)[0];if(!p)return;let f=r.reduce((e,t)=>e+(t.secondary??0),0),h=r.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(i.has("l2"))if(o&&"EventDropChart"===e)a.l2=`${c} classifies ${s(d+f)} ${ha(d+f,"event")} across ${r.length} ${ha(r.length,n)}: ${s(d)} accepted and ${s(f)} late.`;else if(0===u.length)a.l2=`${c} contains ${s(d)} ${ha(d,l)} across ${r.length} ${ha(r.length,n)}; no ${ha(2,n)} are non-empty yet.`;else{let e=f>0?` ${s(f)} ${ha(f,l)} ${1===f?"is":"are"} marked ${h}.`:"";a.l2=`${c} contains ${s(d)} ${ha(d,l)} across ${r.length} ${ha(r.length,n)}; ${u.length} ${ha(u.length,n)} ${1===u.length?"is":"are"} non-empty. The largest ${n} is ${p.label} with ${s(p.count)} ${ha(p.count,l)}.${e}`}if(i.has("l3")&&d>0&&u.length>0){let e=u.find(e=>e!==p),t=pa(p.count,d);a.l3=e?`${c} is most concentrated in ${p.label}, which holds ${s(p.count)} ${ha(p.count,l)} (${t}); ${e.label} follows with ${s(e.count)} ${ha(e.count,l)}.`:`${c} is concentrated in ${p.label}, which holds all ${s(p.count)} ${ha(p.count,l)}.`}}function ha(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function ya(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()}function ma(e){return Ec[e]||ya(e)+" chart"}function ga(e){let t,r=0;for(let[a,i]of Object.entries(e))if("number"==typeof i&&i>0){if(i>r){t=a,r=i;continue}if(i===r&&void 0!==t){let e=Dc.indexOf(a),r=Dc.indexOf(t);-1!==e&&(-1===r||r>e)&&(t=a)}}return t}function va(e){return"BumpChart"===e?"ranking":Rc.has(e)||"StackedAreaChart"===e?"apportioning":Fc.has(e)?"relating":Mc.has(e)?"comparing":Ic.has(e)?"characterizing":Lc.has(e)?"tracking":Nc.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}function ba(e){if(e){if("fits"in e||"buildProps"in e){let t=e,r={};for(let[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 ka(e,t){let r=ba(t);if(r?.act)return r.act;if(r?.intentScores){let e=ga(r.intentScores);if(e&&Oc[e]&&(r.intentScores[e]??0)>=3)return Oc[e]}return r?.family?jc[r.family]:va(e)}function xa(e){let t=e.annotations;return!!Array.isArray(t)&&t.some(e=>{if(!e||"object"!=typeof e)return!1;let t=e;if("string"!=typeof t.type||!zc.has(t.type))return!1;let r=t.provenance;return!(!r||"object"!=typeof r)&&(Uc.has(r.authorKind)||Gc.has(r.source)||Vc.has(r.basis))})}function Ca(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 Aa(e,t,r,a){let i=0,s=0,o=1/0,n=-1/0,l=null,c=null,d=0,u=0,p=null,f=null,h=NaN,y=NaN;for(let r of e){let e=t(r);Number.isFinite(e)&&(0===i&&(h=e,p=r),y=e,f=r,o>e&&(o=e,l=r,d=i),e>n&&(n=e,c=r,u=i),i++,s+=e)}return 0===i?null:{count:i,min:o,max:n,mean:s/i,minLabel:Xr(null!=l?r(l):null,a),maxLabel:Xr(null!=c?r(c):null,a),first:h,last:y,firstLabel:Xr(null!=p?r(p):null,a),lastLabel:Xr(null!=f?r(f):null,a),minIndex:d,maxIndex:u}}function wa(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 $a(e){let 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 Sa(e){let t=qc["string"==typeof e.type?e.type:"annotation"]||"an annotation",r=$a(e),a=r?r+t.replace(/^an? /,""):t,i="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return i?`${a} labeled "${i}"`:a}function Ba(e){let t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;let r=Jr(t.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return;let a=r.map(Sa),i=a.slice(0,5),s=a.length-i.length,o=wa(i)+(s>0?`, and ${s} more`:""),n=r.length;return`The author has marked ${1===n?"one feature":n+" features"} on this chart: ${o}.`}function Pa(e,t,r={}){let a=void 0!==r.levels,i=new Set(r.levels??["l1","l2","l3"]);!a&&(r.capability||xa(t))&&i.add("l4");let s=Ft(e,t,r.recipe);if(s){let e=["l1","l2","l3","l4"].filter(e=>i.has(e));!a&&!e.includes("l4")&&e.push("l4");let o=aa(s,t,{levels:e,locale:r.locale,audience:r.audience,includeCaveats:r.includeCaveats}),n=Ba(t);return{...o,text:n?`${n} ${o.text}`.trim():o.text,...n?{annotations:n}:{}}}let o=Ca(r.locale??"en"),n=ma(e),l=Array.isArray(t.data)?t.data:null,c=Kr(t),d=Tc.has(e)?la(t,o):null,u=Tc.has(e)&&null===d?oa(e,t):null,{measure:p,measureFallback:f,dimension:h,dimensionFallback:y}=Zr(e,t),m="string"==typeof p&&p?p:f,g="string"==typeof h&&h?h:y,v={};if(Tc.has(e)&&fa(e,n,d??(u?la({projectionRows:u.rows},o):null),v,i,o,u),i.has("l1")&&!Tc.has(e))if("BumpChart"===e)v.l1=`A ${n} ranking ${c??"series"} by ${m} across ${g}.`;else if(Lc.has(e)||Mc.has(e))v.l1=`A ${n} of ${m} by ${g}`+(c?`, split by ${c}.`:".");else if(Rc.has(e))v.l1=`A ${n} showing ${m} across ${g} categories.`;else if(Ic.has(e))v.l1=`A ${n} of the distribution of ${m}`+(c?` by ${c}.`:".");else if(Nc.has(e)){let e=Array.isArray(t.nodes)?t.nodes.length:void 0,r=Array.isArray(t.edges)?t.edges.length:void 0,a=[null!=e?`${e} ${Fa(e,"node")}`:null,null!=r?`${r} ${Fa(r,"edge")}`:null].filter(Boolean);v.l1=`A ${n}${a.length?" with "+a.join(" and "):""}.`}else if("BigNumber"===e){let e="string"==typeof t.label?t.label:m;v.l1=`A single value${e?" for "+e:""}.`}else v.l1=`A ${n}.`;let b=Lc.has(e)||"BumpChart"===e||Mc.has(e)||Rc.has(e)||Ic.has(e),k=null;if((i.has("l2")||i.has("l3")||i.has("l4"))&&b&&l&&l.length>0&&(k=Aa(l,Yr(p,f),Qr(h,y),o)),i.has("l2")&&b&&(l&&0!==l.length?k&&(v.l2=Rc.has(e)?`${k.count} segments totaling ${o(Wa(k))}. Largest is ${k.maxLabel} at ${o(k.max)}; smallest is ${k.minLabel} at ${o(k.min)}.`:`${m} ranges from ${o(k.min)} (${k.minLabel}) to ${o(k.max)} (${k.maxLabel}), with a mean of ${o(k.mean)} across ${k.count} points.`):v.l2="No data is loaded yet."),i.has("l3")&&k&&!c&&Lc.has(e)?v.l3=La(k,m,o):i.has("l3")&&k&&!c&&Mc.has(e)&&(v.l3=`The highest ${g} is ${k.maxLabel} and the lowest is ${k.minLabel}.`),i.has("l4")){let a=xa(t)?"alerting":ka(e,r.capability);a&&(v.l4=Ma(a,e,t,c?null:k,m,g,o,r.audience))}let x=["l1","l2","l3","l4"].filter(e=>i.has(e)&&v[e]).map(e=>v[e]).join(" "),C=Ba(t);return{text:C?`${C} ${x}`.trim():x,levels:v,...C?{annotations:C}:{}}}function Wa(e){return e.mean*e.count}function La(e,t,r){let{first:a,last:i,min:s,max:o,maxLabel:n,minLabel:l,firstLabel:c,lastLabel:d,minIndex:u,maxIndex:p,count:f}=e,h=o-s,y=i-a;if(0===h)return`${Ta(t)} is constant at ${r(a)} across the series.`;if(.04>h/(Math.abs(e.mean)||1))return`${Ta(t)} ends roughly where it started (${r(a)} at ${c} to ${r(i)} at ${d}), ranging between ${r(s)} and ${r(o)}.`;let m=p>0&&f-1>p,g=u>0&&f-1>u,v=(o-Math.max(a,i))/h,b=(Math.min(a,i)-s)/h;return m&&v>.15?`Overall ${t} climbs to a peak of ${r(o)} (${n}), then falls to ${r(i)} (${d}).`:g&&b>.15?`Overall ${t} drops to a low of ${r(s)} (${l}), then recovers to ${r(i)} (${d}).`:.05>Math.abs(y)/h?`${Ta(t)} ends roughly where it started (${r(a)} at ${c} to ${r(i)} at ${d}), ranging between ${r(s)} and ${r(o)}.`:y>0?p===f-1?`Overall ${t} rises from ${r(a)} (${c}) to a peak of ${r(i)} (${d}).`:`Overall ${t} rises from ${r(a)} (${c}) to ${r(i)} (${d}), after peaking at ${r(o)} (${n}).`:u===f-1?`Overall ${t} falls from ${r(a)} (${c}) to a low of ${r(i)} (${d}).`:`Overall ${t} falls from ${r(a)} (${c}) to ${r(i)} (${d}), after dipping to ${r(s)} (${l}).`}function Ma(e,t,r,a,i,s,o,n){let l,c,d=_c[e],u=/^[aeiou]/i.test(d)?"an":"a";switch(e){case"locating":l="This is a map",c="read values by location";break;case"presenting":l="This is a single-value display",c=`read ${"string"==typeof r.label&&r.label?r.label:i} as the headline number`;break;case"tracing":l=`This is ${u} ${d} chart`,c="follow the movement between states";break;case"nesting":l=`This is ${u} ${d} chart`,c="read it for nested structure and how children sum into their parents";break;case"relating":l=`This is ${u} ${d} chart`,c=`read it for whether ${s} and ${i} move together`;break;default:l=`This is ${u} ${d} chart`,c=Ra(e,a,i,s,o,t)}return`${l}; ${c}.${Na(t,n)}`}function Ra(e,t,r,a,i,s){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 Ia(t,i,s);case"tracking":return`read it for the trajectory of ${r}, which ${Ea(t)} from ${i(t.first)} (${t.firstLabel}) to ${i(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${r} across ${a}; ${t.maxLabel} leads at ${i(t.max)}`;case"ranking":return`read it top to bottom by ${r}; ${t.maxLabel} ranks highest at ${i(t.max)}`;case"apportioning":{let e=t.mean*t.count,r=e>0?Math.round(t.max/e*100):null;return`read each ${a}'s share of the ${i(e)} total; ${t.maxLabel} is the largest at ${i(t.max)}${null!=r?` (${r}%)`:""}`}case"characterizing":return`read it for the spread of ${r}, from ${i(t.min)} to ${i(t.max)}`;default:return"read the highlighted features"}}function Ia(e,t,r){if(Mc.has(r)||Rc.has(r))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;let{first:a,last:i,min:s,max:o,minLabel:n,maxLabel:l,lastLabel:c,minIndex:d,maxIndex:u,count:p}=e,f=o-s;if(f>0){let e=u>0&&p-1>u,r=d>0&&p-1>d,h=(o-Math.max(a,i))/f,y=(Math.min(a,i)-s)/f;if(e&&h>.15)return`the peak of ${t(o)} at ${l} is the point to investigate`;if(r&&y>.15)return`the dip to ${t(s)} at ${n} is the point to investigate`;if(i>=o)return`the climb to ${t(i)} at ${c} warrants a closer look`;if(s>=i)return`the drop to ${t(i)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(o)}) and ${n} (${t(s)}) — are the points to check`}function Ea(e){let 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 Na(e,t){if(!t)return"";let r=t.familiarity?.[e];return"number"!=typeof r||r>2?"":` This ${ma(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}function Ta(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function Fa(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Oa(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function ja(e){return!!e&&"object"==typeof e}function Da(e,t,r,a){let i=Dt(t,["nominal","ordinal"]),s=t.dataRoles.filter(e=>"quantitative"===e.semanticType),o=i?Ot(i,r,a):void 0,n=[];o&&null!=e[o]&&n.push(e[o]+"");for(let t of s){let i=Ot(t,r,a);i&&null!=e[i]&&n.push(`${t.role}: ${e[i]+""}`)}return n.length>0?n.join(", "):"Data item"}function _a(e,t,r={}){let a=Tt(t),i=Nt(t),s=Math.max(1,r.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:a,config:i,locale:r.locale??"en"});let o=ja(e.navigation)?e.navigation:void 0,n=(o?.groupByRole?jt(e,o.groupByRole):void 0)??(o?.groupBy?.[0]?jt(e,o.groupBy[0])??e.dataRoles.find(e=>e.field===o.groupBy?.[0]):void 0)??Dt(e,["nominal","ordinal"]),l=n?Ot(n,i,a):void 0,c=(o?.idRole?jt(e,o.idRole):void 0)??Dt(e,["identifier"]),d=c?Ot(c,i,a):void 0,u={id:"root",role:"chart",label:o?.summaryTemplate?_t(o.summaryTemplate,void 0,e,i,a,{count:a.length}):`${e.name}: ${a.length} ${1===a.length?"item":"items"} represented.`,level:1,children:[]},p=0,f=(t,r,s)=>{let n=d?t[d]:void 0,l=o?.itemLabelTemplate?_t(o.itemLabelTemplate,t,e,i,a,{count:a.length}):Da(t,e,i,a);return{id:"datum-"+Oa(n??r),role:"datum",label:l,level:s,datum:t}};if(l){let e=/* @__PURE__ */new Map;for(let t of a){let r=(t[l]??"Uncategorized")+"",a=e.get(r);a?a.push(t):e.set(r,[t])}u.children=[...e].map(([e,t],r)=>{let a=t.slice(0,Math.max(0,s-p));p+=a.length;let i=a.map((e,t)=>f(e,1e5*r+t,3));return t.length>a.length&&i.push({id:"more-"+Oa(e),role:"datum",label:`…and ${t.length-a.length} more items`,level:3}),{id:"group-"+Oa(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:i}})}else{let e=a.slice(0,s);u.children=e.map((e,t)=>f(e,t,2)),a.length>e.length&&u.children.push({id:"more",role:"datum",label:`…and ${a.length-e.length} more items`,level:2})}return u}function za(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function Ua(e,t="—"){return null==e||""===e?t:"object"==typeof e?Ua(e.id??e.name??e.label,t):e+""}function Ga(e){if(null==e||""===e)return;let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function Va(e){return Ua(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function qa(e,t){let r=za(e,t,"children");return Array.isArray(r)?r:[]}function Ha(e,t,r){return`${e} ${1===e?t:r}`}function Ya(e,t){return 0===e.numericLeaves?"":e.numericLeaves===e.leaves?", leaf total "+t(e.leafTotal):`, known leaf total ${t(e.leafTotal)} across ${Ha(e.numericLeaves,"valued leaf","valued leaves")}`}function Qa(e){return"TreeDiagram"===e?"tree":"Treemap"===e?"treemap":"CirclePack"===e?"circle-packing":"orbit"}function Za(e,t,r,a){let i=t.data&&"object"==typeof t.data?t.data:null,s=t.childrenAccessor??"children",o=t.valueAccessor??"value",n=t.nodeLabel??t.nodeIdAccessor,l=/* @__PURE__ */new WeakMap,c=/* @__PURE__ */new WeakSet,d=e=>{let t=l.get(e);if(t)return t;if(c.has(e))return{descendants:0,depth:0,leaves:0,numericLeaves:0,leafTotal:0};c.add(e);let r,a=qa(e,s);if(0===a.length){let t=Ga(za(e,o,"value"));r={descendants:0,depth:1,leaves:1,numericLeaves:null==t?0:1,leafTotal:t??0}}else r=a.reduce((e,t)=>{let r=d(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 c.delete(e),l.set(e,r),r},u=0,p=(e,t,i,l)=>{let c=Ua(za(e,n,"name"),"item "+i);if(l.has(e))return{id:`hierarchy-${Va(i)}-cycle`,role:"datum",level:t,label:`Repeated hierarchy reference to ${c}; branch omitted.`};let f=qa(e,s),h=d(e);if(0===f.length){if(u>=r)return null;u+=1;let s=Ga(za(e,o,"value"));return{id:`hierarchy-${Va(i)}-${Va(c)}`,role:"datum",level:t,label:`${c}${null==s?"":": "+a(s)}.`,...null==s?{}:{value:s},datum:e}}let y=new Set(l);y.add(e);let m=[],g=0;for(let[e,a]of f.entries()){if(u>=r){g+=d(a).leaves;continue}let s=p(a,t+1,`${i}-${e}`,y);s&&m.push(s)}return g>0&&m.push({id:`hierarchy-${Va(i)}-more`,role:"datum",level:t+1,label:`${Ha(g,"more leaf","more leaves")} in ${c} not shown; navigation is capped at ${r}.`}),{id:`hierarchy-${Va(i)}-${Va(c)}`,role:"series",level:t,label:`${c}: ${Ha(f.length,"direct child","direct children")}, ${Ha(h.descendants,"total descendant","total descendants")}, ${Ha(h.leaves,"leaf","leaves")}${Ya(h,a)}.`,datum:e,children:m}},f=i?d(i):null,h={id:"root",role:"chart",level:1,label:i?`A ${Qa(e)} chart with ${Ha(f.leaves,"leaf","leaves")} and ${Ha(f.descendants,"total descendant","total descendants")} across ${Ha(f.depth,"hierarchy level","hierarchy levels")}${Ya(f,a)}.`:"A hierarchy chart with no hierarchy data loaded.",children:[]};if(i){let e=p(i,2,"root",/* @__PURE__ */new Set);if(e){let t=Ua(za(i,n,"name"),"");h.children="series"===e.role&&""===t?e.children:[e]}}return h}function Ka(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function Xa(e,t="—"){return null==e||""===e?t:"object"==typeof e?Xa(e.id??e.name??e.label,t):e+""}function Ja(e){if(null==e||""===e)return;let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function ei(e){return Xa(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function ti(e){let 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 ri(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];let t=e;return Array.isArray(t.features)?t.features:"Feature"===t.type?[t]:[]}function ai(e,t,r){let a=Ka(e,t,r);if(void 0!==a)return a;let i=e.properties;return i&&"object"==typeof i?Ka(i,t,r):void 0}function ii(e,t,r){return Xa(ai(e,t,"id")??ai(e,"name","name")??ai(e,"NAME","NAME")??ai(e,"label","label"),r)}function si(e){let t=0,r=1/0,a=-1/0,i=0;for(let s of e)null!=s.value&&(t+=1,r=Math.min(r,s.value),a=Math.max(a,s.value),i+=s.value);return 0===t?null:{count:t,min:r,max:a,total:i,average:i/t}}function oi(e,t){let r=si(e);return r?`range ${t(r.min)} to ${t(r.max)}, average ${t(r.average)}, total ${t(r.total)}`:"no numeric values"}function ni(e){let t=e.filter(e=>null!=e.value),r=e.filter(e=>null==e.value),a=[],i=si(t);if(i)if(i.min===i.max)a.push({id:"equal",label:"Equal values",rows:t});else{let e=i.min+(i.max-i.min)/3,r=i.min+2*(i.max-i.min)/3,s=t.filter(e=>e.value>=r),o=t.filter(t=>t.value>=e&&r>t.value),n=t.filter(t=>e>t.value);s.length>0&&a.push({id:"highest",label:"Highest values",rows:s}),o.length>0&&a.push({id:"middle",label:"Middle values",rows:o}),n.length>0&&a.push({id:"lowest",label:"Lowest values",rows:n})}return r.length>0&&a.push({id:"missing",label:"No numeric value",rows:r}),a}function li(e,t,r){let a,i=e.filter(e=>null!=e.value).sort((e,t)=>t.value-e.value||e.index-t.index),s=/* @__PURE__ */new Map,o=0;for(let[e,t]of i.entries())a!==t.value&&(o=e+1,a=t.value),s.set(t.index,o);let n=0;return ni(e).map(e=>{let a=e.rows.slice(0,Math.max(0,t-n));n+=a.length;let o=a.map(e=>{let t=s.get(e.index),a=null==t||2>i.length?"":`, rank ${t} of ${i.length}`;return{id:`geo-${ei(e.label)}-${e.index}`,role:"datum",level:3,label:null==e.value?e.label+": no numeric value.":`${e.label}: ${r(e.value)}${a}.`,...null==e.value?{}:{value:e.value},datum:e.datum}}),l=e.rows.length-a.length;return l>0&&o.push({id:`geo-${e.id}-more`,role:"datum",level:3,label:`${l} more ${1===l?"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"}, ${oi(e.rows,r)}.`,children:o}})}function ci(e,t,r,a){let i=ri(t.areas),s="FlowMap"===e&&Array.isArray(t.nodes)?t.nodes:Array.isArray(t.points)?t.points:[],o=Array.isArray(t.flows)?t.flows:[],n=Array.isArray(t.lines)?t.lines:[],l=t.valueAccessor??t.sizeBy??t.costAccessor??"value",c=t.pointIdAccessor??t.nodeIdAccessor??"id",d=("ChoroplethMap"===e?i:s).map((r,a)=>({datum:r,index:a,label:ii(r,"ChoroplethMap"===e?t.idAccessor:c,`${"ChoroplethMap"===e?"region":"location"} ${a+1}`),value:Ja(ai(r,l,"value"))})),u=d.filter(e=>null!=e.value),p={id:"root",role:"chart",level:1,label:`${"ChoroplethMap"===e?`A choropleth map with ${i.length} regions.${u.length>0?` Values are available for ${u.length} of ${i.length} regions; ${oi(u,a)}.`:" No regions have numeric values."}`:"FlowMap"===e?`A flow map with ${o.length} flows and ${s.length} locations.`:"DistanceCartogram"===e?`A distance cartogram with ${s.length} locations and ${n.length} routes.`:`A proportional-symbol map with ${s.length} locations.`}${ti(t)}`,children:[]};if("ChoroplethMap"===e)p.children=li(d,r,a);else if(d.length>0){let e=d.slice(0,r).map(e=>({id:`geo-${ei(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}));d.length>r&&e.push({id:"geo-more",role:"datum",level:3,label:`…and ${d.length-r} more locations.`}),p.children?.push({id:"locations",role:"series",level:2,label:`Locations: ${d.length} marks.`,children:e})}let f="FlowMap"===e?o:n;if(f.length>0){let e=f.slice(0,r).map((e,t)=>{let r=Xa(e.source,"unknown"),i=Xa(e.target,"unknown"),s=Ja(Ka(e,l,"value"));return{id:`route-${ei(r)}-${ei(i)}-${t}`,role:"datum",level:3,label:`${r} to ${i}${null==s?"":": "+a(s)}.`,...null==s?{}:{value:s},datum:e}});p.children?.push({id:"routes",role:"series",level:2,label:`Routes: ${f.length} ${1===f.length?"route":"routes"}.`,children:e})}return p}function di(e,t={},r={}){return!!Ft(e,t,r.recipe)||Hc.has(e)||Yc.has(e)||Qc.has(e)||Lc.has(e)||Mc.has(e)||Rc.has(e)||Ic.has(e)}function ui(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function pi(e,t="—"){return null==e||""===e?t:"object"==typeof e?pi(e.id??e.name??e.label,t):e+""}function fi(e){if(null==e||""===e)return;let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function hi(e){return pi(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function yi(e,t){let 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 mi(e,t){t&&e.children?.push(t)}function gi(e,t,r,a){let i=Array.isArray(t.nodes)?t.nodes:[],s=Array.isArray(t.edges)?t.edges:Array.isArray(t.flows)?t.flows:[],o=t.nodeIdAccessor??t.nodeIDAccessor,n=t.sourceAccessor??"source",l=t.targetAccessor??"target",c=t.valueAccessor??"value",d=e=>pi(ui(e,o,"id"),"unknown"),u=(e,t)=>pi(ui(e,t,""),"unknown"),p=/* @__PURE__ */new Set;for(let e of s)p.add(u(e,n)),p.add(u(e,l));let f=i.length>0?i:[...p].map(e=>({id:e})),h=/* @__PURE__ */new Map;for(let e of f)h.set(d(e),{links:0,value:0});for(let e of s){let t=u(e,n),r=u(e,l),a=fi(ui(e,c,"value"))??0;for(let e of[t,r]){let t=h.get(e)??{links:0,value:0};t.links+=1,t.value+=a,h.set(e,t)}}let y={id:"root",role:"chart",level:1,label:`A ${"SankeyDiagram"===e||"ProcessSankey"===e?"flow diagram":"ChordDiagram"===e?"chord diagram":"network graph"} with ${f.length} nodes and ${s.length} links.${yi(t,"network")}`,children:[]},m=0,g=/* @__PURE__ */new Map,v=t.colorBy??"group";for(let e of f){let t=pi(ui(e,v,"group"),"Ungrouped"),r=g.get(t);r?r.push(e):g.set(t,[e])}let b=[...g].map(([e,t],i)=>{let s=[];for(let[e,o]of t.entries()){if(m>=r)break;m+=1;let t=d(o),n=h.get(t)??{links:0,value:0},l=n.value>0?`, ${a(n.value)} total flow`:"";s.push({id:`node-${i}-${e}-${hi(t)}`,role:"datum",level:3,label:`${t}: ${n.links} ${1===n.links?"link":"links"}${l}.`,value:n.value>0?n.value:void 0,datum:o})}return{id:`nodes-${i}-${hi(e)}`,role:"series",level:2,label:`${e}: ${t.length} ${1===t.length?"node":"nodes"}.`,children:s}});b.length>0&&y.children?.push(...b);let k=s.slice(0,r).map((e,t)=>{let r=u(e,n),i=u(e,l),s=fi(ui(e,c,"value"));return{id:`link-${hi(r)}-${hi(i)}-${t}`,role:"datum",level:3,label:`${r} to ${i}${null==s?"":": "+a(s)}.`,value:s,datum:e}});return s.length>r&&k.push({id:"links-more",role:"datum",level:3,label:`…and ${s.length-r} more links.`,value:void 0}),k.length>0&&y.children?.push({id:"links",role:"series",level:2,label:`Links: ${s.length} ${1===s.length?"connection":"connections"}.`,children:k}),y}function vi(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function bi(e,t){let r=Array.isArray(e.annotations)?e.annotations:null;if(!r)return null;let a=Jr(r.filter(e=>!!e&&"object"==typeof e));if(0===a.length)return null;let i=0,s=a.slice(0,t).map(e=>{let t=e.lifecycle?.status,r=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+i++,role:"annotation",level:3,label:`${vi(Sa(e))}${r}.`,datum:e}});a.length>t&&s.push({id:"annotation-"+i++,role:"annotation",level:3,label:`…and ${a.length-t} more annotations.`});let o=a.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===o?"one marked feature":o+" marked features"}.`,children:s}}function ki(e,t,r={}){let a=r.locale??"en",i=Math.max(1,r.maxLeaves??200),s=Ca(a),o=Ft(e,t,r.recipe);if(o)return _a(o,t,{maxLeaves:i,locale:a});let n={id:"root",role:"chart",label:Pa(e,t,{locale:a}).text||"Chart.",level:1,children:[]},l=bi(t,i);if(Hc.has(e)){let r=gi(e,t,i,s);return mi(r,l),r}if(Yc.has(e)){let r=Za(e,t,i,s);return mi(r,l),r}if(Qc.has(e)){let r=ci(e,t,i,s);return mi(r,l),r}let c=Array.isArray(t.data)?t.data:null,d=di(e,t,r);if(!c||0===c.length||!d)return l&&(n.children=[l]),n;let{measure:u,measureFallback:p,dimension:f,dimensionFallback:h}=Zr(e,t),y=Yr(u,p),m=Qr(f,h),g="string"==typeof u&&u?u:p,v="string"==typeof f&&f?f:h,b=Kr(t),k=0,x=e=>`${e}-${k++}`,C=(e,t)=>{let r=y(e),a=Xr(m(e),s);return{id:x("datum"),role:"datum",level:t,label:`${a}: ${Number.isFinite(r)?s(r):"—"}`,value:Number.isFinite(r)?r:void 0,datum:e}},A=(e,t)=>{let r=e.slice(0,i).map(e=>C(e,t));return e.length>i&&r.push({id:x("more"),role:"datum",level:t,label:`…and ${e.length-i} more points`}),r},w=[];if(Lc.has(e)||Mc.has(e)){let t=1/0,r=-1/0,a=1/0,i=-1/0,o=[],n=!0;for(let e of c){let s=y(e);Number.isFinite(s)&&(t>s&&(t=s),s>r&&(r=s));let l=m(e);o.push(l),"number"==typeof l&&Number.isFinite(l)?(a>l&&(a=l),l>i&&(i=l)):n=!1}let l=/* @__PURE__ */new Set,d=[];for(let e of o){let t=e+"";l.has(t)||(l.add(t),d.push(e))}let u=n?`${s(a)} to ${s(i)}`:`${Xr(d[0],s)} to ${Xr(d[d.length-1],s)} (${Mc.has(e)?d.length+" categories":c.length+" points"})`;w.push({id:x("axis"),role:"axis",level:2,label:`${Mc.has(e)?"Category axis":"X axis"}: ${v}, ${u}.`}),r>=t&&w.push({id:x("axis"),role:"axis",level:2,label:`Value axis: ${g}, ${s(t)} to ${s(r)}.`})}if(b){let r=Qr(b,b),i=/* @__PURE__ */new Map;for(let e of c){let t=(r(e)??"—")+"",a=i.get(t);a?a.push(e):i.set(t,[e])}let s=[];for(let[r,o]of i){let i=Pa(e,{...t,data:o},{levels:["l2","l3"],locale:a}).text;s.push({id:x("series"),role:"series",level:2,label:`Series ${r}: ${i}`,children:A(o,3)})}n.children=[...w,...s]}else n.children=[...w,...A(c,2)];return l&&n.children.push(l),n}function xi(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Ci(e){return xi(e)?e:void 0}function Ai(e){let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function wi(e){let t=Ai(e);return null==t?void 0:Math.max(0,Math.floor(t))}function $i(...e){return e.map(Ci).find(Boolean)}function Si(...e){return e.find(Array.isArray)}function Bi(e){let t={};for(let[r,a]of Object.entries(e))void 0!==a&&(t[r]=a);return t}function Pi(e,t,r){return e["string"==typeof t&&t?t:r]}function Wi(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function Li(e,t,r){let a=[];if("GaugeChart"===e){"number"==typeof t.value&&Number.isFinite(t.value)&&a.push(`Current value is ${Wi(t.value)}.`);let 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 ${Wi(e)} to ${Wi(r)}.`)}if("SankeyDiagram"===e||"ProcessSankey"===e){let i=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 ${Wi(t.domain[0])} to ${Wi(t.domain[1])}.`),i.length>0){a.push(`${i.length} source flow${1===i.length?"":"s"} are supplied.`);for(let s of i.slice(0,r)){let r=Pi(s,t.sourceAccessor,"source"),i=Pi(s,t.targetAccessor,"target"),o=Pi(s,t.valueAccessor,"value");a.push("ProcessSankey"!==e||null==s.startTime&&null==s.endTime?`${Wi(r)} to ${Wi(i)} has value ${Wi(o)}.`:`${Wi(r)} to ${Wi(i)} has value ${Wi(o)} over ${Wi(s.startTime)}–${Wi(s.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){let e=Ci(t.data),i="string"==typeof t.childrenAccessor&&t.childrenAccessor?t.childrenAccessor:"children",s="string"==typeof t.valueAccessor&&t.valueAccessor?t.valueAccessor:"value",o="string"==typeof t.nodeIdAccessor&&t.nodeIdAccessor?t.nodeIdAccessor:"string"==typeof t.nodeIDAccessor&&t.nodeIDAccessor?t.nodeIDAccessor:"name",n=[],l=e=>{let t=Array.isArray(e[i])?e[i]:[];if(0!==t.length)for(let e of t){let t=Ci(e);t&&l(t)}else n.push(e)};if(e&&l(e),n.length>0){a.push(n.length+" hierarchy leaves are supplied.");for(let e of n.slice(0,r))a.push(`${Wi(e[o])} has value ${Wi(e[s])}.`)}}if(Zc.has(e)&&Array.isArray(t.data)){let r=t.data;a.push(`${r.length} observed source row${1===r.length?"":"s"} are supplied.`);let i="CollisionSwarmChart"===e?t.xAccessor:t.valueAccessor,s="CollisionSwarmChart"===e?"x":"value",o=r.map(e=>Ai(Pi(e,i,s))).filter(e=>null!=e);o.length>0&&a.push(`Observed ${"string"==typeof i?i:s} ranges from ${Wi(Math.min(...o))} to ${Wi(Math.max(...o))}.`)}if(0!==a.length)return{source:"chart-props",statements:a,text:"Exact chart-prop facts: "+a.join(" ")}}function Mi(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Ri(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function Ii(e,t,r,a){let i=Ci(e.settledProjection),s=Ci(t?.settledProjection);return Si(r?.projectionRows,r?.aggregates,e.settledProjectionRows,e.projectionRows,i?.rows,t?.settledProjectionRows,t?.projectionRows,s?.rows,a?.binCounts)}function Ei(e){if(!e||0===e.length)return;let t=e.map((e,t)=>{let r=Ci(e);if(!r)return;let a=Ai(r.count??r.value??r.total??r.bodies??r.events);if(null==a)return;let i=(r.label??r.id??r.name??"container "+(t+1))+"",s=null==r.id?void 0:r.id+"",o=Ai(r.secondary??r.secondaryCount),n=Ai(r.observed??r.observedCount);return Bi({id:s,label:i,count:a,secondary:o,secondaryLabel:"string"==typeof r.secondaryLabel?r.secondaryLabel:void 0,observed:n})}).filter(e=>null!=e);if(0===t.length)return;let r=t.reduce((e,t)=>e+t.count,0),a=t.filter(e=>e.count>0).length,i=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:r,populatedCount:a,...i?{leader:i}:{}}}function Ni(e,t){let r=e?.map((e,t)=>{let r=Ci(e);if(!r)return;let a=Ai(r.count)??0,i=Ai(r.total),s={label:(r.label??r.id??"sediment "+(t+1))+"",count:a};return null!=r.id&&(s.id=r.id+""),null!=i&&(s.total=i),s}).filter(e=>null!=e),a=wi(t?.bins)??r?.length??0,i=Ai(t?.count)??r?.reduce((e,t)=>e+t.count,0)??0,s=Ai(t?.total)??r?.reduce((e,t)=>e+(t.total??0),0),o=r?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==a||0!==i||s)return{bins:a,count:i,...null!=s&&s>0?{total:s}:{},...o?{leader:o}:{}}}function Ti(e){let t=Ci(e);return!!t&&(xi(t.world)||"simulationState"in t||"liveBodyOrder"in t)}function Fi(e){if(e)return e.filter(e=>!0===Ci(e)?.sleeping).length}function Oi(e,t,r){let a=e?.filter(e=>!0===Ci(e)?.sensor).length,i=Ci(t?.observation),s=Ci(i?.sensors),o=Si(r?.activeSensors);return Math.max(a??0,s?Object.keys(s).length:0,o?.length??0)||void 0}function ji(e){let t=[],r=e.simulation,a=[r.state??(r.settled?"settled":void 0),null!=r.liveBodies?`${r.liveBodies} live ${Mi(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 "+Ri(r.seed):void 0,r.gravity?`gravity (${Ri(r.gravity.x)}, ${Ri(r.gravity.y)})`:void 0,null!=r.fixedDt?`fixed step ${Ri(r.fixedDt)}s`:void 0,null!=r.timeScale?Ri(r.timeScale)+"x time":void 0].filter(Boolean);a.length>0&&t.push(`Physics simulation: ${a.join("; ")}.`);let i=e.geometry;if(i){let e=[null!=i.colliders?`${i.colliders} ${Mi(i.colliders,"collider")}`:void 0,null!=i.sensors?`${i.sensors} ${Mi(i.sensors,"sensor")}`:void 0,null!=i.springs?`${i.springs} ${Mi(i.springs,"spring")}`:void 0,null!=i.activeSensorPairs?`${i.activeSensorPairs} active sensor ${Mi(i.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}let s=e.aggregates;if(s){let e=s.leader,r=e?` Largest is ${e.label} with ${Ri(e.count)}.`:"";t.push(`Physics aggregates: ${Ri(s.totalCount)} settled ${Mi(s.totalCount,"body")} across ${s.rows.length} ${Mi(s.rows.length,"container")}; ${s.populatedCount} populated.${r}`)}let o=e.sediment;if(o){let e=null!=o.total?", value total "+Ri(o.total):"",r=o.leader?`; largest sediment bin is ${o.leader.label} with ${Ri(o.leader.count)}`:"";t.push(`Physics sediment: ${o.count} retained ${Mi(o.count,"body")} in ${o.bins} ${Mi(o.bins,"bin")}${e}${r}.`)}return t.join(" ")}function Di(e,t,r){if(!1===r)return;let a=xi(r)?r:void 0,i=Ci(t.physics),s=$i(a?.snapshot,i?.snapshot,t.physicsSnapshot,Ti(t.snapshot)?t.snapshot:void 0),o=$i(a?.evidence,i?.evidence,t.physicsEvidence,t.settledEvidence),n=$i(a?.config,i?.config,s?.config,t.config),l=$i(Ci(s?.world),Ci(i?.world)),c=$i(Ci(n?.kernel),Ci(l?.options)),d=Si(l?.bodies),u=Si(l?.colliders,n?.colliders),p=Si(s?.queue,i?.queue),f=Si(s?.liveBodyOrder),h=Si(l?.springs),y=Si(s?.activeSensorPairs),m=Ei(Ii(t,i,a,o)),g=Ni(Si(a?.sediment,i?.sediment,s?.sediment),$i(a?.sedimentTotals,i?.sedimentTotals)),v=f?.length??d?.length??wi(o?.bodyCount),b=Fi(d)??wi(o?.sleepingCount),k=p?.length,x="string"==typeof s?.simulationState?s.simulationState:void 0,C="boolean"==typeof o?.settled?o.settled:x?"settled"===x:null!=v||null!=b||null!=k?null!=v&&b===v&&0===(k??0):void 0,A=Ci(c?.gravity),w=Ai(A?.x),$=Ai(A?.y),S=Bi({state:x,settled:C,elapsedSeconds:Ai(s?.elapsedSeconds),paused:"boolean"==typeof s?.paused?s.paused:void 0,visible:"boolean"==typeof s?.visible?s.visible:void 0,seed:Ai(c?.seed),gravity:null!=w&&null!=$?{x:w,y:$}:void 0,fixedDt:Ai(n?.fixedDt??c?.fixedDt),timeScale:Ai(n?.timeScale),maxSubsteps:wi(n?.maxSubsteps),liveBodies:v,sleepingBodies:b,queued:k,bodyLimit:Ai(n?.bodyLimit),eviction:"string"==typeof n?.eviction?n.eviction:void 0}),B=Bi({colliders:u?.length,sensors:Oi(u,n,l),springs:h?.length,activeSensorPairs:y?.length}),P=Object.keys(B).length>0,W=Zc.has(e);if(!(Object.keys(S).length>0||P||m||g)||!W&&null==r)return;let L={simulation:S,...P?{geometry:B}:{},...m?{aggregates:m}:{},...g?{sediment:g}:{}},M=ji(L);return{...L,text:M}}function _i(e){return e?"fits"in e||"buildProps"in e?{family:e.family}:{family:e.family,intentScores:e.intentScores}:{}}function zi(e,t,r={}){let a,{capability:i,audience:s,locale:o}=r,n=r.levels??["l1","l2","l3"],l=!1!==r.includeStructure,c=ka(e,i),d=Pa(e,t,{levels:c?[...n,"l4"]:n,locale:o,capability:i,audience:s}),{l4:u,...p}=d.levels,f=["l1","l2","l3"].map(e=>d.levels[e]).filter(Boolean).join(" "),h={levels:p,text:d.annotations?`${d.annotations} ${f}`.trim():f,...d.annotations?{annotations:d.annotations}:{}};if(c&&u){let e=_i(i);a={act:c,sentence:u,family:e.family,intentScores:e.intentScores}}let y=l?ki(e,t,{maxLeaves:r.maxLeaves,locale:o}):void 0,m=Di(e,t,r.physics),g=Li(e,t,Math.max(1,r.maxLeaves??200)),v=[h.text,a?.sentence,m?.text,g?.text].filter(Boolean).join(" ");return{component:e,description:h,intent:a,structure:y,physics:m,facts:g,text:v}}function Ui(e){return null==e?[]:Array.isArray(e)?e:[e]}function Gi(e){if("string"==typeof e)return e;try{return JSON.stringify(e,null,2)??e+""}catch{return e+""}}function Vi(e,t){return null==t?e.findings:e.findings.slice(0,Math.max(0,t))}function qi(...e){for(let t of e){let e=t?.trim();if(e)return e}return"Review this finding."}function Hi(e){return qi(e.remediation,e.explanation,e.evidence,e.condition)}function Yi(e){return qi(e.name,e.ruleId)}function Qi(e){return"error"===e?"error":"warning"===e?"warning":"info"===e?"info":"neutral"}function Zi(e,t){return e.domain?`${t} · ${e.domain}`:t}function Ki(e,t){return t[e]??t.info??Kc.info}function Xi(e){return qi(e.ruleId,e.name)}function Ji(e,t){return`${Xi(e)}:${t}`}function es(e){return"pitfall-"+(e+"").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function ts(e,t={},r=0,a={kind:"image",findings:[e]}){let i=t.sourcePrefix??"datapitfalls";return{id:Ji(e,r),level:Qi(e.severity),title:Yi(e),message:t.message?t.message(e,r,a):Hi(e),source:Zi(e,i),...void 0===t.dismissible?{}:{dismissible:t.dismissible}}}function rs(e,t={}){return Vi(e,t.max).map((r,a)=>ts(r,t,a,e))}function as(e,t={}){return{notifications:rs(e,t),meta:{count:e.findings.length,kind:e.kind}}}function is(e,t={},r=0,a={kind:"image",findings:[e]}){let i={...Kc,...t.palette};return{...t.anchorFor?.(e,r,a)??{},type:t.type??"label",title:Yi(e),label:Hi(e),wrap:t.wrap??240,color:Ki(e.severity,i),className:es(e.severity),emphasis:"error"===e.severity?"primary":"secondary",provenance:{author:"datapitfalls",authorKind:"watcher",source:"computed",basis:"llm-inference",stableId:e.ruleId},dataPitfall:{ruleId:e.ruleId,domain:e.domain,severity:e.severity,evidence:e.evidence??""}}}function ss(e,t={}){return Vi(e,t.max).map((r,a)=>is(r,t,a,e))}function os(e,t={}){return{annotations:ss(e,t),meta:{count:e.findings.length,kind:e.kind}}}function ns(e,t,r){return{role:e,artifact:{kind:"text",content:t,...r?{filename:r}:{}}}}function ls(e,t,r,a){return{role:e,artifact:{kind:"code",content:t,language:r,...a?{filename:a}:{}}}}function cs(e,t){return t.length>0?{role:e,artifact:{kind:"image",images:t}}:null}function ds(e,t){let r=t.diagnoses.filter(e=>"error"===e.severity).length,a=t.diagnoses.filter(e=>"warning"===e.severity).length,i=[e+": Semiotic diagnoseConfig report","ok: "+t.ok,"errors: "+r,"warnings: "+a];if(0===t.diagnoses.length)return i.push("","No Semiotic config issues detected."),i.join("\n");i.push("");for(let e of t.diagnoses)i.push(`[${e.severity}] ${e.code}: ${e.message}`),e.fix&&i.push("Fix: "+e.fix);return i.join("\n")}function us(e){return[e.component+": Semiotic reader grounding","",e.text,"\nStructured grounding JSON:\n```json",Gi(e),"```"].join("\n")}function ps(e,t,r={}){let a=[],i=!1!==r.includeConfig,s=!1!==r.includeJSX,o=!1!==r.includeGrounding,n=!1!==r.includeDiagnostics,l=!1!==r.includeAccessibility,c=r.filenamePrefix??e,d=Dr(e,t,r.config);r.context?.trim()&&a.push(ns("Analysis context",r.context.trim(),c+".context.md")),i&&a.push(ls("Semiotic chart config",Gi(d),"json",c+".semiotic-config.json")),s&&a.push(ls("Semiotic chart JSX",Vr(d),"jsx",c+".semiotic.jsx"));let u,p,f,h=cs("Rendered chart image",Ui(r.rendered?.image));return h&&a.push(h),r.rendered?.svg?.trim()&&a.push(ls("Rendered chart SVG",r.rendered.svg.trim(),"svg",c+".rendered.svg")),null!=r.rendered?.evidence&&a.push(ns("Semiotic render evidence",[e+": Semiotic render evidence","\n```json",Gi(r.rendered.evidence),"```"].join("\n"),c+".render-evidence.md")),o&&(u=zi(e,t,r.grounding),a.push(ns("Semiotic reader grounding",us(u),c+".reader-grounding.md"))),n&&(p=Rt(e,t),a.push(ns("Semiotic config diagnostics",ds(e,p),c+".diagnose-config.md"))),l&&(f=q(e,t,r.accessibility),a.push(ns("Semiotic accessibility audit",H(f),c+".accessibility.md"))),r.narrative?.trim()&&a.push(ns("Author narrative",r.narrative.trim(),c+".narrative.md")),r.additionalStages?.length&&a.push(...r.additionalStages),0===a.length&&a.push(ls("Semiotic chart config",Gi(d),"json",c+".semiotic-config.json")),{input:{kind:"chain",stages:a},config:d,...u?{grounding:u}:{},...p?{diagnosis:p}:{},...f?{accessibility:f}:{}}}function fs(e,t,r={}){return ps(e,t,r).input}function hs(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ys(e,t,r){("number"!=typeof r||!Number.isInteger(r)||1>r||r>5)&&e.push(t+" must be an integer in [1, 5]")}function ms(e,t,r){void 0!==r&&"string"!=typeof r&&e.push(t+" must be a string")}function gs(e,t,r,a,i){void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||void 0!==a&&a>r||void 0!==i&&r>i)&&e.push(`${t} must be a finite number${void 0!==a&&void 0!==i?` in [${a}, ${i}]`:void 0!==a?" >= "+a:""}`)}function vs(e,t,r){void 0!==r&&"boolean"!=typeof r&&e.push(t+" must be a boolean")}function bs(e,t,r,a){for(let i of Object.keys(r))a.includes(i)||e.push(`${t}.${i} is not allowed`)}function ks(e,t){void 0!==t&&"0.1"!==t&&e.push("specVersion must be the string 0.1")}function xs(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(e)&&!Number.isNaN(Date.parse(e))}function Cs(e){let t=[];if(!hs(e))return{valid:!1,errors:["capability must be an object"]};ks(t,e.specVersion),("string"!=typeof e.component||0===e.component.length)&&t.push("component is required and must be a non-empty string"),ms(t,"family",e.family),ms(t,"importPath",e.importPath);let r=e.rubric;if(hs(r)?(bs(t,"rubric",r,["familiarity","accuracy","precision"]),ys(t,"rubric.familiarity",r.familiarity),ys(t,"rubric.accuracy",r.accuracy),ys(t,"rubric.precision",r.precision)):t.push("rubric is required and must be an object"),void 0!==e.intentScores)if(hs(e.intentScores))for(let[r,a]of Object.entries(e.intentScores))gs(t,"intentScores."+r,a,0,5);else t.push("intentScores must be an object");if(void 0!==e.variants&&(Array.isArray(e.variants)?e.variants.forEach((e,r)=>{if(hs(e)){if("string"!=typeof e.key&&t.push(`variants[${r}].key is required`),"string"!=typeof e.label&&t.push(`variants[${r}].label is required`),ms(t,`variants[${r}].description`,e.description),void 0!==e.intentDeltas)if(hs(e.intentDeltas))for(let[a,i]of Object.entries(e.intentDeltas))gs(t,`variants[${r}].intentDeltas.${a}`,i);else t.push(`variants[${r}].intentDeltas must be an object`);if(void 0!==e.rubricDeltas)if(hs(e.rubricDeltas)){bs(t,`variants[${r}].rubricDeltas`,e.rubricDeltas,["familiarity","accuracy","precision"]);for(let a of["familiarity","accuracy","precision"])gs(t,`variants[${r}].rubricDeltas.${a}`,e.rubricDeltas[a])}else t.push(`variants[${r}].rubricDeltas must be an object`);for(let a of["caveats","tags"]){let i=e[a];void 0!==i&&(!Array.isArray(i)||i.some(e=>"string"!=typeof e))&&t.push(`variants[${r}].${a} must be an array of strings`)}void 0!==e.props&&!hs(e.props)&&t.push(`variants[${r}].props must be an object`)}else t.push(`variants[${r}] must be an object`)}):t.push("variants must be an array")),void 0!==e.mobile)if(hs(e.mobile)){let r=e.mobile;ms(t,"mobile.strategy",r.strategy),vs(t,"mobile.responsive",r.responsive),vs(t,"mobile.supportsResponsiveLayout",r.supportsResponsiveLayout);for(let e of["minViewportWidth","maxMarks","maxAnnotations","minimumHitTarget"])gs(t,"mobile."+e,r[e],0);void 0!==r.breakpoints&&(Array.isArray(r.breakpoints)?r.breakpoints.forEach((e,r)=>{gs(t,`mobile.breakpoints[${r}]`,e)}):t.push("mobile.breakpoints must be an array")),void 0!==r.summary&&"boolean"!=typeof r.summary&&"string"!=typeof r.summary&&t.push("mobile.summary must be a boolean or string"),void 0!==r.interaction&&(hs(r.interaction)?(ms(t,"mobile.interaction.primary",r.interaction.primary),ms(t,"mobile.interaction.hoverFallback",r.interaction.hoverFallback),gs(t,"mobile.interaction.targetSize",r.interaction.targetSize,0),void 0!==r.interaction.alternatives&&(!Array.isArray(r.interaction.alternatives)||r.interaction.alternatives.some(e=>"string"!=typeof e))&&t.push("mobile.interaction.alternatives must be an array of strings")):t.push("mobile.interaction must be an object")),void 0!==r.labels&&(hs(r.labels)?(ms(t,"mobile.labels.strategy",r.labels.strategy),gs(t,"mobile.labels.minFontSize",r.labels.minFontSize,0)):t.push("mobile.labels must be an object")),void 0!==r.custom&&(hs(r.custom)?(vs(t,"mobile.custom.dataBearingSceneNodes",r.custom.dataBearingSceneNodes),vs(t,"mobile.custom.stableIds",r.custom.stableIds),ms(t,"mobile.custom.navigationGranularity",r.custom.navigationGranularity)):t.push("mobile.custom must be an object"))}else t.push("mobile must be an object");for(let r of["caveats","tags"]){let a=e[r];void 0!==a&&(!Array.isArray(a)||a.some(e=>"string"!=typeof e))&&t.push(r+" must be an array of strings")}return{valid:0===t.length,errors:t}}function As(e){let t=[];if(!hs(e))return{valid:!1,errors:["audience profile must be an object"]};if(ks(t,e.specVersion),ms(t,"name",e.name),void 0!==e.familiarity)if(hs(e.familiarity))for(let[r,a]of Object.entries(e.familiarity))("number"!=typeof a||!Number.isInteger(a)||1>a||a>5)&&t.push(`familiarity.${r} must be an integer in [1, 5]`);else t.push("familiarity must be an object");if(void 0!==e.targets)if(hs(e.targets))for(let[r,a]of Object.entries(e.targets))!hs(a)||"increase"!==a.direction&&"decrease"!==a.direction?t.push(`targets.${r}.direction must be "increase" or "decrease"`):(bs(t,"targets."+r,a,["direction","weight","reason"]),void 0!==a.weight&&("number"!=typeof a.weight||!Number.isInteger(a.weight)||1>a.weight||a.weight>3)&&t.push(`targets.${r}.weight must be an integer in [1, 3]`),ms(t,`targets.${r}.reason`,a.reason));else t.push("targets must be an object");return void 0!==e.exposureLevel&&("number"!=typeof e.exposureLevel||!Number.isInteger(e.exposureLevel)||![0,1,2].includes(e.exposureLevel))&&t.push("exposureLevel must be 0, 1, or 2"),void 0!==e.receptionModality&&!ad.has(e.receptionModality)&&t.push("receptionModality must be one of "+[...ad].join(", ")),{valid:0===t.length,errors:t}}function ws(e){let t=[];if(!hs(e))return{valid:!1,errors:["annotation must be an object"]};let r=e.provenance;if(void 0!==r)if(hs(r)){for(let e of["author","authorKind","source","basis","dataVersion","stableId"])ms(t,"provenance."+e,r[e]);gs(t,"provenance.confidence",r.confidence,0,1),void 0!==r.createdAt&&("string"!=typeof r.createdAt||!xs(r.createdAt))&&t.push("provenance.createdAt must be an ISO 8601 date-time string")}else t.push("provenance must be an object");let a=e.lifecycle;return void 0!==a&&(hs(a)?(void 0!==a.freshness&&!ed.has(a.freshness)&&t.push("lifecycle.freshness must be one of "+[...ed].join(", ")),void 0!==a.status&&!td.has(a.status)&&t.push("lifecycle.status must be one of "+[...td].join(", ")),void 0!==a.anchor&&!rd.has(a.anchor)&&t.push("lifecycle.anchor must be one of "+[...rd].join(", ")),ms(t,"lifecycle.supersedes",a.supersedes),void 0!==a.ttlHint&&"string"!=typeof a.ttlHint&&("number"!=typeof a.ttlHint||!Number.isFinite(a.ttlHint))&&t.push("lifecycle.ttlHint must be an ISO 8601 duration string or a number of milliseconds")):t.push("lifecycle must be an object")),{valid:0===t.length,errors:t}}function $s(e){let t=e;return{adapter:"semiotic/idid-capability-binding",direction:"import",sourceFormat:"idid-chart-capability",targetFormat:"semiotic-chart-capability",specVersion:"string"==typeof t?.specVersion?t.specVersion:"0.1"}}function Ss(e,t){return{status:"refused",diagnostics:t,lossReport:t.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:$s(e)}}function Bs(e){return{key:e.key,label:e.label,props:{...e.props??{}},...void 0!==e.description?{description:e.description}:{},...void 0!==e.intentDeltas?{intentDeltas:{...e.intentDeltas}}:{},...void 0!==e.rubricDeltas?{rubricDeltas:{...e.rubricDeltas}}:{},...void 0!==e.caveats?{caveats:[...e.caveats]}:{},...void 0!==e.tags?{tags:[...e.tags]}:{}}}function Ps(e){let t={};if(void 0!==e.strategy&&(t.strategy=e.strategy),void 0!==e.responsive&&(t.responsive=e.responsive),void 0!==e.supportsResponsiveLayout&&(t.supportsResponsiveLayout=e.supportsResponsiveLayout),void 0!==e.breakpoints&&(t.breakpoints=[...e.breakpoints]),void 0!==e.minViewportWidth&&(t.minViewportWidth=e.minViewportWidth),void 0!==e.maxMarks&&(t.maxMarks=e.maxMarks),void 0!==e.maxAnnotations&&(t.maxAnnotations=e.maxAnnotations),void 0!==e.minimumHitTarget&&(t.minimumHitTarget=e.minimumHitTarget),void 0!==e.summary&&(t.summary=e.summary),void 0!==e.interaction){let r={};void 0!==e.interaction.primary&&(r.primary=e.interaction.primary),void 0!==e.interaction.alternatives&&(r.alternatives=[...e.interaction.alternatives]),void 0!==e.interaction.hoverFallback&&(r.hoverFallback=e.interaction.hoverFallback),void 0!==e.interaction.targetSize&&(r.targetSize=e.interaction.targetSize),t.interaction=r}return void 0!==e.labels&&(t.labels={...e.labels}),void 0!==e.custom&&(t.custom={...e.custom}),t}function Ws(e,t){let r=t.caveats?[...t.caveats]:[];if(e.caveats||0!==r.length)return t=>{let a=e.caveats?Array.from(e.caveats(t)):[];return[.../* @__PURE__ */new Set([...a,...r])]}}function Ls(e,t){let r=Cs(e);if(!r.valid)return Ss(e,r.errors.map(e=>({code:"INVALID_PORTABLE_CAPABILITY",severity:"error",message:e})));let a=e;if(!t)return Ss(e,[{code:"HOST_CAPABILITY_NOT_FOUND",severity:"error",path:"/component",message:`No host capability is registered for "${a.component}". Resolve or register the renderer's executable capability before binding portable metadata.`}]);if(a.component!==t.component)return Ss(e,[{code:"CAPABILITY_COMPONENT_MISMATCH",severity:"error",path:"/component",message:`Portable component "${a.component}" cannot bind to host component "${t.component}".`}]);let i=Ws(t,a);return{status:"success",capability:{...t,rubric:{...a.rubric},intentScores:a.intentScores?{...a.intentScores}:{...t.intentScores},variants:a.variants?.map(Bs),...i?{caveats:i}:{caveats:void 0},...void 0!==a.mobile?{mobile:Ps(a.mobile)}:{},portableDescriptor:a},diagnostics:[],lossReport:[],provenance:$s(e)}}function Ms(e){return{field:e,type:"quantitative"}}function Rs(e){return{field:e,type:"nominal"}}function Is(e){return"time"===e.xScaleType?"temporal":"quantitative"}function Es(e,t){return"string"==typeof t&&(e.axis={title:t}),e}function Ns(e,t){let r=[];for(let a of sd[e]||[])("string"!=typeof t[a]||0===t[a].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+a,message:`${e} requires a string ${a} for Vega-Lite export.`});for(let a of od[e]||[])void 0!==t[a]&&("string"!=typeof t[a]||0===t[a].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+a,message:`${e} can export ${a} only as a non-empty string field name.`});return r}function Ts(e,t={}){let r=[],a={adapter:"semiotic/vega-lite",direction:"export",sourceFormat:"semiotic-chart-config",targetFormat:"vega-lite",..."string"==typeof e.version?{specVersion:e.version}:{}},i=e.props||{},s=Ns(e.component,i);if(s.length>0)return{status:"refused",diagnostics:s,lossReport:s.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:a};let o,n={},l=e.component;switch(l){case"BarChart":case"StackedBarChart":case"GroupedBarChart":{o="bar";let e="horizontal"===i.orientation,t=Es(Rs(i.categoryAccessor),i.categoryLabel),a=Es(Ms(i.valueAccessor),i.valueLabel);e?(n.y=t,n.x=a):(n.x=t,n.y=a),"StackedBarChart"===l&&i.stackBy?n.color=Rs(i.stackBy):"GroupedBarChart"===l&&i.groupBy&&(n.color=Rs(i.groupBy),r.push({code:"GROUPED_BAR_APPROXIMATION",path:"/props/groupBy",message:"GroupedBarChart maps groupBy to color; Vega-Lite needs xOffset for an exact grouped layout."}));break}case"LineChart":o=i.curve||i.showPoints?{type:"line"}:"line","object"==typeof o&&(i.curve&&id[i.curve]&&(o.interpolate=id[i.curve]),i.showPoints&&(o.point=!0)),n.x=Es({field:i.xAccessor,type:Is(i)},i.xLabel),n.y=Es(Ms(i.yAccessor),i.yLabel),i.lineBy?n.color=Rs(i.lineBy):i.colorBy&&(n.color=Rs(i.colorBy));break;case"AreaChart":case"StackedAreaChart":o=i.curve?{type:"area"}:"area","object"==typeof o&&i.curve&&id[i.curve]&&(o.interpolate=id[i.curve]),"object"==typeof o&&void 0!==i.areaOpacity&&(o.opacity=i.areaOpacity),n.x=Es({field:i.xAccessor,type:Is(i)},i.xLabel),n.y=Es(Ms(i.yAccessor),i.yLabel),"StackedAreaChart"===l&&i.areaBy&&(n.color=Rs(i.areaBy));break;case"Scatterplot":case"BubbleChart":o="point",n.x=Es(Ms(i.xAccessor),i.xLabel),n.y=Es(Ms(i.yAccessor),i.yLabel),i.colorBy&&(n.color=Rs(i.colorBy)),"BubbleChart"===l&&i.sizeBy&&(n.size=Ms(i.sizeBy),Array.isArray(i.sizeRange)&&(n.size.scale={range:i.sizeRange}));break;case"Heatmap":o="rect",n.x=Es(Rs(i.xAccessor),i.xLabel),n.y=Es(Rs(i.yAccessor),i.yLabel),i.valueAccessor&&(n.color=Ms(i.valueAccessor));break;case"PieChart":case"DonutChart":o="DonutChart"===l?{type:"arc",innerRadius:i.innerRadius??60}:"arc",i.valueAccessor&&(n.theta=Ms(i.valueAccessor)),i.categoryAccessor&&(n.color=Rs(i.categoryAccessor));break;case"DotPlot":{o="tick";let e="horizontal"===i.orientation,t=Es(Rs(i.categoryAccessor),i.categoryLabel),r=Es(Ms(i.valueAccessor),i.valueLabel);e?(n.y=t,n.x=r):(n.x=t,n.y=r);break}case"Histogram":o="bar",i.valueAccessor&&(n.x=Es(Ms(i.valueAccessor),i.valueLabel),n.x.bin=!i.bins||{maxbins:i.bins},n.y={aggregate:"count",type:"quantitative"}),i.categoryAccessor&&(n.color=Rs(i.categoryAccessor));break;default:{let e=`Component "${l}" has no supported Vega-Lite single-view equivalent.`;return{status:"refused",diagnostics:[{code:"UNSUPPORTED_COMPONENT",severity:"error",path:"/component",message:e}],lossReport:[{code:"UNSUPPORTED_COMPONENT",path:"/component",message:e}],provenance:a}}}i.colorScheme&&n.color&&(n.color.scale={...n.color.scale||{},scheme:i.colorScheme});let c={mark:o};return Array.isArray(i.data)&&(c.data={values:i.data}),Object.keys(n).length>0&&(c.encoding=n),"string"==typeof i.title&&(c.title=i.title),"number"==typeof i.width&&(c.width=i.width),"number"==typeof i.height&&(c.height=i.height),r.length>0&&!t.allowLossy?{status:"refused",diagnostics:r.map(({code:e,message:t,path:r})=>({code:e,severity:"error",message:t,path:r})),lossReport:r,provenance:a}:{status:r.length>0?"lossy":"success",spec:c,artifact:c,diagnostics:r.map(({code:e,message:t,path:r})=>({code:e,severity:"warning",message:t,path:r})),lossReport:r,provenance:a}}function Fs(e,t){return Ts(e,t).spec}function Os(e,t){let r={...js(e),specVersion:"0.1"};return void 0!==t.capability&&(r.capability=t.capability),void 0!==t.audience&&(r.audience=t.audience),{...e,usermeta:{...e.usermeta,idid:r}}}function js(e){return e.usermeta?.idid}function Ds(e,t){let r={...js(e),specVersion:"0.1",annotations:[...t]},a=t.map(Us).filter(e=>null!==e).map(e=>({...e,usermeta:{idid:{role:"annotation-layer"}}}));if(0===a.length)return{...e,usermeta:{...e.usermeta,idid:r}};let i=Array.isArray(e.layer)?e.layer:[zs(e)],{mark:s,encoding:o,data:n,transform:l,usermeta:c,...d}=e;return{...d,usermeta:{...e.usermeta,idid:r},layer:[...i,...a]}}function _s(e){let t=js(e)?.annotations;return Array.isArray(t)?t:[]}function zs(e){let{mark:t,encoding:r,data:a,transform:i}=e,s={};return t&&(s.mark=t),r&&(s.encoding=r),a&&(s.data=a),i&&(s.transform=i),s}function Us(e){let t=e;switch(t.type){case"y-threshold":return{mark:"rule",encoding:{y:{datum:t.value}}};case"x-threshold":return{mark:"rule",encoding:{x:{datum:t.value}}};case"callout":case"label":case"text":return"string"==typeof t.label?{mark:{type:"text",text:t.label}}:null;default:return null}}function Gs(e,t){let{groupBy:r,value:a,agg:i="sum"}=t,s=/* @__PURE__ */new Map,o="min"===i?1/0:"max"===i?-1/0:0;for(let t of e){let e=t[r]+"",n=s.get(e);n||(n={total:o,count:0},s.set(e,n));let l=Number(t[a]);switch(n.count++,i){case"count":break;case"min":n.total>l&&(n.total=l);break;case"max":l>n.total&&(n.total=l);break;default:n.total+=l}}let n=[];for(let[e,t]of s){let a="count"===i?t.count:"mean"===i?t.total/t.count:t.total;n.push({[r]:e,value:a})}return n}function Vs(e){if(!e)return{type:"",markProps:{}};if("string"==typeof e)return{type:e,markProps:{}};let{type:t,...r}=e;return{type:t,markProps:r}}function qs(e){if(e)return"string"==typeof e?e:e.text}function Hs(e){return"nominal"===e||"ordinal"===e}function Ys(e){return"quantitative"===e||"temporal"===e}function Qs(e){return e.usermeta?.idid}function Zs(e){return"annotation-layer"===e.usermeta?.idid?.role}function Ks(e){if(!Qs(e)||!Array.isArray(e.layer))return e;let t=e.layer.filter(e=>!Zs(e));if(1!==t.length)return e;let{layer:r,...a}=e,{usermeta:i,...s}=t[0];return{...a,...s}}function Xs(e){let t=e,r=Ks(e),a=r,i=[];if(Array.isArray(t.layer)&&r===e&&i.push({code:"UNSUPPORTED_COMPOSITION",severity:"error",path:"/layer",message:"Only the single base view in an IDID-enriched annotation layer can be imported."}),void 0===a.mark)i.push({code:"MISSING_MARK",severity:"error",path:"/mark",message:"A Vega-Lite spec needs a supported single-view mark."});else{let{type:e}=Vs(a.mark);
2
+ function e(e){if(!e)return{};let t={};return void 0!==e.fill&&(t.fill=e.fill),void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.strokeDasharray&&(t.strokeDasharray=e.strokeDasharray),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.fillOpacity&&(t.fillOpacity=e.fillOpacity),void 0!==e.filter&&(t.filter=e.filter),void 0!==e.mixBlendMode&&(t.style={mixBlendMode:e.mixBlendMode}),t}function t(e){let t=e.match(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi);if(!t||2>t.length)return null;let r=1/0,a=1/0,i=-1/0,s=-1/0;for(let e=0;t.length>e+1;e+=2){let o=parseFloat(t[e]),n=parseFloat(t[e+1]);Number.isFinite(o)&&(r=Math.min(r,o),i=Math.max(i,o)),Number.isFinite(n)&&(a=Math.min(a,n),s=Math.max(s,n))}return Number.isFinite(r)&&Number.isFinite(a)?{x:r,y:a,w:i-r,h:s-a}:null}function r(e){let t=e.fontSize??12,r=Math.max(1,(e.text+"").length*t*.6),a=e.textAnchor??"start";return{x:"middle"===a?e.x-r/2:"end"===a?e.x-r:e.x,y:e.y-t,w:r,h:1.2*t}}function a(e){switch(e.kind){case"rect":case"image":return{x:e.x,y:e.y,w:e.w,h:e.h};case"ellipse":return{x:e.cx-e.rx,y:e.cy-e.ry,w:2*e.rx,h:2*e.ry};case"path":return t(e.d);case"text":return r(e);case"composite":case"mask":return e.bbox;case"group":return null}}function i(e,t){return{x:e.x*t.sx+t.tx,y:e.y*t.sy+t.ty,w:e.w*t.sx,h:e.h*t.sy}}function s(e,t){let[r=0,a=0]=t.translate??[],[i=1,s=1]=t.scale??[];return{tx:e.tx+r*e.sx,ty:e.ty+a*e.sy,sx:e.sx*i,sy:e.sy*s}}function o(e){if(null!=e.datum)return e.datum;let t;if("group"===e.kind?t=e.children:"composite"===e.kind?t=[...e.source,...e.dest]:"mask"===e.kind&&(t=[...e.mask,...e.content]),t)for(let e of t){let t=o(e);if(null!=t)return t}}function n(e){return null==e?null:Array.isArray(e)?0===e.length?null:1===e.length?e[0]:{...e[0],_rows:e}:e}function l(t,r,a){let i=e(t.style);switch(t.kind){case"rect":return Un("rect",{key:r,x:t.x,y:t.y,width:t.w,height:t.h,...void 0!==t.rx?{rx:t.rx}:{},...void 0!==t.ry?{ry:t.ry}:{},...i});case"ellipse":return Un("ellipse",{key:r,cx:t.cx,cy:t.cy,rx:t.rx,ry:t.ry,...i});case"path":return Un("path",{key:r,d:t.d,...i});case"text":return Un("text",{key:r,x:t.x,y:t.y,...void 0!==t.fontSize?{fontSize:t.fontSize}:{},...void 0!==t.fontFamily?{fontFamily:t.fontFamily}:{},...void 0!==t.textAnchor?{textAnchor:t.textAnchor}:{},...void 0!==t.dominantBaseline?{dominantBaseline:t.dominantBaseline}:{},...void 0!==t.rotate?{transform:`rotate(${t.rotate} ${t.x} ${t.y})`}:{},...i},t.text);case"image":return Un("image",{key:r,x:t.x,y:t.y,width:t.w,height:t.h,href:t.href,...void 0!==t.preserveAspectRatio?{preserveAspectRatio:t.preserveAspectRatio}:{},...i});case"group":{let e=[];return t.transform.translate&&e.push(`translate(${t.transform.translate[0]} ${t.transform.translate[1]})`),t.transform.scale&&e.push(`scale(${t.transform.scale[0]} ${t.transform.scale[1]})`),Un("g",{key:r,...e.length?{transform:e.join(" ")}:{},...i},t.children.map((e,t)=>l(e,`${r}-${t}`,a)))}case"composite":case"mask":return c(t,r,a)}}function c(e,t,r){let a="gf-comp-"+r.compositeId++,i=a+"-source",s=a+"-destination";if("mask"===e.kind){let o=a+"-mask";return Un(Gn,{key:t},Un("defs",null,Un("g",{id:i},e.mask.map((e,t)=>l(e,`${o}-m-${t}`,r))),Un("g",{id:s},e.content.map((e,t)=>l(e,`${o}-c-${t}`,r))),Un("mask",{id:o,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse"},Un("use",{href:"#"+i}))),Un("use",{href:"#"+s,mask:`url(#${o})`}))}let{x:o,y:n,w:c,h:d}=e.bbox,u=`translate(${o} ${n})`,p=e.blendMode,f="atop"===e.operator||"in"===e.operator,h=a+"-desat",y=a+"-cov",m=e.source.map((e,t)=>l(e,`${a}-s-${t}`,r)),g=e.dest.map((e,t)=>l(e,`${a}-d-${t}`,r)),v=[];return p&&v.push(Un("filter",{key:"desat",id:h},Un("feColorMatrix",{type:"saturate",values:"0"}))),f&&v.push(Un("mask",{key:"cov",id:y,maskUnits:"userSpaceOnUse",x:o,y:n,width:c,height:d,style:{maskType:"alpha"}},Un("g",{transform:u},e.source.map((e,t)=>l(e,`${a}-m-${t}`,r))))),Un(Gn,{key:t},v.length?Un("defs",{key:"defs"},v):null,Un("g",{key:"g",...f?{mask:`url(#${y})`}:{}},Un("g",{transform:u,style:{isolation:"isolate"}},Un("g",p?{filter:`url(#${h})`}:null,m),Un("g",p?{style:{mixBlendMode:p}}:null,g))))}function d(e,t,r,l){for(let c of e){if("group"===c.kind){d(c.children,s(t,c.transform),r,l);continue}let e=c.role??"node",u=n(o(c));if("node"!==e||!u||"text"===c.kind)continue;let p=a(c);if(!p)continue;let f=i(p,t);f.w>0&&f.h>0&&(r.push({type:"rect",x:f.x,y:f.y,w:f.w,h:f.h,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:u,id:c.id??"gofish-node-"+l.n}),l.n+=1)}}function u(e,t){for(let r of e){if("group"===r.kind){u(r.children,t);continue}if("node"!==(r.role??"node")||"text"===r.kind)continue;let e=n(o(r));e&&t.push(e)}}function p(e){return t=>{let r=t.config?.displayList??e,a=[];d(r.items,qn,a,{n:0});let i={compositeId:0};return{sceneNodes:a,overlays:Un("g",{className:"semiotic-gofish-displaylist","data-gofish-ir":r.ir},r.items.map((e,t)=>l(e,"gf-"+t,i)))}}}function f(e,t={}){let r=[];(!e||"gofish-display-list"!==e.ir)&&r.push(`Expected a "gofish-display-list" document (the output of GoFish's toDisplayList) but got ir="${e?.ir}". This adapter consumes the baked render IR, not the source-level Frontend IR. Attempting best-effort translation.`),0!==e?.irVersion&&r.push(`This adapter targets GoFish DisplayList IR v0; document declares irVersion=${e?.irVersion}. Newer fields are ignored.`);let a=t.displayList??e,i=Array.isArray(a?.items)?a.items:[];0===i.length&&r.push("Display list carried no items; the chart will render empty.");let s=[];u(i,s);let o=a?.viewport??{w:0,h:0};return{family:"network",networkLayout:p(a),layoutConfig:{displayList:a},nodes:s,edges:[],width:o.w,height:o.h,irVersion:a?.irVersion??0,warnings:r.length?r:void 0}}function h(e){return ul.has(e)}function y(e,t){return h(e)&&!pl[t].includes(e)}function m(e){return"string"==typeof e&&e.trim().length>0}function g(e,t,r){let a=hl.has(e)||void 0!==r&&yl.has(r),i=t=>y(e,t)||a,s=fl.filter(e=>m(t[e])&&!i(e));return{hasTitle:i("title")&&m(t.title),hasDescription:i("description")&&m(t.description),hasSummary:i("summary")&&m(t.summary),unsupportedFinding:s.length>0?{id:"understandable.unsupported-description-prop",principle:"understandable",heuristic:"Descriptive text is connected to the rendered chart",critical:!0,status:"warn",message:`Useful ${s.join(" and ")} text was supplied, but ${1===s.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 v(e){return!!Array.isArray(e.styleRules)&&e.styleRules.some(e=>{if("object"!=typeof e||null===e)return!1;let t=e.style;if("object"!=typeof t||null===t||Array.isArray(t))return!1;let r=t.fill;return"object"==typeof r&&null!==r&&"hatch"===r.type})}function b(e){if(!Array.isArray(e))return!1;let t=e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase());return t.length>0&&t.every(e=>ml.has(e))}function k(e){let t=e.replace(/^#/,"");/^[a-f\d]{3}$/i.test(t)&&(t=t.split("").map(e=>e+e).join(""));let r=t.match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!r)return null;let[a,i,s]=[parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255],o=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*o(a)+.7152*o(i)+.0722*o(s)}function x(e,t){let r=k(e),a=k(t);return null===r||null===a?null:(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function C(e){return"string"==typeof e?.type?e.type:""}function A(e){return!!e&&"object"==typeof e&&gl.has(C(e))}function w(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}function $(e){return vl.has(C(e))&&!w(e)}function S(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function B(e,t){return`${e}[Symbol(${t.description??""})]`}function P(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function W(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function L(e,t,r,a){let i=W(e,t);return i&&"value"in i&&i.enumerable?M(i.value,r,a):[r]}function M(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,i,s;try{s=Array.isArray(e),a=Object.getPrototypeOf(e),i=Reflect.ownKeys(e)}catch{return[t]}if(a!==(s?Array.prototype:Object.prototype)&&null!==a)return[t];r.add(e);let o=[];try{if(s){let a=W(e,"length")?.value;if(!Number.isSafeInteger(a)||0>a)return[S(t,"length")];for(let e of i)"length"===e||"string"==typeof e&&P(e,a)||o.push("symbol"==typeof e?B(t,e):S(t,e));for(let i=0;a>i;i+=1)o.push(...L(e,i+"",S(t,i),r))}else for(let a of i)"symbol"!=typeof a?o.push(...L(e,a,S(t,a),r)):o.push(B(t,a));return o}catch{return[t]}finally{r.delete(e)}}function R(){let e=globalThis;return e[jl]||(e[jl]={recipes:/* @__PURE__ */new Map,capabilities:/* @__PURE__ */new Map,layouts:/* @__PURE__ */new Map}),e[jl]}function I(e){return R().recipes.get(e)}function E(e){let t=R().layouts.get(e)?.identity;return t?{...t}:void 0}function N(e){return"string"==typeof e?I(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function T(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?t:null}function F(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis||null!=T(e)}function O(e){let 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(let e of r)a+=j(e);return r.length/t.length*.39+a/r.length*11.8-15.59}function j(e){let t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;let r=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return r?r.length:1}function D(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}function _(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function z(e){let t=_(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 U(e){let t=_(e);return!0===e.settledProjection||!0===t.settledProjection}function G(e){let t=_(e);return!0===e.reducedMotionSettle||"settle"===e.reducedMotion||!0===t.reducedMotionSettle||"settle"===t.reducedMotion}function V(e){let 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.'};let i=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."};let s=[],o=0;for(let e of r){if("string"!=typeof e||!e.startsWith("#"))continue;let t=x(e,i);null!=t&&(o++,3>t&&s.push(`${e} (${t.toFixed(1)}:1)`))}return 0===o?{...t,status:"manual",message:"colorScheme has no parseable hex colors to check.",fix:"Verify contrast manually for non-hex colors."}:s.length>0?{...t,status:"fail",message:`${s.length} color(s) fall below 3:1 contrast vs ${i}: ${s.join(", ")}.`,fix:"Darken (light background) or lighten (dark background) those colors, or use COLOR_BLIND_SAFE_CATEGORICAL."}:{...t,status:"pass",message:`All ${o} checked colorScheme color(s) meet ≥ 3:1 contrast vs ${i}.`}}function q(e,t,r={}){let a=[],i=I(e),s=Ml.has(e),o=h(e)||!!i||s,n=!0===r.inChartContainer,l=!0===r.describe,c=!0===r.navigable,d=Wl.has(e),u=bl.has(e),{hasTitle:p,hasDescription:f,hasSummary:y,unsupportedFinding:k}=g(e,t,i?.frameFamily),x=!1!==t.accessibleTable&&!d,w=p||f||y,S=D(t),B=z(t),P=s,W=U(t)||Il.has(e)&&x,L=G(t)||P,M=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],R=o?"pass":"manual",E=o?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(k&&a.push(k),a.push(V(t)),a.push({id:"perceivable.content-only-visual",principle:"perceivable",heuristic:"Content is only visual",critical:!0,...d?{status:"pass",message:"BigNumber renders its value as real text with an ARIA label — available without vision."}:x?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:f&&y?{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||Rl.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){let e=!0===t.directLabel||!0===t.showLabels,r=v(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."}});let i=b(t.colorScheme);a.push({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1,...i?{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."})}{let e=M.filter(A);if(e.length>0){let r=t.autoPlaceAnnotations,i="object"==typeof r&&null!==r&&!0===r.redundantCues,s=e.filter(e=>{if("string"!=typeof e.color)return!1;let t=C(e),r=i&&"text"===t;return!($(e)||r)});a.push({id:"perceivable.annotation-association",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...0===s.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:`${s.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,...o?{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."}});{let 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."})}{let r=Ol[e];if(r&&S){let 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:R,message:`The chart takes a single tab stop and navigates data with arrow keys${E} — 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,...S?y||f?{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:R,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${E}.`}),a.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:R,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${E}.`,fix:o?"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,...w?{status:"pass",message:`Provided: ${[p&&"title",f&&"description",y&&"summary"].filter(Boolean).join(", ")}.`}:n?{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,...f||y?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:l?{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."}:p?{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)."}});{let e=[t.description,t.summary].filter(m).join(". "),r=e?O(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(Ll.has(e)){let e=m(t.xLabel),r=m(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(Tl.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."}),M.length>1){let e=M.filter(F).length;a.push({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,...e===M.length?{status:"pass",message:`All ${M.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:M.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:`${M.length-e} of ${M.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:R,message:`Transitions animate with object constancy and data changes are mirrored to the live region${E}.`,fix:o?"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:R,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${E}.`,fix:o?"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,...d?{status:"not-applicable",message:"Single-value display — a table isn't meaningful."}:x?{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)."}}),d||a.push({id:"compromising.table-static",principle:"compromising",heuristic:"Table/data is static",critical:!1,...n?{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:o?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${o?"":E}.`,fix:o?"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,...c?u?{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."}:u?{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:R,message:`Keyboard navigation steps through points and switches series/groups${E}.`,fix:o?"For deeper structure (axis → series → datum), enable ChartContainer's navigable option.":void 0}});{let r,i=Array.isArray(t.data)?t.data:null,s=Array.isArray(t.nodes)?t.nodes:null,o={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};r=Bl.has(e)&&i&&i.length>7?{...o,status:"warn",message:i.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.'}:s&&s.length>200?{...o,status:"warn",message:s.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."}:i&&i.length>5e3?{...o,status:"warn",message:i.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."}:i?{...o,status:"pass",message:i.length+" data points — a reasonable density for non-visual consumption."}:s?{...o,status:"pass",message:s.length+" nodes — a reasonable density for non-visual consumption."}:{...o,status:"manual",message:"Data not provided inline (push mode); verify density at runtime."},a.push(r)}{let e=Array.isArray(t.data)?t.data:null,r=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]),i=!1;if(e&&!r)for(let t of e.slice(0,50))if(t&&"object"==typeof t){for(let e of Object.values(t))if("number"==typeof e&&Number.isFinite(e)&&Math.abs(e)>=1e5){i=!0;break}if(i)break}i&&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,...l?{status:"pass",message:"ChartContainer's describe option auto-generates an L1–L3 description (chart type, statistics, and trend) via describeChart()."}:y?{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,...d?{status:"not-applicable",message:"Single value — nothing to skip."}:x?{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:R,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${E}.`,fix:o?"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,...Rl.has(e)||Nl.has(e)?B?{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:R,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${E}.`}}),s&&(a.push({id:"flexible.sim-pause-control",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...B?{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,...W?{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,...L?{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."}}));{let r=!0===t.responsiveWidth||!0===t.responsiveHeight,i=Fl.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.`}:i?{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."}})}i&&(i.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length))&&a.push({id:"perceivable.recipe-color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,status:"warn",message:i.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"===i.accessibility.description&&!f&&a.push({id:"understandable.recipe-description",principle:"understandable",heuristic:"Features are not described",critical:!1,status:"fail",message:i.name+" requires a recipe-aware description, but none is attached.",fix:"Call describeChart with recipeId/recipe metadata and attach the returned text as description."}),i.accessibility.fallbackTable&&!1===t.accessibleTable&&a.push({id:"compromising.recipe-fallback",principle:"compromising",heuristic:"No data table is provided",critical:!0,status:"fail",message:i.name+" requires a fallback table, but accessibleTable is disabled.",fix:"Enable accessibleTable and preserve recipe-declared table fields on scene nodes."}));let N=a.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),T={criticalsPassed:N.filter(e=>"pass"===e.status).length,criticalsEvaluated:N.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:!N.some(e=>"fail"===e.status),summary:T,findings:a,reference:"Chartability (POUR-CAF) — https://chartability.github.io/POUR-CAF/. Not a pass/fail cert; pair with manual screen-reader testing (NVDA+Firefox, JAWS+Chrome, VoiceOver+Safari)."}}function H(e){let 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(let r of _l){let a=e.findings.filter(e=>e.principle===r&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+r.toUpperCase());for(let e of a)t.push(` ${Dl[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 Y(e,t){let r=e.length,a=t.length,i=Array(a+1);for(let e=0;a>=e;e++)i[e]=e;for(let s=1;r>=s;s++){let r=i[0];i[0]=s;for(let o=1;a>=o;o++){let a=i[o];i[o]=e[s-1]===t[o-1]?r:1+Math.min(r,i[o],i[o-1]),r=a}}return i[a]}function Q(e,t,r=3){let a,i=r+1;for(let r of t){let t=Y(e.toLowerCase(),r.toLowerCase());i>t&&(i=t,a=r)}return i>r?void 0:a}function Z(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function K(e,t){if(0===t.length)return null;let r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||(Q(e,t,3)??null)}function X(e){return` Or use a function: ${e}={d => d.myValue}.`}function J({componentName:e,data:t,accessors:r,requiredProps:a}){if(a)for(let[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){let a=Z(t).find(e=>e&&"object"==typeof e);if(a){let t=Object.keys(a);for(let[i,s]of Object.entries(r))if(s&&"string"==typeof s&&!(s in a)){let r=K(s,t),a=r?` Try ${i}="${r}".`:"";return`${e}: ${i} "${s}" not found in data. Available fields: ${t.join(", ")}.${a}`+X(i)}}}return null}function ee({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 te({componentName:e,nodes:t,edges:r,nodesRequired:a=!1,edgesRequired:i=!0,accessors:s}){if(null==t&&null==r)return null;if(i&&(!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(s&&t&&t.length>0){let r=Z(t).find(e=>e&&"object"==typeof e);if(r){let t=Object.keys(r);for(let[a,i]of Object.entries(s))if(i&&"string"==typeof i&&!(i in r)){let r=K(i,t),s=r?` Try ${a}="${r}".`:"";return`${e}: ${a} "${i}" not found in node data. Available fields: ${t.join(", ")}.${s}`+X(a)}}}return null}function re(e){let[t,r]=Array.isArray(e)?e:[e,void 0],a=zl[t],i=Array.isArray(a)?[...a]:a;return void 0===r?{type:i}:{type:i,enum:[...Ul[r]]}}function ae(){return Object.fromEntries(Vl.map(([e,t,r,a,i],s)=>[dl[s],{required:[...e],dataShape:t,dataAccessors:[...r],props:Object.fromEntries(Object.entries(Object.assign({},...a.map(e=>Gl[e]),i)).map(([e,t])=>[e,re(t)]))}]))}function ie(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function se(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"UnitPileChart"===e)}function oe(e){if(!Array.isArray(e.thresholds))return[];let 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".`);let 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.`);let i=Object.keys(a).filter(e=>"value"!==e&&"color"!==e&&"label"!==e);i.length>0&&t.push(`"thresholds[${r}]" has unsupported GaugeChart key(s): ${i.join(", ")}. Use { value, color, label? }; { at, level } belongs to BigNumber.`)}),t}function ne(e){let t=e.frameProps;if(null==t||"object"!=typeof t||Array.isArray(t))return[];let 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)+"."];let a=[],i=r,s=/* @__PURE__ */new Set(["align",...Object.keys(Yl)]);for(let e of Object.keys(i))s.has(e)||a.push(`Unknown "frameProps.legendLayout" key "${e}". Valid keys: ${[...s].join(", ")}.`);void 0!==i.align&&"string"!=typeof i.align?a.push(`"frameProps.legendLayout.align" should be string, got ${Array.isArray(i.align)?"array":typeof i.align}.`):"string"==typeof i.align&&!Hl.has(i.align)&&a.push(`"frameProps.legendLayout.align" value "${i.align}" is not valid. Expected one of: ${[...Hl].join(", ")}.`);for(let[e,t]of Object.entries(Yl)){let r=i[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 le(e,t){let r=[];(null==t||"object"!=typeof t)&&(t={});let a=ql[e];if(!a)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(ql).join(", ")}`]};for(let i of a.required)null==t[i]&&r.push(`"${i}" is required for ${e}.`);"array"===a.dataShape&&Object.prototype.hasOwnProperty.call(a.props,"data")&&!a.required.includes("data")&&!se(e,t)&&null==t.data&&r.push(`"data" is required for ${e}.`);for(let[e,i]of Object.entries(t)){if(null==i)continue;let t=a.props[e];if(t){if(!ie(i,t.type)){let a=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${a}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&r.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}let i=Object.keys(a.props),s=new Set(i);for(let a of Object.keys(t))if(void 0!==t[a]&&!s.has(a)){let t=Q(a,i),s=t?`Unknown prop "${a}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${a}" for ${e}. Valid props: ${i.join(", ")}.`;r.push(s)}if("array"===a.dataShape){let i=t.data,s={};for(let e of a.dataAccessors){let r=t[e];"string"==typeof r&&(s[e]=r)}let o=J({componentName:e,data:i,accessors:Object.keys(s).length>0?s:void 0});o&&r.push(o)}else if("object"===a.dataShape){let a=ee({componentName:e,data:t.data});a&&r.push(a)}else if("network"===a.dataShape){let i=t.nodeIdAccessor??t.nodeIDAccessor??"id",s="string"==typeof i?{nodeIdAccessor:i}:void 0,o=te({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:a.required.includes("nodes"),edgesRequired:a.required.includes("edges"),accessors:s});o&&r.push(o)}return"GaugeChart"===e&&r.push(...oe(t)),"ScatterplotMatrix"===e&&null!=t.frameProps&&r.push('"frameProps" is not supported for ScatterplotMatrix; configure its matrix props directly.'),r.push(...ne(t)),{valid:0===r.length,errors:r}}function ce(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function de(e,t={}){let r=[],a=e.tokenSemantics,i=e.countStrategy,s=t.maxRecommendedTokens??("fixed-denominator"!==i||ce(e.denominator)>100?80:100);return a||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),i||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>s&&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&&i&&"unitized"!==i&&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&&i&&"fixed-denominator"!==i&&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)&&i&&"quantile"!==i&&"sample"!==i&&"posterior-sample"!==i&&"random-sample"!==i&&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"===i&&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"===i&&!e.unitMeaning&&r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function ue(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:2e4))):1/0}function pe(e){let t=e.provenance,r=e.id??e.stableId??t?.stableId;return null==r||""===r?void 0:r+""}function fe(e,t,r){let a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(let e of a)!e||"object"!=typeof e||"widget"!==C(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 he(e,t,r){let a=Array.isArray(t.annotations)?t.annotations:null;if(a)for(let e of a){if(!e||"object"!=typeof e)continue;let t=C(e);if(!A(e)||"widget"===t)continue;let a=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),i="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,s=$(e);!s&&a>120?r.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${i}" 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).'}):s&&a>250&&r.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${i}" 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 ye(e,t,r){let a=Array.isArray(t.annotations)?t.annotations:null;if(!a)return;let i=a.filter(A).length;if(0===i)return;let s="number"==typeof t.width?t.width:600,o="number"==typeof t.height?t.height:400,n=ue(s,o);!Number.isFinite(n)||n>=i||r.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${i} note annotations on a ${s}×${o} chart exceed the ~${n} 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 me(e,t,r){for(let e of Zl){let a=t[e];if(!Array.isArray(a)||2>a.length)continue;let[i,s]=a;"number"!=typeof i||"number"!=typeof s||i>s&&r.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${i}, ${s}] 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}={[${s}, ${i}]}). 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 ge(e,t,r){if("MultiAxisLineChart"!==e)return;let a=t.series;if(!Array.isArray(a)||2!==a.length)return;let i=a.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);i.length>0&&r.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${i.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 ve(e,t,r){if(!Cl.has(e))return;let a=t.xExtent;if(!Array.isArray(a)||2>a.length)return;let[i,s]=a;if("number"!=typeof i||"number"!=typeof s||i>=s)return;let o=t.data;if(!o||!Array.isArray(o)||4>o.length)return;let n=t.xAccessor??"x";if("string"!=typeof n)return;let l=1/0,c=-1/0;for(let e of o){let t=e?.[n];"number"!=typeof t||!Number.isFinite(t)||(l>t&&(l=t),t>c&&(c=t))}if(!Number.isFinite(l)||!Number.isFinite(c)||l>=c)return;let d=c-l,u=Math.max(0,Math.min(s,c)-Math.max(i,l))/d;.7>u&&r.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${i}, ${s}] shows only ~${Math.round(100*u)}% of the data's x range [${l}, ${c}] — 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 be(e,t,r){let a=Sl[e],i=Pl[e];if(!a&&!i||i&&!t.normalize)return;let s=a??i,o=t[s],n="string"==typeof o?o:"yAccessor"===s?"y":"value",l=t.data;if(!l||!Array.isArray(l)||0===l.length)return;let c=l.filter(e=>{let t=e?.[n];return"number"==typeof t&&0>t});c.length>0&&r.push({severity:a?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${c.length} negative value(s) in "${n}" — 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 ke(e,t,r){wl.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 xe(e,t,r){if("LineChart"!==e&&"AreaChart"!==e||"sparkline"===t.mode||t.responsiveWidth||t.responsiveHeight)return;let a="number"==typeof t.width?t.width:600,i="number"==typeof t.height?t.height:400;if(0>=a||0>=i)return;let s=a/i;if(s>8||.25>s){let e=s>8?"flattens":"exaggerates";r.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${a}×${i} (${s.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:s>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 Ce(e,t,r){if(!$l.has(e))return;let a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;let i=t.categoryAccessor,s="string"==typeof i?i:"category",o=/* @__PURE__ */new Set;for(let e of a){let t=e?.[s];null!=t&&o.add(t)}o.size>8&&r.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:o.size+" slices — angle judgments degrade rapidly past ~8 categories (Cleveland & McGill), and thin slices become unreadable and unlabelable.",fix:`Use a BarChart or DotPlot for ${o.size} categories, or group the long tail into an "Other" slice before charting.`})}function Ae(e,t,r){return"function"==typeof r?r(e,t):e[r]}function we(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function $e(e,t,r){return Math.max(t,Math.min(r,e))}function Se(e,t){let r=we(e);return null!=r&&r>0?r:t}function Be(e){if(!e)return;let t=we(e[0]),r=we(e[1]);return null!=t&&null!=r?t>r?[r,t]:[t,r]:void 0}function Pe(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 We(e={}){let 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))),i=Se(e.unitValue,1),s=Pe(e.seed??1),o=e.idPrefix??"mechanical-pile",n=r.map(()=>.65+.9*s()),l=n.reduce((e,t)=>e+t,0)||1,c=a-r.length,d=n.map(e=>e/l*c),u=d.map(e=>1+Math.floor(e)),p=a-u.reduce((e,t)=>e+t,0),f=d.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;p>0;e=(e+1)%f.length)u[f[e].index]+=1,p-=1;return r.map((e,t)=>({id:`${o}-${t}`,category:e,value:u[t]*i,mechanical:!0,unitCount:u[t],unitValue:i,share:u[t]/a}))}function Le(e,t){let r=e/t,a=Math.round(r);return Math.ceil(a>0&&Number.EPSILON*r*4>=Math.abs(r-a)?a:r)}function Me(e,t,r=0){let a=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),i=/* @__PURE__ */new Map;for(let s of e){let e=null==s.id?`${t}-${r++}`:s.id+"";for(;null==s.id&&a.has(e);)e=`${t}-${r++}`;a.add(e),i.set(e,null==s.id?{...s,id:e}:s)}return{seed:e,rows:Array.from(i.values()),nextId:r}}function Re(e){let t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function Ie(e,t,r){return"function"==typeof t?t(e):e?.["string"==typeof t?t:r]}function Ee(e,t,r){if(El.has(e)){if("GaltonBoardChart"===e){let 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."});let a=Re(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."});let i=Re(t.mechanicalCount);null!=t.mechanicalCount&&(null==i||0>=i)&&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){let e=t.windows,a=e&&"object"==typeof e?Re(e.size):null;null!=a&&0>=a&&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&&0>=t.timeScale&&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."});let i=Array.isArray(t.data)?t.data:[];if(i.length>0){let e=t.timeAccessor||"time",a=t.arrivalAccessor||"arrivalTime";i.some(t=>{let r=Re(Ie(t,e,"time")),i=Re(Ie(t,a,"arrivalTime"));return null!=r&&null!=i&&r!==i})||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){let e="mechanical"===(t.simulationMode??t.mode),a=Re(t.mechanicalCount);null!=t.mechanicalCount&&(null==a||0>=a)&&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."});let i=we(t.unitValue??1);if(null==i||0>=i)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."});let s=e?We({count:a??void 0,categories:Array.isArray(t.mechanicalCategories)?t.mechanicalCategories:void 0,seed:we(t.seed)??1,unitValue:i}):Array.isArray(t.data)?t.data:[],{rows:o}=Me(s,"pile"),n=t.valueAccessor??(e?"value":void 0),l=o.reduce((e,t,r)=>{let a="function"==typeof n?n(t,r):"string"==typeof n&&n?t[n]:1;return e+Le(Math.max(0,we(a)??0),i)},0);l>1500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`UnitPileChart would create about ${l} 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(0>=(Re(t.pointRadius??5)??5)&&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."}),0>=(Re(t.collisionIterations??6)??6)&&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){let e=Array.isArray(t.xExtent)?t.xExtent:[],a=Re(e[0]),i=Re(e[1]);(2>e.length||null==a||null==i)&&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."})}let 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."});let a=t.groupAccessor;if(e.length>0&&a){let t=/* @__PURE__ */new Set;for(let r of e){let e=Ie(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){let 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 } }.'});let 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){let e=Array.isArray(t.phases)?t.phases:[],a=Array.isArray(t.products)?t.products:[],i=Array.isArray(t.events)?t.events:[],s=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==Re(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===i.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."});let o=new Set(a.map(e=>e?.id).filter(e=>null!=e).map(String)),n=/* @__PURE__ */new Set(["product","retained","residue","failed","recovered",...s.map(e=>e?.id).filter(e=>null!=e).map(String)]),l=/* @__PURE__ */new Set,c=/* @__PURE__ */new Set;for(let e of i)if(e&&Array.isArray(e.effects))for(let t of e.effects){if(!t||"object"!=typeof t)continue;let e=t.type;if(("combine"===e||"contribute"===e||"complete-product"===e)&&null!=t.productId&&!o.has(t.productId+"")&&l.add(t.productId+""),"split"===e&&Array.isArray(t.products))for(let e of t.products)null!=e?.productId&&!o.has(e.productId+"")&&l.add(e.productId+"");null!=t.outletId&&!n.has(t.outletId+"")&&c.add(t.outletId+"")}l.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_PRODUCT",message:`CrucibleChart events reference undeclared product molds: ${[...l].sort().join(", ")}.`,fix:"Declare every referenced product id in products; do not create product definitions implicitly inside events."}),c.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_OUTLET",message:`CrucibleChart events reference undeclared outlets: ${[...c].sort().join(", ")}.`,fix:"Declare every domain outlet in outlets and reuse its stable id in authored effects."});let d=Re(t.playbackRate);null!=t.playbackRate&&(null==d||0>=d)&&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."});let u=Re(t.rerunMS);null!=t.rerunMS&&(null==u||0>u)&&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){let a=Array.isArray(t.data)?t.data:[],i=Re(t.mechanicalCount)??0,s=a.length>0?a.length:i;s>2500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(s)} 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 Ne(e){let 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."});let a=e.edges;if(Array.isArray(a)&&a.length>0){let 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."})}let i=e.nodes,s=Array.isArray(i)?i.length:0;return!0===e.showLabels&&s>=24&&t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${s} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),(Array.isArray(a)?a.length:0)>=80&&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 Te(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let r=Kl.test(t)?t+"-01":t;if(r===t&&10>t.length)return NaN;let a=Date.parse(r);return Number.isFinite(a)?a:NaN}function Fe(e,t){if(!e||!t)return{data:e,failed:!1};let r=!1,a=!1,i=e.map(e=>{let i=e[t];if("string"!=typeof i)return e;let s=Te(i);return r=!0,Number.isFinite(s)?{...e,[t]:s}:(a=!0,{...e,[t]:NaN})});return{data:r?i:e,failed:a}}function Oe(e,t){let r=e.nestedDataAccessorProp?t[e.nestedDataAccessorProp]:void 0;return"string"==typeof r?r:e.defaultNestedDataAccessor}function je(e,t,r){let a=e.dataProp??"data",i=t[a],s=r??(Array.isArray(i)?i:[]),o=Oe(e,t);if(!o)return{dataProp:a,rows:s};let n=[],l=!1;for(let e of s){let t=e?.[o];if(Array.isArray(t)){l=!0;for(let e of t)e&&"object"==typeof e&&n.push(e)}}return{dataProp:a,rows:l?n:s}}function De(e,t,r){let a=/* @__PURE__ */new Set;for(let i of e.fields){let e=i.dataProp??"data",s=r??t[e];if(!Array.isArray(s))continue;if(0===s.length){a.add(e);continue}let o=Oe(i,t);if(!o)continue;let n=s.map(e=>e?.[o]).filter(Array.isArray);n.length>0&&n.every(e=>0===e.length)&&a.add(`${e}.${o}`)}return[...a]}function _e(){let e=globalThis;return e[pc]??(e[pc]={contracts:/* @__PURE__ */new Map}),e[pc]}function ze(e){return _e().contracts.get(e)??uc[e]}function Ue(e,t){if(0===e.length)return;let r=(e.length-1)*t,a=Math.floor(r),i=Math.ceil(r);if(a===i)return e[a];let s=r-a;return e[a]*(1-s)+e[i]*s}function Ge(e){let t=[];for(let[r,a]of Object.entries(fc))"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 Ve(e,t,r){return"function"==typeof e?e(t,r):t[e]}function qe(e,t){if("number"==typeof e)return Number.isFinite(e)?e:null;if(e instanceof Date){let r=e.getTime();return t&&Number.isFinite(r)?r:null}if("string"==typeof e){let r=e.trim(),a=Number(r);if(r&&Number.isFinite(a))return a;if("date-like"===t){let e=Te(r);return Number.isFinite(e)?e:null}}return null}function He(e){return"number"==typeof e&&!Number.isFinite(e)}function Ye(e,t,r,a,i){let s={field:r,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let r=0;e.length>r;r++){let o;try{o=Ve(t,e[r],r)}catch{s.accessorErrorRows.push(r);continue}if(null==o||""===o){if(void 0!==i){s.numbers.push(i),s.finiteRows.push(r),0===i&&s.zeroRows.push(r),0>i&&s.negativeRows.push(r),Number.isInteger(i)||s.fractionalRows.push(r);continue}s.missingRows.push(r);continue}let n=qe(o,a);null!=n?(s.numbers.push(n),s.finiteRows.push(r),0===n&&s.zeroRows.push(r),0>n&&s.negativeRows.push(r),Number.isInteger(n)||s.fractionalRows.push(r)):He(o)?s.nonFiniteRows.push(r):s.nonNumericRows.push(r)}return s}function Qe(e,t){let 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 Ze(e){let t=1/0,r=-1/0;for(let a of e)t>a&&(t=a),a>r&&(r=a);return[t,r]}function Ke(e,t,r){let a=[],i=/* @__PURE__ */new Set;for(let s of e.fields){if(s.whenProps?.some(e=>null==t[e]))continue;let e=t[s.accessor],o="string"==typeof e||"function"==typeof e?e:s.defaultAccessor;if("string"!=typeof o&&"function"!=typeof o)continue;let{dataProp:n,rows:l}=je(s,t,r);if(0===l.length)continue;let c="string"==typeof o?o:s.accessor+"()",d=`${n}:${s.role}:${c}`;if(i.has(d))continue;i.add(d);let u=s.temporalValues??("time"===s.role||"x"===s.role&&"time"===t.xScaleType?"date-like":void 0),p="x"===s.role&&"log"===t.xScaleType||"y"===s.role&&"log"===t.yScaleType,f=Qe(s,t);a.push({contract:s,accessor:o,accessorLabel:c,dataProp:n,rows:l,requirements:f,logScale:p,observation:Ye(l,o,c,u,s.missingValue)})}return a}function Xe(e){return e.slice(0,5)}function Je(e){return{domain:"data",...e}}function et(e){let 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[];let r=t.map(e=>e.value),a=Ue(r,.25),i=Ue(r,.75),s=Ue(r,.5),o=i-a;if(o>0){let e=a-10*o,r=i+10*o;return t.filter(t=>e>t.value||t.value>r).map(e=>e.row)}let n=100*Math.max(1,Math.abs(s));return t.filter(e=>Math.abs(e.value-s)>n).map(e=>e.row)}function tt(e,t){let r=[],{observation:a,contract:i,accessorLabel:s,requirements:o}=e,n={field:s,role:i.role},l=[...a.nonFiniteRows,...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(0===a.numbers.length)return r.push(Je({severity:"error",code:"DEGENERATE_EXTENT",message:`${i.accessor}="${s}" produces no finite numeric values; the chart cannot resolve its ${i.role} input.`,fix:`Ensure ${s} contains finite numbers${"x"===i.role?" (or valid dates for a time scale)":""}.`,...n,...l.length>0?{rows:Xe(l),count:l.length}:{}})),r;a.nonFiniteRows.length>0&&r.push(Je({severity:"error",code:"NON_FINITE_VALUE",message:`${s} 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 ${s} before rendering.`,...n,rows:Xe(a.nonFiniteRows),count:a.nonFiniteRows.length})),!i.allowMissing&&a.missingRows.length>0&&r.push(Je({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${s} is missing for ${a.missingRows.length} row${1===a.missingRows.length?"":"s"}; the ${i.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${s} values before rendering.`,...n,rows:Xe(a.missingRows),count:a.missingRows.length}));let c=[...a.nonNumericRows,...a.accessorErrorRows].sort((e,t)=>e-t);if(c.length>0&&r.push(Je({severity:"error",code:"NON_NUMERIC_VALUE",message:`${s} produces ${c.length} non-numeric value${1===c.length?"":"s"} for the ${i.role} role.`,fix:`Bind ${i.accessor} to a numeric field or return finite numbers from the accessor.`,...n,rows:Xe(c),count:c.length})),i.domain&&a.numbers.length>=2){let[e,t]=Ze(a.numbers);e===t&&r.push(Je({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${s} is constant at ${e}; its ${i.role} scale has a zero-span data domain.`,fix:`Provide varying ${i.role} values, set an explicit extent around ${e}, or use a single-value display.`,...n,rows:Xe(a.finiteRows),count:a.finiteRows.length}))}if(o.includes("positive")){let 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){let a=e.logScale;r.push(Je({severity:"error",code:a?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${s} 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.",...n,rows:Xe(t),count:t.length}))}}if(o.includes("non-negative")&&a.negativeRows.length>0&&r.push(Je({severity:"error",code:"size"===i.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${s} contains ${a.negativeRows.length} negative ${i.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.",...n,rows:Xe(a.negativeRows),count:a.negativeRows.length})),o.includes("integer")){let e=[.../* @__PURE__ */new Set([...a.negativeRows,...a.zeroRows,...a.fractionalRows])].sort((e,t)=>e-t);e.length>0&&r.push(Je({severity:"error",code:"INVALID_COUNT",message:`${s} 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.",...n,rows:Xe(e),count:e.length}))}if(o.includes("unit-interval")){let 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(Je({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${s} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${s} to [0, 1] before using it as ${i.role}.`,...n,rows:Xe(e),count:e.length}))}if(t&&i.domain){let t=et(e);t.length>0&&r.push(Je({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${s} 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.",...n,rows:Xe(t),count:t.length}))}return r}function rt(e,t,r){if(!e)return"__all__";try{return Ve(e,t,r)+""}catch{return"__accessor_error__"}}function at(e,t,r){if(e.whenProp&&!0!==r[e.whenProp])return[];let a=t.find(t=>t.contract.role===e.role);if(!a||0===a.observation.numbers.length)return[];let i=e.groupAccessor?r[e.groupAccessor]:void 0,s="string"==typeof i||"function"==typeof i?i:e.defaultGroupAccessor,o=/* @__PURE__ */new Map;for(let e=0;a.rows.length>e;e++){let t;try{t=Ve(a.accessor,a.rows[e],e)}catch{continue}let r=qe(t,void 0);if(null==r)continue;let i=rt(s,a.rows[e],e),n=o.get(i)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};n.sum+=r,n.magnitude+=Math.abs(r),n.positive||(n.positive=r>0),n.negative||(n.negative=0>r),n.rows.push(e),0>r&&n.negativeRows.push(e),o.set(i,n)}let n=[],l=[],c=[],d=[],u=[],p=[];for(let[t,r]of o)("positive-total"===e.kind&&0>=r.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,r.magnitude)*10>=Math.abs(r.sum))&&(n.push(t),d.push(...r.rows)),"normalized-total"===e.kind&&r.positive&&r.negative&&(l.push(t),u.push(...r.rows)),"normalized-total"===e.kind&&r.negative&&(c.push(t),p.push(...r.negativeRows));let f=[];return n.length>0&&f.push(Je({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${n.length} normalization group${1===n.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:Xe([...new Set(d)].sort((e,t)=>e-t)),count:n.length})),c.length>0&&f.push(Je({severity:"error",code:"NEGATIVE_NORMALIZED_VALUE",message:`${c.length} normalization group${1===c.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:Xe([...new Set(p)].sort((e,t)=>e-t)),count:p.length})),l.length>0&&f.push(Je({severity:"warning",code:"MIXED_SIGN_NORMALIZATION",message:`${l.length} normalization group${1===l.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:Xe([...new Set(u)].sort((e,t)=>e-t)),count:l.length})),f}function it(e,t,r,a={}){let i=a.contracts??ze(e)??Ge(t);if(!i)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:[]};let s=Ke(i,t,r),o=[],n=!1!==a.checkOutliers;for(let e of De(i,t,r))o.push(Je({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:[]}));let l=new Set(s.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(let e of l)o.push(Je({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(let e of s)o.push(...tt(e,n));for(let e of i.aggregates??[])o.push(...at(e,s,t));let c=o.filter(e=>"error"===e.severity).length,d=o.length-c;return{component:e,ok:0===c,rowCount:s.reduce((e,t)=>Math.max(e,t.rows.length),r?.length??(Array.isArray(t.data)?t.data.length:0)),summary:{fieldsChecked:s.length,errors:c,warnings:d},contracts:s.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:o}}function st(e,t,r){let a=ql[e];if(a){if("array"===a.dataShape||"realtime"===a.dataShape){let 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 ot(e,t){for(let[r,a]of[["width",600],["height",400]]){let i=e[r];void 0!==i&&("number"!=typeof i||0>=i)&&t.push({severity:"error",code:"width"===r?"BAD_WIDTH":"BAD_HEIGHT",message:`${r}=${JSON.stringify(i)} — chart needs a positive number.`,fix:`Set ${r}={${a}}.`})}if(e.size&&Array.isArray(e.size)){let[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 nt(e,t,r){let a=ql[e];if(!a||"array"!==a.dataShape)return;let i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;let s=i[0];if(!s||"object"!=typeof s)return;let o=Object.keys(s);for(let e of a.dataAccessors){let a=t[e];"string"==typeof a&&(a in s||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${a}" not found in data. Available fields: ${o.join(", ")}.`,fix:`Change ${e} to one of: ${o.map(e=>`"${e}"`).join(", ")}, or use a function: ${e}={d => d.myValue}.`}))}}function lt(e,t,r){bl.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 ct(e,t,r){kl.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 dt(e,t,r){let a=ql[e];if(!a||"array"!==a.dataShape)return;let i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;let s=i[0];if(!s||"object"!=typeof s)return;let o=t.xAccessor;"string"==typeof o&&s[o]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${o}" 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 ut(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 pt(e,t,r){if(!Cl.has(e)||t.gapStrategy)return;let a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;let i=t.yAccessor||"y";"string"==typeof i&&a.some(e=>{let t=e[i];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${i}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}function ft(e,t,r){if(!xl.has(e))return;let 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 ht(e,t,r){if(!Al.has(e))return;let 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 yt(e,t,r){if("Heatmap"!==e)return;let a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;let i=a[0];if(i&&"object"==typeof i)for(let e of["xAccessor","yAccessor"]){let a=t[e];if("string"!=typeof a)continue;let s=i[a];"string"==typeof s&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${a}" resolves to string values (e.g. "${s}"). 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 mt(e,t,r){let a=t.colorScheme;if(!a||!Array.isArray(a))return;let i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;let s=[];for(let e of a){if("string"!=typeof e||!e.startsWith("#"))continue;let t=x(e,i);null!==t&&3>t&&s.push(`${e} (${t.toFixed(1)}:1)`)}s.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${s.length} color(s) in colorScheme have < 3:1 contrast against background "${i}": ${s.join(", ")}. Data marks may be hard to see.`,fix:"Choose colors with at least 3:1 contrast against the chart background."})}function gt(e,t){let r=e.width??600,a=e.height??400,i=e.margin;if(!i||"object"!=typeof i)return;let s=(i.left||0)+(i.right||0),o=(i.top||0)+(i.bottom||0);s>=r&&t.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${s}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),o>=a&&t.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${o}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}function vt(e,t,r){let a=ql[e]?.props,i=e=>!!a?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,s=i("title"),o=i("description"),n=i("summary");!s&&!o&&!n&&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){let a=t.colorScheme;"string"!=typeof a||ql[e]?.props?.colorScheme?.enum||hc.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 (${[...hc].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}function kt(e,t,r){let a=t.colorScheme;if(!a||!Array.isArray(a)||2>a.length)return;let i=a.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>i.length)return;let s=[];for(let e=0;i.length-1>e;e++){let t=x(i[e],i[e+1]);null!==t&&1.5>t&&s.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}s.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${s.length} adjacent color pair(s) in colorScheme have very similar luminance: ${s.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 xt(e,t,r){let a=[];for(let e of yc)"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 Ct(e,t,r){let 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 At(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 wt(e,t,r){if(!0!==t.showParticles)return;let a=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},i="number"==typeof a.maxPerLine?a.maxPerLine:void 0,s="number"==typeof a.spawnRate?a.spawnRate:void 0;("number"==typeof i&&i>20||"number"==typeof s&&s>.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 $t(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function St(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function Bt(e,t){let r=St(e.visibleTokens);if(null!=r)return r;let a=St(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=a)return a;let i=St(t.tokenCount),s=St(t.maxTokens);return null!=i&&null!=s?Math.min(i,s):i??a??s}function Pt(e,t,r){let a=[];$t(t.tokenEncoding)&&a.push({source:"tokenEncoding",encoding:t.tokenEncoding}),$t(t.encoding)&&a.push({source:"encoding",encoding:t.encoding});for(let{source:e,encoding:i}of a){let a=Bt(t,i);for(let t of de(i,{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 Wt(e){let t={...e};return delete t.tokenEncoding,delete t.visibleTokens,$t(t.encoding)&&delete t.encoding,t}function Lt(e,t){let r=t.match(/^Unknown prop "([^"]+)"/);if(r)return`Remove \`${r[1]}\` or replace it with a documented ${e} prop.`;let 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 Mt(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 Rt(e,t){let r=[],a=()=>({ok:r.every(e=>"warning"===e.severity),diagnoses:r}),i=/^(XY|Ordinal|Network|Physics|Geo)CustomChart$/.test(e),s=i?[]:le(e,Wt(t)).errors;if(i){"function"!=typeof t.layout&&s.push("Provide a layout function.");let r="NetworkCustomChart"===e?["nodes","edges"]:"GeoCustomChart"===e?["points","areas","lines"]:["data"];for(let e of r)null!=t[e]&&!Array.isArray(t[e])&&s.push(`Provide an array for ${e}.`)}for(let a of s)"BigNumber"===e&&void 0!==t.accessibleTable&&a.startsWith('Unknown prop "accessibleTable"')||r.push({severity:"error",code:"VALIDATION",message:a,fix:i?a:Lt(e,a)});if("BigNumber"===e&&Mt(t,r),(i||ql[e])&&(ot(t,r),gt(t,r),fe(0,t,r)),!ql[e])return a();st(e,t,r),nt(e,t,r),lt(e,t,r),ct(e,t,r),dt(e,t,r),ut(0,t,r),ft(e,t,r),pt(e,t,r);let o=it(e,t,void 0,{checkOutliers:!1}).diagnoses;for(let e of o)"EMPTY_DATA"===e.code&&r.some(e=>"EMPTY_DATA"===e.code||"EMPTY_EDGES"===e.code)||r.push(e);if(ht(e,t,r),yt(e,t,r),mt(0,t,r),kt(0,t,r),bt(e,t,r),vt(e,t,r),xt(0,t,r),Ct(0,t,r),At(0,t,r),wt(0,t,r),Pt(0,t,r),he(0,t,r),ye(0,t,r),me(0,t,r),ge(e,t,r),ve(e,t,r),r.some(e=>"NEGATIVE_VALUE"===e.code||"NEGATIVE_NORMALIZED_VALUE"===e.code)||be(e,t,r),ke(e,t,r),xe(e,t,r),Ce(e,t,r),Ee(e,t,r),"ProcessSankey"===e)for(let e of Ne(t))r.push(e);return a()}function It(e,t){return mc.has(e)&&!("reading"===e&&"string"==typeof t)}function Et(e){return"string"==typeof e?e:e.id??e.name}function Nt(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function Tt(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 Ft(e,t,r){return r??N(t.recipe)??N(t.recipeId)??I(e)}function Ot(e,t,r=[]){let a=e.accessor?t[e.accessor]:void 0;if("string"==typeof a&&a)return a;if(e.field)return e.field;let i=r.find(e=>e&&"object"==typeof e);if(!i)return;let s=Object.entries(i).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?s.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in i):s.find(([,e])=>"string"==typeof e)?.[0]}function jt(e,t){return e.dataRoles.find(e=>e.role===t)}function Dt(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function _t(e,t,r,a,i,s={}){let o={...s};if(t)for(let[e,r]of Object.entries(t))o[e]=r;for(let e of r.dataRoles){let r=Ot(e,a,i),s=t&&r?t[r]:r;void 0!==s&&(o[e.role]=s)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{let r=o[t];return null==r?`{${t}}`:r+""})}function zt(e){let t=[...bc],r=Array.from((new TextEncoder).encode(e)),a=8*r.length;for(r.push(128);r.length%64!=56;)r.push(0);let i=Math.floor(a/4294967296),s=a>>>0;r.push(i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s);let o=[];for(let e=0;r.length>e;e+=4)o.push((r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0);for(let e=0;o.length>e;e+=16){let r=[...o.slice(e,e+16)];for(let e=16;64>e;e+=1){let t=gc(r[e-15],7)^gc(r[e-15],18)^r[e-15]>>>3,a=gc(r[e-2],17)^gc(r[e-2],19)^r[e-2]>>>10;r[e]=r[e-16]+t+r[e-7]+a>>>0}let[a,i,s,n,l,c,d,u]=t;for(let e=0;64>e;e+=1){let t=u+(gc(l,6)^gc(l,11)^gc(l,25))+(l&c^~l&d)+kc[e]+r[e]>>>0,o=a&i^a&s^i&s;u=d,d=c,c=l,l=n+t>>>0,n=s,s=i,i=a,a=t+((gc(a,2)^gc(a,13)^gc(a,22))+o>>>0)>>>0}let p=[a,i,s,n,l,c,d,u];for(let e=0;8>e;e+=1)t[e]=t[e]+p[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function Ut(e,t){return`${e}[Symbol(${t.description??""})]`}function Gt(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let r=Number(e);return Number.isSafeInteger(r)&&r>=0&&t>r}function Vt(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function qt(e){return e.sort((e,t)=>{let r=JSON.stringify(e),a=JSON.stringify(t);return a>r?-1:r>a?1:0})}function Ht(e,t,r){if(null===e)return null;if(e instanceof Date){let 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":{let a=e;if(r.ancestors.has(a))return void r.excluded.push(t);r.ancestors.add(a);try{if(Array.isArray(e)){for(let a of Reflect.ownKeys(e))"length"===a||"string"==typeof a&&Gt(a,e.length)||r.excluded.push("symbol"==typeof a?Ut(t,a):Vt(t,a));return Array.from({length:e.length},(a,i)=>{let s=Vt(t,i),o=Object.getOwnPropertyDescriptor(e,i+"");if(!o||!("value"in o)||!o.enumerable)return r.excluded.push(s),null;let n=Ht(o.value,s,r);return void 0===n?null:n})}let a={},i=Object.getPrototypeOf(e);if(i!==Object.prototype&&null!==i)return void r.excluded.push(t);let s=[];for(let a of Reflect.ownKeys(e)){if("symbol"==typeof a){r.excluded.push(Ut(t,a));continue}let i=Object.getOwnPropertyDescriptor(e,a);i&&"value"in i&&i.enumerable?s.push(a):r.excluded.push(Vt(t,a))}for(let i of s.sort()){let s=Object.getOwnPropertyDescriptor(e,i),o=Ht(s&&"value"in s?s.value:void 0,Vt(t,i),r);void 0!==o&&Object.defineProperty(a,i,{value:o,enumerable:!0,configurable:!0,writable:!0})}return a}finally{r.ancestors.delete(a)}}default:return void r.excluded.push(t)}}function Yt(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{let r=r=>{let a="symbol"==typeof r?["symbol-key",r.description??""]:["string-key",r],i=Object.getOwnPropertyDescriptor(e,r);return i?"value"in i?[a,"data",!!i.enumerable,Yt(i.value,t)]:[a,"accessor",!!i.enumerable,!!i.get,!!i.set]:[a,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,a)=>{let i=a+"";return Object.prototype.hasOwnProperty.call(e,i)?r(i):["hole"]}),qt(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&Gt(t,e.length))).map(r))];let a=Object.getPrototypeOf(e);return[a!==Object.prototype&&null!==a?"non-json-object":"object",qt(Reflect.ownKeys(e).map(r))]}finally{t.delete(e)}default:return["excluded"]}}function Qt(e){let t={excluded:[],ancestors:/* @__PURE__ */new Set},r=Ht(e,"$",t)??null;return{value:r,text:JSON.stringify(r),excludedPaths:t.excluded}}function Zt(e){let t=Qt(e),r=zt(JSON.stringify(["semiotic-value-fingerprint","v2",Yt(e)]));return{...t,algorithm:"sha256",digest:r,fingerprint:"sha256:"+r}}function Kt(e,t,r,a){ir(e,Object.keys(t),r,a);for(let[i,s]of Object.entries(t))s.values?(s.required||void 0!==e[i])&&or(e,i,r,s.values,a):s.required?sr(e,i,r,a):ur(e,i,r,a)}function Xt(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Jt(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 er(e,t,r,a){void 0!==e[t]&&"boolean"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a boolean."})}function tr(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(tr):Xt(e)&&Object.values(e).every(tr))}function rr(e,t,r,a){void 0!==e[t]&&(!Xt(e[t])||!tr(e[t]))&&a.push({path:`${r}.${t}`,message:"Expected a JSON object."})}function ar(e){return e.every(tr)}function ir(e,t,r,a){let i=new Set(t);for(let t of Object.keys(e))i.has(t)||a.push({path:`${r}.${t}`,message:"Unexpected property."})}function sr(e,t,r,a){("string"!=typeof e[t]||!e[t])&&a.push({path:`${r}.${t}`,message:"Expected a non-empty string."})}function or(e,t,r,a,i){("string"!=typeof e[t]||!a.includes(e[t]))&&i.push({path:`${r}.${t}`,message:`Expected one of: ${a.join(", ")}.`})}function nr(e,t,r,a){let i=e[t];if(void 0!==i)return Xt(i)?i:void a.push({path:`${r}.${t}`,message:"Expected an object."})}function lr(e,t,r,a){let i=e[t];if(void 0!==i)return Array.isArray(i)?i:void a.push({path:`${r}.${t}`,message:"Expected an array."})}function cr(e,t,r){e?.some(e=>"string"!=typeof e||!e)&&r.push({path:t,message:"Expected non-empty string values."})}function dr(e,t,r,a,i){void 0!==e[t]&&or(e,t,r,a,i)}function ur(e,t,r,a){void 0!==e[t]&&"string"!=typeof e[t]&&a.push({path:`${r}.${t}`,message:"Expected a string."})}function pr(e,t,r){Xt(e)?(ir(e,["id","name","kind"],t,r),sr(e,"kind",t,r),ur(e,"id",t,r),ur(e,"name",t,r)):r.push({path:t,message:"Expected an actor object."})}function fr(e,t){let r=nr(e,"reception","$",t);if(!r)return;ir(r,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);let a=lr(r,"channels","$.reception",t);a||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),a?.forEach((e,r)=>{let a=`$.reception.channels[${r}]`;Xt(e)?(ir(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],a,t),or(e,"channel",a,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),dr(e,"disclosure",a,["summary","standard","detailed"],t),dr(e,"rawData",a,["deny","bounded","allow"],t),er(e,"navigation",a,t),er(e,"interactionInstructions",a,t),Jt(e,"tokenBudget",a,t),cr(lr(e,"privacyNotes",a,t),a+".privacyNotes",t)):t.push({path:a,message:"Expected a channel object."})});for(let e of["strengths","risks","scaffolds","manualChecks"])cr(lr(r,e,"$.reception",t),"$.reception."+e,t);ur(r,"audience","$.reception",t),ur(r,"description","$.reception",t),er(r,"dataFallback","$.reception",t)}function hr(e,t){let r=nr(e,"form","$",t);r&&(ir(r,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),ur(r,"chartFamily","$.form",t),ur(r,"whyThisForm","$.form",t),cr(lr(r,"risks","$.form",t),"$.form.risks",t),cr(lr(r,"misuse","$.form",t),"$.form.misuse",t),lr(r,"rejectedAlternatives","$.form",t)?.forEach((e,r)=>{let a=`$.form.rejectedAlternatives[${r}]`;Xt(e)?(ir(e,["representation","reason"],a,t),sr(e,"representation",a,t),sr(e,"reason",a,t)):t.push({path:a,message:"Expected an alternative object."})}))}function yr(e,t){let r=nr(e,"contestability","$",t);r&&(ir(r,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),er(r,"sourceRequestsAllowed","$.contestability",t),lr(r,"challenges","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.challenges[${r}]`;if(Xt(e)){ir(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],a,t),sr(e,"id",a,t),sr(e,"claimId",a,t),sr(e,"reason",a,t),or(e,"status",a,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&pr(e.raisedBy,a+".raisedBy",t);for(let r of["raisedAt","counterclaimId","resolution"])ur(e,r,a,t)}else t.push({path:a,message:"Expected a challenge object."})}),lr(r,"corrections","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.corrections[${r}]`;if(!Xt(e))return void t.push({path:a,message:"Expected a correction object."});ir(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],a,t),sr(e,"id",a,t),sr(e,"reason",a,t);let i=lr(e,"affectedClaimIds",a,t);i||t.push({path:a+".affectedClaimIds",message:"Expected an affected-claim array."}),cr(i,a+".affectedClaimIds",t),cr(lr(e,"replacementClaimIds",a,t),a+".replacementClaimIds",t),ur(e,"createdAt",a,t),void 0!==e.createdBy&&pr(e.createdBy,a+".createdBy",t)}),lr(r,"alternativeViews","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.alternativeViews[${r}]`;Xt(e)?(ir(e,["id","label","rationale"],a,t),sr(e,"id",a,t),sr(e,"label",a,t),ur(e,"rationale",a,t)):t.push({path:a,message:"Expected an alternative-view object."})}),lr(r,"editorialExceptions","$.contestability",t)?.forEach((e,r)=>{let a=`$.contestability.editorialExceptions[${r}]`;Xt(e)?(ir(e,["ruleId","rationale","owner","reviewAt"],a,t),sr(e,"ruleId",a,t),sr(e,"rationale",a,t),ur(e,"owner",a,t),ur(e,"reviewAt",a,t)):t.push({path:a,message:"Expected an editorial-exception object."})}))}function mr(e,t){let r=nr(e,"accountability","$",t);r&&(ir(r,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),lr(r,"authors","$.accountability",t)?.forEach((e,r)=>pr(e,`$.accountability.authors[${r}]`,t)),cr(lr(r,"dataSources","$.accountability",t),"$.accountability.dataSources",t),ur(r,"generatedBy","$.accountability",t),ur(r,"codeRef","$.accountability",t),lr(r,"reviews","$.accountability",t)?.forEach((e,r)=>{let a=`$.accountability.reviews[${r}]`;if(Xt(e)){ir(e,["id","status","reviewer","reviewedAt","rationale","policyId"],a,t),sr(e,"id",a,t),or(e,"status",a,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&pr(e.reviewer,a+".reviewer",t);for(let r of["reviewedAt","rationale","policyId"])ur(e,r,a,t)}else t.push({path:a,message:"Expected a review object."})}),lr(r,"actions","$.accountability",t)?.forEach((e,r)=>{let a=`$.accountability.actions[${r}]`;if(!Xt(e))return void t.push({path:a,message:"Expected an action object."});ir(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],a,t),sr(e,"id",a,t),sr(e,"action",a,t);let i=lr(e,"claimIds",a,t);i||t.push({path:a+".claimIds",message:"Expected a claim identifier array."}),cr(i,a+".claimIds",t),void 0!==e.actor&&pr(e.actor,a+".actor",t);for(let r of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])ur(e,r,a,t);dr(e,"status",a,["proposed","taken","reversed","invalidated"],t)}))}function gr(e,t){let r=nr(e,"inheritance","$",t);if(r){ir(r,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(let e of["requiredPaths","prohibitedExports","sourceArtifactIds"])cr(lr(r,e,"$.inheritance",t),"$.inheritance."+e,t);dr(r,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),dr(r,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),dr(r,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function vr(e,t){fr(e,t),hr(e,t),yr(e,t),mr(e,t),gr(e,t)}function br(e){for(let t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function kr(e,t){if(void 0===e||Xt(e)){if(Xt(e))for(let[r,a]of Object.entries(e)){let e="$.fieldStatus."+r;if(!Xt(a)||"string"!=typeof a.status){t.push({path:e,message:"Expected a field state with a status."});continue}ir(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."}),ur(a,"reason",e,t),ur(a,"reviewedBy",e,t),er(a,"derived",e,t);let i=Object.prototype.hasOwnProperty.call(xc,r)?xc[r]:void 0,s="model-proposal"===a.suppliedBy,o=s&&!0===i?.modelMayPropose&&"known"!==a.status;i&&"known"===a.status&&"string"!=typeof a.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${r}" must identify an allowed supplier.`}),i&&"string"==typeof a.suppliedBy&&!o&&!i.suppliedBy.includes(a.suppliedBy)&&t.push({path:e+".suppliedBy",message:`Field "${r}" cannot be supplied by ${a.suppliedBy}.`}),i&&!0===a.derived&&!i.derivable&&t.push({path:e+".derived",message:`Field "${r}" cannot be marked as derived.`}),i&&s&&(!i.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"===i?.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 xr(e,t){let r="$.time";ir(e,[...wc,...Object.keys($c),"sources"],r,t);for(let a of wc)ur(e,a,r,t);for(let[a,i]of Object.entries($c)){let s=nr(e,a,r,t);s&&Kt(s,i,`${r}.${a}`,t)}lr(e,"sources",r,t)?.forEach((e,a)=>{let i=`${r}.sources[${a}]`;Xt(e)?Kt(e,Sc,i,t):t.push({path:i,message:"Expected a source object."})})}function Cr(e){try{return Ar(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function Ar(e){let t=[],r=[];if(!Xt(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:r};let a=M(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(ir(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),"0.1"!==e.contractVersion&&t.push({path:"$.contractVersion",message:"Expected contract version 0.1."}),Xt(e.artifact)){ir(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),sr(e.artifact,"id","$.artifact",t),or(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(let r of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])ur(e.artifact,r,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(Xt(e.purpose))if(Array.isArray(e.purpose.intents)){ir(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,r)=>{(!Xt(e)||"string"!=typeof e.id||!e.id)&&t.push({path:`$.purpose.intents[${r}].id`,message:"Expected a non-empty intent identifier."}),Xt(e)&&ir(e,["id","strength","source","rationale"],`$.purpose.intents[${r}]`,t),Xt(e)&&void 0!==e.strength&&or(e,"strength",`$.purpose.intents[${r}]`,["primary","secondary"],t),Xt(e)&&(dr(e,"source",`$.purpose.intents[${r}]`,["author","derived","model-proposal","import"],t),ur(e,"rationale",`$.purpose.intents[${r}]`,t))});for(let r of["allowedUses","prohibitedUses"])cr(lr(e.purpose,r,"$.purpose",t),"$.purpose."+r,t);dr(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),ur(e.purpose,"communicativeAct","$.purpose",t),ur(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(!Xt(e))return void t.push({path:`$.claims[${r}]`,message:"Expected a claim object."});ir(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${r}]`,t),sr(e,"id",`$.claims[${r}]`,t),or(e,"kind",`$.claims[${r}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),or(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."}),cr(lr(e,"supersedes",`$.claims[${r}]`,t),`$.claims[${r}].supersedes`,t),ur(e,"text",`$.claims[${r}]`,t),ur(e,"asOf",`$.claims[${r}]`,t),rr(e,"scope",`$.claims[${r}]`,t),cr(lr(e,"tags",`$.claims[${r}]`,t),`$.claims[${r}].tags`,t),void 0!==e.authoredBy&&pr(e.authoredBy,`$.claims[${r}].authoredBy`,t);let a=nr(e,"review",`$.claims[${r}]`,t);a&&(ir(a,["status","reviewer","reviewedAt","rationale"],`$.claims[${r}].review`,t),or(a,"status",`$.claims[${r}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==a.reviewer&&pr(a.reviewer,`$.claims[${r}].review.reviewer`,t),ur(a,"reviewedAt",`$.claims[${r}].review`,t),ur(a,"rationale",`$.claims[${r}].review`,t));let i=nr(e,"uncertainty",`$.claims[${r}]`,t);if(i){ir(i,["kind","lower","upper","confidence","unit","description"],`$.claims[${r}].uncertainty`,t),or(i,"kind",`$.claims[${r}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(let e of["lower","upper","confidence"])Jt(i,e,`$.claims[${r}].uncertainty`,t);ur(i,"unit",`$.claims[${r}].uncertainty`,t),ur(i,"description",`$.claims[${r}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,r)=>{if(!Xt(e))return void t.push({path:`$.evidence[${r}]`,message:"Expected an evidence object."});ir(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${r}]`,t),sr(e,"id",`$.evidence[${r}]`,t),or(e,"role",`$.evidence[${r}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(let a of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])ur(e,a,`$.evidence[${r}]`,t);rr(e,"scope",`$.evidence[${r}]`,t);let a=nr(e,"source",`$.evidence[${r}]`,t);if(a){ir(a,["name","uri","version","retrievedAt","publisher"],`$.evidence[${r}].source`,t);for(let e of["name","uri","version","retrievedAt","publisher"])ur(a,e,`$.evidence[${r}].source`,t)}let i=nr(e,"transformation",`$.evidence[${r}]`,t);if(i){ir(i,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${r}].transformation`,t),sr(i,"id",`$.evidence[${r}].transformation`,t),or(i,"kind",`$.evidence[${r}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);let e=lr(i,"inputEvidenceIds",`$.evidence[${r}].transformation`,t);e?cr(e,`$.evidence[${r}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${r}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),cr(lr(i,"assumptions",`$.evidence[${r}].transformation`,t),`$.evidence[${r}].transformation.assumptions`,t),ur(i,"description",`$.evidence[${r}].transformation`,t),ur(i,"implementation",`$.evidence[${r}].transformation`,t),ur(i,"performedAt",`$.evidence[${r}].transformation`,t),rr(i,"parameters",`$.evidence[${r}].transformation`,t),void 0!==i.performedBy&&pr(i.performedBy,`$.evidence[${r}].transformation.performedBy`,t)}let s=nr(e,"sample",`$.evidence[${r}]`,t);if(s){ir(s,["rowCount","fields","values","truncated"],`$.evidence[${r}].sample`,t),cr(lr(s,"fields",`$.evidence[${r}].sample`,t),`$.evidence[${r}].sample.fields`,t);let e=lr(s,"values",`$.evidence[${r}].sample`,t);e&&!ar(e)&&t.push({path:`$.evidence[${r}].sample.values`,message:"Expected JSON values."}),Jt(s,"rowCount",`$.evidence[${r}].sample`,t),er(s,"truncated",`$.evidence[${r}].sample`,t)}dr(e,"relationship",`$.evidence[${r}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),kr(e.fieldStatus,t);let i=nr(e,"time","$",t);return i&&xr(i,t),vr(e,t),rr(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 wr(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function $r(e,t){if(!t||!wr(e)||!Array.isArray(e.evidence))return[];let r=[];return e.evidence.forEach((e,t)=>{wr(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,r.push(`$.evidence[${t}].sample`))}),r}function Sr(e,t={}){try{return Br(e,t)}catch{let t=M(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function Br(e,t){if(!wr(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};let r=Qt(e),a=[.../* @__PURE__ */new Set([...r.excludedPaths,...M(e)])].sort(),i=r.value,s=$r(i,t.excludeEvidenceSamples),o=s.length?["Bounded evidence samples were excluded by the transfer policy."]:[],n=i?.contractVersion;if("string"!=typeof n||!n)return{contract:i,transfer:{status:"invalid",omittedPaths:[...a,...s],warnings:["Artifact contract is missing a string contractVersion.",...o]}};if("0.1"!==n)return{contract:i,transfer:{status:a.length>0?"invalid":"unsupported-version",omittedPaths:[...a,...s],warnings:[`Contract version ${n} is not interpreted by this runtime.`,...a.length>0?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...o]}};let l=Cr(i),c=[...l.errors.map(({path:e,message:t})=>`${e}: ${t}`),...l.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...a.length?[`Non-JSON values could not be preserved at: ${a.join(", ")}.`]:[],...o];return{contract:i,transfer:{status:!l.valid||a.length>0?"invalid":s.length>0?"excluded":"preserved",omittedPaths:[...a,...s],warnings:c}}}function Pr(e){let t=Sr(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 Wr(e){let t=Object.entries(e).filter(([e,t])=>It(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function Lr(e,t=[]){if(void 0===e)return;let 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 Zt(r.length>0?{data:e,transformations:r}:e).fingerprint}function Mr(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!It(e,t)&&"recipeId"!==e))}function Rr(e,t,r,a=Wr(t)){let i=Mr(t),s=0===M(i).length?Zt(i).fingerprint:void 0,o=void 0!==a&&0===M(a).length?Lr(a,e.evidence):void 0,n="ChartRecipe"===r&&"string"==typeof t.recipeId?t.recipeId:r,l=[],c=[];return void 0!==n&&(void 0===e.artifact.component?c.push("artifact.component"):e.artifact.component!==n&&l.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===s?c.push("artifact.configFingerprint"):e.artifact.configFingerprint!==s&&l.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&o?e.artifact.dataFingerprint!==o&&l.push("artifact.dataFingerprint"):c.push("artifact.dataFingerprint"),{status:l.length>0?"mismatch":c.length>0?"unknown":"match",mismatchPaths:l,unknownPaths:c}}function Ir(e,t,r){let a=Rr(e,t,r);return{mismatchPaths:[...a.mismatchPaths,...void 0!==r&&a.unknownPaths.includes("artifact.component")?["artifact.component"]:[]]}}function Er(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;let a=Zt(e[r]),i=Zt(t[r]);return a.excludedPaths.length>0||a.fingerprint!==i.fingerprint}).map(e=>"props."+e).sort()}function Nr(e,t,r,a){return Zt({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 Tr(e,t,r,a,i){let s=Wr(r),o={...e,serializedConfigFingerprint:Zt(Mr(r)).fingerprint,serializedDataFingerprint:void 0===s?null:Zt(s).fingerprint};return{...o,transferFingerprint:Nr(o,t,a,i)}}function Fr(e,t,r,a,i){if(!t)return{};let s=Pr(t),o=i.recipeId??e,n=Ir(t,r,o),l=Er(r,a),c=Ir(t,a,o);return n.mismatchPaths.length>0?{artifactContract:s.contract,artifactTransfer:Tr({status:"invalid",omittedPaths:n.mismatchPaths,warnings:["The artifact contract fingerprints do not match the supplied chart props or data."]},e,a,s.contract,i)}:l.length>0?{artifactContract:s.contract,artifactTransfer:Tr({status:"excluded",omittedPaths:l,warnings:["Chart props or data were excluded from the serialized configuration."]},e,a,s.contract,i)}:c.mismatchPaths.length>0?{artifactContract:s.contract,artifactTransfer:Tr({status:"invalid",omittedPaths:c.mismatchPaths,warnings:["Serialized chart props or data differ from the values bound to the artifact contract."]},e,a,s.contract,i)}:{artifactContract:s.contract,artifactTransfer:Tr(s.transfer,e,a,s.contract,i)}}function Or(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function jr(e,t){return!(!It(e,t)||"areas"===e&&"string"==typeof t)}function Dr(e,t,r){if(r?.selections&&M(r.selections).length>0)throw new TypeError("Serialized selection state must contain only values that survive JSON serialization unchanged.");let a=I(e)??N(t.recipe)??N(t.recipeId);if(a)return zr(a,t,r);if(!h(e))throw Error(`Unknown component "${e}". Known components: ${dl.join(", ")}`);let i=!1!==r?.includeData,s={};for(let[e,r]of Object.entries(t))if(null!=r&&!Pc.has(e)&&(i||!jr(e,r))&&"function"!=typeof r&&0>=M(r).length)try{Or(s,e,Wc(r))}catch{}let o=/* @__PURE__ */(new Date).toISOString(),n={version:Bc,createdAt:o,...r?.selections?{selections:r.selections}:{}};return{component:e,props:s,version:Bc,createdAt:o,...Fr(e,r?.artifactContract,t,s,n),...r?.selections?{selections:r.selections}:{}}}function _r(e,t,r){let a={};for(let[i,s]of Object.entries(e))if(null!=s&&!Pc.has(i)&&"recipeId"!==i&&(t||!jr(i,s))){if("function"==typeof s){if(r)throw Error(`Portable recipe prop "${i}" is not JSON-safe.`);continue}if(M(s).length>0){if(r)throw Error(`Portable recipe prop "${i}" is not JSON-safe.`);continue}Or(a,i,Wc(s))}return a}function zr(e,t,r){let a=!1!==r?.includeData,i=M(e);if("portable"===e.portability&&i.length>0)throw Error(`Portable recipe "${e.id}" has non-JSON definition values at: ${i.join(", ")}.`);let s=_r(t,a,"portable"===e.portability),o=e.intents.map(Et).filter(e=>!!e),n=e.layout&&"object"==typeof e.layout&&"string"==typeof e.layout.id?e.layout.id:void 0,l=n?E(n):void 0,c=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(l&&c&&(l.version!==c.version||l.fingerprint!==c.fingerprint))throw Error(`Recipe layout "${n}" registry identity does not match its portable declaration.`);let d=l??c;if("portable"===e.portability&&n&&!d)throw Error(`Portable recipe layout "${n}" must be registered with an explicit version identity.`);let u={name:e.name,intents:o,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily,...e.version?{recipeVersion:e.version}:{},...0===i.length?{definitionFingerprint:Zt(e).fingerprint}:{},...n?{layoutId:n}:{},...d?{layoutVersion:d.version}:{},...d?.fingerprint?{layoutFingerprint:d.fingerprint}:{}},p=/* @__PURE__ */(new Date).toISOString();if("portable"===e.portability){if(M(s).length>0)throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);let a={version:Bc,createdAt:p,recipeId:e.id,portable:!0,manifest:u,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:s,manifest:u,version:Bc,createdAt:p,...Fr("ChartRecipe",r?.artifactContract,t,s,a),...r?.selections?{selections:r.selections}:{}}}let f="Recipe contains or may depend on non-serializable local layout callbacks.",h=["This config is inspectable but cannot be rendered remotely by CLI or MCP."],y={version:Bc,createdAt:p,recipeId:e.id,portable:!1,manifest:u,reason:f,warnings:h,...r?.selections?{selections:r.selections}:{}};return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:f,warnings:h,props:s,manifest:u,version:Bc,createdAt:p,...Fr("ChartRecipe",r?.artifactContract,t,s,y),...r?.selections?{selections:r.selections}:{}}}function Ur(e){try{if(!e||"object"!=typeof e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}catch{return!1}}function Gr(e){if(!Ur(e))throw Error("Invalid chart config: expected a plain object");let t=M(e);if(t.length>0)throw new TypeError(`Chart config contains values that cannot survive JSON serialization at: ${t.join(", ")}.`);if(e.version!==Bc)throw Error(`Unsupported chart config version ${e.version+""}; expected ${Bc}.`);if("string"!=typeof e.component||!e.component.trim())throw Error("Invalid chart config: missing component");if(!Ur(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&&!Ur(e.selections))throw Error("Invalid chart config: selections must be a plain object");if(void 0!==e.manifest){if(!Ur(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 Vr(e){Gr(e);let{props:t}=e,r="LocalChartRecipe"===e.component?"ChartRecipe":e.component;if("ChartRecipe"!==r&&!h(r))throw Error(`Cannot project unknown component "${r}" to JSX.`);let a=["<"+r];e.recipeId&&a.push(` recipeId={${Hr(e.recipeId)}}`);for(let[e,r]of Object.entries(t)){if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)){let t={};Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),a.push(` {...${Hr(t)}}`);continue}if("string"==typeof r)a.push(qr(r)?` ${e}="${r}"`:` ${e}={${Hr(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{let t=Hr(r);a.push(80>t.length?` ${e}={${t}}`:` ${e}={${Hr(r,2)}}`)}}return a.push("/>"),a.join("\n")}function qr(e){return!/["&<>{}\r\n\u2028\u2029]/.test(e)}function Hr(e,t){return JSON.stringify(e,null,t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Yr(e,t){if("function"==typeof e)return t=>+e(t);let r=e||t;return e=>+e[r]}function Qr(e,t){if("function"==typeof e)return e;let r=e||t;return e=>e[r]}function Zr(e,t){return Mc.has(e)||Rc.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 Kr(e){for(let t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){let r=e[t];if("string"==typeof r&&r)return r}}function Xr(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function Jr(e,t={}){let r=!0===t.showRetractedAnnotations,a=!0===t.showSupersededAnnotations,i=/* @__PURE__ */new Set;for(let t of e){let e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&i.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!r)return!1;let t=e?.provenance?.stableId;return!(t&&i.has(t)&&!a)})}function ea(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function ta(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 ra(e,t,r,a){let i=Dt(e,["nominal","ordinal"]),s=Dt(e,["quantitative"]),o=i?Ot(i,r,t):void 0,n=s?Ot(s,r,t):void 0,l=i?.role??o??"category",c=s?.role??n??"value",d=e.encodings??[],u=d.length?d.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${l} and ${c} are mapped through the recipe's declared visual semantics`,{number:p,percent:f}=ta(a),h=/* @__PURE__ */new Map;if(o&&n)for(let e of t){let t=(e[o]??"Uncategorized")+"",r=Number(e[n]);Number.isFinite(r)&&h.set(t,(h.get(t)??0)+r)}let y=[...h].sort((e,t)=>t[1]-e[1]),m=y.reduce((e,[,t])=>e+t,0),g=y[0],v=y[1],b=m>0?((g?.[1]??0)+(v?.[1]??0))/m:0,k=e.intents.map(e=>({id:Et(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,x=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${l} and ${c}. ${ea(u)}.`,l2:y.length>0?`${y.length} categories total ${p.format(m)}. ${g[0]} accounts for ${p.format(g[1])}${m>0?` (${f.format(g[1]/m)})`:""}${v?`, followed by ${v[0]} at ${p.format(v[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>y.length?g?g[0]+" is the only represented category.":"No quantitative pattern can be derived from the available data.":.5>b?`The total is distributed across ${y.length} categories without the first two forming a majority.`:`Most of the total is concentrated in ${g[0]} and ${v[0]}, which together account for ${f.format(b)}.`,l4:`The chart is intended for ${k??"explanation"}${x?` with a ${x} audience`:""}: ${e.designContract.whyCustom}`}}function aa(e,t,r={}){let a=Tt(t),i=Nt(t),s=r.locale??"en",o=("function"==typeof e.description?e.description({data:a,config:i,locale:s}):void 0)?.levels??ra(e,a,i,s),n=r.levels??["l1","l2","l3","l4"],l={};for(let e of n)o[e]&&(l[e]=o[e]);let c=["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:c,levels:l,...d?.length?{caveats:d}:{}}}function ia(e){let 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))),i=$e(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),s=Pe(e.seed??1),o=e.idPrefix??"mechanical";return Array.from({length:a},(e,t)=>{let a=0;for(let e=0;r>e;e+=1)s()<i&&(a+=1);let n=r/2;return{id:`${o}-${t}`,value:a,mechanical:!0,pegRows:r,branchProbability:i,pathRights:a,side:n>a?"left":a>n?"right":"center"}})}function sa(e){let{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");let{rows:i}=Me(e.data,"event"),s=i.flatMap((t,r)=>{let a=we(Ae(t,r,e.timeAccessor));return null==a?[]:[{datum:t,index:r,eventTime:a,arrivalTime:we(Ae(t,r,e.arrivalAccessor))??a,watermarkAtArrival:0,late:!1}]}),o="function"==typeof r?null:we(r?.value),n="function"==typeof r?t:we(r?.delay)??t,l=-1/0,c=-1/0;for(let e of s.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){l=Math.max(l,e.eventTime);let i="function"==typeof r?we(r(l)):l-n;c=o??Math.max(c,i??l-t);let s=a?we(Ae(e.datum,e.index,a)):null;e.watermarkAtArrival=s??c,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:s,watermarkValue:s.length?c:o??-n}}function oa(e,t){let 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:[],i=Math.max(2,Math.round(we(t.bins)??21)),s=Math.max(1,Math.round(we(t.pegRows)??i-1));if(r&&(a="GaltonBoardChart"===e?ia({bins:i,count:t.mechanicalCount,pegRows:s,branchProbability:t.branchProbability,seed:t.seed}):We({count:t.mechanicalCount,categories:t.mechanicalCategories,unitValue:t.unitValue,seed:t.seed})),a=Me(a,"UnitPileChart"===e?"pile":"GaltonBoardChart"===e?"galton":"EventDropChart"===e?"event":"collision-swarm").rows,"UnitPileChart"===e){let e=/* @__PURE__ */new Map,i=t.valueAccessor??(r?"value":void 0);return a.forEach((r,a)=>{let s=(Ae(r,a,t.categoryAccessor??"category")??"unknown")+"",o=i?we(Ae(r,a,i)):1;e.set(s,(e.get(s)??0)+Math.max(0,o??0))}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("GaltonBoardChart"===e){let e=a.map((e,r)=>we(Ae(e,r,t.valueAccessor??"value"))).filter(e=>null!=e),o=r?[0,s]:Be(t.valueExtent),n=o?.[0]??(e.length?Math.min(...e):0),l=o?.[1]??(e.length?Math.max(...e):1),c=n===l?1:l-n,d=Array.from({length:i},(e,t)=>({label:t+1+"",value:0}));for(let t of e)d[Math.max(0,Math.min(i-1,Math.floor((t-n)/c*i)))].value+=1;return{generated:r,rows:d}}if("CollisionSwarmChart"===e){let e=/* @__PURE__ */new Map;return a.forEach((r,a)=>{if(null==we(Ae(r,a,t.xAccessor??"x")))return;let i=t.groupAccessor?(Ae(r,a,t.groupAccessor)??"All")+"":"All";e.set(i,(e.get(i)??0)+1)}),{generated:r,rows:Array.from(e,([e,t])=>({label:e,value:t}))}}if("EventDropChart"===e){let e=we(t.windows?.size??10);if(null==e||0>=e)return null;let{events:i}=sa({data:a,timeAccessor:t.timeAccessor??"time",arrivalAccessor:t.arrivalAccessor??"arrivalTime",windowSize:e,watermark:t.watermark,watermarkAtArrivalAccessor:t.watermarkAtArrivalAccessor}),s=i.map(e=>e.eventTime),o=s.length?Math.min(...s):0,n=s.length?Math.max(...s):o+e,l=Math.min(we(t.timeExtent?.[0])??o,o),c=Math.max(we(t.timeExtent?.[1])??n,n),d=Math.floor(l/e)*e,u=Math.max(1,Math.ceil((c-d+e)/e)),p=Array.from({length:u},(t,r)=>({label:`${d+r*e}-${d+(r+1)*e}`,value:0,secondary:0,secondaryLabel:"late"}));for(let t of i){let r=p[Math.max(0,Math.min(u-1,Math.floor((t.eventTime-d)/e)))];t.late?r.secondary+=1:r.value+=1}return{generated:r,rows:p}}return null}function na(e){let t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}function la(e,t){let r=e.physics&&"object"==typeof e.physics?e.physics:null,a=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,i=[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(i)?i.map((e,r)=>{if(!e||"object"!=typeof e)return null;let a=e,i=na(a.count??a.value??a.total??a.bodies??a.events);if(null==i)return null;let s=a.label??a.id??a.name??"container "+(r+1),o=na(a.secondary??a.secondaryCount),n=na(a.observed??a.observedCount);return{label:Xr(s,t),count:i,...null!=o?{secondary:o}:{},..."string"==typeof a.secondaryLabel&&a.secondaryLabel?{secondaryLabel:a.secondaryLabel}:{},...null!=n?{observed:n}:{}}}).filter(e=>null!=e):null}function ca(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}function da(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"UnitPileChart"===e?"unit":"body"}function ua(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 pa(e,t){if(0>=t)return"0%";let r=e/t*100;return(10>r?Math.round(10*r)/10:Math.round(r))+"%"}function fa(e,t,r,a,i,s,o=null){let n=ca(e),l=o&&"EventDropChart"===e?"accepted event":da(e),c=o?o.generated?"The generated sample projection":"The source projection":"The settled projection";if(i.has("l1")&&(a.l1=ua(e,t)),!i.has("l2")&&!i.has("l3"))return;if(!r||0===r.length)return void(i.has("l2")&&(a.l2=o?"No valid source records are available.":"No settled projection is loaded yet."));let d=r.reduce((e,t)=>e+t.count,0),u=r.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),p=u[0]??r.slice().sort((e,t)=>t.count-e.count)[0];if(!p)return;let f=r.reduce((e,t)=>e+(t.secondary??0),0),h=r.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(i.has("l2"))if(o&&"EventDropChart"===e)a.l2=`${c} classifies ${s(d+f)} ${ha(d+f,"event")} across ${r.length} ${ha(r.length,n)}: ${s(d)} accepted and ${s(f)} late.`;else if(0===u.length)a.l2=`${c} contains ${s(d)} ${ha(d,l)} across ${r.length} ${ha(r.length,n)}; no ${ha(2,n)} are non-empty yet.`;else{let e=f>0?` ${s(f)} ${ha(f,l)} ${1===f?"is":"are"} marked ${h}.`:"";a.l2=`${c} contains ${s(d)} ${ha(d,l)} across ${r.length} ${ha(r.length,n)}; ${u.length} ${ha(u.length,n)} ${1===u.length?"is":"are"} non-empty. The largest ${n} is ${p.label} with ${s(p.count)} ${ha(p.count,l)}.${e}`}if(i.has("l3")&&d>0&&u.length>0){let e=u.find(e=>e!==p),t=pa(p.count,d);a.l3=e?`${c} is most concentrated in ${p.label}, which holds ${s(p.count)} ${ha(p.count,l)} (${t}); ${e.label} follows with ${s(e.count)} ${ha(e.count,l)}.`:`${c} is concentrated in ${p.label}, which holds all ${s(p.count)} ${ha(p.count,l)}.`}}function ha(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function ya(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()}function ma(e){return Ec[e]||ya(e)+" chart"}function ga(e){let t,r=0;for(let[a,i]of Object.entries(e))if("number"==typeof i&&i>0){if(i>r){t=a,r=i;continue}if(i===r&&void 0!==t){let e=Dc.indexOf(a),r=Dc.indexOf(t);-1!==e&&(-1===r||r>e)&&(t=a)}}return t}function va(e){return"BumpChart"===e?"ranking":Rc.has(e)||"StackedAreaChart"===e?"apportioning":Fc.has(e)?"relating":Mc.has(e)?"comparing":Ic.has(e)?"characterizing":Lc.has(e)?"tracking":Nc.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}function ba(e){if(e){if("fits"in e||"buildProps"in e){let t=e,r={};for(let[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 ka(e,t){let r=ba(t);if(r?.act)return r.act;if(r?.intentScores){let e=ga(r.intentScores);if(e&&Oc[e]&&(r.intentScores[e]??0)>=3)return Oc[e]}return r?.family?jc[r.family]:va(e)}function xa(e){let t=e.annotations;return!!Array.isArray(t)&&t.some(e=>{if(!e||"object"!=typeof e)return!1;let t=e;if("string"!=typeof t.type||!zc.has(t.type))return!1;let r=t.provenance;return!(!r||"object"!=typeof r)&&(Uc.has(r.authorKind)||Gc.has(r.source)||Vc.has(r.basis))})}function Ca(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 Aa(e,t,r,a){let i=0,s=0,o=1/0,n=-1/0,l=null,c=null,d=0,u=0,p=null,f=null,h=NaN,y=NaN;for(let r of e){let e=t(r);Number.isFinite(e)&&(0===i&&(h=e,p=r),y=e,f=r,o>e&&(o=e,l=r,d=i),e>n&&(n=e,c=r,u=i),i++,s+=e)}return 0===i?null:{count:i,min:o,max:n,mean:s/i,minLabel:Xr(null!=l?r(l):null,a),maxLabel:Xr(null!=c?r(c):null,a),first:h,last:y,firstLabel:Xr(null!=p?r(p):null,a),lastLabel:Xr(null!=f?r(f):null,a),minIndex:d,maxIndex:u}}function wa(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 $a(e){let 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 Sa(e){let t=qc["string"==typeof e.type?e.type:"annotation"]||"an annotation",r=$a(e),a=r?r+t.replace(/^an? /,""):t,i="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return i?`${a} labeled "${i}"`:a}function Ba(e){let t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;let r=Jr(t.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return;let a=r.map(Sa),i=a.slice(0,5),s=a.length-i.length,o=wa(i)+(s>0?`, and ${s} more`:""),n=r.length;return`The author has marked ${1===n?"one feature":n+" features"} on this chart: ${o}.`}function Pa(e,t,r={}){let a=void 0!==r.levels,i=new Set(r.levels??["l1","l2","l3"]);!a&&(r.capability||xa(t))&&i.add("l4");let s=Ft(e,t,r.recipe);if(s){let e=["l1","l2","l3","l4"].filter(e=>i.has(e));!a&&!e.includes("l4")&&e.push("l4");let o=aa(s,t,{levels:e,locale:r.locale,audience:r.audience,includeCaveats:r.includeCaveats}),n=Ba(t);return{...o,text:n?`${n} ${o.text}`.trim():o.text,...n?{annotations:n}:{}}}let o=Ca(r.locale??"en"),n=ma(e),l=Array.isArray(t.data)?t.data:null,c=Kr(t),d=Tc.has(e)?la(t,o):null,u=Tc.has(e)&&null===d?oa(e,t):null,{measure:p,measureFallback:f,dimension:h,dimensionFallback:y}=Zr(e,t),m="string"==typeof p&&p?p:f,g="string"==typeof h&&h?h:y,v={};if(Tc.has(e)&&fa(e,n,d??(u?la({projectionRows:u.rows},o):null),v,i,o,u),i.has("l1")&&!Tc.has(e))if("BumpChart"===e)v.l1=`A ${n} ranking ${c??"series"} by ${m} across ${g}.`;else if(Lc.has(e)||Mc.has(e))v.l1=`A ${n} of ${m} by ${g}`+(c?`, split by ${c}.`:".");else if(Rc.has(e))v.l1=`A ${n} showing ${m} across ${g} categories.`;else if(Ic.has(e))v.l1=`A ${n} of the distribution of ${m}`+(c?` by ${c}.`:".");else if(Nc.has(e)){let e=Array.isArray(t.nodes)?t.nodes.length:void 0,r=Array.isArray(t.edges)?t.edges.length:void 0,a=[null!=e?`${e} ${Fa(e,"node")}`:null,null!=r?`${r} ${Fa(r,"edge")}`:null].filter(Boolean);v.l1=`A ${n}${a.length?" with "+a.join(" and "):""}.`}else if("BigNumber"===e){let e="string"==typeof t.label?t.label:m;v.l1=`A single value${e?" for "+e:""}.`}else v.l1=`A ${n}.`;let b=Lc.has(e)||"BumpChart"===e||Mc.has(e)||Rc.has(e)||Ic.has(e),k=null;if((i.has("l2")||i.has("l3")||i.has("l4"))&&b&&l&&l.length>0&&(k=Aa(l,Yr(p,f),Qr(h,y),o)),i.has("l2")&&b&&(l&&0!==l.length?k&&(v.l2=Rc.has(e)?`${k.count} segments totaling ${o(Wa(k))}. Largest is ${k.maxLabel} at ${o(k.max)}; smallest is ${k.minLabel} at ${o(k.min)}.`:`${m} ranges from ${o(k.min)} (${k.minLabel}) to ${o(k.max)} (${k.maxLabel}), with a mean of ${o(k.mean)} across ${k.count} points.`):v.l2="No data is loaded yet."),i.has("l3")&&k&&!c&&Lc.has(e)?v.l3=La(k,m,o):i.has("l3")&&k&&!c&&Mc.has(e)&&(v.l3=`The highest ${g} is ${k.maxLabel} and the lowest is ${k.minLabel}.`),i.has("l4")){let a=xa(t)?"alerting":ka(e,r.capability);a&&(v.l4=Ma(a,e,t,c?null:k,m,g,o,r.audience))}let x=["l1","l2","l3","l4"].filter(e=>i.has(e)&&v[e]).map(e=>v[e]).join(" "),C=Ba(t);return{text:C?`${C} ${x}`.trim():x,levels:v,...C?{annotations:C}:{}}}function Wa(e){return e.mean*e.count}function La(e,t,r){let{first:a,last:i,min:s,max:o,maxLabel:n,minLabel:l,firstLabel:c,lastLabel:d,minIndex:u,maxIndex:p,count:f}=e,h=o-s,y=i-a;if(0===h)return`${Ta(t)} is constant at ${r(a)} across the series.`;if(.04>h/(Math.abs(e.mean)||1))return`${Ta(t)} ends roughly where it started (${r(a)} at ${c} to ${r(i)} at ${d}), ranging between ${r(s)} and ${r(o)}.`;let m=p>0&&f-1>p,g=u>0&&f-1>u,v=(o-Math.max(a,i))/h,b=(Math.min(a,i)-s)/h;return m&&v>.15?`Overall ${t} climbs to a peak of ${r(o)} (${n}), then falls to ${r(i)} (${d}).`:g&&b>.15?`Overall ${t} drops to a low of ${r(s)} (${l}), then recovers to ${r(i)} (${d}).`:.05>Math.abs(y)/h?`${Ta(t)} ends roughly where it started (${r(a)} at ${c} to ${r(i)} at ${d}), ranging between ${r(s)} and ${r(o)}.`:y>0?p===f-1?`Overall ${t} rises from ${r(a)} (${c}) to a peak of ${r(i)} (${d}).`:`Overall ${t} rises from ${r(a)} (${c}) to ${r(i)} (${d}), after peaking at ${r(o)} (${n}).`:u===f-1?`Overall ${t} falls from ${r(a)} (${c}) to a low of ${r(i)} (${d}).`:`Overall ${t} falls from ${r(a)} (${c}) to ${r(i)} (${d}), after dipping to ${r(s)} (${l}).`}function Ma(e,t,r,a,i,s,o,n){let l,c,d=_c[e],u=/^[aeiou]/i.test(d)?"an":"a";switch(e){case"locating":l="This is a map",c="read values by location";break;case"presenting":l="This is a single-value display",c=`read ${"string"==typeof r.label&&r.label?r.label:i} as the headline number`;break;case"tracing":l=`This is ${u} ${d} chart`,c="follow the movement between states";break;case"nesting":l=`This is ${u} ${d} chart`,c="read it for nested structure and how children sum into their parents";break;case"relating":l=`This is ${u} ${d} chart`,c=`read it for whether ${s} and ${i} move together`;break;default:l=`This is ${u} ${d} chart`,c=Ra(e,a,i,s,o,t)}return`${l}; ${c}.${Na(t,n)}`}function Ra(e,t,r,a,i,s){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 Ia(t,i,s);case"tracking":return`read it for the trajectory of ${r}, which ${Ea(t)} from ${i(t.first)} (${t.firstLabel}) to ${i(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${r} across ${a}; ${t.maxLabel} leads at ${i(t.max)}`;case"ranking":return`read it top to bottom by ${r}; ${t.maxLabel} ranks highest at ${i(t.max)}`;case"apportioning":{let e=t.mean*t.count,r=e>0?Math.round(t.max/e*100):null;return`read each ${a}'s share of the ${i(e)} total; ${t.maxLabel} is the largest at ${i(t.max)}${null!=r?` (${r}%)`:""}`}case"characterizing":return`read it for the spread of ${r}, from ${i(t.min)} to ${i(t.max)}`;default:return"read the highlighted features"}}function Ia(e,t,r){if(Mc.has(r)||Rc.has(r))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;let{first:a,last:i,min:s,max:o,minLabel:n,maxLabel:l,lastLabel:c,minIndex:d,maxIndex:u,count:p}=e,f=o-s;if(f>0){let e=u>0&&p-1>u,r=d>0&&p-1>d,h=(o-Math.max(a,i))/f,y=(Math.min(a,i)-s)/f;if(e&&h>.15)return`the peak of ${t(o)} at ${l} is the point to investigate`;if(r&&y>.15)return`the dip to ${t(s)} at ${n} is the point to investigate`;if(i>=o)return`the climb to ${t(i)} at ${c} warrants a closer look`;if(s>=i)return`the drop to ${t(i)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(o)}) and ${n} (${t(s)}) — are the points to check`}function Ea(e){let 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 Na(e,t){if(!t)return"";let r=t.familiarity?.[e];return"number"!=typeof r||r>2?"":` This ${ma(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}function Ta(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function Fa(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Oa(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function ja(e){return!!e&&"object"==typeof e}function Da(e,t,r,a){let i=Dt(t,["nominal","ordinal"]),s=t.dataRoles.filter(e=>"quantitative"===e.semanticType),o=i?Ot(i,r,a):void 0,n=[];o&&null!=e[o]&&n.push(e[o]+"");for(let t of s){let i=Ot(t,r,a);i&&null!=e[i]&&n.push(`${t.role}: ${e[i]+""}`)}return n.length>0?n.join(", "):"Data item"}function _a(e,t,r={}){let a=Tt(t),i=Nt(t),s=Math.max(1,r.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:a,config:i,locale:r.locale??"en"});let o=ja(e.navigation)?e.navigation:void 0,n=(o?.groupByRole?jt(e,o.groupByRole):void 0)??(o?.groupBy?.[0]?jt(e,o.groupBy[0])??e.dataRoles.find(e=>e.field===o.groupBy?.[0]):void 0)??Dt(e,["nominal","ordinal"]),l=n?Ot(n,i,a):void 0,c=(o?.idRole?jt(e,o.idRole):void 0)??Dt(e,["identifier"]),d=c?Ot(c,i,a):void 0,u={id:"root",role:"chart",label:o?.summaryTemplate?_t(o.summaryTemplate,void 0,e,i,a,{count:a.length}):`${e.name}: ${a.length} ${1===a.length?"item":"items"} represented.`,level:1,children:[]},p=0,f=(t,r,s)=>{let n=d?t[d]:void 0,l=o?.itemLabelTemplate?_t(o.itemLabelTemplate,t,e,i,a,{count:a.length}):Da(t,e,i,a);return{id:"datum-"+Oa(n??r),role:"datum",label:l,level:s,datum:t}};if(l){let e=/* @__PURE__ */new Map;for(let t of a){let r=(t[l]??"Uncategorized")+"",a=e.get(r);a?a.push(t):e.set(r,[t])}u.children=[...e].map(([e,t],r)=>{let a=t.slice(0,Math.max(0,s-p));p+=a.length;let i=a.map((e,t)=>f(e,1e5*r+t,3));return t.length>a.length&&i.push({id:"more-"+Oa(e),role:"datum",label:`…and ${t.length-a.length} more items`,level:3}),{id:"group-"+Oa(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:i}})}else{let e=a.slice(0,s);u.children=e.map((e,t)=>f(e,t,2)),a.length>e.length&&u.children.push({id:"more",role:"datum",label:`…and ${a.length-e.length} more items`,level:2})}return u}function za(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function Ua(e,t="—"){return null==e||""===e?t:"object"==typeof e?Ua(e.id??e.name??e.label,t):e+""}function Ga(e){if(null==e||""===e)return;let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function Va(e){return Ua(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function qa(e,t){let r=za(e,t,"children");return Array.isArray(r)?r:[]}function Ha(e,t,r){return`${e} ${1===e?t:r}`}function Ya(e,t){return 0===e.numericLeaves?"":e.numericLeaves===e.leaves?", leaf total "+t(e.leafTotal):`, known leaf total ${t(e.leafTotal)} across ${Ha(e.numericLeaves,"valued leaf","valued leaves")}`}function Qa(e){return"TreeDiagram"===e?"tree":"Treemap"===e?"treemap":"CirclePack"===e?"circle-packing":"orbit"}function Za(e,t,r,a){let i=t.data&&"object"==typeof t.data?t.data:null,s=t.childrenAccessor??"children",o=t.valueAccessor??"value",n=t.nodeLabel??t.nodeIdAccessor,l=/* @__PURE__ */new WeakMap,c=/* @__PURE__ */new WeakSet,d=e=>{let t=l.get(e);if(t)return t;if(c.has(e))return{descendants:0,depth:0,leaves:0,numericLeaves:0,leafTotal:0};c.add(e);let r,a=qa(e,s);if(0===a.length){let t=Ga(za(e,o,"value"));r={descendants:0,depth:1,leaves:1,numericLeaves:null==t?0:1,leafTotal:t??0}}else r=a.reduce((e,t)=>{let r=d(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 c.delete(e),l.set(e,r),r},u=0,p=(e,t,i,l)=>{let c=Ua(za(e,n,"name"),"item "+i);if(l.has(e))return{id:`hierarchy-${Va(i)}-cycle`,role:"datum",level:t,label:`Repeated hierarchy reference to ${c}; branch omitted.`};let f=qa(e,s),h=d(e);if(0===f.length){if(u>=r)return null;u+=1;let s=Ga(za(e,o,"value"));return{id:`hierarchy-${Va(i)}-${Va(c)}`,role:"datum",level:t,label:`${c}${null==s?"":": "+a(s)}.`,...null==s?{}:{value:s},datum:e}}let y=new Set(l);y.add(e);let m=[],g=0;for(let[e,a]of f.entries()){if(u>=r){g+=d(a).leaves;continue}let s=p(a,t+1,`${i}-${e}`,y);s&&m.push(s)}return g>0&&m.push({id:`hierarchy-${Va(i)}-more`,role:"datum",level:t+1,label:`${Ha(g,"more leaf","more leaves")} in ${c} not shown; navigation is capped at ${r}.`}),{id:`hierarchy-${Va(i)}-${Va(c)}`,role:"series",level:t,label:`${c}: ${Ha(f.length,"direct child","direct children")}, ${Ha(h.descendants,"total descendant","total descendants")}, ${Ha(h.leaves,"leaf","leaves")}${Ya(h,a)}.`,datum:e,children:m}},f=i?d(i):null,h={id:"root",role:"chart",level:1,label:i?`A ${Qa(e)} chart with ${Ha(f.leaves,"leaf","leaves")} and ${Ha(f.descendants,"total descendant","total descendants")} across ${Ha(f.depth,"hierarchy level","hierarchy levels")}${Ya(f,a)}.`:"A hierarchy chart with no hierarchy data loaded.",children:[]};if(i){let e=p(i,2,"root",/* @__PURE__ */new Set);if(e){let t=Ua(za(i,n,"name"),"");h.children="series"===e.role&&""===t?e.children:[e]}}return h}function Ka(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function Xa(e,t="—"){return null==e||""===e?t:"object"==typeof e?Xa(e.id??e.name??e.label,t):e+""}function Ja(e){if(null==e||""===e)return;let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function ei(e){return Xa(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function ti(e){let 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 ri(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];let t=e;return Array.isArray(t.features)?t.features:"Feature"===t.type?[t]:[]}function ai(e,t,r){let a=Ka(e,t,r);if(void 0!==a)return a;let i=e.properties;return i&&"object"==typeof i?Ka(i,t,r):void 0}function ii(e,t,r){return Xa(ai(e,t,"id")??ai(e,"name","name")??ai(e,"NAME","NAME")??ai(e,"label","label"),r)}function si(e){let t=0,r=1/0,a=-1/0,i=0;for(let s of e)null!=s.value&&(t+=1,r=Math.min(r,s.value),a=Math.max(a,s.value),i+=s.value);return 0===t?null:{count:t,min:r,max:a,total:i,average:i/t}}function oi(e,t){let r=si(e);return r?`range ${t(r.min)} to ${t(r.max)}, average ${t(r.average)}, total ${t(r.total)}`:"no numeric values"}function ni(e){let t=e.filter(e=>null!=e.value),r=e.filter(e=>null==e.value),a=[],i=si(t);if(i)if(i.min===i.max)a.push({id:"equal",label:"Equal values",rows:t});else{let e=i.min+(i.max-i.min)/3,r=i.min+2*(i.max-i.min)/3,s=t.filter(e=>e.value>=r),o=t.filter(t=>t.value>=e&&r>t.value),n=t.filter(t=>e>t.value);s.length>0&&a.push({id:"highest",label:"Highest values",rows:s}),o.length>0&&a.push({id:"middle",label:"Middle values",rows:o}),n.length>0&&a.push({id:"lowest",label:"Lowest values",rows:n})}return r.length>0&&a.push({id:"missing",label:"No numeric value",rows:r}),a}function li(e,t,r){let a,i=e.filter(e=>null!=e.value).sort((e,t)=>t.value-e.value||e.index-t.index),s=/* @__PURE__ */new Map,o=0;for(let[e,t]of i.entries())a!==t.value&&(o=e+1,a=t.value),s.set(t.index,o);let n=0;return ni(e).map(e=>{let a=e.rows.slice(0,Math.max(0,t-n));n+=a.length;let o=a.map(e=>{let t=s.get(e.index),a=null==t||2>i.length?"":`, rank ${t} of ${i.length}`;return{id:`geo-${ei(e.label)}-${e.index}`,role:"datum",level:3,label:null==e.value?e.label+": no numeric value.":`${e.label}: ${r(e.value)}${a}.`,...null==e.value?{}:{value:e.value},datum:e.datum}}),l=e.rows.length-a.length;return l>0&&o.push({id:`geo-${e.id}-more`,role:"datum",level:3,label:`${l} more ${1===l?"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"}, ${oi(e.rows,r)}.`,children:o}})}function ci(e,t,r,a){let i=ri(t.areas),s="FlowMap"===e&&Array.isArray(t.nodes)?t.nodes:Array.isArray(t.points)?t.points:[],o=Array.isArray(t.flows)?t.flows:[],n=Array.isArray(t.lines)?t.lines:[],l=t.valueAccessor??t.sizeBy??t.costAccessor??"value",c=t.pointIdAccessor??t.nodeIdAccessor??"id",d=("ChoroplethMap"===e?i:s).map((r,a)=>({datum:r,index:a,label:ii(r,"ChoroplethMap"===e?t.idAccessor:c,`${"ChoroplethMap"===e?"region":"location"} ${a+1}`),value:Ja(ai(r,l,"value"))})),u=d.filter(e=>null!=e.value),p={id:"root",role:"chart",level:1,label:`${"ChoroplethMap"===e?`A choropleth map with ${i.length} regions.${u.length>0?` Values are available for ${u.length} of ${i.length} regions; ${oi(u,a)}.`:" No regions have numeric values."}`:"FlowMap"===e?`A flow map with ${o.length} flows and ${s.length} locations.`:"DistanceCartogram"===e?`A distance cartogram with ${s.length} locations and ${n.length} routes.`:`A proportional-symbol map with ${s.length} locations.`}${ti(t)}`,children:[]};if("ChoroplethMap"===e)p.children=li(d,r,a);else if(d.length>0){let e=d.slice(0,r).map(e=>({id:`geo-${ei(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}));d.length>r&&e.push({id:"geo-more",role:"datum",level:3,label:`…and ${d.length-r} more locations.`}),p.children?.push({id:"locations",role:"series",level:2,label:`Locations: ${d.length} marks.`,children:e})}let f="FlowMap"===e?o:n;if(f.length>0){let e=f.slice(0,r).map((e,t)=>{let r=Xa(e.source,"unknown"),i=Xa(e.target,"unknown"),s=Ja(Ka(e,l,"value"));return{id:`route-${ei(r)}-${ei(i)}-${t}`,role:"datum",level:3,label:`${r} to ${i}${null==s?"":": "+a(s)}.`,...null==s?{}:{value:s},datum:e}});p.children?.push({id:"routes",role:"series",level:2,label:`Routes: ${f.length} ${1===f.length?"route":"routes"}.`,children:e})}return p}function di(e,t={},r={}){return!!Ft(e,t,r.recipe)||Hc.has(e)||Yc.has(e)||Qc.has(e)||Lc.has(e)||Mc.has(e)||Rc.has(e)||Ic.has(e)}function ui(e,t,r){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:r]}function pi(e,t="—"){return null==e||""===e?t:"object"==typeof e?pi(e.id??e.name??e.label,t):e+""}function fi(e){if(null==e||""===e)return;let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function hi(e){return pi(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function yi(e,t){let 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 mi(e,t){t&&e.children?.push(t)}function gi(e,t,r,a){let i=Array.isArray(t.nodes)?t.nodes:[],s=Array.isArray(t.edges)?t.edges:Array.isArray(t.flows)?t.flows:[],o=t.nodeIdAccessor??t.nodeIDAccessor,n=t.sourceAccessor??"source",l=t.targetAccessor??"target",c=t.valueAccessor??"value",d=e=>pi(ui(e,o,"id"),"unknown"),u=(e,t)=>pi(ui(e,t,""),"unknown"),p=/* @__PURE__ */new Set;for(let e of s)p.add(u(e,n)),p.add(u(e,l));let f=i.length>0?i:[...p].map(e=>({id:e})),h=/* @__PURE__ */new Map;for(let e of f)h.set(d(e),{links:0,value:0});for(let e of s){let t=u(e,n),r=u(e,l),a=fi(ui(e,c,"value"))??0;for(let e of[t,r]){let t=h.get(e)??{links:0,value:0};t.links+=1,t.value+=a,h.set(e,t)}}let y={id:"root",role:"chart",level:1,label:`A ${"SankeyDiagram"===e||"ProcessSankey"===e?"flow diagram":"ChordDiagram"===e?"chord diagram":"network graph"} with ${f.length} nodes and ${s.length} links.${yi(t,"network")}`,children:[]},m=0,g=/* @__PURE__ */new Map,v=t.colorBy??"group";for(let e of f){let t=pi(ui(e,v,"group"),"Ungrouped"),r=g.get(t);r?r.push(e):g.set(t,[e])}let b=[...g].map(([e,t],i)=>{let s=[];for(let[e,o]of t.entries()){if(m>=r)break;m+=1;let t=d(o),n=h.get(t)??{links:0,value:0},l=n.value>0?`, ${a(n.value)} total flow`:"";s.push({id:`node-${i}-${e}-${hi(t)}`,role:"datum",level:3,label:`${t}: ${n.links} ${1===n.links?"link":"links"}${l}.`,value:n.value>0?n.value:void 0,datum:o})}return{id:`nodes-${i}-${hi(e)}`,role:"series",level:2,label:`${e}: ${t.length} ${1===t.length?"node":"nodes"}.`,children:s}});b.length>0&&y.children?.push(...b);let k=s.slice(0,r).map((e,t)=>{let r=u(e,n),i=u(e,l),s=fi(ui(e,c,"value"));return{id:`link-${hi(r)}-${hi(i)}-${t}`,role:"datum",level:3,label:`${r} to ${i}${null==s?"":": "+a(s)}.`,value:s,datum:e}});return s.length>r&&k.push({id:"links-more",role:"datum",level:3,label:`…and ${s.length-r} more links.`,value:void 0}),k.length>0&&y.children?.push({id:"links",role:"series",level:2,label:`Links: ${s.length} ${1===s.length?"connection":"connections"}.`,children:k}),y}function vi(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function bi(e,t){let r=Array.isArray(e.annotations)?e.annotations:null;if(!r)return null;let a=Jr(r.filter(e=>!!e&&"object"==typeof e));if(0===a.length)return null;let i=0,s=a.slice(0,t).map(e=>{let t=e.lifecycle?.status,r=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+i++,role:"annotation",level:3,label:`${vi(Sa(e))}${r}.`,datum:e}});a.length>t&&s.push({id:"annotation-"+i++,role:"annotation",level:3,label:`…and ${a.length-t} more annotations.`});let o=a.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===o?"one marked feature":o+" marked features"}.`,children:s}}function ki(e,t,r={}){let a=r.locale??"en",i=Math.max(1,r.maxLeaves??200),s=Ca(a),o=Ft(e,t,r.recipe);if(o)return _a(o,t,{maxLeaves:i,locale:a});let n={id:"root",role:"chart",label:Pa(e,t,{locale:a}).text||"Chart.",level:1,children:[]},l=bi(t,i);if(Hc.has(e)){let r=gi(e,t,i,s);return mi(r,l),r}if(Yc.has(e)){let r=Za(e,t,i,s);return mi(r,l),r}if(Qc.has(e)){let r=ci(e,t,i,s);return mi(r,l),r}let c=Array.isArray(t.data)?t.data:null,d=di(e,t,r);if(!c||0===c.length||!d)return l&&(n.children=[l]),n;let{measure:u,measureFallback:p,dimension:f,dimensionFallback:h}=Zr(e,t),y=Yr(u,p),m=Qr(f,h),g="string"==typeof u&&u?u:p,v="string"==typeof f&&f?f:h,b=Kr(t),k=0,x=e=>`${e}-${k++}`,C=(e,t)=>{let r=y(e),a=Xr(m(e),s);return{id:x("datum"),role:"datum",level:t,label:`${a}: ${Number.isFinite(r)?s(r):"—"}`,value:Number.isFinite(r)?r:void 0,datum:e}},A=(e,t)=>{let r=e.slice(0,i).map(e=>C(e,t));return e.length>i&&r.push({id:x("more"),role:"datum",level:t,label:`…and ${e.length-i} more points`}),r},w=[];if(Lc.has(e)||Mc.has(e)){let t=1/0,r=-1/0,a=1/0,i=-1/0,o=[],n=!0;for(let e of c){let s=y(e);Number.isFinite(s)&&(t>s&&(t=s),s>r&&(r=s));let l=m(e);o.push(l),"number"==typeof l&&Number.isFinite(l)?(a>l&&(a=l),l>i&&(i=l)):n=!1}let l=/* @__PURE__ */new Set,d=[];for(let e of o){let t=e+"";l.has(t)||(l.add(t),d.push(e))}let u=n?`${s(a)} to ${s(i)}`:`${Xr(d[0],s)} to ${Xr(d[d.length-1],s)} (${Mc.has(e)?d.length+" categories":c.length+" points"})`;w.push({id:x("axis"),role:"axis",level:2,label:`${Mc.has(e)?"Category axis":"X axis"}: ${v}, ${u}.`}),r>=t&&w.push({id:x("axis"),role:"axis",level:2,label:`Value axis: ${g}, ${s(t)} to ${s(r)}.`})}if(b){let r=Qr(b,b),i=/* @__PURE__ */new Map;for(let e of c){let t=(r(e)??"—")+"",a=i.get(t);a?a.push(e):i.set(t,[e])}let s=[];for(let[r,o]of i){let i=Pa(e,{...t,data:o},{levels:["l2","l3"],locale:a}).text;s.push({id:x("series"),role:"series",level:2,label:`Series ${r}: ${i}`,children:A(o,3)})}n.children=[...w,...s]}else n.children=[...w,...A(c,2)];return l&&n.children.push(l),n}function xi(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Ci(e){return xi(e)?e:void 0}function Ai(e){let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function wi(e){let t=Ai(e);return null==t?void 0:Math.max(0,Math.floor(t))}function $i(...e){return e.map(Ci).find(Boolean)}function Si(...e){return e.find(Array.isArray)}function Bi(e){let t={};for(let[r,a]of Object.entries(e))void 0!==a&&(t[r]=a);return t}function Pi(e,t,r){return e["string"==typeof t&&t?t:r]}function Wi(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function Li(e,t,r){let a=[];if("GaugeChart"===e){"number"==typeof t.value&&Number.isFinite(t.value)&&a.push(`Current value is ${Wi(t.value)}.`);let 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 ${Wi(e)} to ${Wi(r)}.`)}if("SankeyDiagram"===e||"ProcessSankey"===e){let i=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 ${Wi(t.domain[0])} to ${Wi(t.domain[1])}.`),i.length>0){a.push(`${i.length} source flow${1===i.length?"":"s"} are supplied.`);for(let s of i.slice(0,r)){let r=Pi(s,t.sourceAccessor,"source"),i=Pi(s,t.targetAccessor,"target"),o=Pi(s,t.valueAccessor,"value");a.push("ProcessSankey"!==e||null==s.startTime&&null==s.endTime?`${Wi(r)} to ${Wi(i)} has value ${Wi(o)}.`:`${Wi(r)} to ${Wi(i)} has value ${Wi(o)} over ${Wi(s.startTime)}–${Wi(s.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){let e=Ci(t.data),i="string"==typeof t.childrenAccessor&&t.childrenAccessor?t.childrenAccessor:"children",s="string"==typeof t.valueAccessor&&t.valueAccessor?t.valueAccessor:"value",o="string"==typeof t.nodeIdAccessor&&t.nodeIdAccessor?t.nodeIdAccessor:"string"==typeof t.nodeIDAccessor&&t.nodeIDAccessor?t.nodeIDAccessor:"name",n=[],l=e=>{let t=Array.isArray(e[i])?e[i]:[];if(0!==t.length)for(let e of t){let t=Ci(e);t&&l(t)}else n.push(e)};if(e&&l(e),n.length>0){a.push(n.length+" hierarchy leaves are supplied.");for(let e of n.slice(0,r))a.push(`${Wi(e[o])} has value ${Wi(e[s])}.`)}}if(Zc.has(e)&&Array.isArray(t.data)){let r=t.data;a.push(`${r.length} observed source row${1===r.length?"":"s"} are supplied.`);let i="CollisionSwarmChart"===e?t.xAccessor:t.valueAccessor,s="CollisionSwarmChart"===e?"x":"value",o=r.map(e=>Ai(Pi(e,i,s))).filter(e=>null!=e);o.length>0&&a.push(`Observed ${"string"==typeof i?i:s} ranges from ${Wi(Math.min(...o))} to ${Wi(Math.max(...o))}.`)}if(0!==a.length)return{source:"chart-props",statements:a,text:"Exact chart-prop facts: "+a.join(" ")}}function Mi(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Ri(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function Ii(e,t,r,a){let i=Ci(e.settledProjection),s=Ci(t?.settledProjection);return Si(r?.projectionRows,r?.aggregates,e.settledProjectionRows,e.projectionRows,i?.rows,t?.settledProjectionRows,t?.projectionRows,s?.rows,a?.binCounts)}function Ei(e){if(!e||0===e.length)return;let t=e.map((e,t)=>{let r=Ci(e);if(!r)return;let a=Ai(r.count??r.value??r.total??r.bodies??r.events);if(null==a)return;let i=(r.label??r.id??r.name??"container "+(t+1))+"",s=null==r.id?void 0:r.id+"",o=Ai(r.secondary??r.secondaryCount),n=Ai(r.observed??r.observedCount);return Bi({id:s,label:i,count:a,secondary:o,secondaryLabel:"string"==typeof r.secondaryLabel?r.secondaryLabel:void 0,observed:n})}).filter(e=>null!=e);if(0===t.length)return;let r=t.reduce((e,t)=>e+t.count,0),a=t.filter(e=>e.count>0).length,i=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:r,populatedCount:a,...i?{leader:i}:{}}}function Ni(e,t){let r=e?.map((e,t)=>{let r=Ci(e);if(!r)return;let a=Ai(r.count)??0,i=Ai(r.total),s={label:(r.label??r.id??"sediment "+(t+1))+"",count:a};return null!=r.id&&(s.id=r.id+""),null!=i&&(s.total=i),s}).filter(e=>null!=e),a=wi(t?.bins)??r?.length??0,i=Ai(t?.count)??r?.reduce((e,t)=>e+t.count,0)??0,s=Ai(t?.total)??r?.reduce((e,t)=>e+(t.total??0),0),o=r?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==a||0!==i||s)return{bins:a,count:i,...null!=s&&s>0?{total:s}:{},...o?{leader:o}:{}}}function Ti(e){let t=Ci(e);return!!t&&(xi(t.world)||"simulationState"in t||"liveBodyOrder"in t)}function Fi(e){if(e)return e.filter(e=>!0===Ci(e)?.sleeping).length}function Oi(e,t,r){let a=e?.filter(e=>!0===Ci(e)?.sensor).length,i=Ci(t?.observation),s=Ci(i?.sensors),o=Si(r?.activeSensors);return Math.max(a??0,s?Object.keys(s).length:0,o?.length??0)||void 0}function ji(e){let t=[],r=e.simulation,a=[r.state??(r.settled?"settled":void 0),null!=r.liveBodies?`${r.liveBodies} live ${Mi(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 "+Ri(r.seed):void 0,r.gravity?`gravity (${Ri(r.gravity.x)}, ${Ri(r.gravity.y)})`:void 0,null!=r.fixedDt?`fixed step ${Ri(r.fixedDt)}s`:void 0,null!=r.timeScale?Ri(r.timeScale)+"x time":void 0].filter(Boolean);a.length>0&&t.push(`Physics simulation: ${a.join("; ")}.`);let i=e.geometry;if(i){let e=[null!=i.colliders?`${i.colliders} ${Mi(i.colliders,"collider")}`:void 0,null!=i.sensors?`${i.sensors} ${Mi(i.sensors,"sensor")}`:void 0,null!=i.springs?`${i.springs} ${Mi(i.springs,"spring")}`:void 0,null!=i.activeSensorPairs?`${i.activeSensorPairs} active sensor ${Mi(i.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}let s=e.aggregates;if(s){let e=s.leader,r=e?` Largest is ${e.label} with ${Ri(e.count)}.`:"";t.push(`Physics aggregates: ${Ri(s.totalCount)} settled ${Mi(s.totalCount,"body")} across ${s.rows.length} ${Mi(s.rows.length,"container")}; ${s.populatedCount} populated.${r}`)}let o=e.sediment;if(o){let e=null!=o.total?", value total "+Ri(o.total):"",r=o.leader?`; largest sediment bin is ${o.leader.label} with ${Ri(o.leader.count)}`:"";t.push(`Physics sediment: ${o.count} retained ${Mi(o.count,"body")} in ${o.bins} ${Mi(o.bins,"bin")}${e}${r}.`)}return t.join(" ")}function Di(e,t,r){if(!1===r)return;let a=xi(r)?r:void 0,i=Ci(t.physics),s=$i(a?.snapshot,i?.snapshot,t.physicsSnapshot,Ti(t.snapshot)?t.snapshot:void 0),o=$i(a?.evidence,i?.evidence,t.physicsEvidence,t.settledEvidence),n=$i(a?.config,i?.config,s?.config,t.config),l=$i(Ci(s?.world),Ci(i?.world)),c=$i(Ci(n?.kernel),Ci(l?.options)),d=Si(l?.bodies),u=Si(l?.colliders,n?.colliders),p=Si(s?.queue,i?.queue),f=Si(s?.liveBodyOrder),h=Si(l?.springs),y=Si(s?.activeSensorPairs),m=Ei(Ii(t,i,a,o)),g=Ni(Si(a?.sediment,i?.sediment,s?.sediment),$i(a?.sedimentTotals,i?.sedimentTotals)),v=f?.length??d?.length??wi(o?.bodyCount),b=Fi(d)??wi(o?.sleepingCount),k=p?.length,x="string"==typeof s?.simulationState?s.simulationState:void 0,C="boolean"==typeof o?.settled?o.settled:x?"settled"===x:null!=v||null!=b||null!=k?null!=v&&b===v&&0===(k??0):void 0,A=Ci(c?.gravity),w=Ai(A?.x),$=Ai(A?.y),S=Bi({state:x,settled:C,elapsedSeconds:Ai(s?.elapsedSeconds),paused:"boolean"==typeof s?.paused?s.paused:void 0,visible:"boolean"==typeof s?.visible?s.visible:void 0,seed:Ai(c?.seed),gravity:null!=w&&null!=$?{x:w,y:$}:void 0,fixedDt:Ai(n?.fixedDt??c?.fixedDt),timeScale:Ai(n?.timeScale),maxSubsteps:wi(n?.maxSubsteps),liveBodies:v,sleepingBodies:b,queued:k,bodyLimit:Ai(n?.bodyLimit),eviction:"string"==typeof n?.eviction?n.eviction:void 0}),B=Bi({colliders:u?.length,sensors:Oi(u,n,l),springs:h?.length,activeSensorPairs:y?.length}),P=Object.keys(B).length>0,W=Zc.has(e);if(!(Object.keys(S).length>0||P||m||g)||!W&&null==r)return;let L={simulation:S,...P?{geometry:B}:{},...m?{aggregates:m}:{},...g?{sediment:g}:{}},M=ji(L);return{...L,text:M}}function _i(e){return e?"fits"in e||"buildProps"in e?{family:e.family}:{family:e.family,intentScores:e.intentScores}:{}}function zi(e,t,r={}){let a,{capability:i,audience:s,locale:o}=r,n=r.levels??["l1","l2","l3"],l=!1!==r.includeStructure,c=ka(e,i),d=Pa(e,t,{levels:c?[...n,"l4"]:n,locale:o,capability:i,audience:s}),{l4:u,...p}=d.levels,f=["l1","l2","l3"].map(e=>d.levels[e]).filter(Boolean).join(" "),h={levels:p,text:d.annotations?`${d.annotations} ${f}`.trim():f,...d.annotations?{annotations:d.annotations}:{}};if(c&&u){let e=_i(i);a={act:c,sentence:u,family:e.family,intentScores:e.intentScores}}let y=l?ki(e,t,{maxLeaves:r.maxLeaves,locale:o}):void 0,m=Di(e,t,r.physics),g=Li(e,t,Math.max(1,r.maxLeaves??200)),v=[h.text,a?.sentence,m?.text,g?.text].filter(Boolean).join(" ");return{component:e,description:h,intent:a,structure:y,physics:m,facts:g,text:v}}function Ui(e){return null==e?[]:Array.isArray(e)?e:[e]}function Gi(e){if("string"==typeof e)return e;try{return JSON.stringify(e,null,2)??e+""}catch{return e+""}}function Vi(e,t){return null==t?e.findings:e.findings.slice(0,Math.max(0,t))}function qi(...e){for(let t of e){let e=t?.trim();if(e)return e}return"Review this finding."}function Hi(e){return qi(e.remediation,e.explanation,e.evidence,e.condition)}function Yi(e){return qi(e.name,e.ruleId)}function Qi(e){return"error"===e?"error":"warning"===e?"warning":"info"===e?"info":"neutral"}function Zi(e,t){return e.domain?`${t} · ${e.domain}`:t}function Ki(e,t){return t[e]??t.info??Kc.info}function Xi(e){return qi(e.ruleId,e.name)}function Ji(e,t){return`${Xi(e)}:${t}`}function es(e){return"pitfall-"+(e+"").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function ts(e,t={},r=0,a={kind:"image",findings:[e]}){let i=t.sourcePrefix??"datapitfalls";return{id:Ji(e,r),level:Qi(e.severity),title:Yi(e),message:t.message?t.message(e,r,a):Hi(e),source:Zi(e,i),...void 0===t.dismissible?{}:{dismissible:t.dismissible}}}function rs(e,t={}){return Vi(e,t.max).map((r,a)=>ts(r,t,a,e))}function as(e,t={}){return{notifications:rs(e,t),meta:{count:e.findings.length,kind:e.kind}}}function is(e,t={},r=0,a={kind:"image",findings:[e]}){let i={...Kc,...t.palette};return{...t.anchorFor?.(e,r,a)??{},type:t.type??"label",title:Yi(e),label:Hi(e),wrap:t.wrap??240,color:Ki(e.severity,i),className:es(e.severity),emphasis:"error"===e.severity?"primary":"secondary",provenance:{author:"datapitfalls",authorKind:"watcher",source:"computed",basis:"llm-inference",stableId:e.ruleId},dataPitfall:{ruleId:e.ruleId,domain:e.domain,severity:e.severity,evidence:e.evidence??""}}}function ss(e,t={}){return Vi(e,t.max).map((r,a)=>is(r,t,a,e))}function os(e,t={}){return{annotations:ss(e,t),meta:{count:e.findings.length,kind:e.kind}}}function ns(e,t,r){return{role:e,artifact:{kind:"text",content:t,...r?{filename:r}:{}}}}function ls(e,t,r,a){return{role:e,artifact:{kind:"code",content:t,language:r,...a?{filename:a}:{}}}}function cs(e,t){return t.length>0?{role:e,artifact:{kind:"image",images:t}}:null}function ds(e,t){let r=t.diagnoses.filter(e=>"error"===e.severity).length,a=t.diagnoses.filter(e=>"warning"===e.severity).length,i=[e+": Semiotic diagnoseConfig report","ok: "+t.ok,"errors: "+r,"warnings: "+a];if(0===t.diagnoses.length)return i.push("","No Semiotic config issues detected."),i.join("\n");i.push("");for(let e of t.diagnoses)i.push(`[${e.severity}] ${e.code}: ${e.message}`),e.fix&&i.push("Fix: "+e.fix);return i.join("\n")}function us(e){return[e.component+": Semiotic reader grounding","",e.text,"\nStructured grounding JSON:\n```json",Gi(e),"```"].join("\n")}function ps(e,t,r={}){let a=[],i=!1!==r.includeConfig,s=!1!==r.includeJSX,o=!1!==r.includeGrounding,n=!1!==r.includeDiagnostics,l=!1!==r.includeAccessibility,c=r.filenamePrefix??e,d=Dr(e,t,r.config);r.context?.trim()&&a.push(ns("Analysis context",r.context.trim(),c+".context.md")),i&&a.push(ls("Semiotic chart config",Gi(d),"json",c+".semiotic-config.json")),s&&a.push(ls("Semiotic chart JSX",Vr(d),"jsx",c+".semiotic.jsx"));let u,p,f,h=cs("Rendered chart image",Ui(r.rendered?.image));return h&&a.push(h),r.rendered?.svg?.trim()&&a.push(ls("Rendered chart SVG",r.rendered.svg.trim(),"svg",c+".rendered.svg")),null!=r.rendered?.evidence&&a.push(ns("Semiotic render evidence",[e+": Semiotic render evidence","\n```json",Gi(r.rendered.evidence),"```"].join("\n"),c+".render-evidence.md")),o&&(u=zi(e,t,r.grounding),a.push(ns("Semiotic reader grounding",us(u),c+".reader-grounding.md"))),n&&(p=Rt(e,t),a.push(ns("Semiotic config diagnostics",ds(e,p),c+".diagnose-config.md"))),l&&(f=q(e,t,r.accessibility),a.push(ns("Semiotic accessibility audit",H(f),c+".accessibility.md"))),r.narrative?.trim()&&a.push(ns("Author narrative",r.narrative.trim(),c+".narrative.md")),r.additionalStages?.length&&a.push(...r.additionalStages),0===a.length&&a.push(ls("Semiotic chart config",Gi(d),"json",c+".semiotic-config.json")),{input:{kind:"chain",stages:a},config:d,...u?{grounding:u}:{},...p?{diagnosis:p}:{},...f?{accessibility:f}:{}}}function fs(e,t,r={}){return ps(e,t,r).input}function hs(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ys(e,t,r){("number"!=typeof r||!Number.isInteger(r)||1>r||r>5)&&e.push(t+" must be an integer in [1, 5]")}function ms(e,t,r){void 0!==r&&"string"!=typeof r&&e.push(t+" must be a string")}function gs(e,t,r,a,i){void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||void 0!==a&&a>r||void 0!==i&&r>i)&&e.push(`${t} must be a finite number${void 0!==a&&void 0!==i?` in [${a}, ${i}]`:void 0!==a?" >= "+a:""}`)}function vs(e,t,r){void 0!==r&&"boolean"!=typeof r&&e.push(t+" must be a boolean")}function bs(e,t,r,a){for(let i of Object.keys(r))a.includes(i)||e.push(`${t}.${i} is not allowed`)}function ks(e,t){void 0!==t&&"0.1"!==t&&e.push("specVersion must be the string 0.1")}function xs(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(e)&&!Number.isNaN(Date.parse(e))}function Cs(e){let t=[];if(!hs(e))return{valid:!1,errors:["capability must be an object"]};ks(t,e.specVersion),("string"!=typeof e.component||0===e.component.length)&&t.push("component is required and must be a non-empty string"),ms(t,"family",e.family),ms(t,"importPath",e.importPath);let r=e.rubric;if(hs(r)?(bs(t,"rubric",r,["familiarity","accuracy","precision"]),ys(t,"rubric.familiarity",r.familiarity),ys(t,"rubric.accuracy",r.accuracy),ys(t,"rubric.precision",r.precision)):t.push("rubric is required and must be an object"),void 0!==e.intentScores)if(hs(e.intentScores))for(let[r,a]of Object.entries(e.intentScores))gs(t,"intentScores."+r,a,0,5);else t.push("intentScores must be an object");if(void 0!==e.variants&&(Array.isArray(e.variants)?e.variants.forEach((e,r)=>{if(hs(e)){if("string"!=typeof e.key&&t.push(`variants[${r}].key is required`),"string"!=typeof e.label&&t.push(`variants[${r}].label is required`),ms(t,`variants[${r}].description`,e.description),void 0!==e.intentDeltas)if(hs(e.intentDeltas))for(let[a,i]of Object.entries(e.intentDeltas))gs(t,`variants[${r}].intentDeltas.${a}`,i);else t.push(`variants[${r}].intentDeltas must be an object`);if(void 0!==e.rubricDeltas)if(hs(e.rubricDeltas)){bs(t,`variants[${r}].rubricDeltas`,e.rubricDeltas,["familiarity","accuracy","precision"]);for(let a of["familiarity","accuracy","precision"])gs(t,`variants[${r}].rubricDeltas.${a}`,e.rubricDeltas[a])}else t.push(`variants[${r}].rubricDeltas must be an object`);for(let a of["caveats","tags"]){let i=e[a];void 0!==i&&(!Array.isArray(i)||i.some(e=>"string"!=typeof e))&&t.push(`variants[${r}].${a} must be an array of strings`)}void 0!==e.props&&!hs(e.props)&&t.push(`variants[${r}].props must be an object`)}else t.push(`variants[${r}] must be an object`)}):t.push("variants must be an array")),void 0!==e.mobile)if(hs(e.mobile)){let r=e.mobile;ms(t,"mobile.strategy",r.strategy),vs(t,"mobile.responsive",r.responsive),vs(t,"mobile.supportsResponsiveLayout",r.supportsResponsiveLayout);for(let e of["minViewportWidth","maxMarks","maxAnnotations","minimumHitTarget"])gs(t,"mobile."+e,r[e],0);void 0!==r.breakpoints&&(Array.isArray(r.breakpoints)?r.breakpoints.forEach((e,r)=>{gs(t,`mobile.breakpoints[${r}]`,e)}):t.push("mobile.breakpoints must be an array")),void 0!==r.summary&&"boolean"!=typeof r.summary&&"string"!=typeof r.summary&&t.push("mobile.summary must be a boolean or string"),void 0!==r.interaction&&(hs(r.interaction)?(ms(t,"mobile.interaction.primary",r.interaction.primary),ms(t,"mobile.interaction.hoverFallback",r.interaction.hoverFallback),gs(t,"mobile.interaction.targetSize",r.interaction.targetSize,0),void 0!==r.interaction.alternatives&&(!Array.isArray(r.interaction.alternatives)||r.interaction.alternatives.some(e=>"string"!=typeof e))&&t.push("mobile.interaction.alternatives must be an array of strings")):t.push("mobile.interaction must be an object")),void 0!==r.labels&&(hs(r.labels)?(ms(t,"mobile.labels.strategy",r.labels.strategy),gs(t,"mobile.labels.minFontSize",r.labels.minFontSize,0)):t.push("mobile.labels must be an object")),void 0!==r.custom&&(hs(r.custom)?(vs(t,"mobile.custom.dataBearingSceneNodes",r.custom.dataBearingSceneNodes),vs(t,"mobile.custom.stableIds",r.custom.stableIds),ms(t,"mobile.custom.navigationGranularity",r.custom.navigationGranularity)):t.push("mobile.custom must be an object"))}else t.push("mobile must be an object");for(let r of["caveats","tags"]){let a=e[r];void 0!==a&&(!Array.isArray(a)||a.some(e=>"string"!=typeof e))&&t.push(r+" must be an array of strings")}return{valid:0===t.length,errors:t}}function As(e){let t=[];if(!hs(e))return{valid:!1,errors:["audience profile must be an object"]};if(ks(t,e.specVersion),ms(t,"name",e.name),void 0!==e.familiarity)if(hs(e.familiarity))for(let[r,a]of Object.entries(e.familiarity))("number"!=typeof a||!Number.isInteger(a)||1>a||a>5)&&t.push(`familiarity.${r} must be an integer in [1, 5]`);else t.push("familiarity must be an object");if(void 0!==e.targets)if(hs(e.targets))for(let[r,a]of Object.entries(e.targets))!hs(a)||"increase"!==a.direction&&"decrease"!==a.direction?t.push(`targets.${r}.direction must be "increase" or "decrease"`):(bs(t,"targets."+r,a,["direction","weight","reason"]),void 0!==a.weight&&("number"!=typeof a.weight||!Number.isInteger(a.weight)||1>a.weight||a.weight>3)&&t.push(`targets.${r}.weight must be an integer in [1, 3]`),ms(t,`targets.${r}.reason`,a.reason));else t.push("targets must be an object");return void 0!==e.exposureLevel&&("number"!=typeof e.exposureLevel||!Number.isInteger(e.exposureLevel)||![0,1,2].includes(e.exposureLevel))&&t.push("exposureLevel must be 0, 1, or 2"),void 0!==e.receptionModality&&!ad.has(e.receptionModality)&&t.push("receptionModality must be one of "+[...ad].join(", ")),{valid:0===t.length,errors:t}}function ws(e){let t=[];if(!hs(e))return{valid:!1,errors:["annotation must be an object"]};let r=e.provenance;if(void 0!==r)if(hs(r)){for(let e of["author","authorKind","source","basis","dataVersion","stableId"])ms(t,"provenance."+e,r[e]);gs(t,"provenance.confidence",r.confidence,0,1),void 0!==r.createdAt&&("string"!=typeof r.createdAt||!xs(r.createdAt))&&t.push("provenance.createdAt must be an ISO 8601 date-time string")}else t.push("provenance must be an object");let a=e.lifecycle;return void 0!==a&&(hs(a)?(void 0!==a.freshness&&!ed.has(a.freshness)&&t.push("lifecycle.freshness must be one of "+[...ed].join(", ")),void 0!==a.status&&!td.has(a.status)&&t.push("lifecycle.status must be one of "+[...td].join(", ")),void 0!==a.anchor&&!rd.has(a.anchor)&&t.push("lifecycle.anchor must be one of "+[...rd].join(", ")),ms(t,"lifecycle.supersedes",a.supersedes),void 0!==a.ttlHint&&"string"!=typeof a.ttlHint&&("number"!=typeof a.ttlHint||!Number.isFinite(a.ttlHint))&&t.push("lifecycle.ttlHint must be an ISO 8601 duration string or a number of milliseconds")):t.push("lifecycle must be an object")),{valid:0===t.length,errors:t}}function $s(e){let t=e;return{adapter:"semiotic/idid-capability-binding",direction:"import",sourceFormat:"idid-chart-capability",targetFormat:"semiotic-chart-capability",specVersion:"string"==typeof t?.specVersion?t.specVersion:"0.1"}}function Ss(e,t){return{status:"refused",diagnostics:t,lossReport:t.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:$s(e)}}function Bs(e){return{key:e.key,label:e.label,props:{...e.props??{}},...void 0!==e.description?{description:e.description}:{},...void 0!==e.intentDeltas?{intentDeltas:{...e.intentDeltas}}:{},...void 0!==e.rubricDeltas?{rubricDeltas:{...e.rubricDeltas}}:{},...void 0!==e.caveats?{caveats:[...e.caveats]}:{},...void 0!==e.tags?{tags:[...e.tags]}:{}}}function Ps(e){let t={};if(void 0!==e.strategy&&(t.strategy=e.strategy),void 0!==e.responsive&&(t.responsive=e.responsive),void 0!==e.supportsResponsiveLayout&&(t.supportsResponsiveLayout=e.supportsResponsiveLayout),void 0!==e.breakpoints&&(t.breakpoints=[...e.breakpoints]),void 0!==e.minViewportWidth&&(t.minViewportWidth=e.minViewportWidth),void 0!==e.maxMarks&&(t.maxMarks=e.maxMarks),void 0!==e.maxAnnotations&&(t.maxAnnotations=e.maxAnnotations),void 0!==e.minimumHitTarget&&(t.minimumHitTarget=e.minimumHitTarget),void 0!==e.summary&&(t.summary=e.summary),void 0!==e.interaction){let r={};void 0!==e.interaction.primary&&(r.primary=e.interaction.primary),void 0!==e.interaction.alternatives&&(r.alternatives=[...e.interaction.alternatives]),void 0!==e.interaction.hoverFallback&&(r.hoverFallback=e.interaction.hoverFallback),void 0!==e.interaction.targetSize&&(r.targetSize=e.interaction.targetSize),t.interaction=r}return void 0!==e.labels&&(t.labels={...e.labels}),void 0!==e.custom&&(t.custom={...e.custom}),t}function Ws(e,t){let r=t.caveats?[...t.caveats]:[];if(e.caveats||0!==r.length)return t=>{let a=e.caveats?Array.from(e.caveats(t)):[];return[.../* @__PURE__ */new Set([...a,...r])]}}function Ls(e,t){let r=Cs(e);if(!r.valid)return Ss(e,r.errors.map(e=>({code:"INVALID_PORTABLE_CAPABILITY",severity:"error",message:e})));let a=e;if(!t)return Ss(e,[{code:"HOST_CAPABILITY_NOT_FOUND",severity:"error",path:"/component",message:`No host capability is registered for "${a.component}". Resolve or register the renderer's executable capability before binding portable metadata.`}]);if(a.component!==t.component)return Ss(e,[{code:"CAPABILITY_COMPONENT_MISMATCH",severity:"error",path:"/component",message:`Portable component "${a.component}" cannot bind to host component "${t.component}".`}]);let i=Ws(t,a);return{status:"success",capability:{...t,rubric:{...a.rubric},intentScores:a.intentScores?{...a.intentScores}:{...t.intentScores},variants:a.variants?.map(Bs),...i?{caveats:i}:{caveats:void 0},...void 0!==a.mobile?{mobile:Ps(a.mobile)}:{},portableDescriptor:a},diagnostics:[],lossReport:[],provenance:$s(e)}}function Ms(e){return{field:e,type:"quantitative"}}function Rs(e){return{field:e,type:"nominal"}}function Is(e){return"time"===e.xScaleType?"temporal":"quantitative"}function Es(e,t){return"string"==typeof t&&(e.axis={title:t}),e}function Ns(e,t){let r=[];for(let a of sd[e]||[])("string"!=typeof t[a]||0===t[a].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+a,message:`${e} requires a string ${a} for Vega-Lite export.`});for(let a of od[e]||[])void 0!==t[a]&&("string"!=typeof t[a]||0===t[a].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+a,message:`${e} can export ${a} only as a non-empty string field name.`});return r}function Ts(e,t={}){let r=[],a={adapter:"semiotic/vega-lite",direction:"export",sourceFormat:"semiotic-chart-config",targetFormat:"vega-lite",..."string"==typeof e.version?{specVersion:e.version}:{}},i=e.props||{},s=Ns(e.component,i);if(s.length>0)return{status:"refused",diagnostics:s,lossReport:s.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:a};let o,n={},l=e.component;switch(l){case"BarChart":case"StackedBarChart":case"GroupedBarChart":{o="bar";let e="horizontal"===i.orientation,t=Es(Rs(i.categoryAccessor),i.categoryLabel),a=Es(Ms(i.valueAccessor),i.valueLabel);e?(n.y=t,n.x=a):(n.x=t,n.y=a),"StackedBarChart"===l&&i.stackBy?n.color=Rs(i.stackBy):"GroupedBarChart"===l&&i.groupBy&&(n.color=Rs(i.groupBy),r.push({code:"GROUPED_BAR_APPROXIMATION",path:"/props/groupBy",message:"GroupedBarChart maps groupBy to color; Vega-Lite needs xOffset for an exact grouped layout."}));break}case"LineChart":o=i.curve||i.showPoints?{type:"line"}:"line","object"==typeof o&&(i.curve&&id[i.curve]&&(o.interpolate=id[i.curve]),i.showPoints&&(o.point=!0)),n.x=Es({field:i.xAccessor,type:Is(i)},i.xLabel),n.y=Es(Ms(i.yAccessor),i.yLabel),i.lineBy?n.color=Rs(i.lineBy):i.colorBy&&(n.color=Rs(i.colorBy));break;case"AreaChart":case"StackedAreaChart":o=i.curve?{type:"area"}:"area","object"==typeof o&&i.curve&&id[i.curve]&&(o.interpolate=id[i.curve]),"object"==typeof o&&void 0!==i.areaOpacity&&(o.opacity=i.areaOpacity),n.x=Es({field:i.xAccessor,type:Is(i)},i.xLabel),n.y=Es(Ms(i.yAccessor),i.yLabel),"StackedAreaChart"===l&&i.areaBy&&(n.color=Rs(i.areaBy));break;case"Scatterplot":case"BubbleChart":o="point",n.x=Es(Ms(i.xAccessor),i.xLabel),n.y=Es(Ms(i.yAccessor),i.yLabel),i.colorBy&&(n.color=Rs(i.colorBy)),"BubbleChart"===l&&i.sizeBy&&(n.size=Ms(i.sizeBy),Array.isArray(i.sizeRange)&&(n.size.scale={range:i.sizeRange}));break;case"Heatmap":o="rect",n.x=Es(Rs(i.xAccessor),i.xLabel),n.y=Es(Rs(i.yAccessor),i.yLabel),i.valueAccessor&&(n.color=Ms(i.valueAccessor));break;case"PieChart":case"DonutChart":o="DonutChart"===l?{type:"arc",innerRadius:i.innerRadius??60}:"arc",i.valueAccessor&&(n.theta=Ms(i.valueAccessor)),i.categoryAccessor&&(n.color=Rs(i.categoryAccessor));break;case"DotPlot":{o="tick";let e="horizontal"===i.orientation,t=Es(Rs(i.categoryAccessor),i.categoryLabel),r=Es(Ms(i.valueAccessor),i.valueLabel);e?(n.y=t,n.x=r):(n.x=t,n.y=r);break}case"Histogram":o="bar",i.valueAccessor&&(n.x=Es(Ms(i.valueAccessor),i.valueLabel),n.x.bin=!i.bins||{maxbins:i.bins},n.y={aggregate:"count",type:"quantitative"}),i.categoryAccessor&&(n.color=Rs(i.categoryAccessor));break;default:{let e=`Component "${l}" has no supported Vega-Lite single-view equivalent.`;return{status:"refused",diagnostics:[{code:"UNSUPPORTED_COMPONENT",severity:"error",path:"/component",message:e}],lossReport:[{code:"UNSUPPORTED_COMPONENT",path:"/component",message:e}],provenance:a}}}i.colorScheme&&n.color&&(n.color.scale={...n.color.scale||{},scheme:i.colorScheme});let c={mark:o};return Array.isArray(i.data)&&(c.data={values:i.data}),Object.keys(n).length>0&&(c.encoding=n),"string"==typeof i.title&&(c.title=i.title),"number"==typeof i.width&&(c.width=i.width),"number"==typeof i.height&&(c.height=i.height),r.length>0&&!t.allowLossy?{status:"refused",diagnostics:r.map(({code:e,message:t,path:r})=>({code:e,severity:"error",message:t,path:r})),lossReport:r,provenance:a}:{status:r.length>0?"lossy":"success",spec:c,artifact:c,diagnostics:r.map(({code:e,message:t,path:r})=>({code:e,severity:"warning",message:t,path:r})),lossReport:r,provenance:a}}function Fs(e,t){return Ts(e,t).spec}function Os(e,t){let r={...js(e),specVersion:"0.1"};return void 0!==t.capability&&(r.capability=t.capability),void 0!==t.audience&&(r.audience=t.audience),{...e,usermeta:{...e.usermeta,idid:r}}}function js(e){return e.usermeta?.idid}function Ds(e,t){let r={...js(e),specVersion:"0.1",annotations:[...t]},a=t.map(Us).filter(e=>null!==e).map(e=>({...e,usermeta:{idid:{role:"annotation-layer"}}}));if(0===a.length)return{...e,usermeta:{...e.usermeta,idid:r}};let i=Array.isArray(e.layer)?e.layer:[zs(e)],{mark:s,encoding:o,data:n,transform:l,usermeta:c,...d}=e;return{...d,usermeta:{...e.usermeta,idid:r},layer:[...i,...a]}}function _s(e){let t=js(e)?.annotations;return Array.isArray(t)?t:[]}function zs(e){let{mark:t,encoding:r,data:a,transform:i}=e,s={};return t&&(s.mark=t),r&&(s.encoding=r),a&&(s.data=a),i&&(s.transform=i),s}function Us(e){let t=e;switch(t.type){case"y-threshold":return{mark:"rule",encoding:{y:{datum:t.value}}};case"x-threshold":return{mark:"rule",encoding:{x:{datum:t.value}}};case"callout":case"label":case"text":return"string"==typeof t.label?{mark:{type:"text",text:t.label}}:null;default:return null}}function Gs(e,t){let{groupBy:r,value:a,agg:i="sum"}=t,s=/* @__PURE__ */new Map,o="min"===i?1/0:"max"===i?-1/0:0;for(let t of e){let e=t[r]+"",n=s.get(e);n||(n={total:o,count:0},s.set(e,n));let l=Number(t[a]);switch(n.count++,i){case"count":break;case"min":n.total>l&&(n.total=l);break;case"max":l>n.total&&(n.total=l);break;default:n.total+=l}}let n=[];for(let[e,t]of s){let a="count"===i?t.count:"mean"===i?t.total/t.count:t.total;n.push({[r]:e,value:a})}return n}function Vs(e){if(!e)return{type:"",markProps:{}};if("string"==typeof e)return{type:e,markProps:{}};let{type:t,...r}=e;return{type:t,markProps:r}}function qs(e){if(e)return"string"==typeof e?e:e.text}function Hs(e){return"nominal"===e||"ordinal"===e}function Ys(e){return"quantitative"===e||"temporal"===e}function Qs(e){return e.usermeta?.idid}function Zs(e){return"annotation-layer"===e.usermeta?.idid?.role}function Ks(e){if(!Qs(e)||!Array.isArray(e.layer))return e;let t=e.layer.filter(e=>!Zs(e));if(1!==t.length)return e;let{layer:r,...a}=e,{usermeta:i,...s}=t[0];return{...a,...s}}function Xs(e){let t=e,r=Ks(e),a=r,i=[];if(Array.isArray(t.layer)&&r===e&&i.push({code:"UNSUPPORTED_COMPOSITION",severity:"error",path:"/layer",message:"Only the single base view in an IDID-enriched annotation layer can be imported."}),void 0===a.mark)i.push({code:"MISSING_MARK",severity:"error",path:"/mark",message:"A Vega-Lite spec needs a supported single-view mark."});else{let{type:e}=Vs(a.mark);
3
3
  /* @__PURE__ */new Set(["bar","line","area","point","circle","square","rect","arc","tick"]).has(e)||i.push({code:"UNSUPPORTED_MARK",severity:"error",path:"/mark",message:`Vega-Lite mark "${e||"(missing)"}" has no supported Semiotic translation.`})}Array.isArray(a.transform)&&a.transform.length>0&&i.push({code:"UNSUPPORTED_TRANSFORM",severity:"error",path:"/transform",message:"Vega-Lite transforms must be materialized before strict import."});for(let e of["hconcat","vconcat","concat","facet","repeat","params","selection"])void 0!==a[e]&&i.push({code:"UNSUPPORTED_COMPOSITION",severity:"error",path:"/"+e,message:`Vega-Lite "${e}" is not part of the supported single-view import subset.`});return"string"==typeof a.data?.url&&i.push({code:"UNSUPPORTED_DATA_URL",severity:"error",path:"/data/url",message:"Strict import accepts inline data.values only; load URL data before importing."}),i}function Js(e){e=Ks(e);let t,r=[],{type:a,markProps:i}=Vs(e.mark),s=e.encoding||{},o=s.x,n=s.y,l=s.color,c=s.size,d=s.theta,u=s.opacity;e.data?.values?t=e.data.values:e.data?.url&&r.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&r.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&r.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&r.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||s.facet||s.row||s.column)&&r.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&r.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&r.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");let p={};e.width&&(p.width=e.width),e.height&&(p.height=e.height);let f=qs(e.title);if(f&&(p.title=f),l?.field&&(p.colorBy=l.field,l.scale?.scheme)){let e=nd[l.scale.scheme];e&&(p.colorScheme=e)}void 0!==u?.value&&(p.pointOpacity=u.value);let h,y=o?.aggregate,m=n?.aggregate;if(t&&(y||m)){let e=m?n:o,r=m?o:n,a=cd[e.aggregate];if(a&&r?.field&&e.field)t=Gs(t,{groupBy:r.field,value:e.field,agg:a});else if(("count"===a||"count"===e.aggregate)&&r?.field&&t){let e=/* @__PURE__ */new Map;for(let a of t){let t=a[r.field]+"";e.set(t,(e.get(t)||0)+1)}t=Array.from(e,([e,t])=>({[r.field]:e,value:t}))}}if(o?.bin||n?.bin){let e="Histogram";t&&(p.data=t),o?.bin?(p.valueAccessor=o.field,n?.field&&(p.categoryAccessor=n.field),o.axis?.title&&(p.valueLabel=o.axis.title)):n?.bin&&(p.valueAccessor=n.field,o?.field&&(p.categoryAccessor=o.field),n.axis?.title&&(p.valueLabel=n.axis.title));let a=o?.bin||n?.bin,i="object"==typeof a?a.maxbins:void 0;return i&&(p.bins=i),ao(e,p,r)}switch(a){case"bar":h=to(o,n,l,p,t,y,m);break;case"line":if(h="LineChart",ro(o,n,p,y,m),l?.field&&(p.lineBy=l.field),i.interpolate){let e=ld[i.interpolate];e&&(p.curve=e)}!0===i.point&&(p.showPoints=!0),t&&(p.data=t);break;case"area":if(l?.field?(h="StackedAreaChart",p.areaBy=l.field):h="AreaChart",ro(o,n,p,y,m),i.interpolate){let e=ld[i.interpolate];e&&(p.curve=e)}void 0!==i.opacity&&(p.areaOpacity=i.opacity),t&&(p.data=t);break;case"point":case"circle":case"square":c?.field?(h="BubbleChart",p.sizeBy=c.field,c.scale?.range&&(p.sizeRange=c.scale.range)):h="Scatterplot",ro(o,n,p,y,m),t&&(p.data=t);break;case"rect":h="Heatmap",o?.field&&(p.xAccessor=o.field),n?.field&&(p.yAccessor=n.field),l?.field&&(p.valueAccessor=l.field,delete p.colorBy),o?.axis?.title&&(p.xLabel=o.axis.title),n?.axis?.title&&(p.yLabel=n.axis.title),t&&(p.data=t);break;case"arc":i.innerRadius&&i.innerRadius>0?(h="DonutChart",p.innerRadius=i.innerRadius):h="PieChart",d?.field?p.valueAccessor=d.field:n?.field&&(p.valueAccessor=m?"value":n.field),l?.field&&(p.categoryAccessor=l.field),o?.field&&!d?.field&&(p.categoryAccessor=o.field),t&&(p.data=t);break;case"tick":h="DotPlot",Hs(o?.type)?(p.categoryAccessor=o.field,n?.field&&(p.valueAccessor=m?"value":n.field),o?.axis?.title&&(p.categoryLabel=o.axis.title),n?.axis?.title&&(p.valueLabel=n.axis.title)):Hs(n?.type)?(p.categoryAccessor=n.field,o?.field&&(p.valueAccessor=y?"value":o.field),p.orientation="horizontal",n?.axis?.title&&(p.categoryLabel=n.axis.title),o?.axis?.title&&(p.valueLabel=o.axis.title)):(o?.field&&(p.categoryAccessor=o.field),n?.field&&(p.valueAccessor=m?"value":n.field)),t&&(p.data=t);break;default:r.push(`Unsupported mark type "${a}". Defaulting to Scatterplot.`),h="Scatterplot",ro(o,n,p,y,m),t&&(p.data=t)}return ao(h,p,r)}function eo(e,t={}){let r=Xs(e),a=r.filter(e=>"error"===e.severity),i=Qs(e),s={adapter:"semiotic/vega-lite",direction:"import",sourceFormat:"vega-lite",targetFormat:"semiotic-chart-config",..."string"==typeof i?.specVersion?{specVersion:i.specVersion}:{},...i?{metadata:{idid:i}}:{}};if(a.length>0&&"lossy"!==t.mode)return{status:"refused",diagnostics:r,lossReport:a.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:s};let o=Js(e),n=(o.warnings||[]).map(e=>({code:"LEGACY_TRANSLATION_WARNING",severity:"warning",message:e})),l=a.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),c="lossy"===t.mode?r.map(e=>"error"===e.severity?{...e,severity:"warning"}:e):r;return{status:l.length>0?"lossy":"success",config:o,diagnostics:[...c,...n],lossReport:l,provenance:s}}function to(e,t,r,a,i,s,o){let n;return r?.field&&!1!==e?.stack&&!1!==t?.stack&&null!==e?.stack&&null!==t?.stack?(n="StackedBarChart",a.stackBy=r.field):n="BarChart",Hs(e?.type)&&Ys(t?.type)?(a.categoryAccessor=e.field,a.valueAccessor=o?"value":t.field,e?.axis?.title&&(a.categoryLabel=e.axis.title),t?.axis?.title&&(a.valueLabel=t.axis.title)):Ys(e?.type)&&Hs(t?.type)?(a.categoryAccessor=t.field,a.valueAccessor=s?"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=o?"value":t.field),e?.axis?.title&&(a.categoryLabel=e.axis.title),t?.axis?.title&&(a.valueLabel=t.axis.title)),i&&(a.data=i),n}function ro(e,t,r,a,i){e?.field&&(r.xAccessor=a?"value":e.field),t?.field&&(r.yAccessor=i?"value":t.field),e?.axis?.title&&(r.xLabel=e.axis.title),t?.axis?.title&&(r.yLabel=t.axis.title)}function ao(e,t,r){let a={component:e,props:t,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString()};if(r.length>0){a.warnings=r;for(let e of r)console.warn("[semiotic/fromVegaLite] "+e)}return a}function io(e){return"string"==typeof e?e:void 0}function so(e){return"function"==typeof e}function oo(e,t){if(!Array.isArray(e)||!t)return!1;for(let r of e){let e=r?.[t];if(null!=e)return!("number"==typeof e||e instanceof Date)&&"string"==typeof e&&Number.isNaN(Date.parse(e))}return!1}function no(e,t,r){so(t)&&e.push(`The "${r}" channel is a function accessor, which can't be serialized to a config. Pass a field name (string) instead, or pre-derive the field on your data.`)}function lo(e){let t=[];(e.facet||e.fx||e.fy)&&t.push('Faceted plots ("facet"/"fx"/"fy") are not supported. Use Semiotic\'s LinkedCharts or render multiple charts.');let r=(Array.isArray(e.marks)?e.marks:[]).filter(e=>e&&!pd.has(e.type.toLowerCase()));if(0===r.length)return t.push("No translatable data mark found in the Plot spec. Defaulting to an empty Scatterplot."),fo("Scatterplot",{},t);r.length>1&&t.push(`Multiple data marks (${r.map(e=>e.type).join(", ")}); only the first is translated. Layered multi-mark plots aren't supported.`);let a=r[0],i=a.options||{},s=a.data||e.data,o={};"number"==typeof e.width&&(o.width=e.width),"number"==typeof e.height&&(o.height=e.height),"string"==typeof e.title&&(o.title=e.title),e.x?.label&&(o.xLabel=e.x.label),e.y?.label&&(o.yLabel=e.y.label);let n=e.color?.scheme?dd[e.color.scheme]:void 0;no(t,i.x,"x"),no(t,i.y,"y"),no(t,i.fill,"fill"),no(t,i.stroke,"stroke"),no(t,i.r,"r");let l,c=io(i.x),d=io(i.y),u=io(i.fill),p=io(i.stroke),f=u||p,h=a.type.toLowerCase();switch(h){case"line":case"liney":case"linex":{l="LineChart",c&&(o.xAccessor=c),d?o.yAccessor=d:t.push(a.type+" has no explicit y field; provide options.y."),oo(s,c)&&t.push(`The x field "${c}" looks categorical; LineChart uses a continuous x scale, so a categorical x won't position (the line won't draw). Use a numeric/time x, or a bar chart for categories.`),"liney"===h&&!c&&t.push("lineY without an explicit x plots against the row index, which Semiotic doesn't infer. Provide options.x.");let e=p||u;e&&(o.lineBy=e),uo(i,o),po(o,s,{colorScheme:n});break}case"bary":case"bar":l=f?"StackedBarChart":"BarChart",c&&(o.categoryAccessor=c),d&&(o.valueAccessor=d),f&&(o.stackBy=f),po(o,s,{colorScheme:n});break;case"barx":l=f?"StackedBarChart":"BarChart",o.orientation="horizontal",d&&(o.categoryAccessor=d),c&&(o.valueAccessor=c),f&&(o.stackBy=f),po(o,s,{colorScheme:n});break;case"dot":case"doty":case"dotx":case"circle":{let e=i.r;"string"==typeof e?(l="BubbleChart",o.sizeBy=e):(l="Scatterplot","number"==typeof e&&(o.pointRadius=e)),c&&(o.xAccessor=c),d&&(o.yAccessor=d),po(o,s,{colorBy:f,colorScheme:n});break}case"area":case"areay":case"areax":l=u&&u!==d?"StackedAreaChart":"AreaChart",c&&(o.xAccessor=c),d&&(o.yAccessor=d),oo(s,c)&&t.push(`The x field "${c}" looks categorical; ${l} uses a continuous x scale, so a categorical x won't position. Use a numeric/time x.`),"StackedAreaChart"===l&&u&&(o.areaBy=u),uo(i,o),po(o,s,{colorBy:"StackedAreaChart"===l?void 0:f,colorScheme:n});break;case"recty":case"rectx":case"rect":{l="Histogram";let e="rectx"===h?c:d||c;e&&(o.valueAccessor=e),f&&(o.categoryAccessor=f),po(o,s,{colorScheme:n});break}case"cell":case"celly":case"cellx":l="Heatmap",c&&(o.xAccessor=c),d&&(o.yAccessor=d),f&&(o.valueAccessor=f),po(o,s);break;case"tick":case"tickx":case"ticky":l="DotPlot","tickx"===h?(d&&(o.categoryAccessor=d),c&&(o.valueAccessor=c),o.orientation="horizontal"):(c&&(o.categoryAccessor=c),d&&(o.valueAccessor=d)),po(o,s,{colorBy:f,colorScheme:n});break;default:t.push(`Plot mark "${a.type}" has no faithful Semiotic equivalent in this adapter. Defaulting to a Scatterplot of x/y; verify the result or file for support.`),l="Scatterplot",c&&(o.xAccessor=c),d&&(o.yAccessor=d),po(o,s,{colorBy:f,colorScheme:n})}if(fd.has(l)){let t=co(e.x?.type),r=co(e.y?.type);t&&(o.xScaleType=t),r&&(o.yScaleType=r)}return fo(l,o,t)}function co(e){return"time"===e||"utc"===e?"time":"log"===e?"log":void 0}function uo(e,t){e.curve&&ud[e.curve]&&(t.curve=ud[e.curve])}function po(e,t,r={}){Array.isArray(t)&&(e.data=t),r.colorBy&&(e.colorBy=r.colorBy),r.colorScheme&&(e.colorScheme=r.colorScheme)}function fo(e,t,r){let a={component:e,props:t,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString()};if(r.length>0){a.warnings=r;for(let e of r)console.warn("[semiotic/fromObservablePlot] "+e)}return a}function ho(e){let t=e.trim();return t.length>=2&&('"'===t[0]&&t.endsWith('"')||"'"===t[0]&&t.endsWith("'"))?t.slice(1,-1):t}function yo(e){let t=e.trim();if(!t)return null;let r=t.match(/^([A-Za-z0-9_][\w-]*)/);if(!r)return null;let a=r[1],i=t.slice(a.length).trim();if(!i)return{id:a};for(let[e,t,r]of gd)if(i.startsWith(e)&&i.endsWith(t)&&i.length>=e.length+t.length)return{id:a,label:ho(i.slice(e.length,i.length-t.length)),shape:r};return{id:a}}function mo(e){let t=[],r=()=>({kind:"flowchart",direction:"TD",nodes:[],edges:[],...t.length?{warnings:t}:{}});if("string"!=typeof e||!e.trim())return t.push("Empty Mermaid input."),r();let a=e.split("\n").map(e=>e.replace(/%%.*$/,"").trim()).filter(e=>e.length>0);if(0===a.length)return t.push("No content after stripping comments."),r();let i=a[0],s=i.split(/\s+/)[0].toLowerCase();if("graph"!==s&&"flowchart"!==s&&(hd.has(s)?t.push(`Mermaid "${i.split(/\s+/)[0]}" diagrams aren't supported — only graph/flowchart compile to a Semiotic graph. Other diagram types are declined rather than mistranslated.`):t.push(`Expected a "graph" or "flowchart" header; got "${i}". Treating remaining lines as flowchart edges.`),hd.has(s)))return r();let o="TD",n=i.split(/\s+/)[1]?.toUpperCase();n&&yd.has(n)&&(o=n);let l="graph"===s||"flowchart"===s?1:0,c=/* @__PURE__ */new Map,d=[],u=e=>{let t=c.get(e.id);t?e.label&&t.label===t.id&&(t.label=e.label,e.shape&&(t.shape=e.shape)):c.set(e.id,{id:e.id,label:e.label??e.id,shape:e.shape??"rect",layer:0,row:0})},p=e=>e.replace(/--\s+([^->|]+?)\s+-->/g,"--\x3e|$1|").replace(/-\.\s+([^->|]+?)\s+\.->/g,"-.->|$1|").replace(/==\s+([^=>|]+?)\s+==>/g,"==>|$1|");for(let e=l;a.length>e;e++){let r=p(a[e]);if(/^(subgraph|end|classDef|class|style|click|linkStyle|direction)\b/.test(r)){/^subgraph\b/.test(r)&&t.push("`subgraph` grouping is flattened; nodes are kept, the grouping is dropped.");continue}if(!md.test(r)){let e=yo(r);e&&u(e);continue}let i=r.split(md),s=null;for(let e=0;i.length>e;e+=2){let r,a=i[e].trim(),o=a.match(/^\|([^|]*)\|\s*(.*)$/);o&&(r=ho(o[1]),a=o[2].trim()),a.includes("&")&&(t.push('Multiple nodes joined with "&" — only the first is linked in this alpha.'),a=a.split("&")[0].trim());let n=yo(a);n?(u(n),s&&d.push({source:s.id,target:n.id,...r?{label:r}:{}}),s=n):s=null}}return 0===c.size?(t.push("No nodes found."),r()):(go(c,d,t),{kind:"flowchart",direction:o,nodes:[...c.values()],edges:d,...t.length?{warnings:t}:{}})}function go(e,t,r){let a=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let t of e.keys())a.set(t,[]),i.set(t,0);for(let r of t)r.source!==r.target&&(!e.has(r.source)||!e.has(r.target)||(a.get(r.source).push(r.target),i.set(r.target,(i.get(r.target)||0)+1)));let s=[];for(let[e,t]of i)0===t&&s.push(e);for(let t=0;s.length>t;t++){let r=s[t],o=e.get(r).layer;for(let t of a.get(r)){let r=e.get(t);o+1>r.layer&&(r.layer=o+1);let a=(i.get(t)||0)-1;i.set(t,a),0===a&&s.push(t)}}e.size>s.length&&r.push("Graph contains a cycle; layering is best-effort (not a strict DAG).");let o=/* @__PURE__ */new Map;for(let t of e.values())t.row=o.get(t.layer)??0,o.set(t.layer,t.row+1)}function vo(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function bo(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function ko(e){let t=((e||"")+"").toLowerCase().replace(/[^a-z0-9]/g,"");return"barchart"===t||"bar"===t?"bar":"groupedbarchart"===t||"groupedbar"===t||"clusteredbar"===t?"groupedBar":"stackedbarchart"===t||"stackedbar"===t?"stackedBar":"linechart"===t||"line"===t?"line":"areachart"===t||"area"===t||"streamgraph"===t?"area":"scatterplot"===t||"scatter"===t||"scatterchart"===t||"pointchart"===t?"scatter":"heatmap"===t||"heatmapchart"===t?"heatmap":"piechart"===t||"pie"===t||"donutchart"===t||"donut"===t?"pie":"histogram"===t||"histogramchart"===t?"histogram":"boxplot"===t||"boxplotchart"===t||"boxandwhisker"===t||"boxandwhiskerplot"===t?"boxplot":void 0}function xo(e,t){let r={};if(!e||"object"!=typeof e)return r;for(let[a,i]of Object.entries(e)){let e=bo(xd,a)||a,s=i;if(Array.isArray(s)){if(0===s.length)continue;t.push(`Static-series array encoding on "${a}" is not supported; using the first field and preserving the full encoding in flint.unmappedEncodings.`),s=s[0]}"string"==typeof s?r[e]={field:s}:vo(s)?r[e]=s:null!=s&&t.push(`Encoding "${a}" is not an object, string, or array and was ignored.`)}return r}function Co(e,t){let r=e[t]?.field;return"string"==typeof r&&r.length>0?r:void 0}function Ao(e){return"nominal"===e?.type||"ordinal"===e?.type}function wo(e){return"quantitative"===e?.type||"temporal"===e?.type}function $o(e,t){if(!e||!t)return;let r=bo(t,e);return"string"==typeof r?r:"string"==typeof r?.semanticType?r.semanticType:void 0}function So(e,t,r){if("temporal"===e?.type)return!0;let a=$o(t,r);return!!a&&/date|time|year|month|quarter|week/i.test(a)}function Bo(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Po(e){return"string"==typeof e&&e.length>0?e:void 0}function Wo(e){return"boolean"==typeof e?e:void 0}function Lo(e,t,r){r.push(`Temporal ${t} field "${e||"unknown"}" contains unparseable date strings; those rows will be skipped by the time scale. Prefer Date objects, ISO date strings, or epoch timestamps.`)}function Mo(e,t,r,a){let i=t||r;if(!i)return;let s=i.width,o=i.height;t&&r&&(t.width>r.width&&(s=r.width,a.push("chart_spec.canvasSize.width is smaller than baseSize.width; clamped Semiotic width to the canvas ceiling.")),t.height>r.height&&(o=r.height,a.push("chart_spec.canvasSize.height is smaller than baseSize.height; clamped Semiotic height to the canvas ceiling."))),Number.isFinite(s)&&(e.width=s),Number.isFinite(o)&&(e.height=o)}function Ro(e,t){let r=Po(t?.title);r&&(e.title=r)}function Io(e,t,r){if(!t)return;let a=t.toLowerCase(),i=bo(bd,a);i?e.colorScheme=i:r.push(`Flint color scheme "${t}" is not mapped to a Semiotic categorical colorScheme.`)}function Eo(e,t,r){if(!t)return;let a=t.toLowerCase();kd.has(a)?e.colorScheme=a:r.push(`Flint heatmap color scheme "${t}" is not available in Semiotic's Heatmap colorScheme enum.`)}function No(e,t,r,a){r&&("xy"===a?(t.x&&bo(r,t.x)&&(e.xLabel=bo(r,t.x)),t.y&&bo(r,t.y)&&(e.yLabel=bo(r,t.y))):(t.category&&bo(r,t.category)&&(e.categoryLabel=bo(r,t.category)),t.value&&bo(r,t.value)&&(e.valueLabel=bo(r,t.value))))}function To(e){let t=e.x,r=e.y,a=Co(e,"x"),i=Co(e,"y");return Ao(t)&&!Ao(r)?{category:a,value:i,valueEncoding:r}:Ao(r)&&!Ao(t)||wo(t)&&!wo(r)&&i?{category:i,value:a,valueEncoding:t,orientation:"horizontal"}:{category:a,value:i,valueEncoding:r}}function Fo(e){return"count"===e||"sum"===e||"mean"===e?e:"average"===e?"mean":void 0}function Oo(e,t,r,a,i){let s=Fo(a);if(!s)return{data:e,valueAccessor:r};if(!e)return i.push(`aggregate: "${a}" requires inline data.values; leaving the requested value accessor unchanged.`),{data:e,valueAccessor:r||"value"};if("count"!==s&&!r)return i.push(`aggregate: "${a}" requires an encoded value field; leaving data unaggregated.`),{data:e,valueAccessor:r};let o=/* @__PURE__ */new Map,n=t.filter(e=>!!e);for(let t of e){let e={};for(let r of n)e[r]=t[r];let a=JSON.stringify(e),i=o.get(a);if(i||(i={keys:e,values:[],count:0},o.set(a,i)),i.count+=1,r){let e=Number(t[r]);Number.isFinite(e)&&i.values.push(e)}}let l=[];for(let e of o.values()){let t=e.count;"sum"===s?t=e.values.reduce((e,t)=>e+t,0):"mean"===s&&(t=e.values.length>0?e.values.reduce((e,t)=>e+t,0)/e.values.length:0),l.push({...e.keys,value:t})}return{data:l,valueAccessor:"value"}}function jo(e,t){t&&(e.data=t)}function Do(e,t,r){let a=Po(t?.interpolate);if(!a)return;let i=bo(vd,a);i?e.curve=i:r.push(`Flint interpolate "${a}" is not mapped to a Semiotic curve.`)}function _o(e,t,r,a){if(!t)return;let i=/* @__PURE__ */new Set([...r,"title"]),s=Object.keys(t).filter(e=>!i.has(e));s.length>0&&a.push(`Flint chartProperties not mapped for ${e}: ${s.join(", ")}.`)}function zo(e,t,r){if(!t)return;let a=new Set(bo(Cd,e)??[]),i={};for(let[e,r]of Object.entries(t)){let t=bo(xd,e)||e;(!a.has(t)||Array.isArray(r))&&(i[e]=r)}if(0===Object.keys(i).length)return;let s=Object.keys(i),o=s.filter(e=>"column"===e||"row"===e);o.length>0&&r.push(`Flint facet channel(s) ${o.join(", ")} are not supported by this adapter; render multiple Semiotic charts instead.`);let n=s.filter(e=>{let t=bo(xd,e)||e;return"column"!==e&&"row"!==e&&!a.has(t)});return n.length>0&&r.push(`Flint encoding channel(s) not mapped for ${e}: ${n.join(", ")}.`),i}function Uo(e,t,r,a,i,s,o){let n={...a},l=To(t),c="groupedBar"===e?Co(t,"group")||Co(t,"color"):Co(t,"color")||Co(t,"group"),d=Oo(r,[l.category,c],l.value,l.valueEncoding?.aggregate,o);jo(n,d.data),l.category&&(n.categoryAccessor=l.category),d.valueAccessor&&(n.valueAccessor=d.valueAccessor),l.orientation&&(n.orientation=l.orientation),No(n,{category:l.category,value:l.value},s,"ordinal");let u=Bo(i?.cornerRadius);void 0!==u&&(n.roundedTop=u);let p=Po(i?.stackMode);if("normalize"===p?n.normalize=!0:p&&"stacked"!==p&&o.push(`Flint stackMode "${p}" is not supported by Semiotic ${e}; leaving default stacking behavior.`),Io(n,t.color?.scheme,o),"groupedBar"===e)return c&&(n.groupBy=c,n.colorBy=c,n.showLegend=!0),{component:"GroupedBarChart",props:n,supportedProperties:["cornerRadius"]};if("stackedBar"===e)return c?(n.stackBy=c,n.colorBy=c,n.showLegend=!0,{component:"StackedBarChart",props:n,supportedProperties:["cornerRadius","stackMode"]}):(o.push("Stacked Bar Chart has no color/group series field; emitted a BarChart instead."),{component:"BarChart",props:n,supportedProperties:["cornerRadius","stackMode"]});let f=Co(t,"color");return f&&(n.colorBy=f),{component:"BarChart",props:n,supportedProperties:["cornerRadius"]}}function Go(e,t,r,a,i,s,o,n){let l={...a},c=Co(t,"x"),d=Co(t,"y"),u=Co(t,"color"),p=Co(t,"detail"),f=Co(t,"size"),h=Co(t,"shape"),y=Oo(r,[c,u||p],d,t.y?.aggregate,n),m=So(t.x,c,s),g=So(t.y,d,s),v=y.data;if(m){let e=Fe(v,c);v=e.data,e.failed&&Lo(c,"x",n)}if(g){let e=Fe(v,y.valueAccessor);v=e.data,e.failed&&Lo(y.valueAccessor,"y",n)}if(jo(l,v),c&&(l.xAccessor=c),y.valueAccessor&&(l.yAccessor=y.valueAccessor),m&&(l.xScaleType="time"),g&&(l.yScaleType="time"),No(l,{x:c,y:d},o,"xy"),"line"===e){(u||p)&&(l.lineBy=u||p,l.colorBy=u||p),Do(l,i,n);let e=Wo(i?.showPoints);return void 0!==e&&(l.showPoints=e),{component:"LineChart",props:l,supportedProperties:["interpolate","showPoints"]}}if("area"===e){Do(l,i,n);let e=Bo(i?.opacity);void 0!==e&&(l.areaOpacity=e);let t=Po(i?.stackMode);return"normalize"===t?l.normalize=!0:t&&"stacked"!==t&&n.push(`Flint area stackMode "${t}" is not supported by Semiotic; leaving default stacking behavior.`),u?(l.areaBy=u,l.colorBy=u,{component:"StackedAreaChart",props:l,supportedProperties:["interpolate","opacity","stackMode"]}):{component:"AreaChart",props:l,supportedProperties:["interpolate","opacity"]}}if(u&&(l.colorBy=u),f){l.sizeBy=f,h&&n.push("Flint shape encoding is not mapped for BubbleChart; Semiotic only maps shape onto Scatterplot in this adapter.");let e=Bo(i?.opacity);return void 0!==e&&(l.bubbleOpacity=e),Io(l,t.color?.scheme,n),{component:"BubbleChart",props:l,supportedProperties:["opacity"]}}h&&(l.symbolBy=h);let b=Bo(i?.opacity);return void 0!==b&&(l.pointOpacity=b),Io(l,t.color?.scheme,n),{component:"Scatterplot",props:l,supportedProperties:["opacity"]}}function Vo(e,t,r,a,i,s){let o={...r},n=Co(e,"x"),l=Co(e,"y"),c=Co(e,"color");jo(o,t),n&&(o.xAccessor=n),l&&(o.yAccessor=l),c&&(o.valueAccessor=c);let d=Wo(a?.showTextLabels);return void 0!==d&&(o.showValues=d),No(o,{x:n,y:l},i,"xy"),Eo(o,e.color?.scheme||Po(a?.colorScheme),s),{component:"Heatmap",props:o,supportedProperties:["showTextLabels","colorScheme"]}}function qo(e,t,r,a,i,s){let o={...a},n=Co(t,"color"),l=Oo(r,[n],Co(t,"size")||Co(t,"angle")||Co(t,"y"),t.size?.aggregate||t.angle?.aggregate||t.y?.aggregate,s);jo(o,l.data),n&&(o.categoryAccessor=n),l.valueAccessor&&(o.valueAccessor=l.valueAccessor);let c=Bo(i?.innerRadius),d=/donut/i.test(e)||void 0!==c&&c>0;d&&void 0!==c&&(o.innerRadius=c);let u=Bo(i?.cornerRadius);return void 0!==u&&(o.cornerRadius=u),null!=i?.sortSlices&&s.push("Flint sortSlices is not mapped; preserve or sort slice order before calling unstable_fromFlintChart()."),Io(o,t.color?.scheme,s),{component:d?"DonutChart":"PieChart",props:o,supportedProperties:["innerRadius","cornerRadius","sortSlices"]}}function Ho(e,t,r,a){let i={...r},s=Co(e,"x")||Co(e,"y"),o=Co(e,"color");jo(i,t),s&&(i.valueAccessor=s),o&&(i.categoryAccessor=o,i.colorBy=o);let n=Bo(a?.binCount);return void 0!==n&&n>0&&(i.bins=n),{component:"Histogram",props:i,supportedProperties:["binCount"]}}function Yo(e,t,r,a,i,s){let o={...r},n=To(e);jo(o,t),n.category&&(o.categoryAccessor=n.category),n.value&&(o.valueAccessor=n.value),n.orientation&&(o.orientation=n.orientation);let l=Co(e,"color");l&&(o.colorBy=l);let c=Wo(a?.showOutliers);void 0!==c&&(o.showOutliers=c);let d=Po(a?.whiskerMethod);return d&&"iqr"!==d&&s.push(`Flint whiskerMethod "${d}" is not mapped; Semiotic BoxPlot keeps its default whisker calculation.`),No(o,{category:n.category,value:n.value},i,"ordinal"),{component:"BoxPlot",props:o,supportedProperties:["showOutliers","whiskerMethod"]}}function Qo(e){let t=[],r=e.chart_spec,a=r?.chartType,i=ko(a),s=r?.chartProperties,o=Array.isArray(e.data?.values)?e.data.values:void 0,n="string"==typeof e.data?.url?e.data.url:void 0,l=xo(r?.encodings,t),c={};n&&t.push("data.url is preserved in flint.dataUrl but not fetched; resolve it to data.values before rendering."),i||t.push(`Unsupported Flint chartType "${a}". Defaulting to Scatterplot.`),Mo(c,r?.baseSize,r?.canvasSize,t),Ro(c,s);let d,u=i||"scatter";switch(u){case"bar":case"groupedBar":case"stackedBar":d=Uo(u,l,o,c,s,e.field_display_names,t);break;case"line":case"area":case"scatter":d=Go(u,l,o,c,s,e.semantic_types,e.field_display_names,t);break;case"heatmap":d=Vo(l,o,c,s,e.field_display_names,t);break;case"pie":d=qo(a,l,o,c,s,t);break;case"histogram":d=Ho(l,o,c,s);break;case"boxplot":d=Yo(l,o,c,s,e.field_display_names,t)}_o(u,s,d.supportedProperties,t);let p=zo(u,r?.encodings,t),f={component:d.component,props:d.props,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString(),flint:{chartType:a||"",...e.semantic_types?{semanticTypes:e.semantic_types}:{},...e.field_display_names?{fieldDisplayNames:e.field_display_names}:{},...s?{chartProperties:s}:{},...r?.baseSize?{baseSize:r.baseSize}:{},...r?.canvasSize?{canvasSize:r.canvasSize}:{},...n?{dataUrl:n}:{},...e.options?{options:e.options}:{},...p?{unmappedEncodings:p}:{}}};if(t.length>0){f.warnings=t;for(let e of t)console.warn("[semiotic/fromFlintChart] "+e)}return f}function Zo(e){let t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;let r=t.slice(4,-1),a=r.indexOf(",");if(-1===a){let e=r.trim();return e.startsWith("--")?{name:e}:null}let i=r.slice(0,a).trim(),s=r.slice(a+1).trim();return i.startsWith("--")?{name:i,fallback:s||void 0}:null}function Ko(e,t){if(!t)return t;let r=Zo(t);if(!r)return t;let a=()=>r.fallback?Ko(e,r.fallback):t,i=e.canvas;if(!i)return a();let s=Ad.get(i);(!s||0!==s.version)&&(s={version:0,map:/* @__PURE__ */new Map},Ad.set(i,s));let o=s.map.get(t);if(void 0!==o)return o;let n=getComputedStyle(i).getPropertyValue(r.name).trim()||a()||t;return s.map.set(t,n),n}function Xo(e,t,r){if(!t)return r.fallback;for(let a of r.names){let r=t.getPropertyValue(a).trim();if(r)return Ko(e,r)??r}return r.fallback}function Jo(e,t){let r=Math.max(0,Math.min(1,t)),a=e.trim(),i=a.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(i){let[,e,t,a]=i;return Jo(`#${e}${e}${t}${t}${a}${a}`,r)}let s=a.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(s){let[,e,t,a]=s;return`rgba(${parseInt(e,16)}, ${parseInt(t,16)}, ${parseInt(a,16)}, ${r})`}let o=a.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(o)return`rgba(${o[1]}, ${r})`;let n=a.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return n?`rgba(${n[1]}, ${r})`:a}function en(e){let t=e.canvas,r="function"==typeof getComputedStyle&&t?getComputedStyle(t):null,a=Xo(e,r,$d.primary),i=Xo(e,r,$d.danger),s=Xo(e,r,$d.warning),o=Xo(e,r,$d.success),n=Xo(e,r,$d.border),l=Xo(e,r,$d.background),c=Xo(e,r,$d.text),d=Xo(e,r,$d.textSecondary),u=Xo(e,r,$d.focus),p=Xo(e,r,$d.grid);return{annotationBackground:Jo(l,.94),annotationStroke:n,annotationText:c,background:l,border:n,closedWindowFill:Jo(i,.08),closedWindowStroke:Jo(i,.55),danger:i,focus:u,grid:p,gutterFill:Jo(d,.14),lateFill:s,openWindowFill:Jo(a,.07),openWindowStroke:Jo(a,.3),primary:a,selectedFill:s,selectedStroke:u,success:o,text:c,textSecondary:d,warning:s}}function tn(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}function rn(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}function an(e,t,r,a){let i=e-(t+r+a);return{charge:e,live:t,queued:r,sedimented:a,unaccounted:i,balanced:0===i}}function sn(e,t={}){let r=t.bodies??tn(e),a=r.filter(e=>e.sleeping).length,i=e.queue.length,s=e.sediment.reduce((e,t)=>e+t.count,0),o="settled"===e.simulationState&&0===i&&a===r.length,n=[];o||n.push("PHYSICS_NOT_SETTLED"),i>0&&n.push("PHYSICS_QUEUE_UNDRAINED");let l=null!=t.charge&&Number.isFinite(t.charge)?an(t.charge,r.length,i,s):void 0;return l&&!l.balanced&&n.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:r.length,sleepingCount:a,settled:o,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:rn(t.projectionRows),queuedCount:i,sedimentedCount:s,...l?{ledger:l}:{},warnings:n}}function on(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function nn(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function ln(e,t,r){let a="function"==typeof t?t(e,r):t;return{...Sd,...a??{}}}function cn(e,t={},r={index:0,simulationState:"settled"}){let a=on(e),i={label:t.getBodyLabel?.(e)??nn(e)},s={style:ln(e,t.bodyStyle,r),datum:a,accessibleDatum:a,accessibility:i,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...s}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...s}}function dn(e,t={},r="settled"){return e.map((e,a)=>cn(e,t,{index:a,simulationState:r}))}function un(e,t={}){let r=e.settle(t.maxSteps),a=e.readBodies(),i=e.snapshot();return{snapshot:i,bodies:a,sceneNodes:dn(a,t,i.simulationState),evidence:sn(i,{bodies:a,projectionRows:t.projectionRows,stepsRun:r,charge:t.charge}),stepsRun:r}}function pn(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function fn(e,t){let{background:r="transparent",stroke:a="#000",lineWidth:i=1.5,spacing:s=6,angle:o=45,lineOpacity:n=1}=e,l=Math.max(8,Math.ceil(2*s));/* @__PURE__ */
4
4
  return Ld("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==o?`rotate(${o})`:void 0,children:[r&&"transparent"!==r&&/* @__PURE__ */Wd("rect",{width:l,height:l,fill:r}),
5
5
  /* @__PURE__ */Wd("line",{x1:0,y1:0,x2:0,y2:l,stroke:a,strokeWidth:i,strokeOpacity:n}),