shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$mask$stencil$StencilMaskPipe = function(global, require, module, exports) {
  global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions");
  var _const$1 = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$gl$const"), _const = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$state$const");
  "use strict";
  class StencilMaskPipe {
    constructor(renderer) {
      this._maskStackHash = {};
      this._maskHash = new WeakMap();
      this._renderer = renderer;
    }
    push(mask, _container, instructionSet) {
      var _a;
      const renderer = this._renderer;
      renderer.renderPipes.batch.break(instructionSet);
      renderer.renderPipes.blendMode.setBlendMode(mask.mask, "none", instructionSet);
      instructionSet.add({renderPipeId:"stencilMask", action:"pushMaskBegin", mask, inverse:_container._maskOptions.inverse, canBundle:!1});
      const maskContainer = mask.mask;
      maskContainer.includeInBuild = !0;
      this._maskHash.has(mask) || this._maskHash.set(mask, {instructionsStart:0, instructionsLength:0});
      const maskData = this._maskHash.get(mask);
      maskData.instructionsStart = instructionSet.instructionSize;
      maskContainer.collectRenderables(instructionSet, renderer, null);
      maskContainer.includeInBuild = !1;
      renderer.renderPipes.batch.break(instructionSet);
      instructionSet.add({renderPipeId:"stencilMask", action:"pushMaskEnd", mask, inverse:_container._maskOptions.inverse, canBundle:!1});
      maskData.instructionsLength = instructionSet.instructionSize - maskData.instructionsStart - 1;
      mask = renderer.renderTarget.renderTarget.uid;
      (_a = this._maskStackHash)[mask] ?? (_a[mask] = 0);
    }
    pop(mask, _container, instructionSet) {
      const renderer = this._renderer;
      renderer.renderPipes.batch.break(instructionSet);
      renderer.renderPipes.blendMode.setBlendMode(mask.mask, "none", instructionSet);
      instructionSet.add({renderPipeId:"stencilMask", action:"popMaskBegin", inverse:_container._maskOptions.inverse, canBundle:!1});
      mask = this._maskHash.get(mask);
      for (_container = 0; _container < mask.instructionsLength; _container++) {
        instructionSet.instructions[instructionSet.instructionSize++] = instructionSet.instructions[mask.instructionsStart++];
      }
      instructionSet.add({renderPipeId:"stencilMask", action:"popMaskEnd", canBundle:!1});
    }
    execute(instruction) {
      var _a;
      const renderer = this._renderer, renderTargetUid = renderer.renderTarget.renderTarget.uid;
      let maskStackIndex = (_a = this._maskStackHash)[renderTargetUid] ?? (_a[renderTargetUid] = 0);
      "pushMaskBegin" === instruction.action ? (renderer.renderTarget.ensureDepthStencil(), renderer.stencil.setStencilMode(_const.STENCIL_MODES.RENDERING_MASK_ADD, maskStackIndex), maskStackIndex++, renderer.colorMask.setMask(0)) : "pushMaskEnd" === instruction.action ? (instruction.inverse ? renderer.stencil.setStencilMode(_const.STENCIL_MODES.INVERSE_MASK_ACTIVE, maskStackIndex) : renderer.stencil.setStencilMode(_const.STENCIL_MODES.MASK_ACTIVE, maskStackIndex), renderer.colorMask.setMask(15)) : 
      "popMaskBegin" === instruction.action ? (renderer.colorMask.setMask(0), 0 !== maskStackIndex ? renderer.stencil.setStencilMode(_const.STENCIL_MODES.RENDERING_MASK_REMOVE, maskStackIndex) : (renderer.renderTarget.clear(null, _const$1.CLEAR.STENCIL), renderer.stencil.setStencilMode(_const.STENCIL_MODES.DISABLED, maskStackIndex)), maskStackIndex--) : "popMaskEnd" === instruction.action && (instruction.inverse ? renderer.stencil.setStencilMode(_const.STENCIL_MODES.INVERSE_MASK_ACTIVE, maskStackIndex) : 
      renderer.stencil.setStencilMode(_const.STENCIL_MODES.MASK_ACTIVE, maskStackIndex), renderer.colorMask.setMask(15));
      this._maskStackHash[renderTargetUid] = maskStackIndex;
    }
    destroy() {
      this._maskHash = this._maskStackHash = this._renderer = null;
    }
  }
  StencilMaskPipe.extension = {type:[global.ExtensionType.WebGLPipes, global.ExtensionType.WebGPUPipes], name:"stencilMask"};
  exports.StencilMaskPipe = StencilMaskPipe;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$mask$stencil$StencilMaskPipe.js.map
