/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{FeatureMatcher as e}from"./Matcher.js";class s extends e{static async fromLabelSchema(e,a){const r=a.classes.map(async s=>{const a=await e.createMeshWriters(s.meshes);return{minScale:s.minScale,maxScale:s.maxScale,meshes:a,expression:null,where:await e.storage.createWhereClause(s.where)}}),t=await Promise.all(r);return new s(t)}constructor(e){super(),this._labels=e}match(e,s,a){if(!this._labels.length)return null;const r=this._getLabels(s.$view.scale),t=[];for(const l of r)l.where&&!l.where(e,a)||t.push(...l.meshes);return t}hasArcadeDependency(e){return this._labels.some(s=>s.meshes.some(s=>s.hasArcadeDependency(e)))}_getLabels(e){return this._labels.filter(s=>this._validForTileScale(s,e))}_validForTileScale(e,s){const a=s-s/4,r=s+s/2;return(!e.minScale||e.minScale>=a)&&(!e.maxScale||e.maxScale<=r)}}export{s as LabelMatcher};
