shadow$provide.module$node_modules$pixi_DOT_js$lib$events$EventSystem = function(global, require, module, exports) {
  global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions");
  var EventBoundary = require("module$node_modules$pixi_DOT_js$lib$events$EventBoundary"), EventTicker = require("module$node_modules$pixi_DOT_js$lib$events$EventTicker"), FederatedPointerEvent = require("module$node_modules$pixi_DOT_js$lib$events$FederatedPointerEvent"), FederatedWheelEvent = require("module$node_modules$pixi_DOT_js$lib$events$FederatedWheelEvent");
  "use strict";
  const TOUCH_TO_POINTER = {touchstart:"pointerdown", touchend:"pointerup", touchendoutside:"pointerupoutside", touchmove:"pointermove", touchcancel:"pointercancel"}, node_modules$pixi_DOT_js$lib$events$EventSystem$classdecl$var5 = class {
    constructor(renderer) {
      this.supportsTouchEvents = "ontouchstart" in globalThis;
      this.supportsPointerEvents = !!globalThis.PointerEvent;
      this.domElement = null;
      this.resolution = 1;
      this.renderer = renderer;
      this.rootBoundary = new EventBoundary.EventBoundary(null);
      EventTicker.EventsTicker.init(this);
      this.autoPreventDefault = !0;
      this._eventsAdded = !1;
      this._rootPointerEvent = new FederatedPointerEvent.FederatedPointerEvent(null);
      this._rootWheelEvent = new FederatedWheelEvent.FederatedWheelEvent(null);
      this.cursorStyles = {default:"inherit", pointer:"pointer"};
      this.features = new Proxy({...node_modules$pixi_DOT_js$lib$events$EventSystem$classdecl$var5.defaultEventFeatures}, {set:(target, key, value) => {
        "globalMove" === key && (this.rootBoundary.enableGlobalMoveEvents = value);
        target[key] = value;
        return !0;
      }});
      this._onPointerDown = this._onPointerDown.bind(this);
      this._onPointerMove = this._onPointerMove.bind(this);
      this._onPointerUp = this._onPointerUp.bind(this);
      this._onPointerOverOut = this._onPointerOverOut.bind(this);
      this.onWheel = this.onWheel.bind(this);
    }
    static get defaultEventMode() {
      return this._defaultEventMode;
    }
    init(options) {
      const {canvas, resolution} = this.renderer;
      this.setTargetElement(canvas);
      this.resolution = resolution;
      node_modules$pixi_DOT_js$lib$events$EventSystem$classdecl$var5._defaultEventMode = options.eventMode ?? "passive";
      Object.assign(this.features, options.eventFeatures ?? {});
      this.rootBoundary.enableGlobalMoveEvents = this.features.globalMove;
    }
    resolutionChange(resolution) {
      this.resolution = resolution;
    }
    destroy() {
      EventTicker.EventsTicker.destroy();
      this.setTargetElement(null);
      this._currentCursor = this.renderer = null;
    }
    setCursor(mode) {
      mode || (mode = "default");
      let applyStyles = !0;
      globalThis.OffscreenCanvas && this.domElement instanceof OffscreenCanvas && (applyStyles = !1);
      if (this._currentCursor !== mode) {
        this._currentCursor = mode;
        var style = this.cursorStyles[mode];
        if (style) {
          switch(typeof style) {
            case "string":
              applyStyles && (this.domElement.style.cursor = style);
              break;
            case "function":
              style(mode);
              break;
            case "object":
              applyStyles && Object.assign(this.domElement.style, style);
          }
        } else {
          applyStyles && "string" === typeof mode && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode) && (this.domElement.style.cursor = mode);
        }
      }
    }
    get pointer() {
      return this._rootPointerEvent;
    }
    _onPointerDown(nativeEvent) {
      if (this.features.click) {
        this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
        var events = this._normalizeToPointerData(nativeEvent);
        this.autoPreventDefault && events[0].isNormalized && (!nativeEvent.cancelable && "cancelable" in nativeEvent || nativeEvent.preventDefault());
        for (let i = 0, j = events.length; i < j; i++) {
          nativeEvent = this._bootstrapEvent(this._rootPointerEvent, events[i]), this.rootBoundary.mapEvent(nativeEvent);
        }
        this.setCursor(this.rootBoundary.cursor);
      }
    }
    _onPointerMove(nativeEvent) {
      if (this.features.move) {
        this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
        EventTicker.EventsTicker.pointerMoved();
        nativeEvent = this._normalizeToPointerData(nativeEvent);
        for (let i = 0, j = nativeEvent.length; i < j; i++) {
          const event = this._bootstrapEvent(this._rootPointerEvent, nativeEvent[i]);
          this.rootBoundary.mapEvent(event);
        }
        this.setCursor(this.rootBoundary.cursor);
      }
    }
    _onPointerUp(nativeEvent) {
      if (this.features.click) {
        this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
        var target = nativeEvent.target;
        nativeEvent.composedPath && 0 < nativeEvent.composedPath().length && (target = nativeEvent.composedPath()[0]);
        target = target !== this.domElement ? "outside" : "";
        nativeEvent = this._normalizeToPointerData(nativeEvent);
        for (let i = 0, j = nativeEvent.length; i < j; i++) {
          const event = this._bootstrapEvent(this._rootPointerEvent, nativeEvent[i]);
          event.type += target;
          this.rootBoundary.mapEvent(event);
        }
        this.setCursor(this.rootBoundary.cursor);
      }
    }
    _onPointerOverOut(nativeEvent) {
      if (this.features.click) {
        this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
        nativeEvent = this._normalizeToPointerData(nativeEvent);
        for (let i = 0, j = nativeEvent.length; i < j; i++) {
          const event = this._bootstrapEvent(this._rootPointerEvent, nativeEvent[i]);
          this.rootBoundary.mapEvent(event);
        }
        this.setCursor(this.rootBoundary.cursor);
      }
    }
    onWheel(nativeEvent) {
      this.features.wheel && (nativeEvent = this.normalizeWheelEvent(nativeEvent), this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, this.rootBoundary.mapEvent(nativeEvent));
    }
    setTargetElement(element) {
      this._removeEvents();
      this.domElement = element;
      EventTicker.EventsTicker.domElement = element;
      this._addEvents();
    }
    _addEvents() {
      if (!this._eventsAdded && this.domElement) {
        EventTicker.EventsTicker.addTickerListener();
        var style = this.domElement.style;
        style && (globalThis.navigator.msPointerEnabled ? (style.msContentZooming = "none", style.msTouchAction = "none") : this.supportsPointerEvents && (style.touchAction = "none"));
        this.supportsPointerEvents ? (globalThis.document.addEventListener("pointermove", this._onPointerMove, !0), this.domElement.addEventListener("pointerdown", this._onPointerDown, !0), this.domElement.addEventListener("pointerleave", this._onPointerOverOut, !0), this.domElement.addEventListener("pointerover", this._onPointerOverOut, !0), globalThis.addEventListener("pointerup", this._onPointerUp, !0)) : (globalThis.document.addEventListener("mousemove", this._onPointerMove, !0), this.domElement.addEventListener("mousedown", 
        this._onPointerDown, !0), this.domElement.addEventListener("mouseout", this._onPointerOverOut, !0), this.domElement.addEventListener("mouseover", this._onPointerOverOut, !0), globalThis.addEventListener("mouseup", this._onPointerUp, !0), this.supportsTouchEvents && (this.domElement.addEventListener("touchstart", this._onPointerDown, !0), this.domElement.addEventListener("touchend", this._onPointerUp, !0), this.domElement.addEventListener("touchmove", this._onPointerMove, !0)));
        this.domElement.addEventListener("wheel", this.onWheel, {passive:!0, capture:!0});
        this._eventsAdded = !0;
      }
    }
    _removeEvents() {
      if (this._eventsAdded && this.domElement) {
        EventTicker.EventsTicker.removeTickerListener();
        var style = this.domElement.style;
        style && (globalThis.navigator.msPointerEnabled ? (style.msContentZooming = "", style.msTouchAction = "") : this.supportsPointerEvents && (style.touchAction = ""));
        this.supportsPointerEvents ? (globalThis.document.removeEventListener("pointermove", this._onPointerMove, !0), this.domElement.removeEventListener("pointerdown", this._onPointerDown, !0), this.domElement.removeEventListener("pointerleave", this._onPointerOverOut, !0), this.domElement.removeEventListener("pointerover", this._onPointerOverOut, !0), globalThis.removeEventListener("pointerup", this._onPointerUp, !0)) : (globalThis.document.removeEventListener("mousemove", this._onPointerMove, 
        !0), this.domElement.removeEventListener("mousedown", this._onPointerDown, !0), this.domElement.removeEventListener("mouseout", this._onPointerOverOut, !0), this.domElement.removeEventListener("mouseover", this._onPointerOverOut, !0), globalThis.removeEventListener("mouseup", this._onPointerUp, !0), this.supportsTouchEvents && (this.domElement.removeEventListener("touchstart", this._onPointerDown, !0), this.domElement.removeEventListener("touchend", this._onPointerUp, !0), this.domElement.removeEventListener("touchmove", 
        this._onPointerMove, !0)));
        this.domElement.removeEventListener("wheel", this.onWheel, !0);
        this.domElement = null;
        this._eventsAdded = !1;
      }
    }
    mapPositionToPoint(point, x, y) {
      const rect = this.domElement.isConnected ? this.domElement.getBoundingClientRect() : {x:0, y:0, width:this.domElement.width, height:this.domElement.height, left:0, top:0}, resolutionMultiplier = 1 / this.resolution;
      point.x = this.domElement.width / rect.width * (x - rect.left) * resolutionMultiplier;
      point.y = this.domElement.height / rect.height * (y - rect.top) * resolutionMultiplier;
    }
    _normalizeToPointerData(event) {
      const normalizedEvents = [];
      if (this.supportsTouchEvents && event instanceof TouchEvent) {
        for (let i = 0, li = event.changedTouches.length; i < li; i++) {
          const touch = event.changedTouches[i];
          "undefined" === typeof touch.button && (touch.button = 0);
          "undefined" === typeof touch.buttons && (touch.buttons = 1);
          "undefined" === typeof touch.isPrimary && (touch.isPrimary = 1 === event.touches.length && "touchstart" === event.type);
          "undefined" === typeof touch.width && (touch.width = touch.radiusX || 1);
          "undefined" === typeof touch.height && (touch.height = touch.radiusY || 1);
          "undefined" === typeof touch.tiltX && (touch.tiltX = 0);
          "undefined" === typeof touch.tiltY && (touch.tiltY = 0);
          "undefined" === typeof touch.pointerType && (touch.pointerType = "touch");
          "undefined" === typeof touch.pointerId && (touch.pointerId = touch.identifier || 0);
          "undefined" === typeof touch.pressure && (touch.pressure = touch.force || 0.5);
          "undefined" === typeof touch.twist && (touch.twist = 0);
          "undefined" === typeof touch.tangentialPressure && (touch.tangentialPressure = 0);
          "undefined" === typeof touch.layerX && (touch.layerX = touch.offsetX = touch.clientX);
          "undefined" === typeof touch.layerY && (touch.layerY = touch.offsetY = touch.clientY);
          touch.isNormalized = !0;
          touch.type = event.type;
          touch.altKey ?? (touch.altKey = event.altKey);
          touch.ctrlKey ?? (touch.ctrlKey = event.ctrlKey);
          touch.metaKey ?? (touch.metaKey = event.metaKey);
          touch.shiftKey ?? (touch.shiftKey = event.shiftKey);
          normalizedEvents.push(touch);
        }
      } else {
        if (!globalThis.MouseEvent || event instanceof MouseEvent && !(this.supportsPointerEvents && event instanceof globalThis.PointerEvent)) {
          "undefined" === typeof event.isPrimary && (event.isPrimary = !0), "undefined" === typeof event.width && (event.width = 1), "undefined" === typeof event.height && (event.height = 1), "undefined" === typeof event.tiltX && (event.tiltX = 0), "undefined" === typeof event.tiltY && (event.tiltY = 0), "undefined" === typeof event.pointerType && (event.pointerType = "mouse"), "undefined" === typeof event.pointerId && (event.pointerId = 1), "undefined" === typeof event.pressure && (event.pressure = 
          0.5), "undefined" === typeof event.twist && (event.twist = 0), "undefined" === typeof event.tangentialPressure && (event.tangentialPressure = 0), event.isNormalized = !0;
        }
        normalizedEvents.push(event);
      }
      return normalizedEvents;
    }
    normalizeWheelEvent(nativeEvent) {
      const event = this._rootWheelEvent;
      this._transferMouseData(event, nativeEvent);
      event.deltaX = nativeEvent.deltaX;
      event.deltaY = nativeEvent.deltaY;
      event.deltaZ = nativeEvent.deltaZ;
      event.deltaMode = nativeEvent.deltaMode;
      this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
      event.global.copyFrom(event.screen);
      event.offset.copyFrom(event.screen);
      event.nativeEvent = nativeEvent;
      event.type = nativeEvent.type;
      return event;
    }
    _bootstrapEvent(event, nativeEvent) {
      event.originalEvent = null;
      event.nativeEvent = nativeEvent;
      event.pointerId = nativeEvent.pointerId;
      event.width = nativeEvent.width;
      event.height = nativeEvent.height;
      event.isPrimary = nativeEvent.isPrimary;
      event.pointerType = nativeEvent.pointerType;
      event.pressure = nativeEvent.pressure;
      event.tangentialPressure = nativeEvent.tangentialPressure;
      event.tiltX = nativeEvent.tiltX;
      event.tiltY = nativeEvent.tiltY;
      event.twist = nativeEvent.twist;
      this._transferMouseData(event, nativeEvent);
      this.mapPositionToPoint(event.screen, nativeEvent.clientX, nativeEvent.clientY);
      event.global.copyFrom(event.screen);
      event.offset.copyFrom(event.screen);
      event.isTrusted = nativeEvent.isTrusted;
      "pointerleave" === event.type && (event.type = "pointerout");
      event.type.startsWith("mouse") && (event.type = event.type.replace("mouse", "pointer"));
      event.type.startsWith("touch") && (event.type = TOUCH_TO_POINTER[event.type] || event.type);
      return event;
    }
    _transferMouseData(event, nativeEvent) {
      event.isTrusted = nativeEvent.isTrusted;
      event.srcElement = nativeEvent.srcElement;
      event.timeStamp = performance.now();
      event.type = nativeEvent.type;
      event.altKey = nativeEvent.altKey;
      event.button = nativeEvent.button;
      event.buttons = nativeEvent.buttons;
      event.client.x = nativeEvent.clientX;
      event.client.y = nativeEvent.clientY;
      event.ctrlKey = nativeEvent.ctrlKey;
      event.metaKey = nativeEvent.metaKey;
      event.movement.x = nativeEvent.movementX;
      event.movement.y = nativeEvent.movementY;
      event.page.x = nativeEvent.pageX;
      event.page.y = nativeEvent.pageY;
      event.relatedTarget = null;
      event.shiftKey = nativeEvent.shiftKey;
    }
  };
  require = node_modules$pixi_DOT_js$lib$events$EventSystem$classdecl$var5;
  require.extension = {name:"events", type:[global.ExtensionType.WebGLSystem, global.ExtensionType.CanvasSystem, global.ExtensionType.WebGPUSystem], priority:-1};
  require.defaultEventFeatures = {move:!0, globalMove:!0, click:!0, wheel:!0};
  exports.EventSystem = require;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$events$EventSystem.js.map
