@graphysdk/viz-engine 1.9.0-beta.1791469337004 → 1.9.0-beta.1791474469645

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.mjs +1721 -1715
  3. package/package.json +4 -4
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var hl=Object.create,kn=Object.defineProperty,pl=Object.getOwnPropertyDescriptor,fl=Object.getOwnPropertyNames,gl=Object.getPrototypeOf,vl=Object.prototype.hasOwnProperty,yl=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=fl(t),i=0,o=a.length,s;i<o;i++)s=a[i],!vl.call(e,s)&&s!==r&&kn(e,s,{get:(c=>t[c]).bind(null,s),enumerable:!(n=pl(t,s))||n.enumerable});return e},Sl=(e,t,r)=>(r=e!=null?hl(gl(e)):{},yl(t||!e||!e.__esModule?kn(r,"default",{value:e,enumerable:!0}):r,e));const l=require("./annotations-CneJsLr9.cjs"),d=require("./compiler-CYBzUSSA.cjs"),b=require("./spec-builder-DVrY4Me5.cjs");let N=require("lodash-es"),it=require("humanize-duration");it=Sl(it,1);let C=require("d3-shape"),bl=require("d3-delaunay");typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1791469337004");var xl=1e6;function k(e){return String(Math.round(e*xl))}function W(e,t){return e.geom===t}var qe="…",Vn=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(qe)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+qe)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+qe};var L={timeZone:"UTC"},T=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},z=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",bt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",ge=new Map,ve=new Map,Nn=256,le=(e,t)=>{const r=Fn(e,t),n=ge.get(r);if(n!==void 0)return n;ge.size>=Nn&&ge.clear();const a=new Intl.NumberFormat(e,t);return ge.set(r,a),a},E=(e,t)=>{const r=Fn(e,t),n=ve.get(r);if(n!==void 0)return n;ve.size>=Nn&&ve.clear();const a=new Intl.DateTimeFormat(e,t);return ve.set(r,a),a},Fn=(e,t)=>`${e}\0${JSON.stringify(t)}`,Al=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"}}}),De={signDisplay:"negative"},Bn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>z(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=It(a,i),{base:s,suffix:c}=At(a,r.abbreviation);return`${le(t,{...o,...De,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Gn=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>{const{base:a,suffix:i}=At(n,t.abbreviation);return`${le(e,{...It(a,t.decimals),...De,...r}).format(a)}${i}`}),xt=e=>z(t=>{const r=Al(Math.abs(t));return t<0?`-${r}`:r}),Hn=({locale:e,intlOptions:t})=>{const r=le(e,{maximumFractionDigits:0,...De,...t});return z(n=>r.format(n))},$n=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>le(e,{...It(n,t.decimals),...De,...r,style:"percent"}).format(n)),At=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=Il(e);return At(e,r)}default:return{base:e/l.SUFFIX_MULTIPLIERS[t],suffix:t}}},It=(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}},Il=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"},Tl=1440*60*1e3,Ll=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.format(n))},El=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",timeStyle:"medium",...L,...t});return T(n=>Cl(r.formatToParts(n)))},Kn=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",...L,...t});return T(n=>r.format(n))},zn=({locale:e,intlOptions:t})=>{const r=E(e,{month:"long",...L,...t});return T(n=>r.format(n))},Tt=({locale:e,intlOptions:t})=>{const r=E(e,{month:"short",year:"numeric",...L,...t});return T(n=>r.format(n))},Lt=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,qn(n,6)))},Un=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.formatRange(n,qn(n,6)))},Et=({locale:e,intlOptions:t})=>{const r=E(e,{year:"numeric",...L,...t});return T(n=>r.format(n))},Wn=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},qn=(e,t)=>new Date(e.getTime()+t*Tl),Cl=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,Rl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>z(a=>{const i={...Rt(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Ct(a,t,i)}),wl=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...Rt(n,t),notation:"compact",...r};return Ct(n,e,a)}),Pl=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...Rt(n,t),notation:"compact",...r,style:"percent"};return Ct(n,e,a)}),Ct=(e,t,r)=>le(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),Xn=e=>Math.abs(e)>yr?Xn(e/yr):Number.isInteger(e),Ml=e=>{if(e.length<2)return!1;const[t,r]=e;return typeof t!="number"||typeof r!="number"?!1:Math.abs(r-t)<1},Rt=(e,t)=>Xn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:Ml(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:Math.max(1,Dl(t))},Dl=e=>{const t=e.filter(u=>typeof u=="number"&&Number.isFinite(u)),r=t[0],n=t[1];if(r===void 0||n===void 0)return 0;const a=Math.abs(n-r);if(a===0)return 0;let i=0;for(const u of t)i=Math.max(i,Math.abs(u));if(i===0)return 0;const o=Math.floor(Math.log10(i)/3),s=a/10**(Math.max(0,o)*3);if(s>=1)return 0;const c=Math.ceil(-Math.log10(s)-1e-9);return Math.min(4,Math.max(0,c))},Ol=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},_l=({locale:e,intlOptions:t})=>{const r=E(e,{month:"short",...L,...t});return T(n=>r.format(n))},kl=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},Vl=({locale:e,intlOptions:t,tickValues:r})=>{const n=E(e,{...Fl(r),...L,...t});return T(a=>n.format(a))},Nl=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},Fl=e=>{const t=e.filter(r=>r instanceof Date&&!Number.isNaN(r.getTime()));return t.length===0?{day:"numeric",month:"short"}:Bl(t).size>1?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{timeStyle:"short"}},Bl=e=>{const t=new Set;for(const r of e)t.add(`${r.getUTCFullYear()}-${r.getUTCMonth()}-${r.getUTCDate()}`);return t},wt=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return Rl(e);case"date":return Ol(e);case"datetime":return Vl(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return kl(e);case"decimal":case"integer":return wl(e);case"duration":return xt(e);case"month":return _l(e);case"month_year":return Tt(e);case"percentage":return Pl(e);case"quarter":return Lt(e);case"text":return bt(e);case"time":return Nl(e);case"year":return Et(e);case"lookup":return wt({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},Gl=.9,Hl=1/3,$l=1/4,Kl=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?zl(e):Yl(e),zl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=jn(e.ticks,n),s=Ul(e.ticks,r.width),c=s*Gl;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*Hl);return{...e,ticks:ot(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},Yl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=jn(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=st(r.width*$l);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:ot(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},Ul=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},jn=(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:Vn(i.formattedLabel,r,a)})},st=e=>Math.max(0,Math.floor(e)),Wl=(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},ql={ticks:[],labelAt:()=>""},Xl=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=p=>{const f=o.get(p);if(f)return f;const g=a[p],S=g?Zl(g.ticks,n(g)):ql;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);Wl(f.length,g,i,t,r)?(m=p,c=p+1):u=p-1}const h=jl(m,s);return Jl(s(h))},jl=(e,t)=>{const r=e>=0?e:0;for(let n=r;n>=0;n-=1){const{ticks:a,labelAt:i}=t(n);if(Ql(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}}},Jl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Ql=(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},ec=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 Bn(e);case"date":return Ll(e);case"datetime":return El(e);case"day_month":return Kn(e);case"decimal":return Gn(e);case"duration":return xt(e);case"integer":return Hn(e);case"month":return zn(e);case"month_year":return Tt(e);case"percentage":return $n(e);case"quarter":return Lt(e);case"text":return bt(e);case"weekly_date_range":return Yn(e);case"weekly_date_range_with_year":return Un(e);case"year":return Et(e);case"time":return Wn(e);case"lookup":return ec({...e,valueFormat:e.valueFormat});default:{const t=e.valueFormat;throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}}};function Pt({layer:e,numberFormat:t,locale:r}){return I({valueFormat:d.getLayerYValueFormat(e),locale:r,numberFormat:t})}var tc=(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}},Zn=({layer:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:c})=>{const u=Pt({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:oc({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:m}),formatAbsolute:u,formatCategory:rc({layer:e,numberFormat:n,locale:s})}},rc=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=tc(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)}},nc=(e,t,r)=>{switch(t){case"stack":return ac(e);case"fill":return ic(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},ac=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}},ic=(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}},oc=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=d.createRawValueReader(e.data,e.dataLabels.labelSource),c=nc(e,i,o),u=sc({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),m=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&Jn(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)}},sc=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Jn(e))return a;const s=lc(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:cc(e.data,i),locale:n,numberFormat:t})},Jn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(d.resolveSegmentYSource(e.position,e.mapping))},lc=(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})},cc=(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)},uc={cartesian:["cartesian","flip"],polar:["polar"]},dc=null;function Qn(e=[]){const t=mc(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!uc[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 Mt(){return dc??=Qn()}function mc(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*hc({layers:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,locale:s,resolvePlacement:c=Mt()}){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=Zn({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 Xe={abbreviation:"none",decimals:"auto"},ea=({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:Xe,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:Xe,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:Xe,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},Sr=e=>{const t=e.replace(/[^\d.]/g,"");return t===""||t==="."?!1:Number(t)===0},pc=2,fc=6,gc=6,vc=15,yc=15,Sc=2.5,bc=.5,xc=.25,ta=e=>{const t=e-pc,r=1+bc*t,n=1+xc*t;return{arrowStartGap:fc*r,arrowEndGap:gc*r,offsetFromHigherObservation:vc*n,arrowheadSize:Sc*e,curveRadius:yc*n,strokeWidth:e}},Ac=(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},Ic=(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"});var hl=Object.create,Vn=Object.defineProperty,pl=Object.getOwnPropertyDescriptor,fl=Object.getOwnPropertyNames,gl=Object.getPrototypeOf,vl=Object.prototype.hasOwnProperty,yl=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=fl(t),i=0,o=a.length,s;i<o;i++)s=a[i],!vl.call(e,s)&&s!==r&&Vn(e,s,{get:(c=>t[c]).bind(null,s),enumerable:!(n=pl(t,s))||n.enumerable});return e},Sl=(e,t,r)=>(r=e!=null?hl(gl(e)):{},yl(t||!e||!e.__esModule?Vn(r,"default",{value:e,enumerable:!0}):r,e));const l=require("./annotations-CneJsLr9.cjs"),d=require("./compiler-CYBzUSSA.cjs"),b=require("./spec-builder-DVrY4Me5.cjs");let N=require("lodash-es"),ot=require("humanize-duration");ot=Sl(ot,1);let C=require("d3-shape"),bl=require("d3-delaunay");typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1791474469645");var xl=1e6;function k(e){return String(Math.round(e*xl))}function W(e,t){return e.geom===t}var Xe="…",Nn=(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"}},z=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",xt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",ge=new Map,ve=new Map,Fn=256,le=(e,t)=>{const r=Bn(e,t),n=ge.get(r);if(n!==void 0)return n;ge.size>=Fn&&ge.clear();const a=new Intl.NumberFormat(e,t);return ge.set(r,a),a},E=(e,t)=>{const r=Bn(e,t),n=ve.get(r);if(n!==void 0)return n;ve.size>=Fn&&ve.clear();const a=new Intl.DateTimeFormat(e,t);return ve.set(r,a),a},Bn=(e,t)=>`${e}\0${JSON.stringify(t)}`,Al=ot.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),De={signDisplay:"negative"},Gn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>z(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=Tt(a,i),{base:s,suffix:c}=It(a,r.abbreviation);return`${le(t,{...o,...De,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Hn=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>{const{base:a,suffix:i}=It(n,t.abbreviation);return`${le(e,{...Tt(a,t.decimals),...De,...r}).format(a)}${i}`}),At=e=>z(t=>{const r=Al(Math.abs(t));return t<0?`-${r}`:r}),$n=({locale:e,intlOptions:t})=>{const r=le(e,{maximumFractionDigits:0,...De,...t});return z(n=>r.format(n))},Kn=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>le(e,{...Tt(n,t.decimals),...De,...r,style:"percent"}).format(n)),It=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=Il(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}},Il=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"},Tl=1440*60*1e3,Ll=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.format(n))},El=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",timeStyle:"medium",...L,...t});return T(n=>Cl(r.formatToParts(n)))},zn=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",...L,...t});return T(n=>r.format(n))},Yn=({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()}`),Un=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",...L,...t,year:void 0});return T(n=>r.formatRange(n,Xn(n,6)))},Wn=({locale:e,intlOptions:t})=>{const r=E(e,{dateStyle:"medium",...L,...t});return T(n=>r.formatRange(n,Xn(n,6)))},Ct=({locale:e,intlOptions:t})=>{const r=E(e,{year:"numeric",...L,...t});return T(n=>r.format(n))},qn=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},Xn=(e,t)=>new Date(e.getTime()+t*Tl),Cl=e=>{const t=e.findIndex(n=>n.type==="hour")-1,r=e[t];return e.map((n,a)=>a===t&&r?.type==="literal"&&r.value===", "?" • ":n.value).join("")},Sr=1e3,Rl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>z(a=>{const i={...wt(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Rt(a,t,i)}),wl=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...wt(n,t),notation:"compact",...r};return Rt(n,e,a)}),Pl=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...wt(n,t),notation:"compact",...r,style:"percent"};return Rt(n,e,a)}),Rt=(e,t,r)=>le(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),jn=e=>Math.abs(e)>Sr?jn(e/Sr):Number.isInteger(e),Ml=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)=>jn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:Ml(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:Math.max(1,Dl(t))},Dl=e=>{const t=e.filter(u=>typeof u=="number"&&Number.isFinite(u)),r=t[0],n=t[1];if(r===void 0||n===void 0)return 0;const a=Math.abs(n-r);if(a===0)return 0;let i=0;for(const u of t)i=Math.max(i,Math.abs(u));if(i===0)return 0;const o=Math.floor(Math.log10(i)/3),s=a/10**(Math.max(0,o)*3);if(s>=1)return 0;const c=Math.ceil(-Math.log10(s)-1e-9);return Math.min(4,Math.max(0,c))},Ol=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},_l=({locale:e,intlOptions:t})=>{const r=E(e,{month:"short",...L,...t});return T(n=>r.format(n))},kl=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"short",...L,...t});return T(n=>r.format(n))},Vl=({locale:e,intlOptions:t,tickValues:r})=>{const n=E(e,{...Fl(r),...L,...t});return T(a=>n.format(a))},Nl=({locale:e,intlOptions:t})=>{const r=E(e,{timeStyle:"short",...L,...t});return T(n=>r.format(n))},Fl=e=>{const t=e.filter(r=>r instanceof Date&&!Number.isNaN(r.getTime()));return t.length===0?{day:"numeric",month:"short"}:Bl(t).size>1?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{timeStyle:"short"}},Bl=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 Rl(e);case"date":return Ol(e);case"datetime":return Vl(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return kl(e);case"decimal":case"integer":return wl(e);case"duration":return At(e);case"month":return _l(e);case"month_year":return Lt(e);case"percentage":return Pl(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return Nl(e);case"year":return Ct(e);case"lookup":return Pt({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},Gl=.9,Hl=1/3,$l=1/4,Kl=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?zl(e):Yl(e),zl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Zn(e.ticks,n),s=Ul(e.ticks,r.width),c=s*Gl;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const m=lt(c);return{...e,ticks:st(e.ticks,a,m,n),labelRotation:0,labelMaxWidthPx:m}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=lt(r.height*Hl);return{...e,ticks:st(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},Yl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Zn(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=lt(r.width*$l);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:st(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},Ul=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},Zn=(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}},st=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:Nn(i.formattedLabel,r,a)})},lt=e=>Math.max(0,Math.floor(e)),Wl=(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},ql={ticks:[],labelAt:()=>""},Xl=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=p=>{const f=o.get(p);if(f)return f;const g=a[p],S=g?Zl(g.ticks,n(g)):ql;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);Wl(f.length,g,i,t,r)?(m=p,c=p+1):u=p-1}const h=jl(m,s);return Jl(s(h))},jl=(e,t)=>{const r=e>=0?e:0;for(let n=r;n>=0;n-=1){const{ticks:a,labelAt:i}=t(n);if(Ql(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}}},Jl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Ql=(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},ec=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 Gn(e);case"date":return Ll(e);case"datetime":return El(e);case"day_month":return zn(e);case"decimal":return Hn(e);case"duration":return At(e);case"integer":return $n(e);case"month":return Yn(e);case"month_year":return Lt(e);case"percentage":return Kn(e);case"quarter":return Et(e);case"text":return xt(e);case"weekly_date_range":return Un(e);case"weekly_date_range_with_year":return Wn(e);case"year":return Ct(e);case"time":return qn(e);case"lookup":return ec({...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 tc=(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:oc({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:m}),formatAbsolute:u,formatCategory:rc({layer:e,numberFormat:n,locale:s})}},rc=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=tc(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)}},nc=(e,t,r)=>{switch(t){case"stack":return ac(e);case"fill":return ic(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},ac=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}},ic=(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}},oc=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=d.createRawValueReader(e.data,e.dataLabels.labelSource),c=nc(e,i,o),u=sc({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),m=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&Qn(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)}},sc=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Qn(e))return a;const s=lc(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:cc(e.data,i),locale:n,numberFormat:t})},Qn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(d.resolveSegmentYSource(e.position,e.mapping))},lc=(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})},cc=(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)},uc={cartesian:["cartesian","flip"],polar:["polar"]},dc=null;function ea(e=[]){const t=mc(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!uc[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 dc??=ea()}function mc(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*hc({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 je={abbreviation:"none",decimals:"auto"},ta=({locale:e,kind:t,startValue:r,endValue:n,valueFormat:a})=>{if(r===null||n===null)return"n/a";switch(t){case"absolute-difference":{const i=n-r,o=I({valueFormat:a,locale:e,numberFormat:je,intlOptions:{signDisplay:"always"}})(i);return br(o)?"0":o}case"relative-difference":{const i=n-r;if(i===0)return"0%";const o=i/Math.abs(r);if(o===Number.POSITIVE_INFINITY)return"∞";if(o===Number.NEGATIVE_INFINITY)return"-∞";const s=I({valueFormat:{type:"percentage"},locale:e,numberFormat:je,intlOptions:{signDisplay:"always"}})(o);return br(s)?"0%":s}case"proportion":{if(n-r===0)return"=";const i=n/r;return i===Number.POSITIVE_INFINITY?"∞":i===Number.NEGATIVE_INFINITY?"-∞":`${I({valueFormat:{type:"decimal"},locale:e,numberFormat:je,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},br=e=>{const t=e.replace(/[^\d.]/g,"");return t===""||t==="."?!1:Number(t)===0},pc=2,fc=6,gc=6,vc=15,yc=15,Sc=2.5,bc=.5,xc=.25,ra=e=>{const t=e-pc,r=1+bc*t,n=1+xc*t;return{arrowStartGap:fc*r,arrowEndGap:gc*r,offsetFromHigherObservation:vc*n,arrowheadSize:Sc*e,curveRadius:yc*n,strokeWidth:e}},Ac=(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},Ic=(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}
@@ -20,4 +20,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var hl=Object
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
- `,Ec=(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},Cc=(e,t,r)=>Math.abs(e?t.y-r.y:t.x-r.x),ra=({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=ta(t.strokeWidth),m=Ac(o,s,c,u),h=(o?Tc:Ic)(s,c,m,u),p=Lc(o,c,u),f=Ec(o,s,c,m,Cc(o,s,c),e.labelCrossPosition),g=ea({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,Rc=e=>{const t=n=>e(n),r=Ar(t,n=>a=>e(a,n));return Ar(t,()=>r)},wc=(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(Dc(m=>i(s,{annotation:m})),c);if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&Pc(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",Dt=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}})},Pc=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}}},Mc=(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 Mc(a,t,r),br.set(e,a),a}}),Dc=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}},Cr={large:1,medium:23/26,small:19/26},je={large:1,medium:10/12,small:10/12},na=["fontStyle","letterSpacing","textTransform","textDecoration","textOutlineColor","textOutlineWidth","textShadow"],aa=["fontFamily","fontSize","fontWeight","lineHeight","textColor",...na],ia=e=>e.fontSize*e.lineHeight,Oc=(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}}),_c=(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"}},kc=(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",...Hc(e)}},Vc=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()}),Nc=e=>({item:e.legendItem().resolve(),swatch:e.legendItem.swatch().resolve()}),Fc=e=>{const t=e.directLabel();return{...t.resolve(),isTextColorAuthored:Dt(t.getSource("textColor"))}},Bc=(e,t)=>{const r=e.headlineItem,n=r.number().resolve(),a={...n,fontSize:n.fontSize*Cr[t]},i=r.number.center(),o=i.resolve().fontSize;return{gap:r().resolve().gap,number:a,...$c(i)?{numberCenter:ye(i,o===void 0?a.fontSize:o*Cr[t])}:{},caption:ye(r.caption(),r.caption().resolve().fontSize*je[t]),label:ye(r.label(),r.label().resolve().fontSize*je[t]),swatch:r.swatch().resolve(),trend:ye(r.trend(),r.trend().resolve().fontSize*je[t]),trendUp:r.trend.up().resolve(),trendDown:r.trend.down().resolve(),trendFlat:r.trend.flat().resolve()}},Gc=(e,t)=>{const r=t?e.numberCenter:void 0;return r===void 0?e.number:{...e.number,...oa(r)}},Hc=e=>{const t={};for(const r of na){const n=e.get(r);n!==void 0&&Object.assign(t,{[r]:n})}return t},$c=e=>aa.some(t=>e.getSource(t)!=="unresolved"),ye=(e,t)=>({...oa(e.resolve()),fontSize:t}),oa=e=>{const t={};for(const r of aa){const n=e[r];n!==void 0&&Object.assign(t,{[r]:n})}return t},sa=({labelPosition:e,measuredTextWidth:t,label:r})=>{const n=t+2*r.paddingInline,a=ia(r)+2*r.paddingBlock;return{x:e.x-n/2,y:e.y-a/2,width:n,height:a}};function*Kc({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=ra({arrow:o,style:s,mainAxis:t,panelWidth:r.width,panelHeight:r.height,locale:n}),u=sa({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 zc=e=>{const t=e.padding,r=Rr(e.rows,t?.top??0,t?.bottom??0),n=Rr(e.cols,t?.left??0,t?.right??0);return{rows:r.tracks,cols:n.tracks,placements:qc(e.placements,r.nameToIndex,n.nameToIndex),width:e.containerSize.width,height:e.containerSize.height}},Yc=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},Rr=(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(Uc(s));const c=Wc(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}},Uc=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,Wc=(e,t)=>{for(let r=t+1;r<e.length;r++){const n=e[r];if(n&&lt(n))return n}},qc=(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},la={outer:Q,inner:Q},Xc=(e,t,r,n=Q,a=la,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:H(o.header)},{name:"topLegend",size:r.legends.top,gaps:H(o.legend.top)},{name:"headline",size:r.headline,gaps:H(o.headline)},{name:"topAxisLabel",size:c,gaps:H(o.axisLabel.top)},{name:"topAxis",size:r.axes.top,gaps:H(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:H(o.tickLabel.bottom)},{name:"bottomAxisLabel",size:r.axesLabels.bottom,gaps:H(o.axisLabel.bottom)},{name:"bottomLegend",size:r.legends.bottom,gaps:H(o.legend.bottom)},{name:"footer",size:t.footerSize.height,gaps:H(o.footer)}],m=[{name:"leftLegend",size:r.legends.left,gaps:Se(o.legend.left)},{name:"leftAxis",size:r.axes.left,gaps:Se(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:Se(o.tickLabel.right)},{name:"rightLegend",size:r.legends.right,gaps:Se(o.legend.right)}],h=Dr(u,i.top,i.bottom),p=Dr(m,i.left,i.right);return zc({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),...Jc(r.axesLabels,r.axes),...Qc(r.legends)],containerSize:e,padding:{top:h.start,bottom:h.end,left:p.start,right:p.end}})},H=e=>({before:e.top,after:e.bottom}),Se=e=>({before:e.left,after:e.right}),jc=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Dr=(e,t,r)=>{const n=e.filter(jc),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},Jc=(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},Qc=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 eu=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)))}},tu=["top","right","bottom","left"],Ze=(e,t)=>{const r={};for(const n of tu){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"],ru=({size:e,availableWidth:t,measureStripWidth:r})=>{if(e!=="auto")return e;for(const n of ct)if(r(n)<=t)return n;return"small"},nu=({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},au=({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},iu=({headline:e,containerSize:t,measurer:r})=>{if(Oe(e))return 0;const n=ca(e,t.width,r);return r.measureHeadline(e.formatted,n).height},ou=({headline:e,layout:t,containerSize:r,measurer:n,itemGap:a})=>{if(Oe(e)){const s=su(t.panel,e.innerRadius),c=nu({size:e.size,availableWidth:s.width,measureStripWidth:ua(e,n)});return c===null?null:{rect:s,resolvedSize:c,visibleItemCount:1}}const i=ca(e,r.width,n);if(e.formatted.kind!=="perGroup")return{rect:t.headline,resolvedSize:i,visibleItemCount:1};const o=au({itemWidths:n.measureHeadlineItemWidths(e.formatted,i),gap:a,availableWidth:t.headline.width});return o===0?null:{rect:t.headline,resolvedSize:i,visibleItemCount:o}},Oe=e=>e.formatted.kind==="grandTotal"&&e.position==="center"&&e.innerRadius>0,su=(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}},ca=(e,t,r)=>ru({size:e.size,availableWidth:t,measureStripWidth:ua(e,r)}),ua=(e,t)=>r=>t.measureHeadline(e.formatted,r,Oe(e)).width,X={x:0,y:0,width:0,height:0},lu={top:0,right:0,bottom:0,left:0},cu="0000",uu=3,du=e=>e.plot.y+e.plot.height-e.panel.y,mu=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:la,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:hu(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:du(n)}}).result()}measurePanelOverflow(e,t,r,n){if(!e.overflowStrategy||e.coordSystem?.type!=="cartesian")return n;const a=new eu(t);if(e.annotations&&e.resolveDifferenceArrowStyle&&e.overflowStrategy.differenceArrows)for(const o of Kc({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 hc({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<uu;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:cu}],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=Xl({axis:e,availableSpacePx:n,measureLabel:i,resolveFormatter:t}),{tickCandidates:s,...c}=e,u={...c,ticks:o,labelRotation:0,labelMaxWidthPx:null};return e.geometry!=="linear"?u:e.scaleType==="discrete"&&e.bandwidth!==void 0?Kl({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=Yc(Xc(r,n,this.measureGuides(e,t,o,r),i,a,s,pu(c,t)));return{header:u.get("header")??X,headline:u.get("headline")??X,footer:u.get("footer")??X,plot:u.get("plot")??X,panelFrame:u.get("panelFrame")??X,panel:u.get("panel")??X,axes: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:iu({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}}},hu=(e,t,r)=>{const n=new WeakMap;return a=>{const i=n.get(a);if(i)return i;const o=wt({valueFormat:a.valueFormat??e.valueFormat,locale:t,numberFormat:r,tickValues:a.ticks.map(s=>s.value)});return n.set(a,o),o}},pu=(e,t)=>{const r={...e.legend};for(const n of t)n.display==="direct"&&(r[n.position]=lu);return{...e,legend:r}},fu=(e=[])=>{const t=gu(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}},gu=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 vu(e){return e}function F(e){return 1-e}var U=e=>`${Number.parseFloat((e*100).toFixed(4))}%`,Ee=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+F(e.y)*r.height}},da=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+(F(e.y)-e.height)*r.height,width:e.width*r.width,height:e.height*r.height}},yu=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}=Su(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:bu(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}),Su=(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}},bu=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},xu=e=>{const{annotations:t,panelRect:r,measuredBoxes:n,onCycle:a,onMissingRef:i}=e;if(!Au(t))return t;const o=new yu(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,Au=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),ma=(e,t)=>{if(!(e===void 0||e.length===0||t<=0))return e.map(r=>r*t).join(" ")},Ot=e=>e===void 0||e.length===0?"solid":(e[0]??0)<=1?"dotted":"dashed",_t=(e,t)=>e===t?!0:e===void 0||t===void 0||e.length!==t.length?!1:e.every((r,n)=>r===t[n]),Iu=800,Br=400,Tu=.75,Lu=.875,Eu=4,Cu=e=>Math.max(1,(e-Br)/(Iu-Br)+1),Ru=(e,t)=>{const r=Cu(t),n=e*Eu;return{strokeWidth:Math.min(e,e*Tu*r),arrowheadLength:Math.min(n,n*Lu*r)}},be=Math.PI/4,wu=({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-be)} ${o-r*Math.sin(s-be)} M ${i} ${o} L ${i-r*Math.cos(s+be)} ${o-r*Math.sin(s+be)}`},Pu=64,Mu=({arrow:e,style:t,panelWidth:r,panelHeight:n})=>{const a={width:r,height:n},i={start:Ee(e.start,a),end:Ee(e.end,a)};if(i.start.x===i.end.x&&i.start.y===i.end.y)return null;const{strokeWidth:o,arrowheadLength:s}=Ru(t.strokeWidth,r),c=Math.hypot(i.end.x-i.start.x,i.end.y-i.start.y),u=Du(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:wu(i),startArrowheadPath:m?Gr("start",i,u):"",endArrowheadPath:h?Gr("end",i,u):"",strokeWidth:o,dashArray:ma(t.dashArray,o)??null,startX:i.start.x,startY:i.start.y,endX:i.end.x,endY:i.end.y,dashOffset:Ou(t.dashArray,o,m),arrowheadExtent:p}},Du=(e,t)=>Math.min(e,t*e/Pu),Ou=(e,t,r)=>{const n=e[0]??0;return r&&n>1?n*t:0};function _u(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=ku(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 ku(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 ha=(e,t)=>({x:e.x/t.width,y:1-e.y/t.height}),Vu=0,Nu=(e,t)=>e.filter(r=>r.inView).map(r=>({shape:{kind:"rect",rect:r.miniRect},cursor:ha(r.anchorPx,t),tooltip:{kind:"pinned",point:r.anchorPx,placement:r.placement,annotationId:r.id},priority:Vu})),Fu=9,Bu=8,Gu=2,pa=e=>typeof e=="string"?e:fa(e),fa=e=>e.text!==void 0?e.text:e.content?e.content.map(fa).join(""):"",Hr={top:"bottom",bottom:"top",right:"left",left:"right"};function Hu(e,t,r){return r.type==="polar"?zu(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 $u(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 Ku(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 zu(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 Yu(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,pa(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,Wu(n,m,a,u));c.push(h),u.push(h.miniRect)}return c}function Kr(e,t,r,n,a,i){const o=Ee(r,i);return{id:e,kind:t,anchor:r,anchorPx:o,mini:a(t,e,n),inView:Uu(o,i)}}function Uu(e,t){return e.x>=-8&&e.y>=-8&&e.x<=t.width+8&&e.y<=t.height+8}function Wu(e,t,r,n){const a=Hu(t.anchorPx,e,r);for(const i of a){const o=dt(t.anchorPx,i,t.mini);if($r(o,e)&&!n.some(s=>Ku(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:$u(e,dt(t.anchorPx,r,t.mini)),text:t.mini.text,inView:t.inView}}var qu=(e,t)=>Mt().hasCapability(e,t),Xu=({layers:e,coordSystem:t,axes:r,numberFormat:n,parsingLocale:a,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:c,plotBottomY:u,isFooterChromeReserved:m,resolvePlacement:h=Mt()})=>{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=Zn({layer:x,coordSystem:t,axes:r,numberFormat:n,panelRect:i,measureDataLabel:o,readers:s,formattingLocale:f,percentageValueStrategy:A.getPercentageValueStrategy(x)}),q=A.place(P);S+=q.droppedCount;for(const _ of q.labels)Zu(_,g,u,m)||p.push(_)}return{labels:p,warnings:S>0?[ju(S)]:[]}},ju=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,Ju=(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,Qu=100,ed=({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>Qu)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}},td=(e,t)=>ga(e,t,{variables:va(e),allowNull:!1}),ga=(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}},va=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])]},_e=e=>e!=="data-point",rd=(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:va(e),allowNull:!1},ae=[],Ur=new WeakMap,ya=(e,t,r)=>r<0||r>=e.data.size()?null:t==="data-point"?String(r):ie(e,t).keyByRow[r]??null,kt=(e,t,r)=>{if(t==="data-point"){const n=Number(r);return Number.isInteger(n)&&n>=0&&n<e.data.size()?[n]:ae}return ie(e,t).rowsByKey.get(r)??ae},nd=(e,t)=>ie(e,t).keyByRow,ad=(e,t,r,n)=>{if(r!=="data-point")return kt(e,r,n);const a=Number(n);if(!Number.isInteger(a)||a<0||a>=t.data.size())return ae;const i=ie(t,"vertex").keyByRow[a];return i===void 0?ae:ie(e,"vertex").rowsByKey.get(i)??ae},ie=(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=od(id(e,t));return r.set(t,a),a},id=(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,od=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}},Sa=({layer:e,observationIndex:t,scope:r,parsingLocale:n})=>{const a=e.data.getAt(t);if(a===null)return null;const i=dd(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 ud(o,e,a,t,n)?o:null},sd=({layer:e,scope:t,variable:r,value:n,parsingLocale:a})=>{const i={kind:"observations",layerId:e.id,scope:cd(e,t,r),predicate:{variable:r,eq:n}};return ld(i,e,a)?i:null},ba=e=>e.identityKey==="x-group"?"series":l.getGroupVariables(e.data,e.mapping).length===0?"data-point":"series",ld=(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},cd=(e,t,r)=>t==="series"&&!l.getGroupVariables(e.data,e.mapping).includes(r)?"data-point":t,ud=(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(!_e(e.scope))return!1;const o=ya(t,e.scope,n);return o===null?!1:kt(t,e.scope,o).some(s=>{const c=t.data.getAt(s);return c!==null&&i(c)})},dd=(e,t,r)=>{const n=rd(e,r);return n===null?null:ga(e,t,n)},Vt=(e,t)=>{if(t.kind==="circle"){const n=e.x-t.center.x,a=e.y-t.center.y;return n*n+a*a<=t.radius*t.radius}const{rect:r}=t;return e.x>=r.x&&e.x<=r.x+r.width&&e.y>=r.y&&e.y<=r.y+r.height},md=(e,t)=>{for(const r of t)if(Vt(e,r.shape))return r;return null},hd=e=>{const t=[];for(const r of e.values())t.push(...r);return t.sort((r,n)=>n.priority-r.priority)},pd=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>fd(r,t[n])),fd=(e,t)=>t===void 0?!1:e.priority===t.priority&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y&&gd(e.shape,t.shape)&&vd(e.tooltip,t.tooltip),gd=(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},vd=(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},yd=100,Sd=e=>({shape:{kind:"circle",center:e.center,radius:e.radius},cursor:e.target.cursor,tooltip:{kind:"cursor"},priority:yd}),bd=(e,t)=>Vt(e,{kind:"circle",center:t.center,radius:t.radius}),xd=(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&&Ad(e.target,t.target),Ad=(e,t)=>e.kind===t.kind&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y,Id=({layer:e,highlights:t,observation:r,parsingLocale:n})=>{if(e.highlight===null)return[];const a=d.createPredicateCompileContext(e,n),i=Td(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:_e(o.scope)&&i(o.scope).some(s)})},Td=(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}},Ie=({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?Ld(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},xa=(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),Ld=(e,t)=>(e%t+t)%t,Aa=({layer:e,at:t,coordSystem:r})=>{if(r.type!=="cartesian"||e.spatialKind==="cells")return null;const n=d.resolveAnchorVariable(e),a=xa(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=Ie({layer:e,excluding:c,from:a+1,step:1,accepts:s});if(u!==null)return{start:t,end:u.anchor};const m=Ie({layer:e,excluding:c,from:a-1,step:-1,accepts:s});if(m!==null)return{start:m.anchor,end:t};const h=Ie({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},Ed=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=Aa({layer:r,at:i,coordSystem:e.coordSystem});if(o!==null&&!t.some(s=>Cd(s,o)))return o}}return null},Cd=(e,t)=>J(e.start,t.start)&&J(e.end,t.end)||J(e.start,t.end)&&J(e.end,t.start),Rd=(e,t)=>d.resolveGeomScaleDemands(e.layers).zeroAxes[t]!==void 0,wd=new Set(["discrete","datetime"]),Ia=e=>{const t=e.x;return t?.kind!=="position"?!1:wd.has(t.spec.scaleType)},Pd=({layer:e,coordSystem:t,panelSize:r,radialExtent:n="whole"})=>{const a=n==="outerEnd"&&t.type==="polar"?Md:l.readObservationBox,i=[];for(const o of e.data){const s=a(o,t);s!==null&&i.push(Dd(s,r))}return i},Md=(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"}},Dd=(e,t)=>da({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),Od=(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}},ce=e=>d.applyReplayableTransforms(e.data,e.transforms),Ta=(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(kd([a,...i],t.scope)||Vd(a,t.scope)||[a,...i].some(m=>_d(e,m)))return null;const s=Nd(t,o)?void 0:t.predicate,c=qr(a,s);if(c===null)return null;const u=[];for(const m of i){const h=qr(m,s);if(h===null)return null;u.push(h)}return[c,...u]},_d=(e,t)=>{const r=l.readVariableName({...e.mapping,...t.mapping}.color);if(r===null)return!1;const n=d.applyReplayableTransforms(ce(e),t.transforms);return n.hasVariable(r)?n.getType(r)!=="categorical":!0},kd=(e,t)=>(t==="x-value"||t==="data-point")&&e.some(r=>d.paintsEachGroupFromItsFirstObservation(r.geom)),Vd=(e,t)=>t==="x-value"&&l.isStackedPosition(e.position)&&!d.paintsEachGroupFromItsFirstObservation(e.geom),Nd=(e,t)=>{if(e.scope!=="series")return!1;const r=Fd(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)},Fd=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},qr=(e,t)=>{if(d.encodesColorAsValue(e.geom))return null;const r=Bd(e.geom);return r===null?null:{layerId:e.id,geomKind:e.geom,property:r,...t===void 0?{}:{where:t}}},Bd=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},Gd=e=>e?.kind==="visual"&&e.paletteBeforeOverrides!==void 0?e.paletteBeforeOverrides:l.DEFAULT_COLOR_PALETTE,Hd=new Set(["line","rule"]),Nt=e=>Hd.has(e),ke=(e,t,r,n)=>{const a=e.geom(t);if(Nt(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)},Ft=({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(_e(t.scope))return Kd(e,a,t.scope);const i=Ea(e,a),o=i[$d(t,i,n,r)];return o===void 0?i:[o]},$d=(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},Kd=(e,t,r)=>{const n=nd(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},zd=({readers:e,layers:t,target:r,parsingLocale:n})=>{const a=d.findLayerById(t,r.layerId);if(a===void 0)return null;const i=d.findHostLayer(a,t);let o;for(const s of[i,...d.findCompanionLayers(i,t)]){const c=Ft({layer:s,target:r,parsingLocale:n,...s===a?{}:{host:a}});for(const u of c){const m=s.data.getAt(u);if(m===null)continue;const h=ke(e,s,m);if(h!==void 0){if(o===void 0){o=h;continue}if(o!==h)return null}}}return o??null},Yd=["series","data-point","x-value"],Ud=({layer:e,observationIndex:t,parsingLocale:r,scales:n})=>{const a=qd(ba(e)).filter(s=>s!=="x-value"||Wd(n)),i=new Set,o=[];for(const s of Yd){if(!a.includes(s))continue;const c=Xd(e,t,s,r);if(c===null&&s==="data-point")return[];c===null||o.some(u=>jd(u,c))||(o.push(c),i.add(s))}return a.filter(s=>i.has(s))},Wd=e=>{const t=e.x?.domain.some(r=>r instanceof Date)===!0;return Ia(e)&&!t},qd=e=>e==="series"?["data-point","x-value","series"]:["data-point"],Xd=(e,t,r,n)=>{const a=Sa({layer:e,observationIndex:t,scope:r,parsingLocale:n});return a===null?null:Ft({layer:e,target:a,parsingLocale:n})},jd=(e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),Zd=({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}}},Jd=({layer:e,from:t,partner:r,axis:n,step:a,getObservationPoint:i})=>{const o=d.resolveAnchorVariable(e),s=xa(e,t),c=e.data.getAt(s);if(c===null)return null;const u=Qd(c),m=n==="main"?u:f=>!u(f)&&l.areDataValuesEqual(f[o]??null,t.anchorValue),h=Ie({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}},Qd=e=>{const t=d.getGroup(e);return r=>l.areDataValuesEqual(d.getGroup(r),t)};function em({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 tm=({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"?rm(e,o,r):nm(e,t,o,r,i)},rm=(e,t,r)=>({kind:"grandTotal",value:I({valueFormat:e.valueFormat,locale:t,numberFormat:r})(e.value)}),nm=(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=wt({valueFormat:s.mainValueFormat,locale:r,numberFormat:n,tickValues:[]}),h=s.label??u(s.value);return{swatch:s.swatch,label:sm(t,o,h,a),value:s.aggregate===null?null:c(s.aggregate),caption:om(s.caption,m),comparison:am(s.comparison,m,i,a)}})}},am=(e,t,r,n)=>e===null?null:{direction:im(e.variation),percentage:r(Math.abs(e.variation)),reference:n("graph.headlineMetrics.comparisonReference",{value:t(e.against)})},im=e=>e>0?"up":e<0?"down":"flat",om=(e,t)=>e===null?null:e.kind==="point"?t(e.value):`${t(e.from)} – ${t(e.to)}`,sm=(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}},lm=({legends:e,numberFormat:t,parsingLocale:r,formattingLocale:n})=>{const a=n??r;return e.map(i=>cm(i,a,t))},cm=(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 Bt(e,t){return e.axes.find(r=>r.scaleAestheticKey===t)??null}function um(e,t){return e.legends.drawn.find(r=>r.aesthetics.includes(t))??null}var dm=({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:Bt(e,i?l.resolveYScaleAesthetic(r.yScaleType):"x")?.valueFormat??{type:"decimal"},locale:n,numberFormat:t})(o)},Ca=.4,Ra=.18,mm=12,wa=.4,hm=(e,t)=>{const{value:r,caption:n,comparison:a,swatch:i,label:o}=e;return[{role:"value",gap:Je(t.number.fontSize,Ra),segments:Qe([xe("value",r??"–"),xe("caption",n)])},{role:"trend",gap:Je(t.trend.fontSize,wa),ariaLabel:a===null?void 0:vm(a),segments:Qe([fm(a),gm(a),xe("trendReference",a?.reference??null)])},{role:"group",gap:Je(t.label.fontSize,Ca),segments:Qe([pm(i,t.swatch.size),xe("label",o)])}].filter(s=>s.segments.length>0)},Je=(e,t)=>Math.round(e*t),xe=(e,t)=>t===null?null:{kind:"text",textRole:e,text:t},pm=(e,t)=>e===null?null:{kind:"swatch",swatch:e,size:t},fm=e=>e===null?null:{kind:"trendArrow",direction:e.direction,size:12},gm=e=>e===null?null:{kind:"text",textRole:"trendPercentage",text:e.percentage,trendDirection:e.direction},vm=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"?C.curveCatmullRom:C.curveLinear,ym=(e,t)=>{const r=Ve(t.curve),n=(0,C.area)().curve(r),a=(0,C.line)().curve(r);if(e.mainAxis==="y"){const i=c=>F(l.getY(c)??0),o=c=>l.getXMin(c)??0,s=c=>l.getXMax(c)??l.getX(c)??0;n.y(i).x0(o).x1(s),a.y(i).x(s)}else{const i=c=>l.getX(c)??0,o=c=>F(l.getYMin(c)??0),s=c=>F(l.getYMax(c)??l.getY(c)??0);n.x(i).y0(o).y1(s),a.x(i).y(s)}if(t.missingValues==="gap"){const i=o=>l.getX(o)!==null&&l.getY(o)!==null;n.defined(i),a.defined(i)}return{lineGenerator:a,areaGenerator:n}},Sm=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Gt={none:0,xs:2,sm:4,md:8,lg:12,xl:16},Ht=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):Gt[t]},bm=e=>{const t=Ht(e);return Oa(e)?e.mainAxis==="x"?{rx:t}:{ry:t}:{rx:t}},xm=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)}`,Am=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}},$t=(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},Im=(e,t,r)=>{const n=$t(e,t,r);return t.mainAxis==="x"?{x:0,y:n}:{x:n,y:0}},Oa=e=>e.cornerRadius==="full",Tm=e=>{const t=(0,C.line)().x(r=>l.getX(r)??0).y(r=>F(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(_a),t},Lm=e=>{const t=(0,C.area)().x(r=>l.getX(r)??0).y0(()=>1).y1(r=>F(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(_a),t},Em=(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,Kt={circle:C.symbolCircle,square:C.symbolSquare,diamond:C.symbolDiamond,triangle:C.symbolTriangle,cross:C.symbolCross,star:C.symbolStar,wye:C.symbolWye},Cm=(e,t)=>{const r=t/2;return(0,C.symbol)(Kt[e],Math.PI*r*r)()??""},Rm=(e,t,r)=>{const n=ka[e],a=Math.max(0,Math.min(t/n.width,r/n.height));return{path:(0,C.symbol)(Kt[e],a*a)()??"",offsetX:-n.centerX*a,offsetY:-n.centerY*a}},wm=(e,t)=>{const r=t/2;return ka[e].outerRadius*Math.sqrt(Math.PI*r*r)},Pm=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}},ka=Object.fromEntries(Object.entries(Kt).map(([e,t])=>[e,Pm(t)])),Va={centerX:0,centerY:0,radius:1,digits:8},Mm=200,D=1e-12,Dm=Math.PI/2,Om=(e,t)=>{if(e==="full")return Math.max(0,t)/2;const r=e??"sm";return(typeof r=="number"?Math.max(0,r):Gt[r])/Mm},Na=(e,t)=>e==="x"?`${k(t.startAngle)}-${k(t.endAngle)}`:`${k(t.innerRadius)}-${k(t.outerRadius)}`,_m=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}},km=(e,t=Va)=>{const r=$m(t),n=Nm(e);if(!(n.outer>D))return`M${r.writePoint(0,0)}Z`;const{slice:a}=e,i=a===void 0?null:Vm(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 Bm(n.start,o,s,r)}return a?.axis==="radius"&&i!==null?Fm(n,i,r):jr(n,i??[n.start,n.end],r)}},Vm=(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},Nm=({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?Xr(p,s+p,u):null,outerCorner:f>D?Xr(f,c-f,u):null}},Xr=(e,t,r)=>({radius:e,centerRadius:t,offset:Math.min(Math.asin(Math.min(1,e/t)),r/2)}),Fm=(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)}`+oe(t,o(t),s(t),n)+Re(i,t,r,"radius",n)+oe(r,s(r),o(r),n)+Re(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))}`+Re(a,t,r,"angle",n)+`L${n.writePoint(r,Ce(i,r))}`+Re(i,r,t,"angle",n)+"Z"},Bm=(e,t,r,n)=>{const a=`M${n.writePoint(e,r)}${oe(r,e,e-l.TAU,n)}Z`;return t>D?`${a}M${n.writePoint(e,t)}${oe(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*Gm(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=>Hm(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),Gm=({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)))},Hm=({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)},Re=(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}`:oe(u.at(p),p,f,a)}return c},oe=(e,t,r,n)=>{if(!(e>D)||Math.abs(r-t)<=D)return"";const a=Math.max(1,Math.ceil(Math.abs(r-t)/Dm-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},$m=({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)}},Km=(e,t,r="light")=>{const n=Nt(e.geom)?"stroke":"fill",a=l.readVariableName(e.mapping.color),i=e.styles.overrides;for(let o=i.length-1;o>=0;o-=1){const s=i[o];if(!(s===void 0||!zm(s))&&Ym(s.where,a,t)&&s.declarations[n]!==void 0)return Um(s.declarations,n,r)}},zm=e=>e.state===void 0&&e.part===void 0,Ym=(e,t,r)=>e===void 0?!0:t===null||r===void 0?!1:d.readPredicateVariables(e).every(n=>n===t)&&Fa(e,r),Fa=(e,t)=>"eq"in e?l.areDataValuesEqual(e.eq,t):"and"in e?e.and.every(r=>Fa(r,t)):!1,Um=(e,t,r)=>{const n=e[t];if(typeof n=="string")return n;if(!l.isLightDarkColor(n))return;const a=l.resolveColorScheme(n,r);return typeof a=="string"?a:void 0},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}`:""}`}},Wm=(e,t,r)=>{const n=d.createXValueReader(e,t);return a=>{const i=n(a);return i===null||i===""?null:`${r}-${i}`}},qm=(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}`}},Xm=()=>(e,t)=>l.getColor(e)??`default-${t}`,en=2,jm=(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=W(t,"line")?a.get("strokeAlpha",r):a.get("fillAlpha",r)??a.get("strokeAlpha",r),o=a.get("alpha",r)*i,s=Nt(t.geom)?void 0:Zm(e,t,r),c=s===void 0?{alpha:o}:{alpha:o,fill:s};if(W(t,"point"))return{...c,symbol:e.point(t).get("symbol",r)};if(!W(t,"bar"))return c;const u=n.width-en,m=n.height-en,h=Ht({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)}},Zm=(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 Jm(e,t){const r=t.height,n=Math.min(t.width,t.height)/2;return{cartesian:tn(e,r),polar:tn(e,n)}}function ue(e,t){return e<=t.on.point}function se({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 Qm(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||ue(c.distance,a)||se(c,a)?c:rh(e,t,r,a)??c}function eh(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 th(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 rh(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);se(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[nh(e,t)]??null}function nh(e,t){return Ya(e.buckets,t,r=>r.main)}function ah(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 ih(e,t){return{group:oh(e),related:uh(e,t)}}function oh(e){switch(e.kind){case"buckets":{const t=e.match.index;return l.isStackedPosition(t.position)?sh(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)?lh(t.layerId,r,n.pointIndex):ch(t.bandByColumn,t.layerId,r,n.pointIndex)}case"points":case"enclosure":case"render-hit-test":return[]}}function sh(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 lh(e,t,r){const n=[];for(const a of t.rects)a.pointIndex!==r&&n.push(Wt(e,a));return n}function ch(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 uh(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||mh(r,i,e);continue}e.kind==="buckets"&&(l.isStackedPosition(i.position)||i.kind==="buckets"&&dh(r,i.layerId,e.match.bucket,e.match.hit.pointIndex))}return r}function dh(e,t,r,n){for(const a of r.entries)a.pointIndex!==n&&Te(e,t).push({anchored:!0,layerId:t,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation})}function mh(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=Te(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=ah(t,d.getMainAxisCoordinate(t.mainAxis,n));if(!a)return;const i=Te(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?[]:th(t,a.mainMin,a.mainMax,n),o=i.length>0?null:eh(t,n),s=o===null?i:[o];if(s.length===0)return;const c=Te(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 Te(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}=hh(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 hh(e,t){const r=fh(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),ph(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 ph(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 fh(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=gh(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 gh(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 vh=1e-9,rn=-1;function Wa(e,t,r){const n=yh(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:qa(o.entries,t)})):i,entries:a}}function qa(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 yh(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 bh(xh(e)),P=new Map,q=[];let _=-1;for(const dl of n){_+=1;const pe=x?.[_]??null,ml=Ah(P,pe),We=p[_],fe=g?.[_],fr=S?.[_],te=Sh(f[_],fe,fr,m);if(!l.isDefined(We)||te===null){A?.skip(pe);continue}const gr=h[_]??We,vr={pointIndex:_,...c?{x:te,y:gr}:{x:gr,y:te},groupKey:pe,paintOrder:ml,...a==="filled-buckets"&&l.isDefined(fe)&&{fill:Ih(fe,te)},...u&&{extent:Th(te,fe,fr)},previousAt:rn,nextAt:rn,observation:dl};A?.append(pe,{entry:vr,at:q.length}),q.push({main:We,entry:vr})}return r==="polar"&&A?.close(),q}function ne(e,t){return e.hasVariable(t)?e.getValues(t,{type:"numeric"}):null}function Sh(e,t,r,n){return l.isDefined(e)?n?l.isDefined(t)&&l.isDefined(r)?r:null:e:null}var bh=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 xh(e){return"missingValues"in e.params&&e.params.missingValues==="gap"}function Ah(e,t){const r=e.get(t);if(r!==void 0)return r;const n=e.size;return e.set(t,n),n}function Ih(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}}function Th(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 Xa(e,t){return{kind:"enclosure",layerId:e.id,geom:e.geom,position:e.position,projection:t,cells:Lh(e,t)}}function Lh(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 Eh(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:Rh(t,n),delaunay:null,delaunayAspectRatio:null};return ja(a,r),a}function Ch(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=bl.Delaunay.from(e.points,r=>r.x*t,r=>r.y),e.delaunayAspectRatio=t)}function Rh(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:wh(e)}}function Qa(e,t){return{anchored:!1,layerId:e,pointIndex:t.pointIndex,observation:t.observation}}function wh(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):Mh(e,t.mainAxis,r)}function Ph(e,t){switch(e.spatialKind){case"points":return Ch(e);case"buckets":case"filled-buckets":case"spanned-buckets":return Wa(e,"x","polar");case"rects":return t===null?Xa(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 Mh(e,t,r){switch(e.spatialKind){case"points":return Eh(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 Xa(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 Dh(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)?_h(a,t,e.mainAxis):kh(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,...Oh(e,n,t,r)}}function Oh(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 _h(e,t,r){const n=d.getCrossAxisCoordinate(r,t);return O(e,i=>Vh(i,r,n),{shortCircuitOnZero:!0})}function kh(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 Vh(e,t,r){return V(r,t==="x"?e.yMin:e.xMin,t==="x"?e.yMax:e.xMax)}function Nh(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 Fh(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=zh(i.entries,i.span,e.mainAxis,n),s=o.entries.map(S=>({entry:S,crossAtCursor:Gh(e,S,n)}));if(!l.isNonEmptyArray(s))return null;const c=ni(s.filter(S=>$h(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 Bh(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=>Nh(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 Gh(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):Hh(t,a,n,r)}function Hh(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 $h(e,t,r,n){const a=Kh(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function Kh(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 zh(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)<=vh);return o.length===e.length?{entries:e,span:t}:{entries:o,span:qa(o,r)}}function Yh(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 Uh(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?Xh(e.columns,a):Ka(e,i),c=s?.rects??[];if(!s||!l.isNonEmptyArray(c))return null;const u=o?jh(c,i):Zh(c,a),m=Wh(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,...qh(e,s,n)}}function Wh(e,{angle:t,radius:r}){const n=we(t,e.xMin,e.xMax),a=V(r,e.yMin,e.yMax);return Math.hypot(n*r,a)}function we(e,t,r){return l.isAngleWithinArc(e,t,r)?0:Math.min(l.wrappedAngularDistance(e,t),l.wrappedAngularDistance(e,r))}function qh(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:we(r,a.mainMin,a.mainMax)*n,crossDistance:V(n,a.crossMin,a.crossMax)}:{mainDistance:V(n,a.mainMin,a.mainMax),crossDistance:we(r,a.crossMin,a.crossMax)*n}}function Xh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(t,r.mainMid)):null}function jh(e,t){return O(e,r=>V(t,r.yMin,r.yMax),{shortCircuitOnZero:!0})}function Zh(e,t){return O(e,r=>we(t,r.xMin,r.xMax),{shortCircuitOnZero:!0})}var an=1e-9;function Jh(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=Qh(e.buckets,a),s=o?.entries??[];if(!o||!l.isNonEmptyArray(s))return null;const c=ni(s.filter(f=>ep(e,f,a,i)),f=>f),u=c??Bh(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 Qh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(r.main,t)):null}function ep(e,t,r,n){const a=tp(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function tp(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 rp(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 np(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||ue(i.distance,n)||se(i,n))return i;const o=e.points.map(s=>un(e,s,a)).filter(s=>se(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 ap=.05;function ip({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=mp(m,t,a);if(p)return{kind:"render-hit-test",match:p};continue}if(m.projection==="polar"){const p=dp(m,t,r,i?.polar);if(p&&!dn(p,i?.polar))return p;continue}const h=up({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,sp(s,o)).match}function op(e,t){if(e.kind==="render-hit-test")return{intersects:!0,onPoint:!1};const r=lp(e,t),n=e.kind==="buckets"&&ue(e.match.vertexDistance,r);return{intersects:si(e,r),onPoint:n}}function sp(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+ap?e:t}function si(e,t){switch(e.kind){case"banded":case"enclosure":return e.match.distance<=t.on.edge;case"buckets":return cp(e.match,t);case"points":return ue(e.match.distance,t)}}function lp(e,t){return e.match.index.projection==="polar"?t.polar:t.cartesian}function cp(e,t){return e.strokeDistance<=t.on.stroke?!0:ue(e.vertexDistance,t)}function dn(e,t){return t===void 0?!1:!si(e,t)&&!se(e.match,t)}function up({layer:e,cursor:t,aspectRatio:r,warmStarts:n,tolerance:a}){switch(e.kind){case"buckets":{const i=Fh(e,t,r);return i?{kind:"buckets",match:i}:null}case"banded":{const i=Dh(e,t,r);return i?{kind:"banded",match:i}:null}case"points":{const i=Qm(e,t,r,n.get(e.layerId)??null,a);return i?{kind:"points",match:i}:null}case"enclosure":{const i=Yh(e,t);return i?{kind:"enclosure",match:i}:null}case"noop":return null}}function dp(e,t,r,n){switch(e.kind){case"enclosure":{const a=rp(e,t,r,n!==void 0);return a?{kind:"enclosure",match:a}:null}case"points":{const a=np(e,t,r,n);return a?{kind:"points",match:a}:null}case"buckets":{const a=Jh(e,t,r);return a?{kind:"buckets",match:a}:null}case"banded":{const a=Uh(e,t,r);return a?{kind:"banded",match:a}:null}case"noop":case"render-hit-test":return null}}function mp(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 $={primary:null,group:[],related:new Map},hp=class{constructor({layers:e,coordSystem:t}){this.layerIndexes=[],this.layerRefs=[],this.viewport=null,this.aspectRatio=pp,this.isAspectStale=!1,this.warmStarts=new Map,this.cachedState=$,this.cachedKey=null,this.hoverLayers={interactive:[],normal:[],low:[]},this.hitTesters=new Map,this.cachedByKeyId=null,this.cachedByKeyState=$,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&&gp(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 $;this.reindexForAspect();const n=r??this.viewport,a=t!==void 0&&n!==null?Jm(t,n):void 0,i=p=>ip({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(),$;const s=o.match.hit;this.warmStarts.set(s.layerId,s.pointIndex);const c=a===void 0?void 0:op(o,a),u=fp(s,c);if(this.cachedKey===u)return this.cachedState;const{group:m,related:h}=ih(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 $;const n=r.byKey.get(t);if(!n)return $;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=$,this.cachedByKeyId=null,this.cachedByKeyState=$}reindexForAspect(){if(this.isAspectStale){this.isAspectStale=!1;for(const e of this.layerIndexes)e.kind==="points"&&e.projection==="cartesian"&&ja(e,this.aspectRatio)}}},pp=1;function fp(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 gp(e,t){return e.data===t.data&&e.geom===t.geom&&e.position===t.position&&e.coord===t.coord}var vp=Math.PI*2;function yp(e,t){const r=d.getMainAxisCoordinate(e.mainAxis,t);if(e.mainAxis==="y"){const a=U(F(r));return{x1:0,x2:"100%",y1:a,y2:a}}const n=U(r);return{x1:n,x2:n,y1:0,y2:"100%"}}function Sp(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:U(F(n+o)),width:"100%",height:U(i)}:{x:U(n-o),y:0,width:U(i),height:"100%"}}function bp(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+vp,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 xp(e){return e.observationIndex??e.pointIndex}function Ap(e){return e==="buckets"||e==="filled-buckets"||e==="spanned-buckets"}function Ip(e){return e==="buckets"||e==="filled-buckets"}var Ge=.5,Tp=.3,Lp=.4,Ep=10,Cp=({layer:e,coordSystem:t,scales:r,options:n})=>e.data.size()===0?null:e.spatialKind==="rects"?t.type==="cartesian"?wp(e,t,r,n):Pp(e,t,n):Ip(e.spatialKind)&&t.type==="cartesian"?Op(e,t,n):e.spatialKind==="cells"||e.spatialKind==="spanned-buckets"?Dp(e,n):e.spatialKind==="points"?Mp(e,n):null,Rp=e=>Ap(e.spatialKind)?new Set(e.data.getValues(l.GROUP_VARIABLES.group)).size:e.data.size(),wp=(e,t,r,n)=>({type:"grow",layerId:e.id,durationSeconds:Ge*n.durationScale,baseline:$t(e,t,r),growAxis:t.mainAxis==="x"?"y":"x",delayByKey:n.stagger?_p(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?Np(e,t,r):{}}},Mp=(e,t)=>({type:"grow",layerId:e.id,durationSeconds:Ge*t.durationScale,growAxis:"size",baseline:0,delayByKey:t.stagger?kp(e,t):{}}),Dp=(e,t)=>({type:"fade",layerId:e.id,durationSeconds:Tp*t.durationScale}),Op=(e,t,r)=>({type:"wipe",layerId:e.id,durationSeconds:Ge*r.durationScale,axis:t.mainAxis}),_p=(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 qt([...a.values()],r)},kp=(e,t)=>{const r=Ne(e.data,e.mapping,e.id),n=[];for(const a of e.data){const i=Vp(a,t.staggerOrder);i!==null&&n.push({position:i,keys:[r(a)]})}return qt(n,t)},Vp=(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},Np=(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=Na(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 qt([...a.values()],r)},qt=(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/Ep),i=Math.ceil(n.length/a),o=Lp*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},Fp=(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"},Bp={top:"topRight",right:"bottomRight",bottom:"bottomLeft",left:"topLeft"},Gp={topLeft:["left","top"],topRight:["top","right"],bottomRight:["right","bottom"],bottomLeft:["bottom","left"]},Hp=(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]=Gp[c];return a>0&&r[u].strokeWidth>0&&r[m].strokeWidth>0},o=Kp(t,a),s=zp(t,a,i);return Yp(r).map(c=>({dashArray:r[c.firstEdge].dashArray,strokeWidth:r[c.firstEdge].strokeWidth,stroke:r[c.firstEdge].stroke,segments:Up(c,o,s,i)}))},$p=e=>({top:e.edges.top.strokeWidth,right:e.edges.right.strokeWidth,bottom:e.edges.bottom.strokeWidth,left:e.edges.left.strokeWidth}),Kp=(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}}},zp=(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")}}}},Yp=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)||!_t(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}})},Up=(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=Wp(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=Bp[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},Wp=(e,t)=>({x:e.cx+e.radius*Math.cos(t),y:e.cy+e.radius*Math.sin(t)}),qp=/^(?:https?:|mailto:)/i,Xp=e=>{if(typeof e!="string")return!1;const t=e.replace(/^[\x00-\x20]+/,"");return t.length===0?!1:qp.test(t)},jp=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",year:"numeric",weekday:"long",...L,...t});return T(n=>r.format(n))},Zp=({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)),Pe=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return Bn(e);case"date":return jp(e);case"datetime":return Zp(e);case"day_month":return Kn(e);case"decimal":return Gn(e);case"duration":return xt(e);case"integer":return Hn(e);case"month":return zn(e);case"month_year":return Tt(e);case"percentage":return $n(e);case"quarter":return Lt(e);case"text":return bt(e);case"time":return Wn(e);case"weekly_date_range":return Yn(e);case"weekly_date_range_with_year":return Un(e);case"year":return Et(e);case"lookup":return Pe({...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=" · ",Jp=({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=ef(m,h);if(s==="none")return g===null?null:{heading:null,rows:[],comment:g};const S=mf({guides:n,locale:f,numberFormat:a}),x=g===null?tf({layers:e,coordSystem:t,guides:n,primary:p,mode:s,locale:f,numberFormat:a,resolveColorLabel:S}):mi;return{heading:x.text,rows:af({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}},Qp=(e,t,r)=>{if(W(t,"line"))return e.geom.line(t).get("dashArray",r);if(W(t,"area"))return e.geom.area(t).get("dashArray",r);if(W(t,"rule"))return e.geom.rule(t).get("dashArray",r)};function ef(e,t){return e===void 0||t===null||t===void 0?null:e.find(r=>r.id===t)?.content??null}function tf(e){const t=e.layers.find(i=>i.id===e.primary.layerId);if(!t)return mi;const r=e.mode==="observation"?Xt(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&&nf(t,n)?r:null}}const a=rf(t,e);return a===null||r===null?{text:a,group:null}:{text:`${a}${hi}${r}`,group:r}}function rf(e,t){if(t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null)return null;const r=Bt(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)?Pe({valueFormat:r.valueFormat,locale:t.locale,numberFormat:t.numberFormat})(a):null}function Xt(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 nf(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 af(e){const t=e.layers.find(r=>r.id===e.primary.layerId);return of(e.layers.flatMap(r=>{const n=uf({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=sf(e,r,i,a,`${a.layerId}:${a.pointIndex}:field-${o}`);return s===null?[]:[s]})}))}function of(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=df({hits:n,layer:t,colorScale:e.scales.color??null,colorValueReader:a}),o=r.format===void 0?Pt({layer:t,numberFormat:e.numberFormat,locale:e.locale}):I({valueFormat:r.format,locale:e.locale,numberFormat:e.numberFormat}),s=r.title??hf(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(Xt(t,u,e.resolveColorLabel),s,e.headingGroup),f=c(u.observation);return{row:{swatchColor:ke(e.readers,t,u.observation)??null,geom:t.geom,swatchLineType:Ot(Qp(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 sf(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}:lf(t,r,n,e);return{row:{swatchColor:s?ke(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 lf(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(Xt(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=>cf(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 cf=(e,t)=>l.getStableKey(e??null)===l.getStableKey(t??null);function uf({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 df({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 mf({guides:e,locale:t,numberFormat:r}){const n=new Map(e.colorGroups.map(i=>[l.getStableKey(i.value),{label:i.label,format:Pe({valueFormat:i.valueFormat,locale:t,numberFormat:r})}])),a=Pe({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 hf(e,t){return d.resolveVariableLabel(l.readVariableName(t.mapping.y),e.variableLabels)??""}function pf(e,t,r=0){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:r}function ff(e,t,r=""){const n=e[t];return typeof n=="string"?n:r}var gf=(e,t)=>({...e.annotation.arrow(t).resolve(),outline:e.annotation.arrow.outline(t).resolve()}),vf=(e,t)=>{const r=e.annotation.differenceArrow(t);return{...r.resolve(),isStrokeAuthored:Dt(r.getSource("stroke")),label:e.annotation.differenceArrow.label(t).resolve()}},yf=(e,t,r)=>{const n=e.annotation[t](r),a=e.annotation[t].label(r);return{marker:{...n.resolve(),isFillAuthored:Dt(n.getSource("fill"))},label:{...a.resolve(),isTextColorAuthored:a.getSource("textColor")==="authored"}}},Sf=e=>e.strokeWidth>0?e.stroke??l.toPaintColor(e.fill):void 0,bf=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")}),xf=e=>({...l.DEFAULT_GRAPH_PADDING_EDGES_PX,...e.graph().get("padding")}),R=e=>{let t={top:0,right:0,bottom:0,left:0};for(const r of e.collectAll("margin"))t={...t,...r};return t},Af=e=>({header:R(e.header()),footer:R(e.footer()),headline:R(e.headline()),legend:{top:R(e.legend.top()),right:R(e.legend.right()),bottom:R(e.legend.bottom()),left:R(e.legend.left())},axisLabel:{top:R(e.axisLabel.top("x")),bottom:R(e.axisLabel.bottom("x"))},tickLabel:{top:R(e.tickLabel.top("x")),right:R(e.tickLabel.right("y")),bottom:R(e.tickLabel.bottom("x")),left:R(e.tickLabel.left("y"))}}),If=e=>({hover:e.editOutline.hover().resolve(),selected:e.editOutline.selected().resolve()}),Tf={color:l.getColor,alpha:l.getAlpha,strokeWidth:l.getStrokeWidth,lineType:l.getLineType,size:l.getSize},vn={vocabulary:{},aesthetics:{}},yn=new WeakMap,Lf=(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}=Ef(c.styles,u),g=Pf({styles:wf(c.styles,u),colorScheme:t,vocabulary:p,visualVariableReaders:Cf(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=Rc(a);return{readers:c=>{const u=n.get(c.chrome);if(u!==void 0)return u;const m=wc(c.chrome,o,t);return n.set(c.chrome,m),m}}},Ef=(e,t)=>t===void 0?e.observation:Object.hasOwn(e.parts,t)?e.parts[t]??vn:vn,Cf=(e,t)=>{const r={};for(const[n,a]of Object.entries(e)){const i=a===void 0?void 0:Tf[a];i!==void 0&&(r[n]=a==="lineType"?Rf(t):i)}return r},Rf=e=>t=>{const r=l.getLineType(t);return r===void 0?void 0:e[r]},wf=(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=Ae(e.overrides,h,p,f,t);if(x!==void 0)return x;const A=Ae(e.defaults,h,p,f,t);if(A!==void 0)return A}const g=Ae(e.overrides,h,p,void 0,t);if(g!==void 0)return g;const S=i(h,p);return S!==void 0?S:Ae(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}},Ae=(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"],Mf=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"?Of(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=Df)=>{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},Df=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,Of=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),_f=(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(Vf),transforms:e.transforms,highlights:e.highlights,styles:b.styles(e.styles),annotations:e.annotations,coords:e.coords,config:t===void 0?e.config:kf(e.config,t)}}var kf=(e,t)=>Ti({...e},{...t}),bn=e=>(0,N.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,N.isEqual)(a,i)?[]:[[n,a]]});return Object.fromEntries(r)}function Vf(e){const{inferredFrom:t,...r}=e;return r.scaleType==="palette"?Nf(r):r}function Nf(e){return{...e,palette:Ff(e.palette),overrides:Bf(e.overrides)}}function Ff(e){return e.type==="custom"?{type:"custom",id:e.id}:e}function Bf(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)}}},Gf={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=$f(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)}}},Hf={type:"add-annotation",deserialize:(e,t)=>new Qt({kind:e.kind,annotation:e.annotation,index:e.index},t)},$f=(e,t)=>{const r=Zt(t);return r===null?null:Si(e,r)},Kf=(e,t)=>{const r=er(e);return r===null?null:Ei(r.points,t)},zf=e=>er(e)!==null,Yf=(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=Wf[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})},Uf=(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}})},Wf={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=>Uf(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,N.clamp)(t,r,n)},Ci=(e,t,r)=>{const n=t.annotation;if(!jf(n,r))return null;const a=d.readAnnotationBucket(e.annotations,t.kind),i=qf(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:Xf(n,r)}},qf=(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)))},Xf=(e,t)=>{const r={};for(const n of Object.keys(t))r[n]=e[n];return r},jf=(e,t)=>Object.entries(t).some(([r,n])=>!Object.is(e[r],n)),tr=class Ri{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=Ci(t,i,a);return o===null?null:{spec:o.spec,revert:new Ri({kind:r,id:n,patch:o.inverse},this.metadata)}}},Zf={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=Yf(t,this.params.translation);if(r===null)return null;const n=Ci(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)}}},Jf={type:"move-annotation",deserialize:(e,t)=>new wi(e,t)},B=class Le{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 Le({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 Le({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 Le({list:r,rule:{...n,declarations:null}},this.metadata);return{spec:tt(t,r,p),revert:f}}},Qf=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."})},eg={type:"set-style-rule",deserialize:(e,t)=>(Qf(e),new B(e,t))},tt=(e,t,r)=>d.patchSpec(e,{styles:{...e.styles,[t]:r}}),tg={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 B({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)}}},rg=["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:ce(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:pg(t)})}apply(t){const r="previous"in this.params?this.params.previous:fg(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)}}},ng={type:"set-chart-type",deserialize:(e,t)=>new Oi(e,t)},ki={type:"sum"},ag={type:"identity"},ig=["bar","line","area","point","tile"],nr="tile",og=["y","color"],sg=Object.values(l.LAYER_LABEL_VARIABLES),lg={coordType:"cartesian",geom:nr,position:"identity"},de=e=>e.coordType==="cartesian"&&"comboType"in e&&b.COMBO_TYPES.includes(e.comboType),cg=e=>{const t=e.layers.filter(G),[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}},ug=e=>{if(!e)return!1;const t=e.layers.filter(G);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},dg=e=>e?Yi(e,lg)!==null:!1,mg=e=>Vi(e)?.at(-1)?.id??null,Vi=e=>{if(e.coords.coordType!=="cartesian")return null;const t=e.layers.filter(G);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 hg(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)},hg=e=>e.some(t=>t.yScaleType==="secondary"||Me(t))||new Set(e.map(t=>l.readVariableName(t.mapping.y))).size>1,pg=e=>"previous"in e?"Restore the previous chart type":de(e)?`Set chart type to a ${e.comboType} combo`:`Set chart type to ${e.position} ${e.geom} in ${e.coordType} coords`,fg=(e,t)=>{const r=Yi(e,t);if(r===null)return null;const n=de(t)?vg(r,t):gg(r,t,e);return n===null||r===e?n:{...n,scales:Pg({...e,...n},n.scales)}},gg=(e,t,r)=>{if(de(t)||!Mg(t))return null;const n={...e,layers:Ji(e.layers)},a=_g(n.layers.filter(G),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}},vg=(e,t)=>{const r=bg(e,t.comboType);if(r===null)return null;const n={...e,layers:r},a=kg(r.filter(G),t.comboType),i=eo(n.coords,t),o=Ki(n,t),s=Zi({...n,mapping:o},t,a,o!==n.mapping),c=yg(e)?s:Sg(s);return{coords:i,layers:c,scales:rr(to(e,c,i.coordType),c),mapping:o}},yg=e=>Vi(e)!==null,Sg=e=>{const t=e.filter(G).at(-1);return t===void 0||t.yScaleType==="secondary"?e:e.map(r=>r.id===t.id?{...r,yScaleType:"secondary"}:r)},bg=(e,t)=>{const r=e.layers.filter(G);if(r.length>=2)return e.layers;const[n]=r;return n===void 0?null:Fi(e,n)?xg(e,n):Ag(e,n,t)},Fi=(e,t)=>{const r=l.readVariableName(t.mapping.color??e.mapping.color);return r!==null&&r!==""},xg=(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=me(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)},me=e=>l.readMainAxisVariable(e.mapping)||l.inferXVariable(e.data),Ag=(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,me(e)),s=b.COMBO_BAR_POSITIONS[r]===null?l.LAYER_LABEL_VARIABLES.line:l.LAYER_LABEL_VARIABLES.bar,c=Ig(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})]}),Ig=(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)?"":me(e);return n===r?e.mapping:{...e.mapping,x:n}},zi=e=>e.coordType==="polar"&&e.theta==="y"&&e.position==="fill",Tg=e=>!de(e)&&e.geom===nr,Lg=e=>e.layers.filter(G).some(t=>t.geom===nr),Yi=(e,t)=>{const r=Tg(t);return r===Lg(e)?e:r?Eg({...e,layers:Ji(e.layers)}):Cg(e)??e},Eg=e=>{const t=Wi(e);if(t===null)return null;const r=Rg(e,t)===null?wg(e,t):qi(e,t);return r===null?null:Ui(e,t,r)},Cg=e=>{const t=Wi(e);if(t===null)return null;const r=qi(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(G);return t.length===1?t[0]??null:null},qi=(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:Xi(t)}},Xi=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}},Rg=(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===me(e))return null;const i=ce(e);return i.hasVariable(n)&&i.getType(n)==="numeric"?null:n},wg=(e,t)=>{const r=ze(e,e.data.groupVariableNamesByType().numeric);if(r.length<2)return null;const n=l.readFoldKeepVariables(e.data,me(e)),a=Hi(r,n),i=Xi(t);return{mapping:{...e.mapping,y:a.mapping.color,color:a.mapping.y},layer:{...i,transforms:[...i.transforms,...a.transforms]}}},Pg=(e,t)=>og.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),Mg=e=>rg.includes(e.coordType)&&ji(e.geom)&&Dg(e)&&(e.coordType!=="polar"||Number.isFinite(e.innerRadius)),Dg=({geom:e,coordType:t,position:r})=>{const{supportedCoordTypes:n,supportedPositions:a}=w.get(e);return n.includes(t)&&a.includes(r)},ji=e=>ig.includes(e),G=e=>ji(e.geom)&&!Og(e.stat),Og=e=>{switch(e.type){case"smooth":return!0;case"identity":case"count":case"mean":case"sum":case"summary":return!1;default:return!0}},_g=(e,{geom:t,position:r})=>{const n={geom:t,position:r};return new Map(e.map(a=>[a.id,n]))},kg=(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:Vg(i,t,n)}]);return new Map(a)},Vg=(e,t,r)=>e.geom!=="bar"||Me(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=Ng(i.stat,e.coords,t);return a||n||i.geom!==o.geom||i.position!==o.position||s!==i.stat?Bg(e,{...i,stat:s},t.coordType,o):i}))},Ng=(e,t,r)=>zi(r)?e.type==="identity"?ki:e:Fg(t)&&e.type==="sum"?ag:e,Fg=e=>e.coordType==="polar"&&e.params.theta==="y",Bg=(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(G);if(t.length<2||!e.some(Me))return e;const[r]=t;return e.flatMap(n=>n===r?[Gg(n)]:Me(n)?[]:[n])},Me=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:sg.includes(t.options.variableName)?t:null},Gg=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=Hg(e,t);return(0,N.isEqual)(r,e)?e:r},Hg=(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=$g(o,n,a),c=Kg(s,n,a);return Yg(c,r,i)})},$g=(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=zg(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},Kg=(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}},zg=(e,t,r)=>t.nice===(r?.nice??!0)?e:t.nice?l.CONTINUOUS_SCALE_DEFAULTS.nice:!1,Yg=(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:Wg(t)})}apply(t){const r="previous"in this.params?this.params.previous:qg(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)}}},Ug={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,Wg=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}`},qg=(e,{aesthetic:t,variable:r})=>{if(!b.isAestheticKey(t))return null;const n=io(r),a=jg(e.mapping,t,n);return a===e.mapping?null:{mapping:a,scales:Jg(e,t,a,n),layers:Xg(e.layers,a)}},Xg=(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,N.isEqual)(a,r.dataLabels.labelSource)?r:{...r,dataLabels:{...r.dataLabels,labelSource:a}}}),jg=(e,t,r)=>r===null?Zg(e,t):ao(e,t)===r?e:{...e,[t]:r},Zg=(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},Jg=(e,t,r,n)=>{if(!l.isScaledAestheticKey(t))return e.scales;let a=e.scales;for(const i of Qg(e,t))a=tv(e,a,i,r,n);return a},Qg=(e,t)=>t==="y"&&ev(e.layers)?["y","ySecondary"]:[t],ev=e=>{const t=e.find(r=>r.yScaleType==="secondary");return t!==void 0&&t.mapping.y===void 0},tv=(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&&!ce(e).hasVariable(a))return t;const o=ft(e,r,n);return rv(i,o)?t:d.mapItems(t,s=>s.scaledAesthetic===r?o:s)},rv=(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 he(e)?e[t]:e}function nv(e,t){return e.config.axes[t]??{}}function av(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 he(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?iv(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 iv(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 ${sv(t.label)}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,label:n}=this.params,a=nv(t,r).label;if(a===n)return null;const i=av(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)}}},ov={type:"set-axis-label",deserialize:(e,t)=>new lo(e,t)};function sv(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)}}},lv={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)}}},cv={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)}}},uv={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)}}},dv={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)}}},mv={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)}}},hv={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)}}},pv={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)}}},fv={type:"set-content-title",deserialize:(e,t)=>new Lo(e,t)},Co=(e,t,r,n)=>{const a=gv(t,r),i=yv(e,a,n);let o=e,s=!1;for(const c of a){const u=bv(o,c,n,Sv(c,n,vv(r,c)));u!==null&&(o=u,s=!0)}return s?{spec:o,previous:i}:null},gv=(e,t)=>e==="both"&&!he(t)?[void 0]:ar(e),vv=(e,t)=>t===void 0?he(e)?e.x:e:ir(e,t),yv=(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,Sv=(e,t,r)=>r===null||t==="strokeWidth"?r:(e===void 0?["x","y"]:[e]).every(n=>Ro(l.STYLE_TARGETS.gridLine.children[n].rest[t],r))?null:r,Ro=(e,t)=>Array.isArray(e)&&Array.isArray(t)?_t(e,t):e===t,bv=(e,t,r,n)=>{const a=wo(e,t);return Ro(a?.[r]??null,n)?null:new B({list:"overrides",rule:Tv(t,Iv(a,r,n))}).apply(e)?.spec??null},xv=e=>e.select.target==="gridLine",Av=e=>({select:e===void 0?{target:"gridLine"}:{target:"gridLine",axis:e}}),wo=(e,t)=>{const r=d.findStyleRule(e.styles.overrides,Av(t),d.readStyleCoord(e));if(!(r===void 0||!xv(r)))return r.declarations},Iv=(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),Tv=(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 ${Ev(t)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineStyle:n}=this.params,a=Co(t,r,Cn(n,Cv),"dashArray");return a===null?null:{spec:a.spec,revert:new Mo({axis:r,lineStyle:Cn(a.previous,Rv)},this.metadata)}}},Lv={type:"set-grid-line-style",deserialize:(e,t)=>new Po(e,t)},Ev=({axis:e,lineStyle:t})=>{const r=ar(e).map(n=>ir(t,n)??"(theme)");return[...new Set(r)].join(" and ")},Cv=e=>e===null?null:l.DASH_PRESETS.gridLine[e],Rv=e=>e===null?null:Ot(e),Cn=(e,t)=>he(e)?{x:t(e.x),y:t(e.y)}:t(e),wv={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 ${Mv(t.axis,n)}`})}get target(){return{kind:"grid",axis:this.params.axis}}apply(t){const{axis:r,lineWidth:n}=this.params,a=Co(t,r,n,"strokeWidth");return a===null?null:{spec:a.spec,revert:new Oo({axis:r,lineWidth:a.previous},this.metadata)}}},Pv=e=>he(e)?{x:nt(e.x),y:nt(e.y)}:nt(e),nt=e=>e===null||!Number.isFinite(e)?null:Math.max(0,e),Mv=(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)}}},Dv={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)}}},Ov={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)}}},_v={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)}}},kv={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)}}},Vv={type:"set-headline-size",deserialize:(e,t)=>new $o(e,t)},Nv={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 B({list:"overrides",rule:Bv(this.params.dimStyle,Fv(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",Fv=e=>{const t=d.readStyleCoord(e);return d.combineStyleDeclarations(d.readStyleRulesBeneath(e.styles.overrides,gt,t),gt,t)?.saturation===0},Bv=(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)}}},Gv={type:"set-legend-align",deserialize:(e,t)=>new Uo(e,t)},qo=class Xo{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 Xo({display:r},this.metadata)}}},Hv={type:"set-legend-display",deserialize:(e,t)=>new qo(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)}}},$v={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)}}},Kv={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)}}},zv={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)}}},Yv={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=Wv(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)}}},Uv={type:"toggle-content-visibility",deserialize:(e,t)=>new as(e,t)},Rn={title:"isTitleVisible",subtitle:"isSubtitleVisible",caption:"isCaptionVisible",source:"isSourceVisible"};function Wv(e){return Object.hasOwn(Rn,e)?Rn[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:Xv(t.coords,i)}),revert:s}}},qv={type:"set-coord-limits",deserialize:(e,t)=>new os(e,t)};function Xv(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,N.clamp)(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)}}},jv={type:"set-polar-inner-radius",deserialize:(e,t)=>new ls(e,t)},Zv={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}}},Jv={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}}},Qv={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)}}},ey={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)}}},ty={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 B({list:"overrides",rule:{...a,declarations:ny(i,n)}}).apply(t);if(!s)return null;const c=new hs({layerId:r,cornerRadius:o},this.metadata);return{spec:s.spec,revert:c}}},ry={type:"set-bar-corner-radius",deserialize:(e,t)=>new ms(e,t)},ny=(e,t)=>{const{cornerRadius:r,...n}=e??{};return t!==null?{...n,cornerRadius:t}:Object.keys(n).length===0?null:n},ay={type:"set-bar-width",deserialize:(e,t)=>new fs(e,t)},ps=.05,iy=1,fs=class gs{constructor(t,r={}){this.type="set-bar-width";const n=t.width===void 0?void 0:(0,N.clamp)(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)}}},oy={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)}}},sy={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 cy(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)}}},ly={type:"set-layer-stat",deserialize:(e,t)=>new xs(e,t)},cy=(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)}}},uy={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)}}},dy={type:"set-line-curve",deserialize:(e,t)=>new Ls(e,t)},Cs=class Rs{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 Rs({layerId:r.id,missingValues:n},this.metadata)}}},my={type:"set-line-missing-values",deserialize:(e,t)=>new Cs(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=py(i,n),c=new B({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}},hy={type:"set-line-width",deserialize:(e,t)=>new ws(e,t)},py=(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 B({list:"overrides",rule:{...a,declarations:gy(i,n)}}).apply(t);return s?{spec:s.spec,revert:new Ds({layerId:r,size:o},this.metadata)}:null}},fy={type:"set-point-size",deserialize:(e,t)=>new Ms(e,t)},gy=(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)}}},vy={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)}}},yy={type:"set-rule-value",deserialize:(e,t)=>new ks(e,t)},Sy={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:Ey(t.line)})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=xy(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 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"?Ay(this.params):Iy(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}}},by="linear",xy=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}},Ay=({method:e})=>l.geom.line({aes:{lineType:{value:"dashed"}},stat:b.stat.smooth({method:e??by}),interactive:!1}),Iy=(e,{group:t,label:r})=>{const n=Ty(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})},Ty=e=>e.layers.find(t=>t.geom!=="rule"&&t.stat.type!=="smooth"),Ly=(e,t)=>(0,N.isEqual)({...e,id:""},{...t,id:""}),Ey=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)}}},Cy={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)}}},Ry={type:"toggle-data-labels",deserialize:(e,t)=>new Hs(e,t)},wy={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??Py}},params:{labelPosition:r,...this.params.label!==void 0&&{label:this.params.label}},interactive:!1}))}},Py=0,My={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=Oy(r,n,Pn(s?.fillAlpha));return new B({list:"overrides",rule:{...a,declarations:_y(o,c)}},this.metadata).apply(e)}},Dy=.2,Pn=e=>(e??0)>0,Oy=(e,t,r)=>e?t??(r?null:Dy):r?0:null,_y=(e,t)=>{const{fillAlpha:r,...n}=e??{};return t!==null?{...n,fillAlpha:t}:Object.keys(n).length===0?null:n},ky={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)}}},Vy={type:"toggle-stack-totals",deserialize:(e,t)=>new Us(e,t)},qs=class Xs{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 Xs(c,this.metadata)}}},Ny={type:"set-scale-domain",deserialize:(e,t)=>new qs(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)}}},Fy={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||!Gy(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)}}},By={type:"set-scale-reverse",deserialize:(e,t)=>new Js(e,t)};function Gy(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)}}},Hy={type:"set-scale-transform",deserialize:(e,t)=>new el(e,t)},$y=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,N.isEqual)(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=Ta(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 Yy(n,o))a(zy(n,s,o.property));for(const o of t)a(Wy(n,o,this.params.color));if(r.length===0||(0,N.isEqual)(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)}}},Ky={type:"set-observations-color",deserialize:(e,t)=>new nl(e,t)},zy=(e,t,r)=>{const n=t[t.length-1];if(n===void 0||!t.some(o=>Uy(o.declarations,r)))return[];const a=il(al(t),r,null);if(t.length===1)return a!==null&&d.areStyleDeclarationsEqual(a,n.declarations)?[]:[K(n,a)];const i=[K(n,null)];if(a!==null){const o=d.findStyleRuleIndex(e.styles.overrides,n,d.readStyleCoord(e));i.push(K(n,a,o-(t.length-1)))}return i},Yy=(e,t)=>{const r=[],n=new Map;for(const a of e.styles.overrides){if(a.when?.state!==void 0||!Xy(a,t)||!jy(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}),{}),Uy=(e,t)=>Object.entries(e).some(([r])=>r===t),Wy=(e,t,r)=>{const n=e.styles.overrides,a=qy(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?[]:[K(a,c)];if(!d.isGeomStyleRule(s))return[];if(c===null)return[K(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[K(s,c)];const m=u?o-(i.length-1):void 0;return[K(s,null),K(s,c,m)]},K=(e,t,r)=>new B({list:"overrides",rule:{...e,declarations:t},...r===void 0?{}:{index:r}}),qy=e=>({select:{target:"geom",kind:e.geomKind,layer:e.layerId},...e.where===void 0?{}:{when:{where:e.where}}}),Xy=(e,t)=>d.isGeomStyleRule(e)&&e.select.kind===t.geomKind&&e.select.layer===t.layerId&&e.select.part===void 0,jy=(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,N.isEqual)(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(ng);v.register(Ug);v.register(ty);v.register(ey);v.register(oy);v.register(sy);v.register(ly);v.register(uy);v.register(dy);v.register(hy);v.register(ry);v.register(ay);v.register(fy);v.register(my);v.register(vy);v.register(yy);v.register(Sy);v.register(Cy);v.register(Ry);v.register(wy);v.register(My);v.register(ky);v.register(Vy);v.register(Ny);v.register(Fy);v.register(By);v.register(Hy);v.register(ov);v.register(cv);v.register(lv);v.register(uv);v.register(dv);v.register(mv);v.register(hv);v.register(pv);v.register(fv);v.register(Lv);v.register(wv);v.register(Dv);v.register(Ov);v.register(_v);v.register(kv);v.register(Vv);v.register(Nv);v.register(Gv);v.register(Hv);v.register($v);v.register(Kv);v.register(zv);v.register(Yv);v.register(Uv);v.register(Qv);v.register(Jv);v.register(eg);v.register(Ky);v.register(Hf);v.register(Gf);v.register(Zf);v.register(tg);v.register(Jf);v.register(qv);v.register(jv);v.register(Zv);v.register({type:"sequence",deserialize:(e,t)=>($y(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&&Jy(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)}}},Zy=Object.freeze([]),Jy=(e,t)=>e.type===t.type&&sl(e.target,t.target),Dn=e=>e.length===0?Zy:e.map(t=>t.command.metadata),Qy=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}},eS=class{constructor(e){this.compiler=e,this.history=new ll,this.current=null,this.last=null,this.hostSpec=null,this.run=new Qy(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}},tS=new Set(["x","y"]),On=["numeric","categorical","temporal"],_n=["numeric"],rS=(e,t)=>{const r=e.layers.map(a=>Di(a.geom)).filter(l.isDefined),n=ce(e);return t.filter(a=>nS(e,r,a)).map(a=>({aesthetic:a,variables:aS(n,r,a),isRequired:tS.has(a)}))},nS=(e,t,r)=>{switch(r){case"x":return!sS(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))}},aS=(e,t,r)=>{const n=iS(t,r);return e.getVariableNames().filter(a=>!l.isInternalVariable(a)&&n.includes(e.getType(a)))},iS=(e,t)=>t==="size"?_n:t!=="x"&&t!=="y"?On:oS(e,t)?_n:On,oS=(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))),sS=e=>e.coordType==="polar"&&e.params.theta==="y",lS=500,cS="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},uS=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,dS="\0",mS=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(dS)}},hS={" ":.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 pS=1.05,fS=.84,gS=.21,vS=class{measureText(e,t){const r=cl(e,t.textTransform);let n=ul(r,t.letterSpacing);for(const o of r)n+=(hS[o]??.55)*t.size;pr(t.weight)>=hr.semiBold&&(n*=pS);const a=fS*t.size,i=gS*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=Fu;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=Gt;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=mS;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=cS;exports.DEFAULT_FONT_WEIGHT=lS;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=eS;exports.HEADING_PARTS=b.HEADING_PARTS;exports.HEADLINE_ITEM_PARTS=b.HEADLINE_ITEM_PARTS;exports.HEADLINE_SWATCH_GAP_EM=Ca;exports.HEADLINE_TREND_GAP_EM=wa;exports.HEADLINE_TREND_ICON_SIZE_PX=mm;exports.HEADLINE_VALUE_LABEL_GAP_EM=Ra;exports.HeuristicTextMeasurer=vS;exports.HoverEngine=hp;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=mu;exports.MAX_BAR_WIDTH_FRACTION=iy;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=Bu;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=$;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=Gu;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=qo;exports.SetLegendPlacementCommand=jo;exports.SetLegendPositionCommand=Jo;exports.SetLineCurveCommand=Ls;exports.SetLineMissingValuesCommand=Cs;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=qs;exports.SetScalePaletteCommand=js;exports.SetScaleReverseCommand=Js;exports.SetScaleTransformCommand=el;exports.SetStatLineCommand=Ns;exports.SetStyleRuleCommand=B;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=Va;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=_t;exports.areEditMenuTriggersEqual=xd;exports.areEditTargetsEqual=sl;exports.areEndpointsComparable=d.areEndpointsComparable;exports.areMappingsEquivalent=l.areMappingsEquivalent;exports.areObservationAnchorsEqual=yi;exports.arePointerRegionListsEqual=pd;exports.arePredicatesEqual=d.arePredicatesEqual;exports.areStyleDeclarationsEqual=d.areStyleDeclarationsEqual;exports.areStyleRuleAddressesEqual=d.areStyleRuleAddressesEqual;exports.buildAverageLineSymbols=_u;exports.buildBarRectBounds=Ma;exports.buildCalloutHitRegions=Nu;exports.buildColumnKey=Da;exports.buildDataLabelsContent=Xu;exports.buildDiagnostic=d.buildDiagnostic;exports.buildEditMenuTriggerRegion=Sd;exports.buildFontString=uS;exports.buildHeadlineItemRows=hm;exports.buildLayerIntroPlan=Cp;exports.buildLayerStyleAddress=d.buildLayerStyleAddress;exports.buildObservationPredicate=td;exports.buildObservationsTarget=Sa;exports.buildObservationsTargetAtValue=sd;exports.buildPanelAnchorBox=l.buildPanelAnchorBox;exports.buildPointSymbolInBox=Rm;exports.buildPointSymbolPath=Cm;exports.buildPolarBarArcPath=km;exports.buildSliceGroupKey=Na;exports.buildTooltipContent=Jp;exports.canAnchorDirectLabels=d.canAnchorDirectLabels;exports.canBecomeCombo=ug;exports.canBecomeHeatmap=dg;exports.canPlaceDataLabels=qu;exports.clampAnnotationTranslation=Kf;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=Mu;exports.computeDifferenceArrow=ra;exports.computeDirectLabelsLayout=ed;exports.computeLetterSpacingWidth=ul;exports.computeLineBoxHeight=ia;exports.computePanelBorderPaths=Hp;exports.computePanelBorderSizes=$p;exports.config=b.config;exports.coord=b.coord;exports.countLayerGeoms=Rp;exports.createAlphaValueReader=d.createAlphaValueReader;exports.createAnchorResolver=fu;exports.createAreaPathGenerators=ym;exports.createColorValueReader=d.createColorValueReader;exports.createCompiler=d.createCompiler;exports.createDataLabelPlacementResolver=Qn;exports.createDatasetFromKindPartitions=d.createDatasetFromKindPartitions;exports.createEmptyLayerStyles=d.createEmptyLayerStyles;exports.createGroupValueReader=d.createGroupValueReader;exports.createLabelValueReader=d.createLabelValueReader;exports.createLayerYValueFormatter=Pt;exports.createLineFillAreaGenerator=Lm;exports.createLinePathGenerator=Tm;exports.createObservationAnchorBuilder=d.createObservationAnchorBuilder;exports.createObservationAnchorParser=d.createObservationAnchorParser;exports.createPinnedNumberValueFormatter=em;exports.createRawValueReader=d.createRawValueReader;exports.createSegmentYReader=d.createSegmentYReader;exports.createSizeValueReader=d.createSizeValueReader;exports.createSpec=b.createSpec;exports.createSpecBuilder=b.createSpecBuilder;exports.createStableBandKeyGenerator=Wm;exports.createStableCellKeyGenerator=qm;exports.createStableKeyGenerator=Ne;exports.createStablePolarBarKeyGenerator=Xm;exports.createStrokeWidthValueReader=d.createStrokeWidthValueReader;exports.createStyleResolver=Lf;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=pa;exports.filterLayersByGeoms=d.filterLayersByGeoms;exports.findAnnotation=d.findAnnotation;exports.findAverageLineLayer=Ai;exports.findAxisGuide=Bt;exports.findCompanionLayers=d.findCompanionLayers;exports.findDefaultKitStyleTarget=d.findDefaultKitStyleTarget;exports.findDistinctLayers=d.findDistinctLayers;exports.findEquivalentHighlight=_f;exports.findGoalLineLayer=bi;exports.findHighlightsAtObservation=Id;exports.findHostLayer=d.findHostLayer;exports.findKindStyleDeclarations=d.findKindStyleDeclarations;exports.findLayerByGeom=d.findLayerByGeom;exports.findLayerById=d.findLayerById;exports.findLegendForAesthetic=um;exports.findObservationAttachment=Si;exports.findPointerRegion=md;exports.findStyleRule=d.findStyleRule;exports.findStyleRuleIndex=d.findStyleRuleIndex;exports.findTrendLineLayer=xi;exports.formatDifferenceLabel=ea;exports.formatHeadline=tm;exports.formatLegends=lm;exports.formatRuleValue=dm;exports.geom=l.geom;exports.getAestheticFromScaleAestheticKey=l.getAestheticFromScaleAestheticKey;exports.getAlpha=l.getAlpha;exports.getAngleExtent=l.getAngleExtent;exports.getBarRectBounds=Pa;exports.getBoundingRect=Am;exports.getColor=l.getColor;exports.getCrossAxisCoordinate=d.getCrossAxisCoordinate;exports.getCurve=Ve;exports.getDifferenceArrowDimensions=ta;exports.getDifferenceArrowLabelBox=sa;exports.getGroup=d.getGroup;exports.getGroupVariables=l.getGroupVariables;exports.getHoverGuideLineProps=yp;exports.getHoverGuideRectProps=Sp;exports.getInsetTileRect=l.getInsetTileRect;exports.getLineType=l.getLineType;exports.getMainAxisCoordinate=d.getMainAxisCoordinate;exports.getNumericWeight=pr;exports.getPaintedTileRect=l.getPaintedTileRect;exports.getPointSymbolOuterRadius=wm;exports.getPolarHoverGuideArcProps=bp;exports.getRadiusExtent=l.getRadiusExtent;exports.getScaledAesthetic=l.getScaledAesthetic;exports.getShapeAnnotationStroke=Sf;exports.getSize=l.getSize;exports.getStackRole=l.getStackRole;exports.getStrokeWidth=l.getStrokeWidth;exports.getTileRectBounds=l.getTileRectBounds;exports.getUnionExtent=_m;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=Ia;exports.hasMultipleGroups=l.hasMultipleGroups;exports.highlight=b.highlight;exports.inferDefaultDifferenceArrowEndpoints=Ed;exports.inferDifferenceArrowEndpoints=Aa;exports.inferXVariable=l.inferXVariable;exports.isAnnotationMovable=zf;exports.isBorderRadiusToken=l.isBorderRadiusToken;exports.isCartesian=d.isCartesian;exports.isCategoricalValueFormat=l.isCategoricalValueFormat;exports.isComboChartType=de;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=_e;exports.isLayerOf=W;exports.isLayerSpecOf=d.isLayerSpecOf;exports.isLineType=l.isLineType;exports.isLookupValueFormat=l.isLookupValueFormat;exports.isNumericValueFormat=l.isNumericValueFormat;exports.isObservationAttachmentKind=Mf;exports.isOpaquePaint=l.isOpaquePaint;exports.isPatternPaint=l.isPatternPaint;exports.isPointWithinEditMenuTrigger=bd;exports.isPointWithinRegionShape=Vt;exports.isPositionScale=l.isPositionScale;exports.isSafeUrl=Xp;exports.isStackedPosition=l.isStackedPosition;exports.isTemporalValueFormat=l.isTemporalValueFormat;exports.isZeroAnchoredAxis=Rd;exports.mapping=b.mapping;exports.measureObservationsBoxes=Pd;exports.normalizeAngle=l.normalizeAngle;exports.orderPointerRegions=hd;exports.paintKey=l.paintKey;exports.paintsEachGroupFromItsFirstObservation=d.paintsEachGroupFromItsFirstObservation;exports.paintsInDonutHole=Oe;exports.pickFilters=ui;exports.pickReadableTextColor=l.pickReadableTextColor;exports.pipe=b.pipe;exports.placeCallouts=Yu;exports.polarToUnit=l.polarToUnit;exports.positionToAngle=l.positionToAngle;exports.prefixInternalVariable=l.prefixInternalVariable;exports.prepareAreaObservations=Sm;exports.prepareLineObservations=Em;exports.projectAnchorToPanel=Ee;exports.projectRegionToPanel=da;exports.quantizeKey=k;exports.readAnchoredObservation=Od;exports.readAttachedObservation=Zt;exports.readAuthoredNumber=pf;exports.readAuthoredString=ff;exports.readBackdropColor=l.readBackdropColor;exports.readBroadestObservationsScope=ba;exports.readChartType=cg;exports.readColorGroupObservation=jm;exports.readComboLineLayerId=mg;exports.readCompanionRowsAtScopeKey=ad;exports.readConstantValue=l.readConstantValue;exports.readEditTargetKey=St;exports.readFoldKeepVariables=l.readFoldKeepVariables;exports.readGeomColor=ke;exports.readGeomEffects=Fp;exports.readHighlightDimStyle=Yo;exports.readMainAxis=d.readMainAxis;exports.readMainAxisVariable=l.readMainAxisVariable;exports.readMappableAesthetics=rS;exports.readMappedVariable=ao;exports.readObservationIndex=xp;exports.readObservationsColorRoute=Ta;exports.readPaletteChoices=Gd;exports.readPresentedGroupColor=Km;exports.readPresentedObservationsColor=zd;exports.readReachableLevels=Ud;exports.readRowScopeKey=ya;exports.readRowsAtScopeKey=kt;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=gf;exports.resolveArrowColor=Ju;exports.resolveBarBandFraction=l.resolveBarBandFraction;exports.resolveBarBaseline=$t;exports.resolveBarBorderTreatment=xm;exports.resolveBarCornerRadiiPx=bm;exports.resolveBarCornerRadiusPx=Ht;exports.resolveBarPaintOrigin=Im;exports.resolveCalloutAnnotationStyle=yf;exports.resolveChromeMargin=R;exports.resolveChromeMargins=Af;exports.resolveColorRamp=d.resolveColorRamp;exports.resolveComparisonBasis=d.resolveComparisonBasis;exports.resolveDataLabelStyle=_c;exports.resolveDeferredAnchors=xu;exports.resolveDefinition=l.resolveDefinition;exports.resolveDifferenceArrowAnnotationStyle=vf;exports.resolveDirectLabelStyle=Fc;exports.resolveEditOutlineStyle=If;exports.resolveGeomAnchorSpace=d.resolveGeomAnchorSpace;exports.resolveGraphPadding=xf;exports.resolveHeadlineItemStyle=Bc;exports.resolveHeadlineNumberStyle=Gc;exports.resolveHeadlinePlacement=ou;exports.resolveLegendItemStyle=Nc;exports.resolveObservationPoint=Zd;exports.resolveObservationsTarget=Ft;exports.resolvePanelBorderStyle=bf;exports.resolvePolarBarCornerRadiusUnit=Om;exports.resolveRuleLabelStyle=kc;exports.resolveSegmentYSource=d.resolveSegmentYSource;exports.resolveSwatchGeomPaint=zt;exports.resolveTooltipStyle=Vc;exports.resolveYScaleAesthetic=l.resolveYScaleAesthetic;exports.sampleColorScheme=d.sampleColorScheme;exports.scale=b.scale;exports.setCompilerCachingEnabled=l.setCompilerCachingEnabled;exports.stat=b.stat;exports.stepDifferenceArrowEndpoint=Jd;exports.style=b.style;exports.styles=b.styles;exports.toDashPreset=Ot;exports.toFontSpec=Oc;exports.toPaintColor=l.toPaintColor;exports.toPanelCursor=ha;exports.toPercent=U;exports.toSpec=Ii;exports.toStrokeDasharray=ma;exports.toViewBoxX=vu;exports.toViewBoxY=F;exports.token=l.token;exports.transform=b.transform;exports.truncateToWidth=Vn;exports.unitToPolar=l.unitToPolar;exports.updateSpec=d.updateSpec;exports.withAlpha=l.withAlpha;
23
+ `,Ec=(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},Cc=(e,t,r)=>Math.abs(e?t.y-r.y:t.x-r.x),na=({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=ra(t.strokeWidth),m=Ac(o,s,c,u),h=(o?Tc:Ic)(s,c,m,u),p=Lc(o,c,u),f=Ec(o,s,c,m,Cc(o,s,c),e.labelCrossPosition),g=ta({locale:i,kind:e.label,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat});return{id:e.id,start:s,end:c,linePath:h,arrowheadPath:p,labelPosition:f,labelText:g}},xr=new WeakMap,Rc=e=>{const t=n=>e(n),r=Ir(t,n=>a=>e(a,n));return Ir(t,()=>r)},wc=(e,t,r)=>{const n=Er(e.graph,Tr(l.STYLE_TARGETS.graph,{}),r),a=Cr(n,n,l.STYLE_TARGETS.graph.vocabulary),i=(s,c)=>s===l.STYLE_TARGETS.graph?a:Cr(Er(e[s.select.target],Tr(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(Dc(m=>i(s,{annotation:m})),c);if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&Pc(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)]))},Ar=e=>e.list==="builtin"||e.list==="theme"?e.list:"authored",Ot=e=>e==="theme"||e==="authored",Ir=(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}})},Pc=e=>{const t=l.findStyleTarget({target:e.select.target})??e;return Object.values(t.children??{}).some(r=>r.select.axis!==void 0)},Tr=(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}},Lr=(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}},Er=(e,t,r)=>{const n=c=>Lr(e.overrides,c,t)??Lr(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":Ar(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:Ar(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}}},Mc=(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"))},Cr=(e,t,r)=>({...e,resolve:()=>{const n=xr.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 Mc(a,t,r),xr.set(e,a),a}}),Dc=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},Ze={large:1,medium:10/12,small:10/12},aa=["fontStyle","letterSpacing","textTransform","textDecoration","textOutlineColor","textOutlineWidth","textShadow"],ia=["fontFamily","fontSize","fontWeight","lineHeight","textColor",...aa],oa=e=>e.fontSize*e.lineHeight,Oc=(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}}),_c=(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"}},kc=(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",...Hc(e)}},Vc=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()}),Nc=e=>({item:e.legendItem().resolve(),swatch:e.legendItem.swatch().resolve()}),Fc=e=>{const t=e.directLabel();return{...t.resolve(),isTextColorAuthored:Ot(t.getSource("textColor"))}},Bc=(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,...$c(i)?{numberCenter:ye(i,o===void 0?a.fontSize:o*Rr[t])}:{},caption:ye(r.caption(),r.caption().resolve().fontSize*Ze[t]),label:ye(r.label(),r.label().resolve().fontSize*Ze[t]),swatch:r.swatch().resolve(),trend:ye(r.trend(),r.trend().resolve().fontSize*Ze[t]),trendUp:r.trend.up().resolve(),trendDown:r.trend.down().resolve(),trendFlat:r.trend.flat().resolve()}},Gc=(e,t)=>{const r=t?e.numberCenter:void 0;return r===void 0?e.number:{...e.number,...sa(r)}},Hc=e=>{const t={};for(const r of aa){const n=e.get(r);n!==void 0&&Object.assign(t,{[r]:n})}return t},$c=e=>ia.some(t=>e.getSource(t)!=="unresolved"),ye=(e,t)=>({...sa(e.resolve()),fontSize:t}),sa=e=>{const t={};for(const r of ia){const n=e[r];n!==void 0&&Object.assign(t,{[r]:n})}return t},la=({labelPosition:e,measuredTextWidth:t,label:r})=>{const n=t+2*r.paddingInline,a=oa(r)+2*r.paddingBlock;return{x:e.x-n/2,y:e.y-a/2,width:n,height:a}};function*Kc({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=na({arrow:o,style:s,mainAxis:t,panelWidth:r.width,panelHeight:r.height,locale:n}),u=la({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 zc=e=>{const t=e.padding,r=wr(e.rows,t?.top??0,t?.bottom??0),n=wr(e.cols,t?.left??0,t?.right??0);return{rows:r.tracks,cols:n.tracks,placements:qc(e.placements,r.nameToIndex,n.nameToIndex),width:e.containerSize.width,height:e.containerSize.height}},Yc=e=>{const t=Pr(e.rows,e.height),r=Pr(e.cols,e.width),n=Mr(t),a=Mr(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=Dr(r,o.col,c),p=Dr(t,o.row,s);i.set(o.name,{x:u,y:m,width:Math.max(0,h),height:Math.max(0,p)})}return i},wr=(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;ct(s)&&i>0&&(n.push({type:"fixed",pixels:i}),i=0),a.set(s.name,n.length),n.push(Uc(s));const c=Wc(e,o);if(ct(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}},Uc=e=>typeof e.size=="number"?{type:"fixed",pixels:e.size}:{type:"flex",weight:e.size.flex},ct=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Wc=(e,t)=>{for(let r=t+1;r<e.length;r++){const n=e[r];if(n&&ct(n))return n}},qc=(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},Pr=(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)},Mr=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},Dr=(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},ca={outer:Q,inner:Q},Xc=(e,t,r,n=Q,a=ca,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:H(o.header)},{name:"topLegend",size:r.legends.top,gaps:H(o.legend.top)},{name:"headline",size:r.headline,gaps:H(o.headline)},{name:"topAxisLabel",size:c,gaps:H(o.axisLabel.top)},{name:"topAxis",size:r.axes.top,gaps:H(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:H(o.tickLabel.bottom)},{name:"bottomAxisLabel",size:r.axesLabels.bottom,gaps:H(o.axisLabel.bottom)},{name:"bottomLegend",size:r.legends.bottom,gaps:H(o.legend.bottom)},{name:"footer",size:t.footerSize.height,gaps:H(o.footer)}],m=[{name:"leftLegend",size:r.legends.left,gaps:Se(o.legend.left)},{name:"leftAxis",size:r.axes.left,gaps:Se(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:Se(o.tickLabel.right)},{name:"rightLegend",size:r.legends.right,gaps:Se(o.legend.right)}],h=Or(u,i.top,i.bottom),p=Or(m,i.left,i.right);return zc({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),...Jc(r.axesLabels,r.axes),...Qc(r.legends)],containerSize:e,padding:{top:h.start,bottom:h.end,left:p.start,right:p.end}})},H=e=>({before:e.top,after:e.bottom}),Se=e=>({before:e.left,after:e.right}),jc=e=>typeof e.size=="number"?e.size>0:e.size.flex>0,Or=(e,t,r)=>{const n=e.filter(jc),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},Jc=(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},Qc=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 eu=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)))}},tu=["top","right","bottom","left"],Je=(e,t)=>{const r={};for(const n of tu){const a=e.get(`${n}${t}`);a&&(r[n]=a)}return r};function _r(e,t){return e.top===t.top&&e.right===t.right&&e.bottom===t.bottom&&e.left===t.left}var ut=["large","medium","small"],ru=({size:e,availableWidth:t,measureStripWidth:r})=>{if(e!=="auto")return e;for(const n of ut)if(r(n)<=t)return n;return"small"},nu=({size:e,availableWidth:t,measureStripWidth:r})=>{const n=e==="auto"?0:ut.indexOf(e);for(const a of ut.slice(n))if(r(a)<=t)return a;return null},au=({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},iu=({headline:e,containerSize:t,measurer:r})=>{if(Oe(e))return 0;const n=ua(e,t.width,r);return r.measureHeadline(e.formatted,n).height},ou=({headline:e,layout:t,containerSize:r,measurer:n,itemGap:a})=>{if(Oe(e)){const s=su(t.panel,e.innerRadius),c=nu({size:e.size,availableWidth:s.width,measureStripWidth:da(e,n)});return c===null?null:{rect:s,resolvedSize:c,visibleItemCount:1}}const i=ua(e,r.width,n);if(e.formatted.kind!=="perGroup")return{rect:t.headline,resolvedSize:i,visibleItemCount:1};const o=au({itemWidths:n.measureHeadlineItemWidths(e.formatted,i),gap:a,availableWidth:t.headline.width});return o===0?null:{rect:t.headline,resolvedSize:i,visibleItemCount:o}},Oe=e=>e.formatted.kind==="grandTotal"&&e.position==="center"&&e.innerRadius>0,su=(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}},ua=(e,t,r)=>ru({size:e.size,availableWidth:t,measureStripWidth:da(e,r)}),da=(e,t)=>r=>t.measureHeadline(e.formatted,r,Oe(e)).width,X={x:0,y:0,width:0,height:0},lu={top:0,right:0,bottom:0,left:0},cu="0000",uu=3,du=e=>e.plot.y+e.plot.height-e.panel.y,mu=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:ca,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:hu(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=>kr(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=>kr(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:du(n)}}).result()}measurePanelOverflow(e,t,r,n){if(!e.overflowStrategy||e.coordSystem?.type!=="cartesian")return n;const a=new eu(t);if(e.annotations&&e.resolveDifferenceArrowStyle&&e.overflowStrategy.differenceArrows)for(const o of Kc({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 hc({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 _r(i.inner,n.inner)&&_r(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<uu;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?Vr(r,a,0,0):Vr(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:cu}],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=Xl({axis:e,availableSpacePx:n,measureLabel:i,resolveFormatter:t}),{tickCandidates:s,...c}=e,u={...c,ticks:o,labelRotation:0,labelMaxWidthPx:null};return e.geometry!=="linear"?u:e.scaleType==="discrete"&&e.bandwidth!==void 0?Kl({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=Yc(Xc(r,n,this.measureGuides(e,t,o,r),i,a,s,pu(c,t)));return{header:u.get("header")??X,headline:u.get("headline")??X,footer:u.get("footer")??X,plot:u.get("plot")??X,panelFrame:u.get("panelFrame")??X,panel:u.get("panel")??X,axes:Je(u,"Axis"),axisLabels:Je(u,"AxisLabel"),legends:Je(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:iu({headline:e,containerSize:t,measurer:this.measurer})}},kr=e=>e==="left"||e==="right",Vr=(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}}},hu=(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}},pu=(e,t)=>{const r={...e.legend};for(const n of t)n.display==="direct"&&(r[n.position]=lu);return{...e,legend:r}},fu=(e=[])=>{const t=gu(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}},gu=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 vu(e){return e}function F(e){return 1-e}var U=e=>`${Number.parseFloat((e*100).toFixed(4))}%`,Ee=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+F(e.y)*r.height}},ma=(e,t)=>{const r=d.measureAnchorSpace(e.space,t);return{x:r.x+e.x*r.width,y:r.y+(F(e.y)-e.height)*r.height,width:e.width*r.width,height:e.height*r.height}},yu=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}=dt(e.defer,this.panelRect);return Br({...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}=Su(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}=dt(e.defer,this.panelRect);return Br({...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:bu(this.toPanelRegion(r))}case"arrow":{const r=this.resolvePoint(t.annotation.start),n=this.resolvePoint(t.annotation.end);return r===null||n===null?null:Nr(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:Fr(this.toPanelPoint(r))}case"differenceArrow":return Nr(this.toPanelPoint(t.annotation.start),this.toPanelPoint(t.annotation.end));case"pinnedNumber":case"comment":return Fr(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}}},dt=(e,t)=>({x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0}),Su=(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}=dt({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}},bu=e=>({xMin:e.x,xMax:e.x+e.width,yMin:e.y,yMax:e.y+e.height}),Nr=(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)}),Fr=e=>({xMin:e.x,xMax:e.x,yMin:e.y,yMax:e.y}),Br=e=>{const t={...e};return delete t.defer,delete t.space,t},xu=e=>{const{annotations:t,panelRect:r,measuredBoxes:n,onCycle:a,onMissingRef:i}=e;if(!Au(t))return t;const o=new yu(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,Au=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),ha=(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]),Iu=800,Gr=400,Tu=.75,Lu=.875,Eu=4,Cu=e=>Math.max(1,(e-Gr)/(Iu-Gr)+1),Ru=(e,t)=>{const r=Cu(t),n=e*Eu;return{strokeWidth:Math.min(e,e*Tu*r),arrowheadLength:Math.min(n,n*Lu*r)}},be=Math.PI/4,wu=({start:e,end:t})=>`M ${e.x} ${e.y} L ${t.x} ${t.y}`,Hr=(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-be)} ${o-r*Math.sin(s-be)} M ${i} ${o} L ${i-r*Math.cos(s+be)} ${o-r*Math.sin(s+be)}`},Pu=64,Mu=({arrow:e,style:t,panelWidth:r,panelHeight:n})=>{const a={width:r,height:n},i={start:Ee(e.start,a),end:Ee(e.end,a)};if(i.start.x===i.end.x&&i.start.y===i.end.y)return null;const{strokeWidth:o,arrowheadLength:s}=Ru(t.strokeWidth,r),c=Math.hypot(i.end.x-i.start.x,i.end.y-i.start.y),u=Du(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:wu(i),startArrowheadPath:m?Hr("start",i,u):"",endArrowheadPath:h?Hr("end",i,u):"",strokeWidth:o,dashArray:ha(t.dashArray,o)??null,startX:i.start.x,startY:i.start.y,endX:i.end.x,endY:i.end.y,dashOffset:Ou(t.dashArray,o,m),arrowheadExtent:p}},Du=(e,t)=>Math.min(e,t*e/Pu),Ou=(e,t,r)=>{const n=e[0]??0;return r&&n>1?n*t:0};function _u(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=ku(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 ku(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 pa=(e,t)=>({x:e.x/t.width,y:1-e.y/t.height}),Vu=0,Nu=(e,t)=>e.filter(r=>r.inView).map(r=>({shape:{kind:"rect",rect:r.miniRect},cursor:pa(r.anchorPx,t),tooltip:{kind:"pinned",point:r.anchorPx,placement:r.placement,annotationId:r.id},priority:Vu})),Fu=9,Bu=8,Gu=2,fa=e=>typeof e=="string"?e:ga(e),ga=e=>e.text!==void 0?e.text:e.content?e.content.map(ga).join(""):"",$r={top:"bottom",bottom:"top",right:"left",left:"right"};function Hu(e,t,r){return r.type==="polar"?zu(e,t):r.mainAxis==="y"?["right","left","top","bottom"]:["top","bottom","right","left"]}function mt(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 Kr(e,t){return e.x>=0&&e.y>=0&&e.x+e.width<=t.width&&e.y+e.height<=t.height}function $u(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 Ku(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 zu(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,$r[o],s,$r[s]]}function Yu(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 zr(h,"pinned-number",p,o(m),i,n)}),...r.map(({id:m,at:h,content:p})=>zr(m,"comment",h,fa(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,Wu(n,m,a,u));c.push(h),u.push(h.miniRect)}return c}function zr(e,t,r,n,a,i){const o=Ee(r,i);return{id:e,kind:t,anchor:r,anchorPx:o,mini:a(t,e,n),inView:Uu(o,i)}}function Uu(e,t){return e.x>=-8&&e.y>=-8&&e.x<=t.width+8&&e.y<=t.height+8}function Wu(e,t,r,n){const a=Hu(t.anchorPx,e,r);for(const i of a){const o=mt(t.anchorPx,i,t.mini);if(Kr(o,e)&&!n.some(s=>Ku(o,s)))return i}for(const i of a)if(Kr(mt(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:$u(e,mt(t.anchorPx,r,t.mini)),text:t.mini.text,inView:t.inView}}var qu=(e,t)=>Dt().hasCapability(e,t),Xu=({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)}),q=A.place(P);S+=q.droppedCount;for(const _ of q.labels)Zu(_,g,u,m)||p.push(_)}return{labels:p,warnings:S>0?[ju(S)]:[]}},ju=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,Ju=(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,Qu=100,ed=({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>Qu)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}},td=(e,t)=>va(e,t,{variables:ya(e),allowNull:!1}),va=(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}},ya=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])]},_e=e=>e!=="data-point",rd=(e,t)=>{switch(t){case"series":{const r=l.getGroupVariables(e.data,e.mapping);return r.length===0?Ur(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 Ur(e)}},Ur=e=>typeof e.identityKey=="object"?{variables:[e.identityKey.variable],allowNull:!0}:e.identityKey==="index"?null:{variables:ya(e),allowNull:!1},ae=[],Wr=new WeakMap,Sa=(e,t,r)=>r<0||r>=e.data.size()?null:t==="data-point"?String(r):ie(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 ie(e,t).rowsByKey.get(r)??ae},nd=(e,t)=>ie(e,t).keyByRow,ad=(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=ie(t,"vertex").keyByRow[a];return i===void 0?ae:ie(e,"vertex").rowsByKey.get(i)??ae},ie=(e,t)=>{const r=Wr.get(e)??new Map;Wr.set(e,r);const n=r.get(t);if(n!==void 0)return n;const a=od(id(e,t));return r.set(t,a),a},id=(e,t)=>{const r=e.data.size(),n=t==="x-value"?null:qr(e,l.GROUP_VARIABLES.group),a=t==="series"?null:d.readScopeXVariable(e.mapping),i=a===null?null:qr(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},qr=(e,t)=>e.data.hasVariable(t)?e.data.getValues(t):null,od=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}},ba=({layer:e,observationIndex:t,scope:r,parsingLocale:n})=>{const a=e.data.getAt(t);if(a===null)return null;const i=dd(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 ud(o,e,a,t,n)?o:null},sd=({layer:e,scope:t,variable:r,value:n,parsingLocale:a})=>{const i={kind:"observations",layerId:e.id,scope:cd(e,t,r),predicate:{variable:r,eq:n}};return ld(i,e,a)?i:null},xa=e=>e.identityKey==="x-group"?"series":l.getGroupVariables(e.data,e.mapping).length===0?"data-point":"series",ld=(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},cd=(e,t,r)=>t==="series"&&!l.getGroupVariables(e.data,e.mapping).includes(r)?"data-point":t,ud=(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(!_e(e.scope))return!1;const o=Sa(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)})},dd=(e,t,r)=>{const n=rd(e,r);return n===null?null:va(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},md=(e,t)=>{for(const r of t)if(Nt(e,r.shape))return r;return null},hd=e=>{const t=[];for(const r of e.values())t.push(...r);return t.sort((r,n)=>n.priority-r.priority)},pd=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>fd(r,t[n])),fd=(e,t)=>t===void 0?!1:e.priority===t.priority&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y&&gd(e.shape,t.shape)&&vd(e.tooltip,t.tooltip),gd=(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},vd=(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},yd=100,Sd=e=>({shape:{kind:"circle",center:e.center,radius:e.radius},cursor:e.target.cursor,tooltip:{kind:"cursor"},priority:yd}),bd=(e,t)=>Nt(e,{kind:"circle",center:t.center,radius:t.radius}),xd=(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&&Ad(e.target,t.target),Ad=(e,t)=>e.kind===t.kind&&e.cursor.x===t.cursor.x&&e.cursor.y===t.cursor.y,Id=({layer:e,highlights:t,observation:r,parsingLocale:n})=>{if(e.highlight===null)return[];const a=d.createPredicateCompileContext(e,n),i=Td(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:_e(o.scope)&&i(o.scope).some(s)})},Td=(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}},Ie=({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?Ld(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},Aa=(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),Ld=(e,t)=>(e%t+t)%t,Ia=({layer:e,at:t,coordSystem:r})=>{if(r.type!=="cartesian"||e.spatialKind==="cells")return null;const n=d.resolveAnchorVariable(e),a=Aa(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=Ie({layer:e,excluding:c,from:a+1,step:1,accepts:s});if(u!==null)return{start:t,end:u.anchor};const m=Ie({layer:e,excluding:c,from:a-1,step:-1,accepts:s});if(m!==null)return{start:m.anchor,end:t};const h=Ie({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},Ed=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=Ia({layer:r,at:i,coordSystem:e.coordSystem});if(o!==null&&!t.some(s=>Cd(s,o)))return o}}return null},Cd=(e,t)=>J(e.start,t.start)&&J(e.end,t.end)||J(e.start,t.end)&&J(e.end,t.start),Rd=(e,t)=>d.resolveGeomScaleDemands(e.layers).zeroAxes[t]!==void 0,wd=new Set(["discrete","datetime"]),Ta=e=>{const t=e.x;return t?.kind!=="position"?!1:wd.has(t.spec.scaleType)},Pd=({layer:e,coordSystem:t,panelSize:r,radialExtent:n="whole"})=>{const a=n==="outerEnd"&&t.type==="polar"?Md:l.readObservationBox,i=[];for(const o of e.data){const s=a(o,t);s!==null&&i.push(Dd(s,r))}return i},Md=(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"}},Dd=(e,t)=>ma({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),Od=(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}},ce=e=>d.applyReplayableTransforms(e.data,e.transforms),La=(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(kd([a,...i],t.scope)||Vd(a,t.scope)||[a,...i].some(m=>_d(e,m)))return null;const s=Nd(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]},_d=(e,t)=>{const r=l.readVariableName({...e.mapping,...t.mapping}.color);if(r===null)return!1;const n=d.applyReplayableTransforms(ce(e),t.transforms);return n.hasVariable(r)?n.getType(r)!=="categorical":!0},kd=(e,t)=>(t==="x-value"||t==="data-point")&&e.some(r=>d.paintsEachGroupFromItsFirstObservation(r.geom)),Vd=(e,t)=>t==="x-value"&&l.isStackedPosition(e.position)&&!d.paintsEachGroupFromItsFirstObservation(e.geom),Nd=(e,t)=>{if(e.scope!=="series")return!1;const r=Fd(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)},Fd=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=Bd(e.geom);return r===null?null:{layerId:e.id,geomKind:e.geom,property:r,...t===void 0?{}:{where:t}}},Bd=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},Gd=e=>e?.kind==="visual"&&e.paletteBeforeOverrides!==void 0?e.paletteBeforeOverrides:l.DEFAULT_COLOR_PALETTE,Hd=new Set(["line","rule"]),Ft=e=>Hd.has(e),ke=(e,t,r,n)=>{const a=e.geom(t);if(Ft(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)},Bt=({layer:e,target:t,parsingLocale:r,host:n})=>{if(t.layerId!==(n??e).id)return[];const a=Ea(e,t,r);if(a===null)return[];if(_e(t.scope))return Kd(e,a,t.scope);const i=Ca(e,a),o=i[$d(t,i,n,r)];return o===void 0?i:[o]},$d=(e,t,r,n)=>{if(e.observationIndex===void 0)return-1;if(r===void 0)return t.indexOf(e.observationIndex);const a=Ea(r,e,n);return a===null?-1:Ca(r,a).indexOf(e.observationIndex)},Ea=(e,t,r)=>d.findPredicateProblems(t.predicate,e.data).length>0?null:d.compilePredicate(t.predicate,d.createRowPredicateCompileContext(e,r)),Ca=(e,t)=>{const r=[];for(let n=0;n<e.data.size();n++)t(n)&&r.push(n);return r},Kd=(e,t,r)=>{const n=nd(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},zd=({readers:e,layers:t,target:r,parsingLocale:n})=>{const a=d.findLayerById(t,r.layerId);if(a===void 0)return null;const i=d.findHostLayer(a,t);let o;for(const s of[i,...d.findCompanionLayers(i,t)]){const c=Bt({layer:s,target:r,parsingLocale:n,...s===a?{}:{host:a}});for(const u of c){const m=s.data.getAt(u);if(m===null)continue;const h=ke(e,s,m);if(h!==void 0){if(o===void 0){o=h;continue}if(o!==h)return null}}}return o??null},Yd=["series","data-point","x-value"],Ud=({layer:e,observationIndex:t,parsingLocale:r,scales:n})=>{const a=qd(xa(e)).filter(s=>s!=="x-value"||Wd(n)),i=new Set,o=[];for(const s of Yd){if(!a.includes(s))continue;const c=Xd(e,t,s,r);if(c===null&&s==="data-point")return[];c===null||o.some(u=>jd(u,c))||(o.push(c),i.add(s))}return a.filter(s=>i.has(s))},Wd=e=>{const t=e.x?.domain.some(r=>r instanceof Date)===!0;return Ta(e)&&!t},qd=e=>e==="series"?["data-point","x-value","series"]:["data-point"],Xd=(e,t,r,n)=>{const a=ba({layer:e,observationIndex:t,scope:r,parsingLocale:n});return a===null?null:Bt({layer:e,target:a,parsingLocale:n})},jd=(e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),Zd=({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}}},Jd=({layer:e,from:t,partner:r,axis:n,step:a,getObservationPoint:i})=>{const o=d.resolveAnchorVariable(e),s=Aa(e,t),c=e.data.getAt(s);if(c===null)return null;const u=Qd(c),m=n==="main"?u:f=>!u(f)&&l.areDataValuesEqual(f[o]??null,t.anchorValue),h=Ie({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}},Qd=e=>{const t=d.getGroup(e);return r=>l.areDataValuesEqual(d.getGroup(r),t)};function em({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 tm=({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"?rm(e,o,r):nm(e,t,o,r,i)},rm=(e,t,r)=>({kind:"grandTotal",value:I({valueFormat:e.valueFormat,locale:t,numberFormat:r})(e.value)}),nm=(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:sm(t,o,h,a),value:s.aggregate===null?null:c(s.aggregate),caption:om(s.caption,m),comparison:am(s.comparison,m,i,a)}})}},am=(e,t,r,n)=>e===null?null:{direction:im(e.variation),percentage:r(Math.abs(e.variation)),reference:n("graph.headlineMetrics.comparisonReference",{value:t(e.against)})},im=e=>e>0?"up":e<0?"down":"flat",om=(e,t)=>e===null?null:e.kind==="point"?t(e.value):`${t(e.from)} – ${t(e.to)}`,sm=(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}},lm=({legends:e,numberFormat:t,parsingLocale:r,formattingLocale:n})=>{const a=n??r;return e.map(i=>cm(i,a,t))},cm=(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 Gt(e,t){return e.axes.find(r=>r.scaleAestheticKey===t)??null}function um(e,t){return e.legends.drawn.find(r=>r.aesthetics.includes(t))??null}var dm=({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:Gt(e,i?l.resolveYScaleAesthetic(r.yScaleType):"x")?.valueFormat??{type:"decimal"},locale:n,numberFormat:t})(o)},Ra=.4,wa=.18,mm=12,Pa=.4,hm=(e,t)=>{const{value:r,caption:n,comparison:a,swatch:i,label:o}=e;return[{role:"value",gap:Qe(t.number.fontSize,wa),segments:et([xe("value",r??"–"),xe("caption",n)])},{role:"trend",gap:Qe(t.trend.fontSize,Pa),ariaLabel:a===null?void 0:vm(a),segments:et([fm(a),gm(a),xe("trendReference",a?.reference??null)])},{role:"group",gap:Qe(t.label.fontSize,Ra),segments:et([pm(i,t.swatch.size),xe("label",o)])}].filter(s=>s.segments.length>0)},Qe=(e,t)=>Math.round(e*t),xe=(e,t)=>t===null?null:{kind:"text",textRole:e,text:t},pm=(e,t)=>e===null?null:{kind:"swatch",swatch:e,size:t},fm=e=>e===null?null:{kind:"trendArrow",direction:e.direction,size:12},gm=e=>e===null?null:{kind:"text",textRole:"trendPercentage",text:e.percentage,trendDirection:e.direction},vm=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}`}},et=e=>e.filter(t=>t!==null),Ve=e=>e==="smooth"?C.curveCatmullRom:C.curveLinear,ym=(e,t)=>{const r=Ve(t.curve),n=(0,C.area)().curve(r),a=(0,C.line)().curve(r);if(e.mainAxis==="y"){const i=c=>F(l.getY(c)??0),o=c=>l.getXMin(c)??0,s=c=>l.getXMax(c)??l.getX(c)??0;n.y(i).x0(o).x1(s),a.y(i).x(s)}else{const i=c=>l.getX(c)??0,o=c=>F(l.getYMin(c)??0),s=c=>F(l.getYMax(c)??l.getY(c)??0);n.x(i).y0(o).y1(s),a.x(i).y(s)}if(t.missingValues==="gap"){const i=o=>l.getX(o)!==null&&l.getY(o)!==null;n.defined(i),a.defined(i)}return{lineGenerator:a,areaGenerator:n}},Sm=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),Ht={none:0,xs:2,sm:4,md:8,lg:12,xl:16},$t=e=>{if(_a(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):Ht[t]},bm=e=>{const t=$t(e);return _a(e)?e.mainAxis==="x"?{rx:t}:{ry:t}:{rx:t}},xm=e=>({outlineWidth:e*2,separatorWidth:e,insetOffset:e/2}),Ma=(e,t)=>Da(e,{xMin:l.getXMin(t),xMax:l.getXMax(t),yMin:l.getYMin(t),yMax:l.getYMax(t),y:l.getY(t)}),Da=(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}},Oa=(e,t)=>e==="x"?`${k(t.x)}-${k(t.width)}`:`${k(t.y)}-${k(t.height)}`,Am=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}},Kt=(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},Im=(e,t,r)=>{const n=Kt(e,t,r);return t.mainAxis==="x"?{x:0,y:n}:{x:n,y:0}},_a=e=>e.cornerRadius==="full",Tm=e=>{const t=(0,C.line)().x(r=>l.getX(r)??0).y(r=>F(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(ka),t},Lm=e=>{const t=(0,C.area)().x(r=>l.getX(r)??0).y0(()=>1).y1(r=>F(l.getY(r)??0)).curve(Ve(e.curve));return e.missingValues==="gap"&&t.defined(ka),t},Em=(e,t)=>t!=="connect"?e:e.filter(r=>l.getX(r)!==null&&l.getY(r)!==null),ka=e=>l.getX(e)!==null&&l.getY(e)!==null,zt={circle:C.symbolCircle,square:C.symbolSquare,diamond:C.symbolDiamond,triangle:C.symbolTriangle,cross:C.symbolCross,star:C.symbolStar,wye:C.symbolWye},Cm=(e,t)=>{const r=t/2;return(0,C.symbol)(zt[e],Math.PI*r*r)()??""},Rm=(e,t,r)=>{const n=Va[e],a=Math.max(0,Math.min(t/n.width,r/n.height));return{path:(0,C.symbol)(zt[e],a*a)()??"",offsetX:-n.centerX*a,offsetY:-n.centerY*a}},wm=(e,t)=>{const r=t/2;return Va[e].outerRadius*Math.sqrt(Math.PI*r*r)},Pm=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(zt).map(([e,t])=>[e,Pm(t)])),Na={centerX:0,centerY:0,radius:1,digits:8},Mm=200,D=1e-12,Dm=Math.PI/2,Om=(e,t)=>{if(e==="full")return Math.max(0,t)/2;const r=e??"sm";return(typeof r=="number"?Math.max(0,r):Ht[r])/Mm},Fa=(e,t)=>e==="x"?`${k(t.startAngle)}-${k(t.endAngle)}`:`${k(t.innerRadius)}-${k(t.outerRadius)}`,_m=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}},km=(e,t=Na)=>{const r=$m(t),n=Nm(e);if(!(n.outer>D))return`M${r.writePoint(0,0)}Z`;const{slice:a}=e,i=a===void 0?null:Vm(a,a.axis==="radius"?[n.inner,n.outer]:[n.start,n.end]);if(i!==void 0){if(l.isFullTurnSweep(n.start,n.end)){if(a?.axis==="angle"&&i!==null&&!l.isFullTurnSweep(i[0],i[1]))return Zr({...n,start:i[0],end:i[1]},i,r);const[o,s]=a?.axis==="radius"&&i!==null?i:[n.inner,n.outer];return Bm(n.start,o,s,r)}return a?.axis==="radius"&&i!==null?Fm(n,i,r):Zr(n,i??[n.start,n.end],r)}},Vm=(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},Nm=({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?jr(p,s+p,u):null,outerCorner:f>D?jr(f,c-f,u):null}},jr=(e,t,r)=>({radius:e,centerRadius:t,offset:Math.min(Math.asin(Math.min(1,e/t)),r/2)}),Fm=(e,[t,r],n)=>{const a=Jr(e,"start"),i=Jr(e,"end"),o=c=>Ce(a,c),s=c=>Ce(i,c);return`M${n.writePoint(o(t),t)}`+oe(t,o(t),s(t),n)+Re(i,t,r,"radius",n)+oe(r,s(r),o(r),n)+Re(a,r,t,"radius",n)+"Z"},Zr=(e,[t,r],n)=>{const a=Qr(e,"inner"),i=Qr(e,"outer");return`M${n.writePoint(t,Ce(a,t))}`+Re(a,t,r,"angle",n)+`L${n.writePoint(r,Ce(i,r))}`+Re(i,r,t,"angle",n)+"Z"},Bm=(e,t,r,n)=>{const a=`M${n.writePoint(e,r)}${oe(r,e,e-l.TAU,n)}Z`;return t>D?`${a}M${n.writePoint(e,t)}${oe(t,e,e+l.TAU,n)}Z`:a},Jr=(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*Gm(c,m)},i=e.innerCorner===null?e.inner:en(e.innerCorner),o=e.outerCorner===null?e.outer:en(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},Qr=(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=>Hm(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}]},en=e=>e.centerRadius*Math.cos(e.offset),Gm=({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)))},Hm=({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)},Re=(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}`:oe(u.at(p),p,f,a)}return c},oe=(e,t,r,n)=>{if(!(e>D)||Math.abs(r-t)<=D)return"";const a=Math.max(1,Math.ceil(Math.abs(r-t)/Dm-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},$m=({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)}},Km=(e,t,r="light")=>{const n=Ft(e.geom)?"stroke":"fill",a=l.readVariableName(e.mapping.color),i=e.styles.overrides;for(let o=i.length-1;o>=0;o-=1){const s=i[o];if(!(s===void 0||!zm(s))&&Ym(s.where,a,t)&&s.declarations[n]!==void 0)return Um(s.declarations,n,r)}},zm=e=>e.state===void 0&&e.part===void 0,Ym=(e,t,r)=>e===void 0?!0:t===null||r===void 0?!1:d.readPredicateVariables(e).every(n=>n===t)&&Ba(e,r),Ba=(e,t)=>"eq"in e?l.areDataValuesEqual(e.eq,t):"and"in e?e.and.every(r=>Ba(r,t)):!1,Um=(e,t,r)=>{const n=e[t];if(typeof n=="string")return n;if(!l.isLightDarkColor(n))return;const a=l.resolveColorScheme(n,r);return typeof a=="string"?a:void 0},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}`:""}`}},Wm=(e,t,r)=>{const n=d.createXValueReader(e,t);return a=>{const i=n(a);return i===null||i===""?null:`${r}-${i}`}},qm=(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}`}},Xm=()=>(e,t)=>l.getColor(e)??`default-${t}`,tn=2,jm=(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=W(t,"line")?a.get("strokeAlpha",r):a.get("fillAlpha",r)??a.get("strokeAlpha",r),o=a.get("alpha",r)*i,s=Ft(t.geom)?void 0:Zm(e,t,r),c=s===void 0?{alpha:o}:{alpha:o,fill:s};if(W(t,"point"))return{...c,symbol:e.point(t).get("symbol",r)};if(!W(t,"bar"))return c;const u=n.width-tn,m=n.height-tn,h=$t({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)}},Zm=(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 Ut(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 Ga(e,t,r){return Ut(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>t})}function Ha(e,t,r){return Ut(e.length,n=>{const a=e[n];return a!==void 0&&r(a)>=t})}function Wt(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 Jm(e,t){const r=t.height,n=Math.min(t.width,t.height)/2;return{cartesian:rn(e,r),polar:rn(e,n)}}function ue(e,t){return e<=t.on.point}function se({mainDistance:e,crossDistance:t},r){return e<=r.near.main&&t<=r.near.cross}function rn({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 Qm(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=$a(e,s,t,r);return a===void 0||ue(c.distance,a)||se(c,a)?c:rh(e,t,r,a)??c}function eh(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 th(e,t,r,n){if(e.projection==="polar")return[];const a=ht(e.mainAxis),i=Ha(e.byMain,t,a),o=Ga(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 rh(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=Ha(i,o-s,ht(a)),u=Ga(i,o+s,ht(a));let m=null;for(let h=c;h<u;h+=1){const p=i[h];if(p===void 0)continue;const f=$a(e,p,t,r);se(f,n)&&(m===null||f.crossDistance<m.crossDistance)&&(m=f)}return m}function ht(e){return t=>d.getCoordinates(e,t).main}function $a(e,t,r,n){const{main:a,cross:i}=d.getCoordinates(e.mainAxis,r),{main:o,cross:s}=d.getCoordinates(e.mainAxis,t);return{...Wt(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 Ka(e,t){return e.buckets[nh(e,t)]??null}function nh(e,t){return Ua(e.buckets,t,r=>r.main)}function ah(e,t){return Ya(e.bands,t,r=>r.bandCenter)}function za(e,t){return Ya(e.columns,t,r=>r.mainMid)}function Ya(e,t,r){return e[Ua(e,t,r)]??null}function Ua(e,t,r){if(e.length===0)return-1;const n=Ut(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 ih(e,t){return{group:oh(e),related:uh(e,t)}}function oh(e){switch(e.kind){case"buckets":{const t=e.match.index;return l.isStackedPosition(t.position)?sh(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)?lh(t.layerId,r,n.pointIndex):ch(t.bandByColumn,t.layerId,r,n.pointIndex)}case"points":case"enclosure":case"render-hit-test":return[]}}function sh(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 lh(e,t,r){const n=[];for(const a of t.rects)a.pointIndex!==r&&n.push(qt(e,a));return n}function ch(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(qt(t,s));return i}function uh(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||mh(r,i,e);continue}e.kind==="buckets"&&(l.isStackedPosition(i.position)||i.kind==="buckets"&&dh(r,i.layerId,e.match.bucket,e.match.hit.pointIndex))}return r}function dh(e,t,r,n){for(const a of r.entries)a.pointIndex!==n&&Te(e,t).push({anchored:!0,layerId:t,pointIndex:a.pointIndex,x:a.x,y:a.y,observation:a.observation})}function mh(e,t,r){const n=r.match.hit;switch(t.kind){case"buckets":{const a=Ka(t,d.getMainAxisCoordinate(t.mainAxis,n));if(!a)return;const i=Te(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=ah(t,d.getMainAxisCoordinate(t.mainAxis,n));if(!a)return;const i=Te(e,t.layerId);for(const o of a.columns)for(const s of o.rects)i.push(qt(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?[]:th(t,a.mainMin,a.mainMax,n),o=i.length>0?null:eh(t,n),s=o===null?i:[o];if(s.length===0)return;const c=Te(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 Te(e,t){let r=e.get(t);return r||(r=[],e.set(t,r)),r}function qt(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 Wa(e,t,r){const{columns:n,bands:a,bandByColumn:i}=hh(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 hh(e,t){const r=fh(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),ph(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 ph(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 fh(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=gh(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 gh(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 vh=1e-9,nn=-1;function qa(e,t,r){const n=yh(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 yh(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 bh(xh(e)),P=new Map,q=[];let _=-1;for(const dl of n){_+=1;const pe=x?.[_]??null,ml=Ah(P,pe),qe=p[_],fe=g?.[_],gr=S?.[_],te=Sh(f[_],fe,gr,m);if(!l.isDefined(qe)||te===null){A?.skip(pe);continue}const vr=h[_]??qe,yr={pointIndex:_,...c?{x:te,y:vr}:{x:vr,y:te},groupKey:pe,paintOrder:ml,...a==="filled-buckets"&&l.isDefined(fe)&&{fill:Ih(fe,te)},...u&&{extent:Th(te,fe,gr)},previousAt:nn,nextAt:nn,observation:dl};A?.append(pe,{entry:yr,at:q.length}),q.push({main:qe,entry:yr})}return r==="polar"&&A?.close(),q}function ne(e,t){return e.hasVariable(t)?e.getValues(t,{type:"numeric"}):null}function Sh(e,t,r,n){return l.isDefined(e)?n?l.isDefined(t)&&l.isDefined(r)?r:null:e:null}var bh=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 xh(e){return"missingValues"in e.params&&e.params.missingValues==="gap"}function Ah(e,t){const r=e.get(t);if(r!==void 0)return r;const n=e.size;return e.set(t,n),n}function Ih(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}}function Th(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 ja(e,t){return{kind:"enclosure",layerId:e.id,geom:e.geom,position:e.position,projection:t,cells:Lh(e,t)}}function Lh(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 pt(e){return{kind:"noop",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian"}}function Eh(e,t,r){const n=Ja(e),a={kind:"points",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",mainAxis:t,points:n,byMain:Rh(t,n),delaunay:null,delaunayAspectRatio:null};return Za(a,r),a}function Ch(e){const t=Ja(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 Za(e,t){e.delaunay&&e.delaunayAspectRatio===t||(e.delaunay=bl.Delaunay.from(e.points,r=>r.x*t,r=>r.y),e.delaunayAspectRatio=t)}function Rh(e,t){const r=n=>d.getMainAxisCoordinate(e,n);return[...t].sort((n,a)=>r(n)-r(a))}function Ja(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 Qa(e){return{kind:"render-hit-test",layerId:e.id,geom:e.geom,position:e.position,projection:"cartesian",byKey:wh(e)}}function ei(e,t){return{anchored:!1,layerId:e,pointIndex:t.pointIndex,observation:t.observation}}function wh(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 an(e,t,r){return t.type==="polar"?Ph(e,t.bandAxis):Mh(e,t.mainAxis,r)}function Ph(e,t){switch(e.spatialKind){case"points":return Ch(e);case"buckets":case"filled-buckets":case"spanned-buckets":return qa(e,"x","polar");case"rects":return t===null?ja(e,"polar"):Wa(e,t,"polar");case"cells":return pt(e);case"noop":return pt(e);case"render-hit-test":return Qa(e);default:{const r=e.spatialKind;throw new l.InternalError({message:`buildPolarLayerIndex: unhandled spatialKind ${String(r)}`})}}}function Mh(e,t,r){switch(e.spatialKind){case"points":return Eh(e,t,r);case"buckets":case"filled-buckets":case"spanned-buckets":return qa(e,t,"cartesian");case"rects":return Wa(e,t,"cartesian");case"cells":return ja(e,"cartesian");case"noop":return pt(e);case"render-hit-test":return Qa(e);default:{const n=e.spatialKind;throw new l.InternalError({message:`buildCartesianLayerIndex: unhandled spatialKind ${String(n)}`})}}}function Dh(e,t,r){if(e.columns.length===0)return null;const n=za(e,d.getMainAxisCoordinate(e.mainAxis,t)),a=n?.rects??[];if(!n||!l.isNonEmptyArray(a))return null;const i=l.isStackedPosition(e.position)?_h(a,t,e.mainAxis):kh(a,t,r),o=ti(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,...Oh(e,n,t,r)}}function Oh(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 Wt(e.mainAxis,s,c,n)}function _h(e,t,r){const n=d.getCrossAxisCoordinate(r,t);return O(e,i=>Vh(i,r,n),{shortCircuitOnZero:!0})}function kh(e,t,r){return O(e,a=>ti(a,t,r))}function ti(e,t,r){return Fe(V(t.x,e.xMin,e.xMax),V(t.y,e.yMin,e.yMax),r)}function Vh(e,t,r){return V(r,t==="x"?e.yMin:e.xMin,t==="x"?e.yMax:e.xMax)}function Nh(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 Fh(e,t,r){const{main:n,cross:a}=d.getCoordinates(e.mainAxis,t),i=Ka(e,n);if(i===null||!l.isNonEmptyArray(i.entries))return null;const o=zh(i.entries,i.span,e.mainAxis,n),s=o.entries.map(S=>({entry:S,crossAtCursor:Gh(e,S,n)}));if(!l.isNonEmptyArray(s))return null;const c=ai(s.filter(S=>$h(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=ni(h(t),h(u),p,m),g=Wt(e.mainAxis,d.getMainAxisCoordinate(e.mainAxis,u)-n,ri(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 Bh(e,t,r){return O(e,a=>Math.abs(d.getCrossAxisCoordinate(r,a)-t))}function ri(e,t,r){return e!==void 0?V(r,e.min,e.max):Math.abs(t-r)}function ni(e,t,r,n){const a=r.map(i=>Nh(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 ai(e,t){return e.reduce((r,n)=>r===void 0||t(n).paintOrder>t(r).paintOrder?n:r,void 0)}function Gh(e,t,r){const{mainAxis:n}=e,a=r===d.getMainAxisCoordinate(n,t)?null:ii(e,t,r);return a===null?d.getCrossAxisCoordinate(n,t):Hh(t,a,n,r)}function Hh(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 ii(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 $h(e,t,r,n){const a=Kh(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function Kh(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=ii(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 zh(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)<=vh);return o.length===e.length?{entries:e,span:t}:{entries:o,span:Xa(o,r)}}function Yh(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 Uh(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?Xh(e.columns,a):za(e,i),c=s?.rects??[];if(!s||!l.isNonEmptyArray(c))return null;const u=o?jh(c,i):Zh(c,a),m=Wh(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,...qh(e,s,n)}}function Wh(e,{angle:t,radius:r}){const n=we(t,e.xMin,e.xMax),a=V(r,e.yMin,e.yMax);return Math.hypot(n*r,a)}function we(e,t,r){return l.isAngleWithinArc(e,t,r)?0:Math.min(l.wrappedAngularDistance(e,t),l.wrappedAngularDistance(e,r))}function qh(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:we(r,a.mainMin,a.mainMax)*n,crossDistance:V(n,a.crossMin,a.crossMax)}:{mainDistance:V(n,a.mainMin,a.mainMax),crossDistance:we(r,a.crossMin,a.crossMax)*n}}function Xh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(t,r.mainMid)):null}function jh(e,t){return O(e,r=>V(t,r.yMin,r.yMax),{shortCircuitOnZero:!0})}function Zh(e,t){return O(e,r=>we(t,r.xMin,r.xMax),{shortCircuitOnZero:!0})}var on=1e-9;function Jh(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=Qh(e.buckets,a),s=o?.entries??[];if(!o||!l.isNonEmptyArray(s))return null;const c=ai(s.filter(f=>ep(e,f,a,i)),f=>f),u=c??Bh(s,i,e.mainAxis),m=sn(u),h=Math.hypot(n.x-m.x,n.y-m.y),p=ni(n,m,Be(e,u).map(sn),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:ri(o.span,u.y,i)}}function sn(e){return l.polarToUnit(e.x,e.y)}function Qh(e,t){return l.isNonEmptyArray(e)?O(e,r=>l.wrappedAngularDistance(r.main,t)):null}function ep(e,t,r,n){const a=tp(e,t,r);return a!==null&&n>=a.min&&n<=a.max}function tp(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=ln(r,{angle:t.x,radius:t.fill.min},{angle:i.x,radius:i.fill.min}),s=ln(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 ln(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)<on)return t.radius;const o=cn(l.polarToUnit(e,1),i);return Math.abs(o)<on?null:cn(n,i)/o}function cn(e,t){return e.x*t.y-e.y*t.x}function rp(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 un(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 un(e,c,s(c))}function un(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 np(e,t,r,n){if(!l.isNonEmptyArray(e.points))return null;const a=l.cursorToPiePlane(t,r),i=dn(e,O(e.points,s=>oi(s,a)),a);if(n===void 0||ue(i.distance,n)||se(i,n))return i;const o=e.points.map(s=>dn(e,s,a)).filter(s=>se(s,n));return l.isNonEmptyArray(o)?O(o,s=>s.crossDistance):i}function dn(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(oi(t,r))}}function oi(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 ap=.05;function ip({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=mp(m,t,a);if(p)return{kind:"render-hit-test",match:p};continue}if(m.projection==="polar"){const p=dp(m,t,r,i?.polar);if(p&&!mn(p,i?.polar))return p;continue}const h=up({layer:m,cursor:t,aspectRatio:r,warmStarts:n,tolerance:i?.cartesian});if(!(!h||mn(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 si(c,sp(s,o)).match}function op(e,t){if(e.kind==="render-hit-test")return{intersects:!0,onPoint:!1};const r=lp(e,t),n=e.kind==="buckets"&&ue(e.match.vertexDistance,r);return{intersects:li(e,r),onPoint:n}}function sp(e,t){return e.match!==null&&t.match!==null&&e.distance===0&&t.distance===0?e.paintOrder>t.paintOrder?e:t:si(e,t)}function si(e,t){return e.match===null?t:t.match===null||e.distance<=t.distance+ap?e:t}function li(e,t){switch(e.kind){case"banded":case"enclosure":return e.match.distance<=t.on.edge;case"buckets":return cp(e.match,t);case"points":return ue(e.match.distance,t)}}function lp(e,t){return e.match.index.projection==="polar"?t.polar:t.cartesian}function cp(e,t){return e.strokeDistance<=t.on.stroke?!0:ue(e.vertexDistance,t)}function mn(e,t){return t===void 0?!1:!li(e,t)&&!se(e.match,t)}function up({layer:e,cursor:t,aspectRatio:r,warmStarts:n,tolerance:a}){switch(e.kind){case"buckets":{const i=Fh(e,t,r);return i?{kind:"buckets",match:i}:null}case"banded":{const i=Dh(e,t,r);return i?{kind:"banded",match:i}:null}case"points":{const i=Qm(e,t,r,n.get(e.layerId)??null,a);return i?{kind:"points",match:i}:null}case"enclosure":{const i=Yh(e,t);return i?{kind:"enclosure",match:i}:null}case"noop":return null}}function dp(e,t,r,n){switch(e.kind){case"enclosure":{const a=rp(e,t,r,n!==void 0);return a?{kind:"enclosure",match:a}:null}case"points":{const a=np(e,t,r,n);return a?{kind:"points",match:a}:null}case"buckets":{const a=Jh(e,t,r);return a?{kind:"buckets",match:a}:null}case"banded":{const a=Uh(e,t,r);return a?{kind:"banded",match:a}:null}case"noop":case"render-hit-test":return null}}function mp(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:ei(e.layerId,i)}:null}var $={primary:null,group:[],related:new Map},hp=class{constructor({layers:e,coordSystem:t}){this.layerIndexes=[],this.layerRefs=[],this.viewport=null,this.aspectRatio=pp,this.isAspectStale=!1,this.warmStarts=new Map,this.cachedState=$,this.cachedKey=null,this.hoverLayers={interactive:[],normal:[],low:[]},this.hitTesters=new Map,this.cachedByKeyId=null,this.cachedByKeyState=$,this.layerIndexes=e.map(r=>an(r,t,this.aspectRatio)),this.layerRefs=e.map(r=>hn(r,t)),this.hoverLayers=pn(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=hn(i,t);if(o!==void 0&&gp(o.ref,s)){n.push(o.index),a.push(o.ref);continue}this.warmStarts.delete(i.id),n.push(an(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=pn(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 $;this.reindexForAspect();const n=r??this.viewport,a=t!==void 0&&n!==null?Jm(t,n):void 0,i=p=>ip({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(),$;const s=o.match.hit;this.warmStarts.set(s.layerId,s.pointIndex);const c=a===void 0?void 0:op(o,a),u=fp(s,c);if(this.cachedKey===u)return this.cachedState;const{group:m,related:h}=ih(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 $;const n=r.byKey.get(t);if(!n)return $;const a=`${e}:${t}`;return this.cachedByKeyId===a?this.cachedByKeyState:(this.cachedByKeyId=a,this.cachedByKeyState={primary:ei(e,n),group:[],related:new Map},this.cachedByKeyState)}invalidateCache(){this.cachedKey=null,this.cachedState=$,this.cachedByKeyId=null,this.cachedByKeyState=$}reindexForAspect(){if(this.isAspectStale){this.isAspectStale=!1;for(const e of this.layerIndexes)e.kind==="points"&&e.projection==="cartesian"&&Za(e,this.aspectRatio)}}},pp=1;function fp(e,t){const r=`${e.layerId}:${e.pointIndex}`;return t===void 0?r:`${r}:${t.intersects}:${t.onPoint}`}function hn(e,t){return{data:e.data,geom:e.geom,position:e.position,coord:t}}function pn(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 gp(e,t){return e.data===t.data&&e.geom===t.geom&&e.position===t.position&&e.coord===t.coord}var vp=Math.PI*2;function yp(e,t){const r=d.getMainAxisCoordinate(e.mainAxis,t);if(e.mainAxis==="y"){const a=U(F(r));return{x1:0,x2:"100%",y1:a,y2:a}}const n=U(r);return{x1:n,x2:n,y1:0,y2:"100%"}}function Sp(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"?ui(r):ci(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:U(F(n+o)),width:"100%",height:U(i)}:{x:U(n-o),y:0,width:U(i),height:"100%"}}function bp(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+vp,innerRadius:r,outerRadius:n}}function ci(e){const t=l.getXMin(e.observation),r=l.getXMax(e.observation);return t===null||r===null?null:r-t}function ui(e){const t=l.getYMin(e.observation),r=l.getYMax(e.observation);return t===null||r===null?null:r-t}function xp(e){return e.observationIndex??e.pointIndex}function Ap(e){return e==="buckets"||e==="filled-buckets"||e==="spanned-buckets"}function Ip(e){return e==="buckets"||e==="filled-buckets"}var Ge=.5,Tp=.3,Lp=.4,Ep=10,Cp=({layer:e,coordSystem:t,scales:r,options:n})=>e.data.size()===0?null:e.spatialKind==="rects"?t.type==="cartesian"?wp(e,t,r,n):Pp(e,t,n):Ip(e.spatialKind)&&t.type==="cartesian"?Op(e,t,n):e.spatialKind==="cells"||e.spatialKind==="spanned-buckets"?Dp(e,n):e.spatialKind==="points"?Mp(e,n):null,Rp=e=>Ap(e.spatialKind)?new Set(e.data.getValues(l.GROUP_VARIABLES.group)).size:e.data.size(),wp=(e,t,r,n)=>({type:"grow",layerId:e.id,durationSeconds:Ge*n.durationScale,baseline:Kt(e,t,r),growAxis:t.mainAxis==="x"?"y":"x",delayByKey:n.stagger?_p(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?Np(e,t,r):{}}},Mp=(e,t)=>({type:"grow",layerId:e.id,durationSeconds:Ge*t.durationScale,growAxis:"size",baseline:0,delayByKey:t.stagger?kp(e,t):{}}),Dp=(e,t)=>({type:"fade",layerId:e.id,durationSeconds:Tp*t.durationScale}),Op=(e,t,r)=>({type:"wipe",layerId:e.id,durationSeconds:Ge*r.durationScale,axis:t.mainAxis}),_p=(e,t,r)=>{const n=Ne(e.data,e.mapping,e.id),a=new Map;for(const i of e.data){const o=Ma(t,i);if(!o)continue;const s=Oa(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)},kp=(e,t)=>{const r=Ne(e.data,e.mapping,e.id),n=[];for(const a of e.data){const i=Vp(a,t.staggerOrder);i!==null&&n.push({position:i,keys:[r(a)]})}return Xt(n,t)},Vp=(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},Np=(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/Ep),i=Math.ceil(n.length/a),o=Lp*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},Fp=(e,t,r)=>({shadow:e.get("shadow",t,r),blendMode:e.get("blendMode",t,r),...di({saturation:e.get("saturation",t,r),brightness:e.get("brightness",t,r),contrast:e.get("contrast",t,r),blur:e.get("blur",t,r)})}),di=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"],fn={top:"topLeft",right:"topRight",bottom:"bottomRight",left:"bottomLeft"},Bp={top:"topRight",right:"bottomRight",bottom:"bottomLeft",left:"topLeft"},Gp={topLeft:["left","top"],topRight:["top","right"],bottomRight:["right","bottom"],bottomLeft:["bottom","left"]},Hp=(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]=Gp[c];return a>0&&r[u].strokeWidth>0&&r[m].strokeWidth>0},o=Kp(t,a),s=zp(t,a,i);return Yp(r).map(c=>({dashArray:r[c.firstEdge].dashArray,strokeWidth:r[c.firstEdge].strokeWidth,stroke:r[c.firstEdge].stroke,segments:Up(c,o,s,i)}))},$p=e=>({top:e.edges.top.strokeWidth,right:e.edges.right.strokeWidth,bottom:e.edges.bottom.strokeWidth,left:e.edges.left.strokeWidth}),Kp=(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}}},zp=(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")}}}},Yp=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}})},Up=(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=fn[s];if(!e.isClosed&&n(u)){const h=t[u],p=i(h),f=Wp(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=fn[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=Bp[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},Wp=(e,t)=>({x:e.cx+e.radius*Math.cos(t),y:e.cy+e.radius*Math.sin(t)}),qp=/^(?:https?:|mailto:)/i,Xp=e=>{if(typeof e!="string")return!1;const t=e.replace(/^[\x00-\x20]+/,"");return t.length===0?!1:qp.test(t)},jp=({locale:e,intlOptions:t})=>{const r=E(e,{day:"numeric",month:"long",year:"numeric",weekday:"long",...L,...t});return T(n=>r.format(n))},Zp=({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)),Pe=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return Gn(e);case"date":return jp(e);case"datetime":return Zp(e);case"day_month":return zn(e);case"decimal":return Hn(e);case"duration":return At(e);case"integer":return $n(e);case"month":return Yn(e);case"month_year":return Lt(e);case"percentage":return Kn(e);case"quarter":return Et(e);case"text":return xt(e);case"time":return qn(e);case"weekly_date_range":return Un(e);case"weekly_date_range_with_year":return Wn(e);case"year":return Ct(e);case"lookup":return Pe({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},mi={width:12,height:12},hi={text:null,group:null},pi=" · ",Jp=({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=ef(m,h);if(s==="none")return g===null?null:{heading:null,rows:[],comment:g};const S=mf({guides:n,locale:f,numberFormat:a}),x=g===null?tf({layers:e,coordSystem:t,guides:n,primary:p,mode:s,locale:f,numberFormat:a,resolveColorLabel:S}):hi;return{heading:x.text,rows:af({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}},Qp=(e,t,r)=>{if(W(t,"line"))return e.geom.line(t).get("dashArray",r);if(W(t,"area"))return e.geom.area(t).get("dashArray",r);if(W(t,"rule"))return e.geom.rule(t).get("dashArray",r)};function ef(e,t){return e===void 0||t===null||t===void 0?null:e.find(r=>r.id===t)?.content??null}function tf(e){const t=e.layers.find(i=>i.id===e.primary.layerId);if(!t)return hi;const r=e.mode==="observation"?jt(t,e.primary,e.resolveColorLabel):null,n=t.tooltip.fields.find(d.isHeadingField);if(n!==void 0){const i=gi(t,n,e.primary,e);return{text:i,group:i!==null&&nf(t,n)?r:null}}const a=rf(t,e);return a===null||r===null?{text:a,group:null}:{text:`${a}${pi}${r}`,group:r}}function rf(e,t){if(t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null)return null;const r=Gt(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)?Pe({valueFormat:r.valueFormat,locale:t.locale,numberFormat:t.numberFormat})(a):null}function jt(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 nf(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 af(e){const t=e.layers.find(r=>r.id===e.primary.layerId);return of(e.layers.flatMap(r=>{const n=uf({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:vi({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=>gn(e,r,o,n))}return r.tooltip.fields.flatMap((i,o)=>{if(i.kind==="group")return gn(e,r,i,n);if(d.isHeadingField(i))return[];const s=sf(e,r,i,a,`${a.layerId}:${a.pointIndex}:field-${o}`);return s===null?[]:[s]})}))}function of(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}${pi}${n}`}:r)}function fi(e,t,r){return e===null||e===r?{label:t,qualifier:null}:{label:e,qualifier:t}}function gn(e,t,r,n){const a=d.createColorValueReader(t.data,t.mapping),i=df({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??hf(e.guides,t),c=d.createSegmentYReader(t);return i.map(u=>{const m=Yt(e.readers.geom,t,u.observation,mi),{label:h,qualifier:p}=fi(jt(t,u,e.resolveColorLabel),s,e.headingGroup),f=c(u.observation);return{row:{swatchColor:ke(e.readers,t,u.observation)??null,geom:t.geom,swatchLineType:_t(Qp(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 sf(e,t,r,n,a){const i=gi(t,r,n,e);if(i===null)return null;const o=Yt(e.readers.geom,t,n.observation,mi),s=r.kind==="range"||r.kind==="aes"&&r.aes==="color",{label:c,qualifier:u}=r.title!==void 0?{label:r.title,qualifier:null}:lf(t,r,n,e);return{row:{swatchColor:s?ke(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 gi(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 lf(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 fi(jt(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 vi({related:e,layer:t,primaryLayer:r,primary:n}){const a=r===void 0?new Set:vn(r),i=[...vn(t)].filter(o=>a.has(o));return e.find(o=>i.every(s=>cf(o.observation[s],n.observation[s])))??e[0]}function vn(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 cf=(e,t)=>l.getStableKey(e??null)===l.getStableKey(t??null);function uf({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=vi({related:i,layer:e,primaryLayer:t,primary:n});return o===void 0?[]:[o]}function df({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 mf({guides:e,locale:t,numberFormat:r}){const n=new Map(e.colorGroups.map(i=>[l.getStableKey(i.value),{label:i.label,format:Pe({valueFormat:i.valueFormat,locale:t,numberFormat:r})}])),a=Pe({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 hf(e,t){return d.resolveVariableLabel(l.readVariableName(t.mapping.y),e.variableLabels)??""}function pf(e,t,r=0){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:r}function ff(e,t,r=""){const n=e[t];return typeof n=="string"?n:r}var gf=(e,t)=>({...e.annotation.arrow(t).resolve(),outline:e.annotation.arrow.outline(t).resolve()}),vf=(e,t)=>{const r=e.annotation.differenceArrow(t);return{...r.resolve(),isStrokeAuthored:Ot(r.getSource("stroke")),label:e.annotation.differenceArrow.label(t).resolve()}},yf=(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"}}},Sf=e=>e.strokeWidth>0?e.stroke??l.toPaintColor(e.fill):void 0,bf=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")}),xf=e=>({...l.DEFAULT_GRAPH_PADDING_EDGES_PX,...e.graph().get("padding")}),R=e=>{let t={top:0,right:0,bottom:0,left:0};for(const r of e.collectAll("margin"))t={...t,...r};return t},Af=e=>({header:R(e.header()),footer:R(e.footer()),headline:R(e.headline()),legend:{top:R(e.legend.top()),right:R(e.legend.right()),bottom:R(e.legend.bottom()),left:R(e.legend.left())},axisLabel:{top:R(e.axisLabel.top("x")),bottom:R(e.axisLabel.bottom("x"))},tickLabel:{top:R(e.tickLabel.top("x")),right:R(e.tickLabel.right("y")),bottom:R(e.tickLabel.bottom("x")),left:R(e.tickLabel.left("y"))}}),If=e=>({hover:e.editOutline.hover().resolve(),selected:e.editOutline.selected().resolve()}),Tf={color:l.getColor,alpha:l.getAlpha,strokeWidth:l.getStrokeWidth,lineType:l.getLineType,size:l.getSize},yn={vocabulary:{},aesthetics:{}},Sn=new WeakMap,Lf=(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}=Ef(c.styles,u),g=Pf({styles:wf(c.styles,u),colorScheme:t,vocabulary:p,visualVariableReaders:Cf(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=Rc(a);return{readers:c=>{const u=n.get(c.chrome);if(u!==void 0)return u;const m=wc(c.chrome,o,t);return n.set(c.chrome,m),m}}},Ef=(e,t)=>t===void 0?e.observation:Object.hasOwn(e.parts,t)?e.parts[t]??yn:yn,Cf=(e,t)=>{const r={};for(const[n,a]of Object.entries(e)){const i=a===void 0?void 0:Tf[a];i!==void 0&&(r[n]=a==="lineType"?Rf(t):i)}return r},Rf=e=>t=>{const r=l.getLineType(t);return r===void 0?void 0:e[r]},wf=(e,t)=>{let r=Sn.get(e);r===void 0&&(r=new Map,Sn.set(e,r));const n=r.get(t);if(n!==void 0)return n;const a={defaults:bn(e.defaults,t),overrides:bn(e.overrides,t)};return r.set(t,a),a},bn=(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=Ae(e.overrides,h,p,f,t);if(x!==void 0)return x;const A=Ae(e.defaults,h,p,f,t);if(A!==void 0)return A}const g=Ae(e.overrides,h,p,void 0,t);if(g!==void 0)return g;const S=i(h,p);return S!==void 0?S:Ae(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&&yi(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}},Ae=(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&&yi(o,r))return o}},yi=(e,t)=>e.matches===void 0?!0:t!==void 0&&e.matches(t),Zt=["sticker","pinnedNumber","comment","image"],Mf=e=>Zt.includes(e),Jt=e=>{switch(e.kind){case"pinnedNumber":case"comment":return e.annotation.at;case"sticker":return e.annotation.at.anchorType==="observation"?Of(e.annotation.at):null;default:return null}},Si=(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),bi=(e,t,r=Df)=>{const n=r(t);for(const a of Zt){const i=d.readAnnotationBucket(e,a),o=i.findIndex(c=>{const u=Jt({kind:a,annotation:c});if(u===null)return!1;const m=r(u);return Si(m,n)}),s=i[o];if(s!==void 0)return{kind:a,index:o,annotation:s}}return null},Df=e=>({...e,anchorValue:tt(e.anchorValue),...e.groupValue!==void 0&&{groupValue:tt(e.groupValue)},...e.crossValue!==void 0&&{crossValue:tt(e.crossValue)}}),tt=e=>l.readISOInstant(e)??e,Of=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),_f=(e,t)=>e.find(r=>r.scope===t.scope&&r.layerId===t.layerId&&d.arePredicatesEqual(r.predicate,t.predicate))??null,xi=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)))),Ai=e=>e.find(t=>t.geom==="line"&&t.stat.type==="smooth"),Ii=e=>e.find(t=>t.geom==="rule"&&t.stat.type==="mean");function Ti(e,{themeConfig:t}={}){return{mapping:e.mapping,layers:e.layers,scales:e.scales.map(Vf),transforms:e.transforms,highlights:e.highlights,styles:b.styles(e.styles),annotations:e.annotations,coords:e.coords,config:t===void 0?e.config:kf(e.config,t)}}var kf=(e,t)=>Li({...e},{...t}),xn=e=>(0,N.isPlainObject)(e);function Li(e,t){const r=Object.entries(e).flatMap(([n,a])=>{if(!(n in t))return[[n,a]];const i=t[n];return xn(a)&&xn(i)?[[n,Li(a,i)]]:(0,N.isEqual)(a,i)?[]:[[n,a]]});return Object.fromEntries(r)}function Vf(e){const{inferredFrom:t,...r}=e;return r.scaleType==="palette"?Nf(r):r}function Nf(e){return{...e,palette:Ff(e.palette),overrides:Bf(e.overrides)}}function Ff(e){return e.type==="custom"?{type:"custom",id:e.id}:e}function Bf(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 Qt=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 er({kind:r,annotation:a,index:n},this.metadata)}}},Gf={type:"remove-annotation",deserialize:(e,t)=>new Qt(e,t)},er=class Ei{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=$f(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 Qt({id:n.id},this.metadata):new Ei({kind:i.kind,annotation:i.annotation,index:i.index},this.metadata)}}},Hf={type:"add-annotation",deserialize:(e,t)=>new er({kind:e.kind,annotation:e.annotation,index:e.index},t)},$f=(e,t)=>{const r=Jt(t);return r===null?null:bi(e,r)},Kf=(e,t)=>{const r=tr(e);return r===null?null:Ci(r.points,t)},zf=e=>tr(e)!==null,Yf=(e,t)=>{const r=tr(e);if(r===null)return null;const n=Ci(r.points,t);return n.x===0&&n.y===0?null:r.createPatch(n)},tr=e=>{const t=Wf[e.kind];return t===null?null:t(e.annotation)},An=(e,t)=>e.anchorType!=="panel"?null:{points:[ft(e,e.offset)],createPatch:r=>t({...e,x:e.x+r.x,y:e.y+r.y})},In=(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})},Uf=(e,t)=>e.anchorType!=="panel"||t.anchorType!=="panel"?null:{points:[ft(e,e.offset),ft(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}})},Wf={text:e=>An(e.at,t=>({at:t})),sticker:e=>An(e.at,t=>({at:t})),shape:e=>In(e.region,t=>({region:t})),image:e=>In(e.region,t=>({region:t})),arrow:e=>Uf(e.start,e.end),differenceArrow:null,pinnedNumber:null,comment:null},ft=(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)},Ci=(e,t)=>({x:Tn(e.map(r=>r.x),t.x),y:Tn(e.map(r=>r.y),t.y)}),Tn=(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,N.clamp)(t,r,n)},Ri=(e,t,r)=>{const n=t.annotation;if(!jf(n,r))return null;const a=d.readAnnotationBucket(e.annotations,t.kind),i=qf(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:Xf(n,r)}},qf=(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)))},Xf=(e,t)=>{const r={};for(const n of Object.keys(t))r[n]=e[n];return r},jf=(e,t)=>Object.entries(t).some(([r,n])=>!Object.is(e[r],n)),rr=class wi{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 wi({kind:r,id:n,patch:o.inverse},this.metadata)}}},Zf={type:"update-annotation",deserialize:(e,t)=>new rr(e,t)},Pi=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=Yf(t,this.params.translation);if(r===null)return null;const n=Ri(e,t,r);return n===null?null:{spec:n.spec,revert:new rr({kind:t.kind,id:t.annotation.id,patch:n.inverse},this.metadata)}}},Jf={type:"move-annotation",deserialize:(e,t)=>new Pi(e,t)},B=class Le{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 Le({list:r,rule:s,index:o-g},this.metadata),x=i.filter(A=>!d.areStyleRuleAddressesEqual(A,s));return{spec:rt(t,r,x),revert:S}}if(s!==void 0){if(d.areStyleDeclarationsEqual(s.declarations,c))return null;const g={...s,declarations:c},S=new Le({list:r,rule:s,index:o},this.metadata),x=i.map(A=>A===s?g:A);return{spec:rt(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 Le({list:r,rule:{...n,declarations:null}},this.metadata);return{spec:rt(t,r,p),revert:f}}},Qf=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."})},eg={type:"set-style-rule",deserialize:(e,t)=>(Qf(e),new B(e,t))},rt=(e,t,r)=>d.patchSpec(e,{styles:{...e.styles,[t]:r}}),tg={type:"set-difference-arrow-style",deserialize:(e,t)=>new Mi(e,t)},Mi=class Di{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 B({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 Di(c,this.metadata)}}},rg=["cartesian","polar","flip"],w=new l.GeomRegistry,Oi=e=>w.has(e)?w.get(e):null;function nr(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 gt(e,t,r){const n=d.resolveScale(d.createScaleContext(d.createCommonContainer(w),{data:ce(e),layers:e.layers,mapping:r,customPalettes:{}}),l.inferred(t));return e.coords.coordType==="polar"?d.removeDiscreteScalePadding(n):n}var _i=class ki{constructor(t,r={}){this.type="set-chart-type",this.target={kind:"coords"},this.params=t,this.metadata=y({...r,description:pg(t)})}apply(t){const r="previous"in this.params?this.params.previous:fg(t,this.params);if(r===null)return null;const n=d.patchSpec(t,r);return n===t?null:{spec:n,revert:new ki({previous:{coords:t.coords,layers:t.layers,scales:t.scales,mapping:t.mapping}},this.metadata)}}},ng={type:"set-chart-type",deserialize:(e,t)=>new _i(e,t)},Vi={type:"sum"},ag={type:"identity"},ig=["bar","line","area","point","tile"],ar="tile",og=["y","color"],sg=Object.values(l.LAYER_LABEL_VARIABLES),lg={coordType:"cartesian",geom:ar,position:"identity"},de=e=>e.coordType==="cartesian"&&"comboType"in e&&b.COMBO_TYPES.includes(e.comboType),cg=e=>{const t=e.layers.filter(G),[r]=t;if(r===void 0)return null;const{coords:n}=e;if(n.coordType==="cartesian"){const o=Fi(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}},ug=e=>{if(!e)return!1;const t=e.layers.filter(G);if(t.length>=2)return!0;const[r]=t;return r===void 0?!1:Bi(e,r)?Gi(e,r).length>=1:ze(e,e.data.groupVariableNamesByType().numeric).length>=2},dg=e=>e?Ui(e,lg)!==null:!1,mg=e=>Ni(e)?.at(-1)?.id??null,Ni=e=>{if(e.coords.coordType!=="cartesian")return null;const t=e.layers.filter(G);return Fi(t)===null?null:t},Fi=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 hg(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)},hg=e=>e.some(t=>t.yScaleType==="secondary"||Me(t))||new Set(e.map(t=>l.readVariableName(t.mapping.y))).size>1,pg=e=>"previous"in e?"Restore the previous chart type":de(e)?`Set chart type to a ${e.comboType} combo`:`Set chart type to ${e.position} ${e.geom} in ${e.coordType} coords`,fg=(e,t)=>{const r=Ui(e,t);if(r===null)return null;const n=de(t)?vg(r,t):gg(r,t,e);return n===null||r===e?n:{...n,scales:Pg({...e,...n},n.scales)}},gg=(e,t,r)=>{if(de(t)||!Mg(t))return null;const n={...e,layers:Qi(e.layers)},a=_g(n.layers.filter(G),t),i=to(n.coords,t),o=zi(n,t),s=Ji({...n,mapping:o},t,a,o!==n.mapping);return{coords:i,layers:s,scales:nr(ro(r,s,i.coordType),s),mapping:o}},vg=(e,t)=>{const r=bg(e,t.comboType);if(r===null)return null;const n={...e,layers:r},a=kg(r.filter(G),t.comboType),i=to(n.coords,t),o=zi(n,t),s=Ji({...n,mapping:o},t,a,o!==n.mapping),c=yg(e)?s:Sg(s);return{coords:i,layers:c,scales:nr(ro(e,c,i.coordType),c),mapping:o}},yg=e=>Ni(e)!==null,Sg=e=>{const t=e.filter(G).at(-1);return t===void 0||t.yScaleType==="secondary"?e:e.map(r=>r.id===t.id?{...r,yScaleType:"secondary"}:r)},bg=(e,t)=>{const r=e.layers.filter(G);if(r.length>=2)return e.layers;const[n]=r;return n===void 0?null:Bi(e,n)?xg(e,n):Ag(e,n,t)},Bi=(e,t)=>{const r=l.readVariableName(t.mapping.color??e.mapping.color);return r!==null&&r!==""},xg=(e,t)=>{const[r]=Gi(e,t);if(r===void 0)return null;const n=d.resolveLayer(w,e.mapping,e.coords.coordType,{type:"layer",id:Hi(r,new Set(e.layers.map(a=>a.id))),geom:"line",stat:Vi,...Ki(r,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(a=>a.id===t.id?[a,n]:[a])},ze=(e,t)=>{const r=me(e);return t.filter(n=>n!==r)},Gi=(e,t)=>{const r=l.readVariableName(t.mapping.y??e.mapping.y);return ze(e,e.data.groupVariableNamesByType().numeric).filter(n=>n!==r)},me=e=>l.readMainAxisVariable(e.mapping)||l.inferXVariable(e.data),Ag=(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,me(e)),s=b.COMBO_BAR_POSITIONS[r]===null?l.LAYER_LABEL_VARIABLES.line:l.LAYER_LABEL_VARIABLES.bar,c=Ig(t,Ln(a.slice(0,-1),o,s)),u=d.resolveLayer(w,e.mapping,e.coords.coordType,{type:"layer",id:Hi(i,new Set(e.layers.map(m=>m.id))),geom:"line",stat:t.stat,...Ln([i],o,l.LAYER_LABEL_VARIABLES.line)});return e.layers.flatMap(m=>m.id===t.id?[c,u]:[m])},Hi=(e,t)=>{const r=`line:${e}`;let n=r;for(let a=2;t.has(n);a+=1)n=`${r}:${a}`;return n},Ln=(e,t,r)=>{const[n]=e;return e.length===1&&n!==void 0?Ki(n,r):$i(e,t)},$i=(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})]}),Ki=(e,t)=>({mapping:{y:e,color:t},transforms:[b.transform.constant({variableName:t,type:"categorical",value:e})]}),Ig=(e,t)=>({...e,mapping:{...e.mapping,...t.mapping},transforms:[...e.transforms,...t.transforms]}),zi=(e,t)=>{const r=l.readMainAxisVariable(e.mapping),n=Yi(t)?"":me(e);return n===r?e.mapping:{...e.mapping,x:n}},Yi=e=>e.coordType==="polar"&&e.theta==="y"&&e.position==="fill",Tg=e=>!de(e)&&e.geom===ar,Lg=e=>e.layers.filter(G).some(t=>t.geom===ar),Ui=(e,t)=>{const r=Tg(t);return r===Lg(e)?e:r?Eg({...e,layers:Qi(e.layers)}):Cg(e)??e},Eg=e=>{const t=qi(e);if(t===null)return null;const r=Rg(e,t)===null?wg(e,t):Xi(e,t);return r===null?null:Wi(e,t,r)},Cg=e=>{const t=qi(e);if(t===null)return null;const r=Xi(e,t);return r===null?null:Wi(e,t,r)},Wi=(e,t,r)=>({...e,mapping:r.mapping,layers:e.layers.map(n=>n===t?r.layer:n)}),qi=e=>{const t=e.layers.filter(G);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:ji(t)}},ji=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}},Rg=(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===me(e))return null;const i=ce(e);return i.hasVariable(n)&&i.getType(n)==="numeric"?null:n},wg=(e,t)=>{const r=ze(e,e.data.groupVariableNamesByType().numeric);if(r.length<2)return null;const n=l.readFoldKeepVariables(e.data,me(e)),a=$i(r,n),i=ji(t);return{mapping:{...e.mapping,y:a.mapping.color,color:a.mapping.y},layer:{...i,transforms:[...i.transforms,...a.transforms]}}},Pg=(e,t)=>og.reduce((r,n)=>{const a=gt(e,n,e.mapping);return r.some(i=>i.scaledAesthetic===n)?d.mapItems(r,i=>i.scaledAesthetic===n?a:i):[...r,a]},t),Mg=e=>rg.includes(e.coordType)&&Zi(e.geom)&&Dg(e)&&(e.coordType!=="polar"||Number.isFinite(e.innerRadius)),Dg=({geom:e,coordType:t,position:r})=>{const{supportedCoordTypes:n,supportedPositions:a}=w.get(e);return n.includes(t)&&a.includes(r)},Zi=e=>ig.includes(e),G=e=>Zi(e.geom)&&!Og(e.stat),Og=e=>{switch(e.type){case"smooth":return!0;case"identity":case"count":case"mean":case"sum":case"summary":return!1;default:return!0}},_g=(e,{geom:t,position:r})=>{const n={geom:t,position:r};return new Map(e.map(a=>[a.id,n]))},kg=(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:Vg(i,t,n)}]);return new Map(a)},Vg=(e,t,r)=>e.geom!=="bar"||Me(e)?r:b.readComboTypeOfBarPosition(e.position)===t?e.position:r,Ji=(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=Ng(i.stat,e.coords,t);return a||n||i.geom!==o.geom||i.position!==o.position||s!==i.stat?Bg(e,{...i,stat:s},t.coordType,o):i}))},Ng=(e,t,r)=>Yi(r)?e.type==="identity"?Vi:e:Fg(t)&&e.type==="sum"?ag:e,Fg=e=>e.coordType==="polar"&&e.params.theta==="y",Bg=(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}},Qi=e=>{const t=e.filter(G);if(t.length<2||!e.some(Me))return e;const[r]=t;return e.flatMap(n=>n===r?[Gg(n)]:Me(n)?[]:[n])},Me=e=>eo(e)!==null,eo=e=>{const t=e.transforms.at(-1);return t?.transformType==="reshape"?t.options.keyName==="key"?t:null:t?.transformType!=="constant"?null:sg.includes(t.options.variableName)?t:null},Gg=e=>{const t=eo(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)}},to=(e,t)=>{const r=Hg(e,t);return(0,N.isEqual)(r,e)?e:r},Hg=(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}})},ro=(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=$g(o,n,a),c=Kg(s,n,a);return Yg(c,r,i)})},$g=(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=zg(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},Kg=(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}},zg=(e,t,r)=>t.nice===(r?.nice??!0)?e:t.nice?l.CONTINUOUS_SCALE_DEFAULTS.nice:!1,Yg=(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}},no=class ao{constructor(t,r={}){this.type="set-mapping",this.params=t,this.target={kind:"mapping",aesthetic:t.aesthetic},this.metadata=y({...r,description:Wg(t)})}apply(t){const r="previous"in this.params?this.params.previous:qg(t,this.params);if(r===null)return null;const n=d.patchSpec(t,r);return n===t?null:{spec:n,revert:new ao({aesthetic:this.params.aesthetic,previous:{mapping:t.mapping,scales:t.scales,layers:t.layers}},this.metadata)}}},Ug={type:"set-mapping",deserialize:(e,t)=>new no(e,t)},io=(e,t)=>{const r=l.readVariableName(e[t]);return r===null||r===""||l.isInternalVariable(r)?null:r},oo=e=>e===""?null:e,Wg=e=>{if("previous"in e)return`Restore the previous ${e.aesthetic} mapping`;const t=oo(e.variable);return t===null?`Clear the ${e.aesthetic} mapping`:`Map ${e.aesthetic} to ${t}`},qg=(e,{aesthetic:t,variable:r})=>{if(!b.isAestheticKey(t))return null;const n=oo(r),a=jg(e.mapping,t,n);return a===e.mapping?null:{mapping:a,scales:Jg(e,t,a,n),layers:Xg(e.layers,a)}},Xg=(e,t)=>d.mapItems(e,r=>{const n={...t,...r.mapping};if(n.label===void 0&&Oi(r.geom)===null)return r;const a=d.resolveLabelSource(w,r.geom,r.position,n);return(0,N.isEqual)(a,r.dataLabels.labelSource)?r:{...r,dataLabels:{...r.dataLabels,labelSource:a}}}),jg=(e,t,r)=>r===null?Zg(e,t):io(e,t)===r?e:{...e,[t]:r},Zg=(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},Jg=(e,t,r,n)=>{if(!l.isScaledAestheticKey(t))return e.scales;let a=e.scales;for(const i of Qg(e,t))a=tv(e,a,i,r,n);return a},Qg=(e,t)=>t==="y"&&ev(e.layers)?["y","ySecondary"]:[t],ev=e=>{const t=e.find(r=>r.yScaleType==="secondary");return t!==void 0&&t.mapping.y===void 0},tv=(e,t,r,n,a)=>{const i=t.find(s=>s.scaledAesthetic===r);if(i===void 0)return a===null?t:[...t,gt(e,r,n)];if(a===null&&!l.isPositionScale(r)||a!==null&&!ce(e).hasVariable(a))return t;const o=gt(e,r,n);return rv(i,o)?t:d.mapItems(t,s=>s.scaledAesthetic===r?o:s)},rv=(e,t)=>e.scaleType===t.scaleType||En(e)&&En(t),En=e=>e.scaleType==="discrete"||e.scaleType==="palette",ir=e=>e==="both"?["x","y"]:[e],so=e=>e==="both"?"the":`${e} axis`;function or(e,t){return he(e)?e[t]:e}function nv(e,t){return e.config.axes[t]??{}}function av(e,t,r){if(t!=="ySecondary")return d.updateSpec(e,{config:{axes:{[t]:r}}});const n=e.config.axes.ySecondary,a=lo(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 he(e){return l.isPlainObject(e)&&"x"in e&&"y"in e}function lo(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?iv(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 iv(e,t){return l.isPlainObject(t)?lo(l.isPlainObject(e)?e:void 0,t):t}var co=class uo{constructor(t,r={}){this.type="set-axis-label",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis label to ${sv(t.label)}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,label:n}=this.params,a=nv(t,r).label;if(a===n)return null;const i=av(t,r,{label:n});return i===t?null:{spec:i,revert:new uo(r==="ySecondary"?{axis:r,label:a}:{axis:r,label:a??null},this.metadata)}}},ov={type:"set-axis-label",deserialize:(e,t)=>new co(e,t)};function sv(e){return e===void 0?"(inherited)":e??"(none)"}var mo=class ho{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 ho({axis:r,position:a},this.metadata)}}},lv={type:"set-axis-position",deserialize:(e,t)=>new mo(e,t)},po=class fo{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 fo({axis:r,tickMode:a},this.metadata)}}},cv={type:"set-axis-tick-mode",deserialize:(e,t)=>new po(e,t)},go=class vo{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 vo({axis:r,isVisible:a},this.metadata)}}},uv={type:"set-axis-ticks-visibility",deserialize:(e,t)=>new go(e,t)},yo=class So{constructor(t,r={}){this.type="set-axis-visibility",this.params=t,this.metadata=y({...r,description:`Set ${t.axis} axis visibility to ${t.isVisible}`})}get target(){return{kind:"axis",axis:this.params.axis}}apply(t){const{axis:r,isVisible:n}=this.params,a=t.config.axes[r].isVisible;return a===n?null:{spec:d.updateSpec(t,{config:{axes:{[r]:{isVisible:n}}}}),revert:new So({axis:r,isVisible:a},this.metadata)}}},dv={type:"set-axis-visibility",deserialize:(e,t)=>new yo(e,t)},bo=class xo{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 xo({caption:r},this.metadata)}}},mv={type:"set-content-caption",deserialize:(e,t)=>new bo(e,t)},Ao=class Io{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 Io({source:r},this.metadata)}}},hv={type:"set-content-source",deserialize:(e,t)=>new Ao(e,t)},To=class Lo{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 Lo({subtitle:r},this.metadata)}}},pv={type:"set-content-subtitle",deserialize:(e,t)=>new To(e,t)},Eo=class Co{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 Co({title:r},this.metadata)}}},fv={type:"set-content-title",deserialize:(e,t)=>new Eo(e,t)},Ro=(e,t,r,n)=>{const a=gv(t,r),i=yv(e,a,n);let o=e,s=!1;for(const c of a){const u=bv(o,c,n,Sv(c,n,vv(r,c)));u!==null&&(o=u,s=!0)}return s?{spec:o,previous:i}:null},gv=(e,t)=>e==="both"&&!he(t)?[void 0]:ir(e),vv=(e,t)=>t===void 0?he(e)?e.x:e:or(e,t),yv=(e,t,r)=>t.length===1?nt(e,t[0],r):{x:nt(e,"x",r),y:nt(e,"y",r)},nt=(e,t,r)=>Po(e,t)?.[r]??null,Sv=(e,t,r)=>r===null||t==="strokeWidth"?r:(e===void 0?["x","y"]:[e]).every(n=>wo(l.STYLE_TARGETS.gridLine.children[n].rest[t],r))?null:r,wo=(e,t)=>Array.isArray(e)&&Array.isArray(t)?kt(e,t):e===t,bv=(e,t,r,n)=>{const a=Po(e,t);return wo(a?.[r]??null,n)?null:new B({list:"overrides",rule:Tv(t,Iv(a,r,n))}).apply(e)?.spec??null},xv=e=>e.select.target==="gridLine",Av=e=>({select:e===void 0?{target:"gridLine"}:{target:"gridLine",axis:e}}),Po=(e,t)=>{const r=d.findStyleRule(e.styles.overrides,Av(t),d.readStyleCoord(e));if(!(r===void 0||!xv(r)))return r.declarations},Iv=(e,t,r)=>{const{[t]:n,...a}=e??{};return r!==null?{...a,[t]:r}:Object.keys(a).length===0?null:a},Cn=(e,t)=>e===void 0?b.style.gridLine(t):e==="x"?b.style.gridLine.x(t):b.style.gridLine.y(t),Tv=(e,t)=>t===null?{...Cn(e,{}),declarations:null}:Cn(e,t),Mo=class Do{constructor(t,r={}){this.type="set-grid-line-style",this.params=t,this.metadata=y({...r,description:`Set ${so(t.axis)} grid line style to ${Ev(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,Cv),"dashArray");return a===null?null:{spec:a.spec,revert:new Do({axis:r,lineStyle:Rn(a.previous,Rv)},this.metadata)}}},Lv={type:"set-grid-line-style",deserialize:(e,t)=>new Mo(e,t)},Ev=({axis:e,lineStyle:t})=>{const r=ir(e).map(n=>or(t,n)??"(theme)");return[...new Set(r)].join(" and ")},Cv=e=>e===null?null:l.DASH_PRESETS.gridLine[e],Rv=e=>e===null?null:_t(e),Rn=(e,t)=>he(e)?{x:t(e.x),y:t(e.y)}:t(e),wv={type:"set-grid-line-width",deserialize:(e,t)=>new Oo(e,t)},Oo=class _o{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 ${so(t.axis)} grid line width to ${Mv(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 _o({axis:r,lineWidth:a.previous},this.metadata)}}},Pv=e=>he(e)?{x:at(e.x),y:at(e.y)}:at(e),at=e=>e===null||!Number.isFinite(e)?null:Math.max(0,e),Mv=(e,t)=>{const r=ir(e).map(n=>or(t,n)??"(theme)");return[...new Set(r)].join(" and ")},ko=class Vo{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 Vo({axis:r,isVisible:a},this.metadata)}}},Dv={type:"set-grid-visibility",deserialize:(e,t)=>new ko(e,t)},No=class Fo{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 Fo({compareWith:r},this.metadata)}}},Ov={type:"set-headline-compare-with",deserialize:(e,t)=>new No(e,t)},Bo=class Go{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 Go({position:r},this.metadata)}}},_v={type:"set-headline-position",deserialize:(e,t)=>new Bo(e,t)},Ho=class $o{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 $o({show:r},this.metadata)}}},kv={type:"set-headline-show",deserialize:(e,t)=>new Ho(e,t)},Ko=class zo{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 zo({size:r},this.metadata)}}},Vv={type:"set-headline-size",deserialize:(e,t)=>new Ko(e,t)},Nv={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 Uo(e)===this.params.dimStyle?null:new B({list:"overrides",rule:Bv(this.params.dimStyle,Fv(e))},this.metadata).apply(e)}},vt={select:{target:"geom"},when:{state:"dimmed"}},Uo=e=>d.combineStyleDeclarations(e.styles.overrides,vt,d.readStyleCoord(e))?.saturation===0?"desaturate":"dim",Fv=e=>{const t=d.readStyleCoord(e);return d.combineStyleDeclarations(d.readStyleRulesBeneath(e.styles.overrides,vt,t),vt,t)?.saturation===0},Bv=(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"}),Wo=class qo{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 qo({align:r},this.metadata)}}},Gv={type:"set-legend-align",deserialize:(e,t)=>new Wo(e,t)},Xo=class jo{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 jo({display:r},this.metadata)}}},Hv={type:"set-legend-display",deserialize:(e,t)=>new Xo(e,t)},Zo=class Jo{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 Jo({position:r,align:n},this.metadata)}}},$v={type:"set-legend-placement",deserialize:(e,t)=>new Zo(e,t)},Qo=class es{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 es({position:r},this.metadata)}}},Kv={type:"set-legend-position",deserialize:(e,t)=>new Qo(e,t)},ts=class rs{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 rs({abbreviation:r},this.metadata)}}},zv={type:"set-number-format-abbreviation",deserialize:(e,t)=>new ts(e,t)},ns=class as{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 as({decimals:r},this.metadata)}}},Yv={type:"set-number-format-decimals",deserialize:(e,t)=>new ns(e,t)},is=class os{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=Wv(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 os({part:r,isVisible:i},this.metadata)}}},Uv={type:"toggle-content-visibility",deserialize:(e,t)=>new is(e,t)},wn={title:"isTitleVisible",subtitle:"isSubtitleVisible",caption:"isCaptionVisible",source:"isSourceVisible"};function Wv(e){return Object.hasOwn(wn,e)?wn[e]:void 0}var ss=class ls{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 ls(o,this.metadata);return{spec:d.patchSpec(t,{coords:Xv(t.coords,i)}),revert:s}}},qv={type:"set-coord-limits",deserialize:(e,t)=>new ss(e,t)};function Xv(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 cs=class us{constructor(t,r={}){this.type="set-polar-inner-radius",this.target={kind:"coords"},this.params={innerRadius:(0,N.clamp)(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 us({innerRadius:n},this.metadata)}}},jv={type:"set-polar-inner-radius",deserialize:(e,t)=>new cs(e,t)},Zv={type:"set-polar-start-angle",deserialize:(e,t)=>new ds(e,t)},ds=class ms{constructor(t,r={}){this.type="set-polar-start-angle",this.target={kind:"coords"},this.params={startAngle:Pn(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 Pn(n)===this.params.startAngle?null:{spec:d.patchSpec(t,{coords:{...r,params:{...r.params,startAngle:this.params.startAngle}}}),revert:new ms({startAngle:n},this.metadata)}}},it=360,Pn=e=>(e%it+it)%it,sr=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 lr({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}}},Jv={type:"remove-highlight",deserialize:(e,t)=>new sr(e,t)},lr=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 sr({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}}},Qv={type:"add-highlight",deserialize:(e,t)=>new lr(e,t)};function cr(e,t){return{...e,params:{...e.params,...t}}}function Ye(e,t){return{...e,dataLabels:{...e.dataLabels,...t}}}function ur(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 dr=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 mr({layer:r,index:t},this.metadata)}}},ey={type:"remove-layer",deserialize:(e,t)=>new dr(e,t)},mr=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 dr({layerId:t.id},this.metadata)}}},ty={type:"add-layer",deserialize:(e,t)=>new mr(e,t)},hs=class ps{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 B({list:"overrides",rule:{...a,declarations:ny(i,n)}}).apply(t);if(!s)return null;const c=new ps({layerId:r,cornerRadius:o},this.metadata);return{spec:s.spec,revert:c}}},ry={type:"set-bar-corner-radius",deserialize:(e,t)=>new hs(e,t)},ny=(e,t)=>{const{cornerRadius:r,...n}=e??{};return t!==null?{...n,cornerRadius:t}:Object.keys(n).length===0?null:n},ay={type:"set-bar-width",deserialize:(e,t)=>new gs(e,t)},fs=.05,iy=1,gs=class vs{constructor(t,r={}){this.type="set-bar-width";const n=t.width===void 0?void 0:(0,N.clamp)(t.width,fs,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,cr(r,{width:this.params.width})),revert:new vs({layerId:r.id,width:n},this.metadata)}}},ys=class Ss{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 Ss({layerId:r.id,format:n},this.metadata)}}},oy={type:"set-data-labels-format",deserialize:(e,t)=>new ys(e,t)},bs=class xs{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 xs({layerId:r.id,position:n},this.metadata)}}},sy={type:"set-layer-position",deserialize:(e,t)=>new bs(e,t)},As=class Is{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 cy(n,this.params.stat)?null:{spec:M(t,r.id,{...r,stat:this.params.stat}),revert:new Is({layerId:r.id,stat:n},this.metadata)}}},ly={type:"set-layer-stat",deserialize:(e,t)=>new As(e,t)},cy=(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},Ts=class Ls{constructor(t,r={}){this.type="set-layer-y-scale-type",this.params=t,this.metadata=y({...r,description:`Set layer to ${t.yScaleType} y axis`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?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?nr(a.scales,a.layers):this.params.previousScales}),revert:new Ls({layerId:r.id,yScaleType:n,previousScales:t.scales},this.metadata)}}},uy={type:"set-layer-y-scale-type",deserialize:(e,t)=>new Ts(e,t)},Es=class Cs{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,cr(r,{curve:this.params.curve})),revert:new Cs({layerId:r.id,curve:n},this.metadata)}}},dy={type:"set-line-curve",deserialize:(e,t)=>new Es(e,t)},Rs=class ws{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,cr(r,{missingValues:this.params.missingValues})),revert:new ws({layerId:r.id,missingValues:n},this.metadata)}}},my={type:"set-line-missing-values",deserialize:(e,t)=>new Rs(e,t)},Ps=class Ms{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=py(i,n),c=new B({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 Ms({layerId:r,lineWidth:o},this.metadata)}:null}},hy={type:"set-line-width",deserialize:(e,t)=>new Ps(e,t)},py=(e,t)=>{const{strokeWidth:r,...n}=e??{};return t!==null?{...n,strokeWidth:t}:Object.keys(n).length===0?null:n},Ds=class Os{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 B({list:"overrides",rule:{...a,declarations:gy(i,n)}}).apply(t);return s?{spec:s.spec,revert:new Os({layerId:r,size:o},this.metadata)}:null}},fy={type:"set-point-size",deserialize:(e,t)=>new Ds(e,t)},gy=(e,t)=>{const{size:r,...n}=e??{};return t!==null?{...n,size:t}:Object.keys(n).length===0?null:n},_s=class ks{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 ks({layerId:r.id,label:n??null},this.metadata)}}},vy={type:"set-rule-label",deserialize:(e,t)=>new _s(e,t)},Vs=class Ns{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 Ns({layerId:r.id,value:a},this.metadata)}}},yy={type:"set-rule-value",deserialize:(e,t)=>new Vs(e,t)},Sy={type:"set-stat-line",deserialize:(e,t)=>new Fs(e,t)},Fs=class Bs{constructor(t,r={}){this.type="set-stat-line",this.params=t,this.metadata=y({...r,description:Ey(t.line)})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=xy(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 Bs({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:ur(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"?Ay(this.params):Iy(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}}},by="linear",xy=e=>{const t=Ai(e.layers);if(t!==void 0)return{line:"trend",layer:t};const r=Ii(e.layers);if(r!==void 0)return{line:"average",layer:r}},Ay=({method:e})=>l.geom.line({aes:{lineType:{value:"dashed"}},stat:b.stat.smooth({method:e??by}),interactive:!1}),Iy=(e,{group:t,label:r})=>{const n=Ty(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})},Ty=e=>e.layers.find(t=>t.geom!=="rule"&&t.stat.type!=="smooth"),Ly=(e,t)=>(0,N.isEqual)({...e,id:""},{...t,id:""}),Ey=e=>e==="none"?"Hide stat line":`Show ${e} line`,Gs=class Hs{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 Hs({layerId:r.id,showCategoryLabels:n},this.metadata)}}},Cy={type:"toggle-category-labels",deserialize:(e,t)=>new Gs(e,t)},$s=class Ks{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 Ks({layerId:r.id,showDataLabels:n},this.metadata)}}},Ry={type:"toggle-data-labels",deserialize:(e,t)=>new $s(e,t)},wy={type:"toggle-goal-line",deserialize:(e,t)=>new zs(e,t)},zs=class yt{constructor(t,r={}){this.type="toggle-goal-line",this.params=t,this.metadata=y({...r,description:`${t.showGoalLine?"Show":"Hide"} goal line`})}get target(){return{kind:"layer",layerId:this.params.removedLayer?.id??this.params.layerId}}apply(t){const r=xi(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 yt({showGoalLine:!0,removedLayer:r},this.metadata)}}if(r!==void 0)return null;const n=this.params.removedLayer??this.buildGoalLine(t);return{spec:ur(t,n),revert:new yt({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??Py}},params:{labelPosition:r,...this.params.label!==void 0&&{label:this.params.label}},interactive:!1}))}},Py=0,My={type:"toggle-line-fill",deserialize:(e,t)=>new Ys(e,t)},Ys=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(Mn(o?.fillAlpha??s?.fillAlpha)===r)return null;const c=Oy(r,n,Mn(s?.fillAlpha));return new B({list:"overrides",rule:{...a,declarations:_y(o,c)}},this.metadata).apply(e)}},Dy=.2,Mn=e=>(e??0)>0,Oy=(e,t,r)=>e?t??(r?null:Dy):r?0:null,_y=(e,t)=>{const{fillAlpha:r,...n}=e??{};return t!==null?{...n,fillAlpha:t}:Object.keys(n).length===0?null:n},ky={type:"toggle-line-points",deserialize:(e,t)=>new Us(e,t)},Us=class St{constructor(t,r={}){this.type="toggle-line-points",this.params=t,this.metadata=y({...r,description:`${t.showPoints?"Show":"Hide"} points`})}get target(){return{kind:"layer",layerId:this.params.layerId}}apply(t){const r=this.params.layerId?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:ur(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 St({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 St({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]))}},Ws=class qs{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 qs({layerId:r.id,showStackTotals:n},this.metadata)}}},Vy={type:"toggle-stack-totals",deserialize:(e,t)=>new Ws(e,t)},hr=class Xs{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 Xs(c,this.metadata)}}},Ny={type:"set-scale-domain",deserialize:(e,t)=>new hr(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)}}},Fy={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||!Gy(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)}}},By={type:"set-scale-reverse",deserialize:(e,t)=>new Js(e,t)};function Gy(e){return e.scaleType==="continuous"||e.scaleType==="datetime"||e.scaleType==="discrete"}var Hy=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."})},We=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,N.isEqual)(r,t)?null:{spec:r,revert:new el({commands:n.reverse()},this.metadata)}}},tl=class rl{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;if(n===this.params.transform)return null;const a=this.params.transform==="log"&&r.domainMin!==null,i=$e(t,this.params.scaledAesthetic,{...r,transform:this.params.transform,...a?{domainMin:null}:{}}),o=new rl({scaledAesthetic:this.params.scaledAesthetic,transform:n},this.metadata);return{spec:i,revert:a?new We({commands:[o,new hr({scaledAesthetic:this.params.scaledAesthetic,domainMin:r.domainMin},this.metadata)]},this.metadata):o}}},$y={type:"set-scale-transform",deserialize:(e,t)=>new tl(e,t)},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=La(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 Yy(n,o))a(zy(n,s,o.property));for(const o of t)a(Wy(n,o,this.params.color));if(r.length===0||(0,N.isEqual)(n,e))return null;const[i]=r;return r.length===1&&i!==void 0?{spec:n,revert:i}:{spec:n,revert:new We({commands:[...r].reverse()},this.metadata)}}},Ky={type:"set-observations-color",deserialize:(e,t)=>new nl(e,t)},zy=(e,t,r)=>{const n=t[t.length-1];if(n===void 0||!t.some(o=>Uy(o.declarations,r)))return[];const a=il(al(t),r,null);if(t.length===1)return a!==null&&d.areStyleDeclarationsEqual(a,n.declarations)?[]:[K(n,a)];const i=[K(n,null)];if(a!==null){const o=d.findStyleRuleIndex(e.styles.overrides,n,d.readStyleCoord(e));i.push(K(n,a,o-(t.length-1)))}return i},Yy=(e,t)=>{const r=[],n=new Map;for(const a of e.styles.overrides){if(a.when?.state!==void 0||!Xy(a,t)||!jy(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}),{}),Uy=(e,t)=>Object.entries(e).some(([r])=>r===t),Wy=(e,t,r)=>{const n=e.styles.overrides,a=qy(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?[]:[K(a,c)];if(!d.isGeomStyleRule(s))return[];if(c===null)return[K(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[K(s,c)];const m=u?o-(i.length-1):void 0;return[K(s,null),K(s,c,m)]},K=(e,t,r)=>new B({list:"overrides",rule:{...e,declarations:t},...r===void 0?{}:{index:r}}),qy=e=>({select:{target:"geom",kind:e.geomKind,layer:e.layerId},...e.where===void 0?{}:{when:{where:e.where}}}),Xy=(e,t)=>d.isGeomStyleRule(e)&&e.select.kind===t.geomKind&&e.select.layer===t.layerId&&e.select.part===void 0,jy=(e,t)=>{const r=Dn(e);if(r===null)return!1;const n=t===void 0?[]:Dn(t);return n===null?!1:n.every(a=>r.some(i=>i.variable===a.variable&&(0,N.isEqual)(i.eq,a.eq)))&&r.length>n.length},Dn=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(ng);v.register(Ug);v.register(ty);v.register(ey);v.register(oy);v.register(sy);v.register(ly);v.register(uy);v.register(dy);v.register(hy);v.register(ry);v.register(ay);v.register(fy);v.register(my);v.register(vy);v.register(yy);v.register(Sy);v.register(Cy);v.register(Ry);v.register(wy);v.register(My);v.register(ky);v.register(Vy);v.register(Ny);v.register(Fy);v.register(By);v.register($y);v.register(ov);v.register(cv);v.register(lv);v.register(uv);v.register(dv);v.register(mv);v.register(hv);v.register(pv);v.register(fv);v.register(Lv);v.register(wv);v.register(Dv);v.register(Ov);v.register(_v);v.register(kv);v.register(Vv);v.register(Nv);v.register(Gv);v.register(Hv);v.register($v);v.register(Kv);v.register(zv);v.register(Yv);v.register(Uv);v.register(Qv);v.register(Jv);v.register(eg);v.register(Ky);v.register(Hf);v.register(Gf);v.register(Zf);v.register(tg);v.register(Jf);v.register(qv);v.register(jv);v.register(Zv);v.register({type:"sequence",deserialize:(e,t)=>(Hy(e),new We({commands:e.commands.map(r=>v.deserialize(r))},t))});var sl=(e,t)=>e===t?!0:e===null||t===null?!1:bt(e)===bt(t),bt=e=>{switch(e.kind){case"annotation":case"highlight":return JSON.stringify([e.kind,e.id]);case"styleRule":return JSON.stringify([e.kind,e.list,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:On(this.undoStack),redoStack:On(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&&Jy(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)}}},Zy=Object.freeze([]),Jy=(e,t)=>e.type===t.type&&sl(e.target,t.target),On=e=>e.length===0?Zy:e.map(t=>t.command.metadata),Qy=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}},eS=class{constructor(e){this.compiler=e,this.history=new ll,this.current=null,this.last=null,this.hostSpec=null,this.run=new Qy(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=Ti(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}},tS=new Set(["x","y"]),_n=["numeric","categorical","temporal"],kn=["numeric"],rS=(e,t)=>{const r=e.layers.map(a=>Oi(a.geom)).filter(l.isDefined),n=ce(e);return t.filter(a=>nS(e,r,a)).map(a=>({aesthetic:a,variables:aS(n,r,a),isRequired:tS.has(a)}))},nS=(e,t,r)=>{switch(r){case"x":return!sS(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))}},aS=(e,t,r)=>{const n=iS(t,r);return e.getVariableNames().filter(a=>!l.isInternalVariable(a)&&n.includes(e.getType(a)))},iS=(e,t)=>t==="size"?kn:t!=="x"&&t!=="y"?_n:oS(e,t)?kn:_n,oS=(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))),sS=e=>e.coordType==="polar"&&e.params.theta==="y",lS=500,cS="normal",pr={thin:100,hairline:100,extraLight:200,ultraLight:200,light:300,normal:400,regular:400,medium:500,semiBold:600,demiBold:600,bold:700,extraBold:800,ultraBold:800,black:900,heavy:900,extraBlack:950,ultraBlack:950},uS=e=>{const t=e.style??"normal",r=e.weight??500,n=e.family.includes(",")?e.family:`'${e.family}'`;return`${t} ${r} ${e.size}px ${n}`},fr=e=>typeof e!="string"?e??500:pr[e],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,dS="\0",mS=class{constructor(e){this.inner=e,this.cache=new Map}measureText(e,t){const r=this.getCacheKey(e,t),n=this.cache.get(r);if(n)return n;const a=this.inner.measureText(e,t);return this.cache.set(r,a),a}getCacheKey(e,t){return[t.family,t.size,fr(t.weight),t.style??"normal",t.letterSpacing??0,t.textTransform??"none",e].join(dS)}},hS={" ":.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 pS=1.05,fS=.84,gS=.21,vS=class{measureText(e,t){const r=cl(e,t.textTransform);let n=ul(r,t.letterSpacing);for(const o of r)n+=(hS[o]??.55)*t.size;fr(t.weight)>=pr.semiBold&&(n*=pS);const a=fS*t.size,i=gS*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=Fu;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=er;exports.AddHighlightCommand=lr;exports.AddLayerCommand=mr;exports.BAR_WIDTH_FRACTION=l.BAR_WIDTH_FRACTION;exports.BORDER_RADIUS_PX=Ht;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=mS;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=cS;exports.DEFAULT_FONT_WEIGHT=lS;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=eS;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=Pa;exports.HEADLINE_TREND_ICON_SIZE_PX=mm;exports.HEADLINE_VALUE_LABEL_GAP_EM=wa;exports.HeuristicTextMeasurer=vS;exports.HoverEngine=hp;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=mu;exports.MAX_BAR_WIDTH_FRACTION=iy;exports.MIN_BAR_WIDTH_FRACTION=fs;exports.MONO_BASES=l.MONO_BASES;exports.MoveAnnotationCommand=Pi;exports.NAMED_WEIGHTS=pr;exports.NEON_BASES=l.NEON_BASES;exports.OBSERVATION_ATTACHMENT_KINDS=Zt;exports.OUT_OF_VIEW_MARGIN_PX=Bu;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=$;exports.RemoveAnnotationCommand=Qt;exports.RemoveHighlightCommand=sr;exports.RemoveLayerCommand=dr;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=Gu;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=We;exports.SetAxisLabelCommand=co;exports.SetAxisPositionCommand=mo;exports.SetAxisTickModeCommand=po;exports.SetAxisTicksVisibilityCommand=go;exports.SetAxisVisibilityCommand=yo;exports.SetBarCornerRadiusCommand=hs;exports.SetBarWidthCommand=gs;exports.SetChartTypeCommand=_i;exports.SetContentCaptionCommand=bo;exports.SetContentSourceCommand=Ao;exports.SetContentSubtitleCommand=To;exports.SetContentTitleCommand=Eo;exports.SetCoordLimitsCommand=ss;exports.SetDataLabelsFormatCommand=ys;exports.SetDifferenceArrowStyleCommand=Mi;exports.SetGridLineStyleCommand=Mo;exports.SetGridLineWidthCommand=Oo;exports.SetGridVisibilityCommand=ko;exports.SetHeadlineCompareWithCommand=No;exports.SetHeadlinePositionCommand=Bo;exports.SetHeadlineShowCommand=Ho;exports.SetHeadlineSizeCommand=Ko;exports.SetHighlightDimStyleCommand=Yo;exports.SetLayerPositionCommand=bs;exports.SetLayerStatCommand=As;exports.SetLayerYScaleTypeCommand=Ts;exports.SetLegendAlignCommand=Wo;exports.SetLegendDisplayCommand=Xo;exports.SetLegendPlacementCommand=Zo;exports.SetLegendPositionCommand=Qo;exports.SetLineCurveCommand=Es;exports.SetLineMissingValuesCommand=Rs;exports.SetLineWidthCommand=Ps;exports.SetMappingCommand=no;exports.SetNumberFormatAbbreviationCommand=ts;exports.SetNumberFormatDecimalsCommand=ns;exports.SetObservationsColorCommand=nl;exports.SetPointSizeCommand=Ds;exports.SetPolarInnerRadiusCommand=cs;exports.SetPolarStartAngleCommand=ds;exports.SetRuleLabelCommand=_s;exports.SetRuleValueCommand=Vs;exports.SetScaleDomainCommand=hr;exports.SetScalePaletteCommand=js;exports.SetScaleReverseCommand=Js;exports.SetScaleTransformCommand=tl;exports.SetStatLineCommand=Fs;exports.SetStyleRuleCommand=B;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=Gs;exports.ToggleContentVisibilityCommand=is;exports.ToggleDataLabelsCommand=$s;exports.ToggleGoalLineCommand=zs;exports.ToggleLineFillCommand=Ys;exports.ToggleLinePointsCommand=Us;exports.ToggleStackTotalsCommand=Ws;exports.UNIT_POLAR_PATH_FRAME=Na;exports.UpdateAnnotationCommand=rr;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=xd;exports.areEditTargetsEqual=sl;exports.areEndpointsComparable=d.areEndpointsComparable;exports.areMappingsEquivalent=l.areMappingsEquivalent;exports.areObservationAnchorsEqual=Si;exports.arePointerRegionListsEqual=pd;exports.arePredicatesEqual=d.arePredicatesEqual;exports.areStyleDeclarationsEqual=d.areStyleDeclarationsEqual;exports.areStyleRuleAddressesEqual=d.areStyleRuleAddressesEqual;exports.buildAverageLineSymbols=_u;exports.buildBarRectBounds=Da;exports.buildCalloutHitRegions=Nu;exports.buildColumnKey=Oa;exports.buildDataLabelsContent=Xu;exports.buildDiagnostic=d.buildDiagnostic;exports.buildEditMenuTriggerRegion=Sd;exports.buildFontString=uS;exports.buildHeadlineItemRows=hm;exports.buildLayerIntroPlan=Cp;exports.buildLayerStyleAddress=d.buildLayerStyleAddress;exports.buildObservationPredicate=td;exports.buildObservationsTarget=ba;exports.buildObservationsTargetAtValue=sd;exports.buildPanelAnchorBox=l.buildPanelAnchorBox;exports.buildPointSymbolInBox=Rm;exports.buildPointSymbolPath=Cm;exports.buildPolarBarArcPath=km;exports.buildSliceGroupKey=Fa;exports.buildTooltipContent=Jp;exports.canAnchorDirectLabels=d.canAnchorDirectLabels;exports.canBecomeCombo=ug;exports.canBecomeHeatmap=dg;exports.canPlaceDataLabels=qu;exports.clampAnnotationTranslation=Kf;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=Mu;exports.computeDifferenceArrow=na;exports.computeDirectLabelsLayout=ed;exports.computeLetterSpacingWidth=ul;exports.computeLineBoxHeight=oa;exports.computePanelBorderPaths=Hp;exports.computePanelBorderSizes=$p;exports.config=b.config;exports.coord=b.coord;exports.countLayerGeoms=Rp;exports.createAlphaValueReader=d.createAlphaValueReader;exports.createAnchorResolver=fu;exports.createAreaPathGenerators=ym;exports.createColorValueReader=d.createColorValueReader;exports.createCompiler=d.createCompiler;exports.createDataLabelPlacementResolver=ea;exports.createDatasetFromKindPartitions=d.createDatasetFromKindPartitions;exports.createEmptyLayerStyles=d.createEmptyLayerStyles;exports.createGroupValueReader=d.createGroupValueReader;exports.createLabelValueReader=d.createLabelValueReader;exports.createLayerYValueFormatter=Mt;exports.createLineFillAreaGenerator=Lm;exports.createLinePathGenerator=Tm;exports.createObservationAnchorBuilder=d.createObservationAnchorBuilder;exports.createObservationAnchorParser=d.createObservationAnchorParser;exports.createPinnedNumberValueFormatter=em;exports.createRawValueReader=d.createRawValueReader;exports.createSegmentYReader=d.createSegmentYReader;exports.createSizeValueReader=d.createSizeValueReader;exports.createSpec=b.createSpec;exports.createSpecBuilder=b.createSpecBuilder;exports.createStableBandKeyGenerator=Wm;exports.createStableCellKeyGenerator=qm;exports.createStableKeyGenerator=Ne;exports.createStablePolarBarKeyGenerator=Xm;exports.createStrokeWidthValueReader=d.createStrokeWidthValueReader;exports.createStyleResolver=Lf;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=fa;exports.filterLayersByGeoms=d.filterLayersByGeoms;exports.findAnnotation=d.findAnnotation;exports.findAverageLineLayer=Ii;exports.findAxisGuide=Gt;exports.findCompanionLayers=d.findCompanionLayers;exports.findDefaultKitStyleTarget=d.findDefaultKitStyleTarget;exports.findDistinctLayers=d.findDistinctLayers;exports.findEquivalentHighlight=_f;exports.findGoalLineLayer=xi;exports.findHighlightsAtObservation=Id;exports.findHostLayer=d.findHostLayer;exports.findKindStyleDeclarations=d.findKindStyleDeclarations;exports.findLayerByGeom=d.findLayerByGeom;exports.findLayerById=d.findLayerById;exports.findLegendForAesthetic=um;exports.findObservationAttachment=bi;exports.findPointerRegion=md;exports.findStyleRule=d.findStyleRule;exports.findStyleRuleIndex=d.findStyleRuleIndex;exports.findTrendLineLayer=Ai;exports.formatDifferenceLabel=ta;exports.formatHeadline=tm;exports.formatLegends=lm;exports.formatRuleValue=dm;exports.geom=l.geom;exports.getAestheticFromScaleAestheticKey=l.getAestheticFromScaleAestheticKey;exports.getAlpha=l.getAlpha;exports.getAngleExtent=l.getAngleExtent;exports.getBarRectBounds=Ma;exports.getBoundingRect=Am;exports.getColor=l.getColor;exports.getCrossAxisCoordinate=d.getCrossAxisCoordinate;exports.getCurve=Ve;exports.getDifferenceArrowDimensions=ra;exports.getDifferenceArrowLabelBox=la;exports.getGroup=d.getGroup;exports.getGroupVariables=l.getGroupVariables;exports.getHoverGuideLineProps=yp;exports.getHoverGuideRectProps=Sp;exports.getInsetTileRect=l.getInsetTileRect;exports.getLineType=l.getLineType;exports.getMainAxisCoordinate=d.getMainAxisCoordinate;exports.getNumericWeight=fr;exports.getPaintedTileRect=l.getPaintedTileRect;exports.getPointSymbolOuterRadius=wm;exports.getPolarHoverGuideArcProps=bp;exports.getRadiusExtent=l.getRadiusExtent;exports.getScaledAesthetic=l.getScaledAesthetic;exports.getShapeAnnotationStroke=Sf;exports.getSize=l.getSize;exports.getStackRole=l.getStackRole;exports.getStrokeWidth=l.getStrokeWidth;exports.getTileRectBounds=l.getTileRectBounds;exports.getUnionExtent=_m;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=Ta;exports.hasMultipleGroups=l.hasMultipleGroups;exports.highlight=b.highlight;exports.inferDefaultDifferenceArrowEndpoints=Ed;exports.inferDifferenceArrowEndpoints=Ia;exports.inferXVariable=l.inferXVariable;exports.isAnnotationMovable=zf;exports.isBorderRadiusToken=l.isBorderRadiusToken;exports.isCartesian=d.isCartesian;exports.isCategoricalValueFormat=l.isCategoricalValueFormat;exports.isComboChartType=de;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=_e;exports.isLayerOf=W;exports.isLayerSpecOf=d.isLayerSpecOf;exports.isLineType=l.isLineType;exports.isLookupValueFormat=l.isLookupValueFormat;exports.isNumericValueFormat=l.isNumericValueFormat;exports.isObservationAttachmentKind=Mf;exports.isOpaquePaint=l.isOpaquePaint;exports.isPatternPaint=l.isPatternPaint;exports.isPointWithinEditMenuTrigger=bd;exports.isPointWithinRegionShape=Nt;exports.isPositionScale=l.isPositionScale;exports.isSafeUrl=Xp;exports.isStackedPosition=l.isStackedPosition;exports.isTemporalValueFormat=l.isTemporalValueFormat;exports.isZeroAnchoredAxis=Rd;exports.mapping=b.mapping;exports.measureObservationsBoxes=Pd;exports.normalizeAngle=l.normalizeAngle;exports.orderPointerRegions=hd;exports.paintKey=l.paintKey;exports.paintsEachGroupFromItsFirstObservation=d.paintsEachGroupFromItsFirstObservation;exports.paintsInDonutHole=Oe;exports.pickFilters=di;exports.pickReadableTextColor=l.pickReadableTextColor;exports.pipe=b.pipe;exports.placeCallouts=Yu;exports.polarToUnit=l.polarToUnit;exports.positionToAngle=l.positionToAngle;exports.prefixInternalVariable=l.prefixInternalVariable;exports.prepareAreaObservations=Sm;exports.prepareLineObservations=Em;exports.projectAnchorToPanel=Ee;exports.projectRegionToPanel=ma;exports.quantizeKey=k;exports.readAnchoredObservation=Od;exports.readAttachedObservation=Jt;exports.readAuthoredNumber=pf;exports.readAuthoredString=ff;exports.readBackdropColor=l.readBackdropColor;exports.readBroadestObservationsScope=xa;exports.readChartType=cg;exports.readColorGroupObservation=jm;exports.readComboLineLayerId=mg;exports.readCompanionRowsAtScopeKey=ad;exports.readConstantValue=l.readConstantValue;exports.readEditTargetKey=bt;exports.readFoldKeepVariables=l.readFoldKeepVariables;exports.readGeomColor=ke;exports.readGeomEffects=Fp;exports.readHighlightDimStyle=Uo;exports.readMainAxis=d.readMainAxis;exports.readMainAxisVariable=l.readMainAxisVariable;exports.readMappableAesthetics=rS;exports.readMappedVariable=io;exports.readObservationIndex=xp;exports.readObservationsColorRoute=La;exports.readPaletteChoices=Gd;exports.readPresentedGroupColor=Km;exports.readPresentedObservationsColor=zd;exports.readReachableLevels=Ud;exports.readRowScopeKey=Sa;exports.readRowsAtScopeKey=Vt;exports.readScopeXVariable=d.readScopeXVariable;exports.readStyleCoord=d.readStyleCoord;exports.readStyleRulesBeneath=d.readStyleRulesBeneath;exports.readVariableName=l.readVariableName;exports.readXExtent=ci;exports.readYExtent=ui;exports.removeAlpha=l.removeAlpha;exports.resolveAnchorVariable=d.resolveAnchorVariable;exports.resolveAnchoredLabelCenter=l.resolveAnchoredLabelCenter;exports.resolveArrowAnnotationStyle=gf;exports.resolveArrowColor=Ju;exports.resolveBarBandFraction=l.resolveBarBandFraction;exports.resolveBarBaseline=Kt;exports.resolveBarBorderTreatment=xm;exports.resolveBarCornerRadiiPx=bm;exports.resolveBarCornerRadiusPx=$t;exports.resolveBarPaintOrigin=Im;exports.resolveCalloutAnnotationStyle=yf;exports.resolveChromeMargin=R;exports.resolveChromeMargins=Af;exports.resolveColorRamp=d.resolveColorRamp;exports.resolveComparisonBasis=d.resolveComparisonBasis;exports.resolveDataLabelStyle=_c;exports.resolveDeferredAnchors=xu;exports.resolveDefinition=l.resolveDefinition;exports.resolveDifferenceArrowAnnotationStyle=vf;exports.resolveDirectLabelStyle=Fc;exports.resolveEditOutlineStyle=If;exports.resolveGeomAnchorSpace=d.resolveGeomAnchorSpace;exports.resolveGraphPadding=xf;exports.resolveHeadlineItemStyle=Bc;exports.resolveHeadlineNumberStyle=Gc;exports.resolveHeadlinePlacement=ou;exports.resolveLegendItemStyle=Nc;exports.resolveObservationPoint=Zd;exports.resolveObservationsTarget=Bt;exports.resolvePanelBorderStyle=bf;exports.resolvePolarBarCornerRadiusUnit=Om;exports.resolveRuleLabelStyle=kc;exports.resolveSegmentYSource=d.resolveSegmentYSource;exports.resolveSwatchGeomPaint=Yt;exports.resolveTooltipStyle=Vc;exports.resolveYScaleAesthetic=l.resolveYScaleAesthetic;exports.sampleColorScheme=d.sampleColorScheme;exports.scale=b.scale;exports.setCompilerCachingEnabled=l.setCompilerCachingEnabled;exports.stat=b.stat;exports.stepDifferenceArrowEndpoint=Jd;exports.style=b.style;exports.styles=b.styles;exports.toDashPreset=_t;exports.toFontSpec=Oc;exports.toPaintColor=l.toPaintColor;exports.toPanelCursor=pa;exports.toPercent=U;exports.toSpec=Ti;exports.toStrokeDasharray=ha;exports.toViewBoxX=vu;exports.toViewBoxY=F;exports.token=l.token;exports.transform=b.transform;exports.truncateToWidth=Nn;exports.unitToPolar=l.unitToPolar;exports.updateSpec=d.updateSpec;exports.withAlpha=l.withAlpha;