@bicharts/chart-mcp 0.6.85 → 0.6.86
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/check-chart.mjs
CHANGED
|
@@ -300,6 +300,6 @@ License: MIT
|
|
|
300
300
|
.${Ta} .${rf} text {
|
|
301
301
|
font-weight: 700 !important;
|
|
302
302
|
text-decoration: underline !important;
|
|
303
|
-
}`,(t.head||t.documentElement)?.appendChild(K)}catch{}},M=()=>{try{let K=w,ye=!!K&&K.length>0,oe=ye&&!C;r.classList?.[oe?"add":"remove"](fS);let $e=r.querySelectorAll(`.${rf}`);for(let _e of Array.from($e))_e.classList?.remove(rf);let tt=!!T&&(typeof r.contains=="function"?r.contains(T):T.isConnected!==!1);ye&&tt&&T.classList?.add(rf);let dt=new Set(K??[]),yt=r.querySelectorAll(`.${yn}[${Jr}], .${Rl}[${Jr}]`),re=wH(r);if(re!=="any-row"){let _e=Array.from(yt),Re=PH(_e.map(Ge=>({key:hk(Ge),rows:S7(Ge.getAttribute(Jr))})),ye?dt:[],re,F());if(_e.forEach((Ge,De)=>Ge.classList?.[Re.on[De]?"add":"remove"](Tp)),E(Re.keys.length?{keys:Re.keys,selection:Array.from(dt)}:null),ye)try{e.onSelectionPaint?.({rule:re,mode:Re.mode,lit:Re.on.filter(Boolean).length,marks:_e.length,selection:dt.size})}catch{}return}for(let _e of Array.from(yt)){let Re=S7(_e.getAttribute(Jr)),Ge=ye&&Re.some(De=>dt.has(De));_e.classList?.[Ge?"add":"remove"](Tp)}}catch{}},U=(K,ye,oe,$e=!1)=>{w=K,D=K.length>0&&$e,T=K.length?oe??null:null,C=K.length>0&&nk(!!oe,ok(r)),M();for(let tt of W)try{tt(K,ye)}catch{}},I=0,O=150,G=K=>{let ye=K?.detail||{};I=Date.now(),ye.clear?U([],ye.source||"chart"):ye.mark?U(S7(ye.mark.getAttribute?.(Jr)),ye.source||"chart",ye.mark,!0):Array.isArray(ye.rows)&&U(SH(ye.rows),ye.source||"chart",null,!0)},X=EH({root:r,doc:t,log:()=>{}}),Y=()=>{if(w&&w.length){let K=r[Yw];if(D&&typeof K=="function")try{K()}catch{}w&&w.length&&U([],"user")}},H=null,j=()=>{let K=H;H=null;try{K?.destroy()}catch{}},ae=`.${yn}[${Jr}], .${Rl}[${Jr}], .${oc}[${Jr}]`,Q=K=>{let ye=xH(r,K);if(dk(r),ye||Date.now()-I<O||p7(K?.target,r))return;let oe=X.findMark(K?.target,ae,K);if(oe||(oe=X.penetrateOverlayAt(K?.clientX,K?.clientY,ae)),oe||(oe=X.resolveByGeometry(K?.clientX,K?.clientY,ae)),!oe){Y();return}let $e=S7(oe.getAttribute(Jr));if(!$e.length)return;let tt=oe.classList?.contains?.(oc)?oe:null,dt=!!(K?.ctrlKey||K?.metaKey||K?.shiftKey),yt=AH(w,$e,{ctrl:!!(K?.ctrlKey||K?.metaKey),shift:!!K?.shiftKey}),re=!dt&&yt.length===0;E(vH(F(),w,hk(oe),yt,{ctrl:!!(K?.ctrlKey||K?.metaKey),shift:!!K?.shiftKey})),U(yt,"user",re?null:tt)};r.addEventListener(Kw,G);let Pe=NH(r);r.addEventListener("click",Q),r.classList?.add(Ta),v();let we=e.fit??!0,Ve=e.labelContrast??!0,Ue=()=>{let K=r[$5];if(typeof K=="function")try{K()}catch{}},ue=()=>{try{let K=Kz(r,g);if(K.collisions.length&&!p){p=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] ids shared with another chart, scoped: ${K.collisions.slice(0,5).join(", ")}`)}catch{}}e.onIdScope?.(K)}catch{}if(Ve!==!1)try{let K=Ve===!0?{}:{...Ve};if(!K.pageBg){let oe=l.backgroundColor??l.themeBg;typeof oe=="string"&&oe&&(K.pageBg=oe)}let ye=jz(r,K);e.onLabelContrast?.(ye)}catch{}VH(r,t),M();try{let K=N7(r);if(x7({markCount:K.markCount,rows:i.rows?i.rows.length:0,animated:e.animated,contractUntagged:e.contractUntagged,declaresNoRowMarks:K.declaresNoRowMarks})){if(!m){m=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] this chart rendered without error but painted no data marks, against ${i.rows.length} row(s) \u2014 so the container is empty. The usual cause is that the generated code binds a column BY NAME that is no longer in the data, sending it down its own "no data" branch. Check that the columns in your table still match the ones the chart was generated for.`)}catch{}}e.onBlankRender?.({census:K,rows:i.rows?i.rows.length:0})}}catch{}if(e.onHitBandCensus)try{e.onHitBandCensus(HH(r,t))}catch{}if(e.onColourSpreadCensus)try{e.onColourSpreadCensus(Mz(r,t))}catch{}if(e.onClippedTextCensus)try{e.onClippedTextCensus(Fz(r))}catch{}if(e.onValuePlacementCensus)try{e.onValuePlacementCensus(Vz(r,i))}catch{}if(we!==!1)try{let K=JH(r,we===!0?{}:we);e.onFit?.(K)}catch{}try{b()}catch{}try{H=BH({container:r,options:()=>l,rows:i.rows?i.rows.length:0,select:K=>U(K,"user",null,!0),clearSelection:Y})}catch{}},Ce=K=>{let ye=String(K?.message??K??"");return e.onInvalidSentinel&&Yz(ye)?(Ue(),r.innerHTML="",e.onInvalidSentinel({reason:qz(ye),message:ye}),null):Qz(K,n)},le={render(){if(c)return;let K=++y;if(Ue(),j(),r.innerHTML="",!u){if(!e.code)throw new Error("createChartHost: provide code or renderFn");u=ej(e.code,o,t,n)}if(l.geo===void 0&&e.geoKind){let oe=e.geoProvider?.(e.geoKind)??Bz(e.geoKind);if(oe)l={...l,geo:oe};else if(!h){h=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] geoKind "${e.geoKind}" was set but no geometry is available, so this chart will draw without a basemap. Either \`await loadGeo("${e.geoKind}")\` before rendering, pass a geoProvider, or import { geoForKind } from "@bicharts/chart-host/geo" and set options.geo.`)}catch{}}}l.geoUnmatched===void 0&&i.geoUnmatched&&(l={...l,geoUnmatched:i.geoUnmatched}),l.geoPoint===void 0&&i.geoPoint&&(l={...l,geoPoint:i.geoPoint}),l.geoPointDest===void 0&&i.geoPointDest&&(l={...l,geoPointDest:i.geoPointDest}),l.dateCellsAreUtcDays===void 0&&i.dateCellsAreUtcDays&&(l={...l,dateCellsAreUtcDays:!0});let ye;try{ye=u(r,{columns:i.columns,rows:i.rows},l)}catch(oe){let $e=Ce(oe);if($e)throw P(Promise.reject($e)),$e;P(Promise.resolve());return}if(!bse(ye)){ue(),P(Promise.resolve());return}P(new Promise((oe,$e)=>{let tt=setTimeout(()=>{$e(new Error(`[@bicharts/chart-host] the chart did not finish drawing within ${Math.round(mz/1e3)}s, so the host stopped waiting for it. Nothing past that point ran: no label-contrast pass, no hit-target heal, no census, no fit. A render() that returns a promise has to settle it.`))},mz),dt=yt=>{clearTimeout(tt),yt()};Promise.resolve(ye).then(()=>dt(()=>{if(c||K!==y){oe();return}ue(),oe()}),yt=>dt(()=>{if(c||K!==y){oe();return}let re=Ce(yt);re?$e(re):oe()}))}))},setOptions(K){a={...a,...K},l=s(a),le.render()},setData(K){i=K,le.render()},get options(){return l},setAnnotations(K){if(f.set(K),!c)try{b()}catch{}},get annotationReport(){return f.report},get rendered(){return A},selection:{onChange(K){return W.add(K),()=>W.delete(K)},clear(){let K=r[Yw];if(typeof K=="function")try{K()}catch{}E(null),H?.clear({publish:!1,source:"host"}),U([],"host")},highlight(K){let ye=Array.isArray(K)?K.slice():[];H&&H.rows().length&&!qw(ye,H.rows())&&H.clear({publish:!1,source:"host"}),U(ye,"host")},get current(){return w}},animation:{stop:Ue},initialMark(){return r[ek]??null},destroy(){c||(c=!0,Ue(),r.removeEventListener(Kw,G),r.removeEventListener("click",Q),Pe(),dk(r),j(),W.clear(),f.destroy(),Lp(r),r.innerHTML="")}};return le}var Sse=Object.freeze({sourceId:null,rows:Object.freeze([])});function E7(r,e){return r?e.map(t=>r[t]).filter(t=>t!==void 0):e.slice()}function Ase(r,e){let t=new Map;return r.forEach((o,n)=>{t.has(o)||t.set(o,n)}),e.map(o=>t.get(o)).filter(o=>o!==void 0)}var wse=(r,e)=>{if(r.length!==e.length)return!1;let t=r.slice().sort((n,i)=>n-i),o=e.slice().sort((n,i)=>n-i);return t.every((n,i)=>n===o[i])};function tj(r,e,t,o,n,i){if(e.sourceId===t&&e.rows.length>0){if(i){let s=Ase(i,e.rows);wse(s,r.selection.current??[])||r.selection.highlight(s)}return}if(o&&n&&n.length){r.selection.highlight(n.slice());return}r.selection.current&&r.selection.current.length&&r.selection.clear()}function Zk(r,e,t={}){let o=r,n=e,i=t.geo??null,a=t.point??null,s=t.destination??null,l=Sse,u=new Set,c=new Set,h=f=>{for(let b of Array.from(u))b(l,f)},m=(f,b)=>{let A=l,P=A.rows.length&&A.sourceId&&A.sourceId!==f?A.rows.slice():null;return b?A.sourceId===b?P:null:P},p=f=>{let b=f?f.slice():n.map((w,T)=>T),A=b.map(w=>n[w]);return{payload:Dz(o,A,i??void 0,a??void 0,s??void 0),rowMap:b}},g=(f,b={})=>p(b.respondsWith==="highlight"?null:m(f,b.filteredBy)),y={get selection(){return l},get columns(){return o},get rows(){return n},incomingFor:m,payloadFor:p,memberPayload:g,publish(f,b){l=b.length?{sourceId:f,rows:b.slice()}:{sourceId:null,rows:[]},h(b.length?"select":"clear")},clear(){l={sourceId:null,rows:[]},h("clear")},setSource(f,b,A={}){o=f,n=b,i=A.geo??null,a=A.point??null,s=A.destination??null,h("source")},onChange(f){return u.add(f),()=>{u.delete(f)}},attach(f,b,A={}){let P=A.respondsWith==="highlight",w=g(f,A).rowMap,T=W=>P||!W?"*":W.join(","),C=T(m(f,A.filteredBy)),D=b.selection.onChange((W,v)=>{if(v==="host")return;let M=E7(w,W);f&&y.publish(f,M),A.onSelect?.(M)}),F=y.onChange((W,v)=>{let M=m(f,A.filteredBy),U=T(M);if(v==="source"||U!==C){let I=p(P?null:M);w=I.rowMap,C=U,b.setData(I.payload)}tj(b,W,f,P,M,w)}),E={get rowMap(){return w},detach(){D(),F(),c.delete(E)}};return c.add(E),E},destroy(){for(let f of Array.from(c))f.detach();u.clear()}};return y}/*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */var Pse=10,vse=1e5,Nse=1e4,lo=r=>Object.freeze({...r,...r.values?{values:Object.freeze([...r.values])}:{}}),eM=Object.freeze({aggregation:lo({timing:"live-and-next-generate",default:"",values:["","sum","average","median","min","max","count","distinct"],wire:"request"}),colorScaleLow:lo({timing:"live-and-next-generate",default:"",wire:"request"}),colorScaleHigh:lo({timing:"live-and-next-generate",default:"",wire:"request"}),palette:lo({timing:"live-and-next-generate",default:"",wire:"request"}),maxMapPoints:lo({timing:"live-and-next-generate",default:m7,min:Pse,max:vse,wire:"clientHints"}),pageSize:lo({timing:"live",default:0,min:0}),valueAxisBaseline:lo({timing:"live",default:c7,values:["fit","zero","auto"]}),seasonalMarkers:lo({timing:"live",default:h7,values:["auto","always","never"]}),animAutoPlay:lo({timing:"live",default:!1}),animPlaySpeedMs:lo({timing:"live",default:e7,min:t7,max:r7}),animLoopDelaySec:lo({timing:"live",default:o7,min:n7}),animStopAtEnd:lo({timing:"live",default:!1}),animMaxIdealFrames:lo({timing:"live",default:i7,min:a7,max:s7}),animTimelineStyle:lo({timing:"live",default:"",values:["","line","boxes"]}),filtersDuringPlay:lo({timing:"live",default:!1}),flipMode:lo({timing:"live",default:l7,values:["both","all","single"]}),flipIntervalMs:lo({timing:"live",default:"",min:0,max:bH}),flipDirection:lo({timing:"live",default:u7,values:["horizontal","vertical"]}),cardBackgroundColor:lo({timing:"live",default:""}),hoverDropLines:lo({timing:"live",default:"",values:["","on","off"]}),levelOfDetail:lo({timing:"next-generate",default:"",values:["","High","Medium","Low"],wire:"clientHints"}),favorLimitTo:lo({timing:"next-generate",default:"",values:["","latest","top / greatest","bottom / smallest","most common","outliers"],wire:"clientHints"}),favorLimitCount:lo({timing:"next-generate",default:0,min:0,max:Nse,wire:"clientHints"}),favorTitle:lo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),favorDPValues:lo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),legendPlacement:lo({timing:"next-generate",default:"",values:["","outside","inside","none"],wire:"clientHints"}),industryContext:lo({timing:"next-generate",default:"",wire:"clientHints"}),suggestFontFamily:lo({timing:"next-generate",default:"",wire:"clientHints"}),visionReview:lo({timing:"after-render",default:!1}),saveThumbnails:lo({timing:"after-render",default:!1})}),Bbt=Object.freeze(Object.keys(eM).filter(r=>eM[r].timing==="live"||eM[r].timing==="live-and-next-generate"));var Dbt=Object.freeze(["TILE_TOO_NARROW","TILE_TOO_SHORT","TILE_NOT_SQUARE","TILE_NOT_TALL","TILE_TOO_SMALL","EMBED_NOTHING_FITS_TILE","EMBED_BEESWARM_TILE_TOO_SMALL"]);function os(r,e,t,o){var n,i=arguments.length,a=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(n=r[s])&&(a=(i<3?n(a):i>3?n(e,t,a):n(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a}function Ul(r,e,t){if(t||arguments.length===2)for(var o,n=0,i=e.length;n<i;n++)!o&&n in e||(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}var oj=function(r,e,t){return[r,e,t].map((function(o){return(o/=255)>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92}))},nj=function(r,e,t){return[r,e,t].map((function(o){return 255*(o<=.00304?12.92*o:1.055*Math.pow(o,1/2.4)-.055)}))},nn=function(r,e,t){return Math.min(Math.max(r,e),t)},ij=function(r,e){return Math.round((r+Number.EPSILON)*Math.pow(10,e))/Math.pow(10,e)},C7=function(r,e){return Math.floor(Math.random()*(e-r+1)-r)},aj=function(r,e,t,o){for(var n,i=[r,e,t],a="#",s=0;s<i.length;s++)a+=(n=i[s],Math.round(nn(n,0,255)).toString(16).padStart(2,"0"));return o!=null&&(a+=Math.round(nn(o,0,100)/100*255).toString(16).padStart(2,"0")),a},sj=function(r){var e=r.length,t=(r=(function(i){var a=(i=/^#/.test(i)?i.slice(1):i).length;if(![3,4,6,8].includes(a))return"000000";if(a===6||a===8)return i;if(a===3||a===4){for(var s="",l=0;l<a;l++){var u=i[l];s+=""+u+u}return s}return"000000"})(r).padEnd(8,"ff")).match(/.{2}/g);if(!t)return[0,0,0,1];var o=[0,0,0],n=!1;return t.forEach((function(i,a){a<3?o[a]=parseInt(i,16):n=100*parseInt(i,16)/255})),n===!1||e<8?o:Ul(Ul([],o,!0),[n],!1)},lj=function(r,e,t){var o;o=[r,e,t].map((function(a){return a/255})),r=o[0],e=o[1],t=o[2];var n=1-Math.max(r,e,t),i=n<1?1/(1-n):0;return[(1-r-n)*i*100,(1-e-n)*i*100,(1-t-n)*i*100,100*n]},uj=function(r,e,t,o){return o===100?[0,0,0]:(o/=100,[r,e,t].map((function(n){return(n/=100)>=1?0:255*(1-n)*(1-o)})))};function aM(r,e,t,o){var n;o===void 0&&(o="l"),n=[r,e,t].map((function(p){return p/255})),r=n[0],e=n[1],t=n[2];var i=Math.max(r,e,t),a=Math.min(r,e,t),s=(function(p,g,y,f){var b;f===void 0&&(f=!1),b=[p,g,y].map((function(C){return C/255})),p=b[0],g=b[1],y=b[2];var A=Math.max(p,g,y),P=Math.min(p,g,y),w=0;if(A!==P)if(f)w=(p-g+(p-y))/2,w/=Math.sqrt((p-g)*(p-g)+(p-y)*(g-y)),w=Math.acos(w),y>g&&(w=2*Math.PI-w),w/=2*Math.PI;else{var T=A-P;w=A===p?(g-y)/T+(g<y?6:0):A===g?(y-p)/T+2:(p-g)/T+4,w/=6}else w=NaN;return 360*w})(r,e,t,o==="i"),l=0,u=(i+a)/2,c=i-a,h=i,m=(r+e+t)/3;return o==="v"&&(l=i===0?0:c/i),i!==a&&o==="l"&&(l=u>.5?c/(2-i-a):c/(i+a)),o==="i"&&(l=m>0?1-a/m:0),l*=100,u*=100,m*=100,o==="l"?[s,l,u]:o==="v"?[s,l,h*=100]:[s,l,m]}var sM=function(r,e,t){return aM(r,e,t,"l")},Up=function(r,e,t){var o,n,i=function(a){return 6*(a=a<0?a+1:a>1?a-1:a)<1?o+(n-o)*a*6:2*a<1?n:3*a<2?o+(n-o)*(.6666666666666666-a)*6:o};return r=r%360/360,e=nn(e/100,0,1),t=nn(t/100,0,1),o=2*t-(n=t<=.5?t*(e+1):t+e-t*e),[255*i(r+1/3),255*i(r),255*i(r-1/3)]},cj=function(r,e,t){return aM(r,e,t,"v")},lM=function(r,e,t){var o,n,i=[t/=100,t*(1-(e/=100)),t*(1-(n=(r=r%360/360*360)/60-(o=Math.floor(r/60%6)))*e),t*(1-(1-n)*e)],a=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return[255*i[a[o][0]],255*i[a[o][1]],255*i[a[o][2]]]},hj=function(r,e,t){return aM(r,e,t,"i")},uM=function(r,e,t){var o,n,i,a;e/=100,t/=100,isNaN(r)&&(r=0),isNaN(e)&&(e=0);var s=function(l){return(1+e*Math.cos(2*Math.PI*l)/Math.cos(Math.PI/3-2*Math.PI*l))/3};return(r=(360+r)%360/360)<1/3?i=1-((a=(1-e)/3)+(n=s(r))):r<2/3?a=1-((n=(1-e)/3)+(i=s(r-=1/3))):n=1-((i=(1-e)/3)+(a=s(r-=2/3))),o=[n,i,a].map((function(l){return 255*nn(t*l*3,0,1)})),[n=o[0],i=o[1],a=o[2]]},mj=function(r,e,t){return[sM(r,e,t)[0],100*(Math.min(r,e,t)/255),100*(1-Math.max(r,e,t)/255)]};function cM(r,e,t){return e/=100,t/=100,Up(r,100,50).map((function(o){return 255*(o/255*(1-e-t)+e)}))}var tM={x:[.4124564,.3575761,.1804375],y:[.2126729,.7151522,.072175],z:[.0193339,.119192,.9503041]},rM={r:[3.2404542,-1.5371385,-.4985314],g:[-.969266,1.8760108,.041556],b:[.0556434,-.2040259,1.0572252]},pj=.95047,dj=1,yj=1.08883,xse=.206896552,Ese=.008856452,fj=24389/27,oM=function(r,e,t){var o=oj(r,e,t);return[100*tM.x.reduce((function(n,i,a){return n+i*o[a]}),0),100*tM.y.reduce((function(n,i,a){return n+i*o[a]}),0),100*tM.z.reduce((function(n,i,a){return n+i*o[a]}),0)]},uP=function(r,e,t){var o=[r,e,t],n=rM.r.reduce((function(s,l,u){return s+l*o[u]}),0)/100,i=rM.g.reduce((function(s,l,u){return s+l*o[u]}),0)/100,a=rM.b.reduce((function(s,l,u){return s+l*o[u]}),0)/100;return nj(n,i,a)},k7=function(r,e,t){var o;return o=[r=r/pj/100,e=e/dj/100,t=t/yj/100].map((function(n){return n>Ese?Math.pow(n,1/3):(fj*n+16)/116})),r=o[0],e=o[1],t=o[2],[Math.max(0,116*e-16),500*(r-e),200*(e-t)]},hM=function(r,e,t){var o,n=(r+16)/116,i=isNaN(e)?n:n+e/500,a=isNaN(t)?n:n-t/200;return o=[i,n,a].map((function(s){return s>xse?Math.pow(s,3):(116*s-16)/fj})),i=o[0],n=o[1],a=o[2],[i*pj*100,n*dj*100,a*yj*100]},mM=function(r,e,t){return uP.apply(void 0,hM(r,e,t))},nM=function(r,e,t){e=nn(e,-100,100),t=nn(t,-100,100);var o=Math.sqrt(e*e+t*t),n=(180*Math.atan2(t,e)/Math.PI+360)%360;return Math.round(1e4*o)===0&&(n=Number.NaN),[r,o,n]},gj=function(r,e,t){return isNaN(t)&&(t=0),t*=Math.PI/180,[r,Math.cos(t)*e,Math.sin(t)*e]},pM=function(r,e,t){return hM.apply(void 0,gj(r,e,t))},bj=function(r,e,t){var o=r+e+t,n=0,i=0;return o>0&&(n=r/o,i=e/o),[n,i,e]},Cse=Object.freeze({__proto__:null,linear2rgb:nj,rgb2linear:oj,rgb2hex:aj,hex2rgb:sj,rgb2cmyk:lj,cmyk2rgb:uj,rgb2hsl:sM,hsl2rgb:Up,rgb2hsv:cj,hsv2rgb:lM,rgb2hsi:hj,hsi2rgb:uM,rgb2hwb:mj,hwb2rgb:cM,rgb2xyz:oM,xyz2rgb:uP,xyz2lab:k7,lab2xyz:hM,rgb2lab:function(r,e,t){return k7.apply(void 0,oM(r,e,t))},lab2rgb:mM,lch2lab:gj,lab2lch:nM,xyz2lch:function(r,e,t){return nM.apply(void 0,k7(r,e,t))},lch2xyz:pM,xyY2xyz:function(r,e,t){return e===0?[0,0,0]:[r*(t/e),t,t/e*(1-r-e)]},xyz2xyY:bj});function _l(r,e){return e===void 0&&(e=!1),function(t,o,n){var i=n.value;n.value=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];if(a.length>0&&e){var l=JSON.stringify(a);r+=l}if(this.cache.has(r))return this.cache.get(r);var u=i.call.apply(i,Ul([this],a,!1));return this.cache.set(r,u),u}}}function js(r,e,t,o){return r===void 0&&(r=[0,2,2]),e===void 0&&(e=0),t===void 0&&(t=!0),o===void 0&&(o=0),function(n,i,a){var s=a.value;a.value=function(){for(var l=[],u=0;u<arguments.length;u++)l[u]=arguments[u];var c=l[o]===void 0?t:l[o],h=s.call.apply(s,Ul([this],l,!1));if(c===!1)return h;var m=typeof c=="number"?Math.round(c):0,p=typeof r=="number"?new Array(h.length).fill(r):r,g=p.map((function(y){return e===1?typeof c=="number"?m:y:y+m}));return h.map((function(y,f){return ij(y,g[f])}))}}}var Sj=function(r,e,t){var o=r instanceof fn?r:new fn(r),n=e instanceof fn?e:new fn(e),i=nn(t,0,100)/100,a=2*i-1,s=o.alpha()-n.alpha(),l=((a*s==-1?a:(a+s)/(1+a*s))+1)/2,u=1-l,c=[Math.round(nn(o.red()*l+n.red()*u,0,255)),Math.round(nn(o.green()*l+n.green()*u,0,255)),Math.round(nn(o.blue()*l+n.blue()*u,0,255))],h=o.alpha()*i+n.alpha()*(1-i);return new fn(c,h)},Wa=Math.sqrt,Gr=Math.pow,AS=Math.cos,lP=Math.abs,rj=Math.sin,kse=Math.exp,Mse=Math.atan2,Aj=Math.PI,_p=function(r){return Aj*r/180},iM=function(r,e,t){t===void 0&&(t=!0);var o=Mse(e,r);return t&&(o=(o=(o=180*o/Aj)>0?o:o+360)>360?o-360:o),o},wS=function(r,e){e===void 0&&(e=!0);var t=r.lab(!1),o=t[0],n=t[1],i=t[2];return[o,Wa(Gr(n,2)+Gr(i,2)),iM(n,i,e),n,i]},Tse=["CMC","CIE","CIE2000","CIE1994","CIE1976"],Wse="CMC",Lse="CIE2000",Ise="CIE1994",Rse="CIE1976",wj=function(r,e,t,o){t===void 0&&(t="CIE");var n=(function(c){var h=c.toUpperCase();return Tse.includes(h)&&h!=="CIE"?h:Lse})(t);if(o=o||{},n===Wse){var i=Object.assign({},{l:1,c:1},o);return(function(c,h,m,p){m===void 0&&(m=1),p===void 0&&(p=1);var g=wS(c,!0),y=g[0],f=g[1],b=g[2],A=g[3],P=g[4],w=wS(h),T=w[0],C=w[1],D=w[3],F=f-C,E=y-T,W=P-w[4],v=Wa(Gr(A-D,2)+Gr(W,2)-Gr(F,2)),M=y<16?.511:.040975*y/(1+.01765*y),U=.0638*f/(1+.0131*f)+.638,I=164<=b&&b<=345?.56+lP(.2*AS(_p(b+168))):.36+lP(.4*AS(_p(b+35))),O=Wa(Gr(f,4)/(Gr(f,4)+1900)),G=U*(O*I+1-O);return Wa(Gr(E/(m*M),2)+Gr(F/(p*U),2)+Gr(v/G,2))})(r,e,i.l,i.c)}if(n===Ise){var a={kL:1,kC:1,kH:1,cate:"graphic"},s=Object.assign({},a,o);return(function(c,h,m,p,g,y){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1),y===void 0&&(y="graphic");var f=y==="textiles"?.048:.045,b=y==="textiles"?.014:.015;m=y==="textiles"?2:m;var A=wS(c),P=A[0],w=A[1],T=A[3],C=A[4],D=wS(h),F=D[0],E=D[1],W=D[3],v=P-F,M=w-E,U=C-D[4],I=1+f*w,O=1+b*w,G=Wa(Gr(T-W,2)+Gr(U,2)-Gr(M,2));return Wa(Gr(v/(1*m),2)+Gr(M/(p*I),2)+Gr(G/(g*O),2))})(r,e,s.kL,s.kC,s.kH,s.cate)}if(n===Rse)return(function(c,h){var m=c.lab(!1),p=m[0],g=m[1],y=m[2],f=h.lab(!1),b=f[0],A=f[1],P=f[2];return Wa(Gr(p-b,2)+Gr(g-A,2)+Gr(y-P,2))})(r,e);var l={kL:1,kC:1,kH:1},u=Object.assign({},l,o);return(function(c,h,m,p,g){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1);var y=wS(c),f=y[0],b=y[1],A=y[3],P=y[4],w=wS(h),T=w[0],C=w[1],D=w[3],F=w[4],E=(f+T)/2,W=(b+C)/2,v=(1-Wa(Gr(W,7)/(Gr(W,7)+Gr(25,7))))/2,M=A*(1+v),U=D*(1+v),I=Wa(Gr(M,2)+Gr(P,2)),O=Wa(Gr(U,2)+Gr(F,2)),G=iM(M,P,!0),X=iM(U,F,!0),Y=(I+O)/2,H=lP(G-X)>180?(G+X+360)/2:(G+X)/2,j=1-.17*AS(_p(H-30))+.24*AS(_p(2*H))+.32*AS(_p(3*H+6))-.2*AS(_p(4*H-63)),ae=lP(X-G)<=180?X-G:lP(X-G)>180&&X<=G?X-G+360:X-G-360,Q=T-f,Pe=C-b,we=2*Wa(I*O)*rj(_p(ae)/2),Ve=1+.015*Gr(E-50,2)/Wa(20+Gr(E-50,2)),Ue=1+.045*Y,ue=1+.015*Y*j,Ce=30*kse(-Gr((H-275)/25,2)),le=-2*Wa(Gr(Y,7)/(Gr(Y,7)+Gr(25,7)))*rj(2*_p(Ce));return Wa(Gr(Q/(m*Ve),2)+Gr(Pe/(p*Ue),2)+Gr(we/(g*ue),2)+le*(Pe/(p*Ue))*(we/(g*ue)))})(r,e,u.kL,u.kC,u.kH)},_se=function(r,e,t){var o=Math.abs,n=Math.max,i=Math.min,a=r instanceof fn?r:new fn(r),s=e instanceof fn?e:new fn(e),l=Object.assign({},{b:125,c:500},t);return!(o(255*a.brightness()/100-255*s.brightness()/100)<=l.b)&&!(n(a.red(),s.red())-i(a.red(),s.red())+(n(a.green(),s.green())-i(a.green(),s.green()))+(n(a.blue(),s.blue())-i(a.blue(),s.blue()))<=l.c)},PS=function(r,e,t){var o,n=function(u){return nn(u,0,100)},i=function(u){return nn(u,0,255)},a={h:[0,function(u){return u%360}],s:[1,n],l:[2,n],r:[0,i],g:[1,i],b:[2,i]},s=a[e][0];if(["h","s","l"].includes(e)){var l=r.hsl();if(t===void 0)return l[s];t=a[e][1](t),l[s]=t,o=Up.apply(void 0,l)}else{if(o=r.rgb(),t===void 0)return o[s];t=a[e][1](t),o[s]=t}return new fn(o,r.alpha())},T7={},Use=new Set(["rgb","rgba","cmyk","lab","hsl","hsla","hsv","hsva","hsi","hsia","xyz","lch","hwb","hwba"]),Bse=/^([a-zA-Z]+)\(([\s\S]+)\)$/,M7=function(r){return typeof r=="string"?r.indexOf("%")===-1?M7(Number(r.trim())):(r=r.split("%")[0],(r=Number(r.trim()))||0):Math.abs(r)<1?100*r:r},Pj=function(r,e){e===void 0&&(e=new Set);var t=typeof r=="string"?r:r.join(",");if(e.has(t))throw new Error("Invalid Color");e.add(t);var o="rgb",n=[0,0,0],i=100;if(Array.isArray(r)){if(r.length<3)throw new Error("Invalid Color");for(var a=0;a<r.length;a++)if(a<3)n[a]=r[a];else{if(a!==3||r[3]===void 0)break;i=r[3]}}else{var s=!1,l=r.trim().match(Bse);if(l||(s=!0),l){var u=l[1].toLocaleLowerCase();if(o=u,Use.has(u)||(s=!0),l[2]&&!s){var c=l[2],h=c.indexOf(",")!==-1?",":" ",m=c.split(h);for(a=0;a<3;a++)m[a]!==void 0&&(["lch","lab"].includes(o)&&a===0||["hsl","hsla","hsv","hsva","hwb","hwba","hsi","hsia"].includes(o)&&a>0?n[a]=M7(m[a]):n[a]=Number(m[a].trim()));["rgba","hsla","hsva","hwba","hsia"].includes(o)?(o=o.slice(0,-1),m[3]!==void 0&&(i=M7(m[3]))):o==="cmyk"&&n.push(m[3]!==void 0?M7(m[3]):0)}}if(s){if(!/^#(([a-fA-F\d]{3}){1,2}|[a-fA-F\d]{8})$/.test(r))try{return r=(function(p,g){if(g===void 0&&(g=!1),p=p.toLowerCase(),T7[p]===void 0){if(g)throw new Error("Unknown color name: ".concat(p,")"));return p}return T7[p]})(r,!0),Pj(r,e)}catch{throw new Error("Invalid Color")}n=sj(r)}}return[o,n,i]},vj={thowParseError:!1},fn=(function(){function r(e,t,o){this.cache=new Map,this._rgb=[0,0,0],this._alpha=100;var n={thowParseError:vj.thowParseError},i=Object.assign({},n,o??{});try{var a=(function(u){var c,h={lab2rgb:mM,hsl2rgb:Up,hsv2rgb:lM,xyz2rgb:uP,hwb2rgb:cM,hsi2rgb:uM},m=Pj(u),p=m[0],g=m[1],y=m[2];if(p==="rgb")return[g,y];p==="lch"&&(p=(c=["xyz",pM(g[0],g[1],g[2])])[0],g=c[1]);var f=g[0],b=g[1],A=g[2],P=g[3];if(p==="cmyk")return[uj(f,b,A,P).map((function(T){return nn(T,0,255)})),y];var w="".concat(p,"2rgb");if(typeof h[w]=="function")return[h[w](f,b,A).map((function(T){return nn(T,0,255)})),y];throw new Error("Invalid color")})(e),s=a[0],l=a[1];this._alpha=l,this._rgb=s}catch(u){if(i.thowParseError)throw u}t!==void 0&&(this._alpha=nn(t,0,100))}return r.prototype.red=function(e){return PS(this,"r",e)},r.prototype.green=function(e){return PS(this,"g",e)},r.prototype.blue=function(e){return PS(this,"b",e)},r.prototype.alpha=function(e){return e===void 0?this._alpha:(e=nn(e,0,100),new r(this.rgb(),e))},r.prototype.fadeIn=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),nn(this._alpha+e,0,100))},r.prototype.fadeOut=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),nn(this._alpha-e,0,100))},r.prototype.opacify=function(e,t){return e===void 0&&(e=10),this.fadeIn(e,t)},r.prototype.transparentize=function(e,t){return e===void 0&&(e=10),this.fadeOut(e,t)},r.prototype.hue=function(e){return PS(this,"h",e)},r.prototype.saturation=function(e){return PS(this,"s",e)},r.prototype.lightness=function(e){return PS(this,"l",e)},r.prototype.rgb=function(e){return Ul([],this._rgb,!0)},r.prototype.rgba=function(e){return Ul(Ul([],this.rgb(!1),!0),[this._alpha],!1)},r.prototype.cmyk=function(e){return lj.apply(void 0,this._rgb)},r.prototype.hsl=function(e){return sM.apply(void 0,this._rgb)},r.prototype.hsla=function(e){return Ul(Ul([],this.hsl(!1),!0),[this._alpha],!1)},r.prototype.hsv=function(e){return cj.apply(void 0,this._rgb)},r.prototype.hsi=function(e){return hj.apply(void 0,this._rgb)},r.prototype.hwb=function(e){return mj.apply(void 0,this._rgb)},r.prototype.xyz=function(e){return oM.apply(void 0,this._rgb)},r.prototype.lab=function(e){return k7.apply(void 0,this.xyz(!1))},r.prototype.lch=function(e){return nM.apply(void 0,this.lab(!1))},r.prototype.xyY=function(e){return bj.apply(void 0,this.xyz(!1))},r.prototype.hex=function(e){e===void 0&&(e=2);var t=e===0?void 0:e===1?this._alpha:this._alpha===100?void 0:this._alpha,o="color:hex:param_".concat(e);if(this.cache.has(o))return this.cache.get(o);var n=aj.apply(void 0,Ul(Ul([],this._rgb,!1),[t],!1));return this.cache.set(o,n),n},r.prototype.lighten=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return a=nn(a+=t!==void 0&&t==="relative"?a*(e/100):e,0,100),new r(Up(n,i,a),this._alpha)},r.prototype.darken=function(e,t){return e===void 0&&(e=5),this.lighten(-e,t)},r.prototype.saturate=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return i=nn(i+=t!==void 0&&t==="relative"?i*(e/100):e,0,100),new r(Up(n,i,a),this._alpha)},r.prototype.desaturate=function(e,t){return e===void 0&&(e=5),this.saturate(-e,t)},r.prototype.spin=function(e){var t=this.hsl(!1),o=t[0],n=t[1],i=t[2];return new r(Up(o=(o+e%360+360)%360,n,i),this._alpha)},r.prototype.adjustHue=function(e){return this.spin(e)},r.prototype.complement=function(){return this.spin(180)},r.prototype.invert=function(){var e=this._rgb.map((function(t){return 255-t}));return new r([e[0],e[1],e[2]],this._alpha)},r.prototype.mix=function(e,t){return t===void 0&&(t=50),Sj(this,e,100-nn(t,0,100))},r.prototype.luma=function(){var e=this._rgb.map((function(t){return(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}));return .2126*e[0]+.7152*e[1]+.0722*e[2]},r.prototype.brightness=function(){var e=this._rgb;return(function(t,o,n){return(299*t+587*o+114*n)/1e3/255*100})(e[0],e[1],e[2])},r.prototype.deltaE=function(e,t,o){return t===void 0&&(t="CMC"),wj(this,e,t,o)},r.prototype.visibility=function(e,t){return _se(this,e,t)},os([js(0,1,!0,0),_l("color:rgb")],r.prototype,"rgb",null),os([js(0,1,!0,0)],r.prototype,"rgba",null),os([js(0,1,!0,0),_l("color:cmyk")],r.prototype,"cmyk",null),os([js(0,1,!0,0),_l("color:hsl")],r.prototype,"hsl",null),os([js(0,1,!0,0)],r.prototype,"hsla",null),os([js(0,1,!0,0),_l("color:hsv")],r.prototype,"hsv",null),os([js(0,1,!0,0),_l("color:hsi")],r.prototype,"hsi",null),os([js(0,1,!0,0),_l("color: hwb")],r.prototype,"hwb",null),os([js(2,1,!0,0),_l("color:xyz")],r.prototype,"xyz",null),os([js(2,1,!0,0),_l("color:lab")],r.prototype,"lab",null),os([js(2,1,!0,0),_l("color:lch")],r.prototype,"lch",null),os([js(2,1,!0,0),_l("color:xyY")],r.prototype,"xyY",null),os([_l("color:luma")],r.prototype,"luma",null),r})(),Dse=function(r,e,t,o){return new fn([r,e,t],o)},Ose=function(r,e,t,o){return new fn(Up(r,e,t),o)},Fse=function(r,e,t,o){return new fn(lM(r,e,t),o)},Gse=function(r,e,t,o){return new fn(uM(r,e,t),o)},Vse=function(r,e,t,o){return new fn(cM(r,e,t),o)},Hse=function(r,e,t,o){return new fn(uP(r,e,t),o)},zse=function(r,e,t,o){return new fn(mM(r,e,t),o)},jse=function(r,e,t,o){return new fn(uP.apply(void 0,pM(r,e,t)),o)};function bi(r,e,t){return new fn(r,e,t)}bi.config=function(r){Object.assign(vj,r)},bi.random=function(){var r=C7(0,255),e=C7(0,255),t=C7(0,255);return new fn([r,e,t])},bi.convertor=Cse,bi.Color=fn,bi.rgb=Dse,bi.hsl=Ose,bi.hsv=Fse,bi.hsi=Gse,bi.hwb=Vse,bi.xyz=Hse,bi.lab=zse,bi.lch=jse,bi.mix=Sj,bi.deltaE=wj,bi.utils={roundDecimal:ij,randomRange:C7},bi.useNames=function(r,e){return(function(t,o){if(o!==void 0&&typeof o=="function"){var n={};for(var i in t){var a=o(i,t[i]),s=a[0],l=a[1];n[s]=l}Object.assign(T7,n)}else Object.assign(T7,t)})(r,e),bi};var L7=[1,0,0,1,0,0],vS=(r,e)=>[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5]],W7=(r,e,t)=>[r[0]*e+r[2]*t+r[4],r[1]*e+r[3]*t+r[5]];function fM(r){if(!r||!r.trim())return L7;let e=L7,t=/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g,o="";for(let n of r.matchAll(t)){o+=n[0];let i=n[2].split(/[\s,]+/).filter(Boolean).map(Number);if(i.some(s=>!isFinite(s)))return null;let a;switch(n[1]){case"matrix":if(i.length!==6)return null;a=i;break;case"translate":a=[1,0,0,1,i[0]??0,i[1]??0];break;case"scale":a=[i[0]??1,0,0,i[1]??i[0]??1,0,0];break;case"rotate":{let s=(i[0]??0)*Math.PI/180,l=Math.cos(s),u=Math.sin(s),c=[l,u,-u,l,0,0];a=i.length>=3?vS(vS([1,0,0,1,i[1],i[2]],c),[1,0,0,1,-i[1],-i[2]]):c;break}case"skewX":a=[1,0,Math.tan((i[0]??0)*Math.PI/180),1,0,0];break;default:a=[1,Math.tan((i[0]??0)*Math.PI/180),0,1,0,0];break}e=vS(e,a)}return r.replace(t,"").replace(/[\s,]/g,"")!==""?null:o?e:L7}var nc=r=>String(r??"").toLowerCase(),cP=(r,e)=>{let t=nc(r.getAttribute("style")).replace(/\s+/g,"");for(let o of t.split(";")){let n=o.indexOf(":");if(n>0&&o.slice(0,n)===e)return o.slice(n+1)}return null},cf=(r,e)=>cP(r,e)??(r.getAttribute(e)!==null?nc(r.getAttribute(e)):null);function Xse(r){for(let e of String(r.getAttribute?.("style")??"").split(";")){let t=e.indexOf(":");if(t<0||e.slice(0,t).trim().toLowerCase()!=="font")continue;let o=/(?:^|\s)((?:\d*\.)?\d+(?:px|pt|em|%))(?:\s|\/|$)/i.exec(e.slice(t+1));return o?o[1].toLowerCase():"unreadable"}return null}var Nj=10;function NS(r){for(let e=r;e;e=e.parentElement){let t=cP(e,"font-size")??Xse(e)??(e.getAttribute?.("font-size")!=null&&e.getAttribute("font-size").trim()!==""?nc(e.getAttribute("font-size")).trim():null);if(t===null)continue;let o=/^((?:\d*\.)?\d+(?:e[+-]?\d+)?)(px|pt|em|%)?$/.exec(t);if(!o)return{px:Nj,sure:!1};let n=parseFloat(o[1]),i=o[2]??"px";if(i==="px")return{px:n,sure:!0};if(i==="pt")return{px:n*4/3,sure:!0};let a=NS(e.parentElement);return{px:(i==="em"?n:n/100)*a.px,sure:a.sure}}return{px:Nj,sure:!1}}function I7(r,e,t,o){let n=String(r.getAttribute(e)??"").trim().toLowerCase();if(!n)return{v:0,sure:!0};let i=n.split(/[\s,]+/).filter(Boolean),a=/^([-+]?(?:\d*\.)?\d+(?:e[+-]?\d+)?)(px|em|%)?$/.exec(i[0]);if(!a)return null;let s=parseFloat(a[1]),l=a[2]==="em"?s*t:a[2]==="%"?s/100*o:s;return isFinite(l)?{v:l,sure:i.length===1}:null}function Kse(r){return Array.from(r).length*.5}function Yse(r){for(let e=r.parentElement;e;e=e.parentElement)if(nc(e.localName)==="svg")return e;return null}var gM=new Set(["defs","clippath","mask","pattern","marker","symbol","lineargradient","radialgradient","filter","title","desc","metadata","style","script"]);function xj(r){let e=String(r??"").trim();return/^\+?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i.test(e)?parseFloat(e):NaN}function qse(r){if(cf(r,"overflow")==="visible")return null;let e=xj(cP(r,"width")??r.getAttribute("width")),t=xj(cP(r,"height")??r.getAttribute("height")),o=r.getAttribute("viewBox");if(o){let n=o.split(/[\s,]+/).filter(Boolean).map(Number);return n.length!==4||!n.every(isFinite)||n[2]<=0||n[3]<=0||!nc(r.getAttribute("preserveAspectRatio")).includes("none")&&isFinite(e)&&isFinite(t)&&e>0&&t>0&&Math.abs(n[2]/n[3]-e/t)>.01*(e/t)?null:{x0:n[0],y0:n[1],x1:n[0]+n[2],y1:n[1]+n[3]}}return!(e>0)||!(t>0)?null:{x0:0,y0:0,x1:e,y1:t}}function Jse(r,e){for(let t=r;t&&t!==e;t=t.parentElement){if(cf(t,"display")==="none")return!0;let o=cf(t,"visibility");if(o==="hidden"||o==="collapse")return!0;let n=cf(t,"opacity");if(n!==null&&n!==""&&parseFloat(n)===0)return!0}return!1}function $se(r,e){for(let t=r;t&&t!==e;t=t.parentElement)if(t.getAttribute("clip-path")||cP(t,"clip-path")||gM.has(nc(t.localName)))return!0;return!1}function Qse(r,e){let t=L7;for(let o=r;o&&o!==e;o=o.parentElement){let n=fM(o.getAttribute("transform"));if(!n)return null;t=vS(n,t)}return t}var ns=(r,e)=>{let t=parseFloat(r.getAttribute(e)??"");return isFinite(t)?t:0};function yM(r){let e="";for(let t=r.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue??"":t.nodeType===1&&!gM.has(nc(t.localName))&&(e+=yM(t));return e}function Bl(r,e,t){for(let o=r;o&&o!==e.parentElement;o=o.parentElement){let n=cf(o,t);if(n!==null&&n!=="")return n}return null}var dM=["x","y","dx","dy"],uf=(r,e)=>(r.getAttribute(e)??"").trim()!=="";function Zse(r,e,t){let o=NS(r),[n,i,a,s]=dM.map(c=>I7(r,c,o.px,c==="x"||c==="dx"?e:t));if(!n||!i||!a||!s)return null;let l={text:"",x:n.v+a.v,y:i.v+s.v,fontPx:o.px,el:r,extra:0,sure:o.sure&&n.sure&&i.sure&&a.sure&&s.sure},u=[l];for(let c=r.firstChild;c;c=c.nextSibling){if(c.nodeType===3||c.nodeType===4){l.text+=c.nodeValue??"";continue}if(c.nodeType!==1)continue;let h=c,m=nc(h.localName);if(gM.has(m))continue;if(m==="textpath"||h.querySelector("textPath, textpath"))return null;if(cf(h,"display")==="none")continue;let p=NS(h),g=Array.from(h.querySelectorAll("*")).some(y=>dM.some(f=>uf(y,f)));if(uf(h,"x")){let[y,f,b,A]=dM.map(P=>I7(h,P,p.px,P==="x"||P==="dx"?e:t));if(!y||!f||!b||!A)return null;l={text:yM(h),x:y.v+b.v,y:(uf(h,"y")?f.v:l.y)+A.v,fontPx:p.px,el:h,extra:0,sure:p.sure&&y.sure&&f.sure&&b.sure&&A.sure&&!g},u.push(l)}else{l.text+=yM(h);let y=I7(h,"dx",p.px,e);if(!y)return null;l.extra+=y.v,(!y.sure||uf(h,"y")||uf(h,"dy")||g||p.px!==l.fontPx||!p.sure||cf(h,"text-anchor")!==null)&&(l.sure=!1),l.fontPx=Math.max(l.fontPx,p.px)}}for(let c of u)c.text=c.text.replace(/\s+/g," ").trim();return u.filter(c=>c.text)}function bM(r){let e=[],t=r.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g)??[],o=0,n="",i=0,a=0,s=0,l=0,u=()=>parseFloat(t[o++]),c=()=>o<t.length&&!/^[a-zA-Z]$/.test(t[o]);for(;o<t.length;){if(/^[a-zA-Z]$/.test(t[o]))n=t[o++];else if(!n)return[];let h=n===n.toLowerCase(),m=n.toUpperCase();if(m==="Z"){if(i=s,a=l,c())return e;continue}let p={M:2,L:2,T:2,H:1,V:1,C:6,S:4,Q:4,A:7}[m];if(!p)return e;if(!c())continue;let g=[];for(let b=0;b<p;b++)g.push(u());if(g.some(b=>!isFinite(b)))return e;let y=h?i:0,f=h?a:0;if(m==="H")i=y+g[0],e.push([i,a]);else if(m==="V")a=f+g[0],e.push([i,a]);else if(m==="A")i=y+g[5],a=f+g[6],e.push([i,a]);else{for(let b=0;b<p;b+=2)e.push([y+g[b],f+g[b+1]]);i=y+g[p-2],a=f+g[p-1]}m==="M"&&(s=i,l=a,n=h?"l":"L")}return e}function Ej(r){let e=1/0,t=-1/0,o=1/0,n=-1/0;for(let[i,a]of r)e=Math.min(e,i),t=Math.max(t,i),o=Math.min(o,a),n=Math.max(n,a);return{X0:e,X1:t,Y0:o,Y1:n}}var Cj=/condensed|narrow|compressed|impact|agency/,ele=/(?:^|[{;\s])(font-size|font|font-family|font-stretch|text-anchor|letter-spacing|word-spacing|direction|writing-mode|transform|text-transform)\s*:\s*([^;}]*)/gi;function tle(r){for(let e of r.replace(/\/\*[\s\S]*?\*\//g,"").matchAll(ele)){let t=e[1].toLowerCase(),o=e[2].trim().toLowerCase().replace(/\s*!important$/,"");if(!(t!=="font-size"&&t!=="font"&&/^(normal|inherit|initial|unset|none|0|0px|ltr|horizontal-tb)$/.test(o))&&!(t==="font-family"&&!Cj.test(o))&&!(t==="text-transform"&&o==="uppercase"))return!0}return!1}var rle=new Set(["rect","image","foreignobject","circle","ellipse","line","text","path","polygon","polyline"]),Xs=.5,ole=5;function kj(r){let e={frames:0,unmeasured:0,outside:0,crossing:0,textLikely:0,textEvenNarrow:0,samples:{outside:[],crossing:[],textLikely:[],textEvenNarrow:[]}},t=(a,s)=>{a.length<ole&&a.push(s)},o=Math.round,n=r.ownerDocument??r,i=Array.from(n.querySelectorAll("style")).concat(Array.from(r.querySelectorAll("style"))).some(a=>tle(a.textContent??""));for(let a of Array.from(r.querySelectorAll("svg"))){let s=qse(a),l=Array.from(a.querySelectorAll("*")).filter(m=>rle.has(nc(m.localName))&&Yse(m)===a);if(!s){l.length&&e.unmeasured++;continue}e.frames++;let u=(m,p)=>p==="left"||p==="right"?`x ${o(m.X0)}..${o(m.X1)}, frame ${o(s.x0)}..${o(s.x1)}`:`y ${o(m.Y0)}..${o(m.Y1)}, frame ${o(s.y0)}..${o(s.y1)}`,c=m=>m.X0>s.x1+Xs?"right":m.X1<s.x0-Xs?"left":m.Y0>s.y1+Xs?"bottom":m.Y1<s.y0-Xs?"top":"",h=m=>m.X1>s.x1+Xs?"right":m.X0<s.x0-Xs?"left":m.Y1>s.y1+Xs?"bottom":m.Y0<s.y0-Xs?"top":"";for(let m of l){if(Jse(m,a)||$se(m,a))continue;let p=Qse(m,a);if(!p)continue;let g=nc(m.localName);if(g==="text"){if(Math.abs(p[1])>1e-9||Math.abs(p[2])>1e-9)continue;let P=Bl(m,a,"writing-mode")??"";if(P.startsWith("tb")||P.startsWith("vertical")||P.startsWith("sideways"))continue;let w=Bl(m,a,"fill"),T=Bl(m,a,"stroke");if(w==="none"&&(T===null||T==="none"))continue;let C=Zse(m,s.x1-s.x0,s.y1-s.y0);if(!C)continue;let D=I7(m,"textLength",NS(m).px,s.x1-s.x0),F=C.length===1&&uf(m,"textLength")&&D?.sure&&D.v>0?D.v:null,E=null,W=null,v=null;for(let M of C){let U=M.fontPx,I=M.text;if(!(U>0))continue;let O=M.y,G=Bl(M.el,a,"dominant-baseline")??Bl(M.el,a,"alignment-baseline")??"";G==="middle"||G==="central"?O+=.35*U:(G==="hanging"||G==="text-before-edge")&&(O+=.8*U);let X=Bl(M.el,a,"text-anchor")??"start",Y=Bl(M.el,a,"direction")==="rtl",H=Bl(M.el,a,"letter-spacing"),j=H===null||H==="normal"?0:/^(?:\d*\.)?\d+(?:px)?$/.test(H)?parseFloat(H):NaN,ae=Array.from(I).length,Q=isFinite(j)?j*ae:0,Pe=`${Bl(M.el,a,"font-family")??""} ${Bl(M.el,a,"font-stretch")??""}`,we=M.sure&&!i&&!Y&&isFinite(j)&&Bl(M.el,a,"word-spacing")===null&&!Cj.test(Pe)&&(F!==null||!uf(m,"textLength")),Ve=(tt,dt,yt)=>{let re=X==="middle"?M.x-tt/2:X==="end"?M.x-tt:M.x;return Ej([W7(p,re,O-dt*U),W7(p,re+tt,O+yt*U)])},Ue=Ve(F??ae*U*.6+M.extra+Q,.75,.2),ue=`text "${I.length>30?I.slice(0,30)+"...":I}"`,Ce=W7(p,M.x,O)[0],le=Ue.Y0>s.y1+Xs?"bottom":Ue.Y1<s.y0-Xs?"top":Y?"":X==="start"&&Ce>s.x1+Xs?"right":X==="end"&&Ce<s.x0-Xs?"left":"";if(le){E??={what:ue,edge:le,where:u(Ue,le)};continue}let K=h(Ue);if(!K||(W??={what:ue,edge:K,where:u(Ue,K)},!we||v))continue;let ye=Ve(F??Kse(I)*U+M.extra+Q,.5,0),oe=h(ye);if(!oe)continue;let $e=oe==="right"?ye.X1-s.x1:oe==="left"?s.x0-ye.X0:oe==="bottom"?ye.Y1-s.y1:s.y0-ye.Y0;v={what:ue,edge:oe,where:u(ye,oe),pastPx:Math.round($e)}}if(E){e.outside++,t(e.samples.outside,E);continue}W&&(e.textLikely++,t(e.samples.textLikely,W)),v&&(e.textEvenNarrow++,t(e.samples.textEvenNarrow,v));continue}let y;if(g==="circle"||g==="ellipse"){let P=g==="circle"?ns(m,"r"):ns(m,"rx"),w=g==="circle"?P:ns(m,"ry");if(!(P>0&&w>0))continue;let T=ns(m,"cx"),C=ns(m,"cy");y=[[T-P,C-w],[T+P,C+w],[T+P,C-w],[T-P,C+w]]}else if(g==="line")y=[[ns(m,"x1"),ns(m,"y1")],[ns(m,"x2"),ns(m,"y2")]];else if(g==="path"||g==="polygon"||g==="polyline"){if(g==="path")y=bM(m.getAttribute("d")??"");else{let P=(m.getAttribute("points")??"").split(/[\s,]+/).filter(Boolean).map(Number);y=[];for(let w=0;w+1<P.length;w+=2)y.push([P[w],P[w+1]])}if(!y.length||y.some(P=>!isFinite(P[0])||!isFinite(P[1])))continue}else{let P=ns(m,"width"),w=ns(m,"height");if(!(P>0&&w>0))continue;let T=ns(m,"x"),C=ns(m,"y");y=[[T,C],[T+P,C+w],[T+P,C],[T,C+w]]}let f=Ej(y.map(P=>W7(p,P[0],P[1]))),b=c(f);if(b){e.outside++,t(e.samples.outside,{what:g,edge:b,where:u(f,b)});continue}if(g==="path")continue;let A=h(f);A&&(e.crossing++,t(e.samples.crossing,{what:g,edge:A,where:u(f,A)}))}}return e}var lle=new Set(["d3-sankey","d3-hexbin","d3-voronoi-treemap"]),ule=new Set(["title","desc","metadata","style","script"]);function Ij(r){let e="";for(let t=r?.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue||"":t.nodeType===1&&!ule.has(String(t.localName||"").toLowerCase())&&(e+=Ij(t));return e}function SM(r){return NS(r).px}function cle(r,e){let t=o=>{let n=String(r.getAttribute?.(o)??"").trim().split(/[\s,]+/)[0]??"",i=parseFloat(n);return isFinite(i)?/em$/i.test(n)?i*e:i:0};return{x:t("x")+t("dx"),y:t("y")+t("dy")}}function hle(r){for(let e=r;e&&e.getAttribute;e=e.parentElement){let o=(/(?:^|;)\s*text-anchor\s*:\s*([a-z]+)/i.exec(String(e.getAttribute("style")||""))?.[1]??e.getAttribute("text-anchor")??"").trim().toLowerCase();if(o)return o}return"start"}function mle(r){let e=new Set(["SVGElement","SVGGraphicsElement","SVGGeometryElement","SVGTextContentElement"].map(h=>r[h]?.prototype).filter(Boolean)),t=r.Element?.prototype;for(let h of["svg","g","text","tspan","textPath","path","rect","circle","ellipse","line","polyline","polygon","image","use"])try{for(let m=Object.getPrototypeOf(r.document.createElementNS("http://www.w3.org/2000/svg",h));m&&m!==t;m=Object.getPrototypeOf(m))e.add(m)}catch{}let o=h=>["text","tspan","textpath"].includes(String(h.tagName||"").toLowerCase()),n=h=>o(h)?Ij(h).trim().length*SM(h)*.6:0,i=h=>{let m=String(h.tagName||"").toLowerCase();if(m==="path")return bM(h.getAttribute("d")||"");if(m==="line")return[[+h.getAttribute("x1")||0,+h.getAttribute("y1")||0],[+h.getAttribute("x2")||0,+h.getAttribute("y2")||0]];let p=String(h.getAttribute("points")||"").split(/[\s,]+/).filter(Boolean).map(Number),g=[];for(let y=0;y+1<p.length;y+=2)g.push([p[y],p[y+1]]);return g},a=h=>{let m=0;for(let p=1;p<h.length;p++)m+=Math.hypot(h[p][0]-h[p-1][0],h[p][1]-h[p-1][1]);return m},s=function(){if(o(this)){let g=SM(this),y=Math.max(1,n(this)),f=cle(this,g),b=hle(this);return{x:b==="middle"?f.x-y/2:b==="end"?f.x-y:f.x,y:f.y-g*.8,width:y,height:Math.max(1,g)}}let h=parseFloat(this.getAttribute?.("width")||"")||0,m=parseFloat(this.getAttribute?.("height")||"")||0;if(h>0||m>0)return{x:0,y:0,width:h||1,height:m||1};let p=parseFloat(this.getAttribute?.("r")||"")||0;return p>0?{x:-p,y:-p,width:2*p,height:2*p}:{x:0,y:0,width:1,height:1}},l=function(){let h=s.call(this);if(String(this.tagName||"").toLowerCase()!=="svg"){let m=[1,0,0,1,0,0];for(let p=this;p&&m&&String(p.tagName||"").toLowerCase()!=="svg";p=p.parentElement){let g=fM(p.getAttribute?.("transform"));m=g?vS(g,m):null}if(m){let p=[[h.x,h.y],[h.x+h.width,h.y],[h.x,h.y+h.height],[h.x+h.width,h.y+h.height]].map(([A,P])=>[m[0]*A+m[2]*P+m[4],m[1]*A+m[3]*P+m[5]]),g=p.map(A=>A[0]),y=p.map(A=>A[1]),f=Math.min(...g),b=Math.min(...y);h={x:f,y:b,width:Math.max(...g)-f,height:Math.max(...y)-b}}}return{...h,top:h.y,left:h.x,right:h.x+h.width,bottom:h.y+h.height,toJSON(){return h}}},u=(h,m,p)=>Object.defineProperty(h,m,{configurable:!0,writable:!0,value:p});for(let h of e)u(h,"getBBox",s),u(h,"getBoundingClientRect",l),u(h,"getComputedTextLength",function(){return n(this)}),u(h,"getSubStringLength",function(m,p){return o(this)?Math.max(0,(p||0)*SM(this)*.6):0}),u(h,"getTotalLength",function(){return a(i(this))}),u(h,"getPointAtLength",function(m){let p=i(this);if(!p.length)return{x:0,y:0};let g=Math.max(0,+m||0);for(let f=1;f<p.length;f++){let b=Math.hypot(p[f][0]-p[f-1][0],p[f][1]-p[f-1][1]);if(g<=b&&b>0){let A=g/b;return{x:p[f-1][0]+A*(p[f][0]-p[f-1][0]),y:p[f-1][1]+A*(p[f][1]-p[f-1][1])}}g-=b}let y=p[p.length-1];return{x:y[0],y:y[1]}});let c=r.HTMLCanvasElement?.prototype;if(c){let h=new WeakMap,m=g=>{let y=String(g||"").match(/([\d.]+)\s*(px|pt|em|rem)\b/i);if(!y)return 10;let f=parseFloat(y[1]);return y[2].toLowerCase()==="pt"?f*4/3:/r?em/i.test(y[2])?f*16:f},p=()=>{};Object.defineProperty(c,"getContext",{configurable:!0,writable:!0,value:function(g){if(String(g||"").toLowerCase()!=="2d")return null;let y=h.get(this);if(!y){let f=this;y=new Proxy({canvas:f,font:"10px sans-serif",measureText(b){let A=m(this.font),P=String(b??"").length*A*.6;return{width:P,actualBoundingBoxLeft:0,actualBoundingBoxRight:P,actualBoundingBoxAscent:A*.8,actualBoundingBoxDescent:A*.2,fontBoundingBoxAscent:A*.8,fontBoundingBoxDescent:A*.2}},getImageData:(b,A,P,w)=>({width:P,height:w,data:new Uint8ClampedArray(Math.max(1,P*w*4))}),createLinearGradient:()=>({addColorStop:p}),createRadialGradient:()=>({addColorStop:p}),getLineDash:()=>[],isPointInPath:()=>!1,isPointInStroke:()=>!1},{get:(b,A)=>A in b?b[A]:typeof A=="string"&&/^[a-z]/.test(A)?p:void 0}),h.set(this,y)}return y}})}}function ple(r){let e=["window","document","navigator","Event","CustomEvent","MouseEvent","KeyboardEvent","PointerEvent","Element","HTMLElement","SVGElement","Node","getComputedStyle","requestAnimationFrame","cancelAnimationFrame","DOMParser","XMLSerializer","MutationObserver","Image","ResizeObserver"],t=e.map(n=>[n,Object.getOwnPropertyDescriptor(globalThis,n)]),o=n=>n==="window"?r:n==="ResizeObserver"?r.ResizeObserver??class{observe(){}unobserve(){}disconnect(){}}:typeof r[n]=="function"&&/^[a-z]/.test(n)?r[n].bind(r):r[n];for(let n of e){let i=o(n);if(i!==void 0)try{Object.defineProperty(globalThis,n,{configurable:!0,writable:!0,value:i})}catch{}}return()=>{for(let[n,i]of t)try{i?Object.defineProperty(globalThis,n,i):delete globalThis[n]}catch{}}}function Wj(r,e){let t=e.split(/\r?\n/);for(let o of String(r?.stack??"").split(`
|
|
303
|
+
}`,(t.head||t.documentElement)?.appendChild(K)}catch{}},M=()=>{try{let K=w,ye=!!K&&K.length>0,oe=ye&&!C;r.classList?.[oe?"add":"remove"](fS);let $e=r.querySelectorAll(`.${rf}`);for(let _e of Array.from($e))_e.classList?.remove(rf);let tt=!!T&&(typeof r.contains=="function"?r.contains(T):T.isConnected!==!1);ye&&tt&&T.classList?.add(rf);let dt=new Set(K??[]),yt=r.querySelectorAll(`.${yn}[${Jr}], .${Rl}[${Jr}]`),re=wH(r);if(re!=="any-row"){let _e=Array.from(yt),Re=PH(_e.map(Ge=>({key:hk(Ge),rows:S7(Ge.getAttribute(Jr))})),ye?dt:[],re,F());if(_e.forEach((Ge,De)=>Ge.classList?.[Re.on[De]?"add":"remove"](Tp)),E(Re.keys.length?{keys:Re.keys,selection:Array.from(dt)}:null),ye)try{e.onSelectionPaint?.({rule:re,mode:Re.mode,lit:Re.on.filter(Boolean).length,marks:_e.length,selection:dt.size})}catch{}return}for(let _e of Array.from(yt)){let Re=S7(_e.getAttribute(Jr)),Ge=ye&&Re.some(De=>dt.has(De));_e.classList?.[Ge?"add":"remove"](Tp)}}catch{}},U=(K,ye,oe,$e=!1)=>{w=K,D=K.length>0&&$e,T=K.length?oe??null:null,C=K.length>0&&nk(!!oe,ok(r)),M();for(let tt of W)try{tt(K,ye)}catch{}},I=0,O=150,G=K=>{let ye=K?.detail||{};I=Date.now(),ye.clear?U([],ye.source||"chart"):ye.mark?U(S7(ye.mark.getAttribute?.(Jr)),ye.source||"chart",ye.mark,!0):Array.isArray(ye.rows)&&U(SH(ye.rows),ye.source||"chart",null,!0)},X=EH({root:r,doc:t,log:()=>{}}),Y=()=>{if(w&&w.length){let K=r[Yw];if(D&&typeof K=="function")try{K()}catch{}w&&w.length&&U([],"user")}},H=null,j=()=>{let K=H;H=null;try{K?.destroy()}catch{}},ae=`.${yn}[${Jr}], .${Rl}[${Jr}], .${oc}[${Jr}]`,Q=K=>{let ye=xH(r,K);if(dk(r),ye||Date.now()-I<O||p7(K?.target,r))return;let oe=X.findMark(K?.target,ae,K);if(oe||(oe=X.penetrateOverlayAt(K?.clientX,K?.clientY,ae)),oe||(oe=X.resolveByGeometry(K?.clientX,K?.clientY,ae)),!oe){Y();return}let $e=S7(oe.getAttribute(Jr));if(!$e.length)return;let tt=oe.classList?.contains?.(oc)?oe:null,dt=!!(K?.ctrlKey||K?.metaKey||K?.shiftKey),yt=AH(w,$e,{ctrl:!!(K?.ctrlKey||K?.metaKey),shift:!!K?.shiftKey}),re=!dt&&yt.length===0;E(vH(F(),w,hk(oe),yt,{ctrl:!!(K?.ctrlKey||K?.metaKey),shift:!!K?.shiftKey})),U(yt,"user",re?null:tt)};r.addEventListener(Kw,G);let Pe=NH(r);r.addEventListener("click",Q),r.classList?.add(Ta),v();let we=e.fit??!0,Ve=e.labelContrast??!0,Ue=()=>{let K=r[$5];if(typeof K=="function")try{K()}catch{}},ue=()=>{try{let K=Kz(r,g);if(K.collisions.length&&!p){p=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] ids shared with another chart, scoped: ${K.collisions.slice(0,5).join(", ")}`)}catch{}}e.onIdScope?.(K)}catch{}if(Ve!==!1)try{let K=Ve===!0?{}:{...Ve};if(!K.pageBg){let oe=l.backgroundColor??l.themeBg;typeof oe=="string"&&oe&&(K.pageBg=oe)}let ye=jz(r,K);e.onLabelContrast?.(ye)}catch{}if(e.layoutPass)try{e.layoutPass(r)}catch{}VH(r,t),M();try{let K=N7(r);if(x7({markCount:K.markCount,rows:i.rows?i.rows.length:0,animated:e.animated,contractUntagged:e.contractUntagged,declaresNoRowMarks:K.declaresNoRowMarks})){if(!m){m=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] this chart rendered without error but painted no data marks, against ${i.rows.length} row(s) \u2014 so the container is empty. The usual cause is that the generated code binds a column BY NAME that is no longer in the data, sending it down its own "no data" branch. Check that the columns in your table still match the ones the chart was generated for.`)}catch{}}e.onBlankRender?.({census:K,rows:i.rows?i.rows.length:0})}}catch{}if(e.onHitBandCensus)try{e.onHitBandCensus(HH(r,t))}catch{}if(e.onColourSpreadCensus)try{e.onColourSpreadCensus(Mz(r,t))}catch{}if(e.onClippedTextCensus)try{e.onClippedTextCensus(Fz(r))}catch{}if(e.onValuePlacementCensus)try{e.onValuePlacementCensus(Vz(r,i))}catch{}if(we!==!1)try{let K=JH(r,we===!0?{}:we);e.onFit?.(K)}catch{}try{b()}catch{}try{H=BH({container:r,options:()=>l,rows:i.rows?i.rows.length:0,select:K=>U(K,"user",null,!0),clearSelection:Y})}catch{}},Ce=K=>{let ye=String(K?.message??K??"");return e.onInvalidSentinel&&Yz(ye)?(Ue(),r.innerHTML="",e.onInvalidSentinel({reason:qz(ye),message:ye}),null):Qz(K,n)},le={render(){if(c)return;let K=++y;if(Ue(),j(),r.innerHTML="",!u){if(!e.code)throw new Error("createChartHost: provide code or renderFn");u=ej(e.code,o,t,n)}if(l.geo===void 0&&e.geoKind){let oe=e.geoProvider?.(e.geoKind)??Bz(e.geoKind);if(oe)l={...l,geo:oe};else if(!h){h=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] geoKind "${e.geoKind}" was set but no geometry is available, so this chart will draw without a basemap. Either \`await loadGeo("${e.geoKind}")\` before rendering, pass a geoProvider, or import { geoForKind } from "@bicharts/chart-host/geo" and set options.geo.`)}catch{}}}l.geoUnmatched===void 0&&i.geoUnmatched&&(l={...l,geoUnmatched:i.geoUnmatched}),l.geoPoint===void 0&&i.geoPoint&&(l={...l,geoPoint:i.geoPoint}),l.geoPointDest===void 0&&i.geoPointDest&&(l={...l,geoPointDest:i.geoPointDest}),l.dateCellsAreUtcDays===void 0&&i.dateCellsAreUtcDays&&(l={...l,dateCellsAreUtcDays:!0});let ye;try{ye=u(r,{columns:i.columns,rows:i.rows},l)}catch(oe){let $e=Ce(oe);if($e)throw P(Promise.reject($e)),$e;P(Promise.resolve());return}if(!bse(ye)){ue(),P(Promise.resolve());return}P(new Promise((oe,$e)=>{let tt=setTimeout(()=>{$e(new Error(`[@bicharts/chart-host] the chart did not finish drawing within ${Math.round(mz/1e3)}s, so the host stopped waiting for it. Nothing past that point ran: no label-contrast pass, no hit-target heal, no census, no fit. A render() that returns a promise has to settle it.`))},mz),dt=yt=>{clearTimeout(tt),yt()};Promise.resolve(ye).then(()=>dt(()=>{if(c||K!==y){oe();return}ue(),oe()}),yt=>dt(()=>{if(c||K!==y){oe();return}let re=Ce(yt);re?$e(re):oe()}))}))},setOptions(K){a={...a,...K},l=s(a),le.render()},setData(K){i=K,le.render()},get options(){return l},setAnnotations(K){if(f.set(K),!c)try{b()}catch{}},get annotationReport(){return f.report},get rendered(){return A},selection:{onChange(K){return W.add(K),()=>W.delete(K)},clear(){let K=r[Yw];if(typeof K=="function")try{K()}catch{}E(null),H?.clear({publish:!1,source:"host"}),U([],"host")},highlight(K){let ye=Array.isArray(K)?K.slice():[];H&&H.rows().length&&!qw(ye,H.rows())&&H.clear({publish:!1,source:"host"}),U(ye,"host")},get current(){return w}},animation:{stop:Ue},initialMark(){return r[ek]??null},destroy(){c||(c=!0,Ue(),r.removeEventListener(Kw,G),r.removeEventListener("click",Q),Pe(),dk(r),j(),W.clear(),f.destroy(),Lp(r),r.innerHTML="")}};return le}var Sse=Object.freeze({sourceId:null,rows:Object.freeze([])});function E7(r,e){return r?e.map(t=>r[t]).filter(t=>t!==void 0):e.slice()}function Ase(r,e){let t=new Map;return r.forEach((o,n)=>{t.has(o)||t.set(o,n)}),e.map(o=>t.get(o)).filter(o=>o!==void 0)}var wse=(r,e)=>{if(r.length!==e.length)return!1;let t=r.slice().sort((n,i)=>n-i),o=e.slice().sort((n,i)=>n-i);return t.every((n,i)=>n===o[i])};function tj(r,e,t,o,n,i){if(e.sourceId===t&&e.rows.length>0){if(i){let s=Ase(i,e.rows);wse(s,r.selection.current??[])||r.selection.highlight(s)}return}if(o&&n&&n.length){r.selection.highlight(n.slice());return}r.selection.current&&r.selection.current.length&&r.selection.clear()}function Zk(r,e,t={}){let o=r,n=e,i=t.geo??null,a=t.point??null,s=t.destination??null,l=Sse,u=new Set,c=new Set,h=f=>{for(let b of Array.from(u))b(l,f)},m=(f,b)=>{let A=l,P=A.rows.length&&A.sourceId&&A.sourceId!==f?A.rows.slice():null;return b?A.sourceId===b?P:null:P},p=f=>{let b=f?f.slice():n.map((w,T)=>T),A=b.map(w=>n[w]);return{payload:Dz(o,A,i??void 0,a??void 0,s??void 0),rowMap:b}},g=(f,b={})=>p(b.respondsWith==="highlight"?null:m(f,b.filteredBy)),y={get selection(){return l},get columns(){return o},get rows(){return n},incomingFor:m,payloadFor:p,memberPayload:g,publish(f,b){l=b.length?{sourceId:f,rows:b.slice()}:{sourceId:null,rows:[]},h(b.length?"select":"clear")},clear(){l={sourceId:null,rows:[]},h("clear")},setSource(f,b,A={}){o=f,n=b,i=A.geo??null,a=A.point??null,s=A.destination??null,h("source")},onChange(f){return u.add(f),()=>{u.delete(f)}},attach(f,b,A={}){let P=A.respondsWith==="highlight",w=g(f,A).rowMap,T=W=>P||!W?"*":W.join(","),C=T(m(f,A.filteredBy)),D=b.selection.onChange((W,v)=>{if(v==="host")return;let M=E7(w,W);f&&y.publish(f,M),A.onSelect?.(M)}),F=y.onChange((W,v)=>{let M=m(f,A.filteredBy),U=T(M);if(v==="source"||U!==C){let I=p(P?null:M);w=I.rowMap,C=U,b.setData(I.payload)}tj(b,W,f,P,M,w)}),E={get rowMap(){return w},detach(){D(),F(),c.delete(E)}};return c.add(E),E},destroy(){for(let f of Array.from(c))f.detach();u.clear()}};return y}/*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */var Pse=10,vse=1e5,Nse=1e4,lo=r=>Object.freeze({...r,...r.values?{values:Object.freeze([...r.values])}:{}}),eM=Object.freeze({aggregation:lo({timing:"live-and-next-generate",default:"",values:["","sum","average","median","min","max","count","distinct"],wire:"request"}),colorScaleLow:lo({timing:"live-and-next-generate",default:"",wire:"request"}),colorScaleHigh:lo({timing:"live-and-next-generate",default:"",wire:"request"}),palette:lo({timing:"live-and-next-generate",default:"",wire:"request"}),maxMapPoints:lo({timing:"live-and-next-generate",default:m7,min:Pse,max:vse,wire:"clientHints"}),pageSize:lo({timing:"live",default:0,min:0}),valueAxisBaseline:lo({timing:"live",default:c7,values:["fit","zero","auto"]}),seasonalMarkers:lo({timing:"live",default:h7,values:["auto","always","never"]}),animAutoPlay:lo({timing:"live",default:!1}),animPlaySpeedMs:lo({timing:"live",default:e7,min:t7,max:r7}),animLoopDelaySec:lo({timing:"live",default:o7,min:n7}),animStopAtEnd:lo({timing:"live",default:!1}),animMaxIdealFrames:lo({timing:"live",default:i7,min:a7,max:s7}),animTimelineStyle:lo({timing:"live",default:"",values:["","line","boxes"]}),filtersDuringPlay:lo({timing:"live",default:!1}),flipMode:lo({timing:"live",default:l7,values:["both","all","single"]}),flipIntervalMs:lo({timing:"live",default:"",min:0,max:bH}),flipDirection:lo({timing:"live",default:u7,values:["horizontal","vertical"]}),cardBackgroundColor:lo({timing:"live",default:""}),hoverDropLines:lo({timing:"live",default:"",values:["","on","off"]}),levelOfDetail:lo({timing:"next-generate",default:"",values:["","High","Medium","Low"],wire:"clientHints"}),favorLimitTo:lo({timing:"next-generate",default:"",values:["","latest","top / greatest","bottom / smallest","most common","outliers"],wire:"clientHints"}),favorLimitCount:lo({timing:"next-generate",default:0,min:0,max:Nse,wire:"clientHints"}),favorTitle:lo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),favorDPValues:lo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),legendPlacement:lo({timing:"next-generate",default:"",values:["","outside","inside","none"],wire:"clientHints"}),industryContext:lo({timing:"next-generate",default:"",wire:"clientHints"}),suggestFontFamily:lo({timing:"next-generate",default:"",wire:"clientHints"}),visionReview:lo({timing:"after-render",default:!1}),saveThumbnails:lo({timing:"after-render",default:!1})}),Bbt=Object.freeze(Object.keys(eM).filter(r=>eM[r].timing==="live"||eM[r].timing==="live-and-next-generate"));var Dbt=Object.freeze(["TILE_TOO_NARROW","TILE_TOO_SHORT","TILE_NOT_SQUARE","TILE_NOT_TALL","TILE_TOO_SMALL","EMBED_NOTHING_FITS_TILE","EMBED_BEESWARM_TILE_TOO_SMALL"]);function os(r,e,t,o){var n,i=arguments.length,a=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(n=r[s])&&(a=(i<3?n(a):i>3?n(e,t,a):n(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a}function Ul(r,e,t){if(t||arguments.length===2)for(var o,n=0,i=e.length;n<i;n++)!o&&n in e||(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}var oj=function(r,e,t){return[r,e,t].map((function(o){return(o/=255)>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92}))},nj=function(r,e,t){return[r,e,t].map((function(o){return 255*(o<=.00304?12.92*o:1.055*Math.pow(o,1/2.4)-.055)}))},nn=function(r,e,t){return Math.min(Math.max(r,e),t)},ij=function(r,e){return Math.round((r+Number.EPSILON)*Math.pow(10,e))/Math.pow(10,e)},C7=function(r,e){return Math.floor(Math.random()*(e-r+1)-r)},aj=function(r,e,t,o){for(var n,i=[r,e,t],a="#",s=0;s<i.length;s++)a+=(n=i[s],Math.round(nn(n,0,255)).toString(16).padStart(2,"0"));return o!=null&&(a+=Math.round(nn(o,0,100)/100*255).toString(16).padStart(2,"0")),a},sj=function(r){var e=r.length,t=(r=(function(i){var a=(i=/^#/.test(i)?i.slice(1):i).length;if(![3,4,6,8].includes(a))return"000000";if(a===6||a===8)return i;if(a===3||a===4){for(var s="",l=0;l<a;l++){var u=i[l];s+=""+u+u}return s}return"000000"})(r).padEnd(8,"ff")).match(/.{2}/g);if(!t)return[0,0,0,1];var o=[0,0,0],n=!1;return t.forEach((function(i,a){a<3?o[a]=parseInt(i,16):n=100*parseInt(i,16)/255})),n===!1||e<8?o:Ul(Ul([],o,!0),[n],!1)},lj=function(r,e,t){var o;o=[r,e,t].map((function(a){return a/255})),r=o[0],e=o[1],t=o[2];var n=1-Math.max(r,e,t),i=n<1?1/(1-n):0;return[(1-r-n)*i*100,(1-e-n)*i*100,(1-t-n)*i*100,100*n]},uj=function(r,e,t,o){return o===100?[0,0,0]:(o/=100,[r,e,t].map((function(n){return(n/=100)>=1?0:255*(1-n)*(1-o)})))};function aM(r,e,t,o){var n;o===void 0&&(o="l"),n=[r,e,t].map((function(p){return p/255})),r=n[0],e=n[1],t=n[2];var i=Math.max(r,e,t),a=Math.min(r,e,t),s=(function(p,g,y,f){var b;f===void 0&&(f=!1),b=[p,g,y].map((function(C){return C/255})),p=b[0],g=b[1],y=b[2];var A=Math.max(p,g,y),P=Math.min(p,g,y),w=0;if(A!==P)if(f)w=(p-g+(p-y))/2,w/=Math.sqrt((p-g)*(p-g)+(p-y)*(g-y)),w=Math.acos(w),y>g&&(w=2*Math.PI-w),w/=2*Math.PI;else{var T=A-P;w=A===p?(g-y)/T+(g<y?6:0):A===g?(y-p)/T+2:(p-g)/T+4,w/=6}else w=NaN;return 360*w})(r,e,t,o==="i"),l=0,u=(i+a)/2,c=i-a,h=i,m=(r+e+t)/3;return o==="v"&&(l=i===0?0:c/i),i!==a&&o==="l"&&(l=u>.5?c/(2-i-a):c/(i+a)),o==="i"&&(l=m>0?1-a/m:0),l*=100,u*=100,m*=100,o==="l"?[s,l,u]:o==="v"?[s,l,h*=100]:[s,l,m]}var sM=function(r,e,t){return aM(r,e,t,"l")},Up=function(r,e,t){var o,n,i=function(a){return 6*(a=a<0?a+1:a>1?a-1:a)<1?o+(n-o)*a*6:2*a<1?n:3*a<2?o+(n-o)*(.6666666666666666-a)*6:o};return r=r%360/360,e=nn(e/100,0,1),t=nn(t/100,0,1),o=2*t-(n=t<=.5?t*(e+1):t+e-t*e),[255*i(r+1/3),255*i(r),255*i(r-1/3)]},cj=function(r,e,t){return aM(r,e,t,"v")},lM=function(r,e,t){var o,n,i=[t/=100,t*(1-(e/=100)),t*(1-(n=(r=r%360/360*360)/60-(o=Math.floor(r/60%6)))*e),t*(1-(1-n)*e)],a=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return[255*i[a[o][0]],255*i[a[o][1]],255*i[a[o][2]]]},hj=function(r,e,t){return aM(r,e,t,"i")},uM=function(r,e,t){var o,n,i,a;e/=100,t/=100,isNaN(r)&&(r=0),isNaN(e)&&(e=0);var s=function(l){return(1+e*Math.cos(2*Math.PI*l)/Math.cos(Math.PI/3-2*Math.PI*l))/3};return(r=(360+r)%360/360)<1/3?i=1-((a=(1-e)/3)+(n=s(r))):r<2/3?a=1-((n=(1-e)/3)+(i=s(r-=1/3))):n=1-((i=(1-e)/3)+(a=s(r-=2/3))),o=[n,i,a].map((function(l){return 255*nn(t*l*3,0,1)})),[n=o[0],i=o[1],a=o[2]]},mj=function(r,e,t){return[sM(r,e,t)[0],100*(Math.min(r,e,t)/255),100*(1-Math.max(r,e,t)/255)]};function cM(r,e,t){return e/=100,t/=100,Up(r,100,50).map((function(o){return 255*(o/255*(1-e-t)+e)}))}var tM={x:[.4124564,.3575761,.1804375],y:[.2126729,.7151522,.072175],z:[.0193339,.119192,.9503041]},rM={r:[3.2404542,-1.5371385,-.4985314],g:[-.969266,1.8760108,.041556],b:[.0556434,-.2040259,1.0572252]},pj=.95047,dj=1,yj=1.08883,xse=.206896552,Ese=.008856452,fj=24389/27,oM=function(r,e,t){var o=oj(r,e,t);return[100*tM.x.reduce((function(n,i,a){return n+i*o[a]}),0),100*tM.y.reduce((function(n,i,a){return n+i*o[a]}),0),100*tM.z.reduce((function(n,i,a){return n+i*o[a]}),0)]},uP=function(r,e,t){var o=[r,e,t],n=rM.r.reduce((function(s,l,u){return s+l*o[u]}),0)/100,i=rM.g.reduce((function(s,l,u){return s+l*o[u]}),0)/100,a=rM.b.reduce((function(s,l,u){return s+l*o[u]}),0)/100;return nj(n,i,a)},k7=function(r,e,t){var o;return o=[r=r/pj/100,e=e/dj/100,t=t/yj/100].map((function(n){return n>Ese?Math.pow(n,1/3):(fj*n+16)/116})),r=o[0],e=o[1],t=o[2],[Math.max(0,116*e-16),500*(r-e),200*(e-t)]},hM=function(r,e,t){var o,n=(r+16)/116,i=isNaN(e)?n:n+e/500,a=isNaN(t)?n:n-t/200;return o=[i,n,a].map((function(s){return s>xse?Math.pow(s,3):(116*s-16)/fj})),i=o[0],n=o[1],a=o[2],[i*pj*100,n*dj*100,a*yj*100]},mM=function(r,e,t){return uP.apply(void 0,hM(r,e,t))},nM=function(r,e,t){e=nn(e,-100,100),t=nn(t,-100,100);var o=Math.sqrt(e*e+t*t),n=(180*Math.atan2(t,e)/Math.PI+360)%360;return Math.round(1e4*o)===0&&(n=Number.NaN),[r,o,n]},gj=function(r,e,t){return isNaN(t)&&(t=0),t*=Math.PI/180,[r,Math.cos(t)*e,Math.sin(t)*e]},pM=function(r,e,t){return hM.apply(void 0,gj(r,e,t))},bj=function(r,e,t){var o=r+e+t,n=0,i=0;return o>0&&(n=r/o,i=e/o),[n,i,e]},Cse=Object.freeze({__proto__:null,linear2rgb:nj,rgb2linear:oj,rgb2hex:aj,hex2rgb:sj,rgb2cmyk:lj,cmyk2rgb:uj,rgb2hsl:sM,hsl2rgb:Up,rgb2hsv:cj,hsv2rgb:lM,rgb2hsi:hj,hsi2rgb:uM,rgb2hwb:mj,hwb2rgb:cM,rgb2xyz:oM,xyz2rgb:uP,xyz2lab:k7,lab2xyz:hM,rgb2lab:function(r,e,t){return k7.apply(void 0,oM(r,e,t))},lab2rgb:mM,lch2lab:gj,lab2lch:nM,xyz2lch:function(r,e,t){return nM.apply(void 0,k7(r,e,t))},lch2xyz:pM,xyY2xyz:function(r,e,t){return e===0?[0,0,0]:[r*(t/e),t,t/e*(1-r-e)]},xyz2xyY:bj});function _l(r,e){return e===void 0&&(e=!1),function(t,o,n){var i=n.value;n.value=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];if(a.length>0&&e){var l=JSON.stringify(a);r+=l}if(this.cache.has(r))return this.cache.get(r);var u=i.call.apply(i,Ul([this],a,!1));return this.cache.set(r,u),u}}}function js(r,e,t,o){return r===void 0&&(r=[0,2,2]),e===void 0&&(e=0),t===void 0&&(t=!0),o===void 0&&(o=0),function(n,i,a){var s=a.value;a.value=function(){for(var l=[],u=0;u<arguments.length;u++)l[u]=arguments[u];var c=l[o]===void 0?t:l[o],h=s.call.apply(s,Ul([this],l,!1));if(c===!1)return h;var m=typeof c=="number"?Math.round(c):0,p=typeof r=="number"?new Array(h.length).fill(r):r,g=p.map((function(y){return e===1?typeof c=="number"?m:y:y+m}));return h.map((function(y,f){return ij(y,g[f])}))}}}var Sj=function(r,e,t){var o=r instanceof fn?r:new fn(r),n=e instanceof fn?e:new fn(e),i=nn(t,0,100)/100,a=2*i-1,s=o.alpha()-n.alpha(),l=((a*s==-1?a:(a+s)/(1+a*s))+1)/2,u=1-l,c=[Math.round(nn(o.red()*l+n.red()*u,0,255)),Math.round(nn(o.green()*l+n.green()*u,0,255)),Math.round(nn(o.blue()*l+n.blue()*u,0,255))],h=o.alpha()*i+n.alpha()*(1-i);return new fn(c,h)},Wa=Math.sqrt,Gr=Math.pow,AS=Math.cos,lP=Math.abs,rj=Math.sin,kse=Math.exp,Mse=Math.atan2,Aj=Math.PI,_p=function(r){return Aj*r/180},iM=function(r,e,t){t===void 0&&(t=!0);var o=Mse(e,r);return t&&(o=(o=(o=180*o/Aj)>0?o:o+360)>360?o-360:o),o},wS=function(r,e){e===void 0&&(e=!0);var t=r.lab(!1),o=t[0],n=t[1],i=t[2];return[o,Wa(Gr(n,2)+Gr(i,2)),iM(n,i,e),n,i]},Tse=["CMC","CIE","CIE2000","CIE1994","CIE1976"],Wse="CMC",Lse="CIE2000",Ise="CIE1994",Rse="CIE1976",wj=function(r,e,t,o){t===void 0&&(t="CIE");var n=(function(c){var h=c.toUpperCase();return Tse.includes(h)&&h!=="CIE"?h:Lse})(t);if(o=o||{},n===Wse){var i=Object.assign({},{l:1,c:1},o);return(function(c,h,m,p){m===void 0&&(m=1),p===void 0&&(p=1);var g=wS(c,!0),y=g[0],f=g[1],b=g[2],A=g[3],P=g[4],w=wS(h),T=w[0],C=w[1],D=w[3],F=f-C,E=y-T,W=P-w[4],v=Wa(Gr(A-D,2)+Gr(W,2)-Gr(F,2)),M=y<16?.511:.040975*y/(1+.01765*y),U=.0638*f/(1+.0131*f)+.638,I=164<=b&&b<=345?.56+lP(.2*AS(_p(b+168))):.36+lP(.4*AS(_p(b+35))),O=Wa(Gr(f,4)/(Gr(f,4)+1900)),G=U*(O*I+1-O);return Wa(Gr(E/(m*M),2)+Gr(F/(p*U),2)+Gr(v/G,2))})(r,e,i.l,i.c)}if(n===Ise){var a={kL:1,kC:1,kH:1,cate:"graphic"},s=Object.assign({},a,o);return(function(c,h,m,p,g,y){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1),y===void 0&&(y="graphic");var f=y==="textiles"?.048:.045,b=y==="textiles"?.014:.015;m=y==="textiles"?2:m;var A=wS(c),P=A[0],w=A[1],T=A[3],C=A[4],D=wS(h),F=D[0],E=D[1],W=D[3],v=P-F,M=w-E,U=C-D[4],I=1+f*w,O=1+b*w,G=Wa(Gr(T-W,2)+Gr(U,2)-Gr(M,2));return Wa(Gr(v/(1*m),2)+Gr(M/(p*I),2)+Gr(G/(g*O),2))})(r,e,s.kL,s.kC,s.kH,s.cate)}if(n===Rse)return(function(c,h){var m=c.lab(!1),p=m[0],g=m[1],y=m[2],f=h.lab(!1),b=f[0],A=f[1],P=f[2];return Wa(Gr(p-b,2)+Gr(g-A,2)+Gr(y-P,2))})(r,e);var l={kL:1,kC:1,kH:1},u=Object.assign({},l,o);return(function(c,h,m,p,g){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1);var y=wS(c),f=y[0],b=y[1],A=y[3],P=y[4],w=wS(h),T=w[0],C=w[1],D=w[3],F=w[4],E=(f+T)/2,W=(b+C)/2,v=(1-Wa(Gr(W,7)/(Gr(W,7)+Gr(25,7))))/2,M=A*(1+v),U=D*(1+v),I=Wa(Gr(M,2)+Gr(P,2)),O=Wa(Gr(U,2)+Gr(F,2)),G=iM(M,P,!0),X=iM(U,F,!0),Y=(I+O)/2,H=lP(G-X)>180?(G+X+360)/2:(G+X)/2,j=1-.17*AS(_p(H-30))+.24*AS(_p(2*H))+.32*AS(_p(3*H+6))-.2*AS(_p(4*H-63)),ae=lP(X-G)<=180?X-G:lP(X-G)>180&&X<=G?X-G+360:X-G-360,Q=T-f,Pe=C-b,we=2*Wa(I*O)*rj(_p(ae)/2),Ve=1+.015*Gr(E-50,2)/Wa(20+Gr(E-50,2)),Ue=1+.045*Y,ue=1+.015*Y*j,Ce=30*kse(-Gr((H-275)/25,2)),le=-2*Wa(Gr(Y,7)/(Gr(Y,7)+Gr(25,7)))*rj(2*_p(Ce));return Wa(Gr(Q/(m*Ve),2)+Gr(Pe/(p*Ue),2)+Gr(we/(g*ue),2)+le*(Pe/(p*Ue))*(we/(g*ue)))})(r,e,u.kL,u.kC,u.kH)},_se=function(r,e,t){var o=Math.abs,n=Math.max,i=Math.min,a=r instanceof fn?r:new fn(r),s=e instanceof fn?e:new fn(e),l=Object.assign({},{b:125,c:500},t);return!(o(255*a.brightness()/100-255*s.brightness()/100)<=l.b)&&!(n(a.red(),s.red())-i(a.red(),s.red())+(n(a.green(),s.green())-i(a.green(),s.green()))+(n(a.blue(),s.blue())-i(a.blue(),s.blue()))<=l.c)},PS=function(r,e,t){var o,n=function(u){return nn(u,0,100)},i=function(u){return nn(u,0,255)},a={h:[0,function(u){return u%360}],s:[1,n],l:[2,n],r:[0,i],g:[1,i],b:[2,i]},s=a[e][0];if(["h","s","l"].includes(e)){var l=r.hsl();if(t===void 0)return l[s];t=a[e][1](t),l[s]=t,o=Up.apply(void 0,l)}else{if(o=r.rgb(),t===void 0)return o[s];t=a[e][1](t),o[s]=t}return new fn(o,r.alpha())},T7={},Use=new Set(["rgb","rgba","cmyk","lab","hsl","hsla","hsv","hsva","hsi","hsia","xyz","lch","hwb","hwba"]),Bse=/^([a-zA-Z]+)\(([\s\S]+)\)$/,M7=function(r){return typeof r=="string"?r.indexOf("%")===-1?M7(Number(r.trim())):(r=r.split("%")[0],(r=Number(r.trim()))||0):Math.abs(r)<1?100*r:r},Pj=function(r,e){e===void 0&&(e=new Set);var t=typeof r=="string"?r:r.join(",");if(e.has(t))throw new Error("Invalid Color");e.add(t);var o="rgb",n=[0,0,0],i=100;if(Array.isArray(r)){if(r.length<3)throw new Error("Invalid Color");for(var a=0;a<r.length;a++)if(a<3)n[a]=r[a];else{if(a!==3||r[3]===void 0)break;i=r[3]}}else{var s=!1,l=r.trim().match(Bse);if(l||(s=!0),l){var u=l[1].toLocaleLowerCase();if(o=u,Use.has(u)||(s=!0),l[2]&&!s){var c=l[2],h=c.indexOf(",")!==-1?",":" ",m=c.split(h);for(a=0;a<3;a++)m[a]!==void 0&&(["lch","lab"].includes(o)&&a===0||["hsl","hsla","hsv","hsva","hwb","hwba","hsi","hsia"].includes(o)&&a>0?n[a]=M7(m[a]):n[a]=Number(m[a].trim()));["rgba","hsla","hsva","hwba","hsia"].includes(o)?(o=o.slice(0,-1),m[3]!==void 0&&(i=M7(m[3]))):o==="cmyk"&&n.push(m[3]!==void 0?M7(m[3]):0)}}if(s){if(!/^#(([a-fA-F\d]{3}){1,2}|[a-fA-F\d]{8})$/.test(r))try{return r=(function(p,g){if(g===void 0&&(g=!1),p=p.toLowerCase(),T7[p]===void 0){if(g)throw new Error("Unknown color name: ".concat(p,")"));return p}return T7[p]})(r,!0),Pj(r,e)}catch{throw new Error("Invalid Color")}n=sj(r)}}return[o,n,i]},vj={thowParseError:!1},fn=(function(){function r(e,t,o){this.cache=new Map,this._rgb=[0,0,0],this._alpha=100;var n={thowParseError:vj.thowParseError},i=Object.assign({},n,o??{});try{var a=(function(u){var c,h={lab2rgb:mM,hsl2rgb:Up,hsv2rgb:lM,xyz2rgb:uP,hwb2rgb:cM,hsi2rgb:uM},m=Pj(u),p=m[0],g=m[1],y=m[2];if(p==="rgb")return[g,y];p==="lch"&&(p=(c=["xyz",pM(g[0],g[1],g[2])])[0],g=c[1]);var f=g[0],b=g[1],A=g[2],P=g[3];if(p==="cmyk")return[uj(f,b,A,P).map((function(T){return nn(T,0,255)})),y];var w="".concat(p,"2rgb");if(typeof h[w]=="function")return[h[w](f,b,A).map((function(T){return nn(T,0,255)})),y];throw new Error("Invalid color")})(e),s=a[0],l=a[1];this._alpha=l,this._rgb=s}catch(u){if(i.thowParseError)throw u}t!==void 0&&(this._alpha=nn(t,0,100))}return r.prototype.red=function(e){return PS(this,"r",e)},r.prototype.green=function(e){return PS(this,"g",e)},r.prototype.blue=function(e){return PS(this,"b",e)},r.prototype.alpha=function(e){return e===void 0?this._alpha:(e=nn(e,0,100),new r(this.rgb(),e))},r.prototype.fadeIn=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),nn(this._alpha+e,0,100))},r.prototype.fadeOut=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),nn(this._alpha-e,0,100))},r.prototype.opacify=function(e,t){return e===void 0&&(e=10),this.fadeIn(e,t)},r.prototype.transparentize=function(e,t){return e===void 0&&(e=10),this.fadeOut(e,t)},r.prototype.hue=function(e){return PS(this,"h",e)},r.prototype.saturation=function(e){return PS(this,"s",e)},r.prototype.lightness=function(e){return PS(this,"l",e)},r.prototype.rgb=function(e){return Ul([],this._rgb,!0)},r.prototype.rgba=function(e){return Ul(Ul([],this.rgb(!1),!0),[this._alpha],!1)},r.prototype.cmyk=function(e){return lj.apply(void 0,this._rgb)},r.prototype.hsl=function(e){return sM.apply(void 0,this._rgb)},r.prototype.hsla=function(e){return Ul(Ul([],this.hsl(!1),!0),[this._alpha],!1)},r.prototype.hsv=function(e){return cj.apply(void 0,this._rgb)},r.prototype.hsi=function(e){return hj.apply(void 0,this._rgb)},r.prototype.hwb=function(e){return mj.apply(void 0,this._rgb)},r.prototype.xyz=function(e){return oM.apply(void 0,this._rgb)},r.prototype.lab=function(e){return k7.apply(void 0,this.xyz(!1))},r.prototype.lch=function(e){return nM.apply(void 0,this.lab(!1))},r.prototype.xyY=function(e){return bj.apply(void 0,this.xyz(!1))},r.prototype.hex=function(e){e===void 0&&(e=2);var t=e===0?void 0:e===1?this._alpha:this._alpha===100?void 0:this._alpha,o="color:hex:param_".concat(e);if(this.cache.has(o))return this.cache.get(o);var n=aj.apply(void 0,Ul(Ul([],this._rgb,!1),[t],!1));return this.cache.set(o,n),n},r.prototype.lighten=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return a=nn(a+=t!==void 0&&t==="relative"?a*(e/100):e,0,100),new r(Up(n,i,a),this._alpha)},r.prototype.darken=function(e,t){return e===void 0&&(e=5),this.lighten(-e,t)},r.prototype.saturate=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return i=nn(i+=t!==void 0&&t==="relative"?i*(e/100):e,0,100),new r(Up(n,i,a),this._alpha)},r.prototype.desaturate=function(e,t){return e===void 0&&(e=5),this.saturate(-e,t)},r.prototype.spin=function(e){var t=this.hsl(!1),o=t[0],n=t[1],i=t[2];return new r(Up(o=(o+e%360+360)%360,n,i),this._alpha)},r.prototype.adjustHue=function(e){return this.spin(e)},r.prototype.complement=function(){return this.spin(180)},r.prototype.invert=function(){var e=this._rgb.map((function(t){return 255-t}));return new r([e[0],e[1],e[2]],this._alpha)},r.prototype.mix=function(e,t){return t===void 0&&(t=50),Sj(this,e,100-nn(t,0,100))},r.prototype.luma=function(){var e=this._rgb.map((function(t){return(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}));return .2126*e[0]+.7152*e[1]+.0722*e[2]},r.prototype.brightness=function(){var e=this._rgb;return(function(t,o,n){return(299*t+587*o+114*n)/1e3/255*100})(e[0],e[1],e[2])},r.prototype.deltaE=function(e,t,o){return t===void 0&&(t="CMC"),wj(this,e,t,o)},r.prototype.visibility=function(e,t){return _se(this,e,t)},os([js(0,1,!0,0),_l("color:rgb")],r.prototype,"rgb",null),os([js(0,1,!0,0)],r.prototype,"rgba",null),os([js(0,1,!0,0),_l("color:cmyk")],r.prototype,"cmyk",null),os([js(0,1,!0,0),_l("color:hsl")],r.prototype,"hsl",null),os([js(0,1,!0,0)],r.prototype,"hsla",null),os([js(0,1,!0,0),_l("color:hsv")],r.prototype,"hsv",null),os([js(0,1,!0,0),_l("color:hsi")],r.prototype,"hsi",null),os([js(0,1,!0,0),_l("color: hwb")],r.prototype,"hwb",null),os([js(2,1,!0,0),_l("color:xyz")],r.prototype,"xyz",null),os([js(2,1,!0,0),_l("color:lab")],r.prototype,"lab",null),os([js(2,1,!0,0),_l("color:lch")],r.prototype,"lch",null),os([js(2,1,!0,0),_l("color:xyY")],r.prototype,"xyY",null),os([_l("color:luma")],r.prototype,"luma",null),r})(),Dse=function(r,e,t,o){return new fn([r,e,t],o)},Ose=function(r,e,t,o){return new fn(Up(r,e,t),o)},Fse=function(r,e,t,o){return new fn(lM(r,e,t),o)},Gse=function(r,e,t,o){return new fn(uM(r,e,t),o)},Vse=function(r,e,t,o){return new fn(cM(r,e,t),o)},Hse=function(r,e,t,o){return new fn(uP(r,e,t),o)},zse=function(r,e,t,o){return new fn(mM(r,e,t),o)},jse=function(r,e,t,o){return new fn(uP.apply(void 0,pM(r,e,t)),o)};function bi(r,e,t){return new fn(r,e,t)}bi.config=function(r){Object.assign(vj,r)},bi.random=function(){var r=C7(0,255),e=C7(0,255),t=C7(0,255);return new fn([r,e,t])},bi.convertor=Cse,bi.Color=fn,bi.rgb=Dse,bi.hsl=Ose,bi.hsv=Fse,bi.hsi=Gse,bi.hwb=Vse,bi.xyz=Hse,bi.lab=zse,bi.lch=jse,bi.mix=Sj,bi.deltaE=wj,bi.utils={roundDecimal:ij,randomRange:C7},bi.useNames=function(r,e){return(function(t,o){if(o!==void 0&&typeof o=="function"){var n={};for(var i in t){var a=o(i,t[i]),s=a[0],l=a[1];n[s]=l}Object.assign(T7,n)}else Object.assign(T7,t)})(r,e),bi};var L7=[1,0,0,1,0,0],vS=(r,e)=>[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5]],W7=(r,e,t)=>[r[0]*e+r[2]*t+r[4],r[1]*e+r[3]*t+r[5]];function fM(r){if(!r||!r.trim())return L7;let e=L7,t=/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g,o="";for(let n of r.matchAll(t)){o+=n[0];let i=n[2].split(/[\s,]+/).filter(Boolean).map(Number);if(i.some(s=>!isFinite(s)))return null;let a;switch(n[1]){case"matrix":if(i.length!==6)return null;a=i;break;case"translate":a=[1,0,0,1,i[0]??0,i[1]??0];break;case"scale":a=[i[0]??1,0,0,i[1]??i[0]??1,0,0];break;case"rotate":{let s=(i[0]??0)*Math.PI/180,l=Math.cos(s),u=Math.sin(s),c=[l,u,-u,l,0,0];a=i.length>=3?vS(vS([1,0,0,1,i[1],i[2]],c),[1,0,0,1,-i[1],-i[2]]):c;break}case"skewX":a=[1,0,Math.tan((i[0]??0)*Math.PI/180),1,0,0];break;default:a=[1,Math.tan((i[0]??0)*Math.PI/180),0,1,0,0];break}e=vS(e,a)}return r.replace(t,"").replace(/[\s,]/g,"")!==""?null:o?e:L7}var nc=r=>String(r??"").toLowerCase(),cP=(r,e)=>{let t=nc(r.getAttribute("style")).replace(/\s+/g,"");for(let o of t.split(";")){let n=o.indexOf(":");if(n>0&&o.slice(0,n)===e)return o.slice(n+1)}return null},cf=(r,e)=>cP(r,e)??(r.getAttribute(e)!==null?nc(r.getAttribute(e)):null);function Xse(r){for(let e of String(r.getAttribute?.("style")??"").split(";")){let t=e.indexOf(":");if(t<0||e.slice(0,t).trim().toLowerCase()!=="font")continue;let o=/(?:^|\s)((?:\d*\.)?\d+(?:px|pt|em|%))(?:\s|\/|$)/i.exec(e.slice(t+1));return o?o[1].toLowerCase():"unreadable"}return null}var Nj=10;function NS(r){for(let e=r;e;e=e.parentElement){let t=cP(e,"font-size")??Xse(e)??(e.getAttribute?.("font-size")!=null&&e.getAttribute("font-size").trim()!==""?nc(e.getAttribute("font-size")).trim():null);if(t===null)continue;let o=/^((?:\d*\.)?\d+(?:e[+-]?\d+)?)(px|pt|em|%)?$/.exec(t);if(!o)return{px:Nj,sure:!1};let n=parseFloat(o[1]),i=o[2]??"px";if(i==="px")return{px:n,sure:!0};if(i==="pt")return{px:n*4/3,sure:!0};let a=NS(e.parentElement);return{px:(i==="em"?n:n/100)*a.px,sure:a.sure}}return{px:Nj,sure:!1}}function I7(r,e,t,o){let n=String(r.getAttribute(e)??"").trim().toLowerCase();if(!n)return{v:0,sure:!0};let i=n.split(/[\s,]+/).filter(Boolean),a=/^([-+]?(?:\d*\.)?\d+(?:e[+-]?\d+)?)(px|em|%)?$/.exec(i[0]);if(!a)return null;let s=parseFloat(a[1]),l=a[2]==="em"?s*t:a[2]==="%"?s/100*o:s;return isFinite(l)?{v:l,sure:i.length===1}:null}function Kse(r){return Array.from(r).length*.5}function Yse(r){for(let e=r.parentElement;e;e=e.parentElement)if(nc(e.localName)==="svg")return e;return null}var gM=new Set(["defs","clippath","mask","pattern","marker","symbol","lineargradient","radialgradient","filter","title","desc","metadata","style","script"]);function xj(r){let e=String(r??"").trim();return/^\+?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i.test(e)?parseFloat(e):NaN}function qse(r){if(cf(r,"overflow")==="visible")return null;let e=xj(cP(r,"width")??r.getAttribute("width")),t=xj(cP(r,"height")??r.getAttribute("height")),o=r.getAttribute("viewBox");if(o){let n=o.split(/[\s,]+/).filter(Boolean).map(Number);return n.length!==4||!n.every(isFinite)||n[2]<=0||n[3]<=0||!nc(r.getAttribute("preserveAspectRatio")).includes("none")&&isFinite(e)&&isFinite(t)&&e>0&&t>0&&Math.abs(n[2]/n[3]-e/t)>.01*(e/t)?null:{x0:n[0],y0:n[1],x1:n[0]+n[2],y1:n[1]+n[3]}}return!(e>0)||!(t>0)?null:{x0:0,y0:0,x1:e,y1:t}}function Jse(r,e){for(let t=r;t&&t!==e;t=t.parentElement){if(cf(t,"display")==="none")return!0;let o=cf(t,"visibility");if(o==="hidden"||o==="collapse")return!0;let n=cf(t,"opacity");if(n!==null&&n!==""&&parseFloat(n)===0)return!0}return!1}function $se(r,e){for(let t=r;t&&t!==e;t=t.parentElement)if(t.getAttribute("clip-path")||cP(t,"clip-path")||gM.has(nc(t.localName)))return!0;return!1}function Qse(r,e){let t=L7;for(let o=r;o&&o!==e;o=o.parentElement){let n=fM(o.getAttribute("transform"));if(!n)return null;t=vS(n,t)}return t}var ns=(r,e)=>{let t=parseFloat(r.getAttribute(e)??"");return isFinite(t)?t:0};function yM(r){let e="";for(let t=r.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue??"":t.nodeType===1&&!gM.has(nc(t.localName))&&(e+=yM(t));return e}function Bl(r,e,t){for(let o=r;o&&o!==e.parentElement;o=o.parentElement){let n=cf(o,t);if(n!==null&&n!=="")return n}return null}var dM=["x","y","dx","dy"],uf=(r,e)=>(r.getAttribute(e)??"").trim()!=="";function Zse(r,e,t){let o=NS(r),[n,i,a,s]=dM.map(c=>I7(r,c,o.px,c==="x"||c==="dx"?e:t));if(!n||!i||!a||!s)return null;let l={text:"",x:n.v+a.v,y:i.v+s.v,fontPx:o.px,el:r,extra:0,sure:o.sure&&n.sure&&i.sure&&a.sure&&s.sure},u=[l];for(let c=r.firstChild;c;c=c.nextSibling){if(c.nodeType===3||c.nodeType===4){l.text+=c.nodeValue??"";continue}if(c.nodeType!==1)continue;let h=c,m=nc(h.localName);if(gM.has(m))continue;if(m==="textpath"||h.querySelector("textPath, textpath"))return null;if(cf(h,"display")==="none")continue;let p=NS(h),g=Array.from(h.querySelectorAll("*")).some(y=>dM.some(f=>uf(y,f)));if(uf(h,"x")){let[y,f,b,A]=dM.map(P=>I7(h,P,p.px,P==="x"||P==="dx"?e:t));if(!y||!f||!b||!A)return null;l={text:yM(h),x:y.v+b.v,y:(uf(h,"y")?f.v:l.y)+A.v,fontPx:p.px,el:h,extra:0,sure:p.sure&&y.sure&&f.sure&&b.sure&&A.sure&&!g},u.push(l)}else{l.text+=yM(h);let y=I7(h,"dx",p.px,e);if(!y)return null;l.extra+=y.v,(!y.sure||uf(h,"y")||uf(h,"dy")||g||p.px!==l.fontPx||!p.sure||cf(h,"text-anchor")!==null)&&(l.sure=!1),l.fontPx=Math.max(l.fontPx,p.px)}}for(let c of u)c.text=c.text.replace(/\s+/g," ").trim();return u.filter(c=>c.text)}function bM(r){let e=[],t=r.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g)??[],o=0,n="",i=0,a=0,s=0,l=0,u=()=>parseFloat(t[o++]),c=()=>o<t.length&&!/^[a-zA-Z]$/.test(t[o]);for(;o<t.length;){if(/^[a-zA-Z]$/.test(t[o]))n=t[o++];else if(!n)return[];let h=n===n.toLowerCase(),m=n.toUpperCase();if(m==="Z"){if(i=s,a=l,c())return e;continue}let p={M:2,L:2,T:2,H:1,V:1,C:6,S:4,Q:4,A:7}[m];if(!p)return e;if(!c())continue;let g=[];for(let b=0;b<p;b++)g.push(u());if(g.some(b=>!isFinite(b)))return e;let y=h?i:0,f=h?a:0;if(m==="H")i=y+g[0],e.push([i,a]);else if(m==="V")a=f+g[0],e.push([i,a]);else if(m==="A")i=y+g[5],a=f+g[6],e.push([i,a]);else{for(let b=0;b<p;b+=2)e.push([y+g[b],f+g[b+1]]);i=y+g[p-2],a=f+g[p-1]}m==="M"&&(s=i,l=a,n=h?"l":"L")}return e}function Ej(r){let e=1/0,t=-1/0,o=1/0,n=-1/0;for(let[i,a]of r)e=Math.min(e,i),t=Math.max(t,i),o=Math.min(o,a),n=Math.max(n,a);return{X0:e,X1:t,Y0:o,Y1:n}}var Cj=/condensed|narrow|compressed|impact|agency/,ele=/(?:^|[{;\s])(font-size|font|font-family|font-stretch|text-anchor|letter-spacing|word-spacing|direction|writing-mode|transform|text-transform)\s*:\s*([^;}]*)/gi;function tle(r){for(let e of r.replace(/\/\*[\s\S]*?\*\//g,"").matchAll(ele)){let t=e[1].toLowerCase(),o=e[2].trim().toLowerCase().replace(/\s*!important$/,"");if(!(t!=="font-size"&&t!=="font"&&/^(normal|inherit|initial|unset|none|0|0px|ltr|horizontal-tb)$/.test(o))&&!(t==="font-family"&&!Cj.test(o))&&!(t==="text-transform"&&o==="uppercase"))return!0}return!1}var rle=new Set(["rect","image","foreignobject","circle","ellipse","line","text","path","polygon","polyline"]),Xs=.5,ole=5;function kj(r){let e={frames:0,unmeasured:0,outside:0,crossing:0,textLikely:0,textEvenNarrow:0,samples:{outside:[],crossing:[],textLikely:[],textEvenNarrow:[]}},t=(a,s)=>{a.length<ole&&a.push(s)},o=Math.round,n=r.ownerDocument??r,i=Array.from(n.querySelectorAll("style")).concat(Array.from(r.querySelectorAll("style"))).some(a=>tle(a.textContent??""));for(let a of Array.from(r.querySelectorAll("svg"))){let s=qse(a),l=Array.from(a.querySelectorAll("*")).filter(m=>rle.has(nc(m.localName))&&Yse(m)===a);if(!s){l.length&&e.unmeasured++;continue}e.frames++;let u=(m,p)=>p==="left"||p==="right"?`x ${o(m.X0)}..${o(m.X1)}, frame ${o(s.x0)}..${o(s.x1)}`:`y ${o(m.Y0)}..${o(m.Y1)}, frame ${o(s.y0)}..${o(s.y1)}`,c=m=>m.X0>s.x1+Xs?"right":m.X1<s.x0-Xs?"left":m.Y0>s.y1+Xs?"bottom":m.Y1<s.y0-Xs?"top":"",h=m=>m.X1>s.x1+Xs?"right":m.X0<s.x0-Xs?"left":m.Y1>s.y1+Xs?"bottom":m.Y0<s.y0-Xs?"top":"";for(let m of l){if(Jse(m,a)||$se(m,a))continue;let p=Qse(m,a);if(!p)continue;let g=nc(m.localName);if(g==="text"){if(Math.abs(p[1])>1e-9||Math.abs(p[2])>1e-9)continue;let P=Bl(m,a,"writing-mode")??"";if(P.startsWith("tb")||P.startsWith("vertical")||P.startsWith("sideways"))continue;let w=Bl(m,a,"fill"),T=Bl(m,a,"stroke");if(w==="none"&&(T===null||T==="none"))continue;let C=Zse(m,s.x1-s.x0,s.y1-s.y0);if(!C)continue;let D=I7(m,"textLength",NS(m).px,s.x1-s.x0),F=C.length===1&&uf(m,"textLength")&&D?.sure&&D.v>0?D.v:null,E=null,W=null,v=null;for(let M of C){let U=M.fontPx,I=M.text;if(!(U>0))continue;let O=M.y,G=Bl(M.el,a,"dominant-baseline")??Bl(M.el,a,"alignment-baseline")??"";G==="middle"||G==="central"?O+=.35*U:(G==="hanging"||G==="text-before-edge")&&(O+=.8*U);let X=Bl(M.el,a,"text-anchor")??"start",Y=Bl(M.el,a,"direction")==="rtl",H=Bl(M.el,a,"letter-spacing"),j=H===null||H==="normal"?0:/^(?:\d*\.)?\d+(?:px)?$/.test(H)?parseFloat(H):NaN,ae=Array.from(I).length,Q=isFinite(j)?j*ae:0,Pe=`${Bl(M.el,a,"font-family")??""} ${Bl(M.el,a,"font-stretch")??""}`,we=M.sure&&!i&&!Y&&isFinite(j)&&Bl(M.el,a,"word-spacing")===null&&!Cj.test(Pe)&&(F!==null||!uf(m,"textLength")),Ve=(tt,dt,yt)=>{let re=X==="middle"?M.x-tt/2:X==="end"?M.x-tt:M.x;return Ej([W7(p,re,O-dt*U),W7(p,re+tt,O+yt*U)])},Ue=Ve(F??ae*U*.6+M.extra+Q,.75,.2),ue=`text "${I.length>30?I.slice(0,30)+"...":I}"`,Ce=W7(p,M.x,O)[0],le=Ue.Y0>s.y1+Xs?"bottom":Ue.Y1<s.y0-Xs?"top":Y?"":X==="start"&&Ce>s.x1+Xs?"right":X==="end"&&Ce<s.x0-Xs?"left":"";if(le){E??={what:ue,edge:le,where:u(Ue,le)};continue}let K=h(Ue);if(!K||(W??={what:ue,edge:K,where:u(Ue,K)},!we||v))continue;let ye=Ve(F??Kse(I)*U+M.extra+Q,.5,0),oe=h(ye);if(!oe)continue;let $e=oe==="right"?ye.X1-s.x1:oe==="left"?s.x0-ye.X0:oe==="bottom"?ye.Y1-s.y1:s.y0-ye.Y0;v={what:ue,edge:oe,where:u(ye,oe),pastPx:Math.round($e)}}if(E){e.outside++,t(e.samples.outside,E);continue}W&&(e.textLikely++,t(e.samples.textLikely,W)),v&&(e.textEvenNarrow++,t(e.samples.textEvenNarrow,v));continue}let y;if(g==="circle"||g==="ellipse"){let P=g==="circle"?ns(m,"r"):ns(m,"rx"),w=g==="circle"?P:ns(m,"ry");if(!(P>0&&w>0))continue;let T=ns(m,"cx"),C=ns(m,"cy");y=[[T-P,C-w],[T+P,C+w],[T+P,C-w],[T-P,C+w]]}else if(g==="line")y=[[ns(m,"x1"),ns(m,"y1")],[ns(m,"x2"),ns(m,"y2")]];else if(g==="path"||g==="polygon"||g==="polyline"){if(g==="path")y=bM(m.getAttribute("d")??"");else{let P=(m.getAttribute("points")??"").split(/[\s,]+/).filter(Boolean).map(Number);y=[];for(let w=0;w+1<P.length;w+=2)y.push([P[w],P[w+1]])}if(!y.length||y.some(P=>!isFinite(P[0])||!isFinite(P[1])))continue}else{let P=ns(m,"width"),w=ns(m,"height");if(!(P>0&&w>0))continue;let T=ns(m,"x"),C=ns(m,"y");y=[[T,C],[T+P,C+w],[T+P,C],[T,C+w]]}let f=Ej(y.map(P=>W7(p,P[0],P[1]))),b=c(f);if(b){e.outside++,t(e.samples.outside,{what:g,edge:b,where:u(f,b)});continue}if(g==="path")continue;let A=h(f);A&&(e.crossing++,t(e.samples.crossing,{what:g,edge:A,where:u(f,A)}))}}return e}var lle=new Set(["d3-sankey","d3-hexbin","d3-voronoi-treemap"]),ule=new Set(["title","desc","metadata","style","script"]);function Ij(r){let e="";for(let t=r?.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue||"":t.nodeType===1&&!ule.has(String(t.localName||"").toLowerCase())&&(e+=Ij(t));return e}function SM(r){return NS(r).px}function cle(r,e){let t=o=>{let n=String(r.getAttribute?.(o)??"").trim().split(/[\s,]+/)[0]??"",i=parseFloat(n);return isFinite(i)?/em$/i.test(n)?i*e:i:0};return{x:t("x")+t("dx"),y:t("y")+t("dy")}}function hle(r){for(let e=r;e&&e.getAttribute;e=e.parentElement){let o=(/(?:^|;)\s*text-anchor\s*:\s*([a-z]+)/i.exec(String(e.getAttribute("style")||""))?.[1]??e.getAttribute("text-anchor")??"").trim().toLowerCase();if(o)return o}return"start"}function mle(r){let e=new Set(["SVGElement","SVGGraphicsElement","SVGGeometryElement","SVGTextContentElement"].map(h=>r[h]?.prototype).filter(Boolean)),t=r.Element?.prototype;for(let h of["svg","g","text","tspan","textPath","path","rect","circle","ellipse","line","polyline","polygon","image","use"])try{for(let m=Object.getPrototypeOf(r.document.createElementNS("http://www.w3.org/2000/svg",h));m&&m!==t;m=Object.getPrototypeOf(m))e.add(m)}catch{}let o=h=>["text","tspan","textpath"].includes(String(h.tagName||"").toLowerCase()),n=h=>o(h)?Ij(h).trim().length*SM(h)*.6:0,i=h=>{let m=String(h.tagName||"").toLowerCase();if(m==="path")return bM(h.getAttribute("d")||"");if(m==="line")return[[+h.getAttribute("x1")||0,+h.getAttribute("y1")||0],[+h.getAttribute("x2")||0,+h.getAttribute("y2")||0]];let p=String(h.getAttribute("points")||"").split(/[\s,]+/).filter(Boolean).map(Number),g=[];for(let y=0;y+1<p.length;y+=2)g.push([p[y],p[y+1]]);return g},a=h=>{let m=0;for(let p=1;p<h.length;p++)m+=Math.hypot(h[p][0]-h[p-1][0],h[p][1]-h[p-1][1]);return m},s=function(){if(o(this)){let g=SM(this),y=Math.max(1,n(this)),f=cle(this,g),b=hle(this);return{x:b==="middle"?f.x-y/2:b==="end"?f.x-y:f.x,y:f.y-g*.8,width:y,height:Math.max(1,g)}}let h=parseFloat(this.getAttribute?.("width")||"")||0,m=parseFloat(this.getAttribute?.("height")||"")||0;if(h>0||m>0)return{x:0,y:0,width:h||1,height:m||1};let p=parseFloat(this.getAttribute?.("r")||"")||0;return p>0?{x:-p,y:-p,width:2*p,height:2*p}:{x:0,y:0,width:1,height:1}},l=function(){let h=s.call(this);if(String(this.tagName||"").toLowerCase()!=="svg"){let m=[1,0,0,1,0,0];for(let p=this;p&&m&&String(p.tagName||"").toLowerCase()!=="svg";p=p.parentElement){let g=fM(p.getAttribute?.("transform"));m=g?vS(g,m):null}if(m){let p=[[h.x,h.y],[h.x+h.width,h.y],[h.x,h.y+h.height],[h.x+h.width,h.y+h.height]].map(([A,P])=>[m[0]*A+m[2]*P+m[4],m[1]*A+m[3]*P+m[5]]),g=p.map(A=>A[0]),y=p.map(A=>A[1]),f=Math.min(...g),b=Math.min(...y);h={x:f,y:b,width:Math.max(...g)-f,height:Math.max(...y)-b}}}return{...h,top:h.y,left:h.x,right:h.x+h.width,bottom:h.y+h.height,toJSON(){return h}}},u=(h,m,p)=>Object.defineProperty(h,m,{configurable:!0,writable:!0,value:p});for(let h of e)u(h,"getBBox",s),u(h,"getBoundingClientRect",l),u(h,"getComputedTextLength",function(){return n(this)}),u(h,"getSubStringLength",function(m,p){return o(this)?Math.max(0,(p||0)*SM(this)*.6):0}),u(h,"getTotalLength",function(){return a(i(this))}),u(h,"getPointAtLength",function(m){let p=i(this);if(!p.length)return{x:0,y:0};let g=Math.max(0,+m||0);for(let f=1;f<p.length;f++){let b=Math.hypot(p[f][0]-p[f-1][0],p[f][1]-p[f-1][1]);if(g<=b&&b>0){let A=g/b;return{x:p[f-1][0]+A*(p[f][0]-p[f-1][0]),y:p[f-1][1]+A*(p[f][1]-p[f-1][1])}}g-=b}let y=p[p.length-1];return{x:y[0],y:y[1]}});let c=r.HTMLCanvasElement?.prototype;if(c){let h=new WeakMap,m=g=>{let y=String(g||"").match(/([\d.]+)\s*(px|pt|em|rem)\b/i);if(!y)return 10;let f=parseFloat(y[1]);return y[2].toLowerCase()==="pt"?f*4/3:/r?em/i.test(y[2])?f*16:f},p=()=>{};Object.defineProperty(c,"getContext",{configurable:!0,writable:!0,value:function(g){if(String(g||"").toLowerCase()!=="2d")return null;let y=h.get(this);if(!y){let f=this;y=new Proxy({canvas:f,font:"10px sans-serif",measureText(b){let A=m(this.font),P=String(b??"").length*A*.6;return{width:P,actualBoundingBoxLeft:0,actualBoundingBoxRight:P,actualBoundingBoxAscent:A*.8,actualBoundingBoxDescent:A*.2,fontBoundingBoxAscent:A*.8,fontBoundingBoxDescent:A*.2}},getImageData:(b,A,P,w)=>({width:P,height:w,data:new Uint8ClampedArray(Math.max(1,P*w*4))}),createLinearGradient:()=>({addColorStop:p}),createRadialGradient:()=>({addColorStop:p}),getLineDash:()=>[],isPointInPath:()=>!1,isPointInStroke:()=>!1},{get:(b,A)=>A in b?b[A]:typeof A=="string"&&/^[a-z]/.test(A)?p:void 0}),h.set(this,y)}return y}})}}function ple(r){let e=["window","document","navigator","Event","CustomEvent","MouseEvent","KeyboardEvent","PointerEvent","Element","HTMLElement","SVGElement","Node","getComputedStyle","requestAnimationFrame","cancelAnimationFrame","DOMParser","XMLSerializer","MutationObserver","Image","ResizeObserver"],t=e.map(n=>[n,Object.getOwnPropertyDescriptor(globalThis,n)]),o=n=>n==="window"?r:n==="ResizeObserver"?r.ResizeObserver??class{observe(){}unobserve(){}disconnect(){}}:typeof r[n]=="function"&&/^[a-z]/.test(n)?r[n].bind(r):r[n];for(let n of e){let i=o(n);if(i!==void 0)try{Object.defineProperty(globalThis,n,{configurable:!0,writable:!0,value:i})}catch{}}return()=>{for(let[n,i]of t)try{i?Object.defineProperty(globalThis,n,i):delete globalThis[n]}catch{}}}function Wj(r,e){let t=e.split(/\r?\n/);for(let o of String(r?.stack??"").split(`
|
|
304
304
|
`)){if(!/eval at|anonymous/.test(o))continue;let n=o.match(/<anonymous>:(\d+):(\d+)\)?\s*$/);if(!n)continue;let i=parseInt(n[1],10)-2;if(i<1||i>t.length||!t[i-1].trim())continue;let a=t[i-1].trim();return{line:i,lineText:a.length>200?a.slice(0,197)+"...":a}}return{}}var Wh=r=>String(r?.message??r??"unknown error").split(`
|
|
305
305
|
`)[0].slice(0,400),Rj=r=>new Promise(e=>setTimeout(e,r));async function Lj(r,e){let t=Date.now()+e;for(;Date.now()<t;){let o=!1;for(let n of Array.from(r.querySelectorAll("*"))){let i=n.__transition;if(i&&Object.keys(i).length){o=!0;break}}if(!o)return;await Rj(40)}}async function dle(r){let e=Date.now(),t={rows:r.rows.length,payloadRows:0,missingPlugins:[],threw:null,invalid:null,timedOut:!1,marks:{byKind:{},total:0,legend:0,containerKind:"empty",declaresNoRowMarks:!1},blank:!1,frame:null,click:{tried:!1,target:"",reached:!1,sourceRowIdxs:[],sourceRows:[],error:null},consoleErrors:[],elapsedMs:0},o=t.consoleErrors,n=y=>{o.length<8&&!/painted no data marks/.test(y)&&o.push(y.slice(0,300))};if(t.missingPlugins=$k(r.code).filter(y=>!lle.has(y)),t.missingPlugins.length)return t.elapsedMs=Date.now()-e,t;let i=new Proxy({},{get:(y,f)=>f==="error"||f==="warn"?(...b)=>n(b.map(A=>Wh(A)).join(" ")):()=>{}}),a=new Zm({url:"http://localhost/",width:r.width,height:r.height,console:i,settings:{disableJavaScriptFileLoading:!0,disableCSSFileLoading:!0,handleDisabledFileLoadingAsSuccess:!0,suppressInsecureJavaScriptEnvironmentWarning:!0}});mle(a);let s=ple(a),l=console.error,u=console.warn,c=console.log;console.error=(...y)=>n(y.map(f=>Wh(f)).join(" ")),console.warn=(...y)=>n(y.map(f=>Wh(f)).join(" ")),console.log=()=>{};let h=y=>{n(`uncaught: ${Wh(y?.error??y?.message)}`)};a.addEventListener("error",h);let m=qk(kC,ile,ale,sle);a.d3=m;let p=a.document.createElement("div");p.style.width=`${r.width}px`,p.style.height=`${r.height}px`,a.document.body.appendChild(p);let g=null;try{let f=Zk(r.columns,r.rows,r.binding).payloadFor(null);t.payloadRows=f.payload.rows.length,g=Qk(p,{code:r.code,d3:m,data:f.payload,options:{...r.options??{},width:r.width,height:r.height},geoKind:r.geoKind||void 0,geoProvider:()=>r.geo,fit:!1,onInvalidSentinel:A=>{t.invalid=A.reason||A.message}});let b={rows:[]};g.selection.onChange((A,P)=>{P!=="host"&&(b.rows=E7(f.rowMap,A))});try{g.render();let A=r.renderTimeoutMs??15e3;await Promise.race([g.rendered.then(()=>!1),Rj(A).then(()=>!0)])&&(t.timedOut=!0)}catch(A){let P=/could not be COMPILED|did not define render/.test(Wh(A));t.threw={phase:P?"compile":"render",message:Wh(A),...Wj(A,r.code)}}if(!t.threw&&!t.invalid&&!t.timedOut){await Lj(p,2e3);let A=N7(p);t.marks.legend=A.legendMarkCount,t.marks.containerKind=A.containerKind,t.marks.declaresNoRowMarks=A.declaresNoRowMarks;for(let w of Array.from(p.querySelectorAll(".d3-mark"))){if(w.closest(".d3-legend-mark"))continue;let T=String(w.localName||"element").toLowerCase();t.marks.byKind[T]=(t.marks.byKind[T]??0)+1}t.marks.total=A.markCount,t.blank=x7({markCount:A.markCount,rows:t.payloadRows,declaresNoRowMarks:A.declaresNoRowMarks});try{t.frame=kj(p)}catch{t.frame=null}let P=Array.from(p.querySelectorAll(".d3-mark")).find(w=>!w.closest(".d3-legend-mark")&&(w.hasAttribute("data-row-idx")||w.querySelector("[data-row-idx]")));if(P){t.click.tried=!0;let w=P.hasAttribute("data-row-idx")?P:P.querySelector("[data-row-idx]"),T=String(w.getAttribute("data-row-idx")).split(",");t.click.target=`${String(P.localName).toLowerCase()} for ${T.length===1?`row ${T[0]}`:`${T.length} rows`}`;let C=o.length;try{P.dispatchEvent(new a.MouseEvent("click",{bubbles:!0,cancelable:!0,view:a})),await Lj(p,1e3)}catch(D){t.click.error=Wh(D)}!t.click.error&&o.length>C&&(t.click.error=o[C]),b.rows.length&&(t.click.reached=!0,t.click.sourceRowIdxs=b.rows,t.click.sourceRows=b.rows.slice(0,3).map(D=>r.rows[D]).filter(Boolean))}}}catch(y){t.threw=t.threw??{phase:"render",message:Wh(y),...Wj(y,r.code)}}finally{try{g?.animation.stop()}catch{}try{g?.destroy()}catch{}a.removeEventListener("error",h),console.error=l,console.warn=u,console.log=c,s();try{await a.happyDOM.abort(),await a.happyDOM.close()}catch{}}return t.elapsedMs=Date.now()-e,t}if(!nle&&Mj&&Tj?.bicCheckChart){let r=Mj;dle(Tj.job).then(e=>r.postMessage({ok:!0,facts:e}),e=>r.postMessage({ok:!1,error:Wh(e)}))}export{mle as installLayoutEstimates,dle as renderChartCheck};
|
package/dist/index.mjs
CHANGED
|
@@ -229,7 +229,7 @@ export { render };
|
|
|
229
229
|
(and ${t.length-Ru} more refused on a count)`:"";return`This data has ${e} row(s), and ${t.length} chart type(s) were refused on a count that more rows of the same data could meet:
|
|
230
230
|
${r.join(`
|
|
231
231
|
`)}${n}
|
|
232
|
-
If these rows are a sample of a larger result, pass the whole result (every row at the chart's grain, or a csv_path): eligibility reads the row, region and category counts, so a sample can hide the chart you are looking for.`}function vk(e,a,t,r,n,o){if(!r||t!=="name"&&t!=="namePart")return"";let i=new Set(a),s=e.filter(h=>!i.has(h)),l=J2(s,r,Br,n);if(l.tier!=="namePart"&&l.tier!=="desc"||l.rows.length===0)return"";let u=l.rows.slice(0,6).map(h=>o(h)),c=l.rows.length>6?`, and ${l.rows.length-6} more`:"",d=l.tier==="desc"?"in their descriptions":"mid-word in their names";return`${l.rows.length} more eligible type(s) match "${r}" ${d} and were left out because a name matched first: ${u.join(", ")}${c}. Re-run without name_filter to compare them.`}function zu(e){let a=e.rank!==void 0?`${e.rank}. `:"\u2022 ",t=(e.isPreview?" (preview)":"")+(e.alsoWorthALook?" (something different)":""),r=e.language?` [${e.language}]`:"";return`${a}${e.name}${t}${r}${e.description?` \u2014 ${e.description}`:""}`}function Ck(e){let a=e.filter(r=>r.recommended!==!1),t=e.filter(r=>r.recommended===!1);return t.length===0?e.map(zu):["Fits this data:",...a.map(zu),"","Can also render it (the chart ontology judges these a weaker fit for this data; any of them can still be requested):",...t.map(zu)]}function sH(e){return e.map(a=>({rank:typeof a.rank=="number"&&Number.isFinite(a.rank)?a.rank:null,name:a.name,preview:a.isPreview===!0,fit:a.recommended===!1?"can-also-render":"fits",description:a.description??"",language:a.language?a.language:null,renderer:a.renderer?a.renderer:null,alsoWorthALook:a.alsoWorthALook===!0}))}var wk={order:U.enum(["fit","variety"]).describe("The order the rows are in: by fit to this data, or the picker's selection order."),eligibleCount:U.number().describe("How many chart types can render this data before any name_filter or top."),shown:U.number().describe("How many rows this answer carries."),filter:U.object({text:U.string(),tier:U.string().describe("Which match tier answered: name, namePart, desc or none.")}).nullable().describe("The name_filter applied, or null."),metering:U.string().describe("What this call cost, in the words the text block states it in."),charts:U.array(U.object({rank:U.number().nullable().describe("Position in the order asked for; null for a type the server did not rank."),name:U.string(),preview:U.boolean().describe("A newer, less proven type (still selectable by name)."),fit:U.enum(["fits","can-also-render"]).describe("fits = the chart ontology judges it a fit for this data; can-also-render = it can draw this, as a weaker fit."),description:U.string(),language:U.string().nullable(),renderer:U.string().nullable(),alsoWorthALook:U.boolean().describe("A pick drawn from below the top fits, so an offer can include something different. Never a type the fit order rates poor.")})).describe("One row per chart type, in the order issued.")};function Mk(e){let a=sH(e.rows);return{order:e.order,eligibleCount:e.eligibleCount,shown:a.length,filter:e.filter,metering:e.metering,charts:a}}var Ak=["This is RegiaBI's chart server (npm @bicharts/chart-mcp). When a request asks for RegiaBI charts, it means these tools.","Starting to build an app with charts - a Microsoft Fabric App or any other? Your FIRST step, before you scaffold anything, is get_guide (topic 'fabric-app' for a Fabric App, else 'all'): it carries the scaffold command and the setup steps.","For a
|
|
232
|
+
If these rows are a sample of a larger result, pass the whole result (every row at the chart's grain, or a csv_path): eligibility reads the row, region and category counts, so a sample can hide the chart you are looking for.`}function vk(e,a,t,r,n,o){if(!r||t!=="name"&&t!=="namePart")return"";let i=new Set(a),s=e.filter(h=>!i.has(h)),l=J2(s,r,Br,n);if(l.tier!=="namePart"&&l.tier!=="desc"||l.rows.length===0)return"";let u=l.rows.slice(0,6).map(h=>o(h)),c=l.rows.length>6?`, and ${l.rows.length-6} more`:"",d=l.tier==="desc"?"in their descriptions":"mid-word in their names";return`${l.rows.length} more eligible type(s) match "${r}" ${d} and were left out because a name matched first: ${u.join(", ")}${c}. Re-run without name_filter to compare them.`}function zu(e){let a=e.rank!==void 0?`${e.rank}. `:"\u2022 ",t=(e.isPreview?" (preview)":"")+(e.alsoWorthALook?" (something different)":""),r=e.language?` [${e.language}]`:"";return`${a}${e.name}${t}${r}${e.description?` \u2014 ${e.description}`:""}`}function Ck(e){let a=e.filter(r=>r.recommended!==!1),t=e.filter(r=>r.recommended===!1);return t.length===0?e.map(zu):["Fits this data:",...a.map(zu),"","Can also render it (the chart ontology judges these a weaker fit for this data; any of them can still be requested):",...t.map(zu)]}function sH(e){return e.map(a=>({rank:typeof a.rank=="number"&&Number.isFinite(a.rank)?a.rank:null,name:a.name,preview:a.isPreview===!0,fit:a.recommended===!1?"can-also-render":"fits",description:a.description??"",language:a.language?a.language:null,renderer:a.renderer?a.renderer:null,alsoWorthALook:a.alsoWorthALook===!0}))}var wk={order:U.enum(["fit","variety"]).describe("The order the rows are in: by fit to this data, or the picker's selection order."),eligibleCount:U.number().describe("How many chart types can render this data before any name_filter or top."),shown:U.number().describe("How many rows this answer carries."),filter:U.object({text:U.string(),tier:U.string().describe("Which match tier answered: name, namePart, desc or none.")}).nullable().describe("The name_filter applied, or null."),metering:U.string().describe("What this call cost, in the words the text block states it in."),charts:U.array(U.object({rank:U.number().nullable().describe("Position in the order asked for; null for a type the server did not rank."),name:U.string(),preview:U.boolean().describe("A newer, less proven type (still selectable by name)."),fit:U.enum(["fits","can-also-render"]).describe("fits = the chart ontology judges it a fit for this data; can-also-render = it can draw this, as a weaker fit."),description:U.string(),language:U.string().nullable(),renderer:U.string().nullable(),alsoWorthALook:U.boolean().describe("A pick drawn from below the top fits, so an offer can include something different. Never a type the fit order rates poor.")})).describe("One row per chart type, in the order issued.")};function Mk(e){let a=sH(e.rows);return{order:e.order,eligibleCount:e.eligibleCount,shown:a.length,filter:e.filter,metering:e.metering,charts:a}}var Ak=["This is RegiaBI's chart server (npm @bicharts/chart-mcp); it builds charts from a table you hold. When a request asks for RegiaBI charts, it means these tools.","Starting to build an app with charts - a Microsoft Fabric App or any other? Your FIRST step, before you scaffold anything, is get_guide (topic 'fabric-app' for a Fabric App, else 'all'): it carries the scaffold command and the setup steps.","For a Fabric App over a semantic model, scaffold from Rayfin's dataapp template (npx -y @microsoft/create-rayfin --template dataapp), not blankapp; run setup_fabric_app once, then query_semantic_model runs a chart's DAX, saves every row and profiles it in ONE call.","Asked which charts suit the data? Answer from these tools, not from general knowledge: list_eligible_charts for a table you hold; over a Fabric App's semantic model, suggest_charts does it in ONE call, querying the model's natural views and returning what fits each.","Five rules for charts that fit on the first try:","1. Pass the chart's WHOLE result at its grain, not a sample: what fits depends on its counts. Use csv_path when long.","2. Give columns the plain names your app renders with (rename Table[Column] first), unchanged at render time.","3. To pick a type, call list_eligible_charts on that data first and choose what answers the question as asked. Pass chart_type only for a type the person named; else leave it unset and the engine chooses. Where a chart has controls drawn inside the chart, build no input beside it.","4. Host the code with @bicharts/chart-host. With out_dir, a D3 chart comes with chart.component.tsx beside chart.js, wired to generate_chart's binding: import it rather than writing one, and never hand-build __rowIdx__ or __geo* columns.","5. Use `prompt` for what the chart shows; selection, cross-filtering, sizing and theming are the host's: filter with useBicFilter + selects, read a chart's sliders with useBicControls + controls (@bicharts/chart-host/react). Never write a select handler, toggle or clear.","The guide is also skills/bic-charts/SKILL.md."].join(`
|
|
233
233
|
`);import{readFileSync as _k}from"node:fs";import{dirname as lH,join as Pk,resolve as uH}from"node:path";import{fileURLToPath as cH}from"node:url";var Uk=["fabric-app","all","chart-shapes"];function dH(){return uH(lH(cH(import.meta.url)),"..","skills","bic-charts")}function hH(e){let t=e.replace(/^---[\s\S]*?\n---\s*\n/,"").split(/\n(?=## )/),r=new Map,n="";for(let o of t){let i=/^## (\w+)\./.exec(o);i?r.set(i[1],o.trim()):n+=o}return{preamble:n.trim(),byLabel:r}}function Tk(e="fabric-app",a=dH()){if(e==="chart-shapes")return _k(Pk(a,"CHART-SHAPES.md"),"utf-8");let t=_k(Pk(a,"SKILL.md"),"utf-8");if(e==="all")return t.replace(/^---[\s\S]*?\n---\s*\n/,"");let{preamble:r,byLabel:n}=hH(t),o=(n.get("3")??"").split(/\n(?=### Blazor)/)[0].trim();return[r,n.get("0"),n.get("2"),o,n.get("3a"),n.get("4")].filter(i=>!!i&&i.length>0).join(`
|
|
234
234
|
|
|
235
235
|
`)}import{createServer as UH}from"node:http";import{Http2ServerRequest as Ik,constants as pH}from"http2";import{Http2ServerRequest as Iu}from"http2";import{Readable as Rk}from"stream";import CH from"crypto";var qa=class extends Error{constructor(e,a){super(e,a),this.name="RequestError"}},mH=e=>e instanceof qa?e:new qa(e.message,{cause:e}),gH=global.Request,u7=class extends gH{constructor(e,a){typeof e=="object"&&f8 in e&&(e=e[f8]()),typeof a?.body?.getReader<"u"&&(a.duplex??="half"),super(e,a)}},fH=e=>{let a=[],t=e.rawHeaders;for(let r=0;r<t.length;r+=2){let{[r]:n,[r+1]:o}=t;n.charCodeAt(0)!==58&&a.push([n,o])}return new Headers(a)},Ek=Symbol("wrapBodyStream"),yH=(e,a,t,r,n)=>{let o={method:e,headers:t,signal:n.signal};if(e==="TRACE"){o.method="GET";let i=new u7(a,o);return Object.defineProperty(i,"method",{get(){return"TRACE"}}),i}if(!(e==="GET"||e==="HEAD"))if("rawBody"in r&&r.rawBody instanceof Buffer)o.body=new ReadableStream({start(i){i.enqueue(r.rawBody),i.close()}});else if(r[Ek]){let i;o.body=new ReadableStream({async pull(s){try{i||=Rk.toWeb(r).getReader();let{done:l,value:u}=await i.read();l?s.close():s.enqueue(u)}catch(l){s.error(l)}}})}else o.body=Rk.toWeb(r);return new u7(a,o)},f8=Symbol("getRequestCache"),xk=Symbol("requestCache"),Cn=Symbol("incomingKey"),wn=Symbol("urlKey"),NH=Symbol("headersKey"),g8=Symbol("abortControllerKey"),SH=Symbol("getAbortController"),c7={get method(){return this[Cn].method||"GET"},get url(){return this[wn]},get headers(){return this[NH]||=fH(this[Cn])},[SH](){return this[f8](),this[g8]},[f8](){return this[g8]||=new AbortController,this[xk]||=yH(this.method,this[wn],this.headers,this[Cn],this[g8])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(e=>{Object.defineProperty(c7,e,{get(){return this[f8]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(c7,e,{value:function(){return this[f8]()[e]()}})});Object.defineProperty(c7,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,a,t){let r={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[xk]};return`Request (lightweight) ${t(r,{...a,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(c7,u7.prototype);var bH=(e,a)=>{let t=Object.create(c7);t[Cn]=e;let r=e.url||"";if(r[0]!=="/"&&(r.startsWith("http://")||r.startsWith("https://"))){if(e instanceof Iu)throw new qa("Absolute URL for :path is not allowed in HTTP/2");try{let s=new URL(r);t[wn]=s.href}catch(s){throw new qa("Invalid absolute URL",{cause:s})}return t}let n=(e instanceof Iu?e.authority:e.headers.host)||a;if(!n)throw new qa("Missing host header");let o;if(e instanceof Iu){if(o=e.scheme,!(o==="http"||o==="https"))throw new qa("Unsupported scheme")}else o=e.socket&&e.socket.encrypted?"https":"http";let i=new URL(`${o}://${n}${r}`);if(i.hostname.length!==n.length&&i.hostname!==n.replace(/:\d+$/,""))throw new qa("Invalid host header");return t[wn]=i.href,t},xu=Symbol("responseCache"),m8=Symbol("getResponseCache"),Ja=Symbol("cache"),Ou=global.Response,y8=class jk{#a;#e;[m8](){return delete this[Ja],this[xu]||=new Ou(this.#a,this.#e)}constructor(a,t){let r;if(this.#a=a,t instanceof jk){let n=t[xu];if(n){this.#e=n,this[m8]();return}else this.#e=t.#e,r=new Headers(t.#e.headers)}else this.#e=t;(typeof a=="string"||typeof a?.getReader<"u"||a instanceof Blob||a instanceof Uint8Array)&&(this[Ja]=[t?.status||200,a,r||t?.headers])}get headers(){let a=this[Ja];return a?(a[2]instanceof Headers||(a[2]=new Headers(a[2]||{"content-type":"text/plain; charset=UTF-8"})),a[2]):this[m8]().headers}get status(){return this[Ja]?.[0]??this[m8]().status}get ok(){let a=this.status;return a>=200&&a<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(y8.prototype,e,{get(){return this[m8]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(y8.prototype,e,{value:function(){return this[m8]()[e]()}})});Object.defineProperty(y8.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,a,t){let r={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[xu]};return`Response (lightweight) ${t(r,{...a,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(y8,Ou);Object.setPrototypeOf(y8.prototype,Ou.prototype);async function WH(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function Lk(e,a,t){let r=s=>{e.cancel(s).catch(()=>{})};return a.on("close",r),a.on("error",r),(t??e.read()).then(i,n),e.closed.finally(()=>{a.off("close",r),a.off("error",r)});function n(s){s&&a.destroy(s)}function o(){e.read().then(i,n)}function i({done:s,value:l}){try{if(s)a.end();else if(!a.write(l))a.once("drain",o);else return e.read().then(i,n)}catch(u){n(u)}}}function kH(e,a){if(e.locked)throw new TypeError("ReadableStream is locked.");return a.destroyed?void 0:Lk(e.getReader(),a)}var ju=e=>{let a={};e instanceof Headers||(e=new Headers(e??void 0));let t=[];for(let[r,n]of e)r==="set-cookie"?t.push(n):a[r]=n;return t.length>0&&(a["set-cookie"]=t),a["content-type"]??="text/plain; charset=UTF-8",a},vH="x-hono-already-sent";typeof global.crypto>"u"&&(global.crypto=CH);var Du=Symbol("outgoingEnded"),zk=Symbol("incomingDraining"),wH=500,MH=64*1024*1024,Eu=e=>{let a=e;if(e.destroyed||a[zk])return;if(a[zk]=!0,e instanceof Ik){try{e.stream?.close?.(pH.NGHTTP2_NO_ERROR)}catch{}return}let t=0,r=()=>{clearTimeout(o),e.off("data",i),e.off("end",r),e.off("error",r)},n=()=>{r();let s=e.socket;s&&!s.destroyed&&s.destroySoon()},o=setTimeout(n,wH);o.unref?.();let i=s=>{t+=s.length,t>MH&&n()};e.on("data",i),e.on("end",r),e.on("error",r),e.resume()},AH=()=>new Response(null,{status:400}),Ok=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),Lu=(e,a)=>{let t=e instanceof Error?e:new Error("unknown error",{cause:e});t.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),a.headersSent||a.writeHead(500,{"Content-Type":"text/plain"}),a.end(`Error: ${t.message}`),a.destroy(t))},Dk=e=>{"flushHeaders"in e&&e.writable&&e.flushHeaders()},Fk=async(e,a)=>{let[t,r,n]=e[Ja],o=!1;if(!n)n={"content-type":"text/plain; charset=UTF-8"};else if(n instanceof Headers)o=n.has("content-length"),n=ju(n);else if(Array.isArray(n)){let i=new Headers(n);o=i.has("content-length"),n=ju(i)}else for(let i in n)if(i.length===14&&i.toLowerCase()==="content-length"){o=!0;break}o||(typeof r=="string"?n["Content-Length"]=Buffer.byteLength(r):r instanceof Uint8Array?n["Content-Length"]=r.byteLength:r instanceof Blob&&(n["Content-Length"]=r.size)),a.writeHead(t,n),typeof r=="string"||r instanceof Uint8Array?a.end(r):r instanceof Blob?a.end(new Uint8Array(await r.arrayBuffer())):(Dk(a),await kH(r,a)?.catch(i=>Lu(i,a))),a[Du]?.()},_H=e=>typeof e.then=="function",PH=async(e,a,t={})=>{if(_H(e))if(t.errorHandler)try{e=await e}catch(n){let o=await t.errorHandler(n);if(!o)return;e=o}else e=await e.catch(Ok);if(Ja in e)return Fk(e,a);let r=ju(e.headers);if(e.body){let n=e.body.getReader(),o=[],i=!1,s;if(r["transfer-encoding"]!=="chunked"){let l=2;for(let u=0;u<l;u++){s||=n.read();let c=await WH(s).catch(d=>{console.error(d),i=!0});if(!c){if(u===1){await new Promise(d=>setTimeout(d)),l=3;continue}break}if(s=void 0,c.value&&o.push(c.value),c.done){i=!0;break}}i&&!("content-length"in r)&&(r["content-length"]=o.reduce((u,c)=>u+c.length,0))}a.writeHead(e.status,r),o.forEach(l=>{a.write(l)}),i?a.end():(o.length===0&&Dk(a),await Lk(n,a,s))}else r[vH]||(a.writeHead(e.status,r),a.end());a[Du]?.()},Fu=(e,a={})=>{let t=a.autoCleanupIncoming??!0;return a.overrideGlobalObjects!==!1&&global.Request!==u7&&(Object.defineProperty(global,"Request",{value:u7}),Object.defineProperty(global,"Response",{value:y8})),async(r,n)=>{let o,i;try{i=bH(r,a.hostname);let s=!t||r.method==="GET"||r.method==="HEAD";if(s||(r[Ek]=!0,r.on("end",()=>{s=!0}),r instanceof Ik&&(n[Du]=()=>{s||setTimeout(()=>{s||setTimeout(()=>{Eu(r)})})}),n.on("finish",()=>{s||Eu(r)})),n.on("close",()=>{i[g8]&&(r.errored?i[g8].abort(r.errored.toString()):n.writableFinished||i[g8].abort("Client connection prematurely closed.")),s||setTimeout(()=>{s||setTimeout(()=>{Eu(r)})})}),o=e(i,{incoming:r,outgoing:n}),Ja in o)return Fk(o,n)}catch(s){if(o)return Lu(s,n);if(a.errorHandler){if(o=await a.errorHandler(i?s:mH(s)),!o)return}else i?o=Ok(s):o=AH()}try{return await PH(o,n,a)}catch(s){return Lu(s,n)}}};var Mn=class{constructor(a={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=a.sessionIdGenerator,this._enableJsonResponse=a.enableJsonResponse??!1,this._eventStore=a.eventStore,this._onsessioninitialized=a.onsessioninitialized,this._onsessionclosed=a.onsessionclosed,this._allowedHosts=a.allowedHosts,this._allowedOrigins=a.allowedOrigins,this._enableDnsRebindingProtection=a.enableDnsRebindingProtection??!1,this._retryInterval=a.retryInterval}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}createJsonErrorResponse(a,t,r,n){let o={code:t,message:r};return n?.data!==void 0&&(o.data=n.data),new Response(JSON.stringify({jsonrpc:"2.0",error:o,id:null}),{status:a,headers:{"Content-Type":"application/json",...n?.headers}})}validateRequestHeaders(a){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let t=a.headers.get("host");if(!t||!this._allowedHosts.includes(t)){let r=`Invalid Host header: ${t}`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(403,-32e3,r)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let t=a.headers.get("origin");if(t&&!this._allowedOrigins.includes(t)){let r=`Invalid Origin header: ${t}`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(403,-32e3,r)}}}}async handleRequest(a,t){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let r=this.validateRequestHeaders(a);if(r)return r;switch(a.method){case"POST":return this.handlePostRequest(a,t);case"GET":return this.handleGetRequest(a);case"DELETE":return this.handleDeleteRequest(a);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(a,t,r,n){if(!this._eventStore||n<"2025-11-25")return;let o=await this._eventStore.storeEvent(r,{}),i=`id: ${o}
|
|
@@ -244,8 +244,8 @@ data:
|
|
|
244
244
|
`),o+=`data: ${JSON.stringify(r)}
|
|
245
245
|
|
|
246
246
|
`,a.enqueue(t.encode(o)),!0}catch(o){return this.onerror?.(o),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(a,t){try{let r=a.headers.get("accept");if(!r?.includes("application/json")||!r.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let n=a.headers.get("content-type");if(!n||!n.includes("application/json"))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let o={headers:Object.fromEntries(a.headers.entries()),url:new URL(a.url)},i;if(t?.parsedBody!==void 0)i=t.parsedBody;else try{i=await a.json()}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let s;try{Array.isArray(i)?s=i.map(y=>O8.parse(y)):s=[O8.parse(i)]}catch{return this.onerror?.(new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}let l=s.some(Y6);if(l){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(s.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!l){let y=this.validateSession(a);if(y)return y;let N=this.validateProtocolVersion(a);if(N)return N}if(!s.some(P4)){for(let y of s)this.onmessage?.(y,{authInfo:t?.authInfo,requestInfo:o});return new Response(null,{status:202})}let c=crypto.randomUUID(),d=s.find(y=>Y6(y)),h=d?d.params.protocolVersion:a.headers.get("mcp-protocol-version")??Gd;if(this._enableJsonResponse)return new Promise(y=>{this._streamMapping.set(c,{resolveJson:y,cleanup:()=>{this._streamMapping.delete(c)}});for(let N of s)P4(N)&&this._requestToStreamMapping.set(N.id,c);for(let N of s)this.onmessage?.(N,{authInfo:t?.authInfo,requestInfo:o})});let m=new TextEncoder,p,g=new ReadableStream({start:y=>{p=y},cancel:()=>{this._streamMapping.delete(c)}}),f={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};this.sessionId!==void 0&&(f["mcp-session-id"]=this.sessionId);for(let y of s)P4(y)&&(this._streamMapping.set(c,{controller:p,encoder:m,cleanup:()=>{this._streamMapping.delete(c);try{p.close()}catch{}}}),this._requestToStreamMapping.set(y.id,c));await this.writePrimingEvent(p,m,c,h);for(let y of s){let N,W;P4(y)&&this._eventStore&&h>="2025-11-25"&&(N=()=>{this.closeSSEStream(y.id)},W=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(y,{authInfo:t?.authInfo,requestInfo:o,closeSSEStream:N,closeStandaloneSSEStream:W})}return new Response(g,{status:200,headers:f})}catch(r){return this.onerror?.(r),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(r)})}}async handleDeleteRequest(a){let t=this.validateSession(a);if(t)return t;let r=this.validateProtocolVersion(a);return r||(await Promise.resolve(this._onsessionclosed?.(this.sessionId)),await this.close(),new Response(null,{status:200}))}validateSession(a){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let t=a.headers.get("mcp-session-id");if(!t)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(t!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(a){let t=a.headers.get("mcp-protocol-version");if(t!==null&&!pt.includes(t))return this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${t} (supported versions: ${pt.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${t} (supported versions: ${pt.join(", ")})`)}async close(){this._streamMapping.forEach(({cleanup:a})=>{a()}),this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}closeSSEStream(a){let t=this._requestToStreamMapping.get(a);if(!t)return;let r=this._streamMapping.get(t);r&&r.cleanup()}closeStandaloneSSEStream(){let a=this._streamMapping.get(this._standaloneSseStreamId);a&&a.cleanup()}async send(a,t){let r=t?.relatedRequestId;if((i4(a)||mt(a))&&(r=a.id),r===void 0){if(i4(a)||mt(a))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let i;this._eventStore&&(i=await this._eventStore.storeEvent(this._standaloneSseStreamId,a));let s=this._streamMapping.get(this._standaloneSseStreamId);if(s===void 0)return;s.controller&&s.encoder&&this.writeSSEEvent(s.controller,s.encoder,a,i);return}let n=this._requestToStreamMapping.get(r);if(!n)throw new Error(`No connection established for request ID: ${String(r)}`);let o=this._streamMapping.get(n);if(!this._enableJsonResponse&&o?.controller&&o?.encoder){let i;this._eventStore&&(i=await this._eventStore.storeEvent(n,a)),this.writeSSEEvent(o.controller,o.encoder,a,i)}if(i4(a)||mt(a)){this._requestResponseMap.set(r,a);let i=Array.from(this._requestToStreamMapping.entries()).filter(([l,u])=>u===n).map(([l])=>l);if(i.every(l=>this._requestResponseMap.has(l))){if(!o)throw new Error(`No connection established for request ID: ${String(r)}`);if(this._enableJsonResponse&&o.resolveJson){let l={"Content-Type":"application/json"};this.sessionId!==void 0&&(l["mcp-session-id"]=this.sessionId);let u=i.map(c=>this._requestResponseMap.get(c));u.length===1?o.resolveJson(new Response(JSON.stringify(u[0]),{status:200,headers:l})):o.resolveJson(new Response(JSON.stringify(u),{status:200,headers:l}))}else o.cleanup();for(let l of i)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l)}}}};var An=class{constructor(a={}){this._requestContext=new WeakMap,this._webStandardTransport=new Mn(a),this._requestListener=Fu(async t=>{let r=this._requestContext.get(t);return this._webStandardTransport.handleRequest(t,{authInfo:r?.authInfo,parsedBody:r?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(a){this._webStandardTransport.onclose=a}get onclose(){return this._webStandardTransport.onclose}set onerror(a){this._webStandardTransport.onerror=a}get onerror(){return this._webStandardTransport.onerror}set onmessage(a){this._webStandardTransport.onmessage=a}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(a,t){return this._webStandardTransport.send(a,t)}async handleRequest(a,t,r){let n=a.auth;await Fu(async i=>this._webStandardTransport.handleRequest(i,{authInfo:n,parsedBody:r}),{overrideGlobalObjects:!1})(a,t)}closeSSEStream(a){this._webStandardTransport.closeSSEStream(a)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};var TH=16*1024*1024;function Bk(e,a){let t=i=>{let s=e.indexOf(i);return s>=0&&s+1<e.length?e[s+1]:void 0},r=e.includes("--http")||/^(1|true|yes|on)$/i.test((a.BIC_MCP_HOSTED??"").trim()),n=t("--port")??a.BIC_MCP_HTTP_PORT??"8799",o=Number(n);if(!Number.isInteger(o)||o<0||o>65535)throw new Error(`--port must be a whole number from 0 to 65535 (got "${n}").`);return{http:r,host:t("--host")??"127.0.0.1",port:o}}function _n(e,a,t,r={}){if(e.headersSent){e.end();return}e.writeHead(a,{"Content-Type":"application/json","Cache-Control":"no-store",...r}),e.end(JSON.stringify(t))}function d7(e,a,t,r,n={}){_n(e,a,{jsonrpc:"2.0",error:{code:t,message:r},id:null},n)}function RH(e,a,t){return new Promise((r,n)=>{let o=[],i=0,s=!1;e.on("data",l=>{if(!s){if(i+=l.length,i>t){s=!0,o.length=0,d7(a,413,-32600,`The request is larger than this server accepts (${Math.floor(t/1048576)} MB). Send the table at the chart's grain - aggregated - or with fewer columns.`,{Connection:"close"}),r(null);return}o.push(l)}}),e.on("end",()=>{s||r(Buffer.concat(o).toString("utf-8"))}),e.on("error",n)})}async function zH(e,a,t){let r=Wb(e.headers.authorization);if(!r){d7(a,401,-32001,"Sign in to use this chart server: connect to it from your app, which sends your account's access token with each request.",{"WWW-Authenticate":"Bearer"});return}let n=await RH(e,a,t.maxBodyBytes??TH);if(n===null)return;let o;try{o=JSON.parse(n)}catch{d7(a,400,-32700,"Parse error: the request body isn't JSON.");return}let i=t.newServer(),s=new An({sessionIdGenerator:void 0});a.on("close",()=>{s.close().catch(()=>{}),i.close().catch(()=>{})}),await i.connect(s);let l=kb(e.headers[Hl.toLowerCase()]);await Nb({accessToken:r,...l?{clientIp:l}:{}},()=>s.handleRequest(e,a,o))}function $k(e){let a=e.log??(r=>{process.stderr.write(r+`
|
|
247
|
-
`)}),t=UH((r,n)=>{let o=new URL(r.url??"/","http://localhost").pathname;if(o==="/healthz"){if(r.method!=="GET"&&r.method!=="HEAD"){_n(n,405,{error:"Use GET."},{Allow:"GET"});return}_n(n,200,{ok:!0,server:"bic-chart",version:e.version});return}if(o!=="/mcp"){_n(n,404,{error:"Not found. The MCP endpoint is /mcp."});return}if(r.method!=="POST"){d7(n,405,-32e3,"Method not allowed: this server is stateless, so it takes POST only.",{Allow:"POST"});return}zH(r,n,e).catch(i=>{a(`[bic-chart http] request failed (${i?.name??"Error"})`),d7(n,500,-32603,"Internal error: the chart server couldn't handle this request. Try again.")})});return new Promise((r,n)=>{t.once("error",n),t.listen(e.port,e.host,()=>{t.off("error",n),r(t)})})}var Kk=["assess_data_shape","list_eligible_charts","generate_chart","get_guide","preview_request"],h7="This hosted server receives your table, profiles it in memory and sends only the profile to generation; rows aren't stored or logged.",Vk={csv_path:"this hosted server can't read files on your machine, so pass the table as data or csv_text",project_dir:"this hosted server can't see your project folder, so pass language or renderer instead",out_dir:"this hosted server returns the chart inline; it can't write to your machine",preview_html:"this hosted server returns the chart inline; it can't write to your machine"},Un=e=>`Not accepted by this hosted server: ${Vk[e]}.`,Pn={csv_path:U.string().optional().describe(Un("csv_path")),project_dir:U.string().optional().describe(Un("project_dir"))},Hk={out_dir:U.string().optional().describe(Un("out_dir")),preview_html:U.boolean().optional().describe(Un("preview_html"))},Gk=U.enum(["javascript","typescript","python",""]).optional(),Xk=["csv_path","project_dir","out_dir","preview_html"],Zk={assess_data_shape:{description:`Profile a dataset: per-column types, cardinality, ranges, measure/dimension roles, temporal/ordinal detection, and cross-column signals (nesting, shared values, association) - the same measurement engine the BIC Power BI visual uses before generating a chart. Pass the table as data ({columns, rows}) or csv_text. ${h7} This tool sends nothing on.`,inputs:{csv_path:Pn.csv_path},refuse:["csv_path"]},list_eligible_charts:{description:"The AUTHORITATIVE list of chart types that can render this dataset - the server's own eligibility engine, NOT a guess. Pass the table as data ({columns, rows}) or csv_text. "+h7+" Ranked for JavaScript (D3) unless you pass language ('python' ranks Plotly and matplotlib) or renderer ('D3'/'PLOTLY'/... for one renderer, '' for every renderer). No model runs, but the call is METERED: free within a generous hourly allowance, then usage credits per call.",inputs:{...Pn,language:Gk.describe("Project source language: javascript/typescript ranks D3 and Vega, python ranks Plotly and matplotlib. Omit for JavaScript; `renderer`, when given, overrides it.")},refuse:["csv_path","project_dir"]},generate_chart:{description:`Generate ready-to-render chart code for a dataset: the backend picks a suitable chart type (or honors chart_type) and returns code that has passed its eligibility gates and quality checks. Pass the table as data ({columns, rows}) or csv_text. ${h7} The code and the render-ready data come back inline in the reply; this server writes no files. JavaScript (D3) unless you pass language or renderer. The D3 code is a portable render(container, data, options) function meant to be MERGED into your own app; an integration contract describes exactly how to call it. A generation uses your account's credits.`,inputs:{...Pn,...Hk,language:Gk.describe("Project source language: javascript/typescript generates D3 (the renderer @bicharts/chart-host draws), python lets the backend pick within Plotly/matplotlib. Omit for JavaScript (D3); `renderer`, when given, overrides it.")},refuse:Xk},preview_request:{description:`Shows exactly what a chart generation would send on for these arguments - the measured shape of your data (column names, types, counts, ranges), the settings, and whether any sample rows travel - with the credentials removed. It sends nothing on and costs nothing. ${h7} Takes the same arguments as a generation.`,inputs:{...Pn,...Hk},refuse:Xk},get_guide:{description:"How to build an app with these charts, from the guide this server ships. Free, and it sends nothing on. topic 'fabric-app' (the default) is what a Microsoft Fabric App on the Rayfin data app template needs; 'all' is the whole guide, including Blazor; 'chart-shapes' lists every chart type with the columns, limits and renderers it needs. Some steps the guide describes, the ones that write into a project, need the local server (npx -y @bicharts/chart-mcp) rather than this one."}};function qk(e,a){let t=(a??[]).filter(r=>{let n=e?.[r];return n!=null&&n!==!1&&n!==""});return t.length===0?null:t.map(r=>`${r} isn't accepted here: ${Vk[r]}.`).join(" ")}var Jk=["This is RegiaBI's hosted chart server. When a request asks for RegiaBI charts, it means these tools.",h7+" It can't read or write files on your machine: pass each table as data ({columns, rows}) or csv_text, and the chart comes back inline.","Asked which charts suit the data? Answer from list_eligible_charts, not from general knowledge.","Five rules for charts that fit on the first try:","1. Pass the chart's WHOLE result at its grain, not a sample: what fits depends on its counts.","2. Give columns the plain names your app renders with (rename Table[Column] first), unchanged at render time.","3.
|
|
248
|
-
`);function S8(e,a){return fn(e,a).dir??Ya(e??process.cwd())}var $u="0.6.85",Qk=[],Rn=null,k3={registerTool(e,a,t){Qk.push({name:e,config:a,cb:t})},get server(){if(!Rn)throw new Error("The local server isn't running in this process.");return Rn.server}};function Yk(e){let a=e?new M2({name:"bic-chart",version:$u},{instructions:Jk}):new M2({name:"bic-chart",version:$u},{instructions:Ak});e||(a.server.registerCapabilities({logging:{}}),sb(t=>{a.server.sendLoggingMessage({level:"notice",logger:"sign-in",data:t}).catch(()=>{})}));for(let t of Qk){if(e&&!Kk.includes(t.name))continue;let r=e?Zk[t.name]:void 0,n={...t.config,...r?{description:r.description,inputSchema:{...t.config.inputSchema,...r.inputs??{}}}:{},annotations:{title:t.config.title,...t.config.annotations}},o=r?.refuse?(i,s)=>{let l=qk(i,r.refuse);return l?{isError:!0,content:[{type:"text",text:l}]}:t.cb(i,s)}:t.cb;a.registerTool(t.name,n,o)}return a}var p7="2026-10-09T18:29:10Z src:6deb179188f3 (35 files)",Hu="@bicharts/chart-host@0.6.85, @bicharts/shape-core@0.6.85",IH=U.object({columns:U.array(U.object({name:U.string(),dataType:U.enum(["String","Integer","Decimal","DateTime"]).optional().describe("Known type (DAX/semantic-model callers have it); omit to infer from values."),isMeasure:U.boolean().optional().describe("Known measure/dimension role; omit to apply the numeric-non-identifier heuristic. A semantic-model caller should set this."),format:U.string().optional().describe('Format string from the model (e.g. "$#,##0") \u2192 modelFormat.'),description:U.string().optional().describe("Column description from the model \u2192 modelDesc.")})).min(1),rows:U.array(U.union([U.array(U.any()),U.record(U.string(),U.any())])).min(1).describe("Rows as positional arrays aligned to columns, OR objects keyed by column name.")}).describe("A pre-typed {columns, rows} table (DAX query results, dataframe, arrow). Use INSTEAD of csv_path/csv_text."),Gu={csv_path:U.string().optional().describe("Path to a CSV file (header row required)."),csv_text:U.string().optional().describe("Inline CSV text (alternative to csv_path)."),data:IH.optional().describe("A pre-typed {columns, rows} table \u2014 the shape a Fabric DAX query / dataframe already has. Alternative to csv_path/csv_text; when columns carry isMeasure/format/description the shape matches PBI fidelity with no guessing."),measures:U.array(U.string()).optional().describe("Columns to treat as MEASURES (the PBI 'Values' well \u2014 fields the chart aggregates). Numeric non-identifier columns are measures by default."),dimensions:U.array(U.string()).optional().describe("Columns to treat as DIMENSIONS (a PBI category/axis well \u2014 fields to group/break by). Use for numeric codes/years that should NOT be aggregated."),formats:U.record(U.string(),U.string()).optional().describe(`Per-column number/date FORMAT STRING (e.g. {"Revenue":"$#,##0","Margin":"0.0%"}). PBI supplies these from its model; a CSV can't, so provide them to steer number formatting.`),descriptions:U.record(U.string(),U.string()).optional().describe("Per-column human DESCRIPTION \u2014 gives the model semantic context the bare column name lacks."),group_by:U.array(U.string()).optional().describe("Columns that are the PRIMARY series/breakdown (the PBI 'Group by' well); the backend leads the visualization with these."),non_additive:U.array(U.string()).optional().describe("MEASURE columns that must NOT be summed (a ratio/average/rate \u2014 use mean, never stack). Usually auto-detected; this is an authoritative override."),privacy_level:U.enum(["0","10","20","30"]).optional().describe("How much detail to compute/share: 0 names only, 10 +counts, 20 +detailed stats (default), 30 +obfuscated sample rows."),culture:U.string().regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/).max(35).optional().describe("The caller's language and region as a BCP 47 tag such as 'de-DE', 'fr' or 'ja-JP'. Default 'en-US'. It is the language the chart's own text is written in (titles, axis labels, legends, notes), and it breaks the tie when a CSV's numbers or dates are ambiguous: 12.500 as twelve thousand five hundred or twelve and a half, 05.03.2024 as 5 March or 3 May. Set it from the end user's locale when you know it; it does not translate the data.")};function N8(e){return{measures:e.measures,dimensions:e.dimensions,formats:e.formats,descriptions:e.descriptions,groupBy:e.group_by,nonAdditive:e.non_additive,privacyLevel:e.privacy_level??"20",locale:e.culture||void 0}}function In(e){if(e.data)return by(e.data.columns,e.data.rows,N8(e));if(e.csv_text)return H4(e.csv_text,N8(e));if(e.csv_path)return H4(m7(Ya(e.csv_path),"utf-8"),N8(e));throw new Error("Provide one of: data ({columns, rows}), csv_text, or csv_path.")}k3.registerTool("assess_data_shape",{title:"Assess data shape",description:"Profile a dataset locally (no data leaves the machine): per-column types, cardinality, ranges, measure/dimension roles, temporal/ordinal detection, and cross-column signals (nesting, shared values, association). This is the same measurement engine the BIC Power BI visual uses before generating a chart.",inputSchema:Gu,annotations:{readOnlyHint:!0,openWorldHint:!1}},async e=>{let a=In(e),t={totalRows:a.totalRows,leafCardinality:a.index.getLeafCardinality(),columns:a.shape},r=f4()?null:jb(process.env);return{content:[{type:"text",text:JSON.stringify(t,null,2)},...r?[{type:"text",text:r}]:[]]}});k3.registerTool("get_guide",{title:"Read the build guide",description:"How to build an app with these charts, from the guide this package ships. Local and free: no network, no credentials. topic 'fabric-app' (the default) is what a Microsoft Fabric App on the Rayfin data app template needs: what to pull, generating, wiring in React, the Fabric App section and the time-savers. 'all' is the whole guide, including Blazor. 'chart-shapes' lists every chart type with the columns, limits and renderers it needs.",inputSchema:{topic:U.enum(Uk).optional().describe("'fabric-app' (default), 'all', or 'chart-shapes'.")},annotations:{readOnlyHint:!0,openWorldHint:!1}},async e=>{try{return{content:[{type:"text",text:Tk(e.topic??"fabric-app")}]}}catch(a){return{isError:!0,content:[{type:"text",text:`The guide could not be read from this package (${a?.message??a}). It is also published as skills/bic-charts/SKILL.md inside @bicharts/chart-mcp on npm.`}]}}});k3.registerTool("list_eligible_charts",{title:"List eligible chart types",description:"The AUTHORITATIVE list of chart types that can render this dataset \u2014 the server's own eligibility engine, NOT a local guess. Profiles the data locally, then sends that profile to the backend. NO LLM in the loop, but this is a NETWORK call and it is METERED \u2014 see the licensing note below. By default the tool DETECTS the project's language (JS/TS vs Python from the working dir) and returns the charts for THAT language, SCOPED and ordered by how well each type fits this data (best first; `order: 'variety'` favors newer and less-common types instead), each tagged with its source language and renderer. Pass `language` ('javascript'|'python') to force it, or `renderer` ('D3'/'PLOTLY'/\u2026) to rank one specific renderer, or renderer '' for the full renderer-agnostic eligibility across ALL renderers (also ranked, by chart type alone, with no renderer/language tag). If the language can't be auto-detected and none is given, the tool asks you to specify one. Needs an account: eligibility IS the engine, so programmatic access to it is licensed. With nothing configured, the first call opens a browser sign-in, waits for it and then answers (a license key in the environment is the alternative for a machine with no browser). Free within a generous hourly allowance; beyond it each call draws usage credits. The reply carries a text block and a structured table: one row per chart type with its rank, name, preview flag, fit verdict, description, language and renderer. Rows flagged alsoWorthALook are a few picks from below the top fits, drawn so an offer can include something different; the fit order itself never changes.",inputSchema:{...Gu,language:U.enum(["javascript","typescript","python",""]).optional().describe("Project source language \u2192 the server ranks across that language's renderers (javascript/typescript = D3/Vega, python = Plotly/matplotlib). Omit to AUTO-DETECT from the working dir; `renderer` (if given) overrides this."),project_dir:U.string().optional().describe("Directory to auto-detect the project language from (default: the folder setup_fabric_app used, else the working directory or the one project folder directly inside it)."),renderer:U.enum(["D3","PLOTLY","PYMATPLOT","VEGA",""]).optional().describe("Force a specific renderer (overrides `language`): a concrete renderer ranks that renderer's charts; '' = the full renderer-agnostic eligibility (all renderers, ranked by chart type alone). Omit to use `language`/auto-detection."),level_of_detail:U.enum(["High","Medium","Low",""]).optional().describe("The user's own preference for how much of the data to see, as they've stated it. 'High' = every observation as its own mark, 'Medium' = every row shown as a distribution, 'Low' = one mark per category. Ranks this list the same way a generation would. Unset when they haven't stated one; unset changes nothing."),name_filter:U.string().optional().describe("Show only chart types matching this text (the same matcher the Power BI and Excel chart-type lists use). Three tiers, first non-empty one wins outright: the term starting a WORD in the name ('gan' -> Gantt chart, and NOT Organization chart), then mid-word in the name ('eth' -> Choropleth), then the description. A name match therefore SUPPRESSES description matches. Case- and accent-insensitive and, by default, space- and punctuation-insensitive too ('barchart' and 'bar-chart' find Bar chart; see name_filter_match). Minimum two characters, and it never reorders - the picker's ranking is preserved and the ranks stay as issued. Applied after ranking and before `top`."),name_filter_match:U.enum(["loose","exact"]).optional().describe("How name_filter matches a name. 'loose' (the default) ignores accents, case, spaces and punctuation, so 'barchart' finds Bar chart. 'exact' folds accents and case and collapses repeated spaces, and nothing else: a name typed without its space or hyphen matches nothing. The same setting the Power BI and Excel chart-type lists offer."),order:U.enum(["fit","variety"]).optional().describe("How the list is ordered. 'fit' (the default) = by how well each chart type fits THIS data, nothing else - use it to choose a chart for a question. 'variety' = the picker's selection order, which favors newer and less-common types on purpose - use it when the user wants to explore or be surprised. Both lists hold the same chart types; only the order differs."),top:U.number().optional().describe("Show only the top-N ranked results. Omit for all."),width:U.number().optional().describe("Viewport width px (default 800) \u2014 affects small-viewport / facet-budget gates."),height:U.number().optional().describe("Viewport height px (default 600).")},outputSchema:wk,annotations:{readOnlyHint:!0,openWorldHint:!0}},async e=>{let a=In(e),t="",r="",n="",o="";if(e.renderer!==void 0)t=e.renderer;else if(e.language)r=e.language;else if(f4())r="javascript",n=" (language: javascript, this server's default - pass language or renderer for another)";else{let N=mn(S8(e.project_dir,c8));N.language?(r=N.language,n=` (auto-detected language: ${N.language} \u2014 ${N.reason})`):o=`Couldn't tell the project's language (${N.reason}), so this is the list across all renderers; pass language: "javascript" or "python", or project_dir, to narrow it.
|
|
247
|
+
`)}),t=UH((r,n)=>{let o=new URL(r.url??"/","http://localhost").pathname;if(o==="/healthz"){if(r.method!=="GET"&&r.method!=="HEAD"){_n(n,405,{error:"Use GET."},{Allow:"GET"});return}_n(n,200,{ok:!0,server:"bic-chart",version:e.version});return}if(o!=="/mcp"){_n(n,404,{error:"Not found. The MCP endpoint is /mcp."});return}if(r.method!=="POST"){d7(n,405,-32e3,"Method not allowed: this server is stateless, so it takes POST only.",{Allow:"POST"});return}zH(r,n,e).catch(i=>{a(`[bic-chart http] request failed (${i?.name??"Error"})`),d7(n,500,-32603,"Internal error: the chart server couldn't handle this request. Try again.")})});return new Promise((r,n)=>{t.once("error",n),t.listen(e.port,e.host,()=>{t.off("error",n),r(t)})})}var Kk=["assess_data_shape","list_eligible_charts","generate_chart","get_guide","preview_request"],h7="This hosted server receives your table, profiles it in memory and sends only the profile to generation; rows aren't stored or logged.",Vk={csv_path:"this hosted server can't read files on your machine, so pass the table as data or csv_text",project_dir:"this hosted server can't see your project folder, so pass language or renderer instead",out_dir:"this hosted server returns the chart inline; it can't write to your machine",preview_html:"this hosted server returns the chart inline; it can't write to your machine"},Un=e=>`Not accepted by this hosted server: ${Vk[e]}.`,Pn={csv_path:U.string().optional().describe(Un("csv_path")),project_dir:U.string().optional().describe(Un("project_dir"))},Hk={out_dir:U.string().optional().describe(Un("out_dir")),preview_html:U.boolean().optional().describe(Un("preview_html"))},Gk=U.enum(["javascript","typescript","python",""]).optional(),Xk=["csv_path","project_dir","out_dir","preview_html"],Zk={assess_data_shape:{description:`Profile a dataset: per-column types, cardinality, ranges, measure/dimension roles, temporal/ordinal detection, and cross-column signals (nesting, shared values, association) - the same measurement engine the BIC Power BI visual uses before generating a chart. Pass the table as data ({columns, rows}) or csv_text. ${h7} This tool sends nothing on.`,inputs:{csv_path:Pn.csv_path},refuse:["csv_path"]},list_eligible_charts:{description:"The AUTHORITATIVE list of chart types that can render this dataset - the server's own eligibility engine, NOT a guess. Pass the table as data ({columns, rows}) or csv_text. "+h7+" Ranked for JavaScript (D3) unless you pass language ('python' ranks Plotly and matplotlib) or renderer ('D3'/'PLOTLY'/... for one renderer, '' for every renderer). No model runs, but the call is METERED: free within a generous hourly allowance, then usage credits per call.",inputs:{...Pn,language:Gk.describe("Project source language: javascript/typescript ranks D3 and Vega, python ranks Plotly and matplotlib. Omit for JavaScript; `renderer`, when given, overrides it.")},refuse:["csv_path","project_dir"]},generate_chart:{description:`Generate ready-to-render chart code for a dataset: the backend picks a suitable chart type (or honors chart_type) and returns code that has passed its eligibility gates and quality checks. Pass the table as data ({columns, rows}) or csv_text. ${h7} The code and the render-ready data come back inline in the reply; this server writes no files. JavaScript (D3) unless you pass language or renderer. The D3 code is a portable render(container, data, options) function meant to be MERGED into your own app; an integration contract describes exactly how to call it. A generation uses your account's credits.`,inputs:{...Pn,...Hk,language:Gk.describe("Project source language: javascript/typescript generates D3 (the renderer @bicharts/chart-host draws), python lets the backend pick within Plotly/matplotlib. Omit for JavaScript (D3); `renderer`, when given, overrides it.")},refuse:Xk},preview_request:{description:`Shows exactly what a chart generation would send on for these arguments - the measured shape of your data (column names, types, counts, ranges), the settings, and whether any sample rows travel - with the credentials removed. It sends nothing on and costs nothing. ${h7} Takes the same arguments as a generation.`,inputs:{...Pn,...Hk},refuse:Xk},get_guide:{description:"How to build an app with these charts, from the guide this server ships. Free, and it sends nothing on. topic 'fabric-app' (the default) is what a Microsoft Fabric App on the Rayfin data app template needs; 'all' is the whole guide, including Blazor; 'chart-shapes' lists every chart type with the columns, limits and renderers it needs. Some steps the guide describes, the ones that write into a project, need the local server (npx -y @bicharts/chart-mcp) rather than this one."}};function qk(e,a){let t=(a??[]).filter(r=>{let n=e?.[r];return n!=null&&n!==!1&&n!==""});return t.length===0?null:t.map(r=>`${r} isn't accepted here: ${Vk[r]}.`).join(" ")}var Jk=["This is RegiaBI's hosted chart server; it builds charts from a table you send. When a request asks for RegiaBI charts, it means these tools.",h7+" It can't read or write files on your machine: pass each table as data ({columns, rows}) or csv_text, and the chart comes back inline.","Asked which charts suit the data? Answer from list_eligible_charts, not from general knowledge.","Five rules for charts that fit on the first try:","1. Pass the chart's WHOLE result at its grain, not a sample: what fits depends on its counts.","2. Give columns the plain names your app renders with (rename Table[Column] first), unchanged at render time.","3. To pick a type, call list_eligible_charts on that data first and choose what answers the question as asked. Pass chart_type only for a type the person named; else leave it unset and the engine chooses. Where a chart has controls drawn inside the chart, build no input beside it.","4. Host the code with @bicharts/chart-host. generate_chart returns the code, the render-ready rows and the binding: pass them as they are, and never hand-build __rowIdx__ or __geo* columns.","5. Use `prompt` for what the chart shows; selection, cross-filtering, sizing and theming are the host's: filter with useBicFilter + selects, read a chart's sliders with useBicControls + controls (@bicharts/chart-host/react). Never write a select handler, toggle or clear.","Building an app? get_guide has the setup steps. The local server (npx -y @bicharts/chart-mcp) adds project tools that write the chart files into your app for you."].join(`
|
|
248
|
+
`);function S8(e,a){return fn(e,a).dir??Ya(e??process.cwd())}var $u="0.6.86",Qk=[],Rn=null,k3={registerTool(e,a,t){Qk.push({name:e,config:a,cb:t})},get server(){if(!Rn)throw new Error("The local server isn't running in this process.");return Rn.server}};function Yk(e){let a=e?new M2({name:"bic-chart",version:$u},{instructions:Jk}):new M2({name:"bic-chart",version:$u},{instructions:Ak});e||(a.server.registerCapabilities({logging:{}}),sb(t=>{a.server.sendLoggingMessage({level:"notice",logger:"sign-in",data:t}).catch(()=>{})}));for(let t of Qk){if(e&&!Kk.includes(t.name))continue;let r=e?Zk[t.name]:void 0,n={...t.config,...r?{description:r.description,inputSchema:{...t.config.inputSchema,...r.inputs??{}}}:{},annotations:{title:t.config.title,...t.config.annotations}},o=r?.refuse?(i,s)=>{let l=qk(i,r.refuse);return l?{isError:!0,content:[{type:"text",text:l}]}:t.cb(i,s)}:t.cb;a.registerTool(t.name,n,o)}return a}var p7="2026-10-14T03:12:29Z src:ffe8cbf6c688 (35 files)",Hu="@bicharts/chart-host@0.6.86, @bicharts/shape-core@0.6.86",IH=U.object({columns:U.array(U.object({name:U.string(),dataType:U.enum(["String","Integer","Decimal","DateTime"]).optional().describe("Known type (DAX/semantic-model callers have it); omit to infer from values."),isMeasure:U.boolean().optional().describe("Known measure/dimension role; omit to apply the numeric-non-identifier heuristic. A semantic-model caller should set this."),format:U.string().optional().describe('Format string from the model (e.g. "$#,##0") \u2192 modelFormat.'),description:U.string().optional().describe("Column description from the model \u2192 modelDesc.")})).min(1),rows:U.array(U.union([U.array(U.any()),U.record(U.string(),U.any())])).min(1).describe("Rows as positional arrays aligned to columns, OR objects keyed by column name.")}).describe("A pre-typed {columns, rows} table (DAX query results, dataframe, arrow). Use INSTEAD of csv_path/csv_text."),Gu={csv_path:U.string().optional().describe("Path to a CSV file (header row required)."),csv_text:U.string().optional().describe("Inline CSV text (alternative to csv_path)."),data:IH.optional().describe("A pre-typed {columns, rows} table \u2014 the shape a Fabric DAX query / dataframe already has. Alternative to csv_path/csv_text; when columns carry isMeasure/format/description the shape matches PBI fidelity with no guessing."),measures:U.array(U.string()).optional().describe("Columns to treat as MEASURES (the PBI 'Values' well \u2014 fields the chart aggregates). Numeric non-identifier columns are measures by default."),dimensions:U.array(U.string()).optional().describe("Columns to treat as DIMENSIONS (a PBI category/axis well \u2014 fields to group/break by). Use for numeric codes/years that should NOT be aggregated."),formats:U.record(U.string(),U.string()).optional().describe(`Per-column number/date FORMAT STRING (e.g. {"Revenue":"$#,##0","Margin":"0.0%"}). PBI supplies these from its model; a CSV can't, so provide them to steer number formatting.`),descriptions:U.record(U.string(),U.string()).optional().describe("Per-column human DESCRIPTION \u2014 gives the model semantic context the bare column name lacks."),group_by:U.array(U.string()).optional().describe("Columns that are the PRIMARY series/breakdown (the PBI 'Group by' well); the backend leads the visualization with these."),non_additive:U.array(U.string()).optional().describe("MEASURE columns that must NOT be summed (a ratio/average/rate \u2014 use mean, never stack). Usually auto-detected; this is an authoritative override."),privacy_level:U.enum(["0","10","20","30"]).optional().describe("How much detail to compute/share: 0 names only, 10 +counts, 20 +detailed stats (default), 30 +obfuscated sample rows."),culture:U.string().regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/).max(35).optional().describe("The caller's language and region as a BCP 47 tag such as 'de-DE', 'fr' or 'ja-JP'. Default 'en-US'. It is the language the chart's own text is written in (titles, axis labels, legends, notes), and it breaks the tie when a CSV's numbers or dates are ambiguous: 12.500 as twelve thousand five hundred or twelve and a half, 05.03.2024 as 5 March or 3 May. Set it from the end user's locale when you know it; it does not translate the data.")};function N8(e){return{measures:e.measures,dimensions:e.dimensions,formats:e.formats,descriptions:e.descriptions,groupBy:e.group_by,nonAdditive:e.non_additive,privacyLevel:e.privacy_level??"20",locale:e.culture||void 0}}function In(e){if(e.data)return by(e.data.columns,e.data.rows,N8(e));if(e.csv_text)return H4(e.csv_text,N8(e));if(e.csv_path)return H4(m7(Ya(e.csv_path),"utf-8"),N8(e));throw new Error("Provide one of: data ({columns, rows}), csv_text, or csv_path.")}k3.registerTool("assess_data_shape",{title:"Assess data shape",description:"Profile a dataset locally (no data leaves the machine): per-column types, cardinality, ranges, measure/dimension roles, temporal/ordinal detection, and cross-column signals (nesting, shared values, association). This is the same measurement engine the BIC Power BI visual uses before generating a chart.",inputSchema:Gu,annotations:{readOnlyHint:!0,openWorldHint:!1}},async e=>{let a=In(e),t={totalRows:a.totalRows,leafCardinality:a.index.getLeafCardinality(),columns:a.shape},r=f4()?null:jb(process.env);return{content:[{type:"text",text:JSON.stringify(t,null,2)},...r?[{type:"text",text:r}]:[]]}});k3.registerTool("get_guide",{title:"Read the build guide",description:"How to build an app with these charts, from the guide this package ships. Local and free: no network, no credentials. topic 'fabric-app' (the default) is what a Microsoft Fabric App on the Rayfin data app template needs: what to pull, generating, wiring in React, the Fabric App section and the time-savers. 'all' is the whole guide, including Blazor. 'chart-shapes' lists every chart type with the columns, limits and renderers it needs.",inputSchema:{topic:U.enum(Uk).optional().describe("'fabric-app' (default), 'all', or 'chart-shapes'.")},annotations:{readOnlyHint:!0,openWorldHint:!1}},async e=>{try{return{content:[{type:"text",text:Tk(e.topic??"fabric-app")}]}}catch(a){return{isError:!0,content:[{type:"text",text:`The guide could not be read from this package (${a?.message??a}). It is also published as skills/bic-charts/SKILL.md inside @bicharts/chart-mcp on npm.`}]}}});k3.registerTool("list_eligible_charts",{title:"List eligible chart types",description:"The AUTHORITATIVE list of chart types that can render this dataset \u2014 the server's own eligibility engine, NOT a local guess. Profiles the data locally, then sends that profile to the backend. NO LLM in the loop, but this is a NETWORK call and it is METERED \u2014 see the licensing note below. By default the tool DETECTS the project's language (JS/TS vs Python from the working dir) and returns the charts for THAT language, SCOPED and ordered by how well each type fits this data (best first; `order: 'variety'` favors newer and less-common types instead), each tagged with its source language and renderer. Pass `language` ('javascript'|'python') to force it, or `renderer` ('D3'/'PLOTLY'/\u2026) to rank one specific renderer, or renderer '' for the full renderer-agnostic eligibility across ALL renderers (also ranked, by chart type alone, with no renderer/language tag). If the language can't be auto-detected and none is given, the tool asks you to specify one. Needs an account: eligibility IS the engine, so programmatic access to it is licensed. With nothing configured, the first call opens a browser sign-in, waits for it and then answers (a license key in the environment is the alternative for a machine with no browser). Free within a generous hourly allowance; beyond it each call draws usage credits. The reply carries a text block and a structured table: one row per chart type with its rank, name, preview flag, fit verdict, description, language and renderer. Rows flagged alsoWorthALook are a few picks from below the top fits, drawn so an offer can include something different; the fit order itself never changes.",inputSchema:{...Gu,language:U.enum(["javascript","typescript","python",""]).optional().describe("Project source language \u2192 the server ranks across that language's renderers (javascript/typescript = D3/Vega, python = Plotly/matplotlib). Omit to AUTO-DETECT from the working dir; `renderer` (if given) overrides this."),project_dir:U.string().optional().describe("Directory to auto-detect the project language from (default: the folder setup_fabric_app used, else the working directory or the one project folder directly inside it)."),renderer:U.enum(["D3","PLOTLY","PYMATPLOT","VEGA",""]).optional().describe("Force a specific renderer (overrides `language`): a concrete renderer ranks that renderer's charts; '' = the full renderer-agnostic eligibility (all renderers, ranked by chart type alone). Omit to use `language`/auto-detection."),level_of_detail:U.enum(["High","Medium","Low",""]).optional().describe("The user's own preference for how much of the data to see, as they've stated it. 'High' = every observation as its own mark, 'Medium' = every row shown as a distribution, 'Low' = one mark per category. Ranks this list the same way a generation would. Unset when they haven't stated one; unset changes nothing."),name_filter:U.string().optional().describe("Show only chart types matching this text (the same matcher the Power BI and Excel chart-type lists use). Three tiers, first non-empty one wins outright: the term starting a WORD in the name ('gan' -> Gantt chart, and NOT Organization chart), then mid-word in the name ('eth' -> Choropleth), then the description. A name match therefore SUPPRESSES description matches. Case- and accent-insensitive and, by default, space- and punctuation-insensitive too ('barchart' and 'bar-chart' find Bar chart; see name_filter_match). Minimum two characters, and it never reorders - the picker's ranking is preserved and the ranks stay as issued. Applied after ranking and before `top`."),name_filter_match:U.enum(["loose","exact"]).optional().describe("How name_filter matches a name. 'loose' (the default) ignores accents, case, spaces and punctuation, so 'barchart' finds Bar chart. 'exact' folds accents and case and collapses repeated spaces, and nothing else: a name typed without its space or hyphen matches nothing. The same setting the Power BI and Excel chart-type lists offer."),order:U.enum(["fit","variety"]).optional().describe("How the list is ordered. 'fit' (the default) = by how well each chart type fits THIS data, nothing else - use it to choose a chart for a question. 'variety' = the picker's selection order, which favors newer and less-common types on purpose - use it when the user wants to explore or be surprised. Both lists hold the same chart types; only the order differs."),top:U.number().optional().describe("Show only the top-N ranked results. Omit for all."),width:U.number().optional().describe("Viewport width px (default 800) \u2014 affects small-viewport / facet-budget gates."),height:U.number().optional().describe("Viewport height px (default 600).")},outputSchema:wk,annotations:{readOnlyHint:!0,openWorldHint:!0}},async e=>{let a=In(e),t="",r="",n="",o="";if(e.renderer!==void 0)t=e.renderer;else if(e.language)r=e.language;else if(f4())r="javascript",n=" (language: javascript, this server's default - pass language or renderer for another)";else{let N=mn(S8(e.project_dir,c8));N.language?(r=N.language,n=` (auto-detected language: ${N.language} \u2014 ${N.reason})`):o=`Couldn't tell the project's language (${N.reason}), so this is the list across all renderers; pass language: "javascript" or "python", or project_dir, to narrow it.
|
|
249
249
|
`}let i=await Zl({shape:a.shape,totalRows:a.totalRows,leafCardinality:a.index.getLeafCardinality(),geoExtent:a.index.getGeoExtent(),width:e.width,height:e.height,renderer:t,language:r,levelOfDetail:e.level_of_detail||void 0,order:e.order??"fit"});if(!i.ok)return{isError:!0,content:[{type:"text",text:Su(i)?i.errorMessage:`Could not list eligible charts: ${i.errorMessage}`}]};let s=i.charts.length>0&&i.charts[0].rank!==void 0,l=r?`${r}`:t||"all renderers",u=i.charts,c=u.length,d="all",h=N=>Mk({rows:N,order:e.order??"fit",eligibleCount:c,filter:e.name_filter?{text:e.name_filter,tier:d}:null,metering:r7}),m=bS(e.name_filter_match),p=J2(u,e.name_filter,Br,m);u=p.rows,d=p.tier;let g;if(s){e.top&&e.top>0&&(u=u.slice(0,e.top));let N=(e.order??"fit")==="variety"?'ordered for variety (newer and less-common types first; order: "fit" ranks by fit to this data)':'ordered by fit to this data (order: "variety" favors newer and less-common types)';g=`Top ${u.length} chart type(s) for this data in ${l}, ${N} (authoritative \u2014 the server's eligibility engine; ${r7})${n}:`}else g=`${u.length} chart type(s) can render this data \u2014 renderer-agnostic eligibility (authoritative \u2014 the server's eligibility engine; ${r7}):`;if(g=o+g,p.tier!=="all"){let N=p.tier==="desc"?" (no NAME matched; these matched on description)":p.tier==="namePart"?" (matched mid-word in the name)":"";g=`Filtered to "${e.name_filter}"${N}: ${u.length} of ${c} eligible chart type(s). The other ${c-u.length} are eligible and simply do not match the filter.
|
|
250
250
|
`+g}let f=Ck(u);if(u.length===0&&p.tier!=="all"&&c>0){let N=J2(i.refused,e.name_filter,WS,m),W=N.tier==="name"||N.tier==="namePart"?N.rows.filter(A=>A.reason).slice(0,3):[],C=W.length>0?`
|
|
251
251
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.86",
|
|
4
4
|
"description": "MCP (Model Context Protocol) stdio server for BIC AI charts: profile a dataset locally, then generate chart code that has passed the BIC backend's render gates. Works with any MCP-capable client (Claude Code, Claude Desktop, Cursor, Copilot Studio). An account pays to author charts; the code it writes is yours and runs with no licence.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"// dependencies": "NONE, deliberately. dist/ bundles every module the server uses, so a runtime dependency installs nothing it needs - it only makes npx fetch that package (and its tree) before the first start. Everything the bundle carries is a devDependency; scripts/verify-package.mjs fails the release if a dependency appears or a shipped file imports anything but Node's built-ins.",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@bicharts/chart-host": "^0.6.
|
|
51
|
-
"@bicharts/shape-core": "^0.6.
|
|
50
|
+
"@bicharts/chart-host": "^0.6.86",
|
|
51
|
+
"@bicharts/shape-core": "^0.6.86",
|
|
52
52
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
53
53
|
"@types/node": "^20.0.0",
|
|
54
54
|
"@types/papaparse": "^5.3.14",
|
|
@@ -98,6 +98,7 @@ on the same picture, not a looser one.
|
|
|
98
98
|
| Sankey alluvial flow | 2 categorical, 1 continuous | <=10 categories, <=80 edges, needs 420x280 px | D3, Matplotlib, Plotly | Requires at least two categorical variables |
|
|
99
99
|
| Scatter plot | 2 continuous | needs 460x340 px | D3, Matplotlib, Plotly, Seaborn | Requires two continuous variables |
|
|
100
100
|
| Seasonal decomposition | 1 continuous, 24+ time points | needs 320x360 px | Matplotlib, Plotly, Statsmodels | Requires a datetime series with one continuous variable and at least two full seasonal cycles |
|
|
101
|
+
| Selection explainer | 2 continuous | needs 560x360 px | D3 | Two measures over thirty or more rows that also carry other fields - region, plan, tenure, size - when the question is 'what do these points have in common?' |
|
|
101
102
|
| Slope chart | 1 categorical, 1 continuous, 2+ time points | <=40 categories, needs 460x340 px | D3, PLOTLY | Best for two-period change across many categories: YoY by region/segment, before/after comparisons, ranking shifts between two snapshots |
|
|
102
103
|
| Spiral plot | 1 continuous, 12+ time points | needs 320x320 px | D3, PLOTLY | Best for long, finely-grained, strongly periodic series (years of daily data) where the cyclic pattern is the story |
|
|
103
104
|
| Stacked area chart | 1 categorical, 1 continuous | needs 460x340 px | D3, Matplotlib, Plotly | Requires ordered categories with multiple continuous series |
|
|
@@ -175,8 +175,8 @@ correction:
|
|
|
175
175
|
Asking for these in `prompt` prose instead is the most expensive mistake available here: it
|
|
176
176
|
routinely costs two or three extra generations, and each one is minutes of wall-clock.
|
|
177
177
|
|
|
178
|
-
Other parameters worth knowing: `chart_type` (
|
|
179
|
-
disqualifies it), `renderer` (a JavaScript or TypeScript project gets D3 without asking, because D3 is what
|
|
178
|
+
Other parameters worth knowing: `chart_type` (the type the person named, honored unless the data shape
|
|
179
|
+
disqualifies it; leave it unset when they only asked for a chart, and the engine chooses from what fits), `renderer` (a JavaScript or TypeScript project gets D3 without asking, because D3 is what
|
|
180
180
|
`@bicharts/chart-host` draws), `width`/`height`, and
|
|
181
181
|
`reasoning_mode: "1P"` when you want the cheapest, fastest pass.
|
|
182
182
|
|
|
@@ -539,7 +539,9 @@ are. The CLI returns at most 1,000 rows; the tool says so when it cut a result,
|
|
|
539
539
|
chart's grain.
|
|
540
540
|
|
|
541
541
|
**4. Ask before choosing, then choose what answers the question.** `list_eligible_charts` on that
|
|
542
|
-
data.
|
|
542
|
+
data. Pass `chart_type` to `generate_chart` only for a type the person named; when they only asked for a chart, leave it
|
|
543
|
+
unset and the engine chooses from what fits. A type the person described without naming it counts as named once you have
|
|
544
|
+
matched it to the catalogue. The catalogue goes past the template's own charts, and these are the ones people describe
|
|
543
545
|
without naming:
|
|
544
546
|
|
|
545
547
|
| the request sounds like | ask for |
|