vanilla-breeze 0.1.1 → 0.1.3
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.
- package/dist/cdn/components/accordion-wc.js +1 -1
- package/dist/cdn/components/analytics-panel.js +34 -0
- package/dist/cdn/components/audio-player.js +1 -1
- package/dist/cdn/components/audio-visualizer.js +2 -2
- package/dist/cdn/components/author-index.js +3 -0
- package/dist/cdn/components/brand-mark.js +2 -0
- package/dist/cdn/components/calendar-wc.js +2 -2
- package/dist/cdn/components/card-list.js +1 -1
- package/dist/cdn/components/carousel-wc.js +1 -1
- package/dist/cdn/components/change-set.js +1 -1
- package/dist/cdn/components/chart-wc.js +11 -11
- package/dist/cdn/components/chat-input.js +1 -1
- package/dist/cdn/components/chat-window.js +1 -1
- package/dist/cdn/components/color-palette.js +13 -7
- package/dist/cdn/components/color-picker.js +1 -1
- package/dist/cdn/components/combo-box.js +1 -1
- package/dist/cdn/components/command-palette.js +1 -1
- package/dist/cdn/components/comment-wc.js +2 -0
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/component-sampler.js +4 -4
- package/dist/cdn/components/consent-banner.js +1 -1
- package/dist/cdn/components/content-lens.js +2 -0
- package/dist/cdn/components/content-swap.js +1 -1
- package/dist/cdn/components/context-menu.js +1 -1
- package/dist/cdn/components/data-table.js +1 -1
- package/dist/cdn/components/date-picker.js +1 -1
- package/dist/cdn/components/day-view.js +1 -1
- package/dist/cdn/components/drag-surface.js +1 -1
- package/dist/cdn/components/drop-down.js +1 -1
- package/dist/cdn/components/emoji-picker.js +1 -1
- package/dist/cdn/components/flow-diagram.js +1 -1
- package/dist/cdn/components/font-pairer.js +108 -0
- package/dist/cdn/components/foot-notes.js +1 -1
- package/dist/cdn/components/form-field.js +1 -1
- package/dist/cdn/components/gantt-chart.js +1 -1
- package/dist/cdn/components/geo-map.js +7 -7
- package/dist/cdn/components/glossary-index.js +1 -1
- package/dist/cdn/components/glossary-wc.js +1 -1
- package/dist/cdn/components/gradient-builder.js +52 -0
- package/dist/cdn/components/heading-links.js +1 -1
- package/dist/cdn/components/highlight-wc.js +3 -0
- package/dist/cdn/components/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/impact-effort.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/kanban-board.js +1 -1
- package/dist/cdn/components/manifest.json +153 -81
- package/dist/cdn/components/markdown-editor.js +1 -1
- package/dist/cdn/components/markdown-viewer.js +4 -4
- package/dist/cdn/components/motion-specimen.js +21 -0
- package/dist/cdn/components/note-wc.js +3 -0
- package/dist/cdn/components/notification-wc.js +37 -0
- package/dist/cdn/components/page-info.js +55 -24
- package/dist/cdn/components/page-stats.js +1 -1
- package/dist/cdn/components/page-toc.js +1 -1
- package/dist/cdn/components/page-tools.js +1 -1
- package/dist/cdn/components/page-tour.js +2 -2
- package/dist/cdn/components/palette-generator.js +1 -1
- package/dist/cdn/components/popularity-index.js +9 -0
- package/dist/cdn/components/print-page.js +1 -1
- package/dist/cdn/components/qr-code.js +1 -1
- package/dist/cdn/components/reader-view.js +2 -2
- package/dist/cdn/components/recently-visited.js +27 -0
- package/dist/cdn/components/review-surface.js +11 -11
- package/dist/cdn/components/selection-menu.js +2 -0
- package/dist/cdn/components/semantic-palette.js +30 -0
- package/dist/cdn/components/settings-panel.js +55 -51
- package/dist/cdn/components/share-wc.js +2 -2
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -1
- package/dist/cdn/components/site-map-wc.js +1 -1
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +3 -3
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/spacing-specimen.js +5 -5
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/story-map.js +1 -1
- package/dist/cdn/components/tab-set.js +1 -1
- package/dist/cdn/components/text-reader.js +2 -2
- package/dist/cdn/components/theme-export.js +18 -0
- package/dist/cdn/components/theme-picker.js +59 -59
- package/dist/cdn/components/time-index.js +1 -1
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +1 -1
- package/dist/cdn/components/token-specimen.js +25 -20
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +4 -0
- package/dist/cdn/components/trust-filter.js +4 -0
- package/dist/cdn/components/type-specimen.js +16 -13
- package/dist/cdn/components/user-story.js +8 -8
- package/dist/cdn/components/video-player.js +4 -4
- package/dist/cdn/components/watch-wc.js +3 -0
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/work-item.js +14 -14
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/packs/design-system.full.js +124 -47
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/kawaii.full.css +1 -1
- package/dist/cdn/packs/kawaii.full.js +1 -1
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +8 -38
- package/dist/cdn/packs/ui.full.css +1 -1
- package/dist/cdn/packs/ui.full.js +51 -51
- package/dist/cdn/packs/ux-planning.full.js +122 -122
- package/dist/cdn/themes/alpha1999.css +1 -1
- package/dist/cdn/themes/brutalist.css +1 -1
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/genai.css +1 -1
- package/dist/cdn/themes/kawaii.css +1 -1
- package/dist/cdn/themes/magna.css +1 -1
- package/dist/cdn/themes/manifest.json +12 -12
- package/dist/cdn/themes/nes.css +1 -1
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/rough.css +1 -1
- package/dist/cdn/themes/startup.css +1 -1
- package/dist/cdn/themes/super2026.css +1 -1
- package/dist/cdn/themes/win9x.css +1 -1
- package/dist/cdn/vanilla-breeze-charts.css +1 -1
- package/dist/cdn/vanilla-breeze-charts.js +11 -11
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +119 -47
- package/dist/cdn/vanilla-breeze-extras.js +154 -74
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +629 -248
- package/package.json +12 -7
- package/dist/cdn/packs/retro.bundle.js +0 -2
- package/dist/cdn/packs/retro.components.js +0 -1
- package/dist/cdn/packs/retro.effects.css +0 -2
- package/dist/cdn/packs/retro.effects.js +0 -16
- package/dist/cdn/packs/retro.full.css +0 -5
- package/dist/cdn/packs/retro.full.js +0 -16
- package/dist/cdn/packs/retro.theme.css +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function M(l){return String(l).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function
|
|
1
|
+
function M(l){return String(l).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function lt(l){let t=M(String(l));return t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/`(.+?)`/g,"<code>$1</code>"),t=t.replace(/\n/g,"<br>"),t}function z(l){if(!l||typeof l!="object"||Array.isArray(l))return!1;let t=Object.getPrototypeOf(l);return t===Object.prototype||t===null}function A(l){let t=l.toFixed(2);return parseFloat(t[t.length-1]==="0"?l.toFixed(1):t)}function ct(l){return t(l);function t(o){let i="";for(let s in o.options)if(Object.hasOwn(o.options,s)){let r=s,a=o.options[s];if(s==="class"){if(!Array.isArray(a))throw new Error("Wrong argument to class");a="",o.options[s].forEach(c=>{a+=(a===""?"":" ")+`svc-${c}`})}i+=(i===""?"":" ")+`${r}="${M(String(a))}"`}if(o.children.length>0){let s="";return o.children.forEach(function(r){s+=(i===""?"":" ")+t(r)}),`<${o.tagName}${e(i)}>${s}</${o.tagName}>`}else return typeof o.innerHTML<"u"?`<${o.tagName}${e(i)}>${o.innerHTML}</${o.tagName}>`:`<${o.tagName}${e(i)}></${o.tagName}>`}function e(o){return o===""?o:" "+o}}function G(l,t){return o(l,t);function e(i){return z(i)}function o(i,...s){if(!s.length)return i;let r=s.shift();if(e(i)&&e(r))for(let a in r)e(r[a])?(i[a]||Object.assign(i,{[a]:{}}),o(i[a],r[a])):Object.assign(i,{[a]:r[a]});return o(i,...s)}}function dt(l,t){let e=l,o=t.split(".");for(let i=0;i<o.length;i++)if(e=e[o[i]],!e)return!1;return!0}var pt=class{constructor(t="div",e={}){this.children=[],this.tagName=t,this.options={},Object.assign(this.options,e)}set textContent(t){this.innerHTML=M(t)}appendChild(t){this.children.push(t)}prependChild(t){this.children.unshift(t)}removeChild(t){let e=this.children.indexOf(t);e!==-1&&this.children.splice(e,1)}setAttrs(t){Object.assign(this.options,t)}setAttribute(t,e){this.options[t]=e}},y=pt;var be=0,ht=class l{constructor(t,...e){this.config=e.reduce((o,i)=>G(o,i),{}),this.palette=t||l.defaultPalette(),z(this.palette[0])||(this.palette=this.palette.map(o=>({primary:o,secondary:o}))),this.defs=this.createDefs(),G(this.config.l,l.layoutProperties())}static layoutProperties(){return{wrap:{style:{background:"var(--color-surface, #fff)"}},top:{style:{"justify-content":"center","align-items":"center","padding-block":"0.5em 2em","padding-inline":"0.2em"}},ticks:{x:{style:{height:"10px"}},y:{style:{width:"1%"}}}}}static defaultPalette(){return[{primary:"var(--chart-series-1, #3b82f6)",secondary:"var(--chart-series-1, #3b82f6)"},{primary:"var(--chart-series-2, #ef4444)",secondary:"var(--chart-series-2, #ef4444)"},{primary:"var(--chart-series-3, #8b5cf6)",secondary:"var(--chart-series-3, #8b5cf6)"},{primary:"var(--chart-series-4, #f59e0b)",secondary:"var(--chart-series-4, #f59e0b)"},{primary:"var(--chart-series-5, #10b981)",secondary:"var(--chart-series-5, #10b981)"}]}createDefs(){let t=[];return z(this.palette[0])&&z(this.palette[0].primary)&&this.palette.forEach((e,o)=>{Object.keys(e).forEach(i=>{let{url:s,def:r}=this.generateGradient(e[i],o,i);e[i]=`url(#${s})`,t.push(r)})}),t}generateGradient(t,e,o){let i=t.orientation||"vertical",s="svc-grad-"+e+"-"+o+"-"+be++,r=new y("linearGradient",{id:s,x1:"0%",y1:"0%",x2:i==="vertical"?"0%":"100%",y2:i==="vertical"?"100%":"0%"});return Object.keys(t).forEach(a=>{isNaN(parseInt(a))||r.appendChild(new y("stop",{offset:a+"%","stop-color":t[a]}))}),{url:s,def:r}}applyPalette(t){for(let o in t)if(Object.hasOwn(t,o)){let i=e(o,this.config);if(!i)continue;let s=t[o];i.instances||(i.instances=[]),this.palette.forEach((r,a)=>{let c={};for(let n in s)if(Object.hasOwn(s,n)){let u=s[n];Object.prototype.hasOwnProperty.call(r,u)?c[n]=r[u]:c[n]=u}i.instances[a]?Object.keys(c).forEach(n=>{typeof i.instances[a][n]>"u"&&(i.instances[a][n]=c[n])}):i.instances.push(c)})}function e(o,i){let s=o.split("."),r=i,a=!1;return s.forEach(c=>{r[c]?r=r[c]:a=!0}),a?null:r}}},ot=ht;var ut=class{constructor(t){this.config=t}static get defaults(){return{l:{top:{breakpoint:{width:200,height:150}}},title:{enabled:!0,text:"Title",style:{"text-align":"center",width:"100%","font-weight":400,"font-size":"var(--chart-title-size, 1.4rem)",color:"var(--chart-title-color, #444)","text-anchor":"middle","alignment-baseline":"middle"},subtitle:{style:{"font-size":"var(--chart-subtitle-size, 0.9rem)",color:"var(--chart-subtitle-color, var(--chart-label-color, #737373))","font-weight":300}}}}}render(){let t=this.config.title,e=new y("div",{class:["title"]}),o=t.markdown!==!1&&xe(t.text),i=o?lt(t.text):M(t.text);return t.subtitle&&typeof t.subtitle=="string"?e.innerHTML=`<span class="svc-title-text">${i}</span><div class="svc-subtitle">${Qt(t.subtitle,o)}</div>`:t.subtitle&&t.subtitle.text?e.innerHTML=`<span class="svc-title-text">${i}</span><div class="svc-subtitle">${Qt(t.subtitle.text,o)}</div>`:e.innerHTML=i,e}};function xe(l){return/\*\*.+?\*\*|\*.+?\*|`.+?`|\n/.test(String(l))}function Qt(l,t){return t?lt(l):M(l)}var ft=ut;var ve=0,mt=class{constructor({config:t,data:e}){this.config=t,this.data=e}static get defaults(){return{l:{},legend:{breakpoint:{width:300,height:275},enabled:!0,style:{margin:0,padding:0,"flex-direction":"column","flex-wrap":"wrap","justify-content":"center","background-color":"var(--color-surface, rgba(255,255,255,0.8))","z-index":2},item:{style:{display:"flex","align-items":"center",padding:"0.5em",color:"var(--chart-label-color, #616161)","white-space":"nowrap"}}}}}render(t,e,o,i){return this.createLegend(o)}createLegend(t){let e=new y("ul",{class:["legend"]}),o=ve++;return(t!=="pie"?this.data.map((s,r)=>({name:s.name||"Series "+r,index:r})):Object.keys(this.data).map((s,r)=>({name:s,index:r}))).forEach(({name:s,index:r})=>{let a=this._getSeriesColor(r),c=new y("li",{class:["legend-item"]}),n=`legend-item-${r}-${o}`,u=new y("input",{type:"checkbox",id:n,"data-series":r,checked:"",style:`--_series-color: ${a}`});c.appendChild(u);let p=new y("label",{id:`legend-item-text-${r}-${o}`,for:n});p.textContent=s,c.appendChild(p),e.appendChild(c)}),e}_getSeriesColor(t){let e;return this.config.plot.instances&&this.config.plot.instances.length>0?e=this.config.plot.instances[t%this.config.plot.instances.length]:this.config.plot.node?.instances&&this.config.plot.node.instances.length>0&&(e=this.config.plot.node.instances[t%this.config.plot.node.instances.length]),e&&e.stroke?e.stroke:e&&e.fill?e.fill:"#777"}},gt=mt;var yt=class{constructor({stats:t,data:e,config:o,type:i}){this.data=e,this.config=o,this.type=i,i!=="pie"&&(this.min=t.y.min,this.max=t.y.max,this.stats=t)}static get defaults(){return{tooltip:{breakpoint:{width:275,height:275},enabled:!0,container:{style:{display:"flex"}},crosshair:{style:{"z-index":-1}},label:{style:{"background-color":"var(--chart-tooltip-bg, var(--color-surface, #fff))","box-shadow":"var(--chart-tooltip-shadow, 0 2px 4px rgba(0, 0, 0, 0.2))",color:"var(--chart-tooltip-color, var(--chart-label-color, #737373))",padding:"1em","z-index":2},title:{instances:[]}}}}}render(){return{tooltip:this.createDOM(),htmlTooltip:this._createHTMLTooltip()}}createDOM(){return this._createCartesianTooltip()}_createCartesianTooltip(){let t=new y("g",{id:"svc-tooltip-box",class:["tooltip","hide"]}),e=new y("line",{class:["tooltip-crosshair"],y1:"-10%",y2:"-10%",x1:"-10%",x2:"-10%",stroke:"var(--chart-crosshair-color, #777)"});return t.appendChild(e),t.appendChild(this._createTooltipForeignObject("svc-tooltip-label",["tooltip-label","hide"],{role:"tooltip","aria-live":"polite"})),t}_createRingTooltip(){let t=new y("g",{id:"svc-center-label-box",class:["tooltip","hide"]});return t.appendChild(this._createTooltipForeignObject("svc-center-label",["center-label"],{"aria-live":"polite"})),t}_createHTMLTooltip(){let t=new y("line",{class:["tooltip-crosshair"],y1:"-10%",y2:"-10%",x1:"-10%",x2:"-10%",stroke:"var(--chart-crosshair-color, #777)"}),e=new y("div",{id:"svc-tooltip-box",class:["tooltip","hide"],style:"position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;"}),o=new y("div",{class:["tooltip-container"],style:"position:absolute;pointer-events:auto;"}),i=new y("div",{id:"svc-tooltip-label",class:["tooltip-label","hide"],role:"tooltip","aria-live":"polite"});return o.appendChild(i),e.appendChild(o),{crosshair:t,tooltipBox:e}}_createTooltipForeignObject(t,e,o){let i=new y("foreignObject",{class:["tooltip-fo"],width:"100%",height:"100%"}),s=new y("body",{xmlns:"http://www.w3.org/1999/xhtml",style:"width:100%;height:100%;"});i.appendChild(s),s.appendChild(new y("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}));let r=new y("div",{class:["tooltip-container"]});s.appendChild(r);let a=new y("div",{id:t,class:e,...o});return r.appendChild(a),i}},j=yt;var we=`
|
|
2
2
|
/* \u2500\u2500 Custom chart elements \u2500\u2500 */
|
|
3
3
|
chart-title,
|
|
4
4
|
chart-body,
|
|
@@ -287,18 +287,18 @@ path.svc-focus {
|
|
|
287
287
|
.svc-title, .svc-text-label * { font-size: 0.9rem; }
|
|
288
288
|
.svc-tooltip-fo { font-size: 0.9rem; }
|
|
289
289
|
}
|
|
290
|
-
`,
|
|
290
|
+
`,Jt=we;var bt=class{constructor(){this.sheet=Jt,this.rules=[]}addRule(t,e){let o="";Object.keys(e).forEach(i=>{o+=`${i}: ${e[i]};`}),this.sheet+=`.svc-${t}{${o}}`}addRaw(t){this.sheet+=t}convertconfig(t,e,o){let i={width:{},height:{}},s=c(t),r=a(i);return s+r;function a(n){let u="";return Object.keys(n).forEach(p=>{Object.keys(n[p]).forEach(d=>{let h=n[p][d],g=`@media(max-${p}: ${d}px){`,f=h.map(m=>`.svc-${m}.svc-${m}`);g+=f.join(","),g+="{ display: none; }",g+="}",u+=g})}),u}function c(n,u="",p="",d=[]){for(let h in n)if(h==="style"){let g="";for(let f in n[h])Object.hasOwn(n[h],f)&&(g+=`${f}:${n[h][f]};`);if(d.length===0)p+=`figure[data-chart-id] {${g}}`;else{let f=d.reduce((m,b)=>m+=(m===""?"":"-")+b,"");p+=`.svc-${f}{${g}}`}}else if(h==="instances"){let g=n[h];for(let f=0;f<e;f++){let m=g[f];if(!m)continue;let b="";for(let x in m)Object.hasOwn(m,x)&&(b+=`${x}:${m[x]};`);if(b!==""){let x=d.reduce((w,C)=>w+=(w===""?"":"-")+C,""),v=o?`[data-chart-id="${o}"] `:"";p+=`${v}.svc-${x}-${f} {${b}}`}}}else if(h==="breakpoint"){let g=d.reduce((f,m)=>f+=(f===""?"":"-")+m,"");i.width[n.breakpoint.width]?i.width[n.breakpoint.width].push(g):i.width[n.breakpoint.width]=[g],i.height[n.breakpoint.height]?i.height[n.breakpoint.height].push(g):i.height[n.breakpoint.height]=[g]}else typeof n[h]=="object"&&(d.push(h),p=c(n[h],h,p,d),d.pop());return p}}},te=bt;function Ce({interactive:l=!1}={}){let t=new y("svg");t.setAttrs({width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",role:l?"graphics-document":"img","aria-roledescription":"chart"});let e=new y("foreignObject",{width:"100%",height:"100%"});t.appendChild(e);let o=new y("body",{xmlns:"http://www.w3.org/1999/xhtml",style:"width:100%;height:100%;"});e.appendChild(o),o.appendChild(new y("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}));let i=new y("figure");o.appendChild(i);let s=new y("chart-title");i.appendChild(s);let r=new y("chart-body");i.appendChild(r);let a=new y("chart-canvas");r.appendChild(a);let c=new y("chart-label",{position:"y"});a.appendChild(c);let n=new y("chart-axis",{position:"y"});a.appendChild(n);let u=new y("svg",{width:"100%",xmlns:"http://www.w3.org/2000/svg",class:["ticks-y"]});a.appendChild(u);let p=new y("chart-plot");a.appendChild(p);let d=new y("svg");d.setAttrs({width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",class:["plotarea"]}),p.appendChild(d);let h=new y("div"),g=new y("div"),f=new y("div"),m=new y("svg",{width:"100%",xmlns:"http://www.w3.org/2000/svg",class:["ticks-x"]});a.appendChild(m);let b=new y("chart-axis",{position:"x"});a.appendChild(b);let x=new y("chart-label",{position:"x"});a.appendChild(x),d.appendChild(new y("rect",{x:"0%",y:"0%",width:"100%",height:"100%",class:["plotarea"]}));let v=new y("text",{x:"50%",y:"50%",class:["loading"]});return v.innerHTML="Loading Chart...",d.appendChild(v),{root:t,wrap:i,top:s,body:r,plotarea:p,layoutChart:d,layoutXAxis:b,layoutYTicks:u,layoutXTicks:m,layoutYAxis:n,layoutOriginRight:f,layoutOriginCenter:g,layoutXAxisLabel:x,layoutYAxisLabel:c,layoutOriginLeft:h}}var ee=Ce;var ke=new Set(["onInteraction","onResize","onClick"]),xt=class{#t=new Map;register(t,e){this.#t.has(t)||this.#t.set(t,new Set),this.#t.get(t).add(e)}unregister(t,e){let o=this.#t.get(t);o&&o.delete(e)}run(t,e){if(ke.has(t)&&typeof document>"u")return;let o=this.#t.get(t);if(o)for(let i of o)i(e)}registerPlugin(t){if(!(!t||!t.hooks))for(let[e,o]of Object.entries(t.hooks))this.register(e,o)}destroy(){this.#t.clear()}},oe=xt;function vt(l){return JSON.stringify(l).replace(/<\//g,"<\\/").replace(/]]>/g,"]]\\>").replace(/<!--/g,"<\\!--").replace(/<\?/g,"<\\?")}var wt=class{hooks=new oe;toFile(t={}){let e=c(t),o=`<?xml version="1.0" standalone="no"?>
|
|
291
291
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">`,i=this.structure,{body:s}=i,r;e.includeScripts&&(r=this._createScripts(this.structure),s.appendChild(r));let a=this.compile(i.root);return e.includeScripts&&r&&s.removeChild(r),e.prerendered&&(a=a.slice(0,a.indexOf("svg")+3)+' data-prerendered=""'+a.slice(a.indexOf("svg")+3)),o+a;function c(n){if(typeof n=="object"&&n!==null){let u=!!n.prerendered,p=!u;return{prerendered:u,includeScripts:n.includeScripts??p}}return{prerendered:!!n,includeScripts:!0}}}toString(){return this.compile(this.structure.root)}toHTML({prerendered:t}={}){return this.compileHTML(this.structure,{prerendered:t})}async toBlob(t="image/svg+xml",{width:e=800,height:o=600}={}){if(typeof Blob>"u")throw new Error("SVC: toBlob() requires a browser environment.");let i=this.toString();if(t==="image/svg+xml")return new Blob([i],{type:"image/svg+xml"});if(t==="image/png"){if(typeof document>"u")throw new Error("SVC: PNG export requires a browser environment with Canvas.");return this._svgToPngBlob(i,e,o)}throw new Error(`SVC: Unsupported export type "${t}".`)}async toDataURL(t="image/svg+xml",e){if(typeof FileReader>"u")throw new Error("SVC: toDataURL() requires a browser environment with FileReader.");let o=await this.toBlob(t,e);return new Promise((i,s)=>{let r=new FileReader;r.onload=()=>i(r.result),r.onerror=s,r.readAsDataURL(o)})}async download(t="chart.svg",e){if(typeof document>"u")throw new Error("SVC: download() requires a browser environment.");let i=t.split(".").pop().toLowerCase()==="png"?"image/png":"image/svg+xml",s=await this.toBlob(i,e),r=URL.createObjectURL(s),a=document.createElement("a");a.href=r,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}_svgToPngBlob(t,e,o){return new Promise((i,s)=>{let r=document.createElement("canvas");r.width=e,r.height=o;let a=r.getContext("2d"),c=new Image,n=new Blob([t],{type:"image/svg+xml"}),u=URL.createObjectURL(n);c.onload=()=>{a.drawImage(c,0,0,e,o),URL.revokeObjectURL(u),r.toBlob(p=>{p?i(p):s(new Error("SVC: PNG export failed."))},"image/png")},c.onerror=()=>{URL.revokeObjectURL(u),s(new Error("SVC: Failed to load SVG for PNG export."))},c.src=u})}mount(t){if(!t||typeof document>"u")return null;t.innerHTML=this.toHTML(),this._state=this.hydrate(t),this._container=t;let e=t.host||t;return this._observeResize(e),this._state}createElement(){if(typeof document>"u")return null;let t=document.createElement("div");return this.mount(t),t}hydrate(t){if(!t)return null;let e={functions:[]};return this.interactions.forEach(o=>{e.functions[o.name]=o(e,t,this)}),this._state=e,this._container=t,e}update({data:t,config:e}={}){if(!this._container)return null;let o=this._container;return this._state&&this._state._tooltipCleanup&&this._state._tooltipCleanup(),this._state=null,t!=null&&(this.data=t),e!=null&&(G(this.config,e),this.config=this.applyConfigToDefaults(this.config).config),this.interactions=[],this.render(),o.innerHTML=this.toString(),this._state=this.hydrate(o),this._container=o,this._state}destroy(){this.hooks.run("beforeDestroy",{container:this._container,state:this._state}),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._state&&this._state._tooltipCleanup&&this._state._tooltipCleanup(),this._container&&(this._container.innerHTML=""),this._state=null,this._container=null,this.hooks.destroy()}_observeResize(t){typeof ResizeObserver>"u"||(this._resizeObserver=new ResizeObserver(e=>{let o=e[0];o&&this.hooks.run("onResize",{width:o.contentRect.width,height:o.contentRect.height,container:t})}),this._resizeObserver.observe(t))}_createScripts(t){let e=new y("script",{class:["chart-script"]}),o="",i=[];return this.interactions.forEach(s=>{o+=s.toString()+`
|
|
292
292
|
`,i.push(s.name)}),o+=`
|
|
293
293
|
var chart = {
|
|
294
|
-
stats: ${
|
|
295
|
-
data: ${
|
|
296
|
-
config: ${
|
|
294
|
+
stats: ${vt(this.stats||{})},
|
|
295
|
+
data: ${vt(this.data)},
|
|
296
|
+
config: ${vt(this.config)}
|
|
297
297
|
};
|
|
298
298
|
var svgRoot = document.currentScript.closest('svg');
|
|
299
299
|
var state = { functions: []};`,i.forEach(s=>{o+=`state.functions['${s}'] = ${s}(state, svgRoot, chart);`}),e.innerHTML=`//<![CDATA[
|
|
300
300
|
`+o+`
|
|
301
|
-
//]]>`,e}},ee=vt;function wt(l,t,e){var o=e.config&&e.config.tooltip&&e.config.tooltip.hideDelay||2e3,i=t.querySelector("chart-plot"),s=t.querySelector("#svc-tooltip-box"),r=t.querySelector("#svc-tooltip-label"),a=t.querySelector(".svc-tooltip-crosshair"),c=[],n=null,u=null;function p(){u=null}typeof window<"u"&&(window.addEventListener("scroll",p,{passive:!0}),window.addEventListener("resize",p,{passive:!0}));var d=null;typeof ResizeObserver<"u"&&(d=new ResizeObserver(p),d.observe(i));function h(){r.setAttribute("class","svc-tooltip-label svc-hide"),s.setAttribute("class","svc-tooltip svc-hide"),a.setAttribute("x1","-10%"),a.setAttribute("x2","-10%"),a.setAttribute("y1","-10%"),a.setAttribute("y2","-10%");for(var m=0;m<c.length;m++)c[m].classList.remove("svc-plot-node-active-"+m);c=[]}function g(){n&&clearTimeout(n),n=setTimeout(h,o)}i.addEventListener("mousedown",f),i.addEventListener("mousemove",f),l._tooltipCleanup=function(){n&&clearTimeout(n),i.removeEventListener("mousedown",f),i.removeEventListener("mousemove",f),typeof window<"u"&&(window.removeEventListener("scroll",p),window.removeEventListener("resize",p)),d&&(d.disconnect(),d=null)};function f(m){g();var b=l.functions.tooltipLocation(m,l,t,e);if(b){for(var x=t.querySelectorAll('.svc-plot-node[node="'+b.index+'"]'),v=0;v<c.length;v++)c[v].classList.remove("svc-plot-node-active-"+v);c=[];for(var w=0;w<x.length;w++)x[w].classList.add("svc-plot-node-active-"+w),c.push(x[w]);a.setAttribute("x1",b.crosshair.x1+"%"),a.setAttribute("x2",b.crosshair.x2+"%"),a.setAttribute("y1",b.crosshair.y1+"%"),a.setAttribute("y2",b.crosshair.y2+"%"),r.innerHTML=b.tooltip.text,r.setAttribute("class","svc-tooltip-label"),s.setAttribute("class","svc-tooltip"),u||(u=i.getBoundingClientRect());var C=u,k=r.getBoundingClientRect(),S=k.width/C.width*100,L=k.height/C.height*100,$=b.tooltip.x,E=b.tooltip.y,T=1;$+S>98&&($=$-S-T),$<0&&($=0),E+L>98&&(E=98-L),E<0&&(E=0);var O=s.querySelector("foreignObject");if(O)O.setAttribute("x",$+"%"),O.setAttribute("y",E+"%");else{var _=r.parentElement;_&&(_.style.left=$+"%",_.style.top=E+"%")}e.hooks&&e.hooks.run&&e.hooks.run("onInteraction",{type:"tooltip",event:m,data:{index:b.index,tooltip:b.tooltip},element:s})}}}function Ct(l,t,e){l.toggles=Array.from(t.querySelectorAll("chart-legend input")),l.toggles.forEach(function(o){o.removeAttribute("onclick"),o.addEventListener("click",function(i){var s=i.target.getAttribute("data-series");l.toggles[s]=i.target.checked;var r=l.toggles[s]!==!1,a=r?1:0,c=t.getElementsByClassName("svc-plot-"+s)[0];c&&(c.style.opacity=a);for(var n=t.getElementsByClassName("svc-plot-node-"+s),u=0;u<n.length;u++)n[u].style.opacity=a;e&&e.hooks&&e.hooks.run&&e.hooks.run("onInteraction",{type:"legend-toggle",event:i,data:{series:s,visible:r},element:o})})})}function kt(l,t,e){var o=t.querySelectorAll('[role="graphics-symbol"]');if(o.length===0)return;var i=-1,s=t.querySelector("chart-plot");if(!s)return;s.setAttribute("tabindex","0"),s.addEventListener("keydown",function(c){if(c.key==="ArrowRight"||c.key==="ArrowDown")c.preventDefault(),i=Math.min(i+1,o.length-1),r(i);else if(c.key==="ArrowLeft"||c.key==="ArrowUp")c.preventDefault(),i=Math.max(i-1,0),r(i);else if(c.key==="Escape"){a();var n=t.querySelector("#svc-tooltip-label");n&&n.classList.add("svc-hide"),i=-1}});function r(c){a();var n=o[c];if(n){n.classList.add("svc-focus");var u=n.getAttribute("aria-label"),p=t.querySelector("#svc-tooltip-label");p&&u&&(p.textContent=u,p.classList.remove("svc-hide"))}}function a(){for(var c=0;c<o.length;c++)o[c].classList.remove("svc-focus")}}function St(l,t,e){var o=t.querySelector("chart-plot");if(!o)return;function i(r){var a=r.target.closest('[role="graphics-symbol"]');if(a){var c={type:"click",event:r,element:a,seriesIndex:parseInt(a.getAttribute("plot")||a.getAttribute("data-series")||"0",10),dataIndex:parseInt(a.getAttribute("node")||a.getAttribute("data-index")||a.getAttribute("index")||"0",10),key:a.getAttribute("data-key")||null,value:a.getAttribute("data-value")||null,label:a.getAttribute("aria-label")||""};e.hooks&&e.hooks.run&&e.hooks.run("onClick",c)}}o.addEventListener("click",i);var s=l._dataClickCleanup;l._dataClickCleanup=function(){s&&s(),o.removeEventListener("click",i)}}var Ce=0,$t=class l extends ee{#t;#i;constructor({config:t={},data:e}){if(super({config:t,data:e}),e==null)throw new Error('SVC: "data" is required. Pass an array of series objects or a plain object for pie charts.');this.data=e,this.palette=t.palette=t.palette||et.defaultPalette();let o=this.applyConfigToDefaults(t);this.#i=o.defs,this.config=o.config,Array.isArray(this.config.plugins)&&this.config.plugins.forEach(i=>this.hooks.registerPlugin(i)),this.hooks.run("configResolved",{config:this.config,data:this.data,chartType:this.constructor.type}),this.#t=new Qt,this._scopeId="c"+Ce++,this.interactions=[],this.structure=null,this.render()}get stylesheet(){return this.#t}get defs(){return this.#i}applyConfigToDefaults(t){let e=[],o=Object.getPrototypeOf(this);for(;o.constructor.name!=="Object";)o.constructor.defaults&&e.push(o.constructor.defaults),o=Object.getPrototypeOf(o);e=e.reverse();let i={legend:mt,tooltip:j};Object.keys(i).forEach(r=>{(!t[r]||t[r].enabled)&&e.push(i[r].defaults)}),t.title&&t.title.text&&e.push(ut.defaults);let s=new et(this.palette,...e,t);return s.applyPalette(l.specs()),s.applyPalette(this.constructor.specs(s.config)),s}static get defaults(){return{palette:et.defaultPalette(),style:{"font-family":"var(--chart-font-family, inherit)","font-weight":300,color:"var(--chart-label-color, #737373)"},legend:{enabled:!0},tooltip:{enabled:!0},plot:{node:{enabled:!0,instances:[],active:{instances:[]},label:{enabled:!1,instances:[]}},instances:[],style:{overflow:"visible"}},"plot-top":{style:{overflow:"visible"}},plotarea:{style:{fill:"var(--color-surface, #fff)",overflow:"visible"}},loading:{enabled:!0,style:{"font-size":"1.5em",fill:"var(--chart-label-color, #616161)","text-anchor":"middle"}}}}static specs(){return{"plot.node.label":{fill:"primary"},"tooltip.label.title":{color:"primary"}}}render(){this.config.title&&(this.title=new ut(this.config)),this.config.legend&&(this.legend=new mt({config:this.config,data:this.data,chart:this.chart}));let t=!!(this.config.tooltip?.enabled||this.config.legend?.enabled),e=Jt({interactive:t});e.wrap.setAttribute("data-chart-id",this._scopeId);let o=this.constructor.type||"chart";if(this.config.title&&this.config.title.text){let i=M(this.config.title.text);e.root.setAttribute("aria-label",i);let s=new y("desc");s.innerHTML=`${o} chart: ${i}`,e.root.prependChild(s)}else{let i=Array.isArray(this.data)?this.data.length:Object.keys(this.data).length;e.root.setAttribute("aria-label",`${o} chart with ${i} data series`)}e=this.parse(e),this.structure=this.parseComponents(e),this.hooks.run("afterRender",{config:this.config,data:this.data,stats:this.stats,structure:this.structure})}parse(t){let{layoutChart:e}=t,o=new y("defs");return this.defs.forEach(i=>{o.appendChild(i)}),e.appendChild(o),t}parseComponents(t){let{body:e,top:o,layoutChart:i}=t;if(this.config.title&&this.config.title.enabled&&o.appendChild(this.title.render()),this.config.legend&&this.config.legend.enabled){let s=new y("chart-legend");s.appendChild(this.legend.render(null,null,this.constructor.type)),e.appendChild(s),this.interactions.push(Ct)}return this.config.tooltip&&this.config.tooltip.enabled&&(this.tooltip=new j({stats:this.stats,data:this.data,config:this.config,type:this.constructor.type}).render(),i.appendChild(this.tooltip.tooltip),typeof this.tooltipLocation=="function"&&(this.interactions.push(wt),this.interactions.push(this.tooltipLocation)),this.interactions.push(kt)),this.interactions.push(St),t}compile(t,e){return this._styleElement&&t.removeChild(this._styleElement),this._styleElement=this.compileStyles(),t.prependChild(this._styleElement),lt(t)}compileHTML(t,{prerendered:e}={}){let o=t.wrap,i=t.root,s={...o.options};i.options["aria-label"]&&o.setAttribute("aria-label",i.options["aria-label"]),i.options["aria-describedby"]&&o.setAttribute("aria-describedby",i.options["aria-describedby"]),o.setAttribute("role",i.options.role||"figure"),e&&o.setAttribute("data-prerendered",""),this._htmlStyleElement&&o.removeChild(this._htmlStyleElement),this._htmlStyleElement=this.compileStyles(),o.prependChild(this._htmlStyleElement);let r=t.layoutChart,a=t.plotarea,c=this.tooltip?.tooltip,n=this.tooltip?.htmlTooltip;c&&n&&a&&(r.removeChild(c),r.appendChild(n.crosshair),a.appendChild(n.tooltipBox));let u=lt(o);return o.options=s,this._htmlStyleElement&&o.removeChild(this._htmlStyleElement),c&&n&&a&&(r.removeChild(n.crosshair),a.removeChild(n.tooltipBox),r.appendChild(c)),u}compileStyles(){let t=new y("style"),e=this.constructor.type!=="pie"?this.data.length:Object.keys(this.data).length,o=this.stylesheet.convertconfig(this.config,e,this._scopeId)+this.stylesheet.sheet;return t.innerHTML=`@layer charts { ${o} }`,t}createGraph({stretch:t}){return t?new y("svg",{x:"0%",y:"0%",width:"100%",height:"100%",viewBox:"0, 0, 100, 100",preserveAspectRatio:"none",xmlns:"http://www.w3.org/2000/svg",class:["plot"]}):new y("svg",{x:"0%",y:"0%",width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",class:["plot-top"]})}createBackground(){return new y("rect",{width:"100%",height:"100%",x:"0%",y:"0%",class:["container"]})}createPlotArea({config:t}){return new y("rect",{x:"0%",y:"0%",width:"100%",height:"100%",class:["plotarea"]})}},ot=$t;var Et=class{constructor(t){Object.assign(this,t)}render(){let{type:t,stats:e,stroke:o,width:i}=this,{min:s,max:r}=e[t],a=Math.abs(r-s),n=Math.abs(s)/a*100;return t==="x"?new y("line",{class:["baseline","baseline-x"],x1:n.toFixed(3)+"%",y1:"0%",x2:n.toFixed(3)+"%",y2:"100%",stroke:o,"stroke-width":i}):new y("line",{class:["baseline","baseline-y"],x1:"0%",y1:(100-n).toFixed(3)+"%",x2:"100%",y2:(100-n).toFixed(3)+"%",stroke:o,"stroke-width":i})}},Lt=Et;function ke({config:l}){let t=l.scale.minFontSize,e=l.scale.maxItems,o="";o+=`
|
|
301
|
+
//]]>`,e}},ie=wt;function Ct(l,t,e){var o=e.config&&e.config.tooltip&&e.config.tooltip.hideDelay||2e3,i=t.querySelector("chart-plot"),s=t.querySelector("#svc-tooltip-box"),r=t.querySelector("#svc-tooltip-label"),a=t.querySelector(".svc-tooltip-crosshair"),c=[],n=null,u=null;function p(){u=null}typeof window<"u"&&(window.addEventListener("scroll",p,{passive:!0}),window.addEventListener("resize",p,{passive:!0}));var d=null;typeof ResizeObserver<"u"&&(d=new ResizeObserver(p),d.observe(i));function h(){r.setAttribute("class","svc-tooltip-label svc-hide"),s.setAttribute("class","svc-tooltip svc-hide"),a.setAttribute("x1","-10%"),a.setAttribute("x2","-10%"),a.setAttribute("y1","-10%"),a.setAttribute("y2","-10%");for(var m=0;m<c.length;m++)c[m].classList.remove("svc-plot-node-active-"+m);c=[]}function g(){n&&clearTimeout(n),n=setTimeout(h,o)}i.addEventListener("mousedown",f),i.addEventListener("mousemove",f),l._tooltipCleanup=function(){n&&clearTimeout(n),i.removeEventListener("mousedown",f),i.removeEventListener("mousemove",f),typeof window<"u"&&(window.removeEventListener("scroll",p),window.removeEventListener("resize",p)),d&&(d.disconnect(),d=null)};function f(m){g();var b=l.functions.tooltipLocation(m,l,t,e);if(b){for(var x=t.querySelectorAll('.svc-plot-node[node="'+b.index+'"]'),v=0;v<c.length;v++)c[v].classList.remove("svc-plot-node-active-"+v);c=[];for(var w=0;w<x.length;w++)x[w].classList.add("svc-plot-node-active-"+w),c.push(x[w]);a.setAttribute("x1",b.crosshair.x1+"%"),a.setAttribute("x2",b.crosshair.x2+"%"),a.setAttribute("y1",b.crosshair.y1+"%"),a.setAttribute("y2",b.crosshair.y2+"%"),r.innerHTML=b.tooltip.text,r.setAttribute("class","svc-tooltip-label"),s.setAttribute("class","svc-tooltip"),u||(u=i.getBoundingClientRect());var C=u,k=r.getBoundingClientRect(),S=k.width/C.width*100,L=k.height/C.height*100,$=b.tooltip.x,E=b.tooltip.y,T=1;$+S>98&&($=$-S-T),$<0&&($=0),E+L>98&&(E=98-L),E<0&&(E=0);var O=s.querySelector("foreignObject");if(O)O.setAttribute("x",$+"%"),O.setAttribute("y",E+"%");else{var _=r.parentElement;_&&(_.style.left=$+"%",_.style.top=E+"%")}e.hooks&&e.hooks.run&&e.hooks.run("onInteraction",{type:"tooltip",event:m,data:{index:b.index,tooltip:b.tooltip},element:s})}}}function kt(l,t,e){l.toggles=Array.from(t.querySelectorAll("chart-legend input")),l.toggles.forEach(function(o){o.removeAttribute("onclick"),o.addEventListener("click",function(i){var s=i.target.getAttribute("data-series");l.toggles[s]=i.target.checked;var r=l.toggles[s]!==!1,a=r?1:0,c=t.getElementsByClassName("svc-plot-"+s)[0];c&&(c.style.opacity=a);for(var n=t.getElementsByClassName("svc-plot-node-"+s),u=0;u<n.length;u++)n[u].style.opacity=a;e&&e.hooks&&e.hooks.run&&e.hooks.run("onInteraction",{type:"legend-toggle",event:i,data:{series:s,visible:r},element:o})})})}function St(l,t,e){var o=t.querySelectorAll('[role="graphics-symbol"]');if(o.length===0)return;var i=-1,s=t.querySelector("chart-plot");if(!s)return;s.setAttribute("tabindex","0"),s.addEventListener("keydown",function(c){if(c.key==="ArrowRight"||c.key==="ArrowDown")c.preventDefault(),i=Math.min(i+1,o.length-1),r(i);else if(c.key==="ArrowLeft"||c.key==="ArrowUp")c.preventDefault(),i=Math.max(i-1,0),r(i);else if(c.key==="Escape"){a();var n=t.querySelector("#svc-tooltip-label");n&&n.classList.add("svc-hide"),i=-1}});function r(c){a();var n=o[c];if(n){n.classList.add("svc-focus");var u=n.getAttribute("aria-label"),p=t.querySelector("#svc-tooltip-label");p&&u&&(p.textContent=u,p.classList.remove("svc-hide"))}}function a(){for(var c=0;c<o.length;c++)o[c].classList.remove("svc-focus")}}function $t(l,t,e){var o=t.querySelector("chart-plot");if(!o)return;function i(r){var a=r.target.closest('[role="graphics-symbol"]');if(a){var c={type:"click",event:r,element:a,seriesIndex:parseInt(a.getAttribute("plot")||a.getAttribute("data-series")||"0",10),dataIndex:parseInt(a.getAttribute("node")||a.getAttribute("data-index")||a.getAttribute("index")||"0",10),key:a.getAttribute("data-key")||null,value:a.getAttribute("data-value")||null,label:a.getAttribute("aria-label")||""};e.hooks&&e.hooks.run&&e.hooks.run("onClick",c)}}o.addEventListener("click",i);var s=l._dataClickCleanup;l._dataClickCleanup=function(){s&&s(),o.removeEventListener("click",i)}}var Se=0,Et=class l extends ie{#t;#i;constructor({config:t={},data:e}){if(super({config:t,data:e}),e==null)throw new Error('SVC: "data" is required. Pass an array of series objects or a plain object for pie charts.');this.data=e,this.palette=t.palette=t.palette||ot.defaultPalette();let o=this.applyConfigToDefaults(t);this.#i=o.defs,this.config=o.config,Array.isArray(this.config.plugins)&&this.config.plugins.forEach(i=>this.hooks.registerPlugin(i)),this.hooks.run("configResolved",{config:this.config,data:this.data,chartType:this.constructor.type}),this.#t=new te,this._scopeId="c"+Se++,this.interactions=[],this.structure=null,this.render()}get stylesheet(){return this.#t}get defs(){return this.#i}applyConfigToDefaults(t){let e=[],o=Object.getPrototypeOf(this);for(;o.constructor.name!=="Object";)o.constructor.defaults&&e.push(o.constructor.defaults),o=Object.getPrototypeOf(o);e=e.reverse();let i={legend:gt,tooltip:j};Object.keys(i).forEach(r=>{(!t[r]||t[r].enabled)&&e.push(i[r].defaults)}),t.title&&t.title.text&&e.push(ft.defaults);let s=new ot(this.palette,...e,t);return s.applyPalette(l.specs()),s.applyPalette(this.constructor.specs(s.config)),s}static get defaults(){return{palette:ot.defaultPalette(),style:{"font-family":"var(--chart-font-family, inherit)","font-weight":300,color:"var(--chart-label-color, #737373)"},legend:{enabled:!0},tooltip:{enabled:!0},plot:{node:{enabled:!0,instances:[],active:{instances:[]},label:{enabled:!1,instances:[]}},instances:[],style:{overflow:"visible"}},"plot-top":{style:{overflow:"visible"}},plotarea:{style:{fill:"var(--color-surface, #fff)",overflow:"visible"}},loading:{enabled:!0,style:{"font-size":"1.5em",fill:"var(--chart-label-color, #616161)","text-anchor":"middle"}}}}static specs(){return{"plot.node.label":{fill:"primary"},"tooltip.label.title":{color:"primary"}}}render(){this.config.title&&(this.title=new ft(this.config)),this.config.legend&&(this.legend=new gt({config:this.config,data:this.data,chart:this.chart}));let t=!!(this.config.tooltip?.enabled||this.config.legend?.enabled),e=ee({interactive:t});e.wrap.setAttribute("data-chart-id",this._scopeId);let o=this.constructor.type||"chart";if(this.config.title&&this.config.title.text){let i=M(this.config.title.text);e.root.setAttribute("aria-label",i);let s=new y("desc");s.innerHTML=`${o} chart: ${i}`,e.root.prependChild(s)}else{let i=Array.isArray(this.data)?this.data.length:Object.keys(this.data).length;e.root.setAttribute("aria-label",`${o} chart with ${i} data series`)}e=this.parse(e),this.structure=this.parseComponents(e),this.hooks.run("afterRender",{config:this.config,data:this.data,stats:this.stats,structure:this.structure})}parse(t){let{layoutChart:e}=t,o=new y("defs");return this.defs.forEach(i=>{o.appendChild(i)}),e.appendChild(o),t}parseComponents(t){let{body:e,top:o,layoutChart:i}=t;if(this.config.title&&this.config.title.enabled&&o.appendChild(this.title.render()),this.config.legend&&this.config.legend.enabled){let s=new y("chart-legend");s.appendChild(this.legend.render(null,null,this.constructor.type)),e.appendChild(s),this.interactions.push(kt)}return this.config.tooltip&&this.config.tooltip.enabled&&(this.tooltip=new j({stats:this.stats,data:this.data,config:this.config,type:this.constructor.type}).render(),i.appendChild(this.tooltip.tooltip),typeof this.tooltipLocation=="function"&&(this.interactions.push(Ct),this.interactions.push(this.tooltipLocation)),this.interactions.push(St)),this.interactions.push($t),t}compile(t,e){return this._styleElement&&t.removeChild(this._styleElement),this._styleElement=this.compileStyles(),t.prependChild(this._styleElement),ct(t)}compileHTML(t,{prerendered:e}={}){let o=t.wrap,i=t.root,s={...o.options};i.options["aria-label"]&&o.setAttribute("aria-label",i.options["aria-label"]),i.options["aria-describedby"]&&o.setAttribute("aria-describedby",i.options["aria-describedby"]),o.setAttribute("role",i.options.role||"figure"),e&&o.setAttribute("data-prerendered",""),this._htmlStyleElement&&o.removeChild(this._htmlStyleElement),this._htmlStyleElement=this.compileStyles(),o.prependChild(this._htmlStyleElement);let r=t.layoutChart,a=t.plotarea,c=this.tooltip?.tooltip,n=this.tooltip?.htmlTooltip;c&&n&&a&&(r.removeChild(c),r.appendChild(n.crosshair),a.appendChild(n.tooltipBox));let u=ct(o);return o.options=s,this._htmlStyleElement&&o.removeChild(this._htmlStyleElement),c&&n&&a&&(r.removeChild(n.crosshair),a.removeChild(n.tooltipBox),r.appendChild(c)),u}compileStyles(){let t=new y("style"),e=this.constructor.type!=="pie"?this.data.length:Object.keys(this.data).length,o=this.stylesheet.convertconfig(this.config,e,this._scopeId)+this.stylesheet.sheet;return t.innerHTML=`@layer charts { ${o} }`,t}createGraph({stretch:t}){return t?new y("svg",{x:"0%",y:"0%",width:"100%",height:"100%",viewBox:"0, 0, 100, 100",preserveAspectRatio:"none",xmlns:"http://www.w3.org/2000/svg",class:["plot"]}):new y("svg",{x:"0%",y:"0%",width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",class:["plot-top"]})}createBackground(){return new y("rect",{width:"100%",height:"100%",x:"0%",y:"0%",class:["container"]})}createPlotArea({config:t}){return new y("rect",{x:"0%",y:"0%",width:"100%",height:"100%",class:["plotarea"]})}},it=Et;var Lt=class{constructor(t){Object.assign(this,t)}render(){let{type:t,stats:e,stroke:o,width:i}=this,{min:s,max:r}=e[t],a=Math.abs(r-s),n=Math.abs(s)/a*100;return t==="x"?new y("line",{class:["baseline","baseline-x"],x1:n.toFixed(3)+"%",y1:"0%",x2:n.toFixed(3)+"%",y2:"100%",stroke:o,"stroke-width":i}):new y("line",{class:["baseline","baseline-y"],x1:"0%",y1:(100-n).toFixed(3)+"%",x2:"100%",y2:(100-n).toFixed(3)+"%",stroke:o,"stroke-width":i})}},Mt=Lt;function $e({config:l}){let t=l.scale.minFontSize,e=l.scale.maxItems,o="";o+=`
|
|
302
302
|
.svc-scale-label-x,
|
|
303
303
|
.svc-scale-label-y,
|
|
304
304
|
.svc-guides-x,
|
|
@@ -382,14 +382,14 @@ path.svc-focus {
|
|
|
382
382
|
opacity: 1;
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
`,o+=u}),o}var oe=ke;function At(l,t,e){if(!Array.isArray(l)||l.length===0)throw new Error('SVC: "data" must be a non-empty array of series objects.');for(let u=0;u<l.length;u++)if(!l[u]||l[u].values==null)throw new Error(`SVC: data[${u}] must have a "values" property.`);if(e!=="scatter"&&e!=="bubble")for(let u=0;u<l.length;u++){let p=l[u].values,d=Array.isArray(p)?p:Object.values(p);for(let h=0;h<d.length;h++)if(d[h]!=null&&typeof d[h]!="number")throw new Error(`SVC: data[${u}].values contains non-numeric value "${d[h]}" at position ${h}.`)}let o={min:1/0,max:-1/0,ticks:4,scale:0},i={min:1/0,max:-1/0,ticks:6,scale:0},s={min:1/0,max:-1/0},r=!1,a=-1/0;if(e==="scatter"||e==="bubble")Object.assign(o,it(l,"x")),Object.assign(i,it(l,"y")),e==="bubble"&&Object.assign(s,it(l,"size"));else if(Array.isArray(l[0].values)){let u=l.reduce((d,h)=>d.concat(h.values),[]).sort((d,h)=>d-h);if(t.plot&&t.plot.stacked){let d=Math.max(...l.map(f=>f.values.length)),h=0,g=0;for(let f=0;f<d;f++){let m=0,b=0;l.forEach(x=>{let v=x.values[f]||0;v>=0?m+=v:b+=v}),h=Math.max(h,m),g=Math.min(g,b)}i.min=g,i.max=h}else i.min=u[0],i.max=u[u.length-1];let p=l[0].values.length;l.forEach((d,h)=>{d.values.length!==p&&console.warn(`SVC: Series ${h} has ${d.values.length} values, but series 0 has ${p}. Mismatched lengths may cause unexpected results.`),a=d.values.length>a?d.values.length:a}),o.min=0,o.max=a}else{r=!0;let u=l.reduce((d,h)=>d.concat(Object.keys(h.values).map(g=>h.values[g])),[]).sort((d,h)=>d-h),p={};if(l.forEach(d=>{Object.assign(p,d.values)}),p=Object.keys(p),t.scale.sorted&&p.sort(),t.plot&&t.plot.stacked){let d=0,h=0;p.forEach(g=>{let f=0,m=0;l.forEach(b=>{let x=b.values[g]||0;x>=0?f+=x:m+=x}),d=Math.max(d,f),h=Math.min(h,m)}),i.min=h,i.max=d}else i.min=u[0],i.max=u[u.length-1];o.keys=p,o.min=0,o.max=a=p.length}let c=e==="scatter"||e==="bubble";Object.assign(i,Mt(i,{forceZeroMin:!c})),c?Object.assign(o,Mt(o,{forceZeroMin:!1})):e==="bar"||e==="column"?(a>t.scale.maxItems?(o.ticks=t.scale.maxItems,o.step=Math.floor(a/(o.ticks-1))):(o.ticks=a,o.step=1),o.scaleLength=a,o.scaleFactor=A(100/a)):(a>t.scale.maxItems?(o.ticks=t.scale.maxItems,o.step=Math.ceil(a/(o.ticks-1))):(o.ticks=a,o.step=1),o.scaleLength=a,o.scaleFactor=A(100/Math.max(a-1,1)));let n=t.plot.vertical;return{associative:r,x:n?o:i,y:n?i:o,alt:s}}function Mt({max:l,min:t,ticks:e},{forceZeroMin:o=!0}={}){let i=l-t||1;t=Math.floor(t-Math.abs(i*.1)),l=Math.ceil(l+Math.abs(i*.1)),o&&(t=t>0?0:t);let s=l-t;if(s<=0)return{min:t,max:t+1,step:1,scaleLength:1,scaleFactor:100,ticks:2};let r=se(s,e);t=Math.floor(t/r)*r,l=Math.ceil(l/r)*r;let a=l-t;e=Math.round(a/r)+1;let c=100/a;return{min:t,max:l,step:r,scaleLength:a,scaleFactor:c,ticks:e}}function se(l,t){let e=l/t,o=Math.pow(10,Math.floor(Math.log10(e))),i=e/o,s;return i<=1.5?s=1:i<=3.5?s=2.5:i<=7.5?s=5:s=10,s*o}function it(l,t){let e;switch(t){case"x":e=0;break;case"y":e=1;break;case"size":e=2;break}let o=l.map(i=>i.values.map(s=>s[e])).reduce((i,s)=>i.concat(s)).sort((i,s)=>i-s);return{min:o[0],max:o[o.length-1]}}var Tt=new Map;function X(l,t){Tt.set(l,t)}function Ot(l,t){let e=Tt.get(l);if(!e)throw new Error(`SVC: Unknown scale type "${l}". Registered types: ${[...Tt.keys()].join(", ")}`);return new e(t)}var _t=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{min:s,max:r,ticks:a,step:c}=o[t];for(let n=0;n<a;n++){let u=A(n*c*o[t].scaleFactor);if(u>100)continue;i.ticks.push(R(t,u));let p=B(t,n,a,u,e);p&&i.guides.push(p);let d;t==="x"?d=`${s+n*c}`:d=`${r-n*c}`,d=V(d,t,e),i.labels.push(U(t,u,d))}return i}};function R(l,t){return l==="x"?new y("line",{x1:t+"%",y1:"0%",x2:t+"%",y2:"100%",class:["ticks","ticks-x"]}):new y("line",{x1:"0%",y1:t+"%",x2:"100%",y2:t+"%",class:["ticks","ticks-y"]})}function B(l,t,e,o,i){if(l==="x"){if(t!==0&&i.guides.x.enabled)return new y("line",{x1:o+"%",y1:"100%",x2:o+"%",y2:"0%",class:["guides","guides-x"]})}else if(t!==e-1&&i.guides.y.enabled)return new y("line",{x1:"0%",y1:o+"%",x2:"100%",y2:o+"%",class:["guides","guides-y"]});return null}function U(l,t,e){let o=l==="x"?"left":"top",i=new y("div",{style:`${o}: ${t}%`,class:["scale-label",`scale-label-${l}`]});return i.textContent=e,i}function V(l,t,e){if(t==="x"&&ct(e,"scale.label.x.format"))try{return e.scale.label.x.format(l)}catch(o){console.warn("SVC: scale.label.x.format threw an error:",o)}else if(t==="y"&&ct(e,"scale.label.y.format"))try{return e.scale.label.y.format(l)}catch(o){console.warn("SVC: scale.label.y.format threw an error:",o)}return l}var re=_t;var Ft=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{ticks:s,step:r,max:a}=o[t],c=this.chartType,n=c==="bar"||c==="column",u=t==="x"&&e.plot.vertical||t==="y"&&!e.plot.vertical;for(let p=0;p<s;p++){let d,h;if(n&&u){let m=o[t].scaleFactor/2,b=s<=1?0:p/(s-1);h=Math.floor((o[t].scaleLength-1)*b),h===o[t].scaleLength&&h--,d=A(h*o[t].scaleFactor+m)}else d=A(p*r*o[t].scaleFactor);if(d>100)continue;i.ticks.push(R(t,d));let g=B(t,p,s,d,e);g&&i.guides.push(g);let f;if(t==="x"&&e.plot.vertical){let m=h??Math.round(p*(o.x.keys.length-1)/Math.max(s-1,1));f=`${o.x.keys[m]}`}else if(t==="y"&&!e.plot.vertical){let m=h??Math.round(p*(o.y.keys.length-1)/Math.max(s-1,1));f=`${o.y.keys[m]}`}else f=t==="x"?`${p*r}`:`${a-p*r}`;f=V(f,t,e),i.labels.push(U(t,d,f))}return i}},ne=Ft;var Pt=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{min:s,max:r}=o[t],a=Math.max(s,1),c=Math.floor(Math.log10(a)),u=Math.ceil(Math.log10(Math.max(r,1)))-c;if(u<=0)return i;let p=u+1;for(let d=0;d<p;d++){let h=c+d,g=Math.pow(10,h),f=A(d/u*100);if(f>100)continue;let m=t==="y"?A(100-f):f;i.ticks.push(R(t,m));let b=B(t,d,p,m,e);b&&i.guides.push(b);let x=Ee(g);x=V(x,t,e),i.labels.push(U(t,m,x))}return i}};function Ee(l){return l>=1e6?l/1e6+"M":l>=1e3?l/1e3+"K":String(l)}var ae=Pt;var It=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{min:s,max:r,ticks:a}=o[t],c=le(s),u=le(r)-c;if(u<=0||!Number.isFinite(u))return i;let p=Le(u),d=Math.min(a,12);for(let h=0;h<d;h++){let g=h/Math.max(d-1,1),f=A(g*100),m=c+u*g;if(f>100)continue;i.ticks.push(R(t,f));let b=B(t,h,d,f,e);b&&i.guides.push(b);let x=p(new Date(m));x=V(x,t,e),i.labels.push(U(t,f,x))}return i}};function le(l){return typeof l=="number"?l:new Date(l).getTime()}function Le(l){return l<864e5?i=>i.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):l<2592e6?i=>i.toLocaleDateString(void 0,{month:"short",day:"numeric"}):l<31536e6*2?i=>i.toLocaleDateString(void 0,{month:"short",year:"2-digit"}):i=>i.toLocaleDateString(void 0,{year:"numeric"})}var ce=It;X("linear",re);X("category",ne);X("log",ae);X("time",ce);var zt=class extends ot{static get defaults(){let t={width:120,height:120};return{l:{},plot:{vertical:!0},axis:{breakpoint:t,x:{enabled:!0},y:{enabled:!0},label:{x:{enabled:!0,text:"Scale-X"},y:{enabled:!0,text:"Scale-Y"}},style:{stroke:"var(--chart-axis-color, #444)","stroke-width":.3,"vector-effect":"non-scaling-stroke"}},baseline:{x:{},y:{},style:{stroke:"var(--chart-baseline-color, #888)","stroke-width":1}},ticks:{x:{enabled:!0},y:{enabled:!0},style:{"stroke-width":"1",stroke:"var(--chart-tick-color, #DDD)"}},guides:{breakpoint:t,x:{enabled:!0},y:{enabled:!0},style:{stroke:"var(--chart-grid-color, #e4e4e4)","stroke-dasharray":"0, 0","stroke-width":1,"stroke-linecap":"round"}},scale:{sorted:!1,minFontSize:5,maxItems:15,label:{style:{"text-align":"center"}}}}}getName(){return super.getName()}parse(t){t=super.parse(t);let e=this.data,o=this.stylesheet,i=this.config,{layoutChart:s,layoutXAxis:r,layoutYAxis:a,layoutOriginLeft:c,layoutOriginCenter:n,layoutOriginRight:u,layoutYTicks:p,layoutXTicks:d,layoutXAxisLabel:h,layoutYAxisLabel:g}=t,f=this.stats=At(e,this.config,this.constructor.type);this.data=e,this.hooks.run("beforeRender",{config:i,data:e,stats:f,structure:t}),["x","y"].forEach(S=>{let L=Me(S,f,i),$=Ot(L,{type:S,config:i,stats:f,data:e,chartType:this.constructor.type}).render();Object.keys($).forEach(E=>{if(E==="labels")$[E].forEach(T=>{S==="x"?r.appendChild(T):a.appendChild(T)});else if(E==="ticks")S==="x"&&i.ticks.x.enabled?$[E].forEach(T=>{d.appendChild(T)}):S==="y"&&i.ticks.y.enabled&&$[E].forEach(T=>{p.appendChild(T)});else{let T=new y("g",{class:[S+"-"+E]});$[E].forEach(O=>{T.appendChild(O)}),s.appendChild(T)}})});let m=[];if(i.axis.x.enabled&&s.appendChild(this.createAxis({type:"x"})),i.axis.label.x.enabled){let S=`svc-axis-x-label-${this._scopeId}`,L=new y("div",{class:["l-axis-label-text-x"],id:S,role:"note"});L.innerHTML=`<span class="svc-axis-label-x">${M(i.axis.label.x.text)}</span>`,h.appendChild(L),m.push(S)}if(i.axis.y.enabled&&s.appendChild(this.createAxis({type:"y"})),i.axis.label.y.enabled){let S=`svc-axis-y-label-${this._scopeId}`,L=new y("div",{class:["l-axis-y-label-text"],id:S,role:"note"});L.innerHTML=`<span class="svc-axis-label-y">${M(i.axis.label.y.text)}</span>`,g.appendChild(L),m.push(S)}m.length>0&&t.root.setAttribute("aria-describedby",m.join(" "));let b=new y("div",{class:["axis-y-label-dummy"]});b.innerHTML="0",c.appendChild(b),g.appendChild(b);let x=new y("div",{style:"height: 1%; min-height:10px;"});n.appendChild(x);let v=new y("div",{class:["origin-label","scale-label"]});if(f.associative&&!i.plot.vertical){let S=f.y.keys,L=0;S.forEach($=>{L=$.length>L?$.length:L}),v.innerHTML=new Array(L+1).join("0")}else v.innerHTML=f.y.max;n.appendChild(v),a.appendChild(v),u.setAttrs({style:"width: 1%;"}),f.y.min<0&&s.appendChild(new Lt({type:"y",stats:f,stroke:i.baseline.style.stroke,width:i.baseline.style["stroke-width"]}).render()),f.x.min<0&&s.appendChild(new Lt({type:"x",stats:f,stroke:i.baseline.style.stroke,width:i.baseline.style["stroke-width"]}).render());let w=this.createGraph({stretch:!0});s.appendChild(w);let C=this.createGraph({stretch:!1});s.appendChild(C),this.createPlot({data:e,stats:f,subchartStretch:w,subchartNoStretch:C});let k=new y("style");return k.innerHTML=".plot {opacity: 1;} .svc-loading {opacity:0;}",s.appendChild(k),o.addRaw(oe({stats:f,config:i})),t}createScript(){return new j({stats:this.stats,data:this.data,config:this.config}).render()}createAxis({type:t}){return t==="x"?new y("line",{x1:"0%",x2:"100%",y1:"100%",y2:"100%",class:["axis","axis-x"]}):new y("line",{x1:"0%",x2:"0%",y1:"0%",y2:"100%",class:["axis","axis-y"]})}};function Me(l,t,e){return e.scale?.[l]?.type?e.scale[l].type:t.associative?"category":"linear"}var q=zt;var Nt=class extends q{static get type(){return"line"}static get defaults(){return{plot:{style:{fill:"none","vector-effect":"non-scaling-stroke"},node:{type:"open",size:4,style:{"stroke-width":"0.2%","stroke-linecap":"round"},active:{style:{"stroke-width":"0.5%","stroke-linecap":"round"}}}}}}static specs(t){let e={plot:{stroke:"primary"},"plot.node.active":{fill:"secondary",stroke:"secondary"}};return t.plot.node.enabled&&(e["plot.node"]={stroke:"primary"},t.plot.node.type=="closed"?e["plot.node"].fill="primary":e["plot.node"].fill="#FFF"),e}getPlotClass(t){return["plot",`plot-${t}`]}createPlotLine(t){let e=this.stats,o=[],i=.2,s=1,r=0,a=0,c=0,n,u,p=null;for(let d=0;d<t.length;d++){if(t[d]==null){p=null,a=0,c=0;continue}let h={x:A((d-e.x.min)*e.x.scaleFactor),y:A((e.y.max-t[d])*e.y.scaleFactor)};if(!p){o.push(`M ${h.x} ${h.y}`),p=h;continue}let g=null;for(let v=d+1;v<t.length;v++)if(t[v]!=null){g={x:A((v-e.x.min)*e.x.scaleFactor),y:A((e.y.max-t[v])*e.y.scaleFactor)};break}g?(r=(g.y-p.y)/(g.x-p.x),n=(g.x-h.x)*-i,u=n*r*s):n=u=0;let f=A(p.x-a),m=A(p.y-c),b=A(h.x+n),x=A(h.y+u);o.push(`C ${f} ${m}, ${b} ${x}, ${h.x} ${h.y}`),a=n,c=u,p=h}return o}createPlot({data:t,stats:e,subchartStretch:o,subchartNoStretch:i}){this.stats=e,t.forEach((s,r)=>{let a=Array.isArray(s.values)?s.values:e.x.keys.map(p=>s.values[p]??null),c={class:this.getPlotClass(r),plot:r};this.constructor.type==="line"&&(c.fill="none");let n=new y("path",c);o.appendChild(n);let u=this.createPlotLine(a);n.setAttribute("d",u.join(" ")),a.forEach((p,d)=>{if(p!=null){if(this.config.plot.node.enabled){let h=A((d-e.x.min)*e.x.scaleFactor)+"%",g=A((e.y.max-p)*e.y.scaleFactor)+"%",f=s.name||`Series ${r+1}`,m=e.associative&&e.x.keys&&e.x.keys[d]||d,b=new y("circle",{cx:h,cy:g,r:this.config.plot.node.size,class:["plot-node",`plot-node-${r}`],node:d,plot:r,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${f}, ${m}: ${p}`});i.appendChild(b)}if(this.config.plot.node.label.enabled){let h=new y("text",{x:A((d-e.x.min)*e.x.scaleFactor)+"%",y:A((e.y.max-p)*e.y.scaleFactor)+"%",fill:"black",class:["plot-node-label",`plot-node-label-${r}`]});h.innerHTML=p,i.appendChild(h)}}})})}tooltipLocation(t,e,o){return function(s){let r={tooltip:{},crosshair:{}},a=1,c="",n=o.stats,p=e.querySelector("chart-plot").getBoundingClientRect(),d=(s.clientX-p.left)/p.width,h=Math.floor(d*n.x.scaleLength),g=0,f=0,m=o.data,b=n.associative?n.x.keys[h]:h;m.forEach(function(C){let k=n.associative?C.values[b]:C.values[h];k!=null&&(g+=k,f++)});let x=(n.y.max-g/f)*n.y.scaleFactor;isNaN(x)&&(x=n.y.max*n.y.scaleFactor);let v=n.x.scaleFactor*h,w=x.toFixed(2);return isNaN(v)||isNaN(w)||h<0||h>=n.x.scaleLength?null:(r.crosshair.x1=v,r.crosshair.x2=v,r.crosshair.y1=0,r.crosshair.y2=100,r.tooltip.x=v+a,r.tooltip.y=w,m.forEach(function(C,k){let S=M(C.name?C.name:"Series "+k),L=n.associative?o.data[k].values[b]:o.data[k].values[h],$=n.associative?b:h,E;if(o.config.tooltip.format)try{E=M(String(o.config.tooltip.format($,L)))}catch(T){console.warn("SVC: tooltip.format threw an error:",T),E=`(${M(String($))} : ${M(String(L))})`}else E=`(${M(String($))} : ${M(String(L))})`;t.toggles[k]!==!1&&(c+=`<div class="svc-tooltip-content">
|
|
385
|
+
`,o+=u}),o}var se=$e;function Tt(l,t,e){if(!Array.isArray(l)||l.length===0)throw new Error('SVC: "data" must be a non-empty array of series objects.');for(let u=0;u<l.length;u++)if(!l[u]||l[u].values==null)throw new Error(`SVC: data[${u}] must have a "values" property.`);if(e!=="scatter"&&e!=="bubble")for(let u=0;u<l.length;u++){let p=l[u].values,d=Array.isArray(p)?p:Object.values(p);for(let h=0;h<d.length;h++)if(d[h]!=null&&typeof d[h]!="number")throw new Error(`SVC: data[${u}].values contains non-numeric value "${d[h]}" at position ${h}.`)}let o={min:1/0,max:-1/0,ticks:4,scale:0},i={min:1/0,max:-1/0,ticks:6,scale:0},s={min:1/0,max:-1/0},r=!1,a=-1/0;if(e==="scatter"||e==="bubble")Object.assign(o,st(l,"x")),Object.assign(i,st(l,"y")),e==="bubble"&&Object.assign(s,st(l,"size"));else if(Array.isArray(l[0].values)){let u=l.reduce((d,h)=>d.concat(h.values),[]).sort((d,h)=>d-h);if(t.plot&&t.plot.stacked){let d=Math.max(...l.map(f=>f.values.length)),h=0,g=0;for(let f=0;f<d;f++){let m=0,b=0;l.forEach(x=>{let v=x.values[f]||0;v>=0?m+=v:b+=v}),h=Math.max(h,m),g=Math.min(g,b)}i.min=g,i.max=h}else i.min=u[0],i.max=u[u.length-1];let p=l[0].values.length;l.forEach((d,h)=>{d.values.length!==p&&console.warn(`SVC: Series ${h} has ${d.values.length} values, but series 0 has ${p}. Mismatched lengths may cause unexpected results.`),a=d.values.length>a?d.values.length:a}),o.min=0,o.max=a}else{r=!0;let u=l.reduce((d,h)=>d.concat(Object.keys(h.values).map(g=>h.values[g])),[]).sort((d,h)=>d-h),p={};if(l.forEach(d=>{Object.assign(p,d.values)}),p=Object.keys(p),t.scale.sorted&&p.sort(),t.plot&&t.plot.stacked){let d=0,h=0;p.forEach(g=>{let f=0,m=0;l.forEach(b=>{let x=b.values[g]||0;x>=0?f+=x:m+=x}),d=Math.max(d,f),h=Math.min(h,m)}),i.min=h,i.max=d}else i.min=u[0],i.max=u[u.length-1];o.keys=p,o.min=0,o.max=a=p.length}let c=e==="scatter"||e==="bubble";Object.assign(i,At(i,{forceZeroMin:!c})),c?Object.assign(o,At(o,{forceZeroMin:!1})):e==="bar"||e==="column"?(a>t.scale.maxItems?(o.ticks=t.scale.maxItems,o.step=Math.floor(a/(o.ticks-1))):(o.ticks=a,o.step=1),o.scaleLength=a,o.scaleFactor=A(100/a)):(a>t.scale.maxItems?(o.ticks=t.scale.maxItems,o.step=Math.ceil(a/(o.ticks-1))):(o.ticks=a,o.step=1),o.scaleLength=a,o.scaleFactor=A(100/Math.max(a-1,1)));let n=t.plot.vertical;return{associative:r,x:n?o:i,y:n?i:o,alt:s}}function At({max:l,min:t,ticks:e},{forceZeroMin:o=!0}={}){let i=l-t||1;t=Math.floor(t-Math.abs(i*.1)),l=Math.ceil(l+Math.abs(i*.1)),o&&(t=t>0?0:t);let s=l-t;if(s<=0)return{min:t,max:t+1,step:1,scaleLength:1,scaleFactor:100,ticks:2};let r=ne(s,e);t=Math.floor(t/r)*r,l=Math.ceil(l/r)*r;let a=l-t;e=Math.round(a/r)+1;let c=100/a;return{min:t,max:l,step:r,scaleLength:a,scaleFactor:c,ticks:e}}function ne(l,t){let e=l/t,o=Math.pow(10,Math.floor(Math.log10(e))),i=e/o,s;return i<=1.5?s=1:i<=3.5?s=2.5:i<=7.5?s=5:s=10,s*o}function st(l,t){let e;switch(t){case"x":e=0;break;case"y":e=1;break;case"size":e=2;break}let o=l.map(i=>i.values.map(s=>s[e])).reduce((i,s)=>i.concat(s)).sort((i,s)=>i-s);return{min:o[0],max:o[o.length-1]}}var Ot=new Map;function X(l,t){Ot.set(l,t)}function _t(l,t){let e=Ot.get(l);if(!e)throw new Error(`SVC: Unknown scale type "${l}". Registered types: ${[...Ot.keys()].join(", ")}`);return new e(t)}var Ft=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{min:s,max:r,ticks:a,step:c}=o[t];for(let n=0;n<a;n++){let u=A(n*c*o[t].scaleFactor);if(u>100)continue;i.ticks.push(R(t,u));let p=B(t,n,a,u,e);p&&i.guides.push(p);let d;t==="x"?d=`${s+n*c}`:d=`${r-n*c}`,d=V(d,t,e),i.labels.push(U(t,u,d))}return i}};function R(l,t){return l==="x"?new y("line",{x1:t+"%",y1:"0%",x2:t+"%",y2:"100%",class:["ticks","ticks-x"]}):new y("line",{x1:"0%",y1:t+"%",x2:"100%",y2:t+"%",class:["ticks","ticks-y"]})}function B(l,t,e,o,i){if(l==="x"){if(t!==0&&i.guides.x.enabled)return new y("line",{x1:o+"%",y1:"100%",x2:o+"%",y2:"0%",class:["guides","guides-x"]})}else if(t!==e-1&&i.guides.y.enabled)return new y("line",{x1:"0%",y1:o+"%",x2:"100%",y2:o+"%",class:["guides","guides-y"]});return null}function U(l,t,e){let o=l==="x"?"left":"top",i=new y("div",{style:`${o}: ${t}%`,class:["scale-label",`scale-label-${l}`]});return i.textContent=e,i}function V(l,t,e){if(t==="x"&&dt(e,"scale.label.x.format"))try{return e.scale.label.x.format(l)}catch(o){console.warn("SVC: scale.label.x.format threw an error:",o)}else if(t==="y"&&dt(e,"scale.label.y.format"))try{return e.scale.label.y.format(l)}catch(o){console.warn("SVC: scale.label.y.format threw an error:",o)}return l}var ae=Ft;var Pt=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{ticks:s,step:r,max:a}=o[t],c=this.chartType,n=c==="bar"||c==="column",u=t==="x"&&e.plot.vertical||t==="y"&&!e.plot.vertical;for(let p=0;p<s;p++){let d,h;if(n&&u){let m=o[t].scaleFactor/2,b=s<=1?0:p/(s-1);h=Math.floor((o[t].scaleLength-1)*b),h===o[t].scaleLength&&h--,d=A(h*o[t].scaleFactor+m)}else d=A(p*r*o[t].scaleFactor);if(d>100)continue;i.ticks.push(R(t,d));let g=B(t,p,s,d,e);g&&i.guides.push(g);let f;if(t==="x"&&e.plot.vertical){let m=h??Math.round(p*(o.x.keys.length-1)/Math.max(s-1,1));f=`${o.x.keys[m]}`}else if(t==="y"&&!e.plot.vertical){let m=h??Math.round(p*(o.y.keys.length-1)/Math.max(s-1,1));f=`${o.y.keys[m]}`}else f=t==="x"?`${p*r}`:`${a-p*r}`;f=V(f,t,e),i.labels.push(U(t,d,f))}return i}},le=Pt;var It=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{min:s,max:r}=o[t],a=Math.max(s,1),c=Math.floor(Math.log10(a)),u=Math.ceil(Math.log10(Math.max(r,1)))-c;if(u<=0)return i;let p=u+1;for(let d=0;d<p;d++){let h=c+d,g=Math.pow(10,h),f=A(d/u*100);if(f>100)continue;let m=t==="y"?A(100-f):f;i.ticks.push(R(t,m));let b=B(t,d,p,m,e);b&&i.guides.push(b);let x=Me(g);x=V(x,t,e),i.labels.push(U(t,m,x))}return i}};function Me(l){return l>=1e6?l/1e6+"M":l>=1e3?l/1e3+"K":String(l)}var ce=It;var Nt=class{constructor(t){Object.assign(this,t)}render(){let{type:t,config:e,stats:o}=this,i={ticks:[],labels:[],guides:[]},{min:s,max:r,ticks:a}=o[t],c=de(s),u=de(r)-c;if(u<=0||!Number.isFinite(u))return i;let p=Ae(u),d=Math.min(a,12);for(let h=0;h<d;h++){let g=h/Math.max(d-1,1),f=A(g*100),m=c+u*g;if(f>100)continue;i.ticks.push(R(t,f));let b=B(t,h,d,f,e);b&&i.guides.push(b);let x=p(new Date(m));x=V(x,t,e),i.labels.push(U(t,f,x))}return i}};function de(l){return typeof l=="number"?l:new Date(l).getTime()}function Ae(l){return l<864e5?i=>i.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):l<2592e6?i=>i.toLocaleDateString(void 0,{month:"short",day:"numeric"}):l<31536e6*2?i=>i.toLocaleDateString(void 0,{month:"short",year:"2-digit"}):i=>i.toLocaleDateString(void 0,{year:"numeric"})}var pe=Nt;X("linear",ae);X("category",le);X("log",ce);X("time",pe);var zt=class extends it{static get defaults(){let t={width:120,height:120};return{l:{},plot:{vertical:!0},axis:{breakpoint:t,x:{enabled:!0},y:{enabled:!0},label:{x:{enabled:!0,text:"Scale-X"},y:{enabled:!0,text:"Scale-Y"}},style:{stroke:"var(--chart-axis-color, #444)","stroke-width":.3,"vector-effect":"non-scaling-stroke"}},baseline:{x:{},y:{},style:{stroke:"var(--chart-baseline-color, #888)","stroke-width":1}},ticks:{x:{enabled:!0},y:{enabled:!0},style:{"stroke-width":"1",stroke:"var(--chart-tick-color, #DDD)"}},guides:{breakpoint:t,x:{enabled:!0},y:{enabled:!0},style:{stroke:"var(--chart-grid-color, #e4e4e4)","stroke-dasharray":"0, 0","stroke-width":1,"stroke-linecap":"round"}},scale:{sorted:!1,minFontSize:5,maxItems:15,label:{style:{"text-align":"center"}}}}}getName(){return super.getName()}parse(t){t=super.parse(t);let e=this.data,o=this.stylesheet,i=this.config,{layoutChart:s,layoutXAxis:r,layoutYAxis:a,layoutOriginLeft:c,layoutOriginCenter:n,layoutOriginRight:u,layoutYTicks:p,layoutXTicks:d,layoutXAxisLabel:h,layoutYAxisLabel:g}=t,f=this.stats=Tt(e,this.config,this.constructor.type);this.data=e,this.hooks.run("beforeRender",{config:i,data:e,stats:f,structure:t}),["x","y"].forEach(S=>{let L=Te(S,f,i),$=_t(L,{type:S,config:i,stats:f,data:e,chartType:this.constructor.type}).render();Object.keys($).forEach(E=>{if(E==="labels")$[E].forEach(T=>{S==="x"?r.appendChild(T):a.appendChild(T)});else if(E==="ticks")S==="x"&&i.ticks.x.enabled?$[E].forEach(T=>{d.appendChild(T)}):S==="y"&&i.ticks.y.enabled&&$[E].forEach(T=>{p.appendChild(T)});else{let T=new y("g",{class:[S+"-"+E]});$[E].forEach(O=>{T.appendChild(O)}),s.appendChild(T)}})});let m=[];if(i.axis.x.enabled&&s.appendChild(this.createAxis({type:"x"})),i.axis.label.x.enabled){let S=`svc-axis-x-label-${this._scopeId}`,L=new y("div",{class:["l-axis-label-text-x"],id:S,role:"note"});L.innerHTML=`<span class="svc-axis-label-x">${M(i.axis.label.x.text)}</span>`,h.appendChild(L),m.push(S)}if(i.axis.y.enabled&&s.appendChild(this.createAxis({type:"y"})),i.axis.label.y.enabled){let S=`svc-axis-y-label-${this._scopeId}`,L=new y("div",{class:["l-axis-y-label-text"],id:S,role:"note"});L.innerHTML=`<span class="svc-axis-label-y">${M(i.axis.label.y.text)}</span>`,g.appendChild(L),m.push(S)}m.length>0&&t.root.setAttribute("aria-describedby",m.join(" "));let b=new y("div",{class:["axis-y-label-dummy"]});b.innerHTML="0",c.appendChild(b),g.appendChild(b);let x=new y("div",{style:"height: 1%; min-height:10px;"});n.appendChild(x);let v=new y("div",{class:["origin-label","scale-label"]});if(f.associative&&!i.plot.vertical){let S=f.y.keys,L=0;S.forEach($=>{L=$.length>L?$.length:L}),v.innerHTML=new Array(L+1).join("0")}else v.innerHTML=f.y.max;n.appendChild(v),a.appendChild(v),u.setAttrs({style:"width: 1%;"}),f.y.min<0&&s.appendChild(new Mt({type:"y",stats:f,stroke:i.baseline.style.stroke,width:i.baseline.style["stroke-width"]}).render()),f.x.min<0&&s.appendChild(new Mt({type:"x",stats:f,stroke:i.baseline.style.stroke,width:i.baseline.style["stroke-width"]}).render());let w=this.createGraph({stretch:!0});s.appendChild(w);let C=this.createGraph({stretch:!1});s.appendChild(C),this.createPlot({data:e,stats:f,subchartStretch:w,subchartNoStretch:C});let k=new y("style");return k.innerHTML=".plot {opacity: 1;} .svc-loading {opacity:0;}",s.appendChild(k),o.addRaw(se({stats:f,config:i})),t}createScript(){return new j({stats:this.stats,data:this.data,config:this.config}).render()}createAxis({type:t}){return t==="x"?new y("line",{x1:"0%",x2:"100%",y1:"100%",y2:"100%",class:["axis","axis-x"]}):new y("line",{x1:"0%",x2:"0%",y1:"0%",y2:"100%",class:["axis","axis-y"]})}};function Te(l,t,e){return e.scale?.[l]?.type?e.scale[l].type:t.associative?"category":"linear"}var q=zt;var jt=class extends q{static get type(){return"line"}static get defaults(){return{plot:{style:{fill:"none","vector-effect":"non-scaling-stroke"},node:{type:"open",size:4,style:{"stroke-width":"0.2%","stroke-linecap":"round"},active:{style:{"stroke-width":"0.5%","stroke-linecap":"round"}}}}}}static specs(t){let e={plot:{stroke:"primary"},"plot.node.active":{fill:"secondary",stroke:"secondary"}};return t.plot.node.enabled&&(e["plot.node"]={stroke:"primary"},t.plot.node.type=="closed"?e["plot.node"].fill="primary":e["plot.node"].fill="#FFF"),e}getPlotClass(t){return["plot",`plot-${t}`]}createPlotLine(t){let e=this.stats,o=[],i=.2,s=1,r=0,a=0,c=0,n,u,p=null;for(let d=0;d<t.length;d++){if(t[d]==null){p=null,a=0,c=0;continue}let h={x:A((d-e.x.min)*e.x.scaleFactor),y:A((e.y.max-t[d])*e.y.scaleFactor)};if(!p){o.push(`M ${h.x} ${h.y}`),p=h;continue}let g=null;for(let v=d+1;v<t.length;v++)if(t[v]!=null){g={x:A((v-e.x.min)*e.x.scaleFactor),y:A((e.y.max-t[v])*e.y.scaleFactor)};break}g?(r=(g.y-p.y)/(g.x-p.x),n=(g.x-h.x)*-i,u=n*r*s):n=u=0;let f=A(p.x-a),m=A(p.y-c),b=A(h.x+n),x=A(h.y+u);o.push(`C ${f} ${m}, ${b} ${x}, ${h.x} ${h.y}`),a=n,c=u,p=h}return o}createPlot({data:t,stats:e,subchartStretch:o,subchartNoStretch:i}){this.stats=e,t.forEach((s,r)=>{let a=Array.isArray(s.values)?s.values:e.x.keys.map(p=>s.values[p]??null),c={class:this.getPlotClass(r),plot:r};this.constructor.type==="line"&&(c.fill="none");let n=new y("path",c);o.appendChild(n);let u=this.createPlotLine(a);n.setAttribute("d",u.join(" ")),a.forEach((p,d)=>{if(p!=null){if(this.config.plot.node.enabled){let h=A((d-e.x.min)*e.x.scaleFactor)+"%",g=A((e.y.max-p)*e.y.scaleFactor)+"%",f=s.name||`Series ${r+1}`,m=e.associative&&e.x.keys&&e.x.keys[d]||d,b=new y("circle",{cx:h,cy:g,r:this.config.plot.node.size,class:["plot-node",`plot-node-${r}`],node:d,plot:r,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${f}, ${m}: ${p}`});i.appendChild(b)}if(this.config.plot.node.label.enabled){let h=new y("text",{x:A((d-e.x.min)*e.x.scaleFactor)+"%",y:A((e.y.max-p)*e.y.scaleFactor)+"%",fill:"black",class:["plot-node-label",`plot-node-label-${r}`]});h.innerHTML=p,i.appendChild(h)}}})})}tooltipLocation(t,e,o){return function(s){let r={tooltip:{},crosshair:{}},a=1,c="",n=o.stats,p=e.querySelector("chart-plot").getBoundingClientRect(),d=(s.clientX-p.left)/p.width,h=Math.floor(d*n.x.scaleLength),g=0,f=0,m=o.data,b=n.associative?n.x.keys[h]:h;m.forEach(function(C){let k=n.associative?C.values[b]:C.values[h];k!=null&&(g+=k,f++)});let x=(n.y.max-g/f)*n.y.scaleFactor;isNaN(x)&&(x=n.y.max*n.y.scaleFactor);let v=n.x.scaleFactor*h,w=x.toFixed(2);return isNaN(v)||isNaN(w)||h<0||h>=n.x.scaleLength?null:(r.crosshair.x1=v,r.crosshair.x2=v,r.crosshair.y1=0,r.crosshair.y2=100,r.tooltip.x=v+a,r.tooltip.y=w,m.forEach(function(C,k){let S=M(C.name?C.name:"Series "+k),L=n.associative?o.data[k].values[b]:o.data[k].values[h],$=n.associative?b:h,E;if(o.config.tooltip.format)try{E=M(String(o.config.tooltip.format($,L)))}catch(T){console.warn("SVC: tooltip.format threw an error:",T),E=`(${M(String($))} : ${M(String(L))})`}else E=`(${M(String($))} : ${M(String(L))})`;t.toggles[k]!==!1&&(c+=`<div class="svc-tooltip-content">
|
|
386
386
|
<span class="svc-tooltip-label-title svc-tooltip-label-title-${k}">${S}</span> :
|
|
387
387
|
${E}
|
|
388
|
-
</div>`)}),r.tooltip.text=c,r.index=h,r)}}},K=
|
|
388
|
+
</div>`)}),r.tooltip.text=c,r.index=h,r)}}},K=jt;var Rt=class extends K{static get type(){return"area"}static get defaults(){return{plot:{area:{style:{"fill-opacity":"var(--area-fill-opacity, 0.5)","stroke-width":"2%","stroke-linecap":"round"}},node:{enabled:!1,size:4,active:{style:{"stroke-width":"0.5%"}}}}}}static specs(){return{plot:{stroke:"primary"},"plot.area":{fill:"primary",stroke:"secondary"}}}getPlotClass(t){return["plot",`plot-${t}`,"plot-area",`plot-area-${t}`]}createPlotLine(t){let e=super.createPlotLine(t),o=this.stats,i=t.find(c=>c!=null);if(i==null)return e;let s=A((t.length-1-o.x.min)*o.x.scaleFactor),r=A(o.y.max*o.y.scaleFactor),a=A((o.y.max-i)*o.y.scaleFactor);return e.push(`L ${s} ${r} L 0 ${r} L 0 ${a}`),e}},Bt=Rt;var Ut=class extends q{static get type(){return"column"}static get defaults(){return{plot:{vertical:!0,stacked:!1,spacing:10,label:{enabled:!1,format:null}}}}static specs(){return{"plot.node":{fill:"primary"}}}createPlot({data:t,stats:e,subchartStretch:o,subchartNoStretch:i}){let s,r,a=this.config.plot.spacing/100,c=e.y.scaleFactor,n=e.x.scaleFactor;e.plot={},this.config.plot.vertical?(s=e.y.min,r=e.y.max,e.plot.vertical=!0):(s=e.x.min,r=e.x.max,e.plot.vertical=!1),e.plot.barSpacing=this.config.plot.spacing/100;let u=Math.abs(r-s),d=Math.abs(s)/u*100;if(this.config.plot.stacked){this._createStackedPlot({data:t,stats:e,subchartStretch:o,scaleX:n,scaleY:c,barSpacing:a,originPoint:d});return}if(Array.isArray(t[0].values))if(this.config.plot.vertical){let h=n/t.length,g=h*(1-a*2);t.forEach((f,m)=>{f.type!=="line"&&f.values.forEach((b,x)=>{let v;b>0?v=(e.y.max-b)*c+"%":v=(100-d).toFixed(3)+"%";let w=n*x;w+=h*m,w+=h*a,o.appendChild(new y("rect",{class:["plot",`plot-${m}`,`plot-node-${m}`],index:x,plot:m,"data-series":m,"data-index":x,"data-value":b,height:Math.abs(b)*c,x:w+"%",width:g+"%",y:v,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${f.name||"Series "+(m+1)}, ${x}: ${b}`}))})})}else{let h=c/t.length,g=h*(1-a*2);t.forEach((f,m)=>{f.type!=="line"&&f.values.forEach((b,x)=>{let v,w=Math.abs(b)*n;b>0?v=d.toFixed(3)+"%":v=d.toFixed(3)-w+"%";let C=100-c*(x+1);C+=h*m,C+=h*a,o.appendChild(new y("rect",{class:["plot",`plot-${m}`,`plot-node-${m}`],index:x,plot:m,"data-series":m,"data-index":x,"data-value":b,y:C+"%",width:w+"%",height:g+"%",x:v,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${f.name||"Series "+(m+1)}, ${x}: ${b}`}))})})}else if(this.config.plot.vertical){let h=n/t.length,g=h*(1-a*2);e.x.keys.forEach((f,m)=>{t.forEach((b,x)=>{if(b.type!=="line"&&b.values[f]!=null){let v,w=b.values[f];w>0?v=(e.y.max-w)*c+"%":v=(100-d).toFixed(3)+"%";let C=n*m;C+=h*x,C+=h*a,o.appendChild(new y("rect",{class:["plot",`plot-${x}`,`plot-node-${x}`],index:m,plot:x,"data-series":x,"data-key":f,"data-value":w,height:Math.abs(w)*c,x:C+"%",width:g+"%",y:v,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${b.name||"Series "+(x+1)}, ${f}: ${w}`}))}})})}else{let h=c/t.length,g=h*(1-a*2);e.y.keys.slice().reverse().forEach((m,b)=>{t.forEach((x,v)=>{if(x.type!=="line"&&x.values[m]!=null){let w=x.values[m],C,k=Math.abs(w)*n;w>0?C=d.toFixed(3)+"%":C=d.toFixed(3)-k+"%";let S=100-c*(b+1);S+=h*v,S+=h*a,o.appendChild(new y("rect",{class:["plot",`plot-${v}`,`plot-node-${v}`],index:b,plot:v,"data-series":v,"data-key":m,"data-value":w,y:S+"%",width:k+"%",height:g+"%",x:C,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${x.name||"Series "+(v+1)}, ${m}: ${w}`}))}})})}this._renderLineSeries({data:t,stats:e,subchartStretch:o,subchartNoStretch:i}),this.config.plot.label.enabled&&this._renderDataLabels({data:t,stats:e,subchartNoStretch:i,scaleX:n,scaleY:c,barSpacing:a})}_renderDataLabels({data:t,stats:e,subchartNoStretch:o,scaleX:i,scaleY:s,barSpacing:r}){if(!o)return;let a=!Array.isArray(t[0].values),c=this.config.plot.vertical,n=this.config.plot.label.format,u=t.filter(p=>p.type!=="line").length;t.forEach((p,d)=>{if(p.type==="line")return;let h=a?(c?e.x.keys:e.y.keys).map(g=>({key:g,value:p.values[g]})):p.values.map((g,f)=>({key:f,value:g}));h.forEach(({key:g,value:f},m)=>{if(f==null)return;let b=n?n(f,g):String(f);if(c){let x=i,v=x/u,w=x*m+v*d+v/2+v*r,C=(e.y.max-f)*s,k=new y("text",{x:w+"%",y:C-1+"%","text-anchor":"middle",class:["plot-node-label",`plot-node-label-${d}`]});k.textContent=b,o.appendChild(k)}else{let x=s,v=x/u,w=h.length-1-m,C=100-x*(w+1)+v*d+v/2,k=Math.abs(f)*i,S=new y("text",{x:k+1+"%",y:C+"%","alignment-baseline":"middle",class:["plot-node-label",`plot-node-label-${d}`]});S.textContent=b,o.appendChild(S)}})})}_renderLineSeries({data:t,stats:e,subchartStretch:o,subchartNoStretch:i}){let s=!Array.isArray(t[0].values),r=this.config.plot.vertical,a=e.x.scaleFactor,c=e.y.scaleFactor;t.forEach((n,u)=>{if(n.type!=="line")return;let p=r?e.x.keys:e.y.keys,d=s?p.map(m=>n.values[m]??null):n.values,h=[],g=!1;for(let m=0;m<d.length;m++){if(d[m]==null){g=!1;continue}let b=r?m*a+a/2:(e.y.max-d[m])*c,x=r?(e.y.max-d[m])*c:100-(m*c+c/2);g?h.push(`L ${b.toFixed(2)} ${x.toFixed(2)}`):h.push(`M ${b.toFixed(2)} ${x.toFixed(2)}`),g=!0}if(h.length===0)return;let f=new y("path",{d:h.join(" "),fill:"none",class:["plot",`plot-${u}`],style:"vector-effect: non-scaling-stroke"});if(o.appendChild(f),i)for(let m=0;m<d.length;m++){if(d[m]==null)continue;let b=r?m*a+a/2+"%":(e.y.max-d[m])*c+"%",x=r?(e.y.max-d[m])*c+"%":100-(m*c+c/2)+"%",v=s&&p?p[m]:m,w=n.name||"Series "+(u+1);i.appendChild(new y("circle",{cx:b,cy:x,r:4,class:["plot-node",`plot-node-${u}`],node:m,plot:u,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${w}, ${v}: ${d[m]}`}))}})}_createStackedPlot({data:t,stats:e,subchartStretch:o,scaleX:i,scaleY:s,barSpacing:r,originPoint:a}){let c=!Array.isArray(t[0].values),n=this.config.plot.vertical,u=n?i:s,p=u,d=p*(1-r*2),h=c?n?e.x.keys:e.y.keys:Array.from({length:Math.max(...t.map(g=>g.values.length))},(g,f)=>f);h.forEach((g,f)=>{let m=0,b=0;t.forEach((x,v)=>{if(x.type==="line")return;let w=x.values[g];if(w==null)return;let C=Math.abs(w)*(n?s:i),k=x.name||"Series "+(v+1);if(n){let S;w>=0?(m+=w,S=(e.y.max-m)*s):(S=(e.y.max-b)*s,b+=w);let L=u*f+p*r;o.appendChild(new y("rect",{class:["plot",`plot-${v}`,`plot-node-${v}`],index:f,plot:v,"data-series":v,"data-key":c?g:void 0,"data-index":c?void 0:f,"data-value":w,x:L+"%",y:S+"%",width:d+"%",height:C+"%",role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${k}, ${g}: ${w}`}))}else{let S;w>=0?(S=a+m*i,m+=w):(b+=w,S=a+b*i);let L=h.length-1-f,$=100-u*(L+1)+p*r;o.appendChild(new y("rect",{class:["plot",`plot-${v}`,`plot-node-${v}`],index:f,plot:v,"data-series":v,"data-key":c?g:void 0,"data-index":c?void 0:f,"data-value":w,x:S+"%",y:$+"%",width:C+"%",height:d+"%",role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${k}, ${g}: ${w}`}))}})})}tooltipLocation(t,e,o){return function(s){let r={tooltip:{},crosshair:{}},a=1,c="",n=o.stats,p=e.querySelector("chart-plot").getBoundingClientRect(),d=(s.clientX-p.left)/p.width,h=Math.floor(d*n.x.scaleLength),g=0,f=0,m=o.data,b;n.associative&&(b=n.x.keys[h]),m.forEach(function(C){n.associative&&C.values[b]!=null?(g+=C.values[b],f++):!n.associative&&C.values[h]!=null&&(g+=C.values[h],f++)});let x=(n.y.max-g/f)*n.y.scaleFactor;isNaN(x)&&(x=n.y.max*n.y.scaleFactor);let v=n.x.scaleFactor*h+n.x.scaleFactor/2,w=x.toFixed(2);return isNaN(v)||isNaN(w)||h<0||h>=n.x.scaleLength?null:(n.associative&&(w=100-w),r.crosshair.x1=-10,r.crosshair.x2=-10,r.crosshair.y1=-10,r.crosshair.y2=-10,r.tooltip.x=v+a,r.tooltip.y=w,m.forEach(function(C,k){let S=M(C.name?C.name:"Series "+k);if(t.toggles[k]!==!1){let L=n.associative?o.data[k].values[b]:o.data[k].values[h],$=n.associative?b:h,E;if(o.config.tooltip.format)try{E=M(String(o.config.tooltip.format($,L)))}catch(T){console.warn("SVC: tooltip.format threw an error:",T),E=`(${M(String($))} : ${M(String(L))})`}else E=`(${M(String($))} : ${M(String(L))})`;c+=`<div class="svc-tooltip-content">
|
|
389
389
|
<span class="svc-tooltip-label-title svc-tooltip-label-title-${k}">${S}</span> : ${E}
|
|
390
|
-
</div>`}}),r.tooltip.text=c,r.index=h,r)}}},Z=
|
|
390
|
+
</div>`}}),r.tooltip.text=c,r.index=h,r)}}},Z=Ut;var Vt=class extends Z{static get type(){return"bar"}static get defaults(){return{plot:{vertical:!1}}}tooltipLocation(t,e,o){return function(s){let r={tooltip:{},crosshair:{}},a=1,c="",n=o.stats,p=e.querySelector("chart-plot").getBoundingClientRect(),d=(s.clientY-p.top)/p.height;n.associative&&(d=1-d);let h=n.y.scaleLength-1-Math.floor(d*n.y.scaleLength),g=0,f=0,m=o.data,b;n.associative&&(o.config.plot.vertical?b=n.x.keys[h]:b=n.y.keys[h]),m.forEach(function(C){n.associative&&C.values[b]!=null?(g+=C.values[b],f++):!n.associative&&C.values[h]!=null&&(g+=C.values[h],f++)});let x=g/f*n.x.scaleFactor;isNaN(x)&&(x=n.x.max*n.x.scaleFactor);let v=x.toFixed(2),w=100*d.toFixed(2);return isNaN(v)||isNaN(w)||h<0||h>=n.x.scaleLength?null:(n.associative&&(w=100-w),r.crosshair.x1=-10,r.crosshair.x2=-10,r.crosshair.y1=-10,r.crosshair.y2=-10,r.tooltip.x=v+a,r.tooltip.y=w+a,m.forEach(function(C,k){let S=M(C.name?C.name:"Series "+k);if(t.toggles[k]!==!1){let L,$=n.associative?o.data[k].values[b]:o.data[k].values[h],E=n.associative?b:h;if(o.config.tooltip.format)try{L=M(String(o.config.tooltip.format(E,$)))}catch(T){console.warn("SVC: tooltip.format threw an error:",T),L=`(${M(String(E))} : ${M(String($))})`}else L=`(${M(String(E))} : ${M(String($))})`;c+=`<div class="svc-tooltip-content">
|
|
391
391
|
<span class="svc-tooltip-label-title svc-tooltip-label-title-${k}">${S}</span> : ${L}
|
|
392
|
-
</div>`}}),r.tooltip.text=c,r.index=h,r)}}},
|
|
392
|
+
</div>`}}),r.tooltip.text=c,r.index=h,r)}}},rt=Vt;var Dt=class extends q{static get type(){return"scatter"}static get defaults(){return{plot:{size:4}}}static specs(){return{"plot.node":{fill:"primary"}}}tooltipLocation(t,e,o){return function(s){t.nodeMap||(t.nodeMap=Fe(e));let r={tooltip:{},crosshair:{}},a=1,c="",u=e.querySelector("chart-plot").getBoundingClientRect(),p=(s.clientX-u.left)/u.width,d=(s.clientY-u.top)/u.height;p=Math.floor(p*100),d=Math.floor(d*100);let h=Math.floor(p/10),g=parseInt((p/10).toFixed(1).split(".")[1]),f=Math.floor(d/10);for(var m=null,b=[[0,0],[-1,0],[1,0],[0,-1],[0,1]],x=0;x<b.length;x++){var v=f+b[x][0],w=h+b[x][1];if(v>=0&&v<10&&w>=0&&w<10&&t.nodeMap[v]&&t.nodeMap[v][w]){var C=t.nodeMap[v][w][g];if(!C){for(var k=Math.max(0,g-1);k<=Math.min(9,g+1);k++)if(t.nodeMap[v][w][k]){C=t.nodeMap[v][w][k];break}}if(C){m=C;break}}}if(m)return r.crosshair.x1=-1,r.crosshair.x2=-1,r.crosshair.y1=-1,r.crosshair.y2=-1,r.tooltip.x=p+a,r.tooltip.y=d,m.forEach(S=>{let L=S.getAttribute("data-series"),$=S.getAttribute("data-index"),E=o.data[L].values[$],T=M(o.data[L].name||"Series "+L),O;if(o.config.tooltip.format)try{O=M(String(o.config.tooltip.format(T,E)))}catch(_){console.warn("SVC: tooltip.format threw an error:",_),O=M(String(E))}else O=M(String(E));c+=`<div class="svc-tooltip-content">
|
|
393
393
|
<span class="svc-tooltip-label-title svc-tooltip-label-title-${L}">${T}</span> : (${O})
|
|
394
|
-
</div>`}),r.tooltip.text=c,r}}createPlot({data:t,stats:e,subchartNoStretch:o}){t.forEach((i,s)=>{i.values.forEach((a,c)=>{let n=a[0],u=a[1],p=i.name||`Series ${s+1}`,d=new y("circle",{cx:((n-e.x.min)*e.x.scaleFactor).toFixed(3)+"%",cy:((e.y.max-u)*e.y.scaleFactor).toFixed(3)+"%",r:this.config.plot.size,class:["plot-node",`plot-${s}`,`plot-node-${s}`],"data-index":c,"data-series":s,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${p}, (${n}, ${u})`});o.appendChild(d)})})}};function Oe(l){let t=Array.from(new Array(10)).map(()=>Array.from(new Array(10)).map(()=>[]));return l.querySelectorAll(".svc-plot-node").forEach(e=>{let o=parseInt(e.getAttribute("data-series"),10),i=parseInt(e.getAttribute("cx")),s=parseInt(e.getAttribute("cy")),r=Math.min(9,Math.floor(i/10)),a=parseInt((i/10).toFixed(1).split(".")[1]),c=Math.min(9,Math.floor(s/10));t[c][r][a]=t[c][r][a]||[],t[c][r][a][o]=e}),t}var W=Vt;var Dt=class extends W{static get type(){return"bubble"}static get defaults(){return{plot:{maxSize:4,node:{}}}}static specs(){return{"plot.node":{fill:"primary"}}}createPlot({data:t,stats:e,subchartStretch:o,subchartNoStretch:i}){t.forEach((s,r)=>{s.values.forEach((c,n)=>{let u=c[0],p=c[1],d=c[2],h=s.name||`Series ${r+1}`,g=e.alt.max-e.alt.min||1,f=(Math.abs(d)-e.alt.min)/g,m=new y("circle",{cx:((u-e.x.min)*e.x.scaleFactor).toFixed(3)+"%",cy:((e.y.max-p)*e.y.scaleFactor).toFixed(3)+"%",r:f*this.config.plot.maxSize+.5+"%",style:`opacity: ${.7}`,class:["plot-node",`plot-${r}`,`plot-node-${r}`],"data-index":n,"data-series":r,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${h}, (${u}, ${p}), size: ${d}`});i.appendChild(m)})})}},Ht=Dt;var qt=class extends ot{static get type(){return"pie"}static get defaults(){return{plot:{ring:!1,node:{label:{enabled:!0,placement:"auto",scaleBySize:!0,limitBySize:!0,multiplier:1,threshold:12,style:{"font-size":"clamp(8px, 0.6vmin, 16px)"}}}},center:{size:"40%",style:{fill:"#fff"},label:{style:{"font-size":"5vmin",transform:"translate(0%, -50%)","text-align":"center"},container:{style:{display:"flex","justify-content":"center","align-items":"center"}},title:{style:{"font-size":"7vmin"}}}}}}static specs(){return{plot:{fill:"primary"},"plot.node":{fill:"primary"}}}parse(t){t=super.parse(t);let{layoutChart:e}=t,o=this.createGraph({stretch:!0});e.appendChild(o);let i=this.createGraph({stretch:!1});e.appendChild(i),this.createPlot({layoutChart:e,subchartStretch:o,subchartNoStretch:i}),i.appendChild(new y("g"));let s=new y("style");return s.innerHTML=".plot {opacity: 1;}.svc-loading {opacity:0;}",e.appendChild(s),t}createScript(){return new j({stats:this.stats,data:this.data,config:this.config}).render()}createPlot({layoutChart:t,subchartStretch:e,subchartNoStretch:o}){let i=this.data;if(!N(i))throw new Error('SVC: Pie chart "data" must be a plain object with numeric values, e.g. { "Apples": 30, "Oranges": 70 }.');Object.keys(i).forEach(u=>{if(typeof i[u]!="number")throw new Error(`SVC: Pie chart value for "${u}" must be a number.`);if(i[u]<0)throw new Error(`SVC: Pie chart value for "${u}" is negative (${i[u]}). Pie charts require non-negative values.`)});let s=Object.keys(i).reduce((u,p)=>u+=i[p],0);if(s===0){let u=new y("text",{x:"50%",y:"50%","text-anchor":"middle","alignment-baseline":"middle",class:["loading"]});u.textContent="No data",o.appendChild(u);return}let r=0,a=0,c=this.config.plot.node.instances.map(u=>u.fill);Object.keys(i).forEach((u,p)=>{let d=i[u],h=d/s,g=r/s,f=c[a%c.length],m=this.calculateSlice(h,g),b=this.createSlice(m,f,p,d,s,u);o.appendChild(b),a++,r+=d});let n=new y("svg",{height:"100%",width:"100%",overflow:"visible",viewBox:"0 0 100 100",class:["nodeGroup"]});if(this.config.plot.ring){let p=(parseFloat(this.config.center.size)||40)/2;n.appendChild(new y("circle",{cx:"50",cy:"50",r:String(p),fill:"var(--color-surface, #fff)",class:["center"]}))}o.appendChild(n)}calculateSlice(t,e){let i=Math.cos((e+t)*2*Math.PI)*50+50,s=Math.sin((e+t)*2*Math.PI)*50+50,r=Math.cos(e*2*Math.PI)*50+50,a=Math.sin(e*2*Math.PI)*50+50,c=e*360,n=t*360+c,u=(n+c)/2,p=50+50*Math.cos(u*2*Math.PI/360),d=50+50*Math.sin(u*2*Math.PI/360);p=(p+50)*.5,d=(d+50)*.5;let h=n-c;return{radius:50,degrees:u,degreeLength:h,start:{x:i,y:s},end:{x:r,y:a},center:{x:p,y:d}}}createSlice(t,e,o,i,s,r){let{radius:a,start:c,end:n,center:u,degreeLength:p}=t,d=new y("svg",{height:"100%",width:"100%",overflow:"visible",viewBox:"0 0 100 100",class:["nodeGroup"]}),h=p>180?1:0,g=`M ${a} ${a}`,f=`L${c.x} ${c.y}`,m=`A ${a} ${a} 0 ${h} 0 ${n.x} ${n.y}`,b=(i/s*100).toFixed(0);if(d.appendChild(new y("path",{fill:e,style:"vector-effect: non-scaling-stroke",d:`${g} ${f} ${m} Z`,"alignment-baseline":"middle","text-anchor":"middle","data-key":r,"data-value":i,tabindex:"0",class:["plot-node",`plot-node-${o}`],role:"graphics-symbol","aria-roledescription":"slice","aria-label":`${r}: ${b}%`})),this.config.plot.node.label.enabled){let{multiplier:x,threshold:v,limitBySize:w,scaleBySize:C,placement:k}=this.config.plot.node.label,S=p<=v;if(k==="outside"||k==="auto"&&S){let $=t.degrees*Math.PI/180,E=55,T=62,O=50+48*Math.cos($),_=50+48*Math.sin($),Q=50+E*Math.cos($),J=50+E*Math.sin($),tt=50+T*Math.cos($),I=50+T*Math.sin($),Y=Math.cos($)>=0?"start":"end";d.appendChild(new y("line",{x1:O.toFixed(1),y1:_.toFixed(1),x2:Q.toFixed(1),y2:J.toFixed(1),stroke:"var(--chart-label-color, #737373)","stroke-width":"0.5",class:["plot-leader"]}));let z=new y("text",{fill:"var(--chart-label-color, #737373)",x:tt.toFixed(1),y:I.toFixed(1),"alignment-baseline":"middle","text-anchor":Y,style:"font-size: 0.35em;",class:["plot-node-label",`plot-node-label-${o}`]});z.innerHTML=`${M(r)} ${b}%`,d.appendChild(z)}else if(!this.config.plot.ring){let $;C&&($=.37*x*(p/100));let E=new y("text",{fill:"#fff",x:u.x,y:u.y,style:C?`font-size: ${A($)}em;`:"","alignment-baseline":"middle","text-anchor":"middle",class:w&&p>v||!w?["plot-node-label"]:["plot-node-label","hide"]});E.innerHTML=b+"%",d.appendChild(E)}}return d}tooltipLocation(t,e,o){return function(s){var r=e.querySelector("chart-plot");if(!r)return null;var a=r.getBoundingClientRect(),c=r.querySelector(".svc-nodeGroup"),n=c?c.getBoundingClientRect():a,u=n.left+n.width/2,p=n.top+n.height/2,d=s.clientX-u,h=s.clientY-p,g=Math.min(n.width,n.height)/2,f=Math.sqrt(d*d+h*h);if(f>g)return null;if(o.config.plot.ring){var m=parseFloat(o.config.center.size)||40,b=g*(m/100);if(f<b)return null}var x=Math.atan2(h,d);x<0&&(x+=2*Math.PI);var v=x/(2*Math.PI),w=(s.clientX-a.left)/a.width*100,C=(s.clientY-a.top)/a.height*100,k=o.data,S=Object.keys(k),L=S.reduce(function(nt,me){return nt+(k[me]||0)},0);if(L===0)return null;for(var $=0,E=null,T=0,O=0,_=0;_<S.length;_++){var Q=k[S[_]]||0,J=Q/L;if(v>=$&&v<$+J){E=S[_],T=Q,O=_;break}$+=J}if(!E)return null;var tt=(T/L*100).toFixed(1),I={tooltip:{},crosshair:{x1:-10,x2:-10,y1:-10,y2:-10}};I.tooltip.x=w,I.tooltip.y=C;var Y=M(String(E)),z;if(o.config.tooltip&&o.config.tooltip.format)try{z=M(String(o.config.tooltip.format(E,T)))}catch(nt){console.warn("SVC: tooltip.format threw an error:",nt),z=Y+": "+tt+"%"}else z=Y+": "+tt+"%";return I.tooltip.text='<div class="svc-tooltip-content"><span class="svc-tooltip-label-title svc-tooltip-label-title-'+O+'">'+Y+"</span> : "+z+"</div>",I.index=O,I}}},Yt=qt;var Di=window.matchMedia("(prefers-reduced-motion: reduce)");var de=new Map;function pe(l,t,e={}){let o=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:o},s=de.get(l);if(customElements.get(l)){if(!s||s.priority>=o){s&&s.priority===o&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${l}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=o){s.priority===o&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}de.set(l,i),customElements.define(l,t)}var rt=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,o,i){t.addEventListener(e,o,i),this.#t.push(()=>t.removeEventListener(e,o,i))}setup(){}teardown(){}};function Gt(l){let t=l.textContent.trim();if(!t)return null;let e=t.replace(/[$€£¥,% ]/g,""),o=Number(e);return Number.isFinite(o)?o:null}function Fe(l){let t=[...l.cells],e=-1,o=[];for(let i=0;i<t.length;i++){let s=t[i];if(!s.hasAttribute("data-chart-ignore")){if(s.hasAttribute("data-chart-label")||s.getAttribute("scope")==="row"){e=i;continue}(s.hasAttribute("data-chart-series")||!s.hasAttribute("data-chart-ignore"))&&o.push({index:i,name:s.textContent.trim()})}}if(e===-1&&t.length>0){let i=t[0];if(!i.textContent.trim()||i.tagName==="TH"){e=0;let s=o.findIndex(r=>r.index===0);s!==-1&&o.splice(s,1)}}return{labelIndex:e,columns:o}}function Pe(l){let t=l.querySelector("thead"),e=l.querySelector("tbody")||l,o=t?.querySelector("tr"),i=[...e.querySelectorAll("tr")];if(!o||i.length===0)return{data:[],config:{}};let{labelIndex:s,columns:r}=Fe(o),a=s!==-1,c=r.map(p=>({name:p.name,values:a?{}:[]}));for(let p of i){let d=[...p.cells],h=a?d[s]?.textContent.trim()||"":null;for(let g=0;g<r.length;g++){let f=d[r[g].index],m=f?Gt(f):null;a&&h?c[g].values[h]=m??0:c[g].values.push(m??0)}}let n={},u=l.querySelector("caption");return u&&(n.title={text:u.textContent.trim(),enabled:!0}),{data:c,config:n}}function Ie(l){let e=[...(l.querySelector("tbody")||l).querySelectorAll("tr")],o={};for(let r of e){let a=[...r.cells],c=r.querySelector("th"),n=c?c.textContent.trim():a[0]?.textContent.trim(),u=c?a[1]||a[0]:a[1],p=u?Gt(u):null;n&&p!=null&&(o[n]=p)}let i={},s=l.querySelector("caption");return s&&(i.title={text:s.textContent.trim(),enabled:!0}),{data:o,config:i}}function ze(l){let t=l.querySelector("thead"),e=l.querySelector("tbody")||l,o=t?.querySelector("tr"),i=[...e.querySelectorAll("tr")],s=new Map;for(let n of i){let u=[...n.cells],p=n.querySelector("th"),d=p?p.textContent.trim():"Data",h=p?[...n.querySelectorAll("td")]:u.slice(1);s.has(d)||s.set(d,[]);let g=h.map(f=>Gt(f)).filter(f=>f!=null);g.length>=2&&s.get(d).push(g)}let r=[...s.entries()].map(([n,u])=>({name:n,values:u})),a={},c=l.querySelector("caption");return c&&(a.title={text:c.textContent.trim(),enabled:!0}),{data:r,config:a}}function he(l,t){if(!l||!l.querySelector("tbody, tr"))return{data:null,config:{}};let e=(t||"").toLowerCase();return e==="pie"?Ie(l):e==="scatter"||e==="bubble"?ze(l):Pe(l)}function ue(l){let t={};return l.hasAttribute("data-tooltip")&&(t.tooltip={enabled:!0}),l.hasAttribute("data-legend")&&(t.legend={enabled:!0}),l.hasAttribute("data-grid")&&(t.guides={x:{enabled:!0},y:{enabled:!0}}),l.hasAttribute("data-labels")&&(t.plot={node:{label:{enabled:!0}}}),t}function Ne(l){let t=getComputedStyle(l),e=[];for(let o=1;o<=6;o++){let i=t.getPropertyValue(`--chart-series-${o}`).trim();i&&e.push(i)}return e.length>0?e:null}function F(l,t){return l.getPropertyValue(t).trim()||null}function Xt(l){let t=getComputedStyle(l),e={},o=F(t,"--chart-label-color"),i=F(t,"--chart-font-family");(o||i)&&(e.style={},o&&(e.style.color=o),i&&(e.style["font-family"]=i));let s=F(t,"--chart-axis-color");s&&(e.axis={style:{stroke:s}});let r=F(t,"--chart-grid-color");r&&(e.guides={style:{stroke:r}});let a=F(t,"--chart-baseline-color");a&&(e.baseline={style:{stroke:a}});let c=F(t,"--chart-tick-color");c&&(e.ticks={style:{stroke:c}});let n=F(t,"--chart-title-color"),u=F(t,"--chart-title-size");(n||u)&&(e.title=e.title||{},e.title.style={},n&&(e.title.style.color=n),u&&(e.title.style["font-size"]=u));let p=F(t,"--chart-subtitle-color"),d=F(t,"--chart-subtitle-size");(p||d)&&(e.title=e.title||{},e.title.subtitle=e.title.subtitle||{},e.title.subtitle.style={},p&&(e.title.subtitle.style.color=p),d&&(e.title.subtitle.style["font-size"]=d));let h=F(t,"--chart-tooltip-bg"),g=F(t,"--chart-tooltip-color"),f=F(t,"--chart-tooltip-shadow");(h||g||f)&&(e.tooltip=e.tooltip||{},e.tooltip.label=e.tooltip.label||{},e.tooltip.label.style={},h&&(e.tooltip.label.style["background-color"]=h),g&&(e.tooltip.label.style.color=g),f&&(e.tooltip.label.style["box-shadow"]=f));let m=Ne(l);return m&&(e.palette=m),e}function fe(l){return{name:"vb-theme-bridge",hooks:{configResolved({config:t}){let e=Xt(l);e.style&&(t.style=Object.assign({},e.style,t.style)),e.palette&&!t._paletteFromUser&&(t.palette=e.palette)}}}}var je={line:K,area:Rt,bar:st,column:Z,pie:Yt,scatter:W,bubble:Ht};function D(l,t=null){if(l==null)return t;if(typeof l!="string")return l;try{return JSON.parse(l)}catch{return t}}function H(l,t){if(!t||typeof t!="object"||Array.isArray(t))return l;for(let e of Object.keys(t))t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?((!l[e]||typeof l[e]!="object")&&(l[e]={}),H(l[e],t[e])):l[e]=t[e];return l}var Kt=class extends rt{static get observedAttributes(){return["data-type","data-values","data-config","data-title","data-subtitle","data-legend","data-tooltip","data-palette","data-label-x","data-label-y"]}#t=null;#i=null;#s=null;#n=!1;#e=null;#o=null;set data(t){this.#t=t,this.#r()}get data(){return this.#t}set config(t){this.#i=t,this.#r()}get config(){return this.#i}refresh(){this.#r()}toSVG(){return this.#e?.querySelector("svg")?.outerHTML||null}setup(){this.#r()}teardown(){this.#a()}attributeChangedCallback(){this.hasAttribute("data-upgraded")&&this.#r()}#r(){!this.isConnected||this.#n||(this.#n=!0,Promise.resolve().then(()=>{this.#n=!1,this.isConnected&&this.#u()}))}#l(){let t=(this.dataset.type||"").toLowerCase();return t||(t=(this.querySelector("table")?.dataset.type||"bar").toLowerCase()),je[t]||st}#c(){if(this.#t!=null)return{data:D(this.#t,null),tableConfig:{}};let t=this.dataset.values;if(t!=null)return{data:D(t,null),tableConfig:{}};let e=this.querySelector('script[type="application/json"]');if(e)return{data:D(e.textContent,null),tableConfig:{}};let o=this.querySelector("template[data-chart-data]");if(o){let s=o.content?.textContent||o.innerHTML;return{data:D(s,null),tableConfig:{}}}let i=this.querySelector("table");if(i){let s=(this.dataset.type||i.dataset.type||"bar").toLowerCase(),{data:r,config:a}=he(i,s),c=ue(i),n=H(H({},a),c);return{data:r,tableConfig:n}}return null}#d(t={}){let e=Xt(this),o=D(this.#i,{})||{},i=D(this.dataset.config,{})||{},s={};s=H(s,e),s=H(s,t),s=H(s,o),s=H(s,i);let r=this.dataset.labelX,a=this.dataset.labelY;if(s.axis=s.axis||{},s.axis.label=s.axis.label||{},r!=null?s.axis.label.x={text:r,enabled:!0}:s.axis.label.x?.text||(s.axis.label.x=s.axis.label.x||{},s.axis.label.x.enabled=!1),a!=null?s.axis.label.y={text:a,enabled:!0}:s.axis.label.y?.text||(s.axis.label.y=s.axis.label.y||{},s.axis.label.y.enabled=!1),s.plot?.node?.label?.scaleBySize||(s.plot=s.plot||{},s.plot.node=s.plot.node||{},s.plot.node.label=s.plot.node.label||{},s.plot.node.label.scaleBySize=!1),this.dataset.title!=null){let c={text:this.dataset.title,enabled:!0};this.dataset.subtitle!=null&&(c.subtitle=this.dataset.subtitle),s.title=c}if(this.dataset.legend!=null&&(s.legend={enabled:!0}),this.dataset.tooltip!=null&&(s.tooltip={enabled:!0}),this.dataset.palette!=null){let c=D(this.dataset.palette,null);c&&(s.palette=c)}return s.plugins=s.plugins||[],s.plugins.push(fe(this)),s}#p(){if(this.#o&&this.contains(this.#o))return;this.#o=document.createElement("div"),this.#o.setAttribute("data-chart-svg",""),this.#o.setAttribute("aria-hidden","true"),this.appendChild(this.#o);let t=this.#o.attachShadow({mode:"open"});this.#e=document.createElement("div"),this.#e.style.cssText="width:100%;height:100%;overflow:visible;",t.appendChild(this.#e)}#h(t){if(!t)return;(this.dataset.chart||t.dataset.chart||"replace")==="replace"&&(t.classList.add("sr-only"),t.setAttribute("aria-hidden","false"))}#u(){let t=this.#l(),e=this.#c();if(!e||!e.data){this.dispatchEvent(new CustomEvent("chart-wc:error",{detail:{message:"No chart data found"},bubbles:!0}));return}let{data:o,tableConfig:i}=e,s=this.#d(i);this.#a();let r=this.querySelector("table");this.#h(r),this.#p();try{this.dispatchEvent(new CustomEvent("chart-wc:config-resolved",{detail:{type:this.dataset.type||r?.dataset.type||"bar",config:s},bubbles:!0})),this.#s=new t({config:s,data:o}),this.#s.mount(this.#e),this.dispatchEvent(new CustomEvent("chart-wc:render",{detail:{type:this.dataset.type||r?.dataset.type||"bar",seriesCount:Array.isArray(o)?o.length:Object.keys(o).length},bubbles:!0}))}catch(a){this.dispatchEvent(new CustomEvent("chart-wc:error",{detail:{message:a.message},bubbles:!0}))}}#a(){this.#s&&(this.#s.destroy(),this.#s=null),this.#e&&(this.#e.innerHTML="")}};pe("chart-wc",Kt);export{Kt as ChartWc};
|
|
394
|
+
</div>`}),r.tooltip.text=c,r}}createPlot({data:t,stats:e,subchartNoStretch:o}){t.forEach((i,s)=>{i.values.forEach((a,c)=>{let n=a[0],u=a[1],p=i.name||`Series ${s+1}`,d=new y("circle",{cx:((n-e.x.min)*e.x.scaleFactor).toFixed(3)+"%",cy:((e.y.max-u)*e.y.scaleFactor).toFixed(3)+"%",r:this.config.plot.size,class:["plot-node",`plot-${s}`,`plot-node-${s}`],"data-index":c,"data-series":s,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${p}, (${n}, ${u})`});o.appendChild(d)})})}};function Fe(l){let t=Array.from(new Array(10)).map(()=>Array.from(new Array(10)).map(()=>[]));return l.querySelectorAll(".svc-plot-node").forEach(e=>{let o=parseInt(e.getAttribute("data-series"),10),i=parseInt(e.getAttribute("cx")),s=parseInt(e.getAttribute("cy")),r=Math.min(9,Math.floor(i/10)),a=parseInt((i/10).toFixed(1).split(".")[1]),c=Math.min(9,Math.floor(s/10));t[c][r][a]=t[c][r][a]||[],t[c][r][a][o]=e}),t}var W=Dt;var Ht=class extends W{static get type(){return"bubble"}static get defaults(){return{plot:{maxSize:4,node:{}}}}static specs(){return{"plot.node":{fill:"primary"}}}createPlot({data:t,stats:e,subchartStretch:o,subchartNoStretch:i}){t.forEach((s,r)=>{s.values.forEach((c,n)=>{let u=c[0],p=c[1],d=c[2],h=s.name||`Series ${r+1}`,g=e.alt.max-e.alt.min||1,f=(Math.abs(d)-e.alt.min)/g,m=new y("circle",{cx:((u-e.x.min)*e.x.scaleFactor).toFixed(3)+"%",cy:((e.y.max-p)*e.y.scaleFactor).toFixed(3)+"%",r:f*this.config.plot.maxSize+.5+"%",style:`opacity: ${.7}`,class:["plot-node",`plot-${r}`,`plot-node-${r}`],"data-index":n,"data-series":r,role:"graphics-symbol","aria-roledescription":"data point","aria-label":`${h}, (${u}, ${p}), size: ${d}`});i.appendChild(m)})})}},qt=Ht;var Yt=class extends it{static get type(){return"pie"}static get defaults(){return{plot:{ring:!1,node:{label:{enabled:!0,placement:"auto",scaleBySize:!0,limitBySize:!0,multiplier:1,threshold:12,style:{"font-size":"clamp(8px, 0.6vmin, 16px)"}}}},center:{size:"40%",style:{fill:"#fff"},label:{style:{"font-size":"5vmin",transform:"translate(0%, -50%)","text-align":"center"},container:{style:{display:"flex","justify-content":"center","align-items":"center"}},title:{style:{"font-size":"7vmin"}}}}}}static specs(){return{plot:{fill:"primary"},"plot.node":{fill:"primary"}}}parse(t){t=super.parse(t);let{layoutChart:e}=t,o=this.createGraph({stretch:!0});e.appendChild(o);let i=this.createGraph({stretch:!1});e.appendChild(i),this.createPlot({layoutChart:e,subchartStretch:o,subchartNoStretch:i}),i.appendChild(new y("g"));let s=new y("style");return s.innerHTML=".plot {opacity: 1;}.svc-loading {opacity:0;}",e.appendChild(s),t}createScript(){return new j({stats:this.stats,data:this.data,config:this.config}).render()}createPlot({layoutChart:t,subchartStretch:e,subchartNoStretch:o}){let i=this.data;if(!z(i))throw new Error('SVC: Pie chart "data" must be a plain object with numeric values, e.g. { "Apples": 30, "Oranges": 70 }.');Object.keys(i).forEach(u=>{if(typeof i[u]!="number")throw new Error(`SVC: Pie chart value for "${u}" must be a number.`);if(i[u]<0)throw new Error(`SVC: Pie chart value for "${u}" is negative (${i[u]}). Pie charts require non-negative values.`)});let s=Object.keys(i).reduce((u,p)=>u+=i[p],0);if(s===0){let u=new y("text",{x:"50%",y:"50%","text-anchor":"middle","alignment-baseline":"middle",class:["loading"]});u.textContent="No data",o.appendChild(u);return}let r=0,a=0,c=this.config.plot.node.instances.map(u=>u.fill);Object.keys(i).forEach((u,p)=>{let d=i[u],h=d/s,g=r/s,f=c[a%c.length],m=this.calculateSlice(h,g),b=this.createSlice(m,f,p,d,s,u);o.appendChild(b),a++,r+=d});let n=new y("svg",{height:"100%",width:"100%",overflow:"visible",viewBox:"0 0 100 100",class:["nodeGroup"]});if(this.config.plot.ring){let p=(parseFloat(this.config.center.size)||40)/2;n.appendChild(new y("circle",{cx:"50",cy:"50",r:String(p),fill:"var(--color-surface, #fff)",class:["center"]}))}o.appendChild(n)}calculateSlice(t,e){let i=Math.cos((e+t)*2*Math.PI)*50+50,s=Math.sin((e+t)*2*Math.PI)*50+50,r=Math.cos(e*2*Math.PI)*50+50,a=Math.sin(e*2*Math.PI)*50+50,c=e*360,n=t*360+c,u=(n+c)/2,p=50+50*Math.cos(u*2*Math.PI/360),d=50+50*Math.sin(u*2*Math.PI/360);p=(p+50)*.5,d=(d+50)*.5;let h=n-c;return{radius:50,degrees:u,degreeLength:h,start:{x:i,y:s},end:{x:r,y:a},center:{x:p,y:d}}}createSlice(t,e,o,i,s,r){let{radius:a,start:c,end:n,center:u,degreeLength:p}=t,d=new y("svg",{height:"100%",width:"100%",overflow:"visible",viewBox:"0 0 100 100",class:["nodeGroup"]}),h=p>180?1:0,g=`M ${a} ${a}`,f=`L${c.x} ${c.y}`,m=`A ${a} ${a} 0 ${h} 0 ${n.x} ${n.y}`,b=(i/s*100).toFixed(0);if(d.appendChild(new y("path",{fill:e,style:"vector-effect: non-scaling-stroke",d:`${g} ${f} ${m} Z`,"alignment-baseline":"middle","text-anchor":"middle","data-key":r,"data-value":i,tabindex:"0",class:["plot-node",`plot-node-${o}`],role:"graphics-symbol","aria-roledescription":"slice","aria-label":`${r}: ${b}%`})),this.config.plot.node.label.enabled){let{multiplier:x,threshold:v,limitBySize:w,scaleBySize:C,placement:k}=this.config.plot.node.label,S=p<=v;if(k==="outside"||k==="auto"&&S){let $=t.degrees*Math.PI/180,E=55,T=62,O=50+48*Math.cos($),_=50+48*Math.sin($),J=50+E*Math.cos($),tt=50+E*Math.sin($),et=50+T*Math.cos($),I=50+T*Math.sin($),Y=Math.cos($)>=0?"start":"end";d.appendChild(new y("line",{x1:O.toFixed(1),y1:_.toFixed(1),x2:J.toFixed(1),y2:tt.toFixed(1),stroke:"var(--chart-label-color, #737373)","stroke-width":"0.5",class:["plot-leader"]}));let N=new y("text",{fill:"var(--chart-label-color, #737373)",x:et.toFixed(1),y:I.toFixed(1),"alignment-baseline":"middle","text-anchor":Y,style:"font-size: 0.35em;",class:["plot-node-label",`plot-node-label-${o}`]});N.innerHTML=`${M(r)} ${b}%`,d.appendChild(N)}else if(!this.config.plot.ring){let $;C&&($=.37*x*(p/100));let E=new y("text",{fill:"#fff",x:u.x,y:u.y,style:C?`font-size: ${A($)}em;`:"","alignment-baseline":"middle","text-anchor":"middle",class:w&&p>v||!w?["plot-node-label"]:["plot-node-label","hide"]});E.innerHTML=b+"%",d.appendChild(E)}}return d}tooltipLocation(t,e,o){return function(s){var r=e.querySelector("chart-plot");if(!r)return null;var a=r.getBoundingClientRect(),c=r.querySelector(".svc-nodeGroup"),n=c?c.getBoundingClientRect():a,u=n.left+n.width/2,p=n.top+n.height/2,d=s.clientX-u,h=s.clientY-p,g=Math.min(n.width,n.height)/2,f=Math.sqrt(d*d+h*h);if(f>g)return null;if(o.config.plot.ring){var m=parseFloat(o.config.center.size)||40,b=g*(m/100);if(f<b)return null}var x=Math.atan2(h,d);x<0&&(x+=2*Math.PI);var v=x/(2*Math.PI),w=(s.clientX-a.left)/a.width*100,C=(s.clientY-a.top)/a.height*100,k=o.data,S=Object.keys(k),L=S.reduce(function(at,ye){return at+(k[ye]||0)},0);if(L===0)return null;for(var $=0,E=null,T=0,O=0,_=0;_<S.length;_++){var J=k[S[_]]||0,tt=J/L;if(v>=$&&v<$+tt){E=S[_],T=J,O=_;break}$+=tt}if(!E)return null;var et=(T/L*100).toFixed(1),I={tooltip:{},crosshair:{x1:-10,x2:-10,y1:-10,y2:-10}};I.tooltip.x=w,I.tooltip.y=C;var Y=M(String(E)),N;if(o.config.tooltip&&o.config.tooltip.format)try{N=M(String(o.config.tooltip.format(E,T)))}catch(at){console.warn("SVC: tooltip.format threw an error:",at),N=Y+": "+et+"%"}else N=Y+": "+et+"%";return I.tooltip.text='<div class="svc-tooltip-content"><span class="svc-tooltip-label-title svc-tooltip-label-title-'+O+'">'+Y+"</span> : "+N+"</div>",I.index=O,I}}},Q=Yt;var Gt=class extends Q{static get type(){return"pie"}static get defaults(){return{plot:{ring:!0}}}},Xt=Gt;var Xi=window.matchMedia("(prefers-reduced-motion: reduce)");var he=new Map;function ue(l,t,e={}){let o=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:o},s=he.get(l);if(customElements.get(l)){if(!s||s.priority>=o){s&&s.priority===o&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${l}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=o){s.priority===o&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}he.set(l,i),customElements.define(l,t)}var nt=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,o,i){t.addEventListener(e,o,i),this.#t.push(()=>t.removeEventListener(e,o,i))}setup(){}teardown(){}};function Kt(l){let t=l.textContent.trim();if(!t)return null;let e=t.replace(/[$€£¥,% ]/g,""),o=Number(e);return Number.isFinite(o)?o:null}function Ie(l){let t=[...l.cells],e=-1,o=[];for(let i=0;i<t.length;i++){let s=t[i];if(!s.hasAttribute("data-chart-ignore")){if(s.hasAttribute("data-chart-label")||s.getAttribute("scope")==="row"){e=i;continue}(s.hasAttribute("data-chart-series")||!s.hasAttribute("data-chart-ignore"))&&o.push({index:i,name:s.textContent.trim()})}}if(e===-1&&t.length>0){let i=t[0];if(!i.textContent.trim()||i.tagName==="TH"){e=0;let s=o.findIndex(r=>r.index===0);s!==-1&&o.splice(s,1)}}return{labelIndex:e,columns:o}}function Ne(l){let t=l.querySelector("thead"),e=l.querySelector("tbody")||l,o=t?.querySelector("tr"),i=[...e.querySelectorAll("tr")];if(!o||i.length===0)return{data:[],config:{}};let{labelIndex:s,columns:r}=Ie(o),a=s!==-1,c=r.map(p=>({name:p.name,values:a?{}:[]}));for(let p of i){let d=[...p.cells],h=a?d[s]?.textContent.trim()||"":null;for(let g=0;g<r.length;g++){let f=d[r[g].index],m=f?Kt(f):null;a&&h?c[g].values[h]=m??0:c[g].values.push(m??0)}}let n={},u=l.querySelector("caption");return u&&(n.title={text:u.textContent.trim(),enabled:!0}),{data:c,config:n}}function ze(l){let e=[...(l.querySelector("tbody")||l).querySelectorAll("tr")],o={};for(let r of e){let a=[...r.cells],c=r.querySelector("th"),n=c?c.textContent.trim():a[0]?.textContent.trim(),u=c?a[1]||a[0]:a[1],p=u?Kt(u):null;n&&p!=null&&(o[n]=p)}let i={},s=l.querySelector("caption");return s&&(i.title={text:s.textContent.trim(),enabled:!0}),{data:o,config:i}}function je(l){let t=l.querySelector("thead"),e=l.querySelector("tbody")||l,o=t?.querySelector("tr"),i=[...e.querySelectorAll("tr")],s=new Map;for(let n of i){let u=[...n.cells],p=n.querySelector("th"),d=p?p.textContent.trim():"Data",h=p?[...n.querySelectorAll("td")]:u.slice(1);s.has(d)||s.set(d,[]);let g=h.map(f=>Kt(f)).filter(f=>f!=null);g.length>=2&&s.get(d).push(g)}let r=[...s.entries()].map(([n,u])=>({name:n,values:u})),a={},c=l.querySelector("caption");return c&&(a.title={text:c.textContent.trim(),enabled:!0}),{data:r,config:a}}function fe(l,t){if(!l||!l.querySelector("tbody, tr"))return{data:null,config:{}};let e=(t||"").toLowerCase();return e==="pie"||e==="ring"?ze(l):e==="scatter"||e==="bubble"?je(l):Ne(l)}function me(l){let t={};return l.hasAttribute("data-tooltip")&&(t.tooltip={enabled:!0}),l.hasAttribute("data-legend")&&(t.legend={enabled:!0}),l.hasAttribute("data-grid")&&(t.guides={x:{enabled:!0},y:{enabled:!0}}),l.hasAttribute("data-labels")&&(t.plot={node:{label:{enabled:!0}}}),t}function Re(l){let t=getComputedStyle(l),e=[];for(let o=1;o<=6;o++){let i=t.getPropertyValue(`--chart-series-${o}`).trim();i&&e.push(i)}return e.length>0?e:null}function F(l,t){return l.getPropertyValue(t).trim()||null}function Zt(l){let t=getComputedStyle(l),e={},o=F(t,"--chart-label-color"),i=F(t,"--chart-font-family");(o||i)&&(e.style={},o&&(e.style.color=o),i&&(e.style["font-family"]=i));let s=F(t,"--chart-axis-color");s&&(e.axis={style:{stroke:s}});let r=F(t,"--chart-grid-color");r&&(e.guides={style:{stroke:r}});let a=F(t,"--chart-baseline-color");a&&(e.baseline={style:{stroke:a}});let c=F(t,"--chart-tick-color");c&&(e.ticks={style:{stroke:c}});let n=F(t,"--chart-title-color"),u=F(t,"--chart-title-size");(n||u)&&(e.title=e.title||{},e.title.style={},n&&(e.title.style.color=n),u&&(e.title.style["font-size"]=u));let p=F(t,"--chart-subtitle-color"),d=F(t,"--chart-subtitle-size");(p||d)&&(e.title=e.title||{},e.title.subtitle=e.title.subtitle||{},e.title.subtitle.style={},p&&(e.title.subtitle.style.color=p),d&&(e.title.subtitle.style["font-size"]=d));let h=F(t,"--chart-tooltip-bg"),g=F(t,"--chart-tooltip-color"),f=F(t,"--chart-tooltip-shadow");(h||g||f)&&(e.tooltip=e.tooltip||{},e.tooltip.label=e.tooltip.label||{},e.tooltip.label.style={},h&&(e.tooltip.label.style["background-color"]=h),g&&(e.tooltip.label.style.color=g),f&&(e.tooltip.label.style["box-shadow"]=f));let m=Re(l);return m&&(e.palette=m),e}function ge(l){return{name:"vb-theme-bridge",hooks:{configResolved({config:t}){let e=Zt(l);e.style&&(t.style=Object.assign({},e.style,t.style)),e.palette&&!t._paletteFromUser&&(t.palette=e.palette)}}}}var Be={line:K,area:Bt,bar:rt,column:Z,pie:Q,ring:Xt,scatter:W,bubble:qt};function D(l,t=null){if(l==null)return t;if(typeof l!="string")return l;try{return JSON.parse(l)}catch{return t}}function H(l,t){if(!t||typeof t!="object"||Array.isArray(t))return l;for(let e of Object.keys(t))t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?((!l[e]||typeof l[e]!="object")&&(l[e]={}),H(l[e],t[e])):l[e]=t[e];return l}var Wt=class extends nt{static get observedAttributes(){return["data-type","data-values","data-config","data-title","data-subtitle","data-legend","data-tooltip","data-palette","data-label-x","data-label-y"]}#t=null;#i=null;#s=null;#n=!1;#e=null;#o=null;set data(t){this.#t=t,this.#r()}get data(){return this.#t}set config(t){this.#i=t,this.#r()}get config(){return this.#i}refresh(){this.#r()}toSVG(){return this.#e?.querySelector("svg")?.outerHTML||null}setup(){this.#r()}teardown(){this.#a()}attributeChangedCallback(){this.hasAttribute("data-upgraded")&&this.#r()}#r(){!this.isConnected||this.#n||(this.#n=!0,Promise.resolve().then(()=>{this.#n=!1,this.isConnected&&this.#u()}))}#l(){let t=(this.dataset.type||"").toLowerCase();return t||(t=(this.querySelector("table")?.dataset.type||"bar").toLowerCase()),Be[t]||rt}#c(){if(this.#t!=null)return{data:D(this.#t,null),tableConfig:{}};let t=this.dataset.values;if(t!=null)return{data:D(t,null),tableConfig:{}};let e=this.querySelector('script[type="application/json"]');if(e)return{data:D(e.textContent,null),tableConfig:{}};let o=this.querySelector("template[data-chart-data]");if(o){let s=o.content?.textContent||o.innerHTML;return{data:D(s,null),tableConfig:{}}}let i=this.querySelector("table");if(i){let s=(this.dataset.type||i.dataset.type||"bar").toLowerCase(),{data:r,config:a}=fe(i,s),c=me(i),n=H(H({},a),c);return{data:r,tableConfig:n}}return null}#d(t={}){let e=Zt(this),o=D(this.#i,{})||{},i=D(this.dataset.config,{})||{},s={};s=H(s,e),s=H(s,t),s=H(s,o),s=H(s,i);let r=this.dataset.labelX,a=this.dataset.labelY;if(s.axis=s.axis||{},s.axis.label=s.axis.label||{},r!=null?s.axis.label.x={text:r,enabled:!0}:s.axis.label.x?.text||(s.axis.label.x=s.axis.label.x||{},s.axis.label.x.enabled=!1),a!=null?s.axis.label.y={text:a,enabled:!0}:s.axis.label.y?.text||(s.axis.label.y=s.axis.label.y||{},s.axis.label.y.enabled=!1),s.plot?.node?.label?.scaleBySize||(s.plot=s.plot||{},s.plot.node=s.plot.node||{},s.plot.node.label=s.plot.node.label||{},s.plot.node.label.scaleBySize=!1),this.dataset.title!=null){let c={text:this.dataset.title,enabled:!0};this.dataset.subtitle!=null&&(c.subtitle=this.dataset.subtitle),s.title=c}if(this.dataset.legend!=null&&(s.legend={enabled:!0}),this.dataset.tooltip!=null&&(s.tooltip={enabled:!0}),this.dataset.palette!=null){let c=D(this.dataset.palette,null);c&&(s.palette=c)}return s.plugins=s.plugins||[],s.plugins.push(ge(this)),s}#p(){if(this.#o&&this.contains(this.#o))return;this.#o=document.createElement("div"),this.#o.setAttribute("data-chart-svg",""),this.#o.setAttribute("aria-hidden","true"),this.appendChild(this.#o);let t=this.#o.attachShadow({mode:"open"});this.#e=document.createElement("div"),this.#e.style.cssText="width:100%;height:100%;overflow:visible;",t.appendChild(this.#e)}#h(t){if(!t)return;(this.dataset.chart||t.dataset.chart||"replace")==="replace"&&(t.classList.add("visually-hidden"),t.setAttribute("aria-hidden","false"))}#u(){let t=this.#l(),e=this.#c();if(!e||!e.data){this.dispatchEvent(new CustomEvent("chart-wc:error",{detail:{message:"No chart data found"},bubbles:!0}));return}let{data:o,tableConfig:i}=e,s=this.#d(i);this.#a();let r=this.querySelector("table");this.#h(r),this.#p();try{this.dispatchEvent(new CustomEvent("chart-wc:config-resolved",{detail:{type:this.dataset.type||r?.dataset.type||"bar",config:s},bubbles:!0})),this.#s=new t({config:s,data:o}),this.#s.mount(this.#e),this.dispatchEvent(new CustomEvent("chart-wc:render",{detail:{type:this.dataset.type||r?.dataset.type||"bar",seriesCount:Array.isArray(o)?o.length:Object.keys(o).length},bubbles:!0}))}catch(a){this.dispatchEvent(new CustomEvent("chart-wc:error",{detail:{message:a.message},bubbles:!0}))}}#a(){this.#s&&(this.#s.destroy(),this.#s=null),this.#e&&(this.#e.innerHTML="")}};ue("chart-wc",Wt);export{Wt as ChartWc};
|
|
395
395
|
//# sourceMappingURL=chart-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var d=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function u(n,e,t={}){let i=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:i},s=l.get(n);if(customElements.get(n)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==e&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}l.set(n,r),customElements.define(n,e)}var
|
|
1
|
+
var d=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function u(n,e,t={}){let i=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:i},s=l.get(n);if(customElements.get(n)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==e&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}l.set(n,r),customElements.define(n,e)}var a=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#t)e();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,i,r){e.addEventListener(t,i,r),this.#t.push(()=>e.removeEventListener(t,i,r))}setup(){}teardown(){}};var o=class extends a{static formAssociated=!0;#t;#e;#s;#r;constructor(){super(),this.#t=this.attachInternals()}setup(){if(this.#e=this.querySelector(":scope > textarea, :scope textarea[data-grow]"),this.#s=this.querySelector("[data-send]"),!this.#e)return!1;this.listen(this.#e,"keydown",this.#o),this.listen(this.#e,"input",this.#l),this.#s&&this.listen(this.#s,"click",this.#u),this.#i(),this.#n(),this.hasAttribute("autofocus")&&requestAnimationFrame(()=>this.#e.focus())}teardown(){clearTimeout(this.#r)}#o=e=>{switch(e.key){case"Enter":e.shiftKey||(e.preventDefault(),this.#a());break;case"Escape":e.preventDefault(),this.reset();break}};#l=()=>{this.#i(),this.#n(),clearTimeout(this.#r),this.#r=setTimeout(()=>{this.dispatchEvent(new CustomEvent("chat-input:input",{bubbles:!0,detail:{value:this.value,length:this.value.length}}))},100)};#u=e=>{e.preventDefault(),this.#a()};#a(){let e=this.value.trim(),t=parseInt(this.getAttribute("minlength")??"1",10)||1;e.length<t||this.disabled||(this.dispatchEvent(new CustomEvent("chat-input:send",{bubbles:!0,detail:{message:e,from:null,model:null}})),this.reset())}#i(){let e=this.value;e?this.#t.setFormValue(e):this.#t.setFormValue(null)}#n(){let e=this.value,t=parseInt(this.getAttribute("maxlength")??"4000",10)||4e3;e.length>t?this.#t.setValidity({tooLong:!0},`Message exceeds ${t} characters`,this.#e):this.#t.setValidity({})}formResetCallback(){this.reset()}formStateRestoreCallback(e){!e||!this.#e||(this.#e.value=e,this.#i(),this.#n())}get value(){return this.#e?.value??""}set value(e){this.#e&&(this.#e.value=e,this.#e.dispatchEvent(new Event("input",{bubbles:!0})),this.#i(),this.#n())}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?(this.setAttribute("disabled",""),this.#e&&(this.#e.disabled=!0),this.#s&&(this.#s.disabled=!0)):(this.removeAttribute("disabled"),this.#e&&(this.#e.disabled=!1),this.#s&&(this.#s.disabled=!1))}focus(){this.#e?.focus()}reset(){this.#e&&(this.#e.value="",this.#e.dispatchEvent(new Event("input",{bubbles:!0})),this.#i(),this.#n())}static get observedAttributes(){return["disabled"]}attributeChangedCallback(e,t,i){if(e==="disabled"){let r=i!==null;this.#e&&(this.#e.disabled=r),this.#s&&(this.#s.disabled=r)}}};u("chat-input",o);export{o as ChatInput};
|
|
2
2
|
//# sourceMappingURL=chat-input.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function l(r){if(!r||typeof r!="string")return"";let t=document.createElement("template");return t.innerHTML=r,t.content.querySelectorAll("script, iframe, object, embed, form, base, link, meta, noscript").forEach(i=>i.remove()),t.content.querySelectorAll("*").forEach(i=>{for(let s of[...i.attributes]){if(s.name.startsWith("on")){i.removeAttribute(s.name);continue}if(["href","src","action","formaction","xlink:href"].includes(s.name)){let
|
|
1
|
+
function l(r){if(!r||typeof r!="string")return"";let t=document.createElement("template");return t.innerHTML=r,t.content.querySelectorAll("script, iframe, object, embed, form, base, link, meta, noscript").forEach(i=>i.remove()),t.content.querySelectorAll("*").forEach(i=>{for(let s of[...i.attributes]){if(s.name.startsWith("on")){i.removeAttribute(s.name);continue}if(["href","src","action","formaction","xlink:href"].includes(s.name)){let a=s.value.trim().toLowerCase();(a.startsWith("javascript:")||a.startsWith("data:text/html"))&&i.removeAttribute(s.name);continue}(s.name==="srcdoc"||s.name==="data"&&i.tagName==="OBJECT")&&i.removeAttribute(s.name)}}),t.innerHTML}var m=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function h(r,t,e={}){let n=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:n},s=u.get(r);if(customElements.get(r)){if(!s||s.priority>=n){s&&s.priority===n&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=n){s.priority===n&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}u.set(r,i),customElements.define(r,t)}var c=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,i){t.addEventListener(e,n,i),this.#t.push(()=>t.removeEventListener(e,n,i))}setup(){}teardown(){}};var d=class extends c{#t=null;#i=null;#e=null;#n=new Map;#s=null;setup(){this.#u(),this.#h(),this.#f(),this.#c(),this.#r(),this.#m()}teardown(){}#u(){this.#t=this.querySelector(":scope > chat-thread"),this.#i=this.querySelector(":scope > chat-input"),this.#e=this.querySelector(":scope > header select[data-model-select]")}#h(){let t=this.querySelector(":scope > script[data-participants]");if(t)try{let e=JSON.parse(t.textContent);this.#n=new Map(Object.entries(e))}catch{console.warn("[chat-window] Invalid participant JSON")}}#c(){if(this.#t)for(let t of this.#t.querySelectorAll("chat-message[data-from]"))this.#o(t)}#o(t){let e=t.getAttribute("data-from");if(!e)return;let n=this.#n.get(e);n?.name?t.setAttribute("data-from-label",n.name):t.hasAttribute("data-from-label")||t.setAttribute("data-from-label",e)}#f(){if(!this.#e)return;let t=this.getAttribute("model");t?this.#e.value=t:this.#e.value&&this.setAttribute("model",this.#e.value)}#m(){this.listen(this,"chat-input:send",this.#p),this.#e&&this.listen(this.#e,"change",this.#b)}#p=async t=>{t.stopPropagation();let{message:e}=t.detail;if(!e||!this.#t)return;let n=this.#l("user",e,"user");this.#t.appendChild(n),this.#a(),this.#r();let i=this.#y(),s=this.#g(i);this.#t.appendChild(s),this.#a(),this.#i&&(this.#i.disabled=!0);let a=this.getAttribute("endpoint");if(a)try{let o=await this.#E(a,e);this.#d(s,o)}catch(o){this.#d(s,"<p>Sorry, something went wrong.</p>"),s.setAttribute("data-status","error"),this.dispatchEvent(new CustomEvent("chat-window:error",{bubbles:!0,detail:{error:o.message,status:o.status??0}}))}else this.dispatchEvent(new CustomEvent("chat-window:send",{bubbles:!0,detail:{message:e,typingElement:s}}));this.#i&&(this.#i.disabled=!1,this.#i.focus()),this.#a()};#b=()=>{let t=this.#e.value;this.setAttribute("model",t),this.dispatchEvent(new CustomEvent("chat-window:model-change",{bubbles:!0,detail:{model:t}}))};#l(t,e,n){let i=document.createElement("chat-message");i.setAttribute("data-role",t),n&&(i.setAttribute("data-from",n),this.#o(i));let s=document.createElement("chat-bubble");if(e.includes("<"))s.innerHTML=l(e);else{let a=document.createElement("p");a.textContent=e,s.appendChild(a)}return i.appendChild(s),i}#g(t){let e=document.createElement("chat-message");if(e.setAttribute("data-role","agent"),e.setAttribute("data-status","typing"),t){e.setAttribute("data-from",t),this.#o(e);let a=this.#n.get(t)?.name??t;e.setAttribute("aria-label",`${a} is typing`)}else e.setAttribute("aria-label","Agent is typing");let n=this.getAttribute("model");n&&e.setAttribute("data-model",n);let i=document.createElement("chat-bubble");return e.appendChild(i),e}#d(t,e){let n=t.querySelector("chat-bubble");n&&(n.innerHTML=l(e)),t.removeAttribute("data-status"),t.removeAttribute("aria-label")}#y(){for(let[t,e]of this.#n)if(e.role==="agent")return t;return null}#r(){if(!this.#t)return;this.#t.querySelector("chat-message")!==null?(this.#s&&(this.#s.remove(),this.#s=null),this.#t.hidden=!1):(this.#t.hidden=!0,this.#s||(this.#s=document.createElement("p"),this.#s.setAttribute("data-chat-empty",""),this.#s.textContent=this.getAttribute("empty-message")||"Send a message to start.",this.#t.insertAdjacentElement("afterend",this.#s)))}#a(){this.#t&&requestAnimationFrame(()=>{this.#t.scrollTop=this.#t.scrollHeight})}async#E(t,e){let n={message:e,model:this.getAttribute("model")||void 0},i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){let a=new Error(`Chat request failed: ${i.status}`);throw a.status=i.status,a}let s=await i.json();return s.html??s.message??s.content??""}get model(){return this.getAttribute("model")??""}set model(t){this.setAttribute("model",t),this.#e&&(this.#e.value=t)}get participants(){return this.#n}set participants(t){this.#n=t instanceof Map?t:new Map(Object.entries(t)),this.#c()}clearThread(){if(this.#t){for(;this.#t.firstChild;)this.#t.removeChild(this.#t.firstChild);this.#r()}}appendMessage(t,e,n){if(!this.#t)return;let i=this.#l(t,e,n);this.#t.appendChild(i),this.#a(),this.#r()}};h("chat-window",d);export{d as ChatWindow};
|
|
2
2
|
//# sourceMappingURL=chat-window.js.map
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var S=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function g(a,o,i={}){let e=i.priority??10,t={impl:o,bundle:i.bundle,contract:i.contract,priority:e},s=v.get(a);if(customElements.get(a)){if(!s||s.priority>=e){s&&s.priority===e&&s.impl!==o&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=e){s.priority===e&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}v.set(a,t),customElements.define(a,o)}var f=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let o of this.#e)o();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(o,i,e,t){o.addEventListener(i,e,t),this.#e.push(()=>o.removeEventListener(i,e,t))}setup(){}teardown(){}};var b=class extends f{static observedAttributes=["colors","names","layout","show-values","show-names","size","editable"];#e=[];setup(){this.#o()}attributeChangedCallback(){this.isConnected&&this.#o()}#o(){let o=this.getAttribute("colors")||"",i=this.getAttribute("names")||"",e=this.getAttribute("layout")||"inline",t=this.getAttribute("size")||"md",s=this.hasAttribute("show-values"),r=this.hasAttribute("show-names")||i.length>0,n=this.hasAttribute("editable"),u=this.#c(o);this.#e=u.slice();let d=i?i.split(",").map(c=>c.trim()):[],h={sm:48,md:80,lg:120}[t]||80,m="display:flex;flex-wrap:wrap;gap:var(--size-xs,0.5rem)";e==="grid"?m=`display:grid;grid-template-columns:repeat(auto-fill,minmax(${h}px,1fr));gap:var(--size-xs,0.5rem)`:e==="list"&&(m="display:flex;flex-direction:column;gap:var(--size-xs,0.5rem)");let w=u.map((c,p)=>{let l=d[p]||"",E=this.#s(c),y=e==="list"?"display:flex;flex-direction:row;align-items:center;gap:0.75rem":`display:flex;flex-direction:column;align-items:center;gap:0.25rem;max-inline-size:${h}px`,x=e==="list"?36:h,$=`background:${c};color:${E};width:${x}px;height:${x}px;border:1px solid oklch(0% 0 0/0.15);border-radius:var(--radius-s,0.25rem);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;font-family:var(--font-mono,monospace);position:relative;overflow:hidden;flex-shrink:0`;if(n){let C=this.#a(c);return`<div class="swatch-wrap" role="listitem" style="${y}">
|
|
2
|
+
<label class="color-box color-box-edit" style="${$};cursor:pointer" data-index="${p}" title="Click to edit${l?": "+l:""}" aria-label="${l||"Color "+(p+1)}: ${c}. Click to edit.">
|
|
3
|
+
<input type="color" class="color-input" value="${C}" data-index="${p}" style="position:absolute;inset:0;opacity:0;cursor:pointer;inline-size:100%;block-size:100%" aria-label="${l||"Color "+(p+1)} picker">
|
|
4
|
+
<span class="color-value" style="font-size:0.625rem;line-height:1.2;opacity:${s?"1":"0"};text-align:center;padding:2px 4px;word-break:break-all;transition:opacity 0.15s ease;pointer-events:none">${this.#t(c)}</span>
|
|
5
|
+
</label>
|
|
6
|
+
${r&&l?`<span style="font-size:var(--font-size-xs,0.75rem);color:var(--color-text-muted,#666);text-align:center;max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${l}</span>`:""}
|
|
7
|
+
</div>`}return`<div class="swatch-wrap" role="listitem" style="${y}">
|
|
8
|
+
<button type="button" class="color-box" data-index="${p}"
|
|
9
|
+
style="${$}"
|
|
4
10
|
title="Click to copy${l?": "+l:""}"
|
|
5
|
-
aria-label="${l||"Color "+(
|
|
6
|
-
<span class="color-value" style="font-size:0.625rem;line-height:1.2;opacity:${
|
|
11
|
+
aria-label="${l||"Color "+(p+1)}: ${c}">
|
|
12
|
+
<span class="color-value" style="font-size:0.625rem;line-height:1.2;opacity:${s?"1":"0"};text-align:center;padding:2px 4px;word-break:break-all;transition:opacity 0.15s ease">${this.#t(c)}</span>
|
|
7
13
|
</button>
|
|
8
|
-
${
|
|
9
|
-
</div>`}).join("");this.innerHTML=`<div class="palette ${e}" role="list" aria-label="Color palette" style="${
|
|
14
|
+
${r&&l?`<span style="font-size:var(--font-size-xs,0.75rem);color:var(--color-text-muted,#666);text-align:center;max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${l}</span>`:""}
|
|
15
|
+
</div>`}).join("");this.innerHTML=`<div class="palette ${e}" role="list" aria-label="Color palette" style="${m}">${w}</div>`,n?this.#n(d):(this.#l(u,d),this.#r(u,d,s))}#r(o,i,e){this.querySelectorAll(".color-box").forEach(t=>{e||(t.addEventListener("pointerenter",()=>{let s=t.querySelector(".color-value");s&&(s.style.opacity="1")}),t.addEventListener("pointerleave",()=>{let s=t.querySelector(".color-value");s&&(s.style.opacity="0")})),t.addEventListener("click",()=>{let s=Number(t.dataset.index),r=o[s],n=i[s]||"";navigator.clipboard?.writeText(r),this.dispatchEvent(new CustomEvent("color-palette:select",{bubbles:!0,detail:{color:r,name:n,index:s}})),t.style.outline="3px solid currentColor",t.style.outlineOffset="2px",setTimeout(()=>{t.style.outline="",t.style.outlineOffset=""},600)})})}#n(o){this.querySelectorAll(".color-input").forEach(i=>{i.addEventListener("input",()=>{let e=Number(i.dataset.index),t=i.value;this.#e[e]=t;let s=i.parentElement;if(s){s.style.background=t,s.style.color=this.#s(t);let r=s.querySelector(".color-value");r&&(r.textContent=this.#t(t)),s.title=`Click to edit${o[e]?": "+o[e]:""} (${t})`,s.setAttribute("aria-label",`${o[e]||"Color "+(e+1)}: ${t}. Click to edit.`)}this.setAttribute("colors",this.#e.join(",")),this.dispatchEvent(new CustomEvent("color-palette:change",{bubbles:!0,detail:{color:t,name:o[e]||"",index:e,colors:this.#e.slice()}}))})})}get colors(){return this.#e.slice()}#l(o,i){this.querySelectorAll(".color-box").forEach(e=>{let t=Number(e.dataset.index),s=o[t];if(!s||!s.includes("var("))return;let r=getComputedStyle(e).backgroundColor,n=this.#i(r)||r;o[t]=n,this.#e[t]=n;let u=e.querySelector(".color-value");u&&(u.textContent=n),e.style.color=this.#s(n);let d=i[t]||"";e.title=`Click to copy${d?": "+d:""} (${n})`,e.setAttribute("aria-label",`${d||"Color "+(t+1)}: ${n}`)})}#i(o){let i=o.match(/rgba?\(\s*([\d.]+),?\s*([\d.]+),?\s*([\d.]+)/);if(!i)return null;let[,e,t,s]=i,r=n=>Math.round(Number(n)).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(s)}`}#a(o){if(/^#[0-9a-f]{6}$/i.test(o))return o.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(o))return("#"+o.slice(1).split("").map(t=>t+t).join("")).toLowerCase();if(typeof document>"u")return"#000000";let i=document.createElement("span");i.style.color=o,i.style.display="none",document.body.appendChild(i);let e=getComputedStyle(i).color;return i.remove(),this.#i(e)||"#000000"}#t(o){if(o.startsWith("#"))return o;let i=o.match(/oklch\(\s*([\d.]+)%?\s+([\d.]+)\s+([\d.]+)/);return i?`${i[1]}% .${i[2].replace("0.","")}`:o.length>12?o.slice(0,12)+"\u2026":o}#c(o){if(!o)return[];let i=[],e=0,t="";for(let s of o)s==="("?e++:s===")"&&e--,s===","&&e===0?(i.push(t.trim()),t=""):t+=s;return t.trim()&&i.push(t.trim()),i}#s(o){let i=o.match(/oklch\(\s*([\d.]+)%?\s/);if(i){let e=parseFloat(i[1]);return(e>1?e/100:e)>.6?"#000":"#fff"}if(o.startsWith("#")){let e=o.replace("#",""),t=parseInt(e.substring(0,2),16)/255,s=parseInt(e.substring(2,4),16)/255,r=parseInt(e.substring(4,6),16)/255;return .2126*t+.7152*s+.0722*r>.4?"#000":"#fff"}return"#000"}};g("color-palette",b);export{b as ColorPalette};
|
|
10
16
|
//# sourceMappingURL=color-palette.js.map
|