import '../../../globals.js';
import { Shape } from '../../../kite/js/imports.js';
import { CanvasNodeDrawable, Node, Renderer, scenery } from '../imports.js';
const CANVAS_NODE_OPTION_KEYS = [
    'canvasBounds'
];
export default class CanvasNode extends Node {
    constructor(options) {
        super(options);
        // This shouldn't change, as we only support one renderer
        this.setRendererBitmask(Renderer.bitmaskCanvas);
    }
    /**
     * Sets the bounds that are used for layout/repainting.
     *
     * These bounds should always cover at least the area where the CanvasNode will draw in. If this is violated, this
     * node may be partially or completely invisible in Scenery's output.
     */
    setCanvasBounds(selfBounds) {
        this.invalidateSelf(selfBounds);
    }
    set canvasBounds(value) { this.setCanvasBounds(value); }
    get canvasBounds() { return this.getCanvasBounds(); }
    /**
     * Returns the previously-set canvasBounds, or Bounds2.NOTHING if it has not been set yet.
     */
    getCanvasBounds() {
        return this.getSelfBounds();
    }
    /**
     * Whether this Node itself is painted (displays something itself).
     */
    isPainted() {
        // Always true for CanvasNode
        return true;
    }
    /**
     * Should be called when this node needs to be repainted. When not called, Scenery assumes that this node does
     * NOT need to be repainted (although Scenery may repaint it due to other nodes needing to be repainted).
     *
     * This sets a "dirty" flag, so that it will be repainted the next time it would be displayed.
     */
    invalidatePaint() {
        const stateLen = this._drawables.length;
        for (let i = 0; i < stateLen; i++) {
            this._drawables[i].markDirty();
        }
    }
    /**
     * Draws the current Node's self representation, assuming the wrapper's Canvas context is already in the local
     * coordinate frame of this node.
     *
     * @param wrapper
     * @param matrix - The transformation matrix already applied to the context.
     */
    canvasPaintSelf(wrapper, matrix) {
        this.paintCanvas(wrapper.context);
    }
    /**
     * Computes whether the provided point is "inside" (contained) in this Node's self content, or "outside".
     *
     * If CanvasNode subtypes want to support being picked or hit-tested, it should override this function.
     *
     * @param point - Considered to be in the local coordinate frame
     */
    containsPointSelf(point) {
        return false;
    }
    /**
     * Returns a Shape that represents the area covered by containsPointSelf.
     */
    getSelfShape() {
        return new Shape();
    }
    /**
     * Creates a Canvas drawable for this CanvasNode. (scenery-internal)
     *
     * @param renderer - In the bitmask format specified by Renderer, which may contain additional bit flags.
     * @param instance - Instance object that will be associated with the drawable
     */
    createCanvasDrawable(renderer, instance) {
        // @ts-expect-error
        return CanvasNodeDrawable.createFromPool(renderer, instance);
    }
    mutate(options) {
        return super.mutate(options);
    }
}
/**
 * {Array.<string>} - String keys for all of the allowed options that will be set by node.mutate( options ), in the
 * order they will be evaluated in.
 *
 * NOTE: See Node's _mutatorKeys documentation for more information on how this operates, and potential special
 *       cases that may apply.
 */
CanvasNode.prototype._mutatorKeys = CANVAS_NODE_OPTION_KEYS.concat(Node.prototype._mutatorKeys);
scenery.register('CanvasNode', CanvasNode);
//# sourceMappingURL=CanvasNode.js.map