var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
const falseList = [false, "false", null, void 0];
const isDisabled = (element) => {
  const status = element.hasAttribute("disabled");
  const value = element.getAttribute("disabled");
  if (status && !falseList.includes(value))
    return true;
  return false;
};
const removeClassToElementChild = (parent, deleteClass) => {
  const pre = parent.querySelectorAll(`.${deleteClass}`);
  if (pre.length > 0) {
    pre.forEach((item) => item.classList.remove(deleteClass));
  }
};
const loadScript = (src) => {
  return new Promise((resolve, reject) => {
    const script = document.createElement("script");
    script.src = src;
    script.onload = function() {
      resolve({ success: true });
    };
    script.onerror = function(error) {
      reject({ success: false, error });
    };
    document.body.append(script);
  });
};
function createCustomError(msg = "") {
  return class CustomError {
    constructor(message = msg) {
      __publicField(this, "message");
      this.message = message;
    }
  };
}
const HTMLElementSSR = () => {
  if (typeof document !== "undefined") {
    return HTMLElement;
  }
  return null;
};
const createSignal = (value, options) => {
  const signal = {
    value,
    // 订阅者
    subscribers: /* @__PURE__ */ new Set(),
    comparator: options == null ? void 0 : options.equals
  };
  const { subscriber } = options || {};
  if (subscriber && Array.isArray(subscriber)) {
    subscriber.forEach((item) => {
      if (typeof item === "function" && !signal.subscribers.has(item)) {
        signal.subscribers.add(item);
      }
    });
  }
  const getter = () => {
    return signal.value;
  };
  const updateSignal = (newValue) => {
    if (signal.value !== newValue) {
      signal.value = newValue;
      signal.subscribers.forEach((subscriber2) => subscriber2(newValue));
    }
  };
  const setter = (newValue) => {
    const { comparator } = signal;
    if (comparator instanceof Function) {
      return !comparator(signal.value, newValue) && updateSignal(newValue);
    }
    if (comparator === void 0) {
      if (signal.value !== newValue) {
        updateSignal(newValue);
      }
    } else {
      !comparator && updateSignal(newValue);
    }
  };
  return [getter, setter];
};
export {
  HTMLElementSSR as H,
  createSignal as a,
  createCustomError as c,
  falseList as f,
  isDisabled as i,
  loadScript as l,
  removeClassToElementChild as r
};
