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 queryAll_exports = {};
__export(queryAll_exports, {
  QUERY_ALL_METADATA_KEY: () => QUERY_ALL_METADATA_KEY,
  getQueryAllMetadata: () => getQueryAllMetadata,
  queryAll: () => queryAll
});
module.exports = __toCommonJS(queryAll_exports);
var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
const QUERY_ALL_METADATA_KEY = Symbol("simple-web-component:query-all");
function queryAll(arg1, arg2) {
  const decorator = (selector, options, target, propertyKey, descriptor) => {
    const isMethod = !!descriptor;
    const constructor = target.constructor;
    let queries = import_ReflectUtils.ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
    if (!queries) {
      queries = [];
      import_ReflectUtils.ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
    }
    queries.push({ selector, options, propertyKey, isMethod });
    if (!isMethod) {
      Object.defineProperty(target, propertyKey, {
        get() {
          if (!selector)
            return [this];
          let searchRoot = this;
          if (options.root === "shadow")
            searchRoot = this.shadowRoot || this;
          else if (options.root === "light")
            searchRoot = this;
          else
            searchRoot = this.shadowRoot || this;
          return searchRoot.querySelectorAll(selector);
        },
        enumerable: true,
        configurable: true
      });
    }
  };
  if (arg1 && typeof arg2 === "string") {
    return decorator("", {}, arg1, arg2);
  }
  return (target, propertyKey, descriptor) => {
    let selector = "";
    let options = {};
    if (typeof arg1 === "string") {
      selector = arg1;
    } else if (typeof arg1 === "object") {
      options = arg1;
      selector = options.selector || "";
    }
    decorator(selector, options, target, propertyKey, descriptor);
  };
}
const getQueryAllMetadata = (target) => {
  const constructor = target instanceof Function ? target : target.constructor;
  return import_ReflectUtils.ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
};
//# sourceMappingURL=queryAll.js.map
