// node_modules/onejs-core/dist/dom/dom-style.js
var DomStyleWrapper = class {
  _domStyle;
  // Making this public so that Proxy's setProperty can access it
  constructor(domStyle) {
    this._domStyle = domStyle;
    return new Proxy(this, {
      set(target, prop, value, receiver) {
        if (typeof prop === "string" && !(prop in target)) {
          target.setProperty(prop, value);
          return true;
        }
        return Reflect.set(target, prop, value, receiver);
      },
      get(target, prop, receiver) {
        if (typeof prop === "string" && !(prop in target)) {
          return target.getProperty(prop);
        }
        return Reflect.get(target, prop, receiver);
      }
    });
  }
  getProperty(name) {
    return this._domStyle.getProperty(name);
  }
  setProperty(name, value) {
    this._domStyle.setProperty(name, value);
  }
};

// node_modules/onejs-core/dist/dom/dom.js
var DomWrapper = class _DomWrapper {
  get _dom() {
    return this.dom;
  }
  get ve() {
    return this.dom.ve;
  }
  get childNodes() {
    if (this.cachedChildNodes)
      return this.cachedChildNodes;
    this.cachedChildNodes = new Array(this.dom.childNodes.Length);
    var i = this.dom.childNodes.Length;
    while (i--) {
      this.cachedChildNodes[i] = new _DomWrapper(this.dom.childNodes.get_Item(i));
    }
    return this.cachedChildNodes;
  }
  get firstChild() {
    return this.dom.firstChild ? new _DomWrapper(this.dom.firstChild) : null;
  }
  get parentNode() {
    return this.dom.parentNode ? new _DomWrapper(this.dom.parentNode) : null;
  }
  get nextSibling() {
    return this.dom.nextSibling ? new _DomWrapper(this.dom.nextSibling) : null;
  }
  get nodeType() {
    return this.dom.nodeType;
  }
  get style() {
    return this.domStyleWrapper;
  }
  get Id() {
    return this.dom.Id;
  }
  set Id(value) {
    this.dom.Id = value;
  }
  get key() {
    return this.dom.key;
  }
  set key(value) {
    this.dom.key = value;
  }
  get value() {
    return this.dom.value;
  }
  get checked() {
    return this.dom.checked;
  }
  get data() {
    return this.dom.data;
  }
  set data(value) {
    this.dom.data = value;
  }
  get className() {
    return this.dom.className;
  }
  set className(value) {
    this.dom.className = value;
  }
  get classList() {
    return this.domTokenList;
  }
  /**
   * Not using private fields because of issues with the `#private;` line
   * generated by tsc
   */
  dom;
  domStyleWrapper;
  domTokenList;
  cachedChildNodes = null;
  boundListeners = /* @__PURE__ */ new WeakMap();
  constructor(dom) {
    this.dom = dom;
    this.domStyleWrapper = new DomStyleWrapper(dom.style);
    this.domTokenList = new DomTokenList(dom);
  }
  appendChild(child) {
    if (!child)
      return;
    this.dom.appendChild(child.dom);
    this.cachedChildNodes = null;
  }
  removeChild(child) {
    if (!child)
      return;
    this.dom.removeChild(child.dom);
    this.cachedChildNodes = null;
  }
  insertBefore(a, b) {
    this.dom.insertBefore(a?._dom, b?._dom);
    this.cachedChildNodes = null;
  }
  insertAfter(a, b) {
    this.dom.insertAfter(a?._dom, b?._dom);
    this.cachedChildNodes = null;
  }
  contains(child) {
    if (!child)
      return false;
    return this.dom.contains(child._dom);
  }
  clearChildren() {
    this.dom.clearChildren();
    this.cachedChildNodes = null;
  }
  focus() {
    this.dom.focus();
  }
  addEventListener(type, listener, options3) {
    let boundListener = this.boundListeners.get(listener);
    if (!boundListener) {
      boundListener = listener.bind(this);
      this.boundListeners.set(listener, boundListener);
    }
    if (typeof options3 === "object" && options3.once) {
      const onceWrapper = (event) => {
        boundListener(event);
        this.dom.removeEventListener(type, onceWrapper, false);
      };
      this.dom.addEventListener(type, onceWrapper, false);
    } else {
      this.dom.addEventListener(type, boundListener, options3 ? true : false);
    }
  }
  removeEventListener(type, listener, useCapture) {
    const boundListener = this.boundListeners.get(listener);
    if (boundListener) {
      this.dom.removeEventListener(type, boundListener, useCapture ? true : false);
      this.boundListeners.delete(listener);
    }
  }
  setAttribute(name, value) {
    this.dom.setAttribute(name, value);
  }
  removeAttribute(name) {
    this.dom.removeAttribute(name);
  }
  /**
   * Returns all elements matching the specified selector.
   * Supports basic selectors:
   * - Tag names: 'div'
   * - IDs: '#myId'
   * - Classes: '.myClass'
   * - Combinations: 'div.myClass#myId'
   */
  querySelectorAll(selector) {
    const selectorInfo = parseSelector(selector);
    const results = [];
    function traverse(element) {
      if (elementMatchesSelector(element, selectorInfo)) {
        results.push(element);
      }
      for (const child of element.childNodes) {
        traverse(child);
      }
    }
    traverse(this);
    return results;
  }
  /**
   * Returns the first element matching the specified selector.
   * Supports the same basic selectors as querySelectorAll.
   */
  querySelector(selector) {
    const selectorInfo = parseSelector(selector);
    function traverse(element) {
      if (elementMatchesSelector(element, selectorInfo)) {
        return element;
      }
      for (const child of element.childNodes) {
        const match = traverse(child);
        if (match) {
          return match;
        }
      }
      return null;
    }
    return traverse(this);
  }
};
function parseSelector(selector) {
  const selectorInfo = {
    classes: []
  };
  const idMatch = selector.match(/#([^.#\s]+)/);
  if (idMatch) {
    selectorInfo.id = idMatch[1];
    selector = selector.replace(idMatch[0], "");
  }
  const classMatches = selector.match(/\.([^.#\s]+)/g);
  if (classMatches) {
    selectorInfo.classes = classMatches.map((c) => c.substring(1));
    selector = selector.replace(/\.[^.#\s]+/g, "");
  }
  const tagName = selector.trim();
  if (tagName) {
    selectorInfo.tag = tagName.toLowerCase();
  }
  return selectorInfo;
}
function elementMatchesSelector(element, selectorInfo) {
  if (selectorInfo.tag && element.ve.GetType().Name.toLowerCase() !== selectorInfo.tag) {
    return false;
  }
  if (selectorInfo.id && element.Id !== selectorInfo.id) {
    return false;
  }
  if (selectorInfo.classes.length > 0) {
    const elementClasses = element.className.split(" ").filter((c) => c);
    for (const className of selectorInfo.classes) {
      if (!elementClasses.includes(className)) {
        return false;
      }
    }
  }
  return true;
}
var DomTokenList = class {
  dom;
  constructor(dom) {
    this.dom = dom;
  }
  _tokens() {
    return this.dom.className.trim().split(/\s+/).filter(Boolean);
  }
  _update(tokens) {
    this.dom.className = tokens.join(" ");
  }
  add(...tokens) {
    const set = new Set(this._tokens());
    tokens.forEach((t) => t && set.add(t));
    this._update(Array.from(set));
  }
  remove(...tokens) {
    const set = new Set(this._tokens());
    tokens.forEach((t) => set.delete(t));
    this._update(Array.from(set));
  }
  toggle(token, force) {
    if (!token)
      return false;
    const has = this.contains(token);
    if (force === true || !has && force !== false) {
      this.add(token);
      return true;
    }
    if (has && (force === false || force === void 0)) {
      this.remove(token);
      return false;
    }
    return has;
  }
  contains(token) {
    return this._tokens().includes(token);
  }
  replace(oldToken, newToken) {
    if (!this.contains(oldToken))
      return false;
    const tokens = this._tokens().map((t) => t === oldToken ? newToken : t);
    this._update(tokens);
    return true;
  }
  toString() {
    return this.dom.className;
  }
  get length() {
    return this._tokens().length;
  }
  item(index) {
    const t = this._tokens();
    return index >= 0 && index < t.length ? t[index] : null;
  }
  [Symbol.iterator]() {
    return this._tokens()[Symbol.iterator]();
  }
};

// node_modules/onejs-core/dist/dom/document.js
var { Vector2 } = CS.UnityEngine;
var DocumentWrapper = class {
  get _doc() {
    return this.#doc;
  }
  #doc;
  #body;
  /**
   * The body/root element of the document. Will be null for Editor documents.
   */
  get body() {
    return this.#body;
  }
  constructor(doc) {
    this.#doc = doc;
    this.#body = doc.body ? new DomWrapper(doc.body) : null;
  }
  addRuntimeUSS(uss) {
    this.#doc.addRuntimeUSS(uss);
  }
  clearRuntimeStyleSheets() {
    this.#doc.clearRuntimeStyleSheets();
  }
  createElement(tagName, options3) {
    return new DomWrapper(this.#doc.createElement(tagName));
  }
  createElementNS(ns, tagName, options3) {
    tagName = typeof tagName === "string" ? tagName : "div";
    return new DomWrapper(this.#doc.createElement(tagName));
  }
  createTextNode(text) {
    return new DomWrapper(this.#doc.createTextNode(text));
  }
  getElementById(id) {
    return new DomWrapper(this.#doc.getElementById(id));
  }
  querySelectorAll(selector) {
    let doms = this.#doc.querySelectorAll(selector);
    let res = [];
    for (let i = 0; i < doms.Length; i++) {
      res.push(new DomWrapper(doms.get_Item(i)));
    }
    return res;
  }
  elementFromPoint(x, y) {
    const root = this.body;
    if (!root)
      return null;
    const hitTest = (node) => {
      if (!node.ve.worldBound.Contains(new Vector2(x, y)))
        return null;
      for (let i = node.childNodes.length - 1; i >= 0; i--) {
        const hit = hitTest(node.childNodes[i]);
        if (hit)
          return hit;
      }
      return node;
    };
    return hitTest(root);
  }
  elementsFromPoint(x, y) {
    const root = this.body;
    if (!root)
      return [];
    const hits = [];
    const collect = (node) => {
      if (!node.ve.worldBound.Contains(new Vector2(x, y)))
        return;
      for (let i = node.childNodes.length - 1; i >= 0; i--) {
        collect(node.childNodes[i]);
      }
      hits.push(node);
    };
    collect(root);
    return hits;
  }
};

// node_modules/css-simple-parser/dist/constants.js
var TOKEN_TYPE = {
  SELECTOR: 1,
  BODY_START: 2,
  BODY_END: 3
};

// node_modules/css-simple-parser/dist/tokenizer.js
var { SELECTOR, BODY_START, BODY_END } = TOKEN_TYPE;

// node_modules/css-simple-parser/dist/parse.js
var { SELECTOR: SELECTOR2, BODY_START: BODY_START2, BODY_END: BODY_END2 } = TOKEN_TYPE;

// node_modules/onejs-core/dist/index.js
if (typeof globalThis.___document != "undefined") {
  globalThis.onejsDocument = new DocumentWrapper(globalThis.___document);
  if (!globalThis.ONEJS_WEBGL) {
    globalThis.document = globalThis.onejsDocument;
  }
}

// node_modules/onejs-preact/constants.js
var MODE_HYDRATE = 1 << 5;
var MODE_SUSPENDED = 1 << 7;
var INSERT_VNODE = 1 << 16;
var MATCHED = 1 << 17;
var RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);
var EMPTY_OBJ = (
  /** @type {any} */
  {}
);
var EMPTY_ARR = [];
var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;

// node_modules/onejs-preact/util.js
var isArray = Array.isArray;
function assign(obj, props) {
  for (let i in props)
    obj[i] = props[i];
  return (
    /** @type {O & P} */
    obj
  );
}
function removeNode(node) {
  let parentNode = node.parentNode;
  if (parentNode)
    parentNode.removeChild(node);
}
var slice = EMPTY_ARR.slice;

// node_modules/onejs-preact/diff/catch-error.js
function _catchError(error, vnode, oldVNode, errorInfo) {
  let component, ctor, handled;
  for (; vnode = vnode._parent; ) {
    if ((component = vnode._component) && !component._processingException) {
      try {
        ctor = component.constructor;
        if (ctor && ctor.getDerivedStateFromError != null) {
          component.setState(ctor.getDerivedStateFromError(error));
          handled = component._dirty;
        }
        if (component.componentDidCatch != null) {
          component.componentDidCatch(error, errorInfo || {});
          handled = component._dirty;
        }
        if (handled) {
          return component._pendingError = component;
        }
      } catch (e) {
        error = e;
      }
    }
  }
  throw error;
}

// node_modules/onejs-preact/options.js
var options = {
  _catchError
};
var options_default = options;

// node_modules/onejs-preact/create-element.js
var vnodeId = 0;
function createElement(type, props, children) {
  let normalizedProps = {}, key, ref, i;
  for (i in props) {
    if (i == "key")
      key = props[i];
    else if (i == "ref")
      ref = props[i];
    else
      normalizedProps[i] = props[i];
  }
  if (arguments.length > 2) {
    normalizedProps.children = arguments.length > 3 ? slice.call(arguments, 2) : children;
  }
  if (typeof type == "function" && type.defaultProps != null) {
    for (i in type.defaultProps) {
      if (normalizedProps[i] === void 0) {
        normalizedProps[i] = type.defaultProps[i];
      }
    }
  }
  return createVNode(type, normalizedProps, key, ref, null);
}
function createVNode(type, props, key, ref, original) {
  const vnode = {
    type,
    props,
    key,
    ref,
    _children: null,
    _parent: null,
    _depth: 0,
    _dom: null,
    // _nextDom must be initialized to undefined b/c it will eventually
    // be set to dom.nextSibling which can return `null` and it is important
    // to be able to distinguish between an uninitialized _nextDom and
    // a _nextDom that has been set to `null`
    _nextDom: void 0,
    _component: null,
    constructor: void 0,
    _original: original == null ? ++vnodeId : original,
    _index: -1,
    _flags: 0
  };
  if (original == null && options_default.vnode != null)
    options_default.vnode(vnode);
  return vnode;
}
function Fragment(props) {
  return props.children;
}

// node_modules/onejs-preact/component.js
function BaseComponent(props, context) {
  this.props = props;
  this.context = context;
}
BaseComponent.prototype.setState = function(update, callback) {
  let s;
  if (this._nextState != null && this._nextState !== this.state) {
    s = this._nextState;
  } else {
    s = this._nextState = assign({}, this.state);
  }
  if (typeof update == "function") {
    update = update(assign({}, s), this.props);
  }
  if (update) {
    assign(s, update);
  }
  if (update == null)
    return;
  if (this._vnode) {
    if (callback) {
      this._stateCallbacks.push(callback);
    }
    enqueueRender(this);
  }
};
BaseComponent.prototype.forceUpdate = function(callback) {
  if (this._vnode) {
    this._force = true;
    if (callback)
      this._renderCallbacks.push(callback);
    enqueueRender(this);
  }
};
BaseComponent.prototype.render = Fragment;
function getDomSibling(vnode, childIndex) {
  if (childIndex == null) {
    return vnode._parent ? getDomSibling(vnode._parent, vnode._index + 1) : null;
  }
  let sibling;
  for (; childIndex < vnode._children.length; childIndex++) {
    sibling = vnode._children[childIndex];
    if (sibling != null && sibling._dom != null) {
      return sibling._dom;
    }
  }
  return typeof vnode.type == "function" ? getDomSibling(vnode) : null;
}
function renderComponent(component) {
  let oldVNode = component._vnode, oldDom = oldVNode._dom, commitQueue = [], refQueue = [];
  if (component._parentDom) {
    const newVNode = assign({}, oldVNode);
    newVNode._original = oldVNode._original + 1;
    if (options_default.vnode)
      options_default.vnode(newVNode);
    diff(
      component._parentDom,
      newVNode,
      oldVNode,
      component._globalContext,
      component._parentDom.namespaceURI,
      oldVNode._flags & MODE_HYDRATE ? [oldDom] : null,
      commitQueue,
      oldDom == null ? getDomSibling(oldVNode) : oldDom,
      !!(oldVNode._flags & MODE_HYDRATE),
      refQueue
    );
    newVNode._original = oldVNode._original;
    newVNode._parent._children[newVNode._index] = newVNode;
    commitRoot(commitQueue, newVNode, refQueue);
    if (newVNode._dom != oldDom) {
      updateParentDomPointers(newVNode);
    }
  }
}
function updateParentDomPointers(vnode) {
  if ((vnode = vnode._parent) != null && vnode._component != null) {
    vnode._dom = vnode._component.base = null;
    for (let i = 0; i < vnode._children.length; i++) {
      let child = vnode._children[i];
      if (child != null && child._dom != null) {
        vnode._dom = vnode._component.base = child._dom;
        break;
      }
    }
    return updateParentDomPointers(vnode);
  }
}
var rerenderQueue = [];
var prevDebounce;
var defer = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;
function enqueueRender(c) {
  if (!c._dirty && (c._dirty = true) && rerenderQueue.push(c) && !process._rerenderCount++ || prevDebounce !== options_default.debounceRendering) {
    prevDebounce = options_default.debounceRendering;
    (prevDebounce || defer)(process);
  }
}
var depthSort = (a, b) => a._vnode._depth - b._vnode._depth;
function process() {
  let c;
  rerenderQueue.sort(depthSort);
  while (c = rerenderQueue.shift()) {
    if (c._dirty) {
      let renderQueueLength = rerenderQueue.length;
      renderComponent(c);
      if (rerenderQueue.length > renderQueueLength) {
        rerenderQueue.sort(depthSort);
      }
    }
  }
  process._rerenderCount = 0;
}
process._rerenderCount = 0;

// node_modules/onejs-preact/diff/children.js
function diffChildren(parentDom, renderResult, newParentVNode, oldParentVNode, globalContext, namespace, excessDomChildren, commitQueue, oldDom, isHydrating, refQueue) {
  let i, oldVNode, childVNode, newDom, firstChildDom;
  let oldChildren = oldParentVNode && oldParentVNode._children || EMPTY_ARR;
  let newChildrenLength = renderResult.length;
  newParentVNode._nextDom = oldDom;
  constructNewChildrenArray(newParentVNode, renderResult, oldChildren);
  oldDom = newParentVNode._nextDom;
  for (i = 0; i < newChildrenLength; i++) {
    childVNode = newParentVNode._children[i];
    if (childVNode == null || typeof childVNode == "boolean" || typeof childVNode == "function") {
      continue;
    }
    if (childVNode._index === -1) {
      oldVNode = EMPTY_OBJ;
    } else {
      oldVNode = oldChildren[childVNode._index] || EMPTY_OBJ;
    }
    childVNode._index = i;
    diff(
      parentDom,
      childVNode,
      oldVNode,
      globalContext,
      namespace,
      excessDomChildren,
      commitQueue,
      oldDom,
      isHydrating,
      refQueue
    );
    newDom = childVNode._dom;
    if (childVNode.ref && oldVNode.ref != childVNode.ref) {
      if (oldVNode.ref) {
        applyRef(oldVNode.ref, null, childVNode);
      }
      refQueue.push(
        childVNode.ref,
        childVNode._component || newDom,
        childVNode
      );
    }
    if (firstChildDom == null && newDom != null) {
      firstChildDom = newDom;
    }
    if (childVNode._flags & INSERT_VNODE || oldVNode._children === childVNode._children) {
      oldDom = insert(childVNode, oldDom, parentDom);
    } else if (typeof childVNode.type == "function" && childVNode._nextDom !== void 0) {
      oldDom = childVNode._nextDom;
    } else if (newDom) {
      oldDom = newDom.nextSibling;
    }
    childVNode._nextDom = void 0;
    childVNode._flags &= ~(INSERT_VNODE | MATCHED);
  }
  newParentVNode._nextDom = oldDom;
  newParentVNode._dom = firstChildDom;
}
function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
  let i;
  let childVNode;
  let oldVNode;
  const newChildrenLength = renderResult.length;
  let oldChildrenLength = oldChildren.length, remainingOldChildren = oldChildrenLength;
  let skew = 0;
  newParentVNode._children = [];
  for (i = 0; i < newChildrenLength; i++) {
    childVNode = renderResult[i];
    if (childVNode == null || typeof childVNode == "boolean" || typeof childVNode == "function") {
      childVNode = newParentVNode._children[i] = null;
    } else if (typeof childVNode == "string" || typeof childVNode == "number" || // eslint-disable-next-line valid-typeof
    typeof childVNode == "bigint" || childVNode.constructor == String) {
      childVNode = newParentVNode._children[i] = createVNode(
        null,
        childVNode,
        null,
        null,
        null
      );
    } else if (isArray(childVNode)) {
      childVNode = newParentVNode._children[i] = createVNode(
        Fragment,
        { children: childVNode },
        null,
        null,
        null
      );
    } else if (childVNode.constructor === void 0 && childVNode._depth > 0) {
      childVNode = newParentVNode._children[i] = createVNode(
        childVNode.type,
        childVNode.props,
        childVNode.key,
        childVNode.ref ? childVNode.ref : null,
        childVNode._original
      );
    } else {
      childVNode = newParentVNode._children[i] = childVNode;
    }
    const skewedIndex = i + skew;
    if (childVNode == null) {
      oldVNode = oldChildren[skewedIndex];
      if (oldVNode && oldVNode.key == null && oldVNode._dom && (oldVNode._flags & MATCHED) === 0) {
        if (oldVNode._dom == newParentVNode._nextDom) {
          newParentVNode._nextDom = getDomSibling(oldVNode);
        }
        unmount(oldVNode, oldVNode, false);
        oldChildren[skewedIndex] = null;
        remainingOldChildren--;
      }
      continue;
    }
    childVNode._parent = newParentVNode;
    childVNode._depth = newParentVNode._depth + 1;
    const matchingIndex = findMatchingIndex(
      childVNode,
      oldChildren,
      skewedIndex,
      remainingOldChildren
    );
    childVNode._index = matchingIndex;
    oldVNode = null;
    if (matchingIndex !== -1) {
      oldVNode = oldChildren[matchingIndex];
      remainingOldChildren--;
      if (oldVNode) {
        oldVNode._flags |= MATCHED;
      }
    }
    const isMounting = oldVNode == null || oldVNode._original === null;
    if (isMounting) {
      if (matchingIndex == -1) {
        skew--;
      }
      if (typeof childVNode.type != "function") {
        childVNode._flags |= INSERT_VNODE;
      }
    } else if (matchingIndex !== skewedIndex) {
      if (matchingIndex == skewedIndex - 1) {
        skew = matchingIndex - skewedIndex;
      } else if (matchingIndex == skewedIndex + 1) {
        skew++;
      } else if (matchingIndex > skewedIndex) {
        if (remainingOldChildren > newChildrenLength - skewedIndex) {
          skew += matchingIndex - skewedIndex;
        } else {
          skew--;
        }
      } else if (matchingIndex < skewedIndex) {
        skew++;
      }
      if (matchingIndex !== i + skew) {
        childVNode._flags |= INSERT_VNODE;
      }
    }
  }
  if (remainingOldChildren) {
    for (i = 0; i < oldChildrenLength; i++) {
      oldVNode = oldChildren[i];
      if (oldVNode != null && (oldVNode._flags & MATCHED) === 0) {
        if (oldVNode._dom == newParentVNode._nextDom) {
          newParentVNode._nextDom = getDomSibling(oldVNode);
        }
        unmount(oldVNode, oldVNode);
      }
    }
  }
}
function insert(parentVNode, oldDom, parentDom) {
  if (typeof parentVNode.type == "function") {
    let children = parentVNode._children;
    for (let i = 0; children && i < children.length; i++) {
      if (children[i]) {
        children[i]._parent = parentVNode;
        oldDom = insert(children[i], oldDom, parentDom);
      }
    }
    return oldDom;
  } else if (parentVNode._dom != oldDom) {
    if (oldDom && parentVNode.type && // @ts-expect-error olDom should be present on a DOM node
    !parentDom.contains(oldDom)) {
      oldDom = getDomSibling(parentVNode);
    }
    parentDom.insertBefore(parentVNode._dom, oldDom || null);
    oldDom = parentVNode._dom;
  }
  do {
    oldDom = oldDom && oldDom.nextSibling;
  } while (oldDom != null && oldDom.nodeType === 8);
  return oldDom;
}
function findMatchingIndex(childVNode, oldChildren, skewedIndex, remainingOldChildren) {
  const key = childVNode.key;
  const type = childVNode.type;
  let x = skewedIndex - 1;
  let y = skewedIndex + 1;
  let oldVNode = oldChildren[skewedIndex];
  let shouldSearch = remainingOldChildren > (oldVNode != null && (oldVNode._flags & MATCHED) === 0 ? 1 : 0);
  if (oldVNode === null || oldVNode && key == oldVNode.key && type === oldVNode.type && (oldVNode._flags & MATCHED) === 0) {
    return skewedIndex;
  } else if (shouldSearch) {
    while (x >= 0 || y < oldChildren.length) {
      if (x >= 0) {
        oldVNode = oldChildren[x];
        if (oldVNode && (oldVNode._flags & MATCHED) === 0 && key == oldVNode.key && type === oldVNode.type) {
          return x;
        }
        x--;
      }
      if (y < oldChildren.length) {
        oldVNode = oldChildren[y];
        if (oldVNode && (oldVNode._flags & MATCHED) === 0 && key == oldVNode.key && type === oldVNode.type) {
          return y;
        }
        y++;
      }
    }
  }
  return -1;
}

// node_modules/onejs-preact/diff/props.js
function setStyle(style, key, value) {
  if (key[0] === "-") {
    style.setProperty(key, value == null ? "" : value);
  } else if (value == null) {
    style[key] = "";
  } else if (typeof value != "number" || IS_NON_DIMENSIONAL.test(key)) {
    style[key] = value;
  } else {
    style[key] = value;
  }
}
var eventClock = 0;
var MAX_ENTRIES = 1e3;
var eventDispatchTimes = /* @__PURE__ */ new Map();
function setProperty(dom, name, value, oldValue, namespace) {
  let useCapture;
  o:
    if (name === "style") {
      if (typeof value == "string") {
        dom.style.cssText = value;
      } else {
        if (typeof oldValue == "string") {
          dom.style.cssText = oldValue = "";
        }
        if (oldValue) {
          for (name in oldValue) {
            if (!(value && name in value)) {
              setStyle(dom.style, name, "");
            }
          }
        }
        if (value) {
          for (name in value) {
            if (!oldValue || value[name] !== oldValue[name]) {
              setStyle(dom.style, name, value[name]);
            }
          }
        }
      }
    } else if (name[0] === "o" && name[1] === "n") {
      useCapture = name !== (name = name.replace(/(PointerCapture)$|Capture$/i, "$1"));
      name = name.slice(2);
      if (!dom._listeners)
        dom._listeners = {};
      dom._listeners[name + useCapture] = value;
      if (value) {
        if (!oldValue) {
          value._attached = eventClock;
          dom.addEventListener(
            name,
            useCapture ? eventProxyCapture : eventProxy,
            useCapture
          );
        } else {
          value._attached = oldValue._attached;
        }
      } else {
        dom.removeEventListener(
          name,
          useCapture ? eventProxyCapture : eventProxy,
          useCapture
        );
      }
    } else {
      if (namespace == "http://www.w3.org/2000/svg") {
        name = name.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
      } else if (name != "width" && name != "height" && name != "href" && name != "list" && name != "form" && // Default value in browsers is `-1` and an empty string is
      // cast to `0` instead
      name != "tabIndex" && name != "download" && name != "rowSpan" && name != "colSpan" && name != "role" && name != "popover" && name in dom.ve) {
        try {
          dom.setAttribute(name, value == null ? "" : value);
          break o;
        } catch (e) {
        }
      }
      if (typeof value == "function") {
      } else if (value != null && typeof value !== "undefined") {
        dom.setAttribute(name, name == "popover" && value == true ? "" : value);
      } else {
        dom.removeAttribute(name);
      }
    }
}
function createEventProxy(useCapture) {
  return function(e) {
    if (this._listeners) {
      let eventName = e.GetType().Name.replace("Event", "");
      eventName = eventName === "Change`1" ? "ValueChanged" : eventName;
      const eventHandler = this._listeners[eventName + useCapture];
      const key = e.timestamp;
      if (!eventDispatchTimes.has(key)) {
        eventDispatchTimes.set(key, eventClock++);
        if (eventDispatchTimes.size >= MAX_ENTRIES) {
          const oldestKey = eventDispatchTimes.keys().next().value;
          eventDispatchTimes.delete(oldestKey);
        }
      } else {
        const tmpClock = eventDispatchTimes.get(key);
        eventDispatchTimes.delete(key);
        eventDispatchTimes.set(key, tmpClock);
      }
      const dispatchTime = eventDispatchTimes.get(key);
      if (dispatchTime < eventHandler._attached) {
        return;
      }
      return eventHandler(options_default.event ? options_default.event(e) : e);
    }
  };
}
var eventProxy = createEventProxy(false);
var eventProxyCapture = createEventProxy(true);

// node_modules/onejs-preact/diff/index.js
function diff(parentDom, newVNode, oldVNode, globalContext, namespace, excessDomChildren, commitQueue, oldDom, isHydrating, refQueue) {
  let tmp, newType = newVNode.type;
  if (newVNode.constructor !== void 0)
    return null;
  if (oldVNode._flags & MODE_SUSPENDED) {
    isHydrating = !!(oldVNode._flags & MODE_HYDRATE);
    oldDom = newVNode._dom = oldVNode._dom;
    excessDomChildren = [oldDom];
  }
  if (tmp = options_default._diff)
    tmp(newVNode);
  outer:
    if (typeof newType == "function") {
      try {
        let c, isNew, oldProps, oldState, snapshot, clearProcessingException;
        let newProps = newVNode.props;
        const isClassComponent = "prototype" in newType && newType.prototype.render;
        tmp = newType.contextType;
        let provider = tmp && globalContext[tmp._id];
        let componentContext = tmp ? provider ? provider.props.value : tmp._defaultValue : globalContext;
        if (oldVNode._component) {
          c = newVNode._component = oldVNode._component;
          clearProcessingException = c._processingException = c._pendingError;
        } else {
          if (isClassComponent) {
            newVNode._component = c = new newType(newProps, componentContext);
          } else {
            newVNode._component = c = new BaseComponent(
              newProps,
              componentContext
            );
            c.constructor = newType;
            c.render = doRender;
          }
          if (provider)
            provider.sub(c);
          c.props = newProps;
          if (!c.state)
            c.state = {};
          c.context = componentContext;
          c._globalContext = globalContext;
          isNew = c._dirty = true;
          c._renderCallbacks = [];
          c._stateCallbacks = [];
        }
        if (isClassComponent && c._nextState == null) {
          c._nextState = c.state;
        }
        if (isClassComponent && newType.getDerivedStateFromProps != null) {
          if (c._nextState == c.state) {
            c._nextState = assign({}, c._nextState);
          }
          assign(
            c._nextState,
            newType.getDerivedStateFromProps(newProps, c._nextState)
          );
        }
        oldProps = c.props;
        oldState = c.state;
        c._vnode = newVNode;
        if (isNew) {
          if (isClassComponent && newType.getDerivedStateFromProps == null && c.componentWillMount != null) {
            c.componentWillMount();
          }
          if (isClassComponent && c.componentDidMount != null) {
            c._renderCallbacks.push(c.componentDidMount);
          }
        } else {
          if (isClassComponent && newType.getDerivedStateFromProps == null && newProps !== oldProps && c.componentWillReceiveProps != null) {
            c.componentWillReceiveProps(newProps, componentContext);
          }
          if (!c._force && (c.shouldComponentUpdate != null && c.shouldComponentUpdate(
            newProps,
            c._nextState,
            componentContext
          ) === false || newVNode._original === oldVNode._original)) {
            if (newVNode._original !== oldVNode._original) {
              c.props = newProps;
              c.state = c._nextState;
              c._dirty = false;
            }
            newVNode._dom = oldVNode._dom;
            newVNode._children = oldVNode._children;
            newVNode._children.forEach((vnode) => {
              if (vnode)
                vnode._parent = newVNode;
            });
            for (let i = 0; i < c._stateCallbacks.length; i++) {
              c._renderCallbacks.push(c._stateCallbacks[i]);
            }
            c._stateCallbacks = [];
            if (c._renderCallbacks.length) {
              commitQueue.push(c);
            }
            break outer;
          }
          if (c.componentWillUpdate != null) {
            c.componentWillUpdate(newProps, c._nextState, componentContext);
          }
          if (isClassComponent && c.componentDidUpdate != null) {
            c._renderCallbacks.push(() => {
              c.componentDidUpdate(oldProps, oldState, snapshot);
            });
          }
        }
        c.context = componentContext;
        c.props = newProps;
        c._parentDom = parentDom;
        c._force = false;
        let renderHook = options_default._render, count = 0;
        if (isClassComponent) {
          c.state = c._nextState;
          c._dirty = false;
          if (renderHook)
            renderHook(newVNode);
          tmp = c.render(c.props, c.state, c.context);
          for (let i = 0; i < c._stateCallbacks.length; i++) {
            c._renderCallbacks.push(c._stateCallbacks[i]);
          }
          c._stateCallbacks = [];
        } else {
          do {
            c._dirty = false;
            if (renderHook)
              renderHook(newVNode);
            tmp = c.render(c.props, c.state, c.context);
            c.state = c._nextState;
          } while (c._dirty && ++count < 25);
        }
        c.state = c._nextState;
        if (c.getChildContext != null) {
          globalContext = assign(assign({}, globalContext), c.getChildContext());
        }
        if (isClassComponent && !isNew && c.getSnapshotBeforeUpdate != null) {
          snapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);
        }
        let isTopLevelFragment = tmp != null && tmp.type === Fragment && tmp.key == null;
        let renderResult = isTopLevelFragment ? tmp.props.children : tmp;
        diffChildren(
          parentDom,
          isArray(renderResult) ? renderResult : [renderResult],
          newVNode,
          oldVNode,
          globalContext,
          namespace,
          excessDomChildren,
          commitQueue,
          oldDom,
          isHydrating,
          refQueue
        );
        c.base = newVNode._dom;
        newVNode._flags &= RESET_MODE;
        if (c._renderCallbacks.length) {
          commitQueue.push(c);
        }
        if (clearProcessingException) {
          c._pendingError = c._processingException = null;
        }
      } catch (e) {
        newVNode._original = null;
        if (isHydrating || excessDomChildren != null) {
          newVNode._flags |= isHydrating ? MODE_HYDRATE | MODE_SUSPENDED : MODE_HYDRATE;
          while (oldDom && oldDom.nodeType === 8 && oldDom.nextSibling) {
            oldDom = oldDom.nextSibling;
          }
          excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
          newVNode._dom = oldDom;
        } else {
          newVNode._dom = oldVNode._dom;
          newVNode._children = oldVNode._children;
        }
        options_default._catchError(e, newVNode, oldVNode);
      }
    } else if (excessDomChildren == null && newVNode._original === oldVNode._original) {
      newVNode._children = oldVNode._children;
      newVNode._dom = oldVNode._dom;
    } else {
      newVNode._dom = diffElementNodes(
        oldVNode._dom,
        newVNode,
        oldVNode,
        globalContext,
        namespace,
        excessDomChildren,
        commitQueue,
        isHydrating,
        refQueue
      );
    }
  if (tmp = options_default.diffed)
    tmp(newVNode);
}
function commitRoot(commitQueue, root, refQueue) {
  root._nextDom = void 0;
  for (let i = 0; i < refQueue.length; i++) {
    applyRef(refQueue[i], refQueue[++i], refQueue[++i]);
  }
  if (options_default._commit)
    options_default._commit(root, commitQueue);
  commitQueue.some((c) => {
    try {
      commitQueue = c._renderCallbacks;
      c._renderCallbacks = [];
      commitQueue.some((cb) => {
        cb.call(c);
      });
    } catch (e) {
      options_default._catchError(e, c._vnode);
    }
  });
}
function diffElementNodes(dom, newVNode, oldVNode, globalContext, namespace, excessDomChildren, commitQueue, isHydrating, refQueue) {
  let oldProps = oldVNode.props;
  let newProps = newVNode.props;
  let nodeType = (
    /** @type {string} */
    newVNode.type
  );
  let i;
  let newHtml;
  let oldHtml;
  let newChildren;
  let value;
  let inputValue;
  let checked;
  if (nodeType === "svg")
    namespace = "http://www.w3.org/2000/svg";
  else if (nodeType === "math")
    namespace = "http://www.w3.org/1998/Math/MathML";
  else if (!namespace)
    namespace = "http://www.w3.org/1999/xhtml";
  if (excessDomChildren != null) {
    for (i = 0; i < excessDomChildren.length; i++) {
      value = excessDomChildren[i];
      if (value && "setAttribute" in value === !!nodeType && (nodeType ? value.localName === nodeType : value.nodeType === 3)) {
        dom = value;
        excessDomChildren[i] = null;
        break;
      }
    }
  }
  if (dom == null) {
    if (nodeType === null) {
      return globalThis.onejsDocument.createTextNode(newProps);
    }
    dom = globalThis.onejsDocument.createElementNS(
      // MODDED
      namespace,
      nodeType,
      newProps.is && newProps
    );
    excessDomChildren = null;
    isHydrating = false;
  }
  if (nodeType === null) {
    if (oldProps !== newProps && (!isHydrating || dom.data !== newProps)) {
      dom.data = newProps;
    }
  } else {
    excessDomChildren = excessDomChildren && slice.call(dom.childNodes);
    oldProps = oldVNode.props || EMPTY_OBJ;
    if (!isHydrating && excessDomChildren != null) {
      oldProps = {};
      for (i = 0; i < dom.attributes.length; i++) {
        value = dom.attributes[i];
        oldProps[value.name] = value.value;
      }
    }
    for (i in oldProps) {
      value = oldProps[i];
      if (i == "children") {
      } else if (i == "dangerouslySetInnerHTML") {
        oldHtml = value;
      } else if (i !== "key" && !(i in newProps)) {
        if (i == "value" && "defaultValue" in newProps || i == "checked" && "defaultChecked" in newProps) {
          continue;
        }
        setProperty(dom, i, null, value, namespace);
      }
    }
    for (i in newProps) {
      value = newProps[i];
      if (i == "children") {
        newChildren = value;
      } else if (i == "dangerouslySetInnerHTML") {
        newHtml = value;
      } else if (i == "value") {
        inputValue = value;
      } else if (i == "checked") {
        checked = value;
      } else if (i !== "key" && (!isHydrating || typeof value == "function") && oldProps[i] !== value) {
        setProperty(dom, i, value, oldProps[i], namespace);
      }
    }
    if (newHtml) {
      if (!isHydrating && (!oldHtml || newHtml.__html !== oldHtml.__html && newHtml.__html !== dom.innerHTML)) {
        dom.innerHTML = newHtml.__html;
      }
      newVNode._children = [];
    } else {
      if (oldHtml)
        dom.innerHTML = "";
      diffChildren(
        dom,
        isArray(newChildren) ? newChildren : [newChildren],
        newVNode,
        oldVNode,
        globalContext,
        nodeType === "foreignObject" ? "http://www.w3.org/1999/xhtml" : namespace,
        excessDomChildren,
        commitQueue,
        excessDomChildren ? excessDomChildren[0] : oldVNode._children && getDomSibling(oldVNode, 0),
        isHydrating,
        refQueue
      );
      if (excessDomChildren != null) {
        for (i = excessDomChildren.length; i--; ) {
          if (excessDomChildren[i] != null)
            removeNode(excessDomChildren[i]);
        }
      }
    }
    if (!isHydrating) {
      i = "value";
      if (inputValue !== void 0 && // #2756 For the <progress>-element the initial value is 0,
      // despite the attribute not being present. When the attribute
      // is missing the progress bar is treated as indeterminate.
      // To fix that we'll always update it when it is 0 for progress elements
      (inputValue !== dom[i] || nodeType === "progress" && !inputValue || // This is only for IE 11 to fix <select> value not being updated.
      // To avoid a stale select value we need to set the option.value
      // again, which triggers IE11 to re-evaluate the select value
      nodeType === "option" && inputValue !== oldProps[i])) {
        setProperty(dom, i, inputValue, oldProps[i], namespace);
      }
      i = "checked";
      if (checked !== void 0 && checked !== dom[i]) {
        setProperty(dom, i, checked, oldProps[i], namespace);
      }
    }
  }
  return dom;
}
function applyRef(ref, value, vnode) {
  try {
    if (typeof ref == "function") {
      let hasRefUnmount = typeof ref._unmount == "function";
      if (hasRefUnmount) {
        ref._unmount();
      }
      if (!hasRefUnmount || value != null) {
        ref._unmount = ref(value);
      }
    } else
      ref.current = value;
  } catch (e) {
    options_default._catchError(e, vnode);
  }
}
function unmount(vnode, parentVNode, skipRemove) {
  let r;
  if (options_default.unmount)
    options_default.unmount(vnode);
  if (r = vnode.ref) {
    if (!r.current || r.current === vnode._dom) {
      applyRef(r, null, parentVNode);
    }
  }
  if ((r = vnode._component) != null) {
    if (r.componentWillUnmount) {
      try {
        r.componentWillUnmount();
      } catch (e) {
        options_default._catchError(e, parentVNode);
      }
    }
    r.base = r._parentDom = null;
  }
  if (r = vnode._children) {
    for (let i = 0; i < r.length; i++) {
      if (r[i]) {
        unmount(
          r[i],
          parentVNode,
          skipRemove || typeof vnode.type != "function"
        );
      }
    }
  }
  if (!skipRemove && vnode._dom != null) {
    removeNode(vnode._dom);
  }
  vnode._component = vnode._parent = vnode._dom = vnode._nextDom = void 0;
}
function doRender(props, state, context) {
  return this.constructor(props, context);
}

// node_modules/onejs-preact/render.js
var cleanupMap = /* @__PURE__ */ new WeakMap();
function render(vnode, parentDom, replaceNode) {
  if (typeof globalThis.ONEJS_WEBGL !== "undefined" && globalThis.ONEJS_WEBGL && vnode !== null) {
    render(null, parentDom);
  }
  if (typeof onejs !== "undefined" && parentDom && !cleanupMap.has(parentDom)) {
    onejs.add_onDispose(() => render(null, parentDom));
    cleanupMap.set(parentDom, true);
  }
  if (options_default._root)
    options_default._root(vnode, parentDom);
  let isHydrating = typeof replaceNode == "function";
  let oldVNode = isHydrating ? null : replaceNode && replaceNode._children || parentDom._children;
  vnode = (!isHydrating && replaceNode || parentDom)._children = createElement(Fragment, null, [vnode]);
  let commitQueue = [], refQueue = [];
  diff(
    parentDom,
    // Determine the new vnode tree and store it on the DOM element on
    // our custom `_children` property.
    vnode,
    oldVNode || EMPTY_OBJ,
    EMPTY_OBJ,
    parentDom.namespaceURI,
    !isHydrating && replaceNode ? [replaceNode] : oldVNode ? null : parentDom.firstChild ? slice.call(parentDom.childNodes) : null,
    commitQueue,
    !isHydrating && replaceNode ? replaceNode : oldVNode ? oldVNode._dom : parentDom.firstChild,
    isHydrating,
    refQueue
  );
  commitRoot(commitQueue, vnode, refQueue);
}

// node_modules/onejs-preact/hooks/index.js
var currentIndex;
var currentComponent;
var previousComponent;
var currentHook = 0;
var afterPaintEffects = [];
var options2 = (
  /** @type {import('./internal').Options} */
  options_default
);
var oldBeforeDiff = options2._diff;
var oldBeforeRender = options2._render;
var oldAfterDiff = options2.diffed;
var oldCommit = options2._commit;
var oldBeforeUnmount = options2.unmount;
var oldRoot = options2._root;
var RAF_TIMEOUT = 100;
var prevRaf;
options2._diff = (vnode) => {
  currentComponent = null;
  if (oldBeforeDiff)
    oldBeforeDiff(vnode);
};
options2._root = (vnode, parentDom) => {
  if (vnode && parentDom._children && parentDom._children._mask) {
    vnode._mask = parentDom._children._mask;
  }
  if (oldRoot)
    oldRoot(vnode, parentDom);
};
options2._render = (vnode) => {
  if (oldBeforeRender)
    oldBeforeRender(vnode);
  currentComponent = vnode._component;
  currentIndex = 0;
  const hooks = currentComponent.__hooks;
  if (hooks) {
    if (previousComponent === currentComponent) {
      hooks._pendingEffects = [];
      currentComponent._renderCallbacks = [];
      hooks._list.forEach((hookItem) => {
        if (hookItem._nextValue) {
          hookItem._value = hookItem._nextValue;
        }
        hookItem._pendingArgs = hookItem._nextValue = void 0;
      });
    } else {
      hooks._pendingEffects.forEach(invokeCleanup);
      hooks._pendingEffects.forEach(invokeEffect);
      hooks._pendingEffects = [];
      currentIndex = 0;
    }
  }
  previousComponent = currentComponent;
};
options2.diffed = (vnode) => {
  if (oldAfterDiff)
    oldAfterDiff(vnode);
  const c = vnode._component;
  if (c && c.__hooks) {
    if (c.__hooks._pendingEffects.length)
      afterPaint(afterPaintEffects.push(c));
    c.__hooks._list.forEach((hookItem) => {
      if (hookItem._pendingArgs) {
        hookItem._args = hookItem._pendingArgs;
      }
      hookItem._pendingArgs = void 0;
    });
  }
  previousComponent = currentComponent = null;
};
options2._commit = (vnode, commitQueue) => {
  commitQueue.some((component) => {
    try {
      component._renderCallbacks.forEach(invokeCleanup);
      component._renderCallbacks = component._renderCallbacks.filter(
        (cb) => cb._value ? invokeEffect(cb) : true
      );
    } catch (e) {
      commitQueue.some((c) => {
        if (c._renderCallbacks)
          c._renderCallbacks = [];
      });
      commitQueue = [];
      options2._catchError(e, component._vnode);
    }
  });
  if (oldCommit)
    oldCommit(vnode, commitQueue);
};
options2.unmount = (vnode) => {
  if (oldBeforeUnmount)
    oldBeforeUnmount(vnode);
  const c = vnode._component;
  if (c && c.__hooks) {
    let hasErrored;
    c.__hooks._list.forEach((s) => {
      try {
        invokeCleanup(s);
      } catch (e) {
        hasErrored = e;
      }
    });
    c.__hooks = void 0;
    if (hasErrored)
      options2._catchError(hasErrored, c._vnode);
  }
};
function getHookState(index, type) {
  if (options2._hook) {
    options2._hook(currentComponent, index, currentHook || type);
  }
  currentHook = 0;
  const hooks = currentComponent.__hooks || (currentComponent.__hooks = {
    _list: [],
    _pendingEffects: []
  });
  if (index >= hooks._list.length) {
    hooks._list.push({});
  }
  return hooks._list[index];
}
function useState(initialState) {
  currentHook = 1;
  return useReducer(invokeOrReturn, initialState);
}
function useReducer(reducer, initialState, init) {
  const hookState = getHookState(currentIndex++, 2);
  hookState._reducer = reducer;
  if (!hookState._component) {
    hookState._value = [
      !init ? invokeOrReturn(void 0, initialState) : init(initialState),
      (action) => {
        const currentValue = hookState._nextValue ? hookState._nextValue[0] : hookState._value[0];
        const nextValue = hookState._reducer(currentValue, action);
        if (currentValue !== nextValue) {
          hookState._nextValue = [nextValue, hookState._value[1]];
          hookState._component.setState({});
        }
      }
    ];
    hookState._component = currentComponent;
    if (!currentComponent._hasScuFromHooks) {
      let updateHookState = function(p, s, c) {
        if (!hookState._component.__hooks)
          return true;
        const isStateHook = (x) => !!x._component;
        const stateHooks = hookState._component.__hooks._list.filter(isStateHook);
        const allHooksEmpty = stateHooks.every((x) => !x._nextValue);
        if (allHooksEmpty) {
          return prevScu ? prevScu.call(this, p, s, c) : true;
        }
        let shouldUpdate = false;
        stateHooks.forEach((hookItem) => {
          if (hookItem._nextValue) {
            const currentValue = hookItem._value[0];
            hookItem._value = hookItem._nextValue;
            hookItem._nextValue = void 0;
            if (currentValue !== hookItem._value[0])
              shouldUpdate = true;
          }
        });
        return shouldUpdate || hookState._component.props !== p ? prevScu ? prevScu.call(this, p, s, c) : true : false;
      };
      currentComponent._hasScuFromHooks = true;
      let prevScu = currentComponent.shouldComponentUpdate;
      const prevCWU = currentComponent.componentWillUpdate;
      currentComponent.componentWillUpdate = function(p, s, c) {
        if (this._force) {
          let tmp = prevScu;
          prevScu = void 0;
          updateHookState(p, s, c);
          prevScu = tmp;
        }
        if (prevCWU)
          prevCWU.call(this, p, s, c);
      };
      currentComponent.shouldComponentUpdate = updateHookState;
    }
  }
  return hookState._nextValue || hookState._value;
}
function useEffect(callback, args) {
  const state = getHookState(currentIndex++, 3);
  if (!options2._skipEffects && argsChanged(state._args, args)) {
    state._value = callback;
    state._pendingArgs = args;
    currentComponent.__hooks._pendingEffects.push(state);
  }
}
function flushAfterPaintEffects() {
  let component;
  while (component = afterPaintEffects.shift()) {
    if (!component._parentDom || !component.__hooks)
      continue;
    try {
      component.__hooks._pendingEffects.forEach(invokeCleanup);
      component.__hooks._pendingEffects.forEach(invokeEffect);
      component.__hooks._pendingEffects = [];
    } catch (e) {
      component.__hooks._pendingEffects = [];
      options2._catchError(e, component._vnode);
    }
  }
}
var HAS_RAF = typeof requestAnimationFrame == "function";
function afterNextFrame(callback) {
  const done = () => {
    clearTimeout(timeout);
    if (HAS_RAF)
      cancelAnimationFrame(raf);
    setTimeout(callback);
  };
  const timeout = setTimeout(done, RAF_TIMEOUT);
  let raf;
  if (HAS_RAF) {
    raf = requestAnimationFrame(done);
  }
}
function afterPaint(newQueueLength) {
  if (newQueueLength === 1 || prevRaf !== options2.requestAnimationFrame) {
    prevRaf = options2.requestAnimationFrame;
    (prevRaf || afterNextFrame)(flushAfterPaintEffects);
  }
}
function invokeCleanup(hook) {
  const comp = currentComponent;
  let cleanup = hook._cleanup;
  if (typeof cleanup == "function") {
    hook._cleanup = void 0;
    cleanup();
  }
  currentComponent = comp;
}
function invokeEffect(hook) {
  const comp = currentComponent;
  hook._cleanup = hook._value();
  currentComponent = comp;
}
function argsChanged(oldArgs, newArgs) {
  return !oldArgs || oldArgs.length !== newArgs.length || newArgs.some((arg, index) => arg !== oldArgs[index]);
}
function invokeOrReturn(arg, f) {
  return typeof f == "function" ? f(arg) : f;
}

// components/theme.ts
var theme = {
  bg: "#1a1a2eee",
  bgPanel: "#16213e",
  bgCard: "#0f3460",
  bgHover: "#1a4080",
  accent: "#4FC3F7",
  accentDark: "#0288D1",
  text: "#E0E0E0",
  textMuted: "#9E9E9E",
  textBright: "#FFFFFF",
  success: "#66BB6A",
  danger: "#EF5350",
  warning: "#FFA726",
  border: "#2a2a4a",
  radius: 8,
  radiusLg: 12
};

// components/TabContainer.tsx
var TabContainer = ({ tabs, defaultTab }) => {
  const [activeTab, setActiveTab] = useState(defaultTab || tabs[0]?.id);
  const current = tabs.find((t) => t.id === activeTab);
  return /* @__PURE__ */ createElement("div", { style: { flexGrow: 1, flexDirection: "Column", display: "Flex" } }, /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Row",
    display: "Flex",
    borderBottomWidth: 1,
    borderBottomColor: theme.border,
    marginBottom: 12,
    paddingLeft: 4,
    paddingRight: 4
  } }, tabs.map((tab) => /* @__PURE__ */ createElement(
    "div",
    {
      key: tab.id,
      style: {
        paddingTop: 8,
        paddingBottom: 8,
        paddingLeft: 16,
        paddingRight: 16,
        marginRight: 4,
        fontSize: 14,
        color: activeTab === tab.id ? theme.accent : theme.textMuted,
        borderBottomWidth: activeTab === tab.id ? 2 : 0,
        borderBottomColor: theme.accent
      },
      onClick: () => setActiveTab(tab.id)
    },
    tab.label
  ))), /* @__PURE__ */ createElement("div", { style: {
    flexGrow: 1,
    paddingLeft: 4,
    paddingRight: 4
  } }, current?.content()));
};

// components/utils.ts
function parse(json) {
  if (json === "null" || json == null)
    return null;
  return JSON.parse(json);
}

// components/Pagination.tsx
var Pagination = ({ page, totalPages, onPageChange }) => {
  if (totalPages <= 1)
    return null;
  return /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Row",
    display: "Flex",
    justifyContent: "Center",
    alignItems: "Center",
    marginTop: 8
  } }, /* @__PURE__ */ createElement(
    "div",
    {
      style: {
        fontSize: 13,
        color: page > 0 ? theme.accent : theme.textMuted,
        paddingLeft: 12,
        paddingRight: 12,
        paddingTop: 6,
        paddingBottom: 6
      },
      onClick: () => {
        if (page > 0)
          onPageChange(page - 1);
      }
    },
    `\u2039 \u4E0A\u4E00\u9875`
  ), /* @__PURE__ */ createElement("div", { style: { fontSize: 12, color: theme.textMuted, paddingLeft: 8, paddingRight: 8 } }, `${page + 1} / ${totalPages}`), /* @__PURE__ */ createElement(
    "div",
    {
      style: {
        fontSize: 13,
        color: page < totalPages - 1 ? theme.accent : theme.textMuted,
        paddingLeft: 12,
        paddingRight: 12,
        paddingTop: 6,
        paddingBottom: 6
      },
      onClick: () => {
        if (page < totalPages - 1)
          onPageChange(page + 1);
      }
    },
    `\u4E0B\u4E00\u9875 \u203A`
  ));
};

// components/SettingsPanel.tsx
var SETTINGS_PER_PAGE = 6;
var SettingsPanel = () => {
  const [sections, setSections] = useState([]);
  const [activeSection, setActiveSection] = useState("");
  const [entries, setEntries] = useState([]);
  const [page, setPage] = useState(0);
  useEffect(() => {
    try {
      const secs = parse(chill.config.getSections()) || [];
      setSections(secs);
      if (secs.length > 0) {
        setActiveSection(secs[0]);
      }
    } catch (e) {
      console.error("SettingsPanel init error:", e);
    }
  }, []);
  useEffect(() => {
    if (!activeSection)
      return;
    try {
      const items = parse(chill.config.getAll(activeSection)) || [];
      setEntries(items);
      setPage(0);
    } catch (e) {
      console.error("SettingsPanel entries error:", e);
    }
  }, [activeSection]);
  const handleChange = (entry, newValue) => {
    try {
      chill.config.set(entry.section, entry.key, newValue);
      chill.config.save();
      setEntries(parse(chill.config.getAll(activeSection)) || []);
    } catch (e) {
      console.error("SettingsPanel change error:", e);
    }
  };
  const totalPages = Math.max(1, Math.ceil(entries.length / SETTINGS_PER_PAGE));
  const pageEntries = entries.slice(page * SETTINGS_PER_PAGE, (page + 1) * SETTINGS_PER_PAGE);
  return /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", flexGrow: 1 } }, /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Row",
    display: "Flex",
    flexWrap: "Wrap",
    marginBottom: 12
  } }, sections.map((sec) => /* @__PURE__ */ createElement(
    "div",
    {
      key: sec,
      style: {
        paddingTop: 4,
        paddingBottom: 4,
        paddingLeft: 12,
        paddingRight: 12,
        marginRight: 6,
        marginBottom: 4,
        fontSize: 12,
        borderRadius: theme.radius,
        backgroundColor: activeSection === sec ? theme.accent : theme.bgCard,
        color: activeSection === sec ? theme.textBright : theme.textMuted
      },
      onClick: () => setActiveSection(sec)
    },
    sec
  ))), /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", flexGrow: 1 } }, pageEntries.map((entry) => /* @__PURE__ */ createElement(
    ConfigItem,
    {
      key: `${entry.section}::${entry.key}`,
      entry,
      onChange: handleChange
    }
  ))), /* @__PURE__ */ createElement(Pagination, { page, totalPages, onPageChange: setPage }));
};
var ConfigItem = ({ entry, onChange }) => {
  return /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Column",
    display: "Flex",
    backgroundColor: theme.bgCard,
    borderRadius: theme.radius,
    paddingTop: 10,
    paddingBottom: 10,
    paddingLeft: 14,
    paddingRight: 14,
    marginBottom: 6
  } }, /* @__PURE__ */ createElement("div", { style: { flexDirection: "Row", display: "Flex", justifyContent: "SpaceBetween", alignItems: "Center" } }, /* @__PURE__ */ createElement("div", { style: { fontSize: 13, color: theme.text } }, entry.key), /* @__PURE__ */ createElement(ConfigValueEditor, { entry, onChange })), entry.description ? /* @__PURE__ */ createElement("div", { style: { fontSize: 11, color: theme.textMuted, marginTop: 4 } }, entry.description.split("\n")[0]) : null);
};
var ConfigValueEditor = ({ entry, onChange }) => {
  const [editing, setEditing] = useState(false);
  const [draft, setDraft] = useState("");
  if (entry.type === "bool") {
    return /* @__PURE__ */ createElement(
      "div",
      {
        style: {
          paddingTop: 3,
          paddingBottom: 3,
          paddingLeft: 10,
          paddingRight: 10,
          borderRadius: 4,
          fontSize: 12,
          backgroundColor: entry.value ? theme.success : theme.danger,
          color: theme.textBright
        },
        onClick: () => onChange(entry, !entry.value)
      },
      entry.value ? "ON" : "OFF"
    );
  }
  if (editing) {
    const confirm = () => {
      const val = entry.type === "int" || entry.type === "float" || entry.type === "double" ? Number(draft) : draft;
      if (entry.type === "int" || entry.type === "float" || entry.type === "double") {
        if (isNaN(val)) {
          setEditing(false);
          return;
        }
      }
      onChange(entry, val);
      setEditing(false);
    };
    return /* @__PURE__ */ createElement("div", { style: { flexDirection: "Row", display: "Flex", alignItems: "Center" } }, /* @__PURE__ */ createElement(
      "textfield",
      {
        value: draft,
        onValueChanged: (e) => setDraft(e.newValue ?? e.target?.value ?? draft),
        onKeyDown: (e) => {
          if (e.keyCode === 13)
            confirm();
        },
        style: {
          fontSize: 12,
          color: theme.text,
          backgroundColor: theme.bg,
          borderRadius: 4,
          paddingLeft: 6,
          paddingRight: 6,
          paddingTop: 2,
          paddingBottom: 2,
          minWidth: 80
        }
      }
    ), /* @__PURE__ */ createElement(
      "div",
      {
        style: {
          fontSize: 11,
          color: theme.success,
          paddingLeft: 6
        },
        onClick: confirm
      },
      `\u2713`
    ), /* @__PURE__ */ createElement(
      "div",
      {
        style: {
          fontSize: 11,
          color: theme.danger,
          paddingLeft: 4
        },
        onClick: () => setEditing(false)
      },
      `\u2715`
    ));
  }
  return /* @__PURE__ */ createElement(
    "div",
    {
      style: {
        fontSize: 12,
        color: theme.accent,
        paddingLeft: 8
      },
      onClick: () => {
        setDraft(String(entry.value));
        setEditing(true);
      }
    },
    String(entry.value)
  );
};

// components/AboutPanel.tsx
var AboutPanel = () => {
  let version = "unknown";
  let pluginPathVal = "N/A";
  try {
    version = String(chill.version || "unknown").trim();
    pluginPathVal = String(chill.pluginPath || "N/A").trim();
  } catch (e) {
    console.error("AboutPanel init error:", e);
  }
  return /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", alignItems: "Center", paddingTop: 40 } }, /* @__PURE__ */ createElement("div", { style: {
    fontSize: 28,
    color: theme.accent,
    marginBottom: 8
  } }, "ChillPatcher"), /* @__PURE__ */ createElement("div", { style: { fontSize: 14, color: theme.textMuted, marginBottom: 24 } }, `v${version}`), /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Column",
    display: "Flex",
    backgroundColor: theme.bgCard,
    borderRadius: theme.radiusLg,
    paddingTop: 20,
    paddingBottom: 20,
    paddingLeft: 24,
    paddingRight: 24,
    maxWidth: 400,
    width: "100%"
  } }, /* @__PURE__ */ createElement(InfoRow, { label: "Plugin GUID", value: "com.chillpatcher.core" }), /* @__PURE__ */ createElement(InfoRow, { label: "Runtime", value: ".NET Framework 4.7.2" }), /* @__PURE__ */ createElement(InfoRow, { label: "UI Engine", value: "OneJS + Preact" }), /* @__PURE__ */ createElement(InfoRow, { label: "Framework", value: "BepInEx 5" }), /* @__PURE__ */ createElement(InfoRow, { label: "Plugin Path", value: pluginPathVal })), /* @__PURE__ */ createElement("div", { style: {
    fontSize: 12,
    color: theme.textMuted,
    marginTop: 24
  } }, 'A modding framework for "Chill With You"'));
};
var InfoRow = ({ label, value }) => /* @__PURE__ */ createElement("div", { style: {
  flexDirection: "Row",
  display: "Flex",
  justifyContent: "SpaceBetween",
  paddingTop: 6,
  paddingBottom: 6,
  borderBottomWidth: 1,
  borderBottomColor: theme.border
} }, /* @__PURE__ */ createElement("div", { style: { fontSize: 13, color: theme.textMuted } }, label), /* @__PURE__ */ createElement("div", { style: { fontSize: 13, color: theme.text, maxWidth: 240 } }, value));

// components/LicensesPanel.tsx
var ITEMS_PER_PAGE = 8;
var LicensesPanel = () => {
  const [currentPath, setCurrentPath] = useState("licenses");
  const [items, setItems] = useState([]);
  const [page, setPage] = useState(0);
  const [selected, setSelected] = useState(null);
  const [content, setContent] = useState("");
  useEffect(() => {
    loadDirectory(currentPath);
    setPage(0);
  }, [currentPath]);
  const loadDirectory = (dirPath) => {
    try {
      const dirs = parse(chill.io.listDirs(dirPath)) || [];
      const files = parse(chill.io.listFiles(dirPath)) || [];
      const combined = [
        ...dirs.map((d) => ({ type: "dir", name: d, displayName: d })),
        ...files.map((f) => ({ type: "file", name: f.name, displayName: f.nameWithoutExt, size: f.size }))
      ];
      setItems(combined);
    } catch (e) {
      console.error("LicensesPanel load error:", e);
      setItems([]);
    }
  };
  const enterDir = (dirName) => {
    setCurrentPath(`${currentPath}/${dirName}`);
  };
  const goUp = () => {
    const idx = currentPath.lastIndexOf("/");
    if (idx > 0)
      setCurrentPath(currentPath.substring(0, idx));
  };
  const selectFile = (fileName) => {
    setSelected(fileName);
    try {
      const text = chill.io.readText(`${currentPath}/${fileName}`);
      setContent(text || "\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\u5185\u5BB9");
    } catch (e) {
      console.error("LicensesPanel read error:", e);
      setContent("\u8BFB\u53D6\u5931\u8D25");
    }
  };
  if (selected) {
    return /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", flexGrow: 1 } }, /* @__PURE__ */ createElement(
      LicenseDetail,
      {
        fileName: selected,
        content,
        onBack: () => setSelected(null)
      }
    ));
  }
  const totalPages = Math.max(1, Math.ceil(items.length / ITEMS_PER_PAGE));
  const pageItems = items.slice(page * ITEMS_PER_PAGE, (page + 1) * ITEMS_PER_PAGE);
  const isSubDir = currentPath !== "licenses";
  return /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", flexGrow: 1 } }, isSubDir && /* @__PURE__ */ createElement(
    "div",
    {
      style: { fontSize: 13, color: theme.accent, marginBottom: 6 },
      onClick: goUp
    },
    `\u2190 ${currentPath.substring(currentPath.lastIndexOf("/") + 1)}`
  ), /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", flexGrow: 1 } }, pageItems.length === 0 ? /* @__PURE__ */ createElement("div", { style: { fontSize: 13, color: theme.textMuted, paddingTop: 20 } }, `\u8BE5\u76EE\u5F55\u4E0B\u672A\u627E\u5230\u8BB8\u53EF\u8BC1\u6587\u4EF6`) : pageItems.map((item) => /* @__PURE__ */ createElement(
    "div",
    {
      key: `${item.type}-${item.name}`,
      style: {
        flexDirection: "Row",
        display: "Flex",
        justifyContent: "SpaceBetween",
        alignItems: "Center",
        backgroundColor: theme.bgCard,
        borderRadius: theme.radius,
        paddingTop: 10,
        paddingBottom: 10,
        paddingLeft: 14,
        paddingRight: 14,
        marginBottom: 4
      },
      onClick: () => item.type === "dir" ? enterDir(item.name) : selectFile(item.name)
    },
    /* @__PURE__ */ createElement("div", { style: { fontSize: 13, color: item.type === "dir" ? theme.accent : theme.text } }, item.type === "dir" ? `\uF07B ${item.displayName}` : item.displayName),
    /* @__PURE__ */ createElement("div", { style: { fontSize: 11, color: theme.textMuted } }, item.type === "dir" ? "" : formatSize(item.size))
  ))), /* @__PURE__ */ createElement(Pagination, { page, totalPages, onPageChange: setPage }));
};
var LINES_PER_PAGE = 20;
var LicenseDetail = ({ fileName, content, onBack }) => {
  const [page, setPage] = useState(0);
  const lines = content.split("\n");
  const totalPages = Math.max(1, Math.ceil(lines.length / LINES_PER_PAGE));
  const pageLines = lines.slice(page * LINES_PER_PAGE, (page + 1) * LINES_PER_PAGE);
  return /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", flexGrow: 1 } }, /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Row",
    display: "Flex",
    justifyContent: "SpaceBetween",
    alignItems: "Center",
    marginBottom: 8
  } }, /* @__PURE__ */ createElement(
    "div",
    {
      style: { fontSize: 13, color: theme.accent },
      onClick: onBack
    },
    `\u2190 \u8FD4\u56DE\u5217\u8868`
  ), /* @__PURE__ */ createElement("div", { style: { fontSize: 12, color: theme.textMuted } }, fileName)), /* @__PURE__ */ createElement("div", { style: {
    flexGrow: 1,
    backgroundColor: theme.bgCard,
    borderRadius: theme.radius,
    paddingTop: 12,
    paddingBottom: 12,
    paddingLeft: 14,
    paddingRight: 14,
    flexDirection: "Column",
    display: "Flex"
  } }, pageLines.map((line, i) => /* @__PURE__ */ createElement("div", { key: i, style: { fontSize: 11, color: theme.textMuted, minHeight: 14 } }, line || " "))), /* @__PURE__ */ createElement(Pagination, { page, totalPages, onPageChange: setPage }));
};
function formatSize(bytes) {
  if (bytes < 1024)
    return `${bytes} B`;
  if (bytes < 1024 * 1024)
    return `${(bytes / 1024).toFixed(1)} KB`;
  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}

// components/ModulesPanel.tsx
var MODULES_PER_PAGE = 4;
var ModulesPanel = () => {
  const [modules, setModules] = useState([]);
  const [page, setPage] = useState(0);
  const refresh = () => {
    try {
      const list = parse(chill.modules.getAll());
      setModules(list || []);
    } catch (e) {
      console.error("ModulesPanel refresh error:", e);
    }
  };
  useEffect(() => {
    refresh();
    const timer = setInterval(() => {
      try {
        const count = chill.modules.getCount();
        if (count > 0) {
          refresh();
          clearInterval(timer);
        }
      } catch (e) {
        console.error("ModulesPanel poll error:", e);
      }
    }, 2e3);
    return () => clearInterval(timer);
  }, []);
  const toggle = (mod) => {
    try {
      if (mod.enabled) {
        chill.modules.disable(mod.moduleId);
      } else {
        chill.modules.enable(mod.moduleId);
      }
      refresh();
    } catch (e) {
      console.error("ModulesPanel toggle error:", e);
    }
  };
  const totalPages = Math.max(1, Math.ceil(modules.length / MODULES_PER_PAGE));
  const pageModules = modules.slice(page * MODULES_PER_PAGE, (page + 1) * MODULES_PER_PAGE);
  return /* @__PURE__ */ createElement("div", { style: { flexDirection: "Column", display: "Flex", flexGrow: 1 } }, /* @__PURE__ */ createElement("div", { style: { fontSize: 12, color: theme.textMuted, marginBottom: 8 } }, `\u5DF2\u6CE8\u518C ${modules.length} \u4E2A\u6A21\u5757\uFF08\u7981\u7528/\u542F\u7528\u540E\u9700\u91CD\u542F\u6E38\u620F\u751F\u6548\uFF09`), pageModules.map((mod) => /* @__PURE__ */ createElement(ModuleCard, { key: mod.moduleId, module: mod, onToggle: () => toggle(mod) })), /* @__PURE__ */ createElement(Pagination, { page, totalPages, onPageChange: setPage }));
};
var ModuleCard = ({ module: module2, onToggle }) => /* @__PURE__ */ createElement("div", { style: {
  flexDirection: "Column",
  display: "Flex",
  backgroundColor: theme.bgCard,
  borderRadius: theme.radius,
  paddingTop: 12,
  paddingBottom: 12,
  paddingLeft: 14,
  paddingRight: 14,
  marginBottom: 6
} }, /* @__PURE__ */ createElement("div", { style: {
  flexDirection: "Row",
  display: "Flex",
  justifyContent: "SpaceBetween",
  alignItems: "Center",
  marginBottom: 6
} }, /* @__PURE__ */ createElement("div", { style: { flexDirection: "Row", display: "Flex", alignItems: "Center" } }, /* @__PURE__ */ createElement("div", { style: { fontSize: 14, color: theme.text, marginRight: 8 } }, module2.displayName), /* @__PURE__ */ createElement("div", { style: { fontSize: 11, color: theme.textMuted } }, `v${module2.version}`)), /* @__PURE__ */ createElement(
  "div",
  {
    style: {
      paddingTop: 3,
      paddingBottom: 3,
      paddingLeft: 10,
      paddingRight: 10,
      borderRadius: 4,
      fontSize: 11,
      backgroundColor: module2.enabled ? theme.success : theme.danger,
      color: theme.textBright
    },
    onClick: onToggle
  },
  module2.enabled ? "\u542F\u7528" : "\u7981\u7528"
)), /* @__PURE__ */ createElement("div", { style: { fontSize: 11, color: theme.textMuted, marginBottom: 4 } }, module2.moduleId), /* @__PURE__ */ createElement("div", { style: { fontSize: 11, color: theme.textMuted } }, `\u4F18\u5148\u7EA7: ${module2.priority} \xB7 \u52A0\u8F7D\u4E8E ${module2.loadedAt}`), module2.capabilities ? /* @__PURE__ */ createElement("div", { style: {
  flexDirection: "Row",
  display: "Flex",
  flexWrap: "Wrap",
  marginTop: 6
} }, module2.capabilities.canDelete && /* @__PURE__ */ createElement(CapBadge, { label: "\u5220\u9664" }), module2.capabilities.canFavorite && /* @__PURE__ */ createElement(CapBadge, { label: "\u6536\u85CF" }), module2.capabilities.canExclude && /* @__PURE__ */ createElement(CapBadge, { label: "\u6392\u9664" }), module2.capabilities.supportsLiveUpdate && /* @__PURE__ */ createElement(CapBadge, { label: "\u70ED\u66F4\u65B0" }), module2.capabilities.providesCover && /* @__PURE__ */ createElement(CapBadge, { label: "\u5C01\u9762" }), module2.capabilities.providesAlbum && /* @__PURE__ */ createElement(CapBadge, { label: "\u4E13\u8F91" })) : null);
var CapBadge = ({ label }) => /* @__PURE__ */ createElement("div", { style: {
  fontSize: 10,
  color: theme.accent,
  backgroundColor: theme.bg,
  borderRadius: 3,
  paddingTop: 2,
  paddingBottom: 2,
  paddingLeft: 6,
  paddingRight: 6,
  marginRight: 4,
  marginBottom: 2
} }, label);

// index.tsx
var ErrorBoundary = class extends BaseComponent {
  constructor(props) {
    super(props);
    this.state = { error: null };
  }
  componentDidCatch(error) {
    this.setState({ error: String(error) });
  }
  render() {
    if (this.state.error) {
      return /* @__PURE__ */ createElement("div", { style: { color: "#ff5555", fontSize: 11, padding: 8, backgroundColor: "#2a0000", borderRadius: 4, marginBottom: 4 } }, /* @__PURE__ */ createElement("div", { style: { color: "#ff8888", fontSize: 12, marginBottom: 4 } }, "[", this.props.name, "] Error:"), /* @__PURE__ */ createElement("div", { style: { color: "#ffaaaa", fontSize: 10, whiteSpace: "Normal" } }, this.state.error));
    }
    return this.props.children;
  }
};
var App = () => {
  const [visible, setVisible] = useState(true);
  if (!visible) {
    return /* @__PURE__ */ createElement(
      "div",
      {
        key: "collapsed",
        style: {
          position: "Absolute",
          top: 0,
          right: 0,
          width: 52,
          height: 52,
          backgroundColor: theme.bg,
          borderTopLeftRadius: 0,
          borderTopRightRadius: 0,
          borderBottomRightRadius: 0,
          borderBottomLeftRadius: 52,
          justifyContent: "Center",
          alignItems: "Center",
          display: "Flex",
          paddingLeft: 8,
          paddingBottom: 8
        },
        onClick: () => setVisible(true)
      },
      /* @__PURE__ */ createElement("div", { style: { fontSize: 18, color: theme.accent } }, "\uEB51")
    );
  }
  return /* @__PURE__ */ createElement("div", { key: "panel", style: {
    position: "Absolute",
    top: "20%",
    bottom: "20%",
    left: "15%",
    right: "15%",
    backgroundColor: theme.bg,
    borderRadius: theme.radiusLg,
    flexDirection: "Column",
    display: "Flex",
    overflow: "Hidden"
  } }, /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Row",
    display: "Flex",
    justifyContent: "SpaceBetween",
    alignItems: "Center",
    paddingTop: 12,
    paddingBottom: 8,
    paddingLeft: 20,
    paddingRight: 20,
    borderBottomWidth: 1,
    borderBottomColor: theme.border
  } }, /* @__PURE__ */ createElement("div", { style: { fontSize: 16, color: theme.accent } }, "ChillPatcher"), /* @__PURE__ */ createElement(
    "div",
    {
      style: {
        fontSize: 14,
        color: theme.textMuted,
        paddingLeft: 8,
        paddingRight: 4
      },
      onClick: () => setVisible(false)
    },
    "\u2715"
  )), /* @__PURE__ */ createElement("scrollview", { style: { flexGrow: 1 } }, /* @__PURE__ */ createElement("div", { style: {
    flexDirection: "Column",
    display: "Flex",
    paddingTop: 8,
    paddingBottom: 12,
    paddingLeft: 16,
    paddingRight: 16
  } }, /* @__PURE__ */ createElement(
    TabContainer,
    {
      defaultTab: "modules",
      tabs: [
        { id: "modules", label: "\u6A21\u5757", content: () => /* @__PURE__ */ createElement(ErrorBoundary, { name: "ModulesPanel" }, /* @__PURE__ */ createElement(ModulesPanel, null)) },
        { id: "settings", label: "\u8BBE\u7F6E", content: () => /* @__PURE__ */ createElement(ErrorBoundary, { name: "SettingsPanel" }, /* @__PURE__ */ createElement(SettingsPanel, null)) },
        { id: "licenses", label: "\u8BB8\u53EF\u8BC1", content: () => /* @__PURE__ */ createElement(ErrorBoundary, { name: "LicensesPanel" }, /* @__PURE__ */ createElement(LicensesPanel, null)) },
        { id: "about", label: "\u5173\u4E8E", content: () => /* @__PURE__ */ createElement(ErrorBoundary, { name: "AboutPanel" }, /* @__PURE__ */ createElement(AboutPanel, null)) }
      ]
    }
  ))));
};
render(/* @__PURE__ */ createElement(App, null), document.body);
//# sourceMappingURL=app.js.map
