/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","../core/Accessor","../core/jsonMap","../core/lang","../core/maybe","../core/accessorSupport/decorators/property","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/subclass","../geometry/Extent","../geometry/SpatialReference","../geometry/support/webMercatorUtils"],(function(t,e,r,o,s,i,n,a,c,l,u,p){"use strict";var y;const d=new o.JSONMap({avgRating:"avg-rating",numRatings:"num-ratings",numComments:"num-comments",numViews:"num-views"});let h=y=function(e){function r(t){var r;return(r=e.call(this,t)||this).categories=null,r.disableExtraQuery=!1,r.extent=null,r.filter=null,r.num=10,r.query=null,r.sortField=null,r.start=1,r}t._inheritsLoose(r,e);var o=r.prototype;return o.clone=function(){return new y({categories:this.categories?s.clone(this.categories):null,disableExtraQuery:this.disableExtraQuery,extent:this.extent?this.extent.clone():null,filter:this.filter,num:this.num,query:this.query,sortField:this.sortField,sortOrder:this.sortOrder,start:this.start})},o.toRequestOptions=function(t,e){let r,o;if(this.categories&&(r=this.categories.map((t=>Array.isArray(t)?JSON.stringify(t):t))),this.extent){const t=p.project(this.extent,u.WGS84);i.isSome(t)&&(o=`${t.xmin},${t.ymin},${t.xmax},${t.ymax}`)}let s=this.query;!this.disableExtraQuery&&t.extraQuery&&(s="("+s+")"+t.extraQuery);const n={categories:r,bbox:o,q:s,filter:this.filter,num:this.num,sortField:null,sortOrder:null,start:this.start};return this.sortField&&(n.sortField=this.sortField.split(",").map((t=>d.toJSON(t.trim()))).join(","),n.sortOrder=this.sortOrder),{query:{...e,...n}}},t._createClass(r,[{key:"sortOrder",get:function(){return this._get("sortOrder")||"asc"},set:function(t){"asc"!==t&&"desc"!==t||this._set("sortOrder",t)}}]),r}(r);e.__decorate([n.property()],h.prototype,"categories",void 0),e.__decorate([n.property()],h.prototype,"disableExtraQuery",void 0),e.__decorate([n.property({type:l})],h.prototype,"extent",void 0),e.__decorate([n.property()],h.prototype,"filter",void 0),e.__decorate([n.property()],h.prototype,"num",void 0),e.__decorate([n.property()],h.prototype,"query",void 0),e.__decorate([n.property()],h.prototype,"sortField",void 0),e.__decorate([n.property()],h.prototype,"sortOrder",null),e.__decorate([n.property()],h.prototype,"start",void 0),h=y=e.__decorate([c.subclass("esri.portal.PortalQueryParams")],h);return h}));
