import { EventType_default, Event_default, Target_default, listen, listenOnce, unlistenByKey } from "./chunk-KJXIHBKT.js"; import { isEmpty } from "./chunk-5RHQVMYD.js"; // node_modules/ol/util.js function abstract() { throw new Error("Unimplemented abstract method."); } var uidCounter_ = 0; function getUid(obj) { return obj.ol_uid || (obj.ol_uid = String(++uidCounter_)); } var VERSION = "10.6.1"; // node_modules/ol/ObjectEventType.js var ObjectEventType_default = { /** * Triggered when a property is changed. * @event module:ol/Object.ObjectEvent#propertychange * @api */ PROPERTYCHANGE: "propertychange" }; // node_modules/ol/Observable.js var Observable = class extends Target_default { constructor() { super(); this.on = /** @type {ObservableOnSignature} */ this.onInternal; this.once = /** @type {ObservableOnSignature} */ this.onceInternal; this.un = /** @type {ObservableOnSignature} */ this.unInternal; this.revision_ = 0; } /** * Increases the revision counter and dispatches a 'change' event. * @api */ changed() { ++this.revision_; this.dispatchEvent(EventType_default.CHANGE); } /** * Get the version number for this object. Each time the object is modified, * its version number will be incremented. * @return {number} Revision. * @api */ getRevision() { return this.revision_; } /** * @param {string|Array} type Type. * @param {function((Event|import("./events/Event").default)): ?} listener Listener. * @return {import("./events.js").EventsKey|Array} Event key. * @protected */ onInternal(type, listener) { if (Array.isArray(type)) { const len = type.length; const keys = new Array(len); for (let i = 0; i < len; ++i) { keys[i] = listen(this, type[i], listener); } return keys; } return listen( this, /** @type {string} */ type, listener ); } /** * @param {string|Array} type Type. * @param {function((Event|import("./events/Event").default)): ?} listener Listener. * @return {import("./events.js").EventsKey|Array} Event key. * @protected */ onceInternal(type, listener) { let key; if (Array.isArray(type)) { const len = type.length; key = new Array(len); for (let i = 0; i < len; ++i) { key[i] = listenOnce(this, type[i], listener); } } else { key = listenOnce( this, /** @type {string} */ type, listener ); } listener.ol_key = key; return key; } /** * Unlisten for a certain type of event. * @param {string|Array} type Type. * @param {function((Event|import("./events/Event").default)): ?} listener Listener. * @protected */ unInternal(type, listener) { const key = ( /** @type {Object} */ listener.ol_key ); if (key) { unByKey(key); } else if (Array.isArray(type)) { for (let i = 0, ii = type.length; i < ii; ++i) { this.removeEventListener(type[i], listener); } } else { this.removeEventListener(type, listener); } } }; Observable.prototype.on; Observable.prototype.once; Observable.prototype.un; function unByKey(key) { if (Array.isArray(key)) { for (let i = 0, ii = key.length; i < ii; ++i) { unlistenByKey(key[i]); } } else { unlistenByKey( /** @type {import("./events.js").EventsKey} */ key ); } } var Observable_default = Observable; // node_modules/ol/Object.js var ObjectEvent = class extends Event_default { /** * @param {string} type The event type. * @param {string} key The property name. * @param {*} oldValue The old value for `key`. */ constructor(type, key, oldValue) { super(type); this.key = key; this.oldValue = oldValue; } }; var BaseObject = class extends Observable_default { /** * @param {Object} [values] An object with key-value pairs. */ constructor(values) { super(); this.on; this.once; this.un; getUid(this); this.values_ = null; if (values !== void 0) { this.setProperties(values); } } /** * Gets a value. * @param {string} key Key name. * @return {*} Value. * @api */ get(key) { let value; if (this.values_ && this.values_.hasOwnProperty(key)) { value = this.values_[key]; } return value; } /** * Get a list of object property names. * @return {Array} List of property names. * @api */ getKeys() { return this.values_ && Object.keys(this.values_) || []; } /** * Get an object of all property names and values. * @return {Object} Object. * @api */ getProperties() { return this.values_ && Object.assign({}, this.values_) || {}; } /** * Get an object of all property names and values. * @return {Object?} Object. */ getPropertiesInternal() { return this.values_; } /** * @return {boolean} The object has properties. */ hasProperties() { return !!this.values_; } /** * @param {string} key Key name. * @param {*} oldValue Old value. */ notify(key, oldValue) { let eventType; eventType = `change:${key}`; if (this.hasListener(eventType)) { this.dispatchEvent(new ObjectEvent(eventType, key, oldValue)); } eventType = ObjectEventType_default.PROPERTYCHANGE; if (this.hasListener(eventType)) { this.dispatchEvent(new ObjectEvent(eventType, key, oldValue)); } } /** * @param {string} key Key name. * @param {import("./events.js").Listener} listener Listener. */ addChangeListener(key, listener) { this.addEventListener(`change:${key}`, listener); } /** * @param {string} key Key name. * @param {import("./events.js").Listener} listener Listener. */ removeChangeListener(key, listener) { this.removeEventListener(`change:${key}`, listener); } /** * Sets a value. * @param {string} key Key name. * @param {*} value Value. * @param {boolean} [silent] Update without triggering an event. * @api */ set(key, value, silent) { const values = this.values_ || (this.values_ = {}); if (silent) { values[key] = value; } else { const oldValue = values[key]; values[key] = value; if (oldValue !== value) { this.notify(key, oldValue); } } } /** * Sets a collection of key-value pairs. Note that this changes any existing * properties and adds new ones (it does not remove any existing properties). * @param {Object} values Values. * @param {boolean} [silent] Update without triggering an event. * @api */ setProperties(values, silent) { for (const key in values) { this.set(key, values[key], silent); } } /** * Apply any properties from another object without triggering events. * @param {BaseObject} source The source object. * @protected */ applyProperties(source) { if (!source.values_) { return; } Object.assign(this.values_ || (this.values_ = {}), source.values_); } /** * Unsets a property. * @param {string} key Key name. * @param {boolean} [silent] Unset without triggering an event. * @api */ unset(key, silent) { if (this.values_ && key in this.values_) { const oldValue = this.values_[key]; delete this.values_[key]; if (isEmpty(this.values_)) { this.values_ = null; } if (!silent) { this.notify(key, oldValue); } } } }; var Object_default = BaseObject; export { abstract, getUid, VERSION, ObjectEventType_default, Observable_default, Object_default }; //# sourceMappingURL=chunk-H47PV7W6.js.map