{"version":3,"file":"evaluation_context.mjs","names":[],"sources":["../../src/expression/evaluation_context.ts"],"sourcesContent":["import type {FormattedSection} from './types/formatted';\nimport type {GlobalProperties, Feature, FeatureState} from './index';\nimport {ICanonicalTileID} from '../tiles_and_coordinates';\nimport {Color} from './types/color';\n\nconst geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];\n\nexport class EvaluationContext {\n    globals: GlobalProperties;\n    feature: Feature;\n    featureState: FeatureState;\n    formattedSection: FormattedSection;\n    availableImages: Array<string>;\n    canonical: ICanonicalTileID;\n\n    _parseColorCache: Map<string, Color>;\n\n    constructor() {\n        this.globals = null;\n        this.feature = null;\n        this.featureState = null;\n        this.formattedSection = null;\n        this._parseColorCache = new Map<string, Color>();\n        this.availableImages = null;\n        this.canonical = null;\n    }\n\n    id() {\n        return this.feature && 'id' in this.feature ? this.feature.id : null;\n    }\n\n    geometryType() {\n        return this.feature\n            ? typeof this.feature.type === 'number'\n                ? geometryTypes[this.feature.type]\n                : this.feature.type\n            : null;\n    }\n\n    geometry() {\n        return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;\n    }\n\n    canonicalID() {\n        return this.canonical;\n    }\n\n    properties() {\n        return (this.feature && this.feature.properties) || {};\n    }\n\n    parseColor(input: string): Color {\n        let cached = this._parseColorCache.get(input);\n        if (!cached) {\n            cached = Color.parse(input);\n            this._parseColorCache.set(input, cached);\n        }\n        return cached;\n    }\n}\n"],"mappings":";;AAKA,MAAM,gBAAgB;CAAC;CAAW;CAAS;CAAc;AAAS;AAElE,IAAa,oBAAb,MAA+B;CAU3B,cAAc;EACV,KAAK,UAAU;EACf,KAAK,UAAU;EACf,KAAK,eAAe;EACpB,KAAK,mBAAmB;EACxB,KAAK,mCAAmB,IAAI,IAAmB;EAC/C,KAAK,kBAAkB;EACvB,KAAK,YAAY;CACrB;CAEA,KAAK;EACD,OAAO,KAAK,WAAW,QAAQ,KAAK,UAAU,KAAK,QAAQ,KAAK;CACpE;CAEA,eAAe;EACX,OAAO,KAAK,UACN,OAAO,KAAK,QAAQ,SAAS,WACzB,cAAc,KAAK,QAAQ,QAC3B,KAAK,QAAQ,OACjB;CACV;CAEA,WAAW;EACP,OAAO,KAAK,WAAW,cAAc,KAAK,UAAU,KAAK,QAAQ,WAAW;CAChF;CAEA,cAAc;EACV,OAAO,KAAK;CAChB;CAEA,aAAa;EACT,OAAQ,KAAK,WAAW,KAAK,QAAQ,cAAe,CAAC;CACzD;CAEA,WAAW,OAAsB;EAC7B,IAAI,SAAS,KAAK,iBAAiB,IAAI,KAAK;EAC5C,IAAI,CAAC,QAAQ;GACT,SAAS,MAAM,MAAM,KAAK;GAC1B,KAAK,iBAAiB,IAAI,OAAO,MAAM;EAC3C;EACA,OAAO;CACX;AACJ"}