import { u } from "./chunk-NE3ESGA6.js"; import { U, a, f, l } from "./chunk-YIS6BAC3.js"; import { d, e, n2 as n, v2 as v, y3 as y } from "./chunk-Y3WMVFTW.js"; import { t } from "./chunk-GZT4BVFP.js"; // node_modules/@arcgis/core/core/support/WatchUpdatingTracking.js var c = class extends y { constructor() { super(...arguments), this.updating = false, this.handleId = 0, this.handles = new u(), this.scheduleHandleId = 0, this.pendingPromises = new Set(); } destroy() { this.removeAll(), this.handles.destroy(); } add(e2, s, t2 = {}) { return this._installWatch(e2, s, t2, l); } addWhen(e2, s, t2 = {}) { return this._installWatch(e2, s, t2, f); } addOnCollectionChange(e2, s, { initial: t2 = false, final: i = false } = {}) { const n2 = ++this.handleId; return this.handles.add([a(e2, "after-changes", this._createSyncUpdatingCallback(), U), a(e2, "change", s, { onListenerAdd: t2 ? (e3) => s({ added: e3.toArray(), removed: [] }) : void 0, onListenerRemove: i ? (e3) => s({ added: [], removed: e3.toArray() }) : void 0 })], n2), { remove: () => this.handles.remove(n2) }; } addPromise(e2) { if (t(e2)) return e2; const s = ++this.handleId; this.handles.add({ remove: () => { this.pendingPromises.delete(e2) && (this.pendingPromises.size !== 0 || this.handles.has(p) || this._set("updating", false)); } }, s), this.pendingPromises.add(e2), this._set("updating", true); const t2 = () => this.handles.remove(s); return e2.then(t2, t2), e2; } removeAll() { this.pendingPromises.clear(), this.handles.removeAll(), this._set("updating", false); } _installWatch(e2, s, t2 = {}, i) { const n2 = ++this.handleId; t2.sync || this._installSyncUpdatingWatch(e2, n2); const d3 = i(e2, s, t2); return this.handles.add(d3, n2), { remove: () => this.handles.remove(n2) }; } _installSyncUpdatingWatch(e2, s) { const t2 = this._createSyncUpdatingCallback(), i = l(e2, t2, { sync: true, equals: () => false }); return this.handles.add(i, s), i; } _createSyncUpdatingCallback() { return () => { this.handles.remove(p), ++this.scheduleHandleId; const e2 = this.scheduleHandleId; this._get("updating") || this._set("updating", true), this.handles.add(v(() => { e2 === this.scheduleHandleId && (this._set("updating", this.pendingPromises.size > 0), this.handles.remove(p)); }), p); }; } }; e([d({ readOnly: true })], c.prototype, "updating", void 0), c = e([n("esri.core.support.WatchUpdatingTracking")], c); var p = -42; var m; !function(e2) { e2[e2.NONE = 0] = "NONE", e2[e2.SYNC = 1] = "SYNC", e2[e2.INIT = 2] = "INIT"; }(m || (m = {})); // node_modules/@arcgis/core/core/HandleOwner.js var a2 = (s) => { let a3 = class extends s { destroy() { this.destroyed || (this._get("handles")?.destroy(), this._get("updatingHandles")?.destroy()); } get handles() { return this._get("handles") || new u(); } get updatingHandles() { return this._get("updatingHandles") || new c(); } }; return e([d({ readOnly: true })], a3.prototype, "handles", null), e([d({ readOnly: true })], a3.prototype, "updatingHandles", null), a3 = e([n("esri.core.HandleOwner")], a3), a3; }; var d2 = class extends a2(y) { }; d2 = e([n("esri.core.HandleOwner")], d2); export { c, a2 as a, d2 as d }; //# sourceMappingURL=chunk-RMX2AZ4P.js.map