/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{srToRESTValue as e}from"../../geometry/support/spatialReferenceUtils.js";import{serializeLayerDefinitions as s}from"../../layers/support/layerUtils.js";function i(i){const{contains:t,dynamicLayers:r,geometryPrecision:n,layerDefinitions:o,layerIds:l,maxAllowableOffset:a,outSR:c,returnGeometry:f,searchFields:y,searchText:d}=i.toJSON(),m={contains:t,returnGeometry:f,geometryPrecision:n,maxAllowableOffset:a,searchText:d};if(l&&(m.layers=l.join(",")),y&&(m.searchFields=y.join(",")),c&&(m.sr=e(c)),o){const e=[];for(let s=0;s<o.length;s++){const i=o[s];e[i.id]=i.definitionExpression}m.layerDefs=s(e)}if(r?.length){const e=[];for(let i=0;i<r.length;i++){const s=r[i],t=s.id;if(!s.subLayerIds&&l?.includes(t)){const i={id:t};i.source=s.source;let r=null;if(o?.length){const e=o.find(e=>e.id===t);r=e?.definitionExpression}r&&(i.definitionExpression=r),e.push(i)}}let s=JSON.stringify(e);"[]"===s&&(s="[{}]"),m.dynamicLayers=s}return m}export{i as findToFindRESTParameters};
