UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) • 22 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import t from"../../../../../Color.js";import{toLCH as e,toRGB as r,toLAB as s}from"../../../../../core/colorUtils.js";import{unitBezier as n}from"../../../unitBezier.js";import{interpolate as a}from"../GeometryUtils.js";import{booleanType as o,numberType as i,arrayType as l,colorType as u,stringType as c,valueType as h,typeToString as p,objectType as g,getType as f,valueToString as w,matchType as m}from"./types.js";class y{constructor(t){this._parent=t,this._vars={}}add(t,e){this._vars[t]=e}get(t){return this._vars[t]?this._vars[t]:this._parent?this._parent.get(t):null}}class _{constructor(){this.type=h}static parse(t){if(t.length>1)throw new Error('"id" does not expect arguments');return new _}evaluate(t,e){return t?.id}}class v{constructor(){this.type=c}static parse(t){if(t.length>1)throw new Error('"geometry-type" does not expect arguments');return new v}evaluate(t,e){if(!t)return null;switch(t.type){case 1:return"Point";case 2:return"LineString";case 3:return"Polygon";default:return null}}}class b{constructor(){this.type=g}static parse(t){if(t.length>1)throw new Error('"properties" does not expect arguments');return new b}evaluate(t,e){return t?.values}}class d{constructor(){this.type=i}static parse(t){if(t.length>1)throw new Error('"zoom" does not expect arguments');return new d}evaluate(t,e){return e}}class x{constructor(t,e,r){this._lhs=t,this._rhs=e,this._compare=r,this.type=o}static parse(t,e,r){if(3!==t.length&&4!==t.length)throw new Error(`"${t[0]}" expects 2 or 3 arguments`);if(4===t.length)throw new Error(`"${t[0]}" collator not supported`);return new x(pt(t[1],e),pt(t[2],e),r)}evaluate(t,e){return this._compare(this._lhs.evaluate(t,e),this._rhs.evaluate(t,e))}}class E extends x{static parse(t,e){return x.parse(t,e,(t,e)=>t===e)}}class $ extends x{static parse(t,e){return x.parse(t,e,(t,e)=>t!==e)}}class M extends x{static parse(t,e){return x.parse(t,e,(t,e)=>t<e)}}class k extends x{static parse(t,e){return x.parse(t,e,(t,e)=>t<=e)}}class A extends x{static parse(t,e){return x.parse(t,e,(t,e)=>t>e)}}class j extends x{static parse(t,e){return x.parse(t,e,(t,e)=>t>=e)}}class q{constructor(t){this._arg=t,this.type=o}static parse(t,e){if(2!==t.length)throw new Error('"!" expects 1 argument');return new q(pt(t[1],e))}evaluate(t,e){return!this._arg.evaluate(t,e)}}class N{constructor(t){this._args=t,this.type=o}static parse(t,e){const r=[];for(let s=1;s<t.length;s++)r.push(pt(t[s],e));return new N(r)}evaluate(t,e){for(const r of this._args)if(!r.evaluate(t,e))return!1;return!0}}class R{constructor(t){this._args=t,this.type=o}static parse(t,e){const r=[];for(let s=1;s<t.length;s++)r.push(pt(t[s],e));return new R(r)}evaluate(t,e){for(const r of this._args)if(r.evaluate(t,e))return!0;return!1}}class C{constructor(t){this._args=t,this.type=o}static parse(t,e){const r=[];for(let s=1;s<t.length;s++)r.push(pt(t[s],e));return new C(r)}evaluate(t,e){for(const r of this._args)if(r.evaluate(t,e))return!1;return!0}}class z{constructor(t,e,r){this.type=t,this._args=e,this._fallback=r}static parse(t,e,r){if(t.length<4)throw new Error('"case" expects at least 3 arguments');if(t.length%2==1)throw new Error('"case" expects an odd number of arguments');let s;const n=[];for(let o=1;o<t.length-1;o+=2){const a=pt(t[o],e),i=pt(t[o+1],e,r);s||(s=i.type),n.push({condition:a,output:i})}const a=pt(t[t.length-1],e,r);return s||(s=a.type),new z(s,n,a)}evaluate(t,e){for(const r of this._args)if(r.condition.evaluate(t,e))return r.output.evaluate(t,e);return this._fallback.evaluate(t,e)}}class I{constructor(t,e){this.type=t,this._args=e}static parse(t,e){if(t.length<2)throw new Error('"coalesce" expects at least 1 argument');let r;const s=[];for(let n=1;n<t.length;n++){const a=pt(t[n],e);r||(r=a.type),s.push(a)}return new I(r,s)}evaluate(t,e){for(const r of this._args){const s=r.evaluate(t,e);if(null!==s)return s}return null}}class L{constructor(t,e,r,s,n){this.type=t,this._input=e,this._labels=r,this._outputs=s,this._fallback=n}static parse(t,e){if(t.length<3)throw new Error('"match" expects at least 3 arguments');if(t.length%2==0)throw new Error('"case" expects an even number of arguments');let r;const s=pt(t[1],e),n=[],a={};let o;for(let i=2;i<t.length-1;i+=2){let s=t[i];Array.isArray(s)||(s=[s]);for(const t of s){const e=typeof t;if("string"!==e&&"number"!==e)throw new Error('"match" requires string or number literal as labels');if(o){if(e!==o)throw new Error('"match" requires labels to have the same type')}else o=e;a[t]=n.length}const l=pt(t[i+1],e);r||(r=l.type),n.push(l)}return new L(r,s,a,n,pt(t[t.length-1],e))}evaluate(t,e){const r=this._input.evaluate(t,e);return(this._outputs[this._labels[r]]||this._fallback).evaluate(t,e)}}class U{constructor(t,e,r,s,n){this._operator=t,this.type=e,this.interpolation=r,this.input=s,this._stops=n}static parse(t,e,r){const s=t[0];if(t.length<5)throw new Error(`"${s}" expects at least 4 arguments`);const n=t[1];if(!Array.isArray(n)||0===n.length)throw new Error(`"${n}" is not a valid interpolation`);switch(n[0]){case"linear":if(1!==n.length)throw new Error("Linear interpolation cannot have parameters");break;case"exponential":if(2!==n.length||"number"!=typeof n[1])throw new Error("Exponential interpolation requires one numeric argument");break;case"cubic-bezier":if(5!==n.length)throw new Error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1");for(let t=1;t<5;t++){const e=n[t];if("number"!=typeof e||e<0||e>1)throw new Error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1")}break;default:throw new Error(`"${t[0]}" unknown interpolation type "${n[0]}"`)}if(t.length%2!=1)throw new Error(`"${s}" expects an even number of arguments`);const a=pt(t[2],e,i);let o;"interpolate-hcl"===s||"interpolate-lab"===s?o=u:r&&"value"!==r.kind&&(o=r);const l=[];for(let i=3;i<t.length;i+=2){const r=t[i];if("number"!=typeof r)throw new Error(`"${s}" requires stop inputs as literal numbers`);if(l.length&&l[l.length-1][0]>=r)throw new Error(`"${s}" requires strictly ascending stop inputs`);const n=pt(t[i+1],e,o);o||(o=n.type),l.push([r,n])}if(o&&o!==u&&o!==i&&("array"!==o.kind||o.itemType!==i))throw new Error(`"${s}" cannot interpolate type ${p(o)}`);return new U(s,o,n,a,l)}evaluate(n,o){const i=this._stops;if(1===i.length)return i[0][1].evaluate(n,o);const l=this.input.evaluate(n,o);if(l<=i[0][0])return i[0][1].evaluate(n,o);if(l>=i[i.length-1][0])return i[i.length-1][1].evaluate(n,o);let u=0;for(;++u<i.length&&!(l<i[u][0]););const c=i[u-1][0],h=i[u][0],g=U.interpolationRatio(this.interpolation,l,c,h),f=i[u-1][1].evaluate(n,o),w=i[u][1].evaluate(n,o);if("interpolate"===this._operator){if("array"===this.type.kind&&Array.isArray(f)&&Array.isArray(w))return f.map((t,e)=>a(t,w[e],g));if("color"===this.type.kind&&f instanceof t&&w instanceof t){const e=new t(f),r=new t(w);return new t([a(e.r,r.r,g),a(e.g,r.g,g),a(e.b,r.b,g),a(e.a,r.a,g)])}if("number"===this.type.kind&&"number"==typeof f&&"number"==typeof w)return a(f,w,g);throw new Error(`"${this._operator}" cannot interpolate type ${p(this.type)}`)}if("interpolate-hcl"===this._operator){const s=e(f),n=e(w),o=n.h-s.h,i=r({h:s.h+g*(o>180||o<-180?o-360*Math.round(o/360):o),c:a(s.c,n.c,g),l:a(s.l,n.l,g)});return new t({a:a(f.a,w.a,g),...i})}if("interpolate-lab"===this._operator){const e=s(f),n=s(w),o=r({l:a(e.l,n.l,g),a:a(e.a,n.a,g),b:a(e.b,n.b,g)});return new t({a:a(f.a,w.a,g),...o})}throw new Error(`Unexpected operator "${this._operator}"`)}interpolationUniformValue(t,e){const r=this._stops;if(1===r.length)return 0;if(t>=r[r.length-1][0])return 0;let s=0;for(;++s<r.length&&!(t<r[s][0]););const n=r[s-1][0],a=r[s][0];return U.interpolationRatio(this.interpolation,e,n,a)}getInterpolationRange(t){const e=this._stops;if(1===e.length){const t=e[0][0];return[t,t]}const r=e[e.length-1][0];if(t>=r)return[r,r];let s=0;for(;++s<e.length&&!(t<e[s][0]););return[e[s-1][0],e[s][0]]}static interpolationRatio(t,e,r,s){let a=0;if("linear"===t[0])a=U._exponentialInterpolationRatio(e,1,r,s);else if("exponential"===t[0])a=U._exponentialInterpolationRatio(e,t[1],r,s);else if("cubic-bezier"===t[0]){a=n(t[1],t[2],t[3],t[4])(U._exponentialInterpolationRatio(e,1,r,s),1e-5)}return a<0?a=0:a>1&&(a=1),a}static _exponentialInterpolationRatio(t,e,r,s){const n=s-r;if(0===n)return 0;const a=t-r;return 1===e?a/n:(e**a-1)/(e**n-1)}}class B{constructor(t,e,r){this.type=t,this._input=e,this._stops=r}static parse(t,e){if(t.length<5)throw new Error('"step" expects at least 4 arguments');if(t.length%2!=1)throw new Error('"step" expects an even number of arguments');const r=pt(t[1],e,i);let s;const n=[];n.push([-1/0,pt(t[2],e)]);for(let a=3;a<t.length;a+=2){const r=t[a];if("number"!=typeof r)throw new Error('"step" requires stop inputs as literal numbers');if(n.length&&n[n.length-1][0]>=r)throw new Error('"step" requires strictly ascending stop inputs');const o=pt(t[a+1],e);s||(s=o.type),n.push([r,o])}return new B(s,r,n)}evaluate(t,e){const r=this._stops;if(1===r.length)return r[0][1].evaluate(t,e);const s=this._input.evaluate(t,e);let n=0;for(;++n<r.length&&!(s<r[n][0]););return this._stops[n-1][1].evaluate(t,e)}}class S{constructor(t,e){this.type=t,this._output=e}static parse(t,e,r){if(t.length<4)throw new Error('"let" expects at least 3 arguments');if(t.length%2==1)throw new Error('"let" expects an odd number of arguments');const s=new y(e);for(let a=1;a<t.length-1;a+=2){const r=t[a];if("string"!=typeof r)throw new Error(`"let" requires a string to define variable names - found ${r}`);s.add(r,pt(t[a+1],e))}const n=pt(t[t.length-1],s,r);return new S(n.type,n)}evaluate(t,e){return this._output.evaluate(t,e)}}class P{constructor(t,e){this.type=t,this.output=e}static parse(t,e,r){if(2!==t.length||"string"!=typeof t[1])throw new Error('"var" requires just one literal string argument');const s=e.get(t[1]);if(!s)throw new Error(`${t[1]} must be defined before being used in a "var" expression`);return new P(r||h,s)}evaluate(t,e){return this.output.evaluate(t,e)}}class O{constructor(t,e,r){this.type=t,this._index=e,this._array=r}static parse(t,e){if(3!==t.length)throw new Error('"at" expects 2 arguments');const r=pt(t[1],e,i),s=pt(t[2],e);return new O(s.type.itemType,r,s)}evaluate(t,e){const r=this._index.evaluate(t,e),s=this._array.evaluate(t,e);if(r<0||r>=s.length)throw new Error('"at" index out of bounds');if(r!==Math.floor(r))throw new Error('"at" index must be an integer');return s[r]}}class T{constructor(t){this._args=t,this.type=h}static parse(t,e){const r=t.slice(1).map(t=>Array.isArray(t)?pt(t,e):t);return new T(r)}evaluate(t,e){const r=(t,e)=>Array.from({length:t.length/2},(r,s)=>e(t[2*s],t[2*s+1])),s=(t,e)=>t;let n;return this._args&&(n=this._args.map(r=>r&&r.evaluate?r.evaluate(t,e):r)),!n||n.length<2&&n.length%2==1?"":r(n,s).join()}}class F{constructor(t,e){this._key=t,this._obj=e,this.type=h}static parse(t,e){let r,s;switch(t.length){case 2:return r=pt(t[1],e),new F(r);case 3:return r=pt(t[1],e),s=pt(t[2],e),new F(r,s);default:throw new Error('"get" expects 1 or 2 arguments')}}evaluate(t,e){const r=this._key.evaluate(t,e);if(this._obj){return this._obj.evaluate(t,e)[r]}return t?.values[r]}}class G{constructor(t,e){this._key=t,this._obj=e,this.type=o}static parse(t,e){let r,s;switch(t.length){case 2:return r=pt(t[1],e),new G(r);case 3:return r=pt(t[1],e),s=pt(t[2],e),new G(r,s);default:throw new Error('"has" expects 1 or 2 arguments')}}evaluate(t,e){const r=this._key.evaluate(t,e);if(this._obj){return r in this._obj.evaluate(t,e)}return!!t?.values[r]}}class V{constructor(t,e){this._key=t,this._vals=e,this.type=o}static parse(t,e){if(3!==t.length)throw new Error('"in" expects 2 arguments');return new V(pt(t[1],e),pt(t[2],e))}evaluate(t,e){const r=this._key.evaluate(t,e);return this._vals.evaluate(t,e).includes(r)}}class D{constructor(t,e,r){this._item=t,this._array=e,this._from=r,this.type=i}static parse(t,e){if(t.length<3||t.length>4)throw new Error('"index-of" expects 3 or 4 arguments');const r=pt(t[1],e),s=pt(t[2],e);if(4===t.length){const n=pt(t[3],e,i);return new D(r,s,n)}return new D(r,s)}evaluate(t,e){const r=this._item.evaluate(t,e),s=this._array.evaluate(t,e);if(this._from){const n=this._from.evaluate(t,e);if(n!==Math.floor(n))throw new Error('"index-of" index must be an integer');return s.indexOf(r,n)}return s.indexOf(r)}}class H{constructor(t){this._arg=t,this.type=i}static parse(t,e){if(2!==t.length)throw new Error('"length" expects 2 arguments');const r=pt(t[1],e);return new H(r)}evaluate(t,e){const r=this._arg.evaluate(t,e);if("string"==typeof r)return r.length;if(Array.isArray(r))return r.length;throw new Error('"length" expects string or array')}}class J{constructor(t,e,r,s){this.type=t,this._array=e,this._from=r,this._to=s}static parse(t,e){if(t.length<3||t.length>4)throw new Error('"slice" expects 2 or 3 arguments');const r=pt(t[1],e),s=pt(t[2],e,i);if(s.type!==i)throw new Error('"slice" index must return a number');if(4===t.length){const n=pt(t[3],e,i);if(n.type!==i)throw new Error('"slice" index must return a number');return new J(r.type,r,s,n)}return new J(r.type,r,s)}evaluate(t,e){const r=this._array.evaluate(t,e);if(!Array.isArray(r)&&"string"!=typeof r)throw new Error('"slice" input must be an array or a string');const s=this._from.evaluate(t,e);if(s<0||s>=r.length)throw new Error('"slice" index out of bounds');if(s!==Math.floor(s))throw new Error('"slice" index must be an integer');if(this._to){const n=this._to.evaluate(t,e);if(n<0||n>=r.length)throw new Error('"slice" index out of bounds');if(n!==Math.floor(n))throw new Error('"slice" index must be an integer');return r.slice(s,n)}return r.slice(s)}}class K{constructor(){this.type=o}static parse(t){if(1!==t.length)throw new Error('"has-id" expects no arguments');return new K}evaluate(t,e){return void 0!==t?.id}}class Q{constructor(t,e){this._args=t,this._calculate=e,this.type=i}static parse(t,e,r){const s=t.slice(1).map(t=>pt(t,e));return new Q(s,r)}evaluate(t,e){let r;return this._args&&(r=this._args.map(r=>r.evaluate(t,e))),this._calculate(r)}}class W extends Q{static parse(t,e){switch(t.length){case 2:return Q.parse(t,e,t=>-t[0]);case 3:return Q.parse(t,e,t=>t[0]-t[1]);default:throw new Error('"-" expects 1 or 2 arguments')}}}class X extends Q{static parse(t,e){return Q.parse(t,e,t=>{let e=1;for(const r of t)e*=r;return e})}}class Y extends Q{static parse(t,e){if(3===t.length)return Q.parse(t,e,t=>t[0]/t[1]);throw new Error('"/" expects 2 arguments')}}class Z extends Q{static parse(t,e){if(3===t.length)return Q.parse(t,e,t=>t[0]%t[1]);throw new Error('"%" expects 2 arguments')}}class tt extends Q{static parse(t,e){if(3===t.length)return Q.parse(t,e,t=>t[0]**t[1]);throw new Error('"^" expects 1 or 2 arguments')}}class et extends Q{static parse(t,e){return Q.parse(t,e,t=>{let e=0;for(const r of t)e+=r;return e})}}class rt{constructor(t,e){this._args=t,this._calculate=e,this.type=i}static{this.ops={abs:t=>Math.abs(t[0]),acos:t=>Math.acos(t[0]),asin:t=>Math.asin(t[0]),atan:t=>Math.atan(t[0]),ceil:t=>Math.ceil(t[0]),cos:t=>Math.cos(t[0]),e:()=>Math.E,floor:t=>Math.floor(t[0]),ln:t=>Math.log(t[0]),ln2:()=>Math.LN2,log10:t=>Math.log(t[0])/Math.LN10,log2:t=>Math.log(t[0])/Math.LN2,max:t=>Math.max(...t),min:t=>Math.min(...t),pi:()=>Math.PI,round:t=>Math.round(t[0]),sin:t=>Math.sin(t[0]),sqrt:t=>Math.sqrt(t[0]),tan:t=>Math.tan(t[0])}}static parse(t,e){const r=t.slice(1).map(t=>pt(t,e));return new rt(r,rt.ops[t[0]])}evaluate(t,e){let r;return this._args&&(r=this._args.map(r=>r.evaluate(t,e))),this._calculate(r)}}class st{constructor(t){this._args=t,this.type=c}static parse(t,e){return new st(t.slice(1).map(t=>pt(t,e)))}evaluate(t,e){return this._args.map(r=>r.evaluate(t,e)).join("")}}class nt{constructor(t,e){this._arg=t,this._calculate=e,this.type=c}static{this.ops={downcase:t=>t.toLowerCase(),upcase:t=>t.toUpperCase()}}static parse(t,e){if(2!==t.length)throw new Error(`${t[0]} expects 1 argument`);const r=pt(t[1],e);return new nt(r,nt.ops[t[0]])}evaluate(t,e){return this._calculate(this._arg.evaluate(t,e))}}class at{constructor(t){this._args=t,this.type=u}static parse(t,e){if(4!==t.length)throw new Error('"rgb" expects 3 arguments');const r=t.slice(1).map(t=>pt(t,e));return new at(r)}evaluate(e,r){const s=this._validate(this._args[0].evaluate(e,r)),n=this._validate(this._args[1].evaluate(e,r)),a=this._validate(this._args[2].evaluate(e,r));return new t({r:s,g:n,b:a})}_validate(t){if("number"!=typeof t||t<0||t>255)throw new Error(`${t}: invalid color component`);return Math.round(t)}}class ot{constructor(t){this._args=t,this.type=u}static parse(t,e){if(5!==t.length)throw new Error('"rgba" expects 4 arguments');const r=t.slice(1).map(t=>pt(t,e));return new ot(r)}evaluate(e,r){const s=this._validate(this._args[0].evaluate(e,r)),n=this._validate(this._args[1].evaluate(e,r)),a=this._validate(this._args[2].evaluate(e,r)),o=this._validateAlpha(this._args[3].evaluate(e,r));return new t({r:s,g:n,b:a,a:o})}_validate(t){if("number"!=typeof t||t<0||t>255)throw new Error(`${t}: invalid color component`);return Math.round(t)}_validateAlpha(t){if("number"!=typeof t||t<0||t>1)throw new Error(`${t}: invalid alpha color component`);return t}}class it{constructor(t){this._color=t,this.type=l(i,4)}static parse(t,e){if(2!==t.length)throw new Error('"to-rgba" expects 1 argument');const r=pt(t[1],e);return new it(r)}evaluate(e,r){return new t(this._color.evaluate(e,r)).toRgba()}}class lt{constructor(t,e){this.type=t,this._args=e}static parse(t,e){const r=t[0];if(t.length<2)throw new Error(`${r} expects at least one argument`);let s,n=1;if("array"===r){if(t.length>2){switch(t[1]){case"string":s=c;break;case"number":s=i;break;case"boolean":s=o;break;default:throw new Error('"array" type argument must be string, number or boolean')}n++}else s=h;let e;if(t.length>3){if(e=t[2],null!==e&&("number"!=typeof e||e<0||e!==Math.floor(e)))throw new Error('"array" length argument must be a positive integer literal');n++}s=l(s,e)}else switch(r){case"string":s=c;break;case"number":s=i;break;case"boolean":s=o;break;case"object":s=g}const a=[];for(;n<t.length;n++){const r=pt(t[n],e);a.push(r)}return new lt(s,a)}evaluate(t,e){let r;for(const s of this._args){const n=s.evaluate(t,e);if(r=f(n),m(r,this.type))return n}throw new Error(`Expected ${p(this.type)} but got ${p(r)}`)}}class ut{static{this.types={"to-boolean":o,"to-color":u,"to-number":i,"to-string":c}}constructor(t,e){this.type=t,this._args=e}static parse(t,e){const r=t[0],s=ut.types[r];if(s===o||s===c){if(2!==t.length)throw new Error(`${r} expects one argument`)}else if(t.length<2)throw new Error(`${r} expects at least one argument`);const n=[];for(let a=1;a<t.length;a++){const r=pt(t[a],e);n.push(r)}return new ut(s,n)}evaluate(e,r){if(this.type===o)return Boolean(this._args[0].evaluate(e,r));if(this.type===c)return w(this._args[0].evaluate(e,r));if(this.type===i){for(const t of this._args){const s=Number(t.evaluate(e,r));if(!isNaN(s))return s}return null}if(this.type===u){for(const s of this._args)try{const n=ut.toColor(s.evaluate(e,r));if(n instanceof t)return n}catch{}return null}}static toBoolean(t){return Boolean(t)}static toString(t){return w(t)}static toNumber(t){const e=Number(t);if(isNaN(e))throw new Error(`"${t}" is not a number`);return e}static toColor(e){if(e instanceof t)return e;if("string"==typeof e){const r=t.fromString(e);if(r)return r;throw new Error(`"${e}" is not a color`)}if(Array.isArray(e))return t.fromArray(e);throw new Error(`"${e}" is not a color`)}}class ct{constructor(t){this._val=t,this.type=f(t)}static parse(t){if(2!==t.length)throw new Error('"literal" expects 1 argument');return new ct(t[1])}evaluate(t,e){return this._val}}class ht{constructor(t){this._arg=t,this.type=c}static parse(t,e){if(2!==t.length)throw new Error('"typeof" expects 1 argument');return new ht(pt(t[1],e))}evaluate(t,e){return p(f(this._arg.evaluate(t,e)))}}function pt(t,e,r){const s=typeof t;if("string"===s||"boolean"===s||"number"===s||null===t){if(r)switch(r.kind){case"string":"string"!==s&&(t=ut.toString(t));break;case"number":"number"!==s&&(t=ut.toNumber(t));break;case"color":t=ut.toColor(t)}t=["literal",t]}if(!Array.isArray(t)||0===t.length)throw new Error("Expression must be a non empty array");const n=t[0];if("string"!=typeof n)throw new Error("First element of expression must be a string");const a=gt[n];if(void 0===a)throw new Error(`Invalid expression operator "${n}"`);if(!a)throw new Error(`Unimplemented expression operator "${n}"`);return a.parse(t,e,r)}const gt={array:lt,boolean:lt,collator:null,format:T,image:null,literal:ct,number:lt,"number-format":null,object:lt,string:lt,"to-boolean":ut,"to-color":ut,"to-number":ut,"to-string":ut,typeof:ht,accumulated:null,"feature-state":null,"geometry-type":v,id:_,"line-progress":null,properties:b,at:O,get:F,has:G,in:V,"index-of":D,length:H,slice:J,"!":q,"!=":$,"<":M,"<=":k,"==":E,">":A,">=":j,all:N,any:R,case:z,coalesce:I,match:L,within:null,interpolate:U,"interpolate-hcl":U,"interpolate-lab":U,step:B,let:S,var:P,concat:st,downcase:nt,"is-supported-script":null,"resolved-locale":null,upcase:nt,rgb:at,rgba:ot,"to-rgba":it,"-":W,"*":X,"/":Y,"%":Z,"^":tt,"+":et,abs:rt,acos:rt,asin:rt,atan:rt,ceil:rt,cos:rt,e:rt,floor:rt,ln:rt,ln2:rt,log10:rt,log2:rt,max:rt,min:rt,pi:rt,round:rt,sin:rt,sqrt:rt,tan:rt,zoom:d,"heatmap-density":null,"has-id":K,none:C};export{N as ALL,R as ANY,et as Add,lt as Assert,O as At,rt as Calculate,z as Case,I as Coalesce,ut as Coerce,st as Concat,Y as Div,E as EQ,T as Format,j as GE,A as GT,v as GeomType,F as Get,G as Has,K as HasID,_ as ID,V as In,D as IndexOf,U as Interpolate,k as LE,M as LT,H as Length,S as Let,ct as Literal,L as Match,Z as Mod,X as Mul,$ as NE,C as NONE,q as NOT,tt as Pow,b as Properties,at as Rgb,ot as Rgba,J as Slice,B as Step,nt as String,W as Sub,it as ToRgba,ht as TypeOf,P as Var,d as Zoom,pt as createExpression,gt as ops};