import { l } from "./chunk-QC7NCR5N.js"; import { m as m2 } from "./chunk-E3G7BRZB.js"; import { e, m, n5 as n, y3 as y } from "./chunk-2Z2TG5CU.js"; import { s } from "./chunk-YXWMMD76.js"; // node_modules/@arcgis/core/views/2d/tiling/PagedTileQueue.js function u(e2, t) { return e2.length = 0, t.forEach((t2) => e2.push(t2)), e2; } var a = /* @__PURE__ */ new Set(); var c = []; var h = /* @__PURE__ */ new Map(); var l2 = [0, 0]; var p = class extends m { constructor(e2) { super(e2), this._keyToItem = /* @__PURE__ */ new Map(), this.concurrency = 6, this.strategy = "scale-first", this.tileInfoView = null; } initialize() { const { concurrency: e2, process: t } = this; this._queue = new l({ concurrency: e2, process: (e3, s2) => { const r = this._keyToItem.get(e3); return t(r, { signal: s2 }); }, peeker: (e3) => e3.values().next().value }); } destroy() { this.clear(), this._queue = s(this._queue); } get length() { return this._queue ? this._queue.length : 0; } get onGoingCount() { return this._keyToItem.size; } get updating() { return this.length > 0 || this.onGoingCount > 0; } abort(e2) { const t = "string" == typeof e2 ? e2 : e2.id; this._queue.abort(t); } clear() { this._queue.clear(), this._keyToItem.clear(), this.notifyChange("updating"); } has(e2) { return "string" == typeof e2 ? this._keyToItem.has(e2) : this._keyToItem.has(e2.id); } isOngoing(e2) { const t = "string" == typeof e2 ? e2 : e2.id; return this.has(t) && this._queue.isOngoing(t); } pause() { this._queue.pause(); } push(e2, t) { const s2 = e2.key.id + "-" + t; if (this.has(s2)) return this.get(s2); const r = this._queue.push(s2), o = () => { this._keyToItem.delete(s2), this.notifyChange("updating"); }; return this._keyToItem.set(s2, e2), r.then(o, o), this.notifyChange("updating"), r; } reset() { this._queue.reset(), this.notifyChange("updating"); } resume() { this._queue.resume(); } _peekByScaleFirst(e2) { if (!this.state) return e2.values().next().value; const t = this.tileInfoView; let s2 = Number.NEGATIVE_INFINITY, r = Number.POSITIVE_INFINITY; e2.forEach((e3) => { const t2 = this._keyToItem.get(e3), o2 = this.tileInfoView.getTileScale(t2.key); h.has(o2) || (h.set(o2, []), s2 = Math.max(o2, s2), r = Math.min(o2, r)), h.get(o2).push(t2.key), a.add(o2); }); let o = this.state.scale; h.has(o) || (u(c, a), c.sort((e3, t2) => e3 - t2), o = c.reduce((e3, t2) => Math.abs(t2 - o) < Math.abs(e3 - o) ? t2 : e3, c[0])), o = Math.min(o, s2), o = Math.max(o, r); const i = h.get(o), n2 = t.getClosestInfoForScale(o), l3 = n2.getColumnForX(this.state.center[0]), p2 = n2.getRowForY(this.state.center[1]); return i.sort((e3, t2) => { const s3 = n2.denormalizeCol(e3.col, e3.world), r2 = n2.denormalizeCol(t2.col, t2.world); return Math.sqrt((l3 - s3) * (l3 - s3) + (p2 - e3.row) * (p2 - e3.row)) - Math.sqrt((l3 - r2) * (l3 - r2) + (p2 - t2.row) * (p2 - t2.row)); }), a.clear(), h.clear(), i[0].id; } _peekByCenterFirst(e2) { if (!this.state) return e2.values().next().value; const t = this.tileInfoView, s2 = this.state.center; let r, o = Number.POSITIVE_INFINITY; return e2.forEach((e3) => { const n2 = this._keyToItem.get(e3); t.getTileCoords(l2, n2.key); const u2 = m2(l2, s2); u2 < o && (o = u2, r = n2.key); }), r.id; } }; e([y({ constructOnly: true })], p.prototype, "concurrency", void 0), e([y({ constructOnly: true })], p.prototype, "process", void 0), e([y()], p.prototype, "state", void 0), e([y({ constructOnly: true })], p.prototype, "strategy", void 0), e([y({ constructOnly: true })], p.prototype, "tileInfoView", void 0), e([y({ readOnly: true })], p.prototype, "updating", null), p = e([n("esri.views.2d.tiling.PagedTileQueue")], p); //# sourceMappingURL=chunk-L5DZVCCW.js.map