@graphysdk/viz-engine 1.9.0-beta.1791444651663 → 1.9.0-beta.1791447671234

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-BEb-h7gP.cjs"),d=require("./compiler-HmW8owZ7.cjs"),b=require("./spec-builder-n8kRICtS.cjs");let bt=require("lodash-es"),ie=require("lodash-es/clamp");ie=l.__toESM(ie,1);let it=require("humanize-duration");it=l.__toESM(it,1);let R=require("d3-shape"),dl=require("d3-delaunay"),W=require("lodash-es/isEqual");W=l.__toESM(W,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1791444651663");var ml=1e6;function k(e){return String(Math.round(e*ml))}function U(e,t){return e.geom===t}var Xe="…",kn=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Xe)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Xe)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Xe};var L={timeZone:"UTC"},T=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},K=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",xt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",ve=new Map,ye=new Map,Vn=256,ce=(e,t)=>{const r=Nn(e,t),n=ve.get(r);if(n!==void 0)return n;ve.size>=Vn&&ve.clear();const a=new Intl.NumberFormat(e,t);return ve.set(r,a),a},E=(e,t)=>{const r=Nn(e,t),n=ye.get(r);if(n!==void 0)return n;ye.size>=Vn&&ye.clear();const a=new Intl.DateTimeFormat(e,t);return ye.set(r,a),a},Nn=(e,t)=>`${e}\0${JSON.stringify(t)}`,hl=it.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),Oe={signDisplay:"negative"},Fn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>K(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=Tt(a,i),{base:s,suffix:c}=It(a,r.abbreviation);return`${ce(t,{...o,...Oe,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Bn=({locale:e,numberFormat:t,intlOptions:r})=>K(n=>{const{base:a,suffix:i}=It(n,t.abbreviation);return`${ce(e,{...Tt(a,t.decimals),...Oe,...r}).format(a)}${i}`}),At=e=>K(t=>{const r=hl(Math.abs(t));return t<0?`-${r}`:r}),Gn=({locale:e,intlOptions:t})=>{const r=ce(e,{maximumFractionDigits:0,...Oe,...t});return K(n=>r.format(n))},Hn=({locale:e,numberFormat:t,intlOptions:r})=>K(n=>ce(e,{...Tt(n,t.decimals),...Oe,...r,style:"percent"}).format(n)),It=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=pl(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}},pl=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"},fl=1440*60*1e3,gl=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.format(n))},vl=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",timeStyle:"medium",...L,...t});return T(n=>yl(r.formatToParts(n)))},$n=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",...L,...t});return T(n=>r.format(n))},Kn=({locale:e,intlOptions:t})=>{const r=E(e,{month:"long",...L,...t});return T(n=>r.format(n))},Lt=({locale:e,intlOptions:t})=>{const r=E(e,{month:"short",year:"numeric",...L,...t});return T(n=>r.format(n))},Et=e=>T(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),Yn=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",...L,...t,year:void 0});return T(n=>r.formatRange(n,Wn(n,6)))},zn=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.formatRange(n,Wn(n,6)))},Rt=({locale:e,intlOptions:t})=>{const r=E(e,{year:"numeric",...L,...t});return T(n=>r.format(n))},Un=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},Wn=(e,t)=>new Date(e.getTime()+t*fl),yl=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("")},yr=1e3,Sl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>K(a=>{const i={...wt(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Ct(a,t,i)}),bl=({locale:e,tickValues:t,intlOptions:r})=>K(n=>{const a={...wt(n,t),notation:"compact",...r};return Ct(n,e,a)}),xl=({locale:e,tickValues:t,intlOptions:r})=>K(n=>{const a={...wt(n,t),notation:"compact",...r,style:"percent"};return Ct(n,e,a)}),Ct=(e,t,r)=>ce(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),Xn=e=>Math.abs(e)>yr?Xn(e/yr):Number.isInteger(e),Al=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)=>Xn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:Al(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:Math.max(1,Il(t))},Il=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))},Tl=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},Ll=({locale:e,intlOptions:t})=>{const r=E(e,{month:"short",...L,...t});return T(n=>r.format(n))},El=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},Rl=({locale:e,intlOptions:t,tickValues:r})=>{const n=E(e,{...wl(r),...L,...t});return T(a=>n.format(a))},Cl=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},wl=e=>{const t=e.filter(r=>r instanceof Date&&!Number.isNaN(r.getTime()));return t.length===0?{day:"numeric",month:"short"}:Pl(t).size>1?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{timeStyle:"short"}},Pl=e=>{const t=new Set;for(const r of e)t.add(`${r.getUTCFullYear()}-${r.getUTCMonth()}-${r.getUTCDate()}`);return t},Pt=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return Sl(e);case"date":return Tl(e);case"datetime":return Rl(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return El(e);case"decimal":case"integer":return bl(e);case"duration":return At(e);case"month":return Ll(e);case"month_year":return Lt(e);case"percentage":return xl(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return Cl(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,Dl=1/3,Ol=1/4,_l=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?kl(e):Vl(e),kl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=qn(e.ticks,n),s=Nl(e.ticks,r.width),c=s*Ml;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const m=st(c);return{...e,ticks:ot(e.ticks,a,m,n),labelRotation:0,labelMaxWidthPx:m}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=st(r.height*Dl);return{...e,ticks:ot(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}=qn(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=st(r.width*Ol);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:ot(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},Nl=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},qn=(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}},ot=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:kn(i.formattedLabel,r,a)})},st=e=>Math.max(0,Math.floor(e)),Fl=(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:m}=a(t(c));if(s-=i?u:m,s<0)return!1}return!0},Bl={ticks:[],labelAt:()=>""},Gl=({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?$l(g.ticks,n(g)):Bl;return o.set(p,S),S};let c=0,u=a.length-1,m=-1;for(;c<=u;){const p=c+u>>>1,{ticks:f,labelAt:g}=s(p);Fl(f.length,g,i,t,r)?(m=p,c=p+1):u=p-1}const h=Hl(m,s);return Kl(s(h))},Hl=(e,t)=>{const r=e>=0?e:0;for(let n=r;n>=0;n-=1){const{ticks:a,labelAt:i}=t(n);if(Yl(a,i))return n}return 0},$l=(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}}},Kl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Yl=(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},zl=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 Fn(e);case"date":return gl(e);case"datetime":return vl(e);case"day_month":return $n(e);case"decimal":return Bn(e);case"duration":return At(e);case"integer":return Gn(e);case"month":return Kn(e);case"month_year":return Lt(e);case"percentage":return Hn(e);case"quarter":return Et(e);case"text":return xt(e);case"weekly_date_range":return Yn(e);case"weekly_date_range_with_year":return zn(e);case"year":return Rt(e);case"time":return Un(e);case"lookup":return zl({...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:d.getLayerYValueFormat(e),locale:r,numberFormat:t})}var Ul=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:d.createXValueReader(e,t),variable:r}:{read:d.getGroup,variable:l.GROUP_VARIABLES.group}},jn=({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}),m=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,styleReaders:o.geom(e),formatLabel:Zl({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:m}),formatAbsolute:u,formatCategory:Wl({layer:e,numberFormat:n,locale:s})}},Wl=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=Ul(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)}},Xl=(e,t,r)=>{switch(t){case"stack":return ql(e);case"fill":return jl(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},ql=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(d.getObservationXKey(a,t));return s===void 0?null:s.total}},jl=(e,t)=>{const r=t?l.getXMin:l.getYMin,n=t?l.getXMax:l.getYMax,a=d.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}},Zl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=d.createRawValueReader(e.data,e.dataLabels.labelSource),c=Xl(e,i,o),u=Jl({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),m=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&Zn(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):m(f/g)}},Jl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Zn(e))return a;const s=Ql(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:ec(e.data,i),locale:n,numberFormat:t})},Zn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(d.resolveSegmentYSource(e.position,e.mapping))},Ql=(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})},ec=(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)},tc={cartesian:["cartesian","flip"],polar:["polar"]},rc=null;function Jn(e=[]){const t=nc(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!tc[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 rc??=Jn()}function 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*ac({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 m=c.resolve(u.geom,"cartesian");if(m===null)continue;const h=jn({layer:u,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:m.getPercentageValueStrategy(u)});for(const p of m.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 qe={abbreviation:"none",decimals:"auto"},Qn=({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:qe,intlOptions:{signDisplay:"always"}})(i);return Sr(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:qe,intlOptions:{signDisplay:"always"}})(o);return Sr(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:qe,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},Sr=e=>{const t=e.replace(/[^\d.]/g,"");return t===""||t==="."?!1:Number(t)===0},ic=2,oc=6,sc=6,lc=15,cc=15,uc=2.5,dc=.5,mc=.25,ea=e=>{const t=e-ic,r=1+dc*t,n=1+mc*t;return{arrowStartGap:oc*r,arrowEndGap:sc*r,offsetFromHigherObservation:lc*n,arrowheadSize:uc*e,curveRadius:cc*n,strokeWidth:e}},hc=(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},pc=(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},m=t.x>e.x?1:-1;return`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./annotations-BEb-h7gP.cjs"),d=require("./compiler-HmW8owZ7.cjs"),b=require("./spec-builder-n8kRICtS.cjs");let bt=require("lodash-es"),ie=require("lodash-es/clamp");ie=l.__toESM(ie,1);let it=require("humanize-duration");it=l.__toESM(it,1);let R=require("d3-shape"),hl=require("d3-delaunay"),W=require("lodash-es/isEqual");W=l.__toESM(W,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1791447671234");var pl=1e6;function k(e){return String(Math.round(e*pl))}function U(e,t){return e.geom===t}var Xe="…",kn=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Xe)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Xe)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Xe};var L={timeZone:"UTC"},T=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},K=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",xt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",ve=new Map,ye=new Map,Vn=256,ce=(e,t)=>{const r=Nn(e,t),n=ve.get(r);if(n!==void 0)return n;ve.size>=Vn&&ve.clear();const a=new Intl.NumberFormat(e,t);return ve.set(r,a),a},E=(e,t)=>{const r=Nn(e,t),n=ye.get(r);if(n!==void 0)return n;ye.size>=Vn&&ye.clear();const a=new Intl.DateTimeFormat(e,t);return ye.set(r,a),a},Nn=(e,t)=>`${e}\0${JSON.stringify(t)}`,fl=it.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),Oe={signDisplay:"negative"},Fn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>K(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=Tt(a,i),{base:s,suffix:c}=It(a,r.abbreviation);return`${ce(t,{...o,...Oe,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Bn=({locale:e,numberFormat:t,intlOptions:r})=>K(n=>{const{base:a,suffix:i}=It(n,t.abbreviation);return`${ce(e,{...Tt(a,t.decimals),...Oe,...r}).format(a)}${i}`}),At=e=>K(t=>{const r=fl(Math.abs(t));return t<0?`-${r}`:r}),Gn=({locale:e,intlOptions:t})=>{const r=ce(e,{maximumFractionDigits:0,...Oe,...t});return K(n=>r.format(n))},Hn=({locale:e,numberFormat:t,intlOptions:r})=>K(n=>ce(e,{...Tt(n,t.decimals),...Oe,...r,style:"percent"}).format(n)),It=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=gl(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}},gl=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"},vl=1440*60*1e3,yl=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.format(n))},Sl=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",timeStyle:"medium",...L,...t});return T(n=>bl(r.formatToParts(n)))},$n=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",...L,...t});return T(n=>r.format(n))},Kn=({locale:e,intlOptions:t})=>{const r=E(e,{month:"long",...L,...t});return T(n=>r.format(n))},Lt=({locale:e,intlOptions:t})=>{const r=E(e,{month:"short",year:"numeric",...L,...t});return T(n=>r.format(n))},Et=e=>T(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),zn=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",...L,...t,year:void 0});return T(n=>r.formatRange(n,Wn(n,6)))},Yn=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.formatRange(n,Wn(n,6)))},Rt=({locale:e,intlOptions:t})=>{const r=E(e,{year:"numeric",...L,...t});return T(n=>r.format(n))},Un=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},Wn=(e,t)=>new Date(e.getTime()+t*vl),bl=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("")},yr=1e3,xl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>K(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})=>K(n=>{const a={...wt(n,t),notation:"compact",...r};return Ct(n,e,a)}),Il=({locale:e,tickValues:t,intlOptions:r})=>K(n=>{const a={...wt(n,t),notation:"compact",...r,style:"percent"};return Ct(n,e,a)}),Ct=(e,t,r)=>ce(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),Xn=e=>Math.abs(e)>yr?Xn(e/yr):Number.isInteger(e),Tl=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)=>Xn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:Tl(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:Math.max(1,Ll(t))},Ll=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))},El=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},Rl=({locale:e,intlOptions:t})=>{const r=E(e,{month:"short",...L,...t});return T(n=>r.format(n))},Cl=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},wl=({locale:e,intlOptions:t,tickValues:r})=>{const n=E(e,{...Ml(r),...L,...t});return T(a=>n.format(a))},Pl=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},Ml=e=>{const t=e.filter(r=>r instanceof Date&&!Number.isNaN(r.getTime()));return t.length===0?{day:"numeric",month:"short"}:Dl(t).size>1?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{timeStyle:"short"}},Dl=e=>{const t=new Set;for(const r of e)t.add(`${r.getUTCFullYear()}-${r.getUTCMonth()}-${r.getUTCDate()}`);return t},Pt=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return xl(e);case"date":return El(e);case"datetime":return wl(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return Cl(e);case"decimal":case"integer":return Al(e);case"duration":return At(e);case"month":return Rl(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 Pl(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}`})}},Ol=.9,_l=1/3,kl=1/4,Vl=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?Nl(e):Fl(e),Nl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=qn(e.ticks,n),s=Bl(e.ticks,r.width),c=s*Ol;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const m=st(c);return{...e,ticks:ot(e.ticks,a,m,n),labelRotation:0,labelMaxWidthPx:m}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=st(r.height*_l);return{...e,ticks:ot(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},Fl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=qn(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=st(r.width*kl);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:ot(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},Bl=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},qn=(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}},ot=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:kn(i.formattedLabel,r,a)})},st=e=>Math.max(0,Math.floor(e)),Gl=(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:m}=a(t(c));if(s-=i?u:m,s<0)return!1}return!0},Hl={ticks:[],labelAt:()=>""},$l=({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?zl(g.ticks,n(g)):Hl;return o.set(p,S),S};let c=0,u=a.length-1,m=-1;for(;c<=u;){const p=c+u>>>1,{ticks:f,labelAt:g}=s(p);Gl(f.length,g,i,t,r)?(m=p,c=p+1):u=p-1}const h=Kl(m,s);return Yl(s(h))},Kl=(e,t)=>{const r=e>=0?e:0;for(let n=r;n>=0;n-=1){const{ticks:a,labelAt:i}=t(n);if(Ul(a,i))return n}return 0},zl=(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}}},Yl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Ul=(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},Wl=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 Fn(e);case"date":return yl(e);case"datetime":return Sl(e);case"day_month":return $n(e);case"decimal":return Bn(e);case"duration":return At(e);case"integer":return Gn(e);case"month":return Kn(e);case"month_year":return Lt(e);case"percentage":return Hn(e);case"quarter":return Et(e);case"text":return xt(e);case"weekly_date_range":return zn(e);case"weekly_date_range_with_year":return Yn(e);case"year":return Rt(e);case"time":return Un(e);case"lookup":return Wl({...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:d.getLayerYValueFormat(e),locale:r,numberFormat:t})}var Xl=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:d.createXValueReader(e,t),variable:r}:{read:d.getGroup,variable:l.GROUP_VARIABLES.group}},jn=({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}),m=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,styleReaders:o.geom(e),formatLabel:Ql({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:m}),formatAbsolute:u,formatCategory:ql({layer:e,numberFormat:n,locale:s})}},ql=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=Xl(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)}},jl=(e,t,r)=>{switch(t){case"stack":return Zl(e);case"fill":return Jl(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},Zl=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(d.getObservationXKey(a,t));return s===void 0?null:s.total}},Jl=(e,t)=>{const r=t?l.getXMin:l.getYMin,n=t?l.getXMax:l.getYMax,a=d.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}},Ql=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=d.createRawValueReader(e.data,e.dataLabels.labelSource),c=jl(e,i,o),u=ec({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),m=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&Zn(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):m(f/g)}},ec=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Zn(e))return a;const s=tc(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:rc(e.data,i),locale:n,numberFormat:t})},Zn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(d.resolveSegmentYSource(e.position,e.mapping))},tc=(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})},rc=(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)},nc={cartesian:["cartesian","flip"],polar:["polar"]},ac=null;function Jn(e=[]){const t=ic(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!nc[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 ac??=Jn()}function ic(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*oc({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 m=c.resolve(u.geom,"cartesian");if(m===null)continue;const h=jn({layer:u,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:m.getPercentageValueStrategy(u)});for(const p of m.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 qe={abbreviation:"none",decimals:"auto"},Qn=({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:qe,intlOptions:{signDisplay:"always"}})(i);return Sr(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:qe,intlOptions:{signDisplay:"always"}})(o);return Sr(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:qe,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},Sr=e=>{const t=e.replace(/[^\d.]/g,"");return t===""||t==="."?!1:Number(t)===0},sc=2,lc=6,cc=6,uc=15,dc=15,mc=2.5,hc=.5,pc=.25,ea=e=>{const t=e-sc,r=1+hc*t,n=1+pc*t;return{arrowStartGap:lc*r,arrowEndGap:cc*r,offsetFromHigherObservation:uc*n,arrowheadSize:mc*e,curveRadius:dc*n,strokeWidth:e}},fc=(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},gc=(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},m=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+m*i} ${s.y}
5
5
  L ${c.x-m*i} ${c.y}
6
6
  Q ${c.x} ${c.y} ${c.x} ${c.y+i}
7
7
  L ${u.x} ${u.y}
8
- `},fc=(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},m=t.y>e.y?1:-1;return`
8
+ `},vc=(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},m=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+m*i}
12
12
  L ${c.x} ${c.y-m*i}
13
13
  Q ${c.x} ${c.y} ${c.x-i} ${c.y}
14
14
  L ${u.x} ${u.y}
15
- `},gc=(e,t,{arrowEndGap:r,arrowheadSize:n})=>e?`
15
+ `},yc=(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
- `,vc=(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},yc=(e,t,r)=>Math.abs(e?t.y-r.y:t.x-r.x),ta=({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=ea(t.strokeWidth),m=hc(o,s,c,u),h=(o?fc:pc)(s,c,m,u),p=gc(o,c,u),f=vc(o,s,c,m,yc(o,s,c),e.labelCrossPosition),g=Qn({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}},br=new WeakMap,Sc=e=>{const t=n=>e(n),r=Ar(t,n=>a=>e(a,n));return Ar(t,()=>r)},bc=(e,t,r)=>{const n=Lr(e.graph,Ir(l.STYLE_TARGETS.graph,{}),r),a=Er(n,n,l.STYLE_TARGETS.graph.vocabulary),i=(s,c)=>s===l.STYLE_TARGETS.graph?a:Er(Lr(e[s.select.target],Ir(s,c),r),a,s.vocabulary),o=s=>{const c=Object.fromEntries(Object.entries(s.children??{}).map(([m,h])=>[m,o(h)]));if((s.options??[]).includes("annotation"))return Object.assign(Ic(m=>i(s,{annotation:m})),c);if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&xc(s)){const m=new Map;return Object.assign(h=>{const p=m.get(h);if(p!==void 0)return p;const f=i(s,{axis:h});return m.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)]))},xr=e=>e.list==="builtin"||e.list==="theme"?e.list:"authored",Ot=e=>e==="theme"||e==="authored",Ar=(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}})},xc=e=>{const t=l.findStyleTarget({target:e.select.target})??e;return Object.values(t.children??{}).some(r=>r.select.axis!==void 0)},Ir=(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}},Tr=(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}},Lr=(e,t,r)=>{const n=c=>Tr(e.overrides,c,t)??Tr(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":xr(u.origin)},explain:c=>{const u=n(c),m=u?.declarations[c];return u===void 0||m===void 0?{value:void 0,source:"unresolved"}:{value:l.resolveColorScheme(m,r),source:xr(u.origin),origin:u.origin,select:u.select}},collectAll:c=>{const u=[];for(const m of[e.defaults,e.overrides])for(const h of m){if(!t(h))continue;const p=h.declarations[c];p!==void 0&&u.push(l.resolveColorScheme(p,r))}return u}}},Ac=(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"))},Er=(e,t,r)=>({...e,resolve:()=>{const n=br.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 Ac(a,t,r),br.set(e,a),a}}),Ic=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}},Rr={large:1,medium:23/26,small:19/26},je={large:1,medium:10/12,small:10/12},ra=["fontStyle","letterSpacing","textTransform","textDecoration","textOutlineColor","textOutlineWidth","textShadow"],na=["fontFamily","fontSize","fontWeight","lineHeight","textColor",...ra],aa=e=>e.fontSize*e.lineHeight,Tc=(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}}),Lc=(e,t,r)=>{const n=t==="aggregate"?e.dataLabel.aggregate():e.dataLabel[t][r](),a=n.getSource("textColor");return{...n.resolve(),isTextColorAuthored:a==="authored",isTextColorThemed:a==="theme"}},Ec=(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}:{},isTextColorThemed:a==="theme",...Dc(e)}},Rc=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()}),Cc=e=>({item:e.legendItem().resolve(),swatch:e.legendItem.swatch().resolve()}),wc=e=>{const t=e.directLabel();return{...t.resolve(),isTextColorAuthored:Ot(t.getSource("textColor"))}},Pc=(e,t)=>{const r=e.headlineItem,n=r.number().resolve(),a={...n,fontSize:n.fontSize*Rr[t]},i=r.number.center(),o=i.resolve().fontSize;return{gap:r().resolve().gap,number:a,...Oc(i)?{numberCenter:Se(i,o===void 0?a.fontSize:o*Rr[t])}:{},caption:Se(r.caption(),r.caption().resolve().fontSize*je[t]),label:Se(r.label(),r.label().resolve().fontSize*je[t]),swatch:r.swatch().resolve(),trend:Se(r.trend(),r.trend().resolve().fontSize*je[t]),trendUp:r.trend.up().resolve(),trendDown:r.trend.down().resolve(),trendFlat:r.trend.flat().resolve()}},Mc=(e,t)=>{const r=t?e.numberCenter:void 0;return r===void 0?e.number:{...e.number,...ia(r)}},Dc=e=>{const t={};for(const r of ra){const n=e.get(r);n!==void 0&&Object.assign(t,{[r]:n})}return t},Oc=e=>na.some(t=>e.getSource(t)!=="unresolved"),Se=(e,t)=>({...ia(e.resolve()),fontSize:t}),ia=e=>{const t={};for(const r of na){const n=e[r];n!==void 0&&Object.assign(t,{[r]:n})}return t},oa=({labelPosition:e,measuredTextWidth:t,label:r})=>{const n=t+2*r.paddingInline,a=aa(r)+2*r.paddingBlock;return{x:e.x-n/2,y:e.y-a/2,width:n,height:a}};function*_c({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=ta({arrow:o,style:s,mainAxis:t,panelWidth:r.width,panelHeight:r.height,locale:n}),u=oa({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 kc=e=>{const t=e.padding,r=Cr(e.rows,t?.top??0,t?.bottom??0),n=Cr(e.cols,t?.left??0,t?.right??0);return{rows:r.tracks,cols:n.tracks,placements:Bc(e.placements,r.nameToIndex,n.nameToIndex),width:e.containerSize.width,height:e.containerSize.height}},Vc=e=>{const t=wr(e.rows,e.height),r=wr(e.cols,e.width),n=Pr(t),a=Pr(r),i=new Map;for(const o of e.placements){const s=o.rowSpan??1,c=o.colSpan??1,u=a[o.col]??0,m=n[o.row]??0,h=Mr(r,o.col,c),p=Mr(t,o.row,s);i.set(o.name,{x:u,y:m,width:Math.max(0,h),height:Math.max(0,p)})}return i},Cr=(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;lt(s)&&i>0&&(n.push({type:"fixed",pixels:i}),i=0),a.set(s.name,n.length),n.push(Nc(s));const c=Fc(e,o);if(lt(s)&&c){const u=s.gaps?.after??0,m=c.gaps?.before??0;u>=m?u>0&&n.push({type:"fixed",pixels:u}):i=m}}return r>0&&n.push({type:"fixed",pixels:r}),{tracks:n,nameToIndex:a}},Nc=e=>typeof e.size=="number"?{type:"fixed",pixels:e.size}:{type:"flex",weight:e.size.flex},lt=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Fc=(e,t)=>{for(let r=t+1;r<e.length;r++){const n=e[r];if(n&&lt(n))return n}},Bc=(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},wr=(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)},Pr=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},Mr=(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},Q={top:0,right:0,bottom:0,left:0},sa={outer:Q,inner:Q},Gc=(e,t,r,n=Q,a=sa,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)}],m=[{name:"leftLegend",size:r.legends.left,gaps:be(o.legend.left)},{name:"leftAxis",size:r.axes.left,gaps:be(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:be(o.tickLabel.right)},{name:"rightLegend",size:r.legends.right,gaps:be(o.legend.right)}],h=Dr(u,i.top,i.bottom),p=Dr(m,i.left,i.right);return kc({rows:u,cols:m,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"},...$c(r.axes),...Kc(r.axesLabels,r.axes),...Yc(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}),be=e=>({before:e.left,after:e.right}),Hc=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Dr=(e,t,r)=>{const n=e.filter(Hc),a=n[0],i=n[n.length-1];return{start:t+(a?.gaps?.before??0),end:r+(i?.gaps?.after??0)}},$c=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},Kc=(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},Yc=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 zc=class{constructor(e){this.outer={...Q},this.inner={...Q},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)))}},Uc=["top","right","bottom","left"],Ze=(e,t)=>{const r={};for(const n of Uc){const a=e.get(`${n}${t}`);a&&(r[n]=a)}return r};function Or(e,t){return e.top===t.top&&e.right===t.right&&e.bottom===t.bottom&&e.left===t.left}var ct=["large","medium","small"],Wc=({size:e,availableWidth:t,measureStripWidth:r})=>{if(e!=="auto")return e;for(const n of ct)if(r(n)<=t)return n;return"small"},Xc=({size:e,availableWidth:t,measureStripWidth:r})=>{const n=e==="auto"?0:ct.indexOf(e);for(const a of ct.slice(n))if(r(a)<=t)return a;return null},qc=({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},jc=({headline:e,containerSize:t,measurer:r})=>{if(_e(e))return 0;const n=la(e,t.width,r);return r.measureHeadline(e.formatted,n).height},Zc=({headline:e,layout:t,containerSize:r,measurer:n,itemGap:a})=>{if(_e(e)){const s=Jc(t.panel,e.innerRadius),c=Xc({size:e.size,availableWidth:s.width,measureStripWidth:ca(e,n)});return c===null?null:{rect:s,resolvedSize:c,visibleItemCount:1}}const i=la(e,r.width,n);if(e.formatted.kind!=="perGroup")return{rect:t.headline,resolvedSize:i,visibleItemCount:1};const o=qc({itemWidths:n.measureHeadlineItemWidths(e.formatted,i),gap:a,availableWidth:t.headline.width});return o===0?null:{rect:t.headline,resolvedSize:i,visibleItemCount:o}},_e=e=>e.formatted.kind==="grandTotal"&&e.position==="center"&&e.innerRadius>0,Jc=(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}},la=(e,t,r)=>Wc({size:e.size,availableWidth:t,measureStripWidth:ca(e,r)}),ca=(e,t)=>r=>t.measureHeadline(e.formatted,r,_e(e)).width,q={x:0,y:0,width:0,height:0},Qc={top:0,right:0,bottom:0,left:0},eu="0000",tu=3,ru=e=>e.plot.y+e.plot.height-e.panel.y,nu=class{constructor(e){this.measurer=e}compile(e){return d.createPipeline({axes:e.axes,numberFormat:e.numberFormat,formattedLegends:e.formattedLegends,containerSize:e.containerSize,externalMeasurements:e.externalMeasurements,panelOverflow:sa,panelBorder:e.panelBorder??Q,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:au(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(m=>m.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=>_r(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(m=>m.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=>_r(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:m,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:m,margins:h})})).pipe(({formattedAxes:t,layout:r})=>{const n=this.applyPolarPanelInset(e,t,r);return{formattedAxes:t,layout:n,plotBottomY:ru(n)}}).result()}measurePanelOverflow(e,t,r,n){if(!e.overflowStrategy||e.coordSystem?.type!=="cartesian")return n;const a=new zc(t);if(e.annotations&&e.resolveDifferenceArrowStyle&&e.overflowStrategy.differenceArrows)for(const o of _c({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 ac({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 Or(i.inner,n.inner)&&Or(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:m,margins:h}){let p=t,f=o;for(let g=0;g<tu;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:m,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?kr(r,a,0,0):kr(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:eu}],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=m=>this.measurer.measureTickLabel(m,a),o=Gl({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?_l({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=Vc(Gc(r,n,this.measureGuides(e,t,o,r),i,a,s,iu(c,t)));return{header:u.get("header")??q,headline:u.get("headline")??q,footer:u.get("footer")??q,plot:u.get("plot")??q,panelFrame:u.get("panelFrame")??q,panel:u.get("panel")??q,axes:Ze(u,"Axis"),axisLabels:Ze(u,"AxisLabel"),legends:Ze(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:jc({headline:e,containerSize:t,measurer:this.measurer})}},_r=e=>e==="left"||e==="right",kr=(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}}},au=(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}},iu=(e,t)=>{const r={...e.legend};for(const n of t)n.display==="direct"&&(r[n.position]=Qc);return{...e,legend:r}},ou=(e=[])=>{const t=su(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:d.resolveGeomAnchorSpace(a.coordSystem)}},hasCapability:r=>t.has(r)&&t.get(r).resolveAnchorPosition!==void 0,createLayerMeasurement:r=>t.has(r.geom)?d.createLayerMeasurement(r,t.get(r.geom)):null}},su=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 lu(e){return e}function N(e){return 1-e}var z=e=>`${Number.parseFloat((e*100).toFixed(4))}%`,Re=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+N(e.y)*r.height}},ua=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+(N(e.y)-e.height)*r.height,width:e.width*r.width,height:e.height*r.height}},cu=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}=ut(e.defer,this.panelRect);return Fr({...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}=uu(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}=ut(e.defer,this.panelRect);return Fr({...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:du(this.toPanelRegion(r))}case"arrow":{const r=this.resolvePoint(t.annotation.start),n=this.resolvePoint(t.annotation.end);return r===null||n===null?null:Vr(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:Nr(this.toPanelPoint(r))}case"differenceArrow":return Vr(this.toPanelPoint(t.annotation.start),this.toPanelPoint(t.annotation.end));case"pinnedNumber":case"comment":return Nr(this.toPanelPoint(t.annotation.at))}}toPanelPoint(e){return d.toPanelFraction(e,this.panelRect)}toPanelRegion(e){if(e.space!=="disk")return e;const t=d.toPanelFraction(e,this.panelRect),r=d.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}}},ut=(e,t)=>({x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0}),uu=(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}=ut({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}},du=e=>({xMin:e.x,xMax:e.x+e.width,yMin:e.y,yMax:e.y+e.height}),Vr=(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)}),Nr=e=>({xMin:e.x,xMax:e.x,yMin:e.y,yMax:e.y}),Fr=e=>{const t={...e};return delete t.defer,delete t.space,t},mu=e=>{const{annotations:t,panelRect:r,measuredBoxes:n,onCycle:a,onMissingRef:i}=e;if(!hu(t))return t;const o=new cu(t,r,n),s={...t,shapes:re(t.shapes,m=>m.region.defer!==void 0,m=>{const h=o.resolveRegion(m.region);return h===null?null:{...m,region:h}}),images:re(t.images,m=>m.region.defer!==void 0,m=>{const h=o.resolveRegion(m.region);return h===null?null:{...m,region:h}}),arrows:re(t.arrows,m=>m.start.defer!==void 0||m.end.defer!==void 0,m=>{const h=o.resolvePoint(m.start),p=o.resolvePoint(m.end);return h===null||p===null?null:{...m,start:h,end:p}}),textAnnotations:re(t.textAnnotations,m=>m.at.defer!==void 0,m=>{const h=o.resolvePoint(m.at);return h===null?null:{...m,at:h}}),stickers:re(t.stickers,m=>m.at.defer!==void 0,m=>{const h=o.resolvePoint(m.at);return h===null?null:{...m,at:h}})},c=o.cyclicIds();c.length>0&&a?.(c);const u=o.missingRefIds();return u.length>0&&i?.(u),s},re=(e,t,r)=>e.some(t)?e.flatMap(n=>{if(!t(n))return[n];const a=r(n);return a===null?[]:[a]}):e,hu=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),da=(e,t)=>{if(!(e===void 0||e.length===0||t<=0))return e.map(r=>r*t).join(" ")},_t=e=>e===void 0||e.length===0?"solid":(e[0]??0)<=1?"dotted":"dashed",kt=(e,t)=>e===t?!0:e===void 0||t===void 0||e.length!==t.length?!1:e.every((r,n)=>r===t[n]),pu=800,Br=400,fu=.75,gu=.875,vu=4,yu=e=>Math.max(1,(e-Br)/(pu-Br)+1),Su=(e,t)=>{const r=yu(t),n=e*vu;return{strokeWidth:Math.min(e,e*fu*r),arrowheadLength:Math.min(n,n*gu*r)}},xe=Math.PI/4,bu=({start:e,end:t})=>`M ${e.x} ${e.y} L ${t.x} ${t.y}`,Gr=(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-xe)} ${o-r*Math.sin(s-xe)} M ${i} ${o} L ${i-r*Math.cos(s+xe)} ${o-r*Math.sin(s+xe)}`},xu=64,Au=({arrow:e,style:t,panelWidth:r,panelHeight:n})=>{const a={width:r,height:n},i={start:Re(e.start,a),end:Re(e.end,a)};if(i.start.x===i.end.x&&i.start.y===i.end.y)return null;const{strokeWidth:o,arrowheadLength:s}=Su(t.strokeWidth,r),c=Math.hypot(i.end.x-i.start.x,i.end.y-i.start.y),u=Iu(s,c),m=e.startArrowheadStyle==="line-arrow",h=e.endArrowheadStyle==="line-arrow",p=m||h?u*Math.sin(Math.PI/4):0;return{id:e.id,linePath:bu(i),startArrowheadPath:m?Gr("start",i,u):"",endArrowheadPath:h?Gr("end",i,u):"",strokeWidth:o,dashArray:da(t.dashArray,o)??null,startX:i.start.x,startY:i.start.y,endX:i.end.x,endY:i.end.y,dashOffset:Tu(t.dashArray,o,m),arrowheadExtent:p}},Iu=(e,t)=>Math.min(e,t*e/xu),Tu=(e,t,r)=>{const n=e[0]??0;return r&&n>1?n*t:0};function Lu(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=Eu(e,o,s);if(u===null)continue;const m=t.map(c);l.isStrictCategoricalDataValue(m)&&r.set(n.id,{geom:u.geom,color:m,layerId:u.id,groupValue:c})}return r}function Eu(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 ma=(e,t)=>({x:e.x/t.width,y:1-e.y/t.height}),Ru=0,Cu=(e,t)=>e.filter(r=>r.inView).map(r=>({shape:{kind:"rect",rect:r.miniRect},cursor:ma(r.anchorPx,t),tooltip:{kind:"pinned",point:r.anchorPx,placement:r.placement,annotationId:r.id},priority:Ru})),wu=9,Pu=8,Mu=2,ha=e=>typeof e=="string"?e:pa(e),pa=e=>e.text!==void 0?e.text:e.content?e.content.map(pa).join(""):"",Hr={top:"bottom",bottom:"top",right:"left",left:"right"};function Du(e,t,r){return r.type==="polar"?ku(e,t):r.mainAxis==="y"?["right","left","top","bottom"]:["top","bottom","right","left"]}function dt(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 $r(e,t){return e.x>=0&&e.y>=0&&e.x+e.width<=t.width&&e.y+e.height<=t.height}function Ou(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 _u(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 ku(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,Hr[o],s,Hr[s]]}function Vu(e){const{pinnedNumbers:t,comments:r,panelRect:n,coordSystem:a,measurer:i,formatPinnedNumber:o}=e,s=[...t.map(m=>{const{id:h,at:p}=m;return Kr(h,"pinned-number",p,o(m),i,n)}),...r.map(({id:m,at:h,content:p})=>Kr(m,"comment",h,ha(p),i,n))];s.sort((m,h)=>m.anchorPx.x-h.anchorPx.x||m.anchorPx.y-h.anchorPx.y);const c=[],u=[];for(const m of s){if(!m.inView){c.push(Yr(n,m,"top"));continue}const h=Yr(n,m,Fu(n,m,a,u));c.push(h),u.push(h.miniRect)}return c}function Kr(e,t,r,n,a,i){const o=Re(r,i);return{id:e,kind:t,anchor:r,anchorPx:o,mini:a(t,e,n),inView:Nu(o,i)}}function Nu(e,t){return e.x>=-8&&e.y>=-8&&e.x<=t.width+8&&e.y<=t.height+8}function Fu(e,t,r,n){const a=Du(t.anchorPx,e,r);for(const i of a){const o=dt(t.anchorPx,i,t.mini);if($r(o,e)&&!n.some(s=>_u(o,s)))return i}for(const i of a)if($r(dt(t.anchorPx,i,t.mini),e))return i;return"top"}function Yr(e,t,r){return{id:t.id,kind:t.kind,anchorPx:t.anchorPx,placement:r,miniRect:Ou(e,dt(t.anchorPx,r,t.mini)),text:t.mini.text,inView:t.inView}}var Bu=(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:m,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 P=jn({layer:x,coordSystem:t,axes:r,numberFormat:n,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:f,percentageValueStrategy:A.getPercentageValueStrategy(x)}),X=A.place(P);S+=X.droppedCount;for(const _ of X.labels)$u(_,g,u,m)||p.push(_)}return{labels:p,warnings:S>0?[Hu(S)]:[]}},Hu=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}}),$u=(e,t,r,n)=>t==="polar"&&n&&e.position==="outside"&&e.y+e.height/2>r,Ku=(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,Yu=100,zu=({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],m=n[c+1];if(!u||!m)continue;const h=u.y+a,p=m.y-a;if(h>p){o=!0,i=!0;const f=(h-p)/2+1;u.y-=f,m.y+=f,u.y<0&&(u.y=0),m.y>t&&(m.y=t)}}if(s>Yu)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}},Uu=(e,t)=>fa(e,t,{variables:ga(e),allowNull:!1}),fa=(e,t,{variables:r,allowNull:n})=>{const a=d.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}},ga=e=>{const t=d.shouldNarrowByGroup(e)?l.getGroupVariables(e.data,e.mapping):[],r=d.resolveCrossAnchorVariable(e),n=r===null?t:[...t,r],a=d.resolveAnchorVariable(e);return a===l.GROUP_VARIABLES.group?[...new Set(n)]:[...new Set([a,...n])]},ke=e=>e!=="data-point",Wu=(e,t)=>{switch(t){case"series":{const r=l.getGroupVariables(e.data,e.mapping);return r.length===0?zr(e):{variables:r,allowNull:!0}}case"x-value":{const r=d.readScopeXVariable(e.mapping);return r===null?null:{variables:[r],allowNull:!0}}case"data-point":return zr(e)}},zr=e=>typeof e.identityKey=="object"?{variables:[e.identityKey.variable],allowNull:!0}:e.identityKey==="index"?null:{variables:ga(e),allowNull:!1},ae=[],Ur=new WeakMap,va=(e,t,r)=>r<0||r>=e.data.size()?null:t==="data-point"?String(r):oe(e,t).keyByRow[r]??null,Vt=(e,t,r)=>{if(t==="data-point"){const n=Number(r);return Number.isInteger(n)&&n>=0&&n<e.data.size()?[n]:ae}return oe(e,t).rowsByKey.get(r)??ae},Xu=(e,t)=>oe(e,t).keyByRow,qu=(e,t,r,n)=>{if(r!=="data-point")return Vt(e,r,n);const a=Number(n);if(!Number.isInteger(a)||a<0||a>=t.data.size())return ae;const i=oe(t,"vertex").keyByRow[a];return i===void 0?ae:oe(e,"vertex").rowsByKey.get(i)??ae},oe=(e,t)=>{const r=Ur.get(e)??new Map;Ur.set(e,r);const n=r.get(t);if(n!==void 0)return n;const a=Zu(ju(e,t));return r.set(t,a),a},ju=(e,t)=>{const r=e.data.size(),n=t==="x-value"?null:Wr(e,l.GROUP_VARIABLES.group),a=t==="series"?null:d.readScopeXVariable(e.mapping),i=a===null?null:Wr(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},Wr=(e,t)=>e.data.hasVariable(t)?e.data.getValues(t):null,Zu=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}},ya=({layer:e,observationIndex:t,scope:r,parsingLocale:n})=>{const a=e.data.getAt(t);if(a===null)return null;const i=rd(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 td(o,e,a,t,n)?o:null},Ju=({layer:e,scope:t,variable:r,value:n,parsingLocale:a})=>{const i={kind:"observations",layerId:e.id,scope:ed(e,t,r),predicate:{variable:r,eq:n}};return Qu(i,e,a)?i:null},Sa=e=>e.identityKey==="x-group"?"series":l.getGroupVariables(e.data,e.mapping).length===0?"data-point":"series",Qu=(e,t,r)=>{if(d.findPredicateProblems(e.predicate,t.data).length>0)return!1;const n=d.compilePredicate(e.predicate,d.createPredicateCompileContext(t,r));for(const a of t.data)if(n(a))return!0;return!1},ed=(e,t,r)=>t==="series"&&!l.getGroupVariables(e.data,e.mapping).includes(r)?"data-point":t,td=(e,t,r,n,a)=>{if(d.findPredicateProblems(e.predicate,t.data).length>0)return!1;const i=d.compilePredicate(e.predicate,d.createPredicateCompileContext(t,a));if(i(r))return!0;if(!ke(e.scope))return!1;const o=va(t,e.scope,n);return o===null?!1:Vt(t,e.scope,o).some(s=>{const c=t.data.getAt(s);return c!==null&&i(c)})},rd=(e,t,r)=>{const n=Wu(e,r);return n===null?null:fa(e,t,n)},Nt=(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},nd=(e,t)=>{for(const r of t)if(Nt(e,r.shape))return r;return null},ad=e=>{const t=[];for(const r of e.values())t.push(...r);return t.sort((r,n)=>n.priority-r.priority)},id=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>od(r,t[n])),od=(e,t)=>t===void 0?!1:e.priority===t.priority&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y&&sd(e.shape,t.shape)&&ld(e.tooltip,t.tooltip),sd=(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},ld=(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},cd=100,ud=e=>({shape:{kind:"circle",center:e.center,radius:e.radius},cursor:e.target.cursor,tooltip:{kind:"cursor"},priority:cd}),dd=(e,t)=>Nt(e,{kind:"circle",center:t.center,radius:t.radius}),md=(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&&hd(e.target,t.target),hd=(e,t)=>e.kind===t.kind&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y,pd=({layer:e,highlights:t,observation:r,parsingLocale:n})=>{if(e.highlight===null)return[];const a=d.createPredicateCompileContext(e,n),i=fd(e,r);return t.filter(o=>{if(o.layerId!==void 0&&o.layerId!==e.id||d.findPredicateProblems(o.predicate,e.data).length>0)return!1;const s=d.compilePredicate(o.predicate,a);return s(r)?!0:ke(o.scope)&&i(o.scope).some(s)})},fd=(e,t)=>{const r=d.readScopeXVariable(e.mapping),n=new Map;return a=>{const i=n.get(a);if(i!==void 0)return i;const o=d.readScopeKey(a,t,r),s=[];for(const c of e.data)d.readScopeKey(a,c,r)===o&&s.push(c);return n.set(a,s),s}},Te=({layer:e,from:t,step:r,accepts:n,excluding:a,cycles:i=!1})=>{const o=e.data.size(),s=d.createObservationAnchorBuilder(e);for(let c=0;c<o;c+=1){const u=t+c*r,m=i?gd(u,o):u;if(m<0||m>=o)break;const h=e.data.getAt(m);if(h===null||!n(h,m))continue;const p=s(h);if(p!==null&&!a.some(f=>J(p,f)))return{anchor:p,observation:h,observationIndex:m}}return null},ba=(e,t)=>{const r=d.createObservationAnchorMatcher(e);let n=0;for(const a of e.data){if(r(a,t))return n;n+=1}return-1},J=(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),gd=(e,t)=>(e%t+t)%t,xa=({layer:e,at:t,coordSystem:r})=>{if(r.type!=="cartesian"||e.spatialKind==="cells")return null;const n=d.resolveAnchorVariable(e),a=ba(e,t),i=e.data.getAt(a);if(i===null)return null;const o=d.getGroup(i),s=p=>l.areDataValuesEqual(d.getGroup(p),o),c=[t],u=Te({layer:e,excluding:c,from:a+1,step:1,accepts:s});if(u!==null)return{start:t,end:u.anchor};const m=Te({layer:e,excluding:c,from:a-1,step:-1,accepts:s});if(m!==null)return{start:m.anchor,end:t};const h=Te({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},vd=e=>{if(e.coordSystem.type!=="cartesian")return null;const t=e.spec.annotations.differenceArrows;for(const r of e.layers){const n=d.createObservationAnchorBuilder(r);for(const a of r.data){const i=n(a);if(i===null)continue;const o=xa({layer:r,at:i,coordSystem:e.coordSystem});if(o!==null&&!t.some(s=>yd(s,o)))return o}}return null},yd=(e,t)=>J(e.start,t.start)&&J(e.end,t.end)||J(e.start,t.end)&&J(e.end,t.start),Sd=(e,t)=>d.resolveGeomScaleDemands(e.layers).zeroAxes[t]!==void 0,bd=new Set(["discrete","datetime"]),Aa=e=>{const t=e.x;return t?.kind!=="position"?!1:bd.has(t.spec.scaleType)},xd=({layer:e,coordSystem:t,panelSize:r,radialExtent:n="whole"})=>{const a=n==="outerEnd"&&t.type==="polar"?Ad:l.readObservationBox,i=[];for(const o of e.data){const s=a(o,t);s!==null&&i.push(Id(s,r))}return i},Ad=(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"}},Id=(e,t)=>ua({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}},ue=e=>d.applyReplayableTransforms(e.data,e.transforms),Ia=(e,t)=>{const r=e.layers.map(m=>({...m,mapping:{...e.mapping,...m.mapping}})),n=d.findLayerById(r,t.layerId);if(n===void 0)return null;const a=d.findHostLayer(n,r),i=d.findCompanionLayers(a,r),o=a.mapping;if(Ed([a,...i],t.scope)||[a,...i].some(m=>Ld(e,m)))return null;const s=Rd(t,o)?void 0:t.predicate,c=Xr(a,s);if(c===null)return null;const u=[];for(const m of i){const h=Xr(m,s);if(h===null)return null;u.push(h)}return[c,...u]},Ld=(e,t)=>{const r=l.readVariableName({...e.mapping,...t.mapping}.color);if(r===null)return!1;const n=d.applyReplayableTransforms(ue(e),t.transforms);return n.hasVariable(r)?n.getType(r)!=="categorical":!0},Ed=(e,t)=>(t==="x-value"||t==="data-point")&&e.some(r=>d.paintsEachGroupFromItsFirstObservation(r.geom)),Rd=(e,t)=>{if(e.scope!=="series")return!1;const r=Cd(e.predicate);if(r===null)return!1;const n=l.readVariableName(t.x),a=l.readVariableName(t.y),i=r.filter(s=>s===n||s===a),o=l.readVariableName(t.group);return i.length>0&&!i.some(s=>s===o)},Cd=e=>{if("eq"in e)return[e.variable];if(!("and"in e))return null;const t=[];for(const r of e.and){if(!("eq"in r))return null;t.push(r.variable)}return t},Xr=(e,t)=>{if(d.encodesColorAsValue(e.geom))return null;const r=wd(e.geom);return r===null?null:{layerId:e.id,geomKind:e.geom,property:r,...t===void 0?{}:{where:t}}},wd=e=>{const t=d.findDefaultKitStyleTarget(e)?.observation?.aesthetics;if(t===void 0)return null;const r=Object.entries(t).find(([,n])=>n==="color")?.[0];return r==="fill"||r==="stroke"?r:null},Ta=({layer:e,target:t,parsingLocale:r,host:n})=>{if(t.layerId!==(n??e).id)return[];const a=La(e,t,r);if(a===null)return[];if(ke(t.scope))return Md(e,a,t.scope);const i=Ea(e,a),o=i[Pd(t,i,n,r)];return o===void 0?i:[o]},Pd=(e,t,r,n)=>{if(e.observationIndex===void 0)return-1;if(r===void 0)return t.indexOf(e.observationIndex);const a=La(r,e,n);return a===null?-1:Ea(r,a).indexOf(e.observationIndex)},La=(e,t,r)=>d.findPredicateProblems(t.predicate,e.data).length>0?null:d.compilePredicate(t.predicate,d.createRowPredicateCompileContext(e,r)),Ea=(e,t)=>{const r=[];for(let n=0;n<e.data.size();n++)t(n)&&r.push(n);return r},Md=(e,t,r)=>{const n=Xu(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},Dd=["series","data-point","x-value"],Od=({layer:e,observationIndex:t,parsingLocale:r,scales:n})=>{const a=kd(Sa(e)).filter(s=>s!=="x-value"||_d(n)),i=new Set,o=[];for(const s of Dd){if(!a.includes(s))continue;const c=Vd(e,t,s,r);if(c===null&&s==="data-point")return[];c===null||o.some(u=>Nd(u,c))||(o.push(c),i.add(s))}return a.filter(s=>i.has(s))},_d=e=>{const t=e.x?.domain.some(r=>r instanceof Date)===!0;return Aa(e)&&!t},kd=e=>e==="series"?["data-point","x-value","series"]:["data-point"],Vd=(e,t,r,n)=>{const a=ya({layer:e,observationIndex:t,scope:r,parsingLocale:n});return a===null?null:Ta({layer:e,target:a,parsingLocale:n})},Nd=(e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),Fd=({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=d.readObservationMeasurement(t,r,c);if(u===null)return null;const m=d.createObservationAnchorBuilder(t)(r);return m===null?null:{...s,...u,observationIndex:n,anchor:i===void 0?m:{...m,align:i}}},Bd=({layer:e,from:t,partner:r,axis:n,step:a,getObservationPoint:i})=>{const o=d.resolveAnchorVariable(e),s=ba(e,t),c=e.data.getAt(s);if(c===null)return null;const u=Gd(c),m=n==="main"?u:f=>!u(f)&&l.areDataValuesEqual(f[o]??null,t.anchorValue),h=Te({layer:e,excluding:[t,r],from:s+a,step:a,accepts:(f,g)=>m(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}},Gd=e=>{const t=d.getGroup(e);return r=>l.areDataValuesEqual(d.getGroup(r),t)};function Hd({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 $d=({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"?Kd(e,o,r):Yd(e,t,o,r,i)},Kd=(e,t,r)=>({kind:"grandTotal",value:I({valueFormat:e.valueFormat,locale:t,numberFormat:r})(e.value)}),Yd=(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}),m=Pt({valueFormat:s.mainValueFormat,locale:r,numberFormat:n,tickValues:[]}),h=s.label??u(s.value);return{swatch:s.swatch,label:Xd(t,o,h,a),value:s.aggregate===null?null:c(s.aggregate),caption:Wd(s.caption,m),comparison:zd(s.comparison,m,i,a)}})}},zd=(e,t,r,n)=>e===null?null:{direction:Ud(e.variation),percentage:r(Math.abs(e.variation)),reference:n("graph.headlineMetrics.comparisonReference",{value:t(e.against)})},Ud=e=>e>0?"up":e<0?"down":"flat",Wd=(e,t)=>e===null?null:e.kind==="point"?t(e.value):`${t(e.from)} – ${t(e.to)}`,Xd=(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}},qd=({legends:e,numberFormat:t,parsingLocale:r,formattingLocale:n})=>{const a=n??r;return e.map(i=>jd(i,a,t))},jd=(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 Ft(e,t){return e.axes.find(r=>r.scaleAestheticKey===t)??null}function Zd(e,t){return e.legends.drawn.find(r=>r.aesthetics.includes(t))??null}var Jd=({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?d.createYValueReader:d.createXValueReader)(r.data,r.mapping)(a);return o===null?null:I({valueFormat:Ft(e,i?l.resolveYScaleAesthetic(r.yScaleType):"x")?.valueFormat??{type:"decimal"},locale:n,numberFormat:t})(o)},Ra=.4,Ca=.18,Qd=12,wa=.4,em=(e,t)=>{const{value:r,caption:n,comparison:a,swatch:i,label:o}=e;return[{role:"value",gap:Je(t.number.fontSize,Ca),segments:Qe([Ae("value",r??"–"),Ae("caption",n)])},{role:"trend",gap:Je(t.trend.fontSize,wa),ariaLabel:a===null?void 0:am(a),segments:Qe([rm(a),nm(a),Ae("trendReference",a?.reference??null)])},{role:"group",gap:Je(t.label.fontSize,Ra),segments:Qe([tm(i,t.swatch.size),Ae("label",o)])}].filter(s=>s.segments.length>0)},Je=(e,t)=>Math.round(e*t),Ae=(e,t)=>t===null?null:{kind:"text",textRole:e,text:t},tm=(e,t)=>e===null?null:{kind:"swatch",swatch:e,size:t},rm=e=>e===null?null:{kind:"trendArrow",direction:e.direction,size:12},nm=e=>e===null?null:{kind:"text",textRole:"trendPercentage",text:e.percentage,trendDirection:e.direction},am=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}`}},Qe=e=>e.filter(t=>t!==null),Ve=e=>e==="smooth"?R.curveCatmullRom:R.curveLinear,im=(e,t)=>{const r=Ve(t.curve),n=(0,R.area)().curve(r),a=(0,R.line)().curve(r);if(e.mainAxis==="y"){const i=c=>N(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=>N(l.getYMin(c)??0),s=c=>N(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}},om=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Bt={none:0,xs:2,sm:4,md:8,lg:12,xl:16},Gt=e=>{if(Oa(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):Bt[t]},sm=e=>{const t=Gt(e);return Oa(e)?e.mainAxis==="x"?{rx:t}:{ry:t}:{rx:t}},lm=e=>({outlineWidth:e*2,separatorWidth:e,insetOffset:e/2}),Pa=(e,t)=>Ma(e,{xMin:l.getXMin(t),xMax:l.getXMax(t),yMin:l.getYMin(t),yMax:l.getYMax(t),y:l.getY(t)}),Ma=(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,m=o-n;return m<0&&(u+=m,m=-m),{x:t,y:u,width:r-t,height:m}}let s=t,c=r-t;return c<0&&(s+=c,c=-c),{x:s,y:1-o,width:c,height:o-n}},Da=(e,t)=>e==="x"?`${k(t.x)}-${k(t.width)}`:`${k(t.y)}-${k(t.height)}`,cm=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}},Ht=(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},um=(e,t,r)=>{const n=Ht(e,t,r);return t.mainAxis==="x"?{x:0,y:n}:{x:n,y:0}},Oa=e=>e.cornerRadius==="full",dm=e=>{const t=(0,R.line)().x(r=>l.getX(r)??0).y(r=>N(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(_a),t},mm=e=>{const t=(0,R.area)().x(r=>l.getX(r)??0).y0(()=>1).y1(r=>N(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(_a),t},hm=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),_a=e=>l.getX(e)!==null&&l.getY(e)!==null,pm=new Set(["line","rule"]),ka=e=>pm.has(e),$t=(e,t,r,n)=>{const a=e.geom(t);if(ka(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)},Kt={circle:R.symbolCircle,square:R.symbolSquare,diamond:R.symbolDiamond,triangle:R.symbolTriangle,cross:R.symbolCross,star:R.symbolStar,wye:R.symbolWye},fm=(e,t)=>{const r=t/2;return(0,R.symbol)(Kt[e],Math.PI*r*r)()??""},gm=(e,t,r)=>{const n=Va[e],a=Math.max(0,Math.min(t/n.width,r/n.height));return{path:(0,R.symbol)(Kt[e],a*a)()??"",offsetX:-n.centerX*a,offsetY:-n.centerY*a}},vm=(e,t)=>{const r=t/2;return Va[e].outerRadius*Math.sqrt(Math.PI*r*r)},ym=e=>{let t=1/0,r=1/0,n=-1/0,a=-1/0,i=0;const o=(u,m)=>{t=Math.min(t,u),r=Math.min(r,m),n=Math.max(n,u),a=Math.max(a,m)},s=(u,m)=>{o(u,m),i=Math.max(i,Math.hypot(u,m))},c=()=>{throw new Error("Unexpected curve in a point symbol")};return e.draw({moveTo:s,lineTo:s,rect:(u,m,h,p)=>{s(u,m),s(u+h,m),s(u+h,m+p),s(u,m+p)},arc:(u,m,h)=>{o(u-h,m-h),o(u+h,m+h),i=Math.max(i,Math.hypot(u,m)+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}},Va=Object.fromEntries(Object.entries(Kt).map(([e,t])=>[e,ym(t)])),Na={centerX:0,centerY:0,radius:1,digits:8},Sm=200,D=1e-12,bm=Math.PI/2,xm=(e,t)=>{if(e==="full")return Math.max(0,t)/2;const r=e??"sm";return(typeof r=="number"?Math.max(0,r):Bt[r])/Sm},Fa=(e,t)=>e==="x"?`${k(t.startAngle)}-${k(t.endAngle)}`:`${k(t.innerRadius)}-${k(t.outerRadius)}`,Am=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}},Im=(e,t=Na)=>{const r=Pm(t),n=Lm(e);if(!(n.outer>D))return`M${r.writePoint(0,0)}Z`;const{slice:a}=e,i=a===void 0?null:Tm(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 jr({...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?Em(n,i,r):jr(n,i??[n.start,n.end],r)}},Tm=(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},Lm=({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,m=Math.min((c-s)/2,a),h={start:i,end:o,inner:s,outer:c,innerCorner:null,outerCorner:null};if(!(m>D)||l.isFullTurnSweep(i,o))return h;let p=m,f=m;if(u<Math.PI){const g=(c-s)**2*Math.sin(u);if(g*g<D)return h;const S=Math.sin(u/2);p=Math.min(m,s*S/(1-S)),f=Math.min(m,c*S/(1+S))}return{...h,innerCorner:s>D&&p>D?qr(p,s+p,u):null,outerCorner:f>D?qr(f,c-f,u):null}},qr=(e,t,r)=>({radius:e,centerRadius:t,offset:Math.min(Math.asin(Math.min(1,e/t)),r/2)}),Em=(e,[t,r],n)=>{const a=Zr(e,"start"),i=Zr(e,"end"),o=c=>Ce(a,c),s=c=>Ce(i,c);return`M${n.writePoint(o(t),t)}`+se(t,o(t),s(t),n)+we(i,t,r,"radius",n)+se(r,s(r),o(r),n)+we(a,r,t,"radius",n)+"Z"},jr=(e,[t,r],n)=>{const a=Jr(e,"inner"),i=Jr(e,"outer");return`M${n.writePoint(t,Ce(a,t))}`+we(a,t,r,"angle",n)+`L${n.writePoint(r,Ce(i,r))}`+we(i,r,t,"angle",n)+"Z"},Rm=(e,t,r,n)=>{const a=`M${n.writePoint(e,r)}${se(r,e,e-l.TAU,n)}Z`;return t>D?`${a}M${n.writePoint(e,t)}${se(t,e,e+l.TAU,n)}Z`:a},Zr=(e,t)=>{const r=t==="start"?e.start:e.end,n=t==="start"?1:-1,a=c=>{const u=r+n*c.offset;return m=>u-n*Cm(c,m)},i=e.innerCorner===null?e.inner:Qr(e.innerCorner),o=e.outerCorner===null?e.outer:Qr(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},Jr=(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=>wm(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}]},Qr=e=>e.centerRadius*Math.cos(e.offset),Cm=({radius:e,centerRadius:t},r)=>{if(!(r>D))return 0;const n=(t**2+r**2-e**2)/(2*t*r);return Math.acos(Math.max(-1,Math.min(1,n)))},wm=({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))},Ce=(e,t)=>{const r=e.find(n=>t<=n.to)??e[e.length-1];return r===void 0?0:r.at(t)},we=(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 m=Math.max(u.from,o),h=Math.min(u.to,s);if(h-m<=D)continue;const[p,f]=i?[m,h]:[h,m],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}`:se(u.at(p),p,f,a)}return c},se=(e,t,r,n)=>{if(!(e>D)||Math.abs(r-t)<=D)return"";const a=Math.max(1,Math.ceil(Math.abs(r-t)/bm-D)),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},Pm=({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)}},Ne=(e,t,r)=>{const n=d.createXValueReader(e,t);return a=>{const i=d.getGroup(a)??"default",o=n(a);return`${r}-${i}${o!==null&&o!==""?`-${o}`:""}`}},Mm=(e,t,r)=>{const n=d.createXValueReader(e,t);return a=>{const i=n(a);return i===null||i===""?null:`${r}-${i}`}},Dm=(e,t,r)=>{const n=d.createXValueReader(e,t),a=d.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`,m=i.get(u)??0;return i.set(u,m+1),m===0?u:`${u}#${m}`}},Om=()=>(e,t)=>l.getColor(e)??`default-${t}`,en=2,_m=(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},Yt=(e,t,r,n)=>{const a=e(t),i=U(t,"line")?a.get("strokeAlpha",r):a.get("fillAlpha",r)??a.get("strokeAlpha",r),o=a.get("alpha",r)*i,s=ka(t.geom)?void 0:km(e,t,r),c=s===void 0?{alpha:o}:{alpha:o,fill:s};if(U(t,"point"))return{...c,symbol:e.point(t).get("symbol",r)};if(!U(t,"bar"))return c;const u=n.width-en,m=n.height-en,h=Gt({cornerRadius:e.bar(t).get("cornerRadius",r),mainAxis:"x",bounds:{width:u,height:m}});return{...c,cornerRadiusPx:Math.min(h,Math.min(u,m)/2)}},km=(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 d.readPredicateVariables(i.where).every(s=>s===o)?n:void 0};function zt(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 Ba(e,t,r){return zt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>t})}function Ga(e,t,r){return zt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>=t})}function Ut(e,t,r,n){const a=e==="x";return{mainDistance:Math.abs(t)*(a?n:1),crossDistance:Math.abs(r)*(a?1:n)}}function Fe(e,t,r){return Math.hypot(e*r,t)}function V(e,t,r){return e<t?t-e:e>r?e-r:0}function O(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 Vm(e,t){const r=t.height,n=Math.min(t.width,t.height)/2;return{cartesian:tn(e,r),polar:tn(e,n)}}function de(e,t){return e<=t.on.point}function le({mainDistance:e,crossDistance:t},r){return e<=r.near.main&&t<=r.near.cross}function tn({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 Nm(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=Ha(e,s,t,r);return a===void 0||de(c.distance,a)||le(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 Bm(e,t,r,n){if(e.projection==="polar")return[];const a=mt(e.mainAxis),i=Ga(e.byMain,t,a),o=Ba(e.byMain,r,a),s=e.delaunayAspectRatio??1,c=new Map;for(let u=i;u<o;u+=1){const m=e.byMain[u];if(m===void 0)continue;const h=l.getStableKey(m.observation[l.GROUP_VARIABLES.group]??null),p=Fe(m.x-n.x,m.y-n.y,s),f=c.get(h);(f===void 0||p<f.distance)&&c.set(h,{point:m,distance:p})}return[...c.values()].map(u=>u.point)}function Gm(e,t,r,n){const{mainAxis:a,byMain:i}=e,o=d.getCoordinates(a,t).main,s=a==="x"?n.near.main/r:n.near.main,c=Ga(i,o-s,mt(a)),u=Ba(i,o+s,mt(a));let m=null;for(let h=c;h<u;h+=1){const p=i[h];if(p===void 0)continue;const f=Ha(e,p,t,r);le(f,n)&&(m===null||f.crossDistance<m.crossDistance)&&(m=f)}return m}function mt(e){return t=>d.getCoordinates(e,t).main}function Ha(e,t,r,n){const{main:a,cross:i}=d.getCoordinates(e.mainAxis,r),{main:o,cross:s}=d.getCoordinates(e.mainAxis,t);return{...Ut(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:Fe(t.x-r.x,t.y-r.y,n)}}function $a(e,t){return e.buckets[Hm(e,t)]??null}function Hm(e,t){return za(e.buckets,t,r=>r.main)}function $m(e,t){return Ya(e.bands,t,r=>r.bandCenter)}function Ka(e,t){return Ya(e.columns,t,r=>r.mainMid)}function Ya(e,t,r){return e[za(e,t,r)]??null}function za(e,t,r){if(e.length===0)return-1;const n=zt(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 Km(e,t){return{group:Ym(e),related:Xm(e,t)}}function Ym(e){switch(e.kind){case"buckets":{const t=e.match.index;return l.isStackedPosition(t.position)?zm(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)?Um(t.layerId,r,n.pointIndex):Wm(t.bandByColumn,t.layerId,r,n.pointIndex)}case"points":case"enclosure":case"render-hit-test":return[]}}function zm(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 Um(e,t,r){const n=[];for(const a of t.rects)a.pointIndex!==r&&n.push(Wt(e,a));return n}function Wm(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 Xm(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||jm(r,i,e);continue}e.kind==="buckets"&&(l.isStackedPosition(i.position)||i.kind==="buckets"&&qm(r,i.layerId,e.match.bucket,e.match.hit.pointIndex))}return r}function qm(e,t,r,n){for(const a of r.entries)a.pointIndex!==n&&Le(e,t).push({anchored:!0,layerId:t,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation})}function jm(e,t,r){const n=r.match.hit;switch(t.kind){case"buckets":{const a=$a(t,d.getMainAxisCoordinate(t.mainAxis,n));if(!a)return;const i=Le(e,t.layerId);for(const o of a.entries)i.push({anchored:!0,layerId:t.layerId,pointIndex:o.pointIndex,x:o.x,y:o.y,observation:o.observation});return}case"banded":{const a=$m(t,d.getMainAxisCoordinate(t.mainAxis,n));if(!a)return;const i=Le(e,t.layerId);for(const o of a.columns)for(const s of o.rects)i.push(Wt(t.layerId,s));return}case"points":{const a=r.kind==="banded"?r.match.index.bandByColumn.get(r.match.column):void 0,i=a===void 0?[]:Bm(t,a.mainMin,a.mainMax,n),o=i.length>0?null:Fm(t,n),s=o===null?i:[o];if(s.length===0)return;const c=Le(e,t.layerId);for(const u of s)c.push({anchored:!0,layerId:t.layerId,pointIndex:u.pointIndex,observationIndex:u.observationIndex,x:u.x,y:u.y,observation:u.observation});return}case"enclosure":return;case"noop":return;case"render-hit-test":return}}function Le(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 Ua(e,t,r){const{columns:n,bands:a,bandByColumn:i}=Zm(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 Zm(e,t){const r=Qm(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=k(c.mainMid);let m=n.get(u);if(!m){m={mainMid:c.mainMid,rects:[]},n.set(u,m);const h=k(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(m),i.set(m,p)}m.rects.push(c.entry),Jm(i.get(m),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,m)=>u.mainMid-m.mainMid);return{columns:o,bands:s,bandByColumn:i}}function Jm(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 Qm(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=eh(r,s),u=[];let m=0;for(const h of r){const p=n[m],f=a[m],g=i[m],S=o[m];if(!l.isDefined(p)||!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)){m++;continue}const x=s?(g+S)/2:(p+f)/2,A=c?.[m]??x;u.push({mainMid:x,bandCenter:A,entry:{pointIndex:m,xMin:Math.min(p,f),xMax:Math.max(p,f),yMin:Math.min(g,S),yMax:Math.max(g,S),observation:h}}),m++}return u}function eh(e,t){const r=(t?[l.POSITION_VARIABLES.yBand,l.POSITION_VARIABLES.y]:[l.POSITION_VARIABLES.xBand,l.POSITION_VARIABLES.x]).find(n=>e.hasVariable(n));return r?e.getValues(r,{type:"numeric"}):null}var th=1e-9,rn=-1;function Wa(e,t,r){const n=rh(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)<=1e-9?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:Xa(o.entries,t)})):i,entries:a}}function Xa(e,t){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const a of e){const i=d.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 rh(e,t,r){const{data:n,spatialKind:a,position:i}=e,o=ne(n,l.POSITION_VARIABLES.x),s=ne(n,l.POSITION_VARIABLES.y);if(!o||!s)return[];const c=t==="y",u=a==="spanned-buckets",m=l.isStackedPosition(i),h=c?s:o,p=ne(n,c?l.POSITION_VARIABLES.yBand:l.POSITION_VARIABLES.xBand)??h,f=c?o:s,g=ne(n,c?l.POSITION_VARIABLES.xMin:l.POSITION_VARIABLES.yMin),S=ne(n,c?l.POSITION_VARIABLES.xMax:l.POSITION_VARIABLES.yMax),x=n.hasVariable(l.GROUP_VARIABLES.group)?n.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}):null,A=u?null:new ah(ih(e)),P=new Map,X=[];let _=-1;for(const cl of n){_+=1;const fe=x?.[_]??null,ul=oh(P,fe),We=p[_],ge=g?.[_],fr=S?.[_],te=nh(f[_],ge,fr,m);if(!l.isDefined(We)||te===null){A?.skip(fe);continue}const gr=h[_]??We,vr={pointIndex:_,...c?{x:te,y:gr}:{x:gr,y:te},groupKey:fe,paintOrder:ul,...a==="filled-buckets"&&l.isDefined(ge)&&{fill:sh(ge,te)},...u&&{extent:lh(te,ge,fr)},previousAt:rn,nextAt:rn,observation:cl};A?.append(fe,{entry:vr,at:X.length}),X.push({main:We,entry:vr})}return r==="polar"&&A?.close(),X}function ne(e,t){return e.hasVariable(t)?e.getValues(t,{type:"numeric"}):null}function nh(e,t,r,n){return l.isDefined(e)?n?l.isDefined(t)&&l.isDefined(r)?r:null:e:null}var ah=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 ih(e){return"missingValues"in e.params&&e.params.missingValues==="gap"}function oh(e,t){const r=e.get(t);if(r!==void 0)return r;const n=e.size;return e.set(t,n),n}function sh(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}}function lh(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 qa(e,t){return{kind:"enclosure",layerId:e.id,geom:e.geom,position:e.position,projection:t,cells:ch(e,t)}}function ch(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 m=0;for(const h of r){const p=a[m],f=i[m],g=o[m],S=s[m];if(!l.isDefined(p)||!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)){m++;continue}if(c&&!l.isTilePainted(h)){m++;continue}u.push({pointIndex:m,xMin:p,xMax:f,yMin:g,yMax:S,observation:h}),m++}return u}function ht(e){return{kind:"noop",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian"}}function uh(e,t,r){const n=Za(e),a={kind:"points",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",mainAxis:t,points:n,byMain:mh(t,n),delaunay:null,delaunayAspectRatio:null};return ja(a,r),a}function dh(e){const t=Za(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 ja(e,t){e.delaunay&&e.delaunayAspectRatio===t||(e.delaunay=dl.Delaunay.from(e.points,r=>r.x*t,r=>r.y),e.delaunayAspectRatio=t)}function mh(e,t){const r=n=>d.getMainAxisCoordinate(e,n);return[...t].sort((n,a)=>r(n)-r(a))}function Za(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 Ja(e){return{kind:"render-hit-test",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",byKey:hh(e)}}function Qa(e,t){return{anchored:!1,layerId:e,pointIndex:t.pointIndex,observation:t.observation}}function hh(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 nn(e,t,r){return t.type==="polar"?ph(e,t.bandAxis):fh(e,t.mainAxis,r)}function ph(e,t){switch(e.spatialKind){case"points":return dh(e);case"buckets":case"filled-buckets":case"spanned-buckets":return Wa(e,"x","polar");case"rects":return t===null?qa(e,"polar"):Ua(e,t,"polar");case"cells":return ht(e);case"noop":return ht(e);case"render-hit-test":return Ja(e);default:{const r=e.spatialKind;throw new l.InternalError({message:`buildPolarLayerIndex: unhandled spatialKind ${String(r)}`})}}}function fh(e,t,r){switch(e.spatialKind){case"points":return uh(e,t,r);case"buckets":case"filled-buckets":case"spanned-buckets":return Wa(e,t,"cartesian");case"rects":return Ua(e,t,"cartesian");case"cells":return qa(e,"cartesian");case"noop":return ht(e);case"render-hit-test":return Ja(e);default:{const n=e.spatialKind;throw new l.InternalError({message:`buildCartesianLayerIndex: unhandled spatialKind ${String(n)}`})}}}function gh(e,t,r){if(e.columns.length===0)return null;const n=Ka(e,d.getMainAxisCoordinate(e.mainAxis,t)),a=n?.rects??[];if(!n||!l.isNonEmptyArray(a))return null;const i=l.isStackedPosition(e.position)?yh(a,t,e.mainAxis):Sh(a,t,r),o=ei(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,...vh(e,n,t,r)}}function vh(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}=d.getCoordinates(e.mainAxis,r),s=V(i,a.mainMin,a.mainMax),c=V(o,a.crossMin,a.crossMax);return Ut(e.mainAxis,s,c,n)}function yh(e,t,r){const n=d.getCrossAxisCoordinate(r,t);return O(e,i=>bh(i,r,n),{shortCircuitOnZero:!0})}function Sh(e,t,r){return O(e,a=>ei(a,t,r))}function ei(e,t,r){return Fe(V(t.x,e.xMin,e.xMax),V(t.y,e.yMin,e.yMax),r)}function bh(e,t,r){return V(r,t==="x"?e.yMin:e.xMin,t==="x"?e.yMax:e.xMax)}function xh(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 Ah(e,t,r){const{main:n,cross:a}=d.getCoordinates(e.mainAxis,t),i=$a(e,n);if(i===null||!l.isNonEmptyArray(i.entries))return null;const o=Ch(i.entries,i.span,e.mainAxis,n),s=o.entries.map(S=>({entry:S,crossAtCursor:Th(e,S,n)}));if(!l.isNonEmptyArray(s))return null;const c=ni(s.filter(S=>Eh(e,S.entry,n,a)),S=>S.entry),{entry:u}=c??O(s,S=>Math.abs(S.crossAtCursor-a)),m=Fe(u.x-t.x,u.y-t.y,r),h=S=>({x:S.x*r,y:S.y}),p=Be(e,u).map(h),f=ri(h(t),h(u),p,m),g=Ut(e.mainAxis,d.getMainAxisCoordinate(e.mainAxis,u)-n,ti(o.span,d.getCrossAxisCoordinate(e.mainAxis,u),a),r);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:u.pointIndex,x:u.x,y:u.y,observation:u.observation},index:e,bucket:i,distance:c===void 0?m:0,vertexDistance:m,insideFill:c!==void 0,strokeDistance:c===void 0?f:0,...g}}function Ih(e,t,r){return O(e,a=>Math.abs(d.getCrossAxisCoordinate(r,a)-t))}function ti(e,t,r){return e!==void 0?V(r,e.min,e.max):Math.abs(t-r)}function ri(e,t,r,n){const a=r.map(i=>xh(e,t,i));return Math.min(n,...a)}function Be(e,t){return[e.entries[t.previousAt],e.entries[t.nextAt]].filter(l.isDefined)}function ni(e,t){return e.reduce((r,n)=>r===void 0||t(n).paintOrder>t(r).paintOrder?n:r,void 0)}function Th(e,t,r){const{mainAxis:n}=e,a=r===d.getMainAxisCoordinate(n,t)?null:ai(e,t,r);return a===null?d.getCrossAxisCoordinate(n,t):Lh(t,a,n,r)}function Lh(e,t,r,n){const a=d.getMainAxisCoordinate(r,e),i=(n-a)/(d.getMainAxisCoordinate(r,t)-a),o=d.getCrossAxisCoordinate(r,e);return o+(d.getCrossAxisCoordinate(r,t)-o)*i}function ai(e,t,r){const{mainAxis:n}=e,a=d.getMainAxisCoordinate(n,t),i=o=>Math.sign(d.getMainAxisCoordinate(n,o)-a)===Math.sign(r-a);return Be(e,t).find(i)??null}function Eh(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=d.getMainAxisCoordinate(n,t);if(r===a)return t.fill;const i=ai(e,t,r);if(i?.fill===void 0)return null;const o=(r-a)/(d.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 Ch(e,t,r,n){if(t===void 0)return{entries:e,span:t};const a=s=>d.getMainAxisCoordinate(r,s),i=a(O(e,s=>Math.abs(a(s)-n))),o=e.filter(s=>Math.abs(a(s)-i)<=th);return o.length===e.length?{entries:e,span:t}:{entries:o,span:Xa(o,r)}}function wh(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 Ph(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?Oh(e.columns,a):Ka(e,i),c=s?.rects??[];if(!s||!l.isNonEmptyArray(c))return null;const u=o?_h(c,i):kh(c,a),m=Mh(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:m,...Dh(e,s,n)}}function Mh(e,{angle:t,radius:r}){const n=Pe(t,e.xMin,e.xMax),a=V(r,e.yMin,e.yMax);return Math.hypot(n*r,a)}function Pe(e,t,r){return l.isAngleWithinArc(e,t,r)?0:Math.min(l.wrappedAngularDistance(e,t),l.wrappedAngularDistance(e,r))}function Dh(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:Pe(r,a.mainMin,a.mainMax)*n,crossDistance:V(n,a.crossMin,a.crossMax)}:{mainDistance:V(n,a.mainMin,a.mainMax),crossDistance:Pe(r,a.crossMin,a.crossMax)*n}}function Oh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(t,r.mainMid)):null}function _h(e,t){return O(e,r=>V(t,r.yMin,r.yMax),{shortCircuitOnZero:!0})}function kh(e,t){return O(e,r=>Pe(t,r.xMin,r.xMax),{shortCircuitOnZero:!0})}var an=1e-9;function Vh(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=ni(s.filter(f=>Fh(e,f,a,i)),f=>f),u=c??Ih(s,i,e.mainAxis),m=on(u),h=Math.hypot(n.x-m.x,n.y-m.y),p=ri(n,m,Be(e,u).map(on),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:ti(o.span,u.y,i)}}function on(e){return l.polarToUnit(e.x,e.y)}function Nh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(r.main,t)):null}function Fh(e,t,r,n){const a=Bh(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function Bh(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=Be(e,t).find(a);if(i?.fill===void 0)return null;const o=sn(r,{angle:t.x,radius:t.fill.min},{angle:i.x,radius:i.fill.min}),s=sn(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 sn(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)<an)return t.radius;const o=ln(l.polarToUnit(e,1),i);return Math.abs(o)<an?null:ln(n,i)/o}function ln(e,t){return e.x*t.y-e.y*t.x}function Gh(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 cn(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=>V(i,u.yMin,u.yMax),c=O(o,s);return cn(e,c,s(c))}function cn(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 Hh(e,t,r,n){if(!l.isNonEmptyArray(e.points))return null;const a=l.cursorToPiePlane(t,r),i=un(e,O(e.points,s=>ii(s,a)),a);if(n===void 0||de(i.distance,n)||le(i,n))return i;const o=e.points.map(s=>un(e,s,a)).filter(s=>le(s,n));return l.isNonEmptyArray(o)?O(o,s=>s.crossDistance):i}function un(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(ii(t,r))}}function ii(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 $h=.05;function Kh({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,m]of e.entries()){if(m.kind==="render-hit-test"){const p=jh(m,t,a);if(p)return{kind:"render-hit-test",match:p};continue}if(m.projection==="polar"){const p=qh(m,t,r,i?.polar);if(p&&!dn(p,i?.polar))return p;continue}const h=Xh({layer:m,cursor:t,aspectRatio:r,warmStarts:n,tolerance:i?.cartesian});if(!(!h||dn(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 oi(c,zh(s,o)).match}function Yh(e,t){if(e.kind==="render-hit-test")return{intersects:!0,onPoint:!1};const r=Uh(e,t),n=e.kind==="buckets"&&de(e.match.vertexDistance,r);return{intersects:si(e,r),onPoint:n}}function zh(e,t){return e.match!==null&&t.match!==null&&e.distance===0&&t.distance===0?e.paintOrder>t.paintOrder?e:t:oi(e,t)}function oi(e,t){return e.match===null?t:t.match===null||e.distance<=t.distance+$h?e:t}function si(e,t){switch(e.kind){case"banded":case"enclosure":return e.match.distance<=t.on.edge;case"buckets":return Wh(e.match,t);case"points":return de(e.match.distance,t)}}function Uh(e,t){return e.match.index.projection==="polar"?t.polar:t.cartesian}function Wh(e,t){return e.strokeDistance<=t.on.stroke?!0:de(e.vertexDistance,t)}function dn(e,t){return t===void 0?!1:!si(e,t)&&!le(e.match,t)}function Xh({layer:e,cursor:t,aspectRatio:r,warmStarts:n,tolerance:a}){switch(e.kind){case"buckets":{const i=Ah(e,t,r);return i?{kind:"buckets",match:i}:null}case"banded":{const i=gh(e,t,r);return i?{kind:"banded",match:i}:null}case"points":{const i=Nm(e,t,r,n.get(e.layerId)??null,a);return i?{kind:"points",match:i}:null}case"enclosure":{const i=wh(e,t);return i?{kind:"enclosure",match:i}:null}case"noop":return null}}function qh(e,t,r,n){switch(e.kind){case"enclosure":{const a=Gh(e,t,r,n!==void 0);return a?{kind:"enclosure",match:a}:null}case"points":{const a=Hh(e,t,r,n);return a?{kind:"points",match:a}:null}case"buckets":{const a=Vh(e,t,r);return a?{kind:"buckets",match:a}:null}case"banded":{const a=Ph(e,t,r);return a?{kind:"banded",match:a}:null}case"noop":case"render-hit-test":return null}}function jh(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:Qa(e.layerId,i)}:null}var H={primary:null,group:[],related:new Map},Zh=class{constructor({layers:e,coordSystem:t}){this.layerIndexes=[],this.layerRefs=[],this.viewport=null,this.aspectRatio=Jh,this.isAspectStale=!1,this.warmStarts=new Map,this.cachedState=H,this.cachedKey=null,this.hoverLayers={interactive:[],normal:[],low:[]},this.hitTesters=new Map,this.cachedByKeyId=null,this.cachedByKeyState=H,this.layerIndexes=e.map(r=>nn(r,t,this.aspectRatio)),this.layerRefs=e.map(r=>mn(r,t)),this.hoverLayers=hn(e,this.layerIndexes)}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=mn(i,t);if(o!==void 0&&ep(o.ref,s)){n.push(o.index),a.push(o.ref);continue}this.warmStarts.delete(i.id),n.push(nn(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.hoverLayers=hn(e,n),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 H;this.reindexForAspect();const n=r??this.viewport,a=t!==void 0&&n!==null?Vm(t,n):void 0,i=p=>Kh({layers:p,aspectRatio:this.aspectRatio,warmStarts:this.warmStarts,hitTesters:this.hitTesters,cursor:e,tolerance:a}),o=i(this.hoverLayers.normal)??i(this.hoverLayers.low);if(!o)return this.invalidateCache(),H;const s=o.match.hit;this.warmStarts.set(s.layerId,s.pointIndex);const c=a===void 0?void 0:Yh(o,a),u=Qh(s,c);if(this.cachedKey===u)return this.cachedState;const{group:m,related:h}=Km(o,this.hoverLayers.interactive);return this.cachedKey=u,this.cachedState=c===void 0?{primary:s,group:m,related:h}:{primary:s,group:m,related:h,intersection:c},this.cachedState}registerHitTester(e,t){this.hitTesters.set(e,t)}unregisterHitTester(e){this.hitTesters.delete(e)}resolveHoverByKey(e,t){const r=this.hoverLayers.interactive.find(i=>i.layerId===e);if(!r||r.kind!=="render-hit-test")return H;const n=r.byKey.get(t);if(!n)return H;const a=`${e}:${t}`;return this.cachedByKeyId===a?this.cachedByKeyState:(this.cachedByKeyId=a,this.cachedByKeyState={primary:Qa(e,n),group:[],related:new Map},this.cachedByKeyState)}invalidateCache(){this.cachedKey=null,this.cachedState=H,this.cachedByKeyId=null,this.cachedByKeyState=H}reindexForAspect(){if(this.isAspectStale){this.isAspectStale=!1;for(const e of this.layerIndexes)e.kind==="points"&&e.projection==="cartesian"&&ja(e,this.aspectRatio)}}},Jh=1;function Qh(e,t){const r=`${e.layerId}:${e.pointIndex}`;return t===void 0?r:`${r}:${t.intersects}:${t.onPoint}`}function mn(e,t){return{data:e.data,geom:e.geom,position:e.position,coord:t}}function hn(e,t){const r={interactive:[],normal:[],low:[]};for(const[n,a]of e.entries()){const i=t[n];!i||!a.interactive||(r.interactive.push(i),r[a.hoverPriority].push(i))}return r}function ep(e,t){return e.data===t.data&&e.geom===t.geom&&e.position===t.position&&e.coord===t.coord}var tp=Math.PI*2;function rp(e,t){const r=d.getMainAxisCoordinate(e.mainAxis,t);if(e.mainAxis==="y"){const a=z(N(r));return{x1:0,x2:"100%",y1:a,y2:a}}const n=z(r);return{x1:n,x2:n,y1:0,y2:"100%"}}function np(e,t,r){const n=e.mainAxis==="y"?l.getYBand(r.observation):l.getXBand(r.observation);if(n===null)return null;const a=e.mainAxis==="y"?ci(r):li(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:z(N(n+o)),width:"100%",height:z(i)}:{x:z(n-o),y:0,width:z(i),height:"100%"}}function ap(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+tp,innerRadius:r,outerRadius:n}}function li(e){const t=l.getXMin(e.observation),r=l.getXMax(e.observation);return t===null||r===null?null:r-t}function ci(e){const t=l.getYMin(e.observation),r=l.getYMax(e.observation);return t===null||r===null?null:r-t}function ip(e){return e.observationIndex??e.pointIndex}function op(e){return e==="buckets"||e==="filled-buckets"||e==="spanned-buckets"}function sp(e){return e==="buckets"||e==="filled-buckets"}var Ge=.5,lp=.3,cp=.4,up=10,dp=({layer:e,coordSystem:t,scales:r,options:n})=>e.data.size()===0?null:e.spatialKind==="rects"?t.type==="cartesian"?hp(e,t,r,n):pp(e,t,n):sp(e.spatialKind)&&t.type==="cartesian"?vp(e,t,n):e.spatialKind==="cells"||e.spatialKind==="spanned-buckets"?gp(e,n):e.spatialKind==="points"?fp(e,n):null,mp=e=>op(e.spatialKind)?new Set(e.data.getValues(l.GROUP_VARIABLES.group)).size:e.data.size(),hp=(e,t,r,n)=>({type:"grow",layerId:e.id,durationSeconds:Ge*n.durationScale,baseline:Ht(e,t,r),growAxis:t.mainAxis==="x"?"y":"x",delayByKey:n.stagger?yp(e,t.mainAxis,n):{}}),pp=(e,t,r)=>{const n=t.bandAxis==="x"?"radius":"angle";return{type:"grow",layerId:e.id,durationSeconds:Ge*r.durationScale,growAxis:n,baseline:n==="radius"?t.innerRadius:t.startAngle,delayByKey:n==="radius"&&r.stagger?xp(e,t,r):{}}},fp=(e,t)=>({type:"grow",layerId:e.id,durationSeconds:Ge*t.durationScale,growAxis:"size",baseline:0,delayByKey:t.stagger?Sp(e,t):{}}),gp=(e,t)=>({type:"fade",layerId:e.id,durationSeconds:lp*t.durationScale}),vp=(e,t,r)=>({type:"wipe",layerId:e.id,durationSeconds:Ge*r.durationScale,axis:t.mainAxis}),yp=(e,t,r)=>{const n=Ne(e.data,e.mapping,e.id),a=new Map;for(const i of e.data){const o=Pa(t,i);if(!o)continue;const s=Da(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)},Sp=(e,t)=>{const r=Ne(e.data,e.mapping,e.id),n=[];for(const a of e.data){const i=bp(a,t.staggerOrder);i!==null&&n.push({position:i,keys:[r(a)]})}return Xt(n,t)},bp=(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},xp=(e,t,r)=>{const n=Ne(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 m=Fa(t.bandAxis,{startAngle:o,endAngle:s,innerRadius:c,outerRadius:u}),h=n(i),p=a.get(m);p?p.keys.push(h):a.set(m,{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/up),i=Math.ceil(n.length/a),o=cp*t.durationScale/i;return n.forEach((s,c)=>{const u=Math.floor(c/a)*o;for(const m of s.keys)r[m]=u}),r},Ap=(e,t,r)=>({shadow:e.get("shadow",t,r),blendMode:e.get("blendMode",t,r),...ui({saturation:e.get("saturation",t,r),brightness:e.get("brightness",t,r),contrast:e.get("contrast",t,r),blur:e.get("blur",t,r)})}),ui=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},j=["top","right","bottom","left"],pn={top:"topLeft",right:"topRight",bottom:"bottomRight",left:"bottomLeft"},Ip={top:"topRight",right:"bottomRight",bottom:"bottomLeft",left:"topLeft"},Tp={topLeft:["left","top"],topRight:["top","right"],bottomRight:["right","bottom"],bottomLeft:["bottom","left"]},Lp=(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,m]=Tp[c];return a>0&&r[u].strokeWidth>0&&r[m].strokeWidth>0},o=Rp(t,a),s=Cp(t,a,i);return wp(r).map(c=>({dashArray:r[c.firstEdge].dashArray,strokeWidth:r[c.firstEdge].strokeWidth,stroke:r[c.firstEdge].stroke,segments:Pp(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}),Rp=(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}}},Cp=(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")}}}},wp=e=>{const t=o=>e[o].strokeWidth>0,r=(o,s)=>{const c=(j.indexOf(o)+s+j.length)%j.length;return j[c]},n=o=>{const s=r(o,-1);return!t(s)||!kt(e[s].dashArray,e[o].dashArray)||e[s].strokeWidth!==e[o].strokeWidth||e[s].stroke!==e[o].stroke},a=j.filter(t);if(a.length===0)return[];const i=a.filter(n);return i.length===0?[{firstEdge:"top",edges:[...j],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}})},Pp=(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=pn[s];if(!e.isClosed&&n(u)){const h=t[u],p=i(h),f=Mp(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=pn[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 m=Ip[c];if(e.isClosed){if(n(m)){const h=t[m];o.push(a(h,h.startAngle,h.endAngle))}o.push({type:"close"})}else if(n(m)){const h=t[m];o.push(a(h,h.startAngle,i(h)))}return o},Mp=(e,t)=>({x:e.cx+e.radius*Math.cos(t),y:e.cy+e.radius*Math.sin(t)}),Dp=/^(?:https?:|mailto:)/i,Op=e=>{if(typeof e!="string")return!1;const t=e.replace(/^[\x00-\x20]+/,"");return t.length===0?!1:Dp.test(t)},_p=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",year:"numeric",weekday:"long",...L,...t});return T(n=>r.format(n))},kp=({locale:e,intlOptions:t})=>T(r=>E(e,{day:"2-digit",month:"short",year:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit",second:r.getUTCSeconds()!==0?"2-digit":void 0,...L,...t}).format(r)),Me=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return Fn(e);case"date":return _p(e);case"datetime":return kp(e);case"day_month":return $n(e);case"decimal":return Bn(e);case"duration":return At(e);case"integer":return Gn(e);case"month":return Kn(e);case"month_year":return Lt(e);case"percentage":return Hn(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return Un(e);case"weekly_date_range":return Yn(e);case"weekly_date_range_with_year":return zn(e);case"year":return Rt(e);case"lookup":return Me({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},di={width:12,height:12},mi={text:null,group:null},hi=" · ",Vp=({layers:e,coordSystem:t,scales:r,guides:n,numberFormat:a,parsingLocale:i,hover:o,mode:s,readers:c,formattingLocale:u,comments:m,activeCalloutId:h})=>{const{primary:p}=o;if(p===null)return null;const f=u??i,g=Fp(m,h);if(s==="none")return g===null?null:{heading:null,rows:[],comment:g};const S=qp({guides:n,locale:f,numberFormat:a}),x=g===null?Bp({layers:e,coordSystem:t,guides:n,primary:p,mode:s,locale:f,numberFormat:a,resolveColorLabel:S}):mi;return{heading:x.text,rows:$p({layers:e,scales:r,guides:n,hover:o,primary:p,mode:s,locale:f,numberFormat:a,readers:c,resolveColorLabel:S,headingGroup:x.group}),comment:g}},Np=(e,t,r)=>{if(U(t,"line"))return e.geom.line(t).get("dashArray",r);if(U(t,"area"))return e.geom.area(t).get("dashArray",r);if(U(t,"rule"))return e.geom.rule(t).get("dashArray",r)};function Fp(e,t){return e===void 0||t===null||t===void 0?null:e.find(r=>r.id===t)?.content??null}function Bp(e){const t=e.layers.find(i=>i.id===e.primary.layerId);if(!t)return mi;const r=e.mode==="observation"?qt(t,e.primary,e.resolveColorLabel):null,n=t.tooltip.fields.find(d.isHeadingField);if(n!==void 0){const i=fi(t,n,e.primary,e);return{text:i,group:i!==null&&Hp(t,n)?r:null}}const a=Gp(t,e);return a===null||r===null?{text:a,group:null}:{text:`${a}${hi}${r}`,group:r}}function Gp(e,t){if(t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null)return null;const r=Ft(t.guides,"x");if(!r)return null;const n=l.readVariableName(e.mapping.x);if(!l.isDefined(n))return null;const a=t.primary.observation[n];return l.isDefined(a)?Me({valueFormat:r.valueFormat,locale:t.locale,numberFormat:t.numberFormat})(a):null}function qt(e,t,r){if(l.readVariableName(e.mapping.color)===null)return null;const n=d.createColorValueReader(e.data,e.mapping)(t.observation);return n===null?null:r(n)}function Hp(e,t){const r=l.readVariableName(e.mapping.color);return r===null?!1:t.kind==="variable"?t.variable===r:t.kind==="aes"&&l.readVariableName(e.mapping[t.aes])===r}function $p(e){const t=e.layers.find(r=>r.id===e.primary.layerId);return Kp(e.layers.flatMap(r=>{const n=Wp({layer:r,primaryLayer:t,hover:e.hover,primary:e.primary,mode:e.mode});if(n.length===0)return[];const a=r.id===e.primary.layerId?e.primary:gi({related:n,layer:r,primaryLayer:t,primary:e.primary});if(a===void 0){const i=r.tooltip.fields.filter(o=>o.kind==="group");return(i.length>0||r.tooltip.hidesDefaultRows?i:[d.DEFAULT_ROWS_FIELD]).flatMap(o=>fn(e,r,o,n))}return r.tooltip.fields.flatMap((i,o)=>{if(i.kind==="group")return fn(e,r,i,n);if(d.isHeadingField(i))return[];const s=Yp(e,r,i,a,`${a.layerId}:${a.pointIndex}:field-${o}`);return s===null?[]:[s]})}))}function Kp(e){const t=new Map;for(const{row:r,layerId:n}of e){const a=t.get(r.label)??new Set;a.add(n),t.set(r.label,a)}return e.map(({row:r,qualifier:n})=>(t.get(r.label)?.size??0)>1&&n!==null&&n!==""?{...r,label:`${r.label}${hi}${n}`}:r)}function pi(e,t,r){return e===null||e===r?{label:t,qualifier:null}:{label:e,qualifier:t}}function fn(e,t,r,n){const a=d.createColorValueReader(t.data,t.mapping),i=Xp({hits:n,layer:t,colorScale:e.scales.color??null,colorValueReader:a}),o=r.format===void 0?Mt({layer:t,numberFormat:e.numberFormat,locale:e.locale}):I({valueFormat:r.format,locale:e.locale,numberFormat:e.numberFormat}),s=r.title??jp(e.guides,t),c=d.createSegmentYReader(t);return i.map(u=>{const m=Yt(e.readers.geom,t,u.observation,di),{label:h,qualifier:p}=pi(qt(t,u,e.resolveColorLabel),s,e.headingGroup),f=c(u.observation);return{row:{swatchColor:$t(e.readers,t,u.observation)??null,geom:t.geom,swatchLineType:_t(Np(e.readers,t,u.observation)),swatchFill:m.fill,swatchAlpha:m.alpha,swatchCornerRadius:m.cornerRadiusPx,swatchSymbol:m.symbol,label:h,value:f===null?"":o(f,u.observation),isPrimary:u===e.primary,key:`${u.layerId}:${u.pointIndex}`},layerId:t.id,qualifier:p}})}function Yp(e,t,r,n,a){const i=fi(t,r,n,e);if(i===null)return null;const o=Yt(e.readers.geom,t,n.observation,di),s=r.kind==="range"||r.kind==="aes"&&r.aes==="color",{label:c,qualifier:u}=r.title!==void 0?{label:r.title,qualifier:null}:zp(t,r,n,e);return{row:{swatchColor:s?$t(e.readers,t,n.observation)??null:null,geom:t.geom,swatchLineType:"solid",swatchFill:o.fill,swatchAlpha:o.alpha,swatchCornerRadius:o.cornerRadiusPx,swatchSymbol:o.symbol,label:c,value:i,isPrimary:n===e.primary,key:a},layerId:t.id,qualifier:u}}function fi(e,t,r,n){const a=(c,u)=>l.isDefined(u)?I({valueFormat:t.format??d.getLayerVariableValueFormat(e,c),locale:n.locale,numberFormat:n.numberFormat})(u,r.observation):null,i=c=>{const u=e.mapping[c],m=c==="y"&&u!==void 0?d.resolveSegmentYSource(e.position,e.mapping):u;return a(l.readVariableName(u),d.createRawValueReader(e.data,m)(r.observation))};if(t.kind==="variable")return a(t.variable,r.observation[t.variable]??null);if(t.kind==="aes")return i(t.aes);const[o,s]=t.range.map(i);return l.isDefined(o)&&l.isDefined(s)?`${o} – ${s}`:null}function zp(e,t,r,n){if(t.kind==="range"){const i=t.range.map(o=>d.resolveVariableLabel(l.readVariableName(e.mapping[o]),n.guides.variableLabels)??o).join(" – ");return pi(qt(e,r,n.resolveColorLabel),i,n.headingGroup)}const a=t.kind==="variable"?t.variable:l.readVariableName(e.mapping[t.aes]);return{label:d.resolveVariableLabel(a,n.guides.variableLabels)??a??"",qualifier:null}}function gi({related:e,layer:t,primaryLayer:r,primary:n}){const a=r===void 0?new Set:gn(r),i=[...gn(t)].filter(o=>a.has(o));return e.find(o=>i.every(s=>Up(o.observation[s],n.observation[s])))??e[0]}function gn(e){const t=new Set(l.getGroupVariables(e.data,e.mapping));for(const r of Object.values(e.mapping)){const n=l.readVariableName(r);n===null||!e.data.hasVariable(n)||e.data.getType(n)==="categorical"&&t.add(n)}return t}var Up=(e,t)=>l.getStableKey(e??null)===l.getStableKey(t??null);function Wp({layer:e,primaryLayer:t,hover:r,primary:n,mode:a}){const i=r.related.get(e.id)??[];if(e.id===n.layerId)return a==="band"?[n,...r.group,...i]:[n];if(a==="band")return i;const o=gi({related:i,layer:e,primaryLayer:t,primary:n});return o===void 0?[]:[o]}function Xp({hits:e,layer:t,colorScale:r,colorValueReader: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 qp({guides:e,locale:t,numberFormat:r}){const n=new Map(e.colorGroups.map(i=>[l.getStableKey(i.value),{label:i.label,format:Me({valueFormat:i.valueFormat,locale:t,numberFormat:r})}])),a=Me({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 jp(e,t){return d.resolveVariableLabel(l.readVariableName(t.mapping.y),e.variableLabels)??""}function Zp(e,t,r=0){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:r}function Jp(e,t,r=""){const n=e[t];return typeof n=="string"?n:r}var Qp=(e,t)=>({...e.annotation.arrow(t).resolve(),outline:e.annotation.arrow.outline(t).resolve()}),ef=(e,t)=>{const r=e.annotation.differenceArrow(t);return{...r.resolve(),isStrokeAuthored:Ot(r.getSource("stroke")),label:e.annotation.differenceArrow.label(t).resolve()}},tf=(e,t,r)=>{const n=e.annotation[t](r),a=e.annotation[t].label(r);return{marker:{...n.resolve(),isFillAuthored:Ot(n.getSource("fill"))},label:{...a.resolve(),isTextColorAuthored:a.getSource("textColor")==="authored"}}},rf=e=>e.strokeWidth>0?e.stroke??l.toPaintColor(e.fill):void 0,nf=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")}),af=e=>({...l.DEFAULT_GRAPH_PADDING_EDGES_PX,...e.graph().get("padding")}),C=e=>{let t={top:0,right:0,bottom:0,left:0};for(const r of e.collectAll("margin"))t={...t,...r};return t},of=e=>({header:C(e.header()),footer:C(e.footer()),headline:C(e.headline()),legend:{top:C(e.legend.top()),right:C(e.legend.right()),bottom:C(e.legend.bottom()),left:C(e.legend.left())},axisLabel:{top:C(e.axisLabel.top("x")),bottom:C(e.axisLabel.bottom("x"))},tickLabel:{top:C(e.tickLabel.top("x")),right:C(e.tickLabel.right("y")),bottom:C(e.tickLabel.bottom("x")),left:C(e.tickLabel.left("y"))}}),sf=e=>({hover:e.editOutline.hover().resolve(),selected:e.editOutline.selected().resolve()}),lf={color:l.getColor,alpha:l.getAlpha,strokeWidth:l.getStrokeWidth,lineType:l.getLineType,size:l.getSize},vn={vocabulary:{},aesthetics:{}},yn=new WeakMap,cf=(e={})=>{const t=e.colorScheme??"light",r=new WeakMap,n=new WeakMap,a=(c,u)=>{let m=r.get(c);m===void 0&&(m=new Map,r.set(c,m));const h=m.get(u);if(h!==void 0)return h;const{vocabulary:p,aesthetics:f}=uf(c.styles,u),g=pf({styles:hf(c.styles,u),colorScheme:t,vocabulary:p,visualVariableReaders:df(f,c.styles.dashPresets),findPart:S=>i(c,S)});return m.set(u,g),g},i=(c,u)=>Object.hasOwn(c.styles.parts,u)?a(c,u):void 0,o=Sc(a);return{readers:c=>{const u=n.get(c.chrome);if(u!==void 0)return u;const m=bc(c.chrome,o,t);return n.set(c.chrome,m),m}}},uf=(e,t)=>t===void 0?e.observation:Object.hasOwn(e.parts,t)?e.parts[t]??vn:vn,df=(e,t)=>{const r={};for(const[n,a]of Object.entries(e)){const i=a===void 0?void 0:lf[a];i!==void 0&&(r[n]=a==="lineType"?mf(t):i)}return r},mf=e=>t=>{const r=l.getLineType(t);return r===void 0?void 0:e[r]},hf=(e,t)=>{let r=yn.get(e);r===void 0&&(r=new Map,yn.set(e,r));const n=r.get(t);if(n!==void 0)return n;const a={defaults:Sn(e.defaults,t),overrides:Sn(e.overrides,t)};return r.set(t,a),a},Sn=(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},pf=({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=Y(e.overrides,h,p,f);if(A!==void 0)return{value:Z(A,h,t),tier:"override",origin:A.origin,state:f};const P=Y(e.defaults,h,p,f);if(P!==void 0)return{value:Z(P,h,t),tier:"default",origin:P.origin,state:f}}const g=Y(e.overrides,h,p,void 0);if(g!==void 0)return{value:Z(g,h,t),tier:"override",origin:g.origin};const S=i(h,p);if(S!==void 0)return{value:S,tier:"data"};const x=Y(e.defaults,h,p,void 0);return x!==void 0?{value:Z(x,h,t),tier:"default",origin:x.origin}:{value:void 0,tier:"unresolved"}},s=(h,p,f)=>{if(f!==void 0){const x=Ie(e.overrides,h,p,f,t);if(x!==void 0)return x;const A=Ie(e.defaults,h,p,f,t);if(A!==void 0)return A}const g=Ie(e.overrides,h,p,void 0,t);if(g!==void 0)return g;const S=i(h,p);return S!==void 0?S:Ie(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 P=A.declarations[h];P!==void 0&&vi(A,p)&&g.push(l.resolveColorScheme(P,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=Y(e.overrides,g,p,h)??Y(e.defaults,g,p,h),x=Z(S,g,t);x!==void 0&&Object.assign(f,{[g]:x})}return f},part:a}},Ie=(e,t,r,n,a)=>Z(Y(e,t,r,n),t,a),Z=(e,t,r)=>{const n=e?.declarations[t];return n===void 0?void 0:l.resolveColorScheme(n,r)},Y=(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&&vi(o,r))return o}},vi=(e,t)=>e.matches===void 0?!0:t!==void 0&&e.matches(t),jt=["sticker","pinnedNumber","comment","image"],ff=e=>jt.includes(e),Zt=e=>{switch(e.kind){case"pinnedNumber":case"comment":return e.annotation.at;case"sticker":return e.annotation.at.anchorType==="observation"?vf(e.annotation.at):null;default:return null}},yi=(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=gf)=>{const n=r(t);for(const a of jt){const i=d.readAnnotationBucket(e,a),o=i.findIndex(c=>{const u=Zt({kind:a,annotation:c});if(u===null)return!1;const m=r(u);return yi(m,n)}),s=i[o];if(s!==void 0)return{kind:a,index:o,annotation:s}}return null},gf=e=>({...e,anchorValue:et(e.anchorValue),...e.groupValue!==void 0&&{groupValue:et(e.groupValue)},...e.crossValue!==void 0&&{crossValue:et(e.crossValue)}}),et=e=>l.readISOInstant(e)??e,vf=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),yf=(e,t)=>e.find(r=>r.scope===t.scope&&r.layerId===t.layerId&&d.arePredicatesEqual(r.predicate,t.predicate))??null,bi=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)))),xi=e=>e.find(t=>t.geom==="line"&&t.stat.type==="smooth"),Ai=e=>e.find(t=>t.geom==="rule"&&t.stat.type==="mean");function Ii(e,{themeConfig:t}={}){return{mapping:e.mapping,layers:e.layers,scales:e.scales.map(bf),transforms:e.transforms,highlights:e.highlights,styles:b.styles(e.styles),annotations:e.annotations,coords:e.coords,config:t===void 0?e.config:Sf(e.config,t)}}var Sf=(e,t)=>Ti({...e},{...t}),bn=e=>(0,bt.isPlainObject)(e);function Ti(e,t){const r=Object.entries(e).flatMap(([n,a])=>{if(!(n in t))return[[n,a]];const i=t[n];return bn(a)&&bn(i)?[[n,Ti(a,i)]]:(0,bt.isEqual)(a,i)?[]:[[n,a]]});return Object.fromEntries(r)}function bf(e){const{inferredFrom:t,...r}=e;return r.scaleType==="palette"?xf(r):r}function xf(e){return{...e,palette:Af(e.palette),overrides:If(e.overrides)}}function Af(e){return e.type==="custom"?{type:"custom",id:e.id}:e}function If(e){if(!e)return;const t={};for(const[r,n]of Object.entries(e))t[Number(r)]={hex:n};return t}function y(e){return{id:e.id??d.uniqueId(),timestamp:e.timestamp??Date.now(),description:e.description,author:e.author??"unknown"}}function ee(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((r,n)=>ee(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=>ee(e[a],t[a]))}return!1}var Jt=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=d.findAnnotation(e.annotations,this.params.id);if(!t)return null;const{kind:r,index:n,annotation:a}=t;return{spec:d.patchSpec(e,{annotations:d.removeLocatedAnnotation(e.annotations,t)}),revert:new Qt({kind:r,annotation:a,index:n},this.metadata)}}},Tf={type:"remove-annotation",deserialize:(e,t)=>new Jt(e,t)},Qt=class Li{constructor(t,r={}){this.type="add-annotation",this.params={kind:t.kind,annotation:{...t.annotation,id:t.annotation.id??d.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(!d.isAnnotationKind(r)||d.findAnnotation(t.annotations,n.id))return null;const i=Ef(t.annotations,{kind:r,annotation:n}),o=i===null?t.annotations:d.removeLocatedAnnotation(t.annotations,i),s=d.readAnnotationBucket(o,r),c=a??s.length,u=Math.min(Math.max(c,0),s.length);return{spec:d.patchSpec(t,{annotations:d.replaceAnnotationBucket(o,r,[...s.slice(0,u),n,...s.slice(u)])}),revert:i===null?new Jt({id:n.id},this.metadata):new Li({kind:i.kind,annotation:i.annotation,index:i.index},this.metadata)}}},Lf={type:"add-annotation",deserialize:(e,t)=>new Qt({kind:e.kind,annotation:e.annotation,index:e.index},t)},Ef=(e,t)=>{const r=Zt(t);return r===null?null:Si(e,r)},Rf=(e,t)=>{const r=er(e);return r===null?null:Ei(r.points,t)},Cf=e=>er(e)!==null,wf=(e,t)=>{const r=er(e);if(r===null)return null;const n=Ei(r.points,t);return n.x===0&&n.y===0?null:r.createPatch(n)},er=e=>{const t=Mf[e.kind];return t===null?null:t(e.annotation)},xn=(e,t)=>e.anchorType!=="panel"?null:{points:[pt(e,e.offset)],createPatch:r=>t({...e,x:e.x+r.x,y:e.y+r.y})},An=(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})},Pf=(e,t)=>e.anchorType!=="panel"||t.anchorType!=="panel"?null:{points:[pt(e,e.offset),pt(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}})},Mf={text:e=>xn(e.at,t=>({at:t})),sticker:e=>xn(e.at,t=>({at:t})),shape:e=>An(e.region,t=>({region:t})),image:e=>An(e.region,t=>({region:t})),arrow:e=>Pf(e.start,e.end),differenceArrow:null,pinnedNumber:null,comment:null},pt=(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)},Ei=(e,t)=>({x:In(e.map(r=>r.x),t.x),y:In(e.map(r=>r.y),t.y)}),In=(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,ie.default)(t,r,n)},Ri=(e,t,r)=>{const n=t.annotation;if(!_f(n,r))return null;const a=d.readAnnotationBucket(e.annotations,t.kind),i=Df(t.annotation,r),o=[...a.slice(0,t.index),i,...a.slice(t.index+1)];return{spec:d.patchSpec(e,{annotations:d.replaceAnnotationBucket(e.annotations,t.kind,o)}),inverse:Of(n,r)}},Df=(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)))},Of=(e,t)=>{const r={};for(const n of Object.keys(t))r[n]=e[n];return r},_f=(e,t)=>Object.entries(t).some(([r,n])=>!Object.is(e[r],n)),tr=class Ci{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=d.findAnnotation(t.annotations,n);if(i===null||i.kind!==r)return null;const o=Ri(t,i,a);return o===null?null:{spec:o.spec,revert:new Ci({kind:r,id:n,patch:o.inverse},this.metadata)}}},kf={type:"update-annotation",deserialize:(e,t)=>new tr(e,t)},wi=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=d.findAnnotation(e.annotations,this.params.id);if(t===null)return null;const r=wf(t,this.params.translation);if(r===null)return null;const n=Ri(e,t,r);return n===null?null:{spec:n.spec,revert:new tr({kind:t.kind,id:t.annotation.id,patch:n.inverse},this.metadata)}}},Vf={type:"move-annotation",deserialize:(e,t)=>new wi(e,t)},F=class Ee{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=d.findStyleRuleIndex(i,n,d.readStyleCoord(t)),s=o===-1?void 0:i[o],{declarations:c}=n;if(c===null){if(s===void 0)return null;let g=0;for(let A=0;A<o;A+=1){const P=i[A];P!==void 0&&d.areStyleRuleAddressesEqual(P,s)&&(g+=1)}const S=new Ee({list:r,rule:s,index:o-g},this.metadata),x=i.filter(A=>!d.areStyleRuleAddressesEqual(A,s));return{spec:tt(t,r,x),revert:S}}if(s!==void 0){if(d.areStyleDeclarationsEqual(s.declarations,c))return null;const g={...s,declarations:c},S=new Ee({list:r,rule:s,index:o},this.metadata),x=i.map(A=>A===s?g:A);return{spec:tt(t,r,x),revert:S}}const u=a??i.length,m=Math.min(Math.max(u,0),i.length),h={...n,declarations:c},p=[...i.slice(0,m),h,...i.slice(m)],f=new Ee({list:r,rule:{...n,declarations:null}},this.metadata);return{spec:tt(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."})},Ff={type:"set-style-rule",deserialize:(e,t)=>(Nf(e),new F(e,t))},tt=(e,t,r)=>d.patchSpec(e,{styles:{...e.styles,[t]:r}}),Bf={type:"set-difference-arrow-style",deserialize:(e,t)=>new Pi(e,t)},Pi=class Mi{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=m=>{const h=d.findStyleRule(s.styles.overrides,m,d.readStyleCoord(s)),p=new F({list:"overrides",rule:m}).apply(s);if(p)return s=p.spec,h?.declarations??null};if(n!==void 0){const m=u({select:i,declarations:n});m!==void 0&&(c.arrow=m)}if(a!==void 0){const m=u({select:o,declarations:a});m!==void 0&&(c.label=m)}return s===t?null:{spec:s,revert:new Mi(c,this.metadata)}}},Gf=["cartesian","polar","flip"],w=new l.GeomRegistry,Di=e=>w.has(e)?w.get(e):null;function rr(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 He(e,t){return e.scales.find(r=>r.scaledAesthetic===t)}function $e(e,t,r){const n=e.scales.findIndex(a=>a.scaledAesthetic===t);return n===-1?e:d.patchSpec(e,{scales:d.replaceAtIndex(e.scales,n,r)})}function Ke(e){const t=e.replace(/([A-Z])/g," $1").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function ft(e,t,r){const n=d.resolveScale(d.createScaleContext(d.createCommonContainer(w),{data:ue(e),layers:e.layers,mapping:r,customPalettes:{}}),l.inferred(t));return e.coords.coordType==="polar"?d.removeDiscreteScalePadding(n):n}var Oi=class _i{constructor(t,r={}){this.type="set-chart-type",this.target={kind:"coords"},this.params=t,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=d.patchSpec(t,r);return n===t?null:{spec:n,revert:new _i({previous:{coords:t.coords,layers:t.layers,scales:t.scales,mapping:t.mapping}},this.metadata)}}},Hf={type:"set-chart-type",deserialize:(e,t)=>new Oi(e,t)},ki={type:"sum"},$f={type:"identity"},Kf=["bar","line","area","point","tile"],nr="tile",Yf=["y","color"],zf=Object.values(l.LAYER_LABEL_VARIABLES),Uf={coordType:"cartesian",geom:nr,position:"identity"},me=e=>e.coordType==="cartesian"&&"comboType"in e&&b.COMBO_TYPES.includes(e.comboType),Wf=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=Ni(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}},Xf=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:Fi(e,r)?Bi(e,r).length>=1:Ye(e,e.data.groupVariableNamesByType().numeric).length>=2},qf=e=>e?zi(e,Uf)!==null:!1,jf=e=>Vi(e)?.at(-1)?.id??null,Vi=e=>{if(e.coords.coordType!=="cartesian")return null;const t=e.layers.filter(B);return Ni(t)===null?null:t},Ni=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 Zf(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)},Zf=e=>e.some(t=>t.yScaleType==="secondary"||De(t))||new Set(e.map(t=>l.readVariableName(t.mapping.y))).size>1,Jf=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`,Qf=(e,t)=>{const r=zi(e,t);if(r===null)return null;const n=me(t)?tg(r,t):eg(r,t,e);return n===null||r===e?n:{...n,scales:pg({...e,...n},n.scales)}},eg=(e,t,r)=>{if(me(t)||!fg(t))return null;const n={...e,layers:Ji(e.layers)},a=yg(n.layers.filter(B),t),i=eo(n.coords,t),o=Ki(n,t),s=Zi({...n,mapping:o},t,a,o!==n.mapping);return{coords:i,layers:s,scales:rr(to(r,s,i.coordType),s),mapping:o}},tg=(e,t)=>{const r=ag(e,t.comboType);if(r===null)return null;const n={...e,layers:r},a=Sg(r.filter(B),t.comboType),i=eo(n.coords,t),o=Ki(n,t),s=Zi({...n,mapping:o},t,a,o!==n.mapping),c=rg(e)?s:ng(s);return{coords:i,layers:c,scales:rr(to(e,c,i.coordType),c),mapping:o}},rg=e=>Vi(e)!==null,ng=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)},ag=(e,t)=>{const r=e.layers.filter(B);if(r.length>=2)return e.layers;const[n]=r;return n===void 0?null:Fi(e,n)?ig(e,n):og(e,n,t)},Fi=(e,t)=>{const r=l.readVariableName(t.mapping.color??e.mapping.color);return r!==null&&r!==""},ig=(e,t)=>{const[r]=Bi(e,t);if(r===void 0)return null;const n=d.resolveLayer(w,e.mapping,e.coords.coordType,{type:"layer",id:Gi(r,new Set(e.layers.map(a=>a.id))),geom:"line",stat:ki,...$i(r,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(a=>a.id===t.id?[a,n]:[a])},Ye=(e,t)=>{const r=he(e);return t.filter(n=>n!==r)},Bi=(e,t)=>{const r=l.readVariableName(t.mapping.y??e.mapping.y);return Ye(e,e.data.groupVariableNamesByType().numeric).filter(n=>n!==r)},he=e=>l.readMainAxisVariable(e.mapping)||l.inferXVariable(e.data),og=(e,t,r)=>{const{numeric:n}=e.data.groupVariableNamesByType(),a=Ye(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=sg(t,Tn(a.slice(0,-1),o,s)),u=d.resolveLayer(w,e.mapping,e.coords.coordType,{type:"layer",id:Gi(i,new Set(e.layers.map(m=>m.id))),geom:"line",stat:t.stat,...Tn([i],o,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(m=>m.id===t.id?[c,u]:[m])},Gi=(e,t)=>{const r=`line:${e}`;let n=r;for(let a=2;t.has(n);a+=1)n=`${r}:${a}`;return n},Tn=(e,t,r)=>{const[n]=e;return e.length===1&&n!==void 0?$i(n,r):Hi(e,t)},Hi=(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})]}),$i=(e,t)=>({mapping:{y:e,color:t},transforms:[b.transform.constant({variableName:t,type:"categorical",value:e})]}),sg=(e,t)=>({...e,mapping:{...e.mapping,...t.mapping},transforms:[...e.transforms,...t.transforms]}),Ki=(e,t)=>{const r=l.readMainAxisVariable(e.mapping),n=Yi(t)?"":he(e);return n===r?e.mapping:{...e.mapping,x:n}},Yi=e=>e.coordType==="polar"&&e.theta==="y"&&e.position==="fill",lg=e=>!me(e)&&e.geom===nr,cg=e=>e.layers.filter(B).some(t=>t.geom===nr),zi=(e,t)=>{const r=lg(t);return r===cg(e)?e:r?ug({...e,layers:Ji(e.layers)}):dg(e)??e},ug=e=>{const t=Wi(e);if(t===null)return null;const r=mg(e,t)===null?hg(e,t):Xi(e,t);return r===null?null:Ui(e,t,r)},dg=e=>{const t=Wi(e);if(t===null)return null;const r=Xi(e,t);return r===null?null:Ui(e,t,r)},Ui=(e,t,r)=>({...e,mapping:r.mapping,layers:e.layers.map(n=>n===t?r.layer:n)}),Wi=e=>{const t=e.layers.filter(B);return t.length===1?t[0]??null:null},Xi=(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:qi(t)}},qi=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}},mg=(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=ue(e);return i.hasVariable(n)&&i.getType(n)==="numeric"?null:n},hg=(e,t)=>{const r=Ye(e,e.data.groupVariableNamesByType().numeric);if(r.length<2)return null;const n=l.readFoldKeepVariables(e.data,he(e)),a=Hi(r,n),i=qi(t);return{mapping:{...e.mapping,y:a.mapping.color,color:a.mapping.y},layer:{...i,transforms:[...i.transforms,...a.transforms]}}},pg=(e,t)=>Yf.reduce((r,n)=>{const a=ft(e,n,e.mapping);return r.some(i=>i.scaledAesthetic===n)?d.mapItems(r,i=>i.scaledAesthetic===n?a:i):[...r,a]},t),fg=e=>Gf.includes(e.coordType)&&ji(e.geom)&&gg(e)&&(e.coordType!=="polar"||Number.isFinite(e.innerRadius)),gg=({geom:e,coordType:t,position:r})=>{const{supportedCoordTypes:n,supportedPositions:a}=w.get(e);return n.includes(t)&&a.includes(r)},ji=e=>Kf.includes(e),B=e=>ji(e.geom)&&!vg(e.stat),vg=e=>{switch(e.type){case"smooth":return!0;case"identity":case"count":case"mean":case"sum":case"summary":return!1;default:return!0}},yg=(e,{geom:t,position:r})=>{const n={geom:t,position:r};return new Map(e.map(a=>[a.id,n]))},Sg=(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:bg(i,t,n)}]);return new Map(a)},bg=(e,t,r)=>e.geom!=="bar"||De(e)?r:b.readComboTypeOfBarPosition(e.position)===t?e.position:r,Zi=(e,t,r,n)=>{const a=e.coords.coordType!==t.coordType;return d.clampValuesAgainstFillSiblings(w,d.mapItems(e.layers,i=>{const o=r.get(i.id);if(o===void 0)return i;const s=xg(i.stat,e.coords,t);return a||n||i.geom!==o.geom||i.position!==o.position||s!==i.stat?Ig(e,{...i,stat:s},t.coordType,o):i}))},xg=(e,t,r)=>Yi(r)?e.type==="identity"?ki:e:Ag(t)&&e.type==="sum"?$f:e,Ag=e=>e.coordType==="polar"&&e.params.theta==="y",Ig=(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,...m}=t.dataLabels;return{...d.resolveLayer(w,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,tooltip:t.tooltip,dataLabels:{...m,...i.coordType&&{format:s},...i.geom&&i.coordType&&{offset:c},...i.geom&&i.position&&{justify:u}}}),stat:t.stat}},Ji=e=>{const t=e.filter(B);if(t.length<2||!e.some(De))return e;const[r]=t;return e.flatMap(n=>n===r?[Tg(n)]:De(n)?[]:[n])},De=e=>Qi(e)!==null,Qi=e=>{const t=e.transforms.at(-1);return t?.transformType==="reshape"?t.options.keyName==="key"?t:null:t?.transformType!=="constant"?null:zf.includes(t.options.variableName)?t:null},Tg=e=>{const t=Qi(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)}},eo=(e,t)=>{const r=Lg(e,t);return(0,W.default)(r,e)?e:r},Lg=(e,t)=>{const r={xLimits:e.params.xLimits,yLimits:e.params.yLimits};if(t.coordType!=="polar")return d.resolveCoord({type:"coord",coordType:t.coordType,params:r});const n=e.coordType==="polar"?e.params:d.POLAR_COORD_DEFAULTS;return d.resolveCoord({type:"coord",coordType:"polar",params:{...r,theta:t.theta,startAngle:n.startAngle,innerRadius:t.innerRadius}})},to=(e,t,r)=>{const n=d.resolveGeomScaleDemands(d.readGeomScaleConstraints(w,t)),a=d.resolveGeomScaleDemands(d.readGeomScaleConstraints(w,e.layers)),i=e.coords.coordType==="polar";return d.mapItems(e.scales,o=>{const s=Eg(o,n,a),c=Rg(s,n,a);return wg(c,r,i)})},Eg=(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 d.resolveDiscreteScale(l.discrete(e.scaledAesthetic,{..."reverse"in e&&{reverse:e.reverse}}),t);if(e.scaledAesthetic===t.discreteCrossAxis)return d.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=Cg(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}},Cg=(e,t,r)=>t.nice===(r?.nice??!0)?e:t.nice?l.CONTINUOUS_SCALE_DEFAULTS.nice:!1,wg=(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}},ro=class no{constructor(t,r={}){this.type="set-mapping",this.params=t,this.target={kind:"mapping",aesthetic:t.aesthetic},this.metadata=y({...r,description:Mg(t)})}apply(t){const r="previous"in this.params?this.params.previous:Dg(t,this.params);if(r===null)return null;const n=d.patchSpec(t,r);return n===t?null:{spec:n,revert:new no({aesthetic:this.params.aesthetic,previous:{mapping:t.mapping,scales:t.scales,layers:t.layers}},this.metadata)}}},Pg={type:"set-mapping",deserialize:(e,t)=>new ro(e,t)},ao=(e,t)=>{const r=l.readVariableName(e[t]);return r===null||r===""||l.isInternalVariable(r)?null:r},io=e=>e===""?null:e,Mg=e=>{if("previous"in e)return`Restore the previous ${e.aesthetic} mapping`;const t=io(e.variable);return t===null?`Clear the ${e.aesthetic} mapping`:`Map ${e.aesthetic} to ${t}`},Dg=(e,{aesthetic:t,variable:r})=>{if(!b.isAestheticKey(t))return null;const n=io(r),a=_g(e.mapping,t,n);return a===e.mapping?null:{mapping:a,scales:Vg(e,t,a,n),layers:Og(e.layers,a)}},Og=(e,t)=>d.mapItems(e,r=>{const n={...t,...r.mapping};if(n.label===void 0&&Di(r.geom)===null)return r;const a=d.resolveLabelSource(w,r.geom,r.position,n);return(0,W.default)(a,r.dataLabels.labelSource)?r:{...r,dataLabels:{...r.dataLabels,labelSource:a}}}),_g=(e,t,r)=>r===null?kg(e,t):ao(e,t)===r?e:{...e,[t]:r},kg=(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},Vg=(e,t,r,n)=>{if(!l.isScaledAestheticKey(t))return e.scales;let a=e.scales;for(const i of Ng(e,t))a=Bg(e,a,i,r,n);return a},Ng=(e,t)=>t==="y"&&Fg(e.layers)?["y","ySecondary"]:[t],Fg=e=>{const t=e.find(r=>r.yScaleType==="secondary");return t!==void 0&&t.mapping.y===void 0},Bg=(e,t,r,n,a)=>{const i=t.find(s=>s.scaledAesthetic===r);if(i===void 0)return a===null?t:[...t,ft(e,r,n)];if(a===null&&!l.isPositionScale(r)||a!==null&&!ue(e).hasVariable(a))return t;const o=ft(e,r,n);return Gg(i,o)?t:d.mapItems(t,s=>s.scaledAesthetic===r?o:s)},Gg=(e,t)=>e.scaleType===t.scaleType||Ln(e)&&Ln(t),Ln=e=>e.scaleType==="discrete"||e.scaleType==="palette",ar=e=>e==="both"?["x","y"]:[e],oo=e=>e==="both"?"the":`${e} axis`;function ir(e,t){return pe(e)?e[t]:e}function Hg(e,t){return e.config.axes[t]??{}}function $g(e,t,r){if(t!=="ySecondary")return d.updateSpec(e,{config:{axes:{[t]:r}}});const n=e.config.axes.ySecondary,a=so(n,r);if(a===n)return e;const i={...e.config.axes,ySecondary:a};return a===void 0&&delete i.ySecondary,d.patchSpec(e,{config:d.patchSpec(e.config,{axes:i})})}function pe(e){return l.isPlainObject(e)&&"x"in e&&"y"in e}function so(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?Kg(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 Kg(e,t){return l.isPlainObject(t)?so(l.isPlainObject(e)?e:void 0,t):t}var lo=class co{constructor(t,r={}){this.type="set-axis-label",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis label to ${zg(t.label)}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,label:n}=this.params,a=Hg(t,r).label;if(a===n)return null;const i=$g(t,r,{label:n});return i===t?null:{spec:i,revert:new co(r==="ySecondary"?{axis:r,label:a}:{axis:r,label:a??null},this.metadata)}}},Yg={type:"set-axis-label",deserialize:(e,t)=>new lo(e,t)};function zg(e){return e===void 0?"(inherited)":e??"(none)"}var uo=class mo{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:d.updateSpec(t,{config:{axes:{[r]:{position:n}}}}),revert:new mo({axis:r,position:a},this.metadata)}}},Ug={type:"set-axis-position",deserialize:(e,t)=>new uo(e,t)},ho=class po{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:d.updateSpec(t,{config:{axes:{[r]:{ticks:{mode:n}}}}}),revert:new po({axis:r,tickMode:a},this.metadata)}}},Wg={type:"set-axis-tick-mode",deserialize:(e,t)=>new ho(e,t)},fo=class go{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:d.updateSpec(t,{config:{axes:{[r]:{ticks:{isVisible:n}}}}}),revert:new go({axis:r,isVisible:a},this.metadata)}}},Xg={type:"set-axis-ticks-visibility",deserialize:(e,t)=>new fo(e,t)},vo=class yo{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:d.updateSpec(t,{config:{axes:{[r]:{isVisible:n}}}}),revert:new yo({axis:r,isVisible:a},this.metadata)}}},qg={type:"set-axis-visibility",deserialize:(e,t)=>new vo(e,t)},So=class bo{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:d.updateSpec(t,{config:{content:{caption:this.params.caption}}}),revert:new bo({caption:r},this.metadata)}}},jg={type:"set-content-caption",deserialize:(e,t)=>new So(e,t)},xo=class Ao{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(ee(r,this.params.source))return null;const n=d.patchSpec(t.config.content,{source:this.params.source});return{spec:d.patchSpec(t,{config:d.patchSpec(t.config,{content:n})}),revert:new Ao({source:r},this.metadata)}}},Zg={type:"set-content-source",deserialize:(e,t)=>new xo(e,t)},Io=class To{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:d.updateSpec(t,{config:{content:{subtitle:this.params.subtitle}}}),revert:new To({subtitle:r},this.metadata)}}},Jg={type:"set-content-subtitle",deserialize:(e,t)=>new Io(e,t)},Lo=class Eo{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:d.updateSpec(t,{config:{content:{title:this.params.title}}}),revert:new Eo({title:r},this.metadata)}}},Qg={type:"set-content-title",deserialize:(e,t)=>new Lo(e,t)},Ro=(e,t,r,n)=>{const a=ev(t,r),i=rv(e,a,n);let o=e,s=!1;for(const c of a){const u=av(o,c,n,nv(c,n,tv(r,c)));u!==null&&(o=u,s=!0)}return s?{spec:o,previous:i}:null},ev=(e,t)=>e==="both"&&!pe(t)?[void 0]:ar(e),tv=(e,t)=>t===void 0?pe(e)?e.x:e:ir(e,t),rv=(e,t,r)=>t.length===1?rt(e,t[0],r):{x:rt(e,"x",r),y:rt(e,"y",r)},rt=(e,t,r)=>wo(e,t)?.[r]??null,nv=(e,t,r)=>r===null||t==="strokeWidth"?r:(e===void 0?["x","y"]:[e]).every(n=>Co(l.STYLE_TARGETS.gridLine.children[n].rest[t],r))?null:r,Co=(e,t)=>Array.isArray(e)&&Array.isArray(t)?kt(e,t):e===t,av=(e,t,r,n)=>{const a=wo(e,t);return Co(a?.[r]??null,n)?null:new F({list:"overrides",rule:lv(t,sv(a,r,n))}).apply(e)?.spec??null},iv=e=>e.select.target==="gridLine",ov=e=>({select:e===void 0?{target:"gridLine"}:{target:"gridLine",axis:e}}),wo=(e,t)=>{const r=d.findStyleRule(e.styles.overrides,ov(t),d.readStyleCoord(e));if(!(r===void 0||!iv(r)))return r.declarations},sv=(e,t,r)=>{const{[t]:n,...a}=e??{};return r!==null?{...a,[t]:r}:Object.keys(a).length===0?null:a},En=(e,t)=>e===void 0?b.style.gridLine(t):e==="x"?b.style.gridLine.x(t):b.style.gridLine.y(t),lv=(e,t)=>t===null?{...En(e,{}),declarations:null}:En(e,t),Po=class Mo{constructor(t,r={}){this.type="set-grid-line-style",this.params=t,this.metadata=y({...r,description:`Set ${oo(t.axis)} grid line style to ${uv(t)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineStyle:n}=this.params,a=Ro(t,r,Rn(n,dv),"dashArray");return a===null?null:{spec:a.spec,revert:new Mo({axis:r,lineStyle:Rn(a.previous,mv)},this.metadata)}}},cv={type:"set-grid-line-style",deserialize:(e,t)=>new Po(e,t)},uv=({axis:e,lineStyle:t})=>{const r=ar(e).map(n=>ir(t,n)??"(theme)");return[...new Set(r)].join(" and ")},dv=e=>e===null?null:l.DASH_PRESETS.gridLine[e],mv=e=>e===null?null:_t(e),Rn=(e,t)=>pe(e)?{x:t(e.x),y:t(e.y)}:t(e),hv={type:"set-grid-line-width",deserialize:(e,t)=>new Do(e,t)},Do=class Oo{constructor(t,r={}){this.type="set-grid-line-width";const n=pv(t.lineWidth);this.params={...t,lineWidth:n},this.metadata=y({...r,description:`Set ${oo(t.axis)} grid line width to ${fv(t.axis,n)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineWidth:n}=this.params,a=Ro(t,r,n,"strokeWidth");return a===null?null:{spec:a.spec,revert:new Oo({axis:r,lineWidth:a.previous},this.metadata)}}},pv=e=>pe(e)?{x:nt(e.x),y:nt(e.y)}:nt(e),nt=e=>e===null||!Number.isFinite(e)?null:Math.max(0,e),fv=(e,t)=>{const r=ar(e).map(n=>ir(t,n)??"(theme)");return[...new Set(r)].join(" and ")},_o=class ko{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:d.updateSpec(t,{config:{axes:{[r]:{grid:{isVisible:n}}}}}),revert:new ko({axis:r,isVisible:a},this.metadata)}}},gv={type:"set-grid-visibility",deserialize:(e,t)=>new _o(e,t)},Vo=class No{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:d.updateSpec(t,{config:{headline:{compareWith:this.params.compareWith}}}),revert:new No({compareWith:r},this.metadata)}}},vv={type:"set-headline-compare-with",deserialize:(e,t)=>new Vo(e,t)},Fo=class Bo{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:d.updateSpec(t,{config:{headline:{position:this.params.position}}}),revert:new Bo({position:r},this.metadata)}}},yv={type:"set-headline-position",deserialize:(e,t)=>new Fo(e,t)},Go=class Ho{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:d.updateSpec(t,{config:{headline:{show:this.params.show}}}),revert:new Ho({show:r},this.metadata)}}},Sv={type:"set-headline-show",deserialize:(e,t)=>new Go(e,t)},$o=class Ko{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:d.updateSpec(t,{config:{headline:{size:this.params.size}}}),revert:new Ko({size:r},this.metadata)}}},bv={type:"set-headline-size",deserialize:(e,t)=>new $o(e,t)},xv={type:"set-highlight-dim-style",deserialize:(e,t)=>new Yo(e,t)},Yo=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){return zo(e)===this.params.dimStyle?null:new F({list:"overrides",rule:Iv(this.params.dimStyle,Av(e))},this.metadata).apply(e)}},gt={select:{target:"geom"},when:{state:"dimmed"}},zo=e=>d.combineStyleDeclarations(e.styles.overrides,gt,d.readStyleCoord(e))?.saturation===0?"desaturate":"dim",Av=e=>{const t=d.readStyleCoord(e);return d.combineStyleDeclarations(d.readStyleRulesBeneath(e.styles.overrides,gt,t),gt,t)?.saturation===0},Iv=(e,t)=>e==="desaturate"?b.style.geom({saturation:0,alpha:.6},{state:"dimmed"}):b.style.geom({alpha:l.DEFAULT_DIMMED_ALPHA,...t?{saturation:1}:{}},{state:"dimmed"}),Uo=class Wo{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:d.updateSpec(t,{config:{legend:{align:this.params.align}}}),revert:new Wo({align:r},this.metadata)}}},Tv={type:"set-legend-align",deserialize:(e,t)=>new Uo(e,t)},Xo=class qo{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:d.updateSpec(t,{config:{legend:{display:this.params.display}}}),revert:new qo({display:r},this.metadata)}}},Lv={type:"set-legend-display",deserialize:(e,t)=>new Xo(e,t)},jo=class Zo{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:d.updateSpec(t,{config:{legend:{position:this.params.position}}}),revert:new Zo({position:r},this.metadata)}}},Ev={type:"set-legend-position",deserialize:(e,t)=>new jo(e,t)},Jo=class Qo{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:d.updateSpec(t,{config:{numberFormat:{abbreviation:this.params.abbreviation}}}),revert:new Qo({abbreviation:r},this.metadata)}}},Rv={type:"set-number-format-abbreviation",deserialize:(e,t)=>new Jo(e,t)},es=class ts{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:d.updateSpec(t,{config:{numberFormat:{decimals:this.params.decimals}}}),revert:new ts({decimals:r},this.metadata)}}},Cv={type:"set-number-format-decimals",deserialize:(e,t)=>new es(e,t)},rs=class ns{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=Pv(r);if(!a)return null;const i=t.config.content[a];return i===n?null:{spec:d.updateSpec(t,{config:{content:{[a]:n}}}),revert:new ns({part:r,isVisible:i},this.metadata)}}},wv={type:"toggle-content-visibility",deserialize:(e,t)=>new rs(e,t)},Cn={title:"isTitleVisible",subtitle:"isSubtitleVisible",caption:"isCaptionVisible",source:"isSourceVisible"};function Pv(e){return Object.hasOwn(Cn,e)?Cn[e]:void 0}var as=class is{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(ee(i.xLimits,a.xLimits)&&ee(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 is(o,this.metadata);return{spec:d.patchSpec(t,{coords:Dv(t.coords,i)}),revert:s}}},Mv={type:"set-coord-limits",deserialize:(e,t)=>new as(e,t)};function Dv(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 os=class ss{constructor(t,r={}){this.type="set-polar-inner-radius",this.target={kind:"coords"},this.params={innerRadius:(0,ie.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:d.patchSpec(t,{coords:{...r,params:{...r.params,innerRadius:this.params.innerRadius}}}),revert:new ss({innerRadius:n},this.metadata)}}},Ov={type:"set-polar-inner-radius",deserialize:(e,t)=>new os(e,t)},_v={type:"set-polar-start-angle",deserialize:(e,t)=>new ls(e,t)},ls=class cs{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:d.patchSpec(t,{coords:{...r,params:{...r.params,startAngle:this.params.startAngle}}}),revert:new cs({startAngle:n},this.metadata)}}},at=360,wn=e=>(e%at+at)%at,or=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 sr({predicate:t.predicate,id:t.id,scope:t.scope,layerId:t.layerId,index:r},this.metadata);return{spec:d.patchSpec(e,{highlights:n}),revert:a}}},kv={type:"remove-highlight",deserialize:(e,t)=>new or(e,t)},sr=class{constructor(e,t={}){this.type="add-highlight",this.params={...e,id:e.id??d.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(m=>m.id===r))return null;const o=new or({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:d.patchSpec(e,{highlights:[...e.highlights.slice(0,u),s,...e.highlights.slice(u)]}),revert:o}}},Vv={type:"add-highlight",deserialize:(e,t)=>new sr(e,t)};function lr(e,t){return{...e,params:{...e.params,...t}}}function ze(e,t){return{...e,dataLabels:{...e.dataLabels,...t}}}function cr(e,t){return d.patchSpec(e,{layers:[...e.layers,t]})}function M(e,t,r){const n=e.layers.findIndex(a=>a.id===t);return n===-1?e:d.patchSpec(e,{layers:d.replaceAtIndex(e.layers,n,r)})}function Ue(e,t){const r=e.layers.findIndex(n=>n.id===t);return r===-1||e.layers.length<=1?e:d.patchSpec(e,{layers:e.layers.filter((n,a)=>a!==r)})}var ur=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=Ue(e,this.params.layerId);return n===e?null:{spec:n,revert:new dr({layer:r,index:t},this.metadata)}}},Nv={type:"remove-layer",deserialize:(e,t)=>new ur(e,t)},dr=class{constructor(e,t={}){this.type="add-layer",this.params={layer:{...e.layer,id:e.layer.id??d.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:d.patchSpec(e,{layers:[...e.layers.slice(0,a),t,...e.layers.slice(a)]}),revert:new ur({layerId:t.id},this.metadata)}}},Fv={type:"add-layer",deserialize:(e,t)=>new dr(e,t)},us=class ds{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(!d.isLayerSpecOf(d.findLayerById(t.layers,r),"bar"))return null;const a=d.buildLayerStyleAddress("bar",r),i=d.findKindStyleDeclarations(t.styles.overrides,a,d.readStyleCoord(t)),o=i?.cornerRadius??null;if(o===n)return null;const s=new F({list:"overrides",rule:{...a,declarations:Gv(i,n)}}).apply(t);if(!s)return null;const c=new ds({layerId:r,cornerRadius:o},this.metadata);return{spec:s.spec,revert:c}}},Bv={type:"set-bar-corner-radius",deserialize:(e,t)=>new us(e,t)},Gv=(e,t)=>{const{cornerRadius:r,...n}=e??{};return t!==null?{...n,cornerRadius:t}:Object.keys(n).length===0?null:n},Hv={type:"set-bar-width",deserialize:(e,t)=>new hs(e,t)},ms=.05,$v=1,hs=class ps{constructor(t,r={}){this.type="set-bar-width";const n=t.width===void 0?void 0:(0,ie.default)(t.width,ms,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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"bar");if(!d.isLayerSpecOf(r,"bar"))return null;const n=r.params.width;return n===this.params.width?null:{spec:M(t,r.id,lr(r,{width:this.params.width})),revert:new ps({layerId:r.id,width:n},this.metadata)}}},fs=class gs{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?d.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:M(t,r.id,ze(r,{format:this.params.format})),revert:new gs({layerId:r.id,format:n},this.metadata)}}},Kv={type:"set-data-labels-format",deserialize:(e,t)=>new fs(e,t)},vs=class ys{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"bar","area");if(!r)return null;const n=r.position;return n===this.params.position?null:{spec:M(t,r.id,{...r,position:this.params.position}),revert:new ys({layerId:r.id,position:n},this.metadata)}}},Yv={type:"set-layer-position",deserialize:(e,t)=>new vs(e,t)},Ss=class bs{constructor(t,r={}){this.type="set-layer-stat";const n=d.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?d.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.stat;return Uv(n,this.params.stat)?null:{spec:M(t,r.id,{...r,stat:this.params.stat}),revert:new bs({layerId:r.id,stat:n},this.metadata)}}},zv={type:"set-layer-stat",deserialize:(e,t)=>new Ss(e,t)},Uv=(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},xs=class As{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?d.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=M(t,r.id,{...r,yScaleType:this.params.yScaleType});return{spec:d.patchSpec(a,{scales:this.params.previousScales===void 0?rr(a.scales,a.layers):this.params.previousScales}),revert:new As({layerId:r.id,yScaleType:n,previousScales:t.scales},this.metadata)}}},Wv={type:"set-layer-y-scale-type",deserialize:(e,t)=>new xs(e,t)},Is=class Ts{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"line","area");if(!d.isLayerSpecOf(r,"line","area"))return null;const n=r.params.curve;return n===this.params.curve?null:{spec:M(t,r.id,lr(r,{curve:this.params.curve})),revert:new Ts({layerId:r.id,curve:n},this.metadata)}}},Xv={type:"set-line-curve",deserialize:(e,t)=>new Is(e,t)},Ls=class Es{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"line","area");if(!d.isLayerSpecOf(r,"line","area"))return null;const n=r.params.missingValues;return n===this.params.missingValues?null:{spec:M(t,r.id,lr(r,{missingValues:this.params.missingValues})),revert:new Es({layerId:r.id,missingValues:n},this.metadata)}}},qv={type:"set-line-missing-values",deserialize:(e,t)=>new Ls(e,t)},Rs=class Cs{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=d.findLayerById(t.layers,r);if(!d.isLayerSpecOf(a,"line","area"))return null;const i=d.findKindStyleDeclarations(t.styles.overrides,d.buildLayerStyleAddress(a.geom,r),d.readStyleCoord(t)),o=i?.strokeWidth??null;if(o===n)return null;const s=Zv(i,n),c=new F({list:"overrides",rule:a.geom==="area"?{...d.buildLayerStyleAddress("area",r),declarations:s}:{...d.buildLayerStyleAddress("line",r),declarations:s}}).apply(t);return c?{spec:c.spec,revert:new Cs({layerId:r,lineWidth:o},this.metadata)}:null}},jv={type:"set-line-width",deserialize:(e,t)=>new Rs(e,t)},Zv=(e,t)=>{const{strokeWidth:r,...n}=e??{};return t!==null?{...n,strokeWidth:t}:Object.keys(n).length===0?null:n},ws=class Ps{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(!d.isLayerSpecOf(d.findLayerById(t.layers,r),"point"))return null;const a=d.buildLayerStyleAddress("point",r),i=d.findKindStyleDeclarations(t.styles.overrides,a,d.readStyleCoord(t)),o=i?.size??null;if(o===n)return null;const s=new F({list:"overrides",rule:{...a,declarations:Qv(i,n)}}).apply(t);return s?{spec:s.spec,revert:new Ps({layerId:r,size:o},this.metadata)}:null}},Jv={type:"set-point-size",deserialize:(e,t)=>new ws(e,t)},Qv=(e,t)=>{const{size:r,...n}=e??{};return t!==null?{...n,size:t}:Object.keys(n).length===0?null:n},Ms=class Ds{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"rule");if(!d.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:M(t,r.id,{...r,params:i}),revert:new Ds({layerId:r.id,label:n??null},this.metadata)}}},ey={type:"set-rule-label",deserialize:(e,t)=>new Ms(e,t)},Os=class _s{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"rule");if(!d.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:M(t,r.id,{...r,mapping:i}),revert:new _s({layerId:r.id,value:a},this.metadata)}}},ty={type:"set-rule-value",deserialize:(e,t)=>new Os(e,t)},ry={type:"set-stat-line",deserialize:(e,t)=>new ks(e,t)},ks=class Vs{constructor(t,r={}){this.type="set-stat-line",this.params=t,this.metadata=y({...r,description:cy(t.line)})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=ay(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&&ly(r.layer,n))return null;const a=new Vs({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:M(t,r.layer.id,n),revert:a};const i=r===void 0?t:Ue(t,r.layer.id);return n===null&&i===t?null:{spec:n===null?i:cr(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"?iy(this.params):oy(t,this.params);if(n===null)return null;const a=d.resolveLayer(w,t.mapping,t.coords.coordType,n);return r===void 0?a:{...a,id:r}}},ny="linear",ay=e=>{const t=xi(e.layers);if(t!==void 0)return{line:"trend",layer:t};const r=Ai(e.layers);if(r!==void 0)return{line:"average",layer:r}},iy=({method:e})=>l.geom.line({aes:{lineType:{value:"dashed"}},stat:b.stat.smooth({method:e??ny}),interactive:!1}),oy=(e,{group:t,label:r})=>{const n=sy(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})},sy=e=>e.layers.find(t=>t.geom!=="rule"&&t.stat.type!=="smooth"),ly=(e,t)=>(0,bt.isEqual)({...e,id:""},{...t,id:""}),cy=e=>e==="none"?"Hide stat line":`Show ${e} line`,Ns=class Fs{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?d.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:M(t,r.id,ze(r,{showCategoryLabels:this.params.showCategoryLabels})),revert:new Fs({layerId:r.id,showCategoryLabels:n},this.metadata)}}},uy={type:"toggle-category-labels",deserialize:(e,t)=>new Ns(e,t)},Bs=class Gs{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?d.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:M(t,r.id,ze(r,{showDataLabels:this.params.showDataLabels})),revert:new Gs({layerId:r.id,showDataLabels:n},this.metadata)}}},dy={type:"toggle-data-labels",deserialize:(e,t)=>new Bs(e,t)},my={type:"toggle-goal-line",deserialize:(e,t)=>new Hs(e,t)},Hs=class vt{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=bi(t.layers);if(!this.params.showGoalLine){if(r===void 0)return null;const a=Ue(t,r.id);return a===t?null:{spec:a,revert:new vt({showGoalLine:!0,removedLayer:r},this.metadata)}}if(r!==void 0)return null;const n=this.params.removedLayer??this.buildGoalLine(t);return{spec:cr(t,n),revert:new vt({showGoalLine:!1,layerId:n.id},this.metadata)}}buildGoalLine(t){const r=t.coords.coordType==="flip"?"end":"start";return d.resolveLayer(w,t.mapping,t.coords.coordType,l.geom.rule({aes:{y:{value:this.params.value??hy}},params:{labelPosition:r,...this.params.label!==void 0&&{label:this.params.label}},interactive:!1}))}},hy=0,py={type:"toggle-line-fill",deserialize:(e,t)=>new $s(e,t)},$s=class{constructor(e,t={}){this.type="toggle-line-fill",this.params=e,this.metadata=y({...t,description:`Set line fill to ${e.showFill}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(e){const{layerId:t,showFill:r,fillAlpha:n}=this.params;if(!d.isLayerSpecOf(d.findLayerById(e.layers,t),"line"))return null;const a=d.buildLayerStyleAddress("line",t),i=d.readStyleCoord(e),o=d.findKindStyleDeclarations(e.styles.overrides,a,i),s=d.combineKindStyleDeclarations(d.readStyleRulesBeneath(e.styles.overrides,a,i),a,i);if(Pn(o?.fillAlpha??s?.fillAlpha)===r)return null;const c=gy(r,n,Pn(s?.fillAlpha));return new F({list:"overrides",rule:{...a,declarations:vy(o,c)}},this.metadata).apply(e)}},fy=.2,Pn=e=>(e??0)>0,gy=(e,t,r)=>e?t??(r?null:fy):r?0:null,vy=(e,t)=>{const{fillAlpha:r,...n}=e??{};return t!==null?{...n,fillAlpha:t}:Object.keys(n).length===0?null:n},yy={type:"toggle-line-points",deserialize:(e,t)=>new Ks(e,t)},Ks=class yt{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"line","area");return d.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:cr(t,this.params.removedLayer??d.resolveLayer(w,t.mapping,t.coords.coordType,l.geom.point({aes:{...r.mapping},position:r.position,yScaleType:r.yScaleType,transforms:[...r.transforms],interactive:!1}))),revert:new yt({layerId:r.id,showPoints:!1},this.metadata)}}removePointLayer(t,r){const n=this.findAssociatedPointLayer(t,r);return n?{spec:Ue(t,n.id),revert:new yt({layerId:r.id,showPoints:!0,removedLayer:n},this.metadata)}:null}findAssociatedPointLayer(t,r){return t.layers.find(n=>n.geom!=="point"?!1:d.isCompanionLayer(n,[r]))}},Ys=class zs{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?d.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:M(t,r.id,ze(r,{showStackTotals:this.params.showStackTotals})),revert:new zs({layerId:r.id,showStackTotals:n},this.metadata)}}},Sy={type:"toggle-stack-totals",deserialize:(e,t)=>new Ys(e,t)},Us=class Ws{constructor(t,r={}){this.type="set-scale-domain",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} scale domain`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(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=$e(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 Ws(c,this.metadata)}}},by={type:"set-scale-domain",deserialize:(e,t)=>new Us(e,t)},Xs=class qs{constructor(t,r={}){this.type="set-scale-palette",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} palette`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(t,this.params.scaledAesthetic);return r?.scaleType!=="palette"||ee(r.palette,this.params.palette)?null:{spec:$e(t,this.params.scaledAesthetic,{...r,scaledAesthetic:this.params.scaledAesthetic,palette:this.params.palette}),revert:new qs({scaledAesthetic:this.params.scaledAesthetic,palette:r.palette},this.metadata)}}},xy={type:"set-scale-palette",deserialize:(e,t)=>new Xs(e,t)},js=class Zs{constructor(t,r={}){this.type="set-scale-reverse",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} scale reverse to ${t.reverse}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(t,this.params.scaledAesthetic);if(!r||!Iy(r))return null;const n=r.reverse;return n===this.params.reverse?null:{spec:$e(t,this.params.scaledAesthetic,{...r,reverse:this.params.reverse}),revert:new Zs({scaledAesthetic:this.params.scaledAesthetic,reverse:n},this.metadata)}}},Ay={type:"set-scale-reverse",deserialize:(e,t)=>new js(e,t)};function Iy(e){return e.scaleType==="continuous"||e.scaleType==="datetime"||e.scaleType==="discrete"}var Js=class Qs{constructor(t,r={}){this.type="set-scale-transform",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} scale transform to ${t.transform}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(t,this.params.scaledAesthetic);if(!r||r.scaleType!=="continuous")return null;const n=r.transform;return n===this.params.transform?null:{spec:$e(t,this.params.scaledAesthetic,{...r,transform:this.params.transform}),revert:new Qs({scaledAesthetic:this.params.scaledAesthetic,transform:n},this.metadata)}}},Ty={type:"set-scale-transform",deserialize:(e,t)=>new Js(e,t)},Ly=e=>{if(!(Array.isArray(e.commands)&&e.commands.length>0))throw new l.UserInputError({code:"INVALID_SEQUENCE",message:"Command 'sequence' needs at least one command.",suggestion:"Send 'commands' as a list with one or more commands."})},mr=class el{constructor(t,r={}){this.type="sequence";const n=[...t.commands],[a]=n;if(!a)throw new l.InternalError({message:"SequenceCommand needs at least one command"});this.commands=n,this.target=a.target,this.params={commands:n.map(i=>({type:i.type,params:i.params,metadata:i.metadata}))},this.metadata=y({...r,description:a.metadata.description})}apply(t){let r=t;const n=[];for(const a of this.commands){const i=a.apply(r);i&&(r=i.spec,n.push(i.revert))}return n.length===0||(0,W.default)(r,t)?null:{spec:r,revert:new el({commands:n.reverse()},this.metadata)}}},tl=class{constructor(e,t={}){this.type="set-observations-color",this.params=e,this.metadata=y({...t,description:e.color===null?"Remove colour":"Set colour"})}get target(){return this.params.target}apply(e){const t=Ia(e,this.params.target);if(t===null)return null;const r=[];let n=e;const a=o=>{for(const s of o){const c=s.apply(n);c&&(n=c.spec,r.push(c.revert))}};if(this.params.color!==null)for(const o of t)for(const s of Cy(n,o))a(Ry(n,s,o.property));for(const o of t)a(Py(n,o,this.params.color));if(r.length===0||(0,W.default)(n,e))return null;const[i]=r;return r.length===1&&i!==void 0?{spec:n,revert:i}:{spec:n,revert:new mr({commands:[...r].reverse()},this.metadata)}}},Ey={type:"set-observations-color",deserialize:(e,t)=>new tl(e,t)},Ry=(e,t,r)=>{const n=t[t.length-1];if(n===void 0||!t.some(o=>wy(o.declarations,r)))return[];const a=nl(rl(t),r,null);if(t.length===1)return a!==null&&d.areStyleDeclarationsEqual(a,n.declarations)?[]:[$(n,a)];const i=[$(n,null)];if(a!==null){const o=d.findStyleRuleIndex(e.styles.overrides,n,d.readStyleCoord(e));i.push($(n,a,o-(t.length-1)))}return i},Cy=(e,t)=>{const r=[],n=new Map;for(const a of e.styles.overrides){if(a.when?.state!==void 0||!Dy(a,t)||!Oy(a.when?.where,t.where))continue;const i=d.readStyleRuleAddressKey(a),o=n.get(i);if(o===void 0){n.set(i,r.length),r.push([a]);continue}r[o]?.push(a)}return r},rl=e=>e.reduce((t,r)=>({...t,...r.declarations}),{}),wy=(e,t)=>Object.entries(e).some(([r])=>r===t),Py=(e,t,r)=>{const n=e.styles.overrides,a=My(t),i=n.filter(h=>d.areStyleRuleAddressesEqual(h,a)),o=d.findStyleRuleIndex(n,a,d.readStyleCoord(e)),s=o===-1?void 0:n[o],c=nl(i.length===0?{}:rl(i),t.property,r);if(s===void 0)return c===null?[]:[$(a,c)];if(!d.isGeomStyleRule(s))return[];if(c===null)return[$(s,null)];const u=o===n.length-1;if(u&&i.length===1&&d.areStyleDeclarationsEqual(s.declarations,c))return[];if(u&&i.length===1)return[$(s,c)];const m=u?o-(i.length-1):void 0;return[$(s,null),$(s,c,m)]},$=(e,t,r)=>new F({list:"overrides",rule:{...e,declarations:t},...r===void 0?{}:{index:r}}),My=e=>({select:{target:"geom",kind:e.geomKind,layer:e.layerId},...e.where===void 0?{}:{when:{where:e.where}}}),Dy=(e,t)=>d.isGeomStyleRule(e)&&e.select.kind===t.geomKind&&e.select.layer===t.layerId&&e.select.part===void 0,Oy=(e,t)=>{const r=Mn(e);if(r===null)return!1;const n=t===void 0?[]:Mn(t);return n===null?!1:n.every(a=>r.some(i=>i.variable===a.variable&&(0,W.default)(i.eq,a.eq)))&&r.length>n.length},Mn=e=>{if(e===void 0)return null;if("eq"in e)return[{variable:e.variable,eq:e.eq}];if(!("and"in e))return null;const t=[];for(const r of e.and){if(!("eq"in r))return null;t.push({variable:r.variable,eq:r.eq})}return t},nl=(e,t,r)=>{const n={...e,...r===null?{}:{[t]:r}};return r===null&&t==="fill"&&delete n.fill,r===null&&t==="stroke"&&delete n.stroke,Object.keys(n).length===0?null:n},al=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 al;v.register(Hf);v.register(Pg);v.register(Fv);v.register(Nv);v.register(Kv);v.register(Yv);v.register(zv);v.register(Wv);v.register(Xv);v.register(jv);v.register(Bv);v.register(Hv);v.register(Jv);v.register(qv);v.register(ey);v.register(ty);v.register(ry);v.register(uy);v.register(dy);v.register(my);v.register(py);v.register(yy);v.register(Sy);v.register(by);v.register(xy);v.register(Ay);v.register(Ty);v.register(Yg);v.register(Wg);v.register(Ug);v.register(Xg);v.register(qg);v.register(jg);v.register(Zg);v.register(Jg);v.register(Qg);v.register(cv);v.register(hv);v.register(gv);v.register(vv);v.register(yv);v.register(Sv);v.register(bv);v.register(xv);v.register(Tv);v.register(Lv);v.register(Ev);v.register(Rv);v.register(Cv);v.register(wv);v.register(Vv);v.register(kv);v.register(Ff);v.register(Ey);v.register(Lf);v.register(Tf);v.register(kf);v.register(Bf);v.register(Vf);v.register(Mv);v.register(Ov);v.register(_v);v.register({type:"sequence",deserialize:(e,t)=>(Ly(e),new mr({commands:e.commands.map(r=>v.deserialize(r))},t))});var il=(e,t)=>e===t?!0:e===null||t===null?!1:St(e)===St(t),St=e=>{switch(e.kind){case"annotation":case"highlight":return JSON.stringify([e.kind,e.id]);case"styleRule":return JSON.stringify([e.kind,e.list,d.readStyleRuleAddressKey(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,d.readPredicateKey(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}`})}},ol=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,m)=>r?m: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:Dn(this.undoStack),redoStack:Dn(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&&ky(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)}}},_y=Object.freeze([]),ky=(e,t)=>e.type===t.type&&il(e.target,t.target),Dn=e=>e.length===0?_y:e.map(t=>t.command.metadata),Vy=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}},Ny=class{constructor(e){this.compiler=e,this.history=new ol,this.current=null,this.last=null,this.hostSpec=null,this.run=new Vy(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,m=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&&m.ok&&this.history.clear(),{result:m,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=Ii(e,{themeConfig:this.compiler.theme?.config});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}},Fy=new Set(["x","y"]),On=["numeric","categorical","temporal"],_n=["numeric"],By=(e,t)=>{const r=e.layers.map(a=>Di(a.geom)).filter(l.isDefined),n=ue(e);return t.filter(a=>Gy(e,r,a)).map(a=>({aesthetic:a,variables:Hy(n,r,a),isRequired:Fy.has(a)}))},Gy=(e,t,r)=>{switch(r){case"x":return!Yy(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))}},Hy=(e,t,r)=>{const n=$y(t,r);return e.getVariableNames().filter(a=>!l.isInternalVariable(a)&&n.includes(e.getType(a)))},$y=(e,t)=>t==="size"?_n:t!=="x"&&t!=="y"?On:Ky(e,t)?_n:On,Ky=(e,t)=>e.some(r=>r.positionRoles.some(n=>l.POSITION_NUMERIC_ROLES.has(n.role)&&n.aes===t&&!(n.role==="scalar"&&n.aes===n.axis))),Yy=e=>e.coordType==="polar"&&e.params.theta==="y",zy=500,Uy="normal",hr={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},Wy=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}`},pr=e=>typeof e!="string"?e??500:hr[e],sl=(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}},ll=(e,t)=>t===void 0||t===0?0:t*[...e].length,Xy="\0",qy=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,pr(t.weight),t.style??"normal",t.letterSpacing??0,t.textTransform??"none",e].join(Xy)}},jy={" ":.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 Zy=1.05,Jy=.84,Qy=.21,eS=class{measureText(e,t){const r=sl(e,t.textTransform);let n=ll(r,t.letterSpacing);for(const o of r)n+=(jy[o]??.55)*t.size;pr(t.weight)>=hr.semiBold&&(n*=Zy);const a=Jy*t.size,i=Qy*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=wu;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=Qt;exports.AddHighlightCommand=sr;exports.AddLayerCommand=dr;exports.BAR_WIDTH_FRACTION=l.BAR_WIDTH_FRACTION;exports.BORDER_RADIUS_PX=Bt;exports.BORDER_RADIUS_TOKENS=l.BORDER_RADIUS_TOKENS;exports.BUILTIN_STYLES=d.BUILTIN_STYLES;exports.COLOR_INTERPOLATION_SPACES=d.COLOR_INTERPOLATION_SPACES;exports.COMBO_TYPES=b.COMBO_TYPES;exports.COMPILER_STAGE_KEYS=d.COMPILER_STAGE_KEYS;exports.CONSTANT_VARIABLES=l.CONSTANT_VARIABLES;exports.CachedTextMeasurer=qy;exports.CommandRegistry=al;exports.CommandStackManager=ol;exports.Compiler=d.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=zy;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=d.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=Ny;exports.HEADING_PARTS=b.HEADING_PARTS;exports.HEADLINE_ITEM_PARTS=b.HEADLINE_ITEM_PARTS;exports.HEADLINE_SWATCH_GAP_EM=Ra;exports.HEADLINE_TREND_GAP_EM=wa;exports.HEADLINE_TREND_ICON_SIZE_PX=Qd;exports.HEADLINE_VALUE_LABEL_GAP_EM=Ca;exports.HeuristicTextMeasurer=eS;exports.HoverEngine=Zh;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=nu;exports.MAX_BAR_WIDTH_FRACTION=$v;exports.MIN_BAR_WIDTH_FRACTION=ms;exports.MONO_BASES=l.MONO_BASES;exports.MoveAnnotationCommand=wi;exports.NAMED_WEIGHTS=hr;exports.NEON_BASES=l.NEON_BASES;exports.OBSERVATION_ATTACHMENT_KINDS=jt;exports.OUT_OF_VIEW_MARGIN_PX=Pu;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=H;exports.RemoveAnnotationCommand=Jt;exports.RemoveHighlightCommand=or;exports.RemoveLayerCommand=ur;exports.SCALED_POSITION_AESTHETIC_KEYS=l.SCALED_POSITION_AESTHETIC_KEYS;exports.SCALED_VISUAL_AESTHETIC_KEYS=l.SCALED_VISUAL_AESTHETIC_KEYS;exports.SCHEME_ALIASES=d.SCHEME_ALIASES;exports.SEQUENTIAL_SCHEME_NAMES=d.SEQUENTIAL_SCHEME_NAMES;exports.SHAPE_DEFAULTS=l.SHAPE_DEFAULTS;exports.SIBLING_OVERLAP_THRESHOLD_PX=Mu;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.SequenceCommand=mr;exports.SetAxisLabelCommand=lo;exports.SetAxisPositionCommand=uo;exports.SetAxisTickModeCommand=ho;exports.SetAxisTicksVisibilityCommand=fo;exports.SetAxisVisibilityCommand=vo;exports.SetBarCornerRadiusCommand=us;exports.SetBarWidthCommand=hs;exports.SetChartTypeCommand=Oi;exports.SetContentCaptionCommand=So;exports.SetContentSourceCommand=xo;exports.SetContentSubtitleCommand=Io;exports.SetContentTitleCommand=Lo;exports.SetCoordLimitsCommand=as;exports.SetDataLabelsFormatCommand=fs;exports.SetDifferenceArrowStyleCommand=Pi;exports.SetGridLineStyleCommand=Po;exports.SetGridLineWidthCommand=Do;exports.SetGridVisibilityCommand=_o;exports.SetHeadlineCompareWithCommand=Vo;exports.SetHeadlinePositionCommand=Fo;exports.SetHeadlineShowCommand=Go;exports.SetHeadlineSizeCommand=$o;exports.SetHighlightDimStyleCommand=Yo;exports.SetLayerPositionCommand=vs;exports.SetLayerStatCommand=Ss;exports.SetLayerYScaleTypeCommand=xs;exports.SetLegendAlignCommand=Uo;exports.SetLegendDisplayCommand=Xo;exports.SetLegendPositionCommand=jo;exports.SetLineCurveCommand=Is;exports.SetLineMissingValuesCommand=Ls;exports.SetLineWidthCommand=Rs;exports.SetMappingCommand=ro;exports.SetNumberFormatAbbreviationCommand=Jo;exports.SetNumberFormatDecimalsCommand=es;exports.SetObservationsColorCommand=tl;exports.SetPointSizeCommand=ws;exports.SetPolarInnerRadiusCommand=os;exports.SetPolarStartAngleCommand=ls;exports.SetRuleLabelCommand=Ms;exports.SetRuleValueCommand=Os;exports.SetScaleDomainCommand=Us;exports.SetScalePaletteCommand=Xs;exports.SetScaleReverseCommand=js;exports.SetScaleTransformCommand=Js;exports.SetStatLineCommand=ks;exports.SetStyleRuleCommand=F;exports.SpecResolver=d.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=Ns;exports.ToggleContentVisibilityCommand=rs;exports.ToggleDataLabelsCommand=Bs;exports.ToggleGoalLineCommand=Hs;exports.ToggleLineFillCommand=$s;exports.ToggleLinePointsCommand=Ks;exports.ToggleStackTotalsCommand=Ys;exports.UNIT_POLAR_PATH_FRAME=Na;exports.UpdateAnnotationCommand=tr;exports.UserInputError=l.UserInputError;exports.VISUAL_VARIABLES=l.VISUAL_VARIABLES;exports.alignUnitFractions=l.alignUnitFractions;exports.annotation=l.annotation;exports.applyTextTransform=sl;exports.areAnchorsEqual=J;exports.areDashArraysEqual=kt;exports.areEditMenuTriggersEqual=md;exports.areEditTargetsEqual=il;exports.areEndpointsComparable=d.areEndpointsComparable;exports.areMappingsEquivalent=l.areMappingsEquivalent;exports.areObservationAnchorsEqual=yi;exports.arePointerRegionListsEqual=id;exports.arePredicatesEqual=d.arePredicatesEqual;exports.areStyleDeclarationsEqual=d.areStyleDeclarationsEqual;exports.areStyleRuleAddressesEqual=d.areStyleRuleAddressesEqual;exports.buildAverageLineSymbols=Lu;exports.buildBarRectBounds=Ma;exports.buildCalloutHitRegions=Cu;exports.buildColumnKey=Da;exports.buildDataLabelsContent=Gu;exports.buildDiagnostic=d.buildDiagnostic;exports.buildEditMenuTriggerRegion=ud;exports.buildFontString=Wy;exports.buildHeadlineItemRows=em;exports.buildLayerIntroPlan=dp;exports.buildLayerStyleAddress=d.buildLayerStyleAddress;exports.buildObservationPredicate=Uu;exports.buildObservationsTarget=ya;exports.buildObservationsTargetAtValue=Ju;exports.buildPanelAnchorBox=l.buildPanelAnchorBox;exports.buildPointSymbolInBox=gm;exports.buildPointSymbolPath=fm;exports.buildPolarBarArcPath=Im;exports.buildSliceGroupKey=Fa;exports.buildTooltipContent=Vp;exports.canAnchorDirectLabels=d.canAnchorDirectLabels;exports.canBecomeCombo=Xf;exports.canBecomeHeatmap=qf;exports.canPlaceDataLabels=Bu;exports.clampAnnotationTranslation=Rf;exports.combineKindStyleDeclarations=d.combineKindStyleDeclarations;exports.combineStyleDeclarations=d.combineStyleDeclarations;exports.commandRegistry=v;exports.compileChromeStyles=d.compileChromeStyles;exports.composePoint=d.composePoint;exports.compositeColor=l.compositeColor;exports.computeArrow=Au;exports.computeDifferenceArrow=ta;exports.computeDirectLabelsLayout=zu;exports.computeLetterSpacingWidth=ll;exports.computeLineBoxHeight=aa;exports.computePanelBorderPaths=Lp;exports.computePanelBorderSizes=Ep;exports.config=b.config;exports.coord=b.coord;exports.countLayerGeoms=mp;exports.createAlphaValueReader=d.createAlphaValueReader;exports.createAnchorResolver=ou;exports.createAreaPathGenerators=im;exports.createColorValueReader=d.createColorValueReader;exports.createCompiler=d.createCompiler;exports.createDataLabelPlacementResolver=Jn;exports.createDatasetFromKindPartitions=d.createDatasetFromKindPartitions;exports.createEmptyLayerStyles=d.createEmptyLayerStyles;exports.createGroupValueReader=d.createGroupValueReader;exports.createLabelValueReader=d.createLabelValueReader;exports.createLayerYValueFormatter=Mt;exports.createLineFillAreaGenerator=mm;exports.createLinePathGenerator=dm;exports.createObservationAnchorBuilder=d.createObservationAnchorBuilder;exports.createObservationAnchorParser=d.createObservationAnchorParser;exports.createPinnedNumberValueFormatter=Hd;exports.createRawValueReader=d.createRawValueReader;exports.createSegmentYReader=d.createSegmentYReader;exports.createSizeValueReader=d.createSizeValueReader;exports.createSpec=b.createSpec;exports.createSpecBuilder=b.createSpecBuilder;exports.createStableBandKeyGenerator=Mm;exports.createStableCellKeyGenerator=Dm;exports.createStableKeyGenerator=Ne;exports.createStablePolarBarKeyGenerator=Om;exports.createStrokeWidthValueReader=d.createStrokeWidthValueReader;exports.createStyleResolver=cf;exports.createStyleRuleMatcher=d.createStyleRuleMatcher;exports.createValueFormatter=I;exports.createXValueReader=d.createXValueReader;exports.createYValueReader=d.createYValueReader;exports.cursorToPiePlane=l.cursorToPiePlane;exports.cursorToPolar=l.cursorToPolar;exports.defineGeomStyleTarget=l.defineGeomStyleTarget;exports.describeMeasurementBasis=d.describeMeasurementBasis;exports.ensureReadableTextColor=l.ensureReadableTextColor;exports.extractPlainText=ha;exports.filterLayersByGeoms=d.filterLayersByGeoms;exports.findAnnotation=d.findAnnotation;exports.findAverageLineLayer=Ai;exports.findAxisGuide=Ft;exports.findCompanionLayers=d.findCompanionLayers;exports.findDefaultKitStyleTarget=d.findDefaultKitStyleTarget;exports.findDistinctLayers=d.findDistinctLayers;exports.findEquivalentHighlight=yf;exports.findGoalLineLayer=bi;exports.findHighlightsAtObservation=pd;exports.findHostLayer=d.findHostLayer;exports.findKindStyleDeclarations=d.findKindStyleDeclarations;exports.findLayerByGeom=d.findLayerByGeom;exports.findLayerById=d.findLayerById;exports.findLegendForAesthetic=Zd;exports.findObservationAttachment=Si;exports.findPointerRegion=nd;exports.findStyleRule=d.findStyleRule;exports.findStyleRuleIndex=d.findStyleRuleIndex;exports.findTrendLineLayer=xi;exports.formatDifferenceLabel=Qn;exports.formatHeadline=$d;exports.formatLegends=qd;exports.formatRuleValue=Jd;exports.geom=l.geom;exports.getAestheticFromScaleAestheticKey=l.getAestheticFromScaleAestheticKey;exports.getAlpha=l.getAlpha;exports.getAngleExtent=l.getAngleExtent;exports.getBarRectBounds=Pa;exports.getBoundingRect=cm;exports.getColor=l.getColor;exports.getCrossAxisCoordinate=d.getCrossAxisCoordinate;exports.getCurve=Ve;exports.getDifferenceArrowDimensions=ea;exports.getDifferenceArrowLabelBox=oa;exports.getGroup=d.getGroup;exports.getGroupVariables=l.getGroupVariables;exports.getHoverGuideLineProps=rp;exports.getHoverGuideRectProps=np;exports.getInsetTileRect=l.getInsetTileRect;exports.getLineType=l.getLineType;exports.getMainAxisCoordinate=d.getMainAxisCoordinate;exports.getNumericWeight=pr;exports.getPaintedTileRect=l.getPaintedTileRect;exports.getPointSymbolOuterRadius=vm;exports.getPolarHoverGuideArcProps=ap;exports.getRadiusExtent=l.getRadiusExtent;exports.getScaledAesthetic=l.getScaledAesthetic;exports.getShapeAnnotationStroke=rf;exports.getSize=l.getSize;exports.getStackRole=l.getStackRole;exports.getStrokeWidth=l.getStrokeWidth;exports.getTileRectBounds=l.getTileRectBounds;exports.getUnionExtent=Am;exports.getX=l.getX;exports.getXBand=l.getXBand;exports.getXMax=l.getXMax;exports.getXMin=l.getXMin;exports.getY=l.getY;exports.getYBand=l.getYBand;exports.getYMax=l.getYMax;exports.getYMin=l.getYMin;exports.getYRaw=l.getYRaw;exports.hasMainAxisBand=Aa;exports.hasMultipleGroups=l.hasMultipleGroups;exports.highlight=b.highlight;exports.inferDefaultDifferenceArrowEndpoints=vd;exports.inferDifferenceArrowEndpoints=xa;exports.inferXVariable=l.inferXVariable;exports.isAnnotationMovable=Cf;exports.isBorderRadiusToken=l.isBorderRadiusToken;exports.isCartesian=d.isCartesian;exports.isCategoricalValueFormat=l.isCategoricalValueFormat;exports.isComboChartType=me;exports.isCompanionLayer=d.isCompanionLayer;exports.isCompilerCachingEnabled=l.isCompilerCachingEnabled;exports.isCurrencyValueFormat=l.isCurrencyValueFormat;exports.isDateWithoutYearValueFormat=l.isDateWithoutYearValueFormat;exports.isFullTurnSweep=l.isFullTurnSweep;exports.isGeomStyleRule=d.isGeomStyleRule;exports.isGradientPaint=l.isGradientPaint;exports.isImagePaint=l.isImagePaint;exports.isKeyedScope=ke;exports.isLayerOf=U;exports.isLayerSpecOf=d.isLayerSpecOf;exports.isLineType=l.isLineType;exports.isLookupValueFormat=l.isLookupValueFormat;exports.isNumericValueFormat=l.isNumericValueFormat;exports.isObservationAttachmentKind=ff;exports.isOpaquePaint=l.isOpaquePaint;exports.isPatternPaint=l.isPatternPaint;exports.isPointWithinEditMenuTrigger=dd;exports.isPointWithinRegionShape=Nt;exports.isPositionScale=l.isPositionScale;exports.isSafeUrl=Op;exports.isStackedPosition=l.isStackedPosition;exports.isTemporalValueFormat=l.isTemporalValueFormat;exports.isZeroAnchoredAxis=Sd;exports.mapping=b.mapping;exports.measureObservationsBoxes=xd;exports.normalizeAngle=l.normalizeAngle;exports.orderPointerRegions=ad;exports.paintKey=l.paintKey;exports.paintsEachGroupFromItsFirstObservation=d.paintsEachGroupFromItsFirstObservation;exports.paintsInDonutHole=_e;exports.pickFilters=ui;exports.pickReadableTextColor=l.pickReadableTextColor;exports.pipe=b.pipe;exports.placeCallouts=Vu;exports.polarToUnit=l.polarToUnit;exports.positionToAngle=l.positionToAngle;exports.prefixInternalVariable=l.prefixInternalVariable;exports.prepareAreaObservations=om;exports.prepareLineObservations=hm;exports.projectAnchorToPanel=Re;exports.projectRegionToPanel=ua;exports.quantizeKey=k;exports.readAnchoredObservation=Td;exports.readAttachedObservation=Zt;exports.readAuthoredNumber=Zp;exports.readAuthoredString=Jp;exports.readBackdropColor=l.readBackdropColor;exports.readBroadestObservationsScope=Sa;exports.readChartType=Wf;exports.readColorGroupObservation=_m;exports.readComboLineLayerId=jf;exports.readCompanionRowsAtScopeKey=qu;exports.readConstantValue=l.readConstantValue;exports.readEditTargetKey=St;exports.readFoldKeepVariables=l.readFoldKeepVariables;exports.readGeomColor=$t;exports.readGeomEffects=Ap;exports.readHighlightDimStyle=zo;exports.readMainAxis=d.readMainAxis;exports.readMainAxisVariable=l.readMainAxisVariable;exports.readMappableAesthetics=By;exports.readMappedVariable=ao;exports.readObservationIndex=ip;exports.readObservationsColorRoute=Ia;exports.readReachableLevels=Od;exports.readRowScopeKey=va;exports.readRowsAtScopeKey=Vt;exports.readScopeXVariable=d.readScopeXVariable;exports.readStyleCoord=d.readStyleCoord;exports.readStyleRulesBeneath=d.readStyleRulesBeneath;exports.readVariableName=l.readVariableName;exports.readXExtent=li;exports.readYExtent=ci;exports.removeAlpha=l.removeAlpha;exports.resolveAnchorVariable=d.resolveAnchorVariable;exports.resolveAnchoredLabelCenter=l.resolveAnchoredLabelCenter;exports.resolveArrowAnnotationStyle=Qp;exports.resolveArrowColor=Ku;exports.resolveBarBandFraction=l.resolveBarBandFraction;exports.resolveBarBaseline=Ht;exports.resolveBarBorderTreatment=lm;exports.resolveBarCornerRadiiPx=sm;exports.resolveBarCornerRadiusPx=Gt;exports.resolveBarPaintOrigin=um;exports.resolveCalloutAnnotationStyle=tf;exports.resolveChromeMargin=C;exports.resolveChromeMargins=of;exports.resolveColorRamp=d.resolveColorRamp;exports.resolveComparisonBasis=d.resolveComparisonBasis;exports.resolveDataLabelStyle=Lc;exports.resolveDeferredAnchors=mu;exports.resolveDefinition=l.resolveDefinition;exports.resolveDifferenceArrowAnnotationStyle=ef;exports.resolveDirectLabelStyle=wc;exports.resolveEditOutlineStyle=sf;exports.resolveGeomAnchorSpace=d.resolveGeomAnchorSpace;exports.resolveGraphPadding=af;exports.resolveHeadlineItemStyle=Pc;exports.resolveHeadlineNumberStyle=Mc;exports.resolveHeadlinePlacement=Zc;exports.resolveLegendItemStyle=Cc;exports.resolveObservationPoint=Fd;exports.resolveObservationsTarget=Ta;exports.resolvePanelBorderStyle=nf;exports.resolvePolarBarCornerRadiusUnit=xm;exports.resolveRuleLabelStyle=Ec;exports.resolveSegmentYSource=d.resolveSegmentYSource;exports.resolveSwatchGeomPaint=Yt;exports.resolveTooltipStyle=Rc;exports.resolveYScaleAesthetic=l.resolveYScaleAesthetic;exports.sampleColorScheme=d.sampleColorScheme;exports.scale=b.scale;exports.setCompilerCachingEnabled=l.setCompilerCachingEnabled;exports.stat=b.stat;exports.stepDifferenceArrowEndpoint=Bd;exports.style=b.style;exports.styles=b.styles;exports.toDashPreset=_t;exports.toFontSpec=Tc;exports.toPaintColor=l.toPaintColor;exports.toPanelCursor=ma;exports.toPercent=z;exports.toSpec=Ii;exports.toStrokeDasharray=da;exports.toViewBoxX=lu;exports.toViewBoxY=N;exports.token=l.token;exports.transform=b.transform;exports.truncateToWidth=kn;exports.unitToPolar=l.unitToPolar;exports.updateSpec=d.updateSpec;exports.withAlpha=l.withAlpha;
23
+ `,Sc=(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},bc=(e,t,r)=>Math.abs(e?t.y-r.y:t.x-r.x),ta=({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=ea(t.strokeWidth),m=fc(o,s,c,u),h=(o?vc:gc)(s,c,m,u),p=yc(o,c,u),f=Sc(o,s,c,m,bc(o,s,c),e.labelCrossPosition),g=Qn({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}},br=new WeakMap,xc=e=>{const t=n=>e(n),r=Ar(t,n=>a=>e(a,n));return Ar(t,()=>r)},Ac=(e,t,r)=>{const n=Lr(e.graph,Ir(l.STYLE_TARGETS.graph,{}),r),a=Er(n,n,l.STYLE_TARGETS.graph.vocabulary),i=(s,c)=>s===l.STYLE_TARGETS.graph?a:Er(Lr(e[s.select.target],Ir(s,c),r),a,s.vocabulary),o=s=>{const c=Object.fromEntries(Object.entries(s.children??{}).map(([m,h])=>[m,o(h)]));if((s.options??[]).includes("annotation"))return Object.assign(Lc(m=>i(s,{annotation:m})),c);if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&Ic(s)){const m=new Map;return Object.assign(h=>{const p=m.get(h);if(p!==void 0)return p;const f=i(s,{axis:h});return m.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)]))},xr=e=>e.list==="builtin"||e.list==="theme"?e.list:"authored",Ot=e=>e==="theme"||e==="authored",Ar=(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}})},Ic=e=>{const t=l.findStyleTarget({target:e.select.target})??e;return Object.values(t.children??{}).some(r=>r.select.axis!==void 0)},Ir=(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}},Tr=(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}},Lr=(e,t,r)=>{const n=c=>Tr(e.overrides,c,t)??Tr(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":xr(u.origin)},explain:c=>{const u=n(c),m=u?.declarations[c];return u===void 0||m===void 0?{value:void 0,source:"unresolved"}:{value:l.resolveColorScheme(m,r),source:xr(u.origin),origin:u.origin,select:u.select}},collectAll:c=>{const u=[];for(const m of[e.defaults,e.overrides])for(const h of m){if(!t(h))continue;const p=h.declarations[c];p!==void 0&&u.push(l.resolveColorScheme(p,r))}return u}}},Tc=(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"))},Er=(e,t,r)=>({...e,resolve:()=>{const n=br.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 Tc(a,t,r),br.set(e,a),a}}),Lc=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}},Rr={large:1,medium:23/26,small:19/26},je={large:1,medium:10/12,small:10/12},ra=["fontStyle","letterSpacing","textTransform","textDecoration","textOutlineColor","textOutlineWidth","textShadow"],na=["fontFamily","fontSize","fontWeight","lineHeight","textColor",...ra],aa=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}}),Rc=(e,t,r)=>{const n=t==="aggregate"?e.dataLabel.aggregate():e.dataLabel[t][r](),a=n.getSource("textColor");return{...n.resolve(),isTextColorAuthored:a==="authored",isTextColorThemed:a==="theme"}},Cc=(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}:{},isTextColorThemed:a==="theme",..._c(e)}},wc=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()}),Pc=e=>({item:e.legendItem().resolve(),swatch:e.legendItem.swatch().resolve()}),Mc=e=>{const t=e.directLabel();return{...t.resolve(),isTextColorAuthored:Ot(t.getSource("textColor"))}},Dc=(e,t)=>{const r=e.headlineItem,n=r.number().resolve(),a={...n,fontSize:n.fontSize*Rr[t]},i=r.number.center(),o=i.resolve().fontSize;return{gap:r().resolve().gap,number:a,...kc(i)?{numberCenter:Se(i,o===void 0?a.fontSize:o*Rr[t])}:{},caption:Se(r.caption(),r.caption().resolve().fontSize*je[t]),label:Se(r.label(),r.label().resolve().fontSize*je[t]),swatch:r.swatch().resolve(),trend:Se(r.trend(),r.trend().resolve().fontSize*je[t]),trendUp:r.trend.up().resolve(),trendDown:r.trend.down().resolve(),trendFlat:r.trend.flat().resolve()}},Oc=(e,t)=>{const r=t?e.numberCenter:void 0;return r===void 0?e.number:{...e.number,...ia(r)}},_c=e=>{const t={};for(const r of ra){const n=e.get(r);n!==void 0&&Object.assign(t,{[r]:n})}return t},kc=e=>na.some(t=>e.getSource(t)!=="unresolved"),Se=(e,t)=>({...ia(e.resolve()),fontSize:t}),ia=e=>{const t={};for(const r of na){const n=e[r];n!==void 0&&Object.assign(t,{[r]:n})}return t},oa=({labelPosition:e,measuredTextWidth:t,label:r})=>{const n=t+2*r.paddingInline,a=aa(r)+2*r.paddingBlock;return{x:e.x-n/2,y:e.y-a/2,width:n,height:a}};function*Vc({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=ta({arrow:o,style:s,mainAxis:t,panelWidth:r.width,panelHeight:r.height,locale:n}),u=oa({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 Nc=e=>{const t=e.padding,r=Cr(e.rows,t?.top??0,t?.bottom??0),n=Cr(e.cols,t?.left??0,t?.right??0);return{rows:r.tracks,cols:n.tracks,placements:Hc(e.placements,r.nameToIndex,n.nameToIndex),width:e.containerSize.width,height:e.containerSize.height}},Fc=e=>{const t=wr(e.rows,e.height),r=wr(e.cols,e.width),n=Pr(t),a=Pr(r),i=new Map;for(const o of e.placements){const s=o.rowSpan??1,c=o.colSpan??1,u=a[o.col]??0,m=n[o.row]??0,h=Mr(r,o.col,c),p=Mr(t,o.row,s);i.set(o.name,{x:u,y:m,width:Math.max(0,h),height:Math.max(0,p)})}return i},Cr=(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;lt(s)&&i>0&&(n.push({type:"fixed",pixels:i}),i=0),a.set(s.name,n.length),n.push(Bc(s));const c=Gc(e,o);if(lt(s)&&c){const u=s.gaps?.after??0,m=c.gaps?.before??0;u>=m?u>0&&n.push({type:"fixed",pixels:u}):i=m}}return r>0&&n.push({type:"fixed",pixels:r}),{tracks:n,nameToIndex:a}},Bc=e=>typeof e.size=="number"?{type:"fixed",pixels:e.size}:{type:"flex",weight:e.size.flex},lt=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Gc=(e,t)=>{for(let r=t+1;r<e.length;r++){const n=e[r];if(n&&lt(n))return n}},Hc=(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},wr=(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)},Pr=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},Mr=(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},Q={top:0,right:0,bottom:0,left:0},sa={outer:Q,inner:Q},$c=(e,t,r,n=Q,a=sa,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)}],m=[{name:"leftLegend",size:r.legends.left,gaps:be(o.legend.left)},{name:"leftAxis",size:r.axes.left,gaps:be(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:be(o.tickLabel.right)},{name:"rightLegend",size:r.legends.right,gaps:be(o.legend.right)}],h=Dr(u,i.top,i.bottom),p=Dr(m,i.left,i.right);return Nc({rows:u,cols:m,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"},...zc(r.axes),...Yc(r.axesLabels,r.axes),...Uc(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}),be=e=>({before:e.left,after:e.right}),Kc=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Dr=(e,t,r)=>{const n=e.filter(Kc),a=n[0],i=n[n.length-1];return{start:t+(a?.gaps?.before??0),end:r+(i?.gaps?.after??0)}},zc=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},Yc=(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},Uc=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 Wc=class{constructor(e){this.outer={...Q},this.inner={...Q},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)))}},Xc=["top","right","bottom","left"],Ze=(e,t)=>{const r={};for(const n of Xc){const a=e.get(`${n}${t}`);a&&(r[n]=a)}return r};function Or(e,t){return e.top===t.top&&e.right===t.right&&e.bottom===t.bottom&&e.left===t.left}var ct=["large","medium","small"],qc=({size:e,availableWidth:t,measureStripWidth:r})=>{if(e!=="auto")return e;for(const n of ct)if(r(n)<=t)return n;return"small"},jc=({size:e,availableWidth:t,measureStripWidth:r})=>{const n=e==="auto"?0:ct.indexOf(e);for(const a of ct.slice(n))if(r(a)<=t)return a;return null},Zc=({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},Jc=({headline:e,containerSize:t,measurer:r})=>{if(_e(e))return 0;const n=la(e,t.width,r);return r.measureHeadline(e.formatted,n).height},Qc=({headline:e,layout:t,containerSize:r,measurer:n,itemGap:a})=>{if(_e(e)){const s=eu(t.panel,e.innerRadius),c=jc({size:e.size,availableWidth:s.width,measureStripWidth:ca(e,n)});return c===null?null:{rect:s,resolvedSize:c,visibleItemCount:1}}const i=la(e,r.width,n);if(e.formatted.kind!=="perGroup")return{rect:t.headline,resolvedSize:i,visibleItemCount:1};const o=Zc({itemWidths:n.measureHeadlineItemWidths(e.formatted,i),gap:a,availableWidth:t.headline.width});return o===0?null:{rect:t.headline,resolvedSize:i,visibleItemCount:o}},_e=e=>e.formatted.kind==="grandTotal"&&e.position==="center"&&e.innerRadius>0,eu=(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}},la=(e,t,r)=>qc({size:e.size,availableWidth:t,measureStripWidth:ca(e,r)}),ca=(e,t)=>r=>t.measureHeadline(e.formatted,r,_e(e)).width,q={x:0,y:0,width:0,height:0},tu={top:0,right:0,bottom:0,left:0},ru="0000",nu=3,au=e=>e.plot.y+e.plot.height-e.panel.y,iu=class{constructor(e){this.measurer=e}compile(e){return d.createPipeline({axes:e.axes,numberFormat:e.numberFormat,formattedLegends:e.formattedLegends,containerSize:e.containerSize,externalMeasurements:e.externalMeasurements,panelOverflow:sa,panelBorder:e.panelBorder??Q,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:ou(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(m=>m.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=>_r(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(m=>m.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=>_r(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:m,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:m,margins:h})})).pipe(({formattedAxes:t,layout:r})=>{const n=this.applyPolarPanelInset(e,t,r);return{formattedAxes:t,layout:n,plotBottomY:au(n)}}).result()}measurePanelOverflow(e,t,r,n){if(!e.overflowStrategy||e.coordSystem?.type!=="cartesian")return n;const a=new Wc(t);if(e.annotations&&e.resolveDifferenceArrowStyle&&e.overflowStrategy.differenceArrows)for(const o of Vc({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 oc({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 Or(i.inner,n.inner)&&Or(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:m,margins:h}){let p=t,f=o;for(let g=0;g<nu;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:m,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?kr(r,a,0,0):kr(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:ru}],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=m=>this.measurer.measureTickLabel(m,a),o=$l({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?Vl({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=Fc($c(r,n,this.measureGuides(e,t,o,r),i,a,s,su(c,t)));return{header:u.get("header")??q,headline:u.get("headline")??q,footer:u.get("footer")??q,plot:u.get("plot")??q,panelFrame:u.get("panelFrame")??q,panel:u.get("panel")??q,axes:Ze(u,"Axis"),axisLabels:Ze(u,"AxisLabel"),legends:Ze(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:Jc({headline:e,containerSize:t,measurer:this.measurer})}},_r=e=>e==="left"||e==="right",kr=(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}}},ou=(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}},su=(e,t)=>{const r={...e.legend};for(const n of t)n.display==="direct"&&(r[n.position]=tu);return{...e,legend:r}},lu=(e=[])=>{const t=cu(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:d.resolveGeomAnchorSpace(a.coordSystem)}},hasCapability:r=>t.has(r)&&t.get(r).resolveAnchorPosition!==void 0,createLayerMeasurement:r=>t.has(r.geom)?d.createLayerMeasurement(r,t.get(r.geom)):null}},cu=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 uu(e){return e}function N(e){return 1-e}var Y=e=>`${Number.parseFloat((e*100).toFixed(4))}%`,Re=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+N(e.y)*r.height}},ua=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+(N(e.y)-e.height)*r.height,width:e.width*r.width,height:e.height*r.height}},du=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}=ut(e.defer,this.panelRect);return Fr({...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}=mu(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}=ut(e.defer,this.panelRect);return Fr({...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:hu(this.toPanelRegion(r))}case"arrow":{const r=this.resolvePoint(t.annotation.start),n=this.resolvePoint(t.annotation.end);return r===null||n===null?null:Vr(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:Nr(this.toPanelPoint(r))}case"differenceArrow":return Vr(this.toPanelPoint(t.annotation.start),this.toPanelPoint(t.annotation.end));case"pinnedNumber":case"comment":return Nr(this.toPanelPoint(t.annotation.at))}}toPanelPoint(e){return d.toPanelFraction(e,this.panelRect)}toPanelRegion(e){if(e.space!=="disk")return e;const t=d.toPanelFraction(e,this.panelRect),r=d.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}}},ut=(e,t)=>({x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0}),mu=(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}=ut({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}},hu=e=>({xMin:e.x,xMax:e.x+e.width,yMin:e.y,yMax:e.y+e.height}),Vr=(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)}),Nr=e=>({xMin:e.x,xMax:e.x,yMin:e.y,yMax:e.y}),Fr=e=>{const t={...e};return delete t.defer,delete t.space,t},pu=e=>{const{annotations:t,panelRect:r,measuredBoxes:n,onCycle:a,onMissingRef:i}=e;if(!fu(t))return t;const o=new du(t,r,n),s={...t,shapes:re(t.shapes,m=>m.region.defer!==void 0,m=>{const h=o.resolveRegion(m.region);return h===null?null:{...m,region:h}}),images:re(t.images,m=>m.region.defer!==void 0,m=>{const h=o.resolveRegion(m.region);return h===null?null:{...m,region:h}}),arrows:re(t.arrows,m=>m.start.defer!==void 0||m.end.defer!==void 0,m=>{const h=o.resolvePoint(m.start),p=o.resolvePoint(m.end);return h===null||p===null?null:{...m,start:h,end:p}}),textAnnotations:re(t.textAnnotations,m=>m.at.defer!==void 0,m=>{const h=o.resolvePoint(m.at);return h===null?null:{...m,at:h}}),stickers:re(t.stickers,m=>m.at.defer!==void 0,m=>{const h=o.resolvePoint(m.at);return h===null?null:{...m,at:h}})},c=o.cyclicIds();c.length>0&&a?.(c);const u=o.missingRefIds();return u.length>0&&i?.(u),s},re=(e,t,r)=>e.some(t)?e.flatMap(n=>{if(!t(n))return[n];const a=r(n);return a===null?[]:[a]}):e,fu=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),da=(e,t)=>{if(!(e===void 0||e.length===0||t<=0))return e.map(r=>r*t).join(" ")},_t=e=>e===void 0||e.length===0?"solid":(e[0]??0)<=1?"dotted":"dashed",kt=(e,t)=>e===t?!0:e===void 0||t===void 0||e.length!==t.length?!1:e.every((r,n)=>r===t[n]),gu=800,Br=400,vu=.75,yu=.875,Su=4,bu=e=>Math.max(1,(e-Br)/(gu-Br)+1),xu=(e,t)=>{const r=bu(t),n=e*Su;return{strokeWidth:Math.min(e,e*vu*r),arrowheadLength:Math.min(n,n*yu*r)}},xe=Math.PI/4,Au=({start:e,end:t})=>`M ${e.x} ${e.y} L ${t.x} ${t.y}`,Gr=(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-xe)} ${o-r*Math.sin(s-xe)} M ${i} ${o} L ${i-r*Math.cos(s+xe)} ${o-r*Math.sin(s+xe)}`},Iu=64,Tu=({arrow:e,style:t,panelWidth:r,panelHeight:n})=>{const a={width:r,height:n},i={start:Re(e.start,a),end:Re(e.end,a)};if(i.start.x===i.end.x&&i.start.y===i.end.y)return null;const{strokeWidth:o,arrowheadLength:s}=xu(t.strokeWidth,r),c=Math.hypot(i.end.x-i.start.x,i.end.y-i.start.y),u=Lu(s,c),m=e.startArrowheadStyle==="line-arrow",h=e.endArrowheadStyle==="line-arrow",p=m||h?u*Math.sin(Math.PI/4):0;return{id:e.id,linePath:Au(i),startArrowheadPath:m?Gr("start",i,u):"",endArrowheadPath:h?Gr("end",i,u):"",strokeWidth:o,dashArray:da(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,m),arrowheadExtent:p}},Lu=(e,t)=>Math.min(e,t*e/Iu),Eu=(e,t,r)=>{const n=e[0]??0;return r&&n>1?n*t:0};function Ru(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=Cu(e,o,s);if(u===null)continue;const m=t.map(c);l.isStrictCategoricalDataValue(m)&&r.set(n.id,{geom:u.geom,color:m,layerId:u.id,groupValue:c})}return r}function Cu(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 ma=(e,t)=>({x:e.x/t.width,y:1-e.y/t.height}),wu=0,Pu=(e,t)=>e.filter(r=>r.inView).map(r=>({shape:{kind:"rect",rect:r.miniRect},cursor:ma(r.anchorPx,t),tooltip:{kind:"pinned",point:r.anchorPx,placement:r.placement,annotationId:r.id},priority:wu})),Mu=9,Du=8,Ou=2,ha=e=>typeof e=="string"?e:pa(e),pa=e=>e.text!==void 0?e.text:e.content?e.content.map(pa).join(""):"",Hr={top:"bottom",bottom:"top",right:"left",left:"right"};function _u(e,t,r){return r.type==="polar"?Nu(e,t):r.mainAxis==="y"?["right","left","top","bottom"]:["top","bottom","right","left"]}function dt(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 $r(e,t){return e.x>=0&&e.y>=0&&e.x+e.width<=t.width&&e.y+e.height<=t.height}function ku(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 Vu(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 Nu(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,Hr[o],s,Hr[s]]}function Fu(e){const{pinnedNumbers:t,comments:r,panelRect:n,coordSystem:a,measurer:i,formatPinnedNumber:o}=e,s=[...t.map(m=>{const{id:h,at:p}=m;return Kr(h,"pinned-number",p,o(m),i,n)}),...r.map(({id:m,at:h,content:p})=>Kr(m,"comment",h,ha(p),i,n))];s.sort((m,h)=>m.anchorPx.x-h.anchorPx.x||m.anchorPx.y-h.anchorPx.y);const c=[],u=[];for(const m of s){if(!m.inView){c.push(zr(n,m,"top"));continue}const h=zr(n,m,Gu(n,m,a,u));c.push(h),u.push(h.miniRect)}return c}function Kr(e,t,r,n,a,i){const o=Re(r,i);return{id:e,kind:t,anchor:r,anchorPx:o,mini:a(t,e,n),inView:Bu(o,i)}}function Bu(e,t){return e.x>=-8&&e.y>=-8&&e.x<=t.width+8&&e.y<=t.height+8}function Gu(e,t,r,n){const a=_u(t.anchorPx,e,r);for(const i of a){const o=dt(t.anchorPx,i,t.mini);if($r(o,e)&&!n.some(s=>Vu(o,s)))return i}for(const i of a)if($r(dt(t.anchorPx,i,t.mini),e))return i;return"top"}function zr(e,t,r){return{id:t.id,kind:t.kind,anchorPx:t.anchorPx,placement:r,miniRect:ku(e,dt(t.anchorPx,r,t.mini)),text:t.mini.text,inView:t.inView}}var Hu=(e,t)=>Dt().hasCapability(e,t),$u=({layers:e,coordSystem:t,axes:r,numberFormat:n,parsingLocale:a,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:c,plotBottomY:u,isFooterChromeReserved:m,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 P=jn({layer:x,coordSystem:t,axes:r,numberFormat:n,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:f,percentageValueStrategy:A.getPercentageValueStrategy(x)}),X=A.place(P);S+=X.droppedCount;for(const _ of X.labels)zu(_,g,u,m)||p.push(_)}return{labels:p,warnings:S>0?[Ku(S)]:[]}},Ku=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}}),zu=(e,t,r,n)=>t==="polar"&&n&&e.position==="outside"&&e.y+e.height/2>r,Yu=(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,Uu=100,Wu=({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],m=n[c+1];if(!u||!m)continue;const h=u.y+a,p=m.y-a;if(h>p){o=!0,i=!0;const f=(h-p)/2+1;u.y-=f,m.y+=f,u.y<0&&(u.y=0),m.y>t&&(m.y=t)}}if(s>Uu)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}},Xu=(e,t)=>fa(e,t,{variables:ga(e),allowNull:!1}),fa=(e,t,{variables:r,allowNull:n})=>{const a=d.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}},ga=e=>{const t=d.shouldNarrowByGroup(e)?l.getGroupVariables(e.data,e.mapping):[],r=d.resolveCrossAnchorVariable(e),n=r===null?t:[...t,r],a=d.resolveAnchorVariable(e);return a===l.GROUP_VARIABLES.group?[...new Set(n)]:[...new Set([a,...n])]},ke=e=>e!=="data-point",qu=(e,t)=>{switch(t){case"series":{const r=l.getGroupVariables(e.data,e.mapping);return r.length===0?Yr(e):{variables:r,allowNull:!0}}case"x-value":{const r=d.readScopeXVariable(e.mapping);return r===null?null:{variables:[r],allowNull:!0}}case"data-point":return Yr(e)}},Yr=e=>typeof e.identityKey=="object"?{variables:[e.identityKey.variable],allowNull:!0}:e.identityKey==="index"?null:{variables:ga(e),allowNull:!1},ae=[],Ur=new WeakMap,va=(e,t,r)=>r<0||r>=e.data.size()?null:t==="data-point"?String(r):oe(e,t).keyByRow[r]??null,Vt=(e,t,r)=>{if(t==="data-point"){const n=Number(r);return Number.isInteger(n)&&n>=0&&n<e.data.size()?[n]:ae}return oe(e,t).rowsByKey.get(r)??ae},ju=(e,t)=>oe(e,t).keyByRow,Zu=(e,t,r,n)=>{if(r!=="data-point")return Vt(e,r,n);const a=Number(n);if(!Number.isInteger(a)||a<0||a>=t.data.size())return ae;const i=oe(t,"vertex").keyByRow[a];return i===void 0?ae:oe(e,"vertex").rowsByKey.get(i)??ae},oe=(e,t)=>{const r=Ur.get(e)??new Map;Ur.set(e,r);const n=r.get(t);if(n!==void 0)return n;const a=Qu(Ju(e,t));return r.set(t,a),a},Ju=(e,t)=>{const r=e.data.size(),n=t==="x-value"?null:Wr(e,l.GROUP_VARIABLES.group),a=t==="series"?null:d.readScopeXVariable(e.mapping),i=a===null?null:Wr(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},Wr=(e,t)=>e.data.hasVariable(t)?e.data.getValues(t):null,Qu=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}},ya=({layer:e,observationIndex:t,scope:r,parsingLocale:n})=>{const a=e.data.getAt(t);if(a===null)return null;const i=ad(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 nd(o,e,a,t,n)?o:null},ed=({layer:e,scope:t,variable:r,value:n,parsingLocale:a})=>{const i={kind:"observations",layerId:e.id,scope:rd(e,t,r),predicate:{variable:r,eq:n}};return td(i,e,a)?i:null},Sa=e=>e.identityKey==="x-group"?"series":l.getGroupVariables(e.data,e.mapping).length===0?"data-point":"series",td=(e,t,r)=>{if(d.findPredicateProblems(e.predicate,t.data).length>0)return!1;const n=d.compilePredicate(e.predicate,d.createPredicateCompileContext(t,r));for(const a of t.data)if(n(a))return!0;return!1},rd=(e,t,r)=>t==="series"&&!l.getGroupVariables(e.data,e.mapping).includes(r)?"data-point":t,nd=(e,t,r,n,a)=>{if(d.findPredicateProblems(e.predicate,t.data).length>0)return!1;const i=d.compilePredicate(e.predicate,d.createPredicateCompileContext(t,a));if(i(r))return!0;if(!ke(e.scope))return!1;const o=va(t,e.scope,n);return o===null?!1:Vt(t,e.scope,o).some(s=>{const c=t.data.getAt(s);return c!==null&&i(c)})},ad=(e,t,r)=>{const n=qu(e,r);return n===null?null:fa(e,t,n)},Nt=(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},id=(e,t)=>{for(const r of t)if(Nt(e,r.shape))return r;return null},od=e=>{const t=[];for(const r of e.values())t.push(...r);return t.sort((r,n)=>n.priority-r.priority)},sd=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>ld(r,t[n])),ld=(e,t)=>t===void 0?!1:e.priority===t.priority&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y&&cd(e.shape,t.shape)&&ud(e.tooltip,t.tooltip),cd=(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},ud=(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},dd=100,md=e=>({shape:{kind:"circle",center:e.center,radius:e.radius},cursor:e.target.cursor,tooltip:{kind:"cursor"},priority:dd}),hd=(e,t)=>Nt(e,{kind:"circle",center:t.center,radius:t.radius}),pd=(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&&fd(e.target,t.target),fd=(e,t)=>e.kind===t.kind&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y,gd=({layer:e,highlights:t,observation:r,parsingLocale:n})=>{if(e.highlight===null)return[];const a=d.createPredicateCompileContext(e,n),i=vd(e,r);return t.filter(o=>{if(o.layerId!==void 0&&o.layerId!==e.id||d.findPredicateProblems(o.predicate,e.data).length>0)return!1;const s=d.compilePredicate(o.predicate,a);return s(r)?!0:ke(o.scope)&&i(o.scope).some(s)})},vd=(e,t)=>{const r=d.readScopeXVariable(e.mapping),n=new Map;return a=>{const i=n.get(a);if(i!==void 0)return i;const o=d.readScopeKey(a,t,r),s=[];for(const c of e.data)d.readScopeKey(a,c,r)===o&&s.push(c);return n.set(a,s),s}},Te=({layer:e,from:t,step:r,accepts:n,excluding:a,cycles:i=!1})=>{const o=e.data.size(),s=d.createObservationAnchorBuilder(e);for(let c=0;c<o;c+=1){const u=t+c*r,m=i?yd(u,o):u;if(m<0||m>=o)break;const h=e.data.getAt(m);if(h===null||!n(h,m))continue;const p=s(h);if(p!==null&&!a.some(f=>J(p,f)))return{anchor:p,observation:h,observationIndex:m}}return null},ba=(e,t)=>{const r=d.createObservationAnchorMatcher(e);let n=0;for(const a of e.data){if(r(a,t))return n;n+=1}return-1},J=(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),yd=(e,t)=>(e%t+t)%t,xa=({layer:e,at:t,coordSystem:r})=>{if(r.type!=="cartesian"||e.spatialKind==="cells")return null;const n=d.resolveAnchorVariable(e),a=ba(e,t),i=e.data.getAt(a);if(i===null)return null;const o=d.getGroup(i),s=p=>l.areDataValuesEqual(d.getGroup(p),o),c=[t],u=Te({layer:e,excluding:c,from:a+1,step:1,accepts:s});if(u!==null)return{start:t,end:u.anchor};const m=Te({layer:e,excluding:c,from:a-1,step:-1,accepts:s});if(m!==null)return{start:m.anchor,end:t};const h=Te({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},Sd=e=>{if(e.coordSystem.type!=="cartesian")return null;const t=e.spec.annotations.differenceArrows;for(const r of e.layers){const n=d.createObservationAnchorBuilder(r);for(const a of r.data){const i=n(a);if(i===null)continue;const o=xa({layer:r,at:i,coordSystem:e.coordSystem});if(o!==null&&!t.some(s=>bd(s,o)))return o}}return null},bd=(e,t)=>J(e.start,t.start)&&J(e.end,t.end)||J(e.start,t.end)&&J(e.end,t.start),xd=(e,t)=>d.resolveGeomScaleDemands(e.layers).zeroAxes[t]!==void 0,Ad=new Set(["discrete","datetime"]),Aa=e=>{const t=e.x;return t?.kind!=="position"?!1:Ad.has(t.spec.scaleType)},Id=({layer:e,coordSystem:t,panelSize:r,radialExtent:n="whole"})=>{const a=n==="outerEnd"&&t.type==="polar"?Td:l.readObservationBox,i=[];for(const o of e.data){const s=a(o,t);s!==null&&i.push(Ld(s,r))}return i},Td=(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"}},Ld=(e,t)=>ua({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),Ed=(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}},ue=e=>d.applyReplayableTransforms(e.data,e.transforms),Ia=(e,t)=>{const r=e.layers.map(m=>({...m,mapping:{...e.mapping,...m.mapping}})),n=d.findLayerById(r,t.layerId);if(n===void 0)return null;const a=d.findHostLayer(n,r),i=d.findCompanionLayers(a,r),o=a.mapping;if(Cd([a,...i],t.scope)||[a,...i].some(m=>Rd(e,m)))return null;const s=wd(t,o)?void 0:t.predicate,c=Xr(a,s);if(c===null)return null;const u=[];for(const m of i){const h=Xr(m,s);if(h===null)return null;u.push(h)}return[c,...u]},Rd=(e,t)=>{const r=l.readVariableName({...e.mapping,...t.mapping}.color);if(r===null)return!1;const n=d.applyReplayableTransforms(ue(e),t.transforms);return n.hasVariable(r)?n.getType(r)!=="categorical":!0},Cd=(e,t)=>(t==="x-value"||t==="data-point")&&e.some(r=>d.paintsEachGroupFromItsFirstObservation(r.geom)),wd=(e,t)=>{if(e.scope!=="series")return!1;const r=Pd(e.predicate);if(r===null)return!1;const n=l.readVariableName(t.x),a=l.readVariableName(t.y),i=r.filter(s=>s===n||s===a),o=l.readVariableName(t.group);return i.length>0&&!i.some(s=>s===o)},Pd=e=>{if("eq"in e)return[e.variable];if(!("and"in e))return null;const t=[];for(const r of e.and){if(!("eq"in r))return null;t.push(r.variable)}return t},Xr=(e,t)=>{if(d.encodesColorAsValue(e.geom))return null;const r=Md(e.geom);return r===null?null:{layerId:e.id,geomKind:e.geom,property:r,...t===void 0?{}:{where:t}}},Md=e=>{const t=d.findDefaultKitStyleTarget(e)?.observation?.aesthetics;if(t===void 0)return null;const r=Object.entries(t).find(([,n])=>n==="color")?.[0];return r==="fill"||r==="stroke"?r:null},Ta=({layer:e,target:t,parsingLocale:r,host:n})=>{if(t.layerId!==(n??e).id)return[];const a=La(e,t,r);if(a===null)return[];if(ke(t.scope))return Od(e,a,t.scope);const i=Ea(e,a),o=i[Dd(t,i,n,r)];return o===void 0?i:[o]},Dd=(e,t,r,n)=>{if(e.observationIndex===void 0)return-1;if(r===void 0)return t.indexOf(e.observationIndex);const a=La(r,e,n);return a===null?-1:Ea(r,a).indexOf(e.observationIndex)},La=(e,t,r)=>d.findPredicateProblems(t.predicate,e.data).length>0?null:d.compilePredicate(t.predicate,d.createRowPredicateCompileContext(e,r)),Ea=(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=ju(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},_d=["series","data-point","x-value"],kd=({layer:e,observationIndex:t,parsingLocale:r,scales:n})=>{const a=Nd(Sa(e)).filter(s=>s!=="x-value"||Vd(n)),i=new Set,o=[];for(const s of _d){if(!a.includes(s))continue;const c=Fd(e,t,s,r);if(c===null&&s==="data-point")return[];c===null||o.some(u=>Bd(u,c))||(o.push(c),i.add(s))}return a.filter(s=>i.has(s))},Vd=e=>{const t=e.x?.domain.some(r=>r instanceof Date)===!0;return Aa(e)&&!t},Nd=e=>e==="series"?["data-point","x-value","series"]:["data-point"],Fd=(e,t,r,n)=>{const a=ya({layer:e,observationIndex:t,scope:r,parsingLocale:n});return a===null?null:Ta({layer:e,target:a,parsingLocale:n})},Bd=(e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),Gd=({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=d.readObservationMeasurement(t,r,c);if(u===null)return null;const m=d.createObservationAnchorBuilder(t)(r);return m===null?null:{...s,...u,observationIndex:n,anchor:i===void 0?m:{...m,align:i}}},Hd=({layer:e,from:t,partner:r,axis:n,step:a,getObservationPoint:i})=>{const o=d.resolveAnchorVariable(e),s=ba(e,t),c=e.data.getAt(s);if(c===null)return null;const u=$d(c),m=n==="main"?u:f=>!u(f)&&l.areDataValuesEqual(f[o]??null,t.anchorValue),h=Te({layer:e,excluding:[t,r],from:s+a,step:a,accepts:(f,g)=>m(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}},$d=e=>{const t=d.getGroup(e);return r=>l.areDataValuesEqual(d.getGroup(r),t)};function Kd({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 zd=({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):Ud(e,t,o,r,i)},Yd=(e,t,r)=>({kind:"grandTotal",value:I({valueFormat:e.valueFormat,locale:t,numberFormat:r})(e.value)}),Ud=(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}),m=Pt({valueFormat:s.mainValueFormat,locale:r,numberFormat:n,tickValues:[]}),h=s.label??u(s.value);return{swatch:s.swatch,label:jd(t,o,h,a),value:s.aggregate===null?null:c(s.aggregate),caption:qd(s.caption,m),comparison:Wd(s.comparison,m,i,a)}})}},Wd=(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",qd=(e,t)=>e===null?null:e.kind==="point"?t(e.value):`${t(e.from)} – ${t(e.to)}`,jd=(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}},Zd=({legends:e,numberFormat:t,parsingLocale:r,formattingLocale:n})=>{const a=n??r;return e.map(i=>Jd(i,a,t))},Jd=(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 Ft(e,t){return e.axes.find(r=>r.scaleAestheticKey===t)??null}function Qd(e,t){return e.legends.drawn.find(r=>r.aesthetics.includes(t))??null}var em=({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?d.createYValueReader:d.createXValueReader)(r.data,r.mapping)(a);return o===null?null:I({valueFormat:Ft(e,i?l.resolveYScaleAesthetic(r.yScaleType):"x")?.valueFormat??{type:"decimal"},locale:n,numberFormat:t})(o)},Ra=.4,Ca=.18,tm=12,wa=.4,rm=(e,t)=>{const{value:r,caption:n,comparison:a,swatch:i,label:o}=e;return[{role:"value",gap:Je(t.number.fontSize,Ca),segments:Qe([Ae("value",r??"–"),Ae("caption",n)])},{role:"trend",gap:Je(t.trend.fontSize,wa),ariaLabel:a===null?void 0:om(a),segments:Qe([am(a),im(a),Ae("trendReference",a?.reference??null)])},{role:"group",gap:Je(t.label.fontSize,Ra),segments:Qe([nm(i,t.swatch.size),Ae("label",o)])}].filter(s=>s.segments.length>0)},Je=(e,t)=>Math.round(e*t),Ae=(e,t)=>t===null?null:{kind:"text",textRole:e,text:t},nm=(e,t)=>e===null?null:{kind:"swatch",swatch:e,size:t},am=e=>e===null?null:{kind:"trendArrow",direction:e.direction,size:12},im=e=>e===null?null:{kind:"text",textRole:"trendPercentage",text:e.percentage,trendDirection:e.direction},om=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}`}},Qe=e=>e.filter(t=>t!==null),Ve=e=>e==="smooth"?R.curveCatmullRom:R.curveLinear,sm=(e,t)=>{const r=Ve(t.curve),n=(0,R.area)().curve(r),a=(0,R.line)().curve(r);if(e.mainAxis==="y"){const i=c=>N(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=>N(l.getYMin(c)??0),s=c=>N(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}},lm=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Bt={none:0,xs:2,sm:4,md:8,lg:12,xl:16},Gt=e=>{if(Oa(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):Bt[t]},cm=e=>{const t=Gt(e);return Oa(e)?e.mainAxis==="x"?{rx:t}:{ry:t}:{rx:t}},um=e=>({outlineWidth:e*2,separatorWidth:e,insetOffset:e/2}),Pa=(e,t)=>Ma(e,{xMin:l.getXMin(t),xMax:l.getXMax(t),yMin:l.getYMin(t),yMax:l.getYMax(t),y:l.getY(t)}),Ma=(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,m=o-n;return m<0&&(u+=m,m=-m),{x:t,y:u,width:r-t,height:m}}let s=t,c=r-t;return c<0&&(s+=c,c=-c),{x:s,y:1-o,width:c,height:o-n}},Da=(e,t)=>e==="x"?`${k(t.x)}-${k(t.width)}`:`${k(t.y)}-${k(t.height)}`,dm=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}},Ht=(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},mm=(e,t,r)=>{const n=Ht(e,t,r);return t.mainAxis==="x"?{x:0,y:n}:{x:n,y:0}},Oa=e=>e.cornerRadius==="full",hm=e=>{const t=(0,R.line)().x(r=>l.getX(r)??0).y(r=>N(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(_a),t},pm=e=>{const t=(0,R.area)().x(r=>l.getX(r)??0).y0(()=>1).y1(r=>N(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(_a),t},fm=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),_a=e=>l.getX(e)!==null&&l.getY(e)!==null,gm=new Set(["line","rule"]),ka=e=>gm.has(e),$t=(e,t,r,n)=>{const a=e.geom(t);if(ka(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)},Kt={circle:R.symbolCircle,square:R.symbolSquare,diamond:R.symbolDiamond,triangle:R.symbolTriangle,cross:R.symbolCross,star:R.symbolStar,wye:R.symbolWye},vm=(e,t)=>{const r=t/2;return(0,R.symbol)(Kt[e],Math.PI*r*r)()??""},ym=(e,t,r)=>{const n=Va[e],a=Math.max(0,Math.min(t/n.width,r/n.height));return{path:(0,R.symbol)(Kt[e],a*a)()??"",offsetX:-n.centerX*a,offsetY:-n.centerY*a}},Sm=(e,t)=>{const r=t/2;return Va[e].outerRadius*Math.sqrt(Math.PI*r*r)},bm=e=>{let t=1/0,r=1/0,n=-1/0,a=-1/0,i=0;const o=(u,m)=>{t=Math.min(t,u),r=Math.min(r,m),n=Math.max(n,u),a=Math.max(a,m)},s=(u,m)=>{o(u,m),i=Math.max(i,Math.hypot(u,m))},c=()=>{throw new Error("Unexpected curve in a point symbol")};return e.draw({moveTo:s,lineTo:s,rect:(u,m,h,p)=>{s(u,m),s(u+h,m),s(u+h,m+p),s(u,m+p)},arc:(u,m,h)=>{o(u-h,m-h),o(u+h,m+h),i=Math.max(i,Math.hypot(u,m)+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}},Va=Object.fromEntries(Object.entries(Kt).map(([e,t])=>[e,bm(t)])),Na={centerX:0,centerY:0,radius:1,digits:8},xm=200,D=1e-12,Am=Math.PI/2,Im=(e,t)=>{if(e==="full")return Math.max(0,t)/2;const r=e??"sm";return(typeof r=="number"?Math.max(0,r):Bt[r])/xm},Fa=(e,t)=>e==="x"?`${k(t.startAngle)}-${k(t.endAngle)}`:`${k(t.innerRadius)}-${k(t.outerRadius)}`,Tm=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}},Lm=(e,t=Na)=>{const r=Dm(t),n=Rm(e);if(!(n.outer>D))return`M${r.writePoint(0,0)}Z`;const{slice:a}=e,i=a===void 0?null:Em(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 jr({...n,start:i[0],end:i[1]},i,r);const[o,s]=a?.axis==="radius"&&i!==null?i:[n.inner,n.outer];return wm(n.start,o,s,r)}return a?.axis==="radius"&&i!==null?Cm(n,i,r):jr(n,i??[n.start,n.end],r)}},Em=(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},Rm=({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,m=Math.min((c-s)/2,a),h={start:i,end:o,inner:s,outer:c,innerCorner:null,outerCorner:null};if(!(m>D)||l.isFullTurnSweep(i,o))return h;let p=m,f=m;if(u<Math.PI){const g=(c-s)**2*Math.sin(u);if(g*g<D)return h;const S=Math.sin(u/2);p=Math.min(m,s*S/(1-S)),f=Math.min(m,c*S/(1+S))}return{...h,innerCorner:s>D&&p>D?qr(p,s+p,u):null,outerCorner:f>D?qr(f,c-f,u):null}},qr=(e,t,r)=>({radius:e,centerRadius:t,offset:Math.min(Math.asin(Math.min(1,e/t)),r/2)}),Cm=(e,[t,r],n)=>{const a=Zr(e,"start"),i=Zr(e,"end"),o=c=>Ce(a,c),s=c=>Ce(i,c);return`M${n.writePoint(o(t),t)}`+se(t,o(t),s(t),n)+we(i,t,r,"radius",n)+se(r,s(r),o(r),n)+we(a,r,t,"radius",n)+"Z"},jr=(e,[t,r],n)=>{const a=Jr(e,"inner"),i=Jr(e,"outer");return`M${n.writePoint(t,Ce(a,t))}`+we(a,t,r,"angle",n)+`L${n.writePoint(r,Ce(i,r))}`+we(i,r,t,"angle",n)+"Z"},wm=(e,t,r,n)=>{const a=`M${n.writePoint(e,r)}${se(r,e,e-l.TAU,n)}Z`;return t>D?`${a}M${n.writePoint(e,t)}${se(t,e,e+l.TAU,n)}Z`:a},Zr=(e,t)=>{const r=t==="start"?e.start:e.end,n=t==="start"?1:-1,a=c=>{const u=r+n*c.offset;return m=>u-n*Pm(c,m)},i=e.innerCorner===null?e.inner:Qr(e.innerCorner),o=e.outerCorner===null?e.outer:Qr(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},Jr=(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=>Mm(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}]},Qr=e=>e.centerRadius*Math.cos(e.offset),Pm=({radius:e,centerRadius:t},r)=>{if(!(r>D))return 0;const n=(t**2+r**2-e**2)/(2*t*r);return Math.acos(Math.max(-1,Math.min(1,n)))},Mm=({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))},Ce=(e,t)=>{const r=e.find(n=>t<=n.to)??e[e.length-1];return r===void 0?0:r.at(t)},we=(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 m=Math.max(u.from,o),h=Math.min(u.to,s);if(h-m<=D)continue;const[p,f]=i?[m,h]:[h,m],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}`:se(u.at(p),p,f,a)}return c},se=(e,t,r,n)=>{if(!(e>D)||Math.abs(r-t)<=D)return"";const a=Math.max(1,Math.ceil(Math.abs(r-t)/Am-D)),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},Dm=({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)}},Ne=(e,t,r)=>{const n=d.createXValueReader(e,t);return a=>{const i=d.getGroup(a)??"default",o=n(a);return`${r}-${i}${o!==null&&o!==""?`-${o}`:""}`}},Om=(e,t,r)=>{const n=d.createXValueReader(e,t);return a=>{const i=n(a);return i===null||i===""?null:`${r}-${i}`}},_m=(e,t,r)=>{const n=d.createXValueReader(e,t),a=d.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`,m=i.get(u)??0;return i.set(u,m+1),m===0?u:`${u}#${m}`}},km=()=>(e,t)=>l.getColor(e)??`default-${t}`,en=2,Vm=(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=U(t,"line")?a.get("strokeAlpha",r):a.get("fillAlpha",r)??a.get("strokeAlpha",r),o=a.get("alpha",r)*i,s=ka(t.geom)?void 0:Nm(e,t,r),c=s===void 0?{alpha:o}:{alpha:o,fill:s};if(U(t,"point"))return{...c,symbol:e.point(t).get("symbol",r)};if(!U(t,"bar"))return c;const u=n.width-en,m=n.height-en,h=Gt({cornerRadius:e.bar(t).get("cornerRadius",r),mainAxis:"x",bounds:{width:u,height:m}});return{...c,cornerRadiusPx:Math.min(h,Math.min(u,m)/2)}},Nm=(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 d.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 Ba(e,t,r){return Yt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>t})}function Ga(e,t,r){return Yt(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>=t})}function Ut(e,t,r,n){const a=e==="x";return{mainDistance:Math.abs(t)*(a?n:1),crossDistance:Math.abs(r)*(a?1:n)}}function Fe(e,t,r){return Math.hypot(e*r,t)}function V(e,t,r){return e<t?t-e:e>r?e-r:0}function O(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 Fm(e,t){const r=t.height,n=Math.min(t.width,t.height)/2;return{cartesian:tn(e,r),polar:tn(e,n)}}function de(e,t){return e<=t.on.point}function le({mainDistance:e,crossDistance:t},r){return e<=r.near.main&&t<=r.near.cross}function tn({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 Bm(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=Ha(e,s,t,r);return a===void 0||de(c.distance,a)||le(c,a)?c:$m(e,t,r,a)??c}function Gm(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 Hm(e,t,r,n){if(e.projection==="polar")return[];const a=mt(e.mainAxis),i=Ga(e.byMain,t,a),o=Ba(e.byMain,r,a),s=e.delaunayAspectRatio??1,c=new Map;for(let u=i;u<o;u+=1){const m=e.byMain[u];if(m===void 0)continue;const h=l.getStableKey(m.observation[l.GROUP_VARIABLES.group]??null),p=Fe(m.x-n.x,m.y-n.y,s),f=c.get(h);(f===void 0||p<f.distance)&&c.set(h,{point:m,distance:p})}return[...c.values()].map(u=>u.point)}function $m(e,t,r,n){const{mainAxis:a,byMain:i}=e,o=d.getCoordinates(a,t).main,s=a==="x"?n.near.main/r:n.near.main,c=Ga(i,o-s,mt(a)),u=Ba(i,o+s,mt(a));let m=null;for(let h=c;h<u;h+=1){const p=i[h];if(p===void 0)continue;const f=Ha(e,p,t,r);le(f,n)&&(m===null||f.crossDistance<m.crossDistance)&&(m=f)}return m}function mt(e){return t=>d.getCoordinates(e,t).main}function Ha(e,t,r,n){const{main:a,cross:i}=d.getCoordinates(e.mainAxis,r),{main:o,cross:s}=d.getCoordinates(e.mainAxis,t);return{...Ut(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:Fe(t.x-r.x,t.y-r.y,n)}}function $a(e,t){return e.buckets[Km(e,t)]??null}function Km(e,t){return Ya(e.buckets,t,r=>r.main)}function zm(e,t){return za(e.bands,t,r=>r.bandCenter)}function Ka(e,t){return za(e.columns,t,r=>r.mainMid)}function za(e,t,r){return e[Ya(e,t,r)]??null}function Ya(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 Ym(e,t){return{group:Um(e),related:jm(e,t)}}function Um(e){switch(e.kind){case"buckets":{const t=e.match.index;return l.isStackedPosition(t.position)?Wm(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)?Xm(t.layerId,r,n.pointIndex):qm(t.bandByColumn,t.layerId,r,n.pointIndex)}case"points":case"enclosure":case"render-hit-test":return[]}}function Wm(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 Xm(e,t,r){const n=[];for(const a of t.rects)a.pointIndex!==r&&n.push(Wt(e,a));return n}function qm(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 jm(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||Jm(r,i,e);continue}e.kind==="buckets"&&(l.isStackedPosition(i.position)||i.kind==="buckets"&&Zm(r,i.layerId,e.match.bucket,e.match.hit.pointIndex))}return r}function Zm(e,t,r,n){for(const a of r.entries)a.pointIndex!==n&&Le(e,t).push({anchored:!0,layerId:t,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation})}function Jm(e,t,r){const n=r.match.hit;switch(t.kind){case"buckets":{const a=$a(t,d.getMainAxisCoordinate(t.mainAxis,n));if(!a)return;const i=Le(e,t.layerId);for(const o of a.entries)i.push({anchored:!0,layerId:t.layerId,pointIndex:o.pointIndex,x:o.x,y:o.y,observation:o.observation});return}case"banded":{const a=zm(t,d.getMainAxisCoordinate(t.mainAxis,n));if(!a)return;const i=Le(e,t.layerId);for(const o of a.columns)for(const s of o.rects)i.push(Wt(t.layerId,s));return}case"points":{const a=r.kind==="banded"?r.match.index.bandByColumn.get(r.match.column):void 0,i=a===void 0?[]:Hm(t,a.mainMin,a.mainMax,n),o=i.length>0?null:Gm(t,n),s=o===null?i:[o];if(s.length===0)return;const c=Le(e,t.layerId);for(const u of s)c.push({anchored:!0,layerId:t.layerId,pointIndex:u.pointIndex,observationIndex:u.observationIndex,x:u.x,y:u.y,observation:u.observation});return}case"enclosure":return;case"noop":return;case"render-hit-test":return}}function Le(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 Ua(e,t,r){const{columns:n,bands:a,bandByColumn:i}=Qm(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 Qm(e,t){const r=th(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=k(c.mainMid);let m=n.get(u);if(!m){m={mainMid:c.mainMid,rects:[]},n.set(u,m);const h=k(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(m),i.set(m,p)}m.rects.push(c.entry),eh(i.get(m),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,m)=>u.mainMid-m.mainMid);return{columns:o,bands:s,bandByColumn:i}}function eh(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 th(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=rh(r,s),u=[];let m=0;for(const h of r){const p=n[m],f=a[m],g=i[m],S=o[m];if(!l.isDefined(p)||!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)){m++;continue}const x=s?(g+S)/2:(p+f)/2,A=c?.[m]??x;u.push({mainMid:x,bandCenter:A,entry:{pointIndex:m,xMin:Math.min(p,f),xMax:Math.max(p,f),yMin:Math.min(g,S),yMax:Math.max(g,S),observation:h}}),m++}return u}function rh(e,t){const r=(t?[l.POSITION_VARIABLES.yBand,l.POSITION_VARIABLES.y]:[l.POSITION_VARIABLES.xBand,l.POSITION_VARIABLES.x]).find(n=>e.hasVariable(n));return r?e.getValues(r,{type:"numeric"}):null}var nh=1e-9,rn=-1;function Wa(e,t,r){const n=ah(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)<=1e-9?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:Xa(o.entries,t)})):i,entries:a}}function Xa(e,t){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const a of e){const i=d.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 ah(e,t,r){const{data:n,spatialKind:a,position:i}=e,o=ne(n,l.POSITION_VARIABLES.x),s=ne(n,l.POSITION_VARIABLES.y);if(!o||!s)return[];const c=t==="y",u=a==="spanned-buckets",m=l.isStackedPosition(i),h=c?s:o,p=ne(n,c?l.POSITION_VARIABLES.yBand:l.POSITION_VARIABLES.xBand)??h,f=c?o:s,g=ne(n,c?l.POSITION_VARIABLES.xMin:l.POSITION_VARIABLES.yMin),S=ne(n,c?l.POSITION_VARIABLES.xMax:l.POSITION_VARIABLES.yMax),x=n.hasVariable(l.GROUP_VARIABLES.group)?n.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}):null,A=u?null:new oh(sh(e)),P=new Map,X=[];let _=-1;for(const dl of n){_+=1;const fe=x?.[_]??null,ml=lh(P,fe),We=p[_],ge=g?.[_],fr=S?.[_],te=ih(f[_],ge,fr,m);if(!l.isDefined(We)||te===null){A?.skip(fe);continue}const gr=h[_]??We,vr={pointIndex:_,...c?{x:te,y:gr}:{x:gr,y:te},groupKey:fe,paintOrder:ml,...a==="filled-buckets"&&l.isDefined(ge)&&{fill:ch(ge,te)},...u&&{extent:uh(te,ge,fr)},previousAt:rn,nextAt:rn,observation:dl};A?.append(fe,{entry:vr,at:X.length}),X.push({main:We,entry:vr})}return r==="polar"&&A?.close(),X}function ne(e,t){return e.hasVariable(t)?e.getValues(t,{type:"numeric"}):null}function ih(e,t,r,n){return l.isDefined(e)?n?l.isDefined(t)&&l.isDefined(r)?r:null:e:null}var oh=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 sh(e){return"missingValues"in e.params&&e.params.missingValues==="gap"}function lh(e,t){const r=e.get(t);if(r!==void 0)return r;const n=e.size;return e.set(t,n),n}function ch(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}}function uh(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 qa(e,t){return{kind:"enclosure",layerId:e.id,geom:e.geom,position:e.position,projection:t,cells:dh(e,t)}}function dh(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 m=0;for(const h of r){const p=a[m],f=i[m],g=o[m],S=s[m];if(!l.isDefined(p)||!l.isDefined(f)||!l.isDefined(g)||!l.isDefined(S)){m++;continue}if(c&&!l.isTilePainted(h)){m++;continue}u.push({pointIndex:m,xMin:p,xMax:f,yMin:g,yMax:S,observation:h}),m++}return u}function ht(e){return{kind:"noop",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian"}}function mh(e,t,r){const n=Za(e),a={kind:"points",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",mainAxis:t,points:n,byMain:ph(t,n),delaunay:null,delaunayAspectRatio:null};return ja(a,r),a}function hh(e){const t=Za(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 ja(e,t){e.delaunay&&e.delaunayAspectRatio===t||(e.delaunay=hl.Delaunay.from(e.points,r=>r.x*t,r=>r.y),e.delaunayAspectRatio=t)}function ph(e,t){const r=n=>d.getMainAxisCoordinate(e,n);return[...t].sort((n,a)=>r(n)-r(a))}function Za(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 Ja(e){return{kind:"render-hit-test",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",byKey:fh(e)}}function Qa(e,t){return{anchored:!1,layerId:e,pointIndex:t.pointIndex,observation:t.observation}}function fh(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 nn(e,t,r){return t.type==="polar"?gh(e,t.bandAxis):vh(e,t.mainAxis,r)}function gh(e,t){switch(e.spatialKind){case"points":return hh(e);case"buckets":case"filled-buckets":case"spanned-buckets":return Wa(e,"x","polar");case"rects":return t===null?qa(e,"polar"):Ua(e,t,"polar");case"cells":return ht(e);case"noop":return ht(e);case"render-hit-test":return Ja(e);default:{const r=e.spatialKind;throw new l.InternalError({message:`buildPolarLayerIndex: unhandled spatialKind ${String(r)}`})}}}function vh(e,t,r){switch(e.spatialKind){case"points":return mh(e,t,r);case"buckets":case"filled-buckets":case"spanned-buckets":return Wa(e,t,"cartesian");case"rects":return Ua(e,t,"cartesian");case"cells":return qa(e,"cartesian");case"noop":return ht(e);case"render-hit-test":return Ja(e);default:{const n=e.spatialKind;throw new l.InternalError({message:`buildCartesianLayerIndex: unhandled spatialKind ${String(n)}`})}}}function yh(e,t,r){if(e.columns.length===0)return null;const n=Ka(e,d.getMainAxisCoordinate(e.mainAxis,t)),a=n?.rects??[];if(!n||!l.isNonEmptyArray(a))return null;const i=l.isStackedPosition(e.position)?bh(a,t,e.mainAxis):xh(a,t,r),o=ei(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,...Sh(e,n,t,r)}}function Sh(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}=d.getCoordinates(e.mainAxis,r),s=V(i,a.mainMin,a.mainMax),c=V(o,a.crossMin,a.crossMax);return Ut(e.mainAxis,s,c,n)}function bh(e,t,r){const n=d.getCrossAxisCoordinate(r,t);return O(e,i=>Ah(i,r,n),{shortCircuitOnZero:!0})}function xh(e,t,r){return O(e,a=>ei(a,t,r))}function ei(e,t,r){return Fe(V(t.x,e.xMin,e.xMax),V(t.y,e.yMin,e.yMax),r)}function Ah(e,t,r){return V(r,t==="x"?e.yMin:e.xMin,t==="x"?e.yMax:e.xMax)}function Ih(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 Th(e,t,r){const{main:n,cross:a}=d.getCoordinates(e.mainAxis,t),i=$a(e,n);if(i===null||!l.isNonEmptyArray(i.entries))return null;const o=Ph(i.entries,i.span,e.mainAxis,n),s=o.entries.map(S=>({entry:S,crossAtCursor:Eh(e,S,n)}));if(!l.isNonEmptyArray(s))return null;const c=ni(s.filter(S=>Ch(e,S.entry,n,a)),S=>S.entry),{entry:u}=c??O(s,S=>Math.abs(S.crossAtCursor-a)),m=Fe(u.x-t.x,u.y-t.y,r),h=S=>({x:S.x*r,y:S.y}),p=Be(e,u).map(h),f=ri(h(t),h(u),p,m),g=Ut(e.mainAxis,d.getMainAxisCoordinate(e.mainAxis,u)-n,ti(o.span,d.getCrossAxisCoordinate(e.mainAxis,u),a),r);return{hit:{anchored:!0,layerId:e.layerId,pointIndex:u.pointIndex,x:u.x,y:u.y,observation:u.observation},index:e,bucket:i,distance:c===void 0?m:0,vertexDistance:m,insideFill:c!==void 0,strokeDistance:c===void 0?f:0,...g}}function Lh(e,t,r){return O(e,a=>Math.abs(d.getCrossAxisCoordinate(r,a)-t))}function ti(e,t,r){return e!==void 0?V(r,e.min,e.max):Math.abs(t-r)}function ri(e,t,r,n){const a=r.map(i=>Ih(e,t,i));return Math.min(n,...a)}function Be(e,t){return[e.entries[t.previousAt],e.entries[t.nextAt]].filter(l.isDefined)}function ni(e,t){return e.reduce((r,n)=>r===void 0||t(n).paintOrder>t(r).paintOrder?n:r,void 0)}function Eh(e,t,r){const{mainAxis:n}=e,a=r===d.getMainAxisCoordinate(n,t)?null:ai(e,t,r);return a===null?d.getCrossAxisCoordinate(n,t):Rh(t,a,n,r)}function Rh(e,t,r,n){const a=d.getMainAxisCoordinate(r,e),i=(n-a)/(d.getMainAxisCoordinate(r,t)-a),o=d.getCrossAxisCoordinate(r,e);return o+(d.getCrossAxisCoordinate(r,t)-o)*i}function ai(e,t,r){const{mainAxis:n}=e,a=d.getMainAxisCoordinate(n,t),i=o=>Math.sign(d.getMainAxisCoordinate(n,o)-a)===Math.sign(r-a);return Be(e,t).find(i)??null}function Ch(e,t,r,n){const a=wh(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function wh(e,t,r){if(t.fill===void 0)return null;const{mainAxis:n}=e,a=d.getMainAxisCoordinate(n,t);if(r===a)return t.fill;const i=ai(e,t,r);if(i?.fill===void 0)return null;const o=(r-a)/(d.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 Ph(e,t,r,n){if(t===void 0)return{entries:e,span:t};const a=s=>d.getMainAxisCoordinate(r,s),i=a(O(e,s=>Math.abs(a(s)-n))),o=e.filter(s=>Math.abs(a(s)-i)<=nh);return o.length===e.length?{entries:e,span:t}:{entries:o,span:Xa(o,r)}}function Mh(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 Dh(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?kh(e.columns,a):Ka(e,i),c=s?.rects??[];if(!s||!l.isNonEmptyArray(c))return null;const u=o?Vh(c,i):Nh(c,a),m=Oh(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:m,..._h(e,s,n)}}function Oh(e,{angle:t,radius:r}){const n=Pe(t,e.xMin,e.xMax),a=V(r,e.yMin,e.yMax);return Math.hypot(n*r,a)}function Pe(e,t,r){return l.isAngleWithinArc(e,t,r)?0:Math.min(l.wrappedAngularDistance(e,t),l.wrappedAngularDistance(e,r))}function _h(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:Pe(r,a.mainMin,a.mainMax)*n,crossDistance:V(n,a.crossMin,a.crossMax)}:{mainDistance:V(n,a.mainMin,a.mainMax),crossDistance:Pe(r,a.crossMin,a.crossMax)*n}}function kh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(t,r.mainMid)):null}function Vh(e,t){return O(e,r=>V(t,r.yMin,r.yMax),{shortCircuitOnZero:!0})}function Nh(e,t){return O(e,r=>Pe(t,r.xMin,r.xMax),{shortCircuitOnZero:!0})}var an=1e-9;function Fh(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=Bh(e.buckets,a),s=o?.entries??[];if(!o||!l.isNonEmptyArray(s))return null;const c=ni(s.filter(f=>Gh(e,f,a,i)),f=>f),u=c??Lh(s,i,e.mainAxis),m=on(u),h=Math.hypot(n.x-m.x,n.y-m.y),p=ri(n,m,Be(e,u).map(on),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:ti(o.span,u.y,i)}}function on(e){return l.polarToUnit(e.x,e.y)}function Bh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(r.main,t)):null}function Gh(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=Be(e,t).find(a);if(i?.fill===void 0)return null;const o=sn(r,{angle:t.x,radius:t.fill.min},{angle:i.x,radius:i.fill.min}),s=sn(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 sn(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)<an)return t.radius;const o=ln(l.polarToUnit(e,1),i);return Math.abs(o)<an?null:ln(n,i)/o}function ln(e,t){return e.x*t.y-e.y*t.x}function $h(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 cn(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=>V(i,u.yMin,u.yMax),c=O(o,s);return cn(e,c,s(c))}function cn(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 Kh(e,t,r,n){if(!l.isNonEmptyArray(e.points))return null;const a=l.cursorToPiePlane(t,r),i=un(e,O(e.points,s=>ii(s,a)),a);if(n===void 0||de(i.distance,n)||le(i,n))return i;const o=e.points.map(s=>un(e,s,a)).filter(s=>le(s,n));return l.isNonEmptyArray(o)?O(o,s=>s.crossDistance):i}function un(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(ii(t,r))}}function ii(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 zh=.05;function Yh({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,m]of e.entries()){if(m.kind==="render-hit-test"){const p=Jh(m,t,a);if(p)return{kind:"render-hit-test",match:p};continue}if(m.projection==="polar"){const p=Zh(m,t,r,i?.polar);if(p&&!dn(p,i?.polar))return p;continue}const h=jh({layer:m,cursor:t,aspectRatio:r,warmStarts:n,tolerance:i?.cartesian});if(!(!h||dn(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 oi(c,Wh(s,o)).match}function Uh(e,t){if(e.kind==="render-hit-test")return{intersects:!0,onPoint:!1};const r=Xh(e,t),n=e.kind==="buckets"&&de(e.match.vertexDistance,r);return{intersects:si(e,r),onPoint:n}}function Wh(e,t){return e.match!==null&&t.match!==null&&e.distance===0&&t.distance===0?e.paintOrder>t.paintOrder?e:t:oi(e,t)}function oi(e,t){return e.match===null?t:t.match===null||e.distance<=t.distance+zh?e:t}function si(e,t){switch(e.kind){case"banded":case"enclosure":return e.match.distance<=t.on.edge;case"buckets":return qh(e.match,t);case"points":return de(e.match.distance,t)}}function Xh(e,t){return e.match.index.projection==="polar"?t.polar:t.cartesian}function qh(e,t){return e.strokeDistance<=t.on.stroke?!0:de(e.vertexDistance,t)}function dn(e,t){return t===void 0?!1:!si(e,t)&&!le(e.match,t)}function jh({layer:e,cursor:t,aspectRatio:r,warmStarts:n,tolerance:a}){switch(e.kind){case"buckets":{const i=Th(e,t,r);return i?{kind:"buckets",match:i}:null}case"banded":{const i=yh(e,t,r);return i?{kind:"banded",match:i}:null}case"points":{const i=Bm(e,t,r,n.get(e.layerId)??null,a);return i?{kind:"points",match:i}:null}case"enclosure":{const i=Mh(e,t);return i?{kind:"enclosure",match:i}:null}case"noop":return null}}function Zh(e,t,r,n){switch(e.kind){case"enclosure":{const a=$h(e,t,r,n!==void 0);return a?{kind:"enclosure",match:a}:null}case"points":{const a=Kh(e,t,r,n);return a?{kind:"points",match:a}:null}case"buckets":{const a=Fh(e,t,r);return a?{kind:"buckets",match:a}:null}case"banded":{const a=Dh(e,t,r);return a?{kind:"banded",match:a}:null}case"noop":case"render-hit-test":return null}}function Jh(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:Qa(e.layerId,i)}:null}var H={primary:null,group:[],related:new Map},Qh=class{constructor({layers:e,coordSystem:t}){this.layerIndexes=[],this.layerRefs=[],this.viewport=null,this.aspectRatio=ep,this.isAspectStale=!1,this.warmStarts=new Map,this.cachedState=H,this.cachedKey=null,this.hoverLayers={interactive:[],normal:[],low:[]},this.hitTesters=new Map,this.cachedByKeyId=null,this.cachedByKeyState=H,this.layerIndexes=e.map(r=>nn(r,t,this.aspectRatio)),this.layerRefs=e.map(r=>mn(r,t)),this.hoverLayers=hn(e,this.layerIndexes)}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=mn(i,t);if(o!==void 0&&rp(o.ref,s)){n.push(o.index),a.push(o.ref);continue}this.warmStarts.delete(i.id),n.push(nn(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.hoverLayers=hn(e,n),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 H;this.reindexForAspect();const n=r??this.viewport,a=t!==void 0&&n!==null?Fm(t,n):void 0,i=p=>Yh({layers:p,aspectRatio:this.aspectRatio,warmStarts:this.warmStarts,hitTesters:this.hitTesters,cursor:e,tolerance:a}),o=i(this.hoverLayers.normal)??i(this.hoverLayers.low);if(!o)return this.invalidateCache(),H;const s=o.match.hit;this.warmStarts.set(s.layerId,s.pointIndex);const c=a===void 0?void 0:Uh(o,a),u=tp(s,c);if(this.cachedKey===u)return this.cachedState;const{group:m,related:h}=Ym(o,this.hoverLayers.interactive);return this.cachedKey=u,this.cachedState=c===void 0?{primary:s,group:m,related:h}:{primary:s,group:m,related:h,intersection:c},this.cachedState}registerHitTester(e,t){this.hitTesters.set(e,t)}unregisterHitTester(e){this.hitTesters.delete(e)}resolveHoverByKey(e,t){const r=this.hoverLayers.interactive.find(i=>i.layerId===e);if(!r||r.kind!=="render-hit-test")return H;const n=r.byKey.get(t);if(!n)return H;const a=`${e}:${t}`;return this.cachedByKeyId===a?this.cachedByKeyState:(this.cachedByKeyId=a,this.cachedByKeyState={primary:Qa(e,n),group:[],related:new Map},this.cachedByKeyState)}invalidateCache(){this.cachedKey=null,this.cachedState=H,this.cachedByKeyId=null,this.cachedByKeyState=H}reindexForAspect(){if(this.isAspectStale){this.isAspectStale=!1;for(const e of this.layerIndexes)e.kind==="points"&&e.projection==="cartesian"&&ja(e,this.aspectRatio)}}},ep=1;function tp(e,t){const r=`${e.layerId}:${e.pointIndex}`;return t===void 0?r:`${r}:${t.intersects}:${t.onPoint}`}function mn(e,t){return{data:e.data,geom:e.geom,position:e.position,coord:t}}function hn(e,t){const r={interactive:[],normal:[],low:[]};for(const[n,a]of e.entries()){const i=t[n];!i||!a.interactive||(r.interactive.push(i),r[a.hoverPriority].push(i))}return r}function rp(e,t){return e.data===t.data&&e.geom===t.geom&&e.position===t.position&&e.coord===t.coord}var np=Math.PI*2;function ap(e,t){const r=d.getMainAxisCoordinate(e.mainAxis,t);if(e.mainAxis==="y"){const a=Y(N(r));return{x1:0,x2:"100%",y1:a,y2:a}}const n=Y(r);return{x1:n,x2:n,y1:0,y2:"100%"}}function ip(e,t,r){const n=e.mainAxis==="y"?l.getYBand(r.observation):l.getXBand(r.observation);if(n===null)return null;const a=e.mainAxis==="y"?ci(r):li(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(N(n+o)),width:"100%",height:Y(i)}:{x:Y(n-o),y:0,width:Y(i),height:"100%"}}function op(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+np,innerRadius:r,outerRadius:n}}function li(e){const t=l.getXMin(e.observation),r=l.getXMax(e.observation);return t===null||r===null?null:r-t}function ci(e){const t=l.getYMin(e.observation),r=l.getYMax(e.observation);return t===null||r===null?null:r-t}function sp(e){return e.observationIndex??e.pointIndex}function lp(e){return e==="buckets"||e==="filled-buckets"||e==="spanned-buckets"}function cp(e){return e==="buckets"||e==="filled-buckets"}var Ge=.5,up=.3,dp=.4,mp=10,hp=({layer:e,coordSystem:t,scales:r,options:n})=>e.data.size()===0?null:e.spatialKind==="rects"?t.type==="cartesian"?fp(e,t,r,n):gp(e,t,n):cp(e.spatialKind)&&t.type==="cartesian"?Sp(e,t,n):e.spatialKind==="cells"||e.spatialKind==="spanned-buckets"?yp(e,n):e.spatialKind==="points"?vp(e,n):null,pp=e=>lp(e.spatialKind)?new Set(e.data.getValues(l.GROUP_VARIABLES.group)).size:e.data.size(),fp=(e,t,r,n)=>({type:"grow",layerId:e.id,durationSeconds:Ge*n.durationScale,baseline:Ht(e,t,r),growAxis:t.mainAxis==="x"?"y":"x",delayByKey:n.stagger?bp(e,t.mainAxis,n):{}}),gp=(e,t,r)=>{const n=t.bandAxis==="x"?"radius":"angle";return{type:"grow",layerId:e.id,durationSeconds:Ge*r.durationScale,growAxis:n,baseline:n==="radius"?t.innerRadius:t.startAngle,delayByKey:n==="radius"&&r.stagger?Ip(e,t,r):{}}},vp=(e,t)=>({type:"grow",layerId:e.id,durationSeconds:Ge*t.durationScale,growAxis:"size",baseline:0,delayByKey:t.stagger?xp(e,t):{}}),yp=(e,t)=>({type:"fade",layerId:e.id,durationSeconds:up*t.durationScale}),Sp=(e,t,r)=>({type:"wipe",layerId:e.id,durationSeconds:Ge*r.durationScale,axis:t.mainAxis}),bp=(e,t,r)=>{const n=Ne(e.data,e.mapping,e.id),a=new Map;for(const i of e.data){const o=Pa(t,i);if(!o)continue;const s=Da(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)},xp=(e,t)=>{const r=Ne(e.data,e.mapping,e.id),n=[];for(const a of e.data){const i=Ap(a,t.staggerOrder);i!==null&&n.push({position:i,keys:[r(a)]})}return Xt(n,t)},Ap=(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},Ip=(e,t,r)=>{const n=Ne(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 m=Fa(t.bandAxis,{startAngle:o,endAngle:s,innerRadius:c,outerRadius:u}),h=n(i),p=a.get(m);p?p.keys.push(h):a.set(m,{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/mp),i=Math.ceil(n.length/a),o=dp*t.durationScale/i;return n.forEach((s,c)=>{const u=Math.floor(c/a)*o;for(const m of s.keys)r[m]=u}),r},Tp=(e,t,r)=>({shadow:e.get("shadow",t,r),blendMode:e.get("blendMode",t,r),...ui({saturation:e.get("saturation",t,r),brightness:e.get("brightness",t,r),contrast:e.get("contrast",t,r),blur:e.get("blur",t,r)})}),ui=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},j=["top","right","bottom","left"],pn={top:"topLeft",right:"topRight",bottom:"bottomRight",left:"bottomLeft"},Lp={top:"topRight",right:"bottomRight",bottom:"bottomLeft",left:"topLeft"},Ep={topLeft:["left","top"],topRight:["top","right"],bottomRight:["right","bottom"],bottomLeft:["bottom","left"]},Rp=(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,m]=Ep[c];return a>0&&r[u].strokeWidth>0&&r[m].strokeWidth>0},o=wp(t,a),s=Pp(t,a,i);return Mp(r).map(c=>({dashArray:r[c.firstEdge].dashArray,strokeWidth:r[c.firstEdge].strokeWidth,stroke:r[c.firstEdge].stroke,segments:Dp(c,o,s,i)}))},Cp=e=>({top:e.edges.top.strokeWidth,right:e.edges.right.strokeWidth,bottom:e.edges.bottom.strokeWidth,left:e.edges.left.strokeWidth}),wp=(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}}},Pp=(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")}}}},Mp=e=>{const t=o=>e[o].strokeWidth>0,r=(o,s)=>{const c=(j.indexOf(o)+s+j.length)%j.length;return j[c]},n=o=>{const s=r(o,-1);return!t(s)||!kt(e[s].dashArray,e[o].dashArray)||e[s].strokeWidth!==e[o].strokeWidth||e[s].stroke!==e[o].stroke},a=j.filter(t);if(a.length===0)return[];const i=a.filter(n);return i.length===0?[{firstEdge:"top",edges:[...j],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}})},Dp=(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=pn[s];if(!e.isClosed&&n(u)){const h=t[u],p=i(h),f=Op(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=pn[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 m=Lp[c];if(e.isClosed){if(n(m)){const h=t[m];o.push(a(h,h.startAngle,h.endAngle))}o.push({type:"close"})}else if(n(m)){const h=t[m];o.push(a(h,h.startAngle,i(h)))}return o},Op=(e,t)=>({x:e.cx+e.radius*Math.cos(t),y:e.cy+e.radius*Math.sin(t)}),_p=/^(?:https?:|mailto:)/i,kp=e=>{if(typeof e!="string")return!1;const t=e.replace(/^[\x00-\x20]+/,"");return t.length===0?!1:_p.test(t)},Vp=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",year:"numeric",weekday:"long",...L,...t});return T(n=>r.format(n))},Np=({locale:e,intlOptions:t})=>T(r=>E(e,{day:"2-digit",month:"short",year:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit",second:r.getUTCSeconds()!==0?"2-digit":void 0,...L,...t}).format(r)),Me=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return Fn(e);case"date":return Vp(e);case"datetime":return Np(e);case"day_month":return $n(e);case"decimal":return Bn(e);case"duration":return At(e);case"integer":return Gn(e);case"month":return Kn(e);case"month_year":return Lt(e);case"percentage":return Hn(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return Un(e);case"weekly_date_range":return zn(e);case"weekly_date_range_with_year":return Yn(e);case"year":return Rt(e);case"lookup":return Me({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},di={width:12,height:12},mi={text:null,group:null},hi=" · ",Fp=({layers:e,coordSystem:t,scales:r,guides:n,numberFormat:a,parsingLocale:i,hover:o,mode:s,readers:c,formattingLocale:u,comments:m,activeCalloutId:h})=>{const{primary:p}=o;if(p===null)return null;const f=u??i,g=Gp(m,h);if(s==="none")return g===null?null:{heading:null,rows:[],comment:g};const S=Zp({guides:n,locale:f,numberFormat:a}),x=g===null?Hp({layers:e,coordSystem:t,guides:n,primary:p,mode:s,locale:f,numberFormat:a,resolveColorLabel:S}):mi;return{heading:x.text,rows:zp({layers:e,scales:r,guides:n,hover:o,primary:p,mode:s,locale:f,numberFormat:a,readers:c,resolveColorLabel:S,headingGroup:x.group}),comment:g}},Bp=(e,t,r)=>{if(U(t,"line"))return e.geom.line(t).get("dashArray",r);if(U(t,"area"))return e.geom.area(t).get("dashArray",r);if(U(t,"rule"))return e.geom.rule(t).get("dashArray",r)};function Gp(e,t){return e===void 0||t===null||t===void 0?null:e.find(r=>r.id===t)?.content??null}function Hp(e){const t=e.layers.find(i=>i.id===e.primary.layerId);if(!t)return mi;const r=e.mode==="observation"?qt(t,e.primary,e.resolveColorLabel):null,n=t.tooltip.fields.find(d.isHeadingField);if(n!==void 0){const i=fi(t,n,e.primary,e);return{text:i,group:i!==null&&Kp(t,n)?r:null}}const a=$p(t,e);return a===null||r===null?{text:a,group:null}:{text:`${a}${hi}${r}`,group:r}}function $p(e,t){if(t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null)return null;const r=Ft(t.guides,"x");if(!r)return null;const n=l.readVariableName(e.mapping.x);if(!l.isDefined(n))return null;const a=t.primary.observation[n];return l.isDefined(a)?Me({valueFormat:r.valueFormat,locale:t.locale,numberFormat:t.numberFormat})(a):null}function qt(e,t,r){if(l.readVariableName(e.mapping.color)===null)return null;const n=d.createColorValueReader(e.data,e.mapping)(t.observation);return n===null?null:r(n)}function Kp(e,t){const r=l.readVariableName(e.mapping.color);return r===null?!1:t.kind==="variable"?t.variable===r:t.kind==="aes"&&l.readVariableName(e.mapping[t.aes])===r}function zp(e){const t=e.layers.find(r=>r.id===e.primary.layerId);return Yp(e.layers.flatMap(r=>{const n=qp({layer:r,primaryLayer:t,hover:e.hover,primary:e.primary,mode:e.mode});if(n.length===0)return[];const a=r.id===e.primary.layerId?e.primary:gi({related:n,layer:r,primaryLayer:t,primary:e.primary});if(a===void 0){const i=r.tooltip.fields.filter(o=>o.kind==="group");return(i.length>0||r.tooltip.hidesDefaultRows?i:[d.DEFAULT_ROWS_FIELD]).flatMap(o=>fn(e,r,o,n))}return r.tooltip.fields.flatMap((i,o)=>{if(i.kind==="group")return fn(e,r,i,n);if(d.isHeadingField(i))return[];const s=Up(e,r,i,a,`${a.layerId}:${a.pointIndex}:field-${o}`);return s===null?[]:[s]})}))}function Yp(e){const t=new Map;for(const{row:r,layerId:n}of e){const a=t.get(r.label)??new Set;a.add(n),t.set(r.label,a)}return e.map(({row:r,qualifier:n})=>(t.get(r.label)?.size??0)>1&&n!==null&&n!==""?{...r,label:`${r.label}${hi}${n}`}:r)}function pi(e,t,r){return e===null||e===r?{label:t,qualifier:null}:{label:e,qualifier:t}}function fn(e,t,r,n){const a=d.createColorValueReader(t.data,t.mapping),i=jp({hits:n,layer:t,colorScale:e.scales.color??null,colorValueReader:a}),o=r.format===void 0?Mt({layer:t,numberFormat:e.numberFormat,locale:e.locale}):I({valueFormat:r.format,locale:e.locale,numberFormat:e.numberFormat}),s=r.title??Jp(e.guides,t),c=d.createSegmentYReader(t);return i.map(u=>{const m=zt(e.readers.geom,t,u.observation,di),{label:h,qualifier:p}=pi(qt(t,u,e.resolveColorLabel),s,e.headingGroup),f=c(u.observation);return{row:{swatchColor:$t(e.readers,t,u.observation)??null,geom:t.geom,swatchLineType:_t(Bp(e.readers,t,u.observation)),swatchFill:m.fill,swatchAlpha:m.alpha,swatchCornerRadius:m.cornerRadiusPx,swatchSymbol:m.symbol,label:h,value:f===null?"":o(f,u.observation),isPrimary:u===e.primary,key:`${u.layerId}:${u.pointIndex}`},layerId:t.id,qualifier:p}})}function Up(e,t,r,n,a){const i=fi(t,r,n,e);if(i===null)return null;const o=zt(e.readers.geom,t,n.observation,di),s=r.kind==="range"||r.kind==="aes"&&r.aes==="color",{label:c,qualifier:u}=r.title!==void 0?{label:r.title,qualifier:null}:Wp(t,r,n,e);return{row:{swatchColor:s?$t(e.readers,t,n.observation)??null:null,geom:t.geom,swatchLineType:"solid",swatchFill:o.fill,swatchAlpha:o.alpha,swatchCornerRadius:o.cornerRadiusPx,swatchSymbol:o.symbol,label:c,value:i,isPrimary:n===e.primary,key:a},layerId:t.id,qualifier:u}}function fi(e,t,r,n){const a=(c,u)=>l.isDefined(u)?I({valueFormat:t.format??d.getLayerVariableValueFormat(e,c),locale:n.locale,numberFormat:n.numberFormat})(u,r.observation):null,i=c=>{const u=e.mapping[c],m=c==="y"&&u!==void 0?d.resolveSegmentYSource(e.position,e.mapping):u;return a(l.readVariableName(u),d.createRawValueReader(e.data,m)(r.observation))};if(t.kind==="variable")return a(t.variable,r.observation[t.variable]??null);if(t.kind==="aes")return i(t.aes);const[o,s]=t.range.map(i);return l.isDefined(o)&&l.isDefined(s)?`${o} – ${s}`:null}function Wp(e,t,r,n){if(t.kind==="range"){const i=t.range.map(o=>d.resolveVariableLabel(l.readVariableName(e.mapping[o]),n.guides.variableLabels)??o).join(" – ");return pi(qt(e,r,n.resolveColorLabel),i,n.headingGroup)}const a=t.kind==="variable"?t.variable:l.readVariableName(e.mapping[t.aes]);return{label:d.resolveVariableLabel(a,n.guides.variableLabels)??a??"",qualifier:null}}function gi({related:e,layer:t,primaryLayer:r,primary:n}){const a=r===void 0?new Set:gn(r),i=[...gn(t)].filter(o=>a.has(o));return e.find(o=>i.every(s=>Xp(o.observation[s],n.observation[s])))??e[0]}function gn(e){const t=new Set(l.getGroupVariables(e.data,e.mapping));for(const r of Object.values(e.mapping)){const n=l.readVariableName(r);n===null||!e.data.hasVariable(n)||e.data.getType(n)==="categorical"&&t.add(n)}return t}var Xp=(e,t)=>l.getStableKey(e??null)===l.getStableKey(t??null);function qp({layer:e,primaryLayer:t,hover:r,primary:n,mode:a}){const i=r.related.get(e.id)??[];if(e.id===n.layerId)return a==="band"?[n,...r.group,...i]:[n];if(a==="band")return i;const o=gi({related:i,layer:e,primaryLayer:t,primary:n});return o===void 0?[]:[o]}function jp({hits:e,layer:t,colorScale:r,colorValueReader: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 Zp({guides:e,locale:t,numberFormat:r}){const n=new Map(e.colorGroups.map(i=>[l.getStableKey(i.value),{label:i.label,format:Me({valueFormat:i.valueFormat,locale:t,numberFormat:r})}])),a=Me({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 Jp(e,t){return d.resolveVariableLabel(l.readVariableName(t.mapping.y),e.variableLabels)??""}function Qp(e,t,r=0){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:r}function ef(e,t,r=""){const n=e[t];return typeof n=="string"?n:r}var tf=(e,t)=>({...e.annotation.arrow(t).resolve(),outline:e.annotation.arrow.outline(t).resolve()}),rf=(e,t)=>{const r=e.annotation.differenceArrow(t);return{...r.resolve(),isStrokeAuthored:Ot(r.getSource("stroke")),label:e.annotation.differenceArrow.label(t).resolve()}},nf=(e,t,r)=>{const n=e.annotation[t](r),a=e.annotation[t].label(r);return{marker:{...n.resolve(),isFillAuthored:Ot(n.getSource("fill"))},label:{...a.resolve(),isTextColorAuthored:a.getSource("textColor")==="authored"}}},af=e=>e.strokeWidth>0?e.stroke??l.toPaintColor(e.fill):void 0,of=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")}),sf=e=>({...l.DEFAULT_GRAPH_PADDING_EDGES_PX,...e.graph().get("padding")}),C=e=>{let t={top:0,right:0,bottom:0,left:0};for(const r of e.collectAll("margin"))t={...t,...r};return t},lf=e=>({header:C(e.header()),footer:C(e.footer()),headline:C(e.headline()),legend:{top:C(e.legend.top()),right:C(e.legend.right()),bottom:C(e.legend.bottom()),left:C(e.legend.left())},axisLabel:{top:C(e.axisLabel.top("x")),bottom:C(e.axisLabel.bottom("x"))},tickLabel:{top:C(e.tickLabel.top("x")),right:C(e.tickLabel.right("y")),bottom:C(e.tickLabel.bottom("x")),left:C(e.tickLabel.left("y"))}}),cf=e=>({hover:e.editOutline.hover().resolve(),selected:e.editOutline.selected().resolve()}),uf={color:l.getColor,alpha:l.getAlpha,strokeWidth:l.getStrokeWidth,lineType:l.getLineType,size:l.getSize},vn={vocabulary:{},aesthetics:{}},yn=new WeakMap,df=(e={})=>{const t=e.colorScheme??"light",r=new WeakMap,n=new WeakMap,a=(c,u)=>{let m=r.get(c);m===void 0&&(m=new Map,r.set(c,m));const h=m.get(u);if(h!==void 0)return h;const{vocabulary:p,aesthetics:f}=mf(c.styles,u),g=gf({styles:ff(c.styles,u),colorScheme:t,vocabulary:p,visualVariableReaders:hf(f,c.styles.dashPresets),findPart:S=>i(c,S)});return m.set(u,g),g},i=(c,u)=>Object.hasOwn(c.styles.parts,u)?a(c,u):void 0,o=xc(a);return{readers:c=>{const u=n.get(c.chrome);if(u!==void 0)return u;const m=Ac(c.chrome,o,t);return n.set(c.chrome,m),m}}},mf=(e,t)=>t===void 0?e.observation:Object.hasOwn(e.parts,t)?e.parts[t]??vn:vn,hf=(e,t)=>{const r={};for(const[n,a]of Object.entries(e)){const i=a===void 0?void 0:uf[a];i!==void 0&&(r[n]=a==="lineType"?pf(t):i)}return r},pf=e=>t=>{const r=l.getLineType(t);return r===void 0?void 0:e[r]},ff=(e,t)=>{let r=yn.get(e);r===void 0&&(r=new Map,yn.set(e,r));const n=r.get(t);if(n!==void 0)return n;const a={defaults:Sn(e.defaults,t),overrides:Sn(e.overrides,t)};return r.set(t,a),a},Sn=(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},gf=({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:Z(A,h,t),tier:"override",origin:A.origin,state:f};const P=z(e.defaults,h,p,f);if(P!==void 0)return{value:Z(P,h,t),tier:"default",origin:P.origin,state:f}}const g=z(e.overrides,h,p,void 0);if(g!==void 0)return{value:Z(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:Z(x,h,t),tier:"default",origin:x.origin}:{value:void 0,tier:"unresolved"}},s=(h,p,f)=>{if(f!==void 0){const x=Ie(e.overrides,h,p,f,t);if(x!==void 0)return x;const A=Ie(e.defaults,h,p,f,t);if(A!==void 0)return A}const g=Ie(e.overrides,h,p,void 0,t);if(g!==void 0)return g;const S=i(h,p);return S!==void 0?S:Ie(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 P=A.declarations[h];P!==void 0&&vi(A,p)&&g.push(l.resolveColorScheme(P,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=Z(S,g,t);x!==void 0&&Object.assign(f,{[g]:x})}return f},part:a}},Ie=(e,t,r,n,a)=>Z(z(e,t,r,n),t,a),Z=(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&&vi(o,r))return o}},vi=(e,t)=>e.matches===void 0?!0:t!==void 0&&e.matches(t),jt=["sticker","pinnedNumber","comment","image"],vf=e=>jt.includes(e),Zt=e=>{switch(e.kind){case"pinnedNumber":case"comment":return e.annotation.at;case"sticker":return e.annotation.at.anchorType==="observation"?Sf(e.annotation.at):null;default:return null}},yi=(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=yf)=>{const n=r(t);for(const a of jt){const i=d.readAnnotationBucket(e,a),o=i.findIndex(c=>{const u=Zt({kind:a,annotation:c});if(u===null)return!1;const m=r(u);return yi(m,n)}),s=i[o];if(s!==void 0)return{kind:a,index:o,annotation:s}}return null},yf=e=>({...e,anchorValue:et(e.anchorValue),...e.groupValue!==void 0&&{groupValue:et(e.groupValue)},...e.crossValue!==void 0&&{crossValue:et(e.crossValue)}}),et=e=>l.readISOInstant(e)??e,Sf=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),bf=(e,t)=>e.find(r=>r.scope===t.scope&&r.layerId===t.layerId&&d.arePredicatesEqual(r.predicate,t.predicate))??null,bi=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)))),xi=e=>e.find(t=>t.geom==="line"&&t.stat.type==="smooth"),Ai=e=>e.find(t=>t.geom==="rule"&&t.stat.type==="mean");function Ii(e,{themeConfig:t}={}){return{mapping:e.mapping,layers:e.layers,scales:e.scales.map(Af),transforms:e.transforms,highlights:e.highlights,styles:b.styles(e.styles),annotations:e.annotations,coords:e.coords,config:t===void 0?e.config:xf(e.config,t)}}var xf=(e,t)=>Ti({...e},{...t}),bn=e=>(0,bt.isPlainObject)(e);function Ti(e,t){const r=Object.entries(e).flatMap(([n,a])=>{if(!(n in t))return[[n,a]];const i=t[n];return bn(a)&&bn(i)?[[n,Ti(a,i)]]:(0,bt.isEqual)(a,i)?[]:[[n,a]]});return Object.fromEntries(r)}function Af(e){const{inferredFrom:t,...r}=e;return r.scaleType==="palette"?If(r):r}function If(e){return{...e,palette:Tf(e.palette),overrides:Lf(e.overrides)}}function Tf(e){return e.type==="custom"?{type:"custom",id:e.id}:e}function Lf(e){if(!e)return;const t={};for(const[r,n]of Object.entries(e))t[Number(r)]={hex:n};return t}function y(e){return{id:e.id??d.uniqueId(),timestamp:e.timestamp??Date.now(),description:e.description,author:e.author??"unknown"}}function ee(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((r,n)=>ee(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=>ee(e[a],t[a]))}return!1}var Jt=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=d.findAnnotation(e.annotations,this.params.id);if(!t)return null;const{kind:r,index:n,annotation:a}=t;return{spec:d.patchSpec(e,{annotations:d.removeLocatedAnnotation(e.annotations,t)}),revert:new Qt({kind:r,annotation:a,index:n},this.metadata)}}},Ef={type:"remove-annotation",deserialize:(e,t)=>new Jt(e,t)},Qt=class Li{constructor(t,r={}){this.type="add-annotation",this.params={kind:t.kind,annotation:{...t.annotation,id:t.annotation.id??d.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(!d.isAnnotationKind(r)||d.findAnnotation(t.annotations,n.id))return null;const i=Cf(t.annotations,{kind:r,annotation:n}),o=i===null?t.annotations:d.removeLocatedAnnotation(t.annotations,i),s=d.readAnnotationBucket(o,r),c=a??s.length,u=Math.min(Math.max(c,0),s.length);return{spec:d.patchSpec(t,{annotations:d.replaceAnnotationBucket(o,r,[...s.slice(0,u),n,...s.slice(u)])}),revert:i===null?new Jt({id:n.id},this.metadata):new Li({kind:i.kind,annotation:i.annotation,index:i.index},this.metadata)}}},Rf={type:"add-annotation",deserialize:(e,t)=>new Qt({kind:e.kind,annotation:e.annotation,index:e.index},t)},Cf=(e,t)=>{const r=Zt(t);return r===null?null:Si(e,r)},wf=(e,t)=>{const r=er(e);return r===null?null:Ei(r.points,t)},Pf=e=>er(e)!==null,Mf=(e,t)=>{const r=er(e);if(r===null)return null;const n=Ei(r.points,t);return n.x===0&&n.y===0?null:r.createPatch(n)},er=e=>{const t=Of[e.kind];return t===null?null:t(e.annotation)},xn=(e,t)=>e.anchorType!=="panel"?null:{points:[pt(e,e.offset)],createPatch:r=>t({...e,x:e.x+r.x,y:e.y+r.y})},An=(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})},Df=(e,t)=>e.anchorType!=="panel"||t.anchorType!=="panel"?null:{points:[pt(e,e.offset),pt(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=>xn(e.at,t=>({at:t})),sticker:e=>xn(e.at,t=>({at:t})),shape:e=>An(e.region,t=>({region:t})),image:e=>An(e.region,t=>({region:t})),arrow:e=>Df(e.start,e.end),differenceArrow:null,pinnedNumber:null,comment:null},pt=(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)},Ei=(e,t)=>({x:In(e.map(r=>r.x),t.x),y:In(e.map(r=>r.y),t.y)}),In=(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,ie.default)(t,r,n)},Ri=(e,t,r)=>{const n=t.annotation;if(!Vf(n,r))return null;const a=d.readAnnotationBucket(e.annotations,t.kind),i=_f(t.annotation,r),o=[...a.slice(0,t.index),i,...a.slice(t.index+1)];return{spec:d.patchSpec(e,{annotations:d.replaceAnnotationBucket(e.annotations,t.kind,o)}),inverse:kf(n,r)}},_f=(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)))},kf=(e,t)=>{const r={};for(const n of Object.keys(t))r[n]=e[n];return r},Vf=(e,t)=>Object.entries(t).some(([r,n])=>!Object.is(e[r],n)),tr=class Ci{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=d.findAnnotation(t.annotations,n);if(i===null||i.kind!==r)return null;const o=Ri(t,i,a);return o===null?null:{spec:o.spec,revert:new Ci({kind:r,id:n,patch:o.inverse},this.metadata)}}},Nf={type:"update-annotation",deserialize:(e,t)=>new tr(e,t)},wi=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=d.findAnnotation(e.annotations,this.params.id);if(t===null)return null;const r=Mf(t,this.params.translation);if(r===null)return null;const n=Ri(e,t,r);return n===null?null:{spec:n.spec,revert:new tr({kind:t.kind,id:t.annotation.id,patch:n.inverse},this.metadata)}}},Ff={type:"move-annotation",deserialize:(e,t)=>new wi(e,t)},F=class Ee{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=d.findStyleRuleIndex(i,n,d.readStyleCoord(t)),s=o===-1?void 0:i[o],{declarations:c}=n;if(c===null){if(s===void 0)return null;let g=0;for(let A=0;A<o;A+=1){const P=i[A];P!==void 0&&d.areStyleRuleAddressesEqual(P,s)&&(g+=1)}const S=new Ee({list:r,rule:s,index:o-g},this.metadata),x=i.filter(A=>!d.areStyleRuleAddressesEqual(A,s));return{spec:tt(t,r,x),revert:S}}if(s!==void 0){if(d.areStyleDeclarationsEqual(s.declarations,c))return null;const g={...s,declarations:c},S=new Ee({list:r,rule:s,index:o},this.metadata),x=i.map(A=>A===s?g:A);return{spec:tt(t,r,x),revert:S}}const u=a??i.length,m=Math.min(Math.max(u,0),i.length),h={...n,declarations:c},p=[...i.slice(0,m),h,...i.slice(m)],f=new Ee({list:r,rule:{...n,declarations:null}},this.metadata);return{spec:tt(t,r,p),revert:f}}},Bf=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."})},Gf={type:"set-style-rule",deserialize:(e,t)=>(Bf(e),new F(e,t))},tt=(e,t,r)=>d.patchSpec(e,{styles:{...e.styles,[t]:r}}),Hf={type:"set-difference-arrow-style",deserialize:(e,t)=>new Pi(e,t)},Pi=class Mi{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=m=>{const h=d.findStyleRule(s.styles.overrides,m,d.readStyleCoord(s)),p=new F({list:"overrides",rule:m}).apply(s);if(p)return s=p.spec,h?.declarations??null};if(n!==void 0){const m=u({select:i,declarations:n});m!==void 0&&(c.arrow=m)}if(a!==void 0){const m=u({select:o,declarations:a});m!==void 0&&(c.label=m)}return s===t?null:{spec:s,revert:new Mi(c,this.metadata)}}},$f=["cartesian","polar","flip"],w=new l.GeomRegistry,Di=e=>w.has(e)?w.get(e):null;function rr(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 He(e,t){return e.scales.find(r=>r.scaledAesthetic===t)}function $e(e,t,r){const n=e.scales.findIndex(a=>a.scaledAesthetic===t);return n===-1?e:d.patchSpec(e,{scales:d.replaceAtIndex(e.scales,n,r)})}function Ke(e){const t=e.replace(/([A-Z])/g," $1").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function ft(e,t,r){const n=d.resolveScale(d.createScaleContext(d.createCommonContainer(w),{data:ue(e),layers:e.layers,mapping:r,customPalettes:{}}),l.inferred(t));return e.coords.coordType==="polar"?d.removeDiscreteScalePadding(n):n}var Oi=class _i{constructor(t,r={}){this.type="set-chart-type",this.target={kind:"coords"},this.params=t,this.metadata=y({...r,description:eg(t)})}apply(t){const r="previous"in this.params?this.params.previous:tg(t,this.params);if(r===null)return null;const n=d.patchSpec(t,r);return n===t?null:{spec:n,revert:new _i({previous:{coords:t.coords,layers:t.layers,scales:t.scales,mapping:t.mapping}},this.metadata)}}},Kf={type:"set-chart-type",deserialize:(e,t)=>new Oi(e,t)},ki={type:"sum"},zf={type:"identity"},Yf=["bar","line","area","point","tile"],nr="tile",Uf=["y","color"],Wf=Object.values(l.LAYER_LABEL_VARIABLES),Xf={coordType:"cartesian",geom:nr,position:"identity"},me=e=>e.coordType==="cartesian"&&"comboType"in e&&b.COMBO_TYPES.includes(e.comboType),qf=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=Ni(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}},jf=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:Fi(e,r)?Bi(e,r).length>=1:ze(e,e.data.groupVariableNamesByType().numeric).length>=2},Zf=e=>e?Yi(e,Xf)!==null:!1,Jf=e=>Vi(e)?.at(-1)?.id??null,Vi=e=>{if(e.coords.coordType!=="cartesian")return null;const t=e.layers.filter(B);return Ni(t)===null?null:t},Ni=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 Qf(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)},Qf=e=>e.some(t=>t.yScaleType==="secondary"||De(t))||new Set(e.map(t=>l.readVariableName(t.mapping.y))).size>1,eg=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`,tg=(e,t)=>{const r=Yi(e,t);if(r===null)return null;const n=me(t)?ng(r,t):rg(r,t,e);return n===null||r===e?n:{...n,scales:gg({...e,...n},n.scales)}},rg=(e,t,r)=>{if(me(t)||!vg(t))return null;const n={...e,layers:Ji(e.layers)},a=bg(n.layers.filter(B),t),i=eo(n.coords,t),o=Ki(n,t),s=Zi({...n,mapping:o},t,a,o!==n.mapping);return{coords:i,layers:s,scales:rr(to(r,s,i.coordType),s),mapping:o}},ng=(e,t)=>{const r=og(e,t.comboType);if(r===null)return null;const n={...e,layers:r},a=xg(r.filter(B),t.comboType),i=eo(n.coords,t),o=Ki(n,t),s=Zi({...n,mapping:o},t,a,o!==n.mapping),c=ag(e)?s:ig(s);return{coords:i,layers:c,scales:rr(to(e,c,i.coordType),c),mapping:o}},ag=e=>Vi(e)!==null,ig=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)},og=(e,t)=>{const r=e.layers.filter(B);if(r.length>=2)return e.layers;const[n]=r;return n===void 0?null:Fi(e,n)?sg(e,n):lg(e,n,t)},Fi=(e,t)=>{const r=l.readVariableName(t.mapping.color??e.mapping.color);return r!==null&&r!==""},sg=(e,t)=>{const[r]=Bi(e,t);if(r===void 0)return null;const n=d.resolveLayer(w,e.mapping,e.coords.coordType,{type:"layer",id:Gi(r,new Set(e.layers.map(a=>a.id))),geom:"line",stat:ki,...$i(r,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(a=>a.id===t.id?[a,n]:[a])},ze=(e,t)=>{const r=he(e);return t.filter(n=>n!==r)},Bi=(e,t)=>{const r=l.readVariableName(t.mapping.y??e.mapping.y);return ze(e,e.data.groupVariableNamesByType().numeric).filter(n=>n!==r)},he=e=>l.readMainAxisVariable(e.mapping)||l.inferXVariable(e.data),lg=(e,t,r)=>{const{numeric:n}=e.data.groupVariableNamesByType(),a=ze(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=cg(t,Tn(a.slice(0,-1),o,s)),u=d.resolveLayer(w,e.mapping,e.coords.coordType,{type:"layer",id:Gi(i,new Set(e.layers.map(m=>m.id))),geom:"line",stat:t.stat,...Tn([i],o,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(m=>m.id===t.id?[c,u]:[m])},Gi=(e,t)=>{const r=`line:${e}`;let n=r;for(let a=2;t.has(n);a+=1)n=`${r}:${a}`;return n},Tn=(e,t,r)=>{const[n]=e;return e.length===1&&n!==void 0?$i(n,r):Hi(e,t)},Hi=(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})]}),$i=(e,t)=>({mapping:{y:e,color:t},transforms:[b.transform.constant({variableName:t,type:"categorical",value:e})]}),cg=(e,t)=>({...e,mapping:{...e.mapping,...t.mapping},transforms:[...e.transforms,...t.transforms]}),Ki=(e,t)=>{const r=l.readMainAxisVariable(e.mapping),n=zi(t)?"":he(e);return n===r?e.mapping:{...e.mapping,x:n}},zi=e=>e.coordType==="polar"&&e.theta==="y"&&e.position==="fill",ug=e=>!me(e)&&e.geom===nr,dg=e=>e.layers.filter(B).some(t=>t.geom===nr),Yi=(e,t)=>{const r=ug(t);return r===dg(e)?e:r?mg({...e,layers:Ji(e.layers)}):hg(e)??e},mg=e=>{const t=Wi(e);if(t===null)return null;const r=pg(e,t)===null?fg(e,t):Xi(e,t);return r===null?null:Ui(e,t,r)},hg=e=>{const t=Wi(e);if(t===null)return null;const r=Xi(e,t);return r===null?null:Ui(e,t,r)},Ui=(e,t,r)=>({...e,mapping:r.mapping,layers:e.layers.map(n=>n===t?r.layer:n)}),Wi=e=>{const t=e.layers.filter(B);return t.length===1?t[0]??null:null},Xi=(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:qi(t)}},qi=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}},pg=(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=ue(e);return i.hasVariable(n)&&i.getType(n)==="numeric"?null:n},fg=(e,t)=>{const r=ze(e,e.data.groupVariableNamesByType().numeric);if(r.length<2)return null;const n=l.readFoldKeepVariables(e.data,he(e)),a=Hi(r,n),i=qi(t);return{mapping:{...e.mapping,y:a.mapping.color,color:a.mapping.y},layer:{...i,transforms:[...i.transforms,...a.transforms]}}},gg=(e,t)=>Uf.reduce((r,n)=>{const a=ft(e,n,e.mapping);return r.some(i=>i.scaledAesthetic===n)?d.mapItems(r,i=>i.scaledAesthetic===n?a:i):[...r,a]},t),vg=e=>$f.includes(e.coordType)&&ji(e.geom)&&yg(e)&&(e.coordType!=="polar"||Number.isFinite(e.innerRadius)),yg=({geom:e,coordType:t,position:r})=>{const{supportedCoordTypes:n,supportedPositions:a}=w.get(e);return n.includes(t)&&a.includes(r)},ji=e=>Yf.includes(e),B=e=>ji(e.geom)&&!Sg(e.stat),Sg=e=>{switch(e.type){case"smooth":return!0;case"identity":case"count":case"mean":case"sum":case"summary":return!1;default:return!0}},bg=(e,{geom:t,position:r})=>{const n={geom:t,position:r};return new Map(e.map(a=>[a.id,n]))},xg=(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:Ag(i,t,n)}]);return new Map(a)},Ag=(e,t,r)=>e.geom!=="bar"||De(e)?r:b.readComboTypeOfBarPosition(e.position)===t?e.position:r,Zi=(e,t,r,n)=>{const a=e.coords.coordType!==t.coordType;return d.clampValuesAgainstFillSiblings(w,d.mapItems(e.layers,i=>{const o=r.get(i.id);if(o===void 0)return i;const s=Ig(i.stat,e.coords,t);return a||n||i.geom!==o.geom||i.position!==o.position||s!==i.stat?Lg(e,{...i,stat:s},t.coordType,o):i}))},Ig=(e,t,r)=>zi(r)?e.type==="identity"?ki:e:Tg(t)&&e.type==="sum"?zf:e,Tg=e=>e.coordType==="polar"&&e.params.theta==="y",Lg=(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,...m}=t.dataLabels;return{...d.resolveLayer(w,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,tooltip:t.tooltip,dataLabels:{...m,...i.coordType&&{format:s},...i.geom&&i.coordType&&{offset:c},...i.geom&&i.position&&{justify:u}}}),stat:t.stat}},Ji=e=>{const t=e.filter(B);if(t.length<2||!e.some(De))return e;const[r]=t;return e.flatMap(n=>n===r?[Eg(n)]:De(n)?[]:[n])},De=e=>Qi(e)!==null,Qi=e=>{const t=e.transforms.at(-1);return t?.transformType==="reshape"?t.options.keyName==="key"?t:null:t?.transformType!=="constant"?null:Wf.includes(t.options.variableName)?t:null},Eg=e=>{const t=Qi(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)}},eo=(e,t)=>{const r=Rg(e,t);return(0,W.default)(r,e)?e:r},Rg=(e,t)=>{const r={xLimits:e.params.xLimits,yLimits:e.params.yLimits};if(t.coordType!=="polar")return d.resolveCoord({type:"coord",coordType:t.coordType,params:r});const n=e.coordType==="polar"?e.params:d.POLAR_COORD_DEFAULTS;return d.resolveCoord({type:"coord",coordType:"polar",params:{...r,theta:t.theta,startAngle:n.startAngle,innerRadius:t.innerRadius}})},to=(e,t,r)=>{const n=d.resolveGeomScaleDemands(d.readGeomScaleConstraints(w,t)),a=d.resolveGeomScaleDemands(d.readGeomScaleConstraints(w,e.layers)),i=e.coords.coordType==="polar";return d.mapItems(e.scales,o=>{const s=Cg(o,n,a),c=wg(s,n,a);return Mg(c,r,i)})},Cg=(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 d.resolveDiscreteScale(l.discrete(e.scaledAesthetic,{..."reverse"in e&&{reverse:e.reverse}}),t);if(e.scaledAesthetic===t.discreteCrossAxis)return d.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=Pg(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},wg=(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}},Pg=(e,t,r)=>t.nice===(r?.nice??!0)?e:t.nice?l.CONTINUOUS_SCALE_DEFAULTS.nice:!1,Mg=(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}},ro=class no{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:_g(t,this.params);if(r===null)return null;const n=d.patchSpec(t,r);return n===t?null:{spec:n,revert:new no({aesthetic:this.params.aesthetic,previous:{mapping:t.mapping,scales:t.scales,layers:t.layers}},this.metadata)}}},Dg={type:"set-mapping",deserialize:(e,t)=>new ro(e,t)},ao=(e,t)=>{const r=l.readVariableName(e[t]);return r===null||r===""||l.isInternalVariable(r)?null:r},io=e=>e===""?null:e,Og=e=>{if("previous"in e)return`Restore the previous ${e.aesthetic} mapping`;const t=io(e.variable);return t===null?`Clear the ${e.aesthetic} mapping`:`Map ${e.aesthetic} to ${t}`},_g=(e,{aesthetic:t,variable:r})=>{if(!b.isAestheticKey(t))return null;const n=io(r),a=Vg(e.mapping,t,n);return a===e.mapping?null:{mapping:a,scales:Fg(e,t,a,n),layers:kg(e.layers,a)}},kg=(e,t)=>d.mapItems(e,r=>{const n={...t,...r.mapping};if(n.label===void 0&&Di(r.geom)===null)return r;const a=d.resolveLabelSource(w,r.geom,r.position,n);return(0,W.default)(a,r.dataLabels.labelSource)?r:{...r,dataLabels:{...r.dataLabels,labelSource:a}}}),Vg=(e,t,r)=>r===null?Ng(e,t):ao(e,t)===r?e:{...e,[t]:r},Ng=(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},Fg=(e,t,r,n)=>{if(!l.isScaledAestheticKey(t))return e.scales;let a=e.scales;for(const i of Bg(e,t))a=Hg(e,a,i,r,n);return a},Bg=(e,t)=>t==="y"&&Gg(e.layers)?["y","ySecondary"]:[t],Gg=e=>{const t=e.find(r=>r.yScaleType==="secondary");return t!==void 0&&t.mapping.y===void 0},Hg=(e,t,r,n,a)=>{const i=t.find(s=>s.scaledAesthetic===r);if(i===void 0)return a===null?t:[...t,ft(e,r,n)];if(a===null&&!l.isPositionScale(r)||a!==null&&!ue(e).hasVariable(a))return t;const o=ft(e,r,n);return $g(i,o)?t:d.mapItems(t,s=>s.scaledAesthetic===r?o:s)},$g=(e,t)=>e.scaleType===t.scaleType||Ln(e)&&Ln(t),Ln=e=>e.scaleType==="discrete"||e.scaleType==="palette",ar=e=>e==="both"?["x","y"]:[e],oo=e=>e==="both"?"the":`${e} axis`;function ir(e,t){return pe(e)?e[t]:e}function Kg(e,t){return e.config.axes[t]??{}}function zg(e,t,r){if(t!=="ySecondary")return d.updateSpec(e,{config:{axes:{[t]:r}}});const n=e.config.axes.ySecondary,a=so(n,r);if(a===n)return e;const i={...e.config.axes,ySecondary:a};return a===void 0&&delete i.ySecondary,d.patchSpec(e,{config:d.patchSpec(e.config,{axes:i})})}function pe(e){return l.isPlainObject(e)&&"x"in e&&"y"in e}function so(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)?so(l.isPlainObject(e)?e:void 0,t):t}var lo=class co{constructor(t,r={}){this.type="set-axis-label",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis label to ${Wg(t.label)}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,label:n}=this.params,a=Kg(t,r).label;if(a===n)return null;const i=zg(t,r,{label:n});return i===t?null:{spec:i,revert:new co(r==="ySecondary"?{axis:r,label:a}:{axis:r,label:a??null},this.metadata)}}},Ug={type:"set-axis-label",deserialize:(e,t)=>new lo(e,t)};function Wg(e){return e===void 0?"(inherited)":e??"(none)"}var uo=class mo{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:d.updateSpec(t,{config:{axes:{[r]:{position:n}}}}),revert:new mo({axis:r,position:a},this.metadata)}}},Xg={type:"set-axis-position",deserialize:(e,t)=>new uo(e,t)},ho=class po{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:d.updateSpec(t,{config:{axes:{[r]:{ticks:{mode:n}}}}}),revert:new po({axis:r,tickMode:a},this.metadata)}}},qg={type:"set-axis-tick-mode",deserialize:(e,t)=>new ho(e,t)},fo=class go{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:d.updateSpec(t,{config:{axes:{[r]:{ticks:{isVisible:n}}}}}),revert:new go({axis:r,isVisible:a},this.metadata)}}},jg={type:"set-axis-ticks-visibility",deserialize:(e,t)=>new fo(e,t)},vo=class yo{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:d.updateSpec(t,{config:{axes:{[r]:{isVisible:n}}}}),revert:new yo({axis:r,isVisible:a},this.metadata)}}},Zg={type:"set-axis-visibility",deserialize:(e,t)=>new vo(e,t)},So=class bo{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:d.updateSpec(t,{config:{content:{caption:this.params.caption}}}),revert:new bo({caption:r},this.metadata)}}},Jg={type:"set-content-caption",deserialize:(e,t)=>new So(e,t)},xo=class Ao{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(ee(r,this.params.source))return null;const n=d.patchSpec(t.config.content,{source:this.params.source});return{spec:d.patchSpec(t,{config:d.patchSpec(t.config,{content:n})}),revert:new Ao({source:r},this.metadata)}}},Qg={type:"set-content-source",deserialize:(e,t)=>new xo(e,t)},Io=class To{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:d.updateSpec(t,{config:{content:{subtitle:this.params.subtitle}}}),revert:new To({subtitle:r},this.metadata)}}},ev={type:"set-content-subtitle",deserialize:(e,t)=>new Io(e,t)},Lo=class Eo{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:d.updateSpec(t,{config:{content:{title:this.params.title}}}),revert:new Eo({title:r},this.metadata)}}},tv={type:"set-content-title",deserialize:(e,t)=>new Lo(e,t)},Ro=(e,t,r,n)=>{const a=rv(t,r),i=av(e,a,n);let o=e,s=!1;for(const c of a){const u=ov(o,c,n,iv(c,n,nv(r,c)));u!==null&&(o=u,s=!0)}return s?{spec:o,previous:i}:null},rv=(e,t)=>e==="both"&&!pe(t)?[void 0]:ar(e),nv=(e,t)=>t===void 0?pe(e)?e.x:e:ir(e,t),av=(e,t,r)=>t.length===1?rt(e,t[0],r):{x:rt(e,"x",r),y:rt(e,"y",r)},rt=(e,t,r)=>wo(e,t)?.[r]??null,iv=(e,t,r)=>r===null||t==="strokeWidth"?r:(e===void 0?["x","y"]:[e]).every(n=>Co(l.STYLE_TARGETS.gridLine.children[n].rest[t],r))?null:r,Co=(e,t)=>Array.isArray(e)&&Array.isArray(t)?kt(e,t):e===t,ov=(e,t,r,n)=>{const a=wo(e,t);return Co(a?.[r]??null,n)?null:new F({list:"overrides",rule:uv(t,cv(a,r,n))}).apply(e)?.spec??null},sv=e=>e.select.target==="gridLine",lv=e=>({select:e===void 0?{target:"gridLine"}:{target:"gridLine",axis:e}}),wo=(e,t)=>{const r=d.findStyleRule(e.styles.overrides,lv(t),d.readStyleCoord(e));if(!(r===void 0||!sv(r)))return r.declarations},cv=(e,t,r)=>{const{[t]:n,...a}=e??{};return r!==null?{...a,[t]:r}:Object.keys(a).length===0?null:a},En=(e,t)=>e===void 0?b.style.gridLine(t):e==="x"?b.style.gridLine.x(t):b.style.gridLine.y(t),uv=(e,t)=>t===null?{...En(e,{}),declarations:null}:En(e,t),Po=class Mo{constructor(t,r={}){this.type="set-grid-line-style",this.params=t,this.metadata=y({...r,description:`Set ${oo(t.axis)} grid line style to ${mv(t)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineStyle:n}=this.params,a=Ro(t,r,Rn(n,hv),"dashArray");return a===null?null:{spec:a.spec,revert:new Mo({axis:r,lineStyle:Rn(a.previous,pv)},this.metadata)}}},dv={type:"set-grid-line-style",deserialize:(e,t)=>new Po(e,t)},mv=({axis:e,lineStyle:t})=>{const r=ar(e).map(n=>ir(t,n)??"(theme)");return[...new Set(r)].join(" and ")},hv=e=>e===null?null:l.DASH_PRESETS.gridLine[e],pv=e=>e===null?null:_t(e),Rn=(e,t)=>pe(e)?{x:t(e.x),y:t(e.y)}:t(e),fv={type:"set-grid-line-width",deserialize:(e,t)=>new Do(e,t)},Do=class Oo{constructor(t,r={}){this.type="set-grid-line-width";const n=gv(t.lineWidth);this.params={...t,lineWidth:n},this.metadata=y({...r,description:`Set ${oo(t.axis)} grid line width to ${vv(t.axis,n)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineWidth:n}=this.params,a=Ro(t,r,n,"strokeWidth");return a===null?null:{spec:a.spec,revert:new Oo({axis:r,lineWidth:a.previous},this.metadata)}}},gv=e=>pe(e)?{x:nt(e.x),y:nt(e.y)}:nt(e),nt=e=>e===null||!Number.isFinite(e)?null:Math.max(0,e),vv=(e,t)=>{const r=ar(e).map(n=>ir(t,n)??"(theme)");return[...new Set(r)].join(" and ")},_o=class ko{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:d.updateSpec(t,{config:{axes:{[r]:{grid:{isVisible:n}}}}}),revert:new ko({axis:r,isVisible:a},this.metadata)}}},yv={type:"set-grid-visibility",deserialize:(e,t)=>new _o(e,t)},Vo=class No{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:d.updateSpec(t,{config:{headline:{compareWith:this.params.compareWith}}}),revert:new No({compareWith:r},this.metadata)}}},Sv={type:"set-headline-compare-with",deserialize:(e,t)=>new Vo(e,t)},Fo=class Bo{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:d.updateSpec(t,{config:{headline:{position:this.params.position}}}),revert:new Bo({position:r},this.metadata)}}},bv={type:"set-headline-position",deserialize:(e,t)=>new Fo(e,t)},Go=class Ho{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:d.updateSpec(t,{config:{headline:{show:this.params.show}}}),revert:new Ho({show:r},this.metadata)}}},xv={type:"set-headline-show",deserialize:(e,t)=>new Go(e,t)},$o=class Ko{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:d.updateSpec(t,{config:{headline:{size:this.params.size}}}),revert:new Ko({size:r},this.metadata)}}},Av={type:"set-headline-size",deserialize:(e,t)=>new $o(e,t)},Iv={type:"set-highlight-dim-style",deserialize:(e,t)=>new zo(e,t)},zo=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){return Yo(e)===this.params.dimStyle?null:new F({list:"overrides",rule:Lv(this.params.dimStyle,Tv(e))},this.metadata).apply(e)}},gt={select:{target:"geom"},when:{state:"dimmed"}},Yo=e=>d.combineStyleDeclarations(e.styles.overrides,gt,d.readStyleCoord(e))?.saturation===0?"desaturate":"dim",Tv=e=>{const t=d.readStyleCoord(e);return d.combineStyleDeclarations(d.readStyleRulesBeneath(e.styles.overrides,gt,t),gt,t)?.saturation===0},Lv=(e,t)=>e==="desaturate"?b.style.geom({saturation:0,alpha:.6},{state:"dimmed"}):b.style.geom({alpha:l.DEFAULT_DIMMED_ALPHA,...t?{saturation:1}:{}},{state:"dimmed"}),Uo=class Wo{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:d.updateSpec(t,{config:{legend:{align:this.params.align}}}),revert:new Wo({align:r},this.metadata)}}},Ev={type:"set-legend-align",deserialize:(e,t)=>new Uo(e,t)},Xo=class qo{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:d.updateSpec(t,{config:{legend:{display:this.params.display}}}),revert:new qo({display:r},this.metadata)}}},Rv={type:"set-legend-display",deserialize:(e,t)=>new Xo(e,t)},jo=class Zo{constructor(t,r={}){this.type="set-legend-placement",this.target={kind:"legend"},this.params=t,this.metadata=y({...r,description:`Set legend placement to ${t.position}, ${t.align}`})}apply(t){const{position:r,align:n}=t.config.legend;return r===this.params.position&&n===this.params.align?null:{spec:d.updateSpec(t,{config:{legend:{position:this.params.position,align:this.params.align}}}),revert:new Zo({position:r,align:n},this.metadata)}}},Cv={type:"set-legend-placement",deserialize:(e,t)=>new jo(e,t)},Jo=class Qo{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:d.updateSpec(t,{config:{legend:{position:this.params.position}}}),revert:new Qo({position:r},this.metadata)}}},wv={type:"set-legend-position",deserialize:(e,t)=>new Jo(e,t)},es=class ts{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:d.updateSpec(t,{config:{numberFormat:{abbreviation:this.params.abbreviation}}}),revert:new ts({abbreviation:r},this.metadata)}}},Pv={type:"set-number-format-abbreviation",deserialize:(e,t)=>new es(e,t)},rs=class ns{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:d.updateSpec(t,{config:{numberFormat:{decimals:this.params.decimals}}}),revert:new ns({decimals:r},this.metadata)}}},Mv={type:"set-number-format-decimals",deserialize:(e,t)=>new rs(e,t)},as=class is{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=Ov(r);if(!a)return null;const i=t.config.content[a];return i===n?null:{spec:d.updateSpec(t,{config:{content:{[a]:n}}}),revert:new is({part:r,isVisible:i},this.metadata)}}},Dv={type:"toggle-content-visibility",deserialize:(e,t)=>new as(e,t)},Cn={title:"isTitleVisible",subtitle:"isSubtitleVisible",caption:"isCaptionVisible",source:"isSourceVisible"};function Ov(e){return Object.hasOwn(Cn,e)?Cn[e]:void 0}var os=class ss{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(ee(i.xLimits,a.xLimits)&&ee(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 ss(o,this.metadata);return{spec:d.patchSpec(t,{coords:kv(t.coords,i)}),revert:s}}},_v={type:"set-coord-limits",deserialize:(e,t)=>new os(e,t)};function kv(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 ls=class cs{constructor(t,r={}){this.type="set-polar-inner-radius",this.target={kind:"coords"},this.params={innerRadius:(0,ie.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:d.patchSpec(t,{coords:{...r,params:{...r.params,innerRadius:this.params.innerRadius}}}),revert:new cs({innerRadius:n},this.metadata)}}},Vv={type:"set-polar-inner-radius",deserialize:(e,t)=>new ls(e,t)},Nv={type:"set-polar-start-angle",deserialize:(e,t)=>new us(e,t)},us=class ds{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:d.patchSpec(t,{coords:{...r,params:{...r.params,startAngle:this.params.startAngle}}}),revert:new ds({startAngle:n},this.metadata)}}},at=360,wn=e=>(e%at+at)%at,or=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 sr({predicate:t.predicate,id:t.id,scope:t.scope,layerId:t.layerId,index:r},this.metadata);return{spec:d.patchSpec(e,{highlights:n}),revert:a}}},Fv={type:"remove-highlight",deserialize:(e,t)=>new or(e,t)},sr=class{constructor(e,t={}){this.type="add-highlight",this.params={...e,id:e.id??d.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(m=>m.id===r))return null;const o=new or({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:d.patchSpec(e,{highlights:[...e.highlights.slice(0,u),s,...e.highlights.slice(u)]}),revert:o}}},Bv={type:"add-highlight",deserialize:(e,t)=>new sr(e,t)};function lr(e,t){return{...e,params:{...e.params,...t}}}function Ye(e,t){return{...e,dataLabels:{...e.dataLabels,...t}}}function cr(e,t){return d.patchSpec(e,{layers:[...e.layers,t]})}function M(e,t,r){const n=e.layers.findIndex(a=>a.id===t);return n===-1?e:d.patchSpec(e,{layers:d.replaceAtIndex(e.layers,n,r)})}function Ue(e,t){const r=e.layers.findIndex(n=>n.id===t);return r===-1||e.layers.length<=1?e:d.patchSpec(e,{layers:e.layers.filter((n,a)=>a!==r)})}var ur=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=Ue(e,this.params.layerId);return n===e?null:{spec:n,revert:new dr({layer:r,index:t},this.metadata)}}},Gv={type:"remove-layer",deserialize:(e,t)=>new ur(e,t)},dr=class{constructor(e,t={}){this.type="add-layer",this.params={layer:{...e.layer,id:e.layer.id??d.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:d.patchSpec(e,{layers:[...e.layers.slice(0,a),t,...e.layers.slice(a)]}),revert:new ur({layerId:t.id},this.metadata)}}},Hv={type:"add-layer",deserialize:(e,t)=>new dr(e,t)},ms=class hs{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(!d.isLayerSpecOf(d.findLayerById(t.layers,r),"bar"))return null;const a=d.buildLayerStyleAddress("bar",r),i=d.findKindStyleDeclarations(t.styles.overrides,a,d.readStyleCoord(t)),o=i?.cornerRadius??null;if(o===n)return null;const s=new F({list:"overrides",rule:{...a,declarations:Kv(i,n)}}).apply(t);if(!s)return null;const c=new hs({layerId:r,cornerRadius:o},this.metadata);return{spec:s.spec,revert:c}}},$v={type:"set-bar-corner-radius",deserialize:(e,t)=>new ms(e,t)},Kv=(e,t)=>{const{cornerRadius:r,...n}=e??{};return t!==null?{...n,cornerRadius:t}:Object.keys(n).length===0?null:n},zv={type:"set-bar-width",deserialize:(e,t)=>new fs(e,t)},ps=.05,Yv=1,fs=class gs{constructor(t,r={}){this.type="set-bar-width";const n=t.width===void 0?void 0:(0,ie.default)(t.width,ps,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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"bar");if(!d.isLayerSpecOf(r,"bar"))return null;const n=r.params.width;return n===this.params.width?null:{spec:M(t,r.id,lr(r,{width:this.params.width})),revert:new gs({layerId:r.id,width:n},this.metadata)}}},vs=class ys{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?d.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:M(t,r.id,Ye(r,{format:this.params.format})),revert:new ys({layerId:r.id,format:n},this.metadata)}}},Uv={type:"set-data-labels-format",deserialize:(e,t)=>new vs(e,t)},Ss=class bs{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"bar","area");if(!r)return null;const n=r.position;return n===this.params.position?null:{spec:M(t,r.id,{...r,position:this.params.position}),revert:new bs({layerId:r.id,position:n},this.metadata)}}},Wv={type:"set-layer-position",deserialize:(e,t)=>new Ss(e,t)},xs=class As{constructor(t,r={}){this.type="set-layer-stat";const n=d.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?d.findLayerById(t.layers,this.params.layerId):t.layers[0];if(!r)return null;const n=r.stat;return qv(n,this.params.stat)?null:{spec:M(t,r.id,{...r,stat:this.params.stat}),revert:new As({layerId:r.id,stat:n},this.metadata)}}},Xv={type:"set-layer-stat",deserialize:(e,t)=>new xs(e,t)},qv=(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},Is=class Ts{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?d.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=M(t,r.id,{...r,yScaleType:this.params.yScaleType});return{spec:d.patchSpec(a,{scales:this.params.previousScales===void 0?rr(a.scales,a.layers):this.params.previousScales}),revert:new Ts({layerId:r.id,yScaleType:n,previousScales:t.scales},this.metadata)}}},jv={type:"set-layer-y-scale-type",deserialize:(e,t)=>new Is(e,t)},Ls=class Es{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"line","area");if(!d.isLayerSpecOf(r,"line","area"))return null;const n=r.params.curve;return n===this.params.curve?null:{spec:M(t,r.id,lr(r,{curve:this.params.curve})),revert:new Es({layerId:r.id,curve:n},this.metadata)}}},Zv={type:"set-line-curve",deserialize:(e,t)=>new Ls(e,t)},Rs=class Cs{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"line","area");if(!d.isLayerSpecOf(r,"line","area"))return null;const n=r.params.missingValues;return n===this.params.missingValues?null:{spec:M(t,r.id,lr(r,{missingValues:this.params.missingValues})),revert:new Cs({layerId:r.id,missingValues:n},this.metadata)}}},Jv={type:"set-line-missing-values",deserialize:(e,t)=>new Rs(e,t)},ws=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=d.findLayerById(t.layers,r);if(!d.isLayerSpecOf(a,"line","area"))return null;const i=d.findKindStyleDeclarations(t.styles.overrides,d.buildLayerStyleAddress(a.geom,r),d.readStyleCoord(t)),o=i?.strokeWidth??null;if(o===n)return null;const s=ey(i,n),c=new F({list:"overrides",rule:a.geom==="area"?{...d.buildLayerStyleAddress("area",r),declarations:s}:{...d.buildLayerStyleAddress("line",r),declarations:s}}).apply(t);return c?{spec:c.spec,revert:new Ps({layerId:r,lineWidth:o},this.metadata)}:null}},Qv={type:"set-line-width",deserialize:(e,t)=>new ws(e,t)},ey=(e,t)=>{const{strokeWidth:r,...n}=e??{};return t!==null?{...n,strokeWidth:t}:Object.keys(n).length===0?null:n},Ms=class Ds{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(!d.isLayerSpecOf(d.findLayerById(t.layers,r),"point"))return null;const a=d.buildLayerStyleAddress("point",r),i=d.findKindStyleDeclarations(t.styles.overrides,a,d.readStyleCoord(t)),o=i?.size??null;if(o===n)return null;const s=new F({list:"overrides",rule:{...a,declarations:ry(i,n)}}).apply(t);return s?{spec:s.spec,revert:new Ds({layerId:r,size:o},this.metadata)}:null}},ty={type:"set-point-size",deserialize:(e,t)=>new Ms(e,t)},ry=(e,t)=>{const{size:r,...n}=e??{};return t!==null?{...n,size:t}:Object.keys(n).length===0?null:n},Os=class _s{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"rule");if(!d.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:M(t,r.id,{...r,params:i}),revert:new _s({layerId:r.id,label:n??null},this.metadata)}}},ny={type:"set-rule-label",deserialize:(e,t)=>new Os(e,t)},ks=class Vs{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"rule");if(!d.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:M(t,r.id,{...r,mapping:i}),revert:new Vs({layerId:r.id,value:a},this.metadata)}}},ay={type:"set-rule-value",deserialize:(e,t)=>new ks(e,t)},iy={type:"set-stat-line",deserialize:(e,t)=>new Ns(e,t)},Ns=class Fs{constructor(t,r={}){this.type="set-stat-line",this.params=t,this.metadata=y({...r,description:my(t.line)})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=sy(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&&dy(r.layer,n))return null;const a=new Fs({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:M(t,r.layer.id,n),revert:a};const i=r===void 0?t:Ue(t,r.layer.id);return n===null&&i===t?null:{spec:n===null?i:cr(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"?ly(this.params):cy(t,this.params);if(n===null)return null;const a=d.resolveLayer(w,t.mapping,t.coords.coordType,n);return r===void 0?a:{...a,id:r}}},oy="linear",sy=e=>{const t=xi(e.layers);if(t!==void 0)return{line:"trend",layer:t};const r=Ai(e.layers);if(r!==void 0)return{line:"average",layer:r}},ly=({method:e})=>l.geom.line({aes:{lineType:{value:"dashed"}},stat:b.stat.smooth({method:e??oy}),interactive:!1}),cy=(e,{group:t,label:r})=>{const n=uy(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})},uy=e=>e.layers.find(t=>t.geom!=="rule"&&t.stat.type!=="smooth"),dy=(e,t)=>(0,bt.isEqual)({...e,id:""},{...t,id:""}),my=e=>e==="none"?"Hide stat line":`Show ${e} line`,Bs=class Gs{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?d.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:M(t,r.id,Ye(r,{showCategoryLabels:this.params.showCategoryLabels})),revert:new Gs({layerId:r.id,showCategoryLabels:n},this.metadata)}}},hy={type:"toggle-category-labels",deserialize:(e,t)=>new Bs(e,t)},Hs=class $s{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?d.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:M(t,r.id,Ye(r,{showDataLabels:this.params.showDataLabels})),revert:new $s({layerId:r.id,showDataLabels:n},this.metadata)}}},py={type:"toggle-data-labels",deserialize:(e,t)=>new Hs(e,t)},fy={type:"toggle-goal-line",deserialize:(e,t)=>new Ks(e,t)},Ks=class vt{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=bi(t.layers);if(!this.params.showGoalLine){if(r===void 0)return null;const a=Ue(t,r.id);return a===t?null:{spec:a,revert:new vt({showGoalLine:!0,removedLayer:r},this.metadata)}}if(r!==void 0)return null;const n=this.params.removedLayer??this.buildGoalLine(t);return{spec:cr(t,n),revert:new vt({showGoalLine:!1,layerId:n.id},this.metadata)}}buildGoalLine(t){const r=t.coords.coordType==="flip"?"end":"start";return d.resolveLayer(w,t.mapping,t.coords.coordType,l.geom.rule({aes:{y:{value:this.params.value??gy}},params:{labelPosition:r,...this.params.label!==void 0&&{label:this.params.label}},interactive:!1}))}},gy=0,vy={type:"toggle-line-fill",deserialize:(e,t)=>new zs(e,t)},zs=class{constructor(e,t={}){this.type="toggle-line-fill",this.params=e,this.metadata=y({...t,description:`Set line fill to ${e.showFill}`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(e){const{layerId:t,showFill:r,fillAlpha:n}=this.params;if(!d.isLayerSpecOf(d.findLayerById(e.layers,t),"line"))return null;const a=d.buildLayerStyleAddress("line",t),i=d.readStyleCoord(e),o=d.findKindStyleDeclarations(e.styles.overrides,a,i),s=d.combineKindStyleDeclarations(d.readStyleRulesBeneath(e.styles.overrides,a,i),a,i);if(Pn(o?.fillAlpha??s?.fillAlpha)===r)return null;const c=Sy(r,n,Pn(s?.fillAlpha));return new F({list:"overrides",rule:{...a,declarations:by(o,c)}},this.metadata).apply(e)}},yy=.2,Pn=e=>(e??0)>0,Sy=(e,t,r)=>e?t??(r?null:yy):r?0:null,by=(e,t)=>{const{fillAlpha:r,...n}=e??{};return t!==null?{...n,fillAlpha:t}:Object.keys(n).length===0?null:n},xy={type:"toggle-line-points",deserialize:(e,t)=>new Ys(e,t)},Ys=class yt{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?d.findLayerById(t.layers,this.params.layerId):d.findLayerByGeom(t.layers,"line","area");return d.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:cr(t,this.params.removedLayer??d.resolveLayer(w,t.mapping,t.coords.coordType,l.geom.point({aes:{...r.mapping},position:r.position,yScaleType:r.yScaleType,transforms:[...r.transforms],interactive:!1}))),revert:new yt({layerId:r.id,showPoints:!1},this.metadata)}}removePointLayer(t,r){const n=this.findAssociatedPointLayer(t,r);return n?{spec:Ue(t,n.id),revert:new yt({layerId:r.id,showPoints:!0,removedLayer:n},this.metadata)}:null}findAssociatedPointLayer(t,r){return t.layers.find(n=>n.geom!=="point"?!1:d.isCompanionLayer(n,[r]))}},Us=class Ws{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?d.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:M(t,r.id,Ye(r,{showStackTotals:this.params.showStackTotals})),revert:new Ws({layerId:r.id,showStackTotals:n},this.metadata)}}},Ay={type:"toggle-stack-totals",deserialize:(e,t)=>new Us(e,t)},Xs=class qs{constructor(t,r={}){this.type="set-scale-domain",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} scale domain`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(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=$e(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 qs(c,this.metadata)}}},Iy={type:"set-scale-domain",deserialize:(e,t)=>new Xs(e,t)},js=class Zs{constructor(t,r={}){this.type="set-scale-palette",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} palette`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(t,this.params.scaledAesthetic);return r?.scaleType!=="palette"||ee(r.palette,this.params.palette)?null:{spec:$e(t,this.params.scaledAesthetic,{...r,scaledAesthetic:this.params.scaledAesthetic,palette:this.params.palette}),revert:new Zs({scaledAesthetic:this.params.scaledAesthetic,palette:r.palette},this.metadata)}}},Ty={type:"set-scale-palette",deserialize:(e,t)=>new js(e,t)},Js=class Qs{constructor(t,r={}){this.type="set-scale-reverse",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} scale reverse to ${t.reverse}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(t,this.params.scaledAesthetic);if(!r||!Ey(r))return null;const n=r.reverse;return n===this.params.reverse?null:{spec:$e(t,this.params.scaledAesthetic,{...r,reverse:this.params.reverse}),revert:new Qs({scaledAesthetic:this.params.scaledAesthetic,reverse:n},this.metadata)}}},Ly={type:"set-scale-reverse",deserialize:(e,t)=>new Js(e,t)};function Ey(e){return e.scaleType==="continuous"||e.scaleType==="datetime"||e.scaleType==="discrete"}var el=class tl{constructor(t,r={}){this.type="set-scale-transform",this.params=t,this.metadata=y({...r,description:`Set ${Ke(t.scaledAesthetic)} scale transform to ${t.transform}`})}get target(){return{kind:"scale",aesthetic:this.params.scaledAesthetic}}apply(t){const r=He(t,this.params.scaledAesthetic);if(!r||r.scaleType!=="continuous")return null;const n=r.transform;return n===this.params.transform?null:{spec:$e(t,this.params.scaledAesthetic,{...r,transform:this.params.transform}),revert:new tl({scaledAesthetic:this.params.scaledAesthetic,transform:n},this.metadata)}}},Ry={type:"set-scale-transform",deserialize:(e,t)=>new el(e,t)},Cy=e=>{if(!(Array.isArray(e.commands)&&e.commands.length>0))throw new l.UserInputError({code:"INVALID_SEQUENCE",message:"Command 'sequence' needs at least one command.",suggestion:"Send 'commands' as a list with one or more commands."})},mr=class rl{constructor(t,r={}){this.type="sequence";const n=[...t.commands],[a]=n;if(!a)throw new l.InternalError({message:"SequenceCommand needs at least one command"});this.commands=n,this.target=a.target,this.params={commands:n.map(i=>({type:i.type,params:i.params,metadata:i.metadata}))},this.metadata=y({...r,description:a.metadata.description})}apply(t){let r=t;const n=[];for(const a of this.commands){const i=a.apply(r);i&&(r=i.spec,n.push(i.revert))}return n.length===0||(0,W.default)(r,t)?null:{spec:r,revert:new rl({commands:n.reverse()},this.metadata)}}},nl=class{constructor(e,t={}){this.type="set-observations-color",this.params=e,this.metadata=y({...t,description:e.color===null?"Remove colour":"Set colour"})}get target(){return this.params.target}apply(e){const t=Ia(e,this.params.target);if(t===null)return null;const r=[];let n=e;const a=o=>{for(const s of o){const c=s.apply(n);c&&(n=c.spec,r.push(c.revert))}};if(this.params.color!==null)for(const o of t)for(const s of My(n,o))a(Py(n,s,o.property));for(const o of t)a(Oy(n,o,this.params.color));if(r.length===0||(0,W.default)(n,e))return null;const[i]=r;return r.length===1&&i!==void 0?{spec:n,revert:i}:{spec:n,revert:new mr({commands:[...r].reverse()},this.metadata)}}},wy={type:"set-observations-color",deserialize:(e,t)=>new nl(e,t)},Py=(e,t,r)=>{const n=t[t.length-1];if(n===void 0||!t.some(o=>Dy(o.declarations,r)))return[];const a=il(al(t),r,null);if(t.length===1)return a!==null&&d.areStyleDeclarationsEqual(a,n.declarations)?[]:[$(n,a)];const i=[$(n,null)];if(a!==null){const o=d.findStyleRuleIndex(e.styles.overrides,n,d.readStyleCoord(e));i.push($(n,a,o-(t.length-1)))}return i},My=(e,t)=>{const r=[],n=new Map;for(const a of e.styles.overrides){if(a.when?.state!==void 0||!ky(a,t)||!Vy(a.when?.where,t.where))continue;const i=d.readStyleRuleAddressKey(a),o=n.get(i);if(o===void 0){n.set(i,r.length),r.push([a]);continue}r[o]?.push(a)}return r},al=e=>e.reduce((t,r)=>({...t,...r.declarations}),{}),Dy=(e,t)=>Object.entries(e).some(([r])=>r===t),Oy=(e,t,r)=>{const n=e.styles.overrides,a=_y(t),i=n.filter(h=>d.areStyleRuleAddressesEqual(h,a)),o=d.findStyleRuleIndex(n,a,d.readStyleCoord(e)),s=o===-1?void 0:n[o],c=il(i.length===0?{}:al(i),t.property,r);if(s===void 0)return c===null?[]:[$(a,c)];if(!d.isGeomStyleRule(s))return[];if(c===null)return[$(s,null)];const u=o===n.length-1;if(u&&i.length===1&&d.areStyleDeclarationsEqual(s.declarations,c))return[];if(u&&i.length===1)return[$(s,c)];const m=u?o-(i.length-1):void 0;return[$(s,null),$(s,c,m)]},$=(e,t,r)=>new F({list:"overrides",rule:{...e,declarations:t},...r===void 0?{}:{index:r}}),_y=e=>({select:{target:"geom",kind:e.geomKind,layer:e.layerId},...e.where===void 0?{}:{when:{where:e.where}}}),ky=(e,t)=>d.isGeomStyleRule(e)&&e.select.kind===t.geomKind&&e.select.layer===t.layerId&&e.select.part===void 0,Vy=(e,t)=>{const r=Mn(e);if(r===null)return!1;const n=t===void 0?[]:Mn(t);return n===null?!1:n.every(a=>r.some(i=>i.variable===a.variable&&(0,W.default)(i.eq,a.eq)))&&r.length>n.length},Mn=e=>{if(e===void 0)return null;if("eq"in e)return[{variable:e.variable,eq:e.eq}];if(!("and"in e))return null;const t=[];for(const r of e.and){if(!("eq"in r))return null;t.push({variable:r.variable,eq:r.eq})}return t},il=(e,t,r)=>{const n={...e,...r===null?{}:{[t]:r}};return r===null&&t==="fill"&&delete n.fill,r===null&&t==="stroke"&&delete n.stroke,Object.keys(n).length===0?null:n},ol=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 ol;v.register(Kf);v.register(Dg);v.register(Hv);v.register(Gv);v.register(Uv);v.register(Wv);v.register(Xv);v.register(jv);v.register(Zv);v.register(Qv);v.register($v);v.register(zv);v.register(ty);v.register(Jv);v.register(ny);v.register(ay);v.register(iy);v.register(hy);v.register(py);v.register(fy);v.register(vy);v.register(xy);v.register(Ay);v.register(Iy);v.register(Ty);v.register(Ly);v.register(Ry);v.register(Ug);v.register(qg);v.register(Xg);v.register(jg);v.register(Zg);v.register(Jg);v.register(Qg);v.register(ev);v.register(tv);v.register(dv);v.register(fv);v.register(yv);v.register(Sv);v.register(bv);v.register(xv);v.register(Av);v.register(Iv);v.register(Ev);v.register(Rv);v.register(Cv);v.register(wv);v.register(Pv);v.register(Mv);v.register(Dv);v.register(Bv);v.register(Fv);v.register(Gf);v.register(wy);v.register(Rf);v.register(Ef);v.register(Nf);v.register(Hf);v.register(Ff);v.register(_v);v.register(Vv);v.register(Nv);v.register({type:"sequence",deserialize:(e,t)=>(Cy(e),new mr({commands:e.commands.map(r=>v.deserialize(r))},t))});var sl=(e,t)=>e===t?!0:e===null||t===null?!1:St(e)===St(t),St=e=>{switch(e.kind){case"annotation":case"highlight":return JSON.stringify([e.kind,e.id]);case"styleRule":return JSON.stringify([e.kind,e.list,d.readStyleRuleAddressKey(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,d.readPredicateKey(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}`})}},ll=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,m)=>r?m: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:Dn(this.undoStack),redoStack:Dn(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&&Fy(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)}}},Ny=Object.freeze([]),Fy=(e,t)=>e.type===t.type&&sl(e.target,t.target),Dn=e=>e.length===0?Ny:e.map(t=>t.command.metadata),By=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}},Gy=class{constructor(e){this.compiler=e,this.history=new ll,this.current=null,this.last=null,this.hostSpec=null,this.run=new By(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,m=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&&m.ok&&this.history.clear(),{result:m,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=Ii(e,{themeConfig:this.compiler.theme?.config});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}},Hy=new Set(["x","y"]),On=["numeric","categorical","temporal"],_n=["numeric"],$y=(e,t)=>{const r=e.layers.map(a=>Di(a.geom)).filter(l.isDefined),n=ue(e);return t.filter(a=>Ky(e,r,a)).map(a=>({aesthetic:a,variables:zy(n,r,a),isRequired:Hy.has(a)}))},Ky=(e,t,r)=>{switch(r){case"x":return!Wy(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))}},zy=(e,t,r)=>{const n=Yy(t,r);return e.getVariableNames().filter(a=>!l.isInternalVariable(a)&&n.includes(e.getType(a)))},Yy=(e,t)=>t==="size"?_n:t!=="x"&&t!=="y"?On:Uy(e,t)?_n:On,Uy=(e,t)=>e.some(r=>r.positionRoles.some(n=>l.POSITION_NUMERIC_ROLES.has(n.role)&&n.aes===t&&!(n.role==="scalar"&&n.aes===n.axis))),Wy=e=>e.coordType==="polar"&&e.params.theta==="y",Xy=500,qy="normal",hr={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},jy=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}`},pr=e=>typeof e!="string"?e??500:hr[e],cl=(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}},ul=(e,t)=>t===void 0||t===0?0:t*[...e].length,Zy="\0",Jy=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,pr(t.weight),t.style??"normal",t.letterSpacing??0,t.textTransform??"none",e].join(Zy)}},Qy={" ":.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 eS=1.05,tS=.84,rS=.21,nS=class{measureText(e,t){const r=cl(e,t.textTransform);let n=ul(r,t.letterSpacing);for(const o of r)n+=(Qy[o]??.55)*t.size;pr(t.weight)>=hr.semiBold&&(n*=eS);const a=tS*t.size,i=rS*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=Mu;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=Qt;exports.AddHighlightCommand=sr;exports.AddLayerCommand=dr;exports.BAR_WIDTH_FRACTION=l.BAR_WIDTH_FRACTION;exports.BORDER_RADIUS_PX=Bt;exports.BORDER_RADIUS_TOKENS=l.BORDER_RADIUS_TOKENS;exports.BUILTIN_STYLES=d.BUILTIN_STYLES;exports.COLOR_INTERPOLATION_SPACES=d.COLOR_INTERPOLATION_SPACES;exports.COMBO_TYPES=b.COMBO_TYPES;exports.COMPILER_STAGE_KEYS=d.COMPILER_STAGE_KEYS;exports.CONSTANT_VARIABLES=l.CONSTANT_VARIABLES;exports.CachedTextMeasurer=Jy;exports.CommandRegistry=ol;exports.CommandStackManager=ll;exports.Compiler=d.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=qy;exports.DEFAULT_FONT_WEIGHT=Xy;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=d.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=Gy;exports.HEADING_PARTS=b.HEADING_PARTS;exports.HEADLINE_ITEM_PARTS=b.HEADLINE_ITEM_PARTS;exports.HEADLINE_SWATCH_GAP_EM=Ra;exports.HEADLINE_TREND_GAP_EM=wa;exports.HEADLINE_TREND_ICON_SIZE_PX=tm;exports.HEADLINE_VALUE_LABEL_GAP_EM=Ca;exports.HeuristicTextMeasurer=nS;exports.HoverEngine=Qh;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=iu;exports.MAX_BAR_WIDTH_FRACTION=Yv;exports.MIN_BAR_WIDTH_FRACTION=ps;exports.MONO_BASES=l.MONO_BASES;exports.MoveAnnotationCommand=wi;exports.NAMED_WEIGHTS=hr;exports.NEON_BASES=l.NEON_BASES;exports.OBSERVATION_ATTACHMENT_KINDS=jt;exports.OUT_OF_VIEW_MARGIN_PX=Du;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=H;exports.RemoveAnnotationCommand=Jt;exports.RemoveHighlightCommand=or;exports.RemoveLayerCommand=ur;exports.SCALED_POSITION_AESTHETIC_KEYS=l.SCALED_POSITION_AESTHETIC_KEYS;exports.SCALED_VISUAL_AESTHETIC_KEYS=l.SCALED_VISUAL_AESTHETIC_KEYS;exports.SCHEME_ALIASES=d.SCHEME_ALIASES;exports.SEQUENTIAL_SCHEME_NAMES=d.SEQUENTIAL_SCHEME_NAMES;exports.SHAPE_DEFAULTS=l.SHAPE_DEFAULTS;exports.SIBLING_OVERLAP_THRESHOLD_PX=Ou;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.SequenceCommand=mr;exports.SetAxisLabelCommand=lo;exports.SetAxisPositionCommand=uo;exports.SetAxisTickModeCommand=ho;exports.SetAxisTicksVisibilityCommand=fo;exports.SetAxisVisibilityCommand=vo;exports.SetBarCornerRadiusCommand=ms;exports.SetBarWidthCommand=fs;exports.SetChartTypeCommand=Oi;exports.SetContentCaptionCommand=So;exports.SetContentSourceCommand=xo;exports.SetContentSubtitleCommand=Io;exports.SetContentTitleCommand=Lo;exports.SetCoordLimitsCommand=os;exports.SetDataLabelsFormatCommand=vs;exports.SetDifferenceArrowStyleCommand=Pi;exports.SetGridLineStyleCommand=Po;exports.SetGridLineWidthCommand=Do;exports.SetGridVisibilityCommand=_o;exports.SetHeadlineCompareWithCommand=Vo;exports.SetHeadlinePositionCommand=Fo;exports.SetHeadlineShowCommand=Go;exports.SetHeadlineSizeCommand=$o;exports.SetHighlightDimStyleCommand=zo;exports.SetLayerPositionCommand=Ss;exports.SetLayerStatCommand=xs;exports.SetLayerYScaleTypeCommand=Is;exports.SetLegendAlignCommand=Uo;exports.SetLegendDisplayCommand=Xo;exports.SetLegendPlacementCommand=jo;exports.SetLegendPositionCommand=Jo;exports.SetLineCurveCommand=Ls;exports.SetLineMissingValuesCommand=Rs;exports.SetLineWidthCommand=ws;exports.SetMappingCommand=ro;exports.SetNumberFormatAbbreviationCommand=es;exports.SetNumberFormatDecimalsCommand=rs;exports.SetObservationsColorCommand=nl;exports.SetPointSizeCommand=Ms;exports.SetPolarInnerRadiusCommand=ls;exports.SetPolarStartAngleCommand=us;exports.SetRuleLabelCommand=Os;exports.SetRuleValueCommand=ks;exports.SetScaleDomainCommand=Xs;exports.SetScalePaletteCommand=js;exports.SetScaleReverseCommand=Js;exports.SetScaleTransformCommand=el;exports.SetStatLineCommand=Ns;exports.SetStyleRuleCommand=F;exports.SpecResolver=d.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=Bs;exports.ToggleContentVisibilityCommand=as;exports.ToggleDataLabelsCommand=Hs;exports.ToggleGoalLineCommand=Ks;exports.ToggleLineFillCommand=zs;exports.ToggleLinePointsCommand=Ys;exports.ToggleStackTotalsCommand=Us;exports.UNIT_POLAR_PATH_FRAME=Na;exports.UpdateAnnotationCommand=tr;exports.UserInputError=l.UserInputError;exports.VISUAL_VARIABLES=l.VISUAL_VARIABLES;exports.alignUnitFractions=l.alignUnitFractions;exports.annotation=l.annotation;exports.applyTextTransform=cl;exports.areAnchorsEqual=J;exports.areDashArraysEqual=kt;exports.areEditMenuTriggersEqual=pd;exports.areEditTargetsEqual=sl;exports.areEndpointsComparable=d.areEndpointsComparable;exports.areMappingsEquivalent=l.areMappingsEquivalent;exports.areObservationAnchorsEqual=yi;exports.arePointerRegionListsEqual=sd;exports.arePredicatesEqual=d.arePredicatesEqual;exports.areStyleDeclarationsEqual=d.areStyleDeclarationsEqual;exports.areStyleRuleAddressesEqual=d.areStyleRuleAddressesEqual;exports.buildAverageLineSymbols=Ru;exports.buildBarRectBounds=Ma;exports.buildCalloutHitRegions=Pu;exports.buildColumnKey=Da;exports.buildDataLabelsContent=$u;exports.buildDiagnostic=d.buildDiagnostic;exports.buildEditMenuTriggerRegion=md;exports.buildFontString=jy;exports.buildHeadlineItemRows=rm;exports.buildLayerIntroPlan=hp;exports.buildLayerStyleAddress=d.buildLayerStyleAddress;exports.buildObservationPredicate=Xu;exports.buildObservationsTarget=ya;exports.buildObservationsTargetAtValue=ed;exports.buildPanelAnchorBox=l.buildPanelAnchorBox;exports.buildPointSymbolInBox=ym;exports.buildPointSymbolPath=vm;exports.buildPolarBarArcPath=Lm;exports.buildSliceGroupKey=Fa;exports.buildTooltipContent=Fp;exports.canAnchorDirectLabels=d.canAnchorDirectLabels;exports.canBecomeCombo=jf;exports.canBecomeHeatmap=Zf;exports.canPlaceDataLabels=Hu;exports.clampAnnotationTranslation=wf;exports.combineKindStyleDeclarations=d.combineKindStyleDeclarations;exports.combineStyleDeclarations=d.combineStyleDeclarations;exports.commandRegistry=v;exports.compileChromeStyles=d.compileChromeStyles;exports.composePoint=d.composePoint;exports.compositeColor=l.compositeColor;exports.computeArrow=Tu;exports.computeDifferenceArrow=ta;exports.computeDirectLabelsLayout=Wu;exports.computeLetterSpacingWidth=ul;exports.computeLineBoxHeight=aa;exports.computePanelBorderPaths=Rp;exports.computePanelBorderSizes=Cp;exports.config=b.config;exports.coord=b.coord;exports.countLayerGeoms=pp;exports.createAlphaValueReader=d.createAlphaValueReader;exports.createAnchorResolver=lu;exports.createAreaPathGenerators=sm;exports.createColorValueReader=d.createColorValueReader;exports.createCompiler=d.createCompiler;exports.createDataLabelPlacementResolver=Jn;exports.createDatasetFromKindPartitions=d.createDatasetFromKindPartitions;exports.createEmptyLayerStyles=d.createEmptyLayerStyles;exports.createGroupValueReader=d.createGroupValueReader;exports.createLabelValueReader=d.createLabelValueReader;exports.createLayerYValueFormatter=Mt;exports.createLineFillAreaGenerator=pm;exports.createLinePathGenerator=hm;exports.createObservationAnchorBuilder=d.createObservationAnchorBuilder;exports.createObservationAnchorParser=d.createObservationAnchorParser;exports.createPinnedNumberValueFormatter=Kd;exports.createRawValueReader=d.createRawValueReader;exports.createSegmentYReader=d.createSegmentYReader;exports.createSizeValueReader=d.createSizeValueReader;exports.createSpec=b.createSpec;exports.createSpecBuilder=b.createSpecBuilder;exports.createStableBandKeyGenerator=Om;exports.createStableCellKeyGenerator=_m;exports.createStableKeyGenerator=Ne;exports.createStablePolarBarKeyGenerator=km;exports.createStrokeWidthValueReader=d.createStrokeWidthValueReader;exports.createStyleResolver=df;exports.createStyleRuleMatcher=d.createStyleRuleMatcher;exports.createValueFormatter=I;exports.createXValueReader=d.createXValueReader;exports.createYValueReader=d.createYValueReader;exports.cursorToPiePlane=l.cursorToPiePlane;exports.cursorToPolar=l.cursorToPolar;exports.defineGeomStyleTarget=l.defineGeomStyleTarget;exports.describeMeasurementBasis=d.describeMeasurementBasis;exports.ensureReadableTextColor=l.ensureReadableTextColor;exports.extractPlainText=ha;exports.filterLayersByGeoms=d.filterLayersByGeoms;exports.findAnnotation=d.findAnnotation;exports.findAverageLineLayer=Ai;exports.findAxisGuide=Ft;exports.findCompanionLayers=d.findCompanionLayers;exports.findDefaultKitStyleTarget=d.findDefaultKitStyleTarget;exports.findDistinctLayers=d.findDistinctLayers;exports.findEquivalentHighlight=bf;exports.findGoalLineLayer=bi;exports.findHighlightsAtObservation=gd;exports.findHostLayer=d.findHostLayer;exports.findKindStyleDeclarations=d.findKindStyleDeclarations;exports.findLayerByGeom=d.findLayerByGeom;exports.findLayerById=d.findLayerById;exports.findLegendForAesthetic=Qd;exports.findObservationAttachment=Si;exports.findPointerRegion=id;exports.findStyleRule=d.findStyleRule;exports.findStyleRuleIndex=d.findStyleRuleIndex;exports.findTrendLineLayer=xi;exports.formatDifferenceLabel=Qn;exports.formatHeadline=zd;exports.formatLegends=Zd;exports.formatRuleValue=em;exports.geom=l.geom;exports.getAestheticFromScaleAestheticKey=l.getAestheticFromScaleAestheticKey;exports.getAlpha=l.getAlpha;exports.getAngleExtent=l.getAngleExtent;exports.getBarRectBounds=Pa;exports.getBoundingRect=dm;exports.getColor=l.getColor;exports.getCrossAxisCoordinate=d.getCrossAxisCoordinate;exports.getCurve=Ve;exports.getDifferenceArrowDimensions=ea;exports.getDifferenceArrowLabelBox=oa;exports.getGroup=d.getGroup;exports.getGroupVariables=l.getGroupVariables;exports.getHoverGuideLineProps=ap;exports.getHoverGuideRectProps=ip;exports.getInsetTileRect=l.getInsetTileRect;exports.getLineType=l.getLineType;exports.getMainAxisCoordinate=d.getMainAxisCoordinate;exports.getNumericWeight=pr;exports.getPaintedTileRect=l.getPaintedTileRect;exports.getPointSymbolOuterRadius=Sm;exports.getPolarHoverGuideArcProps=op;exports.getRadiusExtent=l.getRadiusExtent;exports.getScaledAesthetic=l.getScaledAesthetic;exports.getShapeAnnotationStroke=af;exports.getSize=l.getSize;exports.getStackRole=l.getStackRole;exports.getStrokeWidth=l.getStrokeWidth;exports.getTileRectBounds=l.getTileRectBounds;exports.getUnionExtent=Tm;exports.getX=l.getX;exports.getXBand=l.getXBand;exports.getXMax=l.getXMax;exports.getXMin=l.getXMin;exports.getY=l.getY;exports.getYBand=l.getYBand;exports.getYMax=l.getYMax;exports.getYMin=l.getYMin;exports.getYRaw=l.getYRaw;exports.hasMainAxisBand=Aa;exports.hasMultipleGroups=l.hasMultipleGroups;exports.highlight=b.highlight;exports.inferDefaultDifferenceArrowEndpoints=Sd;exports.inferDifferenceArrowEndpoints=xa;exports.inferXVariable=l.inferXVariable;exports.isAnnotationMovable=Pf;exports.isBorderRadiusToken=l.isBorderRadiusToken;exports.isCartesian=d.isCartesian;exports.isCategoricalValueFormat=l.isCategoricalValueFormat;exports.isComboChartType=me;exports.isCompanionLayer=d.isCompanionLayer;exports.isCompilerCachingEnabled=l.isCompilerCachingEnabled;exports.isCurrencyValueFormat=l.isCurrencyValueFormat;exports.isDateWithoutYearValueFormat=l.isDateWithoutYearValueFormat;exports.isFullTurnSweep=l.isFullTurnSweep;exports.isGeomStyleRule=d.isGeomStyleRule;exports.isGradientPaint=l.isGradientPaint;exports.isImagePaint=l.isImagePaint;exports.isKeyedScope=ke;exports.isLayerOf=U;exports.isLayerSpecOf=d.isLayerSpecOf;exports.isLineType=l.isLineType;exports.isLookupValueFormat=l.isLookupValueFormat;exports.isNumericValueFormat=l.isNumericValueFormat;exports.isObservationAttachmentKind=vf;exports.isOpaquePaint=l.isOpaquePaint;exports.isPatternPaint=l.isPatternPaint;exports.isPointWithinEditMenuTrigger=hd;exports.isPointWithinRegionShape=Nt;exports.isPositionScale=l.isPositionScale;exports.isSafeUrl=kp;exports.isStackedPosition=l.isStackedPosition;exports.isTemporalValueFormat=l.isTemporalValueFormat;exports.isZeroAnchoredAxis=xd;exports.mapping=b.mapping;exports.measureObservationsBoxes=Id;exports.normalizeAngle=l.normalizeAngle;exports.orderPointerRegions=od;exports.paintKey=l.paintKey;exports.paintsEachGroupFromItsFirstObservation=d.paintsEachGroupFromItsFirstObservation;exports.paintsInDonutHole=_e;exports.pickFilters=ui;exports.pickReadableTextColor=l.pickReadableTextColor;exports.pipe=b.pipe;exports.placeCallouts=Fu;exports.polarToUnit=l.polarToUnit;exports.positionToAngle=l.positionToAngle;exports.prefixInternalVariable=l.prefixInternalVariable;exports.prepareAreaObservations=lm;exports.prepareLineObservations=fm;exports.projectAnchorToPanel=Re;exports.projectRegionToPanel=ua;exports.quantizeKey=k;exports.readAnchoredObservation=Ed;exports.readAttachedObservation=Zt;exports.readAuthoredNumber=Qp;exports.readAuthoredString=ef;exports.readBackdropColor=l.readBackdropColor;exports.readBroadestObservationsScope=Sa;exports.readChartType=qf;exports.readColorGroupObservation=Vm;exports.readComboLineLayerId=Jf;exports.readCompanionRowsAtScopeKey=Zu;exports.readConstantValue=l.readConstantValue;exports.readEditTargetKey=St;exports.readFoldKeepVariables=l.readFoldKeepVariables;exports.readGeomColor=$t;exports.readGeomEffects=Tp;exports.readHighlightDimStyle=Yo;exports.readMainAxis=d.readMainAxis;exports.readMainAxisVariable=l.readMainAxisVariable;exports.readMappableAesthetics=$y;exports.readMappedVariable=ao;exports.readObservationIndex=sp;exports.readObservationsColorRoute=Ia;exports.readReachableLevels=kd;exports.readRowScopeKey=va;exports.readRowsAtScopeKey=Vt;exports.readScopeXVariable=d.readScopeXVariable;exports.readStyleCoord=d.readStyleCoord;exports.readStyleRulesBeneath=d.readStyleRulesBeneath;exports.readVariableName=l.readVariableName;exports.readXExtent=li;exports.readYExtent=ci;exports.removeAlpha=l.removeAlpha;exports.resolveAnchorVariable=d.resolveAnchorVariable;exports.resolveAnchoredLabelCenter=l.resolveAnchoredLabelCenter;exports.resolveArrowAnnotationStyle=tf;exports.resolveArrowColor=Yu;exports.resolveBarBandFraction=l.resolveBarBandFraction;exports.resolveBarBaseline=Ht;exports.resolveBarBorderTreatment=um;exports.resolveBarCornerRadiiPx=cm;exports.resolveBarCornerRadiusPx=Gt;exports.resolveBarPaintOrigin=mm;exports.resolveCalloutAnnotationStyle=nf;exports.resolveChromeMargin=C;exports.resolveChromeMargins=lf;exports.resolveColorRamp=d.resolveColorRamp;exports.resolveComparisonBasis=d.resolveComparisonBasis;exports.resolveDataLabelStyle=Rc;exports.resolveDeferredAnchors=pu;exports.resolveDefinition=l.resolveDefinition;exports.resolveDifferenceArrowAnnotationStyle=rf;exports.resolveDirectLabelStyle=Mc;exports.resolveEditOutlineStyle=cf;exports.resolveGeomAnchorSpace=d.resolveGeomAnchorSpace;exports.resolveGraphPadding=sf;exports.resolveHeadlineItemStyle=Dc;exports.resolveHeadlineNumberStyle=Oc;exports.resolveHeadlinePlacement=Qc;exports.resolveLegendItemStyle=Pc;exports.resolveObservationPoint=Gd;exports.resolveObservationsTarget=Ta;exports.resolvePanelBorderStyle=of;exports.resolvePolarBarCornerRadiusUnit=Im;exports.resolveRuleLabelStyle=Cc;exports.resolveSegmentYSource=d.resolveSegmentYSource;exports.resolveSwatchGeomPaint=zt;exports.resolveTooltipStyle=wc;exports.resolveYScaleAesthetic=l.resolveYScaleAesthetic;exports.sampleColorScheme=d.sampleColorScheme;exports.scale=b.scale;exports.setCompilerCachingEnabled=l.setCompilerCachingEnabled;exports.stat=b.stat;exports.stepDifferenceArrowEndpoint=Hd;exports.style=b.style;exports.styles=b.styles;exports.toDashPreset=_t;exports.toFontSpec=Ec;exports.toPaintColor=l.toPaintColor;exports.toPanelCursor=ma;exports.toPercent=Y;exports.toSpec=Ii;exports.toStrokeDasharray=da;exports.toViewBoxX=uu;exports.toViewBoxY=N;exports.token=l.token;exports.transform=b.transform;exports.truncateToWidth=kn;exports.unitToPolar=l.unitToPolar;exports.updateSpec=d.updateSpec;exports.withAlpha=l.withAlpha;