/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../chunks/_rollupPluginBabelHelpers","../../core/Error","../../core/has","../../core/maybe","../../core/promiseUtils","../../layers/support/source/DataLayerSource","./executeQueryJSON","./executeQueryPBF","../support/FeatureSet","../support/Query"],(function(e,t,o,r,n,i,a,u,s,c,f,l){"use strict";function d(e,t,o,r){return p.apply(this,arguments)}function p(){return(p=o._asyncToGenerator((function*(e,t,o,r){return y(e,t,o,r).then((e=>D(t,e,o,r)))}))).apply(this,arguments)}function y(e,t,o,r){return m.apply(this,arguments)}function m(){return(m=o._asyncToGenerator((function*(e,t,o,r){var i;const a={...r},u=F(t,o),f=null!=(null==(i=t.outStatistics)?void 0:i[0]),l=n("featurelayer-pbf-statistics"),d=!f||l;let p;if("pbf"===o.format&&d)try{p=yield c.executeRawQueryPBF(e,u,a)}catch(y){if("query:parsing-pbf"!==y.name)throw y;o.format="json"}return"json"!==o.format&&d||(p=yield s.executeRawQueryJSON(e,u,a)),S(o.fieldsIndex,p.fields),p}))).apply(this,arguments)}function S(e,t){if(i.isSome(e)&&i.isSome(t))for(const o of t){const t=e.get(o.name);t&&Object.assign(o,t.toJSON())}}function D(e,t,o,r){return b.apply(this,arguments)}function b(){return(b=o._asyncToGenerator((function*(t,o,r,n){if(!O(t,null==r?void 0:r.infoFor3D)||i.isNone(r.infoFor3D)||!o.features||!o.features.length)return f.fromJSON(o);const{meshFeatureSetFromJSON:u}=yield a.whenOrAbort(new Promise(((t,o)=>e(["../support/meshFeatureSet"],t,o))),n);return u(t,r.infoFor3D,o)}))).apply(this,arguments)}function F(e,t){let o=l.from(e);if(o.sourceSpatialReference=o.sourceSpatialReference||(null==t?void 0:t.sourceSpatialReference),(t.gdbVersion||t.dynamicDataSource)&&(o=o===e?o.clone():o,o.gdbVersion=e.gdbVersion||t.gdbVersion,o.dynamicDataSource=e.dynamicDataSource?u.DataLayerSource.from(e.dynamicDataSource):t.dynamicDataSource),i.isSome(t.infoFor3D)&&O(e,null==t?void 0:t.infoFor3D)){o=o===e?o.clone():o,o.formatOf3DObjects=null;for(const e of t.infoFor3D.queryFormats){if("3D_glb"===e.id){o.formatOf3DObjects=e.id;break}"3D_gltf"!==e.id||o.formatOf3DObjects||(o.formatOf3DObjects=e.id)}if(!o.formatOf3DObjects)throw new r("query:unsupported-3d-query-formats","Could not find any supported 3D object query format. Only supported formats are 3D_glb and 3D_gltf");if(i.isNone(o.outFields)||!o.outFields.includes("*")){o=o===e?o.clone():o,i.isNone(o.outFields)&&(o.outFields=[]);const{originX:r,originY:n,originZ:a,translationX:u,translationY:s,translationZ:c,scaleX:f,scaleY:l,scaleZ:d,rotationX:p,rotationY:y,rotationZ:m,rotationDeg:S}=t.infoFor3D.transformFieldRoles;o.outFields.push(r,n,a,u,s,c,f,l,d,p,y,m,S)}}return o}function O(e,t){return i.isSome(t)&&e.returnGeometry&&"xyFootprint"!==e.multipatchOption&&!e.outStatistics}t.executeQuery=d,t.executeRawQuery=y,t.normalizeFields=S,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
