/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{parseWhereClause as i}from"../../../core/sql.js";import{getRelativeTimeFields as e}from"../../../layers/support/relativeTimeQueryUtils.js";class s{constructor(i){this._fieldsIndex=i,this._clauses=[]}async finish(){return{requiresCurrentUser:(await Promise.all(this._clauses)).some(i=>i?.currentUserRequired)}}visitClientWhereClause(e){e&&this._clauses.push(i(e,this._fieldsIndex))}visitFeatureReduction(i){if(i)switch(i.type){case"binning":case"cluster":this.visitLabelingInfo(i.labelsVisible,i.labelingInfo)}}visitLabelingInfo(i,e){if(i&&null!=e)for(const s of e)this.visitClientWhereClause(s.where)}visitDisplayFilter(i,e){if(i)for(const s of e?.filters??[])this.visitClientWhereClause(s.where)}visitFilter(i){this.visitClientWhereClause(i?.where)}visitRelativeTimeQuery(s){this._clauses.push(e(this._fieldsIndex,s).then(e=>s&&e.length>0?i(s,this._fieldsIndex):null))}visitTrackInfo(i){null!=i&&(this.visitLabelingInfo(i?.latestObservations.labelsVisible,i?.latestObservations.labelingInfo),this.visitLabelingInfo(i?.previousObservations.labelsVisible,i?.previousObservations.labelingInfo),this.visitLabelingInfo(i?.trackLines.labelsVisible,i?.trackLines.labelingInfo))}}export{s as WhereClauseVisitor};
