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,s=1/0,o=-1/0,i=-1/0;for(let e=0;t.length>e+1;e+=2){let a=parseFloat(t[e]),l=parseFloat(t[e+1]);Number.isFinite(a)&&(r=Math.min(r,a),o=Math.max(o,a)),Number.isFinite(l)&&(s=Math.min(s,l),i=Math.max(i,l))}return Number.isFinite(r)&&Number.isFinite(s)?{x:r,y:s,w:o-r,h:i-s}:null}function r(e){let t=e.fontSize??12,r=Math.max(1,(e.text+"").length*t*.6),s=e.textAnchor??"start";return{x:"middle"===s?e.x-r/2:"end"===s?e.x-r:e.x,y:e.y-t,w:r,h:1.2*t}}function s(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 o(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 i(e,t){let[r=0,s=0]=t.translate??[],[o=1,i=1]=t.scale??[];return{tx:e.tx+r*e.sx,ty:e.ty+s*e.sy,sx:e.sx*o,sy:e.sy*i}}function a(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=a(e);if(null!=t)return t}}function l(e){return null==e?null:Array.isArray(e)?0===e.length?null:1===e.length?e[0]:{...e[0],_rows:e}:e}function n(t,r,s){let o=e(t.style);switch(t.kind){case"rect":return yo("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}:{},...o});case"ellipse":return yo("ellipse",{key:r,cx:t.cx,cy:t.cy,rx:t.rx,ry:t.ry,...o});case"path":return yo("path",{key:r,d:t.d,...o});case"text":return yo("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})`}:{},...o},t.text);case"image":return yo("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}:{},...o});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]})`),yo("g",{key:r,...e.length?{transform:e.join(" ")}:{},...o},t.children.map((e,t)=>n(e,`${r}-${t}`,s)))}case"composite":case"mask":return c(t,r,s)}}function c(e,t,r){let s="gf-comp-"+r.compositeId++,o=s+"-source",i=s+"-destination";if("mask"===e.kind){let a=s+"-mask";return yo(po,{key:t},yo("defs",null,yo("g",{id:o},e.mask.map((e,t)=>n(e,`${a}-m-${t}`,r))),yo("g",{id:i},e.content.map((e,t)=>n(e,`${a}-c-${t}`,r))),yo("mask",{id:a,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse"},yo("use",{href:"#"+o}))),yo("use",{href:"#"+i,mask:`url(#${a})`}))}let{x:a,y:l,w:c,h:d}=e.bbox,u=`translate(${a} ${l})`,f=e.blendMode,y="atop"===e.operator||"in"===e.operator,p=s+"-desat",h=s+"-cov",m=e.source.map((e,t)=>n(e,`${s}-s-${t}`,r)),g=e.dest.map((e,t)=>n(e,`${s}-d-${t}`,r)),k=[];return f&&k.push(yo("filter",{key:"desat",id:p},yo("feColorMatrix",{type:"saturate",values:"0"}))),y&&k.push(yo("mask",{key:"cov",id:h,maskUnits:"userSpaceOnUse",x:a,y:l,width:c,height:d,style:{maskType:"alpha"}},yo("g",{transform:u},e.source.map((e,t)=>n(e,`${s}-m-${t}`,r))))),yo(po,{key:t},k.length?yo("defs",{key:"defs"},k):null,yo("g",{key:"g",...y?{mask:`url(#${h})`}:{}},yo("g",{transform:u,style:{isolation:"isolate"}},yo("g",f?{filter:`url(#${p})`}:null,m),yo("g",f?{style:{mixBlendMode:f}}:null,g))))}function d(e,t,r,n){for(let c of e){if("group"===c.kind){d(c.children,i(t,c.transform),r,n);continue}let e=c.role??"node",u=l(a(c));if("node"!==e||!u||"text"===c.kind)continue;let f=s(c);if(!f)continue;let y=o(f,t);y.w>0&&y.h>0&&(r.push({type:"rect",x:y.x,y:y.y,w:y.w,h:y.h,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:u,id:c.id??"gofish-node-"+n.n}),n.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=l(a(r));e&&t.push(e)}}function f(e){return t=>{let r=t.config?.displayList??e,s=[];d(r.items,mo,s,{n:0});let o={compositeId:0};return{sceneNodes:s,overlays:yo("g",{className:"semiotic-gofish-displaylist","data-gofish-ir":r.ir},r.items.map((e,t)=>n(e,"gf-"+t,o)))}}}function y(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 s=t.displayList??e,o=Array.isArray(s?.items)?s.items:[];0===o.length&&r.push("Display list carried no items; the chart will render empty.");let i=[];u(o,i);let a=s?.viewport??{w:0,h:0};return{family:"network",networkLayout:f(s),layoutConfig:{displayList:s},nodes:i,edges:[],width:a.w,height:a.h,irVersion:s?.irVersion??0,warnings:r.length?r:void 0}}function p(e,t){let r=e.length,s=t.length,o=Array(s+1);for(let e=0;s>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;s>=a;a++){let s=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=s}}return o[s]}function h(e,t,r=3){let s,o=r+1;for(let r of t){let t=p(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,s=r)}return o>r?void 0:s}function m(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function g(e,t){if(0===t.length)return null;let r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||(h(e,t,3)??null)}function k(e){return` Or use a function: ${e}={d => d.myValue}.`}function v({componentName:e,data:t,accessors:r,requiredProps:s}){if(s)for(let[t,r]of Object.entries(s))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 s=m(t).find(e=>e&&"object"==typeof e);if(s){let t=Object.keys(s);for(let[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in s)){let r=g(i,t),s=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${i}" not found in data. Available fields: ${t.join(", ")}.${s}`+k(o)}}}return null}function x({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 b({componentName:e,nodes:t,edges:r,nodesRequired:s=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(s&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){let r=m(t).find(e=>e&&"object"==typeof e);if(r){let t=Object.keys(r);for(let[s,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){let r=g(o,t),i=r?` Try ${s}="${r}".`:"";return`${e}: ${s} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`+k(s)}}}return null}function C(e){let[t,r]=Array.isArray(e)?e:[e,void 0],s=Eo[t],o=Array.isArray(s)?[...s]:s;return void 0===r?{type:o}:{type:o,enum:[...No[r]]}}function A(){return Object.fromEntries(To.map(([e,t,r,s,o],i)=>[fo[i],{required:[...e],dataShape:t,dataAccessors:[...r],props:Object.fromEntries(Object.entries(Object.assign({},...s.map(e=>_o[e]),o)).map(([e,t])=>[e,C(t)]))}]))}function w(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function S(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"UnitPileChart"===e)}function W(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 s=e;("number"!=typeof s.value||!Number.isFinite(s.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 s.color||0===s.color.length)&&t.push(`"thresholds[${r}].color" is required for GaugeChart and must be a non-empty string.`),void 0!==s.label&&"string"!=typeof s.label&&t.push(`"thresholds[${r}].label" for GaugeChart should be a string.`);let o=Object.keys(s).filter(e=>"value"!==e&&"color"!==e&&"label"!==e);o.length>0&&t.push(`"thresholds[${r}]" has unsupported GaugeChart key(s): ${o.join(", ")}. Use { value, color, label? }; { at, level } belongs to BigNumber.`)}),t}function L(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 s=[],o=r,i=/* @__PURE__ */new Set(["align",...Object.keys(zo)]);for(let e of Object.keys(o))i.has(e)||s.push(`Unknown "frameProps.legendLayout" key "${e}". Valid keys: ${[...i].join(", ")}.`);void 0!==o.align&&"string"!=typeof o.align?s.push(`"frameProps.legendLayout.align" should be string, got ${Array.isArray(o.align)?"array":typeof o.align}.`):"string"==typeof o.align&&!Fo.has(o.align)&&s.push(`"frameProps.legendLayout.align" value "${o.align}" is not valid. Expected one of: ${[...Fo].join(", ")}.`);for(let[e,t]of Object.entries(zo)){let r=o[e];void 0!==r&&("number"==typeof r&&Number.isFinite(r)?t.minimum>r&&s.push(`"frameProps.legendLayout.${e}" should be ${t.label} (minimum ${t.minimum}), got ${r}.`):s.push(`"frameProps.legendLayout.${e}" should be ${t.label}, got ${Array.isArray(r)?"array":typeof r}.`))}return s}function B(e,t){let r=[];(null==t||"object"!=typeof t)&&(t={});let s=Oo[e];if(!s)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Oo).join(", ")}`]};for(let o of s.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);"array"===s.dataShape&&Object.prototype.hasOwnProperty.call(s.props,"data")&&!s.required.includes("data")&&!S(e,t)&&null==t.data&&r.push(`"data" is required for ${e}.`);for(let[e,o]of Object.entries(t)){if(null==o)continue;let t=s.props[e];if(t){if(!w(o,t.type)){let s=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${s}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}let o=Object.keys(s.props),i=new Set(o);for(let s of Object.keys(t))if(void 0!==t[s]&&!i.has(s)){let t=h(s,o),i=t?`Unknown prop "${s}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${s}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(i)}if("array"===s.dataShape){let o=t.data,i={};for(let e of s.dataAccessors){let r=t[e];"string"==typeof r&&(i[e]=r)}let a=v({componentName:e,data:o,accessors:Object.keys(i).length>0?i:void 0});a&&r.push(a)}else if("object"===s.dataShape){let s=x({componentName:e,data:t.data});s&&r.push(s)}else if("network"===s.dataShape){let o=t.nodeIdAccessor??t.nodeIDAccessor??"id",i="string"==typeof o?{nodeIdAccessor:o}:void 0,a=b({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:s.required.includes("nodes"),edgesRequired:s.required.includes("edges"),accessors:i});a&&r.push(a)}return"GaugeChart"===e&&r.push(...W(t)),"ScatterplotMatrix"===e&&null!=t.frameProps&&r.push('"frameProps" is not supported for ScatterplotMatrix; configure its matrix props directly.'),r.push(...L(t)),{valid:0===r.length,errors:r}}function R(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function P(e,t={}){let r=[],s=e.tokenSemantics,o=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==o||R(e.denominator)>100?80:100);return s||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),o||r.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),("icon"===e.tokenType||"glyph"===e.tokenType)&&("icon-only"===e.labelPolicy||"token-only"===e.labelPolicy)&&r.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&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"===s&&("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"===s&&o&&"unitized"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===s&&o&&"fixed-denominator"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),("possible-outcome"===s||"posterior-sample"===s||"hypothetical-case"===s)&&o&&"quantile"!==o&&"sample"!==o&&"posterior-sample"!==o&&"random-sample"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===s&&"unitized"===o&&null==e.unitValue&&null==e.unit&&r.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"===s&&"unitized"===o&&!e.unitMeaning&&r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function $(e,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 M(e){let t=e.provenance,r=e.id??e.stableId??t?.stableId;return null==r||""===r?void 0:r+""}function I(e,t,r){let s=Array.isArray(t.annotations)?t.annotations:null;if(s)for(let e of s)!e||"object"!=typeof e||"widget"!==Hs(e)||null==e.content||M(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 E(e,t,r){let s=Array.isArray(t.annotations)?t.annotations:null;if(s)for(let e of s){if(!e||"object"!=typeof e)continue;let t=Hs(e);if(!qs(e)||"widget"===t)continue;let s=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,i=Ys(e);!i&&s>120?r.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${o}" sits ~${Math.round(s)}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).'}):i&&s>250&&r.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${o}" uses a very long connector (~${Math.round(s)}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 N(e,t,r){let s=Array.isArray(t.annotations)?t.annotations:null;if(!s)return;let o=s.filter(qs).length;if(0===o)return;let i="number"==typeof t.width?t.width:600,a="number"==typeof t.height?t.height:400,l=$(i,a);!Number.isFinite(l)||l>=o||r.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${o} note annotations on a ${i}×${a} chart exceed the ~${l} 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 _(e,t,r){for(let e of jo){let s=t[e];if(!Array.isArray(s)||2>s.length)continue;let[o,i]=s;"number"!=typeof o||"number"!=typeof i||o>i&&r.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${o}, ${i}] 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}={[${i}, ${o}]}). If the inversion is deliberate (e.g. rank #1 at top), say so in the title or an annotation so readers aren't misled.`})}}function T(e,t,r){if("MultiAxisLineChart"!==e)return;let s=t.series;if(!Array.isArray(s)||2!==s.length)return;let o=s.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);o.length>0&&r.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${o.length} unlabeled series. Two y-scales invite false equivalence between the lines; without per-series labels a reader can't tell which scale is whose.`,fix:'Give every series a label: series={[{ yAccessor: "a", label: "Revenue ($)" }, { yAccessor: "b", label: "Users" }]} — and consider whether two separate charts read more honestly.'})}function O(e,t,r){if(!Ks.has(e))return;let s=t.xExtent;if(!Array.isArray(s)||2>s.length)return;let[o,i]=s;if("number"!=typeof o||"number"!=typeof i||o>=i)return;let a=t.data;if(!a||!Array.isArray(a)||4>a.length)return;let l=t.xAccessor??"x";if("string"!=typeof l)return;let n=1/0,c=-1/0;for(let e of a){let t=e?.[l];"number"!=typeof t||!Number.isFinite(t)||(n>t&&(n=t),t>c&&(c=t))}if(!Number.isFinite(n)||!Number.isFinite(c)||n>=c)return;let d=c-n,u=Math.max(0,Math.min(i,c)-Math.max(o,n))/d;.7>u&&r.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${o}, ${i}] shows only ~${Math.round(100*u)}% of the data's x range [${n}, ${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 F(e,t,r){let s=ro[e],o=so[e];if(!s&&!o||o&&!t.normalize)return;let i=s??o,a=t[i],l="string"==typeof a?a:"yAccessor"===i?"y":"value",n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;let c=n.filter(e=>{let t=e?.[l];return"number"==typeof t&&0>t});c.length>0&&r.push({severity:s?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${c.length} negative value(s) in "${l}" — a part-to-whole encoding cannot represent negative parts${s?"; slice angles/areas for negatives are meaningless":"; normalized shares distort when parts are negative"}.`,fix:s?"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 z(e,t,r){eo.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 D(e,t,r){if("LineChart"!==e&&"AreaChart"!==e||"sparkline"===t.mode||t.responsiveWidth||t.responsiveHeight)return;let s="number"==typeof t.width?t.width:600,o="number"==typeof t.height?t.height:400;if(0>=s||0>=o)return;let i=s/o;if(i>8||.25>i){let e=i>8?"flattens":"exaggerates";r.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${s}×${o} (${i.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:i>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 j(e,t,r){if(!to.has(e))return;let s=t.data;if(!s||!Array.isArray(s)||0===s.length)return;let o=t.categoryAccessor,i="string"==typeof o?o:"category",a=/* @__PURE__ */new Set;for(let e of s){let t=e?.[i];null!=t&&a.add(t)}a.size>8&&r.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:a.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 ${a.size} categories, or group the long tail into an "Other" slice before charting.`})}function U(e){let t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function G(e,t,r){return"function"==typeof t?t(e):e?.["string"==typeof t?t:r]}function V(e,t,r){if(oo.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 s=U(t.branchProbability);null!=t.branchProbability&&(null==s||0>s||s>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 o=U(t.mechanicalCount);null!=t.mechanicalCount&&(null==o||0>=o)&&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,s=e&&"object"==typeof e?U(e.size):null;null!=s&&0>=s&&r.push({severity:"error",code:"PHYSICS_BAD_WINDOW_SIZE",message:`windows.size=${s} 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 o=Array.isArray(t.data)?t.data:[];if(o.length>0){let e=t.timeAccessor||"time",s=t.arrivalAccessor||"arrivalTime";o.some(t=>{let r=U(G(t,e,"time")),o=U(G(t,s,"arrivalTime"));return null!=r&&null!=o&&r!==o})||r.push({severity:"warning",code:"PHYSICS_EVENTDROP_NO_ARRIVAL_SPREAD",message:"EventDropChart data does not show distinct arrival times, so the physics replay collapses to event order.",fix:"Provide an arrivalAccessor field with event-arrival times when demonstrating lateness, watermarks, or out-of-order streams."})}}if("UnitPileChart"===e){let e="mechanical"===(t.simulationMode??t.mode),s=U(t.mechanicalCount);null!=t.mechanicalCount&&(null==s||0>=s)&&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 o=lo(t.unitValue??1);if(null==o||0>=o)return void r.push({severity:"error",code:"PHYSICS_BAD_UNIT_VALUE",message:`unitValue=${t.unitValue} cannot unitize values into physical bodies.`,fix:"Set unitValue to a positive number represented by one body."});let i=e?co({count:s??void 0,categories:Array.isArray(t.mechanicalCategories)?t.mechanicalCategories:void 0,seed:lo(t.seed)??1,unitValue:o}):Array.isArray(t.data)?t.data:[],{rows:a}=no(i,"pile"),l=t.valueAccessor??(e?"value":void 0),n=a.reduce((e,t,r)=>{let s="function"==typeof l?l(t,r):"string"==typeof l&&l?t[l]:1,i=Math.max(0,lo(s)??0);return e+uo(i,o)},0);n>1500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`UnitPileChart would create about ${n} 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>=(U(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>=(U(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:[],s=U(e[0]),o=U(e[1]);(2>e.length||null==s||null==o)&&r.push({severity:"error",code:"PHYSICS_BAD_X_EXTENT",message:"xExtent must be a numeric [min, max] pair for CollisionSwarmChart.",fix:"Pass xExtent={[min, max]} or omit it so the chart infers the domain from data."})}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 s=t.groupAccessor;if(e.length>0&&s){let t=/* @__PURE__ */new Set;for(let r of e){let e=G(r,s,"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 s=e.filter(e=>e?.absorb).length;t.groupBy&&0===s&&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:[],s=Array.isArray(t.products)?t.products:[],o=Array.isArray(t.events)?t.events:[],i=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==U(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===s.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_PRODUCTS",message:"CrucibleChart has no declared product molds. Products are never discovered from collisions or source fields.",fix:'Declare products={[{ id: "accepted", label: "Accepted", outletId: "product" }]} when the treatment forms an output.'}),0===o.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_EVENTS",message:"CrucibleChart has no authored events, so its phases cannot transform, combine, split, or route the charge.",fix:"Supply an explicit events array; do not ask the chart or an AI layer to infer a treatment from the rows."}),Array.isArray(t.outlets)||r.push({severity:"warning",code:"CRUCIBLE_IMPLICIT_OUTLETS",message:"CrucibleChart is using generic default outlets rather than domain-specific destinations.",fix:"Provide reason-labelled outlets and reference their ids from products, complete-product, and eject effects."});let a=new Set(s.map(e=>e?.id).filter(e=>null!=e).map(String)),l=/* @__PURE__ */new Set(["product","retained","residue","failed","recovered",...i.map(e=>e?.id).filter(e=>null!=e).map(String)]),n=/* @__PURE__ */new Set,c=/* @__PURE__ */new Set;for(let e of o)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&&!a.has(t.productId+"")&&n.add(t.productId+""),"split"===e&&Array.isArray(t.products))for(let e of t.products)null!=e?.productId&&!a.has(e.productId+"")&&n.add(e.productId+"");null!=t.outletId&&!l.has(t.outletId+"")&&c.add(t.outletId+"")}n.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_PRODUCT",message:`CrucibleChart events reference undeclared product molds: ${[...n].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=U(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=U(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 s=Array.isArray(t.data)?t.data:[],o=U(t.mechanicalCount)??0,i=s.length>0?s.length:o;i>2500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(i)} 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 H(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 s=e.edges;if(Array.isArray(s)&&s.length>0){let e=s[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 o=e.nodes,i=Array.isArray(o)?o.length:0;return!0===e.showLabels&&i>=24&&t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${i} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),(Array.isArray(s)?s.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 q(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let r=Uo.test(t)?t+"-01":t;if(r===t&&10>t.length)return NaN;let s=Date.parse(r);return Number.isFinite(s)?s:NaN}function Y(e,t){if(!e||!t)return{data:e,failed:!1};let r=!1,s=!1,o=e.map(e=>{let o=e[t];if("string"!=typeof o)return e;let i=q(o);return r=!0,Number.isFinite(i)?{...e,[t]:i}:(s=!0,{...e,[t]:NaN})});return{data:r?o:e,failed:s}}function Q(e,t){let r=e.nestedDataAccessorProp?t[e.nestedDataAccessorProp]:void 0;return"string"==typeof r?r:e.defaultNestedDataAccessor}function Z(e,t,r){let s=e.dataProp??"data",o=t[s],i=r??(Array.isArray(o)?o:[]),a=Q(e,t);if(!a)return{dataProp:s,rows:i};let l=[],n=!1;for(let e of i){let t=e?.[a];if(Array.isArray(t)){n=!0;for(let e of t)e&&"object"==typeof e&&l.push(e)}}return{dataProp:s,rows:n?l:i}}function X(e,t,r){let s=/* @__PURE__ */new Set;for(let o of e.fields){let e=o.dataProp??"data",i=r??t[e];if(!Array.isArray(i))continue;if(0===i.length){s.add(e);continue}let a=Q(o,t);if(!a)continue;let l=i.map(e=>e?.[a]).filter(Array.isArray);l.length>0&&l.every(e=>0===e.length)&&s.add(`${e}.${a}`)}return[...s]}function K(){let e=globalThis;return e[oi]??(e[oi]={contracts:/* @__PURE__ */new Map}),e[oi]}function J(e){return K().contracts.get(e)??si[e]}function ee(e,t){if(0===e.length)return;let r=(e.length-1)*t,s=Math.floor(r),o=Math.ceil(r);if(s===o)return e[s];let i=r-s;return e[s]*(1-i)+e[o]*i}function te(e){let t=[];for(let[r,s]of Object.entries(ii))"string"!=typeof e[r]&&"function"!=typeof e[r]||t.push({role:s,accessor:r,..."size"===s?{requirements:["finite","non-negative"]}:{},..."x"===s||"y"===s?{domain:!0}:{}});return t.length>0?{fields:t}:void 0}function re(e,t,r){return"function"==typeof e?e(t,r):t[e]}function se(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(),s=Number(r);if(r&&Number.isFinite(s))return s;if("date-like"===t){let e=q(r);return Number.isFinite(e)?e:null}}return null}function oe(e){return"number"==typeof e&&!Number.isFinite(e)}function ie(e,t,r,s,o){let i={field:r,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let r=0;e.length>r;r++){let a;try{a=re(t,e[r],r)}catch{i.accessorErrorRows.push(r);continue}if(null==a||""===a){if(void 0!==o){i.numbers.push(o),i.finiteRows.push(r),0===o&&i.zeroRows.push(r),0>o&&i.negativeRows.push(r),Number.isInteger(o)||i.fractionalRows.push(r);continue}i.missingRows.push(r);continue}let l=se(a,s);null!=l?(i.numbers.push(l),i.finiteRows.push(r),0===l&&i.zeroRows.push(r),0>l&&i.negativeRows.push(r),Number.isInteger(l)||i.fractionalRows.push(r)):oe(a)?i.nonFiniteRows.push(r):i.nonNumericRows.push(r)}return i}function ae(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 le(e){let t=1/0,r=-1/0;for(let s of e)t>s&&(t=s),s>r&&(r=s);return[t,r]}function ne(e,t,r){let s=[],o=/* @__PURE__ */new Set;for(let i of e.fields){if(i.whenProps?.some(e=>null==t[e]))continue;let e=t[i.accessor],a="string"==typeof e||"function"==typeof e?e:i.defaultAccessor;if("string"!=typeof a&&"function"!=typeof a)continue;let{dataProp:l,rows:n}=Z(i,t,r);if(0===n.length)continue;let c="string"==typeof a?a:i.accessor+"()",d=`${l}:${i.role}:${c}`;if(o.has(d))continue;o.add(d);let u=i.temporalValues??("time"===i.role||"x"===i.role&&"time"===t.xScaleType?"date-like":void 0),f="x"===i.role&&"log"===t.xScaleType||"y"===i.role&&"log"===t.yScaleType,y=ae(i,t);s.push({contract:i,accessor:a,accessorLabel:c,dataProp:l,rows:n,requirements:y,logScale:f,observation:ie(n,a,c,u,i.missingValue)})}return s}function ce(e){return e.slice(0,5)}function de(e){return{domain:"data",...e}}function ue(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),s=ee(r,.25),o=ee(r,.75),i=ee(r,.5),a=o-s;if(a>0){let e=s-10*a,r=o+10*a;return t.filter(t=>e>t.value||t.value>r).map(e=>e.row)}let l=100*Math.max(1,Math.abs(i));return t.filter(e=>Math.abs(e.value-i)>l).map(e=>e.row)}function fe(e,t){let r=[],{observation:s,contract:o,accessorLabel:i,requirements:a}=e,l={field:i,role:o.role},n=[...s.nonFiniteRows,...s.nonNumericRows,...s.accessorErrorRows].sort((e,t)=>e-t);if(0===s.numbers.length)return r.push(de({severity:"error",code:"DEGENERATE_EXTENT",message:`${o.accessor}="${i}" produces no finite numeric values; the chart cannot resolve its ${o.role} input.`,fix:`Ensure ${i} contains finite numbers${"x"===o.role?" (or valid dates for a time scale)":""}.`,...l,...n.length>0?{rows:ce(n),count:n.length}:{}})),r;s.nonFiniteRows.length>0&&r.push(de({severity:"error",code:"NON_FINITE_VALUE",message:`${i} contains ${s.nonFiniteRows.length} NaN or infinite value${1===s.nonFiniteRows.length?"":"s"}; scale and layout math require finite numbers.`,fix:`Filter or replace NaN/Infinity in ${i} before rendering.`,...l,rows:ce(s.nonFiniteRows),count:s.nonFiniteRows.length})),!o.allowMissing&&s.missingRows.length>0&&r.push(de({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${i} is missing for ${s.missingRows.length} row${1===s.missingRows.length?"":"s"}; the ${o.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${i} values before rendering.`,...l,rows:ce(s.missingRows),count:s.missingRows.length}));let c=[...s.nonNumericRows,...s.accessorErrorRows].sort((e,t)=>e-t);if(c.length>0&&r.push(de({severity:"error",code:"NON_NUMERIC_VALUE",message:`${i} produces ${c.length} non-numeric value${1===c.length?"":"s"} for the ${o.role} role.`,fix:`Bind ${o.accessor} to a numeric field or return finite numbers from the accessor.`,...l,rows:ce(c),count:c.length})),o.domain&&s.numbers.length>=2){let[e,t]=le(s.numbers);e===t&&r.push(de({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${i} is constant at ${e}; its ${o.role} scale has a zero-span data domain.`,fix:`Provide varying ${o.role} values, set an explicit extent around ${e}, or use a single-value display.`,...l,rows:ce(s.finiteRows),count:s.finiteRows.length}))}if(a.includes("positive")){let t=s.numbers.map((e,t)=>({number:e,row:s.finiteRows[t]})).filter(({number:e})=>0>=e).map(({row:e})=>e);if(t.length>0){let s=e.logScale;r.push(de({severity:"error",code:s?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${i} contains ${t.length} non-positive value${1===t.length?"":"s"}, which ${s?"cannot be represented on a log scale":"violate the positive-value contract"}.`,fix:s?"Remove or transform values ≤ 0, or use a linear/symlog scale.":"Provide values greater than zero.",...l,rows:ce(t),count:t.length}))}}if(a.includes("non-negative")&&s.negativeRows.length>0&&r.push(de({severity:"error",code:"size"===o.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${i} contains ${s.negativeRows.length} negative ${o.role} value${1===s.negativeRows.length?"":"s"}; the chart maps this role to non-negative geometry.`,fix:"Use a non-negative measure, clamp intentionally, or encode sign with position/color instead.",...l,rows:ce(s.negativeRows),count:s.negativeRows.length})),a.includes("integer")){let e=[.../* @__PURE__ */new Set([...s.negativeRows,...s.zeroRows,...s.fractionalRows])].sort((e,t)=>e-t);e.length>0&&r.push(de({severity:"error",code:"INVALID_COUNT",message:`${i} 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.",...l,rows:ce(e),count:e.length}))}if(a.includes("unit-interval")){let e=s.numbers.map((e,t)=>({number:e,row:s.finiteRows[t]})).filter(({number:e})=>0>e||e>1).map(({row:e})=>e);e.length>0&&r.push(de({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${i} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${i} to [0, 1] before using it as ${o.role}.`,...l,rows:ce(e),count:e.length}))}if(t&&o.domain){let t=ue(e);t.length>0&&r.push(de({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${i} 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.",...l,rows:ce(t),count:t.length}))}return r}function ye(e,t,r){if(!e)return"__all__";try{return re(e,t,r)+""}catch{return"__accessor_error__"}}function pe(e,t,r){if(e.whenProp&&!0!==r[e.whenProp])return[];let s=t.find(t=>t.contract.role===e.role);if(!s||0===s.observation.numbers.length)return[];let o=e.groupAccessor?r[e.groupAccessor]:void 0,i="string"==typeof o||"function"==typeof o?o:e.defaultGroupAccessor,a=/* @__PURE__ */new Map;for(let e=0;s.rows.length>e;e++){let t;try{t=re(s.accessor,s.rows[e],e)}catch{continue}let r=se(t,void 0);if(null==r)continue;let o=ye(i,s.rows[e],e),l=a.get(o)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};l.sum+=r,l.magnitude+=Math.abs(r),l.positive||(l.positive=r>0),l.negative||(l.negative=0>r),l.rows.push(e),0>r&&l.negativeRows.push(e),a.set(o,l)}let l=[],n=[],c=[],d=[],u=[],f=[];for(let[t,r]of a)("positive-total"===e.kind&&0>=r.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,r.magnitude)*10>=Math.abs(r.sum))&&(l.push(t),d.push(...r.rows)),"normalized-total"===e.kind&&r.positive&&r.negative&&(n.push(t),u.push(...r.rows)),"normalized-total"===e.kind&&r.negative&&(c.push(t),f.push(...r.negativeRows));let y=[];return l.length>0&&y.push(de({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${l.length} normalization group${1===l.length?" has":"s have"} a zero total, so division would be undefined.`:"The part-to-whole total is not positive, so meaningful shares cannot be computed.",fix:"normalized-total"===e.kind?"Remove empty/zero-sum groups or disable normalization.":"Provide at least one positive value and ensure the total is greater than zero.",field:s.accessorLabel,role:e.role,rows:ce([...new Set(d)].sort((e,t)=>e-t)),count:l.length})),c.length>0&&y.push(de({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:s.accessorLabel,role:e.role,rows:ce([...new Set(f)].sort((e,t)=>e-t)),count:f.length})),n.length>0&&y.push(de({severity:"warning",code:"MIXED_SIGN_NORMALIZATION",message:`${n.length} normalization group${1===n.length?" mixes":"s mix"} positive and negative contributions; percentage shares may be unstable or misleading.`,fix:"Separate positive and negative contributions, use diverging stacks, or disable normalization.",field:s.accessorLabel,role:e.role,rows:ce([...new Set(u)].sort((e,t)=>e-t)),count:n.length})),y}function he(e,t,r,s={}){let o=s.contracts??J(e)??te(t);if(!o)return{component:e,ok:!0,rowCount:r?.length??(Array.isArray(t.data)?t.data.length:0),summary:{fieldsChecked:0,errors:0,warnings:0},contracts:[],diagnoses:[]};let i=ne(o,t,r),a=[],l=!1!==s.checkOutliers;for(let e of X(o,t,r))a.push(de({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 n=new Set(i.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(let e of n)a.push(de({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 i)a.push(...fe(e,l));for(let e of o.aggregates??[])a.push(...pe(e,i,t));let c=a.filter(e=>"error"===e.severity).length,d=a.length-c;return{component:e,ok:0===c,rowCount:i.reduce((e,t)=>Math.max(e,t.rows.length),r?.length??(Array.isArray(t.data)?t.data.length:0)),summary:{fieldsChecked:i.length,errors:c,warnings:d},contracts:i.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:a}}function me(e,t,r){let s=Oo[e];if(s){if("array"===s.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"===s.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 ge(e,t){for(let[r,s]of[["width",600],["height",400]]){let o=e[r];void 0!==o&&("number"!=typeof o||0>=o)&&t.push({severity:"error",code:"width"===r?"BAD_WIDTH":"BAD_HEIGHT",message:`${r}=${JSON.stringify(o)} — chart needs a positive number.`,fix:`Set ${r}={${s}}.`})}if(e.size&&Array.isArray(e.size)){let[r,s]=e.size;(null!=r&&0>=r||null!=s&&0>=s)&&t.push({severity:"error",code:"BAD_SIZE",message:`size=[${r}, ${s}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}function ke(e,t,r){let s=Oo[e];if(!s||"array"!==s.dataShape)return;let o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;let i=o[0];if(!i||"object"!=typeof i)return;let a=Object.keys(i);for(let e of s.dataAccessors){let s=t[e];"string"==typeof s&&(s in i||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${s}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}, or use a function: ${e}={d => d.myValue}.`}))}}function ve(e,t,r){Qs.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 xe(e,t,r){Zs.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 be(e,t,r){let s=Oo[e];if(!s||"array"!==s.dataShape)return;let o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;let i=o[0];if(!i||"object"!=typeof i)return;let a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" 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 Ce(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 Ae(e,t,r){if(!Ks.has(e)||t.gapStrategy)return;let s=t.data;if(!s||!Array.isArray(s)||0===s.length)return;let o=t.yAccessor||"y";"string"==typeof o&&s.some(e=>{let t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}function we(e,t,r){if(!Xs.has(e))return;let s=t.rExtent||t.yExtent||t.valueExtent;s&&Array.isArray(s)&&s.length>=1&&null!=s[0]&&0!==s[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${s[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, ${s[1]??"auto"}]}. For trend-focused charts, use LineChart instead.`})}function Se(e,t,r){if(!Js.has(e))return;let s=t.barPadding;"number"==typeof s&&10>s&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${s} 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 We(e,t,r){if("Heatmap"!==e)return;let s=t.data;if(!s||!Array.isArray(s)||0===s.length)return;let o=s[0];if(o&&"object"==typeof o)for(let e of["xAccessor","yAccessor"]){let s=t[e];if("string"!=typeof s)continue;let i=o[s];"string"==typeof i&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${s}" resolves to string values (e.g. "${i}"). 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 Le(e,t,r){let s=t.colorScheme;if(!s||!Array.isArray(s))return;let o="string"==typeof t.background?t.background:"#ffffff";if(!o.startsWith("#"))return;let i=[];for(let e of s){if("string"!=typeof e||!e.startsWith("#"))continue;let t=Vs(e,o);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${o}": ${i.join(", ")}. Data marks may be hard to see.`,fix:"Choose colors with at least 3:1 contrast against the chart background."})}function Be(e,t){let r=e.width??600,s=e.height??400,o=e.margin;if(!o||"object"!=typeof o)return;let i=(o.left||0)+(o.right||0),a=(o.top||0)+(o.bottom||0);i>=r&&t.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${i}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>=s&&t.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${a}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}function Re(e,t,r){let s=Oo[e]?.props,o=e=>!!s?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,i=o("title"),a=o("description"),l=o("summary");!i&&!a&&!l&&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 Pe(e,t,r){let s=t.colorScheme;"string"!=typeof s||Oo[e]?.props?.colorScheme?.enum||ai.has(s)||r.push({severity:"warning",code:"UNKNOWN_COLOR_SCHEME",message:`colorScheme "${s}" is not a recognized named scheme — the chart will fall back to the default palette.`,fix:`Use a known scheme name (${[...ai].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}function $e(e,t,r){let s=t.colorScheme;if(!s||!Array.isArray(s)||2>s.length)return;let o=s.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;let i=[];for(let e=0;o.length-1>e;e++){let t=Vs(o[e],o[e+1]);null!==t&&1.5>t&&i.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.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 Me(e,t,r){let s=[];for(let e of li)"function"==typeof t[e]&&s.push(e);s.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${s.length>1?"s":""} detected: ${s.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 Ie(e,t,r){let s=t.hoverRadius;"number"==typeof s&&s>0&&24>s&&!1!==t.enableHover&&(!1!==t.hoverAnnotation||t.tooltip||t.customHoverBehavior||t.customClickBehavior||t.onClick)&&r.push({severity:"warning",code:"TOUCH_TARGET_SMALL",message:`hoverRadius=${s}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 Ee(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 Ne(e,t,r){if(!0!==t.showParticles)return;let s=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},o="number"==typeof s.maxPerLine?s.maxPerLine:void 0,i="number"==typeof s.spawnRate?s.spawnRate:void 0;("number"==typeof o&&o>20||"number"==typeof i&&i>.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 _e(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function Te(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function Oe(e,t){let r=Te(e.visibleTokens);if(null!=r)return r;let s=Te(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=s)return s;let o=Te(t.tokenCount),i=Te(t.maxTokens);return null!=o&&null!=i?Math.min(o,i):o??s??i}function Fe(e,t,r){let s=[];_e(t.tokenEncoding)&&s.push({source:"tokenEncoding",encoding:t.tokenEncoding}),_e(t.encoding)&&s.push({source:"encoding",encoding:t.encoding});for(let{source:e,encoding:o}of s){let s=Oe(t,o);for(let t of P(o,{visibleTokens:s}))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 ze(e){let t={...e};return delete t.tokenEncoding,delete t.visibleTokens,_e(t.encoding)&&delete t.encoding,t}function De(e,t){let r=t.match(/^Unknown prop "([^"]+)"/);if(r)return`Remove \`${r[1]}\` or replace it with a documented ${e} prop.`;let s=t.match(/^"([^"]+)" is required for .+\.$/i)??t.match(/(?:Missing|required) prop "?([^". ]+)/i);return s?`Add the required \`${s[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 je(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 Ue(e,t){let r=[],s=()=>({ok:r.every(e=>"warning"===e.severity),diagnoses:r}),o=/^(XY|Ordinal|Network|Physics|Geo)CustomChart$/.test(e),i=o?[]:B(e,ze(t)).errors;if(o){"function"!=typeof t.layout&&i.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])&&i.push(`Provide an array for ${e}.`)}for(let s of i)"BigNumber"===e&&void 0!==t.accessibleTable&&s.startsWith('Unknown prop "accessibleTable"')||r.push({severity:"error",code:"VALIDATION",message:s,fix:o?s:De(e,s)});if("BigNumber"===e&&je(t,r),(o||Oo[e])&&(ge(t,r),Be(t,r),I(0,t,r)),!Oo[e])return s();me(e,t,r),ke(e,t,r),ve(e,t,r),xe(e,t,r),be(e,t,r),Ce(0,t,r),we(e,t,r),Ae(e,t,r);let a=he(e,t,void 0,{checkOutliers:!1}).diagnoses;for(let e of a)"EMPTY_DATA"===e.code&&r.some(e=>"EMPTY_DATA"===e.code||"EMPTY_EDGES"===e.code)||r.push(e);if(Se(e,t,r),We(e,t,r),Le(0,t,r),$e(0,t,r),Pe(e,t,r),Re(e,t,r),Me(0,t,r),Ie(0,t,r),Ee(0,t,r),Ne(0,t,r),Fe(0,t,r),E(0,t,r),N(0,t,r),_(0,t,r),T(e,t,r),O(e,t,r),r.some(e=>"NEGATIVE_VALUE"===e.code||"NEGATIVE_NORMALIZED_VALUE"===e.code)||F(e,t,r),z(e,t,r),D(e,t,r),j(e,t,r),V(e,t,r),"ProcessSankey"===e)for(let e of H(t))r.push(e);return s()}function Ge(e){return null==e?[]:Array.isArray(e)?e:[e]}function Ve(e){if("string"==typeof e)return e;try{return JSON.stringify(e,null,2)??e+""}catch{return e+""}}function He(e,t){return null==t?e.findings:e.findings.slice(0,Math.max(0,t))}function qe(...e){for(let t of e){let e=t?.trim();if(e)return e}return"Review this finding."}function Ye(e){return qe(e.remediation,e.explanation,e.evidence,e.condition)}function Qe(e){return qe(e.name,e.ruleId)}function Ze(e){return"error"===e?"error":"warning"===e?"warning":"info"===e?"info":"neutral"}function Xe(e,t){return e.domain?`${t} · ${e.domain}`:t}function Ke(e,t){return t[e]??t.info??ni.info}function Je(e){return qe(e.ruleId,e.name)}function et(e,t){return`${Je(e)}:${t}`}function tt(e){return"pitfall-"+(e+"").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function rt(e,t={},r=0,s={kind:"image",findings:[e]}){let o=t.sourcePrefix??"datapitfalls";return{id:et(e,r),level:Ze(e.severity),title:Qe(e),message:t.message?t.message(e,r,s):Ye(e),source:Xe(e,o),...void 0===t.dismissible?{}:{dismissible:t.dismissible}}}function st(e,t={}){return He(e,t.max).map((r,s)=>rt(r,t,s,e))}function ot(e,t={}){return{notifications:st(e,t),meta:{count:e.findings.length,kind:e.kind}}}function it(e,t={},r=0,s={kind:"image",findings:[e]}){let o={...ni,...t.palette};return{...t.anchorFor?.(e,r,s)??{},type:t.type??"label",title:Qe(e),label:Ye(e),wrap:t.wrap??240,color:Ke(e.severity,o),className:tt(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 at(e,t={}){return He(e,t.max).map((r,s)=>it(r,t,s,e))}function lt(e,t={}){return{annotations:at(e,t),meta:{count:e.findings.length,kind:e.kind}}}function nt(e,t,r){return{role:e,artifact:{kind:"text",content:t,...r?{filename:r}:{}}}}function ct(e,t,r,s){return{role:e,artifact:{kind:"code",content:t,language:r,...s?{filename:s}:{}}}}function dt(e,t){return t.length>0?{role:e,artifact:{kind:"image",images:t}}:null}function ut(e,t){let r=t.diagnoses.filter(e=>"error"===e.severity).length,s=t.diagnoses.filter(e=>"warning"===e.severity).length,o=[e+": Semiotic diagnoseConfig report","ok: "+t.ok,"errors: "+r,"warnings: "+s];if(0===t.diagnoses.length)return o.push("","No Semiotic config issues detected."),o.join("\n");o.push("");for(let e of t.diagnoses)o.push(`[${e.severity}] ${e.code}: ${e.message}`),e.fix&&o.push("Fix: "+e.fix);return o.join("\n")}function ft(e){return[e.component+": Semiotic reader grounding","",e.text,"\nStructured grounding JSON:\n```json",Ve(e),"```"].join("\n")}function yt(e,t,r={}){let s=[],o=!1!==r.includeConfig,i=!1!==r.includeJSX,a=!1!==r.includeGrounding,l=!1!==r.includeDiagnostics,n=!1!==r.includeAccessibility,c=r.filenamePrefix??e,d=js(e,t,r.config);r.context?.trim()&&s.push(nt("Analysis context",r.context.trim(),c+".context.md")),o&&s.push(ct("Semiotic chart config",Ve(d),"json",c+".semiotic-config.json")),i&&s.push(ct("Semiotic chart JSX",Us(d),"jsx",c+".semiotic.jsx"));let u,f,y,p=dt("Rendered chart image",Ge(r.rendered?.image));return p&&s.push(p),r.rendered?.svg?.trim()&&s.push(ct("Rendered chart SVG",r.rendered.svg.trim(),"svg",c+".rendered.svg")),null!=r.rendered?.evidence&&s.push(nt("Semiotic render evidence",[e+": Semiotic render evidence","\n```json",Ve(r.rendered.evidence),"```"].join("\n"),c+".render-evidence.md")),a&&(u=Gs(e,t,r.grounding),s.push(nt("Semiotic reader grounding",ft(u),c+".reader-grounding.md"))),l&&(f=Ue(e,t),s.push(nt("Semiotic config diagnostics",ut(e,f),c+".diagnose-config.md"))),n&&(y=io(e,t,r.accessibility),s.push(nt("Semiotic accessibility audit",ao(y),c+".accessibility.md"))),r.narrative?.trim()&&s.push(nt("Author narrative",r.narrative.trim(),c+".narrative.md")),r.additionalStages?.length&&s.push(...r.additionalStages),0===s.length&&s.push(ct("Semiotic chart config",Ve(d),"json",c+".semiotic-config.json")),{input:{kind:"chain",stages:s},config:d,...u?{grounding:u}:{},...f?{diagnosis:f}:{},...y?{accessibility:y}:{}}}function pt(e,t,r={}){return yt(e,t,r).input}function ht(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function mt(e,t,r){("number"!=typeof r||!Number.isInteger(r)||1>r||r>5)&&e.push(t+" must be an integer in [1, 5]")}function gt(e,t,r){void 0!==r&&"string"!=typeof r&&e.push(t+" must be a string")}function kt(e,t,r,s,o){void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||void 0!==s&&s>r||void 0!==o&&r>o)&&e.push(`${t} must be a finite number${void 0!==s&&void 0!==o?` in [${s}, ${o}]`:void 0!==s?" >= "+s:""}`)}function vt(e,t,r){void 0!==r&&"boolean"!=typeof r&&e.push(t+" must be a boolean")}function xt(e,t,r,s){for(let o of Object.keys(r))s.includes(o)||e.push(`${t}.${o} is not allowed`)}function bt(e,t){void 0!==t&&"0.1"!==t&&e.push("specVersion must be the string 0.1")}function Ct(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 At(e){let t=[];if(!ht(e))return{valid:!1,errors:["capability must be an object"]};bt(t,e.specVersion),("string"!=typeof e.component||0===e.component.length)&&t.push("component is required and must be a non-empty string"),gt(t,"family",e.family),gt(t,"importPath",e.importPath);let r=e.rubric;if(ht(r)?(xt(t,"rubric",r,["familiarity","accuracy","precision"]),mt(t,"rubric.familiarity",r.familiarity),mt(t,"rubric.accuracy",r.accuracy),mt(t,"rubric.precision",r.precision)):t.push("rubric is required and must be an object"),void 0!==e.intentScores)if(ht(e.intentScores))for(let[r,s]of Object.entries(e.intentScores))kt(t,"intentScores."+r,s,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(ht(e)){if("string"!=typeof e.key&&t.push(`variants[${r}].key is required`),"string"!=typeof e.label&&t.push(`variants[${r}].label is required`),gt(t,`variants[${r}].description`,e.description),void 0!==e.intentDeltas)if(ht(e.intentDeltas))for(let[s,o]of Object.entries(e.intentDeltas))kt(t,`variants[${r}].intentDeltas.${s}`,o);else t.push(`variants[${r}].intentDeltas must be an object`);if(void 0!==e.rubricDeltas)if(ht(e.rubricDeltas)){xt(t,`variants[${r}].rubricDeltas`,e.rubricDeltas,["familiarity","accuracy","precision"]);for(let s of["familiarity","accuracy","precision"])kt(t,`variants[${r}].rubricDeltas.${s}`,e.rubricDeltas[s])}else t.push(`variants[${r}].rubricDeltas must be an object`);for(let s of["caveats","tags"]){let o=e[s];void 0!==o&&(!Array.isArray(o)||o.some(e=>"string"!=typeof e))&&t.push(`variants[${r}].${s} must be an array of strings`)}void 0!==e.props&&!ht(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(ht(e.mobile)){let r=e.mobile;gt(t,"mobile.strategy",r.strategy),vt(t,"mobile.responsive",r.responsive),vt(t,"mobile.supportsResponsiveLayout",r.supportsResponsiveLayout);for(let e of["minViewportWidth","maxMarks","maxAnnotations","minimumHitTarget"])kt(t,"mobile."+e,r[e],0);void 0!==r.breakpoints&&(Array.isArray(r.breakpoints)?r.breakpoints.forEach((e,r)=>{kt(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&&(ht(r.interaction)?(gt(t,"mobile.interaction.primary",r.interaction.primary),gt(t,"mobile.interaction.hoverFallback",r.interaction.hoverFallback),kt(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&&(ht(r.labels)?(gt(t,"mobile.labels.strategy",r.labels.strategy),kt(t,"mobile.labels.minFontSize",r.labels.minFontSize,0)):t.push("mobile.labels must be an object")),void 0!==r.custom&&(ht(r.custom)?(vt(t,"mobile.custom.dataBearingSceneNodes",r.custom.dataBearingSceneNodes),vt(t,"mobile.custom.stableIds",r.custom.stableIds),gt(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 s=e[r];void 0!==s&&(!Array.isArray(s)||s.some(e=>"string"!=typeof e))&&t.push(r+" must be an array of strings")}return{valid:0===t.length,errors:t}}function wt(e){let t=[];if(!ht(e))return{valid:!1,errors:["audience profile must be an object"]};if(bt(t,e.specVersion),gt(t,"name",e.name),void 0!==e.familiarity)if(ht(e.familiarity))for(let[r,s]of Object.entries(e.familiarity))("number"!=typeof s||!Number.isInteger(s)||1>s||s>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(ht(e.targets))for(let[r,s]of Object.entries(e.targets))!ht(s)||"increase"!==s.direction&&"decrease"!==s.direction?t.push(`targets.${r}.direction must be "increase" or "decrease"`):(xt(t,"targets."+r,s,["direction","weight","reason"]),void 0!==s.weight&&("number"!=typeof s.weight||!Number.isInteger(s.weight)||1>s.weight||s.weight>3)&&t.push(`targets.${r}.weight must be an integer in [1, 3]`),gt(t,`targets.${r}.reason`,s.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&&!pi.has(e.receptionModality)&&t.push("receptionModality must be one of "+[...pi].join(", ")),{valid:0===t.length,errors:t}}function St(e){let t=[];if(!ht(e))return{valid:!1,errors:["annotation must be an object"]};let r=e.provenance;if(void 0!==r)if(ht(r)){for(let e of["author","authorKind","source","basis","dataVersion","stableId"])gt(t,"provenance."+e,r[e]);kt(t,"provenance.confidence",r.confidence,0,1),void 0!==r.createdAt&&("string"!=typeof r.createdAt||!Ct(r.createdAt))&&t.push("provenance.createdAt must be an ISO 8601 date-time string")}else t.push("provenance must be an object");let s=e.lifecycle;return void 0!==s&&(ht(s)?(void 0!==s.freshness&&!ui.has(s.freshness)&&t.push("lifecycle.freshness must be one of "+[...ui].join(", ")),void 0!==s.status&&!fi.has(s.status)&&t.push("lifecycle.status must be one of "+[...fi].join(", ")),void 0!==s.anchor&&!yi.has(s.anchor)&&t.push("lifecycle.anchor must be one of "+[...yi].join(", ")),gt(t,"lifecycle.supersedes",s.supersedes),void 0!==s.ttlHint&&"string"!=typeof s.ttlHint&&("number"!=typeof s.ttlHint||!Number.isFinite(s.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 Wt(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 Lt(e,t){return{status:"refused",diagnostics:t,lossReport:t.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:Wt(e)}}function Bt(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 Rt(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 Pt(e,t){let r=t.caveats?[...t.caveats]:[];if(e.caveats||0!==r.length)return t=>{let s=e.caveats?Array.from(e.caveats(t)):[];return[.../* @__PURE__ */new Set([...s,...r])]}}function $t(e,t){let r=At(e);if(!r.valid)return Lt(e,r.errors.map(e=>({code:"INVALID_PORTABLE_CAPABILITY",severity:"error",message:e})));let s=e;if(!t)return Lt(e,[{code:"HOST_CAPABILITY_NOT_FOUND",severity:"error",path:"/component",message:`No host capability is registered for "${s.component}". Resolve or register the renderer's executable capability before binding portable metadata.`}]);if(s.component!==t.component)return Lt(e,[{code:"CAPABILITY_COMPONENT_MISMATCH",severity:"error",path:"/component",message:`Portable component "${s.component}" cannot bind to host component "${t.component}".`}]);let o=Pt(t,s);return{status:"success",capability:{...t,rubric:{...s.rubric},intentScores:s.intentScores?{...s.intentScores}:{...t.intentScores},variants:s.variants?.map(Bt),...o?{caveats:o}:{caveats:void 0},...void 0!==s.mobile?{mobile:Rt(s.mobile)}:{},portableDescriptor:s},diagnostics:[],lossReport:[],provenance:Wt(e)}}function Mt(e){return{field:e,type:"quantitative"}}function It(e){return{field:e,type:"nominal"}}function Et(e){return"time"===e.xScaleType?"temporal":"quantitative"}function Nt(e,t){return"string"==typeof t&&(e.axis={title:t}),e}function _t(e,t){let r=[];for(let s of mi[e]||[])("string"!=typeof t[s]||0===t[s].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+s,message:`${e} requires a string ${s} for Vega-Lite export.`});for(let s of gi[e]||[])void 0!==t[s]&&("string"!=typeof t[s]||0===t[s].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+s,message:`${e} can export ${s} only as a non-empty string field name.`});return r}function Tt(e,t={}){let r=[],s={adapter:"semiotic/vega-lite",direction:"export",sourceFormat:"semiotic-chart-config",targetFormat:"vega-lite",..."string"==typeof e.version?{specVersion:e.version}:{}},o=e.props||{},i=_t(e.component,o);if(i.length>0)return{status:"refused",diagnostics:i,lossReport:i.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:s};let a,l={},n=e.component;switch(n){case"BarChart":case"StackedBarChart":case"GroupedBarChart":{a="bar";let e="horizontal"===o.orientation,t=Nt(It(o.categoryAccessor),o.categoryLabel),s=Nt(Mt(o.valueAccessor),o.valueLabel);e?(l.y=t,l.x=s):(l.x=t,l.y=s),"StackedBarChart"===n&&o.stackBy?l.color=It(o.stackBy):"GroupedBarChart"===n&&o.groupBy&&(l.color=It(o.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":a=o.curve||o.showPoints?{type:"line"}:"line","object"==typeof a&&(o.curve&&hi[o.curve]&&(a.interpolate=hi[o.curve]),o.showPoints&&(a.point=!0)),l.x=Nt({field:o.xAccessor,type:Et(o)},o.xLabel),l.y=Nt(Mt(o.yAccessor),o.yLabel),o.lineBy?l.color=It(o.lineBy):o.colorBy&&(l.color=It(o.colorBy));break;case"AreaChart":case"StackedAreaChart":a=o.curve?{type:"area"}:"area","object"==typeof a&&o.curve&&hi[o.curve]&&(a.interpolate=hi[o.curve]),"object"==typeof a&&void 0!==o.areaOpacity&&(a.opacity=o.areaOpacity),l.x=Nt({field:o.xAccessor,type:Et(o)},o.xLabel),l.y=Nt(Mt(o.yAccessor),o.yLabel),"StackedAreaChart"===n&&o.areaBy&&(l.color=It(o.areaBy));break;case"Scatterplot":case"BubbleChart":a="point",l.x=Nt(Mt(o.xAccessor),o.xLabel),l.y=Nt(Mt(o.yAccessor),o.yLabel),o.colorBy&&(l.color=It(o.colorBy)),"BubbleChart"===n&&o.sizeBy&&(l.size=Mt(o.sizeBy),Array.isArray(o.sizeRange)&&(l.size.scale={range:o.sizeRange}));break;case"Heatmap":a="rect",l.x=Nt(It(o.xAccessor),o.xLabel),l.y=Nt(It(o.yAccessor),o.yLabel),o.valueAccessor&&(l.color=Mt(o.valueAccessor));break;case"PieChart":case"DonutChart":a="DonutChart"===n?{type:"arc",innerRadius:o.innerRadius??60}:"arc",o.valueAccessor&&(l.theta=Mt(o.valueAccessor)),o.categoryAccessor&&(l.color=It(o.categoryAccessor));break;case"DotPlot":{a="tick";let e="horizontal"===o.orientation,t=Nt(It(o.categoryAccessor),o.categoryLabel),r=Nt(Mt(o.valueAccessor),o.valueLabel);e?(l.y=t,l.x=r):(l.x=t,l.y=r);break}case"Histogram":a="bar",o.valueAccessor&&(l.x=Nt(Mt(o.valueAccessor),o.valueLabel),l.x.bin=!o.bins||{maxbins:o.bins},l.y={aggregate:"count",type:"quantitative"}),o.categoryAccessor&&(l.color=It(o.categoryAccessor));break;default:{let e=`Component "${n}" 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:s}}}o.colorScheme&&l.color&&(l.color.scale={...l.color.scale||{},scheme:o.colorScheme});let c={mark:a};return Array.isArray(o.data)&&(c.data={values:o.data}),Object.keys(l).length>0&&(c.encoding=l),"string"==typeof o.title&&(c.title=o.title),"number"==typeof o.width&&(c.width=o.width),"number"==typeof o.height&&(c.height=o.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:s}:{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:s}}function Ot(e,t){return Tt(e,t).spec}function Ft(e,t){let r={...zt(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 zt(e){return e.usermeta?.idid}function Dt(e,t){let r={...zt(e),specVersion:"0.1",annotations:[...t]},s=t.map(Gt).filter(e=>null!==e).map(e=>({...e,usermeta:{idid:{role:"annotation-layer"}}}));if(0===s.length)return{...e,usermeta:{...e.usermeta,idid:r}};let o=Array.isArray(e.layer)?e.layer:[Ut(e)],{mark:i,encoding:a,data:l,transform:n,usermeta:c,...d}=e;return{...d,usermeta:{...e.usermeta,idid:r},layer:[...o,...s]}}function jt(e){let t=zt(e)?.annotations;return Array.isArray(t)?t:[]}function Ut(e){let{mark:t,encoding:r,data:s,transform:o}=e,i={};return t&&(i.mark=t),r&&(i.encoding=r),s&&(i.data=s),o&&(i.transform=o),i}function Gt(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 Vt(e,t){let{groupBy:r,value:s,agg:o="sum"}=t,i=/* @__PURE__ */new Map,a="min"===o?1/0:"max"===o?-1/0:0;for(let t of e){let e=t[r]+"",l=i.get(e);l||(l={total:a,count:0},i.set(e,l));let n=Number(t[s]);switch(l.count++,o){case"count":break;case"min":l.total>n&&(l.total=n);break;case"max":n>l.total&&(l.total=n);break;default:l.total+=n}}let l=[];for(let[e,t]of i){let s="count"===o?t.count:"mean"===o?t.total/t.count:t.total;l.push({[r]:e,value:s})}return l}function Ht(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 qt(e){if(e)return"string"==typeof e?e:e.text}function Yt(e){return"nominal"===e||"ordinal"===e}function Qt(e){return"quantitative"===e||"temporal"===e}function Zt(e){return e.usermeta?.idid}function Xt(e){return"annotation-layer"===e.usermeta?.idid?.role}function Kt(e){if(!Zt(e)||!Array.isArray(e.layer))return e;let t=e.layer.filter(e=>!Xt(e));if(1!==t.length)return e;let{layer:r,...s}=e,{usermeta:o,...i}=t[0];return{...s,...i}}function Jt(e){let t=e,r=Kt(e),s=r,o=[];if(Array.isArray(t.layer)&&r===e&&o.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===s.mark)o.push({code:"MISSING_MARK",severity:"error",path:"/mark",message:"A Vega-Lite spec needs a supported single-view mark."});else{let{type:e}=Ht(s.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,s=1/0,o=-1/0,i=-1/0;for(let e=0;t.length>e+1;e+=2){let a=parseFloat(t[e]),l=parseFloat(t[e+1]);Number.isFinite(a)&&(r=Math.min(r,a),o=Math.max(o,a)),Number.isFinite(l)&&(s=Math.min(s,l),i=Math.max(i,l))}return Number.isFinite(r)&&Number.isFinite(s)?{x:r,y:s,w:o-r,h:i-s}:null}function r(e){let t=e.fontSize??12,r=Math.max(1,(e.text+"").length*t*.6),s=e.textAnchor??"start";return{x:"middle"===s?e.x-r/2:"end"===s?e.x-r:e.x,y:e.y-t,w:r,h:1.2*t}}function s(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 o(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 i(e,t){let[r=0,s=0]=t.translate??[],[o=1,i=1]=t.scale??[];return{tx:e.tx+r*e.sx,ty:e.ty+s*e.sy,sx:e.sx*o,sy:e.sy*i}}function a(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=a(e);if(null!=t)return t}}function l(e){return null==e?null:Array.isArray(e)?0===e.length?null:1===e.length?e[0]:{...e[0],_rows:e}:e}function n(t,r,s){let o=e(t.style);switch(t.kind){case"rect":return yo("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}:{},...o});case"ellipse":return yo("ellipse",{key:r,cx:t.cx,cy:t.cy,rx:t.rx,ry:t.ry,...o});case"path":return yo("path",{key:r,d:t.d,...o});case"text":return yo("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})`}:{},...o},t.text);case"image":return yo("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}:{},...o});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]})`),yo("g",{key:r,...e.length?{transform:e.join(" ")}:{},...o},t.children.map((e,t)=>n(e,`${r}-${t}`,s)))}case"composite":case"mask":return c(t,r,s)}}function c(e,t,r){let s="gf-comp-"+r.compositeId++,o=s+"-source",i=s+"-destination";if("mask"===e.kind){let a=s+"-mask";return yo(po,{key:t},yo("defs",null,yo("g",{id:o},e.mask.map((e,t)=>n(e,`${a}-m-${t}`,r))),yo("g",{id:i},e.content.map((e,t)=>n(e,`${a}-c-${t}`,r))),yo("mask",{id:a,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse"},yo("use",{href:"#"+o}))),yo("use",{href:"#"+i,mask:`url(#${a})`}))}let{x:a,y:l,w:c,h:d}=e.bbox,u=`translate(${a} ${l})`,f=e.blendMode,y="atop"===e.operator||"in"===e.operator,p=s+"-desat",h=s+"-cov",m=e.source.map((e,t)=>n(e,`${s}-s-${t}`,r)),g=e.dest.map((e,t)=>n(e,`${s}-d-${t}`,r)),k=[];return f&&k.push(yo("filter",{key:"desat",id:p},yo("feColorMatrix",{type:"saturate",values:"0"}))),y&&k.push(yo("mask",{key:"cov",id:h,maskUnits:"userSpaceOnUse",x:a,y:l,width:c,height:d,style:{maskType:"alpha"}},yo("g",{transform:u},e.source.map((e,t)=>n(e,`${s}-m-${t}`,r))))),yo(po,{key:t},k.length?yo("defs",{key:"defs"},k):null,yo("g",{key:"g",...y?{mask:`url(#${h})`}:{}},yo("g",{transform:u,style:{isolation:"isolate"}},yo("g",f?{filter:`url(#${p})`}:null,m),yo("g",f?{style:{mixBlendMode:f}}:null,g))))}function d(e,t,r,n){for(let c of e){if("group"===c.kind){d(c.children,i(t,c.transform),r,n);continue}let e=c.role??"node",u=l(a(c));if("node"!==e||!u||"text"===c.kind)continue;let f=s(c);if(!f)continue;let y=o(f,t);y.w>0&&y.h>0&&(r.push({type:"rect",x:y.x,y:y.y,w:y.w,h:y.h,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:u,id:c.id??"gofish-node-"+n.n}),n.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=l(a(r));e&&t.push(e)}}function f(e){return t=>{let r=t.config?.displayList??e,s=[];d(r.items,mo,s,{n:0});let o={compositeId:0};return{sceneNodes:s,overlays:yo("g",{className:"semiotic-gofish-displaylist","data-gofish-ir":r.ir},r.items.map((e,t)=>n(e,"gf-"+t,o)))}}}function y(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 s=t.displayList??e,o=Array.isArray(s?.items)?s.items:[];0===o.length&&r.push("Display list carried no items; the chart will render empty.");let i=[];u(o,i);let a=s?.viewport??{w:0,h:0};return{family:"network",networkLayout:f(s),layoutConfig:{displayList:s},nodes:i,edges:[],width:a.w,height:a.h,irVersion:s?.irVersion??0,warnings:r.length?r:void 0}}function p(e,t){let r=e.length,s=t.length,o=Array(s+1);for(let e=0;s>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;s>=a;a++){let s=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=s}}return o[s]}function h(e,t,r=3){let s,o=r+1;for(let r of t){let t=p(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,s=r)}return o>r?void 0:s}function m(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function g(e,t){if(0===t.length)return null;let r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||(h(e,t,3)??null)}function k(e){return` Or use a function: ${e}={d => d.myValue}.`}function v({componentName:e,data:t,accessors:r,requiredProps:s}){if(s)for(let[t,r]of Object.entries(s))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 s=m(t).find(e=>e&&"object"==typeof e);if(s){let t=Object.keys(s);for(let[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in s)){let r=g(i,t),s=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${i}" not found in data. Available fields: ${t.join(", ")}.${s}`+k(o)}}}return null}function x({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 b({componentName:e,nodes:t,edges:r,nodesRequired:s=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(s&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){let r=m(t).find(e=>e&&"object"==typeof e);if(r){let t=Object.keys(r);for(let[s,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){let r=g(o,t),i=r?` Try ${s}="${r}".`:"";return`${e}: ${s} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`+k(s)}}}return null}function C(e){let[t,r]=Array.isArray(e)?e:[e,void 0],s=Eo[t],o=Array.isArray(s)?[...s]:s;return void 0===r?{type:o}:{type:o,enum:[...No[r]]}}function A(){return Object.fromEntries(To.map(([e,t,r,s,o],i)=>[fo[i],{required:[...e],dataShape:t,dataAccessors:[...r],props:Object.fromEntries(Object.entries(Object.assign({},...s.map(e=>_o[e]),o)).map(([e,t])=>[e,C(t)]))}]))}function w(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function S(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"UnitPileChart"===e)}function W(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 s=e;("number"!=typeof s.value||!Number.isFinite(s.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 s.color||0===s.color.length)&&t.push(`"thresholds[${r}].color" is required for GaugeChart and must be a non-empty string.`),void 0!==s.label&&"string"!=typeof s.label&&t.push(`"thresholds[${r}].label" for GaugeChart should be a string.`);let o=Object.keys(s).filter(e=>"value"!==e&&"color"!==e&&"label"!==e);o.length>0&&t.push(`"thresholds[${r}]" has unsupported GaugeChart key(s): ${o.join(", ")}. Use { value, color, label? }; { at, level } belongs to BigNumber.`)}),t}function L(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 s=[],o=r,i=/* @__PURE__ */new Set(["align",...Object.keys(zo)]);for(let e of Object.keys(o))i.has(e)||s.push(`Unknown "frameProps.legendLayout" key "${e}". Valid keys: ${[...i].join(", ")}.`);void 0!==o.align&&"string"!=typeof o.align?s.push(`"frameProps.legendLayout.align" should be string, got ${Array.isArray(o.align)?"array":typeof o.align}.`):"string"==typeof o.align&&!Fo.has(o.align)&&s.push(`"frameProps.legendLayout.align" value "${o.align}" is not valid. Expected one of: ${[...Fo].join(", ")}.`);for(let[e,t]of Object.entries(zo)){let r=o[e];void 0!==r&&("number"==typeof r&&Number.isFinite(r)?t.minimum>r&&s.push(`"frameProps.legendLayout.${e}" should be ${t.label} (minimum ${t.minimum}), got ${r}.`):s.push(`"frameProps.legendLayout.${e}" should be ${t.label}, got ${Array.isArray(r)?"array":typeof r}.`))}return s}function B(e,t){let r=[];(null==t||"object"!=typeof t)&&(t={});let s=Oo[e];if(!s)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Oo).join(", ")}`]};for(let o of s.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);"array"===s.dataShape&&Object.prototype.hasOwnProperty.call(s.props,"data")&&!s.required.includes("data")&&!S(e,t)&&null==t.data&&r.push(`"data" is required for ${e}.`);for(let[e,o]of Object.entries(t)){if(null==o)continue;let t=s.props[e];if(t){if(!w(o,t.type)){let s=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${s}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}let o=Object.keys(s.props),i=new Set(o);for(let s of Object.keys(t))if(void 0!==t[s]&&!i.has(s)){let t=h(s,o),i=t?`Unknown prop "${s}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${s}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(i)}if("array"===s.dataShape){let o=t.data,i={};for(let e of s.dataAccessors){let r=t[e];"string"==typeof r&&(i[e]=r)}let a=v({componentName:e,data:o,accessors:Object.keys(i).length>0?i:void 0});a&&r.push(a)}else if("object"===s.dataShape){let s=x({componentName:e,data:t.data});s&&r.push(s)}else if("network"===s.dataShape){let o=t.nodeIdAccessor??t.nodeIDAccessor??"id",i="string"==typeof o?{nodeIdAccessor:o}:void 0,a=b({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:s.required.includes("nodes"),edgesRequired:s.required.includes("edges"),accessors:i});a&&r.push(a)}return"GaugeChart"===e&&r.push(...W(t)),"ScatterplotMatrix"===e&&null!=t.frameProps&&r.push('"frameProps" is not supported for ScatterplotMatrix; configure its matrix props directly.'),r.push(...L(t)),{valid:0===r.length,errors:r}}function R(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function P(e,t={}){let r=[],s=e.tokenSemantics,o=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==o||R(e.denominator)>100?80:100);return s||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),o||r.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),("icon"===e.tokenType||"glyph"===e.tokenType)&&("icon-only"===e.labelPolicy||"token-only"===e.labelPolicy)&&r.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&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"===s&&("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"===s&&o&&"unitized"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===s&&o&&"fixed-denominator"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),("possible-outcome"===s||"posterior-sample"===s||"hypothetical-case"===s)&&o&&"quantile"!==o&&"sample"!==o&&"posterior-sample"!==o&&"random-sample"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===s&&"unitized"===o&&null==e.unitValue&&null==e.unit&&r.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"===s&&"unitized"===o&&!e.unitMeaning&&r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function $(e,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 M(e){let t=e.provenance,r=e.id??e.stableId??t?.stableId;return null==r||""===r?void 0:r+""}function I(e,t,r){let s=Array.isArray(t.annotations)?t.annotations:null;if(s)for(let e of s)!e||"object"!=typeof e||"widget"!==Hs(e)||null==e.content||M(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 E(e,t,r){let s=Array.isArray(t.annotations)?t.annotations:null;if(s)for(let e of s){if(!e||"object"!=typeof e)continue;let t=Hs(e);if(!qs(e)||"widget"===t)continue;let s=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,i=Ys(e);!i&&s>120?r.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${o}" sits ~${Math.round(s)}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).'}):i&&s>250&&r.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${o}" uses a very long connector (~${Math.round(s)}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 N(e,t,r){let s=Array.isArray(t.annotations)?t.annotations:null;if(!s)return;let o=s.filter(qs).length;if(0===o)return;let i="number"==typeof t.width?t.width:600,a="number"==typeof t.height?t.height:400,l=$(i,a);!Number.isFinite(l)||l>=o||r.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${o} note annotations on a ${i}×${a} chart exceed the ~${l} 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 _(e,t,r){for(let e of jo){let s=t[e];if(!Array.isArray(s)||2>s.length)continue;let[o,i]=s;"number"!=typeof o||"number"!=typeof i||o>i&&r.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${o}, ${i}] 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}={[${i}, ${o}]}). If the inversion is deliberate (e.g. rank #1 at top), say so in the title or an annotation so readers aren't misled.`})}}function T(e,t,r){if("MultiAxisLineChart"!==e)return;let s=t.series;if(!Array.isArray(s)||2!==s.length)return;let o=s.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);o.length>0&&r.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${o.length} unlabeled series. Two y-scales invite false equivalence between the lines; without per-series labels a reader can't tell which scale is whose.`,fix:'Give every series a label: series={[{ yAccessor: "a", label: "Revenue ($)" }, { yAccessor: "b", label: "Users" }]} — and consider whether two separate charts read more honestly.'})}function O(e,t,r){if(!Ks.has(e))return;let s=t.xExtent;if(!Array.isArray(s)||2>s.length)return;let[o,i]=s;if("number"!=typeof o||"number"!=typeof i||o>=i)return;let a=t.data;if(!a||!Array.isArray(a)||4>a.length)return;let l=t.xAccessor??"x";if("string"!=typeof l)return;let n=1/0,c=-1/0;for(let e of a){let t=e?.[l];"number"!=typeof t||!Number.isFinite(t)||(n>t&&(n=t),t>c&&(c=t))}if(!Number.isFinite(n)||!Number.isFinite(c)||n>=c)return;let d=c-n,u=Math.max(0,Math.min(i,c)-Math.max(o,n))/d;.7>u&&r.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${o}, ${i}] shows only ~${Math.round(100*u)}% of the data's x range [${n}, ${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 F(e,t,r){let s=ro[e],o=so[e];if(!s&&!o||o&&!t.normalize)return;let i=s??o,a=t[i],l="string"==typeof a?a:"yAccessor"===i?"y":"value",n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;let c=n.filter(e=>{let t=e?.[l];return"number"==typeof t&&0>t});c.length>0&&r.push({severity:s?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${c.length} negative value(s) in "${l}" — a part-to-whole encoding cannot represent negative parts${s?"; slice angles/areas for negatives are meaningless":"; normalized shares distort when parts are negative"}.`,fix:s?"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 z(e,t,r){eo.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 D(e,t,r){if("LineChart"!==e&&"AreaChart"!==e||"sparkline"===t.mode||t.responsiveWidth||t.responsiveHeight)return;let s="number"==typeof t.width?t.width:600,o="number"==typeof t.height?t.height:400;if(0>=s||0>=o)return;let i=s/o;if(i>8||.25>i){let e=i>8?"flattens":"exaggerates";r.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${s}×${o} (${i.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:i>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 j(e,t,r){if(!to.has(e))return;let s=t.data;if(!s||!Array.isArray(s)||0===s.length)return;let o=t.categoryAccessor,i="string"==typeof o?o:"category",a=/* @__PURE__ */new Set;for(let e of s){let t=e?.[i];null!=t&&a.add(t)}a.size>8&&r.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:a.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 ${a.size} categories, or group the long tail into an "Other" slice before charting.`})}function U(e){let t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function G(e,t,r){return"function"==typeof t?t(e):e?.["string"==typeof t?t:r]}function V(e,t,r){if(oo.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 s=U(t.branchProbability);null!=t.branchProbability&&(null==s||0>s||s>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 o=U(t.mechanicalCount);null!=t.mechanicalCount&&(null==o||0>=o)&&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,s=e&&"object"==typeof e?U(e.size):null;null!=s&&0>=s&&r.push({severity:"error",code:"PHYSICS_BAD_WINDOW_SIZE",message:`windows.size=${s} 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 o=Array.isArray(t.data)?t.data:[];if(o.length>0){let e=t.timeAccessor||"time",s=t.arrivalAccessor||"arrivalTime";o.some(t=>{let r=U(G(t,e,"time")),o=U(G(t,s,"arrivalTime"));return null!=r&&null!=o&&r!==o})||r.push({severity:"warning",code:"PHYSICS_EVENTDROP_NO_ARRIVAL_SPREAD",message:"EventDropChart data does not show distinct arrival times, so the physics replay collapses to event order.",fix:"Provide an arrivalAccessor field with event-arrival times when demonstrating lateness, watermarks, or out-of-order streams."})}}if("UnitPileChart"===e){let e="mechanical"===(t.simulationMode??t.mode),s=U(t.mechanicalCount);null!=t.mechanicalCount&&(null==s||0>=s)&&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 o=lo(t.unitValue??1);if(null==o||0>=o)return void r.push({severity:"error",code:"PHYSICS_BAD_UNIT_VALUE",message:`unitValue=${t.unitValue} cannot unitize values into physical bodies.`,fix:"Set unitValue to a positive number represented by one body."});let i=e?co({count:s??void 0,categories:Array.isArray(t.mechanicalCategories)?t.mechanicalCategories:void 0,seed:lo(t.seed)??1,unitValue:o}):Array.isArray(t.data)?t.data:[],{rows:a}=no(i,"pile"),l=t.valueAccessor??(e?"value":void 0),n=a.reduce((e,t,r)=>{let s="function"==typeof l?l(t,r):"string"==typeof l&&l?t[l]:1,i=Math.max(0,lo(s)??0);return e+uo(i,o)},0);n>1500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`UnitPileChart would create about ${n} 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>=(U(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>=(U(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:[],s=U(e[0]),o=U(e[1]);(2>e.length||null==s||null==o)&&r.push({severity:"error",code:"PHYSICS_BAD_X_EXTENT",message:"xExtent must be a numeric [min, max] pair for CollisionSwarmChart.",fix:"Pass xExtent={[min, max]} or omit it so the chart infers the domain from data."})}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 s=t.groupAccessor;if(e.length>0&&s){let t=/* @__PURE__ */new Set;for(let r of e){let e=G(r,s,"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 s=e.filter(e=>e?.absorb).length;t.groupBy&&0===s&&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:[],s=Array.isArray(t.products)?t.products:[],o=Array.isArray(t.events)?t.events:[],i=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==U(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===s.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_PRODUCTS",message:"CrucibleChart has no declared product molds. Products are never discovered from collisions or source fields.",fix:'Declare products={[{ id: "accepted", label: "Accepted", outletId: "product" }]} when the treatment forms an output.'}),0===o.length&&r.push({severity:"warning",code:"CRUCIBLE_NO_EVENTS",message:"CrucibleChart has no authored events, so its phases cannot transform, combine, split, or route the charge.",fix:"Supply an explicit events array; do not ask the chart or an AI layer to infer a treatment from the rows."}),Array.isArray(t.outlets)||r.push({severity:"warning",code:"CRUCIBLE_IMPLICIT_OUTLETS",message:"CrucibleChart is using generic default outlets rather than domain-specific destinations.",fix:"Provide reason-labelled outlets and reference their ids from products, complete-product, and eject effects."});let a=new Set(s.map(e=>e?.id).filter(e=>null!=e).map(String)),l=/* @__PURE__ */new Set(["product","retained","residue","failed","recovered",...i.map(e=>e?.id).filter(e=>null!=e).map(String)]),n=/* @__PURE__ */new Set,c=/* @__PURE__ */new Set;for(let e of o)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&&!a.has(t.productId+"")&&n.add(t.productId+""),"split"===e&&Array.isArray(t.products))for(let e of t.products)null!=e?.productId&&!a.has(e.productId+"")&&n.add(e.productId+"");null!=t.outletId&&!l.has(t.outletId+"")&&c.add(t.outletId+"")}n.size>0&&r.push({severity:"error",code:"CRUCIBLE_UNKNOWN_PRODUCT",message:`CrucibleChart events reference undeclared product molds: ${[...n].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=U(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=U(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 s=Array.isArray(t.data)?t.data:[],o=U(t.mechanicalCount)??0,i=s.length>0?s.length:o;i>2500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(i)} 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 H(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 s=e.edges;if(Array.isArray(s)&&s.length>0){let e=s[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 o=e.nodes,i=Array.isArray(o)?o.length:0;return!0===e.showLabels&&i>=24&&t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${i} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),(Array.isArray(s)?s.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 q(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let r=Uo.test(t)?t+"-01":t;if(r===t&&10>t.length)return NaN;let s=Date.parse(r);return Number.isFinite(s)?s:NaN}function Y(e,t){if(!e||!t)return{data:e,failed:!1};let r=!1,s=!1,o=e.map(e=>{let o=e[t];if("string"!=typeof o)return e;let i=q(o);return r=!0,Number.isFinite(i)?{...e,[t]:i}:(s=!0,{...e,[t]:NaN})});return{data:r?o:e,failed:s}}function Q(e,t){let r=e.nestedDataAccessorProp?t[e.nestedDataAccessorProp]:void 0;return"string"==typeof r?r:e.defaultNestedDataAccessor}function Z(e,t,r){let s=e.dataProp??"data",o=t[s],i=r??(Array.isArray(o)?o:[]),a=Q(e,t);if(!a)return{dataProp:s,rows:i};let l=[],n=!1;for(let e of i){let t=e?.[a];if(Array.isArray(t)){n=!0;for(let e of t)e&&"object"==typeof e&&l.push(e)}}return{dataProp:s,rows:n?l:i}}function X(e,t,r){let s=/* @__PURE__ */new Set;for(let o of e.fields){let e=o.dataProp??"data",i=r??t[e];if(!Array.isArray(i))continue;if(0===i.length){s.add(e);continue}let a=Q(o,t);if(!a)continue;let l=i.map(e=>e?.[a]).filter(Array.isArray);l.length>0&&l.every(e=>0===e.length)&&s.add(`${e}.${a}`)}return[...s]}function K(){let e=globalThis;return e[oi]??(e[oi]={contracts:/* @__PURE__ */new Map}),e[oi]}function J(e){return K().contracts.get(e)??si[e]}function ee(e,t){if(0===e.length)return;let r=(e.length-1)*t,s=Math.floor(r),o=Math.ceil(r);if(s===o)return e[s];let i=r-s;return e[s]*(1-i)+e[o]*i}function te(e){let t=[];for(let[r,s]of Object.entries(ii))"string"!=typeof e[r]&&"function"!=typeof e[r]||t.push({role:s,accessor:r,..."size"===s?{requirements:["finite","non-negative"]}:{},..."x"===s||"y"===s?{domain:!0}:{}});return t.length>0?{fields:t}:void 0}function re(e,t,r){return"function"==typeof e?e(t,r):t[e]}function se(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(),s=Number(r);if(r&&Number.isFinite(s))return s;if("date-like"===t){let e=q(r);return Number.isFinite(e)?e:null}}return null}function oe(e){return"number"==typeof e&&!Number.isFinite(e)}function ie(e,t,r,s,o){let i={field:r,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let r=0;e.length>r;r++){let a;try{a=re(t,e[r],r)}catch{i.accessorErrorRows.push(r);continue}if(null==a||""===a){if(void 0!==o){i.numbers.push(o),i.finiteRows.push(r),0===o&&i.zeroRows.push(r),0>o&&i.negativeRows.push(r),Number.isInteger(o)||i.fractionalRows.push(r);continue}i.missingRows.push(r);continue}let l=se(a,s);null!=l?(i.numbers.push(l),i.finiteRows.push(r),0===l&&i.zeroRows.push(r),0>l&&i.negativeRows.push(r),Number.isInteger(l)||i.fractionalRows.push(r)):oe(a)?i.nonFiniteRows.push(r):i.nonNumericRows.push(r)}return i}function ae(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 le(e){let t=1/0,r=-1/0;for(let s of e)t>s&&(t=s),s>r&&(r=s);return[t,r]}function ne(e,t,r){let s=[],o=/* @__PURE__ */new Set;for(let i of e.fields){if(i.whenProps?.some(e=>null==t[e]))continue;let e=t[i.accessor],a="string"==typeof e||"function"==typeof e?e:i.defaultAccessor;if("string"!=typeof a&&"function"!=typeof a)continue;let{dataProp:l,rows:n}=Z(i,t,r);if(0===n.length)continue;let c="string"==typeof a?a:i.accessor+"()",d=`${l}:${i.role}:${c}`;if(o.has(d))continue;o.add(d);let u=i.temporalValues??("time"===i.role||"x"===i.role&&"time"===t.xScaleType?"date-like":void 0),f="x"===i.role&&"log"===t.xScaleType||"y"===i.role&&"log"===t.yScaleType,y=ae(i,t);s.push({contract:i,accessor:a,accessorLabel:c,dataProp:l,rows:n,requirements:y,logScale:f,observation:ie(n,a,c,u,i.missingValue)})}return s}function ce(e){return e.slice(0,5)}function de(e){return{domain:"data",...e}}function ue(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),s=ee(r,.25),o=ee(r,.75),i=ee(r,.5),a=o-s;if(a>0){let e=s-10*a,r=o+10*a;return t.filter(t=>e>t.value||t.value>r).map(e=>e.row)}let l=100*Math.max(1,Math.abs(i));return t.filter(e=>Math.abs(e.value-i)>l).map(e=>e.row)}function fe(e,t){let r=[],{observation:s,contract:o,accessorLabel:i,requirements:a}=e,l={field:i,role:o.role},n=[...s.nonFiniteRows,...s.nonNumericRows,...s.accessorErrorRows].sort((e,t)=>e-t);if(0===s.numbers.length)return r.push(de({severity:"error",code:"DEGENERATE_EXTENT",message:`${o.accessor}="${i}" produces no finite numeric values; the chart cannot resolve its ${o.role} input.`,fix:`Ensure ${i} contains finite numbers${"x"===o.role?" (or valid dates for a time scale)":""}.`,...l,...n.length>0?{rows:ce(n),count:n.length}:{}})),r;s.nonFiniteRows.length>0&&r.push(de({severity:"error",code:"NON_FINITE_VALUE",message:`${i} contains ${s.nonFiniteRows.length} NaN or infinite value${1===s.nonFiniteRows.length?"":"s"}; scale and layout math require finite numbers.`,fix:`Filter or replace NaN/Infinity in ${i} before rendering.`,...l,rows:ce(s.nonFiniteRows),count:s.nonFiniteRows.length})),!o.allowMissing&&s.missingRows.length>0&&r.push(de({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${i} is missing for ${s.missingRows.length} row${1===s.missingRows.length?"":"s"}; the ${o.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${i} values before rendering.`,...l,rows:ce(s.missingRows),count:s.missingRows.length}));let c=[...s.nonNumericRows,...s.accessorErrorRows].sort((e,t)=>e-t);if(c.length>0&&r.push(de({severity:"error",code:"NON_NUMERIC_VALUE",message:`${i} produces ${c.length} non-numeric value${1===c.length?"":"s"} for the ${o.role} role.`,fix:`Bind ${o.accessor} to a numeric field or return finite numbers from the accessor.`,...l,rows:ce(c),count:c.length})),o.domain&&s.numbers.length>=2){let[e,t]=le(s.numbers);e===t&&r.push(de({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${i} is constant at ${e}; its ${o.role} scale has a zero-span data domain.`,fix:`Provide varying ${o.role} values, set an explicit extent around ${e}, or use a single-value display.`,...l,rows:ce(s.finiteRows),count:s.finiteRows.length}))}if(a.includes("positive")){let t=s.numbers.map((e,t)=>({number:e,row:s.finiteRows[t]})).filter(({number:e})=>0>=e).map(({row:e})=>e);if(t.length>0){let s=e.logScale;r.push(de({severity:"error",code:s?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${i} contains ${t.length} non-positive value${1===t.length?"":"s"}, which ${s?"cannot be represented on a log scale":"violate the positive-value contract"}.`,fix:s?"Remove or transform values ≤ 0, or use a linear/symlog scale.":"Provide values greater than zero.",...l,rows:ce(t),count:t.length}))}}if(a.includes("non-negative")&&s.negativeRows.length>0&&r.push(de({severity:"error",code:"size"===o.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${i} contains ${s.negativeRows.length} negative ${o.role} value${1===s.negativeRows.length?"":"s"}; the chart maps this role to non-negative geometry.`,fix:"Use a non-negative measure, clamp intentionally, or encode sign with position/color instead.",...l,rows:ce(s.negativeRows),count:s.negativeRows.length})),a.includes("integer")){let e=[.../* @__PURE__ */new Set([...s.negativeRows,...s.zeroRows,...s.fractionalRows])].sort((e,t)=>e-t);e.length>0&&r.push(de({severity:"error",code:"INVALID_COUNT",message:`${i} 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.",...l,rows:ce(e),count:e.length}))}if(a.includes("unit-interval")){let e=s.numbers.map((e,t)=>({number:e,row:s.finiteRows[t]})).filter(({number:e})=>0>e||e>1).map(({row:e})=>e);e.length>0&&r.push(de({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${i} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${i} to [0, 1] before using it as ${o.role}.`,...l,rows:ce(e),count:e.length}))}if(t&&o.domain){let t=ue(e);t.length>0&&r.push(de({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${i} 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.",...l,rows:ce(t),count:t.length}))}return r}function ye(e,t,r){if(!e)return"__all__";try{return re(e,t,r)+""}catch{return"__accessor_error__"}}function pe(e,t,r){if(e.whenProp&&!0!==r[e.whenProp])return[];let s=t.find(t=>t.contract.role===e.role);if(!s||0===s.observation.numbers.length)return[];let o=e.groupAccessor?r[e.groupAccessor]:void 0,i="string"==typeof o||"function"==typeof o?o:e.defaultGroupAccessor,a=/* @__PURE__ */new Map;for(let e=0;s.rows.length>e;e++){let t;try{t=re(s.accessor,s.rows[e],e)}catch{continue}let r=se(t,void 0);if(null==r)continue;let o=ye(i,s.rows[e],e),l=a.get(o)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};l.sum+=r,l.magnitude+=Math.abs(r),l.positive||(l.positive=r>0),l.negative||(l.negative=0>r),l.rows.push(e),0>r&&l.negativeRows.push(e),a.set(o,l)}let l=[],n=[],c=[],d=[],u=[],f=[];for(let[t,r]of a)("positive-total"===e.kind&&0>=r.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,r.magnitude)*10>=Math.abs(r.sum))&&(l.push(t),d.push(...r.rows)),"normalized-total"===e.kind&&r.positive&&r.negative&&(n.push(t),u.push(...r.rows)),"normalized-total"===e.kind&&r.negative&&(c.push(t),f.push(...r.negativeRows));let y=[];return l.length>0&&y.push(de({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${l.length} normalization group${1===l.length?" has":"s have"} a zero total, so division would be undefined.`:"The part-to-whole total is not positive, so meaningful shares cannot be computed.",fix:"normalized-total"===e.kind?"Remove empty/zero-sum groups or disable normalization.":"Provide at least one positive value and ensure the total is greater than zero.",field:s.accessorLabel,role:e.role,rows:ce([...new Set(d)].sort((e,t)=>e-t)),count:l.length})),c.length>0&&y.push(de({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:s.accessorLabel,role:e.role,rows:ce([...new Set(f)].sort((e,t)=>e-t)),count:f.length})),n.length>0&&y.push(de({severity:"warning",code:"MIXED_SIGN_NORMALIZATION",message:`${n.length} normalization group${1===n.length?" mixes":"s mix"} positive and negative contributions; percentage shares may be unstable or misleading.`,fix:"Separate positive and negative contributions, use diverging stacks, or disable normalization.",field:s.accessorLabel,role:e.role,rows:ce([...new Set(u)].sort((e,t)=>e-t)),count:n.length})),y}function he(e,t,r,s={}){let o=s.contracts??J(e)??te(t);if(!o)return{component:e,ok:!0,rowCount:r?.length??(Array.isArray(t.data)?t.data.length:0),summary:{fieldsChecked:0,errors:0,warnings:0},contracts:[],diagnoses:[]};let i=ne(o,t,r),a=[],l=!1!==s.checkOutliers;for(let e of X(o,t,r))a.push(de({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 n=new Set(i.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(let e of n)a.push(de({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 i)a.push(...fe(e,l));for(let e of o.aggregates??[])a.push(...pe(e,i,t));let c=a.filter(e=>"error"===e.severity).length,d=a.length-c;return{component:e,ok:0===c,rowCount:i.reduce((e,t)=>Math.max(e,t.rows.length),r?.length??(Array.isArray(t.data)?t.data.length:0)),summary:{fieldsChecked:i.length,errors:c,warnings:d},contracts:i.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:a}}function me(e,t,r){let s=Oo[e];if(s){if("array"===s.dataShape||"realtime"===s.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"===s.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"===s.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 ge(e,t){for(let[r,s]of[["width",600],["height",400]]){let o=e[r];void 0!==o&&("number"!=typeof o||0>=o)&&t.push({severity:"error",code:"width"===r?"BAD_WIDTH":"BAD_HEIGHT",message:`${r}=${JSON.stringify(o)} — chart needs a positive number.`,fix:`Set ${r}={${s}}.`})}if(e.size&&Array.isArray(e.size)){let[r,s]=e.size;(null!=r&&0>=r||null!=s&&0>=s)&&t.push({severity:"error",code:"BAD_SIZE",message:`size=[${r}, ${s}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}function ke(e,t,r){let s=Oo[e];if(!s||"array"!==s.dataShape)return;let o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;let i=o[0];if(!i||"object"!=typeof i)return;let a=Object.keys(i);for(let e of s.dataAccessors){let s=t[e];"string"==typeof s&&(s in i||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${s}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}, or use a function: ${e}={d => d.myValue}.`}))}}function ve(e,t,r){Qs.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 xe(e,t,r){Zs.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 be(e,t,r){let s=Oo[e];if(!s||"array"!==s.dataShape)return;let o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;let i=o[0];if(!i||"object"!=typeof i)return;let a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" 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 Ce(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 Ae(e,t,r){if(!Ks.has(e)||t.gapStrategy)return;let s=t.data;if(!s||!Array.isArray(s)||0===s.length)return;let o=t.yAccessor||"y";"string"==typeof o&&s.some(e=>{let t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}function we(e,t,r){if(!Xs.has(e))return;let s=t.rExtent||t.yExtent||t.valueExtent;s&&Array.isArray(s)&&s.length>=1&&null!=s[0]&&0!==s[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${s[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, ${s[1]??"auto"}]}. For trend-focused charts, use LineChart instead.`})}function Se(e,t,r){if(!Js.has(e))return;let s=t.barPadding;"number"==typeof s&&10>s&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${s} 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 We(e,t,r){if("Heatmap"!==e)return;let s=t.data;if(!s||!Array.isArray(s)||0===s.length)return;let o=s[0];if(o&&"object"==typeof o)for(let e of["xAccessor","yAccessor"]){let s=t[e];if("string"!=typeof s)continue;let i=o[s];"string"==typeof i&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${s}" resolves to string values (e.g. "${i}"). 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 Le(e,t,r){let s=t.colorScheme;if(!s||!Array.isArray(s))return;let o="string"==typeof t.background?t.background:"#ffffff";if(!o.startsWith("#"))return;let i=[];for(let e of s){if("string"!=typeof e||!e.startsWith("#"))continue;let t=Vs(e,o);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${o}": ${i.join(", ")}. Data marks may be hard to see.`,fix:"Choose colors with at least 3:1 contrast against the chart background."})}function Be(e,t){let r=e.width??600,s=e.height??400,o=e.margin;if(!o||"object"!=typeof o)return;let i=(o.left||0)+(o.right||0),a=(o.top||0)+(o.bottom||0);i>=r&&t.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${i}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>=s&&t.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${a}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}function Re(e,t,r){let s=Oo[e]?.props,o=e=>!!s?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,i=o("title"),a=o("description"),l=o("summary");!i&&!a&&!l&&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 Pe(e,t,r){let s=t.colorScheme;"string"!=typeof s||Oo[e]?.props?.colorScheme?.enum||ai.has(s)||r.push({severity:"warning",code:"UNKNOWN_COLOR_SCHEME",message:`colorScheme "${s}" is not a recognized named scheme — the chart will fall back to the default palette.`,fix:`Use a known scheme name (${[...ai].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}function $e(e,t,r){let s=t.colorScheme;if(!s||!Array.isArray(s)||2>s.length)return;let o=s.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;let i=[];for(let e=0;o.length-1>e;e++){let t=Vs(o[e],o[e+1]);null!==t&&1.5>t&&i.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.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 Me(e,t,r){let s=[];for(let e of li)"function"==typeof t[e]&&s.push(e);s.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${s.length>1?"s":""} detected: ${s.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 Ie(e,t,r){let s=t.hoverRadius;"number"==typeof s&&s>0&&24>s&&!1!==t.enableHover&&(!1!==t.hoverAnnotation||t.tooltip||t.customHoverBehavior||t.customClickBehavior||t.onClick)&&r.push({severity:"warning",code:"TOUCH_TARGET_SMALL",message:`hoverRadius=${s}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 Ee(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 Ne(e,t,r){if(!0!==t.showParticles)return;let s=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},o="number"==typeof s.maxPerLine?s.maxPerLine:void 0,i="number"==typeof s.spawnRate?s.spawnRate:void 0;("number"==typeof o&&o>20||"number"==typeof i&&i>.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 _e(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function Te(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function Oe(e,t){let r=Te(e.visibleTokens);if(null!=r)return r;let s=Te(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=s)return s;let o=Te(t.tokenCount),i=Te(t.maxTokens);return null!=o&&null!=i?Math.min(o,i):o??s??i}function Fe(e,t,r){let s=[];_e(t.tokenEncoding)&&s.push({source:"tokenEncoding",encoding:t.tokenEncoding}),_e(t.encoding)&&s.push({source:"encoding",encoding:t.encoding});for(let{source:e,encoding:o}of s){let s=Oe(t,o);for(let t of P(o,{visibleTokens:s}))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 ze(e){let t={...e};return delete t.tokenEncoding,delete t.visibleTokens,_e(t.encoding)&&delete t.encoding,t}function De(e,t){let r=t.match(/^Unknown prop "([^"]+)"/);if(r)return`Remove \`${r[1]}\` or replace it with a documented ${e} prop.`;let s=t.match(/^"([^"]+)" is required for .+\.$/i)??t.match(/(?:Missing|required) prop "?([^". ]+)/i);return s?`Add the required \`${s[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 je(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 Ue(e,t){let r=[],s=()=>({ok:r.every(e=>"warning"===e.severity),diagnoses:r}),o=/^(XY|Ordinal|Network|Physics|Geo)CustomChart$/.test(e),i=o?[]:B(e,ze(t)).errors;if(o){"function"!=typeof t.layout&&i.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])&&i.push(`Provide an array for ${e}.`)}for(let s of i)"BigNumber"===e&&void 0!==t.accessibleTable&&s.startsWith('Unknown prop "accessibleTable"')||r.push({severity:"error",code:"VALIDATION",message:s,fix:o?s:De(e,s)});if("BigNumber"===e&&je(t,r),(o||Oo[e])&&(ge(t,r),Be(t,r),I(0,t,r)),!Oo[e])return s();me(e,t,r),ke(e,t,r),ve(e,t,r),xe(e,t,r),be(e,t,r),Ce(0,t,r),we(e,t,r),Ae(e,t,r);let a=he(e,t,void 0,{checkOutliers:!1}).diagnoses;for(let e of a)"EMPTY_DATA"===e.code&&r.some(e=>"EMPTY_DATA"===e.code||"EMPTY_EDGES"===e.code)||r.push(e);if(Se(e,t,r),We(e,t,r),Le(0,t,r),$e(0,t,r),Pe(e,t,r),Re(e,t,r),Me(0,t,r),Ie(0,t,r),Ee(0,t,r),Ne(0,t,r),Fe(0,t,r),E(0,t,r),N(0,t,r),_(0,t,r),T(e,t,r),O(e,t,r),r.some(e=>"NEGATIVE_VALUE"===e.code||"NEGATIVE_NORMALIZED_VALUE"===e.code)||F(e,t,r),z(e,t,r),D(e,t,r),j(e,t,r),V(e,t,r),"ProcessSankey"===e)for(let e of H(t))r.push(e);return s()}function Ge(e){return null==e?[]:Array.isArray(e)?e:[e]}function Ve(e){if("string"==typeof e)return e;try{return JSON.stringify(e,null,2)??e+""}catch{return e+""}}function He(e,t){return null==t?e.findings:e.findings.slice(0,Math.max(0,t))}function qe(...e){for(let t of e){let e=t?.trim();if(e)return e}return"Review this finding."}function Ye(e){return qe(e.remediation,e.explanation,e.evidence,e.condition)}function Qe(e){return qe(e.name,e.ruleId)}function Ze(e){return"error"===e?"error":"warning"===e?"warning":"info"===e?"info":"neutral"}function Xe(e,t){return e.domain?`${t} · ${e.domain}`:t}function Ke(e,t){return t[e]??t.info??ni.info}function Je(e){return qe(e.ruleId,e.name)}function et(e,t){return`${Je(e)}:${t}`}function tt(e){return"pitfall-"+(e+"").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function rt(e,t={},r=0,s={kind:"image",findings:[e]}){let o=t.sourcePrefix??"datapitfalls";return{id:et(e,r),level:Ze(e.severity),title:Qe(e),message:t.message?t.message(e,r,s):Ye(e),source:Xe(e,o),...void 0===t.dismissible?{}:{dismissible:t.dismissible}}}function st(e,t={}){return He(e,t.max).map((r,s)=>rt(r,t,s,e))}function ot(e,t={}){return{notifications:st(e,t),meta:{count:e.findings.length,kind:e.kind}}}function it(e,t={},r=0,s={kind:"image",findings:[e]}){let o={...ni,...t.palette};return{...t.anchorFor?.(e,r,s)??{},type:t.type??"label",title:Qe(e),label:Ye(e),wrap:t.wrap??240,color:Ke(e.severity,o),className:tt(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 at(e,t={}){return He(e,t.max).map((r,s)=>it(r,t,s,e))}function lt(e,t={}){return{annotations:at(e,t),meta:{count:e.findings.length,kind:e.kind}}}function nt(e,t,r){return{role:e,artifact:{kind:"text",content:t,...r?{filename:r}:{}}}}function ct(e,t,r,s){return{role:e,artifact:{kind:"code",content:t,language:r,...s?{filename:s}:{}}}}function dt(e,t){return t.length>0?{role:e,artifact:{kind:"image",images:t}}:null}function ut(e,t){let r=t.diagnoses.filter(e=>"error"===e.severity).length,s=t.diagnoses.filter(e=>"warning"===e.severity).length,o=[e+": Semiotic diagnoseConfig report","ok: "+t.ok,"errors: "+r,"warnings: "+s];if(0===t.diagnoses.length)return o.push("","No Semiotic config issues detected."),o.join("\n");o.push("");for(let e of t.diagnoses)o.push(`[${e.severity}] ${e.code}: ${e.message}`),e.fix&&o.push("Fix: "+e.fix);return o.join("\n")}function ft(e){return[e.component+": Semiotic reader grounding","",e.text,"\nStructured grounding JSON:\n```json",Ve(e),"```"].join("\n")}function yt(e,t,r={}){let s=[],o=!1!==r.includeConfig,i=!1!==r.includeJSX,a=!1!==r.includeGrounding,l=!1!==r.includeDiagnostics,n=!1!==r.includeAccessibility,c=r.filenamePrefix??e,d=js(e,t,r.config);r.context?.trim()&&s.push(nt("Analysis context",r.context.trim(),c+".context.md")),o&&s.push(ct("Semiotic chart config",Ve(d),"json",c+".semiotic-config.json")),i&&s.push(ct("Semiotic chart JSX",Us(d),"jsx",c+".semiotic.jsx"));let u,f,y,p=dt("Rendered chart image",Ge(r.rendered?.image));return p&&s.push(p),r.rendered?.svg?.trim()&&s.push(ct("Rendered chart SVG",r.rendered.svg.trim(),"svg",c+".rendered.svg")),null!=r.rendered?.evidence&&s.push(nt("Semiotic render evidence",[e+": Semiotic render evidence","\n```json",Ve(r.rendered.evidence),"```"].join("\n"),c+".render-evidence.md")),a&&(u=Gs(e,t,r.grounding),s.push(nt("Semiotic reader grounding",ft(u),c+".reader-grounding.md"))),l&&(f=Ue(e,t),s.push(nt("Semiotic config diagnostics",ut(e,f),c+".diagnose-config.md"))),n&&(y=io(e,t,r.accessibility),s.push(nt("Semiotic accessibility audit",ao(y),c+".accessibility.md"))),r.narrative?.trim()&&s.push(nt("Author narrative",r.narrative.trim(),c+".narrative.md")),r.additionalStages?.length&&s.push(...r.additionalStages),0===s.length&&s.push(ct("Semiotic chart config",Ve(d),"json",c+".semiotic-config.json")),{input:{kind:"chain",stages:s},config:d,...u?{grounding:u}:{},...f?{diagnosis:f}:{},...y?{accessibility:y}:{}}}function pt(e,t,r={}){return yt(e,t,r).input}function ht(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function mt(e,t,r){("number"!=typeof r||!Number.isInteger(r)||1>r||r>5)&&e.push(t+" must be an integer in [1, 5]")}function gt(e,t,r){void 0!==r&&"string"!=typeof r&&e.push(t+" must be a string")}function kt(e,t,r,s,o){void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||void 0!==s&&s>r||void 0!==o&&r>o)&&e.push(`${t} must be a finite number${void 0!==s&&void 0!==o?` in [${s}, ${o}]`:void 0!==s?" >= "+s:""}`)}function vt(e,t,r){void 0!==r&&"boolean"!=typeof r&&e.push(t+" must be a boolean")}function xt(e,t,r,s){for(let o of Object.keys(r))s.includes(o)||e.push(`${t}.${o} is not allowed`)}function bt(e,t){void 0!==t&&"0.1"!==t&&e.push("specVersion must be the string 0.1")}function Ct(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 At(e){let t=[];if(!ht(e))return{valid:!1,errors:["capability must be an object"]};bt(t,e.specVersion),("string"!=typeof e.component||0===e.component.length)&&t.push("component is required and must be a non-empty string"),gt(t,"family",e.family),gt(t,"importPath",e.importPath);let r=e.rubric;if(ht(r)?(xt(t,"rubric",r,["familiarity","accuracy","precision"]),mt(t,"rubric.familiarity",r.familiarity),mt(t,"rubric.accuracy",r.accuracy),mt(t,"rubric.precision",r.precision)):t.push("rubric is required and must be an object"),void 0!==e.intentScores)if(ht(e.intentScores))for(let[r,s]of Object.entries(e.intentScores))kt(t,"intentScores."+r,s,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(ht(e)){if("string"!=typeof e.key&&t.push(`variants[${r}].key is required`),"string"!=typeof e.label&&t.push(`variants[${r}].label is required`),gt(t,`variants[${r}].description`,e.description),void 0!==e.intentDeltas)if(ht(e.intentDeltas))for(let[s,o]of Object.entries(e.intentDeltas))kt(t,`variants[${r}].intentDeltas.${s}`,o);else t.push(`variants[${r}].intentDeltas must be an object`);if(void 0!==e.rubricDeltas)if(ht(e.rubricDeltas)){xt(t,`variants[${r}].rubricDeltas`,e.rubricDeltas,["familiarity","accuracy","precision"]);for(let s of["familiarity","accuracy","precision"])kt(t,`variants[${r}].rubricDeltas.${s}`,e.rubricDeltas[s])}else t.push(`variants[${r}].rubricDeltas must be an object`);for(let s of["caveats","tags"]){let o=e[s];void 0!==o&&(!Array.isArray(o)||o.some(e=>"string"!=typeof e))&&t.push(`variants[${r}].${s} must be an array of strings`)}void 0!==e.props&&!ht(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(ht(e.mobile)){let r=e.mobile;gt(t,"mobile.strategy",r.strategy),vt(t,"mobile.responsive",r.responsive),vt(t,"mobile.supportsResponsiveLayout",r.supportsResponsiveLayout);for(let e of["minViewportWidth","maxMarks","maxAnnotations","minimumHitTarget"])kt(t,"mobile."+e,r[e],0);void 0!==r.breakpoints&&(Array.isArray(r.breakpoints)?r.breakpoints.forEach((e,r)=>{kt(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&&(ht(r.interaction)?(gt(t,"mobile.interaction.primary",r.interaction.primary),gt(t,"mobile.interaction.hoverFallback",r.interaction.hoverFallback),kt(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&&(ht(r.labels)?(gt(t,"mobile.labels.strategy",r.labels.strategy),kt(t,"mobile.labels.minFontSize",r.labels.minFontSize,0)):t.push("mobile.labels must be an object")),void 0!==r.custom&&(ht(r.custom)?(vt(t,"mobile.custom.dataBearingSceneNodes",r.custom.dataBearingSceneNodes),vt(t,"mobile.custom.stableIds",r.custom.stableIds),gt(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 s=e[r];void 0!==s&&(!Array.isArray(s)||s.some(e=>"string"!=typeof e))&&t.push(r+" must be an array of strings")}return{valid:0===t.length,errors:t}}function wt(e){let t=[];if(!ht(e))return{valid:!1,errors:["audience profile must be an object"]};if(bt(t,e.specVersion),gt(t,"name",e.name),void 0!==e.familiarity)if(ht(e.familiarity))for(let[r,s]of Object.entries(e.familiarity))("number"!=typeof s||!Number.isInteger(s)||1>s||s>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(ht(e.targets))for(let[r,s]of Object.entries(e.targets))!ht(s)||"increase"!==s.direction&&"decrease"!==s.direction?t.push(`targets.${r}.direction must be "increase" or "decrease"`):(xt(t,"targets."+r,s,["direction","weight","reason"]),void 0!==s.weight&&("number"!=typeof s.weight||!Number.isInteger(s.weight)||1>s.weight||s.weight>3)&&t.push(`targets.${r}.weight must be an integer in [1, 3]`),gt(t,`targets.${r}.reason`,s.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&&!pi.has(e.receptionModality)&&t.push("receptionModality must be one of "+[...pi].join(", ")),{valid:0===t.length,errors:t}}function St(e){let t=[];if(!ht(e))return{valid:!1,errors:["annotation must be an object"]};let r=e.provenance;if(void 0!==r)if(ht(r)){for(let e of["author","authorKind","source","basis","dataVersion","stableId"])gt(t,"provenance."+e,r[e]);kt(t,"provenance.confidence",r.confidence,0,1),void 0!==r.createdAt&&("string"!=typeof r.createdAt||!Ct(r.createdAt))&&t.push("provenance.createdAt must be an ISO 8601 date-time string")}else t.push("provenance must be an object");let s=e.lifecycle;return void 0!==s&&(ht(s)?(void 0!==s.freshness&&!ui.has(s.freshness)&&t.push("lifecycle.freshness must be one of "+[...ui].join(", ")),void 0!==s.status&&!fi.has(s.status)&&t.push("lifecycle.status must be one of "+[...fi].join(", ")),void 0!==s.anchor&&!yi.has(s.anchor)&&t.push("lifecycle.anchor must be one of "+[...yi].join(", ")),gt(t,"lifecycle.supersedes",s.supersedes),void 0!==s.ttlHint&&"string"!=typeof s.ttlHint&&("number"!=typeof s.ttlHint||!Number.isFinite(s.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 Wt(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 Lt(e,t){return{status:"refused",diagnostics:t,lossReport:t.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:Wt(e)}}function Bt(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 Rt(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 Pt(e,t){let r=t.caveats?[...t.caveats]:[];if(e.caveats||0!==r.length)return t=>{let s=e.caveats?Array.from(e.caveats(t)):[];return[.../* @__PURE__ */new Set([...s,...r])]}}function $t(e,t){let r=At(e);if(!r.valid)return Lt(e,r.errors.map(e=>({code:"INVALID_PORTABLE_CAPABILITY",severity:"error",message:e})));let s=e;if(!t)return Lt(e,[{code:"HOST_CAPABILITY_NOT_FOUND",severity:"error",path:"/component",message:`No host capability is registered for "${s.component}". Resolve or register the renderer's executable capability before binding portable metadata.`}]);if(s.component!==t.component)return Lt(e,[{code:"CAPABILITY_COMPONENT_MISMATCH",severity:"error",path:"/component",message:`Portable component "${s.component}" cannot bind to host component "${t.component}".`}]);let o=Pt(t,s);return{status:"success",capability:{...t,rubric:{...s.rubric},intentScores:s.intentScores?{...s.intentScores}:{...t.intentScores},variants:s.variants?.map(Bt),...o?{caveats:o}:{caveats:void 0},...void 0!==s.mobile?{mobile:Rt(s.mobile)}:{},portableDescriptor:s},diagnostics:[],lossReport:[],provenance:Wt(e)}}function Mt(e){return{field:e,type:"quantitative"}}function It(e){return{field:e,type:"nominal"}}function Et(e){return"time"===e.xScaleType?"temporal":"quantitative"}function Nt(e,t){return"string"==typeof t&&(e.axis={title:t}),e}function _t(e,t){let r=[];for(let s of mi[e]||[])("string"!=typeof t[s]||0===t[s].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+s,message:`${e} requires a string ${s} for Vega-Lite export.`});for(let s of gi[e]||[])void 0!==t[s]&&("string"!=typeof t[s]||0===t[s].length)&&r.push({code:"UNSERIALIZABLE_ACCESSOR",severity:"error",path:"/props/"+s,message:`${e} can export ${s} only as a non-empty string field name.`});return r}function Tt(e,t={}){let r=[],s={adapter:"semiotic/vega-lite",direction:"export",sourceFormat:"semiotic-chart-config",targetFormat:"vega-lite",..."string"==typeof e.version?{specVersion:e.version}:{}},o=e.props||{},i=_t(e.component,o);if(i.length>0)return{status:"refused",diagnostics:i,lossReport:i.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:s};let a,l={},n=e.component;switch(n){case"BarChart":case"StackedBarChart":case"GroupedBarChart":{a="bar";let e="horizontal"===o.orientation,t=Nt(It(o.categoryAccessor),o.categoryLabel),s=Nt(Mt(o.valueAccessor),o.valueLabel);e?(l.y=t,l.x=s):(l.x=t,l.y=s),"StackedBarChart"===n&&o.stackBy?l.color=It(o.stackBy):"GroupedBarChart"===n&&o.groupBy&&(l.color=It(o.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":a=o.curve||o.showPoints?{type:"line"}:"line","object"==typeof a&&(o.curve&&hi[o.curve]&&(a.interpolate=hi[o.curve]),o.showPoints&&(a.point=!0)),l.x=Nt({field:o.xAccessor,type:Et(o)},o.xLabel),l.y=Nt(Mt(o.yAccessor),o.yLabel),o.lineBy?l.color=It(o.lineBy):o.colorBy&&(l.color=It(o.colorBy));break;case"AreaChart":case"StackedAreaChart":a=o.curve?{type:"area"}:"area","object"==typeof a&&o.curve&&hi[o.curve]&&(a.interpolate=hi[o.curve]),"object"==typeof a&&void 0!==o.areaOpacity&&(a.opacity=o.areaOpacity),l.x=Nt({field:o.xAccessor,type:Et(o)},o.xLabel),l.y=Nt(Mt(o.yAccessor),o.yLabel),"StackedAreaChart"===n&&o.areaBy&&(l.color=It(o.areaBy));break;case"Scatterplot":case"BubbleChart":a="point",l.x=Nt(Mt(o.xAccessor),o.xLabel),l.y=Nt(Mt(o.yAccessor),o.yLabel),o.colorBy&&(l.color=It(o.colorBy)),"BubbleChart"===n&&o.sizeBy&&(l.size=Mt(o.sizeBy),Array.isArray(o.sizeRange)&&(l.size.scale={range:o.sizeRange}));break;case"Heatmap":a="rect",l.x=Nt(It(o.xAccessor),o.xLabel),l.y=Nt(It(o.yAccessor),o.yLabel),o.valueAccessor&&(l.color=Mt(o.valueAccessor));break;case"PieChart":case"DonutChart":a="DonutChart"===n?{type:"arc",innerRadius:o.innerRadius??60}:"arc",o.valueAccessor&&(l.theta=Mt(o.valueAccessor)),o.categoryAccessor&&(l.color=It(o.categoryAccessor));break;case"DotPlot":{a="tick";let e="horizontal"===o.orientation,t=Nt(It(o.categoryAccessor),o.categoryLabel),r=Nt(Mt(o.valueAccessor),o.valueLabel);e?(l.y=t,l.x=r):(l.x=t,l.y=r);break}case"Histogram":a="bar",o.valueAccessor&&(l.x=Nt(Mt(o.valueAccessor),o.valueLabel),l.x.bin=!o.bins||{maxbins:o.bins},l.y={aggregate:"count",type:"quantitative"}),o.categoryAccessor&&(l.color=It(o.categoryAccessor));break;default:{let e=`Component "${n}" 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:s}}}o.colorScheme&&l.color&&(l.color.scale={...l.color.scale||{},scheme:o.colorScheme});let c={mark:a};return Array.isArray(o.data)&&(c.data={values:o.data}),Object.keys(l).length>0&&(c.encoding=l),"string"==typeof o.title&&(c.title=o.title),"number"==typeof o.width&&(c.width=o.width),"number"==typeof o.height&&(c.height=o.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:s}:{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:s}}function Ot(e,t){return Tt(e,t).spec}function Ft(e,t){let r={...zt(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 zt(e){return e.usermeta?.idid}function Dt(e,t){let r={...zt(e),specVersion:"0.1",annotations:[...t]},s=t.map(Gt).filter(e=>null!==e).map(e=>({...e,usermeta:{idid:{role:"annotation-layer"}}}));if(0===s.length)return{...e,usermeta:{...e.usermeta,idid:r}};let o=Array.isArray(e.layer)?e.layer:[Ut(e)],{mark:i,encoding:a,data:l,transform:n,usermeta:c,...d}=e;return{...d,usermeta:{...e.usermeta,idid:r},layer:[...o,...s]}}function jt(e){let t=zt(e)?.annotations;return Array.isArray(t)?t:[]}function Ut(e){let{mark:t,encoding:r,data:s,transform:o}=e,i={};return t&&(i.mark=t),r&&(i.encoding=r),s&&(i.data=s),o&&(i.transform=o),i}function Gt(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 Vt(e,t){let{groupBy:r,value:s,agg:o="sum"}=t,i=/* @__PURE__ */new Map,a="min"===o?1/0:"max"===o?-1/0:0;for(let t of e){let e=t[r]+"",l=i.get(e);l||(l={total:a,count:0},i.set(e,l));let n=Number(t[s]);switch(l.count++,o){case"count":break;case"min":l.total>n&&(l.total=n);break;case"max":n>l.total&&(l.total=n);break;default:l.total+=n}}let l=[];for(let[e,t]of i){let s="count"===o?t.count:"mean"===o?t.total/t.count:t.total;l.push({[r]:e,value:s})}return l}function Ht(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 qt(e){if(e)return"string"==typeof e?e:e.text}function Yt(e){return"nominal"===e||"ordinal"===e}function Qt(e){return"quantitative"===e||"temporal"===e}function Zt(e){return e.usermeta?.idid}function Xt(e){return"annotation-layer"===e.usermeta?.idid?.role}function Kt(e){if(!Zt(e)||!Array.isArray(e.layer))return e;let t=e.layer.filter(e=>!Xt(e));if(1!==t.length)return e;let{layer:r,...s}=e,{usermeta:o,...i}=t[0];return{...s,...i}}function Jt(e){let t=e,r=Kt(e),s=r,o=[];if(Array.isArray(t.layer)&&r===e&&o.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===s.mark)o.push({code:"MISSING_MARK",severity:"error",path:"/mark",message:"A Vega-Lite spec needs a supported single-view mark."});else{let{type:e}=Ht(s.mark);
3
3
  /* @__PURE__ */new Set(["bar","line","area","point","circle","square","rect","arc","tick"]).has(e)||o.push({code:"UNSUPPORTED_MARK",severity:"error",path:"/mark",message:`Vega-Lite mark "${e||"(missing)"}" has no supported Semiotic translation.`})}Array.isArray(s.transform)&&s.transform.length>0&&o.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!==s[e]&&o.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 s.data?.url&&o.push({code:"UNSUPPORTED_DATA_URL",severity:"error",path:"/data/url",message:"Strict import accepts inline data.values only; load URL data before importing."}),o}function er(e){e=Kt(e);let t,r=[],{type:s,markProps:o}=Ht(e.mark),i=e.encoding||{},a=i.x,l=i.y,n=i.color,c=i.size,d=i.theta,u=i.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||i.facet||i.row||i.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 f={};e.width&&(f.width=e.width),e.height&&(f.height=e.height);let y=qt(e.title);if(y&&(f.title=y),n?.field&&(f.colorBy=n.field,n.scale?.scheme)){let e=ki[n.scale.scheme];e&&(f.colorScheme=e)}void 0!==u?.value&&(f.pointOpacity=u.value);let p,h=a?.aggregate,m=l?.aggregate;if(t&&(h||m)){let e=m?l:a,r=m?a:l,s=xi[e.aggregate];if(s&&r?.field&&e.field)t=Vt(t,{groupBy:r.field,value:e.field,agg:s});else if(("count"===s||"count"===e.aggregate)&&r?.field&&t){let e=/* @__PURE__ */new Map;for(let s of t){let t=s[r.field]+"";e.set(t,(e.get(t)||0)+1)}t=Array.from(e,([e,t])=>({[r.field]:e,value:t}))}}if(a?.bin||l?.bin){let e="Histogram";t&&(f.data=t),a?.bin?(f.valueAccessor=a.field,l?.field&&(f.categoryAccessor=l.field),a.axis?.title&&(f.valueLabel=a.axis.title)):l?.bin&&(f.valueAccessor=l.field,a?.field&&(f.categoryAccessor=a.field),l.axis?.title&&(f.valueLabel=l.axis.title));let s=a?.bin||l?.bin,o="object"==typeof s?s.maxbins:void 0;return o&&(f.bins=o),or(e,f,r)}switch(s){case"bar":p=rr(a,l,n,f,t,h,m);break;case"line":if(p="LineChart",sr(a,l,f,h,m),n?.field&&(f.lineBy=n.field),o.interpolate){let e=vi[o.interpolate];e&&(f.curve=e)}!0===o.point&&(f.showPoints=!0),t&&(f.data=t);break;case"area":if(n?.field?(p="StackedAreaChart",f.areaBy=n.field):p="AreaChart",sr(a,l,f,h,m),o.interpolate){let e=vi[o.interpolate];e&&(f.curve=e)}void 0!==o.opacity&&(f.areaOpacity=o.opacity),t&&(f.data=t);break;case"point":case"circle":case"square":c?.field?(p="BubbleChart",f.sizeBy=c.field,c.scale?.range&&(f.sizeRange=c.scale.range)):p="Scatterplot",sr(a,l,f,h,m),t&&(f.data=t);break;case"rect":p="Heatmap",a?.field&&(f.xAccessor=a.field),l?.field&&(f.yAccessor=l.field),n?.field&&(f.valueAccessor=n.field,delete f.colorBy),a?.axis?.title&&(f.xLabel=a.axis.title),l?.axis?.title&&(f.yLabel=l.axis.title),t&&(f.data=t);break;case"arc":o.innerRadius&&o.innerRadius>0?(p="DonutChart",f.innerRadius=o.innerRadius):p="PieChart",d?.field?f.valueAccessor=d.field:l?.field&&(f.valueAccessor=m?"value":l.field),n?.field&&(f.categoryAccessor=n.field),a?.field&&!d?.field&&(f.categoryAccessor=a.field),t&&(f.data=t);break;case"tick":p="DotPlot",Yt(a?.type)?(f.categoryAccessor=a.field,l?.field&&(f.valueAccessor=m?"value":l.field),a?.axis?.title&&(f.categoryLabel=a.axis.title),l?.axis?.title&&(f.valueLabel=l.axis.title)):Yt(l?.type)?(f.categoryAccessor=l.field,a?.field&&(f.valueAccessor=h?"value":a.field),f.orientation="horizontal",l?.axis?.title&&(f.categoryLabel=l.axis.title),a?.axis?.title&&(f.valueLabel=a.axis.title)):(a?.field&&(f.categoryAccessor=a.field),l?.field&&(f.valueAccessor=m?"value":l.field)),t&&(f.data=t);break;default:r.push(`Unsupported mark type "${s}". Defaulting to Scatterplot.`),p="Scatterplot",sr(a,l,f,h,m),t&&(f.data=t)}return or(p,f,r)}function tr(e,t={}){let r=Jt(e),s=r.filter(e=>"error"===e.severity),o=Zt(e),i={adapter:"semiotic/vega-lite",direction:"import",sourceFormat:"vega-lite",targetFormat:"semiotic-chart-config",..."string"==typeof o?.specVersion?{specVersion:o.specVersion}:{},...o?{metadata:{idid:o}}:{}};if(s.length>0&&"lossy"!==t.mode)return{status:"refused",diagnostics:r,lossReport:s.map(({code:e,message:t,path:r})=>({code:e,message:t,path:r})),provenance:i};let a=er(e),l=(a.warnings||[]).map(e=>({code:"LEGACY_TRANSLATION_WARNING",severity:"warning",message:e})),n=s.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:n.length>0?"lossy":"success",config:a,diagnostics:[...c,...l],lossReport:n,provenance:i}}function rr(e,t,r,s,o,i,a){let l;return r?.field&&!1!==e?.stack&&!1!==t?.stack&&null!==e?.stack&&null!==t?.stack?(l="StackedBarChart",s.stackBy=r.field):l="BarChart",Yt(e?.type)&&Qt(t?.type)?(s.categoryAccessor=e.field,s.valueAccessor=a?"value":t.field,e?.axis?.title&&(s.categoryLabel=e.axis.title),t?.axis?.title&&(s.valueLabel=t.axis.title)):Qt(e?.type)&&Yt(t?.type)?(s.categoryAccessor=t.field,s.valueAccessor=i?"value":e.field,s.orientation="horizontal",t?.axis?.title&&(s.categoryLabel=t.axis.title),e?.axis?.title&&(s.valueLabel=e.axis.title)):(e?.field&&(s.categoryAccessor=e.field),t?.field&&(s.valueAccessor=a?"value":t.field),e?.axis?.title&&(s.categoryLabel=e.axis.title),t?.axis?.title&&(s.valueLabel=t.axis.title)),o&&(s.data=o),l}function sr(e,t,r,s,o){e?.field&&(r.xAccessor=s?"value":e.field),t?.field&&(r.yAccessor=o?"value":t.field),e?.axis?.title&&(r.xLabel=e.axis.title),t?.axis?.title&&(r.yLabel=t.axis.title)}function or(e,t,r){let s={component:e,props:t,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString()};if(r.length>0){s.warnings=r;for(let e of r)console.warn("[semiotic/fromVegaLite] "+e)}return s}function ir(e){return"string"==typeof e?e:void 0}function ar(e){return"function"==typeof e}function lr(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 nr(e,t,r){ar(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 cr(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&&!Ai.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."),yr("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 s=r[0],o=s.options||{},i=s.data||e.data,a={};"number"==typeof e.width&&(a.width=e.width),"number"==typeof e.height&&(a.height=e.height),"string"==typeof e.title&&(a.title=e.title),e.x?.label&&(a.xLabel=e.x.label),e.y?.label&&(a.yLabel=e.y.label);let l=e.color?.scheme?bi[e.color.scheme]:void 0;nr(t,o.x,"x"),nr(t,o.y,"y"),nr(t,o.fill,"fill"),nr(t,o.stroke,"stroke"),nr(t,o.r,"r");let n,c=ir(o.x),d=ir(o.y),u=ir(o.fill),f=ir(o.stroke),y=u||f,p=s.type.toLowerCase();switch(p){case"line":case"liney":case"linex":{n="LineChart",c&&(a.xAccessor=c),d?a.yAccessor=d:t.push(s.type+" has no explicit y field; provide options.y."),lr(i,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"===p&&!c&&t.push("lineY without an explicit x plots against the row index, which Semiotic doesn't infer. Provide options.x.");let e=f||u;e&&(a.lineBy=e),ur(o,a),fr(a,i,{colorScheme:l});break}case"bary":case"bar":n=y?"StackedBarChart":"BarChart",c&&(a.categoryAccessor=c),d&&(a.valueAccessor=d),y&&(a.stackBy=y),fr(a,i,{colorScheme:l});break;case"barx":n=y?"StackedBarChart":"BarChart",a.orientation="horizontal",d&&(a.categoryAccessor=d),c&&(a.valueAccessor=c),y&&(a.stackBy=y),fr(a,i,{colorScheme:l});break;case"dot":case"doty":case"dotx":case"circle":{let e=o.r;"string"==typeof e?(n="BubbleChart",a.sizeBy=e):(n="Scatterplot","number"==typeof e&&(a.pointRadius=e)),c&&(a.xAccessor=c),d&&(a.yAccessor=d),fr(a,i,{colorBy:y,colorScheme:l});break}case"area":case"areay":case"areax":n=u&&u!==d?"StackedAreaChart":"AreaChart",c&&(a.xAccessor=c),d&&(a.yAccessor=d),lr(i,c)&&t.push(`The x field "${c}" looks categorical; ${n} uses a continuous x scale, so a categorical x won't position. Use a numeric/time x.`),"StackedAreaChart"===n&&u&&(a.areaBy=u),ur(o,a),fr(a,i,{colorBy:"StackedAreaChart"===n?void 0:y,colorScheme:l});break;case"recty":case"rectx":case"rect":{n="Histogram";let e="rectx"===p?c:d||c;e&&(a.valueAccessor=e),y&&(a.categoryAccessor=y),fr(a,i,{colorScheme:l});break}case"cell":case"celly":case"cellx":n="Heatmap",c&&(a.xAccessor=c),d&&(a.yAccessor=d),y&&(a.valueAccessor=y),fr(a,i);break;case"tick":case"tickx":case"ticky":n="DotPlot","tickx"===p?(d&&(a.categoryAccessor=d),c&&(a.valueAccessor=c),a.orientation="horizontal"):(c&&(a.categoryAccessor=c),d&&(a.valueAccessor=d)),fr(a,i,{colorBy:y,colorScheme:l});break;default:t.push(`Plot mark "${s.type}" has no faithful Semiotic equivalent in this adapter. Defaulting to a Scatterplot of x/y; verify the result or file for support.`),n="Scatterplot",c&&(a.xAccessor=c),d&&(a.yAccessor=d),fr(a,i,{colorBy:y,colorScheme:l})}if(wi.has(n)){let t=dr(e.x?.type),r=dr(e.y?.type);t&&(a.xScaleType=t),r&&(a.yScaleType=r)}return yr(n,a,t)}function dr(e){return"time"===e||"utc"===e?"time":"log"===e?"log":void 0}function ur(e,t){e.curve&&Ci[e.curve]&&(t.curve=Ci[e.curve])}function fr(e,t,r={}){Array.isArray(t)&&(e.data=t),r.colorBy&&(e.colorBy=r.colorBy),r.colorScheme&&(e.colorScheme=r.colorScheme)}function yr(e,t,r){let s={component:e,props:t,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString()};if(r.length>0){s.warnings=r;for(let e of r)console.warn("[semiotic/fromObservablePlot] "+e)}return s}function pr(e){let t=e.trim();return t.length>=2&&('"'===t[0]&&t.endsWith('"')||"'"===t[0]&&t.endsWith("'"))?t.slice(1,-1):t}function hr(e){let t=e.trim();if(!t)return null;let r=t.match(/^([A-Za-z0-9_][\w-]*)/);if(!r)return null;let s=r[1],o=t.slice(s.length).trim();if(!o)return{id:s};for(let[e,t,r]of Bi)if(o.startsWith(e)&&o.endsWith(t)&&o.length>=e.length+t.length)return{id:s,label:pr(o.slice(e.length,o.length-t.length)),shape:r};return{id:s}}function mr(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 s=e.split("\n").map(e=>e.replace(/%%.*$/,"").trim()).filter(e=>e.length>0);if(0===s.length)return t.push("No content after stripping comments."),r();let o=s[0],i=o.split(/\s+/)[0].toLowerCase();if("graph"!==i&&"flowchart"!==i&&(Si.has(i)?t.push(`Mermaid "${o.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 "${o}". Treating remaining lines as flowchart edges.`),Si.has(i)))return r();let a="TD",l=o.split(/\s+/)[1]?.toUpperCase();l&&Wi.has(l)&&(a=l);let n="graph"===i||"flowchart"===i?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})},f=e=>e.replace(/--\s+([^->|]+?)\s+-->/g,"--\x3e|$1|").replace(/-\.\s+([^->|]+?)\s+\.->/g,"-.->|$1|").replace(/==\s+([^=>|]+?)\s+==>/g,"==>|$1|");for(let e=n;s.length>e;e++){let r=f(s[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(!Li.test(r)){let e=hr(r);e&&u(e);continue}let o=r.split(Li),i=null;for(let e=0;o.length>e;e+=2){let r,s=o[e].trim(),a=s.match(/^\|([^|]*)\|\s*(.*)$/);a&&(r=pr(a[1]),s=a[2].trim()),s.includes("&")&&(t.push('Multiple nodes joined with "&" — only the first is linked in this alpha.'),s=s.split("&")[0].trim());let l=hr(s);l?(u(l),i&&d.push({source:i.id,target:l.id,...r?{label:r}:{}}),i=l):i=null}}return 0===c.size?(t.push("No nodes found."),r()):(gr(c,d,t),{kind:"flowchart",direction:a,nodes:[...c.values()],edges:d,...t.length?{warnings:t}:{}})}function gr(e,t,r){let s=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(let t of e.keys())s.set(t,[]),o.set(t,0);for(let r of t)r.source!==r.target&&(!e.has(r.source)||!e.has(r.target)||(s.get(r.source).push(r.target),o.set(r.target,(o.get(r.target)||0)+1)));let i=[];for(let[e,t]of o)0===t&&i.push(e);for(let t=0;i.length>t;t++){let r=i[t],a=e.get(r).layer;for(let t of s.get(r)){let r=e.get(t);a+1>r.layer&&(r.layer=a+1);let s=(o.get(t)||0)-1;o.set(t,s),0===s&&i.push(t)}}e.size>i.length&&r.push("Graph contains a cycle; layering is best-effort (not a strict DAG).");let a=/* @__PURE__ */new Map;for(let t of e.values())t.row=a.get(t.layer)??0,a.set(t.layer,t.row+1)}function kr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function vr(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function xr(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 br(e,t){let r={};if(!e||"object"!=typeof e)return r;for(let[s,o]of Object.entries(e)){let e=vr(Mi,s)||s,i=o;if(Array.isArray(i)){if(0===i.length)continue;t.push(`Static-series array encoding on "${s}" is not supported; using the first field and preserving the full encoding in flint.unmappedEncodings.`),i=i[0]}"string"==typeof i?r[e]={field:i}:kr(i)?r[e]=i:null!=i&&t.push(`Encoding "${s}" is not an object, string, or array and was ignored.`)}return r}function Cr(e,t){let r=e[t]?.field;return"string"==typeof r&&r.length>0?r:void 0}function Ar(e){return"nominal"===e?.type||"ordinal"===e?.type}function wr(e){return"quantitative"===e?.type||"temporal"===e?.type}function Sr(e,t){if(!e||!t)return;let r=vr(t,e);return"string"==typeof r?r:"string"==typeof r?.semanticType?r.semanticType:void 0}function Wr(e,t,r){if("temporal"===e?.type)return!0;let s=Sr(t,r);return!!s&&/date|time|year|month|quarter|week/i.test(s)}function Lr(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Br(e){return"string"==typeof e&&e.length>0?e:void 0}function Rr(e){return"boolean"==typeof e?e:void 0}function Pr(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 $r(e,t,r,s){let o=t||r;if(!o)return;let i=o.width,a=o.height;t&&r&&(t.width>r.width&&(i=r.width,s.push("chart_spec.canvasSize.width is smaller than baseSize.width; clamped Semiotic width to the canvas ceiling.")),t.height>r.height&&(a=r.height,s.push("chart_spec.canvasSize.height is smaller than baseSize.height; clamped Semiotic height to the canvas ceiling."))),Number.isFinite(i)&&(e.width=i),Number.isFinite(a)&&(e.height=a)}function Mr(e,t){let r=Br(t?.title);r&&(e.title=r)}function Ir(e,t,r){if(!t)return;let s=t.toLowerCase(),o=vr(Pi,s);o?e.colorScheme=o:r.push(`Flint color scheme "${t}" is not mapped to a Semiotic categorical colorScheme.`)}function Er(e,t,r){if(!t)return;let s=t.toLowerCase();$i.has(s)?e.colorScheme=s:r.push(`Flint heatmap color scheme "${t}" is not available in Semiotic's Heatmap colorScheme enum.`)}function Nr(e,t,r,s){r&&("xy"===s?(t.x&&vr(r,t.x)&&(e.xLabel=vr(r,t.x)),t.y&&vr(r,t.y)&&(e.yLabel=vr(r,t.y))):(t.category&&vr(r,t.category)&&(e.categoryLabel=vr(r,t.category)),t.value&&vr(r,t.value)&&(e.valueLabel=vr(r,t.value))))}function _r(e){let t=e.x,r=e.y,s=Cr(e,"x"),o=Cr(e,"y");return Ar(t)&&!Ar(r)?{category:s,value:o,valueEncoding:r}:Ar(r)&&!Ar(t)||wr(t)&&!wr(r)&&o?{category:o,value:s,valueEncoding:t,orientation:"horizontal"}:{category:s,value:o,valueEncoding:r}}function Tr(e){return"count"===e||"sum"===e||"mean"===e?e:"average"===e?"mean":void 0}function Or(e,t,r,s,o){let i=Tr(s);if(!i)return{data:e,valueAccessor:r};if(!e)return o.push(`aggregate: "${s}" requires inline data.values; leaving the requested value accessor unchanged.`),{data:e,valueAccessor:r||"value"};if("count"!==i&&!r)return o.push(`aggregate: "${s}" requires an encoded value field; leaving data unaggregated.`),{data:e,valueAccessor:r};let a=/* @__PURE__ */new Map,l=t.filter(e=>!!e);for(let t of e){let e={};for(let r of l)e[r]=t[r];let s=JSON.stringify(e),o=a.get(s);if(o||(o={keys:e,values:[],count:0},a.set(s,o)),o.count+=1,r){let e=Number(t[r]);Number.isFinite(e)&&o.values.push(e)}}let n=[];for(let e of a.values()){let t=e.count;"sum"===i?t=e.values.reduce((e,t)=>e+t,0):"mean"===i&&(t=e.values.length>0?e.values.reduce((e,t)=>e+t,0)/e.values.length:0),n.push({...e.keys,value:t})}return{data:n,valueAccessor:"value"}}function Fr(e,t){t&&(e.data=t)}function zr(e,t,r){let s=Br(t?.interpolate);if(!s)return;let o=vr(Ri,s);o?e.curve=o:r.push(`Flint interpolate "${s}" is not mapped to a Semiotic curve.`)}function Dr(e,t,r,s){if(!t)return;let o=/* @__PURE__ */new Set([...r,"title"]),i=Object.keys(t).filter(e=>!o.has(e));i.length>0&&s.push(`Flint chartProperties not mapped for ${e}: ${i.join(", ")}.`)}function jr(e,t,r){if(!t)return;let s=new Set(vr(Ii,e)??[]),o={};for(let[e,r]of Object.entries(t)){let t=vr(Mi,e)||e;(!s.has(t)||Array.isArray(r))&&(o[e]=r)}if(0===Object.keys(o).length)return;let i=Object.keys(o),a=i.filter(e=>"column"===e||"row"===e);a.length>0&&r.push(`Flint facet channel(s) ${a.join(", ")} are not supported by this adapter; render multiple Semiotic charts instead.`);let l=i.filter(e=>{let t=vr(Mi,e)||e;return"column"!==e&&"row"!==e&&!s.has(t)});return l.length>0&&r.push(`Flint encoding channel(s) not mapped for ${e}: ${l.join(", ")}.`),o}function Ur(e,t,r,s,o,i,a){let l={...s},n=_r(t),c="groupedBar"===e?Cr(t,"group")||Cr(t,"color"):Cr(t,"color")||Cr(t,"group"),d=Or(r,[n.category,c],n.value,n.valueEncoding?.aggregate,a);Fr(l,d.data),n.category&&(l.categoryAccessor=n.category),d.valueAccessor&&(l.valueAccessor=d.valueAccessor),n.orientation&&(l.orientation=n.orientation),Nr(l,{category:n.category,value:n.value},i,"ordinal");let u=Lr(o?.cornerRadius);void 0!==u&&(l.roundedTop=u);let f=Br(o?.stackMode);if("normalize"===f?l.normalize=!0:f&&"stacked"!==f&&a.push(`Flint stackMode "${f}" is not supported by Semiotic ${e}; leaving default stacking behavior.`),Ir(l,t.color?.scheme,a),"groupedBar"===e)return c&&(l.groupBy=c,l.colorBy=c,l.showLegend=!0),{component:"GroupedBarChart",props:l,supportedProperties:["cornerRadius"]};if("stackedBar"===e)return c?(l.stackBy=c,l.colorBy=c,l.showLegend=!0,{component:"StackedBarChart",props:l,supportedProperties:["cornerRadius","stackMode"]}):(a.push("Stacked Bar Chart has no color/group series field; emitted a BarChart instead."),{component:"BarChart",props:l,supportedProperties:["cornerRadius","stackMode"]});let y=Cr(t,"color");return y&&(l.colorBy=y),{component:"BarChart",props:l,supportedProperties:["cornerRadius"]}}function Gr(e,t,r,s,o,i,a,l){let n={...s},c=Cr(t,"x"),d=Cr(t,"y"),u=Cr(t,"color"),f=Cr(t,"detail"),y=Cr(t,"size"),p=Cr(t,"shape"),h=Or(r,[c,u||f],d,t.y?.aggregate,l),m=Wr(t.x,c,i),g=Wr(t.y,d,i),k=h.data;if(m){let e=Y(k,c);k=e.data,e.failed&&Pr(c,"x",l)}if(g){let e=Y(k,h.valueAccessor);k=e.data,e.failed&&Pr(h.valueAccessor,"y",l)}if(Fr(n,k),c&&(n.xAccessor=c),h.valueAccessor&&(n.yAccessor=h.valueAccessor),m&&(n.xScaleType="time"),g&&(n.yScaleType="time"),Nr(n,{x:c,y:d},a,"xy"),"line"===e){(u||f)&&(n.lineBy=u||f,n.colorBy=u||f),zr(n,o,l);let e=Rr(o?.showPoints);return void 0!==e&&(n.showPoints=e),{component:"LineChart",props:n,supportedProperties:["interpolate","showPoints"]}}if("area"===e){zr(n,o,l);let e=Lr(o?.opacity);void 0!==e&&(n.areaOpacity=e);let t=Br(o?.stackMode);return"normalize"===t?n.normalize=!0:t&&"stacked"!==t&&l.push(`Flint area stackMode "${t}" is not supported by Semiotic; leaving default stacking behavior.`),u?(n.areaBy=u,n.colorBy=u,{component:"StackedAreaChart",props:n,supportedProperties:["interpolate","opacity","stackMode"]}):{component:"AreaChart",props:n,supportedProperties:["interpolate","opacity"]}}if(u&&(n.colorBy=u),y){n.sizeBy=y,p&&l.push("Flint shape encoding is not mapped for BubbleChart; Semiotic only maps shape onto Scatterplot in this adapter.");let e=Lr(o?.opacity);return void 0!==e&&(n.bubbleOpacity=e),Ir(n,t.color?.scheme,l),{component:"BubbleChart",props:n,supportedProperties:["opacity"]}}p&&(n.symbolBy=p);let v=Lr(o?.opacity);return void 0!==v&&(n.pointOpacity=v),Ir(n,t.color?.scheme,l),{component:"Scatterplot",props:n,supportedProperties:["opacity"]}}function Vr(e,t,r,s,o,i){let a={...r},l=Cr(e,"x"),n=Cr(e,"y"),c=Cr(e,"color");Fr(a,t),l&&(a.xAccessor=l),n&&(a.yAccessor=n),c&&(a.valueAccessor=c);let d=Rr(s?.showTextLabels);return void 0!==d&&(a.showValues=d),Nr(a,{x:l,y:n},o,"xy"),Er(a,e.color?.scheme||Br(s?.colorScheme),i),{component:"Heatmap",props:a,supportedProperties:["showTextLabels","colorScheme"]}}function Hr(e,t,r,s,o,i){let a={...s},l=Cr(t,"color"),n=Or(r,[l],Cr(t,"size")||Cr(t,"angle")||Cr(t,"y"),t.size?.aggregate||t.angle?.aggregate||t.y?.aggregate,i);Fr(a,n.data),l&&(a.categoryAccessor=l),n.valueAccessor&&(a.valueAccessor=n.valueAccessor);let c=Lr(o?.innerRadius),d=/donut/i.test(e)||void 0!==c&&c>0;d&&void 0!==c&&(a.innerRadius=c);let u=Lr(o?.cornerRadius);return void 0!==u&&(a.cornerRadius=u),null!=o?.sortSlices&&i.push("Flint sortSlices is not mapped; preserve or sort slice order before calling unstable_fromFlintChart()."),Ir(a,t.color?.scheme,i),{component:d?"DonutChart":"PieChart",props:a,supportedProperties:["innerRadius","cornerRadius","sortSlices"]}}function qr(e,t,r,s){let o={...r},i=Cr(e,"x")||Cr(e,"y"),a=Cr(e,"color");Fr(o,t),i&&(o.valueAccessor=i),a&&(o.categoryAccessor=a,o.colorBy=a);let l=Lr(s?.binCount);return void 0!==l&&l>0&&(o.bins=l),{component:"Histogram",props:o,supportedProperties:["binCount"]}}function Yr(e,t,r,s,o,i){let a={...r},l=_r(e);Fr(a,t),l.category&&(a.categoryAccessor=l.category),l.value&&(a.valueAccessor=l.value),l.orientation&&(a.orientation=l.orientation);let n=Cr(e,"color");n&&(a.colorBy=n);let c=Rr(s?.showOutliers);void 0!==c&&(a.showOutliers=c);let d=Br(s?.whiskerMethod);return d&&"iqr"!==d&&i.push(`Flint whiskerMethod "${d}" is not mapped; Semiotic BoxPlot keeps its default whisker calculation.`),Nr(a,{category:l.category,value:l.value},o,"ordinal"),{component:"BoxPlot",props:a,supportedProperties:["showOutliers","whiskerMethod"]}}function Qr(e){let t=[],r=e.chart_spec,s=r?.chartType,o=xr(s),i=r?.chartProperties,a=Array.isArray(e.data?.values)?e.data.values:void 0,l="string"==typeof e.data?.url?e.data.url:void 0,n=br(r?.encodings,t),c={};l&&t.push("data.url is preserved in flint.dataUrl but not fetched; resolve it to data.values before rendering."),o||t.push(`Unsupported Flint chartType "${s}". Defaulting to Scatterplot.`),$r(c,r?.baseSize,r?.canvasSize,t),Mr(c,i);let d,u=o||"scatter";switch(u){case"bar":case"groupedBar":case"stackedBar":d=Ur(u,n,a,c,i,e.field_display_names,t);break;case"line":case"area":case"scatter":d=Gr(u,n,a,c,i,e.semantic_types,e.field_display_names,t);break;case"heatmap":d=Vr(n,a,c,i,e.field_display_names,t);break;case"pie":d=Hr(s,n,a,c,i,t);break;case"histogram":d=qr(n,a,c,i);break;case"boxplot":d=Yr(n,a,c,i,e.field_display_names,t)}Dr(u,i,d.supportedProperties,t);let f=jr(u,r?.encodings,t),y={component:d.component,props:d.props,version:"1",createdAt:/* @__PURE__ */(new Date).toISOString(),flint:{chartType:s||"",...e.semantic_types?{semanticTypes:e.semantic_types}:{},...e.field_display_names?{fieldDisplayNames:e.field_display_names}:{},...i?{chartProperties:i}:{},...r?.baseSize?{baseSize:r.baseSize}:{},...r?.canvasSize?{canvasSize:r.canvasSize}:{},...l?{dataUrl:l}:{},...e.options?{options:e.options}:{},...f?{unmappedEncodings:f}:{}}};if(t.length>0){y.warnings=t;for(let e of t)console.warn("[semiotic/fromFlintChart] "+e)}return y}function Zr(e){let t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;let r=t.slice(4,-1),s=r.indexOf(",");if(-1===s){let e=r.trim();return e.startsWith("--")?{name:e}:null}let o=r.slice(0,s).trim(),i=r.slice(s+1).trim();return o.startsWith("--")?{name:o,fallback:i||void 0}:null}function Xr(e,t){if(!t)return t;let r=Zr(t);if(!r)return t;let s=()=>r.fallback?Xr(e,r.fallback):t,o=e.canvas;if(!o)return s();let i=Ei.get(o);(!i||0!==i.version)&&(i={version:0,map:/* @__PURE__ */new Map},Ei.set(o,i));let a=i.map.get(t);if(void 0!==a)return a;let l=getComputedStyle(o).getPropertyValue(r.name).trim()||s()||t;return i.map.set(t,l),l}function Kr(e,t,r){if(!t)return r.fallback;for(let s of r.names){let r=t.getPropertyValue(s).trim();if(r)return Xr(e,r)??r}return r.fallback}function Jr(e,t){let r=Math.max(0,Math.min(1,t)),s=e.trim(),o=s.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(o){let[,e,t,s]=o;return Jr(`#${e}${e}${t}${t}${s}${s}`,r)}let i=s.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(i){let[,e,t,s]=i;return`rgba(${parseInt(e,16)}, ${parseInt(t,16)}, ${parseInt(s,16)}, ${r})`}let a=s.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(a)return`rgba(${a[1]}, ${r})`;let l=s.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return l?`rgba(${l[1]}, ${r})`:s}function es(e){let t=e.canvas,r="function"==typeof getComputedStyle&&t?getComputedStyle(t):null,s=Kr(e,r,_i.primary),o=Kr(e,r,_i.danger),i=Kr(e,r,_i.warning),a=Kr(e,r,_i.success),l=Kr(e,r,_i.border),n=Kr(e,r,_i.background),c=Kr(e,r,_i.text),d=Kr(e,r,_i.textSecondary),u=Kr(e,r,_i.focus),f=Kr(e,r,_i.grid);return{annotationBackground:Jr(n,.94),annotationStroke:l,annotationText:c,background:n,border:l,closedWindowFill:Jr(o,.08),closedWindowStroke:Jr(o,.55),danger:o,focus:u,grid:f,gutterFill:Jr(d,.14),lateFill:i,openWindowFill:Jr(s,.07),openWindowStroke:Jr(s,.3),primary:s,selectedFill:i,selectedStroke:u,success:a,text:c,textSecondary:d,warning:i}}function ts(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 rs(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 ss(e,t,r,s){let o=e-(t+r+s);return{charge:e,live:t,queued:r,sedimented:s,unaccounted:o,balanced:0===o}}function os(e,t={}){let r=t.bodies??ts(e),s=r.filter(e=>e.sleeping).length,o=e.queue.length,i=e.sediment.reduce((e,t)=>e+t.count,0),a="settled"===e.simulationState&&0===o&&s===r.length,l=[];a||l.push("PHYSICS_NOT_SETTLED"),o>0&&l.push("PHYSICS_QUEUE_UNDRAINED");let n=null!=t.charge&&Number.isFinite(t.charge)?ss(t.charge,r.length,o,i):void 0;return n&&!n.balanced&&l.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:r.length,sleepingCount:s,settled:a,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:rs(t.projectionRows),queuedCount:o,sedimentedCount:i,...n?{ledger:n}:{},warnings:l}}function is(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function as(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 ls(e,t,r){let s="function"==typeof t?t(e,r):t;return{...Ti,...s??{}}}function ns(e,t={},r={index:0,simulationState:"settled"}){let s=is(e),o={label:t.getBodyLabel?.(e)??as(e)},i={style:ls(e,t.bodyStyle,r),datum:s,accessibleDatum:s,accessibility:o,_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,...i}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...i}}function cs(e,t={},r="settled"){return e.map((e,s)=>ns(e,t,{index:s,simulationState:r}))}function ds(e,t={}){let r=e.settle(t.maxSteps),s=e.readBodies(),o=e.snapshot();return{snapshot:o,bodies:s,sceneNodes:cs(s,t,o.simulationState),evidence:os(o,{bodies:s,projectionRows:t.projectionRows,stepsRun:r,charge:t.charge}),stepsRun:r}}function us(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function fs(e,t){let{background:r="transparent",stroke:s="#000",lineWidth:o=1.5,spacing:i=6,angle:a=45,lineOpacity:l=1}=e,n=Math.max(8,Math.ceil(2*i));/* @__PURE__ */
4
4
  return Di("pattern",{id:t,width:n,height:n,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[r&&"transparent"!==r&&/* @__PURE__ */zi("rect",{width:n,height:n,fill:r}),
5
5
  /* @__PURE__ */zi("line",{x1:0,y1:0,x2:0,y2:n,stroke:s,strokeWidth:o,strokeOpacity:l}),