/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{sqlAnd as e}from"../../../../../core/sql.js";import l from"../../../../../layers/support/FeatureFilter.js";function o(e,l){return null!=e.floorInfo&&(e.floorInfo.viewAllLevelIds.length>0||l.floors.length>0)}function r(e,o,r){const t=n(e,o?.where,r);return t?(o??=new l,o.where=t,o):o}function n(l,o,r){if(null==l.floorInfo||!r.floors?.length)return o;let n=r.floors;const{floorField:t,viewAllLevelIds:f}=l.floorInfo;f.length&&(n=f);const s=n.filter(e=>""!==e).map(e=>"'"+e+"'");if(s.push("''"),o?.includes(t)){let e=new RegExp("AND \\("+t+".*NULL\\)","g");o=o.replace(e,""),e=new RegExp("\\("+t+".*NULL\\)","g"),o=(o=o.replace(e,"")).replaceAll(/\s+/g," ").trim()}let i="("+t+" IN ({ids}) OR "+t+" IS NULL)";return i=i.replace("{ids}",s.join(", ")),e(o,i)}export{r as addFloorFilter,o as hasFloorFilter};
