pwaLUPMIS2/node_modules/.vite/deps/chunk-Q5ZULJHM.js
2026-03-04 12:59:40 +01:00

197 lines
4.7 KiB
JavaScript

import {
Event_default,
Observable_default
} from "./chunk-NGFXCWUF.js";
import {
isEmpty
} from "./chunk-5RHQVMYD.js";
// 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/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_));
}
// 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<string, *>} [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<string>} List of property names.
* @api
*/
getKeys() {
return this.values_ && Object.keys(this.values_) || [];
}
/**
* Get an object of all property names and values.
* @return {Object<string, *>} Object.
* @api
*/
getProperties() {
return this.values_ && Object.assign({}, this.values_) || {};
}
/**
* Get an object of all property names and values.
* @return {Object<string, *>?} 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<string, *>} 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 {
ObjectEventType_default,
abstract,
getUid,
Object_default
};
//# sourceMappingURL=chunk-Q5ZULJHM.js.map