var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var lifecycles_exports = {};
__export(lifecycles_exports, {
  ATTRIBUTE_CHANGED_WILDCARD: () => ATTRIBUTE_CHANGED_WILDCARD,
  ON_ADD_EVENT_LISTENER_METADATA_KEY: () => ON_ADD_EVENT_LISTENER_METADATA_KEY,
  ON_AFTER_ADOPTED_METADATA_KEY: () => ON_AFTER_ADOPTED_METADATA_KEY,
  ON_AFTER_CONNECTED_METADATA_KEY: () => ON_AFTER_CONNECTED_METADATA_KEY,
  ON_AFTER_DISCONNECTED_METADATA_KEY: () => ON_AFTER_DISCONNECTED_METADATA_KEY,
  ON_ATTRIBUTE_CHANGED_METADATA_KEY: () => ON_ATTRIBUTE_CHANGED_METADATA_KEY,
  ON_BEFORE_ADOPTED_METADATA_KEY: () => ON_BEFORE_ADOPTED_METADATA_KEY,
  ON_BEFORE_CONNECTED_METADATA_KEY: () => ON_BEFORE_CONNECTED_METADATA_KEY,
  ON_BEFORE_DISCONNECTED_METADATA_KEY: () => ON_BEFORE_DISCONNECTED_METADATA_KEY,
  ON_MUTATION_SUBSCRIBE_METADATA_KEY: () => ON_MUTATION_SUBSCRIBE_METADATA_KEY,
  getLifecycleMetadata: () => getLifecycleMetadata,
  getMutationSubscribeMetadataList: () => getMutationSubscribeMetadataList,
  onAddEventListener: () => onAddEventListener,
  onAdopted: () => onAdopted,
  onAfterAdopted: () => onAfterAdopted,
  onAfterConnected: () => onAfterConnected,
  onAfterDisconnected: () => onAfterDisconnected,
  onAttributeChanged: () => onAttributeChanged,
  onBeforeAdopted: () => onBeforeAdopted,
  onBeforeConnected: () => onBeforeConnected,
  onBeforeDisconnected: () => onBeforeDisconnected,
  onConnected: () => onConnected,
  onDisconnected: () => onDisconnected,
  onMutationSubscribe: () => onMutationSubscribe
});
module.exports = __toCommonJS(lifecycles_exports);
var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-connected");
const ON_AFTER_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-connected");
const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-disconnected");
const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-disconnected");
const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-before-adopted");
const ON_AFTER_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-after-adopted");
const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:on-add-event-listener");
const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol("simple-web-component:on-attribute-changed");
const ON_MUTATION_SUBSCRIBE_METADATA_KEY = Symbol("simple-web-component:on-mutation-observed");
const ATTRIBUTE_CHANGED_WILDCARD = "*";
function createLifecycleDecorator(metadataKey) {
  return (target, propertyKey) => {
    const constructor = target.constructor;
    let list = import_ReflectUtils.ReflectUtils.getMetadata(metadataKey, constructor);
    if (!list) {
      list = [];
      import_ReflectUtils.ReflectUtils.defineMetadata(metadataKey, list, constructor);
    }
    list.push(propertyKey);
  };
}
const onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
const onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
const onConnected = onAfterConnected;
const onBeforeDisconnected = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);
const onAfterDisconnected = createLifecycleDecorator(ON_AFTER_DISCONNECTED_METADATA_KEY);
const onDisconnected = onAfterDisconnected;
const onBeforeAdopted = createLifecycleDecorator(ON_BEFORE_ADOPTED_METADATA_KEY);
const onAfterAdopted = createLifecycleDecorator(ON_AFTER_ADOPTED_METADATA_KEY);
const onAdopted = onAfterAdopted;
const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
function onAttributeChanged(arg1, arg2, arg3) {
  const decorator = (attributeName, target, propertyKey) => {
    const constructor = target.constructor;
    let meta = import_ReflectUtils.ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
    if (!meta) {
      meta = /* @__PURE__ */ new Map();
      import_ReflectUtils.ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);
    }
    let methods = meta.get(attributeName);
    if (!methods) {
      methods = [];
      meta.set(attributeName, methods);
    }
    if (!methods.includes(propertyKey)) {
      methods.push(propertyKey);
    }
  };
  if (typeof arg1 === "string") {
    return (target, propertyKey) => {
      decorator(arg1, target, propertyKey);
    };
  } else if (Array.isArray(arg1)) {
    return (target, propertyKey) => {
      arg1.forEach((name) => decorator(name, target, propertyKey));
    };
  } else if (arg1 && arg2) {
    decorator(ATTRIBUTE_CHANGED_WILDCARD, arg1, arg2);
  }
}
const getLifecycleMetadata = (target, metadataKey) => {
  const constructor = target instanceof Function ? target : target.constructor;
  return import_ReflectUtils.ReflectUtils.getMetadata(metadataKey, constructor);
};
function onMutationSubscribe(arg1, arg2, arg3) {
  const register = (options, target, propertyKey) => {
    const constructor = target.constructor;
    let list = import_ReflectUtils.ReflectUtils.getMetadata(ON_MUTATION_SUBSCRIBE_METADATA_KEY, constructor);
    if (!list) {
      list = [];
      import_ReflectUtils.ReflectUtils.defineMetadata(ON_MUTATION_SUBSCRIBE_METADATA_KEY, list, constructor);
    }
    list.push({ propertyKey, options });
  };
  if (arg2 !== void 0) {
    register({ root: "auto" }, arg1, arg2);
    return;
  }
  return (target, propertyKey) => {
    register(arg1 || { root: "auto" }, target, propertyKey);
  };
}
const getMutationSubscribeMetadataList = (target) => {
  const constructor = target instanceof Function ? target : target.constructor;
  return import_ReflectUtils.ReflectUtils.getMetadata(ON_MUTATION_SUBSCRIBE_METADATA_KEY, constructor);
};
//# sourceMappingURL=lifecycles.js.map
