@skdx/web-components-charts 0.38.0 → 0.39.0

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/dist/area.cjs +31 -31
  2. package/dist/area.js +11 -11
  3. package/dist/bar.cjs +31 -31
  4. package/dist/bar.js +11 -11
  5. package/dist/boxplot.cjs +8 -8
  6. package/dist/boxplot.js +9 -9
  7. package/dist/bubble.cjs +9 -9
  8. package/dist/bubble.js +10 -10
  9. package/dist/bullet.cjs +12 -12
  10. package/dist/bullet.js +13 -13
  11. package/dist/bump.cjs +7 -7
  12. package/dist/bump.js +8 -8
  13. package/dist/candlestick.cjs +34 -34
  14. package/dist/candlestick.js +34 -34
  15. package/dist/chord.cjs +35 -35
  16. package/dist/chord.js +21 -21
  17. package/dist/circle-packing.cjs +16 -16
  18. package/dist/circle-packing.js +30 -30
  19. package/dist/combo.cjs +31 -31
  20. package/dist/combo.js +11 -11
  21. package/dist/dumbbell.cjs +21 -21
  22. package/dist/dumbbell.js +24 -24
  23. package/dist/funnel.cjs +7 -7
  24. package/dist/funnel.js +7 -7
  25. package/dist/gantt.cjs +7 -7
  26. package/dist/gantt.js +8 -8
  27. package/dist/gauge.cjs +6 -6
  28. package/dist/gauge.js +6 -6
  29. package/dist/heatmap.cjs +9 -9
  30. package/dist/heatmap.js +10 -10
  31. package/dist/histogram.cjs +30 -30
  32. package/dist/histogram.js +11 -11
  33. package/dist/icicle.cjs +16 -16
  34. package/dist/icicle.js +16 -16
  35. package/dist/index.cjs +33 -33
  36. package/dist/index.js +17 -17
  37. package/dist/line.cjs +31 -31
  38. package/dist/line.js +11 -11
  39. package/dist/linear-gauge.cjs +12 -12
  40. package/dist/linear-gauge.js +13 -13
  41. package/dist/map.cjs +6 -6
  42. package/dist/map.js +6 -6
  43. package/dist/marimekko.cjs +17 -17
  44. package/dist/marimekko.js +20 -20
  45. package/dist/network.cjs +14 -14
  46. package/dist/network.js +13 -13
  47. package/dist/organization.cjs +10 -10
  48. package/dist/organization.js +14 -14
  49. package/dist/parallel.cjs +6 -6
  50. package/dist/parallel.js +6 -6
  51. package/dist/pareto.cjs +30 -30
  52. package/dist/pareto.js +12 -12
  53. package/dist/pie.cjs +6 -6
  54. package/dist/pie.js +6 -6
  55. package/dist/polar-area.cjs +7 -7
  56. package/dist/polar-area.js +7 -7
  57. package/dist/radar.cjs +7 -7
  58. package/dist/radar.js +6 -6
  59. package/dist/radial.cjs +6 -6
  60. package/dist/radial.js +6 -6
  61. package/dist/range.cjs +31 -31
  62. package/dist/range.js +15 -15
  63. package/dist/sankey.cjs +10 -10
  64. package/dist/sankey.js +15 -15
  65. package/dist/scatter.cjs +31 -31
  66. package/dist/scatter.js +12 -12
  67. package/dist/sunburst.cjs +28 -28
  68. package/dist/sunburst.js +8 -8
  69. package/dist/swarm.cjs +16 -16
  70. package/dist/swarm.js +17 -17
  71. package/dist/timeline.cjs +6 -6
  72. package/dist/timeline.js +6 -6
  73. package/dist/tree.cjs +10 -10
  74. package/dist/tree.js +13 -13
  75. package/dist/treemap.cjs +7 -7
  76. package/dist/treemap.js +7 -7
  77. package/dist/waffle.cjs +31 -31
  78. package/dist/waffle.js +31 -31
  79. package/dist/waterfall.cjs +14 -14
  80. package/dist/waterfall.js +18 -18
  81. package/package.json +3 -3
package/dist/bubble.js CHANGED
@@ -1,5 +1,5 @@
1
- var bn=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var g=(e,n,t,r)=>{for(var i=r>1?void 0:r?xn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(r?a(n,t,i):a(i))||i);return r&&i&&bn(n,t,i),i};import{customElement as Vn,property as D}from"lit/decorators.js";var zt=e=>Number(e.toPrecision(12)),gn,yn=e=>(gn??(gn=new Intl.NumberFormat)).format(zt(e)),vn=e=>{let n=Math.round(Math.abs(e)),t=e<0?"-":"",r=Math.floor(n/3600),i=Math.floor(n%3600/60),o=a=>String(a).padStart(2,"0");return r>0?`${t}${r}h ${o(i)}m`:i>0?`${t}${i}m ${o(n%60)}s`:`${t}${n}s`};function le(e){if(e===void 0)return yn;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,a=d=>i?u=>d(u)+i:d,l=d=>r===void 0?d===void 0?{}:{maximumFractionDigits:d}:{minimumFractionDigits:r,maximumFractionDigits:r},s=d=>{let u=new Intl.NumberFormat(t,d);return a(m=>u.format(zt(m)))},c=d=>{let u=new Intl.DateTimeFormat(t,o?{...d,timeZone:o}:d);return m=>u.format(m)};switch(n){case"integer":return s({maximumFractionDigits:0});case"decimal":return s(l(2));case"percent":return s({style:"percent",...l(0)});case"currency":return s({style:"currency",currency:e.currency??"USD",...l()});case"compact":return s({notation:"compact",...l(1)});case"scientific":return s({notation:"scientific",...l(2)});case"date":return c({dateStyle:"medium"});case"time":return c({timeStyle:"short"});case"datetime":return c({dateStyle:"medium",timeStyle:"short"});case"duration":return a(vn)}}var At=e=>{if(e instanceof Date)return e.getTime();if(typeof e=="number")return e;let n=Number(e);return Number.isFinite(n)&&e.trim()!==""?n:Date.parse(e)};function $e([e,n],[t,r]){let i=n-e;return o=>i===0?t:t+(o-e)/i*(r-t)}function Ce(e,n,t=5){if(e===n)return[e];let r=(n-e)/Math.max(1,t),i=10**Math.floor(Math.log10(r)),o=r/i,a=(o<1.5?1:o<3.5?2:o<7.5?5:10)*i,l=Math.floor(e/a)*a,s=Math.ceil(n/a)*a,c=[];for(let d=l;d<=s+a/2;d+=a)c.push(Ot(d));return c}var Ot=e=>Number(e.toPrecision(12)),h=e=>Number(e.toFixed(2)),K=e=>typeof e=="number"&&Number.isFinite(e);function ce(e){let n=1/0,t=-1/0;for(let r of e)K(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}function Lt(e,n="linear"){if(e.length===0)return"";let t=e[0];if(n==="step"||n==="stepBefore"||n==="stepAfter"){let c=`M${t.x} ${t.y}`;for(let d=1;d<e.length;d++){let u=e[d-1],m=e[d];n==="stepAfter"?c+=`H${m.x}V${m.y}`:n==="stepBefore"?c+=`V${m.y}H${m.x}`:c+=`H${h((u.x+m.x)/2)}V${m.y}H${m.x}`}return c}if(n==="linear"||e.length<3)return`M${e.map(c=>`${c.x} ${c.y}`).join("L")}`;let r=e.length,i=e.slice(1).map((c,d)=>c.x-e[d].x),o=e.slice(1).map((c,d)=>c.y-e[d].y),a=i.map((c,d)=>c===0?0:o[d]/c),l=[a[0]];for(let c=1;c<r-1;c++){let d=a[c-1],u=a[c];l.push(d*u<=0?0:(d+u)/2)}l.push(a[r-2]);for(let c=0;c<r-1;c++){let d=a[c];if(d===0){l[c]=0,l[c+1]=0;continue}let u=l[c]/d,m=l[c+1]/d,b=Math.hypot(u,m);b>3&&(l[c]=3*u*d/b,l[c+1]=3*m*d/b)}let s=`M${t.x} ${t.y}`;for(let c=0;c<r-1;c++){let d=e[c],u=e[c+1],m=i[c]/3;s+=`C${h(d.x+m)} ${h(d.y+m*l[c])} ${h(u.x-m)} ${h(u.y-m*l[c+1])} ${u.x} ${u.y}`}return s}var fe=1e3,me=60*fe,be=60*me,ke=24*be,qn=[fe,5*fe,15*fe,30*fe,me,5*me,15*me,30*me,be,3*be,6*be,12*be,ke,2*ke,7*ke,14*ke];function Rt(e,n){let t=Math.floor(Math.log10(e)),r=Math.ceil(Math.log10(n)),i=r-t<=1?[1,2,5]:[1],o=[];for(let a=t;a<=r;a++)for(let l of i)o.push(Ot(l*10**a));return o.filter(a=>a>=e/1.0001&&a<=n*1.0001)}var wn=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,Mn=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,Sn={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function kn(e,n,t){return e.replace(Mn,(r,i,o)=>{let a=Sn[i];if(a===void 0)return i+o;let s=(o.match(wn)??[]).map((c,d)=>{let u=Number(c);if(a===-1)return String(u+n);if(a===-2)return String(u+t);let m=d%a;return a===7?m===5?String(u+n):m===6?String(u+t):c:String(m%2===0?u+n:u+t)});return i+s.join(" ")})}var Pt=(e,n,t)=>e.map(r=>{switch(r.kind){case"rect":return{...r,x:r.x+n,y:r.y+t};case"circle":return{...r,cx:r.cx+n,cy:r.cy+t};case"line":return{...r,x1:r.x1+n,x2:r.x2+n,y1:r.y1+t,y2:r.y2+t};case"text":return{...r,x:r.x+n,y:r.y+t};case"path":return{...r,d:kn(r.d,n,t)}}});var De=["primary","success","warning","danger","neutral"].flatMap(e=>[500,700].map(n=>`var(--skdx-color-${e}-${n})`)).sort((e,n)=>Number(e.endsWith("700)"))-Number(n.endsWith("700)"))),k={axis:"var(--skdx-color-border-strong)",grid:"var(--skdx-color-border-subtle)",label:"var(--skdx-color-text-muted)",focus:"var(--skdx-color-focus-ring)",positive:"var(--skdx-color-success-500)",negative:"var(--skdx-color-danger-500)",fontFamily:"var(--skdx-font-family)",fontSize:"var(--skdx-font-size-xs)"},Ie=(e="neutral")=>e==="neutral"?k.axis:`var(--skdx-color-${e}-500)`,Fe=(e="neutral")=>e==="neutral"?k.label:e==="primary"?"var(--skdx-color-text-accent)":`var(--skdx-color-text-${e})`,Nt=(e,n)=>n??De[e%De.length];var de={top:16,right:16,bottom:32,left:48};function Bt(e,n,t=de){return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}function xe(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function Dt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var Te=20,$n=120,Ft=e=>{let n=xe(e);return n&&(n.position==="left"||n.position==="right")?n.width??$n:0},je=(e,n=600,t=300)=>({width:(e.width??n)-Ft(e),height:(e.height??t)-(xe(e)?.position==="bottom"?Te:0)}),Gt=e=>{let n=xe(e);return n&&(n.position===void 0||n.position==="top")?Te:0},Y=6.5,ze=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:Nt(n)),jt=(e,n)=>e.hiddenSeries?.includes(n)??!1;function Ge(e,n,t=[],r={},i=10,o=8,a=!1){let l=[],s=r.maxItems,c=s!==void 0&&s>=0&&e.length>s?e.slice(0,s):e,d=e.length-c.length,u=r.interactive??!0,m=o,b=i,x=(p,f,y,v)=>{let C=(f?18:4)+p.length*Y;m>o&&(a||m+C>n-8)&&(m=o,b+=Te),f&&l.push({kind:"rect",part:"legend-swatch",x:m,y:b-5,width:10,height:10,fill:f,opacity:v?.3:void 0,item:y}),l.push({kind:"text",part:"legend-label",x:m+(f?14:0),y:b,text:p,baseline:"middle",fill:v?k.grid:k.label,item:y}),m+=C+12};for(let p of c){let f=t.includes(p.name),y=u?{label:p.name,series:p.name,legend:!0}:void 0;x(r.formatter?.(p.name)??p.name,p.color,y,f)}return d>0&&x(`+${d} more`,void 0,void 0,!1),r.align==="end"?Cn(l,n):l}function Cn(e,n){let t=new Map;for(let i of e){let o=i.kind==="rect"?i.y+5:i.y;t.set(o,[...t.get(o)??[],i])}let r=[];for(let i of t.values()){let o=Math.max(...i.map(l=>l.kind==="rect"?l.x+l.width:l.x+l.text.length*Y)),a=n-8-o;for(let l of i)r.push({...l,x:l.x+a})}return r}var In=(e,n,t={})=>new Set(Ge(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function _e(e,n,t,r=[]){let i=xe(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,a=Dt(e),l=o?.position==="bottom",s=Ft(e),c=e.hiddenSeries??[],d=o?s?Ge(r,1/0,c,o,10,(o.position==="right"?n:0)+8,!0):Ge(r,n,c,o,l?t+10:10):[],u=l?In(r,n,o):0;return{width:n+s,height:l?t+Math.max(1,u)*Te:t,legendOffset:o?.position==="left"?s:void 0,tooltip:a.enabled,tooltipFormatter:a.formatter,axisTooltipFormatter:a.axisFormatter,tooltipPortal:a.portal,tooltipPlacement:a.placement,tooltipAnchored:a.followPointer===!1?!0:void 0,description:e.description,decorative:e.decorative,animate:e.animate===!0?300:e.animate||void 0,responsive:!!e.responsive,shapes:d}}function He(e){let n=e.legendOffset;if(!n)return e;let t=[...Pt(e.shapes.filter(s=>!s.part.startsWith("legend-")),n,0),...e.shapes.filter(s=>s.part.startsWith("legend-"))],r=s=>({...s,x:s.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(s=>s+n),brush:e.hit.brush?{box:r(e.hit.brush.box),window:r(e.hit.brush.window)}:void 0}:void 0,o=e.edit,a=o?{...o,scale:s=>o.scale(s)+n,invert:s=>o.invert(s-n),bars:o.bars.map(s=>({...s,x0:s.x0+n,x1:s.x1+n}))}:void 0,l=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:a,map:l,legendOffset:void 0}}function Ae(e,n,t,r,i,o="auto"){let a=Array.isArray(t)?t:[t],l=Math.max(...a.map(m=>m.length))*Y+12,s=6+a.length*16,c=o==="top"?{x:e-l/2,y:n-s-8}:o==="bottom"?{x:e-l/2,y:n+8}:o==="left"?{x:e-l-8,y:n-s/2}:o==="right"?{x:e+8,y:n-s/2}:{x:e+12,y:n-s-6},d=Math.max(0,Math.min(r-l,c.x)),u=Math.max(0,Math.min(i-s,c.y));return[{kind:"rect",part:"tooltip",x:h(d),y:h(u),width:h(l),height:s,fill:"var(--skdx-color-surface-raised)",stroke:k.axis,rx:3},...a.map((m,b)=>({kind:"text",part:"tooltip-label",x:h(d+6),y:h(u+11+b*16),text:m,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:a.length>1&&b===0?"bold":void 0}))]}function Ze(e,n){let[t,r]=ce(e);return n?[Math.min(0,t),Math.max(0,r)]:[t,r]}function Ee([e,n],t,r=!1,i){let o=typeof r=="boolean"?{scale:r?"log":"linear"}:r,a=le(o.format??i),l=o.min??e,s=o.max??n;o.reversed&&(t=[t[1],t[0]]);let c={id:o.id,position:o.position,options:o};if(o.scale==="sqrt"){let p=w=>Math.sign(w)*Math.sqrt(Math.abs(w)),f=o.nice===!1?[l,s]:Ce(l,s,o.ticks),y=o.min??f[0],v=o.max??f[f.length-1],C=$e([p(y),p(v)],t),z=w=>C(p(w)),O=Ce(y,v,o.ticks).filter(w=>w>=y-1e-9&&w<=v+1e-9);return{...c,scale:z,domain:[y,v],format:a,ticks:(O.length>=2?O:[y,v]).map(w=>({pos:h(z(w)),label:a(w)})),zero:h(z(Math.min(Math.max(0,y),v)))}}if(o.scale==="log"){let p=Math.max(l,Number.EPSILON),f=Math.max(s,p),y=Rt(p,f),v=[Math.log10(p),Math.log10(f)],C=$e(v,t),z=O=>C(Math.log10(Math.max(O,Number.EPSILON)));return{...c,scale:z,domain:v,format:a,ticks:y.map(O=>({pos:h(z(O)),label:a(O)})),zero:h(t[0])}}let d=Ce(l,s,o.ticks),u=[o.min??(o.nice===!1?l:d[0]),o.max??(o.nice===!1?s:d[d.length-1])],m=$e(u,t),b=d.filter(p=>p>=u[0]-1e-9&&p<=u[1]+1e-9),x=(b.length>=2?b:[u[0],u[1]]).map(p=>({pos:h(m(p)),label:a(p)}));return{...c,scale:m,domain:u,format:a,ticks:x,zero:h(m(Math.min(Math.max(0,u[0]),u[1])))}}function _t(e,n,t,r){let i=e.error!==void 0?"error":e.loading?"loading":n?"empty":null;if(!i)return null;let{width:o,height:a}=je(e,t,r),l=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",s=[];return i==="loading"&&s.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:a,fill:"var(--skdx-color-surface-sunken)",rx:4}),s.push({kind:"text",part:`state-${i}`,x:h(o/2),y:h(a/2),text:l,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":k.label}),{..._e(e,o,a),shapes:s,tooltip:!1}}function Ht(e,n={}){let{plot:t,xTicks:r,yTicks:i,baseline:o}=e,a=t.x+t.width,l=t.y+t.height,s=[],c=n.grid??!0,d=(x,p)=>p?{kind:"line",part:"grid",x1:x.pos,x2:x.pos,y1:t.y,y2:l,stroke:k.grid}:{kind:"line",part:"grid",x1:t.x,x2:a,y1:x.pos,y2:x.pos,stroke:k.grid},u=n.x?.tickRotation??0,m=(x,p,f,y)=>u?L(x,p,f,{part:y,anchor:u<0?"end":"start",baseline:"middle",rotate:u}):L(x,p,f,{part:y,anchor:"middle"}),b=(x,p,f,y,v)=>{for(let C of x)s.push(p==="x"?{kind:"line",part:"tick",x1:C.pos,x2:C.pos,y1:f,y2:h(f+y*v),stroke:k.axis}:{kind:"line",part:"tick",x1:f,x2:h(f+y*v),y1:C.pos,y2:C.pos,stroke:k.axis})};if(n.categoryGrid)for(let x of r)s.push(d(x,!n.horizontal));if(n.horizontal){let x=n.axes??[{ticks:i,position:"bottom",offset:0,label:n.yLabel,...n.y}];if(c)for(let p of i)s.push(d(p,!0));x[0]?.showLine!==!1&&s.push({kind:"line",part:"axis",x1:o,x2:o,y1:t.y,y2:l,stroke:k.axis});for(let p of x){let f=p.position==="top"||p.position==="right",y=h(f?t.y-p.offset:l+p.offset),v=f||p.offset>0;p.showLine&&v&&s.push({kind:"line",part:"axis",x1:t.x,x2:a,y1:y,y2:y,stroke:k.axis}),p.showTicks&&b(p.ticks,"x",y,f?-1:1,p.tickSize??4);let C=h(f?y-8:y+20);for(let z of p.ticks)s.push(f?L(z.pos,C,z.label,{part:"x-label-top",anchor:"middle"}):m(z.pos,C,z.label,"x-label"));p.label&&s.push(v?L(4,C,p.label,{part:"axis-title",anchor:"start",baseline:f?void 0:"middle"}):L(4,t.y-6,p.label,{part:"axis-title",anchor:"start"}))}n.x?.showLine&&s.push({kind:"line",part:"axis",x1:n.rtl?a:t.x,x2:n.rtl?a:t.x,y1:t.y,y2:l,stroke:k.axis}),n.x?.showTicks&&b(r,"y",n.rtl?a:t.x,n.rtl?1:-1,n.x.tickSize??4);for(let p of r)s.push(n.rtl?L(a+8,p.pos,p.label,{part:"y-label",anchor:"start",baseline:"middle"}):L(t.x-8,p.pos,p.label,{part:"y-label",anchor:"end",baseline:"middle"}))}else{if(c)for(let p of i)s.push(d(p,!1));n.y?.showLine!==!1&&s.push({kind:"line",part:"axis",x1:t.x,x2:a,y1:o,y2:o,stroke:k.axis});let x=n.axes??[{ticks:i,position:"left",offset:0,label:n.yLabel,...n.y},...n.rightTicks?[{ticks:n.rightTicks,position:"right",offset:0,label:n.rightLabel}]:[]];for(let p of x){let f=p.position==="left",y=f?t.x-p.offset:a+p.offset,v=f?"y-label":"y-label-right";p.showLine&&s.push({kind:"line",part:"axis",x1:h(y),x2:h(y),y1:t.y,y2:l,stroke:k.axis}),p.showTicks&&b(p.ticks,"y",h(y),f?-1:1,p.tickSize??4);for(let C of p.ticks)s.push(L(h(f?y-8:y+8),C.pos,C.label,{part:v,anchor:f?"end":"start",baseline:"middle"}));p.label&&s.push(L(h(f?p.offset===0?4:Math.max(4,y-40):p.offset===0?e.width-4:Math.min(e.width-4,y+40)),t.y-6,p.label,{part:"axis-title",anchor:f?"start":"end"}))}n.x?.showTicks&&b(r,"x",l,1,n.x.tickSize??4);for(let p of r)s.push(m(p.pos,l+(u?12:20),p.label,"x-label"))}return n.xLabel&&s.push(L(h(t.x+t.width/2),e.height-4,n.xLabel,{part:"axis-title",anchor:"middle"})),n.horizontal&&n.rightLabel&&s.push(L(e.width-4,t.y-6,n.rightLabel,{part:"axis-title",anchor:"end"})),s}var L=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:k.label,...r}),Zt=(e,n,t,r,i,o)=>({kind:"circle",part:"point",cx:e,cy:n,r:t,fill:r,title:i,item:o});function Ve(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height,a=s=>Math.max(r.x,Math.min(i,s)),l=s=>Math.max(r.y,Math.min(o,s));for(let s of e??[]){let c=s.color??Ie(s.variant),d=s.color??Fe(s.variant),u={part:"reference-label",fill:d},m=n.horizontal===!0;if("y"in s){let b=h(n.y(s.y,s.axis??"left"));if(m){let x=a(b);t.push(...Vt(x,r.y,o,c,s.label,u))}else{let x=l(b);t.push(...Et(r.x,i,x,c,s.label,u))}}else if("x"in s){let b=n.x(s.x);if(b===void 0)continue;m?t.push(...Et(r.x,i,l(h(b)),c,s.label,u)):t.push(...Vt(a(h(b)),r.y,o,c,s.label,u))}else if("y1"in s){let b=h(n.y(s.y1,s.axis??"left")),x=h(n.y(s.y2,s.axis??"left"));m?t.push(...Ut(a(Math.min(b,x)),a(Math.max(b,x)),r,c,s.label,d)):t.push(...Wt(l(Math.min(b,x)),l(Math.max(b,x)),r,c,s.label,d))}else{let b=n.x(s.x1),x=n.x(s.x2);if(b===void 0||x===void 0)continue;let p=h(Math.min(b,x)),f=h(Math.max(b,x));m?t.push(...Wt(l(p),l(f),r,c,s.label,d)):t.push(...Ut(a(p),a(f),r,c,s.label,d))}}return t}function Et(e,n,t,r,i,o){let a={kind:"line",part:"reference",x1:e,x2:n,y1:t,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[a,L(n-4,t-5,i,{...o,anchor:"end"})]:[a]}function Vt(e,n,t,r,i,o){let a={kind:"line",part:"reference",x1:e,x2:e,y1:n,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[a,L(e+4,n+10,i,{...o,anchor:"start"})]:[a]}function Wt(e,n,t,r,i,o){let a={kind:"rect",part:"reference-area",x:t.x,y:e,width:t.width,height:h(Math.max(0,n-e)),fill:r,opacity:.12,title:i};return i?[a,L(t.x+t.width-4,e+12,i,{part:"reference-label",fill:o,anchor:"end"})]:[a]}function Ut(e,n,t,r,i,o){let a={kind:"rect",part:"reference-area",x:e,y:t.y,width:h(Math.max(0,n-e)),height:t.height,fill:r,opacity:.12,title:i};return i?[a,L(e+4,t.y+12,i,{part:"reference-label",fill:o,anchor:"start"})]:[a]}function qt(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height;for(let a of e??[]){let l=a.color??Ie(a.variant),s=a.color??Fe(a.variant),c=(x,p,f)=>{let y=n.x(x);if(y===void 0)return;let v=n.y(p,f??"left");return n.horizontal?{x:h(v),y:h(y)}:{x:h(y),y:h(v)}},d=a.id??a.label,u=x=>({label:x,id:d,name:a.label});if(a.type==="line"||a.type==="band"){let{type:x,id:p,...f}=a;t.push(...Ve([f],n));continue}if(a.type==="rect"){let x=c(a.x1,a.y1,a.axis),p=c(a.x2,a.y2,a.axis);if(!x||!p)continue;let f=Math.max(r.x,Math.min(x.x,p.x)),y=Math.max(r.y,Math.min(x.y,p.y)),v=a.label??"";t.push({kind:"rect",part:"annotation-rect",x:h(f),y:h(y),width:h(Math.max(0,Math.min(i,Math.max(x.x,p.x))-f)),height:h(Math.max(0,Math.min(o,Math.max(x.y,p.y))-y)),fill:l,opacity:.12,stroke:l,title:v||void 0,item:v?u(v):void 0}),a.label&&t.push(L(h(f+4),h(y+12),a.label,{part:"annotation-label",fill:s}));continue}let m=c(a.x,a.y,a.axis);if(!m)continue;if(a.type==="text"){t.push(L(m.x,m.y,a.text,{part:"annotation-text",fill:s,anchor:"middle",baseline:"middle",title:a.label}));continue}let b=a.label??`${String(a.x)}, ${a.y}`;if(t.push({kind:"circle",part:"annotation-point",cx:m.x,cy:m.y,r:5,fill:l,stroke:"var(--skdx-color-surface-default)",title:b,item:u(b)}),a.type==="callout"&&a.label){let[x,p]=a.offset??[16,-16],f=h(Math.max(r.x,Math.min(i,m.x+x))),y=h(Math.max(r.y,Math.min(o,m.y+p)));t.push({kind:"line",part:"annotation-leader",x1:m.x,y1:m.y,x2:f,y2:y,stroke:l},L(f,y,a.label,{part:"annotation-label",fill:s,anchor:x>=0?"start":"end",baseline:"middle"}))}}return t}var ge=e=>Math.max(0,Math.min(1,e));function Kt(e){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(n){let r=n[1],i=r.length===3?r.split("").map(o=>o+o).join(""):r;return[0,2,4].map(o=>parseInt(i.slice(o,o+2),16))}let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0}function Yt(e,n){if(e.length===0)return k.axis;if(e.length===1)return e[0];let t=ge(n)*(e.length-1),r=Math.min(e.length-2,Math.floor(t)),i=t-r,o=Kt(e[r]),a=Kt(e[r+1]);if(!o||!a)return e[Math.round(t)];let l=s=>Math.round(o[s]+(a[s]-o[s])*i);return`rgb(${l(0)}, ${l(1)}, ${l(2)})`}var Xt=(e,n)=>n!==void 0&&n>=2?Math.min(n-1,Math.floor(ge(e)*n))/(n-1):ge(e);function Qt(e,n,t,r=k.negative,i=String){let[o,a]=ce(n),l=e??{type:"sequential"},s=f=>h(.15+.85*f);if(l.type==="threshold"){let{thresholds:f,colors:y,labels:v}=l,C=O=>{if(typeof O!="number"||!Number.isFinite(O))return;let w=0;for(;w<f.length&&O>=f[w];)w++;return{fill:y[Math.min(w,y.length-1)]??t,opacity:1}},z=y.map((O,w)=>({fill:O,opacity:1,label:v?.[w]??(w===0?`< ${i(f[0]??0)}`:w===f.length?`\u2265 ${i(f[w-1])}`:`${i(f[w-1])} \u2013 ${i(f[w])}`)}));return{color:C,domain:[o,a],swatches:z,kind:"threshold"}}if(l.type==="ordinal"){let f=l.colors?.length?l.colors:[t];return{color:v=>typeof v=="number"&&Number.isFinite(v)?{fill:f[Math.abs(Math.round(v))%f.length],opacity:1}:void 0,domain:[o,a],swatches:f.map((v,C)=>({fill:v,opacity:1,label:String(C)})),kind:"ordinal"}}if(l.type==="diverging"){let[f,y,v]=l.domain??[-Math.max(Math.abs(o),Math.abs(a)),0,Math.max(Math.abs(o),Math.abs(a))],C=l.colors,z=N=>N<y?.5*(N-f)/Math.max(1e-12,y-f):.5+.5*(N-y)/Math.max(1e-12,v-y),O=N=>{let j=Xt(l.reversed?1-ge(N):N,l.steps);if(C&&C.length>=2)return{fill:Yt(C,j),opacity:1};let _=j<.5?r:t,ne=Math.abs(j-.5)*2;return{fill:_,opacity:s(ne)}},w=N=>typeof N=="number"&&Number.isFinite(N)?O(z(N)):void 0,F=l.steps??5,V=Array.from({length:F},(N,j)=>{let _=F===1?.5:j/(F-1),ne=_<.5?f+(y-f)*(_*2):y+(v-y)*((_-.5)*2);return{...O(_),label:i(ne)}});return{color:w,domain:[f,v],swatches:V,kind:"diverging"}}let[c,d]=l.domain??[o,a],u=l.colors,m=f=>{let y=Xt(l.reversed?1-ge(f):f,l.steps);return u&&u.length>=2?{fill:Yt(u,y),opacity:1}:{fill:u?.[0]??t,opacity:s(y)}},b=f=>typeof f!="number"||!Number.isFinite(f)?void 0:m(d===c?1:(f-c)/(d-c)),x=l.steps??5,p=Array.from({length:x},(f,y)=>{let v=x===1?1:y/(x-1);return{...m(v),label:i(c+(d-c)*v)}});return{color:b,domain:[c,d],swatches:p,kind:"sequential"}}var Tn=34,zn=72;function Jt(e){if(!e)return{bottom:0,right:0,options:{}};let n=e===!0?{}:e;return n.orientation==="vertical"?{bottom:0,right:zn,options:n}:{bottom:Tn,right:0,options:n}}function en(e,n,t){let r=typeof t=="string"?{title:t}:t??{},i=r.title,o=e.swatches;if(o.length===0||n.width<=0)return[];if(r.orientation==="vertical"){let d=Math.max(0,n.height-(i?16:0)),u=Math.min(16,d/o.length),m=n.y+(i?16:0),b=o.map((p,f)=>({kind:"rect",part:"color-legend-swatch",x:h(n.x),y:h(m+f*u),width:10,height:h(u),fill:p.fill,opacity:p.opacity,title:p.label})),x=u>=12?1:2;return o.forEach((p,f)=>{f%x!==0&&f!==o.length-1||b.push({kind:"text",part:"color-legend-label",x:h(n.x+14),y:h(m+(f+.5)*u),text:p.label,baseline:"middle",fill:k.label})}),i&&b.push({kind:"text",part:"color-legend-title",x:h(n.x),y:h(n.y+6),text:i,baseline:"middle",fill:k.label}),b}let a=Math.min(n.width/o.length,96),l=n.x+(n.width-a*o.length)/2,s=o.map((d,u)=>({kind:"rect",part:"color-legend-swatch",x:h(l+u*a),y:h(n.y),width:h(a),height:10,fill:d.fill,opacity:d.opacity,title:d.label})),c=e.kind==="threshold"?1:Math.max(1,Math.ceil(o.length*7*Y/Math.max(1,a*o.length)));return o.forEach((d,u)=>{u%c!==0&&u!==o.length-1||s.push({kind:"text",part:"color-legend-label",x:h(l+(u+.5)*a),y:h(n.y+22),text:d.label,anchor:"middle",fill:k.label})}),i&&s.push({kind:"text",part:"color-legend-title",x:h(l-6),y:h(n.y+5),text:i,anchor:"end",baseline:"middle",fill:k.label}),s}var An=1e4,On=e=>Array.isArray(e)?{x:e[0],y:e[1],size:e[2],label:void 0,id:void 0,color:void 0,value:void 0}:{x:e.x,y:e.y,size:e.size,label:e.label,id:e.id,color:e.color,value:e.value};function Ln(e,n,t,r,i,o,a,l){if(r==="circle")return{...Zt(e,n,t,i,o,a),part:l};let s=r==="square"?`M${h(e-t)} ${h(n-t)}h${h(2*t)}v${h(2*t)}h${h(-2*t)}Z`:r==="diamond"?`M${h(e)} ${h(n-t*1.3)}L${h(e+t*1.3)} ${h(n)}L${h(e)} ${h(n+t*1.3)}L${h(e-t*1.3)} ${h(n)}Z`:`M${h(e)} ${h(n-t*1.2)}L${h(e+t*1.15)} ${h(n+t*.9)}L${h(e-t*1.15)} ${h(n+t*.9)}Z`;return{kind:"path",part:l,d:s,fill:i,title:o,item:a}}function tn(e,n){let t=[],r=e.series.map((S,W)=>({name:S.name,id:S.id,symbol:S.symbol??"circle",color:ze(e,W,S.color),data:jt(e,S.name)?[]:S.data.flatMap((A,U)=>{let B=On(A);return K(B.x)&&K(B.y)?[{...B,index:U}]:[]})})),i=e.sampling==="auto"?An:typeof e.sampling=="object"?e.sampling.threshold:1/0,o=r.reduce((S,W)=>S+W.data.length,0),a=o>i?Math.ceil(o/i):1;a>1&&t.push({code:"sampled",severity:"warning",message:`${o} points exceed the sampling threshold of ${i}; every ${a}th point is drawn.`});let l=a>1?r.map(S=>({...S,data:S.data.filter((W,A)=>A%a===0)})):r,s=l.flatMap(S=>S.data),c=_t(e,s.length===0);if(c)return{...c,issues:t};let{width:d,height:u}=je(e),m=e.colorScale?Jt(e.colorLegend):{bottom:0,right:0,options:{}},b=Bt(d,u,{...de,top:de.top+Gt(e)+(e.yAxis?.label?12:0),right:de.right+m.right,bottom:de.bottom+(e.xAxis?.label?14:0)+m.bottom}),x=e.markerSize??3,p=Math.max(0,e.hitRadius??0),f=Math.max(0,e.jitter??0),y=new Map,v=e.colorScale?Qt(e.colorScale,s.map(S=>S.value),ze(e,0),void 0,le(e.format)):void 0,C=Ee(Ze(s.map(S=>S.x),!1),[b.x,b.x+b.width],e.xAxis??{},e.format),z=Ee(Ze(s.map(S=>S.y),!1),[b.y+b.height,b.y],e.yAxis??{},e.format),O=ce(s.map(S=>S.size)),w=e.series.map((S,W)=>({name:S.name,color:ze(e,W,S.color)})),F=_e(e,d,u,w),V=[],N=[],j=[],_=[];for(let S of l){let W=S.data.some(A=>A.size!==void 0);for(let A of S.data){let U=A.index,B=n.describe(S.name,A,C,z),re=W?n.radius(A.size,O):x,Z=h(C.scale(A.x)),q=h(z.scale(A.y));if(f>0){let ae=`${Math.round(Z)},${Math.round(q)}`,ie=y.get(ae)??0;if(y.set(ae,ie+1),ie>0){let se=ie*2.399963;Z=h(Z+f*Math.cos(se)),q=h(q+f*Math.sin(se))}}let Me=v?.color(A.value),E={label:B,id:A.id,series:S.name,seriesId:S.id??S.name,name:A.label,index:U,value:A.y},oe=A.color??Me?.fill??S.color;if(V.push(Ln(Z,q,h(re),S.symbol,oe,B,E,W?n.part:"point")),p>0&&V.push({kind:"circle",part:"hit",cx:Z,cy:q,r:h(re+p),fill:oe,opacity:0,title:B,item:E}),e.labels&&A.label){let ae=A.label.length*Y,ie=Z-ae/2,se=q-re-4;_.some(Se=>Math.abs(Se.y-se)<12&&ie<Se.x+Se.w+4&&ie+ae+4>Se.x)||(_.push({x:ie,y:se,w:ae}),N.push(L(Z,h(se),A.label,{part:"point-label",anchor:"middle",fill:"var(--skdx-color-text-default)"})))}}if(e.trendline&&S.data.length>=2){let A=e.trendline===!0?"linear":e.trendline,U=Rn(S.data.map(B=>[B.x,B.y]),A);if(U){let[B,re]=C.domain,Z=`${S.name} trend${A==="linear"?"":` (${A})`}: r\xB2 ${U.r2.toFixed(2)}`,q=S.color;if(A==="linear")j.push({kind:"line",part:"trendline",x1:h(C.scale(B)),y1:h(z.scale(U.predict(B))),x2:h(C.scale(re)),y2:h(z.scale(U.predict(re))),stroke:q,dash:"5 4",strokeWidth:1.5,title:Z});else{let Me=Array.from({length:40},(E,oe)=>B+(re-B)*oe/39).map(E=>({v:E,p:U.predict(E)})).filter(({p:E})=>Number.isFinite(E)).map(({v:E,p:oe})=>({x:h(C.scale(E)),y:h(z.scale(oe))}));Me.length>1&&j.push({kind:"path",part:"trendline",d:Lt(Me),stroke:q,dash:"5 4",strokeWidth:1.5,title:Z})}}}}let ne={...F,plot:b,xTicks:C.ticks,yTicks:z.ticks,baseline:z.zero},It={plot:b,x:S=>C.scale(At(S)),y:S=>z.scale(S)},fn=Ve(e.references,It),mn=v&&(m.bottom||m.right)?en(v,m.right?{x:b.x+b.width+12,y:b.y,width:m.right,height:b.height}:{x:b.x,y:u-m.bottom+8,width:b.width,height:m.bottom},m.options):[],Tt=n.opacity;return{...F,shapes:[...Ht(ne,{xLabel:e.xAxis?.label,yLabel:e.yAxis?.label}),...fn,...Tt!==void 0&&V.some(S=>S.part===n.part)?V.map(S=>(S.kind==="circle"||S.kind==="path")&&S.part!=="hit"?{...S,opacity:Tt}:S):V,...j,...N,...qt(e.annotations,It),...mn,...F.shapes],issues:t}}function Rn(e,n="linear"){let t;if(n==="polynomial"){let s=0,c=0,d=0,u=0,m=0,b=0,x=0,p=0;for(let[w,F]of e)s+=1,c+=w,d+=w*w,u+=w**3,m+=w**4,b+=F,x+=w*F,p+=w*w*F;let f=w=>w[0]*(w[4]*w[8]-w[5]*w[7])-w[1]*(w[3]*w[8]-w[5]*w[6])+w[2]*(w[3]*w[7]-w[4]*w[6]),v=f([m,u,d,u,d,c,d,c,s]);if(Math.abs(v)<1e-12)return;let C=f([p,u,d,x,d,c,b,c,s])/v,z=f([m,p,d,u,x,c,d,b,s])/v,O=f([m,u,p,u,d,x,d,c,b])/v;t=w=>C*w*w+z*w+O}else{let s=n==="logarithmic"||n==="power"?Math.log:b=>b,c=n==="exponential"||n==="power"?Math.log:b=>b,d=e.filter(([b,x])=>Number.isFinite(s(b))&&Number.isFinite(c(x))),u=Pn(d.map(([b,x])=>[s(b),c(x)]));if(!u)return;let m=n==="exponential"||n==="power"?Math.exp:b=>b;t=b=>m(u.intercept+u.slope*s(b))}let r=t,i=e.filter(([s])=>Number.isFinite(r(s)));if(i.length===0)return;let o=i.reduce((s,[,c])=>s+c,0)/i.length,a=0,l=0;for(let[s,c]of i)a+=(c-r(s))**2,l+=(c-o)**2;return{predict:r,r2:l===0?1:Math.max(0,1-a/l)}}function Pn(e){let n=e.length,t=e.reduce((c,d)=>c+d[0],0)/n,r=e.reduce((c,d)=>c+d[1],0)/n,i=0,o=0,a=0;for(let[c,d]of e)i+=(c-t)**2,o+=(c-t)*(d-r),a+=(d-r)**2;if(i===0)return;let l=o/i,s=a===0?1:o*o/(i*a);return{slope:l,intercept:r-l*t,r2:s}}function Oe(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var We=e=>e.id??e.name??e.series,nn=e=>e.seriesId??e.series;function X(e,n){let t=!1;return n.id!==void 0&&(t=!0,We(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,nn(e)!==n.series&&e.series!==n.series)||n.index!==void 0&&(t=!0,e.index!==n.index)||n.category!==void 0&&(t=!0,e.category!==n.category)?!1:t}function J(e){let n={},t=We(e);t!==void 0&&(n.id=t);let r=nn(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Ue=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function qe(e,n,t){let r=Oe(e),i=J(n),o=r.some(a=>X(n,a));return t==="single"?o?[]:[i]:o?r.filter(a=>!X(n,a)):[...r,i]}var Nn=.2;function Bn(e){let n=k.focus;switch(e.kind){case"rect":return{kind:"rect",part:"selected",x:e.x-1.5,y:e.y-1.5,width:e.width+3,height:e.height+3,fill:"none",stroke:n,rx:e.rx};case"circle":return{kind:"circle",part:"selected",cx:e.cx,cy:e.cy,r:e.r+2.5,fill:"none",stroke:n};case"path":return{kind:"path",part:"selected",d:e.d,fill:"none",stroke:n,strokeWidth:2.5};case"line":return{...e,part:"selected",stroke:n,strokeWidth:(e.strokeWidth??1)+3,title:void 0,item:void 0};case"text":return}}var Dn=(e,n)=>e.kind==="text"?{...e,fill:k.grid}:{...e,opacity:(e.opacity??1)*n};function Ke(e,n){let t=Oe(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:Oe(n.highlighted),i=r[0];if(t.length===0&&!i)return e;let o={highlighted:n.highlightScope?.highlighted??"item",faded:n.highlightScope?.faded??"global"},a=[],l=d=>!i||r.some(u=>X(d,u))?!0:o.highlighted==="series"?r.some(u=>u.series!==void 0&&X(d,{series:u.series})):!1,s=d=>{if(!i||o.faded==="none"||l(d))return!1;if(o.faded==="series"){let u=i.series;return u!==void 0&&X(d,{series:u})}return!0},c=e.shapes.map(d=>{let u=d.item;if(!u||u.legend)return d;if(t.some(m=>X(u,m))){let m=Bn(d);m&&a.push(m)}return s(u)?Dn(d,Nn):d});return a.length?{...e,shapes:[...c,...a]}:{...e,shapes:c}}function Ye(e){let[n,t]=e.sizeRange??[4,24],r=le(e.zAxis?.format??e.format),i=e.zAxis?.label,o=e.xAxis?.label,a=e.yAxis?.label,l=(s,c)=>s?`${s} ${c}`:c;return tn({...e,series:e.series.map(s=>({name:s.name,id:s.id,color:s.color,data:s.data.filter(c=>K(c.x)&&K(c.y)).map(c=>({x:c.x,y:c.y,size:K(c.z)?Math.max(0,c.z):0,label:c.label,id:c.id,color:c.color,value:c.value??c.z}))}))},{part:"bubble",opacity:.7,radius:(s,[,c])=>c>0&&K(s)?Math.max(n,Math.sqrt(s/c)*t):n,describe:(s,c,d,u)=>`${s}${c.label?` ${c.label}`:""}: ${l(o,d.format(c.x))}, ${l(a,u.format(c.y))}, ${l(i,r(c.size??0))}`})}function pe(e,n,t,r,i){let o=e.getBoundingClientRect();return{x:o.width?(n-o.left)*r/o.width:n,y:o.height?(t-o.top)*i/o.height:t}}var Xe=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function rn(e,n){let t=0,r=1/0;return e.xs.forEach((i,o)=>{let a=Math.abs(i-n);a<r&&(r=a,t=o)}),t}function ye(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=rn(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Qe(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[rn(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:k.axis,dash:"3 3"}}function Je(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Xe(r.plot,n,t))return[];let i=Qe(e,n),{rows:o}=ye(e,n),a=e.tooltipAnchored?r.plot.y+8:t;return[i,...Ae(i.x1,a,o,e.width,e.height,e.tooltipPlacement)]}function et(e,n){let t=e.hit;if(!t||t.xs.length===0)return[];let r=t.rows.findIndex(o=>o[0]===n);if(r<0)return[];let i=t.xs[r];return Je(e,i,t.plot.y+8)}function tt(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:s,y:c}=pe(t,r,i,e.width,e.height);if(Xe(e.hit.plot,s,c)){let d=ye(e,s),u=Qe(e,s);if(d&&u)return{lines:d.rows,shapes:[u]}}}let o=n?.closest?.("[data-skdx-part]"),a=e.tooltipFormatter?ee(e,n)?.item:void 0,l=a&&e.tooltipFormatter?.(a)||o&&Array.from(o.children).find(s=>s.tagName.toLowerCase()==="title")?.textContent;return l?{lines:Array.isArray(l)?l:[l],shapes:[]}:{lines:[],shapes:[]}}function on(e,n,t,r,i,o,a){let l=e?.closest?.("[data-skdx-part]"),s=a&&a.tooltipFormatter?ee(a,e)?.item:void 0,c=s&&a?.tooltipFormatter?.(s)||l&&Array.from(l.children).find(x=>x.tagName.toLowerCase()==="title")?.textContent;if(!c)return[];let d=a?.tooltipAnchored?ee(a,e):void 0,u=d?a?.shapes[d.index]:void 0,{x:m,y:b}=u?ve(u):pe(n,t,r,i,o);return Ae(m,b,c,i,o,a?.tooltipPlacement)}function nt(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:a}=pe(t,r,i,e.width,e.height),l=Je(e,o,a);if(l.length>0)return l}return on(n,t,r,i,e.width,e.height,e)}function rt(e,n){let t=ee(e,n);return t&&!t.item.legend?J(t.item):null}var Fn=(e,n)=>{let{x:t,y:r}=ve(e),i=e.kind==="circle"?e.cy:e.kind==="rect"?e.y+e.height/2:r;return t>=n.x&&t<=n.x+n.width&&i>=n.y&&i<=n.y+n.height};function it(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!Fn(i,n))continue;let o=J(i.item),a=JSON.stringify(o);t.has(a)||(t.add(a),r.push(o))}return r}var ot=e=>({kind:"rect",part:"selection-box",x:h(e.x),y:h(e.y),width:h(e.width),height:h(e.height),fill:k.focus,opacity:.12,stroke:k.focus}),Re=(e,n,t,r)=>({x:Math.min(e,t),y:Math.min(n,r),width:Math.abs(t-e),height:Math.abs(r-n)});function an(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let a=e[i],l=e[o];a.y>t!=l.y>t&&n<(l.x-a.x)*(t-a.y)/(l.y-a.y)+a.x&&(r=!r)}return r}function at(e,n){if(n.length<3)return[];let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor")continue;let{x:o,y:a}=ve(i),l=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:a;if(!an(n,o,l))continue;let s=J(i.item),c=JSON.stringify(s);t.has(c)||(t.add(c),r.push(s))}return r}var st=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${h(n.x)} ${h(n.y)}`).join("L")}`:"",fill:k.focus,fillOpacity:.12,stroke:k.focus,dash:"4 3"}),Le=6;function lt(e,n,t){let r=e.edit;if(r){for(let i of r.bars)if(!(t<i.y||t>i.y+i.height||n<i.x0-Le||n>i.x1+Le))return Math.abs(n-i.x0)<=Le?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=Le?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function ct(e,n,t){let r=e.edit;return sn(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function dt(e,n,t){let r=e.edit,i=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;if(!r||n===null||!i||!(t.shiftKey||t.altKey))return;let o=r.bars.find(s=>s.index===n);if(!o)return;let a=t.altKey?t.shiftKey?"start":"end":"move",l=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return sn(r,{bar:o,mode:a},i*l)}function sn(e,{bar:n,mode:t},r){let i=l=>e.snap?Math.round(l/e.snap)*e.snap:l,o=n.start,a=n.end;return t==="move"?(o=i(n.start+r),a=o+(n.end-n.start)):t==="start"?o=Math.min(i(n.start+r),n.end):a=Math.max(i(n.end+r),n.start),{id:n.id,name:n.name,start:o,end:a}}function ut(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:h(Math.min(i,o)),y:h(n.bar.y),width:h(Math.max(1,Math.abs(o-i))),height:h(n.bar.height),fill:k.focus,opacity:.25,stroke:k.focus,rx:2}}var Gn=64,jn=e=>Math.max(1,Math.min(Gn,e));function ht(e,n,t,r){let i=n>0?.8:1.25,o=jn(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:a,scale:l}=e,[s,c]=e.view.center,d=(t-(a.x+a.width/2))/l,u=(r-(a.y+a.height/2))/l,m=e.view.zoom/o;return{center:[s+d*(1-m),e.fromY(e.toY(c)-u*(1-m))],zoom:o}}function pt(e,n,t,r){let{scale:i}=e;return{center:[n.center[0]-t/i,e.fromY(e.toY(n.center[1])+r/i)],zoom:n.zoom}}function ee(e,n){let t=n?.closest?.("[data-skdx-i]"),r=Number(t?.getAttribute("data-skdx-i")),i=Number.isInteger(r)?e.shapes[r]?.item:void 0;return i?{index:r,item:i}:void 0}var Pe=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function ve(e){switch(e.kind){case"rect":return{x:e.x+e.width/2,y:e.y};case"circle":return{x:e.cx,y:e.cy-e.r};case"line":return{x:(e.x1+e.x2)/2,y:Math.min(e.y1,e.y2)};case"text":return{x:e.x,y:e.y};case"path":{let n=/M\s*(-?[\d.]+)[ ,](-?[\d.]+)/.exec(e.d);return n?{x:Number(n[1]),y:Number(n[2])}:{x:0,y:0}}}}function ft(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=k.focus,i;switch(t.kind){case"rect":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-2,width:t.width+4,height:t.height+4,fill:"none",stroke:r,rx:2};break;case"circle":i={kind:"circle",part:"focus",cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:r};break;case"line":i={kind:"line",part:"focus",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:r,strokeWidth:4};break;case"text":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-8,width:t.text.length*Y+4,height:16,fill:"none",stroke:r,rx:2};break;case"path":i={kind:"path",part:"focus",d:t.d,stroke:r,strokeWidth:2,fill:"none"};break}let{x:o,y:a}=ve(t),l=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...l?Ae(h(o),h(a),l,e.width,e.height):[]]}function mt(e,n,t){let r=Pe(e);if(r.length===0)return;let i=n===null?-1:r.indexOf(n);switch(t){case"ArrowRight":case"ArrowDown":return r[Math.min(r.length-1,i+1)];case"ArrowLeft":case"ArrowUp":return r[Math.max(0,i<=0?0:i-1)];case"Home":return r[0];case"End":return r[r.length-1];case"Escape":return null;default:return}}var ue=2,he=(e,n,t)=>{let r=Math.max(ue,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},ln=(e,n)=>!e||e.start<=0&&e.end>=n;function bt(e,n,t){if(e.count<=ue||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,a=n>0?1.25:.8,l=Math.max(ue,Math.min(e.count,Math.round(o*a)));if(l===o)return n>0&&!ln(e.zoom,e.count)?he(r,l,e.count):void 0;let s=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),c=r+s*o;return he(c-s*l,l,e.count)}function xt(e,n,t,r){let i=n.end-n.start,o=Math.max(ue,Math.min(e.count,Math.round(i/Math.max(.05,t)))),a=Math.max(0,Math.min(1,(r-e.plot.x)/Math.max(1,e.plot.width)));return he(n.start+a*i-a*o,o,e.count)}function gt(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return he(n.start-t/i,r,e.count)}function yt(e,n,t){let r=e.brush;if(!r||!Xe(r.box,n,t))return;let i=r.window;if(Math.abs(n-i.x)<=6)return{grab:"left",zoom:e.zoom};if(Math.abs(n-(i.x+i.width))<=6)return{grab:"right",zoom:e.zoom};if(n>i.x&&n<i.x+i.width)return{grab:"move",zoom:e.zoom};let o=e.zoom.end-e.zoom.start,a=(n-r.box.x)/Math.max(1,r.box.width)*e.count;return{grab:"move",zoom:he(a-o/2,o,e.count)}}function vt(e,n,t,r){let i=e.brush;if(!i)return t;let o=r/Math.max(1,i.box.width)*e.count;if(n==="move")return he(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-ue,Math.round(t.start+o))),end:t.end};let a=Math.min(e.count,Math.max(t.start+ue,Math.round(t.end+o)));return{start:t.start,end:a}}function Mt(e,n){switch(n.type){case"svg":return Promise.resolve(wt(e,n.label,n.resolve));case"csv":return Promise.resolve(hn(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=wt(e,n.label,n.resolve);return un(t,e.width,e.height,n.scale,n.background)}}}var Q=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;"),we=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${Q(String(t))}"`).join("");function cn(e){let n=e.title?`<title>${Q(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${we([t,["d",e.d],["fill",e.fill??"none"],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-linecap",e.strokeLinecap],["stroke-linejoin",e.strokeLinejoin],["stroke-dasharray",e.dash],["opacity",e.opacity],["fill-opacity",e.fillOpacity]])}>${n}</path>`;case"rect":return`<rect${we([t,["x",e.x],["y",e.y],["width",e.width],["height",e.height],["rx",e.rx],["fill",e.fill],["stroke",e.stroke],["fill-opacity",e.opacity]])}>${n}</rect>`;case"line":return`<line${we([t,["x1",e.x1],["y1",e.y1],["x2",e.x2],["y2",e.y2],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-dasharray",e.dash],["opacity",e.opacity]])}>${n}</line>`;case"circle":return`<circle${we([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${we([t,["x",e.x],["y",e.y],["text-anchor",e.anchor],["dominant-baseline",e.baseline],["fill",e.fill],["font-weight",e.weight],["transform",e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0]])}>${Q(e.text)}</text>`}}function dn(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${Q(t.id)}" x1="0" y1="0" x2="${t.vertical===!1?1:0}" y2="${t.vertical===!1?0:1}">${t.stops.map(r=>`<stop offset="${r.offset}" stop-color="${Q(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function wt(e,n,t){let r=dn(e)+e.shapes.map(cn).join("");return t&&(r=r.replace(/var\((--[\w-]+)\)/g,(i,o)=>t(o).trim()||i)),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e.width} ${e.height}" width="${e.width}" height="${e.height}" role="img" aria-label="${Q(n)}" font-family="${Q(k.fontFamily)}" font-size="${Q(k.fontSize)}"><title>${Q(n)}</title>${r}</svg>`}function un(e,n,t,r=2,i){return new Promise((o,a)=>{let l=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),s=new Image;s.onload=()=>{URL.revokeObjectURL(l);let c=document.createElement("canvas");c.width=Math.round(n*r),c.height=Math.round(t*r);let d=c.getContext("2d");if(!d)return a(new Error("canvas 2d context unavailable"));i&&(d.fillStyle=i,d.fillRect(0,0,c.width,c.height)),d.drawImage(s,0,0,c.width,c.height),c.toBlob(u=>u?o(u):a(new Error("toBlob failed")),"image/png")},s.onerror=()=>{URL.revokeObjectURL(l),a(new Error("svg could not be decoded"))},s.src=l})}function hn(e){let n=t=>{let r=t==null?"":String(t);return/[",\n\r]/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return e.map(t=>t.map(n).join(",")).join(`\r
2
- `)}function St(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let l=r.rows[0];if(r.rows.length>t)return;let s=["",...l.slice(1).map(d=>d.replace(/:\s[^:]*$/,""))],c=r.rows.map(d=>[d[0],...d.slice(1).map(u=>u.slice(u.lastIndexOf(": ")+2))]);return[s,...c]}let i=e.shapes.flatMap(l=>l.item&&!l.item.legend&&!(l.part==="anchor"&&!l.title)?[l.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(l=>i.some(s=>s[l]!==void 0)),a=(l,s)=>l[s]===void 0?"":String(l[s]);return[o.map(l=>l[0]?.toUpperCase()+l.slice(1)),...i.map(l=>o.map(s=>a(l,s)))]}var kt=new Map;function Ne(e){let n=kt.get(e);if(n)return n.group;let t=new Set,r={},i={current:r,subscribe(o){return t.add(o),()=>{t.delete(o),t.size===0&&kt.delete(e)}},publish(o,a){Object.assign(r,o);for(let l of t)l(o,a)}};return kt.set(e,{group:i,listeners:t}),i}var pn='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',$t=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${pn}{animation:skdx-in var(--skdx-chart-duration,0ms) ease-out;transition:${["x","y","width","height","cx","cy","r","opacity","fill-opacity","d"].map(e=>`${e} var(--skdx-chart-duration,0ms) ease-out`).join(",")}}@media (prefers-reduced-motion:reduce){${pn}{animation:none;transition:none}}`;function Ct(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}import{css as _n,html as te,LitElement as Hn,nothing as R,svg as G}from"lit";import{property as M,state as H}from"lit/decorators.js";import{ifDefined as T}from"lit/directives/if-defined.js";var Zn={fromAttribute:()=>!1},$=class extends Hn{constructor(){super(...arguments);this.legend=!1;this.tooltip=!0;this.selectionMode="none";this.loading=!1;this.decorative=!1;this.accessibleTable=!1;this.zoomable=!1;this.editable=!1;this.crossFilter=!1;this.animated=!1;this.responsive=!1;this.tip=[];this.overlay=[];this.portal=null;this.highlightState=null;this.crossState=null;this.lastCross=null;this.pointers=new Map;this.hover=null;this.token={};this.focused=null;this.hiddenState=[];this.drag=null;this.onPointerMove=t=>{let r=this.layout;if(!r)return;this.pointers.has(t.pointerId)&&this.pointers.set(t.pointerId,this.viewBox(t,r).x);let i=this.drag;if(i?.grab==="select"){let{x:o,y:a}=this.viewBox(t,r);this.overlay=[ot(Re(i.x,i.y,o,a))];return}if(i?.grab==="lasso"){let{x:o,y:a}=this.viewBox(t,r);i.points=[...i.points??[],{x:o,y:a}],this.overlay=[st(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=ct(r,i.gantt,o-i.x),this.overlay=[ut(r,i.gantt,i.change)];return}if(i?.grab==="map"){if(!r.map||!i.view)return;let{x:o,y:a}=this.viewBox(t,r);this.setView(pt(r.map,i.view,o-i.x,a-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[a,l]=[...this.pointers.values()];if(a===void 0||l===void 0||!i.distance)return;this.setZoom(xt(r.hit,i.zoom,Math.abs(a-l)/i.distance,(a+l)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?gt(r.hit,i.zoom,o-i.x):vt(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:a}=tt(r,t.target,t.currentTarget,t.clientX,t.clientY);this.tip=a,this.portal=o.length?{x:t.clientX,y:t.clientY,lines:o}:null}else{let o=nt(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(rt(r,t.target)),this.syncId&&r.hit?.crosshair){let o=ye(r,this.viewBox(t,r).x);this.shareCrosshair(o?r.hit.rows[o.index]?.[0]??null:null)}};this.onPointerDown=t=>{let r=this.layout;if(!r||t.button!==0)return;let{x:i,y:o}=this.viewBox(t,r),a=ee(r,t.target)?.item.legend,l=this.canEdit(r)?lt(r,i,o):void 0;if(l){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:l},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.brushing()&&!a){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:this.selectionMode==="lasso"?"lasso":"select",points:[{x:i,y:o}]},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.canPan(r)&&r.map){let c=r.map.plot;if(i<c.x||i>c.x+c.width||o<c.y||o>c.y+c.height)return;this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"map",view:r.map.view},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}let s=r.hit;if(!(!s||!this.canZoom(r))){if(this.pointers.set(t.pointerId,i),this.pointers.size===2){let[c,d]=[...this.pointers.values()];this.drag={x:(c+d)/2,y:o,zoom:s.zoom,grab:"pinch",distance:Math.abs(c-d)||1}}else{let c=yt(s,i,o);if(c)this.drag={x:i,y:o,zoom:c.zoom,grab:c.grab},c.zoom!==s.zoom&&this.setZoom(c.zoom);else if(this.zoomable&&i>=s.plot.x&&i<=s.plot.x+s.plot.width&&o>=s.plot.y&&o<=s.plot.y+s.plot.height)this.drag={x:i,y:o,zoom:s.zoom,grab:"pan"};else{this.pointers.delete(t.pointerId);return}}t.currentTarget.setPointerCapture(t.pointerId),this.clearTip()}};this.onPointerUp=t=>{this.pointers.delete(t.pointerId);let r=t.currentTarget;r.hasPointerCapture(t.pointerId)&&r.releasePointerCapture(t.pointerId);let i=this.drag,o=this.layout;if(o&&(i?.grab==="select"||i?.grab==="lasso"||i?.grab==="edit"||i?.grab==="map")){this.overlay=[];let{x:a,y:l}=this.viewBox(t,o);if(Math.abs(a-i.x)>2||Math.abs(l-i.y)>2){i.grab==="select"?this.setSelected(it(o,Re(i.x,i.y,a,l))):i.grab==="lasso"?this.setSelected(at(o,i.points??[])):i.grab==="edit"&&i.change&&this.emit("skdx-task-change",i.change),this.drag={...i,distance:-1};return}this.drag=null;return}(this.pointers.size===0||this.drag?.grab==="pinch")&&(this.drag=null)};this.onWheel=t=>{let r=this.layout;if(!r)return;let{x:i,y:o}=this.viewBox(t,r);if(r.map&&this.canPan(r)){let s=r.map.plot;if(i<s.x||i>s.x+s.width||o<s.y||o>s.y+s.height)return;t.preventDefault(),this.setView(ht(r.map,t.deltaY,i,o));return}let a=r.hit;if(!a||!this.canZoom(r)||o<a.plot.y||o>a.plot.y+a.plot.height)return;let l=bt(a,t.deltaY,i);l&&(t.preventDefault(),this.setZoom(l))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=ee(this.layout,t.target);r&&(r.item.range?this.setZoom(r.item.range):r.item.legend&&r.item.series!==void 0?this.toggle(r.item.series):(this.select(r.item),this.emit("skdx-item-click",r.item)))};this.onKeyDown=t=>{let r=this.layout;if(!r)return;if((t.key==="Enter"||t.key===" ")&&this.focused!==null){let l=r.shapes[this.focused]?.item;l&&(t.preventDefault(),this.select(l),this.emit("skdx-item-click",l));return}let i=this.canEdit(r)?dt(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=mt(r,this.focused,t.key);if(o===void 0)return;t.preventDefault(),this.focused=o;let a=o===null?void 0:r.shapes[o]?.item;this.highlight(a?J(a):null)}}connectedCallback(){super.connectedCallback(),!(typeof ResizeObserver>"u")&&(this.observer=new ResizeObserver(([t])=>{let r=Math.floor(t?.contentRect.width??0);r>0&&(this.measured=r)}),this.observer.observe(this))}disconnectedCallback(){this.observer?.disconnect(),this.leave?.(),this.leave=void 0,this.joined=void 0,super.disconnectedCallback()}sized(){let{width:t,height:r,legend:i,tooltip:o,format:a,palette:l,loading:s,error:c,emptyMessage:d,description:u,decorative:m,animated:b,responsive:x,highlighted:p,highlightScope:f,accessibleTable:y}=this;return{...typeof x=="object"&&this.measured!==void 0&&this.measured<(x.breakpoint??480)?x.compact:void 0,width:x&&this.measured?this.measured:t,height:r,animate:b,responsive:x,legend:i,tooltip:o,format:a,palette:l,loading:s,error:c,emptyMessage:d,description:u,decorative:m,highlighted:p===void 0?this.highlightState:p,highlightScope:f,accessibleTable:y,hiddenSeries:this.hiddenSeries??this.hiddenState,zoom:this.zoom??this.zoomState,selected:this.selected??this.selectedState,view:this.view??this.viewState}}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}publish(t){this.syncId&&Ne(this.syncId).publish(t,this.token)}join(){if(this.joined===this.syncId||(this.leave?.(),this.leave=void 0,this.joined=this.syncId,!this.syncId))return;let t=Ne(this.syncId),r=i=>{"highlighted"in i&&(this.highlightState=i.highlighted??null),i.selected&&(this.selectedState=i.selected,this.crossFilter&&(this.highlightState=i.selected.length?i.selected:null)),"zoom"in i&&(this.zoomState=i.zoom),i.hiddenSeries&&(this.hiddenState=i.hiddenSeries),"crosshair"in i&&(this.crossState=i.crosshair??null)};r(t.current),this.leave=t.subscribe((i,o)=>{o!==this.token&&r(i)})}setZoom(t){this.zoomState=t,this.emit("skdx-zoom-change",t),this.publish({zoom:t})}setView(t){this.viewState=t,this.emit("skdx-view-change",t)}setSelected(t){this.selectedState=t,this.emit("skdx-selected-change",t),this.publish({selected:t})}toggle(t){let r=this.hiddenSeries??this.hiddenState,i=r.includes(t)?r.filter(o=>o!==t):[...r,t];this.hiddenState=i,this.emit("skdx-hidden-series-change",i),this.publish({hiddenSeries:i})}highlight(t){let r=this.hover;r===t||r&&t&&Ue(r,t)||(this.hover=t,this.emit("skdx-highlighted-change",t),this.syncId&&(this.highlightState=t,this.publish({highlighted:t})))}select(t){let r=this.selectionMode;r!=="none"&&this.setSelected(qe(this.selected??this.selectedState,t,r==="single"?"single":"multiple"))}shareCrosshair(t){!this.syncId||this.lastCross===t||(this.lastCross=t,this.publish({crosshair:t}))}clearTip(){this.tip=[],this.portal=null,this.shareCrosshair(null)}canZoom(t){return!!(t.hit&&(this.zoomable||t.hit.brush))}canPan(t){return!!(t.map&&this.zoomable)}canEdit(t){return!!(this.editable&&t.edit)}brushing(){return this.selectionMode==="brush"||this.selectionMode==="lasso"}viewBox(t,r){return pe(t.currentTarget,t.clientX,t.clientY,r.width,r.height)}getSvgElement(){return this.renderRoot.querySelector("svg")}getLayout(){return this.layout}resetZoom(){this.setZoom(void 0)}zoomTo(t){this.setZoom(t)}focusItem(t){let r=this.layout;if(!r)return!1;let i=r.shapes.findIndex(o=>o.item&&!o.item.legend&&X(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?Mt(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Ke(He(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let y of o.issues??[])this.emit("skdx-data-issue",y)}let a=this.canZoom(o),l=this.canPan(o),s=this.canEdit(o),c=this.brushing(),d=a||l||s||c,u=!o.decorative&&Pe(o).length>0,m=o.description?`${r}-desc`:void 0,b=Ct(o),x=St(o,this.accessibleTable),p=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,f=this.portal;return te`<svg
1
+ var gn=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var g=(e,n,t,r)=>{for(var i=r>1?void 0:r?yn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(r?a(n,t,i):a(i))||i);return r&&i&&gn(n,t,i),i};import{customElement as Wn,property as D}from"lit/decorators.js";var zt=e=>Number(e.toPrecision(12)),vn,wn=e=>(vn??(vn=new Intl.NumberFormat)).format(zt(e)),Mn=e=>{let n=Math.round(Math.abs(e)),t=e<0?"-":"",r=Math.floor(n/3600),i=Math.floor(n%3600/60),o=a=>String(a).padStart(2,"0");return r>0?`${t}${r}h ${o(i)}m`:i>0?`${t}${i}m ${o(n%60)}s`:`${t}${n}s`};function le(e){if(e===void 0)return wn;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,a=d=>i?u=>d(u)+i:d,l=d=>r===void 0?d===void 0?{}:{maximumFractionDigits:d}:{minimumFractionDigits:r,maximumFractionDigits:r},s=d=>{let u=new Intl.NumberFormat(t,d);return a(m=>u.format(zt(m)))},c=d=>{let u=new Intl.DateTimeFormat(t,o?{...d,timeZone:o}:d);return m=>u.format(m)};switch(n){case"integer":return s({maximumFractionDigits:0});case"decimal":return s(l(2));case"percent":return s({style:"percent",...l(0)});case"currency":return s({style:"currency",currency:e.currency??"USD",...l()});case"compact":return s({notation:"compact",...l(1)});case"scientific":return s({notation:"scientific",...l(2)});case"date":return c({dateStyle:"medium"});case"time":return c({timeStyle:"short"});case"datetime":return c({dateStyle:"medium",timeStyle:"short"});case"duration":return a(Mn)}}var At=e=>{if(e instanceof Date)return e.getTime();if(typeof e=="number")return e;let n=Number(e);return Number.isFinite(n)&&e.trim()!==""?n:Date.parse(e)};function $e([e,n],[t,r]){let i=n-e;return o=>i===0?t:t+(o-e)/i*(r-t)}function Ce(e,n,t=5){if(e===n)return[e];let r=(n-e)/Math.max(1,t),i=10**Math.floor(Math.log10(r)),o=r/i,a=(o<1.5?1:o<3.5?2:o<7.5?5:10)*i,l=Math.floor(e/a)*a,s=Math.ceil(n/a)*a,c=[];for(let d=l;d<=s+a/2;d+=a)c.push(Ot(d));return c}var Ot=e=>Number(e.toPrecision(12)),h=e=>Number(e.toFixed(2)),Y=e=>typeof e=="number"&&Number.isFinite(e);function ce(e){let n=1/0,t=-1/0;for(let r of e)Y(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}function Lt(e,n="linear"){if(e.length===0)return"";let t=e[0];if(n==="step"||n==="stepBefore"||n==="stepAfter"){let c=`M${t.x} ${t.y}`;for(let d=1;d<e.length;d++){let u=e[d-1],m=e[d];n==="stepAfter"?c+=`H${m.x}V${m.y}`:n==="stepBefore"?c+=`V${m.y}H${m.x}`:c+=`H${h((u.x+m.x)/2)}V${m.y}H${m.x}`}return c}if(n==="linear"||e.length<3)return`M${e.map(c=>`${c.x} ${c.y}`).join("L")}`;let r=e.length,i=e.slice(1).map((c,d)=>c.x-e[d].x),o=e.slice(1).map((c,d)=>c.y-e[d].y),a=i.map((c,d)=>c===0?0:o[d]/c),l=[a[0]];for(let c=1;c<r-1;c++){let d=a[c-1],u=a[c];l.push(d*u<=0?0:(d+u)/2)}l.push(a[r-2]);for(let c=0;c<r-1;c++){let d=a[c];if(d===0){l[c]=0,l[c+1]=0;continue}let u=l[c]/d,m=l[c+1]/d,b=Math.hypot(u,m);b>3&&(l[c]=3*u*d/b,l[c+1]=3*m*d/b)}let s=`M${t.x} ${t.y}`;for(let c=0;c<r-1;c++){let d=e[c],u=e[c+1],m=i[c]/3;s+=`C${h(d.x+m)} ${h(d.y+m*l[c])} ${h(u.x-m)} ${h(u.y-m*l[c+1])} ${u.x} ${u.y}`}return s}var fe=1e3,me=60*fe,be=60*me,ke=24*be,Kn=[fe,5*fe,15*fe,30*fe,me,5*me,15*me,30*me,be,3*be,6*be,12*be,ke,2*ke,7*ke,14*ke];function Rt(e,n){let t=Math.floor(Math.log10(e)),r=Math.ceil(Math.log10(n)),i=r-t<=1?[1,2,5]:[1],o=[];for(let a=t;a<=r;a++)for(let l of i)o.push(Ot(l*10**a));return o.filter(a=>a>=e/1.0001&&a<=n*1.0001)}var Sn=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,kn=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,$n={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function Cn(e,n,t){return e.replace(kn,(r,i,o)=>{let a=$n[i];if(a===void 0)return i+o;let s=(o.match(Sn)??[]).map((c,d)=>{let u=Number(c);if(a===-1)return String(u+n);if(a===-2)return String(u+t);let m=d%a;return a===7?m===5?String(u+n):m===6?String(u+t):c:String(m%2===0?u+n:u+t)});return i+s.join(" ")})}var Pt=(e,n,t)=>e.map(r=>{switch(r.kind){case"rect":return{...r,x:r.x+n,y:r.y+t};case"circle":return{...r,cx:r.cx+n,cy:r.cy+t};case"line":return{...r,x1:r.x1+n,x2:r.x2+n,y1:r.y1+t,y2:r.y2+t};case"text":return{...r,x:r.x+n,y:r.y+t};case"path":return{...r,d:Cn(r.d,n,t)}}});var Fe=["primary","success","warning","danger","neutral"].flatMap(e=>[500,700].map(n=>`var(--skdx-color-${e}-${n})`)).sort((e,n)=>Number(e.endsWith("700)"))-Number(n.endsWith("700)"))),k={axis:"var(--skdx-color-border-strong)",grid:"var(--skdx-color-border-subtle)",label:"var(--skdx-color-text-muted)",focus:"var(--skdx-color-focus-ring)",positive:"var(--skdx-color-success-500)",negative:"var(--skdx-color-danger-500)",fontFamily:"var(--skdx-font-family)",fontSize:"var(--skdx-font-size-xs)"},Ie=(e="neutral")=>e==="neutral"?k.axis:`var(--skdx-color-${e}-500)`,Ge=(e="neutral")=>e==="neutral"?k.label:e==="primary"?"var(--skdx-color-text-accent)":`var(--skdx-color-text-${e})`,Nt=(e,n)=>n??Fe[e%Fe.length];var de={top:16,right:16,bottom:32,left:48};function Bt(e,n,t=de){return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}function xe(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function Dt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var Te=20,In=120,Ft=e=>{let n=xe(e);return n&&(n.position==="left"||n.position==="right")?n.width??In:0},ze=(e,n=600,t=300)=>({width:(e.width??n)-Ft(e),height:(e.height??t)-(xe(e)?.position==="bottom"?Te:0)}),Gt=(e,n,t)=>{let r=xe(e);return!r||!(r.position===void 0||r.position==="top")?0:(n?Math.max(1,_t(n,t??ze(e).width,r)):1)*Te},H=6.5,Ae=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:Nt(n)),jt=(e,n)=>e.hiddenSeries?.includes(n)??!1;function je(e,n,t=[],r={},i=10,o=8,a=!1){let l=[],s=r.maxItems,c=s!==void 0&&s>=0&&e.length>s?e.slice(0,s):e,d=e.length-c.length,u=r.interactive??!0,m=o,b=i,x=(p,f,y,v)=>{let C=(f?18:4)+p.length*H;m>o&&(a||m+C>n-8)&&(m=o,b+=Te),f&&l.push({kind:"rect",part:"legend-swatch",x:m,y:b-5,width:10,height:10,fill:f,opacity:v?.3:void 0,item:y}),l.push({kind:"text",part:"legend-label",x:m+(f?14:0),y:b,text:p,baseline:"middle",fill:v?k.grid:k.label,item:y}),m+=C+12};for(let p of c){let f=t.includes(p.name),y=u?{label:p.name,series:p.name,legend:!0}:void 0;x(r.formatter?.(p.name)??p.name,p.color,y,f)}return d>0&&x(`+${d} more`,void 0,void 0,!1),r.align==="end"?Tn(l,n):l}function Tn(e,n){let t=new Map;for(let i of e){let o=i.kind==="rect"?i.y+5:i.y;t.set(o,[...t.get(o)??[],i])}let r=[];for(let i of t.values()){let o=Math.max(...i.map(l=>l.kind==="rect"?l.x+l.width:l.x+l.text.length*H)),a=n-8-o;for(let l of i)r.push({...l,x:l.x+a})}return r}var _t=(e,n,t={})=>new Set(je(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function _e(e,n,t,r=[]){let i=xe(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,a=Dt(e),l=o?.position==="bottom",s=Ft(e),c=e.hiddenSeries??[],d=o?s?je(r,1/0,c,o,10,(o.position==="right"?n:0)+8,!0):je(r,n,c,o,l?t+10:10):[],u=l?_t(r,n,o):0;return{width:n+s,height:l?t+Math.max(1,u)*Te:t,legendOffset:o?.position==="left"?s:void 0,tooltip:a.enabled,tooltipFormatter:a.formatter,axisTooltipFormatter:a.axisFormatter,tooltipPortal:a.portal,tooltipPlacement:a.placement,tooltipAnchored:a.followPointer===!1?!0:void 0,description:e.description,decorative:e.decorative,animate:e.animate===!0?300:e.animate||void 0,responsive:!!e.responsive,shapes:d}}function He(e){let n=e.legendOffset;if(!n)return e;let t=[...Pt(e.shapes.filter(s=>!s.part.startsWith("legend-")),n,0),...e.shapes.filter(s=>s.part.startsWith("legend-"))],r=s=>({...s,x:s.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(s=>s+n),brush:e.hit.brush?{box:r(e.hit.brush.box),window:r(e.hit.brush.window)}:void 0}:void 0,o=e.edit,a=o?{...o,scale:s=>o.scale(s)+n,invert:s=>o.invert(s-n),bars:o.bars.map(s=>({...s,x0:s.x0+n,x1:s.x1+n}))}:void 0,l=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:a,map:l,legendOffset:void 0}}function Oe(e,n,t,r,i,o="auto"){let a=Array.isArray(t)?t:[t],l=Math.max(...a.map(m=>m.length))*H+12,s=6+a.length*16,c=o==="top"?{x:e-l/2,y:n-s-8}:o==="bottom"?{x:e-l/2,y:n+8}:o==="left"?{x:e-l-8,y:n-s/2}:o==="right"?{x:e+8,y:n-s/2}:{x:e+12,y:n-s-6},d=Math.max(0,Math.min(r-l,c.x)),u=Math.max(0,Math.min(i-s,c.y));return[{kind:"rect",part:"tooltip",x:h(d),y:h(u),width:h(l),height:s,fill:"var(--skdx-color-surface-raised)",stroke:k.axis,rx:3},...a.map((m,b)=>({kind:"text",part:"tooltip-label",x:h(d+6),y:h(u+11+b*16),text:m,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:a.length>1&&b===0?"bold":void 0}))]}function Ze(e,n){let[t,r]=ce(e);return n?[Math.min(0,t),Math.max(0,r)]:[t,r]}function Ee([e,n],t,r=!1,i){let o=typeof r=="boolean"?{scale:r?"log":"linear"}:r,a=le(o.format??i),l=o.min??e,s=o.max??n;o.reversed&&(t=[t[1],t[0]]);let c={id:o.id,position:o.position,options:o};if(o.scale==="sqrt"){let p=w=>Math.sign(w)*Math.sqrt(Math.abs(w)),f=o.nice===!1?[l,s]:Ce(l,s,o.ticks),y=o.min??f[0],v=o.max??f[f.length-1],C=$e([p(y),p(v)],t),I=w=>C(p(w)),O=Ce(y,v,o.ticks).filter(w=>w>=y-1e-9&&w<=v+1e-9);return{...c,scale:I,domain:[y,v],format:a,ticks:(O.length>=2?O:[y,v]).map(w=>({pos:h(I(w)),label:a(w)})),zero:h(I(Math.min(Math.max(0,y),v)))}}if(o.scale==="log"){let p=Math.max(l,Number.EPSILON),f=Math.max(s,p),y=Rt(p,f),v=[Math.log10(p),Math.log10(f)],C=$e(v,t),I=O=>C(Math.log10(Math.max(O,Number.EPSILON)));return{...c,scale:I,domain:v,format:a,ticks:y.map(O=>({pos:h(I(O)),label:a(O)})),zero:h(t[0])}}let d=Ce(l,s,o.ticks),u=[o.min??(o.nice===!1?l:d[0]),o.max??(o.nice===!1?s:d[d.length-1])],m=$e(u,t),b=d.filter(p=>p>=u[0]-1e-9&&p<=u[1]+1e-9),x=(b.length>=2?b:[u[0],u[1]]).map(p=>({pos:h(m(p)),label:a(p)}));return{...c,scale:m,domain:u,format:a,ticks:x,zero:h(m(Math.min(Math.max(0,u[0]),u[1])))}}function Ht(e,n,t,r){let i=e.error!==void 0?"error":e.loading?"loading":n?"empty":null;if(!i)return null;let{width:o,height:a}=ze(e,t,r),l=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",s=[];return i==="loading"&&s.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:a,fill:"var(--skdx-color-surface-sunken)",rx:4}),s.push({kind:"text",part:`state-${i}`,x:h(o/2),y:h(a/2),text:l,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":k.label}),{..._e(e,o,a),shapes:s,tooltip:!1}}var Zt=(e,n,t)=>{let r=n.length*H/2;return e+r>t?"end":e-r<0?"start":"middle"};function Et(e,n={}){let{plot:t,xTicks:r,yTicks:i,baseline:o}=e,a=t.x+t.width,l=t.y+t.height,s=[],c=n.grid??!0,d=(x,p)=>p?{kind:"line",part:"grid",x1:x.pos,x2:x.pos,y1:t.y,y2:l,stroke:k.grid}:{kind:"line",part:"grid",x1:t.x,x2:a,y1:x.pos,y2:x.pos,stroke:k.grid},u=n.x?.tickRotation??0,m=(x,p,f,y)=>u?L(x,p,f,{part:y,anchor:u<0?"end":"start",baseline:"middle",rotate:u}):L(x,p,f,{part:y,anchor:Zt(x,f,e.width)}),b=(x,p,f,y,v)=>{for(let C of x)s.push(p==="x"?{kind:"line",part:"tick",x1:C.pos,x2:C.pos,y1:f,y2:h(f+y*v),stroke:k.axis}:{kind:"line",part:"tick",x1:f,x2:h(f+y*v),y1:C.pos,y2:C.pos,stroke:k.axis})};if(n.categoryGrid)for(let x of r)s.push(d(x,!n.horizontal));if(n.horizontal){let x=n.axes??[{ticks:i,position:"bottom",offset:0,label:n.yLabel,...n.y}];if(c)for(let p of i)s.push(d(p,!0));x[0]?.showLine!==!1&&s.push({kind:"line",part:"axis",x1:o,x2:o,y1:t.y,y2:l,stroke:k.axis});for(let p of x){let f=p.position==="top"||p.position==="right",y=h(f?t.y-p.offset:l+p.offset),v=f||p.offset>0;p.showLine&&v&&s.push({kind:"line",part:"axis",x1:t.x,x2:a,y1:y,y2:y,stroke:k.axis}),p.showTicks&&b(p.ticks,"x",y,f?-1:1,p.tickSize??4);let C=h(f?y-8:y+20);for(let I of p.ticks)s.push(f?L(I.pos,C,I.label,{part:"x-label-top",anchor:Zt(I.pos,I.label,e.width)}):m(I.pos,C,I.label,"x-label"));p.label&&s.push(v?L(4,C,p.label,{part:"axis-title",anchor:"start",baseline:f?void 0:"middle"}):L(4,t.y-6,p.label,{part:"axis-title",anchor:"start"}))}n.x?.showLine&&s.push({kind:"line",part:"axis",x1:n.rtl?a:t.x,x2:n.rtl?a:t.x,y1:t.y,y2:l,stroke:k.axis}),n.x?.showTicks&&b(r,"y",n.rtl?a:t.x,n.rtl?1:-1,n.x.tickSize??4);for(let p of r)s.push(n.rtl?L(a+8,p.pos,p.label,{part:"y-label",anchor:"start",baseline:"middle"}):L(t.x-8,p.pos,p.label,{part:"y-label",anchor:"end",baseline:"middle"}))}else{if(c)for(let p of i)s.push(d(p,!1));n.y?.showLine!==!1&&s.push({kind:"line",part:"axis",x1:t.x,x2:a,y1:o,y2:o,stroke:k.axis});let x=n.axes??[{ticks:i,position:"left",offset:0,label:n.yLabel,...n.y},...n.rightTicks?[{ticks:n.rightTicks,position:"right",offset:0,label:n.rightLabel}]:[]];for(let p of x){let f=p.position==="left",y=f?t.x-p.offset:a+p.offset,v=f?"y-label":"y-label-right";p.showLine&&s.push({kind:"line",part:"axis",x1:h(y),x2:h(y),y1:t.y,y2:l,stroke:k.axis}),p.showTicks&&b(p.ticks,"y",h(y),f?-1:1,p.tickSize??4);for(let C of p.ticks)s.push(L(h(f?y-8:y+8),C.pos,C.label,{part:v,anchor:f?"end":"start",baseline:"middle"}));p.label&&s.push(L(h(f?p.offset===0?4:Math.max(4,y-40):p.offset===0?e.width-4:Math.min(e.width-4,y+40)),t.y-6,p.label,{part:"axis-title",anchor:f?"start":"end"}))}n.x?.showTicks&&b(r,"x",l,1,n.x.tickSize??4);for(let p of r)s.push(m(p.pos,l+(u?12:20),p.label,"x-label"))}return n.xLabel&&s.push(L(h(t.x+t.width/2),e.height-4,n.xLabel,{part:"axis-title",anchor:"middle"})),n.horizontal&&n.rightLabel&&s.push(L(e.width-4,t.y-6,n.rightLabel,{part:"axis-title",anchor:"end"})),s}var L=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:k.label,...r}),Vt=(e,n,t,r,i,o)=>({kind:"circle",part:"point",cx:e,cy:n,r:t,fill:r,title:i,item:o});function Ve(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height,a=s=>Math.max(r.x,Math.min(i,s)),l=s=>Math.max(r.y,Math.min(o,s));for(let s of e??[]){let c=s.color??Ie(s.variant),d=s.color??Ge(s.variant),u={part:"reference-label",fill:d},m=n.horizontal===!0;if("y"in s){let b=h(n.y(s.y,s.axis??"left"));if(m){let x=a(b);t.push(...Ut(x,r.y,o,c,s.label,u))}else{let x=l(b);t.push(...Wt(r.x,i,x,c,s.label,u))}}else if("x"in s){let b=n.x(s.x);if(b===void 0)continue;m?t.push(...Wt(r.x,i,l(h(b)),c,s.label,u)):t.push(...Ut(a(h(b)),r.y,o,c,s.label,u))}else if("y1"in s){let b=h(n.y(s.y1,s.axis??"left")),x=h(n.y(s.y2,s.axis??"left"));m?t.push(...Kt(a(Math.min(b,x)),a(Math.max(b,x)),r,c,s.label,d)):t.push(...qt(l(Math.min(b,x)),l(Math.max(b,x)),r,c,s.label,d))}else{let b=n.x(s.x1),x=n.x(s.x2);if(b===void 0||x===void 0)continue;let p=h(Math.min(b,x)),f=h(Math.max(b,x));m?t.push(...qt(l(p),l(f),r,c,s.label,d)):t.push(...Kt(a(p),a(f),r,c,s.label,d))}}return t}function Wt(e,n,t,r,i,o){let a={kind:"line",part:"reference",x1:e,x2:n,y1:t,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[a,L(n-4,t-5,i,{...o,anchor:"end"})]:[a]}function Ut(e,n,t,r,i,o){let a={kind:"line",part:"reference",x1:e,x2:e,y1:n,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[a,L(e+4,n+10,i,{...o,anchor:"start"})]:[a]}function qt(e,n,t,r,i,o){let a={kind:"rect",part:"reference-area",x:t.x,y:e,width:t.width,height:h(Math.max(0,n-e)),fill:r,opacity:.12,title:i};return i?[a,L(t.x+t.width-4,e+12,i,{part:"reference-label",fill:o,anchor:"end"})]:[a]}function Kt(e,n,t,r,i,o){let a={kind:"rect",part:"reference-area",x:e,y:t.y,width:h(Math.max(0,n-e)),height:t.height,fill:r,opacity:.12,title:i};return i?[a,L(e+4,t.y+12,i,{part:"reference-label",fill:o,anchor:"start"})]:[a]}function Yt(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height;for(let a of e??[]){let l=a.color??Ie(a.variant),s=a.color??Ge(a.variant),c=(x,p,f)=>{let y=n.x(x);if(y===void 0)return;let v=n.y(p,f??"left");return n.horizontal?{x:h(v),y:h(y)}:{x:h(y),y:h(v)}},d=a.id??a.label,u=x=>({label:x,id:d,name:a.label});if(a.type==="line"||a.type==="band"){let{type:x,id:p,...f}=a;t.push(...Ve([f],n));continue}if(a.type==="rect"){let x=c(a.x1,a.y1,a.axis),p=c(a.x2,a.y2,a.axis);if(!x||!p)continue;let f=Math.max(r.x,Math.min(x.x,p.x)),y=Math.max(r.y,Math.min(x.y,p.y)),v=a.label??"";t.push({kind:"rect",part:"annotation-rect",x:h(f),y:h(y),width:h(Math.max(0,Math.min(i,Math.max(x.x,p.x))-f)),height:h(Math.max(0,Math.min(o,Math.max(x.y,p.y))-y)),fill:l,opacity:.12,stroke:l,title:v||void 0,item:v?u(v):void 0}),a.label&&t.push(L(h(f+4),h(y+12),a.label,{part:"annotation-label",fill:s}));continue}let m=c(a.x,a.y,a.axis);if(!m)continue;if(a.type==="text"){t.push(L(m.x,m.y,a.text,{part:"annotation-text",fill:s,anchor:"middle",baseline:"middle",title:a.label}));continue}let b=a.label??`${String(a.x)}, ${a.y}`;if(t.push({kind:"circle",part:"annotation-point",cx:m.x,cy:m.y,r:5,fill:l,stroke:"var(--skdx-color-surface-default)",title:b,item:u(b)}),a.type==="callout"&&a.label){let[x,p]=a.offset??[16,-16],f=h(Math.max(r.x,Math.min(i,m.x+x))),y=h(Math.max(r.y,Math.min(o,m.y+p)));t.push({kind:"line",part:"annotation-leader",x1:m.x,y1:m.y,x2:f,y2:y,stroke:l},L(f,y,a.label,{part:"annotation-label",fill:s,anchor:x>=0?"start":"end",baseline:"middle"}))}}return t}var ge=e=>Math.max(0,Math.min(1,e));function Xt(e){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(n){let r=n[1],i=r.length===3?r.split("").map(o=>o+o).join(""):r;return[0,2,4].map(o=>parseInt(i.slice(o,o+2),16))}let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0}function Qt(e,n){if(e.length===0)return k.axis;if(e.length===1)return e[0];let t=ge(n)*(e.length-1),r=Math.min(e.length-2,Math.floor(t)),i=t-r,o=Xt(e[r]),a=Xt(e[r+1]);if(!o||!a)return e[Math.round(t)];let l=s=>Math.round(o[s]+(a[s]-o[s])*i);return`rgb(${l(0)}, ${l(1)}, ${l(2)})`}var Jt=(e,n)=>n!==void 0&&n>=2?Math.min(n-1,Math.floor(ge(e)*n))/(n-1):ge(e);function en(e,n,t,r=k.negative,i=String){let[o,a]=ce(n),l=e??{type:"sequential"},s=f=>h(.15+.85*f);if(l.type==="threshold"){let{thresholds:f,colors:y,labels:v}=l,C=O=>{if(typeof O!="number"||!Number.isFinite(O))return;let w=0;for(;w<f.length&&O>=f[w];)w++;return{fill:y[Math.min(w,y.length-1)]??t,opacity:1}},I=y.map((O,w)=>({fill:O,opacity:1,label:v?.[w]??(w===0?`< ${i(f[0]??0)}`:w===f.length?`\u2265 ${i(f[w-1])}`:`${i(f[w-1])} \u2013 ${i(f[w])}`)}));return{color:C,domain:[o,a],swatches:I,kind:"threshold"}}if(l.type==="ordinal"){let f=l.colors?.length?l.colors:[t];return{color:v=>typeof v=="number"&&Number.isFinite(v)?{fill:f[Math.abs(Math.round(v))%f.length],opacity:1}:void 0,domain:[o,a],swatches:f.map((v,C)=>({fill:v,opacity:1,label:String(C)})),kind:"ordinal"}}if(l.type==="diverging"){let[f,y,v]=l.domain??[-Math.max(Math.abs(o),Math.abs(a)),0,Math.max(Math.abs(o),Math.abs(a))],C=l.colors,I=N=>N<y?.5*(N-f)/Math.max(1e-12,y-f):.5+.5*(N-y)/Math.max(1e-12,v-y),O=N=>{let j=Jt(l.reversed?1-ge(N):N,l.steps);if(C&&C.length>=2)return{fill:Qt(C,j),opacity:1};let _=j<.5?r:t,ne=Math.abs(j-.5)*2;return{fill:_,opacity:s(ne)}},w=N=>typeof N=="number"&&Number.isFinite(N)?O(I(N)):void 0,F=l.steps??5,W=Array.from({length:F},(N,j)=>{let _=F===1?.5:j/(F-1),ne=_<.5?f+(y-f)*(_*2):y+(v-y)*((_-.5)*2);return{...O(_),label:i(ne)}});return{color:w,domain:[f,v],swatches:W,kind:"diverging"}}let[c,d]=l.domain??[o,a],u=l.colors,m=f=>{let y=Jt(l.reversed?1-ge(f):f,l.steps);return u&&u.length>=2?{fill:Qt(u,y),opacity:1}:{fill:u?.[0]??t,opacity:s(y)}},b=f=>typeof f!="number"||!Number.isFinite(f)?void 0:m(d===c?1:(f-c)/(d-c)),x=l.steps??5,p=Array.from({length:x},(f,y)=>{let v=x===1?1:y/(x-1);return{...m(v),label:i(c+(d-c)*v)}});return{color:b,domain:[c,d],swatches:p,kind:"sequential"}}var zn=34,An=72;function tn(e){if(!e)return{bottom:0,right:0,options:{}};let n=e===!0?{}:e;return n.orientation==="vertical"?{bottom:0,right:An,options:n}:{bottom:zn,right:0,options:n}}function nn(e,n,t){let r=typeof t=="string"?{title:t}:t??{},i=r.title,o=e.swatches;if(o.length===0||n.width<=0)return[];if(r.orientation==="vertical"){let d=Math.max(0,n.height-(i?16:0)),u=Math.min(16,d/o.length),m=n.y+(i?16:0),b=o.map((p,f)=>({kind:"rect",part:"color-legend-swatch",x:h(n.x),y:h(m+f*u),width:10,height:h(u),fill:p.fill,opacity:p.opacity,title:p.label})),x=u>=12?1:2;return o.forEach((p,f)=>{f%x!==0&&f!==o.length-1||b.push({kind:"text",part:"color-legend-label",x:h(n.x+14),y:h(m+(f+.5)*u),text:p.label,baseline:"middle",fill:k.label})}),i&&b.push({kind:"text",part:"color-legend-title",x:h(n.x),y:h(n.y+6),text:i,baseline:"middle",fill:k.label}),b}let a=Math.min(n.width/o.length,96),l=n.x+(n.width-a*o.length)/2,s=o.map((d,u)=>({kind:"rect",part:"color-legend-swatch",x:h(l+u*a),y:h(n.y),width:h(a),height:10,fill:d.fill,opacity:d.opacity,title:d.label})),c=e.kind==="threshold"?1:Math.max(1,Math.ceil(o.length*7*H/Math.max(1,a*o.length)));return o.forEach((d,u)=>{u%c!==0&&u!==o.length-1||s.push({kind:"text",part:"color-legend-label",x:h(l+(u+.5)*a),y:h(n.y+22),text:d.label,anchor:"middle",fill:k.label})}),i&&s.push({kind:"text",part:"color-legend-title",x:h(l-6),y:h(n.y+5),text:i,anchor:"end",baseline:"middle",fill:k.label}),s}var On=1e4,Ln=e=>Array.isArray(e)?{x:e[0],y:e[1],size:e[2],label:void 0,id:void 0,color:void 0,value:void 0}:{x:e.x,y:e.y,size:e.size,label:e.label,id:e.id,color:e.color,value:e.value};function Rn(e,n,t,r,i,o,a,l){if(r==="circle")return{...Vt(e,n,t,i,o,a),part:l};let s=r==="square"?`M${h(e-t)} ${h(n-t)}h${h(2*t)}v${h(2*t)}h${h(-2*t)}Z`:r==="diamond"?`M${h(e)} ${h(n-t*1.3)}L${h(e+t*1.3)} ${h(n)}L${h(e)} ${h(n+t*1.3)}L${h(e-t*1.3)} ${h(n)}Z`:`M${h(e)} ${h(n-t*1.2)}L${h(e+t*1.15)} ${h(n+t*.9)}L${h(e-t*1.15)} ${h(n+t*.9)}Z`;return{kind:"path",part:l,d:s,fill:i,title:o,item:a}}function rn(e,n){let t=[],r=e.series.map((S,U)=>({name:S.name,id:S.id,symbol:S.symbol??"circle",color:Ae(e,U,S.color),data:jt(e,S.name)?[]:S.data.flatMap((A,q)=>{let B=Ln(A);return Y(B.x)&&Y(B.y)?[{...B,index:q}]:[]})})),i=e.sampling==="auto"?On:typeof e.sampling=="object"?e.sampling.threshold:1/0,o=r.reduce((S,U)=>S+U.data.length,0),a=o>i?Math.ceil(o/i):1;a>1&&t.push({code:"sampled",severity:"warning",message:`${o} points exceed the sampling threshold of ${i}; every ${a}th point is drawn.`});let l=a>1?r.map(S=>({...S,data:S.data.filter((U,A)=>A%a===0)})):r,s=l.flatMap(S=>S.data),c=Ht(e,s.length===0);if(c)return{...c,issues:t};let{width:d,height:u}=ze(e),m=e.colorScale?tn(e.colorLegend):{bottom:0,right:0,options:{}},b=Bt(d,u,{...de,top:de.top+Gt(e)+(e.yAxis?.label?12:0),right:de.right+m.right,bottom:de.bottom+(e.xAxis?.label?14:0)+m.bottom}),x=e.markerSize??3,p=Math.max(0,e.hitRadius??0),f=Math.max(0,e.jitter??0),y=new Map,v=e.colorScale?en(e.colorScale,s.map(S=>S.value),Ae(e,0),void 0,le(e.format)):void 0,C=Ee(Ze(s.map(S=>S.x),!1),[b.x,b.x+b.width],e.xAxis??{},e.format),I=Ee(Ze(s.map(S=>S.y),!1),[b.y+b.height,b.y],e.yAxis??{},e.format),O=ce(s.map(S=>S.size)),w=e.series.map((S,U)=>({name:S.name,color:Ae(e,U,S.color)})),F=_e(e,d,u,w),W=[],N=[],j=[],_=[];for(let S of l){let U=S.data.some(A=>A.size!==void 0);for(let A of S.data){let q=A.index,B=n.describe(S.name,A,C,I),re=U?n.radius(A.size,O):x,E=h(C.scale(A.x)),K=h(I.scale(A.y));if(f>0){let ae=`${Math.round(E)},${Math.round(K)}`,ie=y.get(ae)??0;if(y.set(ae,ie+1),ie>0){let se=ie*2.399963;E=h(E+f*Math.cos(se)),K=h(K+f*Math.sin(se))}}let Me=v?.color(A.value),V={label:B,id:A.id,series:S.name,seriesId:S.id??S.name,name:A.label,index:q,value:A.y},oe=A.color??Me?.fill??S.color;if(W.push(Rn(E,K,h(re),S.symbol,oe,B,V,U?n.part:"point")),p>0&&W.push({kind:"circle",part:"hit",cx:E,cy:K,r:h(re+p),fill:oe,opacity:0,title:B,item:V}),e.labels&&A.label){let ae=A.label.length*H,ie=E-ae/2,se=K-re-4;_.some(Se=>Math.abs(Se.y-se)<12&&ie<Se.x+Se.w+4&&ie+ae+4>Se.x)||(_.push({x:ie,y:se,w:ae}),N.push(L(E,h(se),A.label,{part:"point-label",anchor:"middle",fill:"var(--skdx-color-text-default)"})))}}if(e.trendline&&S.data.length>=2){let A=e.trendline===!0?"linear":e.trendline,q=Pn(S.data.map(B=>[B.x,B.y]),A);if(q){let[B,re]=C.domain,E=`${S.name} trend${A==="linear"?"":` (${A})`}: r\xB2 ${q.r2.toFixed(2)}`,K=S.color;if(A==="linear")j.push({kind:"line",part:"trendline",x1:h(C.scale(B)),y1:h(I.scale(q.predict(B))),x2:h(C.scale(re)),y2:h(I.scale(q.predict(re))),stroke:K,dash:"5 4",strokeWidth:1.5,title:E});else{let Me=Array.from({length:40},(V,oe)=>B+(re-B)*oe/39).map(V=>({v:V,p:q.predict(V)})).filter(({p:V})=>Number.isFinite(V)).map(({v:V,p:oe})=>({x:h(C.scale(V)),y:h(I.scale(oe))}));Me.length>1&&j.push({kind:"path",part:"trendline",d:Lt(Me),stroke:K,dash:"5 4",strokeWidth:1.5,title:E})}}}}let ne={...F,plot:b,xTicks:C.ticks,yTicks:I.ticks,baseline:I.zero},It={plot:b,x:S=>C.scale(At(S)),y:S=>I.scale(S)},bn=Ve(e.references,It),xn=v&&(m.bottom||m.right)?nn(v,m.right?{x:b.x+b.width+12,y:b.y,width:m.right,height:b.height}:{x:b.x,y:u-m.bottom+8,width:b.width,height:m.bottom},m.options):[],Tt=n.opacity;return{...F,shapes:[...Et(ne,{xLabel:e.xAxis?.label,yLabel:e.yAxis?.label}),...bn,...Tt!==void 0&&W.some(S=>S.part===n.part)?W.map(S=>(S.kind==="circle"||S.kind==="path")&&S.part!=="hit"?{...S,opacity:Tt}:S):W,...j,...N,...Yt(e.annotations,It),...xn,...F.shapes],issues:t}}function Pn(e,n="linear"){let t;if(n==="polynomial"){let s=0,c=0,d=0,u=0,m=0,b=0,x=0,p=0;for(let[w,F]of e)s+=1,c+=w,d+=w*w,u+=w**3,m+=w**4,b+=F,x+=w*F,p+=w*w*F;let f=w=>w[0]*(w[4]*w[8]-w[5]*w[7])-w[1]*(w[3]*w[8]-w[5]*w[6])+w[2]*(w[3]*w[7]-w[4]*w[6]),v=f([m,u,d,u,d,c,d,c,s]);if(Math.abs(v)<1e-12)return;let C=f([p,u,d,x,d,c,b,c,s])/v,I=f([m,p,d,u,x,c,d,b,s])/v,O=f([m,u,p,u,d,x,d,c,b])/v;t=w=>C*w*w+I*w+O}else{let s=n==="logarithmic"||n==="power"?Math.log:b=>b,c=n==="exponential"||n==="power"?Math.log:b=>b,d=e.filter(([b,x])=>Number.isFinite(s(b))&&Number.isFinite(c(x))),u=Nn(d.map(([b,x])=>[s(b),c(x)]));if(!u)return;let m=n==="exponential"||n==="power"?Math.exp:b=>b;t=b=>m(u.intercept+u.slope*s(b))}let r=t,i=e.filter(([s])=>Number.isFinite(r(s)));if(i.length===0)return;let o=i.reduce((s,[,c])=>s+c,0)/i.length,a=0,l=0;for(let[s,c]of i)a+=(c-r(s))**2,l+=(c-o)**2;return{predict:r,r2:l===0?1:Math.max(0,1-a/l)}}function Nn(e){let n=e.length,t=e.reduce((c,d)=>c+d[0],0)/n,r=e.reduce((c,d)=>c+d[1],0)/n,i=0,o=0,a=0;for(let[c,d]of e)i+=(c-t)**2,o+=(c-t)*(d-r),a+=(d-r)**2;if(i===0)return;let l=o/i,s=a===0?1:o*o/(i*a);return{slope:l,intercept:r-l*t,r2:s}}function Le(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var We=e=>e.id??e.name??e.series,on=e=>e.seriesId??e.series;function X(e,n){let t=!1;return n.id!==void 0&&(t=!0,We(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,on(e)!==n.series&&e.series!==n.series)||n.index!==void 0&&(t=!0,e.index!==n.index)||n.category!==void 0&&(t=!0,e.category!==n.category)?!1:t}function J(e){let n={},t=We(e);t!==void 0&&(n.id=t);let r=on(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Ue=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function qe(e,n,t){let r=Le(e),i=J(n),o=r.some(a=>X(n,a));return t==="single"?o?[]:[i]:o?r.filter(a=>!X(n,a)):[...r,i]}var Bn=.2;function Dn(e){let n=k.focus;switch(e.kind){case"rect":return{kind:"rect",part:"selected",x:e.x-1.5,y:e.y-1.5,width:e.width+3,height:e.height+3,fill:"none",stroke:n,rx:e.rx};case"circle":return{kind:"circle",part:"selected",cx:e.cx,cy:e.cy,r:e.r+2.5,fill:"none",stroke:n};case"path":return{kind:"path",part:"selected",d:e.d,fill:"none",stroke:n,strokeWidth:2.5};case"line":return{...e,part:"selected",stroke:n,strokeWidth:(e.strokeWidth??1)+3,title:void 0,item:void 0};case"text":return}}var Fn=(e,n)=>e.kind==="text"?{...e,fill:k.grid}:{...e,opacity:(e.opacity??1)*n};function Ke(e,n){let t=Le(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:Le(n.highlighted),i=r[0];if(t.length===0&&!i)return e;let o={highlighted:n.highlightScope?.highlighted??"item",faded:n.highlightScope?.faded??"global"},a=[],l=d=>!i||r.some(u=>X(d,u))?!0:o.highlighted==="series"?r.some(u=>u.series!==void 0&&X(d,{series:u.series})):!1,s=d=>{if(!i||o.faded==="none"||l(d))return!1;if(o.faded==="series"){let u=i.series;return u!==void 0&&X(d,{series:u})}return!0},c=e.shapes.map(d=>{let u=d.item;if(!u||u.legend)return d;if(t.some(m=>X(u,m))){let m=Dn(d);m&&a.push(m)}return s(u)?Fn(d,Bn):d});return a.length?{...e,shapes:[...c,...a]}:{...e,shapes:c}}function Ye(e){let[n,t]=e.sizeRange??[4,24],r=le(e.zAxis?.format??e.format),i=e.zAxis?.label,o=e.xAxis?.label,a=e.yAxis?.label,l=(s,c)=>s?`${s} ${c}`:c;return rn({...e,series:e.series.map(s=>({name:s.name,id:s.id,color:s.color,data:s.data.filter(c=>Y(c.x)&&Y(c.y)).map(c=>({x:c.x,y:c.y,size:Y(c.z)?Math.max(0,c.z):0,label:c.label,id:c.id,color:c.color,value:c.value??c.z}))}))},{part:"bubble",opacity:.7,radius:(s,[,c])=>c>0&&Y(s)?Math.max(n,Math.sqrt(s/c)*t):n,describe:(s,c,d,u)=>`${s}${c.label?` ${c.label}`:""}: ${l(o,d.format(c.x))}, ${l(a,u.format(c.y))}, ${l(i,r(c.size??0))}`})}function pe(e,n,t,r,i){let o=e.getBoundingClientRect();return{x:o.width?(n-o.left)*r/o.width:n,y:o.height?(t-o.top)*i/o.height:t}}var Xe=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function an(e,n){let t=0,r=1/0;return e.xs.forEach((i,o)=>{let a=Math.abs(i-n);a<r&&(r=a,t=o)}),t}function ye(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=an(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Qe(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[an(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:k.axis,dash:"3 3"}}function Je(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Xe(r.plot,n,t))return[];let i=Qe(e,n),{rows:o}=ye(e,n),a=e.tooltipAnchored?r.plot.y+8:t;return[i,...Oe(i.x1,a,o,e.width,e.height,e.tooltipPlacement)]}function et(e,n){let t=e.hit;if(!t||t.xs.length===0)return[];let r=t.rows.findIndex(o=>o[0]===n);if(r<0)return[];let i=t.xs[r];return Je(e,i,t.plot.y+8)}function tt(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:s,y:c}=pe(t,r,i,e.width,e.height);if(Xe(e.hit.plot,s,c)){let d=ye(e,s),u=Qe(e,s);if(d&&u)return{lines:d.rows,shapes:[u]}}}let o=n?.closest?.("[data-skdx-part]"),a=e.tooltipFormatter?ee(e,n)?.item:void 0,l=a&&e.tooltipFormatter?.(a)||o&&Array.from(o.children).find(s=>s.tagName.toLowerCase()==="title")?.textContent;return l?{lines:Array.isArray(l)?l:[l],shapes:[]}:{lines:[],shapes:[]}}function sn(e,n,t,r,i,o,a){let l=e?.closest?.("[data-skdx-part]"),s=a&&a.tooltipFormatter?ee(a,e)?.item:void 0,c=s&&a?.tooltipFormatter?.(s)||l&&Array.from(l.children).find(x=>x.tagName.toLowerCase()==="title")?.textContent;if(!c)return[];let d=a?.tooltipAnchored?ee(a,e):void 0,u=d?a?.shapes[d.index]:void 0,{x:m,y:b}=u?ve(u):pe(n,t,r,i,o);return Oe(m,b,c,i,o,a?.tooltipPlacement)}function nt(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:a}=pe(t,r,i,e.width,e.height),l=Je(e,o,a);if(l.length>0)return l}return sn(n,t,r,i,e.width,e.height,e)}function rt(e,n){let t=ee(e,n);return t&&!t.item.legend?J(t.item):null}var Gn=(e,n)=>{let{x:t,y:r}=ve(e),i=e.kind==="circle"?e.cy:e.kind==="rect"?e.y+e.height/2:r;return t>=n.x&&t<=n.x+n.width&&i>=n.y&&i<=n.y+n.height};function it(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!Gn(i,n))continue;let o=J(i.item),a=JSON.stringify(o);t.has(a)||(t.add(a),r.push(o))}return r}var ot=e=>({kind:"rect",part:"selection-box",x:h(e.x),y:h(e.y),width:h(e.width),height:h(e.height),fill:k.focus,opacity:.12,stroke:k.focus}),Pe=(e,n,t,r)=>({x:Math.min(e,t),y:Math.min(n,r),width:Math.abs(t-e),height:Math.abs(r-n)});function ln(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let a=e[i],l=e[o];a.y>t!=l.y>t&&n<(l.x-a.x)*(t-a.y)/(l.y-a.y)+a.x&&(r=!r)}return r}function at(e,n){if(n.length<3)return[];let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor")continue;let{x:o,y:a}=ve(i),l=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:a;if(!ln(n,o,l))continue;let s=J(i.item),c=JSON.stringify(s);t.has(c)||(t.add(c),r.push(s))}return r}var st=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${h(n.x)} ${h(n.y)}`).join("L")}`:"",fill:k.focus,fillOpacity:.12,stroke:k.focus,dash:"4 3"}),Re=6;function lt(e,n,t){let r=e.edit;if(r){for(let i of r.bars)if(!(t<i.y||t>i.y+i.height||n<i.x0-Re||n>i.x1+Re))return Math.abs(n-i.x0)<=Re?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=Re?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function ct(e,n,t){let r=e.edit;return cn(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function dt(e,n,t){let r=e.edit,i=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;if(!r||n===null||!i||!(t.shiftKey||t.altKey))return;let o=r.bars.find(s=>s.index===n);if(!o)return;let a=t.altKey?t.shiftKey?"start":"end":"move",l=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return cn(r,{bar:o,mode:a},i*l)}function cn(e,{bar:n,mode:t},r){let i=l=>e.snap?Math.round(l/e.snap)*e.snap:l,o=n.start,a=n.end;return t==="move"?(o=i(n.start+r),a=o+(n.end-n.start)):t==="start"?o=Math.min(i(n.start+r),n.end):a=Math.max(i(n.end+r),n.start),{id:n.id,name:n.name,start:o,end:a}}function ut(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:h(Math.min(i,o)),y:h(n.bar.y),width:h(Math.max(1,Math.abs(o-i))),height:h(n.bar.height),fill:k.focus,opacity:.25,stroke:k.focus,rx:2}}var jn=64,_n=e=>Math.max(1,Math.min(jn,e));function ht(e,n,t,r){let i=n>0?.8:1.25,o=_n(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:a,scale:l}=e,[s,c]=e.view.center,d=(t-(a.x+a.width/2))/l,u=(r-(a.y+a.height/2))/l,m=e.view.zoom/o;return{center:[s+d*(1-m),e.fromY(e.toY(c)-u*(1-m))],zoom:o}}function pt(e,n,t,r){let{scale:i}=e;return{center:[n.center[0]-t/i,e.fromY(e.toY(n.center[1])+r/i)],zoom:n.zoom}}function ee(e,n){let t=n?.closest?.("[data-skdx-i]"),r=Number(t?.getAttribute("data-skdx-i")),i=Number.isInteger(r)?e.shapes[r]?.item:void 0;return i?{index:r,item:i}:void 0}var Ne=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function ve(e){switch(e.kind){case"rect":return{x:e.x+e.width/2,y:e.y};case"circle":return{x:e.cx,y:e.cy-e.r};case"line":return{x:(e.x1+e.x2)/2,y:Math.min(e.y1,e.y2)};case"text":return{x:e.x,y:e.y};case"path":{let n=/M\s*(-?[\d.]+)[ ,](-?[\d.]+)/.exec(e.d);return n?{x:Number(n[1]),y:Number(n[2])}:{x:0,y:0}}}}function ft(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=k.focus,i;switch(t.kind){case"rect":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-2,width:t.width+4,height:t.height+4,fill:"none",stroke:r,rx:2};break;case"circle":i={kind:"circle",part:"focus",cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:r};break;case"line":i={kind:"line",part:"focus",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:r,strokeWidth:4};break;case"text":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-8,width:t.text.length*H+4,height:16,fill:"none",stroke:r,rx:2};break;case"path":i={kind:"path",part:"focus",d:t.d,stroke:r,strokeWidth:2,fill:"none"};break}let{x:o,y:a}=ve(t),l=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...l?Oe(h(o),h(a),l,e.width,e.height):[]]}function mt(e,n,t){let r=Ne(e);if(r.length===0)return;let i=n===null?-1:r.indexOf(n);switch(t){case"ArrowRight":case"ArrowDown":return r[Math.min(r.length-1,i+1)];case"ArrowLeft":case"ArrowUp":return r[Math.max(0,i<=0?0:i-1)];case"Home":return r[0];case"End":return r[r.length-1];case"Escape":return null;default:return}}var ue=2,he=(e,n,t)=>{let r=Math.max(ue,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},dn=(e,n)=>!e||e.start<=0&&e.end>=n;function bt(e,n,t){if(e.count<=ue||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,a=n>0?1.25:.8,l=Math.max(ue,Math.min(e.count,Math.round(o*a)));if(l===o)return n>0&&!dn(e.zoom,e.count)?he(r,l,e.count):void 0;let s=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),c=r+s*o;return he(c-s*l,l,e.count)}function xt(e,n,t,r){let i=n.end-n.start,o=Math.max(ue,Math.min(e.count,Math.round(i/Math.max(.05,t)))),a=Math.max(0,Math.min(1,(r-e.plot.x)/Math.max(1,e.plot.width)));return he(n.start+a*i-a*o,o,e.count)}function gt(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return he(n.start-t/i,r,e.count)}function yt(e,n,t){let r=e.brush;if(!r||!Xe(r.box,n,t))return;let i=r.window;if(Math.abs(n-i.x)<=6)return{grab:"left",zoom:e.zoom};if(Math.abs(n-(i.x+i.width))<=6)return{grab:"right",zoom:e.zoom};if(n>i.x&&n<i.x+i.width)return{grab:"move",zoom:e.zoom};let o=e.zoom.end-e.zoom.start,a=(n-r.box.x)/Math.max(1,r.box.width)*e.count;return{grab:"move",zoom:he(a-o/2,o,e.count)}}function vt(e,n,t,r){let i=e.brush;if(!i)return t;let o=r/Math.max(1,i.box.width)*e.count;if(n==="move")return he(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-ue,Math.round(t.start+o))),end:t.end};let a=Math.min(e.count,Math.max(t.start+ue,Math.round(t.end+o)));return{start:t.start,end:a}}function Mt(e,n){switch(n.type){case"svg":return Promise.resolve(wt(e,n.label,n.resolve));case"csv":return Promise.resolve(fn(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=wt(e,n.label,n.resolve);return pn(t,e.width,e.height,n.scale,n.background)}}}var Q=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;"),we=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${Q(String(t))}"`).join("");function un(e){let n=e.title?`<title>${Q(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${we([t,["d",e.d],["fill",e.fill??"none"],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-linecap",e.strokeLinecap],["stroke-linejoin",e.strokeLinejoin],["stroke-dasharray",e.dash],["opacity",e.opacity],["fill-opacity",e.fillOpacity]])}>${n}</path>`;case"rect":return`<rect${we([t,["x",e.x],["y",e.y],["width",e.width],["height",e.height],["rx",e.rx],["fill",e.fill],["stroke",e.stroke],["fill-opacity",e.opacity]])}>${n}</rect>`;case"line":return`<line${we([t,["x1",e.x1],["y1",e.y1],["x2",e.x2],["y2",e.y2],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-dasharray",e.dash],["opacity",e.opacity]])}>${n}</line>`;case"circle":return`<circle${we([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${we([t,["x",e.x],["y",e.y],["text-anchor",e.anchor],["dominant-baseline",e.baseline],["fill",e.fill],["font-weight",e.weight],["transform",e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0]])}>${Q(e.text)}</text>`}}function hn(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${Q(t.id)}" x1="0" y1="0" x2="${t.vertical===!1?1:0}" y2="${t.vertical===!1?0:1}">${t.stops.map(r=>`<stop offset="${r.offset}" stop-color="${Q(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function wt(e,n,t){let r=hn(e)+e.shapes.map(un).join("");return t&&(r=r.replace(/var\((--[\w-]+)\)/g,(i,o)=>t(o).trim()||i)),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e.width} ${e.height}" width="${e.width}" height="${e.height}" role="img" aria-label="${Q(n)}" font-family="${Q(k.fontFamily)}" font-size="${Q(k.fontSize)}"><title>${Q(n)}</title>${r}</svg>`}function pn(e,n,t,r=2,i){return new Promise((o,a)=>{let l=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),s=new Image;s.onload=()=>{URL.revokeObjectURL(l);let c=document.createElement("canvas");c.width=Math.round(n*r),c.height=Math.round(t*r);let d=c.getContext("2d");if(!d)return a(new Error("canvas 2d context unavailable"));i&&(d.fillStyle=i,d.fillRect(0,0,c.width,c.height)),d.drawImage(s,0,0,c.width,c.height),c.toBlob(u=>u?o(u):a(new Error("toBlob failed")),"image/png")},s.onerror=()=>{URL.revokeObjectURL(l),a(new Error("svg could not be decoded"))},s.src=l})}function fn(e){let n=t=>{let r=t==null?"":String(t);return/[",\n\r]/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return e.map(t=>t.map(n).join(",")).join(`\r
2
+ `)}function St(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let l=r.rows[0];if(r.rows.length>t)return;let s=["",...l.slice(1).map(d=>d.replace(/:\s[^:]*$/,""))],c=r.rows.map(d=>[d[0],...d.slice(1).map(u=>u.slice(u.lastIndexOf(": ")+2))]);return[s,...c]}let i=e.shapes.flatMap(l=>l.item&&!l.item.legend&&!(l.part==="anchor"&&!l.title)?[l.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(l=>i.some(s=>s[l]!==void 0)),a=(l,s)=>l[s]===void 0?"":String(l[s]);return[o.map(l=>l[0]?.toUpperCase()+l.slice(1)),...i.map(l=>o.map(s=>a(l,s)))]}var kt=new Map;function Be(e){let n=kt.get(e);if(n)return n.group;let t=new Set,r={},i={current:r,subscribe(o){return t.add(o),()=>{t.delete(o),t.size===0&&kt.delete(e)}},publish(o,a){Object.assign(r,o);for(let l of t)l(o,a)}};return kt.set(e,{group:i,listeners:t}),i}var mn='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',$t=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${mn}{animation:skdx-in var(--skdx-chart-duration,0ms) ease-out;transition:${["x","y","width","height","cx","cy","r","opacity","fill-opacity","d"].map(e=>`${e} var(--skdx-chart-duration,0ms) ease-out`).join(",")}}@media (prefers-reduced-motion:reduce){${mn}{animation:none;transition:none}}`;function Ct(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}import{css as Hn,html as te,LitElement as Zn,nothing as R,svg as G}from"lit";import{property as M,state as Z}from"lit/decorators.js";import{ifDefined as z}from"lit/directives/if-defined.js";var En={fromAttribute:()=>!1},$=class extends Zn{constructor(){super(...arguments);this.legend=!1;this.tooltip=!0;this.selectionMode="none";this.loading=!1;this.decorative=!1;this.accessibleTable=!1;this.zoomable=!1;this.editable=!1;this.crossFilter=!1;this.animated=!1;this.responsive=!1;this.tip=[];this.overlay=[];this.portal=null;this.highlightState=null;this.crossState=null;this.lastCross=null;this.pointers=new Map;this.hover=null;this.token={};this.focused=null;this.hiddenState=[];this.drag=null;this.onPointerMove=t=>{let r=this.layout;if(!r)return;this.pointers.has(t.pointerId)&&this.pointers.set(t.pointerId,this.viewBox(t,r).x);let i=this.drag;if(i?.grab==="select"){let{x:o,y:a}=this.viewBox(t,r);this.overlay=[ot(Pe(i.x,i.y,o,a))];return}if(i?.grab==="lasso"){let{x:o,y:a}=this.viewBox(t,r);i.points=[...i.points??[],{x:o,y:a}],this.overlay=[st(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=ct(r,i.gantt,o-i.x),this.overlay=[ut(r,i.gantt,i.change)];return}if(i?.grab==="map"){if(!r.map||!i.view)return;let{x:o,y:a}=this.viewBox(t,r);this.setView(pt(r.map,i.view,o-i.x,a-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[a,l]=[...this.pointers.values()];if(a===void 0||l===void 0||!i.distance)return;this.setZoom(xt(r.hit,i.zoom,Math.abs(a-l)/i.distance,(a+l)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?gt(r.hit,i.zoom,o-i.x):vt(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:a}=tt(r,t.target,t.currentTarget,t.clientX,t.clientY);this.tip=a,this.portal=o.length?{x:t.clientX,y:t.clientY,lines:o}:null}else{let o=nt(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(rt(r,t.target)),this.syncId&&r.hit?.crosshair){let o=ye(r,this.viewBox(t,r).x);this.shareCrosshair(o?r.hit.rows[o.index]?.[0]??null:null)}};this.onPointerDown=t=>{let r=this.layout;if(!r||t.button!==0)return;let{x:i,y:o}=this.viewBox(t,r),a=ee(r,t.target)?.item.legend,l=this.canEdit(r)?lt(r,i,o):void 0;if(l){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:l},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.brushing()&&!a){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:this.selectionMode==="lasso"?"lasso":"select",points:[{x:i,y:o}]},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.canPan(r)&&r.map){let c=r.map.plot;if(i<c.x||i>c.x+c.width||o<c.y||o>c.y+c.height)return;this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"map",view:r.map.view},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}let s=r.hit;if(!(!s||!this.canZoom(r))){if(this.pointers.set(t.pointerId,i),this.pointers.size===2){let[c,d]=[...this.pointers.values()];this.drag={x:(c+d)/2,y:o,zoom:s.zoom,grab:"pinch",distance:Math.abs(c-d)||1}}else{let c=yt(s,i,o);if(c)this.drag={x:i,y:o,zoom:c.zoom,grab:c.grab},c.zoom!==s.zoom&&this.setZoom(c.zoom);else if(this.zoomable&&i>=s.plot.x&&i<=s.plot.x+s.plot.width&&o>=s.plot.y&&o<=s.plot.y+s.plot.height)this.drag={x:i,y:o,zoom:s.zoom,grab:"pan"};else{this.pointers.delete(t.pointerId);return}}t.currentTarget.setPointerCapture(t.pointerId),this.clearTip()}};this.onPointerUp=t=>{this.pointers.delete(t.pointerId);let r=t.currentTarget;r.hasPointerCapture(t.pointerId)&&r.releasePointerCapture(t.pointerId);let i=this.drag,o=this.layout;if(o&&(i?.grab==="select"||i?.grab==="lasso"||i?.grab==="edit"||i?.grab==="map")){this.overlay=[];let{x:a,y:l}=this.viewBox(t,o);if(Math.abs(a-i.x)>2||Math.abs(l-i.y)>2){i.grab==="select"?this.setSelected(it(o,Pe(i.x,i.y,a,l))):i.grab==="lasso"?this.setSelected(at(o,i.points??[])):i.grab==="edit"&&i.change&&this.emit("skdx-task-change",i.change),this.drag={...i,distance:-1};return}this.drag=null;return}(this.pointers.size===0||this.drag?.grab==="pinch")&&(this.drag=null)};this.onWheel=t=>{let r=this.layout;if(!r)return;let{x:i,y:o}=this.viewBox(t,r);if(r.map&&this.canPan(r)){let s=r.map.plot;if(i<s.x||i>s.x+s.width||o<s.y||o>s.y+s.height)return;t.preventDefault(),this.setView(ht(r.map,t.deltaY,i,o));return}let a=r.hit;if(!a||!this.canZoom(r)||o<a.plot.y||o>a.plot.y+a.plot.height)return;let l=bt(a,t.deltaY,i);l&&(t.preventDefault(),this.setZoom(l))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=ee(this.layout,t.target);r&&(r.item.range?this.setZoom(r.item.range):r.item.legend&&r.item.series!==void 0?this.toggle(r.item.series):(this.select(r.item),this.emit("skdx-item-click",r.item)))};this.onKeyDown=t=>{let r=this.layout;if(!r)return;if((t.key==="Enter"||t.key===" ")&&this.focused!==null){let l=r.shapes[this.focused]?.item;l&&(t.preventDefault(),this.select(l),this.emit("skdx-item-click",l));return}let i=this.canEdit(r)?dt(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=mt(r,this.focused,t.key);if(o===void 0)return;t.preventDefault(),this.focused=o;let a=o===null?void 0:r.shapes[o]?.item;this.highlight(a?J(a):null)}}connectedCallback(){super.connectedCallback(),!(typeof ResizeObserver>"u")&&(this.observer=new ResizeObserver(([t])=>{let r=Math.floor(t?.contentRect.width??0);r>0&&(this.measured=r)}),this.observer.observe(this))}disconnectedCallback(){this.observer?.disconnect(),this.leave?.(),this.leave=void 0,this.joined=void 0,super.disconnectedCallback()}sized(){let{width:t,height:r,legend:i,tooltip:o,format:a,palette:l,loading:s,error:c,emptyMessage:d,description:u,decorative:m,animated:b,responsive:x,highlighted:p,highlightScope:f,accessibleTable:y}=this;return{...typeof x=="object"&&this.measured!==void 0&&this.measured<(x.breakpoint??480)?x.compact:void 0,width:x&&this.measured?this.measured:t,height:r,animate:b,responsive:x,legend:i,tooltip:o,format:a,palette:l,loading:s,error:c,emptyMessage:d,description:u,decorative:m,highlighted:p===void 0?this.highlightState:p,highlightScope:f,accessibleTable:y,hiddenSeries:this.hiddenSeries??this.hiddenState,zoom:this.zoom??this.zoomState,selected:this.selected??this.selectedState,view:this.view??this.viewState}}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}publish(t){this.syncId&&Be(this.syncId).publish(t,this.token)}join(){if(this.joined===this.syncId||(this.leave?.(),this.leave=void 0,this.joined=this.syncId,!this.syncId))return;let t=Be(this.syncId),r=i=>{"highlighted"in i&&(this.highlightState=i.highlighted??null),i.selected&&(this.selectedState=i.selected,this.crossFilter&&(this.highlightState=i.selected.length?i.selected:null)),"zoom"in i&&(this.zoomState=i.zoom),i.hiddenSeries&&(this.hiddenState=i.hiddenSeries),"crosshair"in i&&(this.crossState=i.crosshair??null)};r(t.current),this.leave=t.subscribe((i,o)=>{o!==this.token&&r(i)})}setZoom(t){this.zoomState=t,this.emit("skdx-zoom-change",t),this.publish({zoom:t})}setView(t){this.viewState=t,this.emit("skdx-view-change",t)}setSelected(t){this.selectedState=t,this.emit("skdx-selected-change",t),this.publish({selected:t})}toggle(t){let r=this.hiddenSeries??this.hiddenState,i=r.includes(t)?r.filter(o=>o!==t):[...r,t];this.hiddenState=i,this.emit("skdx-hidden-series-change",i),this.publish({hiddenSeries:i})}highlight(t){let r=this.hover;r===t||r&&t&&Ue(r,t)||(this.hover=t,this.emit("skdx-highlighted-change",t),this.syncId&&(this.highlightState=t,this.publish({highlighted:t})))}select(t){let r=this.selectionMode;r!=="none"&&this.setSelected(qe(this.selected??this.selectedState,t,r==="single"?"single":"multiple"))}shareCrosshair(t){!this.syncId||this.lastCross===t||(this.lastCross=t,this.publish({crosshair:t}))}clearTip(){this.tip=[],this.portal=null,this.shareCrosshair(null)}canZoom(t){return!!(t.hit&&(this.zoomable||t.hit.brush))}canPan(t){return!!(t.map&&this.zoomable)}canEdit(t){return!!(this.editable&&t.edit)}brushing(){return this.selectionMode==="brush"||this.selectionMode==="lasso"}viewBox(t,r){return pe(t.currentTarget,t.clientX,t.clientY,r.width,r.height)}getSvgElement(){return this.renderRoot.querySelector("svg")}getLayout(){return this.layout}resetZoom(){this.setZoom(void 0)}zoomTo(t){this.setZoom(t)}focusItem(t){let r=this.layout;if(!r)return!1;let i=r.shapes.findIndex(o=>o.item&&!o.item.legend&&X(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?Mt(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Ke(He(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let y of o.issues??[])this.emit("skdx-data-issue",y)}let a=this.canZoom(o),l=this.canPan(o),s=this.canEdit(o),c=this.brushing(),d=a||l||s||c,u=!o.decorative&&Ne(o).length>0,m=o.description?`${r}-desc`:void 0,b=Ct(o),x=St(o,this.accessibleTable),p=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,f=this.portal;return te`<svg
3
3
  xmlns="http://www.w3.org/2000/svg"
4
4
  viewBox="0 0 ${o.width} ${o.height}"
5
5
  width=${o.width}
@@ -7,7 +7,7 @@ var bn=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var g=(e,n,t
7
7
  role=${o.decorative?"presentation":"img"}
8
8
  aria-hidden=${o.decorative?"true":R}
9
9
  aria-label=${o.decorative?R:i}
10
- aria-describedby=${T(m)}
10
+ aria-describedby=${z(m)}
11
11
  tabindex=${u?0:R}
12
12
  data-skdx-chart=${r}
13
13
  data-zoomable=${a||l?"":R}
@@ -28,11 +28,11 @@ var bn=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var g=(e,n,t
28
28
  @blur=${()=>{this.focused=null,this.highlight(null)}}
29
29
  >
30
30
  <title>${i}</title>
31
- ${o.description?G`<desc id=${T(m)}>${o.description}</desc>`:R}
32
- ${b?G`<style>${$t}</style>`:R} ${En(o)}
33
- ${Be(o.shapes)}
34
- ${Be(this.tip.length||!this.crossState?this.tip:et(o,this.crossState))}
35
- ${Be(ft(o,this.focused))} ${Be(this.overlay)}
31
+ ${o.description?G`<desc id=${z(m)}>${o.description}</desc>`:R}
32
+ ${b?G`<style>${$t}</style>`:R} ${Vn(o)}
33
+ ${De(o.shapes)}
34
+ ${De(this.tip.length||!this.crossState?this.tip:et(o,this.crossState))}
35
+ ${De(ft(o,this.focused))} ${De(this.overlay)}
36
36
  </svg>
37
37
  ${f?te`<div
38
38
  role="tooltip"
@@ -55,7 +55,7 @@ var bn=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var g=(e,n,t
55
55
  ${y.map((v,C)=>C===0?te`<th scope="row">${v}</th>`:te`<td>${v}</td>`)}
56
56
  </tr>`)}
57
57
  </tbody>
58
- </table>`:R}`}};$.styles=_n`
58
+ </table>`:R}`}};$.styles=Hn`
59
59
  :host {
60
60
  display: inline-block;
61
61
  }
@@ -106,4 +106,4 @@ var bn=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var g=(e,n,t
106
106
  [role='tooltip'] > :first-child:not(:only-child) {
107
107
  font-weight: bold;
108
108
  }
109
- `,g([M({type:Number})],$.prototype,"width",2),g([M({type:Number})],$.prototype,"height",2),g([M()],$.prototype,"label",2),g([M({type:Boolean,reflect:!0})],$.prototype,"legend",2),g([M({type:Boolean,attribute:"no-tooltip",converter:Zn})],$.prototype,"tooltip",2),g([M({attribute:!1})],$.prototype,"format",2),g([M({attribute:!1})],$.prototype,"palette",2),g([M({attribute:!1})],$.prototype,"hiddenSeries",2),g([M({attribute:!1})],$.prototype,"selected",2),g([M({attribute:"selection-mode"})],$.prototype,"selectionMode",2),g([M({attribute:!1})],$.prototype,"highlighted",2),g([M({attribute:!1})],$.prototype,"highlightScope",2),g([M({type:Boolean,reflect:!0})],$.prototype,"loading",2),g([M()],$.prototype,"error",2),g([M({attribute:"empty-message"})],$.prototype,"emptyMessage",2),g([M()],$.prototype,"description",2),g([M({type:Boolean,reflect:!0})],$.prototype,"decorative",2),g([M({type:Boolean,attribute:"accessible-table"})],$.prototype,"accessibleTable",2),g([M({attribute:!1})],$.prototype,"zoom",2),g([M({attribute:!1})],$.prototype,"view",2),g([M({type:Boolean,reflect:!0})],$.prototype,"zoomable",2),g([M({type:Boolean,reflect:!0})],$.prototype,"editable",2),g([M({attribute:"sync-id"})],$.prototype,"syncId",2),g([M({type:Boolean,attribute:"cross-filter"})],$.prototype,"crossFilter",2),g([M({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],$.prototype,"animated",2),g([M({type:Boolean,reflect:!0})],$.prototype,"responsive",2),g([H()],$.prototype,"tip",2),g([H()],$.prototype,"overlay",2),g([H()],$.prototype,"portal",2),g([H()],$.prototype,"measured",2),g([H()],$.prototype,"viewState",2),g([H()],$.prototype,"highlightState",2),g([H()],$.prototype,"crossState",2),g([H()],$.prototype,"focused",2),g([H()],$.prototype,"hiddenState",2),g([H()],$.prototype,"zoomState",2),g([H()],$.prototype,"selectedState",2);var I=class extends ${constructor(){super(...arguments);this.series=[];this.labels=!1;this.connectNulls=!1;this.stacked=!1;this.brush=!1;this.crosshair=!1}input(){let{series:t,categories:r,xAxis:i,yAxis:o,rightAxis:a,references:l,annotations:s,labels:c,curve:d,connectNulls:u,nulls:m,stacked:b,stackOffset:x,orientation:p,radius:f,barGap:y,barWidth:v,sort:C,transform:z,transforms:O,bins:w,binWidth:F,binDomain:V,binMode:N,sampling:j,brush:_,crosshair:ne}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:a,references:l,annotations:s,labels:c,curve:d,connectNulls:u,nulls:m,stacked:b,stackOffset:x,orientation:p,radius:f,barGap:y,barWidth:v,sort:C,transform:z,transforms:O,bins:w,binWidth:F,binDomain:V,binMode:N,sampling:j,brush:_,crosshair:ne}}};g([M({attribute:!1})],I.prototype,"series",2),g([M({attribute:!1})],I.prototype,"categories",2),g([M({attribute:!1})],I.prototype,"xAxis",2),g([M({attribute:!1})],I.prototype,"yAxis",2),g([M({attribute:!1})],I.prototype,"rightAxis",2),g([M({attribute:!1})],I.prototype,"references",2),g([M({attribute:!1})],I.prototype,"annotations",2),g([M({type:Boolean,reflect:!0})],I.prototype,"labels",2),g([M()],I.prototype,"curve",2),g([M({type:Boolean,attribute:"connect-nulls"})],I.prototype,"connectNulls",2),g([M()],I.prototype,"nulls",2),g([M({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],I.prototype,"stacked",2),g([M({attribute:"stack-offset"})],I.prototype,"stackOffset",2),g([M()],I.prototype,"orientation",2),g([M({type:Number})],I.prototype,"radius",2),g([M({type:Number,attribute:"bar-gap"})],I.prototype,"barGap",2),g([M({type:Number,attribute:"bar-width"})],I.prototype,"barWidth",2),g([M()],I.prototype,"sort",2),g([M()],I.prototype,"transform",2),g([M({attribute:!1})],I.prototype,"transforms",2),g([M({type:Number})],I.prototype,"bins",2),g([M({type:Number,attribute:"bin-width"})],I.prototype,"binWidth",2),g([M({attribute:!1})],I.prototype,"binDomain",2),g([M({attribute:"bin-mode"})],I.prototype,"binMode",2),g([M({attribute:!1})],I.prototype,"sampling",2),g([M({type:Boolean,reflect:!0})],I.prototype,"brush",2),g([M({type:Boolean,reflect:!0})],I.prototype,"crosshair",2);var En=e=>e.defs&&e.defs.length?G`<defs>${e.defs.map(n=>G`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>G`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${T(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:R,Be=e=>G`${e.map((n,t)=>{let r=n.title?G`<title>${n.title}</title>`:R,i=n.item?t:void 0;switch(n.kind){case"path":return G`<path data-skdx-part=${n.part} data-skdx-i=${T(i)} d=${n.d} fill=${n.fill??"none"} stroke=${T(n.stroke)} stroke-width=${T(n.strokeWidth)} stroke-linecap=${T(n.strokeLinecap)} stroke-linejoin=${T(n.strokeLinejoin)} stroke-dasharray=${T(n.dash)} opacity=${T(n.opacity)} fill-opacity=${T(n.fillOpacity)}>${r}</path>`;case"rect":return G`<rect data-skdx-part=${n.part} data-skdx-i=${T(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${T(n.rx)} fill=${n.fill} stroke=${T(n.stroke)} fill-opacity=${T(n.opacity)}>${r}</rect>`;case"line":return G`<line data-skdx-part=${n.part} data-skdx-i=${T(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${T(n.strokeWidth)} stroke-dasharray=${T(n.dash)} opacity=${T(n.opacity)}>${r}</line>`;case"circle":return G`<circle data-skdx-part=${n.part} data-skdx-i=${T(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${T(n.stroke)} opacity=${T(n.opacity)}>${r}</circle>`;case"text":return G`<text data-skdx-part=${n.part} data-skdx-i=${T(i)} x=${n.x} y=${n.y} text-anchor=${T(n.anchor)} dominant-baseline=${T(n.baseline)} fill=${T(n.fill)} font-weight=${T(n.weight)} pointer-events=${T(i===void 0?"none":void 0)} transform=${T(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var P=class extends ${constructor(){super(...arguments);this.series=[];this.labels=!1}render(){let{series:t,sizeRange:r,labels:i,xAxis:o,yAxis:a,zAxis:l,references:s,annotations:c,colorScale:d,colorLegend:u,hitRadius:m,jitter:b,trendline:x,sampling:p}=this;return this.root(Ye({...this.sized(),series:t,sizeRange:r,labels:i,xAxis:o,yAxis:a,zAxis:l,references:s,annotations:c,colorScale:d,colorLegend:u,hitRadius:m,jitter:b,trendline:x,sampling:p}),"bubble",this.label??"Bubble chart")}};g([D({attribute:!1})],P.prototype,"series",2),g([D({attribute:!1})],P.prototype,"sizeRange",2),g([D({type:Boolean,reflect:!0})],P.prototype,"labels",2),g([D({attribute:!1})],P.prototype,"xAxis",2),g([D({attribute:!1})],P.prototype,"yAxis",2),g([D({attribute:!1})],P.prototype,"zAxis",2),g([D({attribute:!1})],P.prototype,"references",2),g([D({attribute:!1})],P.prototype,"annotations",2),g([D({attribute:!1})],P.prototype,"colorScale",2),g([D({attribute:!1})],P.prototype,"colorLegend",2),g([D({type:Number,attribute:"hit-radius"})],P.prototype,"hitRadius",2),g([D({type:Number})],P.prototype,"jitter",2),g([D({attribute:!1})],P.prototype,"trendline",2),g([D({attribute:!1})],P.prototype,"sampling",2),P=g([Vn("skdx-bubble-chart")],P);export{P as SkdxBubbleChart};
109
+ `,g([M({type:Number})],$.prototype,"width",2),g([M({type:Number})],$.prototype,"height",2),g([M()],$.prototype,"label",2),g([M({type:Boolean,reflect:!0})],$.prototype,"legend",2),g([M({type:Boolean,attribute:"no-tooltip",converter:En})],$.prototype,"tooltip",2),g([M({attribute:!1})],$.prototype,"format",2),g([M({attribute:!1})],$.prototype,"palette",2),g([M({attribute:!1})],$.prototype,"hiddenSeries",2),g([M({attribute:!1})],$.prototype,"selected",2),g([M({attribute:"selection-mode"})],$.prototype,"selectionMode",2),g([M({attribute:!1})],$.prototype,"highlighted",2),g([M({attribute:!1})],$.prototype,"highlightScope",2),g([M({type:Boolean,reflect:!0})],$.prototype,"loading",2),g([M()],$.prototype,"error",2),g([M({attribute:"empty-message"})],$.prototype,"emptyMessage",2),g([M()],$.prototype,"description",2),g([M({type:Boolean,reflect:!0})],$.prototype,"decorative",2),g([M({type:Boolean,attribute:"accessible-table"})],$.prototype,"accessibleTable",2),g([M({attribute:!1})],$.prototype,"zoom",2),g([M({attribute:!1})],$.prototype,"view",2),g([M({type:Boolean,reflect:!0})],$.prototype,"zoomable",2),g([M({type:Boolean,reflect:!0})],$.prototype,"editable",2),g([M({attribute:"sync-id"})],$.prototype,"syncId",2),g([M({type:Boolean,attribute:"cross-filter"})],$.prototype,"crossFilter",2),g([M({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],$.prototype,"animated",2),g([M({type:Boolean,reflect:!0})],$.prototype,"responsive",2),g([Z()],$.prototype,"tip",2),g([Z()],$.prototype,"overlay",2),g([Z()],$.prototype,"portal",2),g([Z()],$.prototype,"measured",2),g([Z()],$.prototype,"viewState",2),g([Z()],$.prototype,"highlightState",2),g([Z()],$.prototype,"crossState",2),g([Z()],$.prototype,"focused",2),g([Z()],$.prototype,"hiddenState",2),g([Z()],$.prototype,"zoomState",2),g([Z()],$.prototype,"selectedState",2);var T=class extends ${constructor(){super(...arguments);this.series=[];this.labels=!1;this.connectNulls=!1;this.stacked=!1;this.brush=!1;this.crosshair=!1}input(){let{series:t,categories:r,xAxis:i,yAxis:o,rightAxis:a,references:l,annotations:s,labels:c,curve:d,connectNulls:u,nulls:m,stacked:b,stackOffset:x,orientation:p,radius:f,barGap:y,barWidth:v,sort:C,transform:I,transforms:O,bins:w,binWidth:F,binDomain:W,binMode:N,sampling:j,brush:_,crosshair:ne}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:a,references:l,annotations:s,labels:c,curve:d,connectNulls:u,nulls:m,stacked:b,stackOffset:x,orientation:p,radius:f,barGap:y,barWidth:v,sort:C,transform:I,transforms:O,bins:w,binWidth:F,binDomain:W,binMode:N,sampling:j,brush:_,crosshair:ne}}};g([M({attribute:!1})],T.prototype,"series",2),g([M({attribute:!1})],T.prototype,"categories",2),g([M({attribute:!1})],T.prototype,"xAxis",2),g([M({attribute:!1})],T.prototype,"yAxis",2),g([M({attribute:!1})],T.prototype,"rightAxis",2),g([M({attribute:!1})],T.prototype,"references",2),g([M({attribute:!1})],T.prototype,"annotations",2),g([M({type:Boolean,reflect:!0})],T.prototype,"labels",2),g([M()],T.prototype,"curve",2),g([M({type:Boolean,attribute:"connect-nulls"})],T.prototype,"connectNulls",2),g([M()],T.prototype,"nulls",2),g([M({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],T.prototype,"stacked",2),g([M({attribute:"stack-offset"})],T.prototype,"stackOffset",2),g([M()],T.prototype,"orientation",2),g([M({type:Number})],T.prototype,"radius",2),g([M({type:Number,attribute:"bar-gap"})],T.prototype,"barGap",2),g([M({type:Number,attribute:"bar-width"})],T.prototype,"barWidth",2),g([M()],T.prototype,"sort",2),g([M()],T.prototype,"transform",2),g([M({attribute:!1})],T.prototype,"transforms",2),g([M({type:Number})],T.prototype,"bins",2),g([M({type:Number,attribute:"bin-width"})],T.prototype,"binWidth",2),g([M({attribute:!1})],T.prototype,"binDomain",2),g([M({attribute:"bin-mode"})],T.prototype,"binMode",2),g([M({attribute:!1})],T.prototype,"sampling",2),g([M({type:Boolean,reflect:!0})],T.prototype,"brush",2),g([M({type:Boolean,reflect:!0})],T.prototype,"crosshair",2);var Vn=e=>e.defs&&e.defs.length?G`<defs>${e.defs.map(n=>G`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>G`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${z(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:R,De=e=>G`${e.map((n,t)=>{let r=n.title?G`<title>${n.title}</title>`:R,i=n.item?t:void 0;switch(n.kind){case"path":return G`<path data-skdx-part=${n.part} data-skdx-i=${z(i)} d=${n.d} fill=${n.fill??"none"} stroke=${z(n.stroke)} stroke-width=${z(n.strokeWidth)} stroke-linecap=${z(n.strokeLinecap)} stroke-linejoin=${z(n.strokeLinejoin)} stroke-dasharray=${z(n.dash)} opacity=${z(n.opacity)} fill-opacity=${z(n.fillOpacity)}>${r}</path>`;case"rect":return G`<rect data-skdx-part=${n.part} data-skdx-i=${z(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${z(n.rx)} fill=${n.fill} stroke=${z(n.stroke)} fill-opacity=${z(n.opacity)}>${r}</rect>`;case"line":return G`<line data-skdx-part=${n.part} data-skdx-i=${z(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${z(n.strokeWidth)} stroke-dasharray=${z(n.dash)} opacity=${z(n.opacity)}>${r}</line>`;case"circle":return G`<circle data-skdx-part=${n.part} data-skdx-i=${z(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${z(n.stroke)} opacity=${z(n.opacity)}>${r}</circle>`;case"text":return G`<text data-skdx-part=${n.part} data-skdx-i=${z(i)} x=${n.x} y=${n.y} text-anchor=${z(n.anchor)} dominant-baseline=${z(n.baseline)} fill=${z(n.fill)} font-weight=${z(n.weight)} pointer-events=${z(i===void 0?"none":void 0)} transform=${z(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var P=class extends ${constructor(){super(...arguments);this.series=[];this.labels=!1}render(){let{series:t,sizeRange:r,labels:i,xAxis:o,yAxis:a,zAxis:l,references:s,annotations:c,colorScale:d,colorLegend:u,hitRadius:m,jitter:b,trendline:x,sampling:p}=this;return this.root(Ye({...this.sized(),series:t,sizeRange:r,labels:i,xAxis:o,yAxis:a,zAxis:l,references:s,annotations:c,colorScale:d,colorLegend:u,hitRadius:m,jitter:b,trendline:x,sampling:p}),"bubble",this.label??"Bubble chart")}};g([D({attribute:!1})],P.prototype,"series",2),g([D({attribute:!1})],P.prototype,"sizeRange",2),g([D({type:Boolean,reflect:!0})],P.prototype,"labels",2),g([D({attribute:!1})],P.prototype,"xAxis",2),g([D({attribute:!1})],P.prototype,"yAxis",2),g([D({attribute:!1})],P.prototype,"zAxis",2),g([D({attribute:!1})],P.prototype,"references",2),g([D({attribute:!1})],P.prototype,"annotations",2),g([D({attribute:!1})],P.prototype,"colorScale",2),g([D({attribute:!1})],P.prototype,"colorLegend",2),g([D({type:Number,attribute:"hit-radius"})],P.prototype,"hitRadius",2),g([D({type:Number})],P.prototype,"jitter",2),g([D({attribute:!1})],P.prototype,"trendline",2),g([D({attribute:!1})],P.prototype,"sampling",2),P=g([Wn("skdx-bubble-chart")],P);export{P as SkdxBubbleChart};