@graphysdk/viz-engine 1.9.0-beta.1790338050341 → 1.9.0-beta.1790339754852

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.
@@ -0,0 +1 @@
1
+ const o=require("./annotations-ByWZSWnX.cjs");let se=require("lodash-es"),H=require("d3-time"),Ur=require("date-fns/differenceInDays"),D=require("d3-regression"),w=require("d3-scale"),Y=require("d3-interpolate"),A=require("d3-scale-chromatic"),he=require("lodash-es/clamp");he=o.__toESM(he,1);let ye=require("lodash-es/merge");ye=o.__toESM(ye,1);var E=(e,t)=>{const r=o.readConstantValue(t);if(r!==void 0)return()=>r;const n=o.readVariableName(t);return o.isDefined(n)?a=>{const i=a[n];return i===void 0?null:ht(i,e.getType(n))}:()=>null},Fr=(e,t)=>{const r=o.readConstantValue(t);if(r!==void 0)return()=>r;const n=o.readVariableName(t);if(!o.isDefined(n)||!e.hasVariable(n))return()=>null;const a=e.getValues(n),i=e.getType(n);return s=>{const c=a[s];return c===void 0?null:ht(c,i)}},jr=(e,t)=>E(e,t.x),Gr=(e,t)=>E(e,t.y),Kr=(e,t)=>E(e,t.label),Yr=(e,t)=>E(e,t.color),zr=(e,t)=>E(e,t.size),Wr=(e,t)=>E(e,t.alpha),qr=(e,t)=>E(e,t.group),Hr=(e,t)=>E(e,t.strokeWidth),ht=(e,t)=>{switch(t){case"numeric":return o.isStrictNumericDataValue(e)?e:null;case"categorical":return o.isStrictCategoricalDataValue(e)?e:null;case"temporal":return o.isStrictTemporalDataValue(e)?e:null;default:return null}},He={variable:o.POSITION_VARIABLES.yRaw};function ce(e,t){return o.isStackedPosition(e)?He:t.y??He}function we(e){return E(e.data,ce(e.position,e.mapping))}function Xr(e){return Fr(e.data,ce(e.position,e.mapping))}var le=e=>{const t=o.readVariableName(e.mapping.x);return t!==null&&t!==o.CONSTANT_VARIABLES.x?t:o.GROUP_VARIABLES.group},Le=e=>Jr(e)?o.readVariableName(e.mapping.y):null,yt=e=>Le(e)===null?null:we(e),Ce=e=>e.spatialKind!=="cells",Jr=e=>e.spatialKind==="points"||e.spatialKind==="cells",vt=(e,t)=>e.yScaleType===t.yScaleType&&be(e.valueFormat)===be(t.valueFormat),ve=e=>`${e.yScaleType} y axis, ${be(e.valueFormat)}`,be=e=>e.type==="currency"?`${e.type}:${e.iso}`:e.type,bt=(e,t)=>{const r=o.toExplicitValueFormat(e.data.getValueFormat(le(e))),n=Le(e);return a=>({...a,anchorValue:o.parseAddressingValue(a.anchorValue,r,t),...a.groupValue!==void 0&&{groupValue:o.parseAddressingValue(a.groupValue,o.toExplicitValueFormat(e.data.getValueFormat(o.GROUP_VARIABLES.group)),t)},...a.crossValue!==void 0&&n!==null&&{crossValue:o.parseAddressingValue(a.crossValue,o.toExplicitValueFormat(e.data.getValueFormat(n)),t)}})};function St(e){return e instanceof o.VizError?{severity:"error",kind:e.kind,code:e.code,message:e.message,...e.context!==void 0?{context:e.context}:{},...e.suggestion!==void 0?{suggestion:e.suggestion}:{}}:{severity:"error",kind:"internal",code:"INTERNAL_INVARIANT",message:e instanceof Error?e.message:String(e)}}function Qr(e,t){return At(e,t)}function X(e,t){for(const r of Object.keys(t)){const n=t[r];if(n!==void 0&&n!==e[r])return{...e,...t}}return e}function Zr(e,t,r){if(e[t]===r)return e;const n=[...e];return n[t]=r,n}function _e(e,t){let r=null;for(const[n,a]of e.entries()){const i=t(a,n);if(i===a){r?.push(i);continue}r??=e.slice(0,n),r.push(i)}return r??e}function At(e,t){let r=!1;const n={...e};for(const[a,i]of Object.entries(t)){const s=e[a];if(o.isPlainObject(i)&&o.isPlainObject(s)){const c=At(s,i);c!==s&&(n[a]=c,r=!0)}else i!==void 0&&i!==s&&(n[a]=i,r=!0)}return r?n:e}function ue(e){return{pipe:t=>{const r=t(e);return ue({...e,...r})},result:()=>e}}var en=(e,t)=>{if(!o.isLookupValueFormat(e))return e;const r=t[e.byVariable];return r===void 0?e.fallback:e.cases[o.getStableKey(r)]??e.fallback},Tt=e=>e.type==="polar"?"disk":"panel",It=(e,t)=>{if(e!=="disk")return{x:0,y:0,width:t.width,height:t.height};const r=Math.min(t.width,t.height);return{x:(t.width-r)/2,y:(t.height-r)/2,width:r,height:r}},tn=(e,t)=>{if(e.space!=="disk")return{x:e.x,y:e.y};if(t.width<=0||t.height<=0)return{x:0,y:0};const r=It(e.space,t),n=r.y+(1-e.y)*r.height;return{x:(r.x+e.x*r.width)/t.width,y:1-n/t.height}};function Et(e,t){return e==="x"?t.x:t.y}function Vt(e,t){return e==="x"?t.y:t.x}function rn(e,t){return{main:Et(e,t),cross:Vt(e,t)}}function Se(e,t){return e==="x"?{x:t.main,y:t.cross}:{x:t.cross,y:t.main}}function xt(e){return e.type==="cartesian"?e.mainAxis:"x"}function nn(e){return e.type==="cartesian"}var Z=e=>e[o.GROUP_VARIABLES.group],Ot=e=>{const t=le(e),r=yt(e),n=Ce(e)&&t!==o.GROUP_VARIABLES.group;return a=>{const i=a[t]??null;if(i===null)return null;const s=r===null?null:r(a);if(r!==null&&s===null)return null;const c=n?Z(a)??null:null;return{layerId:e.id,anchorValue:i,...s!==null&&{crossValue:s},...c!==null&&{groupValue:c}}}},an={type:"decimal"};function wt(e){return e.length>0&&e.every(t=>t.data.size()===0)}function Pe(e,t){return t!==null&&e.data.hasVariable(t)?e.data.getValueFormat(t):an}function on(e){return Pe(e,o.readVariableName(e.mapping.y))}function Lt({geom:e,position:t,mapping:r,purpose:n}){return e.resolveValueSource?.(r,n)??ce(t,r)}function Ct(e,t){const r=Lt({geom:t,position:e.position,mapping:e.mapping,purpose:"measurement"}),n=o.readVariableName(r),a=n===o.POSITION_VARIABLES.yRaw?o.readVariableName(e.mapping.y):n;return{read:E(e.data,r),valueFormat:Pe(e,a)}}var _t=e=>{const t=le(e),r=yt(e),n=Ce(e);return(a,i)=>!o.areDataValuesEqual(a[t]??null,i.anchorValue)||!(r===null||i.crossValue===void 0||o.areDataValuesEqual(r(a),i.crossValue))?!1:!n||i.groupValue===void 0?!0:o.areDataValuesEqual(Z(a),i.groupValue)},Pt=e=>{const t=o.readVariableName(e.mapping.y),r=we(e);return(n,a)=>t!==null&&a===t?r(n):n[a]??null},sn=e=>t=>{if(t===o.readVariableName(e.mapping.y))return Xr(e);const r=e.data.hasVariable(t)?e.data.getValues(t):null;return n=>r?.[n]??null};var cn=["lt","lte","gt","gte","range"],ln={highlight:{subject:"Highlight predicate",effect:"dropping this highlight"},"selection-anchor":{subject:"Selection anchor predicate",effect:"dropping this annotation"},"style-rule":{subject:"Style rule predicate",effect:"dropping this rule"}},_=()=>!1,F=()=>!0;function de(e,t){const r=Pt(e);return{...Dt(e,t),createValueReader:n=>a=>r(a,n)}}function un(e,t){return{...Dt(e,t),createValueReader:sn(e)}}function N(e,t){if("and"in e){const r=e.and.map(n=>N(n,t)).filter(n=>n!==F);return r.includes(_)?_:r.length===0?F:n=>{for(const a of r)if(!a(n))return!1;return!0}}if("or"in e){const r=e.or.map(n=>N(n,t)).filter(n=>n!==_);return r.includes(F)?F:r.length===0?_:n=>{for(const a of r)if(a(n))return!0;return!1}}if("not"in e){const r=N(e.not,t);return r===_?F:r===F?_:n=>!r(n)}return mn(e,t)}function R(e,t,r="highlight"){return"and"in e?e.and.flatMap(n=>R(n,t,r)):"or"in e?e.or.flatMap(n=>R(n,t,r)):"not"in e?R(e.not,t,r):dn(e,t,r)}function Dt(e,t){return{hasVariable:r=>e.data.hasVariable(r),getType:r=>e.data.getType(r),getValueFormat:r=>e.data.getValueFormat(r),parsingLocale:t}}function dn(e,t,r){const{subject:n,effect:a}=ln[r];if(!t.hasVariable(e.variable))return[{code:"UNKNOWN_VARIABLE",message:`${n} references unknown variable '${e.variable}' — ${a}.`,context:{variableName:e.variable},suggestion:`Map '${e.variable}' in the layer or correct the variable name in the predicate.`}];const i=pn(e);return i!==null&&t.getType(e.variable)==="categorical"?[{code:"INVALID_PREDICATE_OPERATOR",message:`${n} uses ordering operator '${i}' on categorical variable '${e.variable}' — ${a}. Use 'eq' or 'oneOf' instead.`,context:{variableName:e.variable},suggestion:"Use 'eq' or 'oneOf' for categorical variables."}]:[]}function mn(e,t){if(!t.hasVariable(e.variable))return _;const r=t.createValueReader(e.variable),n=o.toExplicitValueFormat(t.getValueFormat(e.variable)),a=i=>o.parseAddressingValue(i,n,t.parsingLocale);if("eq"in e){const i=a(e.eq);return s=>o.areDataValuesEqual(r(s),i)}if("oneOf"in e){const i=e.oneOf.map(a);if(i.length>=32){const s=new Set,c=new Set;for(const l of i)o.isStrictTemporalDataValue(l)?c.add(l.getTime()):s.add(l);return l=>{const u=r(l);return o.isStrictTemporalDataValue(u)?c.has(u.getTime()):!Number.isNaN(u)&&s.has(u)}}return s=>{const c=r(s);for(const l of i)if(o.areDataValuesEqual(c,l))return!0;return!1}}if("lt"in e){const i=a(e.lt);return s=>j(r(s),i)==="less"}if("lte"in e){const i=a(e.lte);return s=>{const c=j(r(s),i);return c==="less"||c==="equal"}}if("gt"in e){const i=a(e.gt);return s=>j(r(s),i)==="greater"}if("gte"in e){const i=a(e.gte);return s=>{const c=j(r(s),i);return c==="greater"||c==="equal"}}if("range"in e){const[i,s]=e.range,c=a(i),l=a(s);return u=>{const d=r(u),m=j(d,c),p=j(d,l);return m==="incomparable"||p==="incomparable"?!1:(m==="greater"||m==="equal")&&(p==="less"||p==="equal")}}return _}function pn(e){for(const t of cn)if(t in e)return t;return null}function j(e,t){if(e===null||t===null)return"incomparable";if(o.isStrictTemporalDataValue(e)&&o.isStrictTemporalDataValue(t)){const r=e.getTime(),n=t.getTime();return r<n?"less":r>n?"greater":"equal"}return o.isStrictNumericDataValue(e)&&o.isStrictNumericDataValue(t)?e<t?"less":e>t?"greater":"equal":"incomparable"}var fn=(e,t,r,n,a,i,s)=>{const c=Rt(e,t,r.predicate,n,a,i,s);if(c===null)return null;const l=Nt(r.padding),u=l===null?yn(c,r.padding):c,d={x:u.xMin,y:u.yMin,width:Math.max(0,u.xMax-u.xMin),height:Math.max(0,u.yMax-u.yMin),space:u.space};return l===null?d:{...d,defer:l}},gn=(e,t,r,n,a,i,s)=>{const c=Rt(e,t,r.predicate,n,a,i,s);return c===null?null:{...o.alignToBoxPoint(c,r.align),space:c.space}},Nt=e=>e===void 0||typeof e=="number"||e.unit!=="px"?null:{type:"px-offset",x:e.x??0,y:e.y??0},Rt=(e,t,r,n,a,i,s)=>{if(t.has(r))return t.get(r)??null;let c=null,l=!1;const u=new Map;for(const d of n){if(!d.interactive)continue;const m=R(r,d.data,"selection-anchor");if(m.length>0){for(const g of m)u.set(`${g.code}:${g.message}`,g);continue}l=!0;const p=N(r,de(d,i));if(p!==_)for(const g of d.data){if(!p(g))continue;const f=o.readObservationBox(g,a);f!==null&&(c=c===null?f:hn(c,f))}}if(!l)for(const d of u.values())s?s.push(d):e.diagnostics.addWarning(d);return t.set(r,c),c},hn=(e,t)=>({space:e.space,xMin:Math.min(e.xMin,t.xMin),xMax:Math.max(e.xMax,t.xMax),yMin:Math.min(e.yMin,t.yMin),yMax:Math.max(e.yMax,t.yMax)}),yn=(e,t)=>{if(t===void 0)return e;const{x:r=0,y:n=0}=typeof t=="number"?{x:t,y:t}:t;return{...e,xMin:e.xMin-r,xMax:e.xMax+r,yMin:e.yMin-n,yMax:e.yMax+n}},ie=(e,t,r)=>{const n=bn(e,t,r);return n===null?null:n.defer?.type==="annotation-ref"?n:Sn(n,t.offset,e.coordSystem)},Mt=(e,t)=>t.anchorType==="selection"?fn(e.container,e.selectionBoxCache,t,e.layers,e.coordSystem,e.parsingLocale,e.warnings):t.anchorType==="annotation"?{x:0,y:0,width:0,height:0,defer:{type:"annotation-ref",ref:t.ref,align:"center"}}:{x:t.x,y:1-t.y-t.height,width:t.width,height:t.height},De=(e,t,r)=>Ae(e,t,r)?.point??null,Ae=({container:e,layers:t,coordSystem:r,parsingLocale:n},a,i)=>{for(const s of t){const c=e.geomRegistry.get(s.geom),{resolveAnchorPosition:l}=c;if(l===void 0||a.layerId!==void 0&&s.id!==a.layerId||a.layerId===void 0&&!s.interactive)continue;const u=Ct(s,c),d=_t(s),m=Ot(s),p=bt(s,n)(a);let g=-1;for(const f of s.data){if(g+=1,!d(f,p))continue;const v=l(f,{coordSystem:r,position:s.position,purpose:i,align:a.align});if(v===null)continue;const y=kt(s,f,u);if(y===null)continue;const h=m(f);if(h!==null)return{point:{...v,...y,space:Tt(r),observationIndex:g,anchor:a.align===void 0?h:{...h,align:a.align}},layerId:s.id}}}return null},vn=(e,t)=>{const{layers:r,coordSystem:n,scales:a,parsingLocale:i}=e;if(n.type!=="cartesian")return null;const s=a.x,c=a.y;if(s===void 0||c===void 0||s.kind!=="position"||c.kind!=="position")return null;const l=Je(t.x,"x",r,i),u=Je(t.y,"y",r,i);if(l===null||u===null)return null;const d=s.map(l),m=c.map(u);if(!o.isPointWithinPanel(d,m))return null;const p=Xe(d,s,An(e)),g=Xe(m,c),f=Se(n.mainAxis,{main:p.min,cross:g.min}),v=Se(n.mainAxis,{main:p.max,cross:g.max});return o.alignToBoxPoint({xMin:f.x,xMax:v.x,yMin:f.y,yMax:v.y},t.align??"center")},kt=(e,t,r)=>{const n=r.read(t);return o.isStrictNumericDataValue(n)?{geom:e.geom,measurementValue:n,valueFormat:en(r.valueFormat,t),yScaleType:e.yScaleType}:null},bn=(e,t,r)=>{switch(t.anchorType){case"panel":return{x:t.x,y:1-t.y};case"axis":return vn(e,t);case"selection":return gn(e.container,e.selectionBoxCache,t,e.layers,e.coordSystem,e.parsingLocale,e.warnings);case"annotation":return{x:0,y:0,defer:{type:"annotation-ref",ref:t.ref,align:t.align??"center",offset:t.offset}};case"observation":return De(e,Tn(t),r)}},Sn=(e,t,r)=>{if(t===void 0||r.type==="polar")return e;const n=Nt(t);return n!==null?{...e,defer:n}:{...e,x:e.x+(t.x??0),y:e.y-(t.y??0)}},Xe=(e,t,r=1)=>{const{bandwidth:n}=t;if(n===null||n<=0)return{min:e,max:e};const a=n*r/2;return{min:e-a,max:e+a}},An=({container:e,layers:t,coordSystem:r})=>{let n=0;for(const a of t){const i=e.geomRegistry.get(a.geom).resolveBandFraction?.(a.params,r);i!==void 0&&(n=Math.max(n,i))}return n>0?n:1},Tn=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),Je=(e,t,r,n)=>{for(const a of r){const i=o.readVariableName(a.mapping[t]);if(!(i===null||i===o.CONSTANT_VARIABLES.x))return o.parseAddressingValue(e,o.toExplicitValueFormat(a.data.getValueFormat(i)),n)}return e},In=class extends o.Stage{constructor(e){super(),this.container=e,this.warningsByOutput=new WeakMap}compile(e){const t=super.compile(e);for(const r of this.warningsByOutput.get(t)??[])this.container.diagnostics.addWarning(r);return t}dependencies(e){return[e.annotations,e.layers,e.coordSystem,e.scales.x,e.scales.y,e.config.parsingLocale]}run(e){const{annotations:t,layers:r,coordSystem:n,scales:a,config:i}=e,s=[],c={container:this.container,warnings:s,layers:r,coordSystem:n,scales:a,selectionBoxCache:new Map,parsingLocale:i.parsingLocale},l={differenceArrows:Nn(c,t.differenceArrows),shapes:On(c,t.shapes),arrows:Ln(c,t.arrows),textAnnotations:Cn(c,t.textAnnotations),images:wn(c,t.images),stickers:_n(c,t.stickers),pinnedNumbers:Pn(c,t.pinnedNumbers),comments:Dn(c,t.comments)};return En(s,l),Vn(s,l),this.warningsByOutput.set(l,s),l}},L=(e,t,r,n)=>{e.push({code:"ANNOTATION_ANCHOR_UNRESOLVED",message:`Annotation "${r}" (${t}) ${n} — dropping this annotation.`,context:{annotationId:r,kind:t},suggestion:"Check that the anchor points at data, an axis value or a panel position that exists."})},En=(e,t)=>{const r=new Set;for(const n of Object.values(t))for(const{id:a}of n){if(r.has(a)){e.push({code:"ANNOTATION_DUPLICATE_ID",message:`More than one annotation carries id "${a}" — references to it resolve to the first, and the rest cannot be addressed.`,context:{annotationId:a},suggestion:"Give each annotation its own id."});continue}r.add(a)}},Vn=(e,t)=>{const r=new Set;for(const n of Object.values(t))for(const a of n)r.add(a.id);for(const{id:n,ref:a}of xn(t))r.has(a)||e.push({code:"ANNOTATION_REF_NOT_FOUND",message:`Annotation "${n}" references id "${a}", whose annotation could not be anchored and was dropped.`,context:{annotationId:n,ref:a},suggestion:"Fix the anchor on the target annotation or point this reference at one that resolves."})},xn=e=>{const t=[],r=(n,a)=>{a.defer?.type==="annotation-ref"&&t.push({id:n,ref:a.defer.ref})};for(const n of e.shapes)r(n.id,n.region);for(const n of e.images)r(n.id,n.region);for(const n of e.arrows)r(n.id,n.start),r(n.id,n.end);for(const n of e.textAnnotations)r(n.id,n.at);for(const n of e.stickers)r(n.id,n.at);return t},On=(e,t)=>{const r=[];for(const n of t){const a=Mt(e,n.region);if(a===null){L(e.warnings,"shape",n.id,"has a region anchor that resolves to nothing");continue}r.push({id:n.id,kind:n.kind,zOrder:n.zOrder,region:a})}return r},wn=(e,t)=>{const r=[];for(const n of t){const a=Mt(e,n.region);if(a===null){L(e.warnings,"image",n.id,"has a region anchor that resolves to nothing");continue}r.push({id:n.id,src:n.src,zOrder:n.zOrder,region:a,fit:n.fit})}return r},Ln=(e,t)=>{const r=[];for(const n of t){const a=ie(e,n.start,"pin"),i=ie(e,n.end,"pin");if(a===null||i===null){L(e.warnings,"arrow",n.id,`has ${Bt(a,i)} resolving to nothing`);continue}r.push({id:n.id,start:a,end:i,startArrowheadStyle:n.startArrowheadStyle,endArrowheadStyle:n.endArrowheadStyle})}return r},Cn=(e,t)=>{const r=[];for(const n of t){const a=ie(e,n.at,"pin");if(a===null){L(e.warnings,"text",n.id,"has a point anchor that resolves to nothing");continue}r.push({id:n.id,content:n.content,at:a,width:n.width,align:n.align})}return r},_n=(e,t)=>{const r=[];for(const n of t){const a=ie(e,n.at,"pin");if(a===null){L(e.warnings,"sticker",n.id,"has a point anchor that resolves to nothing");continue}r.push({id:n.id,at:a,sticker:n.sticker})}return r},Pn=(e,t)=>{const r=[];for(const n of t){const a=De(e,n.at,"pin");if(a===null){L(e.warnings,"pinnedNumber",n.id,"matches no observation");continue}r.push({id:n.id,at:a})}return r},Dn=(e,t)=>{const r=[];for(const n of t){const a=De(e,n.at,"pin");if(a===null){L(e.warnings,"comment",n.id,"matches no observation");continue}r.push({id:n.id,at:a,content:n.content})}return r},Nn=(e,t)=>{if(e.coordSystem.type!=="cartesian"){for(const n of t)L(e.warnings,"differenceArrow",n.id,"needs a cartesian coord system");return[]}const r=[];for(const n of t){const a=Ae(e,n.start,"value"),i=Ae(e,n.end,"value");if(a===null||i===null){L(e.warnings,"differenceArrow",n.id,`has ${Bt(a,i)} matching no observation`);continue}if(a.layerId===i.layerId&&a.point.observationIndex===i.point.observationIndex){L(e.warnings,"differenceArrow",n.id,"has both ends on the same observation");continue}Rn(e,n,a.point,i.point),r.push({id:n.id,start:a.point,end:i.point,label:n.label,labelCrossPosition:n.labelCrossPosition})}return r},Bt=(e,t)=>e===null&&t===null?"start and end anchors":e===null?"a start anchor":"an end anchor",Rn=(e,t,r,n)=>{vt(r,n)||e.warnings.push({code:"INCOMPARABLE_ARROW_ENDPOINTS",message:`Difference arrow "${t.id}" measures between endpoints on different bases, so its label reports a quantity that does not exist.`,context:{annotationId:t.id,expected:ve(r),actual:ve(n)},suggestion:"Point both ends at observations sharing one y scale and one unit, or label the arrow as a proportion."})};function Mn(e,t="kind"){const r=new Map;r.set(t,[]);for(const a of e)for(const i of a.observations)for(const s of Object.keys(i))r.has(s)||r.set(s,[]);for(const a of e)for(const i of a.observations)for(const[s,c]of r)c.push(s===t?a.kind:i[s]??null);const n={};for(const[a,i]of r)n[a]={type:$t(i),values:i};return new o.Dataset(n)}function $t(e){const t=Array.isArray(e)?e:[e];for(const r of t)if(r!==null)return typeof r=="number"?"numeric":r instanceof Date?"temporal":"categorical";return"categorical"}var kn=class extends o.Stage{dependencies(e){return[e.data,e.mapping]}run(e){let t=e.data,r=e.mapping;r.x===""&&(t=t.addConstantVariable(o.CONSTANT_VARIABLES.x,"categorical",""),r={...r,x:o.CONSTANT_VARIABLES.x});for(const n of Object.keys(r)){const a=o.readConstantValue(r[n]);if(a===void 0)continue;const i=o.prefixInternalVariable(`const_${n}`);t=t.addConstantVariable(i,$t(a),a),r={...r,[n]:i}}return{data:t,mapping:r}}},B=class{constructor(){this.perLayerMemo=o.createPerKeyMemo(),this.listMemo=o.createSingleSlotMemo()}get stats(){return o.sumMemoStats(this.perLayerMemo.stats,this.listMemo.stats)}compile(e){const t=this.dependencies(e),r=e.layers.map(n=>this.perLayerMemo(n,t,()=>this.compileLayer(n,e)));return this.listMemo(r,()=>r)}},Bn=class extends o.Stage{constructor(e){super(),this.registry=e}dependencies(e){return[e.coordSpec,e.scales,e.layers]}run(e){return this.registry.get(e.coordSpec.coordType).setup(e)}},$n=class extends B{constructor(e){super(),this.registry=e}dependencies(e){return[e.coordSpec,e.coordSystem]}compileLayer(e,t){const[r]=this.registry.get(t.coordSpec.coordType).transform({coordSpec:t.coordSpec,coordSystem:t.coordSystem,layers:[e]});if(!r)throw new o.InternalError({message:`CoordCompiler: strategy '${t.coordSpec.coordType}' did not return a transformed layer`});return r}},Un=class{constructor(e){this.setupStage=new Bn(e),this.transformStage=new $n(e)}get setupStats(){return this.setupStage.stats}get transformStats(){return this.transformStage.stats}setup(e){return this.setupStage.compile(e)}transform(e){return this.transformStage.compile(e)}},Fn=class{constructor(){this.coordType="cartesian"}setup(e){if(e.coordSpec.coordType!=="cartesian")throw new o.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});return{coordSystem:{type:"cartesian",mainAxis:"x",axisMapping:{x:{position:"bottom",geometry:"linear"},y:{position:"right",geometry:"linear"}}},scales:e.scales}}transform(e){return e.layers}},jn=class{constructor(){this.coordType="flip"}setup(e){if(e.coordSpec.coordType!=="flip")throw new o.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});return{coordSystem:{type:"cartesian",mainAxis:"y",axisMapping:{x:{position:"left",geometry:"linear"},y:{position:"bottom",geometry:"linear"}}},scales:Kn(e.scales,e.layers)}}transform(e){return e.layers.map(t=>zn(t))}},Gn=[[o.POSITION_VARIABLES.x,o.POSITION_VARIABLES.y],[o.POSITION_VARIABLES.xMin,o.POSITION_VARIABLES.yMin],[o.POSITION_VARIABLES.xMax,o.POSITION_VARIABLES.yMax]],Qe=o.prefixInternalVariable("flipSwap"),Kn=(e,t)=>Yn(t)?e.map(r=>r.scaledAesthetic!=="x"||r.scaleType!=="continuous"&&r.scaleType!=="datetime"&&r.scaleType!=="discrete"?r:{...r,reverse:!r.reverse}):e,Yn=e=>{for(const t of e){const r=o.readVariableName(t.mapping.x);if(!r||!t.data.hasVariable(r))continue;const n=t.data.getType(r);if(n==="categorical"||n==="temporal")return!0}return!1},zn=e=>{let t=e.data;for(const[r,n]of Gn){const a=t.hasVariable(r),i=t.hasVariable(n);a&&i?t=t.renameVariable(r,Qe).renameVariable(n,r).renameVariable(Qe,n):a?t=t.renameVariable(r,n):i&&(t=t.renameVariable(n,r))}return{...e,data:t}};function Ut(e){const t=new Set,r=[];for(const n of e){const a=n instanceof Date?n.getTime():String(n);t.has(a)||(t.add(a),r.push(n))}return r}var Ft=(e,t)=>Ut(t.domain!==null&&t.domain.length>0?t.domain:e),Wn=e=>{const t=e.length-1,r=e[t];if(r===void 0||t<1)return null;const n=[];for(let i=1;i<=t;i+=1){const s=e[i-1],c=e[i];s===void 0||c===void 0||n.push(c-s)}n.sort((i,s)=>i-s);const a=n[n.length-1>>1];return a===void 0?null:r+a},qn=e=>[...new Set(e)].sort((t,r)=>t-r),Hn=class{constructor(){this.coordType="polar"}setup(e){if(e.coordSpec.coordType!=="polar")throw new o.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});const{params:t}=e.coordSpec,r=t.startAngle*(Math.PI/180),n=ea(t,e.scales,e.layers),a=ra(t,e.scales,e.layers);return{coordSystem:{type:"polar",axisMapping:t.theta==="x"?{x:{position:"bottom",geometry:"circular"},y:{position:"left",geometry:"radial"}}:{x:{position:"left",geometry:"radial"},y:{position:"bottom",geometry:"circular"}},innerRadius:t.innerRadius,startAngle:r,spokeRotation:n,bandAxis:a},scales:Qn(t,e.scales,e.layers)}}transform(e){if(e.coordSpec.coordType!=="polar")throw new o.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});if(e.coordSystem.type!=="polar")throw new o.InternalError({message:"PolarCoord.transform received a non-polar coord system"});const{params:t}=e.coordSpec,{startAngle:r,spokeRotation:n}=e.coordSystem,a=Jn(r,n),i=na(t);return e.layers.map(s=>aa(t.theta==="y"?ia(s):s,a,i))}},Xn=[[o.POSITION_VARIABLES.x,o.POSITION_VARIABLES.y],[o.POSITION_VARIABLES.xMin,o.POSITION_VARIABLES.yMin],[o.POSITION_VARIABLES.xMax,o.POSITION_VARIABLES.yMax]];function Jn(e,t){return r=>o.positionToAngle(r,e,t)}function Qn(e,t,r){return e.theta!=="x"?t:t.map(n=>{if(n.scaledAesthetic!=="x"||n.scaleType!=="continuous"&&n.scaleType!=="datetime"||n.scaleType==="continuous"&&n.transform!=="linear"||n.domainMax!==null)return n;const a=Zn(e,r),i=Wn(a),s=a[0];return i===null||s===void 0?n:{...n,domainMin:n.domainMin??s,domainMax:i}})}function Zn(e,t){const r=[];for(const n of t){const a=o.readVariableName(n.mapping[e.theta]);if(!(a===null||!n.data.hasVariable(a)))for(const i of n.data.getValues(a))i instanceof Date?r.push(i.getTime()):typeof i=="number"&&r.push(i)}return qn(r)}function ea(e,t,r){const n=t.find(i=>i.scaledAesthetic===e.theta);if(n===void 0||n.scaleType!=="discrete")return 0;const a=ta(n,e,r);return a===0?0:-Math.PI/a}function ta(e,t,r){const n=[];for(const a of r){const i=o.readVariableName(a.mapping[t.theta]);if(!(i===null||!a.data.hasVariable(i)))for(const s of a.data.getValues(i))n.push(s)}return Ft(n,e).length}function ra(e,t,r){if(e.theta==="x")return"x";const n=t.find(i=>i.scaledAesthetic==="x")?.scaleType==="discrete",a=r.some(i=>i.position==="fill");return n&&!a?"y":null}function na(e){const{innerRadius:t}=e;return r=>t+r*(1-t)}function aa(e,t,r){let n=e.data;return n=G(n,o.POSITION_VARIABLES.x,t),n=G(n,o.POSITION_VARIABLES.xMin,t),n=G(n,o.POSITION_VARIABLES.xMax,t),n=G(n,o.POSITION_VARIABLES.y,r),n=G(n,o.POSITION_VARIABLES.yMin,r),n=G(n,o.POSITION_VARIABLES.yMax,r),{...e,data:n}}function G(e,t,r){if(!e.hasVariable(t))return e;const n=e.getValues(t,{type:"numeric"}).map(a=>a===null?null:r(a));return e.addVariable(t,"numeric",n)}function ia(e){let t=e.data;for(const[r,n]of Xn){const a=t.hasVariable(r),i=t.hasVariable(n);if(!a&&!i)continue;const s=a?t.getValues(r):null,c=i?t.getValues(n):null;s&&(t=t.addVariable(n,"numeric",s)),c&&(t=t.addVariable(r,"numeric",c))}return{...e,data:t}}var oa=class extends o.Registry{constructor(){super("coord"),this.register("cartesian",new Fn),this.register("flip",new jn),this.register("polar",new Hn)}},jt=new Set(["min","max","scalar"]),sa={x:{min:o.POSITION_VARIABLES.xMin,max:o.POSITION_VARIABLES.xMax},y:{min:o.POSITION_VARIABLES.yMin,max:o.POSITION_VARIABLES.yMax}};function ca(e){const t=new Set;for(const r of e)r.role==="point"?t.add(r.axis):(r.role==="min"||r.role==="max")&&o.isDefined(r.aes)&&t.add(r.aes);return[...t]}function la(e){const t=new Set;for(const r of e)r.role==="point"&&t.add(r.axis),o.isDefined(r.aes)&&t.add(r.aes);return[...t]}function ua(e,t,r){let n=e;for(const a of t){if(a.role!=="min"&&a.role!=="max"||!o.isDefined(a.aes))continue;const i=sa[a.axis][a.role];if(n.hasVariable(i))continue;const s=o.readVariableName(r[a.aes]);!o.isDefined(s)||!n.hasVariable(s)||(n=n.addVariable(i,"numeric",n.getValues(s,{type:"numeric"})))}return n}var da=class{constructor(e){this.container=e}compile(e,t){const r=this.container.geomRegistry.get(e),n=r.compile(t),a={...t.mapping,...n.mapping};return{...n,data:ua(n.data,r.positionRoles,a)}}},ma=class{compute({data:e,mapping:t}){const r=o.getGroupVariables(e,t);if(r.length===0)return{data:e.addConstantVariable(o.GROUP_VARIABLES.group,"categorical",null)};const n=e.size(),a=r.map(s=>e.getValues(s)),i=new Array(n);for(let s=0;s<n;s++)i[s]=o.getStableKey(a.map(c=>c[s]));return{data:e.addVariable(o.GROUP_VARIABLES.group,"categorical",i)}}},pa=e=>{if(e===void 0)return{};const t={};for(const r of e.columns)r.label!==void 0&&(t[r.key]=r.label);return t},fa=(e,t,r)=>{const n=M(t,"color");return n===null?{}:(e?.columns??[]).some(a=>a.key===n)?{}:r};function M(e,t){const r=o.getAestheticFromScaleAestheticKey(t);for(const n of Gt(t,e)){const a=o.readVariableName(n.mapping[r]);if(o.isDefined(a))return a}return null}var Ne=(e,t)=>e===null?null:t[e]??e,ga=(e,t)=>e===null?null:t[String(e)]??null,k=({layers:e,scaleType:t,variableName:r})=>{if(r===null)return ge(t);for(const n of e){if(!n.data.hasVariable(r))continue;const a=n.data.getValueFormat(r),i=a.type==="lookup"?a.fallback:a;return ya(i,t)?i:ge(t)}return ge(t)},ha=(e,t)=>t!=="y"&&t!=="ySecondary"?!1:Gt(t,e).some(r=>r.position==="fill");function Gt(e,t){return e==="ySecondary"?t.filter(r=>r.yScaleType==="secondary"):e==="y"?t.filter(r=>r.yScaleType==="primary"):t}var ge=e=>{switch(e){case"continuous":return{type:"decimal"};case"datetime":return{type:"date"};case"discrete":case"palette":case"identity":return{type:"text"}}},ya=(e,t)=>{switch(t){case"continuous":return o.isNumericValueFormat(e);case"datetime":return o.isTemporalValueFormat(e);case"discrete":case"palette":case"identity":return!0}},va=[{unit:"year",step:1e3},{unit:"year",step:100},{unit:"year",step:50},{unit:"year",step:20},{unit:"year",step:10},{unit:"year",step:5},{unit:"year",step:2},{unit:"year",step:1},{unit:"month",step:6},{unit:"month",step:3},{unit:"month",step:2},{unit:"month",step:1},{unit:"week",step:2},{unit:"week",step:1},{unit:"day",step:2},{unit:"day",step:1},{unit:"hour",step:12},{unit:"hour",step:6},{unit:"hour",step:3}],Ze={year:0,quarter:1,month:2,week:3,day:4,hour:5},K=40,ba=(e,t,r)=>{const n=r.unit==="quarter"?r.step*3:r.step;return Ia(r.unit).range(e,new Date(t.valueOf()+1),n)},Sa=({unit:e,step:t,start:r,stop:n})=>{const a=(0,Ur.differenceInDays)(n,r);switch(e){case"hour":return 24*a/t>K;case"day":return a/t>K;case"week":return a/(7*t)>K;case"month":return a/(30*t)>K;case"quarter":return a/(90*t)>K;case"year":return a/(365*t)>K}},Aa=(e,t)=>{const r=!o.isDateWithoutYearValueFormat(t);switch(e.unit){case"year":return r?{type:"year"}:{type:"month"};case"quarter":return{type:"quarter"};case"month":return r?{type:"month_year"}:{type:"month"};case"week":return r?{type:"weekly_date_range_with_year"}:{type:"weekly_date_range"};case"day":return r?{type:"date"}:{type:"day_month"};case"hour":return r?{type:"datetime"}:{type:"time"}}},Ta=(e,t)=>{const r=Ea(t);return r===null?!1:Ze[e]>Ze[r]},Ia=e=>{switch(e){case"hour":return H.utcHour;case"day":return H.utcDay;case"week":return H.utcMonday;case"month":case"quarter":return H.utcMonth;case"year":return H.utcYear}},Ea=e=>{switch(e.type){case"year":return"year";case"quarter":return"quarter";case"month_year":case"month":return"month";case"weekly_date_range":case"weekly_date_range_with_year":return"week";case"date":case"day_month":case"datetime":return"day";case"time":return"hour";default:return null}},Kt={left:"right",right:"left",top:"bottom",bottom:"top"},Va={x:!0,y:!0,ySecondary:!1},xa=20,et=new Set(["top","bottom"]),Oa={type:"percentage"};function wa(e,t){const{scales:r,config:n,layers:a,coordSystem:i,variableLabels:s,geomRegistry:c}=e;if(wt(a))return[];if(i.type==="polar"&&i.bandAxis===null)return[];const l=_a(c,a,i.type,n),u=new Set(t.map(p=>p.position)),d=Da(Yt(n.axes.y.position,i.axisMapping.y.position),u),m=[];for(const p of o.SCALED_POSITION_AESTHETIC_KEYS){const g=r[p];if(!o.isDefined(g)||g.kind!=="position")continue;const f=La({scaleAestheticKey:p,scale:g,config:n,layers:a,axisMapping:i.axisMapping,resolvedYPosition:d,gridOverrides:l,variableLabels:s});m.push(f)}return m}function La(e){const{scaleAestheticKey:t,scale:r,config:n,layers:a,axisMapping:i,resolvedYPosition:s,gridOverrides:c,variableLabels:l}=e,{axisConfig:u,position:d,geometry:m}=Pa(t,n,i,s),p=M(a,t),g=ha(a,t)?Oa:k({layers:a,scaleType:r.spec.scaleType,variableName:p});return{scaleAestheticKey:t,position:d,geometry:m,label:Ca(u,p,l),isVisible:u.isVisible,tickCandidates:Ra(r,g,u.ticks.mode),valueFormat:g,tickMode:u.ticks.mode,ticksVisible:u.ticks.isVisible,gridVisible:Na(u,c,t),scaleType:r.spec.scaleType,bandwidth:r.bandwidth??void 0}}function Ca(e,t,r){return e.label?e.label:t?r[t]??null:null}function _a(e,t,r,n){const a=t.flatMap(c=>{const l=e.get(c.geom).grid[r];return l?[l]:[]}),i=a.some(c=>c.hideGridX),s=a.some(c=>c.hideGridY);return{x:{gridVisible:tt(i,n.axes.x.grid.isVisible)},y:{gridVisible:tt(s,n.axes.y.grid.isVisible)}}}function tt(e,t){if(e&&t===null)return!1}function Pa(e,t,r,n){switch(e){case"x":return{axisConfig:t.axes[e],position:Yt(t.axes[e].position,r[e].position),geometry:r.x.geometry};case"y":return{axisConfig:t.axes[e],position:n,geometry:r.y.geometry};case"ySecondary":{const a=Kt[n],i=(0,se.merge)({isVisible:t.axes.y.isVisible,label:null,position:a,grid:t.axes.y.grid,ticks:t.axes.y.ticks},t.axes.ySecondary);return{axisConfig:i,position:i.position,geometry:r.y.geometry}}}}function Yt(e,t){return et.has(e)===et.has(t)?e:t}function Da(e,t){return t.has(e)?Kt[e]:e}function Na(e,t,r){const{gridVisible:n}=r==="x"?t.x:t.y;return n??e.grid.isVisible??Va[r]}var Ra=(e,t,r)=>{const n=e.spec.scaleType==="continuous"||e.spec.scaleType==="datetime";if(r==="edges"&&n){const a=ka(e);if(a)return[a]}if(e.spec.scaleType==="continuous"){const a=new Set,i=[];for(let s=1;s<=xa;s++){const c=e.generateTicks({count:s}),l=o.getStableKey(c);a.has(l)||(a.add(l),i.push({ticks:c.map(u=>z(e,u))}))}return i}return e.spec.scaleType==="datetime"?Ma(e,t):[{ticks:e.generateTicks().map(a=>z(e,a))}]},Ma=(e,t)=>{const[r,n]=e.domain;if(!o.isStrictTemporalDataValue(r)||!o.isStrictTemporalDataValue(n))return[{ticks:e.generateTicks().map(c=>z(e,c))}];const a=new Set,i=[],s=(c,l)=>{if(c.length===0)return;const u=o.getStableKey(c);a.has(u)||(a.add(u),i.push({ticks:c.map(d=>z(e,d)),valueFormat:l}))};for(const c of va)Sa({...c,start:r,stop:n})||Ta(c.unit,t)||s(e.generateTicks({interval:c}),Aa(c,t));return s(e.generateTicks({atInputs:!0})),i.sort((c,l)=>c.ticks.length-l.ticks.length),i},ka=e=>{const{domain:t}=e,r=t[0],n=t.at(-1);return!o.isDefined(r)||!o.isDefined(n)||o.getStableKey([r])===o.getStableKey([n])?null:{ticks:[z(e,r),z(e,n)]}},z=(e,t)=>({value:t,position:e.map(t)});function zt({scale:e,aesthetics:t,layers:r}){const n=Ba({layers:r,aesthetics:t}),a=Wt({layers:r,aesthetics:t});return e.domain.map(i=>({value:i,geom:n(i),owner:a(i)}))}function Ba({layers:e,aesthetics:t}){const r=Wt({layers:e,aesthetics:t}),n=e.find(i=>t.some(s=>o.isDefined(i.mapping[s]))),a=n?n.geom:"bar";return i=>{const s=r(i);return s?s.layer.geom:a}}function Wt({layers:e,aesthetics:t,layerFilter:r}){const n=new Map;for(const[a,i]of e.entries()){if(r&&!r(i))continue;const s=t.find(l=>o.isDefined(i.mapping[l]));if(s===void 0)continue;const c=o.readVariableName(i.mapping[s]);if(!(c===null||!i.data.hasVariable(c)))for(const l of i.data.getValues(c,{distinct:!0})){const u=o.getStableKey(l);n.has(u)||n.set(u,{layer:i,layerIndex:a})}}return a=>n.get(o.getStableKey(a))}var Re=e=>{if(e.kind==="identity")return!1;const t=e.spec.scaleType;return t!=="continuous"&&t!=="datetime"};function $a({scales:e,layers:t,valueLabels:r}){const n=e.color;if(n===void 0||!Re(n))return[];if(!t.some(c=>o.isDefined(c.mapping.color)))return[];const a=M(t,"color");if(qt({colorVariableName:a,xVariableName:M(t,"x"),mapsColorAcrossMultipleLayers:Fa(t)>1,isMergedWithAnotherAesthetic:Ua(e,t,a)}))return[];const i=n.spec.scaleType,s=t.findIndex(c=>o.isDefined(c.mapping.color));return zt({scale:n,aesthetics:["color"],layers:t}).map(({value:c,geom:l,owner:u})=>{const d=u?.layerIndex??s,m=t[d],p=m?o.readVariableName(m.mapping.color):null;return{value:c,color:String(n.map(c)),geom:l,layerIndex:d,valueFormat:k({layers:m?[m]:t,scaleType:i,variableName:p}),label:ga(c,r)}})}var qt=({colorVariableName:e,xVariableName:t,mapsColorAcrossMultipleLayers:r,isMergedWithAnotherAesthetic:n})=>n?!1:e===null||o.isInternalVariable(e)?!r:t!==null&&e===t;function Ua(e,t,r){if(r===null)return!1;for(const n of o.SCALED_VISUAL_AESTHETIC_KEYS){if(n==="color")continue;const a=e[n];if(!(a===void 0||!Re(a))&&M(t,n)===r)return!0}return!1}var Fa=e=>e.filter(t=>o.isDefined(t.mapping.color)).length;function Ht(e,t){return e.get(t.geom).summaries.perGroupHeadline===!0}function ja(e,t,r,n){const a=r.findIndex(i=>Ht(e,i));return a===-1?[]:t.length<2?[{value:null,swatch:null,layerIndex:a,groupLabelFormat:{type:"text"},label:Ne(o.readVariableName(r[a]?.mapping.y),n)}]:t.map(i=>({value:i.value,swatch:{color:i.color,geom:i.geom,layerId:r[i.layerIndex]?.id,value:i.value},layerIndex:i.layerIndex,groupLabelFormat:i.valueFormat,label:i.label}))}function rt(e,t,r){if(r===null||t===null)return[...e];const n=o.getStableKey(r);return e.filter((a,i)=>o.getStableKey(t[i]??null)===n)}var Xt=e=>e==="none"?"first":e,Ga=(e,t)=>{switch(t){case"total":{const{sum:r,count:n}=nt(e);return n===0?null:r}case"average":{const{sum:r,count:n}=nt(e);return n===0?null:r/n}case"current":return e.at(-1)??null}},Ka=(e,t)=>{if(e.length<2)return null;const r=e.at(-1),n=t==="previous"?e.at(-2):e.at(0);return r===void 0||n===void 0||r.cross===null||n.cross===null||n.cross===0?null:{variation:(r.cross-n.cross)/n.cross,against:n.main}},nt=e=>e.reduce((t,r)=>r===null?t:{sum:t.sum+r,count:t.count+1},{sum:0,count:0});function Ya(e){const{config:t,coordSystem:r}=e,n=t.headline.show;return n==="none"||n==="conversion"?null:r.type==="polar"?za(e,n):Wa(e,n)}function za(e,t){if(t!=="total")return null;const{scales:r,layers:n}=e,a=n.find(c=>c.summary.grandTotal!==void 0);if(a===void 0)return null;const i=a.summary.grandTotal;if(i===void 0)return null;const s=o.readVariableName(a.mapping.y);return s===null?null:{kind:"grandTotal",value:i,valueFormat:k({layers:[a],scaleType:r.y?.spec.scaleType??"continuous",variableName:s})}}function Wa(e,t){const{config:r,scales:n,layers:a,variableLabels:i,colorGroups:s,geomRegistry:c}=e;if(!a.some(d=>Ht(c,d)))return null;const l=ja(c,s,a,i);if(l.length===0)return null;const u=l.map(d=>qa({group:d,show:t,compareWith:r.headline.compareWith,layers:a,scales:n})).filter(d=>d!==null);return u.length===0?null:{kind:"perGroup",items:u}}function qa({group:e,show:t,compareWith:r,layers:n,scales:a}){const i=n[e.layerIndex];if(i===void 0)return null;const s=o.readVariableName(i.mapping.y);if(s===null||i.data.getType(s)!=="numeric"||t==="total"&&i.position==="fill")return null;const c=o.readVariableName(i.mapping.x),l=o.readVariableName(i.mapping.color),u=i.yScaleType==="secondary"?a.ySecondary:a.y,d=k({layers:[i],scaleType:u?.spec.scaleType??"continuous",variableName:s}),m=Ja(i.data,c),p=k({layers:[i],scaleType:m?"datetime":a.x?.spec.scaleType??"discrete",variableName:c}),g=Qa(i.data,c),f=g.getValues(s,{type:"numeric"}),v=c!==null?g.getValues(c):[],y=l!==null?g.getValues(l):null,h=rt(f,y,e.value),b=rt(v,y,e.value);return{value:e.value,swatch:e.swatch,aggregate:Ga(h,t),valueFormat:d,groupLabelFormat:e.groupLabelFormat,mainValueFormat:p,label:e.label,caption:Ha(t,m,b),comparison:Xa(t,r,m,b,h)}}function Ha(e,t,r){if(e==="current"){const i=r.at(-1);return i===void 0?null:{kind:"point",value:i}}if(!t)return null;const n=r.at(0),a=r.at(-1);return n===void 0||a===void 0?null:{kind:"range",from:n,to:a}}function Xa(e,t,r,n,a){return e!=="current"||!r?null:Ka(n.map((i,s)=>({main:i,cross:a[s]??null})),Xt(t))}function Ja(e,t){return t!==null&&e.hasVariable(t)&&e.getType(t)==="temporal"}function Qa(e,t){return t===null||!["numeric","temporal"].includes(e.getType(t))?e:e.orderBy(t)}function Za(e,...t){return e?t.includes(e.geom):!1}function ei(e,t){return e.find(r=>r.id===t)}function ti(e,...t){return e.find(r=>t.includes(r.geom))}function ri(e,...t){return e.filter(r=>t.includes(r.geom))}function Jt(e,t){return e.interactive?!1:t.some(r=>r!==e&&o.areMappingsEquivalent(r.mapping,e.mapping))}function ni(e,t){return t.filter(r=>r!==e&&!r.interactive&&o.areMappingsEquivalent(e.mapping,r.mapping))}function Me(e){const t=e.filter(r=>!Jt(r,e));return t.length>0?t:e}function Qt({legendPosition:e,coordSystem:t,layers:r}){if(e!=="right"||t.type!=="cartesian"||t.mainAxis!=="x")return!1;const n=Me(r);return n.length===1&&n[0]?.supportsDirectLabels===!0}var ai=3;function ii({scales:e,config:t,layers:r,coordSystem:n,variableLabels:a,colorGroups:i,geomRegistry:s}){if(t.legend.position==="none")return{drawn:[],position:"none"};const c=new Map(i.map(y=>[o.getStableKey(y.value),y])),l=pi(li({scales:e,layers:r})),u=M(r,"x"),d=l.map(y=>{if(di(y,u,r))return null;const h=gi({group:y,variableLabels:a,layers:r,colorGroupsByValue:c});return h.items.length===0?null:{group:y,built:h}}).filter(o.isDefined),m=oi(d),p=Me(r),g=Ai(s,t.legend.position,m,p,n);if(d.length===0)return{drawn:[],position:g};if(t.legend.position==="auto"&&Si(s,m,p,n))return{drawn:[],position:g};const f=Ti(t.legend.display,{legendPosition:g,coordSystem:n,layers:r}),v=f==="direct"?xi(p[0]):null;return{drawn:d.map(({built:y})=>si(y,{position:g,display:f,align:t.legend.align},v)),position:g}}function oi(e){return e.reduce((t,{group:r,built:n})=>t+(r.some(a=>a.guideType!=="discrete")?1:n.items.length),0)}function si(e,t,r){const{position:n,display:a}=t,i=ci(t.align,n);return a!=="direct"||r===null?{...e,position:n,display:a,align:i}:{...e,position:n,display:a,align:i,items:e.items.map(s=>({...s,normalizedY:r.get(String(s.value))??null}))}}function ci(e,t){return e!=="auto"?e:t==="top"||t==="bottom"?"start":"center"}function li(e){const{scales:t,layers:r}=e,n=[];for(const a of o.SCALED_VISUAL_AESTHETIC_KEYS){const i=t[a];if(i===void 0||i.kind==="identity"||!ui(a,r))continue;const s=M(r,a),c=Vi(a,i);n.push({scaleAestheticKey:a,scale:i,variableName:s,guideType:c})}return n}function ui(e,t){const r=o.getAestheticFromScaleAestheticKey(e);return t.some(n=>o.isDefined(n.mapping[r]))}function di(e,t,r){const[n]=e;return n.scaleAestheticKey!=="color"?!1:qt({colorVariableName:n.variableName,xVariableName:t,mapsColorAcrossMultipleLayers:mi(n.scaleAestheticKey,r),isMergedWithAnotherAesthetic:e.length>1})}function mi(e,t){const r=o.getAestheticFromScaleAestheticKey(e);return t.filter(n=>o.isDefined(n.mapping[r])).length>1}function pi(e){const t=new Map;for(const r of e){const n=Ei(r),a=t.get(n);a?a.push(r):t.set(n,[r])}return[...t.values()]}function fi(e,t,r){if(t==="lineType"){e.lineType=r;return}if(t==="color"){e.color=String(r);return}e[t]=r}function gi({group:e,variableLabels:t,layers:r,colorGroupsByValue:n}){const a=e[0],i=e.map(u=>o.getAestheticFromScaleAestheticKey(u.scaleAestheticKey)),s=zt({scale:a.scale,aesthetics:i,layers:r}),c=k({layers:r,scaleType:a.scale.spec.scaleType,variableName:a.variableName}),l=r.find(u=>i.some(d=>o.isDefined(u.mapping[d])))?.id;return{aesthetics:e.map(u=>u.scaleAestheticKey),title:Ne(a.variableName,t),items:s.map(u=>hi(u,e,i,c,n,l))}}function hi(e,t,r,n,a,i){const s={};for(const l of t)fi(s,l.scaleAestheticKey,l.scale.map(e.value));if(s.color===void 0&&r.includes("size")&&(s.color=o.DEFAULT_GEOM_COLOR),s.lineType===void 0){const l=o.readConstantValue(e.owner?.layer.mapping.lineType);o.isLineType(l)&&(s.lineType=l)}const c=vi(e,t,r,n,a);return{value:e.value,label:yi(t,e,a),visual:s,normalizedY:null,geom:e.geom,valueFormat:c,layerId:e.owner?.layer.id??i}}function yi(e,t,r){return e[0].scaleAestheticKey!=="color"?null:r.get(o.getStableKey(t.value))?.label??null}function vi(e,t,r,n,a){if(t[0].scaleAestheticKey==="color")return a.get(o.getStableKey(e.value))?.valueFormat??n;const i=e.owner?.layer,s=bi(i,r);return i===void 0||s===null?n:k({layers:[i],scaleType:t[0].scale.spec.scaleType,variableName:s})}function bi(e,t){if(e===void 0)return null;for(const r of t){const n=e.mapping[r];if(n===void 0)continue;const a=o.readVariableName(n);if(a!==null)return a}return null}function Si(e,t,r,n){if(t>1)return!1;const a=n.type==="polar";return r.some(i=>e.get(i.geom).legend.suppressWhenSingleItem||a)}function Ai(e,t,r,n,a){if(t!=="auto")return t;if(a.type==="polar")return"top";let i=!1,s=!1,c=!1;for(const u of n){const{sidePlacement:d}=e.get(u.geom).legend;d==="whenCrowded"&&(i=!0),d==="whenStackedVertical"&&(s=!0,o.isStackedPosition(u.position)&&(c=!0))}const l=r>=ai;return i&&s?"top":i?l?"right":"top":c?Ii(a)?"top":l?"right":"top":"top"}function Ti(e,t){return e==="pill"?"pill":Qt(t)?"direct":"pill"}function Ii(e){return e.type==="cartesian"&&e.mainAxis==="y"}function Ei(e){const t=e.scale.domain.map(o.getStableKey);return JSON.stringify([e.variableName,e.guideType,...t])}function Vi(e,t){return Re(t)?"discrete":`continuous:${e}`}function xi(e){if(!e)return new Map;const t=new Map;return e.data.groupBy(o.GROUP_VARIABLES.group).forEach(r=>{const n=r.findLast(l=>o.isDefined(o.getYMax(l))||o.isDefined(o.getY(l)));if(!n)return;const a=Z(n);if(!o.isDefined(a))return;const i=o.getYMin(n),s=o.getYMax(n)??o.getY(n);if(!o.isDefined(s))return;const c=o.isDefined(i)?(i+s)/2:s;t.set(String(a),c)}),t}var Oi=class extends o.Stage{constructor(e){super(),this.container=e}dependencies(e){return[e.scales,e.config.axes,e.config.legend,e.config.headline,e.layers,e.coordSystem,e.originalData]}run(e){const t=pa(e.originalData),r=$a({scales:e.scales,layers:e.layers,valueLabels:fa(e.originalData,e.layers,t)}),n={scales:e.scales,config:e.config,layers:e.layers,coordSystem:e.coordSystem,variableLabels:t,colorGroups:r,geomRegistry:this.container.geomRegistry},a=Ya(n),i=ii(n),s={...i,drawn:wi(a,i.drawn)};return{axes:wa(n,s.drawn),legends:s,headline:a,colorGroups:r,variableLabels:t}}},wi=(e,t)=>e?.kind!=="perGroup"||t.some(r=>r.display==="direct")?t:[],Te=(e,t,r)=>{switch(e){case"series":return Li(t);case"x-value":return ke(t,r)}},Zt=e=>{const t=o.readMainAxisVariable(e);return t===""?null:t},Li=e=>o.getStableKey([Z(e)]),ke=(e,t)=>o.getStableKey([t!==null?e[t]??null:null]);function er(e){return e===null?null:{strategy:e,composition:tr()}}function tr(){return{isDimmed:!1,matchedLayer:null,overlayCandidates:[]}}var Ci=class extends B{constructor(e){super(),this.container=e,this.warningsByLayer=new WeakMap}compile(e){const t=super.compile(e);for(const r of t)for(const n of this.warningsByLayer.get(r)??[])this.container.diagnostics.addWarning(n);return t}dependencies(e){return[e.highlights,e.config.parsingLocale]}compileLayer(e,t){const r=e.highlight;if(r===null)return e;const n=t.highlights.filter(({layerId:c})=>c===void 0||c===e.id);if(n.length===0)return e;const a=[],i=_i({layer:e,highlights:n,parsingLocale:t.config.parsingLocale,strategy:r.strategy,warnings:a}),s={...e,highlight:{...r,composition:i}};return this.warningsByLayer.set(s,a),s}};function _i({layer:e,highlights:t,parsingLocale:r,strategy:n,warnings:a}){const i=t.filter(S=>{const x=R(S.predicate,e.data);for(const O of x)a.push({...O,message:`${O.message} Dropping this highlight.`});return x.length===0}),s=Zt(e.mapping),c=de(e,r),l=i.map(S=>({predicate:N(S.predicate,c),scope:S.scope})),u=l.some(({scope:S})=>S==="series"),d=l.some(({scope:S})=>S==="x-value"),m=n==="overlay-anchor",p=e.data.size(),g=u?new Array(p):null,f=d?new Array(p):null,v=m?new Array(p):null,y=new Uint8Array(p),h=new Set,b=new Set;let C=!1,T=0;for(const S of e.data){let x,O;g!==null&&(x=Te("series",S,s),g[T]=x),f!==null&&(O=Te("x-value",S,s),f[T]=O),v!==null&&(v[T]=S);for(const{predicate:re,scope:ne}of l)if(re(S))switch(ne){case"series":x!==void 0&&h.add(x);break;case"x-value":O!==void 0&&b.add(O);break;case"data-point":y[T]=1,C=!0;break}T++}if(h.size===0&&b.size===0&&!C)return tr();const V=new Uint8Array(p),q=[];let $=0;for(let S=0;S<p;S++){const x=g?.[S],O=f?.[S],re=x!==void 0&&h.has(x),ne=O!==void 0&&b.has(O),We=y[S]===1;if(n==="observation-rerender")(re||We||ne)&&(V[S]=1,$++);else if(re)V[S]=1,$++;else if(We||ne){const qe=v?.[S];qe!==void 0&&q.push({observation:qe,observationIndex:S})}}const U=$>0?{...e,data:e.data.filterByMask(V)}:null;return{isDimmed:(n==="observation-rerender"||h.size>0)&&U!==null,matchedLayer:U,overlayCandidates:q}}var Pi=o.prefixInternalVariable("__ungrouped__");function Di(e){const t=e.getVariableNames().filter(a=>e.getType(a)==="temporal"&&o.isDateWithoutYearValueFormat(e.getValueFormat(a)));if(t.length===0)return e;const r=e.getValues(o.GROUP_VARIABLES.group,{type:"categorical"});let n=e;for(const a of t){const i=n.getValues(a,{type:"temporal"}),s=new Map,c=i.map((l,u)=>{if(l===null)return null;const d=r[u]??Pi;let m=s.get(d);return m||(m=new o.ChronologicalDateManager,s.set(d,m)),m.incrementYearIfNeeded(l)});n=n.addVariable(a,"temporal",c)}return n}var rr=()=>({defaults:[],overrides:[],warnings:[],vocabulary:o.STYLE_TARGETS.geom.vocabulary,aesthetics:o.STYLE_TARGETS.geom.aesthetics,dashPresets:o.DASH_PRESETS.line,parts:{}}),Ni=class extends B{constructor(e,t,r,n,a,i){super(),this.container=e,this.transformCompiler=t,this.statCompiler=r,this.groupCompiler=n,this.geomCompiler=a,this.positionAdjusterCompiler=i}dependencies(e){return[e.data,e.mapping,at(e),e.coords.coordType]}compileLayer(e,t){return this.runLayerPipeline({layer:e,data:this.transformCompiler.compile({data:t.data,transforms:e.transforms}),effectiveMapping:{...t.mapping,...e.mapping},xScaleIsDiscrete:at(t),coordType:t.coords.coordType})}runLayerPipeline({layer:e,data:t,effectiveMapping:r,xScaleIsDiscrete:n,coordType:a}){const i=ue({data:t,mapping:r}).pipe(({data:c,mapping:l})=>{const u=this.statCompiler.compute(e.stat,{data:c,mapping:l,xScaleIsDiscrete:n});return{data:u.data,mapping:{...l,...u.mapping}}}).pipe(({data:c,mapping:l})=>({data:this.groupCompiler.compute({data:c,mapping:l}).data,mapping:l})).pipe(({data:c,mapping:l})=>({data:Di(c),mapping:l})).pipe(({data:c,mapping:l})=>{const u=this.geomCompiler.compile(e.geom,{data:c,mapping:l,params:e.params,coordType:a});return{data:u.data,mapping:{...l,...u.mapping}}}).pipe(({data:c,mapping:l})=>{const u=this.positionAdjusterCompiler.adjust(e.position,{data:c,mapping:l});return{data:u.data,mapping:{...l,...u.mapping}}}).result(),s=this.container.geomRegistry.get(e.geom);return{...i,id:e.id,geom:e.geom,position:e.position,yScaleType:e.yScaleType,params:e.params,interactive:e.interactive,dataLabels:e.dataLabels,summary:{},spatialKind:s.spatialKind,identityKey:s.identityKey,tooltip:s.tooltip,scaleConstraints:s.scaleConstraints,supportsDirectLabels:s.legend.directLabelSupport?.[e.position]===!0,highlight:er(s.highlightStrategy),styles:rr()}}};function at(e){return e.scales.some(t=>t.scaledAesthetic==="x"&&t.scaleType==="discrete")}function nr(e,t){const[r]=t;if(r){for(const n of t)e.addError(n);throw new o.UserInputError(r)}}function Be(e,t){return t.map(r=>({...r,scaleConstraints:e.has(r.geom)?e.get(r.geom).scaleConstraints:void 0}))}function Ri(e){return e.some(t=>o.isStackedPosition(t.position)||t.scaleConstraints?.bandPadding===0)}function $e(e){const t=ar(e),r={};for(const{layer:a,scaleConstraints:i,crossAxis:s}of t)i.zeroBaseline===!0&&(r[s]={nice:(r[s]?.nice??!0)&&a.position!=="fill"});const n=t.find(({scaleConstraints:a})=>a.discreteCrossAxis===!0);return{discreteAxis:t.some(({scaleConstraints:a})=>a.discreteMainAxis===!0)?"x":null,discreteCrossAxis:n?.crossAxis??null,bandedAxes:ki(t),zeroAxes:r,bandPadding:Bi(t),inferredColor:t.some(({scaleConstraints:a})=>a.inferredColor===!0)}}function Mi(e){const t=ar(e);for(const r of t){if(r.scaleConstraints.discreteCrossAxis!==!0)continue;const n=t.find(a=>a.scaleConstraints.zeroBaseline===!0&&a.crossAxis===r.crossAxis);if(n!==void 0)return{crossAxis:r.crossAxis,banded:it(r),zeroAnchored:it(n)}}return null}var it=({layer:e,index:t})=>({layerId:e.id,layerIndex:t,geom:e.geom});function ar(e){const t=[];return e.forEach((r,n)=>{const{scaleConstraints:a,yScaleType:i}=r;a!==void 0&&t.push({layer:r,index:n,scaleConstraints:a,crossAxis:o.resolveYScaleAesthetic(i)})}),t}function ki(e){const t=new Set;for(const{scaleConstraints:r,crossAxis:n}of e)r.discreteMainAxis===!0&&t.add("x"),r.discreteCrossAxis===!0&&t.add(n);return[...t]}function Bi(e){const t={};for(const r of e){const n=r.scaleConstraints.bandPadding;if(n!==void 0)for(const a of $i(r)){const i=t[a];t[a]=i===void 0?n:Math.min(i,n)}}return t}function $i({scaleConstraints:e,crossAxis:t}){return e.discreteCrossAxis!==!0?["x"]:e.discreteMainAxis===!0?["x",t]:[t]}var Ui=new Set(["label","group"]),Fi=class{constructor(e,t,r,n){this.container=e,this.transformCompiler=t,this.statRegistry=r,this.layerCompiler=n}get stats(){return this.layerCompiler.stats}compile(e){this.checkPreCompile(e);const t=this.layerCompiler.compile(e);return this.checkPostCompile(t),t}checkPreCompile(e){const t=[];e.layers.forEach((r,n)=>{const a=this.transformCompiler.compile({data:e.data,transforms:r.transforms}),i={...e.mapping,...r.mapping},s={layerId:r.id,layerIndex:n,geom:r.geom,position:r.position,stat:r.stat,effectiveMapping:i,data:a,coordType:e.coords.coordType,dataLabels:r.dataLabels};t.push(...this.validateLayer(s));const c=[...this.collectUndeclaredAesthetics(s),...this.collectPanelJustifyWarnings(s)];for(const l of c)this.container.diagnostics.addWarning(l)}),t.push(...this.validateSharedScaleDemands(e.layers)),nr(this.container.diagnostics,t)}checkPostCompile(e){wt(e)&&this.container.diagnostics.addWarning({code:"EMPTY_DATASET",message:"No data to plot — every layer resolved to zero observations.",suggestion:"Check the dataset has rows and that transforms (filters, joins) are not removing them all."})}validateLayer(e){return[...this.validateRequiredAesthetics(e),...this.validateVariableExistence(e),...this.validatePositionalAestheticTypes(e),...this.validateGeomMapping(e),...this.validateCoordSupport(e),...this.validateSupportedPosition(e)]}collectPanelJustifyWarnings({geom:e,effectiveMapping:t,data:r,layerIndex:n,coordType:a,dataLabels:i}){const{justify:s,showDataLabels:c}=i;if(!c||s!=="panel-start"&&s!=="panel-end")return[];if(a==="polar"||!this.container.geomRegistry.get(e).isComposite)return[];if(!o.hasMultipleGroups(r,t))return[];const l=s==="panel-end"?"end":"start";return[{code:"DATA_LABEL_PLACEMENT_COERCED",message:`Multiple ${e} groups would all pin their labels to the same panel edge; justify '${s}' will render as '${l}'.`,context:{layerIndex:n,expected:l,actual:s},suggestion:`Use justify '${l}' for this layer.`}]}validateRequiredAesthetics({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const i=[],{positionRoles:s,aesthetics:c}=this.container.geomRegistry.get(r),l=[...ca(s),...c.filter(m=>m.required).map(m=>m.name)],{computedVariables:u}=this.statRegistry.get(n.type),d=u;for(const m of l)d.has(m)||o.isDefined(a[m])||i.push({code:"MISSING_AESTHETIC",message:`Layer '${e}': geom '${r}' requires aesthetic '${m}'`,context:{layerIndex:t,aesthetic:m}});return i}validateVariableExistence({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a,data:i}){const s=[],{computedVariables:c}=this.statRegistry.get(n.type),{derivedVariables:l}=this.container.geomRegistry.get(r),u=c,d=new Set(l);for(const[m,p]of Object.entries(a)){if(u.has(m))continue;const g=o.readVariableName(p);g===null||g===""||d.has(g)||i.hasVariable(g)||s.push({code:"UNKNOWN_VARIABLE",message:`Layer '${e}': aesthetic '${m}' references variable '${g}' which does not exist in the dataset`,context:{layerIndex:t,aesthetic:m,variableName:g}})}return s}validatePositionalAestheticTypes({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a,data:i}){const{positionRoles:s}=this.container.geomRegistry.get(r),{computedVariables:c}=this.statRegistry.get(n.type),l=c,u=[];for(const d of s){if(!jt.has(d.role)||!o.isDefined(d.aes)||l.has(d.aes)||d.role==="scalar"&&d.aes===d.axis)continue;const m=o.readVariableName(a[d.aes]);if(m===null||!i.hasVariable(m)||i.size()===0)continue;const p=i.getType(m);p!=="numeric"&&u.push({code:"INCOMPATIBLE_TYPE",message:`Layer '${e}': aesthetic '${d.aes}' must be numeric, but variable '${m}' is ${p}`,context:{layerIndex:t,aesthetic:d.aes,variableName:m,variableType:p},suggestion:this.suggestNumericAestheticFix(d.aes,d.axis,a,i)})}return u}suggestNumericAestheticFix(e,t,r,n){const a=t==="y"?"x":"y";if(e===t){const i=o.readVariableName(r[a]);if(i!==null&&n.hasVariable(i)&&n.getType(i)==="numeric")return`Swap the '${a}' and '${t}' mappings so the numeric variable is on '${t}'. Add coord.flip() to orient the graph horizontally.`}return`Map '${e}' to a numeric variable.`}validateGeomMapping({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const{validateMapping:i}=this.container.geomRegistry.get(r);if(i===void 0)return[];const{computedVariables:s}=this.statRegistry.get(n.type);return i({mapping:a,computedVariables:s}).map(c=>({...c,message:`Layer '${e}': ${c.message}`,context:{...c.context,layerIndex:t}}))}validateSharedScaleDemands(e){const t=Mi(Be(this.container.geomRegistry,e));if(t===null)return[];const{crossAxis:r,banded:n,zeroAnchored:a}=t;return[{code:"CONFLICTING_SCALE_DEMANDS",message:`Layer '${n.layerId}' (geom '${n.geom}') needs '${r}' to be a band scale, but layer '${a.layerId}' (geom '${a.geom}') needs it to be a value axis anchored at zero. One scale cannot be both.`,context:{aesthetic:r,layerId:n.layerId,layerIndex:n.layerIndex},suggestion:"Drop one of the layers, or move one onto the secondary y axis with 'yScaleType'."}]}validateCoordSupport({layerId:e,layerIndex:t,geom:r,coordType:n}){const{supportedCoordTypes:a}=this.container.geomRegistry.get(r);return a.includes(n)?[]:[{code:"UNSUPPORTED_COORD",message:`Layer '${e}': geom '${r}' is not supported under ${n} coords`,context:{layerIndex:t}}]}validateSupportedPosition({layerId:e,layerIndex:t,geom:r,position:n}){const{supportedPositions:a}=this.container.geomRegistry.get(r);return a.includes(n)?[]:[{code:"UNSUPPORTED_POSITION",message:`Layer '${e}': geom '${r}' does not support the '${n}' position`,context:{layerIndex:t},suggestion:`Use one of: ${a.join(", ")}.`}]}collectUndeclaredAesthetics({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const{positionRoles:i,aesthetics:s}=this.container.geomRegistry.get(r),{computedVariables:c}=this.statRegistry.get(n.type),l=new Set([...la(i),...s.map(p=>p.name)]),u=Ui,d=c,m=[];for(const p of Object.keys(a))o.isDefined(a[p])&&(l.has(p)||u.has(p)||d.has(p)||m.push({code:"UNDECLARED_AESTHETIC",message:`Layer '${e}': geom '${r}' does not declare aesthetic '${p}'; the mapping is ignored`,context:{layerIndex:t,aesthetic:p}}));return m}},ji=class extends o.Stat{constructor(...e){super(...e),this.type="count",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=o.readVariableName(t.x);if(!o.isDefined(r))throw new o.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'x' variable is required for 'count' stat",context:{aesthetic:"x"},suggestion:"Map a variable to 'x' when using the 'count' stat."});if(o.readVariableName(t.y)!==null)throw new o.UserInputError({code:"CONFLICTING_STAT_MAPPING",message:"Cannot map 'y' variable together with 'count' stat",context:{aesthetic:"y"},suggestion:"Remove the 'y' mapping; the 'count' stat computes it."});const n=[...new Set([r,...o.getGroupVariables(e,t)])];return{data:e.groupBy(...n).rollup({[o.STAT_VARIABLES.count]:{variableName:r,aggregation:"count"}}),mapping:{y:o.STAT_VARIABLES.count}}}},Gi=class extends o.Stat{constructor(...e){super(...e),this.type="identity",this.computedVariables=new Set}computeStat({data:e}){return{data:e,mapping:{}}}},Ki=class extends o.Stat{constructor(...e){super(...e),this.type="mean",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=o.readVariableName(t.y);if(!o.isDefined(r))throw new o.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'mean' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'mean' stat."});if(e.hasVariable(r)&&e.getType(r)!=="numeric"){const n=e.getType(r);throw new o.UserInputError({code:"INCOMPATIBLE_TYPE",message:`'mean' stat requires a numeric 'y' (got '${n}' for variable '${r}')`,context:{aesthetic:"y",variableName:r,variableType:n},suggestion:"Map a numeric variable to 'y' when using the 'mean' stat."})}return{data:e.rollup({[o.STAT_VARIABLES.mean]:{variableName:r,aggregation:"mean"}}),mapping:{y:o.STAT_VARIABLES.mean}}}},Yi=2,ir=1440*60*1e3,zi=class extends o.Stat{constructor(...e){super(...e),this.type="smooth",this.computedVariables=new Set}computeStat({data:e,mapping:t,spec:r,xScaleIsDiscrete:n}){if(r.type!=="smooth")throw new o.InternalError({message:`SmoothStat received a spec of type '${r.type}'`});const a=o.readVariableName(t.x),i=o.readVariableName(t.y);if(!o.isDefined(a))throw new o.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'x' variable is required for 'smooth' stat",context:{aesthetic:"x"},suggestion:"Map a variable to 'x' when using the 'smooth' stat."});if(!o.isDefined(i))throw new o.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'smooth' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'smooth' stat."});const s=e.getType(a),c=e.getType(i);if(c!=="numeric")throw new o.UserInputError({code:"INCOMPATIBLE_TYPE",message:`'smooth' stat requires a numeric 'y' (got '${c}' for variable '${i}')`,context:{aesthetic:"y",variableName:i,variableType:c}});const l=o.getGroupVariables(e,t),u=Zi(a,s,i,l,e);return l.length===0?ot({data:e,xVariable:a,xType:s,yVariable:i,spec:r,output:u,groupObservation:{},xScaleIsDiscrete:n}):e.groupBy(...l).forEach(d=>{const m=eo(d,l);ot({data:d,xVariable:a,xType:s,yVariable:i,spec:r,output:u,groupObservation:m,xScaleIsDiscrete:n})}),{data:u.build(),mapping:{}}}},ot=({data:e,xVariable:t,xType:r,yVariable:n,spec:a,output:i,groupObservation:s,xScaleIsDiscrete:c})=>{const{observations:l,temporalOrigin:u}=Wi({data:e,xVariable:t,yVariable:n,xType:r});l.length<Yi||(c?Qi({observations:l,spec:a,output:i,groupObservation:s}):Xi({observations:l,xType:r,temporalOrigin:u,spec:a,output:i,groupObservation:s}))},Wi=({data:e,xVariable:t,yVariable:r,xType:n})=>{const a=e.getValues(t),i=e.getValues(r,{type:"numeric"}),s=n==="temporal"?qi(a):null,c=[],l=new Map;for(let u=0;u<a.length;u++){const d=a[u],m=i[u];if(!o.isDefined(d)||!o.isDefined(m)||!Number.isFinite(m))continue;const p=Hi({xValue:d,xType:n,categoryRank:l,temporalOrigin:s});p!==null&&c.push({x:p,y:m,originalX:d})}return{observations:c,temporalOrigin:s}},qi=e=>{let t=null;for(const r of e){if(!o.isStrictTemporalDataValue(r))continue;const n=r.getTime();(t===null||n<t)&&(t=n)}return t},Hi=({xValue:e,xType:t,categoryRank:r,temporalOrigin:n})=>{switch(t){case"numeric":return!o.isStrictNumericDataValue(e)||!Number.isFinite(e)?null:e;case"temporal":{if(!o.isStrictTemporalDataValue(e))return null;const a=e.getTime();return n===null?a:(a-n)/ir+1}case"categorical":{if(!o.isStrictCategoricalDataValue(e))return null;const a=r.get(e);if(a!==void 0)return a;const i=r.size+1;return r.set(e,i),i}default:throw new o.InternalError({message:`Unexpected xType: ${t}`})}},Xi=({observations:e,xType:t,temporalOrigin:r,spec:n,output:a,groupObservation:i})=>{const s=or(n,e);for(const[c,l]of s){if(!Number.isFinite(c)||!Number.isFinite(l))continue;const u=t==="temporal"?Ji(c,r):c;a.push({x:u,y:l,groupObservation:i})}},Ji=(e,t)=>t===null?new Date(e):new Date((e-1)*ir+t),Qi=({observations:e,spec:t,output:r,groupObservation:n})=>{const a=new Map;for(const c of e)a.has(c.x)||a.set(c.x,c.originalX);const i=[...a.keys()].sort((c,l)=>c-l);if(t.method==="loess"){const c=or(t,e),l=new Map;for(const[u,d]of c)Number.isFinite(d)&&(l.has(u)||l.set(u,d));for(const u of i){const d=l.get(u),m=a.get(u);d===void 0||m===void 0||r.push({x:m,y:d,groupObservation:n})}return}const s=sr(t,e);for(const c of i){const l=a.get(c),u=s.predict(c);l===void 0||!Number.isFinite(u)||r.push({x:l,y:u,groupObservation:n})}},or=(e,t)=>e.method==="loess"?(0,D.regressionLoess)().x(r=>r.x).y(r=>r.y).bandwidth(e.bandwidth)(t):sr(e,t),sr=(e,t)=>{const r=a=>a.x,n=a=>a.y;switch(e.method){case"linear":return(0,D.regressionLinear)().x(r).y(n)(t);case"exponential":return(0,D.regressionExp)().x(r).y(n)(t);case"logarithmic":return(0,D.regressionLog)().x(r).y(n)(t);case"quadratic":return(0,D.regressionQuad)().x(r).y(n)(t);case"power":return(0,D.regressionPow)().x(r).y(n)(t);case"polynomial":return(0,D.regressionPoly)().x(r).y(n).order(e.order)(t);case"loess":throw new o.InternalError({message:"'loess' does not expose a 'predict' function"})}},Zi=(e,t,r,n,a)=>{const i=[],s=[],c=Object.fromEntries(n.map(l=>[l,[]]));return{push:({x:l,y:u,groupObservation:d})=>{i.push(l),s.push(u);for(const m of n)c[m]?.push(d[m]??null)},build:()=>{const l={[e]:{type:t,values:i,valueFormat:a.getValueFormat(e)},[r]:{type:"numeric",values:s,valueFormat:a.getValueFormat(r)}};for(const u of n)l[u]={type:a.getType(u),values:c[u]??[],valueFormat:a.getValueFormat(u)};return new o.Dataset(l)}}},eo=(e,t)=>{const r={};for(const n of t)r[n]=e.getValues(n)[0]??null;return r},to=class extends o.Stat{constructor(...e){super(...e),this.type="sum",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=o.readVariableName(t.y);if(!o.isDefined(r))throw new o.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'sum' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'sum' stat."});if(e.hasVariable(r)&&e.getType(r)!=="numeric"){const i=e.getType(r);throw new o.UserInputError({code:"INCOMPATIBLE_TYPE",message:`'sum' stat requires a numeric 'y' (got '${i}' for variable '${r}')`,context:{aesthetic:"y",variableName:r,variableType:i},suggestion:"Map a numeric variable to 'y' when using the 'sum' stat."})}const n=o.readVariableName(t.x),a=[...new Set([...n===null?[]:[n],...o.getGroupVariables(e,t)])];return{data:e.groupBy(...a).rollup({[o.STAT_VARIABLES.sum]:{variableName:r,aggregation:"sum"}}),mapping:{y:o.STAT_VARIABLES.sum}}}},ro=[new Gi,new ji,new zi,new Ki,new to],no=class extends o.Registry{constructor(){super("stat");for(const e of ro)this.register(e.type,e)}};function ao({geoms:e,stats:t,transforms:r}){const n=new o.GeomRegistry,a=new no,i=new o.TransformRegistry;for(const s of e)n.register(s.type,s);for(const s of t)a.register(s.type,s);for(const s of r)i.register(s.transformType,s);return{geomRegistry:n,statRegistry:a,transformRegistry:i}}var io=class{constructor(e){this.registry=e}adjust(e,t){return this.registry.get(e).adjust(t)}},me=class{},oo=class extends me{constructor(...e){super(...e),this.type="dodge"}adjust({data:e,mapping:t}){if(!o.readVariableName(t.x))return{data:e,mapping:{}};const r=e.getValues(o.GROUP_VARIABLES.group,{type:"categorical",distinct:!0,skipNulls:!0});if(r.length===0)return{data:e,mapping:{}};const n=e.size(),a=e.getValues(o.GROUP_VARIABLES.group,{type:"categorical"}),i=so(e)??[-.7/2,.7/2],s=r.length>1?o.BAR_GROUP_SCALE_PADDING_FRACTION:0,c=(0,w.scaleBand)().domain(r.map(String)).range(i).paddingInner(s).paddingOuter(0),l=c.bandwidth(),u=new Array(n).fill(null),d=new Array(n).fill(null);for(let m=0;m<n;m++){const p=a[m];if(!o.isDefined(p))continue;const g=c(String(p));o.isDefined(g)&&(u[m]=g,d[m]=g+l)}return{data:e.addVariable(o.POSITION_VARIABLES.xMin,"numeric",u).addVariable(o.POSITION_VARIABLES.xMax,"numeric",d),mapping:{}}}},so=e=>{const t=e.getConstant(o.POSITION_VARIABLES.xMin)?.value,r=e.getConstant(o.POSITION_VARIABLES.xMax)?.value;return typeof t!="number"||typeof r!="number"?null:[t,r]},st=o.prefixInternalVariable("__ungrouped__"),cr=(e,t)=>{const r=o.readVariableName(t.x),n=o.readVariableName(t.y);if(!r||!n)return null;const a=e.getValues(o.GROUP_VARIABLES.group,{type:"categorical",distinct:!0,skipNulls:!0}),i=a.length===0,s=i?[st]:a,c=e.getValues(r),l=e.getValues(n,{type:"numeric"}),u=e.getValues(o.GROUP_VARIABLES.group,{type:"categorical"}),d=e.size(),m=new Map;for(let p=0;p<d;p++){const g=o.getStableKey(c[p]??null),f=u[p],v=i?st:f;if(!o.isDefined(v))continue;let y=m.get(g);y||(y=new Map,m.set(g,y));let h=y.get(v);h||(h=[],y.set(v,h)),h.push(p)}return{yValues:l,observationIndicesByXAndGroup:m,uniqueGroupKeys:s,observationCount:d}},lr=(e,t,r,n)=>{const a=new Array(n).fill(null);for(const[,i]of r){const s=[];let c=-1,l=1/0,u=-1/0,d=-1,m=1/0,p=-1/0;for(const g of i.values())for(const f of g){const v=e[f],y=t[f];!o.isDefined(v)||!o.isDefined(y)||(s.push(f),(v<l||v===l&&y>u)&&(c=f,l=v,u=y),(y>p||y===p&&v<m)&&(d=f,m=v,p=y))}for(const g of s)a[g]=co(g===c,g===d)}return a},co=(e,t)=>e&&t?"solo":e?"floor":t?"ceiling":"middle",lo=class extends me{constructor(...e){super(...e),this.type="fill"}adjust({data:e,mapping:t}){const r=cr(e,t);if(r===null)return{data:e,mapping:{}};const{yValues:n,observationIndicesByXAndGroup:a,uniqueGroupKeys:i,observationCount:s}=r,c=[...n],l=new Array(s).fill(0);for(const[,d]of a){let m=0,p=0;for(const v of i){const y=d.get(v);if(y!==void 0)for(const h of y){const b=n[h];b!=null&&(b>=0?m+=b:p-=b)}}let g=0,f=0;for(const v of i){const y=d.get(v);if(y!==void 0)for(const h of y){const b=n[h];if(b===void 0)continue;if(b===null){l[h]=null,c[h]=null;continue}const C=b>=0?m:p;if(C===0){l[h]=0,c[h]=0;continue}const T=b/C;b>=0?(l[h]=g,c[h]=g+=T):(c[h]=f,l[h]=f+=T)}}}const u=lr(l,c,a,s);return{data:e.addVariable(o.POSITION_VARIABLES.yMin,"numeric",l).addVariable(o.POSITION_VARIABLES.yMax,"numeric",c).addVariable(o.POSITION_VARIABLES.yRaw,"numeric",n).addVariable(o.STACK_VARIABLES.role,"categorical",u),mapping:{}}}},uo=class extends me{constructor(...e){super(...e),this.type="identity"}adjust({data:e}){return{data:e,mapping:{}}}},mo=class extends me{constructor(...e){super(...e),this.type="stack"}adjust({data:e,mapping:t}){const r=cr(e,t);if(r===null)return{data:e,mapping:{}};const{yValues:n,observationIndicesByXAndGroup:a,uniqueGroupKeys:i,observationCount:s}=r,c=[...n],l=new Array(s).fill(0);for(const[,p]of a){let g=0,f=0;for(const v of i){const y=p.get(v);if(y!==void 0)for(const h of y){const b=n[h];if(b!==void 0){if(b===null){l[h]=null,c[h]=null;continue}b>=0?(l[h]=g,c[h]=g+=b):(c[h]=f,l[h]=f+=b)}}}}const u=lr(l,c,a,s);let d=e.addVariable(o.POSITION_VARIABLES.yMin,"numeric",l).addVariable(o.POSITION_VARIABLES.yMax,"numeric",c).addVariable(o.POSITION_VARIABLES.yRaw,"numeric",n).addVariable(o.STACK_VARIABLES.role,"categorical",u);const m=o.readVariableName(t.y);return m!==null&&(d=d.addVariable(m,"numeric",c)),{data:d,mapping:{}}}},po=class extends o.Registry{constructor(){super("position"),this.register("identity",new uo),this.register("stack",new mo),this.register("fill",new lo),this.register("dodge",new oo)}},fo=class{map({data:e,layer:t,getPositionScale:r,geomRegistry:n}){let a=e;const i=n.get(t.geom);for(const s of i.positionRoles){if(s.role!=="scalar"||!o.isDefined(s.aes)||o.isVisualScale(s.aes))continue;const c=o.readVariableName(t.mapping[s.aes]);if(!o.isDefined(c)||!a.hasVariable(c))continue;const l=r(o.resolvePositionScaleAesthetic(s.axis,t.yScaleType));if(!l)continue;const u=a.getValues(c,{type:"numeric"}).map(d=>o.isDefined(d)?l.map(d):null);a=a.addVariable(o.resolveScaledAestheticVariable(s.aes),"numeric",u)}return a}},go=class{map({data:e,layer:t,getPositionScale:r}){const n=o.readVariableName(t.mapping.x),a=r("x");if(!n||!a)return e;const i=e.getValues(n).map(s=>o.isDefined(s)?a.map(s):null);return e.addVariable(o.POSITION_VARIABLES.x,"numeric",i)}},ho=class{map({data:e,getPositionScale:t}){const r=t("x");if(!r||!e.hasVariable(o.POSITION_VARIABLES.xMin)||!e.hasVariable(o.POSITION_VARIABLES.xMax))return e;const n=r.bandwidth,a=o.isDefined(n)&&e.hasVariable(o.POSITION_VARIABLES.x)?yo(e,r,n):vo(e,r);return e.addVariable(o.POSITION_VARIABLES.xMin,"numeric",a.min).addVariable(o.POSITION_VARIABLES.xMax,"numeric",a.max)}};function yo(e,t,r){const n=e.getValues(o.POSITION_VARIABLES.x,{type:"numeric"}),a=e.getValues(o.POSITION_VARIABLES.xMin,{type:"numeric"}),i=e.getValues(o.POSITION_VARIABLES.xMax,{type:"numeric"}),s="reverse"in t.spec&&t.spec.reverse===!0,c=e.size(),l=ur(c);for(let u=0;u<c;u++){const d=n[u],m=a[u],p=i[u];!o.isDefined(d)||!o.isDefined(m)||!o.isDefined(p)||(l.min[u]=d+(s?-p:m)*r,l.max[u]=d+(s?-m:p)*r)}return l}function vo(e,t){const r=e.getValues(o.POSITION_VARIABLES.xMin,{type:"numeric"}),n=e.getValues(o.POSITION_VARIABLES.xMax,{type:"numeric"}),a=e.size(),i=ur(a);for(let s=0;s<a;s++){const c=r[s],l=n[s];!o.isDefined(c)||!o.isDefined(l)||(i.min[s]=t.map(c),i.max[s]=t.map(l))}return i}function ur(e){return{min:new Array(e).fill(null),max:new Array(e).fill(null)}}var bo=class{map({data:e,layer:t,getPositionScale:r}){const n=o.readVariableName(t.mapping.y),a=r(o.resolveYScaleAesthetic(t.yScaleType));if(!n||!a)return e;const i=e.getValues(n).map(s=>o.isDefined(s)?a.map(s):null);return e.addVariable(o.POSITION_VARIABLES.y,"numeric",i)}},So=class{map({data:e,layer:t,getPositionScale:r}){const n=r(o.resolveYScaleAesthetic(t.yScaleType));if(!n||!e.hasVariable(o.POSITION_VARIABLES.yMin)||!e.hasVariable(o.POSITION_VARIABLES.yMax))return e;const a=n.bandwidth,i=o.isDefined(a)&&e.hasVariable(o.POSITION_VARIABLES.y)?Ao(e,n,a):To(e,n);return e.addVariable(o.POSITION_VARIABLES.yMin,"numeric",i.min).addVariable(o.POSITION_VARIABLES.yMax,"numeric",i.max)}};function Ao(e,t,r){const n=e.getValues(o.POSITION_VARIABLES.y,{type:"numeric"}),a=e.getValues(o.POSITION_VARIABLES.yMin,{type:"numeric"}),i=e.getValues(o.POSITION_VARIABLES.yMax,{type:"numeric"}),s="reverse"in t.spec&&t.spec.reverse===!0,c=e.size(),l=dr(c);for(let u=0;u<c;u++){const d=n[u],m=a[u],p=i[u];!o.isDefined(d)||!o.isDefined(m)||!o.isDefined(p)||(l.min[u]=d+(s?-p:m)*r,l.max[u]=d+(s?-m:p)*r)}return l}function To(e,t){const r=e.getValues(o.POSITION_VARIABLES.yMin,{type:"numeric"}),n=e.getValues(o.POSITION_VARIABLES.yMax,{type:"numeric"}),a=e.size(),i=dr(a);for(let s=0;s<a;s++){const c=r[s],l=n[s];!o.isDefined(c)||!o.isDefined(l)||(i.min[s]=t.map(c),i.max[s]=t.map(l))}return i}function dr(e){return{min:new Array(e).fill(null),max:new Array(e).fill(null)}}var Io=[new go,new bo,new ho,new So,new fo];function Eo(e,t){const r=e[t];return r?.kind==="position"?r:null}var Vo=class extends B{constructor(e,t=Io){super(),this.container=e,this.mappers=t}dependencies(e){return[e.scales.x,e.scales.y,e.scales.ySecondary]}compileLayer(e,t){const r=a=>Eo(t.scales,a);let n=e.data;for(const a of this.mappers)n=a.map({data:n,layer:e,getPositionScale:r,geomRegistry:this.container.geomRegistry});return{...e,data:n}}},xo=class extends o.Stage{constructor(e,t){super(),this.container=e,this.registry=t}dependencies(e){return[e.layers,e.scales,e.colorScheme]}run(e){this.validateScaleTypeCompatibility(e);const t=new Map;for(const i of e.scales)t.set(i.scaledAesthetic,i);const r=this.collectValues(e.layers,t),n={colorScheme:e.colorScheme,hasTouchingGeoms:Ri(e.layers),zeroAxes:$e(e.layers).zeroAxes},a={};for(const[i,s]of t){const c=r.get(i)??[];a[i]=this.registry.get(s.scaleType).compile(s,c,n)}return a}validateScaleTypeCompatibility(e){const t=[];for(const r of e.scales){const{compatibleDataTypes:n}=this.registry.get(r.scaleType),a=o.getAestheticFromScaleAestheticKey(r.scaledAesthetic),i=e.layers.find(l=>o.isDefined(l.mapping[a]));if(!i)continue;const s=o.readVariableName(i.mapping[a]);if(!o.isDefined(s)||!i.data.hasVariable(s)||i.data.size()===0)continue;const c=i.data.getType(s);if(!n.includes(c)){const l=r.scaleType==="continuous"&&c==="temporal"?`Use scale.${r.scaledAesthetic}.datetime() for a time axis or declare the column's valueFormat in data.columns to read it as a number.`:void 0;t.push({code:"INCOMPATIBLE_TYPE",message:`Scale '${r.scaledAesthetic}' (${r.scaleType}) is incompatible with variable '${s}' (${c})`,context:{aesthetic:a,variableName:s,scaleType:r.scaleType,variableType:c},suggestion:l})}if(r.scaledAesthetic==="lineType"&&c!=="categorical"){const l=c==="temporal"?"Bucket the variable into categorical periods (e.g. quarter, year) first.":"Bin the variable into categorical buckets first.";t.push({code:"INCOMPATIBLE_TYPE",message:`Scale 'lineType' is discrete-only and cannot be mapped to ${c} variable '${s}'. ${l}`,context:{aesthetic:a,variableName:s,scaleType:r.scaleType,variableType:c},suggestion:l})}}nr(this.container.diagnostics,t)}collectValues(e,t){const r=new Map;for(const n of e){const a=this.resolveCustomPositionalAxes(n);for(const[i,s]of Object.entries(n.mapping)){if(!o.isDefined(s))continue;const c=i==="y"?o.resolveYScaleAesthetic(n.yScaleType):i,l=a.get(i)??(o.isScaledAestheticKey(c)?c:void 0);if(!o.isDefined(l)||!t.has(l))continue;const u=t.get(l)?.scaleType,d=this.resolveVariables(i,s,n.data,u);this.collectFromVariables(n.data,d,l,r)}}return r}resolveCustomPositionalAxes(e){const t=new Map,r=this.container.geomRegistry.get(e.geom);for(const n of r.positionRoles)n.role!=="scalar"||!o.isDefined(n.aes)||o.isVisualScale(n.aes)||t.set(n.aes,o.resolvePositionScaleAesthetic(n.axis,e.yScaleType));return t}resolveVariables(e,t,r,n){if(e==="y"&&n!=="discrete"&&this.hasPositionAdjustedY(r))return[o.POSITION_VARIABLES.yMin,o.POSITION_VARIABLES.yMax];const a=o.readVariableName(t);return!a||!r.hasVariable(a)?[]:[a]}hasPositionAdjustedY(e){return e.hasVariable(o.POSITION_VARIABLES.yMin)&&e.hasVariable(o.POSITION_VARIABLES.yMax)}collectFromVariables(e,t,r,n){if(t.length===0)return;let a=[];for(const s of t)a=a.concat(e.getValues(s));const i=n.get(r);n.set(r,i?i.concat(a):a)}},Oo=["rgb","lab","hcl","hsl"],wo=["viridis","magma","inferno","plasma","cividis","turbo","Blues","Greens","Greys","Oranges","Purples","Reds"],mr=["RdBu","BrBG","PuOr","Spectral"],pr={"red-blue":"RdBu","brown-teal":"BrBG","purple-orange":"PuOr",spectral:"Spectral"},Lo=new Set(mr.map(e=>e.toLowerCase()));function fr(e){const t=e.toLowerCase(),r=pr[t];return r?r.toLowerCase():t}function Co(e){return Lo.has(fr(e))}var _o={rgb:Y.interpolateRgb,lab:Y.interpolateLab,hcl:Y.interpolateHcl,hsl:Y.interpolateHsl},Po={viridis:A.interpolateViridis,magma:A.interpolateMagma,inferno:A.interpolateInferno,plasma:A.interpolatePlasma,cividis:A.interpolateCividis,turbo:A.interpolateTurbo,blues:A.interpolateBlues,greens:A.interpolateGreens,greys:A.interpolateGreys,oranges:A.interpolateOranges,purples:A.interpolatePurples,reds:A.interpolateReds,rdbu:A.interpolateRdBu,brbg:A.interpolateBrBG,puor:A.interpolatePuOr,spectral:A.interpolateSpectral};function Ue(e){const t=No(e);return e.reverse?r=>t(1-r):t}function Do(e={},t=2){const r=Ue({range:e.range??null,scheme:e.scheme??null,interpolate:e.interpolate??o.CONTINUOUS_SCALE_DEFAULTS.interpolate,reverse:e.reverse??!1});return t<2?t===1?[r(0)]:[]:Array.from({length:t},(n,a)=>r(a/(t-1)))}function No(e){const t=_o[e.interpolate];if(e.range&&e.range.length>=2)return(0,Y.piecewise)(t,e.range.map(r=>String(r)));if(e.scheme){const r=Po[fr(e.scheme)];if(r)return r}return(0,Y.piecewise)(t,[...o.DEFAULT_SEQUENTIAL_RAMP])}var ee=class{createPositionScale(e,t){return{kind:"position",aesthetic:o.getAestheticFromScaleAestheticKey(e.scaledAesthetic),spec:e,...t}}createVisualScale(e,t){return{kind:"visual",aesthetic:o.getAestheticFromScaleAestheticKey(e.scaledAesthetic),spec:e,...t}}},Ie=(e,t,r)=>{const[n,a]=e;return t===0&&r===null&&a<=0?{domain:[n,0],pinnedLow:!1,pinnedHigh:!0}:r===0&&t===null&&n>=0?{domain:[0,a],pinnedLow:!0,pinnedHigh:!1}:{domain:[t??n,r??a],pinnedLow:t!==null,pinnedHigh:r!==null}};function Ro(e){const[t,r]=e.domain;return t>0?{...e,domain:[0,r],pinnedLow:!0}:r<0?{...e,domain:[t,0],pinnedHigh:!0}:e}function Ee(e,t){return[t.pinnedLow?t.domain[0]:e[0],t.pinnedHigh?t.domain[1]:e[1]]}var Mo=class extends ee{constructor(e){super(),this.container=e,this.compatibleDataTypes=["numeric"]}compile(e,t,r){if(e.scaleType!=="continuous")throw new o.InternalError({message:"ContinuousScale.compile received non-continuous spec"});const n=o.isPositionScale(e.scaledAesthetic),a=e.scaledAesthetic==="color",i=this.computeDataDomain(t);return a?this.buildColorScale(i,e):n?this.buildPositionScale(i,e,r.zeroAxes[e.scaledAesthetic]!==void 0):this.buildVisualScale(i,e)}computeDataDomain(e){let t=1/0,r=-1/0;for(const n of e)typeof n!="number"||!Number.isFinite(n)||(n<t&&(t=n),n>r&&(r=n));return t===1/0?[0,0]:[t,r]}createD3Scale(e,t,r,n=!1){const a=Ie(e,r.domainMin,r.domainMax),i=n?Ro(a):a;let s=i.domain;n&&ko(a,i)&&this.warnIncompatibleDomain(r,a.domain,`'${r.scaledAesthetic}' holds zero for the geom drawn on it, so the pin at [${a.domain[0]}, ${a.domain[1]}] gives way to [${s[0]}, ${s[1]}].`,`Pin '${r.scaledAesthetic}' at or past zero, or drop the pin.`);const c=r.transform==="log"&&Bo(s);r.transform==="log"&&!c&&this.warnIncompatibleDomain(r,s,`Log scale on '${r.scaledAesthetic}' needs a strictly positive or negative domain, but the domain is [${s[0]}, ${s[1]}] — rendering a linear scale instead.`,n?`'${r.scaledAesthetic}' holds zero for the geom drawn on it; use a linear or sqrt transform.`:"Filter out non-positive values or set a positive domainMin so the log scale can apply.");const l=c?(0,w.scaleLog)():r.transform==="sqrt"?(0,w.scaleSqrt)():(0,w.scaleLinear)();return r.nice&&!c&&(s=Ee(l.copy().domain(s).nice().domain(),i)),l.domain(s).range(t).clamp(r.clamp)}warnIncompatibleDomain(e,t,r,n){this.container.diagnostics.addWarning({code:"INCOMPATIBLE_SCALE_DOMAIN",message:r,context:{aesthetic:o.getAestheticFromScaleAestheticKey(e.scaledAesthetic),scaleType:e.scaleType,actual:t},suggestion:n})}buildPositionScale(e,t,r){const n=t.reverse?[1,0]:[0,1],a=this.createD3Scale(e,n,t,r);return this.createPositionScale(t,{map:a,domain:a.domain(),bandwidth:null,generateTicks:i=>i&&"count"in i?a.ticks(i.count):a.ticks()})}buildVisualScale(e,t){const r=$o(t.range)??[0,1],n=t.reverse?[r[1],r[0]]:r,a=this.createD3Scale(e,n,t);return this.createVisualScale(t,{map:a,domain:a.domain(),generateTicks:i=>i&&"count"in i?a.ticks(i.count):a.ticks()})}buildColorScale(e,t){const r=Ue(t),n=t.domainMid;if(n!==null){const a=this.resolveColorDomain(e,t),[i,s]=a.domain;if(n>i&&n<s){const[c,l]=this.symmetrizeDomain(a,t,n);return this.buildDivergingColorScale([c,n,l],t,r)}}return this.buildSequentialColorScale(e,t,r)}buildSequentialColorScale(e,t,r){const n=this.createD3Scale(e,[0,1],t),a=i=>typeof i!="number"||!Number.isFinite(i)?null:r(n(i));return this.createVisualScale(t,{map:a,domain:n.domain(),generateTicks:i=>i&&"count"in i?n.ticks(i.count):n.ticks()})}buildDivergingColorScale(e,t,r){const n=(0,w.scaleLinear)().domain(e).range([0,.5,1]).clamp(t.clamp),a=i=>typeof i!="number"||!Number.isFinite(i)?null:r(n(i));return this.createVisualScale(t,{map:a,domain:e,generateTicks:i=>i&&"count"in i?n.ticks(i.count):n.ticks()})}resolveColorDomain(e,t){const r=Ie(e,t.domainMin,t.domainMax);if(!t.nice)return r;const n=(0,w.scaleLinear)().domain(r.domain).nice().domain();return{...r,domain:Ee(n,r)}}symmetrizeDomain(e,t,r){const{domain:n,pinnedLow:a,pinnedHigh:i}=e;if(!t.symmetric)return n;const s=Math.max(Math.abs(n[0]-r),Math.abs(n[1]-r));return[a?n[0]:r-s,i?n[1]:r+s]}},ko=(e,t)=>e.pinnedLow&&e.domain[0]!==t.domain[0]||e.pinnedHigh&&e.domain[1]!==t.domain[1],Bo=e=>{const[t,r]=e;return t>0&&r>0||t<0&&r<0};function $o(e){if(!e)return null;const[t,r]=e;return typeof t=="number"&&typeof r=="number"?[t,r]:null}var Uo=class extends ee{constructor(...e){super(...e),this.compatibleDataTypes=["temporal"]}compile(e,t){if(e.scaleType!=="datetime")throw new o.InternalError({message:"DatetimeScale.compile received non-datetime spec"});const r=o.isPositionScale(e.scaledAesthetic),n=this.computeDataDomain(t);if(!r)throw new o.UserInputError({code:"INCOMPATIBLE_TYPE",message:"Datetime scale is not supported for non-position aesthetics",context:{aesthetic:e.scaledAesthetic},suggestion:"Use a continuous or discrete scale for non-position aesthetics (color, size, alpha, strokeWidth)."});return this.buildScale(n,e,this.collectInputDates(t))}collectInputDates(e){const t=new Set,r=[];for(const n of e){if(!(n instanceof Date))continue;const a=n.getTime();t.has(a)||(t.add(a),r.push(n))}return r.sort((n,a)=>n.getTime()-a.getTime()),r}computeDataDomain(e){let t=1/0,r=-1/0;for(const n of e){if(!(n instanceof Date))continue;const a=n.getTime();a<t&&(t=a),a>r&&(r=a)}return t===1/0?[]:[new Date(t),new Date(r)]}createD3Scale(e,t,r){const n=(0,w.scaleUtc)().range(t).clamp(r.clamp);if(!Fo(e))return n.domain([]);const a=Ie([e[0].getTime(),e[1].getTime()],r.domainMin,r.domainMax);if(n.domain(a.domain),r.nice){const[i,s]=n.nice().domain();i!==void 0&&s!==void 0&&n.domain(Ee([i.getTime(),s.getTime()],a))}return n}buildScale(e,t,r){const n=t.reverse?[1,0]:[0,1],a=this.createD3Scale(e,n,t),[i,s]=a.domain(),c=i&&s?r.filter(l=>l>=i&&l<=s):[];return this.createPositionScale(t,{map:a,domain:a.domain(),bandwidth:null,generateTicks:l=>l&&"atInputs"in l?c:l&&"interval"in l?i&&s?ba(i,s,l.interval):[]:a.ticks(l?.count)})}},Fo=e=>e.length===2&&o.isStrictTemporalDataValue(e[0])&&o.isStrictTemporalDataValue(e[1]),jo=class extends ee{constructor(...e){super(...e),this.compatibleDataTypes=["categorical","numeric","temporal"]}compile(e,t){if(e.scaleType!=="discrete")throw new o.InternalError({message:"DiscreteScale.compile received non-discrete spec"});const r=o.isPositionScale(e.scaledAesthetic),n=Ft(t,e);return r?this.buildPositionScale(n,e):this.buildVisualScale(n,e)}buildPositionScale(e,t){const r=e.map(String),n=t.padding??o.DISCRETE_SCALE_DEFAULTS.padding,a=t.reverse?[1,0]:[0,1],i=(0,w.scaleBand)().domain(r).range(a).paddingInner(n).paddingOuter(n/2),s=i.bandwidth()/2;return this.createPositionScale(t,{map:c=>(i(String(c))??NaN)+s,domain:e,bandwidth:i.bandwidth(),generateTicks:()=>[...e]})}buildVisualScale(e,t){const r=e.map(String),n=t.range&&t.range.length>0?(0,w.scaleOrdinal)().domain(r).range(t.range).unknown(t.range[0]):null;return this.createVisualScale(t,{map:a=>{const i=String(a);return n?n(i):i},domain:e,generateTicks:()=>e})}},Go=class extends ee{constructor(...e){super(...e),this.compatibleDataTypes=["numeric","categorical","temporal"]}compile(e){if(e.scaleType!=="identity")throw new o.InternalError({message:"IdentityScale.compile received non-identity spec"});return{kind:"identity",aesthetic:o.getAestheticFromScaleAestheticKey(e.scaledAesthetic),spec:e,map:t=>t,domain:[],generateTicks:()=>[]}}},Ko=class extends ee{constructor(...e){super(...e),this.compatibleDataTypes=["categorical","temporal","numeric"]}compile(e,t,r){if(e.scaleType!=="palette")throw new o.InternalError({message:"PaletteScale.compile received non-palette spec"});const n=Ut(t),a=o.resolvePaletteRange(e.palette,{groupCount:n.length,...r}),i=o.applyOverrides(a.length>0?a:[...o.DEFAULT_COLOR_PALETTE],e.overrides),s=(0,w.scaleOrdinal)().domain(n.map(String)).range(i).unknown(i[0]);return this.createVisualScale(e,{map:c=>s(String(c)),domain:n,generateTicks:()=>n})}},Yo=class extends o.Registry{constructor(e){super("scale"),this.register("continuous",new Mo(e)),this.register("discrete",new jo),this.register("datetime",new Uo),this.register("identity",new Go),this.register("palette",new Ko)}},gr={x:"position",y:"position",ySecondary:"position",color:"color-range",size:"continuous-range",alpha:"continuous-range",strokeWidth:"continuous-range",lineType:"discrete-only"},zo={numeric:{position:"continuous","color-range":"continuous","continuous-range":"continuous","discrete-only":"discrete"},categorical:{position:"discrete","color-range":"palette","continuous-range":"discrete","discrete-only":"discrete"},temporal:{position:"datetime","color-range":"continuous","continuous-range":"continuous","discrete-only":"discrete"}};function Fe(e,t){const{data:r,layers:n,mapping:a,customPalettes:i}=t;return{container:e,data:r,layers:n,mapping:a,customPalettes:i,demands:$e(Be(e.geomRegistry,n))}}function pe(e,t){switch(t.scaleType){case"inferred":return{...pe(e,Xo(e,t)),inferredFrom:t};case"continuous":{const r=gr[t.scaledAesthetic],n=r==="continuous-range"&&t.scaledAesthetic in o.NON_POSITION_RANGE_DEFAULTS?o.NON_POSITION_RANGE_DEFAULTS[t.scaledAesthetic]:null,a=t.scaledAesthetic==="size"&&r==="continuous-range"?"sqrt":o.CONTINUOUS_SCALE_DEFAULTS.transform;return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,transform:t.transform??a,reverse:t.reverse??o.CONTINUOUS_SCALE_DEFAULTS.reverse,nice:t.nice??o.CONTINUOUS_SCALE_DEFAULTS.nice,clamp:t.clamp??r!=="position",domainMin:t.domainMin??o.CONTINUOUS_SCALE_DEFAULTS.domainMin,domainMax:t.domainMax??o.CONTINUOUS_SCALE_DEFAULTS.domainMax,range:t.range??n??null,scheme:Jo(e.container,t),interpolate:t.interpolate??o.CONTINUOUS_SCALE_DEFAULTS.interpolate,domainMid:t.domainMid??o.CONTINUOUS_SCALE_DEFAULTS.domainMid,symmetric:t.symmetric??o.isDefined(t.domainMid)}}case"datetime":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,domainMin:t.domainMin??o.DATETIME_SCALE_DEFAULTS.domainMin,domainMax:t.domainMax??o.DATETIME_SCALE_DEFAULTS.domainMax,nice:t.nice??o.DATETIME_SCALE_DEFAULTS.nice,reverse:t.reverse??o.DATETIME_SCALE_DEFAULTS.reverse,clamp:t.clamp??!1};case"discrete":return hr(t,e.demands);case"palette":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,palette:o.resolvePaletteConfig(e.container,t.palette,e.customPalettes),overrides:o.resolvePaletteOverrides(e.container,t.overrides,t.palette,e.customPalettes)};case"identity":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType};default:throw new o.InternalError({message:`Unknown scale type: ${t.scaleType}`})}}function Wo(e,t){const{scales:r,layers:n,coords:a}=t,i=Fe(e,t),s=es(Zo(r,n),i.demands),c=new Map;for(const u of s)c.set(u.scaledAesthetic,u);const l=[...c.values()].map(u=>{const d=qo(i,u);return pe(i,d)});return a.coordType==="polar"?l.map(je):l}function hr(e,t){const r=t?.bandPadding[e.scaledAesthetic];return{type:e.type,scaledAesthetic:e.scaledAesthetic,scaleType:e.scaleType,range:e.range??o.DISCRETE_SCALE_DEFAULTS.range,domain:e.domain??o.DISCRETE_SCALE_DEFAULTS.domain,padding:e.padding??r??o.DISCRETE_SCALE_DEFAULTS.padding,reverse:e.reverse??Ho(e.scaledAesthetic,t)}}var je=e=>e.scaleType==="discrete"?{...e,padding:0}:e;function qo(e,t){return t.scaleType==="inferred"||t.scaleType==="discrete"||!e.demands.bandedAxes.includes(t.scaledAesthetic)?t:(e.container.diagnostics.addWarning({code:"UNSUPPORTED_SCALE_TYPE",message:`A geom drawn on '${t.scaledAesthetic}' needs it to be a band scale, but the spec declares a '${t.scaleType}' one; the band wins.`,context:{aesthetic:o.getAestheticFromScaleAestheticKey(t.scaledAesthetic),scaleType:t.scaleType},suggestion:`Declare '${t.scaledAesthetic}' as a discrete scale, or omit it and let the geom's band be inferred.`}),o.discrete(t.scaledAesthetic,{..."reverse"in t&&t.reverse!==void 0&&{reverse:t.reverse}}))}function Ho(e,t){return e===t?.discreteCrossAxis?!0:o.DISCRETE_SCALE_DEFAULTS.reverse}function Xo({data:e,layers:t,mapping:r,demands:n},a){const i=o.getAestheticFromScaleAestheticKey(a.scaledAesthetic),s=a.scaledAesthetic==="ySecondary"?Qo(t,r):r[i];if(a.scaledAesthetic===n.discreteAxis||a.scaledAesthetic===n.discreteCrossAxis)return o.discrete(a.scaledAesthetic,a.options);const c=n.zeroAxes[a.scaledAesthetic];if(c!==void 0){const m=a.options;return o.continuous(a.scaledAesthetic,{...m,...!c.nice&&{nice:!1}})}const l=o.readVariableName(s);if(!o.isDefined(l)||!e.hasVariable(l)||e.size()===0)return o.continuous(a.scaledAesthetic,a.options);const u=e.getType(l),d=gr[a.scaledAesthetic];switch(zo[u][d]){case"discrete":return o.discrete(a.scaledAesthetic,a.options);case"palette":return o.palette(a.scaledAesthetic);case"datetime":return o.datetime(a.scaledAesthetic,a.options);case"continuous":return o.continuous(a.scaledAesthetic,a.options);default:return o.identity(a.scaledAesthetic)}}function Jo(e,t){const r=t.scheme??o.CONTINUOUS_SCALE_DEFAULTS.scheme;return r===null?null:o.isDefined(t.range)?(e.diagnostics.addWarning({code:"CONFLICTING_COLOR_RAMP",message:`The color scale sets both a 'scheme' ('${r}') and an explicit 'range'; the range wins and the scheme is ignored.`,context:{aesthetic:o.getAestheticFromScaleAestheticKey(t.scaledAesthetic),scaleType:t.scaleType},suggestion:"Set either a scheme or a range, not both."}),null):(!o.isDefined(t.domainMid)&&Co(r)&&e.diagnostics.addWarning({code:"DIVERGING_SCHEME_WITHOUT_MIDPOINT",message:`The color scale uses a diverging scheme ('${r}') without 'domainMid', so its neutral colour lands at the data midpoint rather than a meaningful centre.`,context:{aesthetic:o.getAestheticFromScaleAestheticKey(t.scaledAesthetic),scaleType:t.scaleType,actual:r},suggestion:"Set 'domainMid' (e.g. 0) to centre the neutral colour."}),r)}function Qo(e,t){const r=e.find(n=>n.yScaleType==="secondary");return r?r.mapping.y??t.y:t.y}function Zo(e,t){return!t.some(r=>r.yScaleType==="secondary")||e.some(r=>r.scaledAesthetic==="ySecondary")?e:[...e,o.inferred("ySecondary")]}function es(e,t){return e.some(r=>r.scaledAesthetic==="color")?e:[...e,t.inferredColor?o.inferred("color"):o.palette("color")]}var ct=0;function I(){return ct+=1,`${Math.random().toString(36).slice(2,6)}${ct.toString(36)}`}var ts={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0},"top-left":{x:-1,y:-1},"top-right":{x:1,y:-1},"bottom-left":{x:-1,y:1},"bottom-right":{x:1,y:1}},rs=(e,t,r)=>{const n=ns(e,t),a=os(n);return{differenceArrows:(n.differenceArrows??[]).map(i=>cs(e,i,r)).filter(o.isDefined),shapes:(n.shapes??[]).map(i=>ms(e,i,a)).filter(o.isDefined),arrows:(n.arrows??[]).map(i=>gs(e,i,r,a)).filter(o.isDefined),textAnnotations:(n.textAnnotations??[]).map(i=>ss(e,i,r,a)).filter(o.isDefined),stickers:(n.stickers??[]).map(i=>ls(e,i,r,a)).filter(o.isDefined),images:(n.images??[]).map(i=>ps(e,i,a)).filter(o.isDefined),pinnedNumbers:(n.pinnedNumbers??[]).map(i=>us(e,i,r)).filter(o.isDefined),comments:(n.comments??[]).map(i=>ds(e,i,r)).filter(o.isDefined)}},ns=(e,t)=>{if(t===void 0)return{};if(!as(t))return t;const r=new Set,n=a=>a.id===void 0?a:r.has(a.id)?(e.diagnostics.addWarning({code:"ANNOTATION_DUPLICATE_ID",message:`More than one annotation declares id "${a.id}" — giving this one a generated id, so references to "${a.id}" point at the first.`,context:{annotationId:a.id},suggestion:"Give each annotation its own id."}),{...a,id:I()}):(r.add(a.id),a);return{differenceArrows:t.differenceArrows?.map(a=>n(a)),shapes:t.shapes?.map(a=>n(a)),arrows:t.arrows?.map(a=>n(a)),textAnnotations:t.textAnnotations?.map(a=>n(a)),images:t.images?.map(a=>n(a)),stickers:t.stickers?.map(a=>n(a)),pinnedNumbers:t.pinnedNumbers?.map(a=>n(a)),comments:t.comments?.map(a=>n(a))}},as=e=>{const t=new Set;for(const r of is(e))if(r.id!==void 0){if(t.has(r.id))return!0;t.add(r.id)}return!1},is=e=>[...e.differenceArrows??[],...e.shapes??[],...e.arrows??[],...e.textAnnotations??[],...e.images??[],...e.stickers??[],...e.pinnedNumbers??[],...e.comments??[]],os=e=>{const t=new Set,r=[e.differenceArrows,e.shapes,e.arrows,e.textAnnotations,e.images,e.stickers,e.pinnedNumbers,e.comments];for(const n of r)for(const a of n??[])a.id!==void 0&&t.add(a.id);return t},Ge=(e,t,r,n)=>{if(r.has(t))return!0;const a=n===void 0?"An annotation":`Annotation "${n}"`;return e.diagnostics.addWarning({code:"ANNOTATION_REF_NOT_FOUND",message:`${a} references id "${t}" but no annotation declares that id — dropping this annotation.`,context:{ref:t,...n!==void 0?{annotationId:n}:{}},suggestion:"Reference the explicit id of another annotation in the same spec, or set an id on the target."}),!1},ss=(e,t,r,n)=>{const a=oe(e,t.at,r,n,t.id);return a===null?null:{id:t.id??I(),content:t.content,at:a,width:t.width,align:t.align??o.TEXT_ANNOTATION_DEFAULTS.align}},cs=(e,t,r)=>{const n=J(e,t.start,r),a=J(e,t.end,r);return n===null||a===null?null:{id:t.id??I(),start:n,end:a,label:t.label,labelCrossPosition:t.labelCrossPosition??o.DIFFERENCE_ARROW_DEFAULTS.labelCrossPosition}},J=(e,t,r)=>{const n=t.align!==void 0?{align:t.align}:{};return t.layerId===void 0?{anchorValue:t.anchorValue,groupValue:t.groupValue,crossValue:t.crossValue,...n}:r.some(a=>a.id===t.layerId)?{layerId:t.layerId,anchorValue:t.anchorValue,groupValue:t.groupValue,crossValue:t.crossValue,...n}:(e.diagnostics.addWarning({code:"UNKNOWN_LAYER_ID",message:`Annotation references layerId "${t.layerId}", which no layer carries — dropping this annotation.`,context:{layerId:t.layerId,available:r.map(a=>a.id)},suggestion:"Reference an existing layer id, or omit layerId to anchor against the data directly."}),null)},oe=(e,t,r,n,a)=>{if(t.anchorType==="annotation")return Ge(e,t.ref,n,a)?t:null;if(t.anchorType==="panel"||t.anchorType==="axis"||t.anchorType==="selection")return t;const i=J(e,t,r);return i===null?null:{anchorType:"observation",...i,...t.offset!==void 0?{offset:t.offset}:{}}},ls=(e,t,r,n)=>{const a=oe(e,t.at,r,n,t.id);return a===null?null:{id:t.id??I(),at:a,sticker:t.sticker}},us=(e,t,r)=>{const n=J(e,t.at,r);return n===null?null:{id:t.id??I(),at:n}},ds=(e,t,r)=>{const n=J(e,t.at,r);return n===null?null:{id:t.id??I(),at:n,content:t.content}},ms=(e,t,r)=>t.region.anchorType==="annotation"&&!Ge(e,t.region.ref,r,t.id)?null:{id:t.id??I(),kind:t.kind??o.SHAPE_DEFAULTS.kind,zOrder:t.zOrder??o.SHAPE_DEFAULTS.zOrder,region:fs(t.region)},ps=(e,t,r)=>t.region.anchorType==="annotation"&&!Ge(e,t.region.ref,r,t.id)?null:{id:t.id??I(),src:t.src,zOrder:t.zOrder??o.IMAGE_ANNOTATION_DEFAULTS.zOrder,region:t.region,fit:t.fit??o.IMAGE_ANNOTATION_DEFAULTS.fit},fs=e=>e.anchorType!=="selection"||e.padding!==void 0?e:{...e,padding:o.SELECTION_PADDING_DEFAULT},lt=e=>{if(e.anchorType==="panel"||e.anchorType==="axis"||e.offset!==void 0||e.align===void 0)return e;const t=ts[e.align];return t===void 0?e:{...e,offset:{x:t.x*4,y:t.y*4,unit:"px"}}},gs=(e,t,r,n)=>{const a=oe(e,t.start,r,n,t.id),i=oe(e,t.end,r,n,t.id);return a===null||i===null?null:{id:t.id??I(),start:lt(a),end:lt(i),startArrowheadStyle:t.startArrowheadStyle??o.ARROW_DEFAULTS.startArrowheadStyle,endArrowheadStyle:t.endArrowheadStyle??o.ARROW_DEFAULTS.endArrowheadStyle}},hs={parsingLocale:"en-US",legend:{position:"auto",display:"auto",align:"auto"},axes:{x:{isVisible:!0,label:null,position:"bottom",grid:{isVisible:null},ticks:{isVisible:!0,mode:"auto"}},y:{isVisible:!0,label:null,position:"right",grid:{isVisible:null},ticks:{isVisible:!1,mode:"auto"}}},panel:{overflow:{dataLabels:{x:"inside",y:"inside"},differenceArrows:{x:"outside",y:"outside"}}},headline:{show:"none",compareWith:"none",size:"auto",position:"above"},numberFormat:{decimals:"auto",abbreviation:"auto"},content:{title:null,isTitleVisible:!0,subtitle:null,isSubtitleVisible:!0,caption:null,isCaptionVisible:!1,source:null,isSourceVisible:!1,brandMark:{enabled:!1,placement:"footer",variant:"full"},isBrandMarkVisible:!1}};function ys(e){const t=(0,se.merge)({},hs,e);return t.content=vs(t.content,e?.content),t}var vs=(e,t)=>{const r=t?.brandMark?.enabled??t?.isBrandMarkVisible??e.brandMark.enabled,n={...e.brandMark,enabled:r};return{...e,brandMark:n,isBrandMarkVisible:r}},bs={xLimits:null,yLimits:null},ae={theta:"x",startAngle:0,innerRadius:0};function yr(e){const t=e??{type:"coord",coordType:"cartesian"},r=(0,ye.default)({},bs,t.params??{});switch(t.coordType){case"cartesian":case"flip":return{...t,params:r};case"polar":return{...t,params:{...r,theta:t.params?.theta??ae.theta,startAngle:t.params?.startAngle??ae.startAngle,innerRadius:(0,he.default)(t.params?.innerRadius??ae.innerRadius,0,1)}}}}function Ss(e,t,r){const n=[];for(const a of t){if(a.layerId!==void 0&&!r.some(i=>i.id===a.layerId)){e.diagnostics.addWarning({code:"UNKNOWN_LAYER_ID",message:`Highlight references layerId "${a.layerId}", which no layer carries — dropping this highlight.`,context:{layerId:a.layerId,available:r.map(i=>i.id)},suggestion:"Reference an existing layer id, or omit layerId to apply the highlight across all layers."});continue}n.push({type:"highlight",id:a.id??I(),predicate:a.predicate,scope:a.scope??"data-point",...a.layerId!==void 0?{layerId:a.layerId}:{}})}return n}var As=class{constructor(){this.diagnostics=[],this.persistent=[]}addWarning(e,t={}){const r={...e,severity:"warning",kind:"user-input"};t.persistent?this.persistent.push(r):this.diagnostics.push(r)}addError(e){this.diagnostics.push({...e,severity:"error",kind:"user-input"})}reset(){this.diagnostics=[]}drain(){const e=this.persistent.length===0?this.diagnostics:[...this.persistent,...this.diagnostics];if(e.length===0)return{errors:[],warnings:[]};const t=ut(e.filter(n=>n.severity==="error")),r=ut(e.filter(n=>n.severity==="warning"));return this.diagnostics=[],{errors:t,warnings:r}}},Ts=class{constructor(e,t){this.sink=e,this.baseContext=t}addWarning(e,t){this.sink.addWarning(this.stampBaseContext(e),t)}addError(e){this.sink.addError(this.stampBaseContext(e))}stampBaseContext(e){const t=e.context??{};return{...e,context:{...t,...this.baseContext}}}};function ut(e){const t=new Set;return e.filter(r=>{const n=JSON.stringify(r);return t.has(n)?!1:(t.add(n),!0)})}var vr={showDataLabels:!1,format:"absolute",showStackTotals:!1,showCategoryLabels:!1,labelSource:{variable:o.POSITION_VARIABLES.yRaw},position:"auto",justify:"end",align:"center",offset:4,categoryPosition:"inside",categoryJustify:"start",categoryAlign:"center",categoryOffset:4},Is={stat:{type:"identity"},position:"identity",params:{}},Es={stat:{type:"identity"},position:"identity",params:{curve:"linear",missingValues:"gap"}},Vs={stat:{type:"identity"},position:"stack",params:{curve:"linear",missingValues:"zero"}},xs={stat:{type:"identity"},position:"dodge",params:{}},Os={stat:{type:"identity"},position:"identity",interactive:!1,params:{labelPosition:"start"}},ws={stat:{type:"identity"},position:"identity",params:{}};function br(e,t){const r=e??t,n=typeof r=="string"?r:r.type;if(n==="smooth"){const a=typeof r=="string"?void 0:r;return{type:"smooth",method:a?.method??"linear",order:a?.order??3,bandwidth:a?.bandwidth??.3}}return{type:n}}function Sr(e,t,r,n,a,i){const s=a!==void 0&&i!==void 0?new Ts(a,{layerIndex:i}):a,c=e.get(n.geom),l=n.position??c.defaultPosition,u=_s({dataLabels:Ds(e,t,n,l,r),geom:c,position:l,coordType:r,diagnostics:s});return Cs({diagnostics:s,coordType:r,geom:c,position:l,dataLabels:u}),{id:n.id??I(),type:n.type,geom:n.geom,mapping:n.mapping??{},stat:br(n.stat,"identity"),position:l,yScaleType:n.yScaleType??"primary",params:c.resolveParams({params:n.params,diagnostics:s}),transforms:n.transforms??[],interactive:n.interactive??c.defaultInteractive,dataLabels:u}}function Ls(e,t,r,n,a){const i=n.map((s,c)=>Sr(e,t,r,s,a,c));return Tr(e,i)}var Ar=(e,t,r,n)=>n.label!==void 0?n.label:Lt({geom:e.get(t),position:r,mapping:n,purpose:"label"}),Tr=(e,t)=>{const r=new Set;for(const n of t)n.position==="fill"&&r.add(n.yScaleType);return r.size===0?t:_e(t,n=>{if(!r.has(n.yScaleType)||!e.has(n.geom)||!e.get(n.geom).positionRoles.some(s=>s.axis==="y"&&s.role==="scalar"))return n;const a=o.readConstantValue(n.mapping.y);if(!o.isStrictNumericDataValue(a))return n;const i=(0,se.clamp)(a,0,1);return i===a?n:{...n,mapping:{...n.mapping,y:{value:i}}}})},Cs=({diagnostics:e,coordType:t,geom:r,position:n,dataLabels:a})=>{if(e===void 0)return;const i=r.type==="bar"&&t!=="polar";if(a.showDataLabels&&!r.dataLabelCoordTypes.includes(t)){e.addWarning({code:"DATA_LABELS_UNSUPPORTED",message:`Data labels are not supported for geom '${r.type}' under '${t}' coords; none will render.`,suggestion:"Turn off showDataLabels for this layer."});return}a.showDataLabels&&a.position==="outside"&&i&&o.isStackedPosition(n)&&e.addWarning({code:"DATA_LABEL_PLACEMENT_COERCED",message:"Stacked bar segments only place data labels inside; position 'outside' will render as 'inside'.",context:{expected:"inside",actual:"outside"},suggestion:"Use position 'inside' or 'auto', or enable showStackTotals for a label above the stack."}),a.showStackTotals&&!(i&&n==="stack")&&e.addWarning({code:"DATA_LABEL_SETTING_IGNORED",message:"showStackTotals only applies to stacked cartesian bars; it will be ignored.",suggestion:"Turn off showStackTotals, or use a bar geom with position 'stack'."})},_s=({dataLabels:e,geom:t,position:r,coordType:n,diagnostics:a})=>{const{justify:i,showDataLabels:s}=e;if(i!=="panel-start"&&i!=="panel-end")return e;const c=Ps(t,r,n);if(c===null)return e;const l=i==="panel-end"?"end":"start";return s&&a?.addWarning({code:"DATA_LABEL_PLACEMENT_COERCED",message:`${c}; justify '${i}' will render as '${l}'.`,context:{expected:l,actual:i},suggestion:`Use justify '${l}' for this layer.`}),{...e,justify:l}},Ps=(e,t,r)=>r==="polar"?"Panel-edge anchors do not apply under polar coords":e.type==="bar"&&o.isStackedPosition(t)?"Stacked bar segments would all pin their labels to the same panel edge":null,Ds=(e,t,r,n,a)=>{const i={...t,...r.mapping},s=Ar(e,r.geom,n,i),c=e.get(r.geom);return{...(0,se.merge)({},vr,c.resolveDataLabelDefaults?.(n)??{},c.dataLabels?.[a]??{},r.dataLabels??{}),labelSource:s}},Ns=e=>{const t={tokens:{},defaults:[],overrides:[]};for(const r of Rs(e))Object.assign(t.tokens,r.tokens),t.defaults.push(...r.defaults??[]),t.overrides.push(...r.overrides??[]);return t},Rs=e=>{const t=[],r=new Set,n=e===void 0?[]:[e];for(;n.length>0;){const a=n.pop();if(!(a===void 0||r.has(a))){r.add(a),t.push(a);for(const i of a.extends??[])n.push(i)}}return t.reverse()};function Ms(e,t,r){const n=yr(t.coords),a=Ls(e.geomRegistry,t.mapping,n.coordType,t.layers,e.diagnostics),i=Wo(e,{data:t.data,scales:t.scales,layers:a,mapping:t.mapping,coords:n,customPalettes:r}),s=ys(t.config),c=Ss(e,t.highlights,a),l=rs(e,t.annotations,a),u=Ns(t.styles);return{data:t.data,mapping:t.mapping,layers:a,scales:i,transforms:t.transforms,highlights:c,styles:u,annotations:l,coords:n,config:s}}var Ir=class{constructor(e){this.container=e}compile({spec:e,dataset:t,customPalettes:r}){return Ms(this.container,{...e,data:t},r)}},ks=()=>{let e={},t=null;return{reset:()=>{e={}},getDuration:r=>e[r]??0,wrap:(r,n)=>a=>{const i=t,s={childrenMs:0};t=s;const c=performance.now();try{return n(a)}finally{const l=performance.now()-c;e[r]=(e[r]??0)+l-s.childrenMs,i&&(i.childrenMs+=l),t=i}}}},Bs=class{constructor(e){this.registry=e}compute(e,t){return this.registry.get(e.type).compute({data:t.data,mapping:t.mapping,spec:e,xScaleIsDiscrete:t.xScaleIsDiscrete})}},Er=Object.keys(o.ANNOTATION_BUCKETS),$s=e=>Object.hasOwn(o.ANNOTATION_BUCKETS,e),Us=(e,t)=>{for(const r of Er){const n=js(e,r,t);if(n)return n}return null},Ke=(e,t)=>e[o.ANNOTATION_BUCKETS[t]],Vr=(e,t,r)=>({...e,[o.ANNOTATION_BUCKETS[t]]:r}),Fs=(e,t)=>{const r=Ke(e,t.kind);return Vr(e,t.kind,[...r.slice(0,t.index),...r.slice(t.index+1)])},js=(e,t,r)=>{const n=Ke(e,t),a=n.findIndex(s=>s.id===r),i=n[a];return i===void 0?null:{kind:t,index:a,annotation:i}},dt=Object.freeze({light:"#898373",dark:"#9F9886"}),Gs={graphBackground:o.DEFAULT_GRAPH_BACKGROUND,graphBorder:Object.freeze({light:"rgba(58, 56, 51, 0.15)",dark:"rgba(237, 231, 218, 0.15)"}),geom:o.DEFAULT_GEOM_COLOR,geomBorder:Object.freeze({light:"rgba(58, 56, 51, 0.55)",dark:"rgba(237, 231, 218, 0.55)"}),textPrimary:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),textSecondary:dt,ruleLine:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),gridLine:Object.freeze({light:"#E1DAC9",dark:"#373531"}),hoverAffordance:o.DEFAULT_HOVER_AFFORDANCE_COLOR,hoverGuideFill:Object.freeze({light:"#E7E1D2",dark:"#2B2A27"}),hoverGuideLine:Object.freeze({light:"#D5CDBA",dark:"#3B3934"}),editOutlineHover:Object.freeze({light:"#C4C4C4",dark:"rgba(255, 255, 255, 0.5)"}),editOutlineSelected:Object.freeze({light:"#3D70FF",dark:"#3D70FF"}),tooltipBackground:Object.freeze({light:"#FCFCF9",dark:"#262522"}),tooltipBorder:Object.freeze({light:"rgba(58, 56, 51, 0.15)",dark:"rgba(237, 231, 218, 0.15)"}),tooltipPrimaryRow:Object.freeze({light:"#F5F1E9",dark:"#2E2C29"}),annotationShape:Object.freeze({light:"#3b82f6",dark:"#60a5fa"}),annotationArrow:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),differenceLabelBackground:o.DEFAULT_GRAPH_BACKGROUND,trendPositive:{light:"#06B299",dark:"#0AC600"},trendNegative:{light:"#E14B49",dark:"#CB3333"},trendNeutral:dt},Ks=o.freezeWalkedEntries(o.walkStyleTargets()),Q=Object.freeze({tokens:Object.freeze(Gs),defaults:Object.freeze(Ks),overrides:Object.freeze([])}),Ys=class extends B{constructor(e){super(),this.container=e}compile(e){const t=super.compile(e);for(const n of dc(e.styles,t))this.container.diagnostics.addWarning(n);for(const n of pc(e.styles))this.container.diagnostics.addWarning(n);const r=hc(this.container.geomRegistry);for(const n of r(e.styles))this.container.diagnostics.addWarning(n);for(const n of yc(e.styles))this.container.diagnostics.addWarning(n);for(const n of t)for(const a of n.styles.warnings)this.container.diagnostics.addWarning(a);return t}dependencies(e){return[e.styles,e.config.parsingLocale]}compileLayer(e,t){const r=Or({layer:e,layerIndex:t.layers.indexOf(e),styles:t.styles,parsingLocale:t.config.parsingLocale,styleTarget:wr(this.container.geomRegistry,e.geom)});return{...e,styles:r}}},zs=class extends o.Stage{constructor(e){super(),this.container=e}compile(e){const t=super.compile(e);for(const r of mc(e.styles,e.annotations))this.container.diagnostics.addWarning(r);for(const r of t.warnings)this.container.diagnostics.addWarning(r);return t}dependencies(e){return[e.styles]}run(e){return xr(e.styles)}},Ve=new o.GeomRegistry,Ws=new Set(o.STYLE_PROPERTY_NAMES),qs=new WeakMap,Hs=new WeakMap,mt={stateless:0,dimmed:1,hovered:2},xr=e=>{const t=[],r={...Q.tokens,...e.tokens},n={...Zs(),warnings:t},a=(i,s,c,l)=>{if(te(i))return;const u=i.id===void 0?{}:{styleEntryId:i.id},d=i.select.target,m=ec(i.select);if(m.status==="unknown-target"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${c} targets unknown '${String(d)}'.`,context:{param:"target",actual:String(d),...u},suggestion:`Set 'target' to one of ${[...Ye].map(h=>`'${h}'`).join(", ")}.`});return}if(m.status==="unknown-partition"){const{key:h,value:b,node:C}=m,T=xe(C,h);t.push({code:"INVALID_STYLE_RULE",message:`Style ${c} addresses unknown ${h} '${b}'.`,context:{param:h,actual:b,...u},suggestion:T.length===0?`Remove '${h}' — this target has none.`:`Set '${h}' to one of ${T.map(V=>`'${V}'`).join(", ")}, or omit it.`});return}if(m.status==="namespace"){const h=xe(m.node,"part");t.push({code:"INVALID_STYLE_RULE",message:`Style ${c} ignored: ${i.select.target} entries need a part.`,context:{param:"part",actual:String(i.select.part),...u},suggestion:`Set 'part' to one of ${h.map(b=>`'${b}'`).join(", ")}.`});return}const p=m.node;if(i.when!==void 0&&!ze(p)){t.push({code:"INVALID_STYLE_RULE",message:`Style ${c} ignored: chrome entries take no conditions.`,context:{param:"when",...u},suggestion:"Remove the 'when' clause — chrome is chart-scoped, with no observations or states."});return}const g=p.options??[],f=i.select;if(f.layer!==void 0){t.push({code:"INVALID_STYLE_RULE",message:`Style ${c} does not take a layer.`,context:{param:"layer",actual:P(f.layer),...u},suggestion:"Remove 'layer' — this target is not layer-scoped."});return}if(f.annotation!==void 0){if(!g.includes("annotation")){t.push({code:"INVALID_STYLE_RULE",message:`Style ${c} does not take an annotation.`,context:{param:"annotation",actual:P(f.annotation),...u},suggestion:"Remove 'annotation' — this target is not annotation-scoped."});return}if(typeof f.annotation!="string"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${c} addresses an invalid annotation ${P(f.annotation)}.`,context:{param:"annotation",actual:P(f.annotation),...u},suggestion:"Set 'annotation' to the id of an annotation in the spec, or omit it to address every one of the kind."});return}}const v=Mr({declarations:i.declarations,vocabulary:p.vocabulary,tokens:r,location:c,origin:l,warnings:t,entryTarget:i.select.target});if(Object.keys(v).length===0)return;const y=p.select.target;Lr(y)&&n[y][s].push({select:i.select,declarations:v,origin:l})};return Q.defaults.forEach((i,s)=>{a(i,"defaults",`builtin[${s}]`,{list:"builtin"})}),e.defaults.forEach((i,s)=>{a(i,"defaults",`defaults[${s}]`,{list:"defaults",index:s,...i.id===void 0?{}:{id:i.id}})}),e.overrides.forEach((i,s)=>{a(i,"overrides",`overrides[${s}]`,{list:"overrides",index:s,...i.id===void 0?{}:{id:i.id}})}),n},Xs=e=>Ve.has(e)?Ve.get(e).styleTarget:void 0,Or=e=>{const{layer:t,layerIndex:r,styles:n,parsingLocale:a,styleTarget:i}=e,s=de(t,a),c=[],l={...Q.tokens,...n.tokens},u=m=>m===t.geom?i:void 0,d=(m,p)=>{const g=[];return m.forEach((f,v)=>{if(!te(f))return;const y=f.select.kind;if(y!==void 0&&y!==t.geom||f.select.layer!==void 0&&f.select.layer!==t.id)return;const h=`${p}[${v}]`;if(Rr(f,h,u)!==void 0)return;const b=f.when?.state;if(b!==void 0&&!Nr(b))return;const C=f.id===void 0?{}:{styleEntryId:f.id},T={list:p,index:v,...f.id===void 0?{}:{id:f.id}},V=f.when?.where;if(V!==void 0){const U=R(V,t.data,"style-rule");if(U.length>0){for(const S of U)c.push({...S,code:"INVALID_STYLE_RULE",message:`Style ${h}: ${S.message}`,context:{...S.context,layerIndex:r,...C}});return}}const q=Dr({select:f.select,declarations:f.declarations,layerGeom:t.geom,styleTarget:i,tokens:l,location:h,origin:T,warnings:c});if(Object.keys(q).length===0)return;const{part:$}=f.select;g.push({declarations:q,...V===void 0?{}:{matches:N(V,s)},...b===void 0?{}:{state:b},...$===void 0?{}:{part:$},origin:T})}),g};return{defaults:[...uc(t.geom,i,l,c),...d(n.defaults,"defaults")],overrides:d(n.overrides,"overrides"),warnings:c,vocabulary:Oe({kind:t.geom},i),aesthetics:ic(t.geom,i),dashPresets:i?.observation?.dashPresets??o.DASH_PRESETS.line,parts:ac(t.geom,i)}},wr=(e,t)=>e.has(t)?e.get(t).styleTarget:void 0,Js=e=>t=>wr(e,t),Qs=()=>{const e=new Set,t=r=>{if(e.add(r.select.target),r.children!==void 0)for(const n of Object.values(r.children))t(n)};for(const r of Object.values(o.STYLE_TARGETS))t(r);return e},Ye=Qs(),Lr=e=>e!=="geom"&&Ye.has(e),Zs=()=>{const e={};for(const t of Ye)Lr(t)&&(e[t]={defaults:[],overrides:[]});return e},xe=(e,t)=>{if(e.children===void 0)return[];const r=[];for(const n of Object.values(e.children)){const a=n.select[t];a!==void 0&&r.push(a)}return r},pt=e=>Object.keys(e.vocabulary).length===0&&e.children!==void 0,ec=e=>{const t=o.findStyleTarget(e);if(t!==void 0)return pt(t)?{status:"namespace",node:t}:{status:"found",node:t};const r=o.findStyleTarget({target:e.target});if(r===void 0)return{status:"unknown-target"};let n=r;for(const a of o.STYLE_SELECT_KEYS){const i=e[a];if(i===void 0)continue;const s=n.children===void 0?void 0:Object.values(n.children).find(c=>c.select[a]===i);if(s===void 0)return{status:"unknown-partition",key:a,value:i,node:n};n=s}return pt(n)?{status:"namespace",node:n}:{status:"found",node:n}},ze=e=>{const t=e.options??[];return t.includes("where")||t.includes("state")},tc=(e,t)=>{const r=e==="geom"?Ve.getAll().find(n=>n.styleTarget!==void 0&&o.readObservationVocabulary(n.styleTarget)[t]!==void 0)?.type:e==="annotation"?Object.entries(o.STYLE_TARGETS.annotation.children).find(([,n])=>n.vocabulary[t]!==void 0)?.[0]:void 0;return r===void 0?void 0:`style.${e}.${r}`},te=e=>e.select.target==="geom",rc=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Cr=(e,t,r,n)=>{const a=e.get(r)??new Map;e.set(r,a);const i=a.get(t);if(i!==void 0)return i;const s=n();return a.set(t,s),s},_r=(e,t)=>Cr(qs,e,t,()=>o.createGeomStyleNode(e,t)),W=(e,t)=>{const{kind:r,part:n}=e;if(r===void 0)return o.findStyleTarget({target:"geom",part:n});const a=t(r);if(a===void 0)return;const i=_r(r,a);return n===void 0?i:rc(i.children,n)},nc=(e,t)=>{const r=W(e,()=>t);return r===void 0||ze(r)},Pr=(e,t)=>[e,t].filter(r=>r!==void 0).join(" "),ac=(e,t)=>{const r=W({kind:e},()=>t),n={};for(const a of Object.values(r?.children??{}))a.select.part!==void 0&&(n[a.select.part]=a.vocabulary);return n},ic=(e,t)=>W({kind:e},()=>t)?.aesthetics??o.STYLE_TARGETS.geom.aesthetics,Oe=(e,t)=>W(e,()=>t)?.vocabulary??o.STYLE_TARGETS.geom.vocabulary,oc=(e,t)=>{const r={};for(const n of Object.keys(e)){const a=e[n];a===void 0||t[n]===void 0||(r[n]=a)}return r},Dr=e=>{const t=Mr({declarations:e.declarations,vocabulary:Oe(e.select,e.styleTarget),tokens:e.tokens,location:e.location,origin:e.origin,warnings:e.warnings,entryTarget:"geom"});return e.select.part!==void 0?t:oc(t,Oe({kind:e.layerGeom},e.styleTarget))},sc=(e,t)=>Cr(Hs,e,t,()=>o.freezeWalkedEntries(o.walkStyleTargets([_r(e,t)]))),cc=(e,t)=>mt[e.state??"stateless"]-mt[t.state??"stateless"],lc=(e,t)=>t===void 0?`builtin ${e}`:`builtin ${e}.${t}`,uc=(e,t,r,n)=>{const a=[],i={list:"builtin"},s=(c,l,u,d)=>{if(c.kind!==void 0&&c.kind!==e)return;if(u!==void 0&&!nc(c,t)){const g=Pr(e,c.part);n.push({code:"INVALID_STYLE_RULE",message:`Style ${d} ignored: a ${g} entry takes no conditions.`,context:{param:"state",actual:u},suggestion:`Declare the ${u} paint on 'rest', or add 'state' to the part's options.`});return}const m=Dr({select:c,declarations:l,layerGeom:e,styleTarget:t,tokens:r,location:d,origin:i,warnings:n});if(Object.keys(m).length===0)return;const{part:p}=c;a.push({declarations:m,...u===void 0?{}:{state:u},...p===void 0?{}:{part:p},origin:i})};if(Q.defaults.forEach((c,l)=>{te(c)&&s(c.select,c.declarations,c.when?.state,`builtin[${l}]`)}),t===void 0)return a;for(const c of sc(e,t))s(c.select,c.declarations,c.when?.state,lc(e,c.select.part));return a.sort(cc)},fe=(e,t)=>{e.defaults.forEach((r,n)=>t(r,"defaults",n)),e.overrides.forEach((r,n)=>t(r,"overrides",n))},dc=(e,t)=>{const r=new Set(t.map(a=>a.id)),n=[];return fe(e,(a,i,s)=>{const c=a.select;if(c.target!=="geom")return;const l=c.layer;l===void 0||typeof l!="string"||r.has(l)||n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${s}] targets unknown layer '${l}'.`,context:{param:"layer",actual:l,...a.id===void 0?{}:{styleEntryId:a.id}},suggestion:"Set 'layer' to the id of a layer in the spec."})}),n},mc=(e,t)=>{const r=new Map(Er.flatMap(a=>t[o.ANNOTATION_BUCKETS[a]].map(i=>[i.id,a]))),n=[];return fe(e,(a,i,s)=>{const c=a.select;if(c.target!=="annotation")return;const l=c.annotation;if(l===void 0||typeof l!="string")return;const u={param:"annotation",actual:l,...a.id===void 0?{}:{styleEntryId:a.id}},d=r.get(l);if(d===void 0){n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${s}] targets unknown annotation '${l}'.`,context:u,suggestion:"Set 'annotation' to the id of an annotation in the spec."});return}if(d==="sticker"){n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${s}] targets sticker '${l}', which has no style vocabulary.`,context:u,suggestion:"Remove the entry — stickers take no style declarations."});return}const m=c.kind;m!==void 0&&m!==d&&n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${s}] targets ${d} '${l}' with an entry addressing kind '${String(m)}'.`,context:u,suggestion:`Set 'kind' to '${d}', or omit it to address the annotation with the shared vocabulary.`})}),n},pc=e=>{const t=[];return fe(e,(r,n,a)=>{if(!te(r))return;const i=r.when?.state;i===void 0||Nr(i)||t.push({code:"INVALID_STYLE_RULE",message:`Style ${n}[${a}] scopes to unknown state '${i}'.`,context:{param:"state",actual:String(i),...r.id===void 0?{}:{styleEntryId:r.id}},suggestion:`Set 'state' to one of ${o.STYLE_STATES.map(s=>`'${s}'`).join(", ")}.`})}),t},Nr=e=>o.STYLE_STATES.includes(e),fc=(e,t,r)=>e===void 0?`Set 'kind' to the geom declaring '${t}' — a part is addressed on the kind that has it.`:r.length===0?`Remove 'part' — ${e} has none.`:`Set 'part' to one of ${r.map(n=>`'${n}'`).join(", ")}, or omit it.`,Rr=(e,t,r)=>{const{kind:n,part:a}=e.select;if(a===void 0)return;const i=e.id===void 0?{}:{styleEntryId:e.id},s=W({kind:n,part:a},r);if(s===void 0){const c=W({kind:n},r),l=c===void 0?[]:xe(c,"part");return{code:"INVALID_STYLE_RULE",message:`Style ${t} addresses unknown part '${a}'.`,context:{param:"part",actual:a,...i},suggestion:fc(n,a,l)}}if(e.when!==void 0&&!ze(s)){const c=Pr(n,a);return{code:"INVALID_STYLE_RULE",message:`Style ${t} ignored: a ${c} entry takes no conditions.`,context:{param:"when",...i},suggestion:`Remove the 'when' clause — the ${c} is styled as a whole.`}}},gc=(e,t,r)=>{const{kind:n}=e.select;if(n===void 0||r.has(n))return;const a=r.getAll().map(i=>`'${i.type}'`);return{code:"INVALID_STYLE_RULE",message:`Style ${t} addresses unknown geom kind '${n}'.`,context:{param:"kind",actual:n,...e.id===void 0?{}:{styleEntryId:e.id}},suggestion:`Set 'kind' to one of ${a.join(", ")}, or omit it to reach every geom.`}},hc=e=>{const t=Js(e);return r=>{const n=[];return fe(r,(a,i,s)=>{if(!te(a))return;const c=`${i}[${s}]`,l=gc(a,c,e)??Rr(a,c,t);l!==void 0&&n.push(l)}),n}},yc=e=>{const t=[];for(const[r,n]of Object.entries(e.tokens))o.isUsableTokenValue(n)||t.push({code:"INVALID_STYLE_RULE",message:`Style token '${r}' has an invalid value: ${P(n)}.`,context:{param:"tokens",actual:P(n)},suggestion:`Set '${r}' to a non-empty color string or a { light, dark } pair of colors.`});return t},P=e=>typeof e=="object"&&e!==null?JSON.stringify(e):String(e),Mr=e=>{const{declarations:t,vocabulary:r,tokens:n,location:a,origin:i,warnings:s,entryTarget:c}=e,l={},u=i.list==="builtin"||i.id===void 0?{}:{styleEntryId:i.id},d=(f,v)=>{l[f]=v},m=(f,v,y)=>{s.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: expected ${v}, got ${P(y)}.`,context:{param:f,expected:v,actual:P(y),...u},suggestion:`Set '${f}' to ${v}.`})},p=(f,v)=>{s.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: unknown token '${v}'.`,context:{param:f,actual:v,...u},suggestion:`Declare '${v}' in the stylesheet's tokens.`})},g=f=>{const v=Ws.has(f),y=tc(c,f),h=y===void 0?`Declare '${f}' on a target whose vocabulary carries it.`:`Declare '${f}' on an entry whose kind supports it (e.g. ${y}).`;s.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: ${v?"not in this entry's vocabulary":"not a style property"}.`,context:{param:f,...u},suggestion:v?h:`Remove the unknown declaration '${f}'.`})};for(const f of Object.keys(t)){const v=t[f];if(v===void 0)continue;const y=r[f];if(y===void 0){g(f);continue}const h=o.STYLE_DOMAINS[y](v,n);switch(h.status){case"accepted":d(f,h.value);break;case"rejected":m(f,h.expected,h.actual);break;case"unknownToken":p(f,h.token);break;case"dropped":break;default:break}}return l},vc=({layer:e})=>{if(e.position==="stack")return;const t=o.readVariableName(e.mapping.y);if(t===null)return;let r=0,n=0;for(const a of e.data){const i=a[t];o.isStrictNumericDataValue(i)&&(r+=i,n+=Math.abs(i))}return{grandTotal:r,absoluteGrandTotal:n}},bc=({layer:e,mainAxis:t})=>{if(e.position!=="stack")return;const r=o.readVariableName(e.mapping.x);if(r===null||!e.data.hasVariable(o.POSITION_VARIABLES.yMin)||!e.data.hasVariable(o.POSITION_VARIABLES.yMax))return;const n=c=>t==="y"?c.xMax:c.yMax,a=c=>t==="y"?c.xMin:c.yMin,i=new Map;for(const c of e.data){const l=c[r],u=o.getYMin(c),d=o.getYMax(c),m=o.getXMin(c),p=o.getXMax(c),g=o.getYRaw(c);if(!o.isDefined(l)||!o.isDefined(u)||!o.isDefined(d)||!o.isDefined(m)||!o.isDefined(p)||!o.isDefined(g))continue;const f=g>=0;if(Math.abs(g)===0)continue;const v=ke(c,r),y={xMin:m,xMax:p,yMin:u,yMax:d},h=i.get(v);if(h===void 0){i.set(v,{total:g,topPositive:f?y:null,bottomNegative:f?null:y});continue}h.total+=g,f?(h.topPositive===null||n(y)>n(h.topPositive))&&(h.topPositive=y):(h.bottomNegative===null||a(y)<a(h.bottomNegative))&&(h.bottomNegative=y)}const s=[];for(const[c,l]of i){const u=l.topPositive??l.bottomNegative;u!==null&&s.push({xKey:c,total:l.total,anchor:{xMin:u.xMin,xMax:u.xMax,yMin:u.yMin,yMax:u.yMax,direction:l.topPositive!==null?"positive":"negative"}})}return s},Sc=class extends B{constructor(e){super(),this.container=e}dependencies(e){return[e.coordSystem]}compileLayer(e,t){const r=this.container.geomRegistry.get(e.geom),n={},a=xt(t.coordSystem);if(r.summaries.stackTotals){const i=bc({layer:e,mainAxis:a});i!==void 0&&(n.stackTotals=i)}if(r.summaries.grandTotal){const i=vc({layer:e});i!==void 0&&(n.grandTotal=i.grandTotal,n.absoluteGrandTotal=i.absoluteGrandTotal)}return{...e,summary:n}}},kr=class extends o.Stage{constructor(e){super(),this.registry=e}key(e){return e.data}dependencies(e){return[e.transforms]}run(e){return e.transforms.reduce((t,r)=>this.registry.get(r.transformType).apply(t,r),e.data)}},ft={color:"categorical",size:"numeric",alpha:"numeric",strokeWidth:"numeric",lineType:"categorical"},Ac=["color","size","alpha","strokeWidth","lineType"],Tc=class extends B{dependencies(e){return Ac.map(t=>e.scales[t])}compileLayer(e,t){let r=e.data;const n=Object.entries(o.VISUAL_VARIABLES);for(const[a,i]of n){const s=o.readConstantValue(e.mapping[a]);if(s!==void 0){r=r.addConstantVariable(i,ft[a],s);continue}const c=o.readVariableName(e.mapping[a]),l=t.scales[a];!c||!l||l.kind!=="visual"||(r=r.deriveVariableFrom(c,i,ft[a],Ic(l)))}return{...e,data:r}}},Ic=e=>t=>o.isDefined(t)?e.map(t):null;function Br(e=new o.GeomRegistry){return{diagnostics:new As,geomRegistry:e}}var $r=class{constructor(e,t,r,n,a,i,s,c,l,u,d,m,p,g,f,v){this.container=e,this.dataCompiler=t,this.specCompiler=r,this.transformCompiler=n,this.constantMappingCompiler=a,this.layerPhasedCompiler=i,this.scaleCompiler=s,this.coordCompiler=c,this.positionMapperCompiler=l,this.visualMapperCompiler=u,this.guideCompiler=d,this.summarizeCompiler=m,this.stylesCompiler=p,this.chromeStylesCompiler=g,this.highlightsCompiler=f,this.annotationsCompiler=v,this.stageTimer=o.IS_DEV?ks():null,this.lastCompile=null,this.lastDiagnostics=null,this.lastData=void 0,this.lastCustomPalettes={},this.stages=[{name:"data",getStats:()=>this.dataCompiler.stats},{name:"transform",getStats:()=>this.transformCompiler.stats},{name:"constantMapping",getStats:()=>this.constantMappingCompiler.stats},{name:"layer",getStats:()=>this.layerPhasedCompiler.stats},{name:"coordSetup",getStats:()=>this.coordCompiler.setupStats},{name:"scale",getStats:()=>this.scaleCompiler.stats},{name:"positionMapper",getStats:()=>this.positionMapperCompiler.stats},{name:"visualMapper",getStats:()=>this.visualMapperCompiler.stats},{name:"coordTransform",getStats:()=>this.coordCompiler.transformStats},{name:"summarize",getStats:()=>this.summarizeCompiler.stats},{name:"guide",getStats:()=>this.guideCompiler.stats},{name:"styles",getStats:()=>this.stylesCompiler.stats},{name:"chromeStyles",getStats:()=>this.chromeStylesCompiler.stats},{name:"highlights",getStats:()=>this.highlightsCompiler.stats},{name:"annotations",getStats:()=>this.annotationsCompiler.stats}],o.IS_DEV&&this.setupStageTiming()}compile(e){try{const t=this.runCompile(()=>(this.lastData=e.data,this.lastCustomPalettes=e.customPalettes??{},this.runPipeline({spec:this.specCompiler.compile({spec:e.spec,customPalettes:this.lastCustomPalettes,dataset:this.dataCompiler.compile(e.data)}),colorScheme:e.colorScheme??gt})));return this.toOkResult(t)}catch(t){return this.toErrorResult(t)}}recompile(e){try{const t=this.runCompile(()=>{const r=e.colorScheme??gt;if(e.data===void 0)return this.runPipeline({spec:e.spec,colorScheme:r});this.lastData=e.data;const n=this.dataCompiler.compile(e.data),a=this.reResolveInferredScalesIfNeeded(e.spec.data,X(e.spec,{data:n}));return this.runPipeline({spec:a,colorScheme:r})});return this.toOkResult(t)}catch(t){return this.toErrorResult(t)}}getCacheStats(){const e={};for(const{name:t,getStats:r}of this.stages)e[t]={...r()};return e}getLastCompile(){return this.lastCompile}getDiagnostics(){return this.lastDiagnostics}reResolveInferredScalesIfNeeded(e,t){if(e.size()!==0||t.data.size()===0||t.scales.filter(n=>n.inferredFrom!==void 0).length===0)return t;const r=Fe(this.container,{data:t.data,layers:t.layers,mapping:t.mapping,customPalettes:this.lastCustomPalettes});return X(t,{scales:_e(t.scales,n=>{const a=n.inferredFrom;if(a===void 0)return n;const i=pe(r,a);return t.coords.coordType==="polar"?je(i):i})})}runCompile(e){this.container.diagnostics.reset();const t=this.trackCompile(e);return this.lastDiagnostics=this.container.diagnostics.drain(),t}toOkResult(e){return{ok:!0,scene:e,warnings:this.lastDiagnostics?.warnings??[]}}toErrorResult(e){const t=this.container.diagnostics.drain();return this.lastDiagnostics=t,{ok:!1,errors:t.errors.length>0?t.errors:[St(e)],warnings:t.warnings}}setupStageTiming(){this.stageTimer&&(this.dataCompiler.compile=this.stageTimer.wrap("data",this.dataCompiler.compile.bind(this.dataCompiler)),this.transformCompiler.compile=this.stageTimer.wrap("transform",this.transformCompiler.compile.bind(this.transformCompiler)),this.constantMappingCompiler.compile=this.stageTimer.wrap("constantMapping",this.constantMappingCompiler.compile.bind(this.constantMappingCompiler)),this.layerPhasedCompiler.compile=this.stageTimer.wrap("layer",this.layerPhasedCompiler.compile.bind(this.layerPhasedCompiler)),this.coordCompiler.setup=this.stageTimer.wrap("coordSetup",this.coordCompiler.setup.bind(this.coordCompiler)),this.scaleCompiler.compile=this.stageTimer.wrap("scale",this.scaleCompiler.compile.bind(this.scaleCompiler)),this.positionMapperCompiler.compile=this.stageTimer.wrap("positionMapper",this.positionMapperCompiler.compile.bind(this.positionMapperCompiler)),this.visualMapperCompiler.compile=this.stageTimer.wrap("visualMapper",this.visualMapperCompiler.compile.bind(this.visualMapperCompiler)),this.coordCompiler.transform=this.stageTimer.wrap("coordTransform",this.coordCompiler.transform.bind(this.coordCompiler)),this.summarizeCompiler.compile=this.stageTimer.wrap("summarize",this.summarizeCompiler.compile.bind(this.summarizeCompiler)),this.guideCompiler.compile=this.stageTimer.wrap("guide",this.guideCompiler.compile.bind(this.guideCompiler)),this.stylesCompiler.compile=this.stageTimer.wrap("styles",this.stylesCompiler.compile.bind(this.stylesCompiler)),this.chromeStylesCompiler.compile=this.stageTimer.wrap("chromeStyles",this.chromeStylesCompiler.compile.bind(this.chromeStylesCompiler)),this.highlightsCompiler.compile=this.stageTimer.wrap("highlights",this.highlightsCompiler.compile.bind(this.highlightsCompiler)),this.annotationsCompiler.compile=this.stageTimer.wrap("annotations",this.annotationsCompiler.compile.bind(this.annotationsCompiler)))}trackCompile(e){if(!o.IS_DEV)return e();this.stageTimer?.reset();const t=this.getCacheStats(),r=performance.now();try{return e()}finally{const n=performance.now()-r,a={},i={};for(const{name:s,getStats:c}of this.stages){const l=c();a[s]={hits:l.hits-t[s].hits,misses:l.misses-t[s].misses},i[s]=this.stageTimer?.getDuration(s)??0}this.lastCompile={stages:a,durationMs:n,stageDurationsMs:i}}}runPipeline({spec:e,colorScheme:t}){return{...ue({spec:e}).pipe(({spec:r})=>({spec:X(r,{data:this.transformCompiler.compile({data:r.data,transforms:r.transforms})})})).pipe(({spec:r})=>{const n=this.constantMappingCompiler.compile({data:r.data,mapping:r.mapping});return{spec:X(r,{data:n.data,mapping:n.mapping})}}).pipe(({spec:r})=>({layers:this.layerPhasedCompiler.compile({data:r.data,layers:r.layers,mapping:r.mapping,coords:r.coords,scales:r.scales})})).pipe(({spec:r,layers:n})=>this.coordCompiler.setup({coordSpec:r.coords,scales:r.scales,layers:n})).pipe(({layers:r,scales:n})=>({scales:this.scaleCompiler.compile({layers:r,scales:n,colorScheme:t})})).pipe(({spec:r})=>({config:r.config})).pipe(({layers:r,scales:n})=>({layers:this.positionMapperCompiler.compile({layers:r,scales:n})})).pipe(({layers:r,scales:n})=>({layers:this.visualMapperCompiler.compile({layers:r,scales:n})})).pipe(({spec:r,layers:n,coordSystem:a})=>({layers:this.coordCompiler.transform({coordSpec:r.coords,coordSystem:a,layers:n})})).pipe(({layers:r,coordSystem:n})=>({layers:this.summarizeCompiler.compile({layers:r,coordSystem:n})})).pipe(({spec:r,scales:n,layers:a,coordSystem:i})=>({guides:this.guideCompiler.compile({scales:n,config:r.config,layers:a,coordSystem:i,originalData:this.lastData})})).pipe(({spec:r,layers:n})=>({layers:this.stylesCompiler.compile({layers:n,styles:r.styles,config:r.config})})).pipe(({spec:r})=>({chrome:this.chromeStylesCompiler.compile({styles:r.styles,annotations:r.annotations})})).pipe(({spec:r,layers:n})=>({layers:this.highlightsCompiler.compile({layers:n,highlights:r.highlights,config:r.config})})).pipe(({spec:r,layers:n,coordSystem:a,scales:i})=>({annotations:this.annotationsCompiler.compile({annotations:r.annotations,layers:n,coordSystem:a,scales:i,config:r.config})})).result(),spec:e}}},Ec=["data","transform","constantMapping","layer","coordSetup","scale","positionMapper","visualMapper","coordTransform","summarize","guide","styles","chromeStyles","highlights","annotations"],gt="light",Vc=({plugins:e=[]}={})=>{const t=o.readPlugins(e),{geomRegistry:r,statRegistry:n,transformRegistry:a}=ao(t),i=Br(r),s=new Yo(i),c=new kr(a);for(const l of t.warnings)i.diagnostics.addWarning(l,{persistent:!0});return new $r(i,new o.DataCompiler,new Ir(i),c,new kn,new Fi(i,c,n,new Ni(i,c,new Bs(n),new ma,new da(i),new io(new po))),new xo(i,s),new Un(new oa),new Vo(i),new Tc,new Oi(i),new Sc(i),new Ys(i),new zs(i),new Ci(i),new In(i))};Object.defineProperty(exports,"AREA_DEFAULTS",{enumerable:!0,get:function(){return Vs}});Object.defineProperty(exports,"BAR_DEFAULTS",{enumerable:!0,get:function(){return xs}});Object.defineProperty(exports,"BUILTIN_STYLES",{enumerable:!0,get:function(){return Q}});Object.defineProperty(exports,"COLOR_INTERPOLATION_SPACES",{enumerable:!0,get:function(){return Oo}});Object.defineProperty(exports,"COMPILER_STAGE_KEYS",{enumerable:!0,get:function(){return Ec}});Object.defineProperty(exports,"Compiler",{enumerable:!0,get:function(){return $r}});Object.defineProperty(exports,"DATA_LABELS_DEFAULTS",{enumerable:!0,get:function(){return vr}});Object.defineProperty(exports,"DIVERGING_SCHEME_NAMES",{enumerable:!0,get:function(){return mr}});Object.defineProperty(exports,"LINE_DEFAULTS",{enumerable:!0,get:function(){return Es}});Object.defineProperty(exports,"POINT_DEFAULTS",{enumerable:!0,get:function(){return Is}});Object.defineProperty(exports,"POLAR_COORD_DEFAULTS",{enumerable:!0,get:function(){return ae}});Object.defineProperty(exports,"POSITION_NUMERIC_ROLES",{enumerable:!0,get:function(){return jt}});Object.defineProperty(exports,"RULE_DEFAULTS",{enumerable:!0,get:function(){return Os}});Object.defineProperty(exports,"SCHEME_ALIASES",{enumerable:!0,get:function(){return pr}});Object.defineProperty(exports,"SEQUENTIAL_SCHEME_NAMES",{enumerable:!0,get:function(){return wo}});Object.defineProperty(exports,"SpecCompiler",{enumerable:!0,get:function(){return Ir}});Object.defineProperty(exports,"TILE_DEFAULTS",{enumerable:!0,get:function(){return ws}});Object.defineProperty(exports,"TransformCompiler",{enumerable:!0,get:function(){return kr}});Object.defineProperty(exports,"areEndpointsComparable",{enumerable:!0,get:function(){return vt}});Object.defineProperty(exports,"buildDiagnostic",{enumerable:!0,get:function(){return St}});Object.defineProperty(exports,"buildEmptyHighlightForStrategy",{enumerable:!0,get:function(){return er}});Object.defineProperty(exports,"canAnchorDirectLabels",{enumerable:!0,get:function(){return Qt}});Object.defineProperty(exports,"clampValuesAgainstFillSiblings",{enumerable:!0,get:function(){return Tr}});Object.defineProperty(exports,"compileChromeStyles",{enumerable:!0,get:function(){return xr}});Object.defineProperty(exports,"compileLayerStyles",{enumerable:!0,get:function(){return Or}});Object.defineProperty(exports,"compilePredicate",{enumerable:!0,get:function(){return N}});Object.defineProperty(exports,"composePoint",{enumerable:!0,get:function(){return Se}});Object.defineProperty(exports,"createAlphaValueReader",{enumerable:!0,get:function(){return Wr}});Object.defineProperty(exports,"createColorValueReader",{enumerable:!0,get:function(){return Yr}});Object.defineProperty(exports,"createCommonContainer",{enumerable:!0,get:function(){return Br}});Object.defineProperty(exports,"createCompiler",{enumerable:!0,get:function(){return Vc}});Object.defineProperty(exports,"createDatasetFromKindPartitions",{enumerable:!0,get:function(){return Mn}});Object.defineProperty(exports,"createEmptyLayerStyles",{enumerable:!0,get:function(){return rr}});Object.defineProperty(exports,"createGroupValueReader",{enumerable:!0,get:function(){return qr}});Object.defineProperty(exports,"createLabelValueReader",{enumerable:!0,get:function(){return Kr}});Object.defineProperty(exports,"createLayerMeasurement",{enumerable:!0,get:function(){return Ct}});Object.defineProperty(exports,"createObservationAnchorBuilder",{enumerable:!0,get:function(){return Ot}});Object.defineProperty(exports,"createObservationAnchorMatcher",{enumerable:!0,get:function(){return _t}});Object.defineProperty(exports,"createObservationAnchorParser",{enumerable:!0,get:function(){return bt}});Object.defineProperty(exports,"createPipeline",{enumerable:!0,get:function(){return ue}});Object.defineProperty(exports,"createPredicateCompileContext",{enumerable:!0,get:function(){return de}});Object.defineProperty(exports,"createPredicateValueReader",{enumerable:!0,get:function(){return Pt}});Object.defineProperty(exports,"createRawValueReader",{enumerable:!0,get:function(){return E}});Object.defineProperty(exports,"createRowPredicateCompileContext",{enumerable:!0,get:function(){return un}});Object.defineProperty(exports,"createScaleContext",{enumerable:!0,get:function(){return Fe}});Object.defineProperty(exports,"createSegmentYReader",{enumerable:!0,get:function(){return we}});Object.defineProperty(exports,"createSizeValueReader",{enumerable:!0,get:function(){return zr}});Object.defineProperty(exports,"createStrokeWidthValueReader",{enumerable:!0,get:function(){return Hr}});Object.defineProperty(exports,"createXValueReader",{enumerable:!0,get:function(){return jr}});Object.defineProperty(exports,"createYValueReader",{enumerable:!0,get:function(){return Gr}});Object.defineProperty(exports,"describeMeasurementBasis",{enumerable:!0,get:function(){return ve}});Object.defineProperty(exports,"filterLayersByGeoms",{enumerable:!0,get:function(){return ri}});Object.defineProperty(exports,"findAnnotation",{enumerable:!0,get:function(){return Us}});Object.defineProperty(exports,"findCompanionLayers",{enumerable:!0,get:function(){return ni}});Object.defineProperty(exports,"findDefaultKitStyleTarget",{enumerable:!0,get:function(){return Xs}});Object.defineProperty(exports,"findDistinctLayers",{enumerable:!0,get:function(){return Me}});Object.defineProperty(exports,"findLayerByGeom",{enumerable:!0,get:function(){return ti}});Object.defineProperty(exports,"findLayerById",{enumerable:!0,get:function(){return ei}});Object.defineProperty(exports,"findPredicateProblems",{enumerable:!0,get:function(){return R}});Object.defineProperty(exports,"getCoordinates",{enumerable:!0,get:function(){return rn}});Object.defineProperty(exports,"getCrossAxisCoordinate",{enumerable:!0,get:function(){return Vt}});Object.defineProperty(exports,"getGroup",{enumerable:!0,get:function(){return Z}});Object.defineProperty(exports,"getLayerVariableValueFormat",{enumerable:!0,get:function(){return Pe}});Object.defineProperty(exports,"getLayerYValueFormat",{enumerable:!0,get:function(){return on}});Object.defineProperty(exports,"getMainAxisCoordinate",{enumerable:!0,get:function(){return Et}});Object.defineProperty(exports,"getObservationXKey",{enumerable:!0,get:function(){return ke}});Object.defineProperty(exports,"isAnnotationKind",{enumerable:!0,get:function(){return $s}});Object.defineProperty(exports,"isCartesian",{enumerable:!0,get:function(){return nn}});Object.defineProperty(exports,"isCompanionLayer",{enumerable:!0,get:function(){return Jt}});Object.defineProperty(exports,"isLayerSpecOf",{enumerable:!0,get:function(){return Za}});Object.defineProperty(exports,"mapItems",{enumerable:!0,get:function(){return _e}});Object.defineProperty(exports,"measureAnchorSpace",{enumerable:!0,get:function(){return It}});Object.defineProperty(exports,"patchSpec",{enumerable:!0,get:function(){return X}});Object.defineProperty(exports,"readAnnotationBucket",{enumerable:!0,get:function(){return Ke}});Object.defineProperty(exports,"readGeomScaleConstraints",{enumerable:!0,get:function(){return Be}});Object.defineProperty(exports,"readMainAxis",{enumerable:!0,get:function(){return xt}});Object.defineProperty(exports,"readObservationMeasurement",{enumerable:!0,get:function(){return kt}});Object.defineProperty(exports,"readScopeKey",{enumerable:!0,get:function(){return Te}});Object.defineProperty(exports,"readScopeXVariable",{enumerable:!0,get:function(){return Zt}});Object.defineProperty(exports,"removeDiscreteScalePadding",{enumerable:!0,get:function(){return je}});Object.defineProperty(exports,"removeLocatedAnnotation",{enumerable:!0,get:function(){return Fs}});Object.defineProperty(exports,"replaceAnnotationBucket",{enumerable:!0,get:function(){return Vr}});Object.defineProperty(exports,"replaceAtIndex",{enumerable:!0,get:function(){return Zr}});Object.defineProperty(exports,"resolveAnchorVariable",{enumerable:!0,get:function(){return le}});Object.defineProperty(exports,"resolveColorRamp",{enumerable:!0,get:function(){return Ue}});Object.defineProperty(exports,"resolveComparisonBasis",{enumerable:!0,get:function(){return Xt}});Object.defineProperty(exports,"resolveCoord",{enumerable:!0,get:function(){return yr}});Object.defineProperty(exports,"resolveCrossAnchorVariable",{enumerable:!0,get:function(){return Le}});Object.defineProperty(exports,"resolveDiscreteScale",{enumerable:!0,get:function(){return hr}});Object.defineProperty(exports,"resolveGeomAnchorSpace",{enumerable:!0,get:function(){return Tt}});Object.defineProperty(exports,"resolveGeomScaleDemands",{enumerable:!0,get:function(){return $e}});Object.defineProperty(exports,"resolveLabelSource",{enumerable:!0,get:function(){return Ar}});Object.defineProperty(exports,"resolveLayer",{enumerable:!0,get:function(){return Sr}});Object.defineProperty(exports,"resolveScale",{enumerable:!0,get:function(){return pe}});Object.defineProperty(exports,"resolveSegmentYSource",{enumerable:!0,get:function(){return ce}});Object.defineProperty(exports,"resolveStatSpec",{enumerable:!0,get:function(){return br}});Object.defineProperty(exports,"resolveVariableLabel",{enumerable:!0,get:function(){return Ne}});Object.defineProperty(exports,"sampleColorScheme",{enumerable:!0,get:function(){return Do}});Object.defineProperty(exports,"shouldNarrowByGroup",{enumerable:!0,get:function(){return Ce}});Object.defineProperty(exports,"toPanelFraction",{enumerable:!0,get:function(){return tn}});Object.defineProperty(exports,"uniqueId",{enumerable:!0,get:function(){return I}});Object.defineProperty(exports,"updateSpec",{enumerable:!0,get:function(){return Qr}});