@graphysdk/viz-engine 1.9.0-beta.1790607706146 → 1.9.0-beta.1790694757643

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/index.cjs CHANGED
@@ -1,18 +1,18 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./annotations-CAt5fDW0.cjs"),m=require("./compiler-BbjU78zr.cjs"),b=require("./spec-builder-Bbj1hjAH.cjs");let Xs=require("lodash-es"),ne=require("lodash-es/clamp");ne=l.__toESM(ne,1);let lt=require("humanize-duration");lt=l.__toESM(lt,1);let R=require("d3-shape"),qs=require("d3-delaunay"),we=require("lodash-es/isEqual");we=l.__toESM(we,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1790607706146");var js=1e6;function _(e){return String(Math.round(e*js))}function Y(e,t){return e.geom===t}var Ze="…",Dn=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Ze)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Ze)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Ze};var C={timeZone:"UTC"},L=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},$=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",xt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",Se=new Map,be=new Map,On=256,le=(e,t)=>{const r=_n(e,t),n=Se.get(r);if(n!==void 0)return n;Se.size>=On&&Se.clear();const a=new Intl.NumberFormat(e,t);return Se.set(r,a),a},w=(e,t)=>{const r=_n(e,t),n=be.get(r);if(n!==void 0)return n;be.size>=On&&be.clear();const a=new Intl.DateTimeFormat(e,t);return be.set(r,a),a},_n=(e,t)=>`${e}\0${JSON.stringify(t)}`,Zs=lt.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),Ne={signDisplay:"negative"},kn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>$(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=Tt(a,i),{base:s,suffix:c}=It(a,r.abbreviation);return`${le(t,{...o,...Ne,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Vn=({locale:e,numberFormat:t,intlOptions:r})=>$(n=>{const{base:a,suffix:i}=It(n,t.abbreviation);return`${le(e,{...Tt(a,t.decimals),...Ne,...r}).format(a)}${i}`}),At=e=>$(t=>{const r=Zs(Math.abs(t));return t<0?`-${r}`:r}),Nn=({locale:e,intlOptions:t})=>{const r=le(e,{maximumFractionDigits:0,...Ne,...t});return $(n=>r.format(n))},Fn=({locale:e,numberFormat:t,intlOptions:r})=>$(n=>le(e,{...Tt(n,t.decimals),...Ne,...r,style:"percent"}).format(n)),It=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=Js(e);return It(e,r)}default:return{base:e/l.SUFFIX_MULTIPLIERS[t],suffix:t}}},Tt=(e,t)=>{if(typeof t=="number")return{minimumFractionDigits:t,maximumFractionDigits:t};const r=Math.ceil(Math.log10(Math.abs(e))),n=r>=3?0:r===2?1:2;return{minimumFractionDigits:t==="auto"?0:n,maximumFractionDigits:n}},Js=e=>{const t=Math.abs(e);return t>=l.SUFFIX_MULTIPLIERS.b?"b":t>=l.SUFFIX_MULTIPLIERS.m?"m":t>=l.SUFFIX_MULTIPLIERS.k?"k":"none"},Qs=1440*60*1e3,el=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",...C,...t});return L(n=>r.format(n))},tl=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",timeStyle:"medium",...C,...t});return L(n=>rl(r.formatToParts(n)))},Bn=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"long",...C,...t});return L(n=>r.format(n))},Gn=({locale:e,intlOptions:t})=>{const r=w(e,{month:"long",...C,...t});return L(n=>r.format(n))},Lt=({locale:e,intlOptions:t})=>{const r=w(e,{month:"short",year:"numeric",...C,...t});return L(n=>r.format(n))},Et=e=>L(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),Hn=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"long",...C,...t,year:void 0});return L(n=>r.formatRange(n,Kn(n,6)))},$n=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",...C,...t});return L(n=>r.formatRange(n,Kn(n,6)))},Rt=({locale:e,intlOptions:t})=>{const r=w(e,{year:"numeric",...C,...t});return L(n=>r.format(n))},zn=({locale:e,intlOptions:t})=>{const r=w(e,{timeStyle:"short",...C,...t});return L(n=>r.format(n))},Kn=(e,t)=>new Date(e.getTime()+t*Qs),rl=e=>{const t=e.findIndex(n=>n.type==="hour")-1,r=e[t];return e.map((n,a)=>a===t&&r?.type==="literal"&&r.value===", "?" • ":n.value).join("")},Sr=1e3,nl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>$(a=>{const i={...wt(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Ct(a,t,i)}),al=({locale:e,tickValues:t,intlOptions:r})=>$(n=>{const a={...wt(n,t),notation:"compact",...r};return Ct(n,e,a)}),il=({locale:e,tickValues:t,intlOptions:r})=>$(n=>{const a={...wt(n,t),notation:"compact",...r,style:"percent"};return Ct(n,e,a)}),Ct=(e,t,r)=>le(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),Yn=e=>Math.abs(e)>Sr?Yn(e/Sr):Number.isInteger(e),ol=e=>{if(e.length<2)return!1;const[t,r]=e;return typeof t!="number"||typeof r!="number"?!1:Math.abs(r-t)<1},wt=(e,t)=>Yn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:ol(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:Math.max(1,sl(t))},sl=e=>{const t=e.filter(u=>typeof u=="number"&&Number.isFinite(u)),r=t[0],n=t[1];if(r===void 0||n===void 0)return 0;const a=Math.abs(n-r);if(a===0)return 0;let i=0;for(const u of t)i=Math.max(i,Math.abs(u));if(i===0)return 0;const o=Math.floor(Math.log10(i)/3),s=a/10**(Math.max(0,o)*3);if(s>=1)return 0;const c=Math.ceil(-Math.log10(s)-1e-9);return Math.min(4,Math.max(0,c))},ll=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"short",...C,...t});return L(n=>r.format(n))},cl=({locale:e,intlOptions:t})=>{const r=w(e,{month:"short",...C,...t});return L(n=>r.format(n))},ul=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"short",...C,...t});return L(n=>r.format(n))},dl=({locale:e,intlOptions:t})=>{const r=w(e,{timeStyle:"short",...C,...t});return L(n=>r.format(n))},Pt=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return nl(e);case"date":case"datetime":return ll(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return ul(e);case"decimal":case"integer":return al(e);case"duration":return At(e);case"month":return cl(e);case"month_year":return Lt(e);case"percentage":return il(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return dl(e);case"year":return Rt(e);case"lookup":return Pt({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},ml=.9,hl=1/3,pl=1/4,fl=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?gl(e):vl(e),gl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Un(e.ticks,n),s=yl(e.ticks,r.width),c=s*ml;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const d=ut(c);return{...e,ticks:ct(e.ticks,a,d,n),labelRotation:0,labelMaxWidthPx:d}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=ut(r.height*hl);return{...e,ticks:ct(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},vl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Un(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=ut(r.width*pl);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:ct(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},yl=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},Un=(e,t)=>{const r=[];let n=0,a=0;for(const i of e){const{width:o,height:s}=t(i.formattedLabel);r.push(o),o>n&&(n=o),s>a&&(a=s)}return{widths:r,maxWidth:n,maxHeight:a}},ct=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:Dn(i.formattedLabel,r,a)})},ut=e=>Math.max(0,Math.floor(e)),Sl=(e,t,r,n,a)=>{if(e===0)return!0;const i=r==="top"||r==="bottom",o=i?60:40;let s=n-(e-1)*o;for(let c=0;c<e;c+=1){const{width:u,height:d}=a(t(c));if(s-=i?u:d,s<0)return!1}return!0},bl={ticks:[],labelAt:()=>""},xl=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=p=>{const f=o.get(p);if(f)return f;const g=a[p],S=g?Il(g.ticks,n(g)):bl;return o.set(p,S),S};let c=0,u=a.length-1,d=-1;for(;c<=u;){const p=c+u>>>1,{ticks:f,labelAt:g}=s(p);Sl(f.length,g,i,t,r)?(d=p,c=p+1):u=p-1}const h=Al(d,s);return Tl(s(h))},Al=(e,t)=>{const r=e>=0?e:0;for(let n=r;n>=0;n-=1){const{ticks:a,labelAt:i}=t(n);if(Ll(a,i))return n}return 0},Il=(e,t)=>{const r=new Array(e.length);return{ticks:e,labelAt:n=>{const a=r[n];if(a!==void 0)return a;const i=t(e[n]?.value??null);return r[n]=i,i}}},Tl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Ll=(e,t)=>{const r=new Set;for(let n=0;n<e.length;n+=1){const a=t(n);if(r.has(a))return!1;r.add(a)}return!0},El=e=>{const t=I({...e,valueFormat:e.valueFormat.fallback}),r={};for(const[a,i]of Object.entries(e.valueFormat.cases))r[a]=I({...e,valueFormat:i});const n=e.valueFormat.byVariable;return(a,i)=>{if(i===void 0||i[n]===void 0)return t(a);const o=l.getStableKey(i[n]),s=r[o];return s!==void 0?s(a,i):t(a)}},I=e=>{switch(e.valueFormat.type){case"currency":return kn(e);case"date":return el(e);case"datetime":return tl(e);case"day_month":return Bn(e);case"decimal":return Vn(e);case"duration":return At(e);case"integer":return Nn(e);case"month":return Gn(e);case"month_year":return Lt(e);case"percentage":return Fn(e);case"quarter":return Et(e);case"text":return xt(e);case"weekly_date_range":return Hn(e);case"weekly_date_range_with_year":return $n(e);case"year":return Rt(e);case"time":return zn(e);case"lookup":return El({...e,valueFormat:e.valueFormat});default:{const t=e.valueFormat;throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}}};function Mt({layer:e,numberFormat:t,locale:r}){return I({valueFormat:m.getLayerYValueFormat(e),locale:r,numberFormat:t})}var Rl=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:m.createXValueReader(e,t),variable:r}:{read:m.getGroup,variable:l.GROUP_VARIABLES.group}},Wn=({layer:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:c})=>{const u=Mt({layer:e,numberFormat:n,locale:s}),d=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,styleReaders:o.geom(e),formatLabel:Dl({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:d}),formatAbsolute:u,formatCategory:Cl({layer:e,numberFormat:n,locale:s})}},Cl=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=Rl(e.data,e.mapping),i=I({valueFormat:e.data.hasVariable(a)?e.data.getValueFormat(a):{type:"text"},locale:r,numberFormat:t});return o=>{const s=n(o);return s===null?null:i(s,o)}},wl=(e,t,r)=>{switch(t){case"stack":return Pl(e);case"fill":return Ml(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},Pl=e=>{const t=l.readVariableName(e.mapping.x);let r=null,n=!1;return a=>{const i=e.summary.stackTotals;if(i===void 0||i.length===0||t===null)return null;if(!n){r=new Map;for(const c of i)r.set(c.xKey,c);n=!0}const o=a[t];if(o==null)return null;const s=r?.get(m.getObservationXKey(a,t));return s===void 0?null:s.total}},Ml=(e,t)=>{const r=t?l.getXMin:l.getYMin,n=t?l.getXMax:l.getYMax,a=m.createSegmentYReader(e);return i=>{const o=r(i),s=n(i);if(!l.isStrictNumericDataValue(o)||!l.isStrictNumericDataValue(s))return null;const c=Math.abs(s-o);if(c===0)return null;const u=a(i);return l.isStrictNumericDataValue(u)?u/c:null}},Dl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=m.createRawValueReader(e.data,e.dataLabels.labelSource),c=wl(e,i,o),u=Ol({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),d=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&Xn(e);return p=>{const f=s(p);if(f===null)return"";if(!h||!l.isStrictNumericDataValue(f))return u(f,p);const g=c(p);return g===null||g===0?u(f,p):d(f/g)}},Ol=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Xn(e))return a;const s=_l(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:kl(e.data,i),locale:n,numberFormat:t})},Xn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(m.resolveSegmentYSource(e.position,e.mapping))},_l=(e,t,r,n,a)=>{const i=l.readVariableName(e.mapping.x);if(i===null||i!==a)return null;const o=t.find(s=>s.scaleAestheticKey==="x");return o===void 0?null:I({valueFormat:o.valueFormat,locale:n,numberFormat:r})},kl=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return l.isNumericDataValue(r)?{type:"decimal"}:l.isTemporalDataValue(r)?{type:"date"}:{type:"text"};const n=l.readVariableName(t);return n===null||!e.hasVariable(n)?{type:"text"}:e.getValueFormat(n)},Vl={cartesian:["cartesian","flip"],polar:["polar"]},Nl=null;function qn(e=[]){const t=Fl(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!Vl[a].some(o=>i.dataLabelCoordTypes.includes(o))?null:{place:i.getDataLabelPlacements.bind(i),getPercentageValueStrategy:o=>i.resolvePercentageValueStrategy?.(o,a)??"none"}};return{resolve:r,hasCapability:(n,a)=>r(n,a)!==null,hasPercentageFormat:(n,a)=>(r(n.geom,a)?.getPercentageValueStrategy(n)??"none")!=="none"}}function Dt(){return Nl??=qn()}function Fl(e){const t=new l.GeomRegistry;for(const r of e){const n=l.resolveDefinition(r);n instanceof l.Geom&&t.register(n.type,n)}return t}function*Bl({layers:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,locale:s,resolvePlacement:c=Dt()}){if(!(t.type!=="cartesian"||a.width<=0||a.height<=0))for(const u of e){if(!u.dataLabels.showDataLabels&&!u.dataLabels.showStackTotals)continue;const d=c.resolve(u.geom,"cartesian");if(d===null)continue;const h=Wn({layer:u,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:d.getPercentageValueStrategy(u)});for(const p of d.place(h).labels)yield{x:a.x+p.x-p.width/2,y:a.y+p.y-p.height/2,width:p.width,height:p.height}}}var Je={abbreviation:"none",decimals:"auto"},jn=({locale:e,kind:t,startValue:r,endValue:n,valueFormat:a})=>{if(r===null||n===null)return"n/a";switch(t){case"absolute-difference":{const i=n-r,o=I({valueFormat:a,locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(i);return br(o)?"0":o}case"relative-difference":{const i=n-r;if(i===0)return"0%";const o=i/Math.abs(r);if(o===Number.POSITIVE_INFINITY)return"∞";if(o===Number.NEGATIVE_INFINITY)return"-∞";const s=I({valueFormat:{type:"percentage"},locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(o);return br(s)?"0%":s}case"proportion":{if(n-r===0)return"=";const i=n/r;return i===Number.POSITIVE_INFINITY?"∞":i===Number.NEGATIVE_INFINITY?"-∞":`${I({valueFormat:{type:"decimal"},locale:e,numberFormat:Je,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},br=e=>{const t=e.replace(/[^\d.]/g,"");return t===""||t==="."?!1:Number(t)===0},Gl=2,Hl=6,$l=6,zl=15,Kl=15,Yl=2.5,Ul=.5,Wl=.25,Zn=e=>{const t=e-Gl,r=1+Ul*t,n=1+Wl*t;return{arrowStartGap:Hl*r,arrowEndGap:$l*r,offsetFromHigherObservation:zl*n,arrowheadSize:Yl*e,curveRadius:Kl*n,strokeWidth:e}},Xl=(e,t,r,n)=>{const a=n.offsetFromHigherObservation+n.arrowheadSize+n.arrowEndGap;return e?Math.max(t.x,r.x)+a:Math.min(t.y,r.y)-a},ql=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x,y:e.y-n},s={x:e.x,y:r},c={x:t.x,y:r},u={x:t.x,y:t.y-a},d=t.x>e.x?1:-1;return`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./annotations-CAt5fDW0.cjs"),m=require("./compiler-BbjU78zr.cjs"),b=require("./spec-builder-Bbj1hjAH.cjs");let Js=require("lodash-es"),ne=require("lodash-es/clamp");ne=l.__toESM(ne,1);let lt=require("humanize-duration");lt=l.__toESM(lt,1);let R=require("d3-shape"),Qs=require("d3-delaunay"),Ce=require("lodash-es/isEqual");Ce=l.__toESM(Ce,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1790694757643");var el=1e6;function _(e){return String(Math.round(e*el))}function z(e,t){return e.geom===t}var Ze="…",Dn=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Ze)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Ze)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Ze};var w={timeZone:"UTC"},L=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},$=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",xt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",Se=new Map,be=new Map,On=256,le=(e,t)=>{const r=_n(e,t),n=Se.get(r);if(n!==void 0)return n;Se.size>=On&&Se.clear();const a=new Intl.NumberFormat(e,t);return Se.set(r,a),a},C=(e,t)=>{const r=_n(e,t),n=be.get(r);if(n!==void 0)return n;be.size>=On&&be.clear();const a=new Intl.DateTimeFormat(e,t);return be.set(r,a),a},_n=(e,t)=>`${e}\0${JSON.stringify(t)}`,tl=lt.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),Ne={signDisplay:"negative"},kn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>$(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=Tt(a,i),{base:s,suffix:c}=It(a,r.abbreviation);return`${le(t,{...o,...Ne,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Vn=({locale:e,numberFormat:t,intlOptions:r})=>$(n=>{const{base:a,suffix:i}=It(n,t.abbreviation);return`${le(e,{...Tt(a,t.decimals),...Ne,...r}).format(a)}${i}`}),At=e=>$(t=>{const r=tl(Math.abs(t));return t<0?`-${r}`:r}),Nn=({locale:e,intlOptions:t})=>{const r=le(e,{maximumFractionDigits:0,...Ne,...t});return $(n=>r.format(n))},Fn=({locale:e,numberFormat:t,intlOptions:r})=>$(n=>le(e,{...Tt(n,t.decimals),...Ne,...r,style:"percent"}).format(n)),It=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=rl(e);return It(e,r)}default:return{base:e/l.SUFFIX_MULTIPLIERS[t],suffix:t}}},Tt=(e,t)=>{if(typeof t=="number")return{minimumFractionDigits:t,maximumFractionDigits:t};const r=Math.ceil(Math.log10(Math.abs(e))),n=r>=3?0:r===2?1:2;return{minimumFractionDigits:t==="auto"?0:n,maximumFractionDigits:n}},rl=e=>{const t=Math.abs(e);return t>=l.SUFFIX_MULTIPLIERS.b?"b":t>=l.SUFFIX_MULTIPLIERS.m?"m":t>=l.SUFFIX_MULTIPLIERS.k?"k":"none"},nl=1440*60*1e3,al=({locale:e,intlOptions:t})=>{const r=C(e,{dateStyle:"medium",...w,...t});return L(n=>r.format(n))},il=({locale:e,intlOptions:t})=>{const r=C(e,{dateStyle:"medium",timeStyle:"medium",...w,...t});return L(n=>ol(r.formatToParts(n)))},Bn=({locale:e,intlOptions:t})=>{const r=C(e,{day:"numeric",month:"long",...w,...t});return L(n=>r.format(n))},Gn=({locale:e,intlOptions:t})=>{const r=C(e,{month:"long",...w,...t});return L(n=>r.format(n))},Lt=({locale:e,intlOptions:t})=>{const r=C(e,{month:"short",year:"numeric",...w,...t});return L(n=>r.format(n))},Et=e=>L(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),Hn=({locale:e,intlOptions:t})=>{const r=C(e,{day:"numeric",month:"long",...w,...t,year:void 0});return L(n=>r.formatRange(n,Yn(n,6)))},$n=({locale:e,intlOptions:t})=>{const r=C(e,{dateStyle:"medium",...w,...t});return L(n=>r.formatRange(n,Yn(n,6)))},Rt=({locale:e,intlOptions:t})=>{const r=C(e,{year:"numeric",...w,...t});return L(n=>r.format(n))},Kn=({locale:e,intlOptions:t})=>{const r=C(e,{timeStyle:"short",...w,...t});return L(n=>r.format(n))},Yn=(e,t)=>new Date(e.getTime()+t*nl),ol=e=>{const t=e.findIndex(n=>n.type==="hour")-1,r=e[t];return e.map((n,a)=>a===t&&r?.type==="literal"&&r.value===", "?" • ":n.value).join("")},Sr=1e3,sl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>$(a=>{const i={...Ct(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return wt(a,t,i)}),ll=({locale:e,tickValues:t,intlOptions:r})=>$(n=>{const a={...Ct(n,t),notation:"compact",...r};return wt(n,e,a)}),cl=({locale:e,tickValues:t,intlOptions:r})=>$(n=>{const a={...Ct(n,t),notation:"compact",...r,style:"percent"};return wt(n,e,a)}),wt=(e,t,r)=>le(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),zn=e=>Math.abs(e)>Sr?zn(e/Sr):Number.isInteger(e),ul=e=>{if(e.length<2)return!1;const[t,r]=e;return typeof t!="number"||typeof r!="number"?!1:Math.abs(r-t)<1},Ct=(e,t)=>zn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:ul(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:Math.max(1,dl(t))},dl=e=>{const t=e.filter(u=>typeof u=="number"&&Number.isFinite(u)),r=t[0],n=t[1];if(r===void 0||n===void 0)return 0;const a=Math.abs(n-r);if(a===0)return 0;let i=0;for(const u of t)i=Math.max(i,Math.abs(u));if(i===0)return 0;const o=Math.floor(Math.log10(i)/3),s=a/10**(Math.max(0,o)*3);if(s>=1)return 0;const c=Math.ceil(-Math.log10(s)-1e-9);return Math.min(4,Math.max(0,c))},ml=({locale:e,intlOptions:t})=>{const r=C(e,{day:"numeric",month:"short",...w,...t});return L(n=>r.format(n))},hl=({locale:e,intlOptions:t})=>{const r=C(e,{month:"short",...w,...t});return L(n=>r.format(n))},pl=({locale:e,intlOptions:t})=>{const r=C(e,{day:"numeric",month:"short",...w,...t});return L(n=>r.format(n))},fl=({locale:e,intlOptions:t})=>{const r=C(e,{timeStyle:"short",...w,...t});return L(n=>r.format(n))},Pt=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return sl(e);case"date":case"datetime":return ml(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return pl(e);case"decimal":case"integer":return ll(e);case"duration":return At(e);case"month":return hl(e);case"month_year":return Lt(e);case"percentage":return cl(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return fl(e);case"year":return Rt(e);case"lookup":return Pt({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},gl=.9,vl=1/3,yl=1/4,Sl=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?bl(e):xl(e),bl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Un(e.ticks,n),s=Al(e.ticks,r.width),c=s*gl;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const d=ut(c);return{...e,ticks:ct(e.ticks,a,d,n),labelRotation:0,labelMaxWidthPx:d}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=ut(r.height*vl);return{...e,ticks:ct(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},xl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Un(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=ut(r.width*yl);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:ct(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},Al=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},Un=(e,t)=>{const r=[];let n=0,a=0;for(const i of e){const{width:o,height:s}=t(i.formattedLabel);r.push(o),o>n&&(n=o),s>a&&(a=s)}return{widths:r,maxWidth:n,maxHeight:a}},ct=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:Dn(i.formattedLabel,r,a)})},ut=e=>Math.max(0,Math.floor(e)),Il=(e,t,r,n,a)=>{if(e===0)return!0;const i=r==="top"||r==="bottom",o=i?60:40;let s=n-(e-1)*o;for(let c=0;c<e;c+=1){const{width:u,height:d}=a(t(c));if(s-=i?u:d,s<0)return!1}return!0},Tl={ticks:[],labelAt:()=>""},Ll=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=p=>{const f=o.get(p);if(f)return f;const g=a[p],S=g?Rl(g.ticks,n(g)):Tl;return o.set(p,S),S};let c=0,u=a.length-1,d=-1;for(;c<=u;){const p=c+u>>>1,{ticks:f,labelAt:g}=s(p);Il(f.length,g,i,t,r)?(d=p,c=p+1):u=p-1}const h=El(d,s);return wl(s(h))},El=(e,t)=>{const r=e>=0?e:0;for(let n=r;n>=0;n-=1){const{ticks:a,labelAt:i}=t(n);if(Cl(a,i))return n}return 0},Rl=(e,t)=>{const r=new Array(e.length);return{ticks:e,labelAt:n=>{const a=r[n];if(a!==void 0)return a;const i=t(e[n]?.value??null);return r[n]=i,i}}},wl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Cl=(e,t)=>{const r=new Set;for(let n=0;n<e.length;n+=1){const a=t(n);if(r.has(a))return!1;r.add(a)}return!0},Pl=e=>{const t=I({...e,valueFormat:e.valueFormat.fallback}),r={};for(const[a,i]of Object.entries(e.valueFormat.cases))r[a]=I({...e,valueFormat:i});const n=e.valueFormat.byVariable;return(a,i)=>{if(i===void 0||i[n]===void 0)return t(a);const o=l.getStableKey(i[n]),s=r[o];return s!==void 0?s(a,i):t(a)}},I=e=>{switch(e.valueFormat.type){case"currency":return kn(e);case"date":return al(e);case"datetime":return il(e);case"day_month":return Bn(e);case"decimal":return Vn(e);case"duration":return At(e);case"integer":return Nn(e);case"month":return Gn(e);case"month_year":return Lt(e);case"percentage":return Fn(e);case"quarter":return Et(e);case"text":return xt(e);case"weekly_date_range":return Hn(e);case"weekly_date_range_with_year":return $n(e);case"year":return Rt(e);case"time":return Kn(e);case"lookup":return Pl({...e,valueFormat:e.valueFormat});default:{const t=e.valueFormat;throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}}};function Mt({layer:e,numberFormat:t,locale:r}){return I({valueFormat:m.getLayerYValueFormat(e),locale:r,numberFormat:t})}var Ml=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:m.createXValueReader(e,t),variable:r}:{read:m.getGroup,variable:l.GROUP_VARIABLES.group}},Wn=({layer:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:c})=>{const u=Mt({layer:e,numberFormat:n,locale:s}),d=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,styleReaders:o.geom(e),formatLabel:Vl({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:d}),formatAbsolute:u,formatCategory:Dl({layer:e,numberFormat:n,locale:s})}},Dl=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=Ml(e.data,e.mapping),i=I({valueFormat:e.data.hasVariable(a)?e.data.getValueFormat(a):{type:"text"},locale:r,numberFormat:t});return o=>{const s=n(o);return s===null?null:i(s,o)}},Ol=(e,t,r)=>{switch(t){case"stack":return _l(e);case"fill":return kl(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},_l=e=>{const t=l.readVariableName(e.mapping.x);let r=null,n=!1;return a=>{const i=e.summary.stackTotals;if(i===void 0||i.length===0||t===null)return null;if(!n){r=new Map;for(const c of i)r.set(c.xKey,c);n=!0}const o=a[t];if(o==null)return null;const s=r?.get(m.getObservationXKey(a,t));return s===void 0?null:s.total}},kl=(e,t)=>{const r=t?l.getXMin:l.getYMin,n=t?l.getXMax:l.getYMax,a=m.createSegmentYReader(e);return i=>{const o=r(i),s=n(i);if(!l.isStrictNumericDataValue(o)||!l.isStrictNumericDataValue(s))return null;const c=Math.abs(s-o);if(c===0)return null;const u=a(i);return l.isStrictNumericDataValue(u)?u/c:null}},Vl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=m.createRawValueReader(e.data,e.dataLabels.labelSource),c=Ol(e,i,o),u=Nl({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),d=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&Xn(e);return p=>{const f=s(p);if(f===null)return"";if(!h||!l.isStrictNumericDataValue(f))return u(f,p);const g=c(p);return g===null||g===0?u(f,p):d(f/g)}},Nl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Xn(e))return a;const s=Fl(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:Bl(e.data,i),locale:n,numberFormat:t})},Xn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(m.resolveSegmentYSource(e.position,e.mapping))},Fl=(e,t,r,n,a)=>{const i=l.readVariableName(e.mapping.x);if(i===null||i!==a)return null;const o=t.find(s=>s.scaleAestheticKey==="x");return o===void 0?null:I({valueFormat:o.valueFormat,locale:n,numberFormat:r})},Bl=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return l.isNumericDataValue(r)?{type:"decimal"}:l.isTemporalDataValue(r)?{type:"date"}:{type:"text"};const n=l.readVariableName(t);return n===null||!e.hasVariable(n)?{type:"text"}:e.getValueFormat(n)},Gl={cartesian:["cartesian","flip"],polar:["polar"]},Hl=null;function qn(e=[]){const t=$l(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!Gl[a].some(o=>i.dataLabelCoordTypes.includes(o))?null:{place:i.getDataLabelPlacements.bind(i),getPercentageValueStrategy:o=>i.resolvePercentageValueStrategy?.(o,a)??"none"}};return{resolve:r,hasCapability:(n,a)=>r(n,a)!==null,hasPercentageFormat:(n,a)=>(r(n.geom,a)?.getPercentageValueStrategy(n)??"none")!=="none"}}function Dt(){return Hl??=qn()}function $l(e){const t=new l.GeomRegistry;for(const r of e){const n=l.resolveDefinition(r);n instanceof l.Geom&&t.register(n.type,n)}return t}function*Kl({layers:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,locale:s,resolvePlacement:c=Dt()}){if(!(t.type!=="cartesian"||a.width<=0||a.height<=0))for(const u of e){if(!u.dataLabels.showDataLabels&&!u.dataLabels.showStackTotals)continue;const d=c.resolve(u.geom,"cartesian");if(d===null)continue;const h=Wn({layer:u,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:d.getPercentageValueStrategy(u)});for(const p of d.place(h).labels)yield{x:a.x+p.x-p.width/2,y:a.y+p.y-p.height/2,width:p.width,height:p.height}}}var Je={abbreviation:"none",decimals:"auto"},jn=({locale:e,kind:t,startValue:r,endValue:n,valueFormat:a})=>{if(r===null||n===null)return"n/a";switch(t){case"absolute-difference":{const i=n-r,o=I({valueFormat:a,locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(i);return br(o)?"0":o}case"relative-difference":{const i=n-r;if(i===0)return"0%";const o=i/Math.abs(r);if(o===Number.POSITIVE_INFINITY)return"∞";if(o===Number.NEGATIVE_INFINITY)return"-∞";const s=I({valueFormat:{type:"percentage"},locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(o);return br(s)?"0%":s}case"proportion":{if(n-r===0)return"=";const i=n/r;return i===Number.POSITIVE_INFINITY?"∞":i===Number.NEGATIVE_INFINITY?"-∞":`${I({valueFormat:{type:"decimal"},locale:e,numberFormat:Je,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},br=e=>{const t=e.replace(/[^\d.]/g,"");return t===""||t==="."?!1:Number(t)===0},Yl=2,zl=6,Ul=6,Wl=15,Xl=15,ql=2.5,jl=.5,Zl=.25,Zn=e=>{const t=e-Yl,r=1+jl*t,n=1+Zl*t;return{arrowStartGap:zl*r,arrowEndGap:Ul*r,offsetFromHigherObservation:Wl*n,arrowheadSize:ql*e,curveRadius:Xl*n,strokeWidth:e}},Jl=(e,t,r,n)=>{const a=n.offsetFromHigherObservation+n.arrowheadSize+n.arrowEndGap;return e?Math.max(t.x,r.x)+a:Math.min(t.y,r.y)-a},Ql=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x,y:e.y-n},s={x:e.x,y:r},c={x:t.x,y:r},u={x:t.x,y:t.y-a},d=t.x>e.x?1:-1;return`
2
2
  M ${o.x} ${o.y}
3
3
  L ${s.x} ${s.y+i}
4
4
  Q ${s.x} ${s.y} ${s.x+d*i} ${s.y}
5
5
  L ${c.x-d*i} ${c.y}
6
6
  Q ${c.x} ${c.y} ${c.x} ${c.y+i}
7
7
  L ${u.x} ${u.y}
8
- `},jl=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x+n,y:e.y},s={x:r,y:e.y},c={x:r,y:t.y},u={x:t.x+a,y:t.y},d=t.y>e.y?1:-1;return`
8
+ `},ec=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x+n,y:e.y},s={x:r,y:e.y},c={x:r,y:t.y},u={x:t.x+a,y:t.y},d=t.y>e.y?1:-1;return`
9
9
  M ${o.x} ${o.y}
10
10
  L ${s.x-i} ${s.y}
11
11
  Q ${s.x} ${s.y} ${s.x} ${s.y+d*i}
12
12
  L ${c.x} ${c.y-d*i}
13
13
  Q ${c.x} ${c.y} ${c.x-i} ${c.y}
14
14
  L ${u.x} ${u.y}
15
- `},Zl=(e,t,{arrowEndGap:r,arrowheadSize:n})=>e?`
15
+ `},tc=(e,t,{arrowEndGap:r,arrowheadSize:n})=>e?`
16
16
  M ${t.x+r+n} ${t.y-n}
17
17
  L ${t.x+r} ${t.y}
18
18
  L ${t.x+r+n} ${t.y+n}
@@ -20,4 +20,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=requi
20
20
  M ${t.x-n} ${t.y-r-n}
21
21
  L ${t.x} ${t.y-r}
22
22
  L ${t.x+n} ${t.y-r-n}
23
- `,Jl=(e,t,r,n,a,i=.5)=>e?{x:n,y:Math.min(t.y,r.y)+i*a}:{x:Math.min(t.x,r.x)+i*a,y:n},Ql=(e,t,r)=>Math.abs(e?t.y-r.y:t.x-r.x),Jn=({arrow:e,style:t,mainAxis:r,panelWidth:n,panelHeight:a,locale:i})=>{const o=r==="y",s={x:e.start.x*n,y:(1-e.start.y)*a},c={x:e.end.x*n,y:(1-e.end.y)*a},u=Zn(t.strokeWidth),d=Xl(o,s,c,u),h=(o?jl:ql)(s,c,d,u),p=Zl(o,c,u),f=Jl(o,s,c,d,Ql(o,s,c),e.labelCrossPosition),g=jn({locale:i,kind:e.label,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat});return{id:e.id,start:s,end:c,linePath:h,arrowheadPath:p,labelPosition:f,labelText:g}},xr={large:1,medium:23/26,small:19/26},Qe={large:1,medium:10/12,small:10/12},Qn=["fontStyle","letterSpacing","textTransform","textDecoration","textOutlineColor","textOutlineWidth","textShadow"],ea=["fontFamily","fontSize","fontWeight","lineHeight","textColor",...Qn],ta=e=>e.fontSize*e.lineHeight,ec=(e,t)=>({family:e.fontFamily??t,size:e.fontSize,weight:e.fontWeight,...e.fontStyle===void 0?{}:{style:e.fontStyle},...e.letterSpacing===void 0?{}:{letterSpacing:e.letterSpacing},...e.textTransform===void 0?{}:{textTransform:e.textTransform}}),tc=(e,t,r)=>{const n=t==="aggregate"?e.dataLabel.aggregate():e.dataLabel[t][r]();return{...n.resolve(),isTextColorAuthored:n.getSource("textColor")==="authored"}},rc=(e,t)=>{const r=e.get("fontFamily")??t.get("fontFamily"),n=e.get("textColor"),a=e.explain("textColor").origin?.list;return{...r===void 0?{}:{fontFamily:r},fontSize:e.get("fontSize")*t.get("textScale"),fontWeight:e.get("fontWeight"),lineHeight:e.get("lineHeight"),...n!==void 0&&a!==void 0&&a!=="builtin"?{textColor:n}:{},...lc(e)}},nc=e=>({box:e.tooltip().resolve(),heading:e.tooltip.heading().resolve(),label:e.tooltip.label().resolve(),value:e.tooltip.value().resolve(),primaryRow:e.tooltip.primaryRow().resolve()}),ac=e=>({item:e.legendItem().resolve(),swatch:e.legendItem.swatch().resolve()}),ic=e=>{const t=e.directLabel();return{...t.resolve(),isTextColorAuthored:t.getSource("textColor")==="authored"}},oc=(e,t)=>{const r=e.headlineItem,n=r.number().resolve(),a={...n,fontSize:n.fontSize*xr[t]},i=r.number.center(),o=i.resolve().fontSize;return{number:a,...cc(i)?{numberCenter:xe(i,o===void 0?a.fontSize:o*xr[t])}:{},caption:xe(r.caption(),r.caption().resolve().fontSize*Qe[t]),label:xe(r.label(),r.label().resolve().fontSize*Qe[t]),swatch:r.swatch().resolve(),trend:xe(r.trend(),r.trend().resolve().fontSize*Qe[t]),trendUp:r.trend.up().resolve(),trendDown:r.trend.down().resolve(),trendFlat:r.trend.flat().resolve()}},sc=(e,t)=>{const r=t?e.numberCenter:void 0;return r===void 0?e.number:{...e.number,...ra(r)}},lc=e=>{const t={};for(const r of Qn){const n=e.get(r);n!==void 0&&Object.assign(t,{[r]:n})}return t},cc=e=>ea.some(t=>e.getSource(t)!=="unresolved"),xe=(e,t)=>({...ra(e.resolve()),fontSize:t}),ra=e=>{const t={};for(const r of ea){const n=e[r];n!==void 0&&Object.assign(t,{[r]:n})}return t},na=({labelPosition:e,measuredTextWidth:t,label:r})=>{const n=t+2*r.paddingInline,a=ta(r)+2*r.paddingBlock;return{x:e.x-n/2,y:e.y-a/2,width:n,height:a}};function*uc({annotations:e,mainAxis:t,panelRect:r,locale:n,resolveStyle:a,measureLabel:i}){for(const o of e.differenceArrows){if(!l.isPointWithinPanel(o.start.x,o.start.y)||!l.isPointWithinPanel(o.end.x,o.end.y))continue;const s=a(o.id),c=Jn({arrow:o,style:s,mainAxis:t,panelWidth:r.width,panelHeight:r.height,locale:n}),u=na({labelPosition:c.labelPosition,measuredTextWidth:i(c.labelText,s.label).width,label:s.label});yield{...u,x:r.x+u.x,y:r.y+u.y}}}var dc=e=>{const t=e.padding,r=Ar(e.rows,t?.top??0,t?.bottom??0),n=Ar(e.cols,t?.left??0,t?.right??0);return{rows:r.tracks,cols:n.tracks,placements:fc(e.placements,r.nameToIndex,n.nameToIndex),width:e.containerSize.width,height:e.containerSize.height}},mc=e=>{const t=Ir(e.rows,e.height),r=Ir(e.cols,e.width),n=Tr(t),a=Tr(r),i=new Map;for(const o of e.placements){const s=o.rowSpan??1,c=o.colSpan??1,u=a[o.col]??0,d=n[o.row]??0,h=Lr(r,o.col,c),p=Lr(t,o.row,s);i.set(o.name,{x:u,y:d,width:Math.max(0,h),height:Math.max(0,p)})}return i},Ar=(e,t,r)=>{const n=[],a=new Map;t>0&&n.push({type:"fixed",pixels:t});let i=0;for(let o=0;o<e.length;o++){const s=e[o];if(!s)continue;dt(s)&&i>0&&(n.push({type:"fixed",pixels:i}),i=0),a.set(s.name,n.length),n.push(hc(s));const c=pc(e,o);if(dt(s)&&c){const u=s.gaps?.after??0,d=c.gaps?.before??0;u>=d?u>0&&n.push({type:"fixed",pixels:u}):i=d}}return r>0&&n.push({type:"fixed",pixels:r}),{tracks:n,nameToIndex:a}},hc=e=>typeof e.size=="number"?{type:"fixed",pixels:e.size}:{type:"flex",weight:e.size.flex},dt=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,pc=(e,t)=>{for(let r=t+1;r<e.length;r++){const n=e[r];if(n&&dt(n))return n}},fc=(e,t,r)=>{const n=[];for(const a of e){const i=t.get(a.row),o=r.get(a.col);if(i===void 0||o===void 0)continue;const s=a.rowEnd!==void 0?t.get(a.rowEnd):i,c=a.colEnd!==void 0?r.get(a.colEnd):o;s===void 0||c===void 0||n.push({name:a.name,row:i,col:o,rowSpan:Math.max(1,s-i+1),colSpan:Math.max(1,c-o+1)})}return n},Ir=(e,t)=>{let r=0,n=0;for(const i of e)i.type==="fixed"?r+=i.pixels:n+=i.weight;const a=Math.max(0,t-r);return e.map(i=>i.type==="fixed"?i.pixels:n===0?0:i.weight/n*a)},Tr=e=>{const t=new Array(e.length);let r=0;for(let n=0;n<e.length;n++)t[n]=r,r+=e[n]??0;return t},Lr=(e,t,r)=>{let n=0;const a=Math.min(t+r,e.length);for(let i=t;i<a;i++)n+=e[i]??0;return n},J={top:0,right:0,bottom:0,left:0},aa={outer:J,inner:J},gc=(e,t,r,n=J,a=aa,i=l.DEFAULT_GRAPH_PADDING_EDGES_PX,o)=>{const s={top:a.inner.top+n.top,right:a.inner.right+n.right,bottom:a.inner.bottom+n.bottom,left:a.inner.left+n.left},c=r.axes.top>0||r.axesLabels.top>0?r.axesLabels.top:Math.max(r.axesLabels.top,r.axesLabels.left,r.axesLabels.right),u=[{name:"header",size:t.headerSize.height,gaps:G(o.header)},{name:"topLegend",size:r.legends.top,gaps:G(o.legend.top)},{name:"headline",size:r.headline,gaps:G(o.headline)},{name:"topAxisLabel",size:c,gaps:G(o.axisLabel.top)},{name:"topAxis",size:r.axes.top,gaps:G(o.tickLabel.top)},{name:"topPanelOuter",size:a.outer.top},{name:"topPanelInner",size:s.top},{name:"panel",size:{flex:1}},{name:"bottomPanelInner",size:s.bottom},{name:"bottomPanelOuter",size:a.outer.bottom},{name:"bottomAxis",size:r.axes.bottom,gaps:G(o.tickLabel.bottom)},{name:"bottomAxisLabel",size:r.axesLabels.bottom,gaps:G(o.axisLabel.bottom)},{name:"bottomLegend",size:r.legends.bottom,gaps:G(o.legend.bottom)},{name:"footer",size:t.footerSize.height,gaps:G(o.footer)}],d=[{name:"leftLegend",size:r.legends.left,gaps:Ae(o.legend.left)},{name:"leftAxis",size:r.axes.left,gaps:Ae(o.tickLabel.left)},{name:"leftPanelOuter",size:a.outer.left},{name:"leftPanelInner",size:s.left},{name:"panel",size:{flex:1}},{name:"rightPanelInner",size:s.right},{name:"rightPanelOuter",size:a.outer.right},{name:"rightAxis",size:r.axes.right,gaps:Ae(o.tickLabel.right)},{name:"rightLegend",size:r.legends.right,gaps:Ae(o.legend.right)}],h=Er(u,i.top,i.bottom),p=Er(d,i.left,i.right);return dc({rows:u,cols:d,placements:[{name:"header",row:"header",col:"leftLegend",colEnd:"rightLegend"},{name:"headline",row:"headline",col:"leftLegend",colEnd:"rightLegend"},{name:"footer",row:"footer",col:"leftLegend",colEnd:"rightLegend"},{name:"plot",row:"topAxisLabel",rowEnd:"bottomAxisLabel",col:"leftAxis",colEnd:"rightAxis"},{name:"panelFrame",row:"topPanelInner",rowEnd:"bottomPanelInner",col:"leftPanelInner",colEnd:"rightPanelInner"},{name:"panel",row:"panel",col:"panel"},...yc(r.axes),...Sc(r.axesLabels,r.axes),...bc(r.legends)],containerSize:e,padding:{top:h.start,bottom:h.end,left:p.start,right:p.end}})},G=e=>({before:e.top,after:e.bottom}),Ae=e=>({before:e.left,after:e.right}),vc=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Er=(e,t,r)=>{const n=e.filter(vc),a=n[0],i=n[n.length-1];return{start:t+(a?.gaps?.before??0),end:r+(i?.gaps?.after??0)}},yc=e=>{const t=[];return e.top>0&&t.push({name:"topAxis",row:"topAxis",col:"panel"}),e.bottom>0&&t.push({name:"bottomAxis",row:"bottomAxis",col:"panel"}),e.left>0&&t.push({name:"leftAxis",row:"panel",col:"leftAxis"}),e.right>0&&t.push({name:"rightAxis",row:"panel",col:"rightAxis"}),t},Sc=(e,t)=>{const r=[];return e.top>0||t.top>0?(e.top>0&&r.push({name:"topAxisLabel",row:"topAxisLabel",col:"panel"}),e.left>0&&r.push({name:"leftAxisLabel",row:"topAxis",col:"leftAxis"}),e.right>0&&r.push({name:"rightAxisLabel",row:"topAxis",col:"rightAxis"})):(e.left>0&&r.push({name:"leftAxisLabel",row:"topAxisLabel",col:"leftAxis"}),e.right>0&&r.push({name:"rightAxisLabel",row:"topAxisLabel",col:"rightAxis"})),e.bottom>0&&r.push({name:"bottomAxisLabel",row:"bottomAxisLabel",col:"panel"}),r},bc=e=>{const t=[];return e.top>0&&t.push({name:"topLegend",row:"topLegend",col:"leftAxis",colEnd:"rightAxis"}),e.bottom>0&&t.push({name:"bottomLegend",row:"bottomLegend",col:"leftAxis",colEnd:"rightAxis"}),e.left>0&&t.push({name:"leftLegend",row:"panel",col:"leftLegend"}),e.right>0&&t.push({name:"rightLegend",row:"panel",col:"rightLegend"}),t};var xc=class{constructor(e){this.outer={...J},this.inner={...J},this.currentPanelRect=e}resolve(){return{outer:{...this.outer},inner:{...this.inner}}}add(e,t){const r=this.computeEdgeOverflow(e,8),n=this.computeEdgeOverflow(e,0);this.growEdge("left",t.x,r.left,n.left),this.growEdge("right",t.x,r.right,n.right),this.growEdge("top",t.y,r.top,n.top),this.growEdge("bottom",t.y,r.bottom,n.bottom)}computeEdgeOverflow(e,t){const r=this.currentPanelRect;return{top:Math.max(Math.ceil(r.y+t-e.y),0),right:Math.max(Math.ceil(e.x+e.width-(r.x+r.width-t)),0),bottom:Math.max(Math.ceil(e.y+e.height-(r.y+r.height-t)),0),left:Math.max(Math.ceil(r.x+t-e.x),0)}}growEdge(e,t,r,n){t!=="none"&&(t==="outside"?n>0&&(this.outer[e]=Math.max(this.outer[e],n)):r>0&&(this.inner[e]=Math.max(this.inner[e],r)))}},Ac=["top","right","bottom","left"],et=(e,t)=>{const r={};for(const n of Ac){const a=e.get(`${n}${t}`);a&&(r[n]=a)}return r};function Rr(e,t){return e.top===t.top&&e.right===t.right&&e.bottom===t.bottom&&e.left===t.left}var mt=["large","medium","small"],Ic=({size:e,availableWidth:t,measureStripWidth:r})=>{if(e!=="auto")return e;for(const n of mt)if(r(n)<=t)return n;return"small"},Tc=({size:e,availableWidth:t,measureStripWidth:r})=>{const n=e==="auto"?0:mt.indexOf(e);for(const a of mt.slice(n))if(r(a)<=t)return a;return null},Lc=({itemWidths:e,gap:t,availableWidth:r})=>{let n=0,a=0;for(const i of e){const o=a===0?i:n+t+i;if(o>r)break;n=o,a+=1}return a},Ec=({headline:e,containerSize:t,measurer:r})=>{if(Fe(e))return 0;const n=ia(e,t.width,r);return r.measureHeadline(e.formatted,n).height},Rc=({headline:e,layout:t,containerSize:r,measurer:n,itemGap:a})=>{if(Fe(e)){const s=Cc(t.panel,e.innerRadius),c=Tc({size:e.size,availableWidth:s.width,measureStripWidth:oa(e,n)});return c===null?null:{rect:s,resolvedSize:c,visibleItemCount:1}}const i=ia(e,r.width,n);if(e.formatted.kind!=="perGroup")return{rect:t.headline,resolvedSize:i,visibleItemCount:1};const o=Lc({itemWidths:n.measureHeadlineItemWidths(e.formatted,i),gap:a,availableWidth:t.headline.width});return o===0?null:{rect:t.headline,resolvedSize:i,visibleItemCount:o}},Fe=e=>e.formatted.kind==="grandTotal"&&e.position==="center"&&e.innerRadius>0,Cc=(e,t)=>{const r=t*(Math.min(e.width,e.height)/2)*Math.SQRT2,n=e.x+e.width/2,a=e.y+e.height/2;return{x:n-r/2,y:a-r/2,width:r,height:r}},ia=(e,t,r)=>Ic({size:e.size,availableWidth:t,measureStripWidth:oa(e,r)}),oa=(e,t)=>r=>t.measureHeadline(e.formatted,r,Fe(e)).width,X={x:0,y:0,width:0,height:0},wc={top:0,right:0,bottom:0,left:0},Pc="0000",Mc=3,Dc=e=>e.plot.y+e.plot.height-e.panel.y,Oc=class{constructor(e){this.measurer=e}compile(e){return m.createPipeline({axes:e.axes,numberFormat:e.numberFormat,formattedLegends:e.formattedLegends,containerSize:e.containerSize,externalMeasurements:e.externalMeasurements,panelOverflow:aa,panelBorder:e.panelBorder??J,headline:e.headline,locale:e.formattingLocale??e.parsingLocale,padding:e.padding??l.DEFAULT_GRAPH_PADDING_EDGES_PX,margins:e.margins}).pipe(({axes:t,numberFormat:r,locale:n})=>({axisBundles:t.map(a=>({axis:a,resolveFormatter:_c(a,n,r),formatted:this.seedAxis(a)}))})).pipe(({axisBundles:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})=>({layout:this.resolveLayout({axes:t.map(d=>d.formatted),formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})})).pipe(({axisBundles:t,layout:r})=>({axisBundles:t.map(n=>Cr(n.axis.position)?{...n,formatted:this.finalizeAxis(n.axis,n.resolveFormatter,r.panelFrame)}:n)})).pipe(({axisBundles:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})=>({layout:this.resolveLayout({axes:t.map(d=>d.formatted),formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})})).pipe(({axisBundles:t,layout:r})=>({formattedAxes:t.map(n=>Cr(n.axis.position)?n.formatted:this.finalizeAxis(n.axis,n.resolveFormatter,r.panelFrame))})).pipe(({formattedAxes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})=>({layout:this.resolveLayout({axes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})})).pipe(({formattedAxes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,layout:i,panelOverflow:o,panelBorder:s,headline:c,locale:u,padding:d,margins:h})=>({formattedAxes:t,layout:this.settlePanelOverflow({input:e,layout:i,formattedAxes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:o,panelBorder:s,headline:c,locale:u,padding:d,margins:h})})).pipe(({formattedAxes:t,layout:r})=>{const n=this.applyPolarPanelInset(e,t,r);return{formattedAxes:t,layout:n,plotBottomY:Dc(n)}}).result()}measurePanelOverflow(e,t,r,n){if(!e.overflowStrategy||e.coordSystem?.type!=="cartesian")return n;const a=new xc(t);if(e.annotations&&e.resolveDifferenceArrowStyle&&e.overflowStrategy.differenceArrows)for(const o of uc({annotations:e.annotations,mainAxis:e.coordSystem.mainAxis,panelRect:t,locale:r,resolveStyle:e.resolveDifferenceArrowStyle,measureLabel:this.measurer.measureDifferenceArrowLabel}))a.add(o,e.overflowStrategy.differenceArrows);if(e.layers&&e.layers.length>0&&e.readers&&e.overflowStrategy.dataLabels)for(const o of Bl({layers:e.layers,coordSystem:e.coordSystem,axes:e.axes,numberFormat:e.numberFormat,panelRect:t,measureDataLabel:this.measurer.measureDataLabel,readers:e.readers,locale:r,resolvePlacement:e.resolvePlacement}))a.add(o,e.overflowStrategy.dataLabels);const i=a.resolve();return Rr(i.inner,n.inner)&&Rr(i.outer,n.outer)?n:i}settlePanelOverflow({input:e,layout:t,formattedAxes:r,formattedLegends:n,containerSize:a,externalMeasurements:i,panelOverflow:o,panelBorder:s,headline:c,locale:u,padding:d,margins:h}){let p=t,f=o;for(let g=0;g<Mc;g++){const S=this.measurePanelOverflow(e,p.panelFrame,u,f);if(S===f)break;f=S,p=this.resolveLayout({axes:r,formattedLegends:n,containerSize:a,externalMeasurements:i,panelOverflow:S,panelBorder:s,headline:c,padding:d,margins:h})}return p}applyPolarPanelInset(e,t,r){if(e.coordSystem?.type!=="polar")return r;const n=this.measurePolarRimInset(t),{panel:a}=r,i=a.width-n.horizontal*2,o=a.height-n.vertical*2;return i<=0||o<=0?wr(r,a,0,0):wr(r,a,n.horizontal,n.vertical)}measurePolarRimInset(e){const t=e.find(i=>i.geometry==="circular");if(!t)return{horizontal:0,vertical:0};const r=l.getAestheticFromScaleAestheticKey(t.scaleAestheticKey);let n=0,a=0;for(const i of t.ticks){const o=this.measurer.measureTickLabel(i.formattedLabel,r);n=Math.max(n,o.width),a=Math.max(a,o.height)}return n===0?{horizontal:0,vertical:0}:{horizontal:n+8,vertical:a+8}}seedAxis(e){const{tickCandidates:t,...r}=e;return{...r,ticks:[{value:0,position:0,formattedLabel:Pc}],labelRotation:0,labelMaxWidthPx:null}}finalizeAxis(e,t,r){const n=e.position==="top"||e.position==="bottom"?r.width:r.height,a=l.getAestheticFromScaleAestheticKey(e.scaleAestheticKey),i=d=>this.measurer.measureTickLabel(d,a),o=xl({axis:e,availableSpacePx:n,measureLabel:i,resolveFormatter:t}),{tickCandidates:s,...c}=e,u={...c,ticks:o,labelRotation:0,labelMaxWidthPx:null};return e.geometry!=="linear"?u:e.scaleType==="discrete"&&e.bandwidth!==void 0?fl({formattedAxis:u,bandwidthPx:e.bandwidth*n,panelRect:r,measureLabel:i}):u}resolveLayout({axes:e,formattedLegends:t,containerSize:r,externalMeasurements:n,panelOverflow:a,panelBorder:i,headline:o,padding:s,margins:c}){const u=mc(gc(r,n,this.measureGuides(e,t,o,r),i,a,s,kc(c,t)));return{header:u.get("header")??X,headline:u.get("headline")??X,footer:u.get("footer")??X,plot:u.get("plot")??X,panelFrame:u.get("panelFrame")??X,panel:u.get("panel")??X,axes:et(u,"Axis"),axisLabels:et(u,"AxisLabel"),legends:et(u,"Legend")}}measureGuides(e,t,r,n){const a={top:0,right:0,bottom:0,left:0},i={top:0,right:0,bottom:0,left:0};for(const s of e)s.isVisible&&s.geometry==="linear"&&(a[s.position]=this.measurer.measureAxis(s),s.label!==null&&(i[s.position]=this.measurer.measureAxisLabel(s)));const o={top:0,right:0,bottom:0,left:0};for(const s of t)o[s.position]=this.measurer.measureLegend(s);return{axes:a,axesLabels:i,legends:o,headline:this.measureHeadlineBand(r,n)}}measureHeadlineBand(e,t){return e===void 0?0:Ec({headline:e,containerSize:t,measurer:this.measurer})}},Cr=e=>e==="left"||e==="right",wr=(e,t,r,n)=>{const a=t.width-r*2,i=t.height-n*2,o=Math.min(a,i);return{...e,panel:{x:t.x+r+(a-o)/2,y:t.y+n+(i-o)/2,width:o,height:o}}},_c=(e,t,r)=>{const n=new WeakMap;return a=>{const i=n.get(a);if(i)return i;const o=Pt({valueFormat:a.valueFormat??e.valueFormat,locale:t,numberFormat:r,tickValues:a.ticks.map(s=>s.value)});return n.set(a,o),o}},kc=(e,t)=>{const r={...e.legend};for(const n of t)n.display==="direct"&&(r[n.position]=wc);return{...e,legend:r}},Vc=(e=[])=>{const t=Nc(e);return{resolve:(r,n,a)=>{if(!t.has(r))return null;const i=t.get(r).resolveAnchorPosition?.(n,a)??null;return i===null?null:{...i,space:m.resolveGeomAnchorSpace(a.coordSystem)}},hasCapability:r=>t.has(r)&&t.get(r).resolveAnchorPosition!==void 0,createLayerMeasurement:r=>t.has(r.geom)?m.createLayerMeasurement(r,t.get(r.geom)):null}},Nc=e=>{const t=new l.GeomRegistry;for(const r of e){const n=l.resolveDefinition(r);n instanceof l.Geom&&t.register(n.type,n)}return t};function Fc(e){return e}function F(e){return 1-e}var K=e=>`${Number.parseFloat((e*100).toFixed(4))}%`,Pe=(e,t)=>{const r=m.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+F(e.y)*r.height}},sa=(e,t)=>{const r=m.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+(F(e.y)-e.height)*r.height,width:e.width*r.width,height:e.height*r.height}},Bc=class{constructor(e,t,r){this.annotations=e,this.panelRect=t,this.measuredBoxes=r,this.index=null,this.boxes=new Map,this.resolvingStack=[],this.cyclic=new Set,this.missingRefs=new Set}cyclicIds(){return[...this.cyclic]}missingRefIds(){return[...this.missingRefs]}resolvePoint(e){if(e.defer===void 0)return e;if(e.defer.type==="px-offset"){const i=this.toPanelPoint(e),{x:o,y:s}=ht(e.defer,this.panelRect);return Dr({...e,x:i.x+o,y:i.y-s})}const t=this.boxOf(e.defer.ref);if(t===null)return null;const r=l.alignToBoxPoint(t,e.defer.align),{x:n,y:a}=Gc(r,e.defer.offset,this.panelRect);return{x:n,y:a}}resolveRegion(e){if(e.defer===void 0)return e;if(e.defer.type==="px-offset"){const a=this.toPanelRegion(e),{x:i,y:o}=ht(e.defer,this.panelRect);return Dr({...e,x:a.x-i,y:a.y-o,width:Math.max(0,a.width+2*i),height:Math.max(0,a.height+2*o)})}const t=this.boxOf(e.defer.ref);if(t===null)return null;const r=t.xMax-t.xMin,n=t.yMax-t.yMin;return r<=0||n<=0?null:{x:t.xMin,y:t.yMin,width:r,height:n}}getTargetIndex(){if(this.index!==null)return this.index;const{annotations:e}=this,t=new Map,r=(n,a)=>{t.has(n)||t.set(n,a)};for(const n of e.shapes)r(n.id,{kind:"shape",annotation:n});for(const n of e.images)r(n.id,{kind:"image",annotation:n});for(const n of e.arrows)r(n.id,{kind:"arrow",annotation:n});for(const n of e.textAnnotations)r(n.id,{kind:"text",annotation:n});for(const n of e.stickers)r(n.id,{kind:"sticker",annotation:n});for(const n of e.differenceArrows)r(n.id,{kind:"differenceArrow",annotation:n});for(const n of e.pinnedNumbers)r(n.id,{kind:"pinnedNumber",annotation:n});for(const n of e.comments)r(n.id,{kind:"comment",annotation:n});return this.index=t,t}boxOf(e){const t=this.boxes.get(e);if(t!==void 0)return t;const r=this.resolvingStack.indexOf(e);if(r!==-1){for(const i of this.resolvingStack.slice(r))this.cyclic.add(i);return null}const n=this.getTargetIndex().get(e);if(n===void 0)return this.missingRefs.add(e),null;this.resolvingStack.push(e);const a=this.deriveBox(e,n);return this.resolvingStack.pop(),this.boxes.set(e,a),a}deriveBox(e,t){switch(t.kind){case"shape":case"image":{const r=this.resolveRegion(t.annotation.region);return r===null?null:Hc(this.toPanelRegion(r))}case"arrow":{const r=this.resolvePoint(t.annotation.start),n=this.resolvePoint(t.annotation.end);return r===null||n===null?null:Pr(this.toPanelPoint(r),this.toPanelPoint(n))}case"text":{const r=this.resolvePoint(t.annotation.at);if(r===null)return null;const n=this.measuredBoxes?.get(e);if(n===void 0||n.height<=0||this.panelRect.height<=0)return null;const a=this.toPanelPoint(r),i=t.annotation.width,o=n.height/this.panelRect.height,s=l.alignUnitFractions(t.annotation.align),c=a.x-s.x*i,u=a.y+(1-s.y)*o;return{xMin:c,xMax:c+i,yMin:u-o,yMax:u}}case"sticker":{const r=this.resolvePoint(t.annotation.at);return r===null?null:Mr(this.toPanelPoint(r))}case"differenceArrow":return Pr(this.toPanelPoint(t.annotation.start),this.toPanelPoint(t.annotation.end));case"pinnedNumber":case"comment":return Mr(this.toPanelPoint(t.annotation.at))}}toPanelPoint(e){return m.toPanelFraction(e,this.panelRect)}toPanelRegion(e){if(e.space!=="disk")return e;const t=m.toPanelFraction(e,this.panelRect),r=m.measureAnchorSpace(e.space,this.panelRect);return{...t,width:this.panelRect.width>0?e.width*r.width/this.panelRect.width:0,height:this.panelRect.height>0?e.height*r.height/this.panelRect.height:0}}},ht=(e,t)=>({x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0}),Gc=(e,t,r)=>{if(t===void 0)return e;const n=t.x??0,a=t.y??0;if(t.unit==="px"){const{x:i,y:o}=ht({type:"px-offset",x:n,y:a},r);return{x:e.x+i,y:e.y-o}}return{x:e.x+n,y:e.y-a}},Hc=e=>({xMin:e.x,xMax:e.x+e.width,yMin:e.y,yMax:e.y+e.height}),Pr=(e,t)=>({xMin:Math.min(e.x,t.x),xMax:Math.max(e.x,t.x),yMin:Math.min(e.y,t.y),yMax:Math.max(e.y,t.y)}),Mr=e=>({xMin:e.x,xMax:e.x,yMin:e.y,yMax:e.y}),Dr=e=>{const t={...e};return delete t.defer,delete t.space,t},$c=e=>{const{annotations:t,panelRect:r,measuredBoxes:n,onCycle:a,onMissingRef:i}=e;if(!zc(t))return t;const o=new Bc(t,r,n),s={...t,shapes:te(t.shapes,d=>d.region.defer!==void 0,d=>{const h=o.resolveRegion(d.region);return h===null?null:{...d,region:h}}),images:te(t.images,d=>d.region.defer!==void 0,d=>{const h=o.resolveRegion(d.region);return h===null?null:{...d,region:h}}),arrows:te(t.arrows,d=>d.start.defer!==void 0||d.end.defer!==void 0,d=>{const h=o.resolvePoint(d.start),p=o.resolvePoint(d.end);return h===null||p===null?null:{...d,start:h,end:p}}),textAnnotations:te(t.textAnnotations,d=>d.at.defer!==void 0,d=>{const h=o.resolvePoint(d.at);return h===null?null:{...d,at:h}}),stickers:te(t.stickers,d=>d.at.defer!==void 0,d=>{const h=o.resolvePoint(d.at);return h===null?null:{...d,at:h}})},c=o.cyclicIds();c.length>0&&a?.(c);const u=o.missingRefIds();return u.length>0&&i?.(u),s},te=(e,t,r)=>e.some(t)?e.flatMap(n=>{if(!t(n))return[n];const a=r(n);return a===null?[]:[a]}):e,zc=e=>e.shapes.some(t=>t.region.defer!==void 0)||e.images.some(t=>t.region.defer!==void 0)||e.arrows.some(t=>t.start.defer!==void 0||t.end.defer!==void 0)||e.textAnnotations.some(t=>t.at.defer!==void 0)||e.stickers.some(t=>t.at.defer!==void 0),la=(e,t)=>{if(!(e===void 0||e.length===0||t<=0))return e.map(r=>r*t).join(" ")},Ot=e=>e===void 0||e.length===0?"solid":(e[0]??0)<=1?"dotted":"dashed",_t=(e,t)=>e===t?!0:e===void 0||t===void 0||e.length!==t.length?!1:e.every((r,n)=>r===t[n]),Kc=800,Or=400,Yc=.75,Uc=.875,Wc=4,Xc=e=>Math.max(1,(e-Or)/(Kc-Or)+1),qc=(e,t)=>{const r=Xc(t),n=e*Wc;return{strokeWidth:Math.min(e,e*Yc*r),arrowheadLength:Math.min(n,n*Uc*r)}},Ie=Math.PI/4,jc=({start:e,end:t})=>`M ${e.x} ${e.y} L ${t.x} ${t.y}`,_r=(e,t,r)=>{if(r<=0)return"";const{start:n,end:a}=t,i=e==="start"?n.x:a.x,o=e==="start"?n.y:a.y,s=e==="start"?Math.atan2(n.y-a.y,n.x-a.x):Math.atan2(a.y-n.y,a.x-n.x);return`M ${i} ${o} L ${i-r*Math.cos(s-Ie)} ${o-r*Math.sin(s-Ie)} M ${i} ${o} L ${i-r*Math.cos(s+Ie)} ${o-r*Math.sin(s+Ie)}`},Zc=64,Jc=({arrow:e,style:t,panelWidth:r,panelHeight:n})=>{const a={width:r,height:n},i={start:Pe(e.start,a),end:Pe(e.end,a)};if(i.start.x===i.end.x&&i.start.y===i.end.y)return null;const{strokeWidth:o,arrowheadLength:s}=qc(t.strokeWidth,r),c=Math.hypot(i.end.x-i.start.x,i.end.y-i.start.y),u=Qc(s,c),d=e.startArrowheadStyle==="line-arrow",h=e.endArrowheadStyle==="line-arrow",p=d||h?u*Math.sin(Math.PI/4):0;return{id:e.id,linePath:jc(i),startArrowheadPath:d?_r("start",i,u):"",endArrowheadPath:h?_r("end",i,u):"",strokeWidth:o,dashArray:la(t.dashArray,o)??null,startX:i.start.x,startY:i.start.y,endX:i.end.x,endY:i.end.y,dashOffset:eu(t.dashArray,o,d),arrowheadExtent:p}},Qc=(e,t)=>Math.min(e,t*e/Zc),eu=(e,t,r)=>{const n=e[0]??0;return r&&n>1?n*t:0};function tu(e,t){const r=new Map;if(!t||t.kind!=="visual"||t.domain.length<=1)return r;for(const n of e){if(n.geom!=="rule"||n.stat.type!=="mean")continue;const a=n.transforms.find(h=>h.transformType==="filter"&&h.options.operator==="eq"),i=l.readVariableName(n.mapping.y);let o,s,c;if(a?.transformType==="filter"&&typeof a.options.value=="string")o="color",s=a.options.variableName,c=a.options.value;else if(i!==null)o="y",s=i,c=i;else continue;const u=ru(e,o,s);if(u===null)continue;const d=t.map(c);l.isStrictCategoricalDataValue(d)&&r.set(n.id,{geom:u.geom,color:d,layerId:u.id,groupValue:c})}return r}function ru(e,t,r){let n=null;for(const a of e)if(a.geom!=="rule"&&(n===null&&(n=a),l.readVariableName(a.mapping[t])===r))return a;return n}var ca=(e,t)=>({x:e.x/t.width,y:1-e.y/t.height}),nu=0,au=(e,t)=>e.filter(r=>r.inView).map(r=>({shape:{kind:"rect",rect:r.miniRect},cursor:ca(r.anchorPx,t),tooltip:{kind:"pinned",point:r.anchorPx,placement:r.placement,annotationId:r.id},priority:nu})),iu=9,ou=8,su=2,ua=e=>typeof e=="string"?e:da(e),da=e=>e.text!==void 0?e.text:e.content?e.content.map(da).join(""):"",kr={top:"bottom",bottom:"top",right:"left",left:"right"};function lu(e,t,r){return r.type==="polar"?du(e,t):r.mainAxis==="y"?["right","left","top","bottom"]:["top","bottom","right","left"]}function pt(e,t,r){const{width:n,height:a}=r;switch(t){case"top":return{x:e.x-n/2,y:e.y-9-a,width:n,height:a};case"bottom":return{x:e.x-n/2,y:e.y+9,width:n,height:a};case"right":return{x:e.x+9,y:e.y-a/2,width:n,height:a};case"left":return{x:e.x-9-n,y:e.y-a/2,width:n,height:a}}}function Vr(e,t){return e.x>=0&&e.y>=0&&e.x+e.width<=t.width&&e.y+e.height<=t.height}function cu(e,t){return{...t,x:Math.max(0,Math.min(t.x,e.width-t.width)),y:Math.max(0,Math.min(t.y,e.height-t.height))}}function uu(e,t,r=2){return e.x<t.x+t.width-r&&e.x+e.width>t.x+r&&e.y<t.y+t.height-r&&e.y+e.height>t.y+r}function du(e,t){const r=e.x-t.width/2,n=e.y-t.height/2,a=r>=0?"right":"left",i=n>=0?"bottom":"top",[o,s]=Math.abs(r)>=Math.abs(n)?[a,i]:[i,a];return[o,kr[o],s,kr[s]]}function mu(e){const{pinnedNumbers:t,comments:r,panelRect:n,coordSystem:a,measurer:i,formatPinnedNumber:o}=e,s=[...t.map(d=>{const{id:h,at:p}=d;return Nr(h,"pinned-number",p,o(d),i,n)}),...r.map(({id:d,at:h,content:p})=>Nr(d,"comment",h,ua(p),i,n))];s.sort((d,h)=>d.anchorPx.x-h.anchorPx.x||d.anchorPx.y-h.anchorPx.y);const c=[],u=[];for(const d of s){if(!d.inView){c.push(Fr(n,d,"top"));continue}const h=Fr(n,d,pu(n,d,a,u));c.push(h),u.push(h.miniRect)}return c}function Nr(e,t,r,n,a,i){const o=Pe(r,i);return{id:e,kind:t,anchor:r,anchorPx:o,mini:a(t,e,n),inView:hu(o,i)}}function hu(e,t){return e.x>=-8&&e.y>=-8&&e.x<=t.width+8&&e.y<=t.height+8}function pu(e,t,r,n){const a=lu(t.anchorPx,e,r);for(const i of a){const o=pt(t.anchorPx,i,t.mini);if(Vr(o,e)&&!n.some(s=>uu(o,s)))return i}for(const i of a)if(Vr(pt(t.anchorPx,i,t.mini),e))return i;return"top"}function Fr(e,t,r){return{id:t.id,kind:t.kind,anchorPx:t.anchorPx,placement:r,miniRect:cu(e,pt(t.anchorPx,r,t.mini)),text:t.mini.text,inView:t.inView}}var fu=(e,t)=>Dt().hasCapability(e,t),gu=({layers:e,coordSystem:t,axes:r,numberFormat:n,parsingLocale:a,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:c,plotBottomY:u,isFooterChromeReserved:d,resolvePlacement:h=Dt()})=>{const p=[],f=c??a,g=t.type;let S=0;for(const x of e){if(!x.dataLabels.showDataLabels&&!x.dataLabels.showStackTotals&&!x.dataLabels.showCategoryLabels)continue;const A=h.resolve(x.geom,g);if(A===null)continue;const T=Wn({layer:x,coordSystem:t,axes:r,numberFormat:n,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:f,percentageValueStrategy:A.getPercentageValueStrategy(x)}),E=A.place(T);S+=E.droppedCount;for(const W of E.labels)yu(W,g,u,d)||p.push(W)}return{labels:p,warnings:S>0?[vu(S)]:[]}},vu=e=>({code:"DATA_LABELS_DROPPED",severity:"warning",kind:"user-input",message:e===1?"Dropped 1 data label that did not fit under position 'auto'.":`Dropped ${e} data labels that did not fit under position 'auto'.`,suggestion:"Set dataLabels.position to 'outside' to keep labels that do not fit inside the bars.",context:{actual:e}}),yu=(e,t,r,n)=>t==="polar"&&n&&e.position==="outside"&&e.y+e.height/2>r,Su=(e,t,r)=>e.anchor.layerId!==t.anchor.layerId||!l.areDataValuesEqual(e.anchor.groupValue??null,t.anchor.groupValue??null)||r.start===void 0||r.start!==r.end?null:r.start,bu=100,xu=({items:e,containerHeight:t,labelHeight:r})=>{const n=e.map(c=>{const u=(1-c.normalizedY)*t;return{anchorY:u,y:u,payload:c.payload}}).sort((c,u)=>c.y-u.y),a=r/2;let i=!1,o=!0,s=0;for(;o;){o=!1,s++;for(let c=0;c<n.length-1;c++){const u=n[c],d=n[c+1];if(!u||!d)continue;const h=u.y+a,p=d.y-a;if(h>p){o=!0,i=!0;const f=(h-p)/2+1;u.y-=f,d.y+=f,u.y<0&&(u.y=0),d.y>t&&(d.y=t)}}if(s>bu)break}return{placements:n.filter(c=>c.y>=0&&c.y<=t).map(c=>({y:c.y,anchorY:c.anchorY,payload:c.payload})),hasOverlap:i}},Au=(e,t)=>ma(e,t,{variables:ha(e),allowNull:!1}),ma=(e,t,{variables:r,allowNull:n})=>{const a=m.createPredicateValueReader(e),i=[];for(const s of r){const c=a(t,s);if(c===null&&!n)return null;i.push({variable:s,eq:c})}const[o]=i;return o===void 0?null:i.length===1?o:{and:i}},ha=e=>{const t=m.shouldNarrowByGroup(e)?l.getGroupVariables(e.data,e.mapping):[],r=m.resolveCrossAnchorVariable(e),n=r===null?t:[...t,r],a=m.resolveAnchorVariable(e);return a===l.GROUP_VARIABLES.group?[...new Set(n)]:[...new Set([a,...n])]},Be=e=>e!=="data-point",Iu=(e,t)=>{switch(t){case"series":{const r=l.getGroupVariables(e.data,e.mapping);return r.length===0?Br(e):{variables:r,allowNull:!0}}case"x-value":{const r=m.readScopeXVariable(e.mapping);return r===null?null:{variables:[r],allowNull:!0}}case"data-point":return Br(e)}},Br=e=>typeof e.identityKey=="object"?{variables:[e.identityKey.variable],allowNull:!0}:e.identityKey==="index"?null:{variables:ha(e),allowNull:!1},re=[],Gr=new WeakMap,pa=(e,t,r)=>r<0||r>=e.data.size()?null:t==="data-point"?String(r):ae(e,t).keyByRow[r]??null,kt=(e,t,r)=>{if(t==="data-point"){const n=Number(r);return Number.isInteger(n)&&n>=0&&n<e.data.size()?[n]:re}return ae(e,t).rowsByKey.get(r)??re},Tu=(e,t)=>ae(e,t).keyByRow,Lu=(e,t,r,n)=>{if(r!=="data-point")return kt(e,r,n);const a=Number(n);if(!Number.isInteger(a)||a<0||a>=t.data.size())return re;const i=ae(t,"vertex").keyByRow[a];return i===void 0?re:ae(e,"vertex").rowsByKey.get(i)??re},ae=(e,t)=>{const r=Gr.get(e)??new Map;Gr.set(e,r);const n=r.get(t);if(n!==void 0)return n;const a=Ru(Eu(e,t));return r.set(t,a),a},Eu=(e,t)=>{const r=e.data.size(),n=t==="x-value"?null:Hr(e,l.GROUP_VARIABLES.group),a=t==="series"?null:m.readScopeXVariable(e.mapping),i=a===null?null:Hr(e,a),o=new Array(r);for(let s=0;s<r;s++){const c=n?.[s]??null,u=i?.[s]??null;t==="series"?o[s]=l.getStableKey([c]):t==="x-value"?o[s]=l.getStableKey([u]):o[s]=l.getStableKey([c,u])}return o},Hr=(e,t)=>e.data.hasVariable(t)?e.data.getValues(t):null,Ru=e=>{const t=new Map;return e.forEach((r,n)=>{const a=t.get(r);a===void 0?t.set(r,[n]):a.push(n)}),{keyByRow:e,rowsByKey:t}},Cu=({layer:e,observationIndex:t,scope:r,parsingLocale:n})=>{const a=e.data.getAt(t);if(a===null)return null;const i=_u(e,a,r);if(i===null)return null;const o=r==="data-point"?{kind:"observations",layerId:e.id,scope:r,predicate:i,observationIndex:t}:{kind:"observations",layerId:e.id,scope:r,predicate:i};return Ou(o,e,a,t,n)?o:null},wu=({layer:e,scope:t,variable:r,value:n,parsingLocale:a})=>{const i={kind:"observations",layerId:e.id,scope:Du(e,t,r),predicate:{variable:r,eq:n}};return Mu(i,e,a)?i:null},Pu=e=>e.identityKey==="x-group"?"series":l.getGroupVariables(e.data,e.mapping).length===0?"data-point":"series",Mu=(e,t,r)=>{if(m.findPredicateProblems(e.predicate,t.data).length>0)return!1;const n=m.compilePredicate(e.predicate,m.createPredicateCompileContext(t,r));for(const a of t.data)if(n(a))return!0;return!1},Du=(e,t,r)=>t==="series"&&!l.getGroupVariables(e.data,e.mapping).includes(r)?"data-point":t,Ou=(e,t,r,n,a)=>{if(m.findPredicateProblems(e.predicate,t.data).length>0)return!1;const i=m.compilePredicate(e.predicate,m.createPredicateCompileContext(t,a));if(i(r))return!0;if(!Be(e.scope))return!1;const o=pa(t,e.scope,n);return o===null?!1:kt(t,e.scope,o).some(s=>{const c=t.data.getAt(s);return c!==null&&i(c)})},_u=(e,t,r)=>{const n=Iu(e,r);return n===null?null:ma(e,t,n)},Vt=(e,t)=>{if(t.kind==="circle"){const n=e.x-t.center.x,a=e.y-t.center.y;return n*n+a*a<=t.radius*t.radius}const{rect:r}=t;return e.x>=r.x&&e.x<=r.x+r.width&&e.y>=r.y&&e.y<=r.y+r.height},ku=(e,t)=>{for(const r of t)if(Vt(e,r.shape))return r;return null},Vu=e=>{const t=[];for(const r of e.values())t.push(...r);return t.sort((r,n)=>n.priority-r.priority)},Nu=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>Fu(r,t[n])),Fu=(e,t)=>t===void 0?!1:e.priority===t.priority&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y&&Bu(e.shape,t.shape)&&Gu(e.tooltip,t.tooltip),Bu=(e,t)=>{if(e.kind!==t.kind)return!1;if(e.kind==="circle"){const n=t;return e.center.x===n.center.x&&e.center.y===n.center.y&&e.radius===n.radius}const{rect:r}=t;return e.rect.x===r.x&&e.rect.y===r.y&&e.rect.width===r.width&&e.rect.height===r.height},Gu=(e,t)=>{if(e.kind!==t.kind)return!1;if(e.kind==="cursor")return!0;const r=t;return e.point.x===r.point.x&&e.point.y===r.point.y&&e.placement===r.placement&&e.annotationId===r.annotationId},Hu=100,$u=e=>({shape:{kind:"circle",center:e.center,radius:e.radius},cursor:e.target.cursor,tooltip:{kind:"cursor"},priority:Hu}),zu=(e,t)=>Vt(e,{kind:"circle",center:t.center,radius:t.radius}),Ku=(e,t)=>e===t?!0:e===null||t===null?!1:e.center.x===t.center.x&&e.center.y===t.center.y&&e.radius===t.radius&&Yu(e.target,t.target),Yu=(e,t)=>e.kind===t.kind&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y,Uu=({layer:e,highlights:t,observation:r,parsingLocale:n})=>{if(e.highlight===null)return[];const a=m.createPredicateCompileContext(e,n),i=Wu(e,r);return t.filter(o=>{if(o.layerId!==void 0&&o.layerId!==e.id||m.findPredicateProblems(o.predicate,e.data).length>0)return!1;const s=m.compilePredicate(o.predicate,a);return s(r)?!0:Be(o.scope)&&i(o.scope).some(s)})},Wu=(e,t)=>{const r=m.readScopeXVariable(e.mapping),n=new Map;return a=>{const i=n.get(a);if(i!==void 0)return i;const o=m.readScopeKey(a,t,r),s=[];for(const c of e.data)m.readScopeKey(a,c,r)===o&&s.push(c);return n.set(a,s),s}},Ee=({layer:e,from:t,step:r,accepts:n,excluding:a,cycles:i=!1})=>{const o=e.data.size(),s=m.createObservationAnchorBuilder(e);for(let c=0;c<o;c+=1){const u=t+c*r,d=i?Xu(u,o):u;if(d<0||d>=o)break;const h=e.data.getAt(d);if(h===null||!n(h,d))continue;const p=s(h);if(p!==null&&!a.some(f=>Z(p,f)))return{anchor:p,observation:h,observationIndex:d}}return null},fa=(e,t)=>{const r=m.createObservationAnchorMatcher(e);let n=0;for(const a of e.data){if(r(a,t))return n;n+=1}return-1},Z=(e,t)=>e.layerId===t.layerId&&l.areDataValuesEqual(e.anchorValue,t.anchorValue)&&l.areDataValuesEqual(e.groupValue??null,t.groupValue??null)&&l.areDataValuesEqual(e.crossValue??null,t.crossValue??null),Xu=(e,t)=>(e%t+t)%t,ga=({layer:e,at:t,coordSystem:r})=>{if(r.type!=="cartesian"||e.spatialKind==="cells")return null;const n=m.resolveAnchorVariable(e),a=fa(e,t),i=e.data.getAt(a);if(i===null)return null;const o=m.getGroup(i),s=p=>l.areDataValuesEqual(m.getGroup(p),o),c=[t],u=Ee({layer:e,excluding:c,from:a+1,step:1,accepts:s});if(u!==null)return{start:t,end:u.anchor};const d=Ee({layer:e,excluding:c,from:a-1,step:-1,accepts:s});if(d!==null)return{start:d.anchor,end:t};const h=Ee({layer:e,excluding:c,from:0,step:1,accepts:p=>!s(p)&&l.areDataValuesEqual(p[n]??null,t.anchorValue)});return h!==null?{start:t,end:h.anchor}:null},qu=e=>{if(e.coordSystem.type!=="cartesian")return null;const t=e.spec.annotations.differenceArrows;for(const r of e.layers){const n=m.createObservationAnchorBuilder(r);for(const a of r.data){const i=n(a);if(i===null)continue;const o=ga({layer:r,at:i,coordSystem:e.coordSystem});if(o!==null&&!t.some(s=>ju(s,o)))return o}}return null},ju=(e,t)=>Z(e.start,t.start)&&Z(e.end,t.end)||Z(e.start,t.end)&&Z(e.end,t.start),Zu=(e,t)=>m.resolveGeomScaleDemands(e.layers).zeroAxes[t]!==void 0,Ju=({layer:e,coordSystem:t,panelSize:r,radialExtent:n="whole"})=>{const a=n==="outerEnd"&&t.type==="polar"?Qu:l.readObservationBox,i=[];for(const o of e.data){const s=a(o,t);s!==null&&i.push(ed(s,r))}return i},Qu=(e,t)=>{if(l.isStrictNumericDataValue(l.getXMin(e))||l.isStrictNumericDataValue(l.getXMax(e)))return l.readObservationBox(e,t);const r=l.getX(e),n=l.getYMax(e)??l.getY(e);return!l.isStrictNumericDataValue(r)||!l.isStrictNumericDataValue(n)?null:{...l.polarSectorToInscribedSquare(r,r,n,n),space:"disk"}},ed=(e,t)=>sa({x:Math.min(e.xMin,e.xMax),y:Math.min(e.yMin,e.yMax),width:Math.abs(e.xMax-e.xMin),height:Math.abs(e.yMax-e.yMin),space:e.space},t),td=(e,t)=>{const r=e.find(a=>a.id===t.anchor.layerId);if(r===void 0)return null;const n=r.data.getAt(t.observationIndex);return n===null?null:{layer:r,observation:n}},rd=({resolver:e,layer:t,observation:r,observationIndex:n,coordSystem:a,align:i,measurement:o})=>{const s=e.resolve(t.geom,r,{coordSystem:a,position:t.position,purpose:"value",align:i});if(s===null)return null;const c=o??e.createLayerMeasurement(t);if(c===null)return null;const u=m.readObservationMeasurement(t,r,c);if(u===null)return null;const d=m.createObservationAnchorBuilder(t)(r);return d===null?null:{...s,...u,observationIndex:n,anchor:i===void 0?d:{...d,align:i}}},nd=({layer:e,target:t,parsingLocale:r,host:n})=>{if(t.layerId!==(n??e).id)return[];const a=va(e,t,r);if(a===null)return[];if(Be(t.scope))return id(e,a,t.scope);const i=ya(e,a),o=i[ad(t,i,n,r)];return o===void 0?i:[o]},ad=(e,t,r,n)=>{if(e.observationIndex===void 0)return-1;if(r===void 0)return t.indexOf(e.observationIndex);const a=va(r,e,n);return a===null?-1:ya(r,a).indexOf(e.observationIndex)},va=(e,t,r)=>m.findPredicateProblems(t.predicate,e.data).length>0?null:m.compilePredicate(t.predicate,m.createRowPredicateCompileContext(e,r)),ya=(e,t)=>{const r=[];for(let n=0;n<e.data.size();n++)t(n)&&r.push(n);return r},id=(e,t,r)=>{const n=Tu(e,r),a=new Set;n.forEach((o,s)=>{t(s)&&a.add(o)});const i=[];return n.forEach((o,s)=>{a.has(o)&&i.push(s)}),i},od=({layer:e,from:t,partner:r,axis:n,step:a,getObservationPoint:i})=>{const o=m.resolveAnchorVariable(e),s=fa(e,t),c=e.data.getAt(s);if(c===null)return null;const u=sd(c),d=n==="main"?u:f=>!u(f)&&l.areDataValuesEqual(f[o]??null,t.anchorValue),h=Ee({layer:e,excluding:[t,r],from:s+a,step:a,accepts:(f,g)=>d(f)&&i(f,g)!==null,cycles:n!=="main"});if(h===null)return null;const p=i(h.observation,h.observationIndex);return p===null?null:{...h,point:p}},sd=e=>{const t=m.getGroup(e);return r=>l.areDataValuesEqual(m.getGroup(r),t)};function ld({numberFormat:e,locale:t}){const r=new Map;return n=>{let a=r.get(n.valueFormat);return a??=I({valueFormat:n.valueFormat,locale:t,numberFormat:e}),r.set(n.valueFormat,a),a(n.measurementValue)}}var cd=({headline:e,show:t,numberFormat:r,parsingLocale:n,formattingLocale:a,t:i})=>{if(e===null)return null;const o=a??n;return e.kind==="grandTotal"?ud(e,o,r):dd(e,t,o,r,i)},ud=(e,t,r)=>({kind:"grandTotal",value:I({valueFormat:e.valueFormat,locale:t,numberFormat:r})(e.value)}),dd=(e,t,r,n,a)=>{const i=I({valueFormat:{type:"percentage"},locale:r,numberFormat:n}),o=e.items.length>1;return{kind:"perGroup",items:e.items.map(s=>{const c=I({valueFormat:s.valueFormat,locale:r,numberFormat:n}),u=I({valueFormat:s.groupLabelFormat,locale:r,numberFormat:n}),d=Pt({valueFormat:s.mainValueFormat,locale:r,numberFormat:n,tickValues:[]}),h=s.label??u(s.value);return{swatch:s.swatch,label:fd(t,o,h,a),value:s.aggregate===null?null:c(s.aggregate),caption:pd(s.caption,d),comparison:md(s.comparison,d,i,a)}})}},md=(e,t,r,n)=>e===null?null:{direction:hd(e.variation),percentage:r(Math.abs(e.variation)),reference:n("graph.headlineMetrics.comparisonReference",{value:t(e.against)})},hd=e=>e>0?"up":e<0?"down":"flat",pd=(e,t)=>e===null?null:e.kind==="point"?t(e.value):`${t(e.from)} – ${t(e.to)}`,fd=(e,t,r,n)=>{switch(e){case"total":return n("graph.headlineMetrics.total",{value:r});case"average":return t?n("graph.headlineMetrics.averageShort",{value:r}):n("graph.headlineMetrics.averageLong",{value:r});case"current":case"conversion":case"none":return r}},gd=({legends:e,numberFormat:t,parsingLocale:r,formattingLocale:n})=>{const a=n??r;return e.map(i=>vd(i,a,t))},vd=(e,t,r)=>({...e,items:e.items.map(n=>{const a=I({valueFormat:n.valueFormat,locale:t,numberFormat:r});return{...n,formattedLabel:n.label??a(n.value)}})});function Nt(e,t){return e.axes.find(r=>r.scaleAestheticKey===t)??null}function yd(e,t){return e.legends.drawn.find(r=>r.aesthetics.includes(t))??null}var Sd=({guides:e,numberFormat:t,layer:r,locale:n})=>{const a=r.data.getFirst();if(!a)return null;const i=r.mapping.y!==void 0,o=(i?m.createYValueReader:m.createXValueReader)(r.data,r.mapping)(a);return o===null?null:I({valueFormat:Nt(e,i?l.resolveYScaleAesthetic(r.yScaleType):"x")?.valueFormat??{type:"decimal"},locale:n,numberFormat:t})(o)},Sa=.4,ba=.18,bd=12,xa=.4,xd=(e,t)=>{const{value:r,caption:n,comparison:a,swatch:i,label:o}=e;return[{role:"value",gap:tt(t.number.fontSize,ba),segments:rt([Te("value",r??"–"),Te("caption",n)])},{role:"trend",gap:tt(t.trend.fontSize,xa),ariaLabel:a===null?void 0:Ld(a),segments:rt([Id(a),Td(a),Te("trendReference",a?.reference??null)])},{role:"group",gap:tt(t.label.fontSize,Sa),segments:rt([Ad(i,t.swatch.size),Te("label",o)])}].filter(s=>s.segments.length>0)},tt=(e,t)=>Math.round(e*t),Te=(e,t)=>t===null?null:{kind:"text",textRole:e,text:t},Ad=(e,t)=>e===null?null:{kind:"swatch",swatch:e,size:t},Id=e=>e===null?null:{kind:"trendArrow",direction:e.direction,size:12},Td=e=>e===null?null:{kind:"text",textRole:"trendPercentage",text:e.percentage,trendDirection:e.direction},Ld=e=>{switch(e.direction){case"up":return`Increased ${e.percentage} ${e.reference}`;case"down":return`Decreased ${e.percentage} ${e.reference}`;case"flat":return`No change ${e.reference}`}},rt=e=>e.filter(t=>t!==null),Ge=e=>e==="smooth"?R.curveCatmullRom:R.curveLinear,Ed=(e,t)=>{const r=Ge(t.curve),n=(0,R.area)().curve(r),a=(0,R.line)().curve(r);if(e.mainAxis==="y"){const i=c=>F(l.getY(c)??0),o=c=>l.getXMin(c)??0,s=c=>l.getXMax(c)??l.getX(c)??0;n.y(i).x0(o).x1(s),a.y(i).x(s)}else{const i=c=>l.getX(c)??0,o=c=>F(l.getYMin(c)??0),s=c=>F(l.getYMax(c)??l.getY(c)??0);n.x(i).y0(o).y1(s),a.x(i).y(s)}if(t.missingValues==="gap"){const i=o=>l.getX(o)!==null&&l.getY(o)!==null;n.defined(i),a.defined(i)}return{lineGenerator:a,areaGenerator:n}},Rd=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Ft={none:0,xs:2,sm:4,md:8,lg:12,xl:16},Bt=e=>{if(La(e)){const{width:r,height:n}=e.bounds;return(e.mainAxis==="x"?r:n)/2}const t=e.cornerRadius??"sm";return typeof t=="number"?Math.max(0,t):Ft[t]},Cd=e=>{const t=Bt(e);return La(e)?e.mainAxis==="x"?{rx:t}:{ry:t}:{rx:t}},wd=e=>({outlineWidth:e*2,separatorWidth:e,insetOffset:e/2}),Aa=(e,t)=>Ia(e,{xMin:l.getXMin(t),xMax:l.getXMax(t),yMin:l.getYMin(t),yMax:l.getYMax(t),y:l.getY(t)}),Ia=(e,{xMin:t,xMax:r,yMin:n,yMax:a,y:i})=>{const o=a??i;if(t===null||r===null||n===null||o===null)return null;if(e==="x"){let u=1-o,d=o-n;return d<0&&(u+=d,d=-d),{x:t,y:u,width:r-t,height:d}}let s=t,c=r-t;return c<0&&(s+=c,c=-c),{x:s,y:1-o,width:c,height:o-n}},Ta=(e,t)=>e==="x"?`${_(t.x)}-${_(t.width)}`:`${_(t.y)}-${_(t.height)}`,Pd=e=>{let t=1/0,r=1/0,n=-1/0,a=-1/0;for(const i of e)i.x<t&&(t=i.x),i.y<r&&(r=i.y),i.x+i.width>n&&(n=i.x+i.width),i.y+i.height>a&&(a=i.y+i.height);return{x:t,y:r,width:n-t,height:a-r}},Gt=(e,t,r)=>{const n=t.mainAxis==="x"?1:0,a=r[l.resolveYScaleAesthetic(e.yScaleType)];if(!a||a.kind!=="position")return n;const i=a.map(0);if(!Number.isFinite(i))return n;const o=Math.min(1,Math.max(0,i));return t.mainAxis==="x"?1-o:o},Md=(e,t,r)=>{const n=Gt(e,t,r);return t.mainAxis==="x"?{x:0,y:n}:{x:n,y:0}},La=e=>e.cornerRadius==="full",Dd=e=>{const t=(0,R.line)().x(r=>l.getX(r)??0).y(r=>F(l.getY(r)??0)).curve(Ge(e.curve));return e.missingValues==="gap"&&t.defined(Ea),t},Od=e=>{const t=(0,R.area)().x(r=>l.getX(r)??0).y0(()=>1).y1(r=>F(l.getY(r)??0)).curve(Ge(e.curve));return e.missingValues==="gap"&&t.defined(Ea),t},_d=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Ea=e=>l.getX(e)!==null&&l.getY(e)!==null,kd=new Set(["line","rule"]),Ra=e=>kd.has(e),Ht=(e,t,r,n)=>{const a=e.geom(t);if(Ra(t.geom))return a.get("stroke",r,n);const i=a.get("fill",r,n);return i===void 0?a.get("stroke",r,n):l.toPaintColor(i)},$t={circle:R.symbolCircle,square:R.symbolSquare,diamond:R.symbolDiamond,triangle:R.symbolTriangle,cross:R.symbolCross,star:R.symbolStar,wye:R.symbolWye},Vd=(e,t)=>{const r=t/2;return(0,R.symbol)($t[e],Math.PI*r*r)()??""},Nd=(e,t,r)=>{const n=Ca[e],a=Math.max(0,Math.min(t/n.width,r/n.height));return{path:(0,R.symbol)($t[e],a*a)()??"",offsetX:-n.centerX*a,offsetY:-n.centerY*a}},Fd=(e,t)=>{const r=t/2;return Ca[e].outerRadius*Math.sqrt(Math.PI*r*r)},Bd=e=>{let t=1/0,r=1/0,n=-1/0,a=-1/0,i=0;const o=(u,d)=>{t=Math.min(t,u),r=Math.min(r,d),n=Math.max(n,u),a=Math.max(a,d)},s=(u,d)=>{o(u,d),i=Math.max(i,Math.hypot(u,d))},c=()=>{throw new Error("Unexpected curve in a point symbol")};return e.draw({moveTo:s,lineTo:s,rect:(u,d,h,p)=>{s(u,d),s(u+h,d),s(u+h,d+p),s(u,d+p)},arc:(u,d,h)=>{o(u-h,d-h),o(u+h,d+h),i=Math.max(i,Math.hypot(u,d)+h)},closePath:()=>{},arcTo:c,bezierCurveTo:c,quadraticCurveTo:c,ellipse:c},1),{width:n-t,height:a-r,centerX:(t+n)/2,centerY:(r+a)/2,outerRadius:i}},Ca=Object.fromEntries(Object.entries($t).map(([e,t])=>[e,Bd(t)])),wa={centerX:0,centerY:0,radius:1,digits:8},Gd=200,O=1e-12,Hd=Math.PI/2,$d=(e,t)=>{if(e==="full")return Math.max(0,t)/2;const r=e??"sm";return(typeof r=="number"?Math.max(0,r):Ft[r])/Gd},Pa=(e,t)=>e==="x"?`${_(t.startAngle)}-${_(t.endAngle)}`:`${_(t.innerRadius)}-${_(t.outerRadius)}`,zd=e=>{let t=1/0,r=-1/0,n=1/0,a=-1/0;for(const i of e)t=Math.min(t,i.startAngle,i.endAngle),r=Math.max(r,i.startAngle,i.endAngle),n=Math.min(n,i.innerRadius,i.outerRadius),a=Math.max(a,i.innerRadius,i.outerRadius);return{startAngle:t,endAngle:r,innerRadius:n,outerRadius:a}},Kd=(e,t=wa)=>{const r=Zd(t),n=Ud(e);if(!(n.outer>O))return`M${r.writePoint(0,0)}Z`;const{slice:a}=e,i=a===void 0?null:Yd(a,a.axis==="radius"?[n.inner,n.outer]:[n.start,n.end]);if(i!==void 0){if(l.isFullTurnSweep(n.start,n.end)){if(a?.axis==="angle"&&i!==null&&!l.isFullTurnSweep(i[0],i[1]))return zr({...n,start:i[0],end:i[1]},i,r);const[o,s]=a?.axis==="radius"&&i!==null?i:[n.inner,n.outer];return Xd(n.start,o,s,r)}return a?.axis==="radius"&&i!==null?Wd(n,i,r):zr(n,i??[n.start,n.end],r)}},Yd=(e,[t,r])=>{const n=Math.max(t,Math.min(e.from,e.to)),a=Math.min(r,Math.max(e.from,e.to));return a-n>0?[n,a]:void 0},Ud=({startAngle:e,endAngle:t,innerRadius:r,outerRadius:n,cornerRadius:a=0})=>{const i=Math.min(e,t),o=Math.max(e,t),s=Math.min(r,n),c=Math.max(r,n),u=o-i,d=Math.min((c-s)/2,a),h={start:i,end:o,inner:s,outer:c,innerCorner:null,outerCorner:null};if(!(d>O)||l.isFullTurnSweep(i,o))return h;let p=d,f=d;if(u<Math.PI){const g=(c-s)**2*Math.sin(u);if(g*g<O)return h;const S=Math.sin(u/2);p=Math.min(d,s*S/(1-S)),f=Math.min(d,c*S/(1+S))}return{...h,innerCorner:s>O&&p>O?$r(p,s+p,u):null,outerCorner:f>O?$r(f,c-f,u):null}},$r=(e,t,r)=>({radius:e,centerRadius:t,offset:Math.min(Math.asin(Math.min(1,e/t)),r/2)}),Wd=(e,[t,r],n)=>{const a=Kr(e,"start"),i=Kr(e,"end"),o=c=>Me(a,c),s=c=>Me(i,c);return`M${n.writePoint(o(t),t)}`+ie(t,o(t),s(t),n)+De(i,t,r,"radius",n)+ie(r,s(r),o(r),n)+De(a,r,t,"radius",n)+"Z"},zr=(e,[t,r],n)=>{const a=Yr(e,"inner"),i=Yr(e,"outer");return`M${n.writePoint(t,Me(a,t))}`+De(a,t,r,"angle",n)+`L${n.writePoint(r,Me(i,r))}`+De(i,r,t,"angle",n)+"Z"},Xd=(e,t,r,n)=>{const a=`M${n.writePoint(e,r)}${ie(r,e,e-l.TAU,n)}Z`;return t>O?`${a}M${n.writePoint(e,t)}${ie(t,e,e+l.TAU,n)}Z`:a},Kr=(e,t)=>{const r=t==="start"?e.start:e.end,n=t==="start"?1:-1,a=c=>{const u=r+n*c.offset;return d=>u-n*qd(c,d)},i=e.innerCorner===null?e.inner:Ur(e.innerCorner),o=e.outerCorner===null?e.outer:Ur(e.outerCorner),s=[];return e.innerCorner!==null&&s.push({from:e.inner,to:i,at:a(e.innerCorner),corner:e.innerCorner}),s.push({from:i,to:o,at:()=>r,corner:null}),e.outerCorner!==null&&s.push({from:o,to:e.outer,at:a(e.outerCorner),corner:e.outerCorner}),s},Yr=(e,t)=>{const r=t==="inner"?e.inner:e.outer,n=t==="inner"?e.innerCorner:e.outerCorner;if(n===null)return[{from:e.start,to:e.end,at:()=>r,corner:null}];const a=t==="inner"?-1:1,i=e.start+n.offset,o=e.end-n.offset,s=c=>u=>jd(n,u-c,a);return[{from:e.start,to:i,at:s(i),corner:n},{from:i,to:o,at:()=>r,corner:null},{from:o,to:e.end,at:s(o),corner:n}]},Ur=e=>e.centerRadius*Math.cos(e.offset),qd=({radius:e,centerRadius:t},r)=>{if(!(r>O))return 0;const n=(t**2+r**2-e**2)/(2*t*r);return Math.acos(Math.max(-1,Math.min(1,n)))},jd=({radius:e,centerRadius:t},r,n)=>{const a=t*Math.sin(r);return t*Math.cos(r)+n*Math.sqrt(Math.max(0,e**2-a**2))},Me=(e,t)=>{const r=e.find(n=>t<=n.to)??e[e.length-1];return r===void 0?0:r.at(t)},De=(e,t,r,n,a)=>{const i=r>=t,o=Math.min(t,r),s=Math.max(t,r);let c="";for(const u of i?e:[...e].reverse()){const d=Math.max(u.from,o),h=Math.min(u.to,s);if(h-d<=O)continue;const[p,f]=i?[d,h]:[h,d],g=n==="radius"?a.writePoint(u.at(f),f):a.writePoint(f,u.at(f));if(u.corner!==null){const S=a.scaleLength(u.corner.radius);c+=`A${S},${S} 0 0 0 ${g}`}else c+=n==="radius"?`L${g}`:ie(u.at(p),p,f,a)}return c},ie=(e,t,r,n)=>{if(!(e>O)||Math.abs(r-t)<=O)return"";const a=Math.max(1,Math.ceil(Math.abs(r-t)/Hd-O)),i=n.scaleLength(e),o=r>t?1:0;let s="";for(let c=1;c<=a;c++)s+=`A${i},${i} 0 0 ${o} ${n.writePoint(t+(r-t)*c/a,e)}`;return s},Zd=({centerX:e,centerY:t,radius:r,digits:n})=>{const a=10**n,i=o=>Math.round(o*a)/a;return{writePoint:(o,s)=>{const c=l.polarToUnit(o,s);return`${i(e+c.x*r)},${i(t-c.y*r)}`},scaleLength:o=>i(o*r)}},He=(e,t,r)=>{const n=m.createXValueReader(e,t);return a=>{const i=m.getGroup(a)??"default",o=n(a);return`${r}-${i}${o!==null&&o!==""?`-${o}`:""}`}},Jd=(e,t,r)=>{const n=m.createXValueReader(e,t);return a=>{const i=n(a);return i===null||i===""?null:`${r}-${i}`}},Qd=(e,t,r)=>{const n=m.createXValueReader(e,t),a=m.createYValueReader(e,t),i=new Map;return o=>{const s=n(o),c=a(o),u=s!==null&&s!==""&&c!==null&&c!==""?`${r}-${s}-${c}`:`${r}-cell`,d=i.get(u)??0;return i.set(u,d+1),d===0?u:`${u}#${d}`}},em=()=>(e,t)=>l.getColor(e)??`default-${t}`,Wr=2,tm=(e,t)=>{const r=l.readVariableName(e.mapping.color);if(t!==void 0&&r!==null&&e.data.hasVariable(r)){const n=e.data.getValues(r).findIndex(a=>l.areDataValuesEqual(a,t));if(n!==-1)return e.data.getAt(n)??void 0}return e.data.getFirst()??void 0},zt=(e,t,r,n)=>{const a=e(t),i=Y(t,"line")?a.get("strokeAlpha",r):a.get("fillAlpha",r)??a.get("strokeAlpha",r),o=a.get("alpha",r)*i,s=Ra(t.geom)?void 0:rm(e,t,r),c=s===void 0?{alpha:o}:{alpha:o,fill:s};if(Y(t,"point"))return{...c,symbol:e.point(t).get("symbol",r)};if(!Y(t,"bar"))return c;const u=n.width-Wr,d=n.height-Wr,h=Bt({cornerRadius:e.bar(t).get("cornerRadius",r),mainAxis:"x",bounds:{width:u,height:d}});return{...c,cornerRadiusPx:Math.min(h,Math.min(u,d)/2)}},rm=(e,t,r)=>{const{value:n,origin:a}=e(t).explain("fill",r);if(typeof n!="object")return;const i=[...t.styles.overrides,...t.styles.defaults].find(s=>s.origin===a);if(i?.where===void 0)return n;const o=l.readVariableName(t.mapping.color);return m.readPredicateVariables(i.where).every(s=>s===o)?n:void 0};function Kt(e,t){let r=0,n=e;for(;r<n;){const a=r+n>>>1;t(a)?n=a:r=a+1}return r}function nm(e,t,r){return Kt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>t})}function am(e,t,r){return Kt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>=t})}function Yt(e,t,r,n){const a=e==="x";return{mainDistance:Math.abs(t)*(a?n:1),crossDistance:Math.abs(r)*(a?1:n)}}function Ut(e,t,r){return Math.hypot(e*r,t)}function k(e,t,r){return e<t?t-e:e>r?e-r:0}function V(e,t,{shortCircuitOnZero:r=!1}={}){let n=e[0],a=t(n);if(r&&a===0)return n;for(let i=1;i<e.length;i+=1){const o=e[i];if(o===void 0)continue;const s=t(o);if(r&&s===0)return o;s<a&&(n=o,a=s)}return n}function im(e,t){const r=t.height,n=Math.min(t.width,t.height)/2;return{cartesian:Xr(e,r),polar:Xr(e,n)}}function ce(e,t){return e<=t.on.point}function oe({mainDistance:e,crossDistance:t},r){return e<=r.near.main&&t<=r.near.cross}function Xr({on:e,near:t},r){return{on:{edge:e.edge/r,stroke:(e.stroke??e.edge)/r,point:(e.point??e.edge)/r},near:{main:t.main/r,cross:(t.cross??t.main)/r}}}function om(e,t,r,n,a){if(e.points.length===0)return null;const i=e.delaunay;if(!i)return null;const o=i.find(t.x*r,t.y,n??void 0),s=e.points[o];if(!s)return null;const c=Ma(e,s,t,r);return a===void 0||ce(c.distance,a)||oe(c,a)?c:lm(e,t,r,a)??c}function sm(e,t){if(e.projection==="polar"||e.points.length===0||!e.delaunay||e.delaunayAspectRatio===null)return null;const r=e.delaunay.find(t.x*e.delaunayAspectRatio,t.y);return e.points[r]??null}function lm(e,t,r,n){const{mainAxis:a,byMain:i}=e,o=m.getCoordinates(a,t).main,s=a==="x"?n.near.main/r:n.near.main,c=am(i,o-s,qr(a)),u=nm(i,o+s,qr(a));let d=null;for(let h=c;h<u;h+=1){const p=i[h];if(p===void 0)continue;const f=Ma(e,p,t,r);oe(f,n)&&(d===null||f.crossDistance<d.crossDistance)&&(d=f)}return d}function qr(e){return t=>m.getCoordinates(e,t).main}function Ma(e,t,r,n){const{main:a,cross:i}=m.getCoordinates(e.mainAxis,r),{main:o,cross:s}=m.getCoordinates(e.mainAxis,t);return{...Yt(e.mainAxis,o-a,s-i,n),hit:{anchored:!0,layerId:e.layerId,pointIndex:t.pointIndex,observationIndex:t.observationIndex,x:t.x,y:t.y,observation:t.observation},index:e,distance:Ut(t.x-r.x,t.y-r.y,n)}}function Da(e,t){return e.buckets[cm(e,t)]??null}function cm(e,t){return ka(e.buckets,t,r=>r.main)}function um(e,t){return _a(e.bands,t,r=>r.bandCenter)}function Oa(e,t){return _a(e.columns,t,r=>r.mainMid)}function _a(e,t,r){return e[ka(e,t,r)]??null}function ka(e,t,r){if(e.length===0)return-1;const n=Kt(e.length,o=>{const s=e[o];return s!==void 0&&r(s)>=t}),a=e[n-1],i=e[n];return a?i&&Math.abs(r(i)-t)<Math.abs(r(a)-t)?n:n-1:n}function dm(e,t){return{group:mm(e),related:gm(e,t)}}function mm(e){switch(e.kind){case"buckets":{const t=e.match.index;return l.isStackedPosition(t.position)?hm(t.layerId,e.match.bucket,e.match.hit.pointIndex):[]}case"banded":{const{index:t,column:r,hit:n}=e.match;return l.isStackedPosition(t.position)?pm(t.layerId,r,n.pointIndex):fm(t.bandByColumn,t.layerId,r,n.pointIndex)}case"points":case"enclosure":case"render-hit-test":return[]}}function hm(e,t,r){const n=[];for(const a of t.entries)a.pointIndex!==r&&n.push({anchored:!0,layerId:e,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation});return n}function pm(e,t,r){const n=[];for(const a of t.rects)a.pointIndex!==r&&n.push(Wt(e,a));return n}function fm(e,t,r,n){const a=e.get(r);if(!a)return[];const i=[];for(const o of a.columns)for(const s of o.rects)s.pointIndex!==n&&i.push(Wt(t,s));return i}function gm(e,t){const r=new Map;if(e.kind==="render-hit-test"||e.kind==="enclosure")return r;const n=e.match.index,a=n.projection==="polar";for(const i of t){if(i.layerId!==n.layerId){a||ym(r,i,e.match.hit);continue}e.kind==="buckets"&&(l.isStackedPosition(i.position)||i.kind==="buckets"&&vm(r,i.layerId,e.match.bucket,e.match.hit.pointIndex))}return r}function vm(e,t,r,n){for(const a of r.entries)a.pointIndex!==n&&Re(e,t).push({anchored:!0,layerId:t,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation})}function ym(e,t,r){switch(t.kind){case"buckets":{const n=Da(t,m.getMainAxisCoordinate(t.mainAxis,r));if(!n)return;const a=Re(e,t.layerId);for(const i of n.entries)a.push({anchored:!0,layerId:t.layerId,pointIndex:i.pointIndex,x:i.x,y:i.y,observation:i.observation});return}case"banded":{const n=um(t,m.getMainAxisCoordinate(t.mainAxis,r));if(!n)return;const a=Re(e,t.layerId);for(const i of n.columns)for(const o of i.rects)a.push(Wt(t.layerId,o));return}case"points":{const n=sm(t,r);if(!n)return;Re(e,t.layerId).push({anchored:!0,layerId:t.layerId,pointIndex:n.pointIndex,observationIndex:n.observationIndex,x:n.x,y:n.y,observation:n.observation});return}case"enclosure":return;case"noop":return;case"render-hit-test":return}}function Re(e,t){let r=e.get(t);return r||(r=[],e.set(t,r)),r}function Wt(e,t){return{anchored:!0,layerId:e,pointIndex:t.pointIndex,x:(t.xMin+t.xMax)/2,y:(t.yMin+t.yMax)/2,observation:t.observation}}function Va(e,t,r){const{columns:n,bands:a,bandByColumn:i}=Sm(e,t);return{kind:"banded",layerId:e.id,geom:e.geom,position:e.position,projection:r,mainAxis:t,columns:n,bands:a,bandByColumn:i}}function Sm(e,t){const r=xm(e,t);r.sort((c,u)=>c.mainMid-u.mainMid);const n=new Map,a=new Map,i=new Map;for(const c of r){const u=_(c.mainMid);let d=n.get(u);if(!d){d={mainMid:c.mainMid,rects:[]},n.set(u,d);const h=_(c.bandCenter);let p=a.get(h);p||(p={bandCenter:c.bandCenter,columns:[],mainMin:1/0,mainMax:-1/0,crossMin:1/0,crossMax:-1/0},a.set(h,p)),p.columns.push(d),i.set(d,p)}d.rects.push(c.entry),bm(i.get(d),c.entry,t)}const o=[...n.values()].sort((c,u)=>c.mainMid-u.mainMid),s=[...a.values()].sort((c,u)=>c.bandCenter-u.bandCenter);for(const c of s)c.columns.sort((u,d)=>u.mainMid-d.mainMid);return{columns:o,bands:s,bandByColumn:i}}function bm(e,t,r){if(e===void 0)return;const n=r==="x",a=n?t.xMin:t.yMin,i=n?t.xMax:t.yMax,o=n?t.yMin:t.xMin,s=n?t.yMax:t.xMax;e.mainMin=Math.min(e.mainMin,a),e.mainMax=Math.max(e.mainMax,i),e.crossMin=Math.min(e.crossMin,o),e.crossMax=Math.max(e.crossMax,s)}function xm(e,t){const r=e.data;if(r.size()===0)return[];if(!(r.hasVariable(l.POSITION_VARIABLES.xMin)&&r.hasVariable(l.POSITION_VARIABLES.xMax)&&r.hasVariable(l.POSITION_VARIABLES.yMin)&&r.hasVariable(l.POSITION_VARIABLES.yMax)))return[];const n=r.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),a=r.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),i=r.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),o=r.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),s=t==="y",c=s?l.POSITION_VARIABLES.y:l.POSITION_VARIABLES.x,u=r.hasVariable(c)?r.getValues(c,{type:"numeric"}):null,d=[];let h=0;for(const p of r){const f=n[h],g=a[h],S=i[h],x=o[h];if(!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)||!l.isDefined(x)){h++;continue}const A=s?(S+x)/2:(f+g)/2,T=u?.[h]??A;d.push({mainMid:A,bandCenter:T,entry:{pointIndex:h,xMin:Math.min(f,g),xMax:Math.max(f,g),yMin:Math.min(S,x),yMax:Math.max(S,x),observation:p}}),h++}return d}var Am=1e-9,jr=-1;function Na(e,t,r){const n=Im(e,t,r),a=n.map(o=>o.entry);n.sort((o,s)=>o.main-s.main);const i=[];for(const o of n){const s=i[i.length-1];s&&Math.abs(s.main-o.main)<=Am?s.entries.push(o.entry):i.push({main:o.main,entries:[o.entry]})}return{kind:"buckets",layerId:e.id,geom:e.geom,position:e.position,projection:r,mainAxis:t,buckets:e.spatialKind==="spanned-buckets"?i.map(o=>({...o,span:wm(o.entries,t)})):i,entries:a}}function Im(e,t,r){const n=e.data;if(n.size()===0)return[];const a=n.hasVariable(l.POSITION_VARIABLES.x),i=n.hasVariable(l.POSITION_VARIABLES.y);if(!a||!i)return[];const o=n.getValues(l.POSITION_VARIABLES.x,{type:"numeric"}),s=n.getValues(l.POSITION_VARIABLES.y,{type:"numeric"}),c=t==="y",u=c?l.POSITION_VARIABLES.xMin:l.POSITION_VARIABLES.yMin,d=c?l.POSITION_VARIABLES.xMax:l.POSITION_VARIABLES.yMax,h=e.spatialKind==="spanned-buckets",p=l.isStackedPosition(e.position),f=n.hasVariable(u)?n.getValues(u,{type:"numeric"}):null,g=n.hasVariable(d)?n.getValues(d,{type:"numeric"}):null,S=n.hasVariable(l.GROUP_VARIABLES.group)?n.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}):null,x=e.spatialKind==="spanned-buckets"?null:new Lm(Tm(e)),A=new Map,T=[];let E=0;for(const W of n){const fe=o[E],ge=s[E],ee=S?.[E]??null,Us=Em(A,ee);if(!l.isDefined(fe)||!l.isDefined(ge)){x?.skip(ee),E+=1;continue}const Ws=c?ge:fe,ve=f?.[E],gr=g?.[E],vr=p?gr:void 0;if(p&&(!l.isDefined(ve)||!l.isDefined(vr))){x?.skip(ee),E+=1;continue}const ye=vr??m.getCrossAxisCoordinate(t,{x:fe,y:ge}),yr={pointIndex:E,...c?{x:ye,y:ge}:{x:fe,y:ye},groupKey:ee,paintOrder:Us,...e.spatialKind==="filled-buckets"&&l.isDefined(ve)&&{fill:Rm(ve,ye)},...h&&{extent:Cm(ye,ve,gr)},previousAt:jr,nextAt:jr,observation:W};x?.append(ee,{entry:yr,at:T.length}),T.push({main:Ws,entry:yr}),E+=1}return r==="polar"&&x?.close(),T}function Tm(e){return"missingValues"in e.params&&e.params.missingValues==="gap"}var Lm=class{constructor(e){this.breaksAtNull=e,this.firstByGroup=new Map,this.lastByGroup=new Map,this.brokenGroups=new Set}append(e,t){const r=this.lastByGroup.get(e);r!==void 0&&(r.entry.nextAt=t.at,t.entry.previousAt=r.at),this.firstByGroup.has(e)||this.firstByGroup.set(e,t),this.lastByGroup.set(e,t)}skip(e){this.breaksAtNull&&(this.lastByGroup.delete(e),this.brokenGroups.add(e))}close(){for(const[e,t]of this.firstByGroup){const r=this.lastByGroup.get(e);r===void 0||r===t||this.brokenGroups.has(e)||(r.entry.nextAt=t.at,t.entry.previousAt=r.at)}}};function Em(e,t){const r=e.get(t);if(r!==void 0)return r;const n=e.size;return e.set(t,n),n}function Rm(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}}function Cm(e,t,r){if(!l.isDefined(t)&&!l.isDefined(r))return;const n=l.isDefined(t)?t:e,a=l.isDefined(r)?r:e;return{min:Math.min(n,a,e),max:Math.max(n,a,e)}}function wm(e,t){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const a of e){const i=m.getCrossAxisCoordinate(t,a),o=a.extent?.min??i,s=a.extent?.max??i;o<r&&(r=o),s>n&&(n=s)}return{min:r,max:n}}function Fa(e,t){return{kind:"enclosure",layerId:e.id,geom:e.geom,position:e.position,projection:t,cells:Pm(e,t)}}function Pm(e,t){const r=e.data;if(r.size()===0)return[];const n=[l.POSITION_VARIABLES.xMin,l.POSITION_VARIABLES.xMax,l.POSITION_VARIABLES.yMin,l.POSITION_VARIABLES.yMax];for(const h of n)if(!r.hasVariable(h))return[];const a=r.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),i=r.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),o=r.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),s=r.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),c=t==="cartesian",u=[];let d=0;for(const h of r){const p=a[d],f=i[d],g=o[d],S=s[d];if(!l.isDefined(p)||!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)){d++;continue}if(c&&!l.isTilePainted(h)){d++;continue}u.push({pointIndex:d,xMin:p,xMax:f,yMin:g,yMax:S,observation:h}),d++}return u}function ft(e){return{kind:"noop",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian"}}function Mm(e,t,r){const n=Ga(e),a={kind:"points",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",mainAxis:t,points:n,byMain:Om(t,n),delaunay:null,delaunayAspectRatio:null};return Ba(a,r),a}function Dm(e){const t=Ga(e).map(r=>{const n=l.polarToUnit(r.x,r.y);return{...r,unitX:n.x,unitY:n.y}});return{kind:"points",layerId:e.id,geom:e.geom,position:e.position,projection:"polar",points:t}}function Ba(e,t){e.delaunay&&e.delaunayAspectRatio===t||(e.delaunay=qs.Delaunay.from(e.points,r=>r.x*t,r=>r.y),e.delaunayAspectRatio=t)}function Om(e,t){const r=n=>m.getMainAxisCoordinate(e,n);return[...t].sort((n,a)=>r(n)-r(a))}function Ga(e){const t=e.data;if(t.size()===0)return[];if(!t.hasVariable(l.POSITION_VARIABLES.x)||!t.hasVariable(l.POSITION_VARIABLES.y))return[];const r=t.getValues(l.POSITION_VARIABLES.x,{type:"numeric"}),n=t.getValues(l.POSITION_VARIABLES.y,{type:"numeric"}),a=[];let i=0;for(const o of t){const s=r[i],c=n[i];l.isDefined(s)&&l.isDefined(c)&&a.push({pointIndex:a.length,observationIndex:i,x:s,y:c,observation:o}),i+=1}return a}function Ha(e){return{kind:"render-hit-test",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",byKey:_m(e)}}function $a(e,t){return{anchored:!1,layerId:e,pointIndex:t.pointIndex,observation:t.observation}}function _m(e){const t=e.identityKey,r=new Map;if(typeof t=="object"){let n=0;for(const a of e.data){const i=a[t.variable];l.isDefined(i)&&r.set(l.getStableKey(i),{pointIndex:n,observation:a}),n+=1}return r}if(t==="index"){let n=0;for(const a of e.data)r.set(String(n),{pointIndex:n,observation:a}),n+=1}return r}function Zr(e,t,r){return t.type==="polar"?km(e,t.bandAxis):Vm(e,t.mainAxis,r)}function km(e,t){switch(e.spatialKind){case"points":return Dm(e);case"buckets":case"filled-buckets":case"spanned-buckets":return Na(e,"x","polar");case"rects":return t===null?Fa(e,"polar"):Va(e,t,"polar");case"cells":return ft(e);case"noop":return ft(e);case"render-hit-test":return Ha(e);default:{const r=e.spatialKind;throw new l.InternalError({message:`buildPolarLayerIndex: unhandled spatialKind ${String(r)}`})}}}function Vm(e,t,r){switch(e.spatialKind){case"points":return Mm(e,t,r);case"buckets":case"filled-buckets":case"spanned-buckets":return Na(e,t,"cartesian");case"rects":return Va(e,t,"cartesian");case"cells":return Fa(e,"cartesian");case"noop":return ft(e);case"render-hit-test":return Ha(e);default:{const n=e.spatialKind;throw new l.InternalError({message:`buildCartesianLayerIndex: unhandled spatialKind ${String(n)}`})}}}function Nm(e,t,r){if(e.columns.length===0)return null;const n=Oa(e,m.getMainAxisCoordinate(e.mainAxis,t)),a=n?.rects??[];if(!n||!l.isNonEmptyArray(a))return null;const i=l.isStackedPosition(e.position)?Bm(a,t,e.mainAxis):Gm(a,t,r),o=za(i,t,r);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:i.pointIndex,x:(i.xMin+i.xMax)/2,y:(i.yMin+i.yMax)/2,observation:i.observation},index:e,column:n,distance:o,...Fm(e,n,t,r)}}function Fm(e,t,r,n){const a=e.bandByColumn.get(t);if(a===void 0)return{mainDistance:Number.POSITIVE_INFINITY,crossDistance:Number.POSITIVE_INFINITY};const{main:i,cross:o}=m.getCoordinates(e.mainAxis,r),s=k(i,a.mainMin,a.mainMax),c=k(o,a.crossMin,a.crossMax);return Yt(e.mainAxis,s,c,n)}function Bm(e,t,r){const n=m.getCrossAxisCoordinate(r,t);return V(e,i=>Hm(i,r,n),{shortCircuitOnZero:!0})}function Gm(e,t,r){return V(e,a=>za(a,t,r))}function za(e,t,r){return Ut(k(t.x,e.xMin,e.xMax),k(t.y,e.yMin,e.yMax),r)}function Hm(e,t,r){return k(r,t==="x"?e.yMin:e.xMin,t==="x"?e.yMax:e.xMax)}function $m(e,t,r){const n=r.x-t.x,a=r.y-t.y,i=n*n+a*a;if(i===0)return Math.hypot(e.x-t.x,e.y-t.y);const o=((e.x-t.x)*n+(e.y-t.y)*a)/i,s=Math.max(0,Math.min(1,o));return Math.hypot(e.x-(t.x+s*n),e.y-(t.y+s*a))}function zm(e,t,r){const{main:n,cross:a}=m.getCoordinates(e.mainAxis,t),i=Da(e,n);if(i===null)return null;const o=i.entries.map(g=>({entry:g,crossAtCursor:Ym(e,g,n)}));if(!l.isNonEmptyArray(o))return null;const s=Ua(o.filter(g=>Wm(e,g.entry,n,a)),g=>g.entry),{entry:c}=s??V(o,g=>Math.abs(g.crossAtCursor-a)),u=Ut(c.x-t.x,c.y-t.y,r),d=g=>({x:g.x*r,y:g.y}),h=$e(e,c).map(d),p=Ya(d(t),d(c),h,u),f=Yt(e.mainAxis,i.main-n,Ka(i,m.getCrossAxisCoordinate(e.mainAxis,c),a),r);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:c.pointIndex,x:c.x,y:c.y,observation:c.observation},index:e,bucket:i,distance:s===void 0?u:0,vertexDistance:u,insideFill:s!==void 0,strokeDistance:s===void 0?p:0,...f}}function Km(e,t,r){return V(e,a=>Math.abs(m.getCrossAxisCoordinate(r,a)-t))}function Ka(e,t,r){return e.span!==void 0?k(r,e.span.min,e.span.max):Math.abs(t-r)}function Ya(e,t,r,n){const a=r.map(i=>$m(e,t,i));return Math.min(n,...a)}function $e(e,t){return[e.entries[t.previousAt],e.entries[t.nextAt]].filter(l.isDefined)}function Ua(e,t){return e.reduce((r,n)=>r===void 0||t(n).paintOrder>t(r).paintOrder?n:r,void 0)}function Ym(e,t,r){const{mainAxis:n}=e,a=r===m.getMainAxisCoordinate(n,t)?null:Wa(e,t,r);return a===null?m.getCrossAxisCoordinate(n,t):Um(t,a,n,r)}function Um(e,t,r,n){const a=m.getMainAxisCoordinate(r,e),i=(n-a)/(m.getMainAxisCoordinate(r,t)-a),o=m.getCrossAxisCoordinate(r,e);return o+(m.getCrossAxisCoordinate(r,t)-o)*i}function Wa(e,t,r){const{mainAxis:n}=e,a=m.getMainAxisCoordinate(n,t),i=o=>Math.sign(m.getMainAxisCoordinate(n,o)-a)===Math.sign(r-a);return $e(e,t).find(i)??null}function Wm(e,t,r,n){const a=Xm(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function Xm(e,t,r){if(t.fill===void 0)return null;const{mainAxis:n}=e,a=m.getMainAxisCoordinate(n,t);if(r===a)return t.fill;const i=Wa(e,t,r);if(i?.fill===void 0)return null;const o=(r-a)/(m.getMainAxisCoordinate(n,i)-a);return{min:t.fill.min+(i.fill.min-t.fill.min)*o,max:t.fill.max+(i.fill.max-t.fill.max)*o}}function qm(e,t){if(e.cells.length===0)return null;for(const r of e.cells)if(!(t.x<r.xMin||t.x>r.xMax)&&!(t.y<r.yMin||t.y>r.yMax))return{hit:{anchored:!0,layerId:e.layerId,pointIndex:r.pointIndex,x:(r.xMin+r.xMax)/2,y:(r.yMin+r.yMax)/2,observation:r.observation},index:e,distance:0,mainDistance:0,crossDistance:0};return null}function jm(e,t,r){if(e.columns.length===0)return null;const n=l.cursorToPolar(t,r),{angle:a,radius:i}=n,o=e.mainAxis==="x",s=o?Qm(e.columns,a):Oa(e,i),c=s?.rects??[];if(!s||!l.isNonEmptyArray(c))return null;const u=o?eh(c,i):th(c,a),d=Zm(u,n);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:u.pointIndex,x:(u.xMin+u.xMax)/2,y:(u.yMin+u.yMax)/2,observation:u.observation},index:e,column:s,distance:d,...Jm(e,s,n)}}function Zm(e,{angle:t,radius:r}){const n=Oe(t,e.xMin,e.xMax),a=k(r,e.yMin,e.yMax);return Math.hypot(n*r,a)}function Oe(e,t,r){return l.isAngleWithinArc(e,t,r)?0:Math.min(l.wrappedAngularDistance(e,t),l.wrappedAngularDistance(e,r))}function Jm(e,t,{angle:r,radius:n}){const a=e.bandByColumn.get(t);return a===void 0?{mainDistance:Number.POSITIVE_INFINITY,crossDistance:Number.POSITIVE_INFINITY}:e.mainAxis==="x"?{mainDistance:Oe(r,a.mainMin,a.mainMax)*n,crossDistance:k(n,a.crossMin,a.crossMax)}:{mainDistance:k(n,a.mainMin,a.mainMax),crossDistance:Oe(r,a.crossMin,a.crossMax)*n}}function Qm(e,t){return l.isNonEmptyArray(e)?V(e,r=>l.wrappedAngularDistance(t,r.mainMid)):null}function eh(e,t){return V(e,r=>k(t,r.yMin,r.yMax),{shortCircuitOnZero:!0})}function th(e,t){return V(e,r=>Oe(t,r.xMin,r.xMax),{shortCircuitOnZero:!0})}var Jr=1e-9;function rh(e,t,r){if(e.buckets.length===0)return null;const n=l.cursorToPiePlane(t,r),{angle:a,radius:i}=l.unitToPolar(n.x,n.y),o=nh(e.buckets,a),s=o?.entries??[];if(!o||!l.isNonEmptyArray(s))return null;const c=Ua(s.filter(f=>ah(e,f,a,i)),f=>f),u=c??Km(s,i,e.mainAxis),d=Qr(u),h=Math.hypot(n.x-d.x,n.y-d.y),p=Ya(n,d,$e(e,u).map(Qr),h);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:u.pointIndex,x:u.x,y:u.y,observation:u.observation},index:e,bucket:o,distance:c===void 0?h:0,vertexDistance:h,insideFill:c!==void 0,strokeDistance:c===void 0?p:0,mainDistance:l.wrappedAngularDistance(o.main,a)*i,crossDistance:Ka(o,u.y,i)}}function Qr(e){return l.polarToUnit(e.x,e.y)}function nh(e,t){return l.isNonEmptyArray(e)?V(e,r=>l.wrappedAngularDistance(r.main,t)):null}function ah(e,t,r,n){const a=ih(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function ih(e,t,r){if(t.fill===void 0)return null;const n=l.measureSignedAngularDelta(t.x,r);if(n===0)return t.fill;const a=c=>Math.sign(l.measureSignedAngularDelta(t.x,c.x))===Math.sign(n),i=$e(e,t).find(a);if(i?.fill===void 0)return null;const o=en(r,{angle:t.x,radius:t.fill.min},{angle:i.x,radius:i.fill.min}),s=en(r,{angle:t.x,radius:t.fill.max},{angle:i.x,radius:i.fill.max});return o===null||s===null?null:{min:o,max:s}}function en(e,t,r){const n=l.polarToUnit(t.angle,t.radius),a=l.polarToUnit(r.angle,r.radius),i={x:a.x-n.x,y:a.y-n.y};if(Math.hypot(i.x,i.y)<Jr)return t.radius;const o=tn(l.polarToUnit(e,1),i);return Math.abs(o)<Jr?null:tn(n,i)/o}function tn(e,t){return e.x*t.y-e.y*t.x}function oh(e,t,r,n=!1){if(e.cells.length===0)return null;const{angle:a,radius:i}=l.cursorToPolar(t,r);for(const u of e.cells)if(!(i<u.yMin||i>u.yMax)&&l.isAngleWithinArc(a,u.xMin,u.xMax))return rn(e,u,0);if(!n)return null;const o=e.cells.filter(u=>l.isAngleWithinArc(a,u.xMin,u.xMax));if(!l.isNonEmptyArray(o))return null;const s=u=>k(i,u.yMin,u.yMax),c=V(o,s);return rn(e,c,s(c))}function rn(e,t,r){return{hit:{anchored:!0,layerId:e.layerId,pointIndex:t.pointIndex,x:(t.xMin+t.xMax)/2,y:(t.yMin+t.yMax)/2,observation:t.observation},index:e,distance:r,mainDistance:0,crossDistance:r}}function sh(e,t,r,n){if(!l.isNonEmptyArray(e.points))return null;const a=l.cursorToPiePlane(t,r),i=nn(e,V(e.points,s=>Xa(s,a)),a);if(n===void 0||ce(i.distance,n)||oe(i,n))return i;const o=e.points.map(s=>nn(e,s,a)).filter(s=>oe(s,n));return l.isNonEmptyArray(o)?V(o,s=>s.crossDistance):i}function nn(e,t,r){const{angle:n,radius:a}=l.unitToPolar(r.x,r.y);return{mainDistance:l.wrappedAngularDistance(t.x,n)*a,crossDistance:Math.abs(a-t.y),hit:{anchored:!0,layerId:e.layerId,pointIndex:t.pointIndex,observationIndex:t.observationIndex,x:t.x,y:t.y,observation:t.observation},index:e,distance:Math.sqrt(Xa(t,r))}}function Xa(e,t){const r=e.unitX??l.polarToUnit(e.x,e.y).x,n=e.unitY??l.polarToUnit(e.x,e.y).y,a=r-t.x,i=n-t.y;return a*a+i*i}var lh=.05;function ch({layers:e,cursor:t,aspectRatio:r,warmStarts:n,hitTesters:a,tolerance:i}){const o={match:null,distance:Number.POSITIVE_INFINITY,paintOrder:-1},s={match:null,distance:Number.POSITIVE_INFINITY,paintOrder:-1},c={match:null,distance:Number.POSITIVE_INFINITY,paintOrder:-1};for(const[u,d]of e.entries()){if(d.kind==="render-hit-test"){const p=gh(d,t,a);if(p)return{kind:"render-hit-test",match:p};continue}if(d.projection==="polar"){const p=fh(d,t,r,i?.polar);if(p&&!an(p,i?.polar))return p;continue}const h=ph({layer:d,cursor:t,aspectRatio:r,warmStarts:n,tolerance:i?.cartesian});if(!(!h||an(h,i?.cartesian))){if(h.kind==="banded"||h.kind==="enclosure"){const p=h.match.distance;p<o.distance&&(o.match=h,o.distance=p,o.paintOrder=u);continue}if(h.kind==="buckets"&&h.match.insideFill){s.match=h,s.distance=0,s.paintOrder=u;continue}h.match.distance<c.distance&&(c.match=h,c.distance=h.match.distance,c.paintOrder=u)}}return qa(c,dh(s,o)).match}function uh(e,t){if(e.kind==="render-hit-test")return{intersects:!0,onPoint:!1};const r=mh(e,t),n=e.kind==="buckets"&&ce(e.match.vertexDistance,r);return{intersects:ja(e,r),onPoint:n}}function dh(e,t){return e.match!==null&&t.match!==null&&e.distance===0&&t.distance===0?e.paintOrder>t.paintOrder?e:t:qa(e,t)}function qa(e,t){return e.match===null?t:t.match===null||e.distance<=t.distance+lh?e:t}function ja(e,t){switch(e.kind){case"banded":case"enclosure":return e.match.distance<=t.on.edge;case"buckets":return hh(e.match,t);case"points":return ce(e.match.distance,t)}}function mh(e,t){return e.match.index.projection==="polar"?t.polar:t.cartesian}function hh(e,t){return e.strokeDistance<=t.on.stroke?!0:ce(e.vertexDistance,t)}function an(e,t){return t===void 0?!1:!ja(e,t)&&!oe(e.match,t)}function ph({layer:e,cursor:t,aspectRatio:r,warmStarts:n,tolerance:a}){switch(e.kind){case"buckets":{const i=zm(e,t,r);return i?{kind:"buckets",match:i}:null}case"banded":{const i=Nm(e,t,r);return i?{kind:"banded",match:i}:null}case"points":{const i=om(e,t,r,n.get(e.layerId)??null,a);return i?{kind:"points",match:i}:null}case"enclosure":{const i=qm(e,t);return i?{kind:"enclosure",match:i}:null}case"noop":return null}}function fh(e,t,r,n){switch(e.kind){case"enclosure":{const a=oh(e,t,r,n!==void 0);return a?{kind:"enclosure",match:a}:null}case"points":{const a=sh(e,t,r,n);return a?{kind:"points",match:a}:null}case"buckets":{const a=rh(e,t,r);return a?{kind:"buckets",match:a}:null}case"banded":{const a=jm(e,t,r);return a?{kind:"banded",match:a}:null}case"noop":case"render-hit-test":return null}}function gh(e,t,r){const n=r.get(e.layerId);if(!n)return null;const a=n({x:t.x,y:1-t.y});if(!a)return null;const i=e.byKey.get(a.key);return i?{hit:$a(e.layerId,i)}:null}var N={primary:null,group:[],related:new Map},vh=1,yh=class{constructor({layers:e,coordSystem:t}){this.layerIndexes=[],this.layerRefs=[],this.viewport=null,this.aspectRatio=vh,this.isAspectStale=!1,this.warmStarts=new Map,this.cachedState=N,this.cachedKey=null,this.nonInteractiveLayerIds=new Set,this.hitTesters=new Map,this.cachedByKeyId=null,this.cachedByKeyState=N,this.layerIndexes=e.map(r=>Zr(r,t,this.aspectRatio)),this.layerRefs=e.map(r=>on(r,t)),this.nonInteractiveLayerIds=sn(e)}update({layers:e,coordSystem:t}){const r=new Map;for(let i=0;i<this.layerIndexes.length;i+=1){const o=this.layerIndexes[i],s=this.layerRefs[i];!o||!s||r.set(o.layerId,{index:o,ref:s})}const n=[],a=[];for(const i of e){const o=r.get(i.id),s=on(i,t);if(o!==void 0&&bh(o.ref,s)){n.push(o.index),a.push(o.ref);continue}this.warmStarts.delete(i.id),n.push(Zr(i,t,this.aspectRatio)),a.push(s)}for(const i of this.warmStarts.keys())e.some(o=>o.id===i)||this.warmStarts.delete(i);this.layerIndexes=n,this.layerRefs=a,this.nonInteractiveLayerIds=sn(e),this.invalidateCache()}setViewport(e){if(e.width<=0||e.height<=0)return;this.viewport=e;const t=e.width/e.height;t!==this.aspectRatio&&(this.aspectRatio=t,this.isAspectStale=!0)}query(e,t,r){if(this.layerIndexes.length===0)return N;this.reindexForAspect();const n=this.nonInteractiveLayerIds.size===0?this.layerIndexes:this.layerIndexes.filter(p=>!this.nonInteractiveLayerIds.has(p.layerId)),a=r??this.viewport,i=t!==void 0&&a!==null?im(t,a):void 0,o=ch({layers:n,aspectRatio:this.aspectRatio,warmStarts:this.warmStarts,hitTesters:this.hitTesters,cursor:e,tolerance:i});if(!o)return this.invalidateCache(),N;const s=o.match.hit;this.warmStarts.set(s.layerId,s.pointIndex);const c=i===void 0?void 0:uh(o,i),u=Sh(s,c);if(this.cachedKey===u)return this.cachedState;const{group:d,related:h}=dm(o,n);return this.cachedKey=u,this.cachedState=c===void 0?{primary:s,group:d,related:h}:{primary:s,group:d,related:h,intersection:c},this.cachedState}registerHitTester(e,t){this.hitTesters.set(e,t)}unregisterHitTester(e){this.hitTesters.delete(e)}resolveHoverByKey(e,t){if(this.nonInteractiveLayerIds.has(e))return N;const r=this.layerIndexes.find(i=>i.layerId===e);if(!r||r.kind!=="render-hit-test")return N;const n=r.byKey.get(t);if(!n)return N;const a=`${e}:${t}`;return this.cachedByKeyId===a?this.cachedByKeyState:(this.cachedByKeyId=a,this.cachedByKeyState={primary:$a(e,n),group:[],related:new Map},this.cachedByKeyState)}invalidateCache(){this.cachedKey=null,this.cachedState=N,this.cachedByKeyId=null,this.cachedByKeyState=N}reindexForAspect(){if(this.isAspectStale){this.isAspectStale=!1;for(const e of this.layerIndexes)e.kind==="points"&&e.projection==="cartesian"&&Ba(e,this.aspectRatio)}}};function Sh(e,t){const r=`${e.layerId}:${e.pointIndex}`;return t===void 0?r:`${r}:${t.intersects}:${t.onPoint}`}function on(e,t){return{data:e.data,geom:e.geom,position:e.position,coord:t}}function sn(e){const t=new Set;for(const r of e)r.interactive||t.add(r.id);return t}function bh(e,t){return e.data===t.data&&e.geom===t.geom&&e.position===t.position&&e.coord===t.coord}var xh=Math.PI*2;function Ah(e,t){const r=m.getMainAxisCoordinate(e.mainAxis,t);if(e.mainAxis==="y"){const a=K(F(r));return{x1:0,x2:"100%",y1:a,y2:a}}const n=K(r);return{x1:n,x2:n,y1:0,y2:"100%"}}function Ih(e,t,r){const n=e.mainAxis==="y"?l.getY(r.observation):l.getX(r.observation);if(n===null)return null;const a=e.mainAxis==="y"?Ja(r):Za(r),i=(t.x?.kind==="position"?t.x:null)?.bandwidth??a;if(i===null||i<=0)return null;const o=i/2;return e.mainAxis==="y"?{x:0,y:K(F(n+o)),width:"100%",height:K(i)}:{x:K(n-o),y:0,width:K(i),height:"100%"}}function Th(e,t){if(e.bandAxis===null)return null;if(e.bandAxis==="x"){const a=l.getXMin(t.observation),i=l.getXMax(t.observation);return a===null||i===null?null:{startAngle:a,endAngle:i,innerRadius:e.innerRadius,outerRadius:1}}const r=l.getYMin(t.observation),n=l.getYMax(t.observation);return r===null||n===null?null:{startAngle:e.startAngle,endAngle:e.startAngle+xh,innerRadius:r,outerRadius:n}}function Za(e){const t=l.getXMin(e.observation),r=l.getXMax(e.observation);return t===null||r===null?null:r-t}function Ja(e){const t=l.getYMin(e.observation),r=l.getYMax(e.observation);return t===null||r===null?null:r-t}function Lh(e){return e.observationIndex??e.pointIndex}function Eh(e){return e==="buckets"||e==="filled-buckets"||e==="spanned-buckets"}function Rh(e){return e==="buckets"||e==="filled-buckets"}var ze=.5,Ch=.3,wh=.4,Ph=10,Mh=({layer:e,coordSystem:t,scales:r,options:n})=>e.data.size()===0?null:e.spatialKind==="rects"?t.type==="cartesian"?Oh(e,t,r,n):_h(e,t,n):Rh(e.spatialKind)&&t.type==="cartesian"?Nh(e,t,n):e.spatialKind==="cells"||e.spatialKind==="spanned-buckets"?Vh(e,n):e.spatialKind==="points"?kh(e,n):null,Dh=e=>Eh(e.spatialKind)?new Set(e.data.getValues(l.GROUP_VARIABLES.group)).size:e.data.size(),Oh=(e,t,r,n)=>({type:"grow",layerId:e.id,durationSeconds:ze*n.durationScale,baseline:Gt(e,t,r),growAxis:t.mainAxis==="x"?"y":"x",delayByKey:n.stagger?Fh(e,t.mainAxis,n):{}}),_h=(e,t,r)=>{const n=t.bandAxis==="x"?"radius":"angle";return{type:"grow",layerId:e.id,durationSeconds:ze*r.durationScale,growAxis:n,baseline:n==="radius"?t.innerRadius:t.startAngle,delayByKey:n==="radius"&&r.stagger?Hh(e,t,r):{}}},kh=(e,t)=>({type:"grow",layerId:e.id,durationSeconds:ze*t.durationScale,growAxis:"size",baseline:0,delayByKey:t.stagger?Bh(e,t):{}}),Vh=(e,t)=>({type:"fade",layerId:e.id,durationSeconds:Ch*t.durationScale}),Nh=(e,t,r)=>({type:"wipe",layerId:e.id,durationSeconds:ze*r.durationScale,axis:t.mainAxis}),Fh=(e,t,r)=>{const n=He(e.data,e.mapping,e.id),a=new Map;for(const i of e.data){const o=Aa(t,i);if(!o)continue;const s=Ta(t,o),c=n(i),u=a.get(s);u?u.keys.push(c):a.set(s,{position:t==="x"?o.x:o.y,keys:[c]})}return Xt([...a.values()],r)},Bh=(e,t)=>{const r=He(e.data,e.mapping,e.id),n=[];for(const a of e.data){const i=Gh(a,t.staggerOrder);i!==null&&n.push({position:i,keys:[r(a)]})}return Xt(n,t)},Gh=(e,t)=>{if(t==="main-axis")return l.getX(e);const r=l.getSize(e)??l.getX(e);return r===null?null:t==="value-descending"?-r:r},Hh=(e,t,r)=>{const n=He(e.data,e.mapping,e.id),a=new Map;for(const i of e.data){const{startAngle:o,endAngle:s}=l.getAngleExtent(i),{innerRadius:c,outerRadius:u}=l.getRadiusExtent(i);if(o===null||s===null||c===null||u===null)continue;const d=Pa(t.bandAxis,{startAngle:o,endAngle:s,innerRadius:c,outerRadius:u}),h=n(i),p=a.get(d);p?p.keys.push(h):a.set(d,{position:o,keys:[h]})}return Xt([...a.values()],r)},Xt=(e,t)=>{const r={};if(e.length===0)return r;const n=[...e].sort((s,c)=>s.position-c.position),a=Math.ceil(n.length/Ph),i=Math.ceil(n.length/a),o=wh*t.durationScale/i;return n.forEach((s,c)=>{const u=Math.floor(c/a)*o;for(const d of s.keys)r[d]=u}),r},$h=(e,t,r)=>({shadow:e.get("shadow",t,r),blendMode:e.get("blendMode",t,r),...Qa({saturation:e.get("saturation",t,r),brightness:e.get("brightness",t,r),contrast:e.get("contrast",t,r),blur:e.get("blur",t,r)})}),Qa=e=>{const t={};return e.saturation!==void 0&&(t.saturation=e.saturation),e.brightness!==void 0&&(t.brightness=e.brightness),e.contrast!==void 0&&(t.contrast=e.contrast),e.blur!==void 0&&(t.blur=e.blur),t},q=["top","right","bottom","left"],ln={top:"topLeft",right:"topRight",bottom:"bottomRight",left:"bottomLeft"},zh={top:"topRight",right:"bottomRight",bottom:"bottomLeft",left:"topLeft"},Kh={topLeft:["left","top"],topRight:["top","right"],bottomRight:["right","bottom"],bottomLeft:["bottom","left"]},Yh=(e,t)=>{const{edges:r,cornerRadius:n}=e,a=Math.max(0,Math.min(n,t.width/2,t.height/2)),i=c=>{const[u,d]=Kh[c];return a>0&&r[u].strokeWidth>0&&r[d].strokeWidth>0},o=Wh(t,a),s=Xh(t,a,i);return qh(r).map(c=>({dashArray:r[c.firstEdge].dashArray,strokeWidth:r[c.firstEdge].strokeWidth,stroke:r[c.firstEdge].stroke,segments:jh(c,o,s,i)}))},Uh=e=>({top:e.edges.top.strokeWidth,right:e.edges.right.strokeWidth,bottom:e.edges.bottom.strokeWidth,left:e.edges.left.strokeWidth}),Wh=(e,t)=>{const{x:r,y:n,width:a,height:i}=e;return{topLeft:{cx:r+t,cy:n+t,startAngle:Math.PI,endAngle:Math.PI*1.5,radius:t},topRight:{cx:r+a-t,cy:n+t,startAngle:Math.PI*1.5,endAngle:Math.PI*2,radius:t},bottomRight:{cx:r+a-t,cy:n+i-t,startAngle:0,endAngle:Math.PI*.5,radius:t},bottomLeft:{cx:r+t,cy:n+i-t,startAngle:Math.PI*.5,endAngle:Math.PI,radius:t}}},Xh=(e,t,r)=>{const{x:n,y:a,width:i,height:o}=e,s=c=>r(c)?t:0;return{top:{start:{x:n+s("topLeft"),y:a},end:{x:n+i-s("topRight"),y:a}},right:{start:{x:n+i,y:a+s("topRight")},end:{x:n+i,y:a+o-s("bottomRight")}},bottom:{start:{x:n+i-s("bottomRight"),y:a+o},end:{x:n+s("bottomLeft"),y:a+o}},left:{start:{x:n,y:a+o-s("bottomLeft")},end:{x:n,y:a+s("topLeft")}}}},qh=e=>{const t=o=>e[o].strokeWidth>0,r=(o,s)=>{const c=(q.indexOf(o)+s+q.length)%q.length;return q[c]},n=o=>{const s=r(o,-1);return!t(s)||!_t(e[s].dashArray,e[o].dashArray)||e[s].strokeWidth!==e[o].strokeWidth||e[s].stroke!==e[o].stroke},a=q.filter(t);if(a.length===0)return[];const i=a.filter(n);return i.length===0?[{firstEdge:"top",edges:[...q],isClosed:!0}]:i.map(o=>{const s=[o];for(let c=r(o,1);t(c)&&!n(c);c=r(c,1))s.push(c);return{firstEdge:o,edges:s,isClosed:!1}})},jh=(e,t,r,n)=>{const a=(h,p,f)=>({type:"arc",cx:h.cx,cy:h.cy,radius:h.radius,startAngle:p,endAngle:f}),i=h=>(h.startAngle+h.endAngle)/2,o=[],s=e.firstEdge,c=e.edges[e.edges.length-1],u=ln[s];if(!e.isClosed&&n(u)){const h=t[u],p=i(h),f=Zh(h,p);o.push({type:"move",x:f.x,y:f.y}),o.push(a(h,p,h.endAngle))}else o.push({type:"move",x:r[s].start.x,y:r[s].start.y});o.push({type:"line",x:r[s].end.x,y:r[s].end.y});for(const h of e.edges.slice(1)){const p=ln[h];if(n(p)){const f=t[p];o.push(a(f,f.startAngle,f.endAngle))}o.push({type:"line",x:r[h].end.x,y:r[h].end.y})}const d=zh[c];if(e.isClosed){if(n(d)){const h=t[d];o.push(a(h,h.startAngle,h.endAngle))}o.push({type:"close"})}else if(n(d)){const h=t[d];o.push(a(h,h.startAngle,i(h)))}return o},Zh=(e,t)=>({x:e.cx+e.radius*Math.cos(t),y:e.cy+e.radius*Math.sin(t)}),Jh=/^(?:https?:|mailto:)/i,Qh=e=>{if(typeof e!="string")return!1;const t=e.replace(/^[\x00-\x20]+/,"");return t.length===0?!1:Jh.test(t)},ep=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"long",year:"numeric",weekday:"long",...C,...t});return L(n=>r.format(n))},tp=({locale:e,intlOptions:t})=>L(r=>w(e,{day:"2-digit",month:"short",year:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit",second:r.getUTCSeconds()!==0?"2-digit":void 0,...C,...t}).format(r)),_e=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return kn(e);case"date":return ep(e);case"datetime":return tp(e);case"day_month":return Bn(e);case"decimal":return Vn(e);case"duration":return At(e);case"integer":return Nn(e);case"month":return Gn(e);case"month_year":return Lt(e);case"percentage":return Fn(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return zn(e);case"weekly_date_range":return Hn(e);case"weekly_date_range_with_year":return $n(e);case"year":return Rt(e);case"lookup":return _e({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},ei={width:12,height:12},rp=({layers:e,coordSystem:t,scales:r,guides:n,numberFormat:a,parsingLocale:i,hover:o,readers:s,formattingLocale:c,comments:u,activeCalloutId:d})=>{const{primary:h}=o;if(h===null)return null;const p=c??i,f=ap(u,d);return{heading:f===null?ip({layers:e,coordSystem:t,guides:n,primary:h,locale:p,numberFormat:a}):null,rows:op({layers:e,scales:r,guides:n,hover:o,locale:p,numberFormat:a,readers:s}),comment:f}},np=(e,t,r)=>{if(Y(t,"line"))return e.geom.line(t).get("dashArray",r);if(Y(t,"area"))return e.geom.area(t).get("dashArray",r);if(Y(t,"rule"))return e.geom.rule(t).get("dashArray",r)};function ap(e,t){return e===void 0||t===null||t===void 0?null:e.find(r=>r.id===t)?.content??null}function ip(e){if(e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null)return null;const t=Nt(e.guides,"x");if(!t)return null;const r=e.layers.find(i=>i.id===e.primary.layerId);if(!r)return null;const n=l.readVariableName(r.mapping.x);if(!l.isDefined(n))return null;const a=e.primary.observation[n];return l.isDefined(a)?_e({valueFormat:t.valueFormat,locale:e.locale,numberFormat:e.numberFormat})(a):null}function op(e){const t=[],r=e.scales.color??null,n=up({guides:e.guides,locale:e.locale,numberFormat:e.numberFormat});for(const a of e.layers){const i=lp(a,e.hover);if(i.length===0)continue;const o=i[0];if(a.tooltip.length>0&&o){t.push(...sp(a,o,e.guides,e.readers,{locale:e.locale,numberFormat:e.numberFormat}));continue}const s=m.createColorValueReader(a.data,a.mapping),c=cp(i,a,r,s),u=Mt({layer:a,numberFormat:e.numberFormat,locale:e.locale}),d=dp(e.guides,a),h=m.createSegmentYReader(a),p=a.mapping.color!==void 0;for(const f of c){const g=p?s(f.observation):null,S=Ht(e.readers,a,f.observation)??null,x=Ot(np(e.readers,a,f.observation)),A=zt(e.readers.geom,a,f.observation,ei),T=p&&g!==null?n(g):d,E=h(f.observation),W=E===null?"":u(E,f.observation);t.push({swatchColor:S,geom:a.geom,swatchLineType:x,swatchFill:A.fill,swatchAlpha:A.alpha,swatchCornerRadius:A.cornerRadiusPx,swatchSymbol:A.symbol,label:T,value:W,isPrimary:f===e.hover.primary,key:`${f.layerId}:${f.pointIndex}`})}}return t}function sp(e,t,r,n,a){const i=zt(n.geom,e,t.observation,ei);return e.tooltip.map(o=>{const s=e.mapping[o.aes],c=l.readVariableName(s),u=m.createRawValueReader(e.data,s)(t.observation),d=I({valueFormat:m.getLayerVariableValueFormat(e,c),locale:a.locale,numberFormat:a.numberFormat});return{swatchColor:o.aes==="color"?Ht(n,e,t.observation)??null:null,geom:e.geom,swatchLineType:"solid",swatchFill:i.fill,swatchAlpha:i.alpha,swatchCornerRadius:i.cornerRadiusPx,swatchSymbol:i.symbol,label:o.key??m.resolveVariableLabel(c,r.variableLabels)??"",value:u===null?"":d(u,t.observation),isPrimary:!1,key:`${t.layerId}:${t.pointIndex}:${o.aes}`}})}function lp(e,t){const r=[];return t.primary!==null&&t.primary.layerId===e.id&&r.push(t.primary,...t.group),r.push(...t.related.get(e.id)??[]),r}function cp(e,t,r,n){if(r===null||t.mapping.color===void 0)return e;const a=new Map;return r.domain.forEach((i,o)=>{a.set(l.getStableKey(i),o)}),e.map((i,o)=>{const s=n(i.observation),c=s===null?null:l.getStableKey(s);return{hit:i,originalIndex:o,rank:c===null?Number.POSITIVE_INFINITY:a.get(c)??Number.POSITIVE_INFINITY}}).sort((i,o)=>i.rank===o.rank?i.originalIndex-o.originalIndex:i.rank-o.rank).map(i=>i.hit)}function up({guides:e,locale:t,numberFormat:r}){const n=new Map(e.colorGroups.map(i=>[l.getStableKey(i.value),{label:i.label,format:_e({valueFormat:i.valueFormat,locale:t,numberFormat:r})}])),a=_e({valueFormat:{type:"text"},locale:t,numberFormat:r});return i=>{const o=n.get(l.getStableKey(i));return o===void 0?a(i):o.label??o.format(i)}}function dp(e,t){return m.resolveVariableLabel(l.readVariableName(t.mapping.y),e.variableLabels)??""}function mp(e,t,r=0){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:r}function hp(e,t,r=""){const n=e[t];return typeof n=="string"?n:r}var pp=(e,t)=>({...e.annotation.arrow(t).resolve(),outline:e.annotation.arrow.outline(t).resolve()}),fp=(e,t)=>{const r=e.annotation.differenceArrow(t);return{...r.resolve(),isStrokeAuthored:r.getSource("stroke")==="authored",label:e.annotation.differenceArrow.label(t).resolve()}},gp=(e,t,r)=>{const n=e.annotation[t](r),a=e.annotation[t].label(r);return{marker:{...n.resolve(),isFillAuthored:n.getSource("fill")==="authored"},label:{...a.resolve(),isTextColorAuthored:a.getSource("textColor")==="authored"}}},vp=e=>e.strokeWidth>0?e.stroke??l.toPaintColor(e.fill):void 0,yp=e=>({edges:{top:e.panelBorder.top().resolve(),right:e.panelBorder.right().resolve(),bottom:e.panelBorder.bottom().resolve(),left:e.panelBorder.left().resolve()},cornerRadius:e.panelBorder().get("cornerRadius")}),Sp=e=>({...l.DEFAULT_GRAPH_PADDING_EDGES_PX,...e.graph().get("padding")}),P=e=>{let t={top:0,right:0,bottom:0,left:0};for(const r of e.collectAll("margin"))t={...t,...r};return t},bp=e=>({header:P(e.header()),footer:P(e.footer()),headline:P(e.headline()),legend:{top:P(e.legend.top()),right:P(e.legend.right()),bottom:P(e.legend.bottom()),left:P(e.legend.left())},axisLabel:{top:P(e.axisLabel.top("x")),bottom:P(e.axisLabel.bottom("x"))},tickLabel:{top:P(e.tickLabel.top("x")),right:P(e.tickLabel.right("y")),bottom:P(e.tickLabel.bottom("x")),left:P(e.tickLabel.left("y"))}}),xp=e=>({hover:e.editOutline.hover().resolve(),selected:e.editOutline.selected().resolve()}),cn=new WeakMap,Ap=e=>{const t=n=>e(n),r=un(t,n=>a=>e(a,n));return un(t,()=>r)},Ip=(e,t,r)=>{const n=hn(e.graph,dn(l.STYLE_TARGETS.graph,{}),r),a=pn(n,n,l.STYLE_TARGETS.graph.vocabulary),i=(s,c)=>s===l.STYLE_TARGETS.graph?a:pn(hn(e[s.select.target],dn(s,c),r),a,s.vocabulary),o=s=>{const c=Object.fromEntries(Object.entries(s.children??{}).map(([d,h])=>[d,o(h)]));if((s.options??[]).includes("annotation"))return Object.assign(Ep(d=>i(s,{annotation:d})),c);if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&Tp(s)){const d=new Map;return Object.assign(h=>{const p=d.get(h);if(p!==void 0)return p;const f=i(s,{axis:h});return d.set(h,f),f},c)}const u=i(s,{});return Object.assign(()=>u,c)};return Object.fromEntries(Object.entries(l.STYLE_TARGETS).map(([s,c])=>[s,s==="geom"?t:o(c)]))},un=(e,t)=>{const r=new Map;return new Proxy(e,{get:(n,a,i)=>{if(typeof a!="string"||a in n)return Reflect.get(n,a,i);const o=r.get(a);if(o!==void 0)return o;const s=t(a);return r.set(a,s),s}})},Tp=e=>{const t=l.findStyleTarget({target:e.select.target})??e;return Object.values(t.children??{}).some(r=>r.select.axis!==void 0)},dn=(e,t)=>{const r=l.findStyleTarget({target:e.select.target})??e,n=t.axis!==void 0?{...e.select,axis:t.axis}:e.select,a=r.partWildcard!==!0;return i=>{const o=i.select;if(o.target!==n.target)return!1;for(const s of l.STYLE_SELECT_KEYS){const c=n[s],u=o[s];if(s==="part"&&a){if(u!==c)return!1;continue}if(c===void 0){if(u!==void 0)return!1}else if(u!==void 0&&u!==c)return!1}if(t.annotation!==void 0){const s="annotation"in i.select?i.select.annotation:void 0;if(s!==void 0&&s!==t.annotation)return!1}return!0}},mn=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){const a=e[n];if(!(a===void 0||!r(a))&&a.declarations[t]!==void 0)return a}},hn=(e,t,r)=>{const n=c=>mn(e.overrides,c,t)??mn(e.defaults,c,t);return{get:c=>{const u=n(c)?.declarations[c];if(u!==void 0)return l.resolveColorScheme(u,r)},getSource:c=>{const u=n(c);return u===void 0?"unresolved":u.origin.list==="builtin"?"builtin":"authored"},explain:c=>{const u=n(c),d=u?.declarations[c];return u===void 0||d===void 0?{value:void 0,source:"unresolved"}:{value:l.resolveColorScheme(d,r),source:u.origin.list==="builtin"?"builtin":"authored",origin:u.origin,select:u.select}},collectAll:c=>{const u=[];for(const d of[e.defaults,e.overrides])for(const h of d){if(!t(h))continue;const p=h.declarations[c];p!==void 0&&u.push(l.resolveColorScheme(p,r))}return u}}},Lp=(e,t,r)=>{const n=t.get("textScale");e.fontSize!==void 0&&n!==void 0&&(e.fontSize*=n),"fontFamily"in r&&(e.fontFamily??=t.get("fontFamily"))},pn=(e,t,r)=>({...e,resolve:()=>{const n=cn.get(e);if(n!==void 0)return n;const a={};for(const i of Object.keys(r)){const o=e.get(i);o!==void 0&&Object.assign(a,{[i]:o})}return Lp(a,t,r),cn.set(e,a),a}}),Ep=e=>{const t=new Map;return r=>{const n=t.get(r);if(n!==void 0)return n;const a=e(r);return t.set(r,a),a}},Rp={color:l.getColor,alpha:l.getAlpha,strokeWidth:l.getStrokeWidth,lineType:l.getLineType,size:l.getSize},fn={vocabulary:{},aesthetics:{}},gn=new WeakMap,Cp=(e={})=>{const t=e.colorScheme??"light",r=new WeakMap,n=new WeakMap,a=(c,u)=>{let d=r.get(c);d===void 0&&(d=new Map,r.set(c,d));const h=d.get(u);if(h!==void 0)return h;const{vocabulary:p,aesthetics:f}=wp(c.styles,u),g=Op({styles:Dp(c.styles,u),colorScheme:t,vocabulary:p,visualVariableReaders:Pp(f,c.styles.dashPresets),findPart:S=>i(c,S)});return d.set(u,g),g},i=(c,u)=>Object.hasOwn(c.styles.parts,u)?a(c,u):void 0,o=Ap(a);return{readers:c=>{const u=n.get(c.chrome);if(u!==void 0)return u;const d=Ip(c.chrome,o,t);return n.set(c.chrome,d),d}}},wp=(e,t)=>t===void 0?e.observation:Object.hasOwn(e.parts,t)?e.parts[t]??fn:fn,Pp=(e,t)=>{const r={};for(const[n,a]of Object.entries(e)){const i=a===void 0?void 0:Rp[a];i!==void 0&&(r[n]=a==="lineType"?Mp(t):i)}return r},Mp=e=>t=>{const r=l.getLineType(t);return r===void 0?void 0:e[r]},Dp=(e,t)=>{let r=gn.get(e);r===void 0&&(r=new Map,gn.set(e,r));const n=r.get(t);if(n!==void 0)return n;const a={defaults:vn(e.defaults,t),overrides:vn(e.overrides,t)};return r.set(t,a),a},vn=(e,t)=>{const r={};for(const n of e)if(n.part===t)for(const a of Object.keys(n.declarations)){if(n.declarations[a]===void 0)continue;const i=r[a]??={};(i[n.state??"stateless"]??=[]).push(n)}return r},Op=({styles:e,colorScheme:t,vocabulary:r,visualVariableReaders:n,findPart:a})=>{const i=(h,p)=>{const f=n[h];if(!(f===void 0||p===void 0))return f(p)??void 0},o=(h,p,f)=>{if(f!==void 0){const A=z(e.overrides,h,p,f);if(A!==void 0)return{value:j(A,h,t),tier:"override",origin:A.origin,state:f};const T=z(e.defaults,h,p,f);if(T!==void 0)return{value:j(T,h,t),tier:"default",origin:T.origin,state:f}}const g=z(e.overrides,h,p,void 0);if(g!==void 0)return{value:j(g,h,t),tier:"override",origin:g.origin};const S=i(h,p);if(S!==void 0)return{value:S,tier:"data"};const x=z(e.defaults,h,p,void 0);return x!==void 0?{value:j(x,h,t),tier:"default",origin:x.origin}:{value:void 0,tier:"unresolved"}},s=(h,p,f)=>{if(f!==void 0){const x=Le(e.overrides,h,p,f,t);if(x!==void 0)return x;const A=Le(e.defaults,h,p,f,t);if(A!==void 0)return A}const g=Le(e.overrides,h,p,void 0,t);if(g!==void 0)return g;const S=i(h,p);return S!==void 0?S:Le(e.defaults,h,p,void 0,t)};return{get:s,getSource:(h,p,f)=>o(h,p,f).tier,explain:o,collectAll:(h,p,f)=>{const g=[];for(const S of[e.defaults,e.overrides]){const x=S[h]?.[f??"stateless"];if(x!==void 0)for(const A of x){const T=A.declarations[h];T!==void 0&&ti(A,p)&&g.push(l.resolveColorScheme(T,t))}}return g},resolve:(h,p)=>{const f={};for(const g of Object.keys(r)){const S=s(g,h,p);S!==void 0&&Object.assign(f,{[g]:S})}return f},resolveState:(h,p)=>{const f={};for(const g of Object.keys(r)){const S=z(e.overrides,g,p,h)??z(e.defaults,g,p,h),x=j(S,g,t);x!==void 0&&Object.assign(f,{[g]:x})}return f},part:a}},Le=(e,t,r,n,a)=>j(z(e,t,r,n),t,a),j=(e,t,r)=>{const n=e?.declarations[t];return n===void 0?void 0:l.resolveColorScheme(n,r)},z=(e,t,r,n)=>{const a=e[t]?.[n??"stateless"];if(a!==void 0)for(let i=a.length-1;i>=0;i--){const o=a[i];if(o!==void 0&&ti(o,r))return o}},ti=(e,t)=>e.matches===void 0?!0:t!==void 0&&e.matches(t),qt=["sticker","pinnedNumber","comment","image"],_p=e=>qt.includes(e),jt=e=>{switch(e.kind){case"pinnedNumber":case"comment":return e.annotation.at;case"sticker":return e.annotation.at.anchorType==="observation"?Vp(e.annotation.at):null;default:return null}},ri=(e,t)=>e.layerId===t.layerId&&l.areDataValuesEqual(e.anchorValue,t.anchorValue)&&l.areDataValuesEqual(e.groupValue??null,t.groupValue??null)&&l.areDataValuesEqual(e.crossValue??null,t.crossValue??null),ni=(e,t,r=kp)=>{const n=r(t);for(const a of qt){const i=m.readAnnotationBucket(e,a),o=i.findIndex(c=>{const u=jt({kind:a,annotation:c});if(u===null)return!1;const d=r(u);return ri(d,n)}),s=i[o];if(s!==void 0)return{kind:a,index:o,annotation:s}}return null},kp=e=>({...e,anchorValue:nt(e.anchorValue),...e.groupValue!==void 0&&{groupValue:nt(e.groupValue)},...e.crossValue!==void 0&&{crossValue:nt(e.crossValue)}}),nt=e=>l.readISOInstant(e)??e,Vp=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),ai=(e,t)=>ke(e)===ke(t),ke=e=>JSON.stringify(Zt(e)),Zt=e=>{const t=e;return typeof t!="object"||t===null?["invalid",String(t)]:"and"in e?["and",...yn(e.and)]:"or"in e?["or",...yn(e.or)]:"not"in e?["not",Zt(e.not)]:[e.variable,...Np(e)]},Np=e=>{if("eq"in e)return["eq",l.readDataValueKey(e.eq)];if("oneOf"in e)return["oneOf",...Sn(e.oneOf)];if("lt"in e)return["lt",l.readDataValueKey(e.lt)];if("lte"in e)return["lte",l.readDataValueKey(e.lte)];if("gt"in e)return["gt",l.readDataValueKey(e.gt)];if("gte"in e)return["gte",l.readDataValueKey(e.gte)];if("range"in e)return["range",...Sn(e.range)];const t=Object.entries(e).sort(([r],[n])=>r.localeCompare(n));return["invalid",JSON.stringify(t)]},yn=e=>Array.isArray(e)?e.map(Zt):["invalid",JSON.stringify(e)],Sn=e=>Array.isArray(e)?e.map(l.readDataValueKey):["invalid",JSON.stringify(e)],Fp=(e,t)=>e.find(r=>r.scope===t.scope&&r.layerId===t.layerId&&ai(r.predicate,t.predicate))??null,ii=e=>e.find(t=>t.geom==="rule"&&t.stat.type==="identity"&&(l.isStrictNumericDataValue(l.readConstantValue(t.mapping.y))||l.isStrictNumericDataValue(l.readConstantValue(t.mapping.x)))),oi=e=>e.find(t=>t.geom==="line"&&t.stat.type==="smooth"),si=e=>e.find(t=>t.geom==="rule"&&t.stat.type==="mean");function li(e){return{mapping:e.mapping,layers:e.layers,scales:e.scales.map(Bp),transforms:e.transforms,highlights:e.highlights,styles:b.styles(e.styles),annotations:e.annotations,coords:e.coords,config:e.config}}function Bp(e){const{inferredFrom:t,...r}=e;return r.scaleType==="palette"?Gp(r):r}function Gp(e){return{...e,palette:Hp(e.palette),overrides:$p(e.overrides)}}function Hp(e){return e.type==="custom"?{type:"custom",id:e.id}:e}function $p(e){if(!e)return;const t={};for(const[r,n]of Object.entries(e))t[Number(r)]={hex:n};return t}var ue=(e,t)=>{const r=Jt(e,t);return r===-1?void 0:e[r]},Jt=(e,t)=>{const r=se(t);for(let n=e.length-1;n>=0;n-=1){const a=e[n];if(a!==void 0&&se(a)===r)return n}return-1},ci=(e,t)=>se(e)===se(t),se=e=>{const t=Object.entries(e.select).filter(([,n])=>n!==void 0).sort(([n],[a])=>n.localeCompare(a)),r=e.when?.where===void 0?null:ke(e.when.where);return JSON.stringify([t,e.when?.state??null,r])},ui=(e,t)=>[...new Set([...Object.keys(e),...Object.keys(t)])].every(r=>zp(e[r],t[r])),U=(e,t)=>({select:{target:"geom",kind:e,layer:t}}),Qt=e=>e.select.target==="geom",de=(e,t)=>{const r=ue(e,t);if(!(r===void 0||!Qt(r)))return r.declarations},zp=(e,t)=>e===t?!0:l.isLightDarkColor(e)?l.isLightDarkColor(t)&&e.light===t.light&&e.dark===t.dark:l.isStyleTokenRef(e)?l.isStyleTokenRef(t)&&e.token===t.token:!1;function y(e){return{id:e.id??m.uniqueId(),timestamp:e.timestamp??Date.now(),description:e.description,author:e.author??"unknown"}}function Q(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((r,n)=>Q(r,t[n]));if(l.isPlainObject(e)&&l.isPlainObject(t)){const r=Object.keys(e).filter(a=>e[a]!==void 0),n=Object.keys(t).filter(a=>t[a]!==void 0);return r.length===n.length&&r.every(a=>Q(e[a],t[a]))}return!1}var er=class{constructor(e,t={}){this.type="remove-annotation",this.params=e,this.metadata=y({...t,description:"Remove annotation"})}get target(){return{kind:"annotation",id:this.params.id}}apply(e){const t=m.findAnnotation(e.annotations,this.params.id);if(!t)return null;const{kind:r,index:n,annotation:a}=t;return{spec:m.patchSpec(e,{annotations:m.removeLocatedAnnotation(e.annotations,t)}),revert:new tr({kind:r,annotation:a,index:n},this.metadata)}}},Kp={type:"remove-annotation",deserialize:(e,t)=>new er(e,t)},tr=class di{constructor(t,r={}){this.type="add-annotation",this.params={kind:t.kind,annotation:{...t.annotation,id:t.annotation.id??m.uniqueId()},...t.index!==void 0&&{index:t.index}},this.metadata=y({...r,description:"Add annotation"})}get target(){return{kind:"annotation",id:this.params.annotation.id}}apply(t){const{kind:r,annotation:n,index:a}=this.params;if(!m.isAnnotationKind(r)||m.findAnnotation(t.annotations,n.id))return null;const i=Up(t.annotations,{kind:r,annotation:n}),o=i===null?t.annotations:m.removeLocatedAnnotation(t.annotations,i),s=m.readAnnotationBucket(o,r),c=a??s.length,u=Math.min(Math.max(c,0),s.length);return{spec:m.patchSpec(t,{annotations:m.replaceAnnotationBucket(o,r,[...s.slice(0,u),n,...s.slice(u)])}),revert:i===null?new er({id:n.id},this.metadata):new di({kind:i.kind,annotation:i.annotation,index:i.index},this.metadata)}}},Yp={type:"add-annotation",deserialize:(e,t)=>new tr({kind:e.kind,annotation:e.annotation,index:e.index},t)},Up=(e,t)=>{const r=jt(t);return r===null?null:ni(e,r)},Wp=(e,t)=>{const r=rr(e);return r===null?null:mi(r.points,t)},Xp=e=>rr(e)!==null,qp=(e,t)=>{const r=rr(e);if(r===null)return null;const n=mi(r.points,t);return n.x===0&&n.y===0?null:r.createPatch(n)},rr=e=>{const t=Zp[e.kind];return t===null?null:t(e.annotation)},bn=(e,t)=>e.anchorType!=="panel"?null:{points:[gt(e,e.offset)],createPatch:r=>t({...e,x:e.x+r.x,y:e.y+r.y})},xn=(e,t)=>e.anchorType!=="panel"?null:{points:[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y+e.height}],createPatch:r=>t({...e,x:e.x+r.x,y:e.y+r.y})},jp=(e,t)=>e.anchorType!=="panel"||t.anchorType!=="panel"?null:{points:[gt(e,e.offset),gt(t,t.offset)],createPatch:r=>({start:{...e,x:e.x+r.x,y:e.y+r.y},end:{...t,x:t.x+r.x,y:t.y+r.y}})},Zp={text:e=>bn(e.at,t=>({at:t})),sticker:e=>bn(e.at,t=>({at:t})),shape:e=>xn(e.region,t=>({region:t})),image:e=>xn(e.region,t=>({region:t})),arrow:e=>jp(e.start,e.end),differenceArrow:null,pinnedNumber:null,comment:null},gt=(e,t)=>t===void 0||t.unit==="px"?{x:e.x,y:e.y}:{x:e.x+(t.x??0),y:e.y+(t.y??0)},mi=(e,t)=>({x:An(e.map(r=>r.x),t.x),y:An(e.map(r=>r.y),t.y)}),An=(e,t)=>{if(!Number.isFinite(t))return 0;const r=Math.min(-Math.min(...e),0),n=Math.max(1-Math.max(...e),0);return!Number.isFinite(r)||!Number.isFinite(n)?0:(0,ne.default)(t,r,n)},hi=(e,t,r)=>{const n=t.annotation;if(!ef(n,r))return null;const a=m.readAnnotationBucket(e.annotations,t.kind),i=Jp(t.annotation,r),o=[...a.slice(0,t.index),i,...a.slice(t.index+1)];return{spec:m.patchSpec(e,{annotations:m.replaceAnnotationBucket(e.annotations,t.kind,o)}),inverse:Qp(n,r)}},Jp=(e,t)=>{const r=new Set(Object.entries(t).filter(([,n])=>n===void 0).map(([n])=>n));return Object.fromEntries(Object.entries({...e,...t}).filter(([n])=>!r.has(n)))},Qp=(e,t)=>{const r={};for(const n of Object.keys(t))r[n]=e[n];return r},ef=(e,t)=>Object.entries(t).some(([r,n])=>!Object.is(e[r],n)),nr=class pi{constructor(t,r={}){this.type="update-annotation",this.params=t,this.metadata=y({...r,description:"Update annotation"})}get target(){return{kind:"annotation",id:this.params.id}}apply(t){const{kind:r,id:n,patch:a}=this.params,i=m.findAnnotation(t.annotations,n);if(i===null||i.kind!==r)return null;const o=hi(t,i,a);return o===null?null:{spec:o.spec,revert:new pi({kind:r,id:n,patch:o.inverse},this.metadata)}}},tf={type:"update-annotation",deserialize:(e,t)=>new nr(e,t)},fi=class{constructor(e,t={}){this.type="move-annotation",this.params={id:e.id,translation:{x:e.translation.x,y:e.translation.y}},this.metadata=y({...t,description:"Move annotation"})}get target(){return{kind:"annotation",id:this.params.id}}apply(e){const t=m.findAnnotation(e.annotations,this.params.id);if(t===null)return null;const r=qp(t,this.params.translation);if(r===null)return null;const n=hi(e,t,r);return n===null?null:{spec:n.spec,revert:new nr({kind:t.kind,id:t.annotation.id,patch:n.inverse},this.metadata)}}},rf={type:"move-annotation",deserialize:(e,t)=>new fi(e,t)},H=class Ce{constructor(t,r={}){this.type="set-style-rule",this.params=t,this.metadata=y({...r,description:t.rule.declarations===null?"Remove style rule":"Set style rule"})}get target(){const{list:t,rule:r}=this.params;return{kind:"styleRule",list:t,select:r.select,...r.when===void 0?{}:{when:r.when}}}apply(t){const{list:r,rule:n,index:a}=this.params,i=t.styles[r],o=Jt(i,n),s=o===-1?void 0:i[o],{declarations:c}=n;if(c===null){if(s===void 0)return null;const g=new Ce({list:r,rule:s,index:o},this.metadata),S=i.filter(x=>!ci(x,n));return{spec:at(t,r,S),revert:g}}if(s!==void 0){if(ui(s.declarations,c))return null;const g={...s,declarations:c},S=new Ce({list:r,rule:s,index:o},this.metadata),x=i.map(A=>A===s?g:A);return{spec:at(t,r,x),revert:S}}const u=a??i.length,d=Math.min(Math.max(u,0),i.length),h={...n,declarations:c},p=[...i.slice(0,d),h,...i.slice(d)],f=new Ce({list:r,rule:{...n,declarations:null}},this.metadata);return{spec:at(t,r,p),revert:f}}},nf=e=>{const{rule:t}=e;if(t==null)throw new l.UserInputError({code:"INVALID_STYLE_RULE",message:"Command 'set-style-rule' is missing its 'rule'.",suggestion:"Send the entry's 'select' (and 'when') with 'declarations: null' to remove it."})},af={type:"set-style-rule",deserialize:(e,t)=>(nf(e),new H(e,t))},at=(e,t,r)=>m.patchSpec(e,{styles:{...e.styles,[t]:r}}),of={type:"set-difference-arrow-style",deserialize:(e,t)=>new gi(e,t)},gi=class vi{constructor(t,r={}){this.type="set-difference-arrow-style",this.params=t,this.metadata=y({...r,description:"Set difference arrow style"})}get target(){return{kind:"annotation",id:this.params.annotationId}}apply(t){const{annotationId:r,arrow:n,label:a}=this.params,i={target:"annotation",kind:"differenceArrow",annotation:r},o={...i,part:"label"};let s=t;const c={annotationId:r},u=d=>{const h=ue(s.styles.overrides,d),p=new H({list:"overrides",rule:d}).apply(s);if(p)return s=p.spec,h?.declarations??null};if(n!==void 0){const d=u({select:i,declarations:n});d!==void 0&&(c.arrow=d)}if(a!==void 0){const d=u({select:o,declarations:a});d!==void 0&&(c.label=d)}return s===t?null:{spec:s,revert:new vi(c,this.metadata)}}},sf=["cartesian","polar","flip"],M=new l.GeomRegistry,yi=e=>M.has(e)?M.get(e):null,Ke=e=>m.applyReplayableTransforms(e.data,e.transforms);function ar(e,t){const r=t.some(i=>i.yScaleType==="secondary"),n=e.find(i=>i.scaledAesthetic==="ySecondary");if(!r)return n===void 0?e:e.filter(i=>i!==n);if(n!==void 0)return e;const a=e.find(i=>i.scaledAesthetic==="y");return a===void 0?e:[...e,{...a,scaledAesthetic:"ySecondary"}]}function Ye(e,t){return e.scales.find(r=>r.scaledAesthetic===t)}function Ue(e,t,r){const n=e.scales.findIndex(a=>a.scaledAesthetic===t);return n===-1?e:m.patchSpec(e,{scales:m.replaceAtIndex(e.scales,n,r)})}function We(e){const t=e.replace(/([A-Z])/g," $1").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function vt(e,t,r){const n=m.resolveScale(m.createScaleContext(m.createCommonContainer(M),{data:Ke(e),layers:e.layers,mapping:r,customPalettes:{}}),l.inferred(t));return e.coords.coordType==="polar"?m.removeDiscreteScalePadding(n):n}var Si=class bi{constructor(t,r={}){this.type="set-chart-type",this.target={kind:"coords"},this.params=t,this.metadata=y({...r,description:Sf(t)})}apply(t){const r="previous"in this.params?this.params.previous:bf(t,this.params);if(r===null)return null;const n=m.patchSpec(t,r);return n===t?null:{spec:n,revert:new bi({previous:{coords:t.coords,layers:t.layers,scales:t.scales,mapping:t.mapping}},this.metadata)}}},lf={type:"set-chart-type",deserialize:(e,t)=>new Si(e,t)},xi={type:"sum"},cf={type:"identity"},uf=["bar","line","area","point","tile"],ir="tile",df=["y","color"],mf=Object.values(l.LAYER_LABEL_VARIABLES),hf={coordType:"cartesian",geom:ir,position:"identity"},me=e=>e.coordType==="cartesian"&&"comboType"in e&&b.COMBO_TYPES.includes(e.comboType),pf=e=>{const t=e.layers.filter(B),[r]=t;if(r===void 0)return null;const{coords:n}=e;if(n.coordType==="cartesian"){const o=Ii(t);if(o!==null)return{coordType:"cartesian",comboType:o}}if(!t.every(o=>o.geom===r.geom&&o.position===r.position))return null;const{geom:a,position:i}=r;return n.coordType==="polar"?{coordType:"polar",geom:a,position:i,theta:n.params.theta,innerRadius:n.params.innerRadius}:{coordType:n.coordType,geom:a,position:i}},ff=e=>{if(!e)return!1;const t=e.layers.filter(B);if(t.length>=2)return!0;const[r]=t;return r===void 0?!1:Ti(e,r)?Li(e,r).length>=1:Xe(e,e.data.groupVariableNamesByType().numeric).length>=2},gf=e=>e?Mi(e,hf)!==null:!1,vf=e=>Ai(e)?.at(-1)?.id??null,Ai=e=>{if(e.coords.coordType!=="cartesian")return null;const t=e.layers.filter(B);return Ii(t)===null?null:t},Ii=e=>{const t=e.at(-1);if(e.length<2||t?.geom!=="line")return null;const r=e.slice(0,-1);if(r.every(a=>a.geom==="line"))return yf(e)?"lines":null;if(!r.every(a=>a.geom==="bar"))return null;const[n]=r;return n===void 0||!r.every(a=>a.position===n.position)?null:b.readComboTypeOfBarPosition(n.position)},yf=e=>e.some(t=>t.yScaleType==="secondary"||Ve(t))||new Set(e.map(t=>l.readVariableName(t.mapping.y))).size>1,Sf=e=>"previous"in e?"Restore the previous chart type":me(e)?`Set chart type to a ${e.comboType} combo`:`Set chart type to ${e.position} ${e.geom} in ${e.coordType} coords`,bf=(e,t)=>{const r=Mi(e,t);if(r===null)return null;const n=me(t)?Af(r,t):xf(r,t,e);return n===null||r===e?n:{...n,scales:kf({...e,...n},n.scales)}},xf=(e,t,r)=>{if(me(t)||!Vf(t))return null;const n={...e,layers:Fi(e.layers)},a=Bf(n.layers.filter(B),t),i=Gi(n.coords,t),o=wi(n,t),s=Ni({...n,mapping:o},t,a,o!==n.mapping);return{coords:i,layers:s,scales:ar(Hi(r,s,i.coordType),s),mapping:o}},Af=(e,t)=>{const r=Lf(e,t.comboType);if(r===null)return null;const n={...e,layers:r},a=Gf(r.filter(B),t.comboType),i=Gi(n.coords,t),o=wi(n,t),s=Ni({...n,mapping:o},t,a,o!==n.mapping),c=If(e)?s:Tf(s);return{coords:i,layers:c,scales:ar(Hi(e,c,i.coordType),c),mapping:o}},If=e=>Ai(e)!==null,Tf=e=>{const t=e.filter(B).at(-1);return t===void 0||t.yScaleType==="secondary"?e:e.map(r=>r.id===t.id?{...r,yScaleType:"secondary"}:r)},Lf=(e,t)=>{const r=e.layers.filter(B);if(r.length>=2)return e.layers;const[n]=r;return n===void 0?null:Ti(e,n)?Ef(e,n):Rf(e,n,t)},Ti=(e,t)=>{const r=l.readVariableName(t.mapping.color??e.mapping.color);return r!==null&&r!==""},Ef=(e,t)=>{const[r]=Li(e,t);if(r===void 0)return null;const n=m.resolveLayer(M,e.mapping,e.coords.coordType,{type:"layer",id:Ei(r,new Set(e.layers.map(a=>a.id))),geom:"line",stat:xi,...Ci(r,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(a=>a.id===t.id?[a,n]:[a])},Xe=(e,t)=>{const r=he(e);return t.filter(n=>n!==r)},Li=(e,t)=>{const r=l.readVariableName(t.mapping.y??e.mapping.y);return Xe(e,e.data.groupVariableNamesByType().numeric).filter(n=>n!==r)},he=e=>l.readMainAxisVariable(e.mapping)||l.inferXVariable(e.data),Rf=(e,t,r)=>{const{numeric:n}=e.data.groupVariableNamesByType(),a=Xe(e,n),i=a.at(-1);if(a.length<2||i===void 0)return null;const o=l.readFoldKeepVariables(e.data,he(e)),s=b.COMBO_BAR_POSITIONS[r]===null?l.LAYER_LABEL_VARIABLES.line:l.LAYER_LABEL_VARIABLES.bar,c=Cf(t,In(a.slice(0,-1),o,s)),u=m.resolveLayer(M,e.mapping,e.coords.coordType,{type:"layer",id:Ei(i,new Set(e.layers.map(d=>d.id))),geom:"line",stat:t.stat,...In([i],o,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(d=>d.id===t.id?[c,u]:[d])},Ei=(e,t)=>{const r=`line:${e}`;let n=r;for(let a=2;t.has(n);a+=1)n=`${r}:${a}`;return n},In=(e,t,r)=>{const[n]=e;return e.length===1&&n!==void 0?Ci(n,r):Ri(e,t)},Ri=(e,t)=>({mapping:{y:l.DEFAULT_RESHAPE_VALUE_NAME,color:"key"},transforms:[b.transform.reshape({keep:t,reshape:e,keyName:"key",valueName:l.DEFAULT_RESHAPE_VALUE_NAME})]}),Ci=(e,t)=>({mapping:{y:e,color:t},transforms:[b.transform.constant({variableName:t,type:"categorical",value:e})]}),Cf=(e,t)=>({...e,mapping:{...e.mapping,...t.mapping},transforms:[...e.transforms,...t.transforms]}),wi=(e,t)=>{const r=l.readMainAxisVariable(e.mapping),n=Pi(t)?"":he(e);return n===r?e.mapping:{...e.mapping,x:n}},Pi=e=>e.coordType==="polar"&&e.theta==="y"&&e.position==="fill",wf=e=>!me(e)&&e.geom===ir,Pf=e=>e.layers.filter(B).some(t=>t.geom===ir),Mi=(e,t)=>{const r=wf(t);return r===Pf(e)?e:r?Mf({...e,layers:Fi(e.layers)}):Df(e)??e},Mf=e=>{const t=Oi(e);if(t===null)return null;const r=Of(e,t)===null?_f(e,t):_i(e,t);return r===null?null:Di(e,t,r)},Df=e=>{const t=Oi(e);if(t===null)return null;const r=_i(e,t);return r===null?null:Di(e,t,r)},Di=(e,t,r)=>({...e,mapping:r.mapping,layers:e.layers.map(n=>n===t?r.layer:n)}),Oi=e=>{const t=e.layers.filter(B);return t.length===1?t[0]??null:null},_i=(e,t)=>{const r={...e.mapping,...t.mapping};return r.y===void 0||r.color===void 0?null:{mapping:{...e.mapping,y:r.color,color:r.y},layer:ki(t)}},ki=e=>{if(e.mapping.y===void 0&&e.mapping.color===void 0)return e;const{y:t,color:r,...n}=e.mapping;return{...e,mapping:n}},Of=(e,t)=>{const r={...e.mapping,...t.mapping},n=l.readVariableName(r.color),a=l.readVariableName(r.y);if(n===null||n===""||a===null||a===""||n===he(e))return null;const i=Ke(e);return i.hasVariable(n)&&i.getType(n)==="numeric"?null:n},_f=(e,t)=>{const r=Xe(e,e.data.groupVariableNamesByType().numeric);if(r.length<2)return null;const n=l.readFoldKeepVariables(e.data,he(e)),a=Ri(r,n),i=ki(t);return{mapping:{...e.mapping,y:a.mapping.color,color:a.mapping.y},layer:{...i,transforms:[...i.transforms,...a.transforms]}}},kf=(e,t)=>df.reduce((r,n)=>{const a=vt(e,n,e.mapping);return r.some(i=>i.scaledAesthetic===n)?m.mapItems(r,i=>i.scaledAesthetic===n?a:i):[...r,a]},t),Vf=e=>sf.includes(e.coordType)&&Vi(e.geom)&&Nf(e)&&(e.coordType!=="polar"||Number.isFinite(e.innerRadius)),Nf=({geom:e,coordType:t,position:r})=>{const{supportedCoordTypes:n,supportedPositions:a}=M.get(e);return n.includes(t)&&a.includes(r)},Vi=e=>uf.includes(e),B=e=>Vi(e.geom)&&!Ff(e.stat),Ff=e=>{switch(e.type){case"smooth":return!0;case"identity":case"count":case"mean":case"sum":return!1;default:return!0}},Bf=(e,{geom:t,position:r})=>{const n={geom:t,position:r};return new Map(e.map(a=>[a.id,n]))},Gf=(e,t)=>{const r={geom:"line",position:"identity"},n=b.COMBO_BAR_POSITIONS[t],a=e.map((i,o)=>n===null||o===e.length-1?[i.id,r]:[i.id,{geom:"bar",position:Hf(i,t,n)}]);return new Map(a)},Hf=(e,t,r)=>e.geom!=="bar"||Ve(e)?r:b.readComboTypeOfBarPosition(e.position)===t?e.position:r,Ni=(e,t,r,n)=>{const a=e.coords.coordType!==t.coordType;return m.clampValuesAgainstFillSiblings(M,m.mapItems(e.layers,i=>{const o=r.get(i.id);if(o===void 0)return i;const s=$f(i.stat,e.coords,t);return a||n||i.geom!==o.geom||i.position!==o.position||s!==i.stat?Kf(e,{...i,stat:s},t.coordType,o):i}))},$f=(e,t,r)=>Pi(r)?e.type==="identity"?xi:e:zf(t)&&e.type==="sum"?cf:e,zf=e=>e.coordType==="polar"&&e.params.theta==="y",Kf=(e,t,r,{geom:n,position:a})=>{const i={geom:t.geom===n,coordType:e.coords.coordType===r,position:t.position===a},{labelSource:o,format:s,offset:c,justify:u,...d}=t.dataLabels;return{...m.resolveLayer(M,e.mapping,r,{type:"layer",id:t.id,geom:n,mapping:t.mapping,stat:t.stat,position:a,params:i.geom?t.params:void 0,yScaleType:t.yScaleType,transforms:t.transforms,interactive:t.interactive,dataLabels:{...d,...i.coordType&&{format:s},...i.geom&&i.coordType&&{offset:c},...i.geom&&i.position&&{justify:u}}}),stat:t.stat}},Fi=e=>{const t=e.filter(B);if(t.length<2||!e.some(Ve))return e;const[r]=t;return e.flatMap(n=>n===r?[Yf(n)]:Ve(n)?[]:[n])},Ve=e=>Bi(e)!==null,Bi=e=>{const t=e.transforms.at(-1);return t?.transformType==="reshape"?t.options.keyName==="key"?t:null:t?.transformType!=="constant"?null:mf.includes(t.options.variableName)?t:null},Yf=e=>{const t=Bi(e);if(t===null)return e;const{color:r,...n}=e.mapping,a=t.transformType==="reshape"?t.options.reshape?.[0]:void 0;return{...e,mapping:a===void 0?n:{...n,y:a},transforms:e.transforms.slice(0,-1)}},Gi=(e,t)=>{const r=Uf(e,t);return(0,we.default)(r,e)?e:r},Uf=(e,t)=>{const r={xLimits:e.params.xLimits,yLimits:e.params.yLimits};if(t.coordType!=="polar")return m.resolveCoord({type:"coord",coordType:t.coordType,params:r});const n=e.coordType==="polar"?e.params:m.POLAR_COORD_DEFAULTS;return m.resolveCoord({type:"coord",coordType:"polar",params:{...r,theta:t.theta,startAngle:n.startAngle,innerRadius:t.innerRadius}})},Hi=(e,t,r)=>{const n=m.resolveGeomScaleDemands(m.readGeomScaleConstraints(M,t)),a=m.resolveGeomScaleDemands(m.readGeomScaleConstraints(M,e.layers)),i=e.coords.coordType==="polar";return m.mapItems(e.scales,o=>{const s=Wf(o,n,a),c=Xf(s,n,a);return jf(c,r,i)})},Wf=(e,t,r)=>{if(e.scaleType==="discrete"){const a=t.bandPadding[e.scaledAesthetic];return a===void 0||e.padding===a?e:{...e,padding:a}}if(e.scaledAesthetic===t.discreteAxis)return m.resolveDiscreteScale(l.discrete(e.scaledAesthetic,{..."reverse"in e&&{reverse:e.reverse}}),t);if(e.scaledAesthetic===t.discreteCrossAxis)return m.resolveDiscreteScale(l.discrete(e.scaledAesthetic),t);const n=t.zeroAxes[e.scaledAesthetic];if(n!==void 0&&e.scaleType==="continuous"){const a=r.zeroAxes[e.scaledAesthetic],i=qf(e.nice,n,a),o=a===void 0?null:e.domainMin;return e.nice===i&&e.domainMin===o?e:{...e,nice:i,domainMin:o}}return e},Xf=(e,t,r)=>{if(e.scaleType!=="discrete"||!l.isPositionScale(e.scaledAesthetic))return e;const n=t.bandPadding[e.scaledAesthetic];if(n===r.bandPadding[e.scaledAesthetic])return e;const a=n??l.DISCRETE_SCALE_DEFAULTS.padding;return e.padding===a?e:{...e,padding:a}},qf=(e,t,r)=>t.nice===(r?.nice??!0)?e:t.nice?l.CONTINUOUS_SCALE_DEFAULTS.nice:!1,jf=(e,t,r)=>{if(e.scaleType!=="discrete"||!l.isPositionScale(e.scaledAesthetic))return e;if(t==="polar")return e.padding===0?e:{...e,padding:0};if(!r)return e;const{padding:n}=l.DISCRETE_SCALE_DEFAULTS;return e.padding===n?e:{...e,padding:n}},$i=class zi{constructor(t,r={}){this.type="set-mapping",this.params=t,this.target={kind:"mapping",aesthetic:t.aesthetic},this.metadata=y({...r,description:Jf(t)})}apply(t){const r="previous"in this.params?this.params.previous:Qf(t,this.params);if(r===null)return null;const n=m.patchSpec(t,r);return n===t?null:{spec:n,revert:new zi({aesthetic:this.params.aesthetic,previous:{mapping:t.mapping,scales:t.scales,layers:t.layers}},this.metadata)}}},Zf={type:"set-mapping",deserialize:(e,t)=>new $i(e,t)},Ki=(e,t)=>{const r=l.readVariableName(e[t]);return r===null||r===""||l.isInternalVariable(r)?null:r},Yi=e=>e===""?null:e,Jf=e=>{if("previous"in e)return`Restore the previous ${e.aesthetic} mapping`;const t=Yi(e.variable);return t===null?`Clear the ${e.aesthetic} mapping`:`Map ${e.aesthetic} to ${t}`},Qf=(e,{aesthetic:t,variable:r})=>{if(!b.isAestheticKey(t))return null;const n=Yi(r),a=tg(e.mapping,t,n);return a===e.mapping?null:{mapping:a,scales:ng(e,t,a,n),layers:eg(e.layers,a)}},eg=(e,t)=>m.mapItems(e,r=>{const n={...t,...r.mapping};if(n.label===void 0&&yi(r.geom)===null)return r;const a=m.resolveLabelSource(M,r.geom,r.position,n);return(0,we.default)(a,r.dataLabels.labelSource)?r:{...r,dataLabels:{...r.dataLabels,labelSource:a}}}),tg=(e,t,r)=>r===null?rg(e,t):Ki(e,t)===r?e:{...e,[t]:r},rg=(e,t)=>{if(t==="x")return l.readMainAxisVariable(e)===""?e:{...e,x:""};const r=e[t];if(r===void 0||l.readVariableName(r)==="")return e;const n={};for(const[a,i]of Object.entries(e))a!==t&&(n[a]=i);return n},ng=(e,t,r,n)=>{if(!l.isScaledAestheticKey(t))return e.scales;let a=e.scales;for(const i of ag(e,t))a=og(e,a,i,r,n);return a},ag=(e,t)=>t==="y"&&ig(e.layers)?["y","ySecondary"]:[t],ig=e=>{const t=e.find(r=>r.yScaleType==="secondary");return t!==void 0&&t.mapping.y===void 0},og=(e,t,r,n,a)=>{const i=t.find(s=>s.scaledAesthetic===r);if(i===void 0)return a===null?t:[...t,vt(e,r,n)];if(a===null&&!l.isPositionScale(r)||a!==null&&!Ke(e).hasVariable(a))return t;const o=vt(e,r,n);return sg(i,o)?t:m.mapItems(t,s=>s.scaledAesthetic===r?o:s)},sg=(e,t)=>e.scaleType===t.scaleType||Tn(e)&&Tn(t),Tn=e=>e.scaleType==="discrete"||e.scaleType==="palette",or=e=>e==="both"?["x","y"]:[e],Ui=e=>e==="both"?"the":`${e} axis`;function sr(e,t){return pe(e)?e[t]:e}function lg(e,t){return e.config.axes[t]??{}}function cg(e,t,r){if(t!=="ySecondary")return m.updateSpec(e,{config:{axes:{[t]:r}}});const n=e.config.axes.ySecondary,a=Wi(n,r);if(a===n)return e;const i={...e.config.axes,ySecondary:a};return a===void 0&&delete i.ySecondary,m.patchSpec(e,{config:m.patchSpec(e.config,{axes:i})})}function pe(e){return l.isPlainObject(e)&&"x"in e&&"y"in e}function Wi(e,t){const r={};let n=!1;for(const a of new Set([...Object.keys(e??{}),...Object.keys(t)])){const i=e?.[a],o=a in t?ug(i,t[a]):i;o!==i&&(n=!0),o!==void 0&&(r[a]=o)}return n?Object.keys(r).length>0?r:void 0:e}function ug(e,t){return l.isPlainObject(t)?Wi(l.isPlainObject(e)?e:void 0,t):t}var Xi=class qi{constructor(t,r={}){this.type="set-axis-label",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis label to ${mg(t.label)}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,label:n}=this.params,a=lg(t,r).label;if(a===n)return null;const i=cg(t,r,{label:n});return i===t?null:{spec:i,revert:new qi(r==="ySecondary"?{axis:r,label:a}:{axis:r,label:a??null},this.metadata)}}},dg={type:"set-axis-label",deserialize:(e,t)=>new Xi(e,t)};function mg(e){return e===void 0?"(inherited)":e??"(none)"}var ji=class Zi{constructor(t,r={}){this.type="set-axis-position",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis position to ${t.position}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,position:n}=this.params,a=t.config.axes[r].position;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{position:n}}}}),revert:new Zi({axis:r,position:a},this.metadata)}}},hg={type:"set-axis-position",deserialize:(e,t)=>new ji(e,t)},Ji=class Qi{constructor(t,r={}){this.type="set-axis-tick-mode",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis tick mode to ${t.tickMode}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,tickMode:n}=this.params,a=t.config.axes[r].ticks.mode;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{ticks:{mode:n}}}}}),revert:new Qi({axis:r,tickMode:a},this.metadata)}}},pg={type:"set-axis-tick-mode",deserialize:(e,t)=>new Ji(e,t)},eo=class to{constructor(t,r={}){this.type="set-axis-ticks-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis ticks visibility to ${t.isVisible}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,isVisible:n}=this.params,a=t.config.axes[r].ticks.isVisible;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{ticks:{isVisible:n}}}}}),revert:new to({axis:r,isVisible:a},this.metadata)}}},fg={type:"set-axis-ticks-visibility",deserialize:(e,t)=>new eo(e,t)},ro=class no{constructor(t,r={}){this.type="set-axis-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis visibility to ${t.isVisible}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,isVisible:n}=this.params,a=t.config.axes[r].isVisible;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{isVisible:n}}}}),revert:new no({axis:r,isVisible:a},this.metadata)}}},gg={type:"set-axis-visibility",deserialize:(e,t)=>new ro(e,t)},ao=class io{constructor(t,r={}){this.type="set-content-caption",this.target={kind:"content",part:"caption"},this.params=t,this.metadata=y({...r,description:"Set chart caption"})}apply(t){const r=t.config.content.caption;return r===this.params.caption?null:{spec:m.updateSpec(t,{config:{content:{caption:this.params.caption}}}),revert:new io({caption:r},this.metadata)}}},vg={type:"set-content-caption",deserialize:(e,t)=>new ao(e,t)},oo=class so{constructor(t,r={}){this.type="set-content-source",this.target={kind:"content",part:"source"},this.params=t,this.metadata=y({...r,description:`Set content source to ${t.source?.label??t.source?.url??"(none)"}`})}apply(t){const r=t.config.content.source;if(Q(r,this.params.source))return null;const n=m.patchSpec(t.config.content,{source:this.params.source});return{spec:m.patchSpec(t,{config:m.patchSpec(t.config,{content:n})}),revert:new so({source:r},this.metadata)}}},yg={type:"set-content-source",deserialize:(e,t)=>new oo(e,t)},lo=class co{constructor(t,r={}){this.type="set-content-subtitle",this.target={kind:"content",part:"subtitle"},this.params=t,this.metadata=y({...r,description:"Set chart subtitle"})}apply(t){const r=t.config.content.subtitle;return r===this.params.subtitle?null:{spec:m.updateSpec(t,{config:{content:{subtitle:this.params.subtitle}}}),revert:new co({subtitle:r},this.metadata)}}},Sg={type:"set-content-subtitle",deserialize:(e,t)=>new lo(e,t)},uo=class mo{constructor(t,r={}){this.type="set-content-title",this.target={kind:"content",part:"title"},this.params=t,this.metadata=y({...r,description:"Set chart title"})}apply(t){const r=t.config.content.title;return r===this.params.title?null:{spec:m.updateSpec(t,{config:{content:{title:this.params.title}}}),revert:new mo({title:r},this.metadata)}}},bg={type:"set-content-title",deserialize:(e,t)=>new uo(e,t)},ho=(e,t,r,n)=>{const a=xg(t,r),i=Ig(e,a,n);let o=e,s=!1;for(const c of a){const u=Lg(o,c,n,Tg(c,n,Ag(r,c)));u!==null&&(o=u,s=!0)}return s?{spec:o,previous:i}:null},xg=(e,t)=>e==="both"&&!pe(t)?[void 0]:or(e),Ag=(e,t)=>t===void 0?pe(e)?e.x:e:sr(e,t),Ig=(e,t,r)=>t.length===1?it(e,t[0],r):{x:it(e,"x",r),y:it(e,"y",r)},it=(e,t,r)=>fo(e.styles.overrides,t)?.[r]??null,Tg=(e,t,r)=>r===null||t==="strokeWidth"?r:(e===void 0?["x","y"]:[e]).every(n=>po(l.STYLE_TARGETS.gridLine.children[n].rest[t],r))?null:r,po=(e,t)=>Array.isArray(e)&&Array.isArray(t)?_t(e,t):e===t,Lg=(e,t,r,n)=>{const a=fo(e.styles.overrides,t);return po(a?.[r]??null,n)?null:new H({list:"overrides",rule:Cg(t,Rg(a,r,n))}).apply(e)?.spec??null},Eg=e=>e.select.target==="gridLine",fo=(e,t)=>{const r=ue(e,{select:t===void 0?{target:"gridLine"}:{target:"gridLine",axis:t}});if(!(r===void 0||!Eg(r)))return r.declarations},Rg=(e,t,r)=>{const{[t]:n,...a}=e??{};return r!==null?{...a,[t]:r}:Object.keys(a).length===0?null:a},Ln=(e,t)=>e===void 0?b.style.gridLine(t):e==="x"?b.style.gridLine.x(t):b.style.gridLine.y(t),Cg=(e,t)=>t===null?{...Ln(e,{}),declarations:null}:Ln(e,t),go=class vo{constructor(t,r={}){this.type="set-grid-line-style",this.params=t,this.metadata=y({...r,description:`Set ${Ui(t.axis)} grid line style to ${Pg(t)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineStyle:n}=this.params,a=ho(t,r,En(n,Mg),"dashArray");return a===null?null:{spec:a.spec,revert:new vo({axis:r,lineStyle:En(a.previous,Dg)},this.metadata)}}},wg={type:"set-grid-line-style",deserialize:(e,t)=>new go(e,t)},Pg=({axis:e,lineStyle:t})=>{const r=or(e).map(n=>sr(t,n)??"(theme)");return[...new Set(r)].join(" and ")},Mg=e=>e===null?null:l.DASH_PRESETS.gridLine[e],Dg=e=>e===null?null:Ot(e),En=(e,t)=>pe(e)?{x:t(e.x),y:t(e.y)}:t(e),Og={type:"set-grid-line-width",deserialize:(e,t)=>new yo(e,t)},yo=class So{constructor(t,r={}){this.type="set-grid-line-width";const n=_g(t.lineWidth);this.params={...t,lineWidth:n},this.metadata=y({...r,description:`Set ${Ui(t.axis)} grid line width to ${kg(t.axis,n)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineWidth:n}=this.params,a=ho(t,r,n,"strokeWidth");return a===null?null:{spec:a.spec,revert:new So({axis:r,lineWidth:a.previous},this.metadata)}}},_g=e=>pe(e)?{x:ot(e.x),y:ot(e.y)}:ot(e),ot=e=>e===null||!Number.isFinite(e)?null:Math.max(0,e),kg=(e,t)=>{const r=or(e).map(n=>sr(t,n)??"(theme)");return[...new Set(r)].join(" and ")},bo=class xo{constructor(t,r={}){this.type="set-grid-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis grid visibility to ${t.isVisible??"(auto)"}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,isVisible:n}=this.params,a=t.config.axes[r].grid.isVisible;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{grid:{isVisible:n}}}}}),revert:new xo({axis:r,isVisible:a},this.metadata)}}},Vg={type:"set-grid-visibility",deserialize:(e,t)=>new bo(e,t)},Ao=class Io{constructor(t,r={}){this.type="set-headline-compare-with",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline compare with to ${t.compareWith}`})}apply(t){const r=t.config.headline.compareWith;return r===this.params.compareWith?null:{spec:m.updateSpec(t,{config:{headline:{compareWith:this.params.compareWith}}}),revert:new Io({compareWith:r},this.metadata)}}},Ng={type:"set-headline-compare-with",deserialize:(e,t)=>new Ao(e,t)},To=class Lo{constructor(t,r={}){this.type="set-headline-position",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline position to ${t.position}`})}apply(t){const r=t.config.headline.position;return r===this.params.position?null:{spec:m.updateSpec(t,{config:{headline:{position:this.params.position}}}),revert:new Lo({position:r},this.metadata)}}},Fg={type:"set-headline-position",deserialize:(e,t)=>new To(e,t)},Eo=class Ro{constructor(t,r={}){this.type="set-headline-show",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline show to ${t.show}`})}apply(t){const r=t.config.headline.show;return r===this.params.show?null:{spec:m.updateSpec(t,{config:{headline:{show:this.params.show}}}),revert:new Ro({show:r},this.metadata)}}},Bg={type:"set-headline-show",deserialize:(e,t)=>new Eo(e,t)},Co=class wo{constructor(t,r={}){this.type="set-headline-size",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline size to ${t.size}`})}apply(t){const r=t.config.headline.size;return r===this.params.size?null:{spec:m.updateSpec(t,{config:{headline:{size:this.params.size}}}),revert:new wo({size:r},this.metadata)}}},Gg={type:"set-headline-size",deserialize:(e,t)=>new Co(e,t)},Hg={type:"set-highlight-dim-style",deserialize:(e,t)=>new Po(e,t)},Po=class{constructor(e,t={}){this.type="set-highlight-dim-style",this.params=e,this.metadata=y({...t,description:`Set highlight style to ${e.dimStyle}`})}get target(){return{kind:"appearance"}}apply(e){if(Mo(e)===this.params.dimStyle)return null;const t=new H({list:"overrides",rule:zg(this.params.dimStyle)},this.metadata).apply(e);return t||null}},$g={select:{target:"geom"},when:{state:"dimmed"}},Mo=e=>{const t=ue(e.styles.overrides,$g);return(t!==void 0&&Qt(t)?t.declarations:void 0)?.saturation===0?"desaturate":"dim"},zg=e=>e==="desaturate"?b.style.geom({saturation:0,alpha:.6},{state:"dimmed"}):b.style.geom({alpha:l.DEFAULT_DIMMED_ALPHA},{state:"dimmed"}),Do=class Oo{constructor(t,r={}){this.type="set-legend-align",this.target={kind:"legend"},this.params=t,this.metadata=y({...r,description:`Set legend align to ${t.align}`})}apply(t){const r=t.config.legend.align;return r===this.params.align?null:{spec:m.updateSpec(t,{config:{legend:{align:this.params.align}}}),revert:new Oo({align:r},this.metadata)}}},Kg={type:"set-legend-align",deserialize:(e,t)=>new Do(e,t)},_o=class ko{constructor(t,r={}){this.type="set-legend-display",this.target={kind:"legend"},this.params=t,this.metadata=y({...r,description:`Set legend display to ${t.display}`})}apply(t){const r=t.config.legend.display;return r===this.params.display?null:{spec:m.updateSpec(t,{config:{legend:{display:this.params.display}}}),revert:new ko({display:r},this.metadata)}}},Yg={type:"set-legend-display",deserialize:(e,t)=>new _o(e,t)},Vo=class No{constructor(t,r={}){this.type="set-legend-position",this.target={kind:"legend"},this.params=t,this.metadata=y({...r,description:`Set legend position to ${t.position}`})}apply(t){const r=t.config.legend.position;return r===this.params.position?null:{spec:m.updateSpec(t,{config:{legend:{position:this.params.position}}}),revert:new No({position:r},this.metadata)}}},Ug={type:"set-legend-position",deserialize:(e,t)=>new Vo(e,t)},Fo=class Bo{constructor(t,r={}){this.type="set-number-format-abbreviation",this.target={kind:"numberFormat"},this.params=t,this.metadata=y({...r,description:`Set number format abbreviation to ${t.abbreviation}`})}apply(t){const r=t.config.numberFormat.abbreviation;return r===this.params.abbreviation?null:{spec:m.updateSpec(t,{config:{numberFormat:{abbreviation:this.params.abbreviation}}}),revert:new Bo({abbreviation:r},this.metadata)}}},Wg={type:"set-number-format-abbreviation",deserialize:(e,t)=>new Fo(e,t)},Go=class Ho{constructor(t,r={}){this.type="set-number-format-decimals",this.target={kind:"numberFormat"},this.params=t,this.metadata=y({...r,description:`Set number format decimals to ${t.decimals}`})}apply(t){const r=t.config.numberFormat.decimals;return r===this.params.decimals?null:{spec:m.updateSpec(t,{config:{numberFormat:{decimals:this.params.decimals}}}),revert:new Ho({decimals:r},this.metadata)}}},Xg={type:"set-number-format-decimals",deserialize:(e,t)=>new Go(e,t)},$o=class zo{constructor(t,r={}){this.type="toggle-content-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.part} visibility to ${t.isVisible}`})}get target(){return{kind:"content",part:this.params.part}}apply(t){const{part:r,isVisible:n}=this.params,a=jg(r);if(!a)return null;const i=t.config.content[a];return i===n?null:{spec:m.updateSpec(t,{config:{content:{[a]:n}}}),revert:new zo({part:r,isVisible:i},this.metadata)}}},qg={type:"toggle-content-visibility",deserialize:(e,t)=>new $o(e,t)},Rn={title:"isTitleVisible",subtitle:"isSubtitleVisible",caption:"isCaptionVisible",source:"isSourceVisible"};function jg(e){return Object.hasOwn(Rn,e)?Rn[e]:void 0}var Ko=class Yo{constructor(t,r={}){this.type="set-coord-limits",this.target={kind:"coords"},this.params=t,this.metadata=y({...r,description:"Set coordinate limits"})}apply(t){const{xLimits:r,yLimits:n}=this.params,a=t.coords.params,i={xLimits:r!==void 0?r:a.xLimits,yLimits:n!==void 0?n:a.yLimits};if(Q(i.xLimits,a.xLimits)&&Q(i.yLimits,a.yLimits))return null;const o={};r!==void 0&&(o.xLimits=a.xLimits),n!==void 0&&(o.yLimits=a.yLimits);const s=new Yo(o,this.metadata);return{spec:m.patchSpec(t,{coords:Jg(t.coords,i)}),revert:s}}},Zg={type:"set-coord-limits",deserialize:(e,t)=>new Ko(e,t)};function Jg(e,t){switch(e.coordType){case"cartesian":return{...e,params:{...e.params,...t}};case"flip":return{...e,params:{...e.params,...t}};case"polar":return{...e,params:{...e.params,...t}}}}var Uo=class Wo{constructor(t,r={}){this.type="set-polar-inner-radius",this.target={kind:"coords"},this.params={innerRadius:(0,ne.default)(t.innerRadius,0,1)},this.metadata=y({...r,description:`Set polar inner radius to ${this.params.innerRadius}`})}apply(t){const r=t.coords;if(r.coordType!=="polar")return null;const n=r.params.innerRadius;return n===this.params.innerRadius?null:{spec:m.patchSpec(t,{coords:{...r,params:{...r.params,innerRadius:this.params.innerRadius}}}),revert:new Wo({innerRadius:n},this.metadata)}}},Qg={type:"set-polar-inner-radius",deserialize:(e,t)=>new Uo(e,t)},ev={type:"set-polar-start-angle",deserialize:(e,t)=>new Xo(e,t)},Xo=class qo{constructor(t,r={}){this.type="set-polar-start-angle",this.target={kind:"coords"},this.params={startAngle:Cn(t.startAngle)},this.metadata=y({...r,description:`Set polar start angle to ${this.params.startAngle}`})}apply(t){const r=t.coords;if(r.coordType!=="polar")return null;const n=r.params.startAngle;return Cn(n)===this.params.startAngle?null:{spec:m.patchSpec(t,{coords:{...r,params:{...r.params,startAngle:this.params.startAngle}}}),revert:new qo({startAngle:n},this.metadata)}}},st=360,Cn=e=>(e%st+st)%st,lr=class{constructor(e,t={}){this.type="remove-highlight",this.params=e,this.metadata=y({...t,description:"Remove highlight"})}get target(){return{kind:"highlight",id:this.params.id}}apply(e){const t=e.highlights.find(i=>i.id===this.params.id);if(!t)return null;const r=e.highlights.indexOf(t),n=e.highlights.filter(i=>i!==t),a=new cr({predicate:t.predicate,id:t.id,scope:t.scope,layerId:t.layerId,index:r},this.metadata);return{spec:m.patchSpec(e,{highlights:n}),revert:a}}},tv={type:"remove-highlight",deserialize:(e,t)=>new lr(e,t)},cr=class{constructor(e,t={}){this.type="add-highlight",this.params={...e,id:e.id??m.uniqueId(),scope:e.scope??"data-point"},this.metadata=y({...t,description:"Add highlight"})}get target(){return{kind:"highlight",id:this.params.id}}apply(e){const{predicate:t,id:r,scope:n,layerId:a,index:i}=this.params;if(e.highlights.some(d=>d.id===r))return null;const o=new lr({id:r},this.metadata),s={type:"highlight",id:r,predicate:t,scope:n,...a!==void 0&&{layerId:a}},c=i??e.highlights.length,u=Math.min(Math.max(c,0),e.highlights.length);return{spec:m.patchSpec(e,{highlights:[...e.highlights.slice(0,u),s,...e.highlights.slice(u)]}),revert:o}}},rv={type:"add-highlight",deserialize:(e,t)=>new cr(e,t)};function ur(e,t){return{...e,params:{...e.params,...t}}}function qe(e,t){return{...e,dataLabels:{...e.dataLabels,...t}}}function dr(e,t){return m.patchSpec(e,{layers:[...e.layers,t]})}function D(e,t,r){const n=e.layers.findIndex(a=>a.id===t);return n===-1?e:m.patchSpec(e,{layers:m.replaceAtIndex(e.layers,n,r)})}function je(e,t){const r=e.layers.findIndex(n=>n.id===t);return r===-1||e.layers.length<=1?e:m.patchSpec(e,{layers:e.layers.filter((n,a)=>a!==r)})}var mr=class{constructor(e,t={}){this.type="remove-layer",this.params=e,this.metadata=y({...t,description:"Remove layer"})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(e){const t=e.layers.findIndex(a=>a.id===this.params.layerId),r=e.layers[t];if(r===void 0)return null;const n=je(e,this.params.layerId);return n===e?null:{spec:n,revert:new hr({layer:r,index:t},this.metadata)}}},nv={type:"remove-layer",deserialize:(e,t)=>new mr(e,t)},hr=class{constructor(e,t={}){this.type="add-layer",this.params={layer:{...e.layer,id:e.layer.id??m.uniqueId()},...e.index!==void 0&&{index:e.index}},this.metadata=y({...t,description:`Add ${this.params.layer.geom} layer`})}get target(){return{kind:"layer",layerId:this.params.layer.id}}apply(e){const{layer:t,index:r}=this.params;if(e.layers.some(i=>i.id===t.id))return null;const n=r??e.layers.length,a=Math.min(Math.max(n,0),e.layers.length);return{spec:m.patchSpec(e,{layers:[...e.layers.slice(0,a),t,...e.layers.slice(a)]}),revert:new mr({layerId:t.id},this.metadata)}}},av={type:"add-layer",deserialize:(e,t)=>new hr(e,t)},jo=class Zo{constructor(t,r={}){this.type="set-bar-corner-radius",this.params=t,this.metadata=y({...r,description:`Set bar border radius to ${t.cornerRadius??"(themed)"}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,cornerRadius:n}=this.params;if(!m.isLayerSpecOf(m.findLayerById(t.layers,r),"bar"))return null;const a=U("bar",r),i=de(t.styles.overrides,a),o=i?.cornerRadius??null;if(o===n)return null;const s=new H({list:"overrides",rule:{...a,declarations:ov(i,n)}}).apply(t);if(!s)return null;const c=new Zo({layerId:r,cornerRadius:o},this.metadata);return{spec:s.spec,revert:c}}},iv={type:"set-bar-corner-radius",deserialize:(e,t)=>new jo(e,t)},ov=(e,t)=>{const{cornerRadius:r,...n}=e??{};return t!==null?{...n,cornerRadius:t}:Object.keys(n).length===0?null:n},sv={type:"set-bar-width",deserialize:(e,t)=>new Qo(e,t)},Jo=.05,lv=1,Qo=class es{constructor(t,r={}){this.type="set-bar-width";const n=t.width===void 0?void 0:(0,ne.default)(t.width,Jo,1);this.params={...t,width:n},this.metadata=y({...r,description:n===void 0?"Reset bar width":`Set bar width to ${n}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){if(this.params.width!==void 0&&!Number.isFinite(this.params.width))return null;const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"bar");if(!m.isLayerSpecOf(r,"bar"))return null;const n=r.params.width;return n===this.params.width?null:{spec:D(t,r.id,ur(r,{width:this.params.width})),revert:new es({layerId:r.id,width:n},this.metadata)}}},ts=class rs{constructor(t,r={}){this.type="set-data-labels-format",this.params=t,this.metadata=y({...r,description:`Set data labels format to ${t.format}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.format;return n===this.params.format?null:{spec:D(t,r.id,qe(r,{format:this.params.format})),revert:new rs({layerId:r.id,format:n},this.metadata)}}},cv={type:"set-data-labels-format",deserialize:(e,t)=>new ts(e,t)},ns=class as{constructor(t,r={}){this.type="set-layer-position",this.params=t,this.metadata=y({...r,description:`Set layer position to ${t.position}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"bar","area");if(!r)return null;const n=r.position;return n===this.params.position?null:{spec:D(t,r.id,{...r,position:this.params.position}),revert:new as({layerId:r.id,position:n},this.metadata)}}},uv={type:"set-layer-position",deserialize:(e,t)=>new ns(e,t)},is=class os{constructor(t,r={}){this.type="set-layer-stat";const n=m.resolveStatSpec(t.stat,"identity");this.params={...t.layerId!==void 0&&{layerId:t.layerId},stat:n},this.metadata=y({...r,description:`Set layer stat to ${n.type}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.stat;return mv(n,this.params.stat)?null:{spec:D(t,r.id,{...r,stat:this.params.stat}),revert:new os({layerId:r.id,stat:n},this.metadata)}}},dv={type:"set-layer-stat",deserialize:(e,t)=>new is(e,t)},mv=(e,t)=>{if(e.type!==t.type)return!1;const r=e,n=t,a=new Set([...Object.keys(r),...Object.keys(n)]);for(const i of a)if(!Object.is(r[i],n[i]))return!1;return!0},ss=class ls{constructor(t,r={}){this.type="set-layer-y-scale-type",this.params=t,this.metadata=y({...r,description:`Set layer to ${t.yScaleType} y axis`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.yScaleType;if(n===this.params.yScaleType)return null;const a=D(t,r.id,{...r,yScaleType:this.params.yScaleType});return{spec:m.patchSpec(a,{scales:this.params.previousScales===void 0?ar(a.scales,a.layers):this.params.previousScales}),revert:new ls({layerId:r.id,yScaleType:n,previousScales:t.scales},this.metadata)}}},hv={type:"set-layer-y-scale-type",deserialize:(e,t)=>new ss(e,t)},cs=class us{constructor(t,r={}){this.type="set-line-curve",this.params=t,this.metadata=y({...r,description:`Set line curve to ${t.curve}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"line","area");if(!m.isLayerSpecOf(r,"line","area"))return null;const n=r.params.curve;return n===this.params.curve?null:{spec:D(t,r.id,ur(r,{curve:this.params.curve})),revert:new us({layerId:r.id,curve:n},this.metadata)}}},pv={type:"set-line-curve",deserialize:(e,t)=>new cs(e,t)},ds=class ms{constructor(t,r={}){this.type="set-line-missing-values",this.params=t,this.metadata=y({...r,description:`Set missing values handling to ${t.missingValues}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"line","area");if(!m.isLayerSpecOf(r,"line","area"))return null;const n=r.params.missingValues;return n===this.params.missingValues?null:{spec:D(t,r.id,ur(r,{missingValues:this.params.missingValues})),revert:new ms({layerId:r.id,missingValues:n},this.metadata)}}},fv={type:"set-line-missing-values",deserialize:(e,t)=>new ds(e,t)},hs=class ps{constructor(t,r={}){this.type="set-line-width",this.params=t,this.metadata=y({...r,description:`Set line width to ${t.lineWidth??"(themed)"}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,lineWidth:n}=this.params,a=m.findLayerById(t.layers,r);if(!m.isLayerSpecOf(a,"line","area"))return null;const i=de(t.styles.overrides,U(a.geom,r)),o=i?.strokeWidth??null;if(o===n)return null;const s=vv(i,n),c=new H({list:"overrides",rule:a.geom==="area"?{...U("area",r),declarations:s}:{...U("line",r),declarations:s}}).apply(t);return c?{spec:c.spec,revert:new ps({layerId:r,lineWidth:o},this.metadata)}:null}},gv={type:"set-line-width",deserialize:(e,t)=>new hs(e,t)},vv=(e,t)=>{const{strokeWidth:r,...n}=e??{};return t!==null?{...n,strokeWidth:t}:Object.keys(n).length===0?null:n},fs=class gs{constructor(t,r={}){this.type="set-point-size",this.params=t,this.metadata=y({...r,description:`Set point size to ${t.size??"(themed)"}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,size:n}=this.params;if(!m.isLayerSpecOf(m.findLayerById(t.layers,r),"point"))return null;const a=U("point",r),i=de(t.styles.overrides,a),o=i?.size??null;if(o===n)return null;const s=new H({list:"overrides",rule:{...a,declarations:Sv(i,n)}}).apply(t);return s?{spec:s.spec,revert:new gs({layerId:r,size:o},this.metadata)}:null}},yv={type:"set-point-size",deserialize:(e,t)=>new fs(e,t)},Sv=(e,t)=>{const{size:r,...n}=e??{};return t!==null?{...n,size:t}:Object.keys(n).length===0?null:n},vs=class ys{constructor(t,r={}){this.type="set-rule-label",this.params=t,this.metadata=y({...r,description:"Set reference line label"})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"rule");if(!m.isLayerSpecOf(r,"rule"))return null;const n=r.params.label,a=this.params.label??void 0;if(n===a)return null;const i=a===void 0?Object.fromEntries(Object.entries(r.params).filter(([o])=>o!=="label")):{...r.params,label:a};return{spec:D(t,r.id,{...r,params:i}),revert:new ys({layerId:r.id,label:n??null},this.metadata)}}},bv={type:"set-rule-label",deserialize:(e,t)=>new vs(e,t)},Ss=class bs{constructor(t,r={}){this.type="set-rule-value",this.params=t,this.metadata=y({...r,description:`Set reference line to ${t.value}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"rule");if(!m.isLayerSpecOf(r,"rule"))return null;const n=typeof l.readConstantValue(r.mapping.y)=="number"?"y":"x",a=l.readConstantValue(r.mapping[n]);if(typeof a!="number"||a===this.params.value)return null;const i={...r.mapping,[n]:{value:this.params.value}};return{spec:D(t,r.id,{...r,mapping:i}),revert:new bs({layerId:r.id,value:a},this.metadata)}}},xv={type:"set-rule-value",deserialize:(e,t)=>new Ss(e,t)},Av={type:"set-stat-line",deserialize:(e,t)=>new xs(e,t)},xs=class As{constructor(t,r={}){this.type="set-stat-line",this.params=t,this.metadata=y({...r,description:wv(t.line)})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=Tv(t),n=this.buildStatLine(t,r?.line===this.params.line?r.layer.id:void 0);if(this.params.line!=="none"&&n===null||r===void 0&&n===null||r!==void 0&&n!==null&&Cv(r.layer,n))return null;const a=new As({line:r?.line??"none",...r!==void 0&&{removedLayer:r.layer},...r===void 0&&n!==null&&{layerId:n.id}},this.metadata);if(r!==void 0&&n!==null&&r.line===this.params.line)return{spec:D(t,r.layer.id,n),revert:a};const i=r===void 0?t:je(t,r.layer.id);return n===null&&i===t?null:{spec:n===null?i:dr(i,n),revert:a}}buildStatLine(t,r){if(this.params.line==="none")return null;if(this.params.removedLayer!==void 0)return this.params.removedLayer;const n=this.params.line==="trend"?Lv(this.params):Ev(t,this.params);if(n===null)return null;const a=m.resolveLayer(M,t.mapping,t.coords.coordType,n);return r===void 0?a:{...a,id:r}}},Iv="linear",Tv=e=>{const t=oi(e.layers);if(t!==void 0)return{line:"trend",layer:t};const r=si(e.layers);if(r!==void 0)return{line:"average",layer:r}},Lv=({method:e})=>l.geom.line({aes:{lineType:{value:"dashed"}},stat:b.stat.smooth({method:e??Iv}),interactive:!1}),Ev=(e,{group:t,label:r})=>{const n=Rv(e),a=l.readVariableName(n?.mapping.y??e.mapping.y);if(a===null)return null;const i=l.readVariableName(n?.mapping.color??e.mapping.color),o=i!==null&&t!==void 0;return l.geom.rule({aes:{y:a,color:void 0,group:void 0,lineType:void 0},stat:b.stat.mean(),transforms:o?[b.transform.filter({variableName:i,operator:"eq",value:t})]:[],params:{labelPosition:e.coords.coordType==="flip"?"end":"start",...r!==void 0&&{label:r}},yScaleType:n?.yScaleType,interactive:!1})},Rv=e=>e.layers.find(t=>t.geom!=="rule"&&t.stat.type!=="smooth"),Cv=(e,t)=>(0,Xs.isEqual)({...e,id:""},{...t,id:""}),wv=e=>e==="none"?"Hide stat line":`Show ${e} line`,Is=class Ts{constructor(t,r={}){this.type="toggle-category-labels",this.params=t,this.metadata=y({...r,description:`${t.showCategoryLabels?"Show":"Hide"} category labels`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.showCategoryLabels;return n===this.params.showCategoryLabels?null:{spec:D(t,r.id,qe(r,{showCategoryLabels:this.params.showCategoryLabels})),revert:new Ts({layerId:r.id,showCategoryLabels:n},this.metadata)}}},Pv={type:"toggle-category-labels",deserialize:(e,t)=>new Is(e,t)},Ls=class Es{constructor(t,r={}){this.type="toggle-data-labels",this.params=t,this.metadata=y({...r,description:`${t.showDataLabels?"Show":"Hide"} data labels`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.showDataLabels;return n===this.params.showDataLabels?null:{spec:D(t,r.id,qe(r,{showDataLabels:this.params.showDataLabels})),revert:new Es({layerId:r.id,showDataLabels:n},this.metadata)}}},Mv={type:"toggle-data-labels",deserialize:(e,t)=>new Ls(e,t)},Dv={type:"toggle-goal-line",deserialize:(e,t)=>new Rs(e,t)},Rs=class yt{constructor(t,r={}){this.type="toggle-goal-line",this.params=t,this.metadata=y({...r,description:`${t.showGoalLine?"Show":"Hide"} goal line`})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=ii(t.layers);if(!this.params.showGoalLine){if(r===void 0)return null;const a=je(t,r.id);return a===t?null:{spec:a,revert:new yt({showGoalLine:!0,removedLayer:r},this.metadata)}}if(r!==void 0)return null;const n=this.params.removedLayer??this.buildGoalLine(t);return{spec:dr(t,n),revert:new yt({showGoalLine:!1,layerId:n.id},this.metadata)}}buildGoalLine(t){const r=t.coords.coordType==="flip"?"end":"start";return m.resolveLayer(M,t.mapping,t.coords.coordType,l.geom.rule({aes:{y:{value:this.params.value??Ov}},params:{labelPosition:r,...this.params.label!==void 0&&{label:this.params.label}},interactive:!1}))}},Ov=0,_v={type:"toggle-line-fill",deserialize:(e,t)=>new Cs(e,t)},Cs=class ws{constructor(t,r={}){this.type="toggle-line-fill",this.params=t,this.metadata=y({...r,description:`Set line fill to ${t.showFill}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,showFill:n,fillAlpha:a}=this.params;if(!m.isLayerSpecOf(m.findLayerById(t.layers,r),"line"))return null;const i=U("line",r),o=de(t.styles.overrides,i),s=o?.fillAlpha,c=s!==void 0;if(c===n)return null;const u=new H({list:"overrides",rule:{...i,declarations:Vv(o,n?a??kv:null)}}).apply(t);if(!u)return null;const d=new ws({layerId:r,showFill:c,...s===void 0?{}:{fillAlpha:s}},this.metadata);return{spec:u.spec,revert:d}}},kv=.2,Vv=(e,t)=>{const{fillAlpha:r,...n}=e??{};return t!==null?{...n,fillAlpha:t}:Object.keys(n).length===0?null:n},Nv={type:"toggle-line-points",deserialize:(e,t)=>new Ps(e,t)},Ps=class St{constructor(t,r={}){this.type="toggle-line-points",this.params=t,this.metadata=y({...r,description:`${t.showPoints?"Show":"Hide"} points`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"line","area");return m.isLayerSpecOf(r,"line","area")?this.params.showPoints?this.addPointLayer(t,r):this.removePointLayer(t,r):null}addPointLayer(t,r){return this.findAssociatedPointLayer(t,r)?null:{spec:dr(t,this.params.removedLayer??m.resolveLayer(M,t.mapping,t.coords.coordType,l.geom.point({aes:{...r.mapping},position:r.position,yScaleType:r.yScaleType,transforms:[...r.transforms],interactive:!1}))),revert:new St({layerId:r.id,showPoints:!1},this.metadata)}}removePointLayer(t,r){const n=this.findAssociatedPointLayer(t,r);return n?{spec:je(t,n.id),revert:new St({layerId:r.id,showPoints:!0,removedLayer:n},this.metadata)}:null}findAssociatedPointLayer(t,r){return t.layers.find(n=>n.geom!=="point"?!1:m.isCompanionLayer(n,[r]))}},Ms=class Ds{constructor(t,r={}){this.type="toggle-stack-totals",this.params=t,this.metadata=y({...r,description:`${t.showStackTotals?"Show":"Hide"} stack totals`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.showStackTotals;return n===this.params.showStackTotals?null:{spec:D(t,r.id,qe(r,{showStackTotals:this.params.showStackTotals})),revert:new Ds({layerId:r.id,showStackTotals:n},this.metadata)}}},Fv={type:"toggle-stack-totals",deserialize:(e,t)=>new Ms(e,t)},Os=class _s{constructor(t,r={}){this.type="set-scale-domain",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} scale domain`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=Ye(t,this.params.scaledAesthetic);if(!r||r.scaleType!=="continuous"&&r.scaleType!=="datetime")return null;const n={min:r.domainMin??null,max:r.domainMax??null},a=this.params.domainMin===void 0?n.min:this.params.domainMin,i=this.params.domainMax===void 0?n.max:this.params.domainMax;if(a===n.min&&i===n.max)return null;const o={...r,...this.params.domainMin!==void 0&&{domainMin:this.params.domainMin},...this.params.domainMax!==void 0&&{domainMax:this.params.domainMax}},s=Ue(t,this.params.scaledAesthetic,o),c={scaledAesthetic:this.params.scaledAesthetic};return this.params.domainMin!==void 0&&(c.domainMin=n.min),this.params.domainMax!==void 0&&(c.domainMax=n.max),{spec:s,revert:new _s(c,this.metadata)}}},Bv={type:"set-scale-domain",deserialize:(e,t)=>new Os(e,t)},ks=class Vs{constructor(t,r={}){this.type="set-scale-palette",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} palette`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=Ye(t,this.params.scaledAesthetic);return r?.scaleType!=="palette"||Q(r.palette,this.params.palette)?null:{spec:Ue(t,this.params.scaledAesthetic,{...r,scaledAesthetic:this.params.scaledAesthetic,palette:this.params.palette}),revert:new Vs({scaledAesthetic:this.params.scaledAesthetic,palette:r.palette},this.metadata)}}},Gv={type:"set-scale-palette",deserialize:(e,t)=>new ks(e,t)},Ns=class Fs{constructor(t,r={}){this.type="set-scale-reverse",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} scale reverse to ${t.reverse}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=Ye(t,this.params.scaledAesthetic);if(!r||!$v(r))return null;const n=r.reverse;return n===this.params.reverse?null:{spec:Ue(t,this.params.scaledAesthetic,{...r,reverse:this.params.reverse}),revert:new Fs({scaledAesthetic:this.params.scaledAesthetic,reverse:n},this.metadata)}}},Hv={type:"set-scale-reverse",deserialize:(e,t)=>new Ns(e,t)};function $v(e){return e.scaleType==="continuous"||e.scaleType==="datetime"||e.scaleType==="discrete"}var Bs=class Gs{constructor(t,r={}){this.type="set-scale-transform",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} scale transform to ${t.transform}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=Ye(t,this.params.scaledAesthetic);if(!r||r.scaleType!=="continuous")return null;const n=r.transform;return n===this.params.transform?null:{spec:Ue(t,this.params.scaledAesthetic,{...r,transform:this.params.transform}),revert:new Gs({scaledAesthetic:this.params.scaledAesthetic,transform:n},this.metadata)}}},zv={type:"set-scale-transform",deserialize:(e,t)=>new Bs(e,t)},Hs=class{constructor(){this.descriptors=new Map}register(e){if(this.descriptors.has(e.type))throw new l.InternalError({message:`CommandRegistry: descriptor for type '${e.type}' is already registered`});this.descriptors.set(e.type,e)}serialize(e){return{type:e.type,params:e.params,metadata:e.metadata}}deserialize(e){return this.getDescriptor(e.type).deserialize(e.params,e.metadata)}getRegisteredTypes(){return[...this.descriptors.keys()]}getDescriptor(e){const t=this.descriptors.get(e);if(!t)throw new l.InternalError({message:`CommandRegistry: no descriptor registered for type '${e}'`});return t}},v=new Hs;v.register(lf);v.register(Zf);v.register(av);v.register(nv);v.register(cv);v.register(uv);v.register(dv);v.register(hv);v.register(pv);v.register(gv);v.register(iv);v.register(sv);v.register(yv);v.register(fv);v.register(bv);v.register(xv);v.register(Av);v.register(Pv);v.register(Mv);v.register(Dv);v.register(_v);v.register(Nv);v.register(Fv);v.register(Bv);v.register(Gv);v.register(Hv);v.register(zv);v.register(dg);v.register(pg);v.register(hg);v.register(fg);v.register(gg);v.register(vg);v.register(yg);v.register(Sg);v.register(bg);v.register(wg);v.register(Og);v.register(Vg);v.register(Ng);v.register(Fg);v.register(Bg);v.register(Gg);v.register(Hg);v.register(Kg);v.register(Yg);v.register(Ug);v.register(Wg);v.register(Xg);v.register(qg);v.register(rv);v.register(tv);v.register(af);v.register(Yp);v.register(Kp);v.register(tf);v.register(of);v.register(rf);v.register(Zg);v.register(Qg);v.register(ev);var $s=(e,t)=>e===t?!0:e===null||t===null?!1:bt(e)===bt(t),bt=e=>{switch(e.kind){case"annotation":case"highlight":return JSON.stringify([e.kind,e.id]);case"styleRule":return JSON.stringify([e.kind,e.list,se(e)]);case"content":return JSON.stringify([e.kind,e.part]);case"axis":case"grid":return JSON.stringify([e.kind,e.axis]);case"layer":return JSON.stringify([e.kind,e.layerId??null]);case"observations":return JSON.stringify([e.kind,e.layerId,e.scope,e.observationIndex??null,ke(e.predicate)]);case"mapping":case"scale":return JSON.stringify([e.kind,e.aesthetic]);case"legend":case"coords":case"graph":case"appearance":case"headline":case"numberFormat":return JSON.stringify([e.kind]);default:throw new l.InternalError({message:`Unhandled edit target kind: ${e.kind}`})}},zs=class{constructor(e={}){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.isEmitting=!1,this.cachedSnapshot=null,this.hasOpenRun=!1,this.maxHistorySize=e.maxHistorySize??100}apply(e,t,r,n={}){return this.withReentrancyGuard(()=>{const a=n.transient??!1,i=(u,d)=>r?d:u,o=e.apply(t);if(!o)return a||(this.hasOpenRun=!1),i(t,null);const s=r?.({spec:o.spec,command:e})??null,c=s?s.adopted:o.spec;return c?(this.push(e,c,o.revert,a),i(c,s?.value??null)):(a||(this.hasOpenRun=!1),i(t,s?.value??null))})}commit(){return this.withReentrancyGuard(()=>this.hasOpenRun?(this.hasOpenRun=!1,this.emit({type:"commit"}),!0):!1)}undo(e,t){return this.withReentrancyGuard(()=>{const r=this.undoStack[this.undoStack.length-1];if(!r)return null;const n=this.step(r,e,t);return n?n.adopted?(this.undoStack.pop(),this.redoStack.push({command:r.command,revert:n.revert}),this.hasOpenRun=!1,this.emit({type:"undo",command:r.command,spec:n.adopted}),t?n.value:{spec:n.adopted,command:r.command}):n.value:null})}redo(e,t){return this.withReentrancyGuard(()=>{const r=this.redoStack[this.redoStack.length-1];if(!r)return null;const n=this.step(r,e,t);return n?n.adopted?(this.redoStack.pop(),this.undoStack.push({command:r.command,revert:n.revert}),this.hasOpenRun=!1,this.emit({type:"redo",command:r.command,spec:n.adopted}),t?n.value:{spec:n.adopted,command:r.command}):n.value:null})}clear(){this.withReentrancyGuard(()=>{this.hasOpenRun=!1,!(this.undoStack.length===0&&this.redoStack.length===0)&&(this.undoStack=[],this.redoStack=[],this.emit({type:"clear"}))})}getSnapshot(){return this.cachedSnapshot||(this.cachedSnapshot={canUndo:this.undoStack.length>0,canRedo:this.redoStack.length>0,undoDescription:this.undoStack[this.undoStack.length-1]?.command.metadata.description??null,redoDescription:this.redoStack[this.redoStack.length-1]?.command.metadata.description??null,undoStack:wn(this.undoStack),redoStack:wn(this.redoStack)}),this.cachedSnapshot}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}step(e,t,r){const n=e.revert.apply(t);if(!n)return null;const a=r?.({spec:n.spec,command:e.command})??null;return{adopted:a?a.adopted:n.spec,revert:n.revert,value:a?.value??null}}push(e,t,r,n){const a=this.undoStack.length-1,i=this.undoStack[a],o=this.hasOpenRun&&i!==void 0&&Yv(i.command,e);if(n&&o){this.undoStack[a]={command:e,revert:i.revert},this.cachedSnapshot=null;return}this.undoStack.push({command:e,revert:r}),this.undoStack.length>this.maxHistorySize&&this.undoStack.shift(),this.hasOpenRun=n,this.redoStack=[],this.emit({type:"apply",command:e,spec:t})}withReentrancyGuard(e){if(this.isEmitting)throw new l.InternalError({message:"CommandStack: cannot call apply/undo/redo/clear from within a listener"});this.isEmitting=!0;try{return e()}finally{this.isEmitting=!1}}emit(e){this.cachedSnapshot=null;for(const t of this.listeners)try{t(e)}catch(r){console.error("CommandStack listener error:",r)}}},Kv=Object.freeze([]),Yv=(e,t)=>e.type===t.type&&$s(e.target,t.target),wn=e=>e.length===0?Kv:e.map(t=>t.command.metadata),Uv=class{constructor(e){this.history=e,this.frame=null}open(e){this.frame=e}clear(){this.frame=null}close(){const e=this.history.commit(),t=this.frame;return this.frame=null,e?t:null}},Wv=class{constructor(e){this.compiler=e,this.history=new zs,this.current=null,this.last=null,this.hostSpec=null,this.run=new Uv(this.history)}get scene(){return this.current}compile(e){return this.last=e,this.hostSpec=e.spec,this.absorb(this.compiler.compile(e))}update(e){const t=this.last,r=!t||e.spec!==this.hostSpec&&e.spec!==t.spec,n=!t||e.data!==t.data,a=!t||e.customPalettes!==t.customPalettes,i=!t||e.colorScheme!==t.colorScheme;if(this.hostSpec=e.spec,!r&&!n&&!a&&!i)return null;let o=null;r?this.run.close():o=this.closeAndConvert();const s=this.last,c=s&&!r?s.spec:e.spec;this.last={spec:c,data:e.data,customPalettes:e.customPalettes,colorScheme:e.colorScheme};const u=this.current,d=r||a||!u?this.absorb(this.compiler.compile(this.last)):this.absorb(this.compiler.recompile({spec:u.spec,data:e.data,colorScheme:e.colorScheme}));return r&&d.ok&&this.history.clear(),{result:d,specChanged:r,...o&&{committedSpec:o.spec}}}applyCommand(e,t={}){const r=t.transient??!1,n=[];if(!r){const c=this.commitNotification(!1);c&&n.push(c)}const{current:a,last:i,history:o}=this;if(!a||!i)return n;const s=o.apply(e,a.spec,({spec:c})=>{const u=this.applyEdit(c,i,r,e);return{adopted:u.ok?u.scene.spec:null,value:u}},t);return s&&n.push(this.renderedNotification(s,e,r)),n}commit(){const e=this.commitNotification(!0);return e?[e]:[]}undo(){return this.stepHistory((e,t)=>this.history.undo(e,t))}redo(){return this.stepHistory((e,t)=>this.history.redo(e,t))}stepHistory(e){const{current:t,last:r}=this;if(!t||!r)return[];const n=e(t.spec,({spec:a,command:i})=>{const o=this.applyEdit(a,r);return{adopted:o.ok?o.scene.spec:null,value:{result:o,command:i}}});return n?[this.renderedNotification(n.result,n.command,!1)]:[]}renderedNotification(e,t,r){return e.ok?r?{scene:e.scene}:{scene:e.scene,result:e,command:t,...e.spec&&{spec:e.spec}}:{errors:e.errors}}commitNotification(e){const t=this.closeAndConvert();return t?{result:t.result,spec:t.spec,...e&&{command:t.command}}:null}closeAndConvert(){const e=this.run.close(),{current:t,last:r}=this;return!t||!r||!e?null:{spec:this.recordSpec(t.spec,r),result:e.result,command:e.command}}applyEdit(e,t,r=!1,n=null){const a=this.compiler.recompile({spec:e,colorScheme:t.colorScheme});if(!a.ok)return{ok:!1,errors:a.errors};if(this.current=a.scene,r&&n){const o={ok:!0,scene:a.scene,warnings:a.warnings};return this.run.open({result:o,command:n}),o}this.run.clear();const i=this.recordSpec(a.scene.spec,t);return{ok:!0,scene:a.scene,warnings:a.warnings,spec:i}}recordSpec(e,t){const r=li(e);return this.last={spec:r,data:t.data,customPalettes:t.customPalettes,colorScheme:t.colorScheme},r}absorb(e){return e.ok&&(this.current=e.scene),e}},Xv=new Set(["x","y"]),Pn=["numeric","categorical","temporal"],Mn=["numeric"],qv=(e,t)=>{const r=e.layers.map(a=>yi(a.geom)).filter(l.isDefined),n=Ke(e);return t.filter(a=>jv(e,r,a)).map(a=>({aesthetic:a,variables:Zv(n,r,a),isRequired:Xv.has(a)}))},jv=(e,t,r)=>{switch(r){case"x":return!ey(e.coords);case"y":return!0;case"label":return t.some(n=>n.dataLabelCoordTypes.includes(e.coords.coordType));default:return t.some(n=>n.aesthetics.some(a=>a.kind==="visual"&&a.name===r))}},Zv=(e,t,r)=>{const n=Jv(t,r);return e.getVariableNames().filter(a=>!l.isInternalVariable(a)&&n.includes(e.getType(a)))},Jv=(e,t)=>t==="size"?Mn:t!=="x"&&t!=="y"?Pn:Qv(e,t)?Mn:Pn,Qv=(e,t)=>e.some(r=>r.positionRoles.some(n=>m.POSITION_NUMERIC_ROLES.has(n.role)&&n.aes===t&&!(n.role==="scalar"&&n.aes===n.axis))),ey=e=>e.coordType==="polar"&&e.params.theta==="y",ty=500,ry="normal",pr={thin:100,hairline:100,extraLight:200,ultraLight:200,light:300,normal:400,regular:400,medium:500,semiBold:600,demiBold:600,bold:700,extraBold:800,ultraBold:800,black:900,heavy:900,extraBlack:950,ultraBlack:950},ny=e=>{const t=e.style??"normal",r=e.weight??500,n=e.family.includes(",")?e.family:`'${e.family}'`;return`${t} ${r} ${e.size}px ${n}`},fr=e=>typeof e!="string"?e??500:pr[e],Ks=(e,t)=>{switch(t){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();case"capitalize":return e.replace(/(^|\s)(\S)/gu,(r,n,a)=>`${n}${a.toUpperCase()}`);default:return e}},Ys=(e,t)=>t===void 0||t===0?0:t*[...e].length,ay="\0",iy=class{constructor(e){this.inner=e,this.cache=new Map}measureText(e,t){const r=this.getCacheKey(e,t),n=this.cache.get(r);if(n)return n;const a=this.inner.measureText(e,t);return this.cache.set(r,a),a}getCacheKey(e,t){return[t.family,t.size,fr(t.weight),t.style??"normal",t.letterSpacing??0,t.textTransform??"none",e].join(ay)}},oy={" ":.25,"!":.27,'"':.36,"#":.6,$:.56,"%":.78,"&":.66,"'":.21,"(":.31,")":.31,"*":.44,"+":.56,",":.22,"-":.36,".":.22,"/":.35,0:.56,1:.56,2:.56,3:.56,4:.56,5:.56,6:.56,7:.56,8:.56,9:.56,":":.22,";":.22,"<":.56,"=":.56,">":.56,"?":.46,"@":.88,A:.63,B:.63,C:.65,D:.69,E:.56,F:.53,G:.7,H:.7,I:.26,J:.44,K:.62,L:.53,M:.84,N:.7,O:.73,P:.6,Q:.73,R:.62,S:.56,T:.56,U:.69,V:.6,W:.88,X:.58,Y:.56,Z:.58,"[":.29,"\\":.35,"]":.29,"^":.56,_:.44,"`":.33,a:.53,b:.58,c:.48,d:.58,e:.54,f:.31,g:.56,h:.57,i:.23,j:.23,k:.52,l:.23,m:.87,n:.57,o:.57,p:.58,q:.58,r:.35,s:.45,t:.34,u:.57,v:.49,w:.74,x:.49,y:.49,z:.46,"{":.33,"|":.26,"}":.33,"~":.56};var sy=1.05,ly=.84,cy=.21,uy=class{measureText(e,t){const r=Ks(e,t.textTransform);let n=Ys(r,t.letterSpacing);for(const o of r)n+=(oy[o]??.55)*t.size;fr(t.weight)>=pr.semiBold&&(n*=sy);const a=ly*t.size,i=cy*t.size;return{width:n,height:a+i,ascent:a,descent:i}}};exports.ANNOTATION_PARTS=b.ANNOTATION_PARTS;exports.ANNOTATION_STYLE_KINDS=b.ANNOTATION_STYLE_KINDS;exports.ANNOTATION_TOOLTIP_MARKER_GAP_PX=iu;exports.ARROW_DEFAULTS=l.ARROW_DEFAULTS;exports.ARROW_STICKER_DECLARATIONS=l.ARROW_STICKER_DECLARATIONS;exports.ARROW_STROKE_WIDTHS_PX=l.ARROW_STROKE_WIDTHS_PX;exports.AXIS_KEYS=l.AXIS_KEYS;exports.AddAnnotationCommand=tr;exports.AddHighlightCommand=cr;exports.AddLayerCommand=hr;exports.BORDER_RADIUS_PX=Ft;exports.BORDER_RADIUS_TOKENS=l.BORDER_RADIUS_TOKENS;exports.BUILTIN_STYLES=m.BUILTIN_STYLES;exports.COLOR_INTERPOLATION_SPACES=m.COLOR_INTERPOLATION_SPACES;exports.COMBO_TYPES=b.COMBO_TYPES;exports.COMPILER_STAGE_KEYS=m.COMPILER_STAGE_KEYS;exports.CONSTANT_VARIABLES=l.CONSTANT_VARIABLES;exports.CachedTextMeasurer=iy;exports.CommandRegistry=Hs;exports.CommandStackManager=zs;exports.Compiler=m.Compiler;exports.DASH_PRESETS=l.DASH_PRESETS;exports.DATA_LABEL_ROLES=b.DATA_LABEL_ROLES;exports.DEFAULT_BAR_CORNER_RADIUS=l.DEFAULT_BAR_CORNER_RADIUS;exports.DEFAULT_COLOR_PALETTE=l.DEFAULT_COLOR_PALETTE;exports.DEFAULT_DIMMED_ALPHA=l.DEFAULT_DIMMED_ALPHA;exports.DEFAULT_FONT_STYLE=ry;exports.DEFAULT_FONT_WEIGHT=ty;exports.DEFAULT_GEOM_COLOR=l.DEFAULT_GEOM_COLOR;exports.DEFAULT_GRAPH_BACKGROUND=l.DEFAULT_GRAPH_BACKGROUND;exports.DEFAULT_GRAPH_BORDER_WIDTH_PX=l.DEFAULT_GRAPH_BORDER_WIDTH_PX;exports.DEFAULT_GRAPH_PADDING_PX=l.DEFAULT_GRAPH_PADDING_PX;exports.DEFAULT_HEADLINE_SWATCH_SIZE_PX=l.DEFAULT_HEADLINE_SWATCH_SIZE_PX;exports.DEFAULT_HOVER_AFFORDANCE_COLOR=l.DEFAULT_HOVER_AFFORDANCE_COLOR;exports.DEFAULT_LOCALE=l.DEFAULT_LOCALE;exports.DEFAULT_MONO_BASE=l.DEFAULT_MONO_BASE;exports.DEFAULT_POINT_SIZE_PX=l.DEFAULT_POINT_SIZE_PX;exports.DEFAULT_STROKE_WIDTH_PX=l.DEFAULT_STROKE_WIDTH_PX;exports.DIFFERENCE_ARROW_DEFAULTS=l.DIFFERENCE_ARROW_DEFAULTS;exports.DIFFERENCE_ARROW_SIZE_DECLARATIONS=l.DIFFERENCE_ARROW_SIZE_DECLARATIONS;exports.DIVERGING_SCHEME_NAMES=m.DIVERGING_SCHEME_NAMES;exports.Dataset=l.Dataset;exports.EDIT_OUTLINE_PARTS=b.EDIT_OUTLINE_PARTS;exports.GROUP_VARIABLES=l.GROUP_VARIABLES;exports.Geom=l.Geom;exports.GraphCompilationSession=Wv;exports.HEADING_PARTS=b.HEADING_PARTS;exports.HEADLINE_ITEM_PARTS=b.HEADLINE_ITEM_PARTS;exports.HEADLINE_SWATCH_GAP_EM=Sa;exports.HEADLINE_TREND_GAP_EM=xa;exports.HEADLINE_TREND_ICON_SIZE_PX=bd;exports.HEADLINE_VALUE_LABEL_GAP_EM=ba;exports.HeuristicTextMeasurer=uy;exports.HoverEngine=yh;exports.InternalError=l.InternalError;exports.LEGEND_ITEM_PARTS=b.LEGEND_ITEM_PARTS;exports.LEGEND_PARTS=b.LEGEND_PARTS;exports.LINE_TYPES=l.LINE_TYPES;exports.LayoutCompiler=Oc;exports.MAX_BAR_WIDTH_FRACTION=lv;exports.MIN_BAR_WIDTH_FRACTION=Jo;exports.MONO_BASES=l.MONO_BASES;exports.MoveAnnotationCommand=fi;exports.NAMED_WEIGHTS=pr;exports.NEON_BASES=l.NEON_BASES;exports.OBSERVATION_ATTACHMENT_KINDS=qt;exports.OUT_OF_VIEW_MARGIN_PX=ou;exports.PANEL_BORDER_EDGES=b.PANEL_BORDER_EDGES;exports.POLAR_RIM_LABEL_GAP_PX=l.POLAR_RIM_LABEL_GAP_PX;exports.POSITION_ADJUSTMENTS=l.POSITION_ADJUSTMENTS;exports.POSITION_VARIABLES=l.POSITION_VARIABLES;exports.RESOLVED_DATA_LABEL_POSITIONS=b.RESOLVED_DATA_LABEL_POSITIONS;exports.RESTING_HOVER_STATE=N;exports.RemoveAnnotationCommand=er;exports.RemoveHighlightCommand=lr;exports.RemoveLayerCommand=mr;exports.SCALED_POSITION_AESTHETIC_KEYS=l.SCALED_POSITION_AESTHETIC_KEYS;exports.SCALED_VISUAL_AESTHETIC_KEYS=l.SCALED_VISUAL_AESTHETIC_KEYS;exports.SCHEME_ALIASES=m.SCHEME_ALIASES;exports.SEQUENTIAL_SCHEME_NAMES=m.SEQUENTIAL_SCHEME_NAMES;exports.SHAPE_DEFAULTS=l.SHAPE_DEFAULTS;exports.SIBLING_OVERLAP_THRESHOLD_PX=su;exports.SOURCE_PARTS=b.SOURCE_PARTS;exports.STACK_VARIABLES=l.STACK_VARIABLES;exports.STYLE_BLEND_MODES=l.STYLE_BLEND_MODES;exports.STYLE_FONT_STYLES=l.STYLE_FONT_STYLES;exports.STYLE_IMAGE_FITS=l.STYLE_IMAGE_FITS;exports.STYLE_LINE_CAPS=l.STYLE_LINE_CAPS;exports.STYLE_LINE_JOINS=l.STYLE_LINE_JOINS;exports.STYLE_PATTERN_PRESETS=l.STYLE_PATTERN_PRESETS;exports.STYLE_POINT_SYMBOLS=l.STYLE_POINT_SYMBOLS;exports.STYLE_STATES=l.STYLE_STATES;exports.STYLE_TEXT_DECORATIONS=l.STYLE_TEXT_DECORATIONS;exports.STYLE_TEXT_TRANSFORMS=l.STYLE_TEXT_TRANSFORMS;exports.SetAxisLabelCommand=Xi;exports.SetAxisPositionCommand=ji;exports.SetAxisTickModeCommand=Ji;exports.SetAxisTicksVisibilityCommand=eo;exports.SetAxisVisibilityCommand=ro;exports.SetBarCornerRadiusCommand=jo;exports.SetBarWidthCommand=Qo;exports.SetChartTypeCommand=Si;exports.SetContentCaptionCommand=ao;exports.SetContentSourceCommand=oo;exports.SetContentSubtitleCommand=lo;exports.SetContentTitleCommand=uo;exports.SetCoordLimitsCommand=Ko;exports.SetDataLabelsFormatCommand=ts;exports.SetDifferenceArrowStyleCommand=gi;exports.SetGridLineStyleCommand=go;exports.SetGridLineWidthCommand=yo;exports.SetGridVisibilityCommand=bo;exports.SetHeadlineCompareWithCommand=Ao;exports.SetHeadlinePositionCommand=To;exports.SetHeadlineShowCommand=Eo;exports.SetHeadlineSizeCommand=Co;exports.SetHighlightDimStyleCommand=Po;exports.SetLayerPositionCommand=ns;exports.SetLayerStatCommand=is;exports.SetLayerYScaleTypeCommand=ss;exports.SetLegendAlignCommand=Do;exports.SetLegendDisplayCommand=_o;exports.SetLegendPositionCommand=Vo;exports.SetLineCurveCommand=cs;exports.SetLineMissingValuesCommand=ds;exports.SetLineWidthCommand=hs;exports.SetMappingCommand=$i;exports.SetNumberFormatAbbreviationCommand=Fo;exports.SetNumberFormatDecimalsCommand=Go;exports.SetPointSizeCommand=fs;exports.SetPolarInnerRadiusCommand=Uo;exports.SetPolarStartAngleCommand=Xo;exports.SetRuleLabelCommand=vs;exports.SetRuleValueCommand=Ss;exports.SetScaleDomainCommand=Os;exports.SetScalePaletteCommand=ks;exports.SetScaleReverseCommand=Ns;exports.SetScaleTransformCommand=Bs;exports.SetStatLineCommand=xs;exports.SetStyleRuleCommand=H;exports.SpecResolver=m.SpecCompiler;exports.Stat=l.Stat;exports.TEXT_ANNOTATION_DEFAULTS=l.TEXT_ANNOTATION_DEFAULTS;exports.TEXT_ANNOTATION_FADE_ALPHA=l.TEXT_ANNOTATION_FADE_ALPHA;exports.TOOLTIP_PARTS=b.TOOLTIP_PARTS;exports.ToggleCategoryLabelsCommand=Is;exports.ToggleContentVisibilityCommand=$o;exports.ToggleDataLabelsCommand=Ls;exports.ToggleGoalLineCommand=Rs;exports.ToggleLineFillCommand=Cs;exports.ToggleLinePointsCommand=Ps;exports.ToggleStackTotalsCommand=Ms;exports.UNIT_POLAR_PATH_FRAME=wa;exports.UpdateAnnotationCommand=nr;exports.VISUAL_VARIABLES=l.VISUAL_VARIABLES;exports.alignUnitFractions=l.alignUnitFractions;exports.annotation=l.annotation;exports.applyTextTransform=Ks;exports.areAnchorsEqual=Z;exports.areDashArraysEqual=_t;exports.areEditMenuTriggersEqual=Ku;exports.areEditTargetsEqual=$s;exports.areEndpointsComparable=m.areEndpointsComparable;exports.areMappingsEquivalent=l.areMappingsEquivalent;exports.areObservationAnchorsEqual=ri;exports.arePointerRegionListsEqual=Nu;exports.arePredicatesEqual=ai;exports.areStyleDeclarationsEqual=ui;exports.areStyleRuleAddressesEqual=ci;exports.buildAverageLineSymbols=tu;exports.buildBarRectBounds=Ia;exports.buildCalloutHitRegions=au;exports.buildColumnKey=Ta;exports.buildDataLabelsContent=gu;exports.buildDiagnostic=m.buildDiagnostic;exports.buildEditMenuTriggerRegion=$u;exports.buildFontString=ny;exports.buildHeadlineItemRows=xd;exports.buildLayerIntroPlan=Mh;exports.buildLayerStyleAddress=U;exports.buildObservationPredicate=Au;exports.buildObservationsTarget=Cu;exports.buildObservationsTargetAtValue=wu;exports.buildPanelAnchorBox=l.buildPanelAnchorBox;exports.buildPointSymbolInBox=Nd;exports.buildPointSymbolPath=Vd;exports.buildPolarBarArcPath=Kd;exports.buildSliceGroupKey=Pa;exports.buildTooltipContent=rp;exports.canAnchorDirectLabels=m.canAnchorDirectLabels;exports.canBecomeCombo=ff;exports.canBecomeHeatmap=gf;exports.canPlaceDataLabels=fu;exports.clampAnnotationTranslation=Wp;exports.commandRegistry=v;exports.compileChromeStyles=m.compileChromeStyles;exports.composePoint=m.composePoint;exports.compositeColor=l.compositeColor;exports.computeArrow=Jc;exports.computeDifferenceArrow=Jn;exports.computeDirectLabelsLayout=xu;exports.computeLetterSpacingWidth=Ys;exports.computeLineBoxHeight=ta;exports.computePanelBorderPaths=Yh;exports.computePanelBorderSizes=Uh;exports.config=b.config;exports.coord=b.coord;exports.countLayerGeoms=Dh;exports.createAlphaValueReader=m.createAlphaValueReader;exports.createAnchorResolver=Vc;exports.createAreaPathGenerators=Ed;exports.createColorValueReader=m.createColorValueReader;exports.createCompiler=m.createCompiler;exports.createDataLabelPlacementResolver=qn;exports.createDatasetFromKindPartitions=m.createDatasetFromKindPartitions;exports.createEmptyLayerStyles=m.createEmptyLayerStyles;exports.createGroupValueReader=m.createGroupValueReader;exports.createLabelValueReader=m.createLabelValueReader;exports.createLayerYValueFormatter=Mt;exports.createLineFillAreaGenerator=Od;exports.createLinePathGenerator=Dd;exports.createObservationAnchorBuilder=m.createObservationAnchorBuilder;exports.createObservationAnchorParser=m.createObservationAnchorParser;exports.createPinnedNumberValueFormatter=ld;exports.createRawValueReader=m.createRawValueReader;exports.createSegmentYReader=m.createSegmentYReader;exports.createSizeValueReader=m.createSizeValueReader;exports.createSpec=b.createSpec;exports.createSpecBuilder=b.createSpecBuilder;exports.createStableBandKeyGenerator=Jd;exports.createStableCellKeyGenerator=Qd;exports.createStableKeyGenerator=He;exports.createStablePolarBarKeyGenerator=em;exports.createStrokeWidthValueReader=m.createStrokeWidthValueReader;exports.createStyleResolver=Cp;exports.createValueFormatter=I;exports.createXValueReader=m.createXValueReader;exports.createYValueReader=m.createYValueReader;exports.cursorToPiePlane=l.cursorToPiePlane;exports.cursorToPolar=l.cursorToPolar;exports.defineGeomStyleTarget=l.defineGeomStyleTarget;exports.describeMeasurementBasis=m.describeMeasurementBasis;exports.ensureReadableTextColor=l.ensureReadableTextColor;exports.extractPlainText=ua;exports.filterLayersByGeoms=m.filterLayersByGeoms;exports.findAnnotation=m.findAnnotation;exports.findAverageLineLayer=si;exports.findAxisGuide=Nt;exports.findCompanionLayers=m.findCompanionLayers;exports.findDefaultKitStyleTarget=m.findDefaultKitStyleTarget;exports.findDistinctLayers=m.findDistinctLayers;exports.findEquivalentHighlight=Fp;exports.findGoalLineLayer=ii;exports.findHighlightsAtObservation=Uu;exports.findKindStyleDeclarations=de;exports.findLayerByGeom=m.findLayerByGeom;exports.findLayerById=m.findLayerById;exports.findLegendForAesthetic=yd;exports.findObservationAttachment=ni;exports.findPointerRegion=ku;exports.findStyleRule=ue;exports.findStyleRuleIndex=Jt;exports.findTrendLineLayer=oi;exports.formatDifferenceLabel=jn;exports.formatHeadline=cd;exports.formatLegends=gd;exports.formatRuleValue=Sd;exports.geom=l.geom;exports.getAestheticFromScaleAestheticKey=l.getAestheticFromScaleAestheticKey;exports.getAlpha=l.getAlpha;exports.getAngleExtent=l.getAngleExtent;exports.getBarRectBounds=Aa;exports.getBoundingRect=Pd;exports.getColor=l.getColor;exports.getCrossAxisCoordinate=m.getCrossAxisCoordinate;exports.getCurve=Ge;exports.getDifferenceArrowDimensions=Zn;exports.getDifferenceArrowLabelBox=na;exports.getGroup=m.getGroup;exports.getGroupVariables=l.getGroupVariables;exports.getHoverGuideLineProps=Ah;exports.getHoverGuideRectProps=Ih;exports.getInsetTileRect=l.getInsetTileRect;exports.getLineType=l.getLineType;exports.getMainAxisCoordinate=m.getMainAxisCoordinate;exports.getNumericWeight=fr;exports.getPaintedTileRect=l.getPaintedTileRect;exports.getPointSymbolOuterRadius=Fd;exports.getPolarHoverGuideArcProps=Th;exports.getRadiusExtent=l.getRadiusExtent;exports.getScaledAesthetic=l.getScaledAesthetic;exports.getShapeAnnotationStroke=vp;exports.getSize=l.getSize;exports.getStackRole=l.getStackRole;exports.getStrokeWidth=l.getStrokeWidth;exports.getTileRectBounds=l.getTileRectBounds;exports.getUnionExtent=zd;exports.getX=l.getX;exports.getXMax=l.getXMax;exports.getXMin=l.getXMin;exports.getY=l.getY;exports.getYMax=l.getYMax;exports.getYMin=l.getYMin;exports.getYRaw=l.getYRaw;exports.hasMultipleGroups=l.hasMultipleGroups;exports.highlight=b.highlight;exports.inferDefaultDifferenceArrowEndpoints=qu;exports.inferDifferenceArrowEndpoints=ga;exports.inferXVariable=l.inferXVariable;exports.isAnnotationMovable=Xp;exports.isBorderRadiusToken=l.isBorderRadiusToken;exports.isCartesian=m.isCartesian;exports.isCategoricalValueFormat=l.isCategoricalValueFormat;exports.isComboChartType=me;exports.isCompanionLayer=m.isCompanionLayer;exports.isCompilerCachingEnabled=l.isCompilerCachingEnabled;exports.isCurrencyValueFormat=l.isCurrencyValueFormat;exports.isDateWithoutYearValueFormat=l.isDateWithoutYearValueFormat;exports.isFullTurnSweep=l.isFullTurnSweep;exports.isGeomStyleRule=Qt;exports.isGradientPaint=l.isGradientPaint;exports.isImagePaint=l.isImagePaint;exports.isKeyedScope=Be;exports.isLayerOf=Y;exports.isLayerSpecOf=m.isLayerSpecOf;exports.isLineType=l.isLineType;exports.isLookupValueFormat=l.isLookupValueFormat;exports.isNumericValueFormat=l.isNumericValueFormat;exports.isObservationAttachmentKind=_p;exports.isPatternPaint=l.isPatternPaint;exports.isPointWithinEditMenuTrigger=zu;exports.isPointWithinRegionShape=Vt;exports.isPositionScale=l.isPositionScale;exports.isSafeUrl=Qh;exports.isStackedPosition=l.isStackedPosition;exports.isTemporalValueFormat=l.isTemporalValueFormat;exports.isZeroAnchoredAxis=Zu;exports.mapping=b.mapping;exports.measureObservationsBoxes=Ju;exports.normalizeAngle=l.normalizeAngle;exports.orderPointerRegions=Vu;exports.paintKey=l.paintKey;exports.paintsInDonutHole=Fe;exports.pickFilters=Qa;exports.pickReadableTextColor=l.pickReadableTextColor;exports.pipe=b.pipe;exports.placeCallouts=mu;exports.polarToUnit=l.polarToUnit;exports.positionToAngle=l.positionToAngle;exports.prefixInternalVariable=l.prefixInternalVariable;exports.prepareAreaObservations=Rd;exports.prepareLineObservations=_d;exports.projectAnchorToPanel=Pe;exports.projectRegionToPanel=sa;exports.quantizeKey=_;exports.readAnchoredObservation=td;exports.readAttachedObservation=jt;exports.readAuthoredNumber=mp;exports.readAuthoredString=hp;exports.readBroadestObservationsScope=Pu;exports.readChartType=pf;exports.readColorGroupObservation=tm;exports.readComboLineLayerId=vf;exports.readCompanionRowsAtScopeKey=Lu;exports.readConstantValue=l.readConstantValue;exports.readEditTargetKey=bt;exports.readFoldKeepVariables=l.readFoldKeepVariables;exports.readGeomColor=Ht;exports.readGeomEffects=$h;exports.readHighlightDimStyle=Mo;exports.readMainAxis=m.readMainAxis;exports.readMainAxisVariable=l.readMainAxisVariable;exports.readMappableAesthetics=qv;exports.readMappedVariable=Ki;exports.readObservationIndex=Lh;exports.readRowScopeKey=pa;exports.readRowsAtScopeKey=kt;exports.readScopeXVariable=m.readScopeXVariable;exports.readVariableName=l.readVariableName;exports.readXExtent=Za;exports.readYExtent=Ja;exports.removeAlpha=l.removeAlpha;exports.resolveAnchorVariable=m.resolveAnchorVariable;exports.resolveAnchoredLabelCenter=l.resolveAnchoredLabelCenter;exports.resolveArrowAnnotationStyle=pp;exports.resolveArrowColor=Su;exports.resolveBarBandFraction=l.resolveBarBandFraction;exports.resolveBarBaseline=Gt;exports.resolveBarBorderTreatment=wd;exports.resolveBarCornerRadiiPx=Cd;exports.resolveBarCornerRadiusPx=Bt;exports.resolveBarPaintOrigin=Md;exports.resolveCalloutAnnotationStyle=gp;exports.resolveChromeMargin=P;exports.resolveChromeMargins=bp;exports.resolveColorRamp=m.resolveColorRamp;exports.resolveComparisonBasis=m.resolveComparisonBasis;exports.resolveDataLabelStyle=tc;exports.resolveDeferredAnchors=$c;exports.resolveDefinition=l.resolveDefinition;exports.resolveDifferenceArrowAnnotationStyle=fp;exports.resolveDirectLabelStyle=ic;exports.resolveEditOutlineStyle=xp;exports.resolveGeomAnchorSpace=m.resolveGeomAnchorSpace;exports.resolveGraphPadding=Sp;exports.resolveHeadlineItemStyle=oc;exports.resolveHeadlineNumberStyle=sc;exports.resolveHeadlinePlacement=Rc;exports.resolveLegendItemStyle=ac;exports.resolveObservationPoint=rd;exports.resolveObservationsTarget=nd;exports.resolvePanelBorderStyle=yp;exports.resolvePolarBarCornerRadiusUnit=$d;exports.resolveRuleLabelStyle=rc;exports.resolveSegmentYSource=m.resolveSegmentYSource;exports.resolveSwatchGeomPaint=zt;exports.resolveTooltipStyle=nc;exports.resolveYScaleAesthetic=l.resolveYScaleAesthetic;exports.sampleColorScheme=m.sampleColorScheme;exports.scale=b.scale;exports.setCompilerCachingEnabled=l.setCompilerCachingEnabled;exports.stat=b.stat;exports.stepDifferenceArrowEndpoint=od;exports.style=b.style;exports.styles=b.styles;exports.toDashPreset=Ot;exports.toFontSpec=ec;exports.toPaintColor=l.toPaintColor;exports.toPanelCursor=ca;exports.toPercent=K;exports.toSpec=li;exports.toStrokeDasharray=la;exports.toViewBoxX=Fc;exports.toViewBoxY=F;exports.token=l.token;exports.transform=b.transform;exports.truncateToWidth=Dn;exports.unitToPolar=l.unitToPolar;exports.updateSpec=m.updateSpec;exports.withAlpha=l.withAlpha;
23
+ `,rc=(e,t,r,n,a,i=.5)=>e?{x:n,y:Math.min(t.y,r.y)+i*a}:{x:Math.min(t.x,r.x)+i*a,y:n},nc=(e,t,r)=>Math.abs(e?t.y-r.y:t.x-r.x),Jn=({arrow:e,style:t,mainAxis:r,panelWidth:n,panelHeight:a,locale:i})=>{const o=r==="y",s={x:e.start.x*n,y:(1-e.start.y)*a},c={x:e.end.x*n,y:(1-e.end.y)*a},u=Zn(t.strokeWidth),d=Jl(o,s,c,u),h=(o?ec:Ql)(s,c,d,u),p=tc(o,c,u),f=rc(o,s,c,d,nc(o,s,c),e.labelCrossPosition),g=jn({locale:i,kind:e.label,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat});return{id:e.id,start:s,end:c,linePath:h,arrowheadPath:p,labelPosition:f,labelText:g}},xr={large:1,medium:23/26,small:19/26},Qe={large:1,medium:10/12,small:10/12},Qn=["fontStyle","letterSpacing","textTransform","textDecoration","textOutlineColor","textOutlineWidth","textShadow"],ea=["fontFamily","fontSize","fontWeight","lineHeight","textColor",...Qn],ta=e=>e.fontSize*e.lineHeight,ac=(e,t)=>({family:e.fontFamily??t,size:e.fontSize,weight:e.fontWeight,...e.fontStyle===void 0?{}:{style:e.fontStyle},...e.letterSpacing===void 0?{}:{letterSpacing:e.letterSpacing},...e.textTransform===void 0?{}:{textTransform:e.textTransform}}),ic=(e,t,r)=>{const n=t==="aggregate"?e.dataLabel.aggregate():e.dataLabel[t][r]();return{...n.resolve(),isTextColorAuthored:n.getSource("textColor")==="authored"}},oc=(e,t)=>{const r=e.get("fontFamily")??t.get("fontFamily"),n=e.get("textColor"),a=e.explain("textColor").origin?.list;return{...r===void 0?{}:{fontFamily:r},fontSize:e.get("fontSize")*t.get("textScale"),fontWeight:e.get("fontWeight"),lineHeight:e.get("lineHeight"),...n!==void 0&&a!==void 0&&a!=="builtin"?{textColor:n}:{},...mc(e)}},sc=e=>({box:e.tooltip().resolve(),heading:e.tooltip.heading().resolve(),label:e.tooltip.label().resolve(),value:e.tooltip.value().resolve(),primaryRow:e.tooltip.primaryRow().resolve()}),lc=e=>({item:e.legendItem().resolve(),swatch:e.legendItem.swatch().resolve()}),cc=e=>{const t=e.directLabel();return{...t.resolve(),isTextColorAuthored:t.getSource("textColor")==="authored"}},uc=(e,t)=>{const r=e.headlineItem,n=r.number().resolve(),a={...n,fontSize:n.fontSize*xr[t]},i=r.number.center(),o=i.resolve().fontSize;return{number:a,...hc(i)?{numberCenter:xe(i,o===void 0?a.fontSize:o*xr[t])}:{},caption:xe(r.caption(),r.caption().resolve().fontSize*Qe[t]),label:xe(r.label(),r.label().resolve().fontSize*Qe[t]),swatch:r.swatch().resolve(),trend:xe(r.trend(),r.trend().resolve().fontSize*Qe[t]),trendUp:r.trend.up().resolve(),trendDown:r.trend.down().resolve(),trendFlat:r.trend.flat().resolve()}},dc=(e,t)=>{const r=t?e.numberCenter:void 0;return r===void 0?e.number:{...e.number,...ra(r)}},mc=e=>{const t={};for(const r of Qn){const n=e.get(r);n!==void 0&&Object.assign(t,{[r]:n})}return t},hc=e=>ea.some(t=>e.getSource(t)!=="unresolved"),xe=(e,t)=>({...ra(e.resolve()),fontSize:t}),ra=e=>{const t={};for(const r of ea){const n=e[r];n!==void 0&&Object.assign(t,{[r]:n})}return t},na=({labelPosition:e,measuredTextWidth:t,label:r})=>{const n=t+2*r.paddingInline,a=ta(r)+2*r.paddingBlock;return{x:e.x-n/2,y:e.y-a/2,width:n,height:a}};function*pc({annotations:e,mainAxis:t,panelRect:r,locale:n,resolveStyle:a,measureLabel:i}){for(const o of e.differenceArrows){if(!l.isPointWithinPanel(o.start.x,o.start.y)||!l.isPointWithinPanel(o.end.x,o.end.y))continue;const s=a(o.id),c=Jn({arrow:o,style:s,mainAxis:t,panelWidth:r.width,panelHeight:r.height,locale:n}),u=na({labelPosition:c.labelPosition,measuredTextWidth:i(c.labelText,s.label).width,label:s.label});yield{...u,x:r.x+u.x,y:r.y+u.y}}}var fc=e=>{const t=e.padding,r=Ar(e.rows,t?.top??0,t?.bottom??0),n=Ar(e.cols,t?.left??0,t?.right??0);return{rows:r.tracks,cols:n.tracks,placements:Sc(e.placements,r.nameToIndex,n.nameToIndex),width:e.containerSize.width,height:e.containerSize.height}},gc=e=>{const t=Ir(e.rows,e.height),r=Ir(e.cols,e.width),n=Tr(t),a=Tr(r),i=new Map;for(const o of e.placements){const s=o.rowSpan??1,c=o.colSpan??1,u=a[o.col]??0,d=n[o.row]??0,h=Lr(r,o.col,c),p=Lr(t,o.row,s);i.set(o.name,{x:u,y:d,width:Math.max(0,h),height:Math.max(0,p)})}return i},Ar=(e,t,r)=>{const n=[],a=new Map;t>0&&n.push({type:"fixed",pixels:t});let i=0;for(let o=0;o<e.length;o++){const s=e[o];if(!s)continue;dt(s)&&i>0&&(n.push({type:"fixed",pixels:i}),i=0),a.set(s.name,n.length),n.push(vc(s));const c=yc(e,o);if(dt(s)&&c){const u=s.gaps?.after??0,d=c.gaps?.before??0;u>=d?u>0&&n.push({type:"fixed",pixels:u}):i=d}}return r>0&&n.push({type:"fixed",pixels:r}),{tracks:n,nameToIndex:a}},vc=e=>typeof e.size=="number"?{type:"fixed",pixels:e.size}:{type:"flex",weight:e.size.flex},dt=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,yc=(e,t)=>{for(let r=t+1;r<e.length;r++){const n=e[r];if(n&&dt(n))return n}},Sc=(e,t,r)=>{const n=[];for(const a of e){const i=t.get(a.row),o=r.get(a.col);if(i===void 0||o===void 0)continue;const s=a.rowEnd!==void 0?t.get(a.rowEnd):i,c=a.colEnd!==void 0?r.get(a.colEnd):o;s===void 0||c===void 0||n.push({name:a.name,row:i,col:o,rowSpan:Math.max(1,s-i+1),colSpan:Math.max(1,c-o+1)})}return n},Ir=(e,t)=>{let r=0,n=0;for(const i of e)i.type==="fixed"?r+=i.pixels:n+=i.weight;const a=Math.max(0,t-r);return e.map(i=>i.type==="fixed"?i.pixels:n===0?0:i.weight/n*a)},Tr=e=>{const t=new Array(e.length);let r=0;for(let n=0;n<e.length;n++)t[n]=r,r+=e[n]??0;return t},Lr=(e,t,r)=>{let n=0;const a=Math.min(t+r,e.length);for(let i=t;i<a;i++)n+=e[i]??0;return n},J={top:0,right:0,bottom:0,left:0},aa={outer:J,inner:J},bc=(e,t,r,n=J,a=aa,i=l.DEFAULT_GRAPH_PADDING_EDGES_PX,o)=>{const s={top:a.inner.top+n.top,right:a.inner.right+n.right,bottom:a.inner.bottom+n.bottom,left:a.inner.left+n.left},c=r.axes.top>0||r.axesLabels.top>0?r.axesLabels.top:Math.max(r.axesLabels.top,r.axesLabels.left,r.axesLabels.right),u=[{name:"header",size:t.headerSize.height,gaps:G(o.header)},{name:"topLegend",size:r.legends.top,gaps:G(o.legend.top)},{name:"headline",size:r.headline,gaps:G(o.headline)},{name:"topAxisLabel",size:c,gaps:G(o.axisLabel.top)},{name:"topAxis",size:r.axes.top,gaps:G(o.tickLabel.top)},{name:"topPanelOuter",size:a.outer.top},{name:"topPanelInner",size:s.top},{name:"panel",size:{flex:1}},{name:"bottomPanelInner",size:s.bottom},{name:"bottomPanelOuter",size:a.outer.bottom},{name:"bottomAxis",size:r.axes.bottom,gaps:G(o.tickLabel.bottom)},{name:"bottomAxisLabel",size:r.axesLabels.bottom,gaps:G(o.axisLabel.bottom)},{name:"bottomLegend",size:r.legends.bottom,gaps:G(o.legend.bottom)},{name:"footer",size:t.footerSize.height,gaps:G(o.footer)}],d=[{name:"leftLegend",size:r.legends.left,gaps:Ae(o.legend.left)},{name:"leftAxis",size:r.axes.left,gaps:Ae(o.tickLabel.left)},{name:"leftPanelOuter",size:a.outer.left},{name:"leftPanelInner",size:s.left},{name:"panel",size:{flex:1}},{name:"rightPanelInner",size:s.right},{name:"rightPanelOuter",size:a.outer.right},{name:"rightAxis",size:r.axes.right,gaps:Ae(o.tickLabel.right)},{name:"rightLegend",size:r.legends.right,gaps:Ae(o.legend.right)}],h=Er(u,i.top,i.bottom),p=Er(d,i.left,i.right);return fc({rows:u,cols:d,placements:[{name:"header",row:"header",col:"leftLegend",colEnd:"rightLegend"},{name:"headline",row:"headline",col:"leftLegend",colEnd:"rightLegend"},{name:"footer",row:"footer",col:"leftLegend",colEnd:"rightLegend"},{name:"plot",row:"topAxisLabel",rowEnd:"bottomAxisLabel",col:"leftAxis",colEnd:"rightAxis"},{name:"panelFrame",row:"topPanelInner",rowEnd:"bottomPanelInner",col:"leftPanelInner",colEnd:"rightPanelInner"},{name:"panel",row:"panel",col:"panel"},...Ac(r.axes),...Ic(r.axesLabels,r.axes),...Tc(r.legends)],containerSize:e,padding:{top:h.start,bottom:h.end,left:p.start,right:p.end}})},G=e=>({before:e.top,after:e.bottom}),Ae=e=>({before:e.left,after:e.right}),xc=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Er=(e,t,r)=>{const n=e.filter(xc),a=n[0],i=n[n.length-1];return{start:t+(a?.gaps?.before??0),end:r+(i?.gaps?.after??0)}},Ac=e=>{const t=[];return e.top>0&&t.push({name:"topAxis",row:"topAxis",col:"panel"}),e.bottom>0&&t.push({name:"bottomAxis",row:"bottomAxis",col:"panel"}),e.left>0&&t.push({name:"leftAxis",row:"panel",col:"leftAxis"}),e.right>0&&t.push({name:"rightAxis",row:"panel",col:"rightAxis"}),t},Ic=(e,t)=>{const r=[];return e.top>0||t.top>0?(e.top>0&&r.push({name:"topAxisLabel",row:"topAxisLabel",col:"panel"}),e.left>0&&r.push({name:"leftAxisLabel",row:"topAxis",col:"leftAxis"}),e.right>0&&r.push({name:"rightAxisLabel",row:"topAxis",col:"rightAxis"})):(e.left>0&&r.push({name:"leftAxisLabel",row:"topAxisLabel",col:"leftAxis"}),e.right>0&&r.push({name:"rightAxisLabel",row:"topAxisLabel",col:"rightAxis"})),e.bottom>0&&r.push({name:"bottomAxisLabel",row:"bottomAxisLabel",col:"panel"}),r},Tc=e=>{const t=[];return e.top>0&&t.push({name:"topLegend",row:"topLegend",col:"leftAxis",colEnd:"rightAxis"}),e.bottom>0&&t.push({name:"bottomLegend",row:"bottomLegend",col:"leftAxis",colEnd:"rightAxis"}),e.left>0&&t.push({name:"leftLegend",row:"panel",col:"leftLegend"}),e.right>0&&t.push({name:"rightLegend",row:"panel",col:"rightLegend"}),t};var Lc=class{constructor(e){this.outer={...J},this.inner={...J},this.currentPanelRect=e}resolve(){return{outer:{...this.outer},inner:{...this.inner}}}add(e,t){const r=this.computeEdgeOverflow(e,8),n=this.computeEdgeOverflow(e,0);this.growEdge("left",t.x,r.left,n.left),this.growEdge("right",t.x,r.right,n.right),this.growEdge("top",t.y,r.top,n.top),this.growEdge("bottom",t.y,r.bottom,n.bottom)}computeEdgeOverflow(e,t){const r=this.currentPanelRect;return{top:Math.max(Math.ceil(r.y+t-e.y),0),right:Math.max(Math.ceil(e.x+e.width-(r.x+r.width-t)),0),bottom:Math.max(Math.ceil(e.y+e.height-(r.y+r.height-t)),0),left:Math.max(Math.ceil(r.x+t-e.x),0)}}growEdge(e,t,r,n){t!=="none"&&(t==="outside"?n>0&&(this.outer[e]=Math.max(this.outer[e],n)):r>0&&(this.inner[e]=Math.max(this.inner[e],r)))}},Ec=["top","right","bottom","left"],et=(e,t)=>{const r={};for(const n of Ec){const a=e.get(`${n}${t}`);a&&(r[n]=a)}return r};function Rr(e,t){return e.top===t.top&&e.right===t.right&&e.bottom===t.bottom&&e.left===t.left}var mt=["large","medium","small"],Rc=({size:e,availableWidth:t,measureStripWidth:r})=>{if(e!=="auto")return e;for(const n of mt)if(r(n)<=t)return n;return"small"},wc=({size:e,availableWidth:t,measureStripWidth:r})=>{const n=e==="auto"?0:mt.indexOf(e);for(const a of mt.slice(n))if(r(a)<=t)return a;return null},Cc=({itemWidths:e,gap:t,availableWidth:r})=>{let n=0,a=0;for(const i of e){const o=a===0?i:n+t+i;if(o>r)break;n=o,a+=1}return a},Pc=({headline:e,containerSize:t,measurer:r})=>{if(Fe(e))return 0;const n=ia(e,t.width,r);return r.measureHeadline(e.formatted,n).height},Mc=({headline:e,layout:t,containerSize:r,measurer:n,itemGap:a})=>{if(Fe(e)){const s=Dc(t.panel,e.innerRadius),c=wc({size:e.size,availableWidth:s.width,measureStripWidth:oa(e,n)});return c===null?null:{rect:s,resolvedSize:c,visibleItemCount:1}}const i=ia(e,r.width,n);if(e.formatted.kind!=="perGroup")return{rect:t.headline,resolvedSize:i,visibleItemCount:1};const o=Cc({itemWidths:n.measureHeadlineItemWidths(e.formatted,i),gap:a,availableWidth:t.headline.width});return o===0?null:{rect:t.headline,resolvedSize:i,visibleItemCount:o}},Fe=e=>e.formatted.kind==="grandTotal"&&e.position==="center"&&e.innerRadius>0,Dc=(e,t)=>{const r=t*(Math.min(e.width,e.height)/2)*Math.SQRT2,n=e.x+e.width/2,a=e.y+e.height/2;return{x:n-r/2,y:a-r/2,width:r,height:r}},ia=(e,t,r)=>Rc({size:e.size,availableWidth:t,measureStripWidth:oa(e,r)}),oa=(e,t)=>r=>t.measureHeadline(e.formatted,r,Fe(e)).width,X={x:0,y:0,width:0,height:0},Oc={top:0,right:0,bottom:0,left:0},_c="0000",kc=3,Vc=e=>e.plot.y+e.plot.height-e.panel.y,Nc=class{constructor(e){this.measurer=e}compile(e){return m.createPipeline({axes:e.axes,numberFormat:e.numberFormat,formattedLegends:e.formattedLegends,containerSize:e.containerSize,externalMeasurements:e.externalMeasurements,panelOverflow:aa,panelBorder:e.panelBorder??J,headline:e.headline,locale:e.formattingLocale??e.parsingLocale,padding:e.padding??l.DEFAULT_GRAPH_PADDING_EDGES_PX,margins:e.margins}).pipe(({axes:t,numberFormat:r,locale:n})=>({axisBundles:t.map(a=>({axis:a,resolveFormatter:Fc(a,n,r),formatted:this.seedAxis(a)}))})).pipe(({axisBundles:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})=>({layout:this.resolveLayout({axes:t.map(d=>d.formatted),formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})})).pipe(({axisBundles:t,layout:r})=>({axisBundles:t.map(n=>wr(n.axis.position)?{...n,formatted:this.finalizeAxis(n.axis,n.resolveFormatter,r.panelFrame)}:n)})).pipe(({axisBundles:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})=>({layout:this.resolveLayout({axes:t.map(d=>d.formatted),formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})})).pipe(({axisBundles:t,layout:r})=>({formattedAxes:t.map(n=>wr(n.axis.position)?n.formatted:this.finalizeAxis(n.axis,n.resolveFormatter,r.panelFrame))})).pipe(({formattedAxes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})=>({layout:this.resolveLayout({axes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:i,panelBorder:o,headline:s,padding:c,margins:u})})).pipe(({formattedAxes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,layout:i,panelOverflow:o,panelBorder:s,headline:c,locale:u,padding:d,margins:h})=>({formattedAxes:t,layout:this.settlePanelOverflow({input:e,layout:i,formattedAxes:t,formattedLegends:r,containerSize:n,externalMeasurements:a,panelOverflow:o,panelBorder:s,headline:c,locale:u,padding:d,margins:h})})).pipe(({formattedAxes:t,layout:r})=>{const n=this.applyPolarPanelInset(e,t,r);return{formattedAxes:t,layout:n,plotBottomY:Vc(n)}}).result()}measurePanelOverflow(e,t,r,n){if(!e.overflowStrategy||e.coordSystem?.type!=="cartesian")return n;const a=new Lc(t);if(e.annotations&&e.resolveDifferenceArrowStyle&&e.overflowStrategy.differenceArrows)for(const o of pc({annotations:e.annotations,mainAxis:e.coordSystem.mainAxis,panelRect:t,locale:r,resolveStyle:e.resolveDifferenceArrowStyle,measureLabel:this.measurer.measureDifferenceArrowLabel}))a.add(o,e.overflowStrategy.differenceArrows);if(e.layers&&e.layers.length>0&&e.readers&&e.overflowStrategy.dataLabels)for(const o of Kl({layers:e.layers,coordSystem:e.coordSystem,axes:e.axes,numberFormat:e.numberFormat,panelRect:t,measureDataLabel:this.measurer.measureDataLabel,readers:e.readers,locale:r,resolvePlacement:e.resolvePlacement}))a.add(o,e.overflowStrategy.dataLabels);const i=a.resolve();return Rr(i.inner,n.inner)&&Rr(i.outer,n.outer)?n:i}settlePanelOverflow({input:e,layout:t,formattedAxes:r,formattedLegends:n,containerSize:a,externalMeasurements:i,panelOverflow:o,panelBorder:s,headline:c,locale:u,padding:d,margins:h}){let p=t,f=o;for(let g=0;g<kc;g++){const S=this.measurePanelOverflow(e,p.panelFrame,u,f);if(S===f)break;f=S,p=this.resolveLayout({axes:r,formattedLegends:n,containerSize:a,externalMeasurements:i,panelOverflow:S,panelBorder:s,headline:c,padding:d,margins:h})}return p}applyPolarPanelInset(e,t,r){if(e.coordSystem?.type!=="polar")return r;const n=this.measurePolarRimInset(t),{panel:a}=r,i=a.width-n.horizontal*2,o=a.height-n.vertical*2;return i<=0||o<=0?Cr(r,a,0,0):Cr(r,a,n.horizontal,n.vertical)}measurePolarRimInset(e){const t=e.find(i=>i.geometry==="circular");if(!t)return{horizontal:0,vertical:0};const r=l.getAestheticFromScaleAestheticKey(t.scaleAestheticKey);let n=0,a=0;for(const i of t.ticks){const o=this.measurer.measureTickLabel(i.formattedLabel,r);n=Math.max(n,o.width),a=Math.max(a,o.height)}return n===0?{horizontal:0,vertical:0}:{horizontal:n+8,vertical:a+8}}seedAxis(e){const{tickCandidates:t,...r}=e;return{...r,ticks:[{value:0,position:0,formattedLabel:_c}],labelRotation:0,labelMaxWidthPx:null}}finalizeAxis(e,t,r){const n=e.position==="top"||e.position==="bottom"?r.width:r.height,a=l.getAestheticFromScaleAestheticKey(e.scaleAestheticKey),i=d=>this.measurer.measureTickLabel(d,a),o=Ll({axis:e,availableSpacePx:n,measureLabel:i,resolveFormatter:t}),{tickCandidates:s,...c}=e,u={...c,ticks:o,labelRotation:0,labelMaxWidthPx:null};return e.geometry!=="linear"?u:e.scaleType==="discrete"&&e.bandwidth!==void 0?Sl({formattedAxis:u,bandwidthPx:e.bandwidth*n,panelRect:r,measureLabel:i}):u}resolveLayout({axes:e,formattedLegends:t,containerSize:r,externalMeasurements:n,panelOverflow:a,panelBorder:i,headline:o,padding:s,margins:c}){const u=gc(bc(r,n,this.measureGuides(e,t,o,r),i,a,s,Bc(c,t)));return{header:u.get("header")??X,headline:u.get("headline")??X,footer:u.get("footer")??X,plot:u.get("plot")??X,panelFrame:u.get("panelFrame")??X,panel:u.get("panel")??X,axes:et(u,"Axis"),axisLabels:et(u,"AxisLabel"),legends:et(u,"Legend")}}measureGuides(e,t,r,n){const a={top:0,right:0,bottom:0,left:0},i={top:0,right:0,bottom:0,left:0};for(const s of e)s.isVisible&&s.geometry==="linear"&&(a[s.position]=this.measurer.measureAxis(s),s.label!==null&&(i[s.position]=this.measurer.measureAxisLabel(s)));const o={top:0,right:0,bottom:0,left:0};for(const s of t)o[s.position]=this.measurer.measureLegend(s);return{axes:a,axesLabels:i,legends:o,headline:this.measureHeadlineBand(r,n)}}measureHeadlineBand(e,t){return e===void 0?0:Pc({headline:e,containerSize:t,measurer:this.measurer})}},wr=e=>e==="left"||e==="right",Cr=(e,t,r,n)=>{const a=t.width-r*2,i=t.height-n*2,o=Math.min(a,i);return{...e,panel:{x:t.x+r+(a-o)/2,y:t.y+n+(i-o)/2,width:o,height:o}}},Fc=(e,t,r)=>{const n=new WeakMap;return a=>{const i=n.get(a);if(i)return i;const o=Pt({valueFormat:a.valueFormat??e.valueFormat,locale:t,numberFormat:r,tickValues:a.ticks.map(s=>s.value)});return n.set(a,o),o}},Bc=(e,t)=>{const r={...e.legend};for(const n of t)n.display==="direct"&&(r[n.position]=Oc);return{...e,legend:r}},Gc=(e=[])=>{const t=Hc(e);return{resolve:(r,n,a)=>{if(!t.has(r))return null;const i=t.get(r).resolveAnchorPosition?.(n,a)??null;return i===null?null:{...i,space:m.resolveGeomAnchorSpace(a.coordSystem)}},hasCapability:r=>t.has(r)&&t.get(r).resolveAnchorPosition!==void 0,createLayerMeasurement:r=>t.has(r.geom)?m.createLayerMeasurement(r,t.get(r.geom)):null}},Hc=e=>{const t=new l.GeomRegistry;for(const r of e){const n=l.resolveDefinition(r);n instanceof l.Geom&&t.register(n.type,n)}return t};function $c(e){return e}function F(e){return 1-e}var Y=e=>`${Number.parseFloat((e*100).toFixed(4))}%`,Pe=(e,t)=>{const r=m.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+F(e.y)*r.height}},sa=(e,t)=>{const r=m.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+(F(e.y)-e.height)*r.height,width:e.width*r.width,height:e.height*r.height}},Kc=class{constructor(e,t,r){this.annotations=e,this.panelRect=t,this.measuredBoxes=r,this.index=null,this.boxes=new Map,this.resolvingStack=[],this.cyclic=new Set,this.missingRefs=new Set}cyclicIds(){return[...this.cyclic]}missingRefIds(){return[...this.missingRefs]}resolvePoint(e){if(e.defer===void 0)return e;if(e.defer.type==="px-offset"){const i=this.toPanelPoint(e),{x:o,y:s}=ht(e.defer,this.panelRect);return Dr({...e,x:i.x+o,y:i.y-s})}const t=this.boxOf(e.defer.ref);if(t===null)return null;const r=l.alignToBoxPoint(t,e.defer.align),{x:n,y:a}=Yc(r,e.defer.offset,this.panelRect);return{x:n,y:a}}resolveRegion(e){if(e.defer===void 0)return e;if(e.defer.type==="px-offset"){const a=this.toPanelRegion(e),{x:i,y:o}=ht(e.defer,this.panelRect);return Dr({...e,x:a.x-i,y:a.y-o,width:Math.max(0,a.width+2*i),height:Math.max(0,a.height+2*o)})}const t=this.boxOf(e.defer.ref);if(t===null)return null;const r=t.xMax-t.xMin,n=t.yMax-t.yMin;return r<=0||n<=0?null:{x:t.xMin,y:t.yMin,width:r,height:n}}getTargetIndex(){if(this.index!==null)return this.index;const{annotations:e}=this,t=new Map,r=(n,a)=>{t.has(n)||t.set(n,a)};for(const n of e.shapes)r(n.id,{kind:"shape",annotation:n});for(const n of e.images)r(n.id,{kind:"image",annotation:n});for(const n of e.arrows)r(n.id,{kind:"arrow",annotation:n});for(const n of e.textAnnotations)r(n.id,{kind:"text",annotation:n});for(const n of e.stickers)r(n.id,{kind:"sticker",annotation:n});for(const n of e.differenceArrows)r(n.id,{kind:"differenceArrow",annotation:n});for(const n of e.pinnedNumbers)r(n.id,{kind:"pinnedNumber",annotation:n});for(const n of e.comments)r(n.id,{kind:"comment",annotation:n});return this.index=t,t}boxOf(e){const t=this.boxes.get(e);if(t!==void 0)return t;const r=this.resolvingStack.indexOf(e);if(r!==-1){for(const i of this.resolvingStack.slice(r))this.cyclic.add(i);return null}const n=this.getTargetIndex().get(e);if(n===void 0)return this.missingRefs.add(e),null;this.resolvingStack.push(e);const a=this.deriveBox(e,n);return this.resolvingStack.pop(),this.boxes.set(e,a),a}deriveBox(e,t){switch(t.kind){case"shape":case"image":{const r=this.resolveRegion(t.annotation.region);return r===null?null:zc(this.toPanelRegion(r))}case"arrow":{const r=this.resolvePoint(t.annotation.start),n=this.resolvePoint(t.annotation.end);return r===null||n===null?null:Pr(this.toPanelPoint(r),this.toPanelPoint(n))}case"text":{const r=this.resolvePoint(t.annotation.at);if(r===null)return null;const n=this.measuredBoxes?.get(e);if(n===void 0||n.height<=0||this.panelRect.height<=0)return null;const a=this.toPanelPoint(r),i=t.annotation.width,o=n.height/this.panelRect.height,s=l.alignUnitFractions(t.annotation.align),c=a.x-s.x*i,u=a.y+(1-s.y)*o;return{xMin:c,xMax:c+i,yMin:u-o,yMax:u}}case"sticker":{const r=this.resolvePoint(t.annotation.at);return r===null?null:Mr(this.toPanelPoint(r))}case"differenceArrow":return Pr(this.toPanelPoint(t.annotation.start),this.toPanelPoint(t.annotation.end));case"pinnedNumber":case"comment":return Mr(this.toPanelPoint(t.annotation.at))}}toPanelPoint(e){return m.toPanelFraction(e,this.panelRect)}toPanelRegion(e){if(e.space!=="disk")return e;const t=m.toPanelFraction(e,this.panelRect),r=m.measureAnchorSpace(e.space,this.panelRect);return{...t,width:this.panelRect.width>0?e.width*r.width/this.panelRect.width:0,height:this.panelRect.height>0?e.height*r.height/this.panelRect.height:0}}},ht=(e,t)=>({x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0}),Yc=(e,t,r)=>{if(t===void 0)return e;const n=t.x??0,a=t.y??0;if(t.unit==="px"){const{x:i,y:o}=ht({type:"px-offset",x:n,y:a},r);return{x:e.x+i,y:e.y-o}}return{x:e.x+n,y:e.y-a}},zc=e=>({xMin:e.x,xMax:e.x+e.width,yMin:e.y,yMax:e.y+e.height}),Pr=(e,t)=>({xMin:Math.min(e.x,t.x),xMax:Math.max(e.x,t.x),yMin:Math.min(e.y,t.y),yMax:Math.max(e.y,t.y)}),Mr=e=>({xMin:e.x,xMax:e.x,yMin:e.y,yMax:e.y}),Dr=e=>{const t={...e};return delete t.defer,delete t.space,t},Uc=e=>{const{annotations:t,panelRect:r,measuredBoxes:n,onCycle:a,onMissingRef:i}=e;if(!Wc(t))return t;const o=new Kc(t,r,n),s={...t,shapes:te(t.shapes,d=>d.region.defer!==void 0,d=>{const h=o.resolveRegion(d.region);return h===null?null:{...d,region:h}}),images:te(t.images,d=>d.region.defer!==void 0,d=>{const h=o.resolveRegion(d.region);return h===null?null:{...d,region:h}}),arrows:te(t.arrows,d=>d.start.defer!==void 0||d.end.defer!==void 0,d=>{const h=o.resolvePoint(d.start),p=o.resolvePoint(d.end);return h===null||p===null?null:{...d,start:h,end:p}}),textAnnotations:te(t.textAnnotations,d=>d.at.defer!==void 0,d=>{const h=o.resolvePoint(d.at);return h===null?null:{...d,at:h}}),stickers:te(t.stickers,d=>d.at.defer!==void 0,d=>{const h=o.resolvePoint(d.at);return h===null?null:{...d,at:h}})},c=o.cyclicIds();c.length>0&&a?.(c);const u=o.missingRefIds();return u.length>0&&i?.(u),s},te=(e,t,r)=>e.some(t)?e.flatMap(n=>{if(!t(n))return[n];const a=r(n);return a===null?[]:[a]}):e,Wc=e=>e.shapes.some(t=>t.region.defer!==void 0)||e.images.some(t=>t.region.defer!==void 0)||e.arrows.some(t=>t.start.defer!==void 0||t.end.defer!==void 0)||e.textAnnotations.some(t=>t.at.defer!==void 0)||e.stickers.some(t=>t.at.defer!==void 0),la=(e,t)=>{if(!(e===void 0||e.length===0||t<=0))return e.map(r=>r*t).join(" ")},Ot=e=>e===void 0||e.length===0?"solid":(e[0]??0)<=1?"dotted":"dashed",_t=(e,t)=>e===t?!0:e===void 0||t===void 0||e.length!==t.length?!1:e.every((r,n)=>r===t[n]),Xc=800,Or=400,qc=.75,jc=.875,Zc=4,Jc=e=>Math.max(1,(e-Or)/(Xc-Or)+1),Qc=(e,t)=>{const r=Jc(t),n=e*Zc;return{strokeWidth:Math.min(e,e*qc*r),arrowheadLength:Math.min(n,n*jc*r)}},Ie=Math.PI/4,eu=({start:e,end:t})=>`M ${e.x} ${e.y} L ${t.x} ${t.y}`,_r=(e,t,r)=>{if(r<=0)return"";const{start:n,end:a}=t,i=e==="start"?n.x:a.x,o=e==="start"?n.y:a.y,s=e==="start"?Math.atan2(n.y-a.y,n.x-a.x):Math.atan2(a.y-n.y,a.x-n.x);return`M ${i} ${o} L ${i-r*Math.cos(s-Ie)} ${o-r*Math.sin(s-Ie)} M ${i} ${o} L ${i-r*Math.cos(s+Ie)} ${o-r*Math.sin(s+Ie)}`},tu=64,ru=({arrow:e,style:t,panelWidth:r,panelHeight:n})=>{const a={width:r,height:n},i={start:Pe(e.start,a),end:Pe(e.end,a)};if(i.start.x===i.end.x&&i.start.y===i.end.y)return null;const{strokeWidth:o,arrowheadLength:s}=Qc(t.strokeWidth,r),c=Math.hypot(i.end.x-i.start.x,i.end.y-i.start.y),u=nu(s,c),d=e.startArrowheadStyle==="line-arrow",h=e.endArrowheadStyle==="line-arrow",p=d||h?u*Math.sin(Math.PI/4):0;return{id:e.id,linePath:eu(i),startArrowheadPath:d?_r("start",i,u):"",endArrowheadPath:h?_r("end",i,u):"",strokeWidth:o,dashArray:la(t.dashArray,o)??null,startX:i.start.x,startY:i.start.y,endX:i.end.x,endY:i.end.y,dashOffset:au(t.dashArray,o,d),arrowheadExtent:p}},nu=(e,t)=>Math.min(e,t*e/tu),au=(e,t,r)=>{const n=e[0]??0;return r&&n>1?n*t:0};function iu(e,t){const r=new Map;if(!t||t.kind!=="visual"||t.domain.length<=1)return r;for(const n of e){if(n.geom!=="rule"||n.stat.type!=="mean")continue;const a=n.transforms.find(h=>h.transformType==="filter"&&h.options.operator==="eq"),i=l.readVariableName(n.mapping.y);let o,s,c;if(a?.transformType==="filter"&&typeof a.options.value=="string")o="color",s=a.options.variableName,c=a.options.value;else if(i!==null)o="y",s=i,c=i;else continue;const u=ou(e,o,s);if(u===null)continue;const d=t.map(c);l.isStrictCategoricalDataValue(d)&&r.set(n.id,{geom:u.geom,color:d,layerId:u.id,groupValue:c})}return r}function ou(e,t,r){let n=null;for(const a of e)if(a.geom!=="rule"&&(n===null&&(n=a),l.readVariableName(a.mapping[t])===r))return a;return n}var ca=(e,t)=>({x:e.x/t.width,y:1-e.y/t.height}),su=0,lu=(e,t)=>e.filter(r=>r.inView).map(r=>({shape:{kind:"rect",rect:r.miniRect},cursor:ca(r.anchorPx,t),tooltip:{kind:"pinned",point:r.anchorPx,placement:r.placement,annotationId:r.id},priority:su})),cu=9,uu=8,du=2,ua=e=>typeof e=="string"?e:da(e),da=e=>e.text!==void 0?e.text:e.content?e.content.map(da).join(""):"",kr={top:"bottom",bottom:"top",right:"left",left:"right"};function mu(e,t,r){return r.type==="polar"?fu(e,t):r.mainAxis==="y"?["right","left","top","bottom"]:["top","bottom","right","left"]}function pt(e,t,r){const{width:n,height:a}=r;switch(t){case"top":return{x:e.x-n/2,y:e.y-9-a,width:n,height:a};case"bottom":return{x:e.x-n/2,y:e.y+9,width:n,height:a};case"right":return{x:e.x+9,y:e.y-a/2,width:n,height:a};case"left":return{x:e.x-9-n,y:e.y-a/2,width:n,height:a}}}function Vr(e,t){return e.x>=0&&e.y>=0&&e.x+e.width<=t.width&&e.y+e.height<=t.height}function hu(e,t){return{...t,x:Math.max(0,Math.min(t.x,e.width-t.width)),y:Math.max(0,Math.min(t.y,e.height-t.height))}}function pu(e,t,r=2){return e.x<t.x+t.width-r&&e.x+e.width>t.x+r&&e.y<t.y+t.height-r&&e.y+e.height>t.y+r}function fu(e,t){const r=e.x-t.width/2,n=e.y-t.height/2,a=r>=0?"right":"left",i=n>=0?"bottom":"top",[o,s]=Math.abs(r)>=Math.abs(n)?[a,i]:[i,a];return[o,kr[o],s,kr[s]]}function gu(e){const{pinnedNumbers:t,comments:r,panelRect:n,coordSystem:a,measurer:i,formatPinnedNumber:o}=e,s=[...t.map(d=>{const{id:h,at:p}=d;return Nr(h,"pinned-number",p,o(d),i,n)}),...r.map(({id:d,at:h,content:p})=>Nr(d,"comment",h,ua(p),i,n))];s.sort((d,h)=>d.anchorPx.x-h.anchorPx.x||d.anchorPx.y-h.anchorPx.y);const c=[],u=[];for(const d of s){if(!d.inView){c.push(Fr(n,d,"top"));continue}const h=Fr(n,d,yu(n,d,a,u));c.push(h),u.push(h.miniRect)}return c}function Nr(e,t,r,n,a,i){const o=Pe(r,i);return{id:e,kind:t,anchor:r,anchorPx:o,mini:a(t,e,n),inView:vu(o,i)}}function vu(e,t){return e.x>=-8&&e.y>=-8&&e.x<=t.width+8&&e.y<=t.height+8}function yu(e,t,r,n){const a=mu(t.anchorPx,e,r);for(const i of a){const o=pt(t.anchorPx,i,t.mini);if(Vr(o,e)&&!n.some(s=>pu(o,s)))return i}for(const i of a)if(Vr(pt(t.anchorPx,i,t.mini),e))return i;return"top"}function Fr(e,t,r){return{id:t.id,kind:t.kind,anchorPx:t.anchorPx,placement:r,miniRect:hu(e,pt(t.anchorPx,r,t.mini)),text:t.mini.text,inView:t.inView}}var Su=(e,t)=>Dt().hasCapability(e,t),bu=({layers:e,coordSystem:t,axes:r,numberFormat:n,parsingLocale:a,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:c,plotBottomY:u,isFooterChromeReserved:d,resolvePlacement:h=Dt()})=>{const p=[],f=c??a,g=t.type;let S=0;for(const x of e){if(!x.dataLabels.showDataLabels&&!x.dataLabels.showStackTotals&&!x.dataLabels.showCategoryLabels)continue;const A=h.resolve(x.geom,g);if(A===null)continue;const T=Wn({layer:x,coordSystem:t,axes:r,numberFormat:n,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:f,percentageValueStrategy:A.getPercentageValueStrategy(x)}),E=A.place(T);S+=E.droppedCount;for(const W of E.labels)Au(W,g,u,d)||p.push(W)}return{labels:p,warnings:S>0?[xu(S)]:[]}},xu=e=>({code:"DATA_LABELS_DROPPED",severity:"warning",kind:"user-input",message:e===1?"Dropped 1 data label that did not fit under position 'auto'.":`Dropped ${e} data labels that did not fit under position 'auto'.`,suggestion:"Set dataLabels.position to 'outside' to keep labels that do not fit inside the bars.",context:{actual:e}}),Au=(e,t,r,n)=>t==="polar"&&n&&e.position==="outside"&&e.y+e.height/2>r,Iu=(e,t,r)=>e.anchor.layerId!==t.anchor.layerId||!l.areDataValuesEqual(e.anchor.groupValue??null,t.anchor.groupValue??null)||r.start===void 0||r.start!==r.end?null:r.start,Tu=100,Lu=({items:e,containerHeight:t,labelHeight:r})=>{const n=e.map(c=>{const u=(1-c.normalizedY)*t;return{anchorY:u,y:u,payload:c.payload}}).sort((c,u)=>c.y-u.y),a=r/2;let i=!1,o=!0,s=0;for(;o;){o=!1,s++;for(let c=0;c<n.length-1;c++){const u=n[c],d=n[c+1];if(!u||!d)continue;const h=u.y+a,p=d.y-a;if(h>p){o=!0,i=!0;const f=(h-p)/2+1;u.y-=f,d.y+=f,u.y<0&&(u.y=0),d.y>t&&(d.y=t)}}if(s>Tu)break}return{placements:n.filter(c=>c.y>=0&&c.y<=t).map(c=>({y:c.y,anchorY:c.anchorY,payload:c.payload})),hasOverlap:i}},Eu=(e,t)=>ma(e,t,{variables:ha(e),allowNull:!1}),ma=(e,t,{variables:r,allowNull:n})=>{const a=m.createPredicateValueReader(e),i=[];for(const s of r){const c=a(t,s);if(c===null&&!n)return null;i.push({variable:s,eq:c})}const[o]=i;return o===void 0?null:i.length===1?o:{and:i}},ha=e=>{const t=m.shouldNarrowByGroup(e)?l.getGroupVariables(e.data,e.mapping):[],r=m.resolveCrossAnchorVariable(e),n=r===null?t:[...t,r],a=m.resolveAnchorVariable(e);return a===l.GROUP_VARIABLES.group?[...new Set(n)]:[...new Set([a,...n])]},Be=e=>e!=="data-point",Ru=(e,t)=>{switch(t){case"series":{const r=l.getGroupVariables(e.data,e.mapping);return r.length===0?Br(e):{variables:r,allowNull:!0}}case"x-value":{const r=m.readScopeXVariable(e.mapping);return r===null?null:{variables:[r],allowNull:!0}}case"data-point":return Br(e)}},Br=e=>typeof e.identityKey=="object"?{variables:[e.identityKey.variable],allowNull:!0}:e.identityKey==="index"?null:{variables:ha(e),allowNull:!1},re=[],Gr=new WeakMap,pa=(e,t,r)=>r<0||r>=e.data.size()?null:t==="data-point"?String(r):ae(e,t).keyByRow[r]??null,kt=(e,t,r)=>{if(t==="data-point"){const n=Number(r);return Number.isInteger(n)&&n>=0&&n<e.data.size()?[n]:re}return ae(e,t).rowsByKey.get(r)??re},wu=(e,t)=>ae(e,t).keyByRow,Cu=(e,t,r,n)=>{if(r!=="data-point")return kt(e,r,n);const a=Number(n);if(!Number.isInteger(a)||a<0||a>=t.data.size())return re;const i=ae(t,"vertex").keyByRow[a];return i===void 0?re:ae(e,"vertex").rowsByKey.get(i)??re},ae=(e,t)=>{const r=Gr.get(e)??new Map;Gr.set(e,r);const n=r.get(t);if(n!==void 0)return n;const a=Mu(Pu(e,t));return r.set(t,a),a},Pu=(e,t)=>{const r=e.data.size(),n=t==="x-value"?null:Hr(e,l.GROUP_VARIABLES.group),a=t==="series"?null:m.readScopeXVariable(e.mapping),i=a===null?null:Hr(e,a),o=new Array(r);for(let s=0;s<r;s++){const c=n?.[s]??null,u=i?.[s]??null;t==="series"?o[s]=l.getStableKey([c]):t==="x-value"?o[s]=l.getStableKey([u]):o[s]=l.getStableKey([c,u])}return o},Hr=(e,t)=>e.data.hasVariable(t)?e.data.getValues(t):null,Mu=e=>{const t=new Map;return e.forEach((r,n)=>{const a=t.get(r);a===void 0?t.set(r,[n]):a.push(n)}),{keyByRow:e,rowsByKey:t}},fa=({layer:e,observationIndex:t,scope:r,parsingLocale:n})=>{const a=e.data.getAt(t);if(a===null)return null;const i=Vu(e,a,r);if(i===null)return null;const o=r==="data-point"?{kind:"observations",layerId:e.id,scope:r,predicate:i,observationIndex:t}:{kind:"observations",layerId:e.id,scope:r,predicate:i};return ku(o,e,a,t,n)?o:null},Du=({layer:e,scope:t,variable:r,value:n,parsingLocale:a})=>{const i={kind:"observations",layerId:e.id,scope:_u(e,t,r),predicate:{variable:r,eq:n}};return Ou(i,e,a)?i:null},ga=e=>e.identityKey==="x-group"?"series":l.getGroupVariables(e.data,e.mapping).length===0?"data-point":"series",Ou=(e,t,r)=>{if(m.findPredicateProblems(e.predicate,t.data).length>0)return!1;const n=m.compilePredicate(e.predicate,m.createPredicateCompileContext(t,r));for(const a of t.data)if(n(a))return!0;return!1},_u=(e,t,r)=>t==="series"&&!l.getGroupVariables(e.data,e.mapping).includes(r)?"data-point":t,ku=(e,t,r,n,a)=>{if(m.findPredicateProblems(e.predicate,t.data).length>0)return!1;const i=m.compilePredicate(e.predicate,m.createPredicateCompileContext(t,a));if(i(r))return!0;if(!Be(e.scope))return!1;const o=pa(t,e.scope,n);return o===null?!1:kt(t,e.scope,o).some(s=>{const c=t.data.getAt(s);return c!==null&&i(c)})},Vu=(e,t,r)=>{const n=Ru(e,r);return n===null?null:ma(e,t,n)},Vt=(e,t)=>{if(t.kind==="circle"){const n=e.x-t.center.x,a=e.y-t.center.y;return n*n+a*a<=t.radius*t.radius}const{rect:r}=t;return e.x>=r.x&&e.x<=r.x+r.width&&e.y>=r.y&&e.y<=r.y+r.height},Nu=(e,t)=>{for(const r of t)if(Vt(e,r.shape))return r;return null},Fu=e=>{const t=[];for(const r of e.values())t.push(...r);return t.sort((r,n)=>n.priority-r.priority)},Bu=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>Gu(r,t[n])),Gu=(e,t)=>t===void 0?!1:e.priority===t.priority&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y&&Hu(e.shape,t.shape)&&$u(e.tooltip,t.tooltip),Hu=(e,t)=>{if(e.kind!==t.kind)return!1;if(e.kind==="circle"){const n=t;return e.center.x===n.center.x&&e.center.y===n.center.y&&e.radius===n.radius}const{rect:r}=t;return e.rect.x===r.x&&e.rect.y===r.y&&e.rect.width===r.width&&e.rect.height===r.height},$u=(e,t)=>{if(e.kind!==t.kind)return!1;if(e.kind==="cursor")return!0;const r=t;return e.point.x===r.point.x&&e.point.y===r.point.y&&e.placement===r.placement&&e.annotationId===r.annotationId},Ku=100,Yu=e=>({shape:{kind:"circle",center:e.center,radius:e.radius},cursor:e.target.cursor,tooltip:{kind:"cursor"},priority:Ku}),zu=(e,t)=>Vt(e,{kind:"circle",center:t.center,radius:t.radius}),Uu=(e,t)=>e===t?!0:e===null||t===null?!1:e.center.x===t.center.x&&e.center.y===t.center.y&&e.radius===t.radius&&Wu(e.target,t.target),Wu=(e,t)=>e.kind===t.kind&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y,Xu=({layer:e,highlights:t,observation:r,parsingLocale:n})=>{if(e.highlight===null)return[];const a=m.createPredicateCompileContext(e,n),i=qu(e,r);return t.filter(o=>{if(o.layerId!==void 0&&o.layerId!==e.id||m.findPredicateProblems(o.predicate,e.data).length>0)return!1;const s=m.compilePredicate(o.predicate,a);return s(r)?!0:Be(o.scope)&&i(o.scope).some(s)})},qu=(e,t)=>{const r=m.readScopeXVariable(e.mapping),n=new Map;return a=>{const i=n.get(a);if(i!==void 0)return i;const o=m.readScopeKey(a,t,r),s=[];for(const c of e.data)m.readScopeKey(a,c,r)===o&&s.push(c);return n.set(a,s),s}},Ee=({layer:e,from:t,step:r,accepts:n,excluding:a,cycles:i=!1})=>{const o=e.data.size(),s=m.createObservationAnchorBuilder(e);for(let c=0;c<o;c+=1){const u=t+c*r,d=i?ju(u,o):u;if(d<0||d>=o)break;const h=e.data.getAt(d);if(h===null||!n(h,d))continue;const p=s(h);if(p!==null&&!a.some(f=>Z(p,f)))return{anchor:p,observation:h,observationIndex:d}}return null},va=(e,t)=>{const r=m.createObservationAnchorMatcher(e);let n=0;for(const a of e.data){if(r(a,t))return n;n+=1}return-1},Z=(e,t)=>e.layerId===t.layerId&&l.areDataValuesEqual(e.anchorValue,t.anchorValue)&&l.areDataValuesEqual(e.groupValue??null,t.groupValue??null)&&l.areDataValuesEqual(e.crossValue??null,t.crossValue??null),ju=(e,t)=>(e%t+t)%t,ya=({layer:e,at:t,coordSystem:r})=>{if(r.type!=="cartesian"||e.spatialKind==="cells")return null;const n=m.resolveAnchorVariable(e),a=va(e,t),i=e.data.getAt(a);if(i===null)return null;const o=m.getGroup(i),s=p=>l.areDataValuesEqual(m.getGroup(p),o),c=[t],u=Ee({layer:e,excluding:c,from:a+1,step:1,accepts:s});if(u!==null)return{start:t,end:u.anchor};const d=Ee({layer:e,excluding:c,from:a-1,step:-1,accepts:s});if(d!==null)return{start:d.anchor,end:t};const h=Ee({layer:e,excluding:c,from:0,step:1,accepts:p=>!s(p)&&l.areDataValuesEqual(p[n]??null,t.anchorValue)});return h!==null?{start:t,end:h.anchor}:null},Zu=e=>{if(e.coordSystem.type!=="cartesian")return null;const t=e.spec.annotations.differenceArrows;for(const r of e.layers){const n=m.createObservationAnchorBuilder(r);for(const a of r.data){const i=n(a);if(i===null)continue;const o=ya({layer:r,at:i,coordSystem:e.coordSystem});if(o!==null&&!t.some(s=>Ju(s,o)))return o}}return null},Ju=(e,t)=>Z(e.start,t.start)&&Z(e.end,t.end)||Z(e.start,t.end)&&Z(e.end,t.start),Qu=(e,t)=>m.resolveGeomScaleDemands(e.layers).zeroAxes[t]!==void 0,ed=new Set(["discrete","datetime"]),Sa=e=>{const t=e.x;return t?.kind!=="position"?!1:ed.has(t.spec.scaleType)},td=({layer:e,coordSystem:t,panelSize:r,radialExtent:n="whole"})=>{const a=n==="outerEnd"&&t.type==="polar"?rd:l.readObservationBox,i=[];for(const o of e.data){const s=a(o,t);s!==null&&i.push(nd(s,r))}return i},rd=(e,t)=>{if(l.isStrictNumericDataValue(l.getXMin(e))||l.isStrictNumericDataValue(l.getXMax(e)))return l.readObservationBox(e,t);const r=l.getX(e),n=l.getYMax(e)??l.getY(e);return!l.isStrictNumericDataValue(r)||!l.isStrictNumericDataValue(n)?null:{...l.polarSectorToInscribedSquare(r,r,n,n),space:"disk"}},nd=(e,t)=>sa({x:Math.min(e.xMin,e.xMax),y:Math.min(e.yMin,e.yMax),width:Math.abs(e.xMax-e.xMin),height:Math.abs(e.yMax-e.yMin),space:e.space},t),ad=(e,t)=>{const r=e.find(a=>a.id===t.anchor.layerId);if(r===void 0)return null;const n=r.data.getAt(t.observationIndex);return n===null?null:{layer:r,observation:n}},ba=({layer:e,target:t,parsingLocale:r,host:n})=>{if(t.layerId!==(n??e).id)return[];const a=xa(e,t,r);if(a===null)return[];if(Be(t.scope))return od(e,a,t.scope);const i=Aa(e,a),o=i[id(t,i,n,r)];return o===void 0?i:[o]},id=(e,t,r,n)=>{if(e.observationIndex===void 0)return-1;if(r===void 0)return t.indexOf(e.observationIndex);const a=xa(r,e,n);return a===null?-1:Aa(r,a).indexOf(e.observationIndex)},xa=(e,t,r)=>m.findPredicateProblems(t.predicate,e.data).length>0?null:m.compilePredicate(t.predicate,m.createRowPredicateCompileContext(e,r)),Aa=(e,t)=>{const r=[];for(let n=0;n<e.data.size();n++)t(n)&&r.push(n);return r},od=(e,t,r)=>{const n=wu(e,r),a=new Set;n.forEach((o,s)=>{t(s)&&a.add(o)});const i=[];return n.forEach((o,s)=>{a.has(o)&&i.push(s)}),i},sd=["series","data-point","x-value"],ld=({layer:e,observationIndex:t,parsingLocale:r,scales:n})=>{const a=ud(ga(e)).filter(s=>s!=="x-value"||cd(n)),i=new Set,o=[];for(const s of sd){if(!a.includes(s))continue;const c=dd(e,t,s,r);if(c===null&&s==="data-point")return[];c===null||o.some(u=>md(u,c))||(o.push(c),i.add(s))}return a.filter(s=>i.has(s))},cd=e=>{const t=e.x?.domain.some(r=>r instanceof Date)===!0;return Sa(e)&&!t},ud=e=>e==="series"?["data-point","x-value","series"]:["data-point"],dd=(e,t,r,n)=>{const a=fa({layer:e,observationIndex:t,scope:r,parsingLocale:n});return a===null?null:ba({layer:e,target:a,parsingLocale:n})},md=(e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),hd=({resolver:e,layer:t,observation:r,observationIndex:n,coordSystem:a,align:i,measurement:o})=>{const s=e.resolve(t.geom,r,{coordSystem:a,position:t.position,purpose:"value",align:i});if(s===null)return null;const c=o??e.createLayerMeasurement(t);if(c===null)return null;const u=m.readObservationMeasurement(t,r,c);if(u===null)return null;const d=m.createObservationAnchorBuilder(t)(r);return d===null?null:{...s,...u,observationIndex:n,anchor:i===void 0?d:{...d,align:i}}},pd=({layer:e,from:t,partner:r,axis:n,step:a,getObservationPoint:i})=>{const o=m.resolveAnchorVariable(e),s=va(e,t),c=e.data.getAt(s);if(c===null)return null;const u=fd(c),d=n==="main"?u:f=>!u(f)&&l.areDataValuesEqual(f[o]??null,t.anchorValue),h=Ee({layer:e,excluding:[t,r],from:s+a,step:a,accepts:(f,g)=>d(f)&&i(f,g)!==null,cycles:n!=="main"});if(h===null)return null;const p=i(h.observation,h.observationIndex);return p===null?null:{...h,point:p}},fd=e=>{const t=m.getGroup(e);return r=>l.areDataValuesEqual(m.getGroup(r),t)};function gd({numberFormat:e,locale:t}){const r=new Map;return n=>{let a=r.get(n.valueFormat);return a??=I({valueFormat:n.valueFormat,locale:t,numberFormat:e}),r.set(n.valueFormat,a),a(n.measurementValue)}}var vd=({headline:e,show:t,numberFormat:r,parsingLocale:n,formattingLocale:a,t:i})=>{if(e===null)return null;const o=a??n;return e.kind==="grandTotal"?yd(e,o,r):Sd(e,t,o,r,i)},yd=(e,t,r)=>({kind:"grandTotal",value:I({valueFormat:e.valueFormat,locale:t,numberFormat:r})(e.value)}),Sd=(e,t,r,n,a)=>{const i=I({valueFormat:{type:"percentage"},locale:r,numberFormat:n}),o=e.items.length>1;return{kind:"perGroup",items:e.items.map(s=>{const c=I({valueFormat:s.valueFormat,locale:r,numberFormat:n}),u=I({valueFormat:s.groupLabelFormat,locale:r,numberFormat:n}),d=Pt({valueFormat:s.mainValueFormat,locale:r,numberFormat:n,tickValues:[]}),h=s.label??u(s.value);return{swatch:s.swatch,label:Id(t,o,h,a),value:s.aggregate===null?null:c(s.aggregate),caption:Ad(s.caption,d),comparison:bd(s.comparison,d,i,a)}})}},bd=(e,t,r,n)=>e===null?null:{direction:xd(e.variation),percentage:r(Math.abs(e.variation)),reference:n("graph.headlineMetrics.comparisonReference",{value:t(e.against)})},xd=e=>e>0?"up":e<0?"down":"flat",Ad=(e,t)=>e===null?null:e.kind==="point"?t(e.value):`${t(e.from)} – ${t(e.to)}`,Id=(e,t,r,n)=>{switch(e){case"total":return n("graph.headlineMetrics.total",{value:r});case"average":return t?n("graph.headlineMetrics.averageShort",{value:r}):n("graph.headlineMetrics.averageLong",{value:r});case"current":case"conversion":case"none":return r}},Td=({legends:e,numberFormat:t,parsingLocale:r,formattingLocale:n})=>{const a=n??r;return e.map(i=>Ld(i,a,t))},Ld=(e,t,r)=>({...e,items:e.items.map(n=>{const a=I({valueFormat:n.valueFormat,locale:t,numberFormat:r});return{...n,formattedLabel:n.label??a(n.value)}})});function Nt(e,t){return e.axes.find(r=>r.scaleAestheticKey===t)??null}function Ed(e,t){return e.legends.drawn.find(r=>r.aesthetics.includes(t))??null}var Rd=({guides:e,numberFormat:t,layer:r,locale:n})=>{const a=r.data.getFirst();if(!a)return null;const i=r.mapping.y!==void 0,o=(i?m.createYValueReader:m.createXValueReader)(r.data,r.mapping)(a);return o===null?null:I({valueFormat:Nt(e,i?l.resolveYScaleAesthetic(r.yScaleType):"x")?.valueFormat??{type:"decimal"},locale:n,numberFormat:t})(o)},Ia=.4,Ta=.18,wd=12,La=.4,Cd=(e,t)=>{const{value:r,caption:n,comparison:a,swatch:i,label:o}=e;return[{role:"value",gap:tt(t.number.fontSize,Ta),segments:rt([Te("value",r??"–"),Te("caption",n)])},{role:"trend",gap:tt(t.trend.fontSize,La),ariaLabel:a===null?void 0:Od(a),segments:rt([Md(a),Dd(a),Te("trendReference",a?.reference??null)])},{role:"group",gap:tt(t.label.fontSize,Ia),segments:rt([Pd(i,t.swatch.size),Te("label",o)])}].filter(s=>s.segments.length>0)},tt=(e,t)=>Math.round(e*t),Te=(e,t)=>t===null?null:{kind:"text",textRole:e,text:t},Pd=(e,t)=>e===null?null:{kind:"swatch",swatch:e,size:t},Md=e=>e===null?null:{kind:"trendArrow",direction:e.direction,size:12},Dd=e=>e===null?null:{kind:"text",textRole:"trendPercentage",text:e.percentage,trendDirection:e.direction},Od=e=>{switch(e.direction){case"up":return`Increased ${e.percentage} ${e.reference}`;case"down":return`Decreased ${e.percentage} ${e.reference}`;case"flat":return`No change ${e.reference}`}},rt=e=>e.filter(t=>t!==null),Ge=e=>e==="smooth"?R.curveCatmullRom:R.curveLinear,_d=(e,t)=>{const r=Ge(t.curve),n=(0,R.area)().curve(r),a=(0,R.line)().curve(r);if(e.mainAxis==="y"){const i=c=>F(l.getY(c)??0),o=c=>l.getXMin(c)??0,s=c=>l.getXMax(c)??l.getX(c)??0;n.y(i).x0(o).x1(s),a.y(i).x(s)}else{const i=c=>l.getX(c)??0,o=c=>F(l.getYMin(c)??0),s=c=>F(l.getYMax(c)??l.getY(c)??0);n.x(i).y0(o).y1(s),a.x(i).y(s)}if(t.missingValues==="gap"){const i=o=>l.getX(o)!==null&&l.getY(o)!==null;n.defined(i),a.defined(i)}return{lineGenerator:a,areaGenerator:n}},kd=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Ft={none:0,xs:2,sm:4,md:8,lg:12,xl:16},Bt=e=>{if(Ca(e)){const{width:r,height:n}=e.bounds;return(e.mainAxis==="x"?r:n)/2}const t=e.cornerRadius??"sm";return typeof t=="number"?Math.max(0,t):Ft[t]},Vd=e=>{const t=Bt(e);return Ca(e)?e.mainAxis==="x"?{rx:t}:{ry:t}:{rx:t}},Nd=e=>({outlineWidth:e*2,separatorWidth:e,insetOffset:e/2}),Ea=(e,t)=>Ra(e,{xMin:l.getXMin(t),xMax:l.getXMax(t),yMin:l.getYMin(t),yMax:l.getYMax(t),y:l.getY(t)}),Ra=(e,{xMin:t,xMax:r,yMin:n,yMax:a,y:i})=>{const o=a??i;if(t===null||r===null||n===null||o===null)return null;if(e==="x"){let u=1-o,d=o-n;return d<0&&(u+=d,d=-d),{x:t,y:u,width:r-t,height:d}}let s=t,c=r-t;return c<0&&(s+=c,c=-c),{x:s,y:1-o,width:c,height:o-n}},wa=(e,t)=>e==="x"?`${_(t.x)}-${_(t.width)}`:`${_(t.y)}-${_(t.height)}`,Fd=e=>{let t=1/0,r=1/0,n=-1/0,a=-1/0;for(const i of e)i.x<t&&(t=i.x),i.y<r&&(r=i.y),i.x+i.width>n&&(n=i.x+i.width),i.y+i.height>a&&(a=i.y+i.height);return{x:t,y:r,width:n-t,height:a-r}},Gt=(e,t,r)=>{const n=t.mainAxis==="x"?1:0,a=r[l.resolveYScaleAesthetic(e.yScaleType)];if(!a||a.kind!=="position")return n;const i=a.map(0);if(!Number.isFinite(i))return n;const o=Math.min(1,Math.max(0,i));return t.mainAxis==="x"?1-o:o},Bd=(e,t,r)=>{const n=Gt(e,t,r);return t.mainAxis==="x"?{x:0,y:n}:{x:n,y:0}},Ca=e=>e.cornerRadius==="full",Gd=e=>{const t=(0,R.line)().x(r=>l.getX(r)??0).y(r=>F(l.getY(r)??0)).curve(Ge(e.curve));return e.missingValues==="gap"&&t.defined(Pa),t},Hd=e=>{const t=(0,R.area)().x(r=>l.getX(r)??0).y0(()=>1).y1(r=>F(l.getY(r)??0)).curve(Ge(e.curve));return e.missingValues==="gap"&&t.defined(Pa),t},$d=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Pa=e=>l.getX(e)!==null&&l.getY(e)!==null,Kd=new Set(["line","rule"]),Ma=e=>Kd.has(e),Ht=(e,t,r,n)=>{const a=e.geom(t);if(Ma(t.geom))return a.get("stroke",r,n);const i=a.get("fill",r,n);return i===void 0?a.get("stroke",r,n):l.toPaintColor(i)},$t={circle:R.symbolCircle,square:R.symbolSquare,diamond:R.symbolDiamond,triangle:R.symbolTriangle,cross:R.symbolCross,star:R.symbolStar,wye:R.symbolWye},Yd=(e,t)=>{const r=t/2;return(0,R.symbol)($t[e],Math.PI*r*r)()??""},zd=(e,t,r)=>{const n=Da[e],a=Math.max(0,Math.min(t/n.width,r/n.height));return{path:(0,R.symbol)($t[e],a*a)()??"",offsetX:-n.centerX*a,offsetY:-n.centerY*a}},Ud=(e,t)=>{const r=t/2;return Da[e].outerRadius*Math.sqrt(Math.PI*r*r)},Wd=e=>{let t=1/0,r=1/0,n=-1/0,a=-1/0,i=0;const o=(u,d)=>{t=Math.min(t,u),r=Math.min(r,d),n=Math.max(n,u),a=Math.max(a,d)},s=(u,d)=>{o(u,d),i=Math.max(i,Math.hypot(u,d))},c=()=>{throw new Error("Unexpected curve in a point symbol")};return e.draw({moveTo:s,lineTo:s,rect:(u,d,h,p)=>{s(u,d),s(u+h,d),s(u+h,d+p),s(u,d+p)},arc:(u,d,h)=>{o(u-h,d-h),o(u+h,d+h),i=Math.max(i,Math.hypot(u,d)+h)},closePath:()=>{},arcTo:c,bezierCurveTo:c,quadraticCurveTo:c,ellipse:c},1),{width:n-t,height:a-r,centerX:(t+n)/2,centerY:(r+a)/2,outerRadius:i}},Da=Object.fromEntries(Object.entries($t).map(([e,t])=>[e,Wd(t)])),Oa={centerX:0,centerY:0,radius:1,digits:8},Xd=200,O=1e-12,qd=Math.PI/2,jd=(e,t)=>{if(e==="full")return Math.max(0,t)/2;const r=e??"sm";return(typeof r=="number"?Math.max(0,r):Ft[r])/Xd},_a=(e,t)=>e==="x"?`${_(t.startAngle)}-${_(t.endAngle)}`:`${_(t.innerRadius)}-${_(t.outerRadius)}`,Zd=e=>{let t=1/0,r=-1/0,n=1/0,a=-1/0;for(const i of e)t=Math.min(t,i.startAngle,i.endAngle),r=Math.max(r,i.startAngle,i.endAngle),n=Math.min(n,i.innerRadius,i.outerRadius),a=Math.max(a,i.innerRadius,i.outerRadius);return{startAngle:t,endAngle:r,innerRadius:n,outerRadius:a}},Jd=(e,t=Oa)=>{const r=im(t),n=em(e);if(!(n.outer>O))return`M${r.writePoint(0,0)}Z`;const{slice:a}=e,i=a===void 0?null:Qd(a,a.axis==="radius"?[n.inner,n.outer]:[n.start,n.end]);if(i!==void 0){if(l.isFullTurnSweep(n.start,n.end)){if(a?.axis==="angle"&&i!==null&&!l.isFullTurnSweep(i[0],i[1]))return Kr({...n,start:i[0],end:i[1]},i,r);const[o,s]=a?.axis==="radius"&&i!==null?i:[n.inner,n.outer];return rm(n.start,o,s,r)}return a?.axis==="radius"&&i!==null?tm(n,i,r):Kr(n,i??[n.start,n.end],r)}},Qd=(e,[t,r])=>{const n=Math.max(t,Math.min(e.from,e.to)),a=Math.min(r,Math.max(e.from,e.to));return a-n>0?[n,a]:void 0},em=({startAngle:e,endAngle:t,innerRadius:r,outerRadius:n,cornerRadius:a=0})=>{const i=Math.min(e,t),o=Math.max(e,t),s=Math.min(r,n),c=Math.max(r,n),u=o-i,d=Math.min((c-s)/2,a),h={start:i,end:o,inner:s,outer:c,innerCorner:null,outerCorner:null};if(!(d>O)||l.isFullTurnSweep(i,o))return h;let p=d,f=d;if(u<Math.PI){const g=(c-s)**2*Math.sin(u);if(g*g<O)return h;const S=Math.sin(u/2);p=Math.min(d,s*S/(1-S)),f=Math.min(d,c*S/(1+S))}return{...h,innerCorner:s>O&&p>O?$r(p,s+p,u):null,outerCorner:f>O?$r(f,c-f,u):null}},$r=(e,t,r)=>({radius:e,centerRadius:t,offset:Math.min(Math.asin(Math.min(1,e/t)),r/2)}),tm=(e,[t,r],n)=>{const a=Yr(e,"start"),i=Yr(e,"end"),o=c=>Me(a,c),s=c=>Me(i,c);return`M${n.writePoint(o(t),t)}`+ie(t,o(t),s(t),n)+De(i,t,r,"radius",n)+ie(r,s(r),o(r),n)+De(a,r,t,"radius",n)+"Z"},Kr=(e,[t,r],n)=>{const a=zr(e,"inner"),i=zr(e,"outer");return`M${n.writePoint(t,Me(a,t))}`+De(a,t,r,"angle",n)+`L${n.writePoint(r,Me(i,r))}`+De(i,r,t,"angle",n)+"Z"},rm=(e,t,r,n)=>{const a=`M${n.writePoint(e,r)}${ie(r,e,e-l.TAU,n)}Z`;return t>O?`${a}M${n.writePoint(e,t)}${ie(t,e,e+l.TAU,n)}Z`:a},Yr=(e,t)=>{const r=t==="start"?e.start:e.end,n=t==="start"?1:-1,a=c=>{const u=r+n*c.offset;return d=>u-n*nm(c,d)},i=e.innerCorner===null?e.inner:Ur(e.innerCorner),o=e.outerCorner===null?e.outer:Ur(e.outerCorner),s=[];return e.innerCorner!==null&&s.push({from:e.inner,to:i,at:a(e.innerCorner),corner:e.innerCorner}),s.push({from:i,to:o,at:()=>r,corner:null}),e.outerCorner!==null&&s.push({from:o,to:e.outer,at:a(e.outerCorner),corner:e.outerCorner}),s},zr=(e,t)=>{const r=t==="inner"?e.inner:e.outer,n=t==="inner"?e.innerCorner:e.outerCorner;if(n===null)return[{from:e.start,to:e.end,at:()=>r,corner:null}];const a=t==="inner"?-1:1,i=e.start+n.offset,o=e.end-n.offset,s=c=>u=>am(n,u-c,a);return[{from:e.start,to:i,at:s(i),corner:n},{from:i,to:o,at:()=>r,corner:null},{from:o,to:e.end,at:s(o),corner:n}]},Ur=e=>e.centerRadius*Math.cos(e.offset),nm=({radius:e,centerRadius:t},r)=>{if(!(r>O))return 0;const n=(t**2+r**2-e**2)/(2*t*r);return Math.acos(Math.max(-1,Math.min(1,n)))},am=({radius:e,centerRadius:t},r,n)=>{const a=t*Math.sin(r);return t*Math.cos(r)+n*Math.sqrt(Math.max(0,e**2-a**2))},Me=(e,t)=>{const r=e.find(n=>t<=n.to)??e[e.length-1];return r===void 0?0:r.at(t)},De=(e,t,r,n,a)=>{const i=r>=t,o=Math.min(t,r),s=Math.max(t,r);let c="";for(const u of i?e:[...e].reverse()){const d=Math.max(u.from,o),h=Math.min(u.to,s);if(h-d<=O)continue;const[p,f]=i?[d,h]:[h,d],g=n==="radius"?a.writePoint(u.at(f),f):a.writePoint(f,u.at(f));if(u.corner!==null){const S=a.scaleLength(u.corner.radius);c+=`A${S},${S} 0 0 0 ${g}`}else c+=n==="radius"?`L${g}`:ie(u.at(p),p,f,a)}return c},ie=(e,t,r,n)=>{if(!(e>O)||Math.abs(r-t)<=O)return"";const a=Math.max(1,Math.ceil(Math.abs(r-t)/qd-O)),i=n.scaleLength(e),o=r>t?1:0;let s="";for(let c=1;c<=a;c++)s+=`A${i},${i} 0 0 ${o} ${n.writePoint(t+(r-t)*c/a,e)}`;return s},im=({centerX:e,centerY:t,radius:r,digits:n})=>{const a=10**n,i=o=>Math.round(o*a)/a;return{writePoint:(o,s)=>{const c=l.polarToUnit(o,s);return`${i(e+c.x*r)},${i(t-c.y*r)}`},scaleLength:o=>i(o*r)}},He=(e,t,r)=>{const n=m.createXValueReader(e,t);return a=>{const i=m.getGroup(a)??"default",o=n(a);return`${r}-${i}${o!==null&&o!==""?`-${o}`:""}`}},om=(e,t,r)=>{const n=m.createXValueReader(e,t);return a=>{const i=n(a);return i===null||i===""?null:`${r}-${i}`}},sm=(e,t,r)=>{const n=m.createXValueReader(e,t),a=m.createYValueReader(e,t),i=new Map;return o=>{const s=n(o),c=a(o),u=s!==null&&s!==""&&c!==null&&c!==""?`${r}-${s}-${c}`:`${r}-cell`,d=i.get(u)??0;return i.set(u,d+1),d===0?u:`${u}#${d}`}},lm=()=>(e,t)=>l.getColor(e)??`default-${t}`,Wr=2,cm=(e,t)=>{const r=l.readVariableName(e.mapping.color);if(t!==void 0&&r!==null&&e.data.hasVariable(r)){const n=e.data.getValues(r).findIndex(a=>l.areDataValuesEqual(a,t));if(n!==-1)return e.data.getAt(n)??void 0}return e.data.getFirst()??void 0},Kt=(e,t,r,n)=>{const a=e(t),i=z(t,"line")?a.get("strokeAlpha",r):a.get("fillAlpha",r)??a.get("strokeAlpha",r),o=a.get("alpha",r)*i,s=Ma(t.geom)?void 0:um(e,t,r),c=s===void 0?{alpha:o}:{alpha:o,fill:s};if(z(t,"point"))return{...c,symbol:e.point(t).get("symbol",r)};if(!z(t,"bar"))return c;const u=n.width-Wr,d=n.height-Wr,h=Bt({cornerRadius:e.bar(t).get("cornerRadius",r),mainAxis:"x",bounds:{width:u,height:d}});return{...c,cornerRadiusPx:Math.min(h,Math.min(u,d)/2)}},um=(e,t,r)=>{const{value:n,origin:a}=e(t).explain("fill",r);if(typeof n!="object")return;const i=[...t.styles.overrides,...t.styles.defaults].find(s=>s.origin===a);if(i?.where===void 0)return n;const o=l.readVariableName(t.mapping.color);return m.readPredicateVariables(i.where).every(s=>s===o)?n:void 0};function Yt(e,t){let r=0,n=e;for(;r<n;){const a=r+n>>>1;t(a)?n=a:r=a+1}return r}function dm(e,t,r){return Yt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>t})}function mm(e,t,r){return Yt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>=t})}function zt(e,t,r,n){const a=e==="x";return{mainDistance:Math.abs(t)*(a?n:1),crossDistance:Math.abs(r)*(a?1:n)}}function Ut(e,t,r){return Math.hypot(e*r,t)}function k(e,t,r){return e<t?t-e:e>r?e-r:0}function V(e,t,{shortCircuitOnZero:r=!1}={}){let n=e[0],a=t(n);if(r&&a===0)return n;for(let i=1;i<e.length;i+=1){const o=e[i];if(o===void 0)continue;const s=t(o);if(r&&s===0)return o;s<a&&(n=o,a=s)}return n}function hm(e,t){const r=t.height,n=Math.min(t.width,t.height)/2;return{cartesian:Xr(e,r),polar:Xr(e,n)}}function ce(e,t){return e<=t.on.point}function oe({mainDistance:e,crossDistance:t},r){return e<=r.near.main&&t<=r.near.cross}function Xr({on:e,near:t},r){return{on:{edge:e.edge/r,stroke:(e.stroke??e.edge)/r,point:(e.point??e.edge)/r},near:{main:t.main/r,cross:(t.cross??t.main)/r}}}function pm(e,t,r,n,a){if(e.points.length===0)return null;const i=e.delaunay;if(!i)return null;const o=i.find(t.x*r,t.y,n??void 0),s=e.points[o];if(!s)return null;const c=ka(e,s,t,r);return a===void 0||ce(c.distance,a)||oe(c,a)?c:gm(e,t,r,a)??c}function fm(e,t){if(e.projection==="polar"||e.points.length===0||!e.delaunay||e.delaunayAspectRatio===null)return null;const r=e.delaunay.find(t.x*e.delaunayAspectRatio,t.y);return e.points[r]??null}function gm(e,t,r,n){const{mainAxis:a,byMain:i}=e,o=m.getCoordinates(a,t).main,s=a==="x"?n.near.main/r:n.near.main,c=mm(i,o-s,qr(a)),u=dm(i,o+s,qr(a));let d=null;for(let h=c;h<u;h+=1){const p=i[h];if(p===void 0)continue;const f=ka(e,p,t,r);oe(f,n)&&(d===null||f.crossDistance<d.crossDistance)&&(d=f)}return d}function qr(e){return t=>m.getCoordinates(e,t).main}function ka(e,t,r,n){const{main:a,cross:i}=m.getCoordinates(e.mainAxis,r),{main:o,cross:s}=m.getCoordinates(e.mainAxis,t);return{...zt(e.mainAxis,o-a,s-i,n),hit:{anchored:!0,layerId:e.layerId,pointIndex:t.pointIndex,observationIndex:t.observationIndex,x:t.x,y:t.y,observation:t.observation},index:e,distance:Ut(t.x-r.x,t.y-r.y,n)}}function Va(e,t){return e.buckets[vm(e,t)]??null}function vm(e,t){return Ba(e.buckets,t,r=>r.main)}function ym(e,t){return Fa(e.bands,t,r=>r.bandCenter)}function Na(e,t){return Fa(e.columns,t,r=>r.mainMid)}function Fa(e,t,r){return e[Ba(e,t,r)]??null}function Ba(e,t,r){if(e.length===0)return-1;const n=Yt(e.length,o=>{const s=e[o];return s!==void 0&&r(s)>=t}),a=e[n-1],i=e[n];return a?i&&Math.abs(r(i)-t)<Math.abs(r(a)-t)?n:n-1:n}function Sm(e,t){return{group:bm(e),related:Tm(e,t)}}function bm(e){switch(e.kind){case"buckets":{const t=e.match.index;return l.isStackedPosition(t.position)?xm(t.layerId,e.match.bucket,e.match.hit.pointIndex):[]}case"banded":{const{index:t,column:r,hit:n}=e.match;return l.isStackedPosition(t.position)?Am(t.layerId,r,n.pointIndex):Im(t.bandByColumn,t.layerId,r,n.pointIndex)}case"points":case"enclosure":case"render-hit-test":return[]}}function xm(e,t,r){const n=[];for(const a of t.entries)a.pointIndex!==r&&n.push({anchored:!0,layerId:e,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation});return n}function Am(e,t,r){const n=[];for(const a of t.rects)a.pointIndex!==r&&n.push(Wt(e,a));return n}function Im(e,t,r,n){const a=e.get(r);if(!a)return[];const i=[];for(const o of a.columns)for(const s of o.rects)s.pointIndex!==n&&i.push(Wt(t,s));return i}function Tm(e,t){const r=new Map;if(e.kind==="render-hit-test"||e.kind==="enclosure")return r;const n=e.match.index,a=n.projection==="polar";for(const i of t){if(i.layerId!==n.layerId){a||Em(r,i,e.match.hit);continue}e.kind==="buckets"&&(l.isStackedPosition(i.position)||i.kind==="buckets"&&Lm(r,i.layerId,e.match.bucket,e.match.hit.pointIndex))}return r}function Lm(e,t,r,n){for(const a of r.entries)a.pointIndex!==n&&Re(e,t).push({anchored:!0,layerId:t,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation})}function Em(e,t,r){switch(t.kind){case"buckets":{const n=Va(t,m.getMainAxisCoordinate(t.mainAxis,r));if(!n)return;const a=Re(e,t.layerId);for(const i of n.entries)a.push({anchored:!0,layerId:t.layerId,pointIndex:i.pointIndex,x:i.x,y:i.y,observation:i.observation});return}case"banded":{const n=ym(t,m.getMainAxisCoordinate(t.mainAxis,r));if(!n)return;const a=Re(e,t.layerId);for(const i of n.columns)for(const o of i.rects)a.push(Wt(t.layerId,o));return}case"points":{const n=fm(t,r);if(!n)return;Re(e,t.layerId).push({anchored:!0,layerId:t.layerId,pointIndex:n.pointIndex,observationIndex:n.observationIndex,x:n.x,y:n.y,observation:n.observation});return}case"enclosure":return;case"noop":return;case"render-hit-test":return}}function Re(e,t){let r=e.get(t);return r||(r=[],e.set(t,r)),r}function Wt(e,t){return{anchored:!0,layerId:e,pointIndex:t.pointIndex,x:(t.xMin+t.xMax)/2,y:(t.yMin+t.yMax)/2,observation:t.observation}}function Ga(e,t,r){const{columns:n,bands:a,bandByColumn:i}=Rm(e,t);return{kind:"banded",layerId:e.id,geom:e.geom,position:e.position,projection:r,mainAxis:t,columns:n,bands:a,bandByColumn:i}}function Rm(e,t){const r=Cm(e,t);r.sort((c,u)=>c.mainMid-u.mainMid);const n=new Map,a=new Map,i=new Map;for(const c of r){const u=_(c.mainMid);let d=n.get(u);if(!d){d={mainMid:c.mainMid,rects:[]},n.set(u,d);const h=_(c.bandCenter);let p=a.get(h);p||(p={bandCenter:c.bandCenter,columns:[],mainMin:1/0,mainMax:-1/0,crossMin:1/0,crossMax:-1/0},a.set(h,p)),p.columns.push(d),i.set(d,p)}d.rects.push(c.entry),wm(i.get(d),c.entry,t)}const o=[...n.values()].sort((c,u)=>c.mainMid-u.mainMid),s=[...a.values()].sort((c,u)=>c.bandCenter-u.bandCenter);for(const c of s)c.columns.sort((u,d)=>u.mainMid-d.mainMid);return{columns:o,bands:s,bandByColumn:i}}function wm(e,t,r){if(e===void 0)return;const n=r==="x",a=n?t.xMin:t.yMin,i=n?t.xMax:t.yMax,o=n?t.yMin:t.xMin,s=n?t.yMax:t.xMax;e.mainMin=Math.min(e.mainMin,a),e.mainMax=Math.max(e.mainMax,i),e.crossMin=Math.min(e.crossMin,o),e.crossMax=Math.max(e.crossMax,s)}function Cm(e,t){const r=e.data;if(r.size()===0)return[];if(!(r.hasVariable(l.POSITION_VARIABLES.xMin)&&r.hasVariable(l.POSITION_VARIABLES.xMax)&&r.hasVariable(l.POSITION_VARIABLES.yMin)&&r.hasVariable(l.POSITION_VARIABLES.yMax)))return[];const n=r.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),a=r.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),i=r.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),o=r.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),s=t==="y",c=s?l.POSITION_VARIABLES.y:l.POSITION_VARIABLES.x,u=r.hasVariable(c)?r.getValues(c,{type:"numeric"}):null,d=[];let h=0;for(const p of r){const f=n[h],g=a[h],S=i[h],x=o[h];if(!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)||!l.isDefined(x)){h++;continue}const A=s?(S+x)/2:(f+g)/2,T=u?.[h]??A;d.push({mainMid:A,bandCenter:T,entry:{pointIndex:h,xMin:Math.min(f,g),xMax:Math.max(f,g),yMin:Math.min(S,x),yMax:Math.max(S,x),observation:p}}),h++}return d}var Pm=1e-9,jr=-1;function Ha(e,t,r){const n=Mm(e,t,r),a=n.map(o=>o.entry);n.sort((o,s)=>o.main-s.main);const i=[];for(const o of n){const s=i[i.length-1];s&&Math.abs(s.main-o.main)<=Pm?s.entries.push(o.entry):i.push({main:o.main,entries:[o.entry]})}return{kind:"buckets",layerId:e.id,geom:e.geom,position:e.position,projection:r,mainAxis:t,buckets:e.spatialKind==="spanned-buckets"?i.map(o=>({...o,span:Nm(o.entries,t)})):i,entries:a}}function Mm(e,t,r){const n=e.data;if(n.size()===0)return[];const a=n.hasVariable(l.POSITION_VARIABLES.x),i=n.hasVariable(l.POSITION_VARIABLES.y);if(!a||!i)return[];const o=n.getValues(l.POSITION_VARIABLES.x,{type:"numeric"}),s=n.getValues(l.POSITION_VARIABLES.y,{type:"numeric"}),c=t==="y",u=c?l.POSITION_VARIABLES.xMin:l.POSITION_VARIABLES.yMin,d=c?l.POSITION_VARIABLES.xMax:l.POSITION_VARIABLES.yMax,h=e.spatialKind==="spanned-buckets",p=l.isStackedPosition(e.position),f=n.hasVariable(u)?n.getValues(u,{type:"numeric"}):null,g=n.hasVariable(d)?n.getValues(d,{type:"numeric"}):null,S=n.hasVariable(l.GROUP_VARIABLES.group)?n.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}):null,x=e.spatialKind==="spanned-buckets"?null:new Om(Dm(e)),A=new Map,T=[];let E=0;for(const W of n){const fe=o[E],ge=s[E],ee=S?.[E]??null,js=_m(A,ee);if(!l.isDefined(fe)||!l.isDefined(ge)){x?.skip(ee),E+=1;continue}const Zs=c?ge:fe,ve=f?.[E],gr=g?.[E],vr=p?gr:void 0;if(p&&(!l.isDefined(ve)||!l.isDefined(vr))){x?.skip(ee),E+=1;continue}const ye=vr??m.getCrossAxisCoordinate(t,{x:fe,y:ge}),yr={pointIndex:E,...c?{x:ye,y:ge}:{x:fe,y:ye},groupKey:ee,paintOrder:js,...e.spatialKind==="filled-buckets"&&l.isDefined(ve)&&{fill:km(ve,ye)},...h&&{extent:Vm(ye,ve,gr)},previousAt:jr,nextAt:jr,observation:W};x?.append(ee,{entry:yr,at:T.length}),T.push({main:Zs,entry:yr}),E+=1}return r==="polar"&&x?.close(),T}function Dm(e){return"missingValues"in e.params&&e.params.missingValues==="gap"}var Om=class{constructor(e){this.breaksAtNull=e,this.firstByGroup=new Map,this.lastByGroup=new Map,this.brokenGroups=new Set}append(e,t){const r=this.lastByGroup.get(e);r!==void 0&&(r.entry.nextAt=t.at,t.entry.previousAt=r.at),this.firstByGroup.has(e)||this.firstByGroup.set(e,t),this.lastByGroup.set(e,t)}skip(e){this.breaksAtNull&&(this.lastByGroup.delete(e),this.brokenGroups.add(e))}close(){for(const[e,t]of this.firstByGroup){const r=this.lastByGroup.get(e);r===void 0||r===t||this.brokenGroups.has(e)||(r.entry.nextAt=t.at,t.entry.previousAt=r.at)}}};function _m(e,t){const r=e.get(t);if(r!==void 0)return r;const n=e.size;return e.set(t,n),n}function km(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}}function Vm(e,t,r){if(!l.isDefined(t)&&!l.isDefined(r))return;const n=l.isDefined(t)?t:e,a=l.isDefined(r)?r:e;return{min:Math.min(n,a,e),max:Math.max(n,a,e)}}function Nm(e,t){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const a of e){const i=m.getCrossAxisCoordinate(t,a),o=a.extent?.min??i,s=a.extent?.max??i;o<r&&(r=o),s>n&&(n=s)}return{min:r,max:n}}function $a(e,t){return{kind:"enclosure",layerId:e.id,geom:e.geom,position:e.position,projection:t,cells:Fm(e,t)}}function Fm(e,t){const r=e.data;if(r.size()===0)return[];const n=[l.POSITION_VARIABLES.xMin,l.POSITION_VARIABLES.xMax,l.POSITION_VARIABLES.yMin,l.POSITION_VARIABLES.yMax];for(const h of n)if(!r.hasVariable(h))return[];const a=r.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),i=r.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),o=r.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),s=r.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),c=t==="cartesian",u=[];let d=0;for(const h of r){const p=a[d],f=i[d],g=o[d],S=s[d];if(!l.isDefined(p)||!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)){d++;continue}if(c&&!l.isTilePainted(h)){d++;continue}u.push({pointIndex:d,xMin:p,xMax:f,yMin:g,yMax:S,observation:h}),d++}return u}function ft(e){return{kind:"noop",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian"}}function Bm(e,t,r){const n=Ya(e),a={kind:"points",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",mainAxis:t,points:n,byMain:Hm(t,n),delaunay:null,delaunayAspectRatio:null};return Ka(a,r),a}function Gm(e){const t=Ya(e).map(r=>{const n=l.polarToUnit(r.x,r.y);return{...r,unitX:n.x,unitY:n.y}});return{kind:"points",layerId:e.id,geom:e.geom,position:e.position,projection:"polar",points:t}}function Ka(e,t){e.delaunay&&e.delaunayAspectRatio===t||(e.delaunay=Qs.Delaunay.from(e.points,r=>r.x*t,r=>r.y),e.delaunayAspectRatio=t)}function Hm(e,t){const r=n=>m.getMainAxisCoordinate(e,n);return[...t].sort((n,a)=>r(n)-r(a))}function Ya(e){const t=e.data;if(t.size()===0)return[];if(!t.hasVariable(l.POSITION_VARIABLES.x)||!t.hasVariable(l.POSITION_VARIABLES.y))return[];const r=t.getValues(l.POSITION_VARIABLES.x,{type:"numeric"}),n=t.getValues(l.POSITION_VARIABLES.y,{type:"numeric"}),a=[];let i=0;for(const o of t){const s=r[i],c=n[i];l.isDefined(s)&&l.isDefined(c)&&a.push({pointIndex:a.length,observationIndex:i,x:s,y:c,observation:o}),i+=1}return a}function za(e){return{kind:"render-hit-test",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",byKey:$m(e)}}function Ua(e,t){return{anchored:!1,layerId:e,pointIndex:t.pointIndex,observation:t.observation}}function $m(e){const t=e.identityKey,r=new Map;if(typeof t=="object"){let n=0;for(const a of e.data){const i=a[t.variable];l.isDefined(i)&&r.set(l.getStableKey(i),{pointIndex:n,observation:a}),n+=1}return r}if(t==="index"){let n=0;for(const a of e.data)r.set(String(n),{pointIndex:n,observation:a}),n+=1}return r}function Zr(e,t,r){return t.type==="polar"?Km(e,t.bandAxis):Ym(e,t.mainAxis,r)}function Km(e,t){switch(e.spatialKind){case"points":return Gm(e);case"buckets":case"filled-buckets":case"spanned-buckets":return Ha(e,"x","polar");case"rects":return t===null?$a(e,"polar"):Ga(e,t,"polar");case"cells":return ft(e);case"noop":return ft(e);case"render-hit-test":return za(e);default:{const r=e.spatialKind;throw new l.InternalError({message:`buildPolarLayerIndex: unhandled spatialKind ${String(r)}`})}}}function Ym(e,t,r){switch(e.spatialKind){case"points":return Bm(e,t,r);case"buckets":case"filled-buckets":case"spanned-buckets":return Ha(e,t,"cartesian");case"rects":return Ga(e,t,"cartesian");case"cells":return $a(e,"cartesian");case"noop":return ft(e);case"render-hit-test":return za(e);default:{const n=e.spatialKind;throw new l.InternalError({message:`buildCartesianLayerIndex: unhandled spatialKind ${String(n)}`})}}}function zm(e,t,r){if(e.columns.length===0)return null;const n=Na(e,m.getMainAxisCoordinate(e.mainAxis,t)),a=n?.rects??[];if(!n||!l.isNonEmptyArray(a))return null;const i=l.isStackedPosition(e.position)?Wm(a,t,e.mainAxis):Xm(a,t,r),o=Wa(i,t,r);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:i.pointIndex,x:(i.xMin+i.xMax)/2,y:(i.yMin+i.yMax)/2,observation:i.observation},index:e,column:n,distance:o,...Um(e,n,t,r)}}function Um(e,t,r,n){const a=e.bandByColumn.get(t);if(a===void 0)return{mainDistance:Number.POSITIVE_INFINITY,crossDistance:Number.POSITIVE_INFINITY};const{main:i,cross:o}=m.getCoordinates(e.mainAxis,r),s=k(i,a.mainMin,a.mainMax),c=k(o,a.crossMin,a.crossMax);return zt(e.mainAxis,s,c,n)}function Wm(e,t,r){const n=m.getCrossAxisCoordinate(r,t);return V(e,i=>qm(i,r,n),{shortCircuitOnZero:!0})}function Xm(e,t,r){return V(e,a=>Wa(a,t,r))}function Wa(e,t,r){return Ut(k(t.x,e.xMin,e.xMax),k(t.y,e.yMin,e.yMax),r)}function qm(e,t,r){return k(r,t==="x"?e.yMin:e.xMin,t==="x"?e.yMax:e.xMax)}function jm(e,t,r){const n=r.x-t.x,a=r.y-t.y,i=n*n+a*a;if(i===0)return Math.hypot(e.x-t.x,e.y-t.y);const o=((e.x-t.x)*n+(e.y-t.y)*a)/i,s=Math.max(0,Math.min(1,o));return Math.hypot(e.x-(t.x+s*n),e.y-(t.y+s*a))}function Zm(e,t,r){const{main:n,cross:a}=m.getCoordinates(e.mainAxis,t),i=Va(e,n);if(i===null)return null;const o=i.entries.map(g=>({entry:g,crossAtCursor:Qm(e,g,n)}));if(!l.isNonEmptyArray(o))return null;const s=ja(o.filter(g=>th(e,g.entry,n,a)),g=>g.entry),{entry:c}=s??V(o,g=>Math.abs(g.crossAtCursor-a)),u=Ut(c.x-t.x,c.y-t.y,r),d=g=>({x:g.x*r,y:g.y}),h=$e(e,c).map(d),p=qa(d(t),d(c),h,u),f=zt(e.mainAxis,i.main-n,Xa(i,m.getCrossAxisCoordinate(e.mainAxis,c),a),r);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:c.pointIndex,x:c.x,y:c.y,observation:c.observation},index:e,bucket:i,distance:s===void 0?u:0,vertexDistance:u,insideFill:s!==void 0,strokeDistance:s===void 0?p:0,...f}}function Jm(e,t,r){return V(e,a=>Math.abs(m.getCrossAxisCoordinate(r,a)-t))}function Xa(e,t,r){return e.span!==void 0?k(r,e.span.min,e.span.max):Math.abs(t-r)}function qa(e,t,r,n){const a=r.map(i=>jm(e,t,i));return Math.min(n,...a)}function $e(e,t){return[e.entries[t.previousAt],e.entries[t.nextAt]].filter(l.isDefined)}function ja(e,t){return e.reduce((r,n)=>r===void 0||t(n).paintOrder>t(r).paintOrder?n:r,void 0)}function Qm(e,t,r){const{mainAxis:n}=e,a=r===m.getMainAxisCoordinate(n,t)?null:Za(e,t,r);return a===null?m.getCrossAxisCoordinate(n,t):eh(t,a,n,r)}function eh(e,t,r,n){const a=m.getMainAxisCoordinate(r,e),i=(n-a)/(m.getMainAxisCoordinate(r,t)-a),o=m.getCrossAxisCoordinate(r,e);return o+(m.getCrossAxisCoordinate(r,t)-o)*i}function Za(e,t,r){const{mainAxis:n}=e,a=m.getMainAxisCoordinate(n,t),i=o=>Math.sign(m.getMainAxisCoordinate(n,o)-a)===Math.sign(r-a);return $e(e,t).find(i)??null}function th(e,t,r,n){const a=rh(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function rh(e,t,r){if(t.fill===void 0)return null;const{mainAxis:n}=e,a=m.getMainAxisCoordinate(n,t);if(r===a)return t.fill;const i=Za(e,t,r);if(i?.fill===void 0)return null;const o=(r-a)/(m.getMainAxisCoordinate(n,i)-a);return{min:t.fill.min+(i.fill.min-t.fill.min)*o,max:t.fill.max+(i.fill.max-t.fill.max)*o}}function nh(e,t){if(e.cells.length===0)return null;for(const r of e.cells)if(!(t.x<r.xMin||t.x>r.xMax)&&!(t.y<r.yMin||t.y>r.yMax))return{hit:{anchored:!0,layerId:e.layerId,pointIndex:r.pointIndex,x:(r.xMin+r.xMax)/2,y:(r.yMin+r.yMax)/2,observation:r.observation},index:e,distance:0,mainDistance:0,crossDistance:0};return null}function ah(e,t,r){if(e.columns.length===0)return null;const n=l.cursorToPolar(t,r),{angle:a,radius:i}=n,o=e.mainAxis==="x",s=o?sh(e.columns,a):Na(e,i),c=s?.rects??[];if(!s||!l.isNonEmptyArray(c))return null;const u=o?lh(c,i):ch(c,a),d=ih(u,n);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:u.pointIndex,x:(u.xMin+u.xMax)/2,y:(u.yMin+u.yMax)/2,observation:u.observation},index:e,column:s,distance:d,...oh(e,s,n)}}function ih(e,{angle:t,radius:r}){const n=Oe(t,e.xMin,e.xMax),a=k(r,e.yMin,e.yMax);return Math.hypot(n*r,a)}function Oe(e,t,r){return l.isAngleWithinArc(e,t,r)?0:Math.min(l.wrappedAngularDistance(e,t),l.wrappedAngularDistance(e,r))}function oh(e,t,{angle:r,radius:n}){const a=e.bandByColumn.get(t);return a===void 0?{mainDistance:Number.POSITIVE_INFINITY,crossDistance:Number.POSITIVE_INFINITY}:e.mainAxis==="x"?{mainDistance:Oe(r,a.mainMin,a.mainMax)*n,crossDistance:k(n,a.crossMin,a.crossMax)}:{mainDistance:k(n,a.mainMin,a.mainMax),crossDistance:Oe(r,a.crossMin,a.crossMax)*n}}function sh(e,t){return l.isNonEmptyArray(e)?V(e,r=>l.wrappedAngularDistance(t,r.mainMid)):null}function lh(e,t){return V(e,r=>k(t,r.yMin,r.yMax),{shortCircuitOnZero:!0})}function ch(e,t){return V(e,r=>Oe(t,r.xMin,r.xMax),{shortCircuitOnZero:!0})}var Jr=1e-9;function uh(e,t,r){if(e.buckets.length===0)return null;const n=l.cursorToPiePlane(t,r),{angle:a,radius:i}=l.unitToPolar(n.x,n.y),o=dh(e.buckets,a),s=o?.entries??[];if(!o||!l.isNonEmptyArray(s))return null;const c=ja(s.filter(f=>mh(e,f,a,i)),f=>f),u=c??Jm(s,i,e.mainAxis),d=Qr(u),h=Math.hypot(n.x-d.x,n.y-d.y),p=qa(n,d,$e(e,u).map(Qr),h);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:u.pointIndex,x:u.x,y:u.y,observation:u.observation},index:e,bucket:o,distance:c===void 0?h:0,vertexDistance:h,insideFill:c!==void 0,strokeDistance:c===void 0?p:0,mainDistance:l.wrappedAngularDistance(o.main,a)*i,crossDistance:Xa(o,u.y,i)}}function Qr(e){return l.polarToUnit(e.x,e.y)}function dh(e,t){return l.isNonEmptyArray(e)?V(e,r=>l.wrappedAngularDistance(r.main,t)):null}function mh(e,t,r,n){const a=hh(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function hh(e,t,r){if(t.fill===void 0)return null;const n=l.measureSignedAngularDelta(t.x,r);if(n===0)return t.fill;const a=c=>Math.sign(l.measureSignedAngularDelta(t.x,c.x))===Math.sign(n),i=$e(e,t).find(a);if(i?.fill===void 0)return null;const o=en(r,{angle:t.x,radius:t.fill.min},{angle:i.x,radius:i.fill.min}),s=en(r,{angle:t.x,radius:t.fill.max},{angle:i.x,radius:i.fill.max});return o===null||s===null?null:{min:o,max:s}}function en(e,t,r){const n=l.polarToUnit(t.angle,t.radius),a=l.polarToUnit(r.angle,r.radius),i={x:a.x-n.x,y:a.y-n.y};if(Math.hypot(i.x,i.y)<Jr)return t.radius;const o=tn(l.polarToUnit(e,1),i);return Math.abs(o)<Jr?null:tn(n,i)/o}function tn(e,t){return e.x*t.y-e.y*t.x}function ph(e,t,r,n=!1){if(e.cells.length===0)return null;const{angle:a,radius:i}=l.cursorToPolar(t,r);for(const u of e.cells)if(!(i<u.yMin||i>u.yMax)&&l.isAngleWithinArc(a,u.xMin,u.xMax))return rn(e,u,0);if(!n)return null;const o=e.cells.filter(u=>l.isAngleWithinArc(a,u.xMin,u.xMax));if(!l.isNonEmptyArray(o))return null;const s=u=>k(i,u.yMin,u.yMax),c=V(o,s);return rn(e,c,s(c))}function rn(e,t,r){return{hit:{anchored:!0,layerId:e.layerId,pointIndex:t.pointIndex,x:(t.xMin+t.xMax)/2,y:(t.yMin+t.yMax)/2,observation:t.observation},index:e,distance:r,mainDistance:0,crossDistance:r}}function fh(e,t,r,n){if(!l.isNonEmptyArray(e.points))return null;const a=l.cursorToPiePlane(t,r),i=nn(e,V(e.points,s=>Ja(s,a)),a);if(n===void 0||ce(i.distance,n)||oe(i,n))return i;const o=e.points.map(s=>nn(e,s,a)).filter(s=>oe(s,n));return l.isNonEmptyArray(o)?V(o,s=>s.crossDistance):i}function nn(e,t,r){const{angle:n,radius:a}=l.unitToPolar(r.x,r.y);return{mainDistance:l.wrappedAngularDistance(t.x,n)*a,crossDistance:Math.abs(a-t.y),hit:{anchored:!0,layerId:e.layerId,pointIndex:t.pointIndex,observationIndex:t.observationIndex,x:t.x,y:t.y,observation:t.observation},index:e,distance:Math.sqrt(Ja(t,r))}}function Ja(e,t){const r=e.unitX??l.polarToUnit(e.x,e.y).x,n=e.unitY??l.polarToUnit(e.x,e.y).y,a=r-t.x,i=n-t.y;return a*a+i*i}var gh=.05;function vh({layers:e,cursor:t,aspectRatio:r,warmStarts:n,hitTesters:a,tolerance:i}){const o={match:null,distance:Number.POSITIVE_INFINITY,paintOrder:-1},s={match:null,distance:Number.POSITIVE_INFINITY,paintOrder:-1},c={match:null,distance:Number.POSITIVE_INFINITY,paintOrder:-1};for(const[u,d]of e.entries()){if(d.kind==="render-hit-test"){const p=Th(d,t,a);if(p)return{kind:"render-hit-test",match:p};continue}if(d.projection==="polar"){const p=Ih(d,t,r,i?.polar);if(p&&!an(p,i?.polar))return p;continue}const h=Ah({layer:d,cursor:t,aspectRatio:r,warmStarts:n,tolerance:i?.cartesian});if(!(!h||an(h,i?.cartesian))){if(h.kind==="banded"||h.kind==="enclosure"){const p=h.match.distance;p<o.distance&&(o.match=h,o.distance=p,o.paintOrder=u);continue}if(h.kind==="buckets"&&h.match.insideFill){s.match=h,s.distance=0,s.paintOrder=u;continue}h.match.distance<c.distance&&(c.match=h,c.distance=h.match.distance,c.paintOrder=u)}}return Qa(c,Sh(s,o)).match}function yh(e,t){if(e.kind==="render-hit-test")return{intersects:!0,onPoint:!1};const r=bh(e,t),n=e.kind==="buckets"&&ce(e.match.vertexDistance,r);return{intersects:ei(e,r),onPoint:n}}function Sh(e,t){return e.match!==null&&t.match!==null&&e.distance===0&&t.distance===0?e.paintOrder>t.paintOrder?e:t:Qa(e,t)}function Qa(e,t){return e.match===null?t:t.match===null||e.distance<=t.distance+gh?e:t}function ei(e,t){switch(e.kind){case"banded":case"enclosure":return e.match.distance<=t.on.edge;case"buckets":return xh(e.match,t);case"points":return ce(e.match.distance,t)}}function bh(e,t){return e.match.index.projection==="polar"?t.polar:t.cartesian}function xh(e,t){return e.strokeDistance<=t.on.stroke?!0:ce(e.vertexDistance,t)}function an(e,t){return t===void 0?!1:!ei(e,t)&&!oe(e.match,t)}function Ah({layer:e,cursor:t,aspectRatio:r,warmStarts:n,tolerance:a}){switch(e.kind){case"buckets":{const i=Zm(e,t,r);return i?{kind:"buckets",match:i}:null}case"banded":{const i=zm(e,t,r);return i?{kind:"banded",match:i}:null}case"points":{const i=pm(e,t,r,n.get(e.layerId)??null,a);return i?{kind:"points",match:i}:null}case"enclosure":{const i=nh(e,t);return i?{kind:"enclosure",match:i}:null}case"noop":return null}}function Ih(e,t,r,n){switch(e.kind){case"enclosure":{const a=ph(e,t,r,n!==void 0);return a?{kind:"enclosure",match:a}:null}case"points":{const a=fh(e,t,r,n);return a?{kind:"points",match:a}:null}case"buckets":{const a=uh(e,t,r);return a?{kind:"buckets",match:a}:null}case"banded":{const a=ah(e,t,r);return a?{kind:"banded",match:a}:null}case"noop":case"render-hit-test":return null}}function Th(e,t,r){const n=r.get(e.layerId);if(!n)return null;const a=n({x:t.x,y:1-t.y});if(!a)return null;const i=e.byKey.get(a.key);return i?{hit:Ua(e.layerId,i)}:null}var N={primary:null,group:[],related:new Map},Lh=1,Eh=class{constructor({layers:e,coordSystem:t}){this.layerIndexes=[],this.layerRefs=[],this.viewport=null,this.aspectRatio=Lh,this.isAspectStale=!1,this.warmStarts=new Map,this.cachedState=N,this.cachedKey=null,this.nonInteractiveLayerIds=new Set,this.hitTesters=new Map,this.cachedByKeyId=null,this.cachedByKeyState=N,this.layerIndexes=e.map(r=>Zr(r,t,this.aspectRatio)),this.layerRefs=e.map(r=>on(r,t)),this.nonInteractiveLayerIds=sn(e)}update({layers:e,coordSystem:t}){const r=new Map;for(let i=0;i<this.layerIndexes.length;i+=1){const o=this.layerIndexes[i],s=this.layerRefs[i];!o||!s||r.set(o.layerId,{index:o,ref:s})}const n=[],a=[];for(const i of e){const o=r.get(i.id),s=on(i,t);if(o!==void 0&&wh(o.ref,s)){n.push(o.index),a.push(o.ref);continue}this.warmStarts.delete(i.id),n.push(Zr(i,t,this.aspectRatio)),a.push(s)}for(const i of this.warmStarts.keys())e.some(o=>o.id===i)||this.warmStarts.delete(i);this.layerIndexes=n,this.layerRefs=a,this.nonInteractiveLayerIds=sn(e),this.invalidateCache()}setViewport(e){if(e.width<=0||e.height<=0)return;this.viewport=e;const t=e.width/e.height;t!==this.aspectRatio&&(this.aspectRatio=t,this.isAspectStale=!0)}query(e,t,r){if(this.layerIndexes.length===0)return N;this.reindexForAspect();const n=this.nonInteractiveLayerIds.size===0?this.layerIndexes:this.layerIndexes.filter(p=>!this.nonInteractiveLayerIds.has(p.layerId)),a=r??this.viewport,i=t!==void 0&&a!==null?hm(t,a):void 0,o=vh({layers:n,aspectRatio:this.aspectRatio,warmStarts:this.warmStarts,hitTesters:this.hitTesters,cursor:e,tolerance:i});if(!o)return this.invalidateCache(),N;const s=o.match.hit;this.warmStarts.set(s.layerId,s.pointIndex);const c=i===void 0?void 0:yh(o,i),u=Rh(s,c);if(this.cachedKey===u)return this.cachedState;const{group:d,related:h}=Sm(o,n);return this.cachedKey=u,this.cachedState=c===void 0?{primary:s,group:d,related:h}:{primary:s,group:d,related:h,intersection:c},this.cachedState}registerHitTester(e,t){this.hitTesters.set(e,t)}unregisterHitTester(e){this.hitTesters.delete(e)}resolveHoverByKey(e,t){if(this.nonInteractiveLayerIds.has(e))return N;const r=this.layerIndexes.find(i=>i.layerId===e);if(!r||r.kind!=="render-hit-test")return N;const n=r.byKey.get(t);if(!n)return N;const a=`${e}:${t}`;return this.cachedByKeyId===a?this.cachedByKeyState:(this.cachedByKeyId=a,this.cachedByKeyState={primary:Ua(e,n),group:[],related:new Map},this.cachedByKeyState)}invalidateCache(){this.cachedKey=null,this.cachedState=N,this.cachedByKeyId=null,this.cachedByKeyState=N}reindexForAspect(){if(this.isAspectStale){this.isAspectStale=!1;for(const e of this.layerIndexes)e.kind==="points"&&e.projection==="cartesian"&&Ka(e,this.aspectRatio)}}};function Rh(e,t){const r=`${e.layerId}:${e.pointIndex}`;return t===void 0?r:`${r}:${t.intersects}:${t.onPoint}`}function on(e,t){return{data:e.data,geom:e.geom,position:e.position,coord:t}}function sn(e){const t=new Set;for(const r of e)r.interactive||t.add(r.id);return t}function wh(e,t){return e.data===t.data&&e.geom===t.geom&&e.position===t.position&&e.coord===t.coord}var Ch=Math.PI*2;function Ph(e,t){const r=m.getMainAxisCoordinate(e.mainAxis,t);if(e.mainAxis==="y"){const a=Y(F(r));return{x1:0,x2:"100%",y1:a,y2:a}}const n=Y(r);return{x1:n,x2:n,y1:0,y2:"100%"}}function Mh(e,t,r){const n=e.mainAxis==="y"?l.getY(r.observation):l.getX(r.observation);if(n===null)return null;const a=e.mainAxis==="y"?ri(r):ti(r),i=(t.x?.kind==="position"?t.x:null)?.bandwidth??a;if(i===null||i<=0)return null;const o=i/2;return e.mainAxis==="y"?{x:0,y:Y(F(n+o)),width:"100%",height:Y(i)}:{x:Y(n-o),y:0,width:Y(i),height:"100%"}}function Dh(e,t){if(e.bandAxis===null)return null;if(e.bandAxis==="x"){const a=l.getXMin(t.observation),i=l.getXMax(t.observation);return a===null||i===null?null:{startAngle:a,endAngle:i,innerRadius:e.innerRadius,outerRadius:1}}const r=l.getYMin(t.observation),n=l.getYMax(t.observation);return r===null||n===null?null:{startAngle:e.startAngle,endAngle:e.startAngle+Ch,innerRadius:r,outerRadius:n}}function ti(e){const t=l.getXMin(e.observation),r=l.getXMax(e.observation);return t===null||r===null?null:r-t}function ri(e){const t=l.getYMin(e.observation),r=l.getYMax(e.observation);return t===null||r===null?null:r-t}function Oh(e){return e.observationIndex??e.pointIndex}function _h(e){return e==="buckets"||e==="filled-buckets"||e==="spanned-buckets"}function kh(e){return e==="buckets"||e==="filled-buckets"}var Ke=.5,Vh=.3,Nh=.4,Fh=10,Bh=({layer:e,coordSystem:t,scales:r,options:n})=>e.data.size()===0?null:e.spatialKind==="rects"?t.type==="cartesian"?Hh(e,t,r,n):$h(e,t,n):kh(e.spatialKind)&&t.type==="cartesian"?zh(e,t,n):e.spatialKind==="cells"||e.spatialKind==="spanned-buckets"?Yh(e,n):e.spatialKind==="points"?Kh(e,n):null,Gh=e=>_h(e.spatialKind)?new Set(e.data.getValues(l.GROUP_VARIABLES.group)).size:e.data.size(),Hh=(e,t,r,n)=>({type:"grow",layerId:e.id,durationSeconds:Ke*n.durationScale,baseline:Gt(e,t,r),growAxis:t.mainAxis==="x"?"y":"x",delayByKey:n.stagger?Uh(e,t.mainAxis,n):{}}),$h=(e,t,r)=>{const n=t.bandAxis==="x"?"radius":"angle";return{type:"grow",layerId:e.id,durationSeconds:Ke*r.durationScale,growAxis:n,baseline:n==="radius"?t.innerRadius:t.startAngle,delayByKey:n==="radius"&&r.stagger?qh(e,t,r):{}}},Kh=(e,t)=>({type:"grow",layerId:e.id,durationSeconds:Ke*t.durationScale,growAxis:"size",baseline:0,delayByKey:t.stagger?Wh(e,t):{}}),Yh=(e,t)=>({type:"fade",layerId:e.id,durationSeconds:Vh*t.durationScale}),zh=(e,t,r)=>({type:"wipe",layerId:e.id,durationSeconds:Ke*r.durationScale,axis:t.mainAxis}),Uh=(e,t,r)=>{const n=He(e.data,e.mapping,e.id),a=new Map;for(const i of e.data){const o=Ea(t,i);if(!o)continue;const s=wa(t,o),c=n(i),u=a.get(s);u?u.keys.push(c):a.set(s,{position:t==="x"?o.x:o.y,keys:[c]})}return Xt([...a.values()],r)},Wh=(e,t)=>{const r=He(e.data,e.mapping,e.id),n=[];for(const a of e.data){const i=Xh(a,t.staggerOrder);i!==null&&n.push({position:i,keys:[r(a)]})}return Xt(n,t)},Xh=(e,t)=>{if(t==="main-axis")return l.getX(e);const r=l.getSize(e)??l.getX(e);return r===null?null:t==="value-descending"?-r:r},qh=(e,t,r)=>{const n=He(e.data,e.mapping,e.id),a=new Map;for(const i of e.data){const{startAngle:o,endAngle:s}=l.getAngleExtent(i),{innerRadius:c,outerRadius:u}=l.getRadiusExtent(i);if(o===null||s===null||c===null||u===null)continue;const d=_a(t.bandAxis,{startAngle:o,endAngle:s,innerRadius:c,outerRadius:u}),h=n(i),p=a.get(d);p?p.keys.push(h):a.set(d,{position:o,keys:[h]})}return Xt([...a.values()],r)},Xt=(e,t)=>{const r={};if(e.length===0)return r;const n=[...e].sort((s,c)=>s.position-c.position),a=Math.ceil(n.length/Fh),i=Math.ceil(n.length/a),o=Nh*t.durationScale/i;return n.forEach((s,c)=>{const u=Math.floor(c/a)*o;for(const d of s.keys)r[d]=u}),r},jh=(e,t,r)=>({shadow:e.get("shadow",t,r),blendMode:e.get("blendMode",t,r),...ni({saturation:e.get("saturation",t,r),brightness:e.get("brightness",t,r),contrast:e.get("contrast",t,r),blur:e.get("blur",t,r)})}),ni=e=>{const t={};return e.saturation!==void 0&&(t.saturation=e.saturation),e.brightness!==void 0&&(t.brightness=e.brightness),e.contrast!==void 0&&(t.contrast=e.contrast),e.blur!==void 0&&(t.blur=e.blur),t},q=["top","right","bottom","left"],ln={top:"topLeft",right:"topRight",bottom:"bottomRight",left:"bottomLeft"},Zh={top:"topRight",right:"bottomRight",bottom:"bottomLeft",left:"topLeft"},Jh={topLeft:["left","top"],topRight:["top","right"],bottomRight:["right","bottom"],bottomLeft:["bottom","left"]},Qh=(e,t)=>{const{edges:r,cornerRadius:n}=e,a=Math.max(0,Math.min(n,t.width/2,t.height/2)),i=c=>{const[u,d]=Jh[c];return a>0&&r[u].strokeWidth>0&&r[d].strokeWidth>0},o=tp(t,a),s=rp(t,a,i);return np(r).map(c=>({dashArray:r[c.firstEdge].dashArray,strokeWidth:r[c.firstEdge].strokeWidth,stroke:r[c.firstEdge].stroke,segments:ap(c,o,s,i)}))},ep=e=>({top:e.edges.top.strokeWidth,right:e.edges.right.strokeWidth,bottom:e.edges.bottom.strokeWidth,left:e.edges.left.strokeWidth}),tp=(e,t)=>{const{x:r,y:n,width:a,height:i}=e;return{topLeft:{cx:r+t,cy:n+t,startAngle:Math.PI,endAngle:Math.PI*1.5,radius:t},topRight:{cx:r+a-t,cy:n+t,startAngle:Math.PI*1.5,endAngle:Math.PI*2,radius:t},bottomRight:{cx:r+a-t,cy:n+i-t,startAngle:0,endAngle:Math.PI*.5,radius:t},bottomLeft:{cx:r+t,cy:n+i-t,startAngle:Math.PI*.5,endAngle:Math.PI,radius:t}}},rp=(e,t,r)=>{const{x:n,y:a,width:i,height:o}=e,s=c=>r(c)?t:0;return{top:{start:{x:n+s("topLeft"),y:a},end:{x:n+i-s("topRight"),y:a}},right:{start:{x:n+i,y:a+s("topRight")},end:{x:n+i,y:a+o-s("bottomRight")}},bottom:{start:{x:n+i-s("bottomRight"),y:a+o},end:{x:n+s("bottomLeft"),y:a+o}},left:{start:{x:n,y:a+o-s("bottomLeft")},end:{x:n,y:a+s("topLeft")}}}},np=e=>{const t=o=>e[o].strokeWidth>0,r=(o,s)=>{const c=(q.indexOf(o)+s+q.length)%q.length;return q[c]},n=o=>{const s=r(o,-1);return!t(s)||!_t(e[s].dashArray,e[o].dashArray)||e[s].strokeWidth!==e[o].strokeWidth||e[s].stroke!==e[o].stroke},a=q.filter(t);if(a.length===0)return[];const i=a.filter(n);return i.length===0?[{firstEdge:"top",edges:[...q],isClosed:!0}]:i.map(o=>{const s=[o];for(let c=r(o,1);t(c)&&!n(c);c=r(c,1))s.push(c);return{firstEdge:o,edges:s,isClosed:!1}})},ap=(e,t,r,n)=>{const a=(h,p,f)=>({type:"arc",cx:h.cx,cy:h.cy,radius:h.radius,startAngle:p,endAngle:f}),i=h=>(h.startAngle+h.endAngle)/2,o=[],s=e.firstEdge,c=e.edges[e.edges.length-1],u=ln[s];if(!e.isClosed&&n(u)){const h=t[u],p=i(h),f=ip(h,p);o.push({type:"move",x:f.x,y:f.y}),o.push(a(h,p,h.endAngle))}else o.push({type:"move",x:r[s].start.x,y:r[s].start.y});o.push({type:"line",x:r[s].end.x,y:r[s].end.y});for(const h of e.edges.slice(1)){const p=ln[h];if(n(p)){const f=t[p];o.push(a(f,f.startAngle,f.endAngle))}o.push({type:"line",x:r[h].end.x,y:r[h].end.y})}const d=Zh[c];if(e.isClosed){if(n(d)){const h=t[d];o.push(a(h,h.startAngle,h.endAngle))}o.push({type:"close"})}else if(n(d)){const h=t[d];o.push(a(h,h.startAngle,i(h)))}return o},ip=(e,t)=>({x:e.cx+e.radius*Math.cos(t),y:e.cy+e.radius*Math.sin(t)}),op=/^(?:https?:|mailto:)/i,sp=e=>{if(typeof e!="string")return!1;const t=e.replace(/^[\x00-\x20]+/,"");return t.length===0?!1:op.test(t)},lp=({locale:e,intlOptions:t})=>{const r=C(e,{day:"numeric",month:"long",year:"numeric",weekday:"long",...w,...t});return L(n=>r.format(n))},cp=({locale:e,intlOptions:t})=>L(r=>C(e,{day:"2-digit",month:"short",year:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit",second:r.getUTCSeconds()!==0?"2-digit":void 0,...w,...t}).format(r)),_e=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return kn(e);case"date":return lp(e);case"datetime":return cp(e);case"day_month":return Bn(e);case"decimal":return Vn(e);case"duration":return At(e);case"integer":return Nn(e);case"month":return Gn(e);case"month_year":return Lt(e);case"percentage":return Fn(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return Kn(e);case"weekly_date_range":return Hn(e);case"weekly_date_range_with_year":return $n(e);case"year":return Rt(e);case"lookup":return _e({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},ai={width:12,height:12},up=({layers:e,coordSystem:t,scales:r,guides:n,numberFormat:a,parsingLocale:i,hover:o,readers:s,formattingLocale:c,comments:u,activeCalloutId:d})=>{const{primary:h}=o;if(h===null)return null;const p=c??i,f=mp(u,d);return{heading:f===null?hp({layers:e,coordSystem:t,guides:n,primary:h,locale:p,numberFormat:a}):null,rows:pp({layers:e,scales:r,guides:n,hover:o,locale:p,numberFormat:a,readers:s}),comment:f}},dp=(e,t,r)=>{if(z(t,"line"))return e.geom.line(t).get("dashArray",r);if(z(t,"area"))return e.geom.area(t).get("dashArray",r);if(z(t,"rule"))return e.geom.rule(t).get("dashArray",r)};function mp(e,t){return e===void 0||t===null||t===void 0?null:e.find(r=>r.id===t)?.content??null}function hp(e){if(e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null)return null;const t=Nt(e.guides,"x");if(!t)return null;const r=e.layers.find(i=>i.id===e.primary.layerId);if(!r)return null;const n=l.readVariableName(r.mapping.x);if(!l.isDefined(n))return null;const a=e.primary.observation[n];return l.isDefined(a)?_e({valueFormat:t.valueFormat,locale:e.locale,numberFormat:e.numberFormat})(a):null}function pp(e){const t=[],r=e.scales.color??null,n=yp({guides:e.guides,locale:e.locale,numberFormat:e.numberFormat});for(const a of e.layers){const i=gp(a,e.hover);if(i.length===0)continue;const o=i[0];if(a.tooltip.length>0&&o){t.push(...fp(a,o,e.guides,e.readers,{locale:e.locale,numberFormat:e.numberFormat}));continue}const s=m.createColorValueReader(a.data,a.mapping),c=vp(i,a,r,s),u=Mt({layer:a,numberFormat:e.numberFormat,locale:e.locale}),d=Sp(e.guides,a),h=m.createSegmentYReader(a),p=a.mapping.color!==void 0;for(const f of c){const g=p?s(f.observation):null,S=Ht(e.readers,a,f.observation)??null,x=Ot(dp(e.readers,a,f.observation)),A=Kt(e.readers.geom,a,f.observation,ai),T=p&&g!==null?n(g):d,E=h(f.observation),W=E===null?"":u(E,f.observation);t.push({swatchColor:S,geom:a.geom,swatchLineType:x,swatchFill:A.fill,swatchAlpha:A.alpha,swatchCornerRadius:A.cornerRadiusPx,swatchSymbol:A.symbol,label:T,value:W,isPrimary:f===e.hover.primary,key:`${f.layerId}:${f.pointIndex}`})}}return t}function fp(e,t,r,n,a){const i=Kt(n.geom,e,t.observation,ai);return e.tooltip.map(o=>{const s=e.mapping[o.aes],c=l.readVariableName(s),u=m.createRawValueReader(e.data,s)(t.observation),d=I({valueFormat:m.getLayerVariableValueFormat(e,c),locale:a.locale,numberFormat:a.numberFormat});return{swatchColor:o.aes==="color"?Ht(n,e,t.observation)??null:null,geom:e.geom,swatchLineType:"solid",swatchFill:i.fill,swatchAlpha:i.alpha,swatchCornerRadius:i.cornerRadiusPx,swatchSymbol:i.symbol,label:o.key??m.resolveVariableLabel(c,r.variableLabels)??"",value:u===null?"":d(u,t.observation),isPrimary:!1,key:`${t.layerId}:${t.pointIndex}:${o.aes}`}})}function gp(e,t){const r=[];return t.primary!==null&&t.primary.layerId===e.id&&r.push(t.primary,...t.group),r.push(...t.related.get(e.id)??[]),r}function vp(e,t,r,n){if(r===null||t.mapping.color===void 0)return e;const a=new Map;return r.domain.forEach((i,o)=>{a.set(l.getStableKey(i),o)}),e.map((i,o)=>{const s=n(i.observation),c=s===null?null:l.getStableKey(s);return{hit:i,originalIndex:o,rank:c===null?Number.POSITIVE_INFINITY:a.get(c)??Number.POSITIVE_INFINITY}}).sort((i,o)=>i.rank===o.rank?i.originalIndex-o.originalIndex:i.rank-o.rank).map(i=>i.hit)}function yp({guides:e,locale:t,numberFormat:r}){const n=new Map(e.colorGroups.map(i=>[l.getStableKey(i.value),{label:i.label,format:_e({valueFormat:i.valueFormat,locale:t,numberFormat:r})}])),a=_e({valueFormat:{type:"text"},locale:t,numberFormat:r});return i=>{const o=n.get(l.getStableKey(i));return o===void 0?a(i):o.label??o.format(i)}}function Sp(e,t){return m.resolveVariableLabel(l.readVariableName(t.mapping.y),e.variableLabels)??""}function bp(e,t,r=0){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:r}function xp(e,t,r=""){const n=e[t];return typeof n=="string"?n:r}var Ap=(e,t)=>({...e.annotation.arrow(t).resolve(),outline:e.annotation.arrow.outline(t).resolve()}),Ip=(e,t)=>{const r=e.annotation.differenceArrow(t);return{...r.resolve(),isStrokeAuthored:r.getSource("stroke")==="authored",label:e.annotation.differenceArrow.label(t).resolve()}},Tp=(e,t,r)=>{const n=e.annotation[t](r),a=e.annotation[t].label(r);return{marker:{...n.resolve(),isFillAuthored:n.getSource("fill")==="authored"},label:{...a.resolve(),isTextColorAuthored:a.getSource("textColor")==="authored"}}},Lp=e=>e.strokeWidth>0?e.stroke??l.toPaintColor(e.fill):void 0,Ep=e=>({edges:{top:e.panelBorder.top().resolve(),right:e.panelBorder.right().resolve(),bottom:e.panelBorder.bottom().resolve(),left:e.panelBorder.left().resolve()},cornerRadius:e.panelBorder().get("cornerRadius")}),Rp=e=>({...l.DEFAULT_GRAPH_PADDING_EDGES_PX,...e.graph().get("padding")}),P=e=>{let t={top:0,right:0,bottom:0,left:0};for(const r of e.collectAll("margin"))t={...t,...r};return t},wp=e=>({header:P(e.header()),footer:P(e.footer()),headline:P(e.headline()),legend:{top:P(e.legend.top()),right:P(e.legend.right()),bottom:P(e.legend.bottom()),left:P(e.legend.left())},axisLabel:{top:P(e.axisLabel.top("x")),bottom:P(e.axisLabel.bottom("x"))},tickLabel:{top:P(e.tickLabel.top("x")),right:P(e.tickLabel.right("y")),bottom:P(e.tickLabel.bottom("x")),left:P(e.tickLabel.left("y"))}}),Cp=e=>({hover:e.editOutline.hover().resolve(),selected:e.editOutline.selected().resolve()}),cn=new WeakMap,Pp=e=>{const t=n=>e(n),r=un(t,n=>a=>e(a,n));return un(t,()=>r)},Mp=(e,t,r)=>{const n=hn(e.graph,dn(l.STYLE_TARGETS.graph,{}),r),a=pn(n,n,l.STYLE_TARGETS.graph.vocabulary),i=(s,c)=>s===l.STYLE_TARGETS.graph?a:pn(hn(e[s.select.target],dn(s,c),r),a,s.vocabulary),o=s=>{const c=Object.fromEntries(Object.entries(s.children??{}).map(([d,h])=>[d,o(h)]));if((s.options??[]).includes("annotation"))return Object.assign(_p(d=>i(s,{annotation:d})),c);if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&Dp(s)){const d=new Map;return Object.assign(h=>{const p=d.get(h);if(p!==void 0)return p;const f=i(s,{axis:h});return d.set(h,f),f},c)}const u=i(s,{});return Object.assign(()=>u,c)};return Object.fromEntries(Object.entries(l.STYLE_TARGETS).map(([s,c])=>[s,s==="geom"?t:o(c)]))},un=(e,t)=>{const r=new Map;return new Proxy(e,{get:(n,a,i)=>{if(typeof a!="string"||a in n)return Reflect.get(n,a,i);const o=r.get(a);if(o!==void 0)return o;const s=t(a);return r.set(a,s),s}})},Dp=e=>{const t=l.findStyleTarget({target:e.select.target})??e;return Object.values(t.children??{}).some(r=>r.select.axis!==void 0)},dn=(e,t)=>{const r=l.findStyleTarget({target:e.select.target})??e,n=t.axis!==void 0?{...e.select,axis:t.axis}:e.select,a=r.partWildcard!==!0;return i=>{const o=i.select;if(o.target!==n.target)return!1;for(const s of l.STYLE_SELECT_KEYS){const c=n[s],u=o[s];if(s==="part"&&a){if(u!==c)return!1;continue}if(c===void 0){if(u!==void 0)return!1}else if(u!==void 0&&u!==c)return!1}if(t.annotation!==void 0){const s="annotation"in i.select?i.select.annotation:void 0;if(s!==void 0&&s!==t.annotation)return!1}return!0}},mn=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){const a=e[n];if(!(a===void 0||!r(a))&&a.declarations[t]!==void 0)return a}},hn=(e,t,r)=>{const n=c=>mn(e.overrides,c,t)??mn(e.defaults,c,t);return{get:c=>{const u=n(c)?.declarations[c];if(u!==void 0)return l.resolveColorScheme(u,r)},getSource:c=>{const u=n(c);return u===void 0?"unresolved":u.origin.list==="builtin"?"builtin":"authored"},explain:c=>{const u=n(c),d=u?.declarations[c];return u===void 0||d===void 0?{value:void 0,source:"unresolved"}:{value:l.resolveColorScheme(d,r),source:u.origin.list==="builtin"?"builtin":"authored",origin:u.origin,select:u.select}},collectAll:c=>{const u=[];for(const d of[e.defaults,e.overrides])for(const h of d){if(!t(h))continue;const p=h.declarations[c];p!==void 0&&u.push(l.resolveColorScheme(p,r))}return u}}},Op=(e,t,r)=>{const n=t.get("textScale");e.fontSize!==void 0&&n!==void 0&&(e.fontSize*=n),"fontFamily"in r&&(e.fontFamily??=t.get("fontFamily"))},pn=(e,t,r)=>({...e,resolve:()=>{const n=cn.get(e);if(n!==void 0)return n;const a={};for(const i of Object.keys(r)){const o=e.get(i);o!==void 0&&Object.assign(a,{[i]:o})}return Op(a,t,r),cn.set(e,a),a}}),_p=e=>{const t=new Map;return r=>{const n=t.get(r);if(n!==void 0)return n;const a=e(r);return t.set(r,a),a}},kp={color:l.getColor,alpha:l.getAlpha,strokeWidth:l.getStrokeWidth,lineType:l.getLineType,size:l.getSize},fn={vocabulary:{},aesthetics:{}},gn=new WeakMap,Vp=(e={})=>{const t=e.colorScheme??"light",r=new WeakMap,n=new WeakMap,a=(c,u)=>{let d=r.get(c);d===void 0&&(d=new Map,r.set(c,d));const h=d.get(u);if(h!==void 0)return h;const{vocabulary:p,aesthetics:f}=Np(c.styles,u),g=Hp({styles:Gp(c.styles,u),colorScheme:t,vocabulary:p,visualVariableReaders:Fp(f,c.styles.dashPresets),findPart:S=>i(c,S)});return d.set(u,g),g},i=(c,u)=>Object.hasOwn(c.styles.parts,u)?a(c,u):void 0,o=Pp(a);return{readers:c=>{const u=n.get(c.chrome);if(u!==void 0)return u;const d=Mp(c.chrome,o,t);return n.set(c.chrome,d),d}}},Np=(e,t)=>t===void 0?e.observation:Object.hasOwn(e.parts,t)?e.parts[t]??fn:fn,Fp=(e,t)=>{const r={};for(const[n,a]of Object.entries(e)){const i=a===void 0?void 0:kp[a];i!==void 0&&(r[n]=a==="lineType"?Bp(t):i)}return r},Bp=e=>t=>{const r=l.getLineType(t);return r===void 0?void 0:e[r]},Gp=(e,t)=>{let r=gn.get(e);r===void 0&&(r=new Map,gn.set(e,r));const n=r.get(t);if(n!==void 0)return n;const a={defaults:vn(e.defaults,t),overrides:vn(e.overrides,t)};return r.set(t,a),a},vn=(e,t)=>{const r={};for(const n of e)if(n.part===t)for(const a of Object.keys(n.declarations)){if(n.declarations[a]===void 0)continue;const i=r[a]??={};(i[n.state??"stateless"]??=[]).push(n)}return r},Hp=({styles:e,colorScheme:t,vocabulary:r,visualVariableReaders:n,findPart:a})=>{const i=(h,p)=>{const f=n[h];if(!(f===void 0||p===void 0))return f(p)??void 0},o=(h,p,f)=>{if(f!==void 0){const A=K(e.overrides,h,p,f);if(A!==void 0)return{value:j(A,h,t),tier:"override",origin:A.origin,state:f};const T=K(e.defaults,h,p,f);if(T!==void 0)return{value:j(T,h,t),tier:"default",origin:T.origin,state:f}}const g=K(e.overrides,h,p,void 0);if(g!==void 0)return{value:j(g,h,t),tier:"override",origin:g.origin};const S=i(h,p);if(S!==void 0)return{value:S,tier:"data"};const x=K(e.defaults,h,p,void 0);return x!==void 0?{value:j(x,h,t),tier:"default",origin:x.origin}:{value:void 0,tier:"unresolved"}},s=(h,p,f)=>{if(f!==void 0){const x=Le(e.overrides,h,p,f,t);if(x!==void 0)return x;const A=Le(e.defaults,h,p,f,t);if(A!==void 0)return A}const g=Le(e.overrides,h,p,void 0,t);if(g!==void 0)return g;const S=i(h,p);return S!==void 0?S:Le(e.defaults,h,p,void 0,t)};return{get:s,getSource:(h,p,f)=>o(h,p,f).tier,explain:o,collectAll:(h,p,f)=>{const g=[];for(const S of[e.defaults,e.overrides]){const x=S[h]?.[f??"stateless"];if(x!==void 0)for(const A of x){const T=A.declarations[h];T!==void 0&&ii(A,p)&&g.push(l.resolveColorScheme(T,t))}}return g},resolve:(h,p)=>{const f={};for(const g of Object.keys(r)){const S=s(g,h,p);S!==void 0&&Object.assign(f,{[g]:S})}return f},resolveState:(h,p)=>{const f={};for(const g of Object.keys(r)){const S=K(e.overrides,g,p,h)??K(e.defaults,g,p,h),x=j(S,g,t);x!==void 0&&Object.assign(f,{[g]:x})}return f},part:a}},Le=(e,t,r,n,a)=>j(K(e,t,r,n),t,a),j=(e,t,r)=>{const n=e?.declarations[t];return n===void 0?void 0:l.resolveColorScheme(n,r)},K=(e,t,r,n)=>{const a=e[t]?.[n??"stateless"];if(a!==void 0)for(let i=a.length-1;i>=0;i--){const o=a[i];if(o!==void 0&&ii(o,r))return o}},ii=(e,t)=>e.matches===void 0?!0:t!==void 0&&e.matches(t),qt=["sticker","pinnedNumber","comment","image"],$p=e=>qt.includes(e),jt=e=>{switch(e.kind){case"pinnedNumber":case"comment":return e.annotation.at;case"sticker":return e.annotation.at.anchorType==="observation"?Yp(e.annotation.at):null;default:return null}},oi=(e,t)=>e.layerId===t.layerId&&l.areDataValuesEqual(e.anchorValue,t.anchorValue)&&l.areDataValuesEqual(e.groupValue??null,t.groupValue??null)&&l.areDataValuesEqual(e.crossValue??null,t.crossValue??null),si=(e,t,r=Kp)=>{const n=r(t);for(const a of qt){const i=m.readAnnotationBucket(e,a),o=i.findIndex(c=>{const u=jt({kind:a,annotation:c});if(u===null)return!1;const d=r(u);return oi(d,n)}),s=i[o];if(s!==void 0)return{kind:a,index:o,annotation:s}}return null},Kp=e=>({...e,anchorValue:nt(e.anchorValue),...e.groupValue!==void 0&&{groupValue:nt(e.groupValue)},...e.crossValue!==void 0&&{crossValue:nt(e.crossValue)}}),nt=e=>l.readISOInstant(e)??e,Yp=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),li=(e,t)=>ke(e)===ke(t),ke=e=>JSON.stringify(Zt(e)),Zt=e=>{const t=e;return typeof t!="object"||t===null?["invalid",String(t)]:"and"in e?["and",...yn(e.and)]:"or"in e?["or",...yn(e.or)]:"not"in e?["not",Zt(e.not)]:[e.variable,...zp(e)]},zp=e=>{if("eq"in e)return["eq",l.readDataValueKey(e.eq)];if("oneOf"in e)return["oneOf",...Sn(e.oneOf)];if("lt"in e)return["lt",l.readDataValueKey(e.lt)];if("lte"in e)return["lte",l.readDataValueKey(e.lte)];if("gt"in e)return["gt",l.readDataValueKey(e.gt)];if("gte"in e)return["gte",l.readDataValueKey(e.gte)];if("range"in e)return["range",...Sn(e.range)];const t=Object.entries(e).sort(([r],[n])=>r.localeCompare(n));return["invalid",JSON.stringify(t)]},yn=e=>Array.isArray(e)?e.map(Zt):["invalid",JSON.stringify(e)],Sn=e=>Array.isArray(e)?e.map(l.readDataValueKey):["invalid",JSON.stringify(e)],Up=(e,t)=>e.find(r=>r.scope===t.scope&&r.layerId===t.layerId&&li(r.predicate,t.predicate))??null,ci=e=>e.find(t=>t.geom==="rule"&&t.stat.type==="identity"&&(l.isStrictNumericDataValue(l.readConstantValue(t.mapping.y))||l.isStrictNumericDataValue(l.readConstantValue(t.mapping.x)))),ui=e=>e.find(t=>t.geom==="line"&&t.stat.type==="smooth"),di=e=>e.find(t=>t.geom==="rule"&&t.stat.type==="mean");function mi(e){return{mapping:e.mapping,layers:e.layers,scales:e.scales.map(Wp),transforms:e.transforms,highlights:e.highlights,styles:b.styles(e.styles),annotations:e.annotations,coords:e.coords,config:e.config}}function Wp(e){const{inferredFrom:t,...r}=e;return r.scaleType==="palette"?Xp(r):r}function Xp(e){return{...e,palette:qp(e.palette),overrides:jp(e.overrides)}}function qp(e){return e.type==="custom"?{type:"custom",id:e.id}:e}function jp(e){if(!e)return;const t={};for(const[r,n]of Object.entries(e))t[Number(r)]={hex:n};return t}var ue=(e,t)=>{const r=Jt(e,t);return r===-1?void 0:e[r]},Jt=(e,t)=>{const r=se(t);for(let n=e.length-1;n>=0;n-=1){const a=e[n];if(a!==void 0&&se(a)===r)return n}return-1},hi=(e,t)=>se(e)===se(t),se=e=>{const t=Object.entries(e.select).filter(([,n])=>n!==void 0).sort(([n],[a])=>n.localeCompare(a)),r=e.when?.where===void 0?null:ke(e.when.where);return JSON.stringify([t,e.when?.state??null,r])},pi=(e,t)=>[...new Set([...Object.keys(e),...Object.keys(t)])].every(r=>Zp(e[r],t[r])),U=(e,t)=>({select:{target:"geom",kind:e,layer:t}}),Qt=e=>e.select.target==="geom",de=(e,t)=>{const r=ue(e,t);if(!(r===void 0||!Qt(r)))return r.declarations},Zp=(e,t)=>e===t?!0:l.isLightDarkColor(e)?l.isLightDarkColor(t)&&e.light===t.light&&e.dark===t.dark:l.isStyleTokenRef(e)?l.isStyleTokenRef(t)&&e.token===t.token:!1;function y(e){return{id:e.id??m.uniqueId(),timestamp:e.timestamp??Date.now(),description:e.description,author:e.author??"unknown"}}function Q(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((r,n)=>Q(r,t[n]));if(l.isPlainObject(e)&&l.isPlainObject(t)){const r=Object.keys(e).filter(a=>e[a]!==void 0),n=Object.keys(t).filter(a=>t[a]!==void 0);return r.length===n.length&&r.every(a=>Q(e[a],t[a]))}return!1}var er=class{constructor(e,t={}){this.type="remove-annotation",this.params=e,this.metadata=y({...t,description:"Remove annotation"})}get target(){return{kind:"annotation",id:this.params.id}}apply(e){const t=m.findAnnotation(e.annotations,this.params.id);if(!t)return null;const{kind:r,index:n,annotation:a}=t;return{spec:m.patchSpec(e,{annotations:m.removeLocatedAnnotation(e.annotations,t)}),revert:new tr({kind:r,annotation:a,index:n},this.metadata)}}},Jp={type:"remove-annotation",deserialize:(e,t)=>new er(e,t)},tr=class fi{constructor(t,r={}){this.type="add-annotation",this.params={kind:t.kind,annotation:{...t.annotation,id:t.annotation.id??m.uniqueId()},...t.index!==void 0&&{index:t.index}},this.metadata=y({...r,description:"Add annotation"})}get target(){return{kind:"annotation",id:this.params.annotation.id}}apply(t){const{kind:r,annotation:n,index:a}=this.params;if(!m.isAnnotationKind(r)||m.findAnnotation(t.annotations,n.id))return null;const i=ef(t.annotations,{kind:r,annotation:n}),o=i===null?t.annotations:m.removeLocatedAnnotation(t.annotations,i),s=m.readAnnotationBucket(o,r),c=a??s.length,u=Math.min(Math.max(c,0),s.length);return{spec:m.patchSpec(t,{annotations:m.replaceAnnotationBucket(o,r,[...s.slice(0,u),n,...s.slice(u)])}),revert:i===null?new er({id:n.id},this.metadata):new fi({kind:i.kind,annotation:i.annotation,index:i.index},this.metadata)}}},Qp={type:"add-annotation",deserialize:(e,t)=>new tr({kind:e.kind,annotation:e.annotation,index:e.index},t)},ef=(e,t)=>{const r=jt(t);return r===null?null:si(e,r)},tf=(e,t)=>{const r=rr(e);return r===null?null:gi(r.points,t)},rf=e=>rr(e)!==null,nf=(e,t)=>{const r=rr(e);if(r===null)return null;const n=gi(r.points,t);return n.x===0&&n.y===0?null:r.createPatch(n)},rr=e=>{const t=of[e.kind];return t===null?null:t(e.annotation)},bn=(e,t)=>e.anchorType!=="panel"?null:{points:[gt(e,e.offset)],createPatch:r=>t({...e,x:e.x+r.x,y:e.y+r.y})},xn=(e,t)=>e.anchorType!=="panel"?null:{points:[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y+e.height}],createPatch:r=>t({...e,x:e.x+r.x,y:e.y+r.y})},af=(e,t)=>e.anchorType!=="panel"||t.anchorType!=="panel"?null:{points:[gt(e,e.offset),gt(t,t.offset)],createPatch:r=>({start:{...e,x:e.x+r.x,y:e.y+r.y},end:{...t,x:t.x+r.x,y:t.y+r.y}})},of={text:e=>bn(e.at,t=>({at:t})),sticker:e=>bn(e.at,t=>({at:t})),shape:e=>xn(e.region,t=>({region:t})),image:e=>xn(e.region,t=>({region:t})),arrow:e=>af(e.start,e.end),differenceArrow:null,pinnedNumber:null,comment:null},gt=(e,t)=>t===void 0||t.unit==="px"?{x:e.x,y:e.y}:{x:e.x+(t.x??0),y:e.y+(t.y??0)},gi=(e,t)=>({x:An(e.map(r=>r.x),t.x),y:An(e.map(r=>r.y),t.y)}),An=(e,t)=>{if(!Number.isFinite(t))return 0;const r=Math.min(-Math.min(...e),0),n=Math.max(1-Math.max(...e),0);return!Number.isFinite(r)||!Number.isFinite(n)?0:(0,ne.default)(t,r,n)},vi=(e,t,r)=>{const n=t.annotation;if(!cf(n,r))return null;const a=m.readAnnotationBucket(e.annotations,t.kind),i=sf(t.annotation,r),o=[...a.slice(0,t.index),i,...a.slice(t.index+1)];return{spec:m.patchSpec(e,{annotations:m.replaceAnnotationBucket(e.annotations,t.kind,o)}),inverse:lf(n,r)}},sf=(e,t)=>{const r=new Set(Object.entries(t).filter(([,n])=>n===void 0).map(([n])=>n));return Object.fromEntries(Object.entries({...e,...t}).filter(([n])=>!r.has(n)))},lf=(e,t)=>{const r={};for(const n of Object.keys(t))r[n]=e[n];return r},cf=(e,t)=>Object.entries(t).some(([r,n])=>!Object.is(e[r],n)),nr=class yi{constructor(t,r={}){this.type="update-annotation",this.params=t,this.metadata=y({...r,description:"Update annotation"})}get target(){return{kind:"annotation",id:this.params.id}}apply(t){const{kind:r,id:n,patch:a}=this.params,i=m.findAnnotation(t.annotations,n);if(i===null||i.kind!==r)return null;const o=vi(t,i,a);return o===null?null:{spec:o.spec,revert:new yi({kind:r,id:n,patch:o.inverse},this.metadata)}}},uf={type:"update-annotation",deserialize:(e,t)=>new nr(e,t)},Si=class{constructor(e,t={}){this.type="move-annotation",this.params={id:e.id,translation:{x:e.translation.x,y:e.translation.y}},this.metadata=y({...t,description:"Move annotation"})}get target(){return{kind:"annotation",id:this.params.id}}apply(e){const t=m.findAnnotation(e.annotations,this.params.id);if(t===null)return null;const r=nf(t,this.params.translation);if(r===null)return null;const n=vi(e,t,r);return n===null?null:{spec:n.spec,revert:new nr({kind:t.kind,id:t.annotation.id,patch:n.inverse},this.metadata)}}},df={type:"move-annotation",deserialize:(e,t)=>new Si(e,t)},H=class we{constructor(t,r={}){this.type="set-style-rule",this.params=t,this.metadata=y({...r,description:t.rule.declarations===null?"Remove style rule":"Set style rule"})}get target(){const{list:t,rule:r}=this.params;return{kind:"styleRule",list:t,select:r.select,...r.when===void 0?{}:{when:r.when}}}apply(t){const{list:r,rule:n,index:a}=this.params,i=t.styles[r],o=Jt(i,n),s=o===-1?void 0:i[o],{declarations:c}=n;if(c===null){if(s===void 0)return null;const g=new we({list:r,rule:s,index:o},this.metadata),S=i.filter(x=>!hi(x,n));return{spec:at(t,r,S),revert:g}}if(s!==void 0){if(pi(s.declarations,c))return null;const g={...s,declarations:c},S=new we({list:r,rule:s,index:o},this.metadata),x=i.map(A=>A===s?g:A);return{spec:at(t,r,x),revert:S}}const u=a??i.length,d=Math.min(Math.max(u,0),i.length),h={...n,declarations:c},p=[...i.slice(0,d),h,...i.slice(d)],f=new we({list:r,rule:{...n,declarations:null}},this.metadata);return{spec:at(t,r,p),revert:f}}},mf=e=>{const{rule:t}=e;if(t==null)throw new l.UserInputError({code:"INVALID_STYLE_RULE",message:"Command 'set-style-rule' is missing its 'rule'.",suggestion:"Send the entry's 'select' (and 'when') with 'declarations: null' to remove it."})},hf={type:"set-style-rule",deserialize:(e,t)=>(mf(e),new H(e,t))},at=(e,t,r)=>m.patchSpec(e,{styles:{...e.styles,[t]:r}}),pf={type:"set-difference-arrow-style",deserialize:(e,t)=>new bi(e,t)},bi=class xi{constructor(t,r={}){this.type="set-difference-arrow-style",this.params=t,this.metadata=y({...r,description:"Set difference arrow style"})}get target(){return{kind:"annotation",id:this.params.annotationId}}apply(t){const{annotationId:r,arrow:n,label:a}=this.params,i={target:"annotation",kind:"differenceArrow",annotation:r},o={...i,part:"label"};let s=t;const c={annotationId:r},u=d=>{const h=ue(s.styles.overrides,d),p=new H({list:"overrides",rule:d}).apply(s);if(p)return s=p.spec,h?.declarations??null};if(n!==void 0){const d=u({select:i,declarations:n});d!==void 0&&(c.arrow=d)}if(a!==void 0){const d=u({select:o,declarations:a});d!==void 0&&(c.label=d)}return s===t?null:{spec:s,revert:new xi(c,this.metadata)}}},ff=["cartesian","polar","flip"],M=new l.GeomRegistry,Ai=e=>M.has(e)?M.get(e):null,Ye=e=>m.applyReplayableTransforms(e.data,e.transforms);function ar(e,t){const r=t.some(i=>i.yScaleType==="secondary"),n=e.find(i=>i.scaledAesthetic==="ySecondary");if(!r)return n===void 0?e:e.filter(i=>i!==n);if(n!==void 0)return e;const a=e.find(i=>i.scaledAesthetic==="y");return a===void 0?e:[...e,{...a,scaledAesthetic:"ySecondary"}]}function ze(e,t){return e.scales.find(r=>r.scaledAesthetic===t)}function Ue(e,t,r){const n=e.scales.findIndex(a=>a.scaledAesthetic===t);return n===-1?e:m.patchSpec(e,{scales:m.replaceAtIndex(e.scales,n,r)})}function We(e){const t=e.replace(/([A-Z])/g," $1").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function vt(e,t,r){const n=m.resolveScale(m.createScaleContext(m.createCommonContainer(M),{data:Ye(e),layers:e.layers,mapping:r,customPalettes:{}}),l.inferred(t));return e.coords.coordType==="polar"?m.removeDiscreteScalePadding(n):n}var Ii=class Ti{constructor(t,r={}){this.type="set-chart-type",this.target={kind:"coords"},this.params=t,this.metadata=y({...r,description:Rf(t)})}apply(t){const r="previous"in this.params?this.params.previous:wf(t,this.params);if(r===null)return null;const n=m.patchSpec(t,r);return n===t?null:{spec:n,revert:new Ti({previous:{coords:t.coords,layers:t.layers,scales:t.scales,mapping:t.mapping}},this.metadata)}}},gf={type:"set-chart-type",deserialize:(e,t)=>new Ii(e,t)},Li={type:"sum"},vf={type:"identity"},yf=["bar","line","area","point","tile"],ir="tile",Sf=["y","color"],bf=Object.values(l.LAYER_LABEL_VARIABLES),xf={coordType:"cartesian",geom:ir,position:"identity"},me=e=>e.coordType==="cartesian"&&"comboType"in e&&b.COMBO_TYPES.includes(e.comboType),Af=e=>{const t=e.layers.filter(B),[r]=t;if(r===void 0)return null;const{coords:n}=e;if(n.coordType==="cartesian"){const o=Ri(t);if(o!==null)return{coordType:"cartesian",comboType:o}}if(!t.every(o=>o.geom===r.geom&&o.position===r.position))return null;const{geom:a,position:i}=r;return n.coordType==="polar"?{coordType:"polar",geom:a,position:i,theta:n.params.theta,innerRadius:n.params.innerRadius}:{coordType:n.coordType,geom:a,position:i}},If=e=>{if(!e)return!1;const t=e.layers.filter(B);if(t.length>=2)return!0;const[r]=t;return r===void 0?!1:wi(e,r)?Ci(e,r).length>=1:Xe(e,e.data.groupVariableNamesByType().numeric).length>=2},Tf=e=>e?ki(e,xf)!==null:!1,Lf=e=>Ei(e)?.at(-1)?.id??null,Ei=e=>{if(e.coords.coordType!=="cartesian")return null;const t=e.layers.filter(B);return Ri(t)===null?null:t},Ri=e=>{const t=e.at(-1);if(e.length<2||t?.geom!=="line")return null;const r=e.slice(0,-1);if(r.every(a=>a.geom==="line"))return Ef(e)?"lines":null;if(!r.every(a=>a.geom==="bar"))return null;const[n]=r;return n===void 0||!r.every(a=>a.position===n.position)?null:b.readComboTypeOfBarPosition(n.position)},Ef=e=>e.some(t=>t.yScaleType==="secondary"||Ve(t))||new Set(e.map(t=>l.readVariableName(t.mapping.y))).size>1,Rf=e=>"previous"in e?"Restore the previous chart type":me(e)?`Set chart type to a ${e.comboType} combo`:`Set chart type to ${e.position} ${e.geom} in ${e.coordType} coords`,wf=(e,t)=>{const r=ki(e,t);if(r===null)return null;const n=me(t)?Pf(r,t):Cf(r,t,e);return n===null||r===e?n:{...n,scales:Kf({...e,...n},n.scales)}},Cf=(e,t,r)=>{if(me(t)||!Yf(t))return null;const n={...e,layers:$i(e.layers)},a=Wf(n.layers.filter(B),t),i=Yi(n.coords,t),o=Oi(n,t),s=Hi({...n,mapping:o},t,a,o!==n.mapping);return{coords:i,layers:s,scales:ar(zi(r,s,i.coordType),s),mapping:o}},Pf=(e,t)=>{const r=Of(e,t.comboType);if(r===null)return null;const n={...e,layers:r},a=Xf(r.filter(B),t.comboType),i=Yi(n.coords,t),o=Oi(n,t),s=Hi({...n,mapping:o},t,a,o!==n.mapping),c=Mf(e)?s:Df(s);return{coords:i,layers:c,scales:ar(zi(e,c,i.coordType),c),mapping:o}},Mf=e=>Ei(e)!==null,Df=e=>{const t=e.filter(B).at(-1);return t===void 0||t.yScaleType==="secondary"?e:e.map(r=>r.id===t.id?{...r,yScaleType:"secondary"}:r)},Of=(e,t)=>{const r=e.layers.filter(B);if(r.length>=2)return e.layers;const[n]=r;return n===void 0?null:wi(e,n)?_f(e,n):kf(e,n,t)},wi=(e,t)=>{const r=l.readVariableName(t.mapping.color??e.mapping.color);return r!==null&&r!==""},_f=(e,t)=>{const[r]=Ci(e,t);if(r===void 0)return null;const n=m.resolveLayer(M,e.mapping,e.coords.coordType,{type:"layer",id:Pi(r,new Set(e.layers.map(a=>a.id))),geom:"line",stat:Li,...Di(r,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(a=>a.id===t.id?[a,n]:[a])},Xe=(e,t)=>{const r=he(e);return t.filter(n=>n!==r)},Ci=(e,t)=>{const r=l.readVariableName(t.mapping.y??e.mapping.y);return Xe(e,e.data.groupVariableNamesByType().numeric).filter(n=>n!==r)},he=e=>l.readMainAxisVariable(e.mapping)||l.inferXVariable(e.data),kf=(e,t,r)=>{const{numeric:n}=e.data.groupVariableNamesByType(),a=Xe(e,n),i=a.at(-1);if(a.length<2||i===void 0)return null;const o=l.readFoldKeepVariables(e.data,he(e)),s=b.COMBO_BAR_POSITIONS[r]===null?l.LAYER_LABEL_VARIABLES.line:l.LAYER_LABEL_VARIABLES.bar,c=Vf(t,In(a.slice(0,-1),o,s)),u=m.resolveLayer(M,e.mapping,e.coords.coordType,{type:"layer",id:Pi(i,new Set(e.layers.map(d=>d.id))),geom:"line",stat:t.stat,...In([i],o,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(d=>d.id===t.id?[c,u]:[d])},Pi=(e,t)=>{const r=`line:${e}`;let n=r;for(let a=2;t.has(n);a+=1)n=`${r}:${a}`;return n},In=(e,t,r)=>{const[n]=e;return e.length===1&&n!==void 0?Di(n,r):Mi(e,t)},Mi=(e,t)=>({mapping:{y:l.DEFAULT_RESHAPE_VALUE_NAME,color:"key"},transforms:[b.transform.reshape({keep:t,reshape:e,keyName:"key",valueName:l.DEFAULT_RESHAPE_VALUE_NAME})]}),Di=(e,t)=>({mapping:{y:e,color:t},transforms:[b.transform.constant({variableName:t,type:"categorical",value:e})]}),Vf=(e,t)=>({...e,mapping:{...e.mapping,...t.mapping},transforms:[...e.transforms,...t.transforms]}),Oi=(e,t)=>{const r=l.readMainAxisVariable(e.mapping),n=_i(t)?"":he(e);return n===r?e.mapping:{...e.mapping,x:n}},_i=e=>e.coordType==="polar"&&e.theta==="y"&&e.position==="fill",Nf=e=>!me(e)&&e.geom===ir,Ff=e=>e.layers.filter(B).some(t=>t.geom===ir),ki=(e,t)=>{const r=Nf(t);return r===Ff(e)?e:r?Bf({...e,layers:$i(e.layers)}):Gf(e)??e},Bf=e=>{const t=Ni(e);if(t===null)return null;const r=Hf(e,t)===null?$f(e,t):Fi(e,t);return r===null?null:Vi(e,t,r)},Gf=e=>{const t=Ni(e);if(t===null)return null;const r=Fi(e,t);return r===null?null:Vi(e,t,r)},Vi=(e,t,r)=>({...e,mapping:r.mapping,layers:e.layers.map(n=>n===t?r.layer:n)}),Ni=e=>{const t=e.layers.filter(B);return t.length===1?t[0]??null:null},Fi=(e,t)=>{const r={...e.mapping,...t.mapping};return r.y===void 0||r.color===void 0?null:{mapping:{...e.mapping,y:r.color,color:r.y},layer:Bi(t)}},Bi=e=>{if(e.mapping.y===void 0&&e.mapping.color===void 0)return e;const{y:t,color:r,...n}=e.mapping;return{...e,mapping:n}},Hf=(e,t)=>{const r={...e.mapping,...t.mapping},n=l.readVariableName(r.color),a=l.readVariableName(r.y);if(n===null||n===""||a===null||a===""||n===he(e))return null;const i=Ye(e);return i.hasVariable(n)&&i.getType(n)==="numeric"?null:n},$f=(e,t)=>{const r=Xe(e,e.data.groupVariableNamesByType().numeric);if(r.length<2)return null;const n=l.readFoldKeepVariables(e.data,he(e)),a=Mi(r,n),i=Bi(t);return{mapping:{...e.mapping,y:a.mapping.color,color:a.mapping.y},layer:{...i,transforms:[...i.transforms,...a.transforms]}}},Kf=(e,t)=>Sf.reduce((r,n)=>{const a=vt(e,n,e.mapping);return r.some(i=>i.scaledAesthetic===n)?m.mapItems(r,i=>i.scaledAesthetic===n?a:i):[...r,a]},t),Yf=e=>ff.includes(e.coordType)&&Gi(e.geom)&&zf(e)&&(e.coordType!=="polar"||Number.isFinite(e.innerRadius)),zf=({geom:e,coordType:t,position:r})=>{const{supportedCoordTypes:n,supportedPositions:a}=M.get(e);return n.includes(t)&&a.includes(r)},Gi=e=>yf.includes(e),B=e=>Gi(e.geom)&&!Uf(e.stat),Uf=e=>{switch(e.type){case"smooth":return!0;case"identity":case"count":case"mean":case"sum":return!1;default:return!0}},Wf=(e,{geom:t,position:r})=>{const n={geom:t,position:r};return new Map(e.map(a=>[a.id,n]))},Xf=(e,t)=>{const r={geom:"line",position:"identity"},n=b.COMBO_BAR_POSITIONS[t],a=e.map((i,o)=>n===null||o===e.length-1?[i.id,r]:[i.id,{geom:"bar",position:qf(i,t,n)}]);return new Map(a)},qf=(e,t,r)=>e.geom!=="bar"||Ve(e)?r:b.readComboTypeOfBarPosition(e.position)===t?e.position:r,Hi=(e,t,r,n)=>{const a=e.coords.coordType!==t.coordType;return m.clampValuesAgainstFillSiblings(M,m.mapItems(e.layers,i=>{const o=r.get(i.id);if(o===void 0)return i;const s=jf(i.stat,e.coords,t);return a||n||i.geom!==o.geom||i.position!==o.position||s!==i.stat?Jf(e,{...i,stat:s},t.coordType,o):i}))},jf=(e,t,r)=>_i(r)?e.type==="identity"?Li:e:Zf(t)&&e.type==="sum"?vf:e,Zf=e=>e.coordType==="polar"&&e.params.theta==="y",Jf=(e,t,r,{geom:n,position:a})=>{const i={geom:t.geom===n,coordType:e.coords.coordType===r,position:t.position===a},{labelSource:o,format:s,offset:c,justify:u,...d}=t.dataLabels;return{...m.resolveLayer(M,e.mapping,r,{type:"layer",id:t.id,geom:n,mapping:t.mapping,stat:t.stat,position:a,params:i.geom?t.params:void 0,yScaleType:t.yScaleType,transforms:t.transforms,interactive:t.interactive,dataLabels:{...d,...i.coordType&&{format:s},...i.geom&&i.coordType&&{offset:c},...i.geom&&i.position&&{justify:u}}}),stat:t.stat}},$i=e=>{const t=e.filter(B);if(t.length<2||!e.some(Ve))return e;const[r]=t;return e.flatMap(n=>n===r?[Qf(n)]:Ve(n)?[]:[n])},Ve=e=>Ki(e)!==null,Ki=e=>{const t=e.transforms.at(-1);return t?.transformType==="reshape"?t.options.keyName==="key"?t:null:t?.transformType!=="constant"?null:bf.includes(t.options.variableName)?t:null},Qf=e=>{const t=Ki(e);if(t===null)return e;const{color:r,...n}=e.mapping,a=t.transformType==="reshape"?t.options.reshape?.[0]:void 0;return{...e,mapping:a===void 0?n:{...n,y:a},transforms:e.transforms.slice(0,-1)}},Yi=(e,t)=>{const r=eg(e,t);return(0,Ce.default)(r,e)?e:r},eg=(e,t)=>{const r={xLimits:e.params.xLimits,yLimits:e.params.yLimits};if(t.coordType!=="polar")return m.resolveCoord({type:"coord",coordType:t.coordType,params:r});const n=e.coordType==="polar"?e.params:m.POLAR_COORD_DEFAULTS;return m.resolveCoord({type:"coord",coordType:"polar",params:{...r,theta:t.theta,startAngle:n.startAngle,innerRadius:t.innerRadius}})},zi=(e,t,r)=>{const n=m.resolveGeomScaleDemands(m.readGeomScaleConstraints(M,t)),a=m.resolveGeomScaleDemands(m.readGeomScaleConstraints(M,e.layers)),i=e.coords.coordType==="polar";return m.mapItems(e.scales,o=>{const s=tg(o,n,a),c=rg(s,n,a);return ag(c,r,i)})},tg=(e,t,r)=>{if(e.scaleType==="discrete"){const a=t.bandPadding[e.scaledAesthetic];return a===void 0||e.padding===a?e:{...e,padding:a}}if(e.scaledAesthetic===t.discreteAxis)return m.resolveDiscreteScale(l.discrete(e.scaledAesthetic,{..."reverse"in e&&{reverse:e.reverse}}),t);if(e.scaledAesthetic===t.discreteCrossAxis)return m.resolveDiscreteScale(l.discrete(e.scaledAesthetic),t);const n=t.zeroAxes[e.scaledAesthetic];if(n!==void 0&&e.scaleType==="continuous"){const a=r.zeroAxes[e.scaledAesthetic],i=ng(e.nice,n,a),o=a===void 0?null:e.domainMin;return e.nice===i&&e.domainMin===o?e:{...e,nice:i,domainMin:o}}return e},rg=(e,t,r)=>{if(e.scaleType!=="discrete"||!l.isPositionScale(e.scaledAesthetic))return e;const n=t.bandPadding[e.scaledAesthetic];if(n===r.bandPadding[e.scaledAesthetic])return e;const a=n??l.DISCRETE_SCALE_DEFAULTS.padding;return e.padding===a?e:{...e,padding:a}},ng=(e,t,r)=>t.nice===(r?.nice??!0)?e:t.nice?l.CONTINUOUS_SCALE_DEFAULTS.nice:!1,ag=(e,t,r)=>{if(e.scaleType!=="discrete"||!l.isPositionScale(e.scaledAesthetic))return e;if(t==="polar")return e.padding===0?e:{...e,padding:0};if(!r)return e;const{padding:n}=l.DISCRETE_SCALE_DEFAULTS;return e.padding===n?e:{...e,padding:n}},Ui=class Wi{constructor(t,r={}){this.type="set-mapping",this.params=t,this.target={kind:"mapping",aesthetic:t.aesthetic},this.metadata=y({...r,description:og(t)})}apply(t){const r="previous"in this.params?this.params.previous:sg(t,this.params);if(r===null)return null;const n=m.patchSpec(t,r);return n===t?null:{spec:n,revert:new Wi({aesthetic:this.params.aesthetic,previous:{mapping:t.mapping,scales:t.scales,layers:t.layers}},this.metadata)}}},ig={type:"set-mapping",deserialize:(e,t)=>new Ui(e,t)},Xi=(e,t)=>{const r=l.readVariableName(e[t]);return r===null||r===""||l.isInternalVariable(r)?null:r},qi=e=>e===""?null:e,og=e=>{if("previous"in e)return`Restore the previous ${e.aesthetic} mapping`;const t=qi(e.variable);return t===null?`Clear the ${e.aesthetic} mapping`:`Map ${e.aesthetic} to ${t}`},sg=(e,{aesthetic:t,variable:r})=>{if(!b.isAestheticKey(t))return null;const n=qi(r),a=cg(e.mapping,t,n);return a===e.mapping?null:{mapping:a,scales:dg(e,t,a,n),layers:lg(e.layers,a)}},lg=(e,t)=>m.mapItems(e,r=>{const n={...t,...r.mapping};if(n.label===void 0&&Ai(r.geom)===null)return r;const a=m.resolveLabelSource(M,r.geom,r.position,n);return(0,Ce.default)(a,r.dataLabels.labelSource)?r:{...r,dataLabels:{...r.dataLabels,labelSource:a}}}),cg=(e,t,r)=>r===null?ug(e,t):Xi(e,t)===r?e:{...e,[t]:r},ug=(e,t)=>{if(t==="x")return l.readMainAxisVariable(e)===""?e:{...e,x:""};const r=e[t];if(r===void 0||l.readVariableName(r)==="")return e;const n={};for(const[a,i]of Object.entries(e))a!==t&&(n[a]=i);return n},dg=(e,t,r,n)=>{if(!l.isScaledAestheticKey(t))return e.scales;let a=e.scales;for(const i of mg(e,t))a=pg(e,a,i,r,n);return a},mg=(e,t)=>t==="y"&&hg(e.layers)?["y","ySecondary"]:[t],hg=e=>{const t=e.find(r=>r.yScaleType==="secondary");return t!==void 0&&t.mapping.y===void 0},pg=(e,t,r,n,a)=>{const i=t.find(s=>s.scaledAesthetic===r);if(i===void 0)return a===null?t:[...t,vt(e,r,n)];if(a===null&&!l.isPositionScale(r)||a!==null&&!Ye(e).hasVariable(a))return t;const o=vt(e,r,n);return fg(i,o)?t:m.mapItems(t,s=>s.scaledAesthetic===r?o:s)},fg=(e,t)=>e.scaleType===t.scaleType||Tn(e)&&Tn(t),Tn=e=>e.scaleType==="discrete"||e.scaleType==="palette",or=e=>e==="both"?["x","y"]:[e],ji=e=>e==="both"?"the":`${e} axis`;function sr(e,t){return pe(e)?e[t]:e}function gg(e,t){return e.config.axes[t]??{}}function vg(e,t,r){if(t!=="ySecondary")return m.updateSpec(e,{config:{axes:{[t]:r}}});const n=e.config.axes.ySecondary,a=Zi(n,r);if(a===n)return e;const i={...e.config.axes,ySecondary:a};return a===void 0&&delete i.ySecondary,m.patchSpec(e,{config:m.patchSpec(e.config,{axes:i})})}function pe(e){return l.isPlainObject(e)&&"x"in e&&"y"in e}function Zi(e,t){const r={};let n=!1;for(const a of new Set([...Object.keys(e??{}),...Object.keys(t)])){const i=e?.[a],o=a in t?yg(i,t[a]):i;o!==i&&(n=!0),o!==void 0&&(r[a]=o)}return n?Object.keys(r).length>0?r:void 0:e}function yg(e,t){return l.isPlainObject(t)?Zi(l.isPlainObject(e)?e:void 0,t):t}var Ji=class Qi{constructor(t,r={}){this.type="set-axis-label",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis label to ${bg(t.label)}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,label:n}=this.params,a=gg(t,r).label;if(a===n)return null;const i=vg(t,r,{label:n});return i===t?null:{spec:i,revert:new Qi(r==="ySecondary"?{axis:r,label:a}:{axis:r,label:a??null},this.metadata)}}},Sg={type:"set-axis-label",deserialize:(e,t)=>new Ji(e,t)};function bg(e){return e===void 0?"(inherited)":e??"(none)"}var eo=class to{constructor(t,r={}){this.type="set-axis-position",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis position to ${t.position}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,position:n}=this.params,a=t.config.axes[r].position;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{position:n}}}}),revert:new to({axis:r,position:a},this.metadata)}}},xg={type:"set-axis-position",deserialize:(e,t)=>new eo(e,t)},ro=class no{constructor(t,r={}){this.type="set-axis-tick-mode",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis tick mode to ${t.tickMode}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,tickMode:n}=this.params,a=t.config.axes[r].ticks.mode;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{ticks:{mode:n}}}}}),revert:new no({axis:r,tickMode:a},this.metadata)}}},Ag={type:"set-axis-tick-mode",deserialize:(e,t)=>new ro(e,t)},ao=class io{constructor(t,r={}){this.type="set-axis-ticks-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis ticks visibility to ${t.isVisible}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,isVisible:n}=this.params,a=t.config.axes[r].ticks.isVisible;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{ticks:{isVisible:n}}}}}),revert:new io({axis:r,isVisible:a},this.metadata)}}},Ig={type:"set-axis-ticks-visibility",deserialize:(e,t)=>new ao(e,t)},oo=class so{constructor(t,r={}){this.type="set-axis-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis visibility to ${t.isVisible}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,isVisible:n}=this.params,a=t.config.axes[r].isVisible;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{isVisible:n}}}}),revert:new so({axis:r,isVisible:a},this.metadata)}}},Tg={type:"set-axis-visibility",deserialize:(e,t)=>new oo(e,t)},lo=class co{constructor(t,r={}){this.type="set-content-caption",this.target={kind:"content",part:"caption"},this.params=t,this.metadata=y({...r,description:"Set chart caption"})}apply(t){const r=t.config.content.caption;return r===this.params.caption?null:{spec:m.updateSpec(t,{config:{content:{caption:this.params.caption}}}),revert:new co({caption:r},this.metadata)}}},Lg={type:"set-content-caption",deserialize:(e,t)=>new lo(e,t)},uo=class mo{constructor(t,r={}){this.type="set-content-source",this.target={kind:"content",part:"source"},this.params=t,this.metadata=y({...r,description:`Set content source to ${t.source?.label??t.source?.url??"(none)"}`})}apply(t){const r=t.config.content.source;if(Q(r,this.params.source))return null;const n=m.patchSpec(t.config.content,{source:this.params.source});return{spec:m.patchSpec(t,{config:m.patchSpec(t.config,{content:n})}),revert:new mo({source:r},this.metadata)}}},Eg={type:"set-content-source",deserialize:(e,t)=>new uo(e,t)},ho=class po{constructor(t,r={}){this.type="set-content-subtitle",this.target={kind:"content",part:"subtitle"},this.params=t,this.metadata=y({...r,description:"Set chart subtitle"})}apply(t){const r=t.config.content.subtitle;return r===this.params.subtitle?null:{spec:m.updateSpec(t,{config:{content:{subtitle:this.params.subtitle}}}),revert:new po({subtitle:r},this.metadata)}}},Rg={type:"set-content-subtitle",deserialize:(e,t)=>new ho(e,t)},fo=class go{constructor(t,r={}){this.type="set-content-title",this.target={kind:"content",part:"title"},this.params=t,this.metadata=y({...r,description:"Set chart title"})}apply(t){const r=t.config.content.title;return r===this.params.title?null:{spec:m.updateSpec(t,{config:{content:{title:this.params.title}}}),revert:new go({title:r},this.metadata)}}},wg={type:"set-content-title",deserialize:(e,t)=>new fo(e,t)},vo=(e,t,r,n)=>{const a=Cg(t,r),i=Mg(e,a,n);let o=e,s=!1;for(const c of a){const u=Og(o,c,n,Dg(c,n,Pg(r,c)));u!==null&&(o=u,s=!0)}return s?{spec:o,previous:i}:null},Cg=(e,t)=>e==="both"&&!pe(t)?[void 0]:or(e),Pg=(e,t)=>t===void 0?pe(e)?e.x:e:sr(e,t),Mg=(e,t,r)=>t.length===1?it(e,t[0],r):{x:it(e,"x",r),y:it(e,"y",r)},it=(e,t,r)=>So(e.styles.overrides,t)?.[r]??null,Dg=(e,t,r)=>r===null||t==="strokeWidth"?r:(e===void 0?["x","y"]:[e]).every(n=>yo(l.STYLE_TARGETS.gridLine.children[n].rest[t],r))?null:r,yo=(e,t)=>Array.isArray(e)&&Array.isArray(t)?_t(e,t):e===t,Og=(e,t,r,n)=>{const a=So(e.styles.overrides,t);return yo(a?.[r]??null,n)?null:new H({list:"overrides",rule:Vg(t,kg(a,r,n))}).apply(e)?.spec??null},_g=e=>e.select.target==="gridLine",So=(e,t)=>{const r=ue(e,{select:t===void 0?{target:"gridLine"}:{target:"gridLine",axis:t}});if(!(r===void 0||!_g(r)))return r.declarations},kg=(e,t,r)=>{const{[t]:n,...a}=e??{};return r!==null?{...a,[t]:r}:Object.keys(a).length===0?null:a},Ln=(e,t)=>e===void 0?b.style.gridLine(t):e==="x"?b.style.gridLine.x(t):b.style.gridLine.y(t),Vg=(e,t)=>t===null?{...Ln(e,{}),declarations:null}:Ln(e,t),bo=class xo{constructor(t,r={}){this.type="set-grid-line-style",this.params=t,this.metadata=y({...r,description:`Set ${ji(t.axis)} grid line style to ${Fg(t)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineStyle:n}=this.params,a=vo(t,r,En(n,Bg),"dashArray");return a===null?null:{spec:a.spec,revert:new xo({axis:r,lineStyle:En(a.previous,Gg)},this.metadata)}}},Ng={type:"set-grid-line-style",deserialize:(e,t)=>new bo(e,t)},Fg=({axis:e,lineStyle:t})=>{const r=or(e).map(n=>sr(t,n)??"(theme)");return[...new Set(r)].join(" and ")},Bg=e=>e===null?null:l.DASH_PRESETS.gridLine[e],Gg=e=>e===null?null:Ot(e),En=(e,t)=>pe(e)?{x:t(e.x),y:t(e.y)}:t(e),Hg={type:"set-grid-line-width",deserialize:(e,t)=>new Ao(e,t)},Ao=class Io{constructor(t,r={}){this.type="set-grid-line-width";const n=$g(t.lineWidth);this.params={...t,lineWidth:n},this.metadata=y({...r,description:`Set ${ji(t.axis)} grid line width to ${Kg(t.axis,n)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineWidth:n}=this.params,a=vo(t,r,n,"strokeWidth");return a===null?null:{spec:a.spec,revert:new Io({axis:r,lineWidth:a.previous},this.metadata)}}},$g=e=>pe(e)?{x:ot(e.x),y:ot(e.y)}:ot(e),ot=e=>e===null||!Number.isFinite(e)?null:Math.max(0,e),Kg=(e,t)=>{const r=or(e).map(n=>sr(t,n)??"(theme)");return[...new Set(r)].join(" and ")},To=class Lo{constructor(t,r={}){this.type="set-grid-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis grid visibility to ${t.isVisible??"(auto)"}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,isVisible:n}=this.params,a=t.config.axes[r].grid.isVisible;return a===n?null:{spec:m.updateSpec(t,{config:{axes:{[r]:{grid:{isVisible:n}}}}}),revert:new Lo({axis:r,isVisible:a},this.metadata)}}},Yg={type:"set-grid-visibility",deserialize:(e,t)=>new To(e,t)},Eo=class Ro{constructor(t,r={}){this.type="set-headline-compare-with",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline compare with to ${t.compareWith}`})}apply(t){const r=t.config.headline.compareWith;return r===this.params.compareWith?null:{spec:m.updateSpec(t,{config:{headline:{compareWith:this.params.compareWith}}}),revert:new Ro({compareWith:r},this.metadata)}}},zg={type:"set-headline-compare-with",deserialize:(e,t)=>new Eo(e,t)},wo=class Co{constructor(t,r={}){this.type="set-headline-position",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline position to ${t.position}`})}apply(t){const r=t.config.headline.position;return r===this.params.position?null:{spec:m.updateSpec(t,{config:{headline:{position:this.params.position}}}),revert:new Co({position:r},this.metadata)}}},Ug={type:"set-headline-position",deserialize:(e,t)=>new wo(e,t)},Po=class Mo{constructor(t,r={}){this.type="set-headline-show",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline show to ${t.show}`})}apply(t){const r=t.config.headline.show;return r===this.params.show?null:{spec:m.updateSpec(t,{config:{headline:{show:this.params.show}}}),revert:new Mo({show:r},this.metadata)}}},Wg={type:"set-headline-show",deserialize:(e,t)=>new Po(e,t)},Do=class Oo{constructor(t,r={}){this.type="set-headline-size",this.target={kind:"headline"},this.params=t,this.metadata=y({...r,description:`Set headline size to ${t.size}`})}apply(t){const r=t.config.headline.size;return r===this.params.size?null:{spec:m.updateSpec(t,{config:{headline:{size:this.params.size}}}),revert:new Oo({size:r},this.metadata)}}},Xg={type:"set-headline-size",deserialize:(e,t)=>new Do(e,t)},qg={type:"set-highlight-dim-style",deserialize:(e,t)=>new _o(e,t)},_o=class{constructor(e,t={}){this.type="set-highlight-dim-style",this.params=e,this.metadata=y({...t,description:`Set highlight style to ${e.dimStyle}`})}get target(){return{kind:"appearance"}}apply(e){if(ko(e)===this.params.dimStyle)return null;const t=new H({list:"overrides",rule:Zg(this.params.dimStyle)},this.metadata).apply(e);return t||null}},jg={select:{target:"geom"},when:{state:"dimmed"}},ko=e=>{const t=ue(e.styles.overrides,jg);return(t!==void 0&&Qt(t)?t.declarations:void 0)?.saturation===0?"desaturate":"dim"},Zg=e=>e==="desaturate"?b.style.geom({saturation:0,alpha:.6},{state:"dimmed"}):b.style.geom({alpha:l.DEFAULT_DIMMED_ALPHA},{state:"dimmed"}),Vo=class No{constructor(t,r={}){this.type="set-legend-align",this.target={kind:"legend"},this.params=t,this.metadata=y({...r,description:`Set legend align to ${t.align}`})}apply(t){const r=t.config.legend.align;return r===this.params.align?null:{spec:m.updateSpec(t,{config:{legend:{align:this.params.align}}}),revert:new No({align:r},this.metadata)}}},Jg={type:"set-legend-align",deserialize:(e,t)=>new Vo(e,t)},Fo=class Bo{constructor(t,r={}){this.type="set-legend-display",this.target={kind:"legend"},this.params=t,this.metadata=y({...r,description:`Set legend display to ${t.display}`})}apply(t){const r=t.config.legend.display;return r===this.params.display?null:{spec:m.updateSpec(t,{config:{legend:{display:this.params.display}}}),revert:new Bo({display:r},this.metadata)}}},Qg={type:"set-legend-display",deserialize:(e,t)=>new Fo(e,t)},Go=class Ho{constructor(t,r={}){this.type="set-legend-position",this.target={kind:"legend"},this.params=t,this.metadata=y({...r,description:`Set legend position to ${t.position}`})}apply(t){const r=t.config.legend.position;return r===this.params.position?null:{spec:m.updateSpec(t,{config:{legend:{position:this.params.position}}}),revert:new Ho({position:r},this.metadata)}}},ev={type:"set-legend-position",deserialize:(e,t)=>new Go(e,t)},$o=class Ko{constructor(t,r={}){this.type="set-number-format-abbreviation",this.target={kind:"numberFormat"},this.params=t,this.metadata=y({...r,description:`Set number format abbreviation to ${t.abbreviation}`})}apply(t){const r=t.config.numberFormat.abbreviation;return r===this.params.abbreviation?null:{spec:m.updateSpec(t,{config:{numberFormat:{abbreviation:this.params.abbreviation}}}),revert:new Ko({abbreviation:r},this.metadata)}}},tv={type:"set-number-format-abbreviation",deserialize:(e,t)=>new $o(e,t)},Yo=class zo{constructor(t,r={}){this.type="set-number-format-decimals",this.target={kind:"numberFormat"},this.params=t,this.metadata=y({...r,description:`Set number format decimals to ${t.decimals}`})}apply(t){const r=t.config.numberFormat.decimals;return r===this.params.decimals?null:{spec:m.updateSpec(t,{config:{numberFormat:{decimals:this.params.decimals}}}),revert:new zo({decimals:r},this.metadata)}}},rv={type:"set-number-format-decimals",deserialize:(e,t)=>new Yo(e,t)},Uo=class Wo{constructor(t,r={}){this.type="toggle-content-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.part} visibility to ${t.isVisible}`})}get target(){return{kind:"content",part:this.params.part}}apply(t){const{part:r,isVisible:n}=this.params,a=av(r);if(!a)return null;const i=t.config.content[a];return i===n?null:{spec:m.updateSpec(t,{config:{content:{[a]:n}}}),revert:new Wo({part:r,isVisible:i},this.metadata)}}},nv={type:"toggle-content-visibility",deserialize:(e,t)=>new Uo(e,t)},Rn={title:"isTitleVisible",subtitle:"isSubtitleVisible",caption:"isCaptionVisible",source:"isSourceVisible"};function av(e){return Object.hasOwn(Rn,e)?Rn[e]:void 0}var Xo=class qo{constructor(t,r={}){this.type="set-coord-limits",this.target={kind:"coords"},this.params=t,this.metadata=y({...r,description:"Set coordinate limits"})}apply(t){const{xLimits:r,yLimits:n}=this.params,a=t.coords.params,i={xLimits:r!==void 0?r:a.xLimits,yLimits:n!==void 0?n:a.yLimits};if(Q(i.xLimits,a.xLimits)&&Q(i.yLimits,a.yLimits))return null;const o={};r!==void 0&&(o.xLimits=a.xLimits),n!==void 0&&(o.yLimits=a.yLimits);const s=new qo(o,this.metadata);return{spec:m.patchSpec(t,{coords:ov(t.coords,i)}),revert:s}}},iv={type:"set-coord-limits",deserialize:(e,t)=>new Xo(e,t)};function ov(e,t){switch(e.coordType){case"cartesian":return{...e,params:{...e.params,...t}};case"flip":return{...e,params:{...e.params,...t}};case"polar":return{...e,params:{...e.params,...t}}}}var jo=class Zo{constructor(t,r={}){this.type="set-polar-inner-radius",this.target={kind:"coords"},this.params={innerRadius:(0,ne.default)(t.innerRadius,0,1)},this.metadata=y({...r,description:`Set polar inner radius to ${this.params.innerRadius}`})}apply(t){const r=t.coords;if(r.coordType!=="polar")return null;const n=r.params.innerRadius;return n===this.params.innerRadius?null:{spec:m.patchSpec(t,{coords:{...r,params:{...r.params,innerRadius:this.params.innerRadius}}}),revert:new Zo({innerRadius:n},this.metadata)}}},sv={type:"set-polar-inner-radius",deserialize:(e,t)=>new jo(e,t)},lv={type:"set-polar-start-angle",deserialize:(e,t)=>new Jo(e,t)},Jo=class Qo{constructor(t,r={}){this.type="set-polar-start-angle",this.target={kind:"coords"},this.params={startAngle:wn(t.startAngle)},this.metadata=y({...r,description:`Set polar start angle to ${this.params.startAngle}`})}apply(t){const r=t.coords;if(r.coordType!=="polar")return null;const n=r.params.startAngle;return wn(n)===this.params.startAngle?null:{spec:m.patchSpec(t,{coords:{...r,params:{...r.params,startAngle:this.params.startAngle}}}),revert:new Qo({startAngle:n},this.metadata)}}},st=360,wn=e=>(e%st+st)%st,lr=class{constructor(e,t={}){this.type="remove-highlight",this.params=e,this.metadata=y({...t,description:"Remove highlight"})}get target(){return{kind:"highlight",id:this.params.id}}apply(e){const t=e.highlights.find(i=>i.id===this.params.id);if(!t)return null;const r=e.highlights.indexOf(t),n=e.highlights.filter(i=>i!==t),a=new cr({predicate:t.predicate,id:t.id,scope:t.scope,layerId:t.layerId,index:r},this.metadata);return{spec:m.patchSpec(e,{highlights:n}),revert:a}}},cv={type:"remove-highlight",deserialize:(e,t)=>new lr(e,t)},cr=class{constructor(e,t={}){this.type="add-highlight",this.params={...e,id:e.id??m.uniqueId(),scope:e.scope??"data-point"},this.metadata=y({...t,description:"Add highlight"})}get target(){return{kind:"highlight",id:this.params.id}}apply(e){const{predicate:t,id:r,scope:n,layerId:a,index:i}=this.params;if(e.highlights.some(d=>d.id===r))return null;const o=new lr({id:r},this.metadata),s={type:"highlight",id:r,predicate:t,scope:n,...a!==void 0&&{layerId:a}},c=i??e.highlights.length,u=Math.min(Math.max(c,0),e.highlights.length);return{spec:m.patchSpec(e,{highlights:[...e.highlights.slice(0,u),s,...e.highlights.slice(u)]}),revert:o}}},uv={type:"add-highlight",deserialize:(e,t)=>new cr(e,t)};function ur(e,t){return{...e,params:{...e.params,...t}}}function qe(e,t){return{...e,dataLabels:{...e.dataLabels,...t}}}function dr(e,t){return m.patchSpec(e,{layers:[...e.layers,t]})}function D(e,t,r){const n=e.layers.findIndex(a=>a.id===t);return n===-1?e:m.patchSpec(e,{layers:m.replaceAtIndex(e.layers,n,r)})}function je(e,t){const r=e.layers.findIndex(n=>n.id===t);return r===-1||e.layers.length<=1?e:m.patchSpec(e,{layers:e.layers.filter((n,a)=>a!==r)})}var mr=class{constructor(e,t={}){this.type="remove-layer",this.params=e,this.metadata=y({...t,description:"Remove layer"})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(e){const t=e.layers.findIndex(a=>a.id===this.params.layerId),r=e.layers[t];if(r===void 0)return null;const n=je(e,this.params.layerId);return n===e?null:{spec:n,revert:new hr({layer:r,index:t},this.metadata)}}},dv={type:"remove-layer",deserialize:(e,t)=>new mr(e,t)},hr=class{constructor(e,t={}){this.type="add-layer",this.params={layer:{...e.layer,id:e.layer.id??m.uniqueId()},...e.index!==void 0&&{index:e.index}},this.metadata=y({...t,description:`Add ${this.params.layer.geom} layer`})}get target(){return{kind:"layer",layerId:this.params.layer.id}}apply(e){const{layer:t,index:r}=this.params;if(e.layers.some(i=>i.id===t.id))return null;const n=r??e.layers.length,a=Math.min(Math.max(n,0),e.layers.length);return{spec:m.patchSpec(e,{layers:[...e.layers.slice(0,a),t,...e.layers.slice(a)]}),revert:new mr({layerId:t.id},this.metadata)}}},mv={type:"add-layer",deserialize:(e,t)=>new hr(e,t)},es=class ts{constructor(t,r={}){this.type="set-bar-corner-radius",this.params=t,this.metadata=y({...r,description:`Set bar border radius to ${t.cornerRadius??"(themed)"}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,cornerRadius:n}=this.params;if(!m.isLayerSpecOf(m.findLayerById(t.layers,r),"bar"))return null;const a=U("bar",r),i=de(t.styles.overrides,a),o=i?.cornerRadius??null;if(o===n)return null;const s=new H({list:"overrides",rule:{...a,declarations:pv(i,n)}}).apply(t);if(!s)return null;const c=new ts({layerId:r,cornerRadius:o},this.metadata);return{spec:s.spec,revert:c}}},hv={type:"set-bar-corner-radius",deserialize:(e,t)=>new es(e,t)},pv=(e,t)=>{const{cornerRadius:r,...n}=e??{};return t!==null?{...n,cornerRadius:t}:Object.keys(n).length===0?null:n},fv={type:"set-bar-width",deserialize:(e,t)=>new ns(e,t)},rs=.05,gv=1,ns=class as{constructor(t,r={}){this.type="set-bar-width";const n=t.width===void 0?void 0:(0,ne.default)(t.width,rs,1);this.params={...t,width:n},this.metadata=y({...r,description:n===void 0?"Reset bar width":`Set bar width to ${n}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){if(this.params.width!==void 0&&!Number.isFinite(this.params.width))return null;const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"bar");if(!m.isLayerSpecOf(r,"bar"))return null;const n=r.params.width;return n===this.params.width?null:{spec:D(t,r.id,ur(r,{width:this.params.width})),revert:new as({layerId:r.id,width:n},this.metadata)}}},is=class os{constructor(t,r={}){this.type="set-data-labels-format",this.params=t,this.metadata=y({...r,description:`Set data labels format to ${t.format}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.format;return n===this.params.format?null:{spec:D(t,r.id,qe(r,{format:this.params.format})),revert:new os({layerId:r.id,format:n},this.metadata)}}},vv={type:"set-data-labels-format",deserialize:(e,t)=>new is(e,t)},ss=class ls{constructor(t,r={}){this.type="set-layer-position",this.params=t,this.metadata=y({...r,description:`Set layer position to ${t.position}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"bar","area");if(!r)return null;const n=r.position;return n===this.params.position?null:{spec:D(t,r.id,{...r,position:this.params.position}),revert:new ls({layerId:r.id,position:n},this.metadata)}}},yv={type:"set-layer-position",deserialize:(e,t)=>new ss(e,t)},cs=class us{constructor(t,r={}){this.type="set-layer-stat";const n=m.resolveStatSpec(t.stat,"identity");this.params={...t.layerId!==void 0&&{layerId:t.layerId},stat:n},this.metadata=y({...r,description:`Set layer stat to ${n.type}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.stat;return bv(n,this.params.stat)?null:{spec:D(t,r.id,{...r,stat:this.params.stat}),revert:new us({layerId:r.id,stat:n},this.metadata)}}},Sv={type:"set-layer-stat",deserialize:(e,t)=>new cs(e,t)},bv=(e,t)=>{if(e.type!==t.type)return!1;const r=e,n=t,a=new Set([...Object.keys(r),...Object.keys(n)]);for(const i of a)if(!Object.is(r[i],n[i]))return!1;return!0},ds=class ms{constructor(t,r={}){this.type="set-layer-y-scale-type",this.params=t,this.metadata=y({...r,description:`Set layer to ${t.yScaleType} y axis`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.yScaleType;if(n===this.params.yScaleType)return null;const a=D(t,r.id,{...r,yScaleType:this.params.yScaleType});return{spec:m.patchSpec(a,{scales:this.params.previousScales===void 0?ar(a.scales,a.layers):this.params.previousScales}),revert:new ms({layerId:r.id,yScaleType:n,previousScales:t.scales},this.metadata)}}},xv={type:"set-layer-y-scale-type",deserialize:(e,t)=>new ds(e,t)},hs=class ps{constructor(t,r={}){this.type="set-line-curve",this.params=t,this.metadata=y({...r,description:`Set line curve to ${t.curve}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"line","area");if(!m.isLayerSpecOf(r,"line","area"))return null;const n=r.params.curve;return n===this.params.curve?null:{spec:D(t,r.id,ur(r,{curve:this.params.curve})),revert:new ps({layerId:r.id,curve:n},this.metadata)}}},Av={type:"set-line-curve",deserialize:(e,t)=>new hs(e,t)},fs=class gs{constructor(t,r={}){this.type="set-line-missing-values",this.params=t,this.metadata=y({...r,description:`Set missing values handling to ${t.missingValues}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"line","area");if(!m.isLayerSpecOf(r,"line","area"))return null;const n=r.params.missingValues;return n===this.params.missingValues?null:{spec:D(t,r.id,ur(r,{missingValues:this.params.missingValues})),revert:new gs({layerId:r.id,missingValues:n},this.metadata)}}},Iv={type:"set-line-missing-values",deserialize:(e,t)=>new fs(e,t)},vs=class ys{constructor(t,r={}){this.type="set-line-width",this.params=t,this.metadata=y({...r,description:`Set line width to ${t.lineWidth??"(themed)"}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,lineWidth:n}=this.params,a=m.findLayerById(t.layers,r);if(!m.isLayerSpecOf(a,"line","area"))return null;const i=de(t.styles.overrides,U(a.geom,r)),o=i?.strokeWidth??null;if(o===n)return null;const s=Lv(i,n),c=new H({list:"overrides",rule:a.geom==="area"?{...U("area",r),declarations:s}:{...U("line",r),declarations:s}}).apply(t);return c?{spec:c.spec,revert:new ys({layerId:r,lineWidth:o},this.metadata)}:null}},Tv={type:"set-line-width",deserialize:(e,t)=>new vs(e,t)},Lv=(e,t)=>{const{strokeWidth:r,...n}=e??{};return t!==null?{...n,strokeWidth:t}:Object.keys(n).length===0?null:n},Ss=class bs{constructor(t,r={}){this.type="set-point-size",this.params=t,this.metadata=y({...r,description:`Set point size to ${t.size??"(themed)"}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,size:n}=this.params;if(!m.isLayerSpecOf(m.findLayerById(t.layers,r),"point"))return null;const a=U("point",r),i=de(t.styles.overrides,a),o=i?.size??null;if(o===n)return null;const s=new H({list:"overrides",rule:{...a,declarations:Rv(i,n)}}).apply(t);return s?{spec:s.spec,revert:new bs({layerId:r,size:o},this.metadata)}:null}},Ev={type:"set-point-size",deserialize:(e,t)=>new Ss(e,t)},Rv=(e,t)=>{const{size:r,...n}=e??{};return t!==null?{...n,size:t}:Object.keys(n).length===0?null:n},xs=class As{constructor(t,r={}){this.type="set-rule-label",this.params=t,this.metadata=y({...r,description:"Set reference line label"})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"rule");if(!m.isLayerSpecOf(r,"rule"))return null;const n=r.params.label,a=this.params.label??void 0;if(n===a)return null;const i=a===void 0?Object.fromEntries(Object.entries(r.params).filter(([o])=>o!=="label")):{...r.params,label:a};return{spec:D(t,r.id,{...r,params:i}),revert:new As({layerId:r.id,label:n??null},this.metadata)}}},wv={type:"set-rule-label",deserialize:(e,t)=>new xs(e,t)},Is=class Ts{constructor(t,r={}){this.type="set-rule-value",this.params=t,this.metadata=y({...r,description:`Set reference line to ${t.value}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"rule");if(!m.isLayerSpecOf(r,"rule"))return null;const n=typeof l.readConstantValue(r.mapping.y)=="number"?"y":"x",a=l.readConstantValue(r.mapping[n]);if(typeof a!="number"||a===this.params.value)return null;const i={...r.mapping,[n]:{value:this.params.value}};return{spec:D(t,r.id,{...r,mapping:i}),revert:new Ts({layerId:r.id,value:a},this.metadata)}}},Cv={type:"set-rule-value",deserialize:(e,t)=>new Is(e,t)},Pv={type:"set-stat-line",deserialize:(e,t)=>new Ls(e,t)},Ls=class Es{constructor(t,r={}){this.type="set-stat-line",this.params=t,this.metadata=y({...r,description:Nv(t.line)})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=Dv(t),n=this.buildStatLine(t,r?.line===this.params.line?r.layer.id:void 0);if(this.params.line!=="none"&&n===null||r===void 0&&n===null||r!==void 0&&n!==null&&Vv(r.layer,n))return null;const a=new Es({line:r?.line??"none",...r!==void 0&&{removedLayer:r.layer},...r===void 0&&n!==null&&{layerId:n.id}},this.metadata);if(r!==void 0&&n!==null&&r.line===this.params.line)return{spec:D(t,r.layer.id,n),revert:a};const i=r===void 0?t:je(t,r.layer.id);return n===null&&i===t?null:{spec:n===null?i:dr(i,n),revert:a}}buildStatLine(t,r){if(this.params.line==="none")return null;if(this.params.removedLayer!==void 0)return this.params.removedLayer;const n=this.params.line==="trend"?Ov(this.params):_v(t,this.params);if(n===null)return null;const a=m.resolveLayer(M,t.mapping,t.coords.coordType,n);return r===void 0?a:{...a,id:r}}},Mv="linear",Dv=e=>{const t=ui(e.layers);if(t!==void 0)return{line:"trend",layer:t};const r=di(e.layers);if(r!==void 0)return{line:"average",layer:r}},Ov=({method:e})=>l.geom.line({aes:{lineType:{value:"dashed"}},stat:b.stat.smooth({method:e??Mv}),interactive:!1}),_v=(e,{group:t,label:r})=>{const n=kv(e),a=l.readVariableName(n?.mapping.y??e.mapping.y);if(a===null)return null;const i=l.readVariableName(n?.mapping.color??e.mapping.color),o=i!==null&&t!==void 0;return l.geom.rule({aes:{y:a,color:void 0,group:void 0,lineType:void 0},stat:b.stat.mean(),transforms:o?[b.transform.filter({variableName:i,operator:"eq",value:t})]:[],params:{labelPosition:e.coords.coordType==="flip"?"end":"start",...r!==void 0&&{label:r}},yScaleType:n?.yScaleType,interactive:!1})},kv=e=>e.layers.find(t=>t.geom!=="rule"&&t.stat.type!=="smooth"),Vv=(e,t)=>(0,Js.isEqual)({...e,id:""},{...t,id:""}),Nv=e=>e==="none"?"Hide stat line":`Show ${e} line`,Rs=class ws{constructor(t,r={}){this.type="toggle-category-labels",this.params=t,this.metadata=y({...r,description:`${t.showCategoryLabels?"Show":"Hide"} category labels`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.showCategoryLabels;return n===this.params.showCategoryLabels?null:{spec:D(t,r.id,qe(r,{showCategoryLabels:this.params.showCategoryLabels})),revert:new ws({layerId:r.id,showCategoryLabels:n},this.metadata)}}},Fv={type:"toggle-category-labels",deserialize:(e,t)=>new Rs(e,t)},Cs=class Ps{constructor(t,r={}){this.type="toggle-data-labels",this.params=t,this.metadata=y({...r,description:`${t.showDataLabels?"Show":"Hide"} data labels`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.showDataLabels;return n===this.params.showDataLabels?null:{spec:D(t,r.id,qe(r,{showDataLabels:this.params.showDataLabels})),revert:new Ps({layerId:r.id,showDataLabels:n},this.metadata)}}},Bv={type:"toggle-data-labels",deserialize:(e,t)=>new Cs(e,t)},Gv={type:"toggle-goal-line",deserialize:(e,t)=>new Ms(e,t)},Ms=class yt{constructor(t,r={}){this.type="toggle-goal-line",this.params=t,this.metadata=y({...r,description:`${t.showGoalLine?"Show":"Hide"} goal line`})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=ci(t.layers);if(!this.params.showGoalLine){if(r===void 0)return null;const a=je(t,r.id);return a===t?null:{spec:a,revert:new yt({showGoalLine:!0,removedLayer:r},this.metadata)}}if(r!==void 0)return null;const n=this.params.removedLayer??this.buildGoalLine(t);return{spec:dr(t,n),revert:new yt({showGoalLine:!1,layerId:n.id},this.metadata)}}buildGoalLine(t){const r=t.coords.coordType==="flip"?"end":"start";return m.resolveLayer(M,t.mapping,t.coords.coordType,l.geom.rule({aes:{y:{value:this.params.value??Hv}},params:{labelPosition:r,...this.params.label!==void 0&&{label:this.params.label}},interactive:!1}))}},Hv=0,$v={type:"toggle-line-fill",deserialize:(e,t)=>new Ds(e,t)},Ds=class Os{constructor(t,r={}){this.type="toggle-line-fill",this.params=t,this.metadata=y({...r,description:`Set line fill to ${t.showFill}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const{layerId:r,showFill:n,fillAlpha:a}=this.params;if(!m.isLayerSpecOf(m.findLayerById(t.layers,r),"line"))return null;const i=U("line",r),o=de(t.styles.overrides,i),s=o?.fillAlpha,c=s!==void 0;if(c===n)return null;const u=new H({list:"overrides",rule:{...i,declarations:Yv(o,n?a??Kv:null)}}).apply(t);if(!u)return null;const d=new Os({layerId:r,showFill:c,...s===void 0?{}:{fillAlpha:s}},this.metadata);return{spec:u.spec,revert:d}}},Kv=.2,Yv=(e,t)=>{const{fillAlpha:r,...n}=e??{};return t!==null?{...n,fillAlpha:t}:Object.keys(n).length===0?null:n},zv={type:"toggle-line-points",deserialize:(e,t)=>new _s(e,t)},_s=class St{constructor(t,r={}){this.type="toggle-line-points",this.params=t,this.metadata=y({...r,description:`${t.showPoints?"Show":"Hide"} points`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):m.findLayerByGeom(t.layers,"line","area");return m.isLayerSpecOf(r,"line","area")?this.params.showPoints?this.addPointLayer(t,r):this.removePointLayer(t,r):null}addPointLayer(t,r){return this.findAssociatedPointLayer(t,r)?null:{spec:dr(t,this.params.removedLayer??m.resolveLayer(M,t.mapping,t.coords.coordType,l.geom.point({aes:{...r.mapping},position:r.position,yScaleType:r.yScaleType,transforms:[...r.transforms],interactive:!1}))),revert:new St({layerId:r.id,showPoints:!1},this.metadata)}}removePointLayer(t,r){const n=this.findAssociatedPointLayer(t,r);return n?{spec:je(t,n.id),revert:new St({layerId:r.id,showPoints:!0,removedLayer:n},this.metadata)}:null}findAssociatedPointLayer(t,r){return t.layers.find(n=>n.geom!=="point"?!1:m.isCompanionLayer(n,[r]))}},ks=class Vs{constructor(t,r={}){this.type="toggle-stack-totals",this.params=t,this.metadata=y({...r,description:`${t.showStackTotals?"Show":"Hide"} stack totals`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?m.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.dataLabels.showStackTotals;return n===this.params.showStackTotals?null:{spec:D(t,r.id,qe(r,{showStackTotals:this.params.showStackTotals})),revert:new Vs({layerId:r.id,showStackTotals:n},this.metadata)}}},Uv={type:"toggle-stack-totals",deserialize:(e,t)=>new ks(e,t)},Ns=class Fs{constructor(t,r={}){this.type="set-scale-domain",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} scale domain`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=ze(t,this.params.scaledAesthetic);if(!r||r.scaleType!=="continuous"&&r.scaleType!=="datetime")return null;const n={min:r.domainMin??null,max:r.domainMax??null},a=this.params.domainMin===void 0?n.min:this.params.domainMin,i=this.params.domainMax===void 0?n.max:this.params.domainMax;if(a===n.min&&i===n.max)return null;const o={...r,...this.params.domainMin!==void 0&&{domainMin:this.params.domainMin},...this.params.domainMax!==void 0&&{domainMax:this.params.domainMax}},s=Ue(t,this.params.scaledAesthetic,o),c={scaledAesthetic:this.params.scaledAesthetic};return this.params.domainMin!==void 0&&(c.domainMin=n.min),this.params.domainMax!==void 0&&(c.domainMax=n.max),{spec:s,revert:new Fs(c,this.metadata)}}},Wv={type:"set-scale-domain",deserialize:(e,t)=>new Ns(e,t)},Bs=class Gs{constructor(t,r={}){this.type="set-scale-palette",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} palette`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=ze(t,this.params.scaledAesthetic);return r?.scaleType!=="palette"||Q(r.palette,this.params.palette)?null:{spec:Ue(t,this.params.scaledAesthetic,{...r,scaledAesthetic:this.params.scaledAesthetic,palette:this.params.palette}),revert:new Gs({scaledAesthetic:this.params.scaledAesthetic,palette:r.palette},this.metadata)}}},Xv={type:"set-scale-palette",deserialize:(e,t)=>new Bs(e,t)},Hs=class $s{constructor(t,r={}){this.type="set-scale-reverse",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} scale reverse to ${t.reverse}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=ze(t,this.params.scaledAesthetic);if(!r||!jv(r))return null;const n=r.reverse;return n===this.params.reverse?null:{spec:Ue(t,this.params.scaledAesthetic,{...r,reverse:this.params.reverse}),revert:new $s({scaledAesthetic:this.params.scaledAesthetic,reverse:n},this.metadata)}}},qv={type:"set-scale-reverse",deserialize:(e,t)=>new Hs(e,t)};function jv(e){return e.scaleType==="continuous"||e.scaleType==="datetime"||e.scaleType==="discrete"}var Ks=class Ys{constructor(t,r={}){this.type="set-scale-transform",this.params=t,this.metadata=y({...r,description:`Set ${We(t.scaledAesthetic)} scale transform to ${t.transform}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=ze(t,this.params.scaledAesthetic);if(!r||r.scaleType!=="continuous")return null;const n=r.transform;return n===this.params.transform?null:{spec:Ue(t,this.params.scaledAesthetic,{...r,transform:this.params.transform}),revert:new Ys({scaledAesthetic:this.params.scaledAesthetic,transform:n},this.metadata)}}},Zv={type:"set-scale-transform",deserialize:(e,t)=>new Ks(e,t)},zs=class{constructor(){this.descriptors=new Map}register(e){if(this.descriptors.has(e.type))throw new l.InternalError({message:`CommandRegistry: descriptor for type '${e.type}' is already registered`});this.descriptors.set(e.type,e)}serialize(e){return{type:e.type,params:e.params,metadata:e.metadata}}deserialize(e){return this.getDescriptor(e.type).deserialize(e.params,e.metadata)}getRegisteredTypes(){return[...this.descriptors.keys()]}getDescriptor(e){const t=this.descriptors.get(e);if(!t)throw new l.InternalError({message:`CommandRegistry: no descriptor registered for type '${e}'`});return t}},v=new zs;v.register(gf);v.register(ig);v.register(mv);v.register(dv);v.register(vv);v.register(yv);v.register(Sv);v.register(xv);v.register(Av);v.register(Tv);v.register(hv);v.register(fv);v.register(Ev);v.register(Iv);v.register(wv);v.register(Cv);v.register(Pv);v.register(Fv);v.register(Bv);v.register(Gv);v.register($v);v.register(zv);v.register(Uv);v.register(Wv);v.register(Xv);v.register(qv);v.register(Zv);v.register(Sg);v.register(Ag);v.register(xg);v.register(Ig);v.register(Tg);v.register(Lg);v.register(Eg);v.register(Rg);v.register(wg);v.register(Ng);v.register(Hg);v.register(Yg);v.register(zg);v.register(Ug);v.register(Wg);v.register(Xg);v.register(qg);v.register(Jg);v.register(Qg);v.register(ev);v.register(tv);v.register(rv);v.register(nv);v.register(uv);v.register(cv);v.register(hf);v.register(Qp);v.register(Jp);v.register(uf);v.register(pf);v.register(df);v.register(iv);v.register(sv);v.register(lv);var Us=(e,t)=>e===t?!0:e===null||t===null?!1:bt(e)===bt(t),bt=e=>{switch(e.kind){case"annotation":case"highlight":return JSON.stringify([e.kind,e.id]);case"styleRule":return JSON.stringify([e.kind,e.list,se(e)]);case"content":return JSON.stringify([e.kind,e.part]);case"axis":case"grid":return JSON.stringify([e.kind,e.axis]);case"layer":return JSON.stringify([e.kind,e.layerId??null]);case"observations":return JSON.stringify([e.kind,e.layerId,e.scope,e.observationIndex??null,ke(e.predicate)]);case"mapping":case"scale":return JSON.stringify([e.kind,e.aesthetic]);case"legend":case"coords":case"graph":case"appearance":case"headline":case"numberFormat":return JSON.stringify([e.kind]);default:throw new l.InternalError({message:`Unhandled edit target kind: ${e.kind}`})}},Ws=class{constructor(e={}){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.isEmitting=!1,this.cachedSnapshot=null,this.hasOpenRun=!1,this.maxHistorySize=e.maxHistorySize??100}apply(e,t,r,n={}){return this.withReentrancyGuard(()=>{const a=n.transient??!1,i=(u,d)=>r?d:u,o=e.apply(t);if(!o)return a||(this.hasOpenRun=!1),i(t,null);const s=r?.({spec:o.spec,command:e})??null,c=s?s.adopted:o.spec;return c?(this.push(e,c,o.revert,a),i(c,s?.value??null)):(a||(this.hasOpenRun=!1),i(t,s?.value??null))})}commit(){return this.withReentrancyGuard(()=>this.hasOpenRun?(this.hasOpenRun=!1,this.emit({type:"commit"}),!0):!1)}undo(e,t){return this.withReentrancyGuard(()=>{const r=this.undoStack[this.undoStack.length-1];if(!r)return null;const n=this.step(r,e,t);return n?n.adopted?(this.undoStack.pop(),this.redoStack.push({command:r.command,revert:n.revert}),this.hasOpenRun=!1,this.emit({type:"undo",command:r.command,spec:n.adopted}),t?n.value:{spec:n.adopted,command:r.command}):n.value:null})}redo(e,t){return this.withReentrancyGuard(()=>{const r=this.redoStack[this.redoStack.length-1];if(!r)return null;const n=this.step(r,e,t);return n?n.adopted?(this.redoStack.pop(),this.undoStack.push({command:r.command,revert:n.revert}),this.hasOpenRun=!1,this.emit({type:"redo",command:r.command,spec:n.adopted}),t?n.value:{spec:n.adopted,command:r.command}):n.value:null})}clear(){this.withReentrancyGuard(()=>{this.hasOpenRun=!1,!(this.undoStack.length===0&&this.redoStack.length===0)&&(this.undoStack=[],this.redoStack=[],this.emit({type:"clear"}))})}getSnapshot(){return this.cachedSnapshot||(this.cachedSnapshot={canUndo:this.undoStack.length>0,canRedo:this.redoStack.length>0,undoDescription:this.undoStack[this.undoStack.length-1]?.command.metadata.description??null,redoDescription:this.redoStack[this.redoStack.length-1]?.command.metadata.description??null,undoStack:Cn(this.undoStack),redoStack:Cn(this.redoStack)}),this.cachedSnapshot}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}step(e,t,r){const n=e.revert.apply(t);if(!n)return null;const a=r?.({spec:n.spec,command:e.command})??null;return{adopted:a?a.adopted:n.spec,revert:n.revert,value:a?.value??null}}push(e,t,r,n){const a=this.undoStack.length-1,i=this.undoStack[a],o=this.hasOpenRun&&i!==void 0&&Qv(i.command,e);if(n&&o){this.undoStack[a]={command:e,revert:i.revert},this.cachedSnapshot=null;return}this.undoStack.push({command:e,revert:r}),this.undoStack.length>this.maxHistorySize&&this.undoStack.shift(),this.hasOpenRun=n,this.redoStack=[],this.emit({type:"apply",command:e,spec:t})}withReentrancyGuard(e){if(this.isEmitting)throw new l.InternalError({message:"CommandStack: cannot call apply/undo/redo/clear from within a listener"});this.isEmitting=!0;try{return e()}finally{this.isEmitting=!1}}emit(e){this.cachedSnapshot=null;for(const t of this.listeners)try{t(e)}catch(r){console.error("CommandStack listener error:",r)}}},Jv=Object.freeze([]),Qv=(e,t)=>e.type===t.type&&Us(e.target,t.target),Cn=e=>e.length===0?Jv:e.map(t=>t.command.metadata),ey=class{constructor(e){this.history=e,this.frame=null}open(e){this.frame=e}clear(){this.frame=null}close(){const e=this.history.commit(),t=this.frame;return this.frame=null,e?t:null}},ty=class{constructor(e){this.compiler=e,this.history=new Ws,this.current=null,this.last=null,this.hostSpec=null,this.run=new ey(this.history)}get scene(){return this.current}compile(e){return this.last=e,this.hostSpec=e.spec,this.absorb(this.compiler.compile(e))}update(e){const t=this.last,r=!t||e.spec!==this.hostSpec&&e.spec!==t.spec,n=!t||e.data!==t.data,a=!t||e.customPalettes!==t.customPalettes,i=!t||e.colorScheme!==t.colorScheme;if(this.hostSpec=e.spec,!r&&!n&&!a&&!i)return null;let o=null;r?this.run.close():o=this.closeAndConvert();const s=this.last,c=s&&!r?s.spec:e.spec;this.last={spec:c,data:e.data,customPalettes:e.customPalettes,colorScheme:e.colorScheme};const u=this.current,d=r||a||!u?this.absorb(this.compiler.compile(this.last)):this.absorb(this.compiler.recompile({spec:u.spec,data:e.data,colorScheme:e.colorScheme}));return r&&d.ok&&this.history.clear(),{result:d,specChanged:r,...o&&{committedSpec:o.spec}}}applyCommand(e,t={}){const r=t.transient??!1,n=[];if(!r){const c=this.commitNotification(!1);c&&n.push(c)}const{current:a,last:i,history:o}=this;if(!a||!i)return n;const s=o.apply(e,a.spec,({spec:c})=>{const u=this.applyEdit(c,i,r,e);return{adopted:u.ok?u.scene.spec:null,value:u}},t);return s&&n.push(this.renderedNotification(s,e,r)),n}commit(){const e=this.commitNotification(!0);return e?[e]:[]}undo(){return this.stepHistory((e,t)=>this.history.undo(e,t))}redo(){return this.stepHistory((e,t)=>this.history.redo(e,t))}stepHistory(e){const{current:t,last:r}=this;if(!t||!r)return[];const n=e(t.spec,({spec:a,command:i})=>{const o=this.applyEdit(a,r);return{adopted:o.ok?o.scene.spec:null,value:{result:o,command:i}}});return n?[this.renderedNotification(n.result,n.command,!1)]:[]}renderedNotification(e,t,r){return e.ok?r?{scene:e.scene}:{scene:e.scene,result:e,command:t,...e.spec&&{spec:e.spec}}:{errors:e.errors}}commitNotification(e){const t=this.closeAndConvert();return t?{result:t.result,spec:t.spec,...e&&{command:t.command}}:null}closeAndConvert(){const e=this.run.close(),{current:t,last:r}=this;return!t||!r||!e?null:{spec:this.recordSpec(t.spec,r),result:e.result,command:e.command}}applyEdit(e,t,r=!1,n=null){const a=this.compiler.recompile({spec:e,colorScheme:t.colorScheme});if(!a.ok)return{ok:!1,errors:a.errors};if(this.current=a.scene,r&&n){const o={ok:!0,scene:a.scene,warnings:a.warnings};return this.run.open({result:o,command:n}),o}this.run.clear();const i=this.recordSpec(a.scene.spec,t);return{ok:!0,scene:a.scene,warnings:a.warnings,spec:i}}recordSpec(e,t){const r=mi(e);return this.last={spec:r,data:t.data,customPalettes:t.customPalettes,colorScheme:t.colorScheme},r}absorb(e){return e.ok&&(this.current=e.scene),e}},ry=new Set(["x","y"]),Pn=["numeric","categorical","temporal"],Mn=["numeric"],ny=(e,t)=>{const r=e.layers.map(a=>Ai(a.geom)).filter(l.isDefined),n=Ye(e);return t.filter(a=>ay(e,r,a)).map(a=>({aesthetic:a,variables:iy(n,r,a),isRequired:ry.has(a)}))},ay=(e,t,r)=>{switch(r){case"x":return!ly(e.coords);case"y":return!0;case"label":return t.some(n=>n.dataLabelCoordTypes.includes(e.coords.coordType));default:return t.some(n=>n.aesthetics.some(a=>a.kind==="visual"&&a.name===r))}},iy=(e,t,r)=>{const n=oy(t,r);return e.getVariableNames().filter(a=>!l.isInternalVariable(a)&&n.includes(e.getType(a)))},oy=(e,t)=>t==="size"?Mn:t!=="x"&&t!=="y"?Pn:sy(e,t)?Mn:Pn,sy=(e,t)=>e.some(r=>r.positionRoles.some(n=>m.POSITION_NUMERIC_ROLES.has(n.role)&&n.aes===t&&!(n.role==="scalar"&&n.aes===n.axis))),ly=e=>e.coordType==="polar"&&e.params.theta==="y",cy=500,uy="normal",pr={thin:100,hairline:100,extraLight:200,ultraLight:200,light:300,normal:400,regular:400,medium:500,semiBold:600,demiBold:600,bold:700,extraBold:800,ultraBold:800,black:900,heavy:900,extraBlack:950,ultraBlack:950},dy=e=>{const t=e.style??"normal",r=e.weight??500,n=e.family.includes(",")?e.family:`'${e.family}'`;return`${t} ${r} ${e.size}px ${n}`},fr=e=>typeof e!="string"?e??500:pr[e],Xs=(e,t)=>{switch(t){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();case"capitalize":return e.replace(/(^|\s)(\S)/gu,(r,n,a)=>`${n}${a.toUpperCase()}`);default:return e}},qs=(e,t)=>t===void 0||t===0?0:t*[...e].length,my="\0",hy=class{constructor(e){this.inner=e,this.cache=new Map}measureText(e,t){const r=this.getCacheKey(e,t),n=this.cache.get(r);if(n)return n;const a=this.inner.measureText(e,t);return this.cache.set(r,a),a}getCacheKey(e,t){return[t.family,t.size,fr(t.weight),t.style??"normal",t.letterSpacing??0,t.textTransform??"none",e].join(my)}},py={" ":.25,"!":.27,'"':.36,"#":.6,$:.56,"%":.78,"&":.66,"'":.21,"(":.31,")":.31,"*":.44,"+":.56,",":.22,"-":.36,".":.22,"/":.35,0:.56,1:.56,2:.56,3:.56,4:.56,5:.56,6:.56,7:.56,8:.56,9:.56,":":.22,";":.22,"<":.56,"=":.56,">":.56,"?":.46,"@":.88,A:.63,B:.63,C:.65,D:.69,E:.56,F:.53,G:.7,H:.7,I:.26,J:.44,K:.62,L:.53,M:.84,N:.7,O:.73,P:.6,Q:.73,R:.62,S:.56,T:.56,U:.69,V:.6,W:.88,X:.58,Y:.56,Z:.58,"[":.29,"\\":.35,"]":.29,"^":.56,_:.44,"`":.33,a:.53,b:.58,c:.48,d:.58,e:.54,f:.31,g:.56,h:.57,i:.23,j:.23,k:.52,l:.23,m:.87,n:.57,o:.57,p:.58,q:.58,r:.35,s:.45,t:.34,u:.57,v:.49,w:.74,x:.49,y:.49,z:.46,"{":.33,"|":.26,"}":.33,"~":.56};var fy=1.05,gy=.84,vy=.21,yy=class{measureText(e,t){const r=Xs(e,t.textTransform);let n=qs(r,t.letterSpacing);for(const o of r)n+=(py[o]??.55)*t.size;fr(t.weight)>=pr.semiBold&&(n*=fy);const a=gy*t.size,i=vy*t.size;return{width:n,height:a+i,ascent:a,descent:i}}};exports.ANNOTATION_PARTS=b.ANNOTATION_PARTS;exports.ANNOTATION_STYLE_KINDS=b.ANNOTATION_STYLE_KINDS;exports.ANNOTATION_TOOLTIP_MARKER_GAP_PX=cu;exports.ARROW_DEFAULTS=l.ARROW_DEFAULTS;exports.ARROW_STICKER_DECLARATIONS=l.ARROW_STICKER_DECLARATIONS;exports.ARROW_STROKE_WIDTHS_PX=l.ARROW_STROKE_WIDTHS_PX;exports.AXIS_KEYS=l.AXIS_KEYS;exports.AddAnnotationCommand=tr;exports.AddHighlightCommand=cr;exports.AddLayerCommand=hr;exports.BORDER_RADIUS_PX=Ft;exports.BORDER_RADIUS_TOKENS=l.BORDER_RADIUS_TOKENS;exports.BUILTIN_STYLES=m.BUILTIN_STYLES;exports.COLOR_INTERPOLATION_SPACES=m.COLOR_INTERPOLATION_SPACES;exports.COMBO_TYPES=b.COMBO_TYPES;exports.COMPILER_STAGE_KEYS=m.COMPILER_STAGE_KEYS;exports.CONSTANT_VARIABLES=l.CONSTANT_VARIABLES;exports.CachedTextMeasurer=hy;exports.CommandRegistry=zs;exports.CommandStackManager=Ws;exports.Compiler=m.Compiler;exports.DASH_PRESETS=l.DASH_PRESETS;exports.DATA_LABEL_ROLES=b.DATA_LABEL_ROLES;exports.DEFAULT_BAR_CORNER_RADIUS=l.DEFAULT_BAR_CORNER_RADIUS;exports.DEFAULT_COLOR_PALETTE=l.DEFAULT_COLOR_PALETTE;exports.DEFAULT_DIMMED_ALPHA=l.DEFAULT_DIMMED_ALPHA;exports.DEFAULT_FONT_STYLE=uy;exports.DEFAULT_FONT_WEIGHT=cy;exports.DEFAULT_GEOM_COLOR=l.DEFAULT_GEOM_COLOR;exports.DEFAULT_GRAPH_BACKGROUND=l.DEFAULT_GRAPH_BACKGROUND;exports.DEFAULT_GRAPH_BORDER_WIDTH_PX=l.DEFAULT_GRAPH_BORDER_WIDTH_PX;exports.DEFAULT_GRAPH_PADDING_PX=l.DEFAULT_GRAPH_PADDING_PX;exports.DEFAULT_HEADLINE_SWATCH_SIZE_PX=l.DEFAULT_HEADLINE_SWATCH_SIZE_PX;exports.DEFAULT_HOVER_AFFORDANCE_COLOR=l.DEFAULT_HOVER_AFFORDANCE_COLOR;exports.DEFAULT_LOCALE=l.DEFAULT_LOCALE;exports.DEFAULT_MONO_BASE=l.DEFAULT_MONO_BASE;exports.DEFAULT_POINT_SIZE_PX=l.DEFAULT_POINT_SIZE_PX;exports.DEFAULT_STROKE_WIDTH_PX=l.DEFAULT_STROKE_WIDTH_PX;exports.DIFFERENCE_ARROW_DEFAULTS=l.DIFFERENCE_ARROW_DEFAULTS;exports.DIFFERENCE_ARROW_SIZE_DECLARATIONS=l.DIFFERENCE_ARROW_SIZE_DECLARATIONS;exports.DIVERGING_SCHEME_NAMES=m.DIVERGING_SCHEME_NAMES;exports.Dataset=l.Dataset;exports.EDIT_OUTLINE_PARTS=b.EDIT_OUTLINE_PARTS;exports.GROUP_VARIABLES=l.GROUP_VARIABLES;exports.Geom=l.Geom;exports.GraphCompilationSession=ty;exports.HEADING_PARTS=b.HEADING_PARTS;exports.HEADLINE_ITEM_PARTS=b.HEADLINE_ITEM_PARTS;exports.HEADLINE_SWATCH_GAP_EM=Ia;exports.HEADLINE_TREND_GAP_EM=La;exports.HEADLINE_TREND_ICON_SIZE_PX=wd;exports.HEADLINE_VALUE_LABEL_GAP_EM=Ta;exports.HeuristicTextMeasurer=yy;exports.HoverEngine=Eh;exports.InternalError=l.InternalError;exports.LEGEND_ITEM_PARTS=b.LEGEND_ITEM_PARTS;exports.LEGEND_PARTS=b.LEGEND_PARTS;exports.LINE_TYPES=l.LINE_TYPES;exports.LayoutCompiler=Nc;exports.MAX_BAR_WIDTH_FRACTION=gv;exports.MIN_BAR_WIDTH_FRACTION=rs;exports.MONO_BASES=l.MONO_BASES;exports.MoveAnnotationCommand=Si;exports.NAMED_WEIGHTS=pr;exports.NEON_BASES=l.NEON_BASES;exports.OBSERVATION_ATTACHMENT_KINDS=qt;exports.OUT_OF_VIEW_MARGIN_PX=uu;exports.PANEL_BORDER_EDGES=b.PANEL_BORDER_EDGES;exports.POLAR_RIM_LABEL_GAP_PX=l.POLAR_RIM_LABEL_GAP_PX;exports.POSITION_ADJUSTMENTS=l.POSITION_ADJUSTMENTS;exports.POSITION_VARIABLES=l.POSITION_VARIABLES;exports.RESOLVED_DATA_LABEL_POSITIONS=b.RESOLVED_DATA_LABEL_POSITIONS;exports.RESTING_HOVER_STATE=N;exports.RemoveAnnotationCommand=er;exports.RemoveHighlightCommand=lr;exports.RemoveLayerCommand=mr;exports.SCALED_POSITION_AESTHETIC_KEYS=l.SCALED_POSITION_AESTHETIC_KEYS;exports.SCALED_VISUAL_AESTHETIC_KEYS=l.SCALED_VISUAL_AESTHETIC_KEYS;exports.SCHEME_ALIASES=m.SCHEME_ALIASES;exports.SEQUENTIAL_SCHEME_NAMES=m.SEQUENTIAL_SCHEME_NAMES;exports.SHAPE_DEFAULTS=l.SHAPE_DEFAULTS;exports.SIBLING_OVERLAP_THRESHOLD_PX=du;exports.SOURCE_PARTS=b.SOURCE_PARTS;exports.STACK_VARIABLES=l.STACK_VARIABLES;exports.STYLE_BLEND_MODES=l.STYLE_BLEND_MODES;exports.STYLE_FONT_STYLES=l.STYLE_FONT_STYLES;exports.STYLE_IMAGE_FITS=l.STYLE_IMAGE_FITS;exports.STYLE_LINE_CAPS=l.STYLE_LINE_CAPS;exports.STYLE_LINE_JOINS=l.STYLE_LINE_JOINS;exports.STYLE_PATTERN_PRESETS=l.STYLE_PATTERN_PRESETS;exports.STYLE_POINT_SYMBOLS=l.STYLE_POINT_SYMBOLS;exports.STYLE_STATES=l.STYLE_STATES;exports.STYLE_TEXT_DECORATIONS=l.STYLE_TEXT_DECORATIONS;exports.STYLE_TEXT_TRANSFORMS=l.STYLE_TEXT_TRANSFORMS;exports.SetAxisLabelCommand=Ji;exports.SetAxisPositionCommand=eo;exports.SetAxisTickModeCommand=ro;exports.SetAxisTicksVisibilityCommand=ao;exports.SetAxisVisibilityCommand=oo;exports.SetBarCornerRadiusCommand=es;exports.SetBarWidthCommand=ns;exports.SetChartTypeCommand=Ii;exports.SetContentCaptionCommand=lo;exports.SetContentSourceCommand=uo;exports.SetContentSubtitleCommand=ho;exports.SetContentTitleCommand=fo;exports.SetCoordLimitsCommand=Xo;exports.SetDataLabelsFormatCommand=is;exports.SetDifferenceArrowStyleCommand=bi;exports.SetGridLineStyleCommand=bo;exports.SetGridLineWidthCommand=Ao;exports.SetGridVisibilityCommand=To;exports.SetHeadlineCompareWithCommand=Eo;exports.SetHeadlinePositionCommand=wo;exports.SetHeadlineShowCommand=Po;exports.SetHeadlineSizeCommand=Do;exports.SetHighlightDimStyleCommand=_o;exports.SetLayerPositionCommand=ss;exports.SetLayerStatCommand=cs;exports.SetLayerYScaleTypeCommand=ds;exports.SetLegendAlignCommand=Vo;exports.SetLegendDisplayCommand=Fo;exports.SetLegendPositionCommand=Go;exports.SetLineCurveCommand=hs;exports.SetLineMissingValuesCommand=fs;exports.SetLineWidthCommand=vs;exports.SetMappingCommand=Ui;exports.SetNumberFormatAbbreviationCommand=$o;exports.SetNumberFormatDecimalsCommand=Yo;exports.SetPointSizeCommand=Ss;exports.SetPolarInnerRadiusCommand=jo;exports.SetPolarStartAngleCommand=Jo;exports.SetRuleLabelCommand=xs;exports.SetRuleValueCommand=Is;exports.SetScaleDomainCommand=Ns;exports.SetScalePaletteCommand=Bs;exports.SetScaleReverseCommand=Hs;exports.SetScaleTransformCommand=Ks;exports.SetStatLineCommand=Ls;exports.SetStyleRuleCommand=H;exports.SpecResolver=m.SpecCompiler;exports.Stat=l.Stat;exports.TEXT_ANNOTATION_DEFAULTS=l.TEXT_ANNOTATION_DEFAULTS;exports.TEXT_ANNOTATION_FADE_ALPHA=l.TEXT_ANNOTATION_FADE_ALPHA;exports.TOOLTIP_PARTS=b.TOOLTIP_PARTS;exports.ToggleCategoryLabelsCommand=Rs;exports.ToggleContentVisibilityCommand=Uo;exports.ToggleDataLabelsCommand=Cs;exports.ToggleGoalLineCommand=Ms;exports.ToggleLineFillCommand=Ds;exports.ToggleLinePointsCommand=_s;exports.ToggleStackTotalsCommand=ks;exports.UNIT_POLAR_PATH_FRAME=Oa;exports.UpdateAnnotationCommand=nr;exports.VISUAL_VARIABLES=l.VISUAL_VARIABLES;exports.alignUnitFractions=l.alignUnitFractions;exports.annotation=l.annotation;exports.applyTextTransform=Xs;exports.areAnchorsEqual=Z;exports.areDashArraysEqual=_t;exports.areEditMenuTriggersEqual=Uu;exports.areEditTargetsEqual=Us;exports.areEndpointsComparable=m.areEndpointsComparable;exports.areMappingsEquivalent=l.areMappingsEquivalent;exports.areObservationAnchorsEqual=oi;exports.arePointerRegionListsEqual=Bu;exports.arePredicatesEqual=li;exports.areStyleDeclarationsEqual=pi;exports.areStyleRuleAddressesEqual=hi;exports.buildAverageLineSymbols=iu;exports.buildBarRectBounds=Ra;exports.buildCalloutHitRegions=lu;exports.buildColumnKey=wa;exports.buildDataLabelsContent=bu;exports.buildDiagnostic=m.buildDiagnostic;exports.buildEditMenuTriggerRegion=Yu;exports.buildFontString=dy;exports.buildHeadlineItemRows=Cd;exports.buildLayerIntroPlan=Bh;exports.buildLayerStyleAddress=U;exports.buildObservationPredicate=Eu;exports.buildObservationsTarget=fa;exports.buildObservationsTargetAtValue=Du;exports.buildPanelAnchorBox=l.buildPanelAnchorBox;exports.buildPointSymbolInBox=zd;exports.buildPointSymbolPath=Yd;exports.buildPolarBarArcPath=Jd;exports.buildSliceGroupKey=_a;exports.buildTooltipContent=up;exports.canAnchorDirectLabels=m.canAnchorDirectLabels;exports.canBecomeCombo=If;exports.canBecomeHeatmap=Tf;exports.canPlaceDataLabels=Su;exports.clampAnnotationTranslation=tf;exports.commandRegistry=v;exports.compileChromeStyles=m.compileChromeStyles;exports.composePoint=m.composePoint;exports.compositeColor=l.compositeColor;exports.computeArrow=ru;exports.computeDifferenceArrow=Jn;exports.computeDirectLabelsLayout=Lu;exports.computeLetterSpacingWidth=qs;exports.computeLineBoxHeight=ta;exports.computePanelBorderPaths=Qh;exports.computePanelBorderSizes=ep;exports.config=b.config;exports.coord=b.coord;exports.countLayerGeoms=Gh;exports.createAlphaValueReader=m.createAlphaValueReader;exports.createAnchorResolver=Gc;exports.createAreaPathGenerators=_d;exports.createColorValueReader=m.createColorValueReader;exports.createCompiler=m.createCompiler;exports.createDataLabelPlacementResolver=qn;exports.createDatasetFromKindPartitions=m.createDatasetFromKindPartitions;exports.createEmptyLayerStyles=m.createEmptyLayerStyles;exports.createGroupValueReader=m.createGroupValueReader;exports.createLabelValueReader=m.createLabelValueReader;exports.createLayerYValueFormatter=Mt;exports.createLineFillAreaGenerator=Hd;exports.createLinePathGenerator=Gd;exports.createObservationAnchorBuilder=m.createObservationAnchorBuilder;exports.createObservationAnchorParser=m.createObservationAnchorParser;exports.createPinnedNumberValueFormatter=gd;exports.createRawValueReader=m.createRawValueReader;exports.createSegmentYReader=m.createSegmentYReader;exports.createSizeValueReader=m.createSizeValueReader;exports.createSpec=b.createSpec;exports.createSpecBuilder=b.createSpecBuilder;exports.createStableBandKeyGenerator=om;exports.createStableCellKeyGenerator=sm;exports.createStableKeyGenerator=He;exports.createStablePolarBarKeyGenerator=lm;exports.createStrokeWidthValueReader=m.createStrokeWidthValueReader;exports.createStyleResolver=Vp;exports.createValueFormatter=I;exports.createXValueReader=m.createXValueReader;exports.createYValueReader=m.createYValueReader;exports.cursorToPiePlane=l.cursorToPiePlane;exports.cursorToPolar=l.cursorToPolar;exports.defineGeomStyleTarget=l.defineGeomStyleTarget;exports.describeMeasurementBasis=m.describeMeasurementBasis;exports.ensureReadableTextColor=l.ensureReadableTextColor;exports.extractPlainText=ua;exports.filterLayersByGeoms=m.filterLayersByGeoms;exports.findAnnotation=m.findAnnotation;exports.findAverageLineLayer=di;exports.findAxisGuide=Nt;exports.findCompanionLayers=m.findCompanionLayers;exports.findDefaultKitStyleTarget=m.findDefaultKitStyleTarget;exports.findDistinctLayers=m.findDistinctLayers;exports.findEquivalentHighlight=Up;exports.findGoalLineLayer=ci;exports.findHighlightsAtObservation=Xu;exports.findKindStyleDeclarations=de;exports.findLayerByGeom=m.findLayerByGeom;exports.findLayerById=m.findLayerById;exports.findLegendForAesthetic=Ed;exports.findObservationAttachment=si;exports.findPointerRegion=Nu;exports.findStyleRule=ue;exports.findStyleRuleIndex=Jt;exports.findTrendLineLayer=ui;exports.formatDifferenceLabel=jn;exports.formatHeadline=vd;exports.formatLegends=Td;exports.formatRuleValue=Rd;exports.geom=l.geom;exports.getAestheticFromScaleAestheticKey=l.getAestheticFromScaleAestheticKey;exports.getAlpha=l.getAlpha;exports.getAngleExtent=l.getAngleExtent;exports.getBarRectBounds=Ea;exports.getBoundingRect=Fd;exports.getColor=l.getColor;exports.getCrossAxisCoordinate=m.getCrossAxisCoordinate;exports.getCurve=Ge;exports.getDifferenceArrowDimensions=Zn;exports.getDifferenceArrowLabelBox=na;exports.getGroup=m.getGroup;exports.getGroupVariables=l.getGroupVariables;exports.getHoverGuideLineProps=Ph;exports.getHoverGuideRectProps=Mh;exports.getInsetTileRect=l.getInsetTileRect;exports.getLineType=l.getLineType;exports.getMainAxisCoordinate=m.getMainAxisCoordinate;exports.getNumericWeight=fr;exports.getPaintedTileRect=l.getPaintedTileRect;exports.getPointSymbolOuterRadius=Ud;exports.getPolarHoverGuideArcProps=Dh;exports.getRadiusExtent=l.getRadiusExtent;exports.getScaledAesthetic=l.getScaledAesthetic;exports.getShapeAnnotationStroke=Lp;exports.getSize=l.getSize;exports.getStackRole=l.getStackRole;exports.getStrokeWidth=l.getStrokeWidth;exports.getTileRectBounds=l.getTileRectBounds;exports.getUnionExtent=Zd;exports.getX=l.getX;exports.getXMax=l.getXMax;exports.getXMin=l.getXMin;exports.getY=l.getY;exports.getYMax=l.getYMax;exports.getYMin=l.getYMin;exports.getYRaw=l.getYRaw;exports.hasMainAxisBand=Sa;exports.hasMultipleGroups=l.hasMultipleGroups;exports.highlight=b.highlight;exports.inferDefaultDifferenceArrowEndpoints=Zu;exports.inferDifferenceArrowEndpoints=ya;exports.inferXVariable=l.inferXVariable;exports.isAnnotationMovable=rf;exports.isBorderRadiusToken=l.isBorderRadiusToken;exports.isCartesian=m.isCartesian;exports.isCategoricalValueFormat=l.isCategoricalValueFormat;exports.isComboChartType=me;exports.isCompanionLayer=m.isCompanionLayer;exports.isCompilerCachingEnabled=l.isCompilerCachingEnabled;exports.isCurrencyValueFormat=l.isCurrencyValueFormat;exports.isDateWithoutYearValueFormat=l.isDateWithoutYearValueFormat;exports.isFullTurnSweep=l.isFullTurnSweep;exports.isGeomStyleRule=Qt;exports.isGradientPaint=l.isGradientPaint;exports.isImagePaint=l.isImagePaint;exports.isKeyedScope=Be;exports.isLayerOf=z;exports.isLayerSpecOf=m.isLayerSpecOf;exports.isLineType=l.isLineType;exports.isLookupValueFormat=l.isLookupValueFormat;exports.isNumericValueFormat=l.isNumericValueFormat;exports.isObservationAttachmentKind=$p;exports.isPatternPaint=l.isPatternPaint;exports.isPointWithinEditMenuTrigger=zu;exports.isPointWithinRegionShape=Vt;exports.isPositionScale=l.isPositionScale;exports.isSafeUrl=sp;exports.isStackedPosition=l.isStackedPosition;exports.isTemporalValueFormat=l.isTemporalValueFormat;exports.isZeroAnchoredAxis=Qu;exports.mapping=b.mapping;exports.measureObservationsBoxes=td;exports.normalizeAngle=l.normalizeAngle;exports.orderPointerRegions=Fu;exports.paintKey=l.paintKey;exports.paintsInDonutHole=Fe;exports.pickFilters=ni;exports.pickReadableTextColor=l.pickReadableTextColor;exports.pipe=b.pipe;exports.placeCallouts=gu;exports.polarToUnit=l.polarToUnit;exports.positionToAngle=l.positionToAngle;exports.prefixInternalVariable=l.prefixInternalVariable;exports.prepareAreaObservations=kd;exports.prepareLineObservations=$d;exports.projectAnchorToPanel=Pe;exports.projectRegionToPanel=sa;exports.quantizeKey=_;exports.readAnchoredObservation=ad;exports.readAttachedObservation=jt;exports.readAuthoredNumber=bp;exports.readAuthoredString=xp;exports.readBroadestObservationsScope=ga;exports.readChartType=Af;exports.readColorGroupObservation=cm;exports.readComboLineLayerId=Lf;exports.readCompanionRowsAtScopeKey=Cu;exports.readConstantValue=l.readConstantValue;exports.readEditTargetKey=bt;exports.readFoldKeepVariables=l.readFoldKeepVariables;exports.readGeomColor=Ht;exports.readGeomEffects=jh;exports.readHighlightDimStyle=ko;exports.readMainAxis=m.readMainAxis;exports.readMainAxisVariable=l.readMainAxisVariable;exports.readMappableAesthetics=ny;exports.readMappedVariable=Xi;exports.readObservationIndex=Oh;exports.readReachableLevels=ld;exports.readRowScopeKey=pa;exports.readRowsAtScopeKey=kt;exports.readScopeXVariable=m.readScopeXVariable;exports.readVariableName=l.readVariableName;exports.readXExtent=ti;exports.readYExtent=ri;exports.removeAlpha=l.removeAlpha;exports.resolveAnchorVariable=m.resolveAnchorVariable;exports.resolveAnchoredLabelCenter=l.resolveAnchoredLabelCenter;exports.resolveArrowAnnotationStyle=Ap;exports.resolveArrowColor=Iu;exports.resolveBarBandFraction=l.resolveBarBandFraction;exports.resolveBarBaseline=Gt;exports.resolveBarBorderTreatment=Nd;exports.resolveBarCornerRadiiPx=Vd;exports.resolveBarCornerRadiusPx=Bt;exports.resolveBarPaintOrigin=Bd;exports.resolveCalloutAnnotationStyle=Tp;exports.resolveChromeMargin=P;exports.resolveChromeMargins=wp;exports.resolveColorRamp=m.resolveColorRamp;exports.resolveComparisonBasis=m.resolveComparisonBasis;exports.resolveDataLabelStyle=ic;exports.resolveDeferredAnchors=Uc;exports.resolveDefinition=l.resolveDefinition;exports.resolveDifferenceArrowAnnotationStyle=Ip;exports.resolveDirectLabelStyle=cc;exports.resolveEditOutlineStyle=Cp;exports.resolveGeomAnchorSpace=m.resolveGeomAnchorSpace;exports.resolveGraphPadding=Rp;exports.resolveHeadlineItemStyle=uc;exports.resolveHeadlineNumberStyle=dc;exports.resolveHeadlinePlacement=Mc;exports.resolveLegendItemStyle=lc;exports.resolveObservationPoint=hd;exports.resolveObservationsTarget=ba;exports.resolvePanelBorderStyle=Ep;exports.resolvePolarBarCornerRadiusUnit=jd;exports.resolveRuleLabelStyle=oc;exports.resolveSegmentYSource=m.resolveSegmentYSource;exports.resolveSwatchGeomPaint=Kt;exports.resolveTooltipStyle=sc;exports.resolveYScaleAesthetic=l.resolveYScaleAesthetic;exports.sampleColorScheme=m.sampleColorScheme;exports.scale=b.scale;exports.setCompilerCachingEnabled=l.setCompilerCachingEnabled;exports.stat=b.stat;exports.stepDifferenceArrowEndpoint=pd;exports.style=b.style;exports.styles=b.styles;exports.toDashPreset=Ot;exports.toFontSpec=ac;exports.toPaintColor=l.toPaintColor;exports.toPanelCursor=ca;exports.toPercent=Y;exports.toSpec=mi;exports.toStrokeDasharray=la;exports.toViewBoxX=$c;exports.toViewBoxY=F;exports.token=l.token;exports.transform=b.transform;exports.truncateToWidth=Dn;exports.unitToPolar=l.unitToPolar;exports.updateSpec=m.updateSpec;exports.withAlpha=l.withAlpha;