diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map
index b80d877..18cd55c 100644
--- a/dist/index.d.ts.map
+++ b/dist/index.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/Area.ts","../src/AreaAllocator.ts","../src/AtlasResource.ts","../src/GuilloteneAllocator.ts","../src/TextureSlab.ts","../src/TextureAllocator.ts","../src/AtlasAllocator.ts","../src/CanvasTextureAllocator.ts","../src/RenderTextureAllocator.ts","../src/index.ts"],"names":[],"mappings":";IAAA;;;;OAIG;IACH,MAAM,MAAM,eAAe;QACvB,UAAU,IAAI;QACd,QAAQ,IAAI;KACf;IAED;;;;OAIG;IACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;IAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiDG;IACH,MAAM,OAAO,IAAI;QAEb,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;QAKrF,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;QAK7C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;QAK9C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe;QAKvD,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;QAS7D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;KAQjE;;;IC1GD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;IAE3C;;;OAGG;IACH,MAAM,WAAW,aAAa,CAAC,CAAC;QAE5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAExB,Q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H,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,aAAa;KAIrF;;;ICxCD,qBAAuB;IACvB,8BAAgC;IAChC,+BAAiC;IACjC,8BAAgC;IAChC,uCAAyC;IACzC,oCAAsC;IACtC,uCAAyC;IACzC,iCAAmC;IACnC,4BAA8B"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/Area.ts","../src/AreaAllocator.ts","../src/AtlasResource.ts","../src/GuilloteneAllocator.ts","../src/TextureSlab.ts","../src/TextureAllocator.ts","../src/AtlasAllocator.ts","../src/CanvasTextureAllocator.ts","../src/RenderTextureAllocator.ts","../src/index.ts"],"names":[],"mappings":";IAAA;;;;OAIG;IACH,MAAM,MAAM,eAAe;QACvB,UAAU,IAAI;QACd,QAAQ,IAAI;KACf;IAED;;;;OAIG;IACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;IAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiDG;IACH,MAAM,OAAO,IAAI;QAEb,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;QAKrF,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;QAK7C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;QAK9C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe;QAKvD,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;QAS7D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;KAQjE;;;IC1GD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;IAE3C;;;OAGG;IACH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H,MAAM,OAAO,sBAAuB,SAAQ,gBAAgB,CAAC,aAAa,CAAC;QAEvE;;WAEG;QACH,SAAS,CAAC,UAAU,IAAI,WAAW;QAYnC;;;;;WAKG;QACH,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,aAAa;KAIrF;;;ICxCD,qBAAuB;IACvB,8BAAgC;IAChC,+BAAiC;IACjC,8BAAgC;IAChC,uCAAyC;IACzC,oCAAsC;IACtC,uCAAyC;IACzC,iCAAmC;IACnC,4BAA8B"}
\ No newline at end of file
diff --git a/dist/pixi-texture-allocator.cjs b/dist/pixi-texture-allocator.cjs
index a981229..a5e4b9b 100644
--- a/dist/pixi-texture-allocator.cjs
+++ b/dist/pixi-texture-allocator.cjs
@@ -130,9 +130,6 @@ var AtlasResource = class extends import_core.Resource {
* @param item - The item to upload.
*/
uploadItem(renderer, target, format, type, item) {
- if (item.updateId === item.dirtyId) {
- return;
- }
const gl = renderer.gl;
const isWebGL2 = gl instanceof WebGL2RenderingContext;
const frame = item.frame;
diff --git a/dist/pixi-texture-allocator.cjs.map b/dist/pixi-texture-allocator.cjs.map
index 12c81c9..86090ff 100644
--- a/dist/pixi-texture-allocator.cjs.map
+++ b/dist/pixi-texture-allocator.cjs.map
@@ -1,7 +1,7 @@
{
"version": 3,
"sources": ["../src/index.ts", "../src/Area.ts", "../src/AtlasResource.ts", "../src/AtlasAllocator.ts", "../src/GuilloteneAllocator.ts", "../src/TextureAllocator.ts", "../src/CanvasTextureAllocator.ts", "../src/RenderTextureAllocator.ts"],
- "sourcesContent": ["export * from './Area';\nexport * from './AreaAllocator';\nexport * from './AtlasAllocator';\nexport * from './AtlasResource';\nexport * from './CanvasTextureAllocator';\nexport * from './GuilloteneAllocator';\nexport * from './RenderTextureAllocator';\nexport * from './TextureAllocator';\nexport * from './TextureSlab';", "/**\n * The orientation of an area indicates the axis along which it is split. This is a 1-bit field.\n *\n * @public\n */\nexport enum AreaOrientation {\n HORIZONTAL = 0,\n VERTICAL = 1\n};\n\n/**\n * Alias for the 31-bit field texture-area type.\n *\n * @public\n */\nexport type AreaField = number;\n\n/**\n * An area represents an oriented rectangular region. It is implemented as a 31-bit field. The open/close edges are\n * specified along its parent's orientation axis, i.e. if the parent is horizontal, the left and right edges are defined,\n * else if the parent is vertical, the top and bottom edges are defined. Similarly, the open/close edges of its\n * children will be along its own orientation axis.\n *\n * The orientation axes flip-flop along the hierarchy, i.e. an area's parent's orientation is always opposite to\n * the area's own orientation. This is because if the orientation were to be same, the area's children could be\n * \"pulled up\" to the parent making itself redundant.\n *\n * All four edges of an area can be retrieved from it and its parent.\n *\n *
\n * \n *
\n *
Field
\n *
Bits
\n *
Description
\n *
\n * \n * \n *
\n *
OPEN_OFFSET
\n *
0-14
\n *
\n * The offset along the parent's axis at which the area begins. If orientation is horizontal,\n * this is the left edge. If orientation is vertical, this is the top edge.\n *
\n *
\n *
\n *
CLOSE_OFFSET
\n *
15-29
\n *
\n * The offset along the parent's axis at which the area ends. If orientation is horizontal,\n * this is the right edge. If orientation is vertical, this is the bottom edge.\n *
\n *
\n *
\n *
ORIENTATION
\n *
30
\n *
\n * The orientation of the area, which indicates the axis along it is split. The open and close\n * offsets of its children are along this axis. See {@link AreaOrientation}.\n *
\n *
\n * \n *
\n *\n * @public\n */\nexport class Area\n{\n static makeArea(openOffset: number, closeOffset: number, orientation: number): number\n {\n return openOffset | (closeOffset << 15) | (orientation << 30);\n }\n\n static getOpenOffset(area: AreaField): number\n {\n return area & ((1 << 15) - 1);\n }\n\n static getCloseOffset(area: AreaField): number\n {\n return (area >> 15) & ((1 << 15) - 1);\n }\n\n static getOrientation(area: AreaField): AreaOrientation\n {\n return (area >> 30) & 1;\n }\n\n static setOpenOffset(area: AreaField, offset: number): number\n {\n return Area.makeArea(\n offset,\n Area.getCloseOffset(area),\n Area.getOrientation(area)\n );\n }\n\n static setCloseOffset(area: AreaField, offset: number): number\n {\n return Area.makeArea(\n Area.getOpenOffset(offset),\n offset,\n Area.getOrientation(area)\n );\n }\n}", "import { ALPHA_MODES } from '@pixi/constants';\nimport { BaseTexture, GLTexture, Resource, Renderer } from '@pixi/core';\n\nimport type { Rectangle } from '@pixi/math';\nimport type { Texture } from '@pixi/core';\n\n/**\n * Types of image sources supported by {@link AtlasResource}.\n *\n * @public\n */\nexport type AtlasResourceSource = HTMLImageElement | HTMLCanvasElement | ImageBitmap | ImageData | ArrayBufferView;\n\n/**\n * An item that is uploaded to the atlas texture.\n *\n * @public\n */\nexport type AtlasResourceItem =\n{\n /**\n * The location of the atlas item in the base-texture's space.\n */\n frame: Rectangle;\n\n /**\n * The source of the texture data.\n */\n source: AtlasResourceSource;\n\n /**\n * This flags when the resource is to be re-uploaded.\n */\n dirtyId: number;\n\n /**\n * This flags when the resource is uploaded and update-to-date with the dirty ID.\n */\n updateId: number;\n\n /**\n * The texture holding this item.\n */\n texture: Texture;\n};\n\n/**\n * An {@code AtlasResource} is used by {@link AtlasAllocator} to manage texture sources\n *\n * @public\n */\nexport class AtlasResource extends Resource\n{\n /**\n * The list of managed resources in the atlas.\n */\n public managedItems: AtlasResourceItem[];\n\n /**\n * Creates an atlas resource.\n *\n * @param width\n * @param height\n */\n constructor(width: number, height: number)\n {\n super(width, height);\n\n this.managedItems = [];\n }\n\n /**\n * Uploads the atlas.\n *\n * @param renderer\n * @param baseTexture\n * @param glTexture\n */\n upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean\n {\n const gl: WebGLRenderingContext = renderer.gl;\n const width = baseTexture.realWidth;\n const height = baseTexture.realHeight;\n\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK)\n\n // Allocate the texture on the GPU\n if (glTexture.width !== width ||\n glTexture.height !== height)\n {\n glTexture.width = width;\n glTexture.height = height;\n\n gl.texImage2D(\n baseTexture.target,\n 0,\n baseTexture.format,\n width,\n height,\n 0,\n baseTexture.format,\n baseTexture.type,\n undefined\n );\n }\n\n const items = this.managedItems;\n\n // Upload all atlas items.\n for (let i = 0, j = items.length; i < j; i++)\n {\n this.uploadItem(\n renderer,\n baseTexture.target,\n baseTexture.format,\n baseTexture.type,\n items[i]\n );\n }\n\n return true;\n }\n\n /**\n * Uploads the atlas item to the GPU.\n *\n * @param renderer - The renderer holding the WebGL context.\n * @param target - The binding point of the base-texture.\n * @param format - The format of the base-texture.\n * @param type - The type of the base-texture data.\n * @param item - The item to upload.\n */\n protected uploadItem(\n renderer: Renderer,\n target: number,\n format: number,\n type: number,\n item: AtlasResourceItem\n ): void\n {\n if (item.updateId === item.dirtyId)\n {\n return;\n }\n\n const gl: WebGLRenderingContext = renderer.gl;\n const isWebGL2 = (gl instanceof WebGL2RenderingContext);\n const frame = item.frame;\n let source = item.source;\n\n // if WebGL1, convert whatever we have into a typed array\n if (!isWebGL2) {\n if (source instanceof ImageData) {\n source = source.data; // pass the typed array directly\n\n } else if (source instanceof HTMLCanvasElement) {\n const ctx = source.getContext('2d');\n const [w, h] = [source.width, source.height];\n source = ctx.getImageData(0, 0, w, h).data;\n\n } else if (source instanceof HTMLImageElement) {\n const [w, h] = [source.naturalWidth, source.naturalHeight];\n const canvas = document.createElement('canvas');\n canvas.width = w;\n canvas.height = h;\n\n const ctx = canvas.getContext('2d');\n ctx.drawImage(source, 0, 0);\n source = ctx.getImageData(0, 0, w, h).data;\n }\n }\n\n gl.texSubImage2D(\n target,\n 0,\n frame.x,\n frame.y,\n frame.width,\n frame.height,\n format,\n type,\n source as any,\n );\n\n item.updateId = item.dirtyId;\n }\n}", "import { AtlasResource } from './AtlasResource';\nimport { BaseTexture, Texture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\nimport { TextureSlab } from './TextureSlab';\n\nimport type { AtlasResourceSource } from './AtlasResource';\n\n/**\n * This texture allocator auto-manages the base-texture with an {@link AtlasResource}. You can also\n * pass a texture source to `allocate`, mimicing {@link Texture.from} functionality.\n *\n * @public\n */\nexport class AtlasAllocator extends TextureAllocator\n{\n /**\n * Creates a texture slab backed by an {@link AtlasResource}.\n */\n protected createSlab(): TextureSlab\n {\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseTexture(new AtlasResource(this.slabWidth, this.slabHeight),\n {\n width: this.slabWidth,\n height: this.slabHeight,\n }),\n };\n }\n\n /**\n * Allocates a texture backed by the given atlas source, with the given padding.\n *\n * @override\n * @param width\n * @param height\n * @param padding\n * @param source\n */\n allocate(width: number, height: number, padding?: number, source?: AtlasResourceSource): Texture;\n\n /**\n * Allocates a texture backed by the given source, with default padding.\n *\n * @param width\n * @param height\n * @param source\n */\n allocate(width: number, height: number, source?: AtlasResourceSource): Texture;\n\n allocate(width: number, height: number, paddingOrSource?: number | AtlasResourceSource, source?: AtlasResourceSource): Texture\n {\n let padding: number;\n\n if (typeof paddingOrSource === 'number')\n {\n padding = paddingOrSource;\n }\n else\n {\n padding = this.calculatePadding(width, height);\n source = paddingOrSource;\n }\n\n const texture = super.allocate(width, height, padding);\n\n if (source)\n {\n const atlas = texture.baseTexture.resource as AtlasResource;\n const item = {\n frame: texture.frame,\n source,\n // dirtyId !== updateId only if image loaded\n dirtyId: source instanceof HTMLImageElement && !source.complete ? -1 : 0,\n updateId: -1,\n texture,\n };\n\n atlas.managedItems.push(item);\n\n if (source instanceof HTMLImageElement && !source.complete) {\n source.addEventListener('load', () => {\n if (texture.baseTexture.valid && !texture.baseTexture.destroyed && atlas.managedItems.indexOf(item) >= 0) {\n item.dirtyId++;\n texture.baseTexture.update();\n }\n });\n }\n\n texture.baseTexture.update();\n }\n\n return texture;\n }\n\n free(texture: Texture): void\n {\n super.free(texture);\n\n const atlas = texture.baseTexture.resource as AtlasResource;\n const item = atlas.managedItems.find(item => item.texture === texture);\n\n if (item)\n {\n atlas.managedItems.splice(atlas.managedItems.indexOf(item), 1);\n }\n }\n}", "import { Rectangle } from '@pixi/math';\nimport { Area, AreaOrientation } from './Area';\n\nimport type { AreaAllocator } from './AreaAllocator';\nimport type { AreaField } from './Area';\n\n/**\n * An allocator node is represented as a tuple. The zeroth element is the parent of the node. The first element\n * always exists and is the texture area it wholly represents. The second element is whether the rectangle\n * is allocated or free. The last element is optional and is the list\n * of its children.\n *\n * @public\n * @ignore\n */\nexport type AreaNode = [AreaNode, AreaField, boolean] | [AreaNode, AreaField, AreaNode[]];\n\n/**\n * Pointer to guillotene node.\n *\n * @public\n * @ignore\n */\nexport type AreaPtr = { __mem_area: AreaNode };\n\n/**\n * @public\n * @ignore\n */\nexport enum SPLIT_ORIENTATION {\n HOR = 0,\n VERT = 1,\n NONE = 2\n}\n\nconst tempRect = new Rectangle();\n\n/** @public */\nexport class GuilloteneAllocator implements AreaAllocator\n{\n protected _root: AreaNode;\n\n private _width: number;\n private _height: number;\n\n constructor(width: number, height: number)\n {\n this._width = width;\n this._height = height;\n\n // NOTE: getFrame assumes root node is always horizontal!\n this._root = [\n null,\n Area.makeArea(0, this._height, AreaOrientation.HORIZONTAL),\n false\n ];\n }\n\n /**\n * Allocates an area of the given `width` and `height`.\n *\n * @param width - The width required for the allocated area.\n * @param height - The height required for the allocated area.\n * @param rect - An optional `Rectangle` instance to put the resulting area frame into.\n * @return The rectangle frame of the area allocated.\n */\n allocate(width: number, height: number, rect?: Rectangle): Rectangle & AreaPtr\n {\n const area = this.findArea(width, height);\n\n if (!area)\n {\n return null;\n }\n\n if (!rect)\n {\n rect = new Rectangle();\n }\n\n this.getFrame(area, rect);\n\n const hole = new Rectangle(rect.x, rect.y, width, height);\n const node = this.split(area, rect, hole);\n\n rect.copyFrom(hole);\n (rect as any).__mem_area = node;\n\n return rect as (Rectangle & AreaPtr);\n }\n\n /**\n * Frees the area represented by the given area pointer. The original rectangle returned by\n * {@link GuilloteneAllocator#allocate} included this pointer (the `__mem_area` property).\n *\n * @param areaPtr\n */\n free(areaPtr: AreaPtr): void\n {\n const area = areaPtr.__mem_area;\n\n area[2] = false;\n this.merge(area);\n }\n\n get width(): number\n {\n return this._width;\n }\n\n get height(): number\n {\n return this._height;\n }\n\n /**\n * Returns the [area]{@link Area} data for the node.\n *\n * @param node\n * @returns The area data for the node.\n */\n protected getAreaField(node: AreaNode): AreaField\n {\n return node[1];\n }\n\n /**\n * Returns the rectangle covered by the area node.\n *\n * @param node - The node whose covered rectangular area is needed.\n * @param rect - An optional `Rectangle` instance to put the data in.\n * @return The rectangle covered by `node`.\n */\n protected getFrame(node: AreaNode, rect?: Rectangle): Rectangle\n {\n if (!rect)\n {\n rect = new Rectangle();\n }\n\n const nodeArea = this.getAreaField(node);\n const nodeParent = this.getParent(node);\n const nodeOrientation = Area.getOrientation(nodeArea);\n const nodeOpen = Area.getOpenOffset(nodeArea);\n const nodeClose = Area.getCloseOffset(nodeArea);\n const parentOpen = nodeParent ? Area.getOpenOffset(nodeParent[1]) : 0;\n const parentClose = nodeParent ? Area.getCloseOffset(nodeParent[1]) : this._width;// (because root node is horizontal)\n\n if (nodeOrientation) // VERTICAL\n {\n rect.x = nodeOpen;\n rect.y = parentOpen;\n rect.width = nodeClose - rect.x;\n rect.height = parentClose - parentOpen;\n }\n else // HORIZONTAL\n {\n rect.x = parentOpen;\n rect.y = nodeOpen;\n rect.width = parentClose - rect.x;\n rect.height = nodeClose - rect.y;\n }\n\n return rect;\n }\n\n /**\n * Returns the parent of the area node.\n *\n * @param node\n * @return The parent of `node`\n */\n protected getParent(node: AreaNode): AreaNode\n {\n return node[0];\n }\n\n /**\n * Returns whether the given node has any children.\n *\n * @param node\n * @return Whether the given node has any children.\n */\n protected hasChildren(node: AreaNode): boolean\n {\n return (Array.isArray(node[2]) && (node[2].length !== 0));\n }\n\n /**\n * Returns the children of the passed node, if any.\n *\n * @param node\n */\n protected getChildren(node: AreaNode): AreaNode[]\n {\n if (!Array.isArray(node[2])) {\n throw new Error(\"Children don't exist\")\n }\n\n return node[2];\n }\n\n protected addChild(parent: AreaNode, ...nodes: AreaNode[]): void\n {\n parent[2] = Array.isArray(parent[2]) ? parent[2] : []\n parent[2].push(...nodes)\n }\n\n /**\n * Finds an area node with minimum width `aw` and minimum height `ah`.\n *\n * @param aw\n * @param ah\n */\n protected findArea(aw: number, ah: number): AreaNode\n {\n return this.findAreaRecursive(this._root, aw, ah);\n }\n\n /**\n * The recursive implementation for {@link AreaAllocator#findArea}.\n *\n * @param rootArea\n * @param aw\n * @param ah\n */\n protected findAreaRecursive(rootArea: AreaNode, aw: number, ah: number): AreaNode\n {\n const frame = this.getFrame(rootArea, tempRect);\n\n if (frame.width < aw || frame.height < ah)\n {\n return null;\n }\n\n if (!this.hasChildren(rootArea))\n {\n const dx = frame.width - aw;\n const dy = frame.height - ah;\n\n if (dx < 0 || dy < 0 || rootArea[2])\n {\n return null;\n }\n\n return rootArea;\n }\n\n const children = this.getChildren(rootArea);\n\n let bestCandidate = null;\n let bestCandidateScore = Infinity;\n\n for (let i = 0, j = children.length; i < j; i++)\n {\n const candidate = this.findAreaRecursive(children[i], aw, ah);\n\n if (!candidate)\n {\n continue;\n }\n\n const candidateFrame = this.getFrame(candidate, tempRect);\n\n const dx = candidateFrame.width - aw;\n const dy = candidateFrame.height - ah;\n\n if (dx < 0 || dy < 0)\n {\n continue;\n }\n if (!dx && !dy)\n {\n // Perfect fit!\n return candidate;\n }\n\n const score = Math.min(dx, dy);\n\n if (bestCandidateScore > score)\n {\n bestCandidate = candidate;\n bestCandidateScore = score;\n }\n }\n\n return bestCandidate;\n }\n\n /**\n * Returns the orientation of the primary split of host.\n */\n protected splitOrientation(host: Rectangle, hole: Rectangle): SPLIT_ORIENTATION\n {\n if (hole.width === host.width && hole.height === host.height) {\n return SPLIT_ORIENTATION.NONE;\n }\n if (hole.width === host.width) {\n return SPLIT_ORIENTATION.VERT;\n }\n if (hole.height === host.height) {\n return SPLIT_ORIENTATION.HOR;\n }\n\n // ____________________\n // | | |\n // | | |\n // | hole | |\n // | | |\n // |________| Primary |\n // | | |\n // | | |\n // | Sec. | |\n // |________|_________|\n const horAreaDiff = Math.abs(\n // (Primary) Right\n (host.width - hole.width) * host.height -\n // (Secondary) Bottom\n hole.width * (host.height - hole.height)\n )\n\n // ____________________\n // | | |\n // | | |\n // | hole | Sec. |\n // | | |\n // |________|_________|\n // | |\n // | Primary |\n // |__________________|\n const verAreaDiff = Math.abs(\n // (Primary) Bottom\n host.width * (host.height - hole.height) -\n (host.width - hole.width) * hole.height\n )\n\n if (horAreaDiff > verAreaDiff)\n {\n return SPLIT_ORIENTATION.HOR\n }\n else\n {\n return SPLIT_ORIENTATION.VERT\n }\n }\n\n protected split(\n area: AreaNode,\n areaFrame: Rectangle,\n holeFrame: Rectangle,\n orientation: SPLIT_ORIENTATION = this.getParent(area) ? this.splitOrientation(areaFrame, holeFrame) : SPLIT_ORIENTATION.HOR\n ): AreaNode\n {\n if (area[2] === true)\n {\n throw new Error('Cannot deallocate')\n }\n if (orientation === SPLIT_ORIENTATION.NONE)\n {\n area[2] = true;\n return area;\n }\n\n return this[orientation === SPLIT_ORIENTATION.HOR\n ? 'splitPrimaryHorizontal'\n : 'splitPrimaryVertical'](area, areaFrame, holeFrame);\n }\n\n private splitPrimaryHorizontal(area: AreaNode, areaFrame: Rectangle, holeFrame: Rectangle): AreaNode\n {\n const field = this.getAreaField(area);\n const axis = Area.getOrientation(field);\n const parent = this.getParent(area);\n\n if (this.hasChildren(area))\n {\n throw new Error(\"Can't split non-leaf node\")\n }\n\n const firstChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.left,\n areaFrame.x + holeFrame.width,\n AreaOrientation.VERTICAL\n ),\n []\n ];\n const secondChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.x + holeFrame.width,\n areaFrame.right,\n AreaOrientation.VERTICAL\n ),\n false\n ];\n\n if (axis === AreaOrientation.HORIZONTAL) {\n this.addChild(area, firstChild, secondChild)\n } else {\n const i = this.getChildren(parent).indexOf(area);\n\n firstChild[0] = parent;\n secondChild[0] = parent;\n\n this.getChildren(parent).splice(i, 1, firstChild, secondChild);\n }\n\n if (holeFrame.height !== areaFrame.height)\n {\n const secondaryFirstChild: AreaNode = [\n firstChild,\n Area.makeArea(\n areaFrame.top,\n areaFrame.y + holeFrame.height,\n AreaOrientation.HORIZONTAL\n ),\n true\n ];\n const secondarySecondChild: AreaNode = [\n firstChild,\n Area.makeArea(\n areaFrame.y + holeFrame.height,\n areaFrame.bottom,\n AreaOrientation.HORIZONTAL\n ),\n false\n ];\n\n this.addChild(firstChild, secondaryFirstChild, secondarySecondChild);\n\n return secondaryFirstChild;\n }\n else\n {\n (firstChild as AreaNode)[2] = true;\n }\n\n return firstChild;\n }\n\n private splitPrimaryVertical(area: AreaNode, areaFrame: Rectangle, holeFrame: Rectangle): AreaNode\n {\n const field = this.getAreaField(area);\n const axis = Area.getOrientation(field);\n const parent = this.getParent(area);\n\n if (this.hasChildren(area)) {\n throw new Error(\"Can't split non-leaf node\")\n }\n\n const primaryFirstChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.top,\n areaFrame.y + holeFrame.height,\n AreaOrientation.HORIZONTAL\n ),\n []\n ];\n const primarySecondChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.y + holeFrame.height,\n areaFrame.bottom,\n AreaOrientation.HORIZONTAL\n ),\n false\n ];\n\n if (axis === AreaOrientation.VERTICAL)\n {\n this.addChild(area, primaryFirstChild, primarySecondChild);\n }\n else\n {\n const i = this.getChildren(parent).indexOf(area);\n primaryFirstChild[0] = parent;\n primarySecondChild[0] = parent;\n this.getChildren(parent).splice(i, 1, primaryFirstChild, primarySecondChild);\n }\n\n if (holeFrame.width !== areaFrame.height)\n {\n const secondaryFirstChild: AreaNode = [\n primaryFirstChild,\n Area.makeArea(\n areaFrame.left,\n areaFrame.x + holeFrame.width,\n AreaOrientation.VERTICAL\n ),\n true\n ];\n const secondarySecondChild: AreaNode = [\n primaryFirstChild,\n Area.makeArea(\n areaFrame.x + holeFrame.width,\n areaFrame.right,\n AreaOrientation.VERTICAL\n ),\n false\n ];\n\n this.addChild(primaryFirstChild, secondaryFirstChild, secondarySecondChild);\n\n return secondaryFirstChild;\n }\n else\n {\n (primaryFirstChild as AreaNode)[2] = true;\n }\n\n return primaryFirstChild;\n }\n\n protected merge(\n area: AreaNode\n ) {\n if (this.hasChildren(area))\n {\n throw new Error(\"Cannot merge a non-leaf node\");\n }\n\n const parent = this.getParent(area);\n\n if (!parent)\n {\n return;\n }\n\n const siblings = this.getChildren(parent);\n const i = siblings.indexOf(area);\n\n const leftSibling = siblings[i - 1];\n const rightSibling = siblings[i + 1];\n\n if (rightSibling && rightSibling[2] === false)\n {\n // Merge rightSibling into area\n area[1] = Area.setCloseOffset(area[1], Area.getCloseOffset(rightSibling[1]));\n siblings.splice(i + 1, 1);\n }\n if (leftSibling && leftSibling[2] === false)\n {\n // Merge leftSibling into area\n area[1] = Area.setOpenOffset(area[1], Area.getOpenOffset(leftSibling[1]));\n siblings.splice(i - 1, 1);\n }\n\n if (siblings.length === 1) {\n parent[2] = false;\n this.merge(parent);\n }\n }\n\n private printState(area: AreaNode): void\n {\n if (!this.hasChildren(area)) {\n console.log({ ...this.getFrame(area) }, area[2])\n } else {\n this.getChildren(area).forEach(n => this.printState(n))\n }\n }\n}", "import { BaseTexture, Texture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { Rectangle } from '@pixi/math';\n\nimport type { TextureSlab } from './TextureSlab';\n\nconst tempRect = new Rectangle();\n\n/**\n * The texture allocator dynamically manages space on base-texture slabs. It can be used to generate\n * atlases on demand, which improve batching efficiency.\n *\n * @public\n */\nexport class TextureAllocator\n{\n /**\n * The width of texture slabs.\n */\n public readonly slabWidth: number;\n\n /**\n * The height of texture slabs.\n */\n public readonly slabHeight: number;\n\n /**\n * The list of base-textures that are used to allocate texture space.\n */\n protected textureSlabs: TextureSlab[];\n\n /**\n * @param slabWidth - The width of base-texture slabs. This should be at most 2048.\n * @param slabHeight - The height of base-texture slabs. This should be at most 2048.\n */\n constructor(slabWidth = 2048, slabHeight = 2048)\n {\n this.slabWidth = slabWidth;\n this.slabHeight = slabHeight;\n\n this.textureSlabs = [];\n }\n\n get maxWidth() {\n return this.slabWidth - (2 * this.calculatePadding(this.slabWidth, this.slabHeight));\n }\n\n get maxHeight() {\n return this.slabHeight - (2 * this.calculatePadding(this.slabWidth, this.slabHeight));\n }\n\n /**\n * Allocates a texture from this allocator.\n *\n * If its existing slab pool has enough space, the texture is issued from one. Otherwise,\n * a new slab is created and the texture is issued from it. However, if the requested\n * dimensions are larger than slabs themselves, then `null` is always returned.\n *\n * To upload a texture source, you will have to create an atlas-managing {@link Resource}\n * yourself on the base-texture. The {@link AtlasAllocator} does this for you, while the\n * {@link CanvasTextureAllocator} can be used to draw on a canvas-based atlas.\n *\n * @param width - The width of the requested texture.\n * @param height - The height of the requested texture.\n * @param padding - The padding requested around the texture, to prevent bleeding.\n * @return The allocated texture, if successful; otherwise, `null`.\n */\n allocate(width: number, height: number, padding = this.calculatePadding(width, height)): T\n {\n // Cannot allocate a texture larger than a texture-slab.\n if (width + 2 * padding > this.slabWidth ||\n height + 2 * padding > this.slabHeight)\n {\n return null;\n }\n\n const slabs = this.textureSlabs;\n\n // Loop through the slabs and find one with enough space, if any.\n for (let i = 0, j = slabs.length; i < j; i++)\n {\n const slab = slabs[i];\n const texture = this.issueTexture(slab, width, height, padding);\n\n if (texture)\n {\n return texture;\n }\n }\n\n // Issue a new slab.\n const slab = this.createSlab();\n\n // Append this slab to the head of the list.\n this.textureSlabs.unshift(slab);\n\n // Issue the texture from this blank slab.\n return this.issueTexture(slab, width, height, padding);\n }\n\n /**\n * Frees the texture and reclaims its space. It is assumed you will not use it again, and have\n * destroyed any resource uploading its data.\n *\n * @param texture\n * @throws When the texture was not located in this allocator.\n */\n free(texture: T): void\n {\n const baseTexture = (texture as Texture).baseTexture;\n const slab = this.textureSlabs.find(sl => sl.slab === baseTexture);\n\n if (!slab)\n {\n throw new Error(\"The texture cannot be freed because \" +\n \"its base-texture is not pooled by this allocator. \" +\n \"This is either a bug in TextureAllocator or you tried to free a \" +\n \"texture that was never allocated by one.\");\n }\n\n const textureEntry = slab.managedTextures.find(entry => entry.texture === texture);\n\n if (!textureEntry)\n {\n throw new Error(\"The texture cannot be freed because it was not found \" +\n \"in the managed list of issued textures on its slab. This may be because you \" +\n \"duplicated this texture or a bug in TextureAllocator\");\n }\n\n slab.managedArea.free(textureEntry.area);\n slab.managedTextures.splice(slab.managedTextures.indexOf(textureEntry), 1);\n }\n\n protected calculatePadding(width: number, height: number): number\n {\n const dimen = Math.max(width, height);\n\n if (dimen < 64)\n {\n return 2;\n }\n else if (dimen < 128)\n {\n return 4;\n }\n else if (dimen < 1024)\n {\n return 8;\n }\n else\n {\n return 16;\n }\n }\n\n /**\n * Creates a texture slab. The slab's base-texture is not backed by any resource. You\n * will have to manage that yourself. See {@link AtlasAllocator} or {@link CanvasTextureAllocator}\n * for better resource semantics.\n */\n protected createSlab(): TextureSlab\n {\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseTexture(null,\n {\n width: this.slabWidth,\n height: this.slabHeight,\n }),\n };\n }\n\n /**\n * Creates a texture on the given base-texture at {@code frame}.\n *\n * @param baseTexture - The base texture that will hold the texture's space.\n * @param frame - The frame in which the texture will be stored.\n */\n protected createTexture(baseTexture: BaseTexture, frame: Rectangle): T\n {\n // Override this method to return correct texture type T.\n return new Texture(baseTexture, frame) as T;\n }\n\n /**\n * Issues a texture from the given texture slab, if possible.\n *\n * @param slab - The texture slab to allocate frame.\n * @param width - The width of the requested texture.\n * @param height - The height of the requested texture.\n * @param padding - Padding required around the texture.\n * @return The issued texture, if successful; otherwise, `null`.\n */\n protected issueTexture(slab: TextureSlab, width: number, height: number, padding = 0): T\n {\n const area = slab.managedArea.allocate(width + 2 * padding, height + 2 * padding);\n\n if (!area)\n {\n return null;\n }\n\n tempRect.copyFrom(area);\n tempRect.pad(-padding);\n\n const baseTexture = slab.slab;\n const issuedTexture = this.createTexture(baseTexture, tempRect.clone());\n\n slab.managedTextures.push({\n area,\n texture: issuedTexture,\n });\n\n return issuedTexture;\n }\n}", "import { BaseTexture } from '@pixi/core';\n\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\nimport { TextureSlab } from './TextureSlab';\n\n/**\n * This allocator issues texture backed by a canvas. You can draw on to that canvas to soruce\n * each texture.\n *\n * @public\n */\nexport class CanvasTextureAllocator extends TextureAllocator\n{\n /**\n * Creates a texture slab backed by a canvas.\n */\n protected createSlab(): TextureSlab\n {\n const canvas = document.createElement('canvas');\n\n canvas.width = this.slabWidth;\n canvas.height = this.slabHeight;\n\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseTexture(canvas, {\n width: this.slabWidth,\n height: this.slabHeight\n })\n };\n }\n}", "import { BaseRenderTexture, RenderTexture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\n\nimport type { BaseTexture } from '@pixi/core';\nimport type { Rectangle } from '@pixi/math';\nimport type { TextureSlab } from './TextureSlab';\n\n/**\n * This allocator issues render-textures, and is otherwise just like {@link TextureAllocator}.\n *\n * @public\n */\nexport class RenderTextureAllocator extends TextureAllocator\n{\n /**\n * Creates a texture slab backed by a base render-texture.\n */\n protected createSlab(): TextureSlab\n {\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseRenderTexture({\n width: this.slabWidth,\n height: this.slabHeight\n })\n };\n }\n\n /**\n * Creates a render-texture from the given base render-texture.\n *\n * @param baseTexture\n * @param frame\n */\n protected createTexture(baseTexture: BaseTexture, frame: Rectangle): RenderTexture\n {\n return new RenderTexture(baseTexture as BaseRenderTexture, frame);\n }\n}"],
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAa,OAAO,MAAM,aAAa,QAAQ,IAAI,GAAG,CAAC;AAAA,IACjE;AAAA,EACJ;AACJ;;;AG7GA,IAAAC,eAA4B;AAYrB,IAAM,yBAAN,cAAqC,iBAC5C;AAAA;AAAA;AAAA;AAAA,EAIc,aACV;AACI,UAAM,SAAS,SAAS,cAAc,QAAQ;AAE9C,WAAO,QAAQ,KAAK;AACpB,WAAO,SAAS,KAAK;AAErB,WAAO;AAAA,MACH,aAAa,IAAI,oBAAoB,KAAK,WAAW,KAAK,UAAU;AAAA,MACpE,iBAAiB,CAAC;AAAA,MAClB,MAAM,IAAI,yBAAY,QAAQ;AAAA,QAC1B,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;;;ACjCA,IAAAC,eAAiD;AAa1C,IAAM,yBAAN,cAAqC,iBAC5C;AAAA;AAAA;AAAA;AAAA,EAIc,aACV;AACI,WAAO;AAAA,MACH,aAAa,IAAI,oBAAoB,KAAK,WAAW,KAAK,UAAU;AAAA,MACpE,iBAAiB,CAAC;AAAA,MAClB,MAAM,IAAI,+BAAkB;AAAA,QACxB,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,IACL;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQU,cAAc,aAA0B,OAClD;AACI,WAAO,IAAI,2BAAc,aAAkC,KAAK;AAAA,EACpE;AACJ;",
+ "sourcesContent": ["export * from './Area';\nexport * from './AreaAllocator';\nexport * from './AtlasAllocator';\nexport * from './AtlasResource';\nexport * from './CanvasTextureAllocator';\nexport * from './GuilloteneAllocator';\nexport * from './RenderTextureAllocator';\nexport * from './TextureAllocator';\nexport * from './TextureSlab';", "/**\n * The orientation of an area indicates the axis along which it is split. This is a 1-bit field.\n *\n * @public\n */\nexport enum AreaOrientation {\n HORIZONTAL = 0,\n VERTICAL = 1\n};\n\n/**\n * Alias for the 31-bit field texture-area type.\n *\n * @public\n */\nexport type AreaField = number;\n\n/**\n * An area represents an oriented rectangular region. It is implemented as a 31-bit field. The open/close edges are\n * specified along its parent's orientation axis, i.e. if the parent is horizontal, the left and right edges are defined,\n * else if the parent is vertical, the top and bottom edges are defined. Similarly, the open/close edges of its\n * children will be along its own orientation axis.\n *\n * The orientation axes flip-flop along the hierarchy, i.e. an area's parent's orientation is always opposite to\n * the area's own orientation. This is because if the orientation were to be same, the area's children could be\n * \"pulled up\" to the parent making itself redundant.\n *\n * All four edges of an area can be retrieved from it and its parent.\n *\n *
\n * \n *
\n *
Field
\n *
Bits
\n *
Description
\n *
\n * \n * \n *
\n *
OPEN_OFFSET
\n *
0-14
\n *
\n * The offset along the parent's axis at which the area begins. If orientation is horizontal,\n * this is the left edge. If orientation is vertical, this is the top edge.\n *
\n *
\n *
\n *
CLOSE_OFFSET
\n *
15-29
\n *
\n * The offset along the parent's axis at which the area ends. If orientation is horizontal,\n * this is the right edge. If orientation is vertical, this is the bottom edge.\n *
\n *
\n *
\n *
ORIENTATION
\n *
30
\n *
\n * The orientation of the area, which indicates the axis along it is split. The open and close\n * offsets of its children are along this axis. See {@link AreaOrientation}.\n *
\n *
\n * \n *
\n *\n * @public\n */\nexport class Area\n{\n static makeArea(openOffset: number, closeOffset: number, orientation: number): number\n {\n return openOffset | (closeOffset << 15) | (orientation << 30);\n }\n\n static getOpenOffset(area: AreaField): number\n {\n return area & ((1 << 15) - 1);\n }\n\n static getCloseOffset(area: AreaField): number\n {\n return (area >> 15) & ((1 << 15) - 1);\n }\n\n static getOrientation(area: AreaField): AreaOrientation\n {\n return (area >> 30) & 1;\n }\n\n static setOpenOffset(area: AreaField, offset: number): number\n {\n return Area.makeArea(\n offset,\n Area.getCloseOffset(area),\n Area.getOrientation(area)\n );\n }\n\n static setCloseOffset(area: AreaField, offset: number): number\n {\n return Area.makeArea(\n Area.getOpenOffset(offset),\n offset,\n Area.getOrientation(area)\n );\n }\n}", "import { ALPHA_MODES } from '@pixi/constants';\nimport { BaseTexture, GLTexture, Resource, Renderer } from '@pixi/core';\n\nimport type { Rectangle } from '@pixi/math';\nimport type { Texture } from '@pixi/core';\n\n/**\n * Types of image sources supported by {@link AtlasResource}.\n *\n * @public\n */\nexport type AtlasResourceSource = HTMLImageElement | HTMLCanvasElement | ImageBitmap | ImageData | ArrayBufferView;\n\n/**\n * An item that is uploaded to the atlas texture.\n *\n * @public\n */\nexport type AtlasResourceItem =\n{\n /**\n * The location of the atlas item in the base-texture's space.\n */\n frame: Rectangle;\n\n /**\n * The source of the texture data.\n */\n source: AtlasResourceSource;\n\n /**\n * This flags when the resource is to be re-uploaded.\n */\n dirtyId: number;\n\n /**\n * This flags when the resource is uploaded and update-to-date with the dirty ID.\n */\n updateId: number;\n\n /**\n * The texture holding this item.\n */\n texture: Texture;\n};\n\n/**\n * An {@code AtlasResource} is used by {@link AtlasAllocator} to manage texture sources\n *\n * @public\n */\nexport class AtlasResource extends Resource\n{\n /**\n * The list of managed resources in the atlas.\n */\n public managedItems: AtlasResourceItem[];\n\n /**\n * Creates an atlas resource.\n *\n * @param width\n * @param height\n */\n constructor(width: number, height: number)\n {\n super(width, height);\n\n this.managedItems = [];\n }\n\n /**\n * Uploads the atlas.\n *\n * @param renderer\n * @param baseTexture\n * @param glTexture\n */\n upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean\n {\n const gl: WebGLRenderingContext = renderer.gl;\n const width = baseTexture.realWidth;\n const height = baseTexture.realHeight;\n\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK)\n\n // Allocate the texture on the GPU\n if (glTexture.width !== width ||\n glTexture.height !== height)\n {\n glTexture.width = width;\n glTexture.height = height;\n\n gl.texImage2D(\n baseTexture.target,\n 0,\n baseTexture.format,\n width,\n height,\n 0,\n baseTexture.format,\n baseTexture.type,\n undefined\n );\n }\n\n const items = this.managedItems;\n\n // Upload all atlas items.\n for (let i = 0, j = items.length; i < j; i++)\n {\n this.uploadItem(\n renderer,\n baseTexture.target,\n baseTexture.format,\n baseTexture.type,\n items[i]\n );\n }\n\n return true;\n }\n\n /**\n * Uploads the atlas item to the GPU.\n *\n * @param renderer - The renderer holding the WebGL context.\n * @param target - The binding point of the base-texture.\n * @param format - The format of the base-texture.\n * @param type - The type of the base-texture data.\n * @param item - The item to upload.\n */\n protected uploadItem(\n renderer: Renderer,\n target: number,\n format: number,\n type: number,\n item: AtlasResourceItem\n ): void\n {\n // see https://github.com/rapideditor/pixi-texture-allocator/issues/2\n // if (item.updateId === item.dirtyId)\n // {\n // return;\n // }\n\n const gl: WebGLRenderingContext = renderer.gl;\n const isWebGL2 = (gl instanceof WebGL2RenderingContext);\n const frame = item.frame;\n let source = item.source;\n\n // if WebGL1, convert whatever we have into a typed array\n if (!isWebGL2) {\n if (source instanceof ImageData) {\n source = source.data; // pass the typed array directly\n\n } else if (source instanceof HTMLCanvasElement) {\n const ctx = source.getContext('2d');\n const [w, h] = [source.width, source.height];\n source = ctx.getImageData(0, 0, w, h).data;\n\n } else if (source instanceof HTMLImageElement) {\n const [w, h] = [source.naturalWidth, source.naturalHeight];\n const canvas = document.createElement('canvas');\n canvas.width = w;\n canvas.height = h;\n\n const ctx = canvas.getContext('2d');\n ctx.drawImage(source, 0, 0);\n source = ctx.getImageData(0, 0, w, h).data;\n }\n }\n\n gl.texSubImage2D(\n target,\n 0,\n frame.x,\n frame.y,\n frame.width,\n frame.height,\n format,\n type,\n source as any,\n );\n\n item.updateId = item.dirtyId;\n }\n}", "import { AtlasResource } from './AtlasResource';\nimport { BaseTexture, Texture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\nimport { TextureSlab } from './TextureSlab';\n\nimport type { AtlasResourceSource } from './AtlasResource';\n\n/**\n * This texture allocator auto-manages the base-texture with an {@link AtlasResource}. You can also\n * pass a texture source to `allocate`, mimicing {@link Texture.from} functionality.\n *\n * @public\n */\nexport class AtlasAllocator extends TextureAllocator\n{\n /**\n * Creates a texture slab backed by an {@link AtlasResource}.\n */\n protected createSlab(): TextureSlab\n {\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseTexture(new AtlasResource(this.slabWidth, this.slabHeight),\n {\n width: this.slabWidth,\n height: this.slabHeight,\n }),\n };\n }\n\n /**\n * Allocates a texture backed by the given atlas source, with the given padding.\n *\n * @override\n * @param width\n * @param height\n * @param padding\n * @param source\n */\n allocate(width: number, height: number, padding?: number, source?: AtlasResourceSource): Texture;\n\n /**\n * Allocates a texture backed by the given source, with default padding.\n *\n * @param width\n * @param height\n * @param source\n */\n allocate(width: number, height: number, source?: AtlasResourceSource): Texture;\n\n allocate(width: number, height: number, paddingOrSource?: number | AtlasResourceSource, source?: AtlasResourceSource): Texture\n {\n let padding: number;\n\n if (typeof paddingOrSource === 'number')\n {\n padding = paddingOrSource;\n }\n else\n {\n padding = this.calculatePadding(width, height);\n source = paddingOrSource;\n }\n\n const texture = super.allocate(width, height, padding);\n\n if (source)\n {\n const atlas = texture.baseTexture.resource as AtlasResource;\n const item = {\n frame: texture.frame,\n source,\n // dirtyId !== updateId only if image loaded\n dirtyId: source instanceof HTMLImageElement && !source.complete ? -1 : 0,\n updateId: -1,\n texture,\n };\n\n atlas.managedItems.push(item);\n\n if (source instanceof HTMLImageElement && !source.complete) {\n source.addEventListener('load', () => {\n if (texture.baseTexture.valid && !texture.baseTexture.destroyed && atlas.managedItems.indexOf(item) >= 0) {\n item.dirtyId++;\n texture.baseTexture.update();\n }\n });\n }\n\n texture.baseTexture.update();\n }\n\n return texture;\n }\n\n free(texture: Texture): void\n {\n super.free(texture);\n\n const atlas = texture.baseTexture.resource as AtlasResource;\n const item = atlas.managedItems.find(item => item.texture === texture);\n\n if (item)\n {\n atlas.managedItems.splice(atlas.managedItems.indexOf(item), 1);\n }\n }\n}", "import { Rectangle } from '@pixi/math';\nimport { Area, AreaOrientation } from './Area';\n\nimport type { AreaAllocator } from './AreaAllocator';\nimport type { AreaField } from './Area';\n\n/**\n * An allocator node is represented as a tuple. The zeroth element is the parent of the node. The first element\n * always exists and is the texture area it wholly represents. The second element is whether the rectangle\n * is allocated or free. The last element is optional and is the list\n * of its children.\n *\n * @public\n * @ignore\n */\nexport type AreaNode = [AreaNode, AreaField, boolean] | [AreaNode, AreaField, AreaNode[]];\n\n/**\n * Pointer to guillotene node.\n *\n * @public\n * @ignore\n */\nexport type AreaPtr = { __mem_area: AreaNode };\n\n/**\n * @public\n * @ignore\n */\nexport enum SPLIT_ORIENTATION {\n HOR = 0,\n VERT = 1,\n NONE = 2\n}\n\nconst tempRect = new Rectangle();\n\n/** @public */\nexport class GuilloteneAllocator implements AreaAllocator\n{\n protected _root: AreaNode;\n\n private _width: number;\n private _height: number;\n\n constructor(width: number, height: number)\n {\n this._width = width;\n this._height = height;\n\n // NOTE: getFrame assumes root node is always horizontal!\n this._root = [\n null,\n Area.makeArea(0, this._height, AreaOrientation.HORIZONTAL),\n false\n ];\n }\n\n /**\n * Allocates an area of the given `width` and `height`.\n *\n * @param width - The width required for the allocated area.\n * @param height - The height required for the allocated area.\n * @param rect - An optional `Rectangle` instance to put the resulting area frame into.\n * @return The rectangle frame of the area allocated.\n */\n allocate(width: number, height: number, rect?: Rectangle): Rectangle & AreaPtr\n {\n const area = this.findArea(width, height);\n\n if (!area)\n {\n return null;\n }\n\n if (!rect)\n {\n rect = new Rectangle();\n }\n\n this.getFrame(area, rect);\n\n const hole = new Rectangle(rect.x, rect.y, width, height);\n const node = this.split(area, rect, hole);\n\n rect.copyFrom(hole);\n (rect as any).__mem_area = node;\n\n return rect as (Rectangle & AreaPtr);\n }\n\n /**\n * Frees the area represented by the given area pointer. The original rectangle returned by\n * {@link GuilloteneAllocator#allocate} included this pointer (the `__mem_area` property).\n *\n * @param areaPtr\n */\n free(areaPtr: AreaPtr): void\n {\n const area = areaPtr.__mem_area;\n\n area[2] = false;\n this.merge(area);\n }\n\n get width(): number\n {\n return this._width;\n }\n\n get height(): number\n {\n return this._height;\n }\n\n /**\n * Returns the [area]{@link Area} data for the node.\n *\n * @param node\n * @returns The area data for the node.\n */\n protected getAreaField(node: AreaNode): AreaField\n {\n return node[1];\n }\n\n /**\n * Returns the rectangle covered by the area node.\n *\n * @param node - The node whose covered rectangular area is needed.\n * @param rect - An optional `Rectangle` instance to put the data in.\n * @return The rectangle covered by `node`.\n */\n protected getFrame(node: AreaNode, rect?: Rectangle): Rectangle\n {\n if (!rect)\n {\n rect = new Rectangle();\n }\n\n const nodeArea = this.getAreaField(node);\n const nodeParent = this.getParent(node);\n const nodeOrientation = Area.getOrientation(nodeArea);\n const nodeOpen = Area.getOpenOffset(nodeArea);\n const nodeClose = Area.getCloseOffset(nodeArea);\n const parentOpen = nodeParent ? Area.getOpenOffset(nodeParent[1]) : 0;\n const parentClose = nodeParent ? Area.getCloseOffset(nodeParent[1]) : this._width;// (because root node is horizontal)\n\n if (nodeOrientation) // VERTICAL\n {\n rect.x = nodeOpen;\n rect.y = parentOpen;\n rect.width = nodeClose - rect.x;\n rect.height = parentClose - parentOpen;\n }\n else // HORIZONTAL\n {\n rect.x = parentOpen;\n rect.y = nodeOpen;\n rect.width = parentClose - rect.x;\n rect.height = nodeClose - rect.y;\n }\n\n return rect;\n }\n\n /**\n * Returns the parent of the area node.\n *\n * @param node\n * @return The parent of `node`\n */\n protected getParent(node: AreaNode): AreaNode\n {\n return node[0];\n }\n\n /**\n * Returns whether the given node has any children.\n *\n * @param node\n * @return Whether the given node has any children.\n */\n protected hasChildren(node: AreaNode): boolean\n {\n return (Array.isArray(node[2]) && (node[2].length !== 0));\n }\n\n /**\n * Returns the children of the passed node, if any.\n *\n * @param node\n */\n protected getChildren(node: AreaNode): AreaNode[]\n {\n if (!Array.isArray(node[2])) {\n throw new Error(\"Children don't exist\")\n }\n\n return node[2];\n }\n\n protected addChild(parent: AreaNode, ...nodes: AreaNode[]): void\n {\n parent[2] = Array.isArray(parent[2]) ? parent[2] : []\n parent[2].push(...nodes)\n }\n\n /**\n * Finds an area node with minimum width `aw` and minimum height `ah`.\n *\n * @param aw\n * @param ah\n */\n protected findArea(aw: number, ah: number): AreaNode\n {\n return this.findAreaRecursive(this._root, aw, ah);\n }\n\n /**\n * The recursive implementation for {@link AreaAllocator#findArea}.\n *\n * @param rootArea\n * @param aw\n * @param ah\n */\n protected findAreaRecursive(rootArea: AreaNode, aw: number, ah: number): AreaNode\n {\n const frame = this.getFrame(rootArea, tempRect);\n\n if (frame.width < aw || frame.height < ah)\n {\n return null;\n }\n\n if (!this.hasChildren(rootArea))\n {\n const dx = frame.width - aw;\n const dy = frame.height - ah;\n\n if (dx < 0 || dy < 0 || rootArea[2])\n {\n return null;\n }\n\n return rootArea;\n }\n\n const children = this.getChildren(rootArea);\n\n let bestCandidate = null;\n let bestCandidateScore = Infinity;\n\n for (let i = 0, j = children.length; i < j; i++)\n {\n const candidate = this.findAreaRecursive(children[i], aw, ah);\n\n if (!candidate)\n {\n continue;\n }\n\n const candidateFrame = this.getFrame(candidate, tempRect);\n\n const dx = candidateFrame.width - aw;\n const dy = candidateFrame.height - ah;\n\n if (dx < 0 || dy < 0)\n {\n continue;\n }\n if (!dx && !dy)\n {\n // Perfect fit!\n return candidate;\n }\n\n const score = Math.min(dx, dy);\n\n if (bestCandidateScore > score)\n {\n bestCandidate = candidate;\n bestCandidateScore = score;\n }\n }\n\n return bestCandidate;\n }\n\n /**\n * Returns the orientation of the primary split of host.\n */\n protected splitOrientation(host: Rectangle, hole: Rectangle): SPLIT_ORIENTATION\n {\n if (hole.width === host.width && hole.height === host.height) {\n return SPLIT_ORIENTATION.NONE;\n }\n if (hole.width === host.width) {\n return SPLIT_ORIENTATION.VERT;\n }\n if (hole.height === host.height) {\n return SPLIT_ORIENTATION.HOR;\n }\n\n // ____________________\n // | | |\n // | | |\n // | hole | |\n // | | |\n // |________| Primary |\n // | | |\n // | | |\n // | Sec. | |\n // |________|_________|\n const horAreaDiff = Math.abs(\n // (Primary) Right\n (host.width - hole.width) * host.height -\n // (Secondary) Bottom\n hole.width * (host.height - hole.height)\n )\n\n // ____________________\n // | | |\n // | | |\n // | hole | Sec. |\n // | | |\n // |________|_________|\n // | |\n // | Primary |\n // |__________________|\n const verAreaDiff = Math.abs(\n // (Primary) Bottom\n host.width * (host.height - hole.height) -\n (host.width - hole.width) * hole.height\n )\n\n if (horAreaDiff > verAreaDiff)\n {\n return SPLIT_ORIENTATION.HOR\n }\n else\n {\n return SPLIT_ORIENTATION.VERT\n }\n }\n\n protected split(\n area: AreaNode,\n areaFrame: Rectangle,\n holeFrame: Rectangle,\n orientation: SPLIT_ORIENTATION = this.getParent(area) ? this.splitOrientation(areaFrame, holeFrame) : SPLIT_ORIENTATION.HOR\n ): AreaNode\n {\n if (area[2] === true)\n {\n throw new Error('Cannot deallocate')\n }\n if (orientation === SPLIT_ORIENTATION.NONE)\n {\n area[2] = true;\n return area;\n }\n\n return this[orientation === SPLIT_ORIENTATION.HOR\n ? 'splitPrimaryHorizontal'\n : 'splitPrimaryVertical'](area, areaFrame, holeFrame);\n }\n\n private splitPrimaryHorizontal(area: AreaNode, areaFrame: Rectangle, holeFrame: Rectangle): AreaNode\n {\n const field = this.getAreaField(area);\n const axis = Area.getOrientation(field);\n const parent = this.getParent(area);\n\n if (this.hasChildren(area))\n {\n throw new Error(\"Can't split non-leaf node\")\n }\n\n const firstChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.left,\n areaFrame.x + holeFrame.width,\n AreaOrientation.VERTICAL\n ),\n []\n ];\n const secondChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.x + holeFrame.width,\n areaFrame.right,\n AreaOrientation.VERTICAL\n ),\n false\n ];\n\n if (axis === AreaOrientation.HORIZONTAL) {\n this.addChild(area, firstChild, secondChild)\n } else {\n const i = this.getChildren(parent).indexOf(area);\n\n firstChild[0] = parent;\n secondChild[0] = parent;\n\n this.getChildren(parent).splice(i, 1, firstChild, secondChild);\n }\n\n if (holeFrame.height !== areaFrame.height)\n {\n const secondaryFirstChild: AreaNode = [\n firstChild,\n Area.makeArea(\n areaFrame.top,\n areaFrame.y + holeFrame.height,\n AreaOrientation.HORIZONTAL\n ),\n true\n ];\n const secondarySecondChild: AreaNode = [\n firstChild,\n Area.makeArea(\n areaFrame.y + holeFrame.height,\n areaFrame.bottom,\n AreaOrientation.HORIZONTAL\n ),\n false\n ];\n\n this.addChild(firstChild, secondaryFirstChild, secondarySecondChild);\n\n return secondaryFirstChild;\n }\n else\n {\n (firstChild as AreaNode)[2] = true;\n }\n\n return firstChild;\n }\n\n private splitPrimaryVertical(area: AreaNode, areaFrame: Rectangle, holeFrame: Rectangle): AreaNode\n {\n const field = this.getAreaField(area);\n const axis = Area.getOrientation(field);\n const parent = this.getParent(area);\n\n if (this.hasChildren(area)) {\n throw new Error(\"Can't split non-leaf node\")\n }\n\n const primaryFirstChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.top,\n areaFrame.y + holeFrame.height,\n AreaOrientation.HORIZONTAL\n ),\n []\n ];\n const primarySecondChild: AreaNode = [\n area,\n Area.makeArea(\n areaFrame.y + holeFrame.height,\n areaFrame.bottom,\n AreaOrientation.HORIZONTAL\n ),\n false\n ];\n\n if (axis === AreaOrientation.VERTICAL)\n {\n this.addChild(area, primaryFirstChild, primarySecondChild);\n }\n else\n {\n const i = this.getChildren(parent).indexOf(area);\n primaryFirstChild[0] = parent;\n primarySecondChild[0] = parent;\n this.getChildren(parent).splice(i, 1, primaryFirstChild, primarySecondChild);\n }\n\n if (holeFrame.width !== areaFrame.height)\n {\n const secondaryFirstChild: AreaNode = [\n primaryFirstChild,\n Area.makeArea(\n areaFrame.left,\n areaFrame.x + holeFrame.width,\n AreaOrientation.VERTICAL\n ),\n true\n ];\n const secondarySecondChild: AreaNode = [\n primaryFirstChild,\n Area.makeArea(\n areaFrame.x + holeFrame.width,\n areaFrame.right,\n AreaOrientation.VERTICAL\n ),\n false\n ];\n\n this.addChild(primaryFirstChild, secondaryFirstChild, secondarySecondChild);\n\n return secondaryFirstChild;\n }\n else\n {\n (primaryFirstChild as AreaNode)[2] = true;\n }\n\n return primaryFirstChild;\n }\n\n protected merge(\n area: AreaNode\n ) {\n if (this.hasChildren(area))\n {\n throw new Error(\"Cannot merge a non-leaf node\");\n }\n\n const parent = this.getParent(area);\n\n if (!parent)\n {\n return;\n }\n\n const siblings = this.getChildren(parent);\n const i = siblings.indexOf(area);\n\n const leftSibling = siblings[i - 1];\n const rightSibling = siblings[i + 1];\n\n if (rightSibling && rightSibling[2] === false)\n {\n // Merge rightSibling into area\n area[1] = Area.setCloseOffset(area[1], Area.getCloseOffset(rightSibling[1]));\n siblings.splice(i + 1, 1);\n }\n if (leftSibling && leftSibling[2] === false)\n {\n // Merge leftSibling into area\n area[1] = Area.setOpenOffset(area[1], Area.getOpenOffset(leftSibling[1]));\n siblings.splice(i - 1, 1);\n }\n\n if (siblings.length === 1) {\n parent[2] = false;\n this.merge(parent);\n }\n }\n\n private printState(area: AreaNode): void\n {\n if (!this.hasChildren(area)) {\n console.log({ ...this.getFrame(area) }, area[2])\n } else {\n this.getChildren(area).forEach(n => this.printState(n))\n }\n }\n}", "import { BaseTexture, Texture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { Rectangle } from '@pixi/math';\n\nimport type { TextureSlab } from './TextureSlab';\n\nconst tempRect = new Rectangle();\n\n/**\n * The texture allocator dynamically manages space on base-texture slabs. It can be used to generate\n * atlases on demand, which improve batching efficiency.\n *\n * @public\n */\nexport class TextureAllocator\n{\n /**\n * The width of texture slabs.\n */\n public readonly slabWidth: number;\n\n /**\n * The height of texture slabs.\n */\n public readonly slabHeight: number;\n\n /**\n * The list of base-textures that are used to allocate texture space.\n */\n protected textureSlabs: TextureSlab[];\n\n /**\n * @param slabWidth - The width of base-texture slabs. This should be at most 2048.\n * @param slabHeight - The height of base-texture slabs. This should be at most 2048.\n */\n constructor(slabWidth = 2048, slabHeight = 2048)\n {\n this.slabWidth = slabWidth;\n this.slabHeight = slabHeight;\n\n this.textureSlabs = [];\n }\n\n get maxWidth() {\n return this.slabWidth - (2 * this.calculatePadding(this.slabWidth, this.slabHeight));\n }\n\n get maxHeight() {\n return this.slabHeight - (2 * this.calculatePadding(this.slabWidth, this.slabHeight));\n }\n\n /**\n * Allocates a texture from this allocator.\n *\n * If its existing slab pool has enough space, the texture is issued from one. Otherwise,\n * a new slab is created and the texture is issued from it. However, if the requested\n * dimensions are larger than slabs themselves, then `null` is always returned.\n *\n * To upload a texture source, you will have to create an atlas-managing {@link Resource}\n * yourself on the base-texture. The {@link AtlasAllocator} does this for you, while the\n * {@link CanvasTextureAllocator} can be used to draw on a canvas-based atlas.\n *\n * @param width - The width of the requested texture.\n * @param height - The height of the requested texture.\n * @param padding - The padding requested around the texture, to prevent bleeding.\n * @return The allocated texture, if successful; otherwise, `null`.\n */\n allocate(width: number, height: number, padding = this.calculatePadding(width, height)): T\n {\n // Cannot allocate a texture larger than a texture-slab.\n if (width + 2 * padding > this.slabWidth ||\n height + 2 * padding > this.slabHeight)\n {\n return null;\n }\n\n const slabs = this.textureSlabs;\n\n // Loop through the slabs and find one with enough space, if any.\n for (let i = 0, j = slabs.length; i < j; i++)\n {\n const slab = slabs[i];\n const texture = this.issueTexture(slab, width, height, padding);\n\n if (texture)\n {\n return texture;\n }\n }\n\n // Issue a new slab.\n const slab = this.createSlab();\n\n // Append this slab to the head of the list.\n this.textureSlabs.unshift(slab);\n\n // Issue the texture from this blank slab.\n return this.issueTexture(slab, width, height, padding);\n }\n\n /**\n * Frees the texture and reclaims its space. It is assumed you will not use it again, and have\n * destroyed any resource uploading its data.\n *\n * @param texture\n * @throws When the texture was not located in this allocator.\n */\n free(texture: T): void\n {\n const baseTexture = (texture as Texture).baseTexture;\n const slab = this.textureSlabs.find(sl => sl.slab === baseTexture);\n\n if (!slab)\n {\n throw new Error(\"The texture cannot be freed because \" +\n \"its base-texture is not pooled by this allocator. \" +\n \"This is either a bug in TextureAllocator or you tried to free a \" +\n \"texture that was never allocated by one.\");\n }\n\n const textureEntry = slab.managedTextures.find(entry => entry.texture === texture);\n\n if (!textureEntry)\n {\n throw new Error(\"The texture cannot be freed because it was not found \" +\n \"in the managed list of issued textures on its slab. This may be because you \" +\n \"duplicated this texture or a bug in TextureAllocator\");\n }\n\n slab.managedArea.free(textureEntry.area);\n slab.managedTextures.splice(slab.managedTextures.indexOf(textureEntry), 1);\n }\n\n protected calculatePadding(width: number, height: number): number\n {\n const dimen = Math.max(width, height);\n\n if (dimen < 64)\n {\n return 2;\n }\n else if (dimen < 128)\n {\n return 4;\n }\n else if (dimen < 1024)\n {\n return 8;\n }\n else\n {\n return 16;\n }\n }\n\n /**\n * Creates a texture slab. The slab's base-texture is not backed by any resource. You\n * will have to manage that yourself. See {@link AtlasAllocator} or {@link CanvasTextureAllocator}\n * for better resource semantics.\n */\n protected createSlab(): TextureSlab\n {\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseTexture(null,\n {\n width: this.slabWidth,\n height: this.slabHeight,\n }),\n };\n }\n\n /**\n * Creates a texture on the given base-texture at {@code frame}.\n *\n * @param baseTexture - The base texture that will hold the texture's space.\n * @param frame - The frame in which the texture will be stored.\n */\n protected createTexture(baseTexture: BaseTexture, frame: Rectangle): T\n {\n // Override this method to return correct texture type T.\n return new Texture(baseTexture, frame) as T;\n }\n\n /**\n * Issues a texture from the given texture slab, if possible.\n *\n * @param slab - The texture slab to allocate frame.\n * @param width - The width of the requested texture.\n * @param height - The height of the requested texture.\n * @param padding - Padding required around the texture.\n * @return The issued texture, if successful; otherwise, `null`.\n */\n protected issueTexture(slab: TextureSlab, width: number, height: number, padding = 0): T\n {\n const area = slab.managedArea.allocate(width + 2 * padding, height + 2 * padding);\n\n if (!area)\n {\n return null;\n }\n\n tempRect.copyFrom(area);\n tempRect.pad(-padding);\n\n const baseTexture = slab.slab;\n const issuedTexture = this.createTexture(baseTexture, tempRect.clone());\n\n slab.managedTextures.push({\n area,\n texture: issuedTexture,\n });\n\n return issuedTexture;\n }\n}", "import { BaseTexture } from '@pixi/core';\n\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\nimport { TextureSlab } from './TextureSlab';\n\n/**\n * This allocator issues texture backed by a canvas. You can draw on to that canvas to soruce\n * each texture.\n *\n * @public\n */\nexport class CanvasTextureAllocator extends TextureAllocator\n{\n /**\n * Creates a texture slab backed by a canvas.\n */\n protected createSlab(): TextureSlab\n {\n const canvas = document.createElement('canvas');\n\n canvas.width = this.slabWidth;\n canvas.height = this.slabHeight;\n\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseTexture(canvas, {\n width: this.slabWidth,\n height: this.slabHeight\n })\n };\n }\n}", "import { BaseRenderTexture, RenderTexture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\n\nimport type { BaseTexture } from '@pixi/core';\nimport type { Rectangle } from '@pixi/math';\nimport type { TextureSlab } from './TextureSlab';\n\n/**\n * This allocator issues render-textures, and is otherwise just like {@link TextureAllocator}.\n *\n * @public\n */\nexport class RenderTextureAllocator extends TextureAllocator\n{\n /**\n * Creates a texture slab backed by a base render-texture.\n */\n protected createSlab(): TextureSlab\n {\n return {\n managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n managedTextures: [],\n slab: new BaseRenderTexture({\n width: this.slabWidth,\n height: this.slabHeight\n })\n };\n }\n\n /**\n * Creates a render-texture from the given base render-texture.\n *\n * @param baseTexture\n * @param frame\n */\n protected createTexture(baseTexture: BaseTexture, frame: Rectangle): RenderTexture\n {\n return new RenderTexture(baseTexture as BaseRenderTexture, frame);\n }\n}"],
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA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IACjE;AAAA,EACJ;AACJ;;;AG7GA,IAAAC,eAA4B;AAYrB,IAAM,yBAAN,cAAqC,iBAC5C;AAAA;AAAA;AAAA;AAAA,EAIc,aACV;AACI,UAAM,SAAS,SAAS,cAAc,QAAQ;AAE9C,WAAO,QAAQ,KAAK;AACpB,WAAO,SAAS,KAAK;AAErB,WAAO;AAAA,MACH,aAAa,IAAI,oBAAoB,KAAK,WAAW,KAAK,UAAU;AAAA,MACpE,iBAAiB,CAAC;AAAA,MAClB,MAAM,IAAI,yBAAY,QAAQ;AAAA,QAC1B,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;;;ACjCA,IAAAC,eAAiD;AAa1C,IAAM,yBAAN,cAAqC,iBAC5C;AAAA;AAAA;AAAA;AAAA,EAIc,aACV;AACI,WAAO;AAAA,MACH,aAAa,IAAI,oBAAoB,KAAK,WAAW,KAAK,UAAU;AAAA,MACpE,iBAAiB,CAAC;AAAA,MAClB,MAAM,IAAI,+BAAkB;AAAA,QACxB,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,IACL;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQU,cAAc,aAA0B,OAClD;AACI,WAAO,IAAI,2BAAc,aAAkC,KAAK;AAAA,EACpE;AACJ;",
"names": ["AreaOrientation", "import_core", "SPLIT_ORIENTATION", "import_core", "import_math", "tempRect", "slab", "item", "import_core", "import_core"]
}
diff --git a/dist/pixi-texture-allocator.iife.js b/dist/pixi-texture-allocator.iife.js
index 404cc0d..e4b919e 100644
--- a/dist/pixi-texture-allocator.iife.js
+++ b/dist/pixi-texture-allocator.iife.js
@@ -11189,9 +11189,6 @@ ${this.fragmentSrc}`;
* @param item - The item to upload.
*/
uploadItem(renderer, target, format2, type, item) {
- if (item.updateId === item.dirtyId) {
- return;
- }
const gl = renderer.gl;
const isWebGL2 = gl instanceof WebGL2RenderingContext;
const frame = item.frame;
diff --git a/dist/pixi-texture-allocator.iife.js.map b/dist/pixi-texture-allocator.iife.js.map
index a23e30a..2a57c62 100644
--- a/dist/pixi-texture-allocator.iife.js.map
+++ b/dist/pixi-texture-allocator.iife.js.map
@@ -1,7 +1,7 @@
{
"version": 3,
"sources": ["../node_modules/eventemitter3/index.js", "../node_modules/earcut/src/earcut.js", "../node_modules/punycode/punycode.js", "../node_modules/url/util.js", "../node_modules/querystring/decode.js", "../node_modules/querystring/encode.js", "../node_modules/querystring/index.js", "../node_modules/url/url.js", "../src/index.ts", "../src/Area.ts", "../node_modules/@pixi/constants/src/index.ts", "../node_modules/@pixi/settings/src/adapter.ts", "../node_modules/@pixi/settings/src/settings.ts", "../node_modules/ismobilejs/src/isMobile.ts", "../node_modules/@pixi/settings/src/utils/isMobile.ts", "../node_modules/@pixi/utils/src/settings.ts", "../node_modules/@pixi/utils/lib/index.mjs", "../node_modules/@pixi/utils/src/url.ts", "../node_modules/@pixi/utils/src/logging/deprecation.ts", "../node_modules/@pixi/utils/src/browser/isWebGLSupported.ts", "../node_modules/colord/index.mjs", "../node_modules/colord/plugins/names.mjs", "../node_modules/@pixi/color/src/Color.ts", "../node_modules/@pixi/utils/src/color/premultiply.ts", "../node_modules/@pixi/utils/src/data/getBufferType.ts", "../node_modules/@pixi/utils/src/data/pow2.ts", "../node_modules/@pixi/utils/src/data/removeItems.ts", "../node_modules/@pixi/utils/src/data/uid.ts", "../node_modules/@pixi/utils/src/media/BoundingBox.ts", "../node_modules/@pixi/utils/src/media/caches.ts", "../node_modules/@pixi/utils/src/network/determineCrossOrigin.ts", "../node_modules/@pixi/utils/src/network/getResolutionOfUrl.ts", "../node_modules/@pixi/extensions/src/index.ts", "../node_modules/@pixi/core/src/geometry/ViewableBuffer.ts", "../node_modules/@pixi/core/src/shader/utils/checkMaxIfStatementsInShader.ts", "../node_modules/@pixi/core/src/state/State.ts", "../node_modules/@pixi/core/src/textures/resources/autoDetectResource.ts", "../node_modules/@pixi/runner/src/Runner.ts", "../node_modules/@pixi/core/src/textures/resources/Resource.ts", "../node_modules/@pixi/core/src/textures/resources/BufferResource.ts", "../node_modules/@pixi/core/src/textures/BaseTexture.ts", "../node_modules/@pixi/core/src/batch/BatchDrawCall.ts", "../node_modules/@pixi/core/src/geometry/Buffer.ts", "../node_modules/@pixi/core/src/geometry/Attribute.ts", "../node_modules/@pixi/core/src/geometry/utils/interleaveTypedArrays.ts", "../node_modules/@pixi/core/src/geometry/Geometry.ts", "../node_modules/@pixi/core/src/batch/BatchGeometry.ts", "../node_modules/@pixi/math/src/const.ts", "../node_modules/@pixi/math/src/Point.ts", "../node_modules/@pixi/math/src/shapes/Rectangle.ts", "../node_modules/@pixi/math/src/Matrix.ts", "../node_modules/@pixi/math/src/groupD8.ts", "../node_modules/@pixi/math/src/ObservablePoint.ts", "../node_modules/@pixi/math/src/Transform.ts", "../node_modules/@pixi/core/lib/shader/defaultProgram.mjs", "../node_modules/@pixi/core/lib/shader/defaultProgram2.mjs", "../node_modules/@pixi/core/src/shader/utils/compileShader.ts", "../node_modules/@pixi/core/src/shader/utils/defaultValue.ts", "../node_modules/@pixi/core/src/shader/utils/uniformParsers.ts", "../node_modules/@pixi/core/src/shader/utils/generateUniformsSync.ts", "../node_modules/@pixi/core/src/shader/utils/getTestContext.ts", "../node_modules/@pixi/core/src/shader/utils/getMaxFragmentPrecision.ts", "../node_modules/@pixi/core/src/shader/utils/logProgramError.ts", "../node_modules/@pixi/core/src/shader/utils/mapSize.ts", "../node_modules/@pixi/core/src/shader/utils/mapType.ts", "../node_modules/@pixi/core/src/shader/utils/setPrecision.ts", "../node_modules/@pixi/core/src/shader/utils/unsafeEvalSupported.ts", "../node_modules/@pixi/core/src/shader/Program.ts", "../node_modules/@pixi/core/src/shader/UniformGroup.ts", "../node_modules/@pixi/core/src/shader/Shader.ts", "../node_modules/@pixi/core/src/batch/BatchShaderGenerator.ts", "../node_modules/@pixi/core/src/batch/BatchTextureArray.ts", "../node_modules/@pixi/core/src/batch/canUploadSameBuffer.ts", "../node_modules/@pixi/core/src/batch/maxRecommendedTextures.ts", "../node_modules/@pixi/core/src/batch/ObjectRenderer.ts", "../node_modules/@pixi/core/lib/batch/texture.mjs", "../node_modules/@pixi/core/lib/batch/texture2.mjs", "../node_modules/@pixi/core/src/batch/BatchRenderer.ts", "../node_modules/@pixi/core/lib/filters/defaultFilter.mjs", "../node_modules/@pixi/core/lib/filters/defaultFilter2.mjs", "../node_modules/@pixi/core/src/filters/Filter.ts", "../node_modules/@pixi/core/src/background/BackgroundSystem.ts", "../node_modules/@pixi/core/src/batch/BatchSystem.ts", "../node_modules/@pixi/core/src/context/ContextSystem.ts", "../node_modules/@pixi/core/src/textures/resources/DepthResource.ts", "../node_modules/@pixi/core/src/framebuffer/Framebuffer.ts", "../node_modules/@pixi/core/src/renderTexture/BaseRenderTexture.ts", "../node_modules/@pixi/core/src/textures/resources/BaseImageResource.ts", "../node_modules/@pixi/core/src/textures/resources/ImageResource.ts", "../node_modules/@pixi/core/src/textures/TextureUvs.ts", "../node_modules/@pixi/core/src/textures/Texture.ts", "../node_modules/@pixi/core/src/renderTexture/RenderTexture.ts", "../node_modules/@pixi/core/src/renderTexture/RenderTexturePool.ts", "../node_modules/@pixi/core/src/utils/Quad.ts", "../node_modules/@pixi/core/src/utils/QuadUv.ts", "../node_modules/@pixi/core/src/filters/FilterState.ts", "../node_modules/@pixi/core/src/filters/FilterSystem.ts", "../node_modules/@pixi/core/src/framebuffer/GLFramebuffer.ts", "../node_modules/@pixi/core/src/framebuffer/FramebufferSystem.ts", "../node_modules/@pixi/core/src/geometry/GeometrySystem.ts", "../node_modules/@pixi/core/src/textures/TextureMatrix.ts", "../node_modules/@pixi/core/lib/filters/spriteMask/spriteMaskFilter2.mjs", "../node_modules/@pixi/core/lib/filters/spriteMask/spriteMaskFilter3.mjs", "../node_modules/@pixi/core/src/filters/spriteMask/SpriteMaskFilter.ts", "../node_modules/@pixi/core/src/mask/MaskData.ts", "../node_modules/@pixi/core/src/mask/MaskSystem.ts", "../node_modules/@pixi/core/src/mask/AbstractMaskSystem.ts", "../node_modules/@pixi/core/src/mask/ScissorSystem.ts", "../node_modules/@pixi/core/src/mask/StencilSystem.ts", "../node_modules/@pixi/core/src/plugin/PluginSystem.ts", "../node_modules/@pixi/core/src/projection/ProjectionSystem.ts", "../node_modules/@pixi/core/src/renderTexture/GenerateTextureSystem.ts", "../node_modules/@pixi/core/src/renderTexture/RenderTextureSystem.ts", "../node_modules/@pixi/core/src/shader/GLProgram.ts", "../node_modules/@pixi/core/src/shader/utils/getAttributeData.ts", "../node_modules/@pixi/core/src/shader/utils/getUniformData.ts", "../node_modules/@pixi/core/src/shader/utils/generateProgram.ts", "../node_modules/@pixi/core/src/shader/utils/generateUniformBufferSync.ts", "../node_modules/@pixi/core/src/shader/ShaderSystem.ts", "../node_modules/@pixi/core/src/startup/StartupSystem.ts", "../node_modules/@pixi/core/src/state/utils/mapWebGLBlendModesToPixi.ts", "../node_modules/@pixi/core/src/state/StateSystem.ts", "../node_modules/@pixi/core/src/system/SystemManager.ts", "../node_modules/@pixi/core/src/textures/TextureGCSystem.ts", "../node_modules/@pixi/core/src/textures/GLTexture.ts", "../node_modules/@pixi/core/src/textures/utils/mapTypeAndFormatToInternalFormat.ts", "../node_modules/@pixi/core/src/textures/TextureSystem.ts", "../node_modules/@pixi/core/src/transformFeedback/TransformFeedbackSystem.ts", "../node_modules/@pixi/core/src/view/ViewSystem.ts", "../node_modules/@pixi/core/src/settings.ts", "../node_modules/@pixi/ticker/src/const.ts", "../node_modules/@pixi/ticker/src/TickerListener.ts", "../node_modules/@pixi/ticker/src/Ticker.ts", "../node_modules/@pixi/ticker/src/settings.ts", "../node_modules/@pixi/ticker/src/TickerPlugin.ts", "../node_modules/@pixi/core/src/autoDetectRenderer.ts", "../node_modules/@pixi/core/src/framebuffer/MultisampleSystem.ts", "../node_modules/@pixi/core/src/geometry/GLBuffer.ts", "../node_modules/@pixi/core/src/geometry/BufferSystem.ts", "../node_modules/@pixi/core/src/render/ObjectRendererSystem.ts", "../node_modules/@pixi/core/src/Renderer.ts", "../node_modules/@pixi/core/src/textures/resources/AbstractMultiResource.ts", "../node_modules/@pixi/core/src/textures/resources/ArrayResource.ts", "../node_modules/@pixi/core/src/textures/resources/CanvasResource.ts", "../node_modules/@pixi/core/src/textures/resources/CubeResource.ts", "../node_modules/@pixi/core/src/textures/resources/ImageBitmapResource.ts", "../node_modules/@pixi/core/src/textures/resources/SVGResource.ts", "../node_modules/@pixi/core/src/textures/resources/VideoResource.ts", "../node_modules/@pixi/core/src/textures/resources/index.ts", "../src/AtlasResource.ts", "../src/GuilloteneAllocator.ts", "../src/TextureAllocator.ts", "../src/AtlasAllocator.ts", "../src/CanvasTextureAllocator.ts", "../src/RenderTextureAllocator.ts"],
- "sourcesContent": ["'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n", "'use strict';\n\nmodule.exports = earcut;\nmodule.exports.default = earcut;\n\nfunction earcut(data, holeIndices, dim) {\n\n dim = dim || 2;\n\n var hasHoles = holeIndices && holeIndices.length,\n outerLen = hasHoles ? holeIndices[0] * dim : data.length,\n outerNode = linkedList(data, 0, outerLen, dim, true),\n triangles = [];\n\n if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n var minX, minY, maxX, maxY, x, y, invSize;\n\n if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n if (data.length > 80 * dim) {\n minX = maxX = data[0];\n minY = maxY = data[1];\n\n for (var i = dim; i < outerLen; i += dim) {\n x = data[i];\n y = data[i + 1];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n\n // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n invSize = Math.max(maxX - minX, maxY - minY);\n invSize = invSize !== 0 ? 32767 / invSize : 0;\n }\n\n earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);\n\n return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\nfunction linkedList(data, start, end, dim, clockwise) {\n var i, last;\n\n if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);\n } else {\n for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);\n }\n\n if (last && equals(last, last.next)) {\n removeNode(last);\n last = last.next;\n }\n\n return last;\n}\n\n// eliminate colinear or duplicate points\nfunction filterPoints(start, end) {\n if (!start) return start;\n if (!end) end = start;\n\n var p = start,\n again;\n do {\n again = false;\n\n if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n removeNode(p);\n p = end = p.prev;\n if (p === p.next) break;\n again = true;\n\n } else {\n p = p.next;\n }\n } while (again || p !== end);\n\n return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n if (!ear) return;\n\n // interlink polygon nodes in z-order\n if (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\n var stop = ear,\n prev, next;\n\n // iterate through ears, slicing them one by one\n while (ear.prev !== ear.next) {\n prev = ear.prev;\n next = ear.next;\n\n if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n // cut off the triangle\n triangles.push(prev.i / dim | 0);\n triangles.push(ear.i / dim | 0);\n triangles.push(next.i / dim | 0);\n\n removeNode(ear);\n\n // skipping the next vertex leads to less sliver triangles\n ear = next.next;\n stop = next.next;\n\n continue;\n }\n\n ear = next;\n\n // if we looped through the whole remaining polygon and can't find any more ears\n if (ear === stop) {\n // try filtering points and slicing again\n if (!pass) {\n earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);\n\n // if this didn't work, try curing all small self-intersections locally\n } else if (pass === 1) {\n ear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);\n\n // as a last resort, try splitting the remaining polygon into two\n } else if (pass === 2) {\n splitEarcut(ear, triangles, dim, minX, minY, invSize);\n }\n\n break;\n }\n }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\nfunction isEar(ear) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n // now make sure we don't have other points inside the potential ear\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n var p = c.next;\n while (p !== a) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&\n area(p.prev, p, p.next) >= 0) return false;\n p = p.next;\n }\n\n return true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n // z-order range for the current triangle bbox;\n var minZ = zOrder(x0, y0, minX, minY, invSize),\n maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n var p = ear.prevZ,\n n = ear.nextZ;\n\n // look for points inside the triangle in both directions\n while (p && p.z >= minZ && n && n.z <= maxZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n // look for remaining points in decreasing z-order\n while (p && p.z >= minZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n }\n\n // look for remaining points in increasing z-order\n while (n && n.z <= maxZ) {\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\nfunction cureLocalIntersections(start, triangles, dim) {\n var p = start;\n do {\n var a = p.prev,\n b = p.next.next;\n\n if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\n triangles.push(a.i / dim | 0);\n triangles.push(p.i / dim | 0);\n triangles.push(b.i / dim | 0);\n\n // remove two nodes involved\n removeNode(p);\n removeNode(p.next);\n\n p = start = b;\n }\n p = p.next;\n } while (p !== start);\n\n return filterPoints(p);\n}\n\n// try splitting polygon into two and triangulate them independently\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n // look for a valid diagonal that divides the polygon into two\n var a = start;\n do {\n var b = a.next.next;\n while (b !== a.prev) {\n if (a.i !== b.i && isValidDiagonal(a, b)) {\n // split the polygon in two by the diagonal\n var c = splitPolygon(a, b);\n\n // filter colinear points around the cuts\n a = filterPoints(a, a.next);\n c = filterPoints(c, c.next);\n\n // run earcut on each half\n earcutLinked(a, triangles, dim, minX, minY, invSize, 0);\n earcutLinked(c, triangles, dim, minX, minY, invSize, 0);\n return;\n }\n b = b.next;\n }\n a = a.next;\n } while (a !== start);\n}\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n var queue = [],\n i, len, start, end, list;\n\n for (i = 0, len = holeIndices.length; i < len; i++) {\n start = holeIndices[i] * dim;\n end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n list = linkedList(data, start, end, dim, false);\n if (list === list.next) list.steiner = true;\n queue.push(getLeftmost(list));\n }\n\n queue.sort(compareX);\n\n // process holes from left to right\n for (i = 0; i < queue.length; i++) {\n outerNode = eliminateHole(queue[i], outerNode);\n }\n\n return outerNode;\n}\n\nfunction compareX(a, b) {\n return a.x - b.x;\n}\n\n// find a bridge between vertices that connects hole with an outer ring and and link it\nfunction eliminateHole(hole, outerNode) {\n var bridge = findHoleBridge(hole, outerNode);\n if (!bridge) {\n return outerNode;\n }\n\n var bridgeReverse = splitPolygon(bridge, hole);\n\n // filter collinear points around the cuts\n filterPoints(bridgeReverse, bridgeReverse.next);\n return filterPoints(bridge, bridge.next);\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\nfunction findHoleBridge(hole, outerNode) {\n var p = outerNode,\n hx = hole.x,\n hy = hole.y,\n qx = -Infinity,\n m;\n\n // find a segment intersected by a ray from the hole's leftmost point to the left;\n // segment's endpoint with lesser x will be potential connection point\n do {\n if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n if (x <= hx && x > qx) {\n qx = x;\n m = p.x < p.next.x ? p : p.next;\n if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n }\n }\n p = p.next;\n } while (p !== outerNode);\n\n if (!m) return null;\n\n // look for points inside the triangle of hole point, segment intersection and endpoint;\n // if there are no points found, we have a valid connection;\n // otherwise choose the point of the minimum angle with the ray as connection point\n\n var stop = m,\n mx = m.x,\n my = m.y,\n tanMin = Infinity,\n tan;\n\n p = m;\n\n do {\n if (hx >= p.x && p.x >= mx && hx !== p.x &&\n pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n if (locallyInside(p, hole) &&\n (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n m = p;\n tanMin = tan;\n }\n }\n\n p = p.next;\n } while (p !== stop);\n\n return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\nfunction sectorContainsSector(m, p) {\n return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// interlink polygon nodes in z-order\nfunction indexCurve(start, minX, minY, invSize) {\n var p = start;\n do {\n if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n p.prevZ = p.prev;\n p.nextZ = p.next;\n p = p.next;\n } while (p !== start);\n\n p.prevZ.nextZ = null;\n p.prevZ = null;\n\n sortLinked(p);\n}\n\n// Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\nfunction sortLinked(list) {\n var i, p, q, e, tail, numMerges, pSize, qSize,\n inSize = 1;\n\n do {\n p = list;\n list = null;\n tail = null;\n numMerges = 0;\n\n while (p) {\n numMerges++;\n q = p;\n pSize = 0;\n for (i = 0; i < inSize; i++) {\n pSize++;\n q = q.nextZ;\n if (!q) break;\n }\n qSize = inSize;\n\n while (pSize > 0 || (qSize > 0 && q)) {\n\n if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n e = p;\n p = p.nextZ;\n pSize--;\n } else {\n e = q;\n q = q.nextZ;\n qSize--;\n }\n\n if (tail) tail.nextZ = e;\n else list = e;\n\n e.prevZ = tail;\n tail = e;\n }\n\n p = q;\n }\n\n tail.nextZ = null;\n inSize *= 2;\n\n } while (numMerges > 1);\n\n return list;\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\nfunction zOrder(x, y, minX, minY, invSize) {\n // coords are transformed into non-negative 15-bit integer range\n x = (x - minX) * invSize | 0;\n y = (y - minY) * invSize | 0;\n\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n\n y = (y | (y << 8)) & 0x00FF00FF;\n y = (y | (y << 4)) & 0x0F0F0F0F;\n y = (y | (y << 2)) & 0x33333333;\n y = (y | (y << 1)) & 0x55555555;\n\n return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\nfunction getLeftmost(start) {\n var p = start,\n leftmost = start;\n do {\n if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n p = p.next;\n } while (p !== start);\n\n return leftmost;\n}\n\n// check if a point lies within a convex triangle\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\nfunction isValidDiagonal(a, b) {\n return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges\n (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible\n (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n}\n\n// signed area of a triangle\nfunction area(p, q, r) {\n return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\nfunction equals(p1, p2) {\n return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect\nfunction intersects(p1, q1, p2, q2) {\n var o1 = sign(area(p1, q1, p2));\n var o2 = sign(area(p1, q1, q2));\n var o3 = sign(area(p2, q2, p1));\n var o4 = sign(area(p2, q2, q1));\n\n if (o1 !== o2 && o3 !== o4) return true; // general case\n\n if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\nfunction onSegment(p, q, r) {\n return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n return num > 0 ? 1 : num < 0 ? -1 : 0;\n}\n\n// check if a polygon diagonal intersects any polygon segments\nfunction intersectsPolygon(a, b) {\n var p = a;\n do {\n if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n intersects(p, p.next, a, b)) return true;\n p = p.next;\n } while (p !== a);\n\n return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\nfunction locallyInside(a, b) {\n return area(a.prev, a, a.next) < 0 ?\n area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\nfunction middleInside(a, b) {\n var p = a,\n inside = false,\n px = (a.x + b.x) / 2,\n py = (a.y + b.y) / 2;\n do {\n if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&\n (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))\n inside = !inside;\n p = p.next;\n } while (p !== a);\n\n return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\nfunction splitPolygon(a, b) {\n var a2 = new Node(a.i, a.x, a.y),\n b2 = new Node(b.i, b.x, b.y),\n an = a.next,\n bp = b.prev;\n\n a.next = b;\n b.prev = a;\n\n a2.next = an;\n an.prev = a2;\n\n b2.next = a2;\n a2.prev = b2;\n\n bp.next = b2;\n b2.prev = bp;\n\n return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\nfunction insertNode(i, x, y, last) {\n var p = new Node(i, x, y);\n\n if (!last) {\n p.prev = p;\n p.next = p;\n\n } else {\n p.next = last.next;\n p.prev = last;\n last.next.prev = p;\n last.next = p;\n }\n return p;\n}\n\nfunction removeNode(p) {\n p.next.prev = p.prev;\n p.prev.next = p.next;\n\n if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction Node(i, x, y) {\n // vertex index in coordinates array\n this.i = i;\n\n // vertex coordinates\n this.x = x;\n this.y = y;\n\n // previous and next vertex nodes in a polygon ring\n this.prev = null;\n this.next = null;\n\n // z-order curve value\n this.z = 0;\n\n // previous and next nodes in z-order\n this.prevZ = null;\n this.nextZ = null;\n\n // indicates whether this is a steiner point\n this.steiner = false;\n}\n\n// return a percentage difference between the polygon area and its triangulation area;\n// used to verify correctness of triangulation\nearcut.deviation = function (data, holeIndices, dim, triangles) {\n var hasHoles = holeIndices && holeIndices.length;\n var outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n if (hasHoles) {\n for (var i = 0, len = holeIndices.length; i < len; i++) {\n var start = holeIndices[i] * dim;\n var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n polygonArea -= Math.abs(signedArea(data, start, end, dim));\n }\n }\n\n var trianglesArea = 0;\n for (i = 0; i < triangles.length; i += 3) {\n var a = triangles[i] * dim;\n var b = triangles[i + 1] * dim;\n var c = triangles[i + 2] * dim;\n trianglesArea += Math.abs(\n (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n }\n\n return polygonArea === 0 && trianglesArea === 0 ? 0 :\n Math.abs((trianglesArea - polygonArea) / polygonArea);\n};\n\nfunction signedArea(data, start, end, dim) {\n var sum = 0;\n for (var i = start, j = end - dim; i < end; i += dim) {\n sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n j = i;\n }\n return sum;\n}\n\n// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts\nearcut.flatten = function (data) {\n var dim = data[0][0].length,\n result = {vertices: [], holes: [], dimensions: dim},\n holeIndex = 0;\n\n for (var i = 0; i < data.length; i++) {\n for (var j = 0; j < data[i].length; j++) {\n for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);\n }\n if (i > 0) {\n holeIndex += data[i - 1].length;\n result.holes.push(holeIndex);\n }\n }\n return result;\n};\n", "/*! https://mths.be/punycode v1.3.2 by @mathias */\n;(function(root) {\n\n\t/** Detect free variables */\n\tvar freeExports = typeof exports == 'object' && exports &&\n\t\t!exports.nodeType && exports;\n\tvar freeModule = typeof module == 'object' && module &&\n\t\t!module.nodeType && module;\n\tvar freeGlobal = typeof global == 'object' && global;\n\tif (\n\t\tfreeGlobal.global === freeGlobal ||\n\t\tfreeGlobal.window === freeGlobal ||\n\t\tfreeGlobal.self === freeGlobal\n\t) {\n\t\troot = freeGlobal;\n\t}\n\n\t/**\n\t * The `punycode` object.\n\t * @name punycode\n\t * @type Object\n\t */\n\tvar punycode,\n\n\t/** Highest positive signed 32-bit float value */\n\tmaxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1\n\n\t/** Bootstring parameters */\n\tbase = 36,\n\ttMin = 1,\n\ttMax = 26,\n\tskew = 38,\n\tdamp = 700,\n\tinitialBias = 72,\n\tinitialN = 128, // 0x80\n\tdelimiter = '-', // '\\x2D'\n\n\t/** Regular expressions */\n\tregexPunycode = /^xn--/,\n\tregexNonASCII = /[^\\x20-\\x7E]/, // unprintable ASCII chars + non-ASCII chars\n\tregexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g, // RFC 3490 separators\n\n\t/** Error messages */\n\terrors = {\n\t\t'overflow': 'Overflow: input needs wider integers to process',\n\t\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t\t'invalid-input': 'Invalid input'\n\t},\n\n\t/** Convenience shortcuts */\n\tbaseMinusTMin = base - tMin,\n\tfloor = Math.floor,\n\tstringFromCharCode = String.fromCharCode,\n\n\t/** Temporary variable */\n\tkey;\n\n\t/*--------------------------------------------------------------------------*/\n\n\t/**\n\t * A generic error utility function.\n\t * @private\n\t * @param {String} type The error type.\n\t * @returns {Error} Throws a `RangeError` with the applicable error message.\n\t */\n\tfunction error(type) {\n\t\tthrow RangeError(errors[type]);\n\t}\n\n\t/**\n\t * A generic `Array#map` utility function.\n\t * @private\n\t * @param {Array} array The array to iterate over.\n\t * @param {Function} callback The function that gets called for every array\n\t * item.\n\t * @returns {Array} A new array of values returned by the callback function.\n\t */\n\tfunction map(array, fn) {\n\t\tvar length = array.length;\n\t\tvar result = [];\n\t\twhile (length--) {\n\t\t\tresult[length] = fn(array[length]);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * A simple `Array#map`-like wrapper to work with domain name strings or email\n\t * addresses.\n\t * @private\n\t * @param {String} domain The domain name or email address.\n\t * @param {Function} callback The function that gets called for every\n\t * character.\n\t * @returns {Array} A new string of characters returned by the callback\n\t * function.\n\t */\n\tfunction mapDomain(string, fn) {\n\t\tvar parts = string.split('@');\n\t\tvar result = '';\n\t\tif (parts.length > 1) {\n\t\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t\t// the local part (i.e. everything up to `@`) intact.\n\t\t\tresult = parts[0] + '@';\n\t\t\tstring = parts[1];\n\t\t}\n\t\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\t\tstring = string.replace(regexSeparators, '\\x2E');\n\t\tvar labels = string.split('.');\n\t\tvar encoded = map(labels, fn).join('.');\n\t\treturn result + encoded;\n\t}\n\n\t/**\n\t * Creates an array containing the numeric code points of each Unicode\n\t * character in the string. While JavaScript uses UCS-2 internally,\n\t * this function will convert a pair of surrogate halves (each of which\n\t * UCS-2 exposes as separate characters) into a single code point,\n\t * matching UTF-16.\n\t * @see `punycode.ucs2.encode`\n\t * @see \n\t * @memberOf punycode.ucs2\n\t * @name decode\n\t * @param {String} string The Unicode input string (UCS-2).\n\t * @returns {Array} The new array of code points.\n\t */\n\tfunction ucs2decode(string) {\n\t\tvar output = [],\n\t\t counter = 0,\n\t\t length = string.length,\n\t\t value,\n\t\t extra;\n\t\twhile (counter < length) {\n\t\t\tvalue = string.charCodeAt(counter++);\n\t\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t\t// high surrogate, and there is a next character\n\t\t\t\textra = string.charCodeAt(counter++);\n\t\t\t\tif ((extra & 0xFC00) == 0xDC00) { // low surrogate\n\t\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t\t} else {\n\t\t\t\t\t// unmatched surrogate; only append this code unit, in case the next\n\t\t\t\t\t// code unit is the high surrogate of a surrogate pair\n\t\t\t\t\toutput.push(value);\n\t\t\t\t\tcounter--;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toutput.push(value);\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\n\t/**\n\t * Creates a string based on an array of numeric code points.\n\t * @see `punycode.ucs2.decode`\n\t * @memberOf punycode.ucs2\n\t * @name encode\n\t * @param {Array} codePoints The array of numeric code points.\n\t * @returns {String} The new Unicode string (UCS-2).\n\t */\n\tfunction ucs2encode(array) {\n\t\treturn map(array, function(value) {\n\t\t\tvar output = '';\n\t\t\tif (value > 0xFFFF) {\n\t\t\t\tvalue -= 0x10000;\n\t\t\t\toutput += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n\t\t\t\tvalue = 0xDC00 | value & 0x3FF;\n\t\t\t}\n\t\t\toutput += stringFromCharCode(value);\n\t\t\treturn output;\n\t\t}).join('');\n\t}\n\n\t/**\n\t * Converts a basic code point into a digit/integer.\n\t * @see `digitToBasic()`\n\t * @private\n\t * @param {Number} codePoint The basic numeric code point value.\n\t * @returns {Number} The numeric value of a basic code point (for use in\n\t * representing integers) in the range `0` to `base - 1`, or `base` if\n\t * the code point does not represent a value.\n\t */\n\tfunction basicToDigit(codePoint) {\n\t\tif (codePoint - 48 < 10) {\n\t\t\treturn codePoint - 22;\n\t\t}\n\t\tif (codePoint - 65 < 26) {\n\t\t\treturn codePoint - 65;\n\t\t}\n\t\tif (codePoint - 97 < 26) {\n\t\t\treturn codePoint - 97;\n\t\t}\n\t\treturn base;\n\t}\n\n\t/**\n\t * Converts a digit/integer into a basic code point.\n\t * @see `basicToDigit()`\n\t * @private\n\t * @param {Number} digit The numeric value of a basic code point.\n\t * @returns {Number} The basic code point whose value (when used for\n\t * representing integers) is `digit`, which needs to be in the range\n\t * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n\t * used; else, the lowercase form is used. The behavior is undefined\n\t * if `flag` is non-zero and `digit` has no uppercase form.\n\t */\n\tfunction digitToBasic(digit, flag) {\n\t\t// 0..25 map to ASCII a..z or A..Z\n\t\t// 26..35 map to ASCII 0..9\n\t\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n\t}\n\n\t/**\n\t * Bias adaptation function as per section 3.4 of RFC 3492.\n\t * http://tools.ietf.org/html/rfc3492#section-3.4\n\t * @private\n\t */\n\tfunction adapt(delta, numPoints, firstTime) {\n\t\tvar k = 0;\n\t\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\t\tdelta += floor(delta / numPoints);\n\t\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\t\tdelta = floor(delta / baseMinusTMin);\n\t\t}\n\t\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n\t}\n\n\t/**\n\t * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n\t * symbols.\n\t * @memberOf punycode\n\t * @param {String} input The Punycode string of ASCII-only symbols.\n\t * @returns {String} The resulting string of Unicode symbols.\n\t */\n\tfunction decode(input) {\n\t\t// Don't use UCS-2\n\t\tvar output = [],\n\t\t inputLength = input.length,\n\t\t out,\n\t\t i = 0,\n\t\t n = initialN,\n\t\t bias = initialBias,\n\t\t basic,\n\t\t j,\n\t\t index,\n\t\t oldi,\n\t\t w,\n\t\t k,\n\t\t digit,\n\t\t t,\n\t\t /** Cached calculation results */\n\t\t baseMinusT;\n\n\t\t// Handle the basic code points: let `basic` be the number of input code\n\t\t// points before the last delimiter, or `0` if there is none, then copy\n\t\t// the first basic code points to the output.\n\n\t\tbasic = input.lastIndexOf(delimiter);\n\t\tif (basic < 0) {\n\t\t\tbasic = 0;\n\t\t}\n\n\t\tfor (j = 0; j < basic; ++j) {\n\t\t\t// if it's not a basic code point\n\t\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\t\terror('not-basic');\n\t\t\t}\n\t\t\toutput.push(input.charCodeAt(j));\n\t\t}\n\n\t\t// Main decoding loop: start just after the last delimiter if any basic code\n\t\t// points were copied; start at the beginning otherwise.\n\n\t\tfor (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t\t// `index` is the index of the next character to be consumed.\n\t\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t\t// which gets added to `i`. The overflow checking is easier\n\t\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t\t// value at the end to obtain `delta`.\n\t\t\tfor (oldi = i, w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\t\tif (index >= inputLength) {\n\t\t\t\t\terror('invalid-input');\n\t\t\t\t}\n\n\t\t\t\tdigit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\t\tif (digit >= base || digit > floor((maxInt - i) / w)) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\ti += digit * w;\n\t\t\t\tt = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\t\tif (digit < t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbaseMinusT = base - t;\n\t\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\tw *= baseMinusT;\n\n\t\t\t}\n\n\t\t\tout = output.length + 1;\n\t\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t\t// incrementing `n` each time, so we'll fix that now:\n\t\t\tif (floor(i / out) > maxInt - n) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tn += floor(i / out);\n\t\t\ti %= out;\n\n\t\t\t// Insert `n` at position `i` of the output\n\t\t\toutput.splice(i++, 0, n);\n\n\t\t}\n\n\t\treturn ucs2encode(output);\n\t}\n\n\t/**\n\t * Converts a string of Unicode symbols (e.g. a domain name label) to a\n\t * Punycode string of ASCII-only symbols.\n\t * @memberOf punycode\n\t * @param {String} input The string of Unicode symbols.\n\t * @returns {String} The resulting Punycode string of ASCII-only symbols.\n\t */\n\tfunction encode(input) {\n\t\tvar n,\n\t\t delta,\n\t\t handledCPCount,\n\t\t basicLength,\n\t\t bias,\n\t\t j,\n\t\t m,\n\t\t q,\n\t\t k,\n\t\t t,\n\t\t currentValue,\n\t\t output = [],\n\t\t /** `inputLength` will hold the number of code points in `input`. */\n\t\t inputLength,\n\t\t /** Cached calculation results */\n\t\t handledCPCountPlusOne,\n\t\t baseMinusT,\n\t\t qMinusT;\n\n\t\t// Convert the input in UCS-2 to Unicode\n\t\tinput = ucs2decode(input);\n\n\t\t// Cache the length\n\t\tinputLength = input.length;\n\n\t\t// Initialize the state\n\t\tn = initialN;\n\t\tdelta = 0;\n\t\tbias = initialBias;\n\n\t\t// Handle the basic code points\n\t\tfor (j = 0; j < inputLength; ++j) {\n\t\t\tcurrentValue = input[j];\n\t\t\tif (currentValue < 0x80) {\n\t\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t\t}\n\t\t}\n\n\t\thandledCPCount = basicLength = output.length;\n\n\t\t// `handledCPCount` is the number of code points that have been handled;\n\t\t// `basicLength` is the number of basic code points.\n\n\t\t// Finish the basic string - if it is not empty - with a delimiter\n\t\tif (basicLength) {\n\t\t\toutput.push(delimiter);\n\t\t}\n\n\t\t// Main encoding loop:\n\t\twhile (handledCPCount < inputLength) {\n\n\t\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t\t// larger one:\n\t\t\tfor (m = maxInt, j = 0; j < inputLength; ++j) {\n\t\t\t\tcurrentValue = input[j];\n\t\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\t\tm = currentValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Increase `delta` enough to advance the decoder's state to ,\n\t\t\t// but guard against overflow\n\t\t\thandledCPCountPlusOne = handledCPCount + 1;\n\t\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\t\tn = m;\n\n\t\t\tfor (j = 0; j < inputLength; ++j) {\n\t\t\t\tcurrentValue = input[j];\n\n\t\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\tif (currentValue == n) {\n\t\t\t\t\t// Represent delta as a generalized variable-length integer\n\t\t\t\t\tfor (q = delta, k = base; /* no condition */; k += base) {\n\t\t\t\t\t\tt = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tqMinusT = q - t;\n\t\t\t\t\t\tbaseMinusT = base - t;\n\t\t\t\t\t\toutput.push(\n\t\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t\t);\n\t\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t\t}\n\n\t\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n\t\t\t\t\tdelta = 0;\n\t\t\t\t\t++handledCPCount;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t++delta;\n\t\t\t++n;\n\n\t\t}\n\t\treturn output.join('');\n\t}\n\n\t/**\n\t * Converts a Punycode string representing a domain name or an email address\n\t * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n\t * it doesn't matter if you call it on a string that has already been\n\t * converted to Unicode.\n\t * @memberOf punycode\n\t * @param {String} input The Punycoded domain name or email address to\n\t * convert to Unicode.\n\t * @returns {String} The Unicode representation of the given Punycode\n\t * string.\n\t */\n\tfunction toUnicode(input) {\n\t\treturn mapDomain(input, function(string) {\n\t\t\treturn regexPunycode.test(string)\n\t\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t\t: string;\n\t\t});\n\t}\n\n\t/**\n\t * Converts a Unicode string representing a domain name or an email address to\n\t * Punycode. Only the non-ASCII parts of the domain name will be converted,\n\t * i.e. it doesn't matter if you call it with a domain that's already in\n\t * ASCII.\n\t * @memberOf punycode\n\t * @param {String} input The domain name or email address to convert, as a\n\t * Unicode string.\n\t * @returns {String} The Punycode representation of the given domain name or\n\t * email address.\n\t */\n\tfunction toASCII(input) {\n\t\treturn mapDomain(input, function(string) {\n\t\t\treturn regexNonASCII.test(string)\n\t\t\t\t? 'xn--' + encode(string)\n\t\t\t\t: string;\n\t\t});\n\t}\n\n\t/*--------------------------------------------------------------------------*/\n\n\t/** Define the public API */\n\tpunycode = {\n\t\t/**\n\t\t * A string representing the current Punycode.js version number.\n\t\t * @memberOf punycode\n\t\t * @type String\n\t\t */\n\t\t'version': '1.3.2',\n\t\t/**\n\t\t * An object of methods to convert from JavaScript's internal character\n\t\t * representation (UCS-2) to Unicode code points, and back.\n\t\t * @see \n\t\t * @memberOf punycode\n\t\t * @type Object\n\t\t */\n\t\t'ucs2': {\n\t\t\t'decode': ucs2decode,\n\t\t\t'encode': ucs2encode\n\t\t},\n\t\t'decode': decode,\n\t\t'encode': encode,\n\t\t'toASCII': toASCII,\n\t\t'toUnicode': toUnicode\n\t};\n\n\t/** Expose `punycode` */\n\t// Some AMD build optimizers, like r.js, check for specific condition patterns\n\t// like the following:\n\tif (\n\t\ttypeof define == 'function' &&\n\t\ttypeof define.amd == 'object' &&\n\t\tdefine.amd\n\t) {\n\t\tdefine('punycode', function() {\n\t\t\treturn punycode;\n\t\t});\n\t} else if (freeExports && freeModule) {\n\t\tif (module.exports == freeExports) { // in Node.js or RingoJS v0.8.0+\n\t\t\tfreeModule.exports = punycode;\n\t\t} else { // in Narwhal or RingoJS v0.7.0-\n\t\t\tfor (key in punycode) {\n\t\t\t\tpunycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);\n\t\t\t}\n\t\t}\n\t} else { // in Rhino or a web browser\n\t\troot.punycode = punycode;\n\t}\n\n}(this));\n", "'use strict';\n\nmodule.exports = {\n isString: function(arg) {\n return typeof(arg) === 'string';\n },\n isObject: function(arg) {\n return typeof(arg) === 'object' && arg !== null;\n },\n isNull: function(arg) {\n return arg === null;\n },\n isNullOrUndefined: function(arg) {\n return arg == null;\n }\n};\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n// If obj.hasOwnProperty has been overridden, then calling\n// obj.hasOwnProperty(prop) will break.\n// See: https://github.com/joyent/node/issues/1707\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nmodule.exports = function(qs, sep, eq, options) {\n sep = sep || '&';\n eq = eq || '=';\n var obj = {};\n\n if (typeof qs !== 'string' || qs.length === 0) {\n return obj;\n }\n\n var regexp = /\\+/g;\n qs = qs.split(sep);\n\n var maxKeys = 1000;\n if (options && typeof options.maxKeys === 'number') {\n maxKeys = options.maxKeys;\n }\n\n var len = qs.length;\n // maxKeys <= 0 means that we should not limit keys count\n if (maxKeys > 0 && len > maxKeys) {\n len = maxKeys;\n }\n\n for (var i = 0; i < len; ++i) {\n var x = qs[i].replace(regexp, '%20'),\n idx = x.indexOf(eq),\n kstr, vstr, k, v;\n\n if (idx >= 0) {\n kstr = x.substr(0, idx);\n vstr = x.substr(idx + 1);\n } else {\n kstr = x;\n vstr = '';\n }\n\n k = decodeURIComponent(kstr);\n v = decodeURIComponent(vstr);\n\n if (!hasOwnProperty(obj, k)) {\n obj[k] = v;\n } else if (Array.isArray(obj[k])) {\n obj[k].push(v);\n } else {\n obj[k] = [obj[k], v];\n }\n }\n\n return obj;\n};\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar stringifyPrimitive = function(v) {\n switch (typeof v) {\n case 'string':\n return v;\n\n case 'boolean':\n return v ? 'true' : 'false';\n\n case 'number':\n return isFinite(v) ? v : '';\n\n default:\n return '';\n }\n};\n\nmodule.exports = function(obj, sep, eq, name) {\n sep = sep || '&';\n eq = eq || '=';\n if (obj === null) {\n obj = undefined;\n }\n\n if (typeof obj === 'object') {\n return Object.keys(obj).map(function(k) {\n var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;\n if (Array.isArray(obj[k])) {\n return obj[k].map(function(v) {\n return ks + encodeURIComponent(stringifyPrimitive(v));\n }).join(sep);\n } else {\n return ks + encodeURIComponent(stringifyPrimitive(obj[k]));\n }\n }).join(sep);\n\n }\n\n if (!name) return '';\n return encodeURIComponent(stringifyPrimitive(name)) + eq +\n encodeURIComponent(stringifyPrimitive(obj));\n};\n", "'use strict';\n\nexports.decode = exports.parse = require('./decode');\nexports.encode = exports.stringify = require('./encode');\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar punycode = require('punycode');\nvar util = require('./util');\n\nexports.parse = urlParse;\nexports.resolve = urlResolve;\nexports.resolveObject = urlResolveObject;\nexports.format = urlFormat;\n\nexports.Url = Url;\n\nfunction Url() {\n this.protocol = null;\n this.slashes = null;\n this.auth = null;\n this.host = null;\n this.port = null;\n this.hostname = null;\n this.hash = null;\n this.search = null;\n this.query = null;\n this.pathname = null;\n this.path = null;\n this.href = null;\n}\n\n// Reference: RFC 3986, RFC 1808, RFC 2396\n\n// define these here so at least they only have to be\n// compiled once on the first module load.\nvar protocolPattern = /^([a-z0-9.+-]+:)/i,\n portPattern = /:[0-9]*$/,\n\n // Special case for a simple path URL\n simplePathPattern = /^(\\/\\/?(?!\\/)[^\\?\\s]*)(\\?[^\\s]*)?$/,\n\n // RFC 2396: characters reserved for delimiting URLs.\n // We actually just auto-escape these.\n delims = ['<', '>', '\"', '`', ' ', '\\r', '\\n', '\\t'],\n\n // RFC 2396: characters not allowed for various reasons.\n unwise = ['{', '}', '|', '\\\\', '^', '`'].concat(delims),\n\n // Allowed by RFCs, but cause of XSS attacks. Always escape these.\n autoEscape = ['\\''].concat(unwise),\n // Characters that are never ever allowed in a hostname.\n // Note that any invalid chars are also handled, but these\n // are the ones that are *expected* to be seen, so we fast-path\n // them.\n nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),\n hostEndingChars = ['/', '?', '#'],\n hostnameMaxLen = 255,\n hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,\n hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,\n // protocols that can allow \"unsafe\" and \"unwise\" chars.\n unsafeProtocol = {\n 'javascript': true,\n 'javascript:': true\n },\n // protocols that never have a hostname.\n hostlessProtocol = {\n 'javascript': true,\n 'javascript:': true\n },\n // protocols that always contain a // bit.\n slashedProtocol = {\n 'http': true,\n 'https': true,\n 'ftp': true,\n 'gopher': true,\n 'file': true,\n 'http:': true,\n 'https:': true,\n 'ftp:': true,\n 'gopher:': true,\n 'file:': true\n },\n querystring = require('querystring');\n\nfunction urlParse(url, parseQueryString, slashesDenoteHost) {\n if (url && util.isObject(url) && url instanceof Url) return url;\n\n var u = new Url;\n u.parse(url, parseQueryString, slashesDenoteHost);\n return u;\n}\n\nUrl.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {\n if (!util.isString(url)) {\n throw new TypeError(\"Parameter 'url' must be a string, not \" + typeof url);\n }\n\n // Copy chrome, IE, opera backslash-handling behavior.\n // Back slashes before the query string get converted to forward slashes\n // See: https://code.google.com/p/chromium/issues/detail?id=25916\n var queryIndex = url.indexOf('?'),\n splitter =\n (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',\n uSplit = url.split(splitter),\n slashRegex = /\\\\/g;\n uSplit[0] = uSplit[0].replace(slashRegex, '/');\n url = uSplit.join(splitter);\n\n var rest = url;\n\n // trim before proceeding.\n // This is to support parse stuff like \" http://foo.com \\n\"\n rest = rest.trim();\n\n if (!slashesDenoteHost && url.split('#').length === 1) {\n // Try fast path regexp\n var simplePath = simplePathPattern.exec(rest);\n if (simplePath) {\n this.path = rest;\n this.href = rest;\n this.pathname = simplePath[1];\n if (simplePath[2]) {\n this.search = simplePath[2];\n if (parseQueryString) {\n this.query = querystring.parse(this.search.substr(1));\n } else {\n this.query = this.search.substr(1);\n }\n } else if (parseQueryString) {\n this.search = '';\n this.query = {};\n }\n return this;\n }\n }\n\n var proto = protocolPattern.exec(rest);\n if (proto) {\n proto = proto[0];\n var lowerProto = proto.toLowerCase();\n this.protocol = lowerProto;\n rest = rest.substr(proto.length);\n }\n\n // figure out if it's got a host\n // user@server is *always* interpreted as a hostname, and url\n // resolution will treat //foo/bar as host=foo,path=bar because that's\n // how the browser resolves relative URLs.\n if (slashesDenoteHost || proto || rest.match(/^\\/\\/[^@\\/]+@[^@\\/]+/)) {\n var slashes = rest.substr(0, 2) === '//';\n if (slashes && !(proto && hostlessProtocol[proto])) {\n rest = rest.substr(2);\n this.slashes = true;\n }\n }\n\n if (!hostlessProtocol[proto] &&\n (slashes || (proto && !slashedProtocol[proto]))) {\n\n // there's a hostname.\n // the first instance of /, ?, ;, or # ends the host.\n //\n // If there is an @ in the hostname, then non-host chars *are* allowed\n // to the left of the last @ sign, unless some host-ending character\n // comes *before* the @-sign.\n // URLs are obnoxious.\n //\n // ex:\n // http://a@b@c/ => user:a@b host:c\n // http://a@b?@c => user:a host:c path:/?@c\n\n // v0.12 TODO(isaacs): This is not quite how Chrome does things.\n // Review our test case against browsers more comprehensively.\n\n // find the first instance of any hostEndingChars\n var hostEnd = -1;\n for (var i = 0; i < hostEndingChars.length; i++) {\n var hec = rest.indexOf(hostEndingChars[i]);\n if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))\n hostEnd = hec;\n }\n\n // at this point, either we have an explicit point where the\n // auth portion cannot go past, or the last @ char is the decider.\n var auth, atSign;\n if (hostEnd === -1) {\n // atSign can be anywhere.\n atSign = rest.lastIndexOf('@');\n } else {\n // atSign must be in auth portion.\n // http://a@b/c@d => host:b auth:a path:/c@d\n atSign = rest.lastIndexOf('@', hostEnd);\n }\n\n // Now we have a portion which is definitely the auth.\n // Pull that off.\n if (atSign !== -1) {\n auth = rest.slice(0, atSign);\n rest = rest.slice(atSign + 1);\n this.auth = decodeURIComponent(auth);\n }\n\n // the host is the remaining to the left of the first non-host char\n hostEnd = -1;\n for (var i = 0; i < nonHostChars.length; i++) {\n var hec = rest.indexOf(nonHostChars[i]);\n if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))\n hostEnd = hec;\n }\n // if we still have not hit it, then the entire thing is a host.\n if (hostEnd === -1)\n hostEnd = rest.length;\n\n this.host = rest.slice(0, hostEnd);\n rest = rest.slice(hostEnd);\n\n // pull out port.\n this.parseHost();\n\n // we've indicated that there is a hostname,\n // so even if it's empty, it has to be present.\n this.hostname = this.hostname || '';\n\n // if hostname begins with [ and ends with ]\n // assume that it's an IPv6 address.\n var ipv6Hostname = this.hostname[0] === '[' &&\n this.hostname[this.hostname.length - 1] === ']';\n\n // validate a little.\n if (!ipv6Hostname) {\n var hostparts = this.hostname.split(/\\./);\n for (var i = 0, l = hostparts.length; i < l; i++) {\n var part = hostparts[i];\n if (!part) continue;\n if (!part.match(hostnamePartPattern)) {\n var newpart = '';\n for (var j = 0, k = part.length; j < k; j++) {\n if (part.charCodeAt(j) > 127) {\n // we replace non-ASCII char with a temporary placeholder\n // we need this to make sure size of hostname is not\n // broken by replacing non-ASCII by nothing\n newpart += 'x';\n } else {\n newpart += part[j];\n }\n }\n // we test again with ASCII char only\n if (!newpart.match(hostnamePartPattern)) {\n var validParts = hostparts.slice(0, i);\n var notHost = hostparts.slice(i + 1);\n var bit = part.match(hostnamePartStart);\n if (bit) {\n validParts.push(bit[1]);\n notHost.unshift(bit[2]);\n }\n if (notHost.length) {\n rest = '/' + notHost.join('.') + rest;\n }\n this.hostname = validParts.join('.');\n break;\n }\n }\n }\n }\n\n if (this.hostname.length > hostnameMaxLen) {\n this.hostname = '';\n } else {\n // hostnames are always lower case.\n this.hostname = this.hostname.toLowerCase();\n }\n\n if (!ipv6Hostname) {\n // IDNA Support: Returns a punycoded representation of \"domain\".\n // It only converts parts of the domain name that\n // have non-ASCII characters, i.e. it doesn't matter if\n // you call it with a domain that already is ASCII-only.\n this.hostname = punycode.toASCII(this.hostname);\n }\n\n var p = this.port ? ':' + this.port : '';\n var h = this.hostname || '';\n this.host = h + p;\n this.href += this.host;\n\n // strip [ and ] from the hostname\n // the host field still retains them, though\n if (ipv6Hostname) {\n this.hostname = this.hostname.substr(1, this.hostname.length - 2);\n if (rest[0] !== '/') {\n rest = '/' + rest;\n }\n }\n }\n\n // now rest is set to the post-host stuff.\n // chop off any delim chars.\n if (!unsafeProtocol[lowerProto]) {\n\n // First, make 100% sure that any \"autoEscape\" chars get\n // escaped, even if encodeURIComponent doesn't think they\n // need to be.\n for (var i = 0, l = autoEscape.length; i < l; i++) {\n var ae = autoEscape[i];\n if (rest.indexOf(ae) === -1)\n continue;\n var esc = encodeURIComponent(ae);\n if (esc === ae) {\n esc = escape(ae);\n }\n rest = rest.split(ae).join(esc);\n }\n }\n\n\n // chop off from the tail first.\n var hash = rest.indexOf('#');\n if (hash !== -1) {\n // got a fragment string.\n this.hash = rest.substr(hash);\n rest = rest.slice(0, hash);\n }\n var qm = rest.indexOf('?');\n if (qm !== -1) {\n this.search = rest.substr(qm);\n this.query = rest.substr(qm + 1);\n if (parseQueryString) {\n this.query = querystring.parse(this.query);\n }\n rest = rest.slice(0, qm);\n } else if (parseQueryString) {\n // no query string, but parseQueryString still requested\n this.search = '';\n this.query = {};\n }\n if (rest) this.pathname = rest;\n if (slashedProtocol[lowerProto] &&\n this.hostname && !this.pathname) {\n this.pathname = '/';\n }\n\n //to support http.request\n if (this.pathname || this.search) {\n var p = this.pathname || '';\n var s = this.search || '';\n this.path = p + s;\n }\n\n // finally, reconstruct the href based on what has been validated.\n this.href = this.format();\n return this;\n};\n\n// format a parsed object into a url string\nfunction urlFormat(obj) {\n // ensure it's an object, and not a string url.\n // If it's an obj, this is a no-op.\n // this way, you can call url_format() on strings\n // to clean up potentially wonky urls.\n if (util.isString(obj)) obj = urlParse(obj);\n if (!(obj instanceof Url)) return Url.prototype.format.call(obj);\n return obj.format();\n}\n\nUrl.prototype.format = function() {\n var auth = this.auth || '';\n if (auth) {\n auth = encodeURIComponent(auth);\n auth = auth.replace(/%3A/i, ':');\n auth += '@';\n }\n\n var protocol = this.protocol || '',\n pathname = this.pathname || '',\n hash = this.hash || '',\n host = false,\n query = '';\n\n if (this.host) {\n host = auth + this.host;\n } else if (this.hostname) {\n host = auth + (this.hostname.indexOf(':') === -1 ?\n this.hostname :\n '[' + this.hostname + ']');\n if (this.port) {\n host += ':' + this.port;\n }\n }\n\n if (this.query &&\n util.isObject(this.query) &&\n Object.keys(this.query).length) {\n query = querystring.stringify(this.query);\n }\n\n var search = this.search || (query && ('?' + query)) || '';\n\n if (protocol && protocol.substr(-1) !== ':') protocol += ':';\n\n // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.\n // unless they had them to begin with.\n if (this.slashes ||\n (!protocol || slashedProtocol[protocol]) && host !== false) {\n host = '//' + (host || '');\n if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;\n } else if (!host) {\n host = '';\n }\n\n if (hash && hash.charAt(0) !== '#') hash = '#' + hash;\n if (search && search.charAt(0) !== '?') search = '?' + search;\n\n pathname = pathname.replace(/[?#]/g, function(match) {\n return encodeURIComponent(match);\n });\n search = search.replace('#', '%23');\n\n return protocol + host + pathname + search + hash;\n};\n\nfunction urlResolve(source, relative) {\n return urlParse(source, false, true).resolve(relative);\n}\n\nUrl.prototype.resolve = function(relative) {\n return this.resolveObject(urlParse(relative, false, true)).format();\n};\n\nfunction urlResolveObject(source, relative) {\n if (!source) return relative;\n return urlParse(source, false, true).resolveObject(relative);\n}\n\nUrl.prototype.resolveObject = function(relative) {\n if (util.isString(relative)) {\n var rel = new Url();\n rel.parse(relative, false, true);\n relative = rel;\n }\n\n var result = new Url();\n var tkeys = Object.keys(this);\n for (var tk = 0; tk < tkeys.length; tk++) {\n var tkey = tkeys[tk];\n result[tkey] = this[tkey];\n }\n\n // hash is always overridden, no matter what.\n // even href=\"\" will remove it.\n result.hash = relative.hash;\n\n // if the relative url is empty, then there's nothing left to do here.\n if (relative.href === '') {\n result.href = result.format();\n return result;\n }\n\n // hrefs like //foo/bar always cut to the protocol.\n if (relative.slashes && !relative.protocol) {\n // take everything except the protocol from relative\n var rkeys = Object.keys(relative);\n for (var rk = 0; rk < rkeys.length; rk++) {\n var rkey = rkeys[rk];\n if (rkey !== 'protocol')\n result[rkey] = relative[rkey];\n }\n\n //urlParse appends trailing / to urls like http://www.example.com\n if (slashedProtocol[result.protocol] &&\n result.hostname && !result.pathname) {\n result.path = result.pathname = '/';\n }\n\n result.href = result.format();\n return result;\n }\n\n if (relative.protocol && relative.protocol !== result.protocol) {\n // if it's a known url protocol, then changing\n // the protocol does weird things\n // first, if it's not file:, then we MUST have a host,\n // and if there was a path\n // to begin with, then we MUST have a path.\n // if it is file:, then the host is dropped,\n // because that's known to be hostless.\n // anything else is assumed to be absolute.\n if (!slashedProtocol[relative.protocol]) {\n var keys = Object.keys(relative);\n for (var v = 0; v < keys.length; v++) {\n var k = keys[v];\n result[k] = relative[k];\n }\n result.href = result.format();\n return result;\n }\n\n result.protocol = relative.protocol;\n if (!relative.host && !hostlessProtocol[relative.protocol]) {\n var relPath = (relative.pathname || '').split('/');\n while (relPath.length && !(relative.host = relPath.shift()));\n if (!relative.host) relative.host = '';\n if (!relative.hostname) relative.hostname = '';\n if (relPath[0] !== '') relPath.unshift('');\n if (relPath.length < 2) relPath.unshift('');\n result.pathname = relPath.join('/');\n } else {\n result.pathname = relative.pathname;\n }\n result.search = relative.search;\n result.query = relative.query;\n result.host = relative.host || '';\n result.auth = relative.auth;\n result.hostname = relative.hostname || relative.host;\n result.port = relative.port;\n // to support http.request\n if (result.pathname || result.search) {\n var p = result.pathname || '';\n var s = result.search || '';\n result.path = p + s;\n }\n result.slashes = result.slashes || relative.slashes;\n result.href = result.format();\n return result;\n }\n\n var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),\n isRelAbs = (\n relative.host ||\n relative.pathname && relative.pathname.charAt(0) === '/'\n ),\n mustEndAbs = (isRelAbs || isSourceAbs ||\n (result.host && relative.pathname)),\n removeAllDots = mustEndAbs,\n srcPath = result.pathname && result.pathname.split('/') || [],\n relPath = relative.pathname && relative.pathname.split('/') || [],\n psychotic = result.protocol && !slashedProtocol[result.protocol];\n\n // if the url is a non-slashed url, then relative\n // links like ../.. should be able\n // to crawl up to the hostname, as well. This is strange.\n // result.protocol has already been set by now.\n // Later on, put the first path part into the host field.\n if (psychotic) {\n result.hostname = '';\n result.port = null;\n if (result.host) {\n if (srcPath[0] === '') srcPath[0] = result.host;\n else srcPath.unshift(result.host);\n }\n result.host = '';\n if (relative.protocol) {\n relative.hostname = null;\n relative.port = null;\n if (relative.host) {\n if (relPath[0] === '') relPath[0] = relative.host;\n else relPath.unshift(relative.host);\n }\n relative.host = null;\n }\n mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');\n }\n\n if (isRelAbs) {\n // it's absolute.\n result.host = (relative.host || relative.host === '') ?\n relative.host : result.host;\n result.hostname = (relative.hostname || relative.hostname === '') ?\n relative.hostname : result.hostname;\n result.search = relative.search;\n result.query = relative.query;\n srcPath = relPath;\n // fall through to the dot-handling below.\n } else if (relPath.length) {\n // it's relative\n // throw away the existing file, and take the new path instead.\n if (!srcPath) srcPath = [];\n srcPath.pop();\n srcPath = srcPath.concat(relPath);\n result.search = relative.search;\n result.query = relative.query;\n } else if (!util.isNullOrUndefined(relative.search)) {\n // just pull out the search.\n // like href='?foo'.\n // Put this after the other two cases because it simplifies the booleans\n if (psychotic) {\n result.hostname = result.host = srcPath.shift();\n //occationaly the auth can get stuck only in host\n //this especially happens in cases like\n //url.resolveObject('mailto:local1@domain1', 'local2@domain2')\n var authInHost = result.host && result.host.indexOf('@') > 0 ?\n result.host.split('@') : false;\n if (authInHost) {\n result.auth = authInHost.shift();\n result.host = result.hostname = authInHost.shift();\n }\n }\n result.search = relative.search;\n result.query = relative.query;\n //to support http.request\n if (!util.isNull(result.pathname) || !util.isNull(result.search)) {\n result.path = (result.pathname ? result.pathname : '') +\n (result.search ? result.search : '');\n }\n result.href = result.format();\n return result;\n }\n\n if (!srcPath.length) {\n // no path at all. easy.\n // we've already handled the other stuff above.\n result.pathname = null;\n //to support http.request\n if (result.search) {\n result.path = '/' + result.search;\n } else {\n result.path = null;\n }\n result.href = result.format();\n return result;\n }\n\n // if a url ENDs in . or .., then it must get a trailing slash.\n // however, if it ends in anything else non-slashy,\n // then it must NOT get a trailing slash.\n var last = srcPath.slice(-1)[0];\n var hasTrailingSlash = (\n (result.host || relative.host || srcPath.length > 1) &&\n (last === '.' || last === '..') || last === '');\n\n // strip single dots, resolve double dots to parent dir\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = srcPath.length; i >= 0; i--) {\n last = srcPath[i];\n if (last === '.') {\n srcPath.splice(i, 1);\n } else if (last === '..') {\n srcPath.splice(i, 1);\n up++;\n } else if (up) {\n srcPath.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (!mustEndAbs && !removeAllDots) {\n for (; up--; up) {\n srcPath.unshift('..');\n }\n }\n\n if (mustEndAbs && srcPath[0] !== '' &&\n (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {\n srcPath.unshift('');\n }\n\n if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {\n srcPath.push('');\n }\n\n var isAbsolute = srcPath[0] === '' ||\n (srcPath[0] && srcPath[0].charAt(0) === '/');\n\n // put the host back\n if (psychotic) {\n result.hostname = result.host = isAbsolute ? '' :\n srcPath.length ? srcPath.shift() : '';\n //occationaly the auth can get stuck only in host\n //this especially happens in cases like\n //url.resolveObject('mailto:local1@domain1', 'local2@domain2')\n var authInHost = result.host && result.host.indexOf('@') > 0 ?\n result.host.split('@') : false;\n if (authInHost) {\n result.auth = authInHost.shift();\n result.host = result.hostname = authInHost.shift();\n }\n }\n\n mustEndAbs = mustEndAbs || (result.host && srcPath.length);\n\n if (mustEndAbs && !isAbsolute) {\n srcPath.unshift('');\n }\n\n if (!srcPath.length) {\n result.pathname = null;\n result.path = null;\n } else {\n result.pathname = srcPath.join('/');\n }\n\n //to support request.http\n if (!util.isNull(result.pathname) || !util.isNull(result.search)) {\n result.path = (result.pathname ? result.pathname : '') +\n (result.search ? result.search : '');\n }\n result.auth = relative.auth || result.auth;\n result.slashes = result.slashes || relative.slashes;\n result.href = result.format();\n return result;\n};\n\nUrl.prototype.parseHost = function() {\n var host = this.host;\n var port = portPattern.exec(host);\n if (port) {\n port = port[0];\n if (port !== ':') {\n this.port = port.substr(1);\n }\n host = host.substr(0, host.length - port.length);\n }\n if (host) this.hostname = host;\n};\n", "export * from './Area';\nexport * from './AreaAllocator';\nexport * from './AtlasAllocator';\nexport * from './AtlasResource';\nexport * from './CanvasTextureAllocator';\nexport * from './GuilloteneAllocator';\nexport * from './RenderTextureAllocator';\nexport * from './TextureAllocator';\nexport * from './TextureSlab';", "/**\n * The orientation of an area indicates the axis along which it is split. This is a 1-bit field.\n *\n * @public\n */\nexport enum AreaOrientation {\n HORIZONTAL = 0,\n VERTICAL = 1\n};\n\n/**\n * Alias for the 31-bit field texture-area type.\n *\n * @public\n */\nexport type AreaField = number;\n\n/**\n * An area represents an oriented rectangular region. It is implemented as a 31-bit field. The open/close edges are\n * specified along its parent's orientation axis, i.e. if the parent is horizontal, the left and right edges are defined,\n * else if the parent is vertical, the top and bottom edges are defined. Similarly, the open/close edges of its\n * children will be along its own orientation axis.\n *\n * The orientation axes flip-flop along the hierarchy, i.e. an area's parent's orientation is always opposite to\n * the area's own orientation. This is because if the orientation were to be same, the area's children could be\n * \"pulled up\" to the parent making itself redundant.\n *\n * All four edges of an area can be retrieved from it and its parent.\n *\n *
\n * \n *
\n *
Field
\n *
Bits
\n *
Description
\n *
\n * \n * \n *
\n *
OPEN_OFFSET
\n *
0-14
\n *
\n * The offset along the parent's axis at which the area begins. If orientation is horizontal,\n * this is the left edge. If orientation is vertical, this is the top edge.\n *
\n *
\n *
\n *
CLOSE_OFFSET
\n *
15-29
\n *
\n * The offset along the parent's axis at which the area ends. If orientation is horizontal,\n * this is the right edge. If orientation is vertical, this is the bottom edge.\n *
\n *
\n *
\n *
ORIENTATION
\n *
30
\n *
\n * The orientation of the area, which indicates the axis along it is split. The open and close\n * offsets of its children are along this axis. See {@link AreaOrientation}.\n *
\n *
\n * \n *
\n *\n * @public\n */\nexport class Area\n{\n static makeArea(openOffset: number, closeOffset: number, orientation: number): number\n {\n return openOffset | (closeOffset << 15) | (orientation << 30);\n }\n\n static getOpenOffset(area: AreaField): number\n {\n return area & ((1 << 15) - 1);\n }\n\n static getCloseOffset(area: AreaField): number\n {\n return (area >> 15) & ((1 << 15) - 1);\n }\n\n static getOrientation(area: AreaField): AreaOrientation\n {\n return (area >> 30) & 1;\n }\n\n static setOpenOffset(area: AreaField, offset: number): number\n {\n return Area.makeArea(\n offset,\n Area.getCloseOffset(area),\n Area.getOrientation(area)\n );\n }\n\n static setCloseOffset(area: AreaField, offset: number): number\n {\n return Area.makeArea(\n Area.getOpenOffset(offset),\n offset,\n Area.getOrientation(area)\n );\n }\n}", "/**\n * Different types of environments for WebGL.\n * @static\n * @memberof PIXI\n * @enum {number}\n */\nexport enum ENV\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Used for older v1 WebGL devices. PixiJS will aim to ensure compatibility\n * with older / less advanced devices. If you experience unexplained flickering prefer this environment.\n * @default 0\n */\n WEBGL_LEGACY,\n /**\n * Version 1 of WebGL\n * @default 1\n */\n WEBGL,\n /**\n * Version 2 of WebGL\n * @default 2\n */\n WEBGL2,\n}\n\n/**\n * Constant to identify the Renderer Type.\n * @static\n * @memberof PIXI\n * @enum {number}\n */\nexport enum RENDERER_TYPE\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Unknown render type.\n * @default 0\n */\n UNKNOWN,\n /**\n * WebGL render type.\n * @default 1\n */\n WEBGL,\n /**\n * Canvas render type.\n * @default 2\n */\n CANVAS,\n}\n\n/**\n * Bitwise OR of masks that indicate the buffers to be cleared.\n * @static\n * @memberof PIXI\n * @enum {number}\n */\nexport enum BUFFER_BITS\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Indicates the buffers currently enabled for color writing.\n * @default 0x00004000\n */\n COLOR = 0x00004000,\n /**\n * Indicates the depth buffer.\n * @default 0x00000100\n */\n DEPTH = 0x00000100,\n /**\n * Indicates the stencil buffer.\n * @default 0x00000400\n */\n STENCIL = 0x00000400\n}\n\n/**\n * Various blend modes supported by PIXI.\n *\n * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.\n * Anything else will silently act like NORMAL.\n * @memberof PIXI\n * @enum {number}\n */\nexport enum BLEND_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * @default 0\n */\n NORMAL = 0,\n /**\n * @default 1\n */\n ADD = 1,\n /**\n * The pixels of the top layer are multiplied with the corresponding pixel of the bottom layer.\n * A darker picture is the result.\n * @default 2\n */\n MULTIPLY = 2,\n /**\n * The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)\n * @default 3\n */\n SCREEN = 3,\n /**\n * A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter.\n *\n * Canvas Renderer only.\n * @default 4\n */\n OVERLAY = 4,\n /**\n * Retains the darkest pixels of both layers.\n *\n * Canvas Renderer only.\n * @default 5\n */\n DARKEN = 5,\n /**\n * Retains the lightest pixels of both layers.\n *\n * Canvas Renderer only.\n * @default 6\n */\n LIGHTEN = 6,\n /**\n * Divides the bottom layer by the inverted top layer.\n *\n * Canvas Renderer only.\n * @default 7\n */\n COLOR_DODGE = 7,\n /**\n * Divides the inverted bottom layer by the top layer, and then inverts the result.\n *\n * Canvas Renderer only.\n * @default 8\n */\n COLOR_BURN = 8,\n /**\n * A combination of multiply and screen like overlay, but with top and bottom layer swapped.\n *\n * Canvas Renderer only.\n * @default 9\n */\n HARD_LIGHT = 9,\n /**\n * A softer version of hard-light. Pure black or white does not result in pure black or white.\n *\n * Canvas Renderer only.\n * @default 10\n */\n SOFT_LIGHT = 10,\n /**\n * Subtracts the bottom layer from the top layer or the other way round to always get a positive value.\n *\n * Canvas Renderer only.\n * @default 11\n */\n DIFFERENCE = 11,\n /**\n * Like difference, but with lower contrast.\n *\n * Canvas Renderer only.\n * @default 12\n */\n EXCLUSION = 12,\n /**\n * Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer.\n *\n * Canvas Renderer only.\n * @default 13\n */\n HUE = 13,\n /**\n * Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer.\n *\n * Canvas Renderer only.\n * @default 14\n */\n SATURATION = 14,\n /**\n * Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer.\n *\n * Canvas Renderer only.\n * @default 15\n */\n COLOR = 15,\n /**\n * Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer.\n *\n * Canvas Renderer only.\n * @default 16\n */\n LUMINOSITY = 16,\n /**\n * @default 17\n */\n NORMAL_NPM = 17,\n /**\n * @default 18\n */\n ADD_NPM = 18,\n /**\n * @default 19\n */\n SCREEN_NPM = 19,\n /**\n * @default 20\n */\n NONE = 20,\n\n /**\n * Draws new shapes on top of the existing canvas content.\n * @default 0\n */\n SRC_OVER = 0,\n /**\n * The new shape is drawn only where both the new shape and the destination canvas overlap.\n * Everything else is made transparent.\n * @default 21\n */\n SRC_IN = 21,\n /**\n * The new shape is drawn where it doesn't overlap the existing canvas content.\n * @default 22\n */\n SRC_OUT = 22,\n /**\n * The new shape is only drawn where it overlaps the existing canvas content.\n * @default 23\n */\n SRC_ATOP = 23,\n /**\n * New shapes are drawn behind the existing canvas content.\n * @default 24\n */\n DST_OVER = 24,\n /**\n * The existing canvas content is kept where both the new shape and existing canvas content overlap.\n * Everything else is made transparent.\n * @default 25\n */\n DST_IN = 25,\n /**\n * The existing content is kept where it doesn't overlap the new shape.\n * @default 26\n */\n DST_OUT = 26,\n /**\n * The existing canvas is only kept where it overlaps the new shape. The new shape is drawn behind the canvas content.\n * @default 27\n */\n DST_ATOP = 27,\n /**\n * @default 26\n */\n ERASE = 26,\n /**\n * @default 28\n */\n SUBTRACT = 28,\n /**\n * Shapes are made transparent where both overlap and drawn normal everywhere else.\n * @default 29\n */\n XOR = 29,\n}\n\n/**\n * Various webgl draw modes. These can be used to specify which GL drawMode to use\n * under certain situations and renderers.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum DRAW_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * To draw a series of points.\n * @default 0\n */\n POINTS,\n /**\n * To draw a series of unconnected line segments (individual lines).\n * @default 1\n */\n LINES,\n /**\n * To draw a series of connected line segments. It also joins the first and last vertices to form a loop.\n * @default 2\n */\n LINE_LOOP,\n /**\n * To draw a series of connected line segments.\n * @default 3\n */\n LINE_STRIP,\n /**\n * To draw a series of separate triangles.\n * @default 4\n */\n TRIANGLES,\n /**\n * To draw a series of connected triangles in strip fashion.\n * @default 5\n */\n TRIANGLE_STRIP,\n /**\n * To draw a series of connected triangles sharing the first vertex in a fan-like fashion.\n * @default 6\n */\n TRIANGLE_FAN,\n}\n\n/**\n * Various GL texture/resources formats.\n * @memberof PIXI\n * @static\n * @name FORMATS\n * @enum {number}\n */\nexport enum FORMATS\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * @default 6408\n */\n RGBA = 6408,\n /**\n * @default 6407\n */\n RGB = 6407,\n /**\n * @default 33319\n */\n RG = 33319,\n /**\n * @default 6403\n */\n RED = 6403,\n /**\n * @default 36249\n */\n RGBA_INTEGER = 36249,\n /**\n * @default 36248\n */\n RGB_INTEGER = 36248,\n /**\n * @default 33320\n */\n RG_INTEGER = 33320,\n /**\n * @default 36244\n */\n RED_INTEGER = 36244,\n /**\n * @default 6406\n */\n ALPHA = 6406,\n /**\n * @default 6409\n */\n LUMINANCE = 6409,\n /**\n * @default 6410\n */\n LUMINANCE_ALPHA = 6410,\n /**\n * @default 6402\n */\n DEPTH_COMPONENT = 6402,\n /**\n * @default 34041\n */\n DEPTH_STENCIL = 34041,\n}\n\n/**\n * Various GL target types.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum TARGETS\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * A two-dimensional texture\n * @default 3553\n */\n TEXTURE_2D = 3553,\n /**\n * A cube-mapped texture. When using a WebGL 2 context, the following values are available additionally:\n * - gl.TEXTURE_3D: A three-dimensional texture.\n * - gl.TEXTURE_2D_ARRAY: A two-dimensional array texture.\n * @default 34067\n */\n TEXTURE_CUBE_MAP = 34067,\n /**\n * A two-dimensional array texture.\n * @default 35866\n */\n TEXTURE_2D_ARRAY = 35866,\n /**\n * Positive X face for a cube-mapped texture.\n * @default 34069\n */\n TEXTURE_CUBE_MAP_POSITIVE_X = 34069,\n /**\n * Negative X face for a cube-mapped texture.\n * @default 34070\n */\n TEXTURE_CUBE_MAP_NEGATIVE_X = 34070,\n /**\n * Positive Y face for a cube-mapped texture.\n * @default 34071\n */\n TEXTURE_CUBE_MAP_POSITIVE_Y = 34071,\n /**\n * Negative Y face for a cube-mapped texture.\n * @default 34072\n */\n TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072,\n /**\n * Positive Z face for a cube-mapped texture.\n * @default 34073\n */\n TEXTURE_CUBE_MAP_POSITIVE_Z = 34073,\n /**\n * Negative Z face for a cube-mapped texture.\n * @default 34074\n */\n TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074,\n}\n\n/**\n * Various GL data format types.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum TYPES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * 8 bits per channel for gl.RGBA\n * @default 5121\n */\n UNSIGNED_BYTE = 5121,\n /**\n * @default 5123\n */\n UNSIGNED_SHORT = 5123,\n /**\n * 5 red bits, 6 green bits, 5 blue bits.\n * @default 33635\n */\n UNSIGNED_SHORT_5_6_5 = 33635,\n /**\n * 4 red bits, 4 green bits, 4 blue bits, 4 alpha bits.\n * @default 32819\n */\n UNSIGNED_SHORT_4_4_4_4 = 32819,\n /**\n * 5 red bits, 5 green bits, 5 blue bits, 1 alpha bit.\n * @default 32820\n */\n UNSIGNED_SHORT_5_5_5_1 = 32820,\n /**\n * @default 5125\n */\n UNSIGNED_INT = 5125,\n /**\n * @default 35899\n */\n UNSIGNED_INT_10F_11F_11F_REV = 35899,\n /**\n * @default 33640\n */\n UNSIGNED_INT_2_10_10_10_REV = 33640,\n /**\n * @default 34042\n */\n UNSIGNED_INT_24_8 = 34042,\n /**\n * @default 35902\n */\n UNSIGNED_INT_5_9_9_9_REV = 35902,\n /**\n * @default 5120\n */\n BYTE = 5120,\n /**\n * @default 5122\n */\n SHORT = 5122,\n /**\n * @default 5124\n */\n INT = 5124,\n /**\n * @default 5126\n */\n FLOAT = 5126,\n /**\n * @default 36269\n */\n FLOAT_32_UNSIGNED_INT_24_8_REV = 36269,\n /**\n * @default 36193\n */\n HALF_FLOAT = 36193,\n}\n\n/**\n * Various sampler types. Correspond to `sampler`, `isampler`, `usampler` GLSL types respectively.\n * WebGL1 works only with FLOAT.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum SAMPLER_TYPES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * @default 0\n */\n FLOAT = 0,\n /**\n * @default 1\n */\n INT = 1,\n /**\n * @default 2\n */\n UINT = 2,\n}\n\n/**\n * The scale modes that are supported by pixi.\n *\n * The {@link PIXI.BaseTexture.defaultOptions.scaleMode} scale mode affects the default scaling mode of future operations.\n * It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum SCALE_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Pixelating scaling\n * @default 0\n */\n NEAREST,\n /**\n * Smooth scaling\n * @default 1\n */\n LINEAR,\n}\n\n/**\n * The wrap modes that are supported by pixi.\n *\n * The wrap mode affects the default wrapping mode of future operations.\n * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability.\n * If the texture is non power of two then clamp will be used regardless as WebGL can\n * only use REPEAT if the texture is po2.\n *\n * This property only affects WebGL.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum WRAP_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * The textures uvs are clamped\n * @default 33071\n */\n CLAMP = 33071,\n /**\n * The texture uvs tile and repeat\n * @default 10497\n */\n REPEAT = 10497,\n /**\n * The texture uvs tile and repeat with mirroring\n * @default 33648\n */\n MIRRORED_REPEAT = 33648,\n}\n\n/**\n * Mipmap filtering modes that are supported by pixi.\n *\n * The {@link PIXI.BaseTexture.defaultOptions.mipmap} affects default texture filtering.\n * Mipmaps are generated for a baseTexture if its `mipmap` field is `ON`,\n * or its `POW2` and texture dimensions are powers of 2.\n * Since WebGL 1 don't support mipmap for non-power-of-two textures,\n * `ON` option will work like `POW2` for WebGL 1.\n *\n * This property only affects WebGL.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum MIPMAP_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * No mipmaps.\n * @default 0\n */\n OFF,\n /**\n * Generate mipmaps if texture dimensions are powers of 2.\n * @default 1\n */\n POW2,\n /**\n * Always generate mipmaps.\n * @default 2\n */\n ON,\n /**\n * Use mipmaps, but do not auto-generate them.\n * this is used with a resource that supports buffering each level-of-detail.\n * @default 3\n */\n ON_MANUAL,\n}\n\n/**\n * How to treat textures with premultiplied alpha\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum ALPHA_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Alias for NO_PREMULTIPLIED_ALPHA.\n * @type {number}\n * @default 0\n */\n NPM = 0,\n /**\n * Default option, alias for PREMULTIPLY_ON_UPLOAD.\n * @type {number}\n * @default 1\n */\n UNPACK = 1,\n /**\n * Alias for PREMULTIPLIED_ALPHA.\n * @type {number}\n * @default 2\n */\n PMA = 2,\n /**\n * Source is not premultiplied, leave it like that.\n * Option for compressed and data textures that are created from typed arrays.\n * @type {number}\n * @default 0\n */\n NO_PREMULTIPLIED_ALPHA = 0,\n /**\n * Source is not premultiplied, premultiply on upload.\n * Default option, used for all loaded images.\n * @type {number}\n * @default 1\n */\n PREMULTIPLY_ON_UPLOAD = 1,\n /**\n * Source is already premultiplied. Example: spine atlases with `_pma` suffix.\n * @type {number}\n * @default 2\n */\n PREMULTIPLIED_ALPHA = 2,\n}\n\n/**\n * Configure whether filter textures are cleared after binding.\n *\n * Filter textures need not be cleared if the filter does not use pixel blending. {@link PIXI.CLEAR_MODES.BLIT} will detect\n * this and skip clearing as an optimization.\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum CLEAR_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Alias for BLEND, same as `false` in earlier versions\n * @default 0\n */\n NO = 0,\n /**\n * Alias for CLEAR, same as `true` in earlier versions\n * @default 1\n */\n YES = 1,\n /**\n * Alias for BLIT\n * @default 2\n */\n AUTO = 2,\n /**\n * Do not clear the filter texture. The filter's output will blend on top of the output texture.\n * @default 0\n */\n BLEND = 0,\n /**\n * Always clear the filter texture.\n * @default 1\n */\n CLEAR = 1,\n /**\n * Clear only if {@link PIXI.FilterSystem.forceClear} is set or if the filter uses pixel blending.\n * @default 2\n */\n BLIT = 2,\n}\n\n/**\n * The gc modes that are supported by pixi.\n *\n * The {@link PIXI.TextureGCSystem.defaultMode} Garbage Collection mode for PixiJS textures is AUTO\n * If set to GC_MODE, the renderer will occasionally check textures usage. If they are not\n * used for a specified period of time they will be removed from the GPU. They will of course\n * be uploaded again when they are required. This is a silent behind the scenes process that\n * should ensure that the GPU does not get filled up.\n *\n * Handy for mobile devices!\n * This property only affects WebGL.\n * @enum {number}\n * @static\n * @memberof PIXI\n */\nexport enum GC_MODES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Garbage collection will happen periodically automatically\n * @default 0\n */\n AUTO,\n /**\n * Garbage collection will need to be called manually\n * @default 1\n */\n MANUAL,\n}\n\n/**\n * Constants that specify float precision in shaders.\n * @memberof PIXI\n * @static\n * @enum {string}\n */\nexport enum PRECISION\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * lowp is at least an 9 bit value.\n * For floating point values they can range from: -2 to +2,\n * for integer values they are similar to Uint8Array or Int8Array\n * @default lowp\n */\n LOW = 'lowp',\n /**\n * mediump is at least a 16 bit value.\n * For floating point values they can range from: -2^14 to +2^14,\n * for integer values they are similar to Uint16Array or Int16Array\n * @default mediump\n */\n MEDIUM = 'mediump',\n /**\n * highp is at least a 32 bit value.\n * For floating point values they can range from: -2^62 to +2^62,\n * for integer values they are similar to Uint32Array or Int32Array\n * @default highp\n */\n HIGH = 'highp',\n}\n\n/**\n * Constants for mask implementations.\n * We use `type` suffix because it leads to very different behaviours\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum MASK_TYPES\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Mask is ignored\n * @default 0\n */\n NONE = 0,\n /**\n * Scissor mask, rectangle on screen, cheap\n * @default 1\n */\n SCISSOR = 1,\n /**\n * Stencil mask, 1-bit, medium, works only if renderer supports stencil\n * @default 2\n */\n STENCIL = 2,\n /**\n * Mask that uses SpriteMaskFilter, uses temporary RenderTexture\n * @default 3\n */\n SPRITE = 3,\n /**\n * Color mask (RGBA)\n * @default 4\n */\n COLOR = 4,\n}\n\n/**\n * Bitwise OR of masks that indicate the color channels that are rendered to.\n * @static\n * @memberof PIXI\n * @enum {number}\n */\nexport enum COLOR_MASK_BITS\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Red channel.\n * @default 0x1\n */\n RED = 0x1,\n /**\n * Green channel\n * @default 0x2\n */\n GREEN = 0x2,\n /**\n * Blue channel.\n * @default 0x4\n */\n BLUE = 0x4,\n /**\n * Alpha channel.\n * @default 0x\n */\n ALPHA = 0x8\n}\n\n/**\n * Constants for multi-sampling antialiasing.\n * @see PIXI.Framebuffer#multisample\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum MSAA_QUALITY\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * No multisampling for this renderTexture\n * @default 0\n */\n NONE = 0,\n /**\n * Try 2 samples\n * @default 2\n */\n LOW = 2,\n /**\n * Try 4 samples\n * @default 4\n */\n MEDIUM = 4,\n /**\n * Try 8 samples\n * @default 8\n */\n HIGH = 8\n}\n\n/**\n * Constants for various buffer types in Pixi\n * @see PIXI.BUFFER_TYPE\n * @memberof PIXI\n * @static\n * @enum {number}\n */\nexport enum BUFFER_TYPE\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * buffer type for using as an index buffer\n * @default 34963\n */\n ELEMENT_ARRAY_BUFFER = 34963,\n /**\n * buffer type for using attribute data\n * @default 34962\n */\n ARRAY_BUFFER = 34962,\n /**\n * the buffer type is for uniform buffer objects\n * @default 35345\n */\n UNIFORM_BUFFER = 35345,\n}\n", "import type { ICanvas } from './ICanvas';\nimport type { ICanvasRenderingContext2D } from './ICanvasRenderingContext2D';\n\n/**\n * This interface describes all the DOM dependent calls that Pixi makes throughout its codebase.\n * Implementations of this interface can be used to make sure Pixi will work in any environment,\n * such as browser, Web Workers, and Node.js.\n * @memberof PIXI\n */\nexport interface IAdapter\n{\n /** Returns a canvas object that can be used to create a webgl context. */\n createCanvas: (width?: number, height?: number) => ICanvas;\n /** Returns a 2D rendering context. */\n getCanvasRenderingContext2D: () => { prototype: ICanvasRenderingContext2D; };\n /** Returns a WebGL rendering context. */\n getWebGLRenderingContext: () => typeof WebGLRenderingContext;\n /** Returns a partial implementation of the browsers window.navigator */\n getNavigator: () => { userAgent: string };\n /** Returns the current base URL For browser environments this is either the document.baseURI or window.location.href */\n getBaseUrl: () => string;\n getFontFaceSet: () => FontFaceSet | null;\n fetch: (url: RequestInfo, options?: RequestInit) => Promise;\n parseXML: (xml: string) => Document;\n}\n\nexport const BrowserAdapter = {\n /**\n * Creates a canvas element of the given size.\n * This canvas is created using the browser's native canvas element.\n * @param width - width of the canvas\n * @param height - height of the canvas\n */\n createCanvas: (width: number, height: number): HTMLCanvasElement =>\n {\n const canvas = document.createElement('canvas');\n\n canvas.width = width;\n canvas.height = height;\n\n return canvas;\n },\n getCanvasRenderingContext2D: () => CanvasRenderingContext2D,\n getWebGLRenderingContext: () => WebGLRenderingContext,\n getNavigator: () => navigator,\n getBaseUrl: () => (document.baseURI ?? window.location.href),\n getFontFaceSet: () => document.fonts,\n fetch: (url: RequestInfo, options?: RequestInit) => fetch(url, options),\n parseXML: (xml: string) =>\n {\n const parser = new DOMParser();\n\n return parser.parseFromString(xml, 'text/xml');\n },\n} as IAdapter;\n", "import { BrowserAdapter } from './adapter';\n\nimport type { IAdapter } from './adapter';\n\ninterface ISettings\n{\n ADAPTER: IAdapter;\n RESOLUTION: number;\n CREATE_IMAGE_BITMAP: boolean;\n ROUND_PIXELS: boolean;\n}\n\n/**\n * User's customizable globals for overriding the default PIXI settings, such\n * as a renderer's default resolution, framerate, float precision, etc.\n * @example\n * import { settings, ENV } from 'pixi.js';\n *\n * // Use the native window resolution as the default resolution\n * // will support high-density displays when rendering\n * settings.RESOLUTION = window.devicePixelRatio;\n *\n * // Used for older v1 WebGL devices for backwards compatibility\n * settings.PREFER_ENV = ENV.WEBGL_LEGACY;\n * @namespace PIXI.settings\n */\nexport const settings: ISettings & Partial = {\n /**\n * This adapter is used to call methods that are platform dependent.\n * For example `document.createElement` only runs on the web but fails in node environments.\n * This allows us to support more platforms by abstracting away specific implementations per platform.\n *\n * By default the adapter is set to work in the browser. However you can create your own\n * by implementing the `IAdapter` interface. See `IAdapter` for more information.\n * @name ADAPTER\n * @memberof PIXI.settings\n * @type {PIXI.IAdapter}\n * @default PIXI.BrowserAdapter\n */\n ADAPTER: BrowserAdapter,\n\n /**\n * Default resolution / device pixel ratio of the renderer.\n * @static\n * @name RESOLUTION\n * @memberof PIXI.settings\n * @type {number}\n * @default 1\n */\n RESOLUTION: 1,\n\n /**\n * Enables bitmap creation before image load. This feature is experimental.\n * @static\n * @name CREATE_IMAGE_BITMAP\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\n CREATE_IMAGE_BITMAP: false,\n\n /**\n * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.\n * Advantages can include sharper image quality (like text) and faster rendering on canvas.\n * The main disadvantage is movement of objects may appear less smooth.\n * @static\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\n ROUND_PIXELS: false,\n};\n", "const appleIphone = /iPhone/i;\nconst appleIpod = /iPod/i;\nconst appleTablet = /iPad/i;\nconst appleUniversal = /\\biOS-universal(?:.+)Mac\\b/i;\nconst androidPhone = /\\bAndroid(?:.+)Mobile\\b/i; // Match 'Android' AND 'Mobile'\nconst androidTablet = /Android/i;\nconst amazonPhone = /(?:SD4930UR|\\bSilk(?:.+)Mobile\\b)/i; // Match 'Silk' AND 'Mobile'\nconst amazonTablet = /Silk/i;\nconst windowsPhone = /Windows Phone/i;\nconst windowsTablet = /\\bWindows(?:.+)ARM\\b/i; // Match 'Windows' AND 'ARM'\nconst otherBlackBerry = /BlackBerry/i;\nconst otherBlackBerry10 = /BB10/i;\nconst otherOpera = /Opera Mini/i;\nconst otherChrome = /\\b(CriOS|Chrome)(?:.+)Mobile/i;\nconst otherFirefox = /Mobile(?:.+)Firefox\\b/i; // Match 'Mobile' AND 'Firefox'\n\nexport type UserAgent = string;\nexport type Navigator = {\n userAgent: string;\n platform: string;\n maxTouchPoints?: number;\n};\n\nconst isAppleTabletOnIos13 = (navigator?: Navigator): boolean => {\n return (\n typeof navigator !== 'undefined' &&\n navigator.platform === 'MacIntel' &&\n typeof navigator.maxTouchPoints === 'number' &&\n navigator.maxTouchPoints > 1 &&\n typeof MSStream === 'undefined'\n );\n};\n\nfunction createMatch(userAgent: UserAgent): (regex: RegExp) => boolean {\n return (regex: RegExp): boolean => regex.test(userAgent);\n}\n\nexport type isMobileResult = {\n apple: {\n phone: boolean;\n ipod: boolean;\n tablet: boolean;\n universal: boolean;\n device: boolean;\n };\n amazon: {\n phone: boolean;\n tablet: boolean;\n device: boolean;\n };\n android: {\n phone: boolean;\n tablet: boolean;\n device: boolean;\n };\n windows: {\n phone: boolean;\n tablet: boolean;\n device: boolean;\n };\n other: {\n blackberry: boolean;\n blackberry10: boolean;\n opera: boolean;\n firefox: boolean;\n chrome: boolean;\n device: boolean;\n };\n phone: boolean;\n tablet: boolean;\n any: boolean;\n};\n\nexport type IsMobileParameter = UserAgent | Navigator;\n\nexport default function isMobile(param?: IsMobileParameter): isMobileResult {\n let nav: Navigator = {\n userAgent: '',\n platform: '',\n maxTouchPoints: 0,\n };\n\n if (!param && typeof navigator !== 'undefined') {\n nav = {\n userAgent: navigator.userAgent,\n platform: navigator.platform,\n maxTouchPoints: navigator.maxTouchPoints || 0,\n };\n } else if (typeof param === 'string') {\n nav.userAgent = param;\n } else if (param && param.userAgent) {\n nav = {\n userAgent: param.userAgent,\n platform: param.platform,\n maxTouchPoints: param.maxTouchPoints || 0,\n };\n }\n\n let userAgent = nav.userAgent;\n\n // Facebook mobile app's integrated browser adds a bunch of strings that\n // match everything. Strip it out if it exists.\n let tmp = userAgent.split('[FBAN');\n if (typeof tmp[1] !== 'undefined') {\n userAgent = tmp[0];\n }\n\n // Twitter mobile app's integrated browser on iPad adds a \"Twitter for\n // iPhone\" string. Same probably happens on other tablet platforms.\n // This will confuse detection so strip it out if it exists.\n tmp = userAgent.split('Twitter');\n if (typeof tmp[1] !== 'undefined') {\n userAgent = tmp[0];\n }\n\n const match = createMatch(userAgent);\n\n const result: isMobileResult = {\n apple: {\n phone: match(appleIphone) && !match(windowsPhone),\n ipod: match(appleIpod),\n tablet:\n !match(appleIphone) &&\n (match(appleTablet) || isAppleTabletOnIos13(nav)) &&\n !match(windowsPhone),\n universal: match(appleUniversal),\n device:\n (match(appleIphone) ||\n match(appleIpod) ||\n match(appleTablet) ||\n match(appleUniversal) ||\n isAppleTabletOnIos13(nav)) &&\n !match(windowsPhone),\n },\n amazon: {\n phone: match(amazonPhone),\n tablet: !match(amazonPhone) && match(amazonTablet),\n device: match(amazonPhone) || match(amazonTablet),\n },\n android: {\n phone:\n (!match(windowsPhone) && match(amazonPhone)) ||\n (!match(windowsPhone) && match(androidPhone)),\n tablet:\n !match(windowsPhone) &&\n !match(amazonPhone) &&\n !match(androidPhone) &&\n (match(amazonTablet) || match(androidTablet)),\n device:\n (!match(windowsPhone) &&\n (match(amazonPhone) ||\n match(amazonTablet) ||\n match(androidPhone) ||\n match(androidTablet))) ||\n match(/\\bokhttp\\b/i),\n },\n windows: {\n phone: match(windowsPhone),\n tablet: match(windowsTablet),\n device: match(windowsPhone) || match(windowsTablet),\n },\n other: {\n blackberry: match(otherBlackBerry),\n blackberry10: match(otherBlackBerry10),\n opera: match(otherOpera),\n firefox: match(otherFirefox),\n chrome: match(otherChrome),\n device:\n match(otherBlackBerry) ||\n match(otherBlackBerry10) ||\n match(otherOpera) ||\n match(otherFirefox) ||\n match(otherChrome),\n },\n any: false,\n phone: false,\n tablet: false,\n };\n\n result.any =\n result.apple.device ||\n result.android.device ||\n result.windows.device ||\n result.other.device;\n // excludes 'other' devices and ipods, targeting touchscreen phones\n result.phone =\n result.apple.phone || result.android.phone || result.windows.phone;\n result.tablet =\n result.apple.tablet || result.android.tablet || result.windows.tablet;\n\n return result;\n}\n", "import isMobileJs from 'ismobilejs';\n\n// ismobilejs have different import behavior for CJS and ESM, so here is the hack\ntype isMobileJsType = typeof isMobileJs & { default?: typeof isMobileJs };\nconst isMobileCall = (isMobileJs as isMobileJsType).default ?? isMobileJs;\n\nexport type isMobileResult = {\n apple: {\n phone: boolean;\n ipod: boolean;\n tablet: boolean;\n universal: boolean;\n device: boolean;\n };\n amazon: {\n phone: boolean;\n tablet: boolean;\n device: boolean;\n };\n android: {\n phone: boolean;\n tablet: boolean;\n device: boolean;\n };\n windows: {\n phone: boolean;\n tablet: boolean;\n device: boolean;\n };\n other: {\n blackberry: boolean;\n blackberry10: boolean;\n opera: boolean;\n firefox: boolean;\n chrome: boolean;\n device: boolean;\n };\n phone: boolean;\n tablet: boolean;\n any: boolean;\n};\n\nexport const isMobile: isMobileResult = isMobileCall(globalThis.navigator);\n", "import { settings } from '@pixi/settings';\n\n/**\n * The prefix that denotes a URL is for a retina asset.\n * @static\n * @name RETINA_PREFIX\n * @memberof PIXI.settings\n * @type {RegExp}\n * @default /@([0-9\\.]+)x/\n * @example `@2x`\n */\nsettings.RETINA_PREFIX = /@([0-9\\.]+)x/;\n\n/**\n * Should the `failIfMajorPerformanceCaveat` flag be enabled as a context option used in the `isWebGLSupported` function.\n * If set to true, a WebGL renderer can fail to be created if the browser thinks there could be performance issues when\n * using WebGL.\n *\n * In PixiJS v6 this has changed from true to false by default, to allow WebGL to work in as many scenarios as possible.\n * However, some users may have a poor experience, for example, if a user has a gpu or driver version blacklisted by the\n * browser.\n *\n * If your application requires high performance rendering, you may wish to set this to false.\n * We recommend one of two options if you decide to set this flag to false:\n *\n * 1: Use the `pixi.js-legacy` package, which includes a Canvas renderer as a fallback in case high performance WebGL is\n * not supported.\n *\n * 2: Call `isWebGLSupported` (which if found in the PIXI.utils package) in your code before attempting to create a PixiJS\n * renderer, and show an error message to the user if the function returns false, explaining that their device & browser\n * combination does not support high performance WebGL.\n * This is a much better strategy than trying to create a PixiJS renderer and finding it then fails.\n * @static\n * @name FAIL_IF_MAJOR_PERFORMANCE_CAVEAT\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\nsettings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT = false;\n\nexport { settings };\n", "import './settings.mjs';\nexport { isMobile } from '@pixi/settings';\nexport { default as EventEmitter } from 'eventemitter3';\nexport { default as earcut } from 'earcut';\nexport { url } from './url.mjs';\nexport { path } from './path.mjs';\nexport { sayHello, skipHello } from './browser/hello.mjs';\nexport { isWebGLSupported } from './browser/isWebGLSupported.mjs';\nexport { hex2rgb, hex2string, rgb2hex, string2hex } from './color/hex.mjs';\nexport { correctBlendMode, premultiplyBlendMode, premultiplyRgba, premultiplyTint, premultiplyTintToRgba } from './color/premultiply.mjs';\nexport { DATA_URI } from './const.mjs';\nexport { createIndicesForQuads } from './data/createIndicesForQuads.mjs';\nexport { getBufferType } from './data/getBufferType.mjs';\nexport { interleaveTypedArrays } from './data/interleaveTypedArrays.mjs';\nexport { isPow2, log2, nextPow2 } from './data/pow2.mjs';\nexport { removeItems } from './data/removeItems.mjs';\nexport { sign } from './data/sign.mjs';\nexport { uid } from './data/uid.mjs';\nexport { deprecation } from './logging/deprecation.mjs';\nexport { BoundingBox } from './media/BoundingBox.mjs';\nexport { BaseTextureCache, ProgramCache, TextureCache, clearTextureCache, destroyTextureCache } from './media/caches.mjs';\nexport { CanvasRenderTarget } from './media/CanvasRenderTarget.mjs';\nexport { getCanvasBoundingBox } from './media/getCanvasBoundingBox.mjs';\nexport { trimCanvas } from './media/trimCanvas.mjs';\nexport { decomposeDataUri } from './network/decomposeDataUri.mjs';\nexport { determineCrossOrigin } from './network/determineCrossOrigin.mjs';\nexport { getResolutionOfUrl } from './network/getResolutionOfUrl.mjs';\nimport './types/index.mjs';\n//# sourceMappingURL=index.mjs.map\n", "/*\n * This file contains redeclared types for Node `url` and `querystring` modules. These modules\n * don't provide their own typings but instead are a part of the full Node typings. The purpose of\n * this file is to redeclare the required types to avoid having the whole Node types as a\n * dependency.\n */\n\nimport { format as _format, parse as _parse, resolve as _resolve } from 'url';\n\ninterface ParsedUrlQuery\n{\n [key: string]: string | string[];\n}\n\ninterface ParsedUrlQueryInput\n{\n [key: string]: unknown;\n}\n\ninterface UrlObjectCommon\n{\n auth?: string;\n hash?: string;\n host?: string;\n hostname?: string;\n href?: string;\n path?: string;\n pathname?: string;\n protocol?: string;\n search?: string;\n slashes?: boolean;\n}\n\n// Input to `url.format`\ninterface UrlObject extends UrlObjectCommon\n{\n port?: string | number;\n query?: string | null | ParsedUrlQueryInput;\n}\n\n// Output of `url.parse`\ninterface Url extends UrlObjectCommon\n{\n port?: string;\n query?: string | null | ParsedUrlQuery;\n}\n\ninterface UrlWithParsedQuery extends Url\n{\n query: ParsedUrlQuery;\n}\n\ninterface UrlWithStringQuery extends Url\n{\n query: string | null;\n}\n\ninterface URLFormatOptions\n{\n auth?: boolean;\n fragment?: boolean;\n search?: boolean;\n unicode?: boolean;\n}\n\ntype ParseFunction = {\n (urlStr: string): UrlWithStringQuery;\n (urlStr: string, parseQueryString: false | undefined, slashesDenoteHost?: boolean): UrlWithStringQuery;\n (urlStr: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;\n (urlStr: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;\n};\n\ntype FormatFunction = {\n (URL: URL, options?: URLFormatOptions): string;\n (urlObject: UrlObject | string): string;\n};\n\ntype ResolveFunction = {\n (from: string, to: string): string;\n};\n\nexport const url = {\n parse: _parse as ParseFunction,\n format: _format as FormatFunction,\n resolve: _resolve as ResolveFunction,\n};\n", "import type { Dict } from '../types';\n\n// A map of warning messages already fired\nconst warnings: Dict = {};\n\n/**\n * Helper for warning developers about deprecated features & settings.\n * A stack track for warnings is given; useful for tracking-down where\n * deprecated methods/properties/classes are being used within the code.\n * @memberof PIXI.utils\n * @function deprecation\n * @param {string} version - The version where the feature became deprecated\n * @param {string} message - Message should include what is deprecated, where, and the new solution\n * @param {number} [ignoreDepth=3] - The number of steps to ignore at the top of the error stack\n * this is mostly to ignore internal deprecation calls.\n */\nexport function deprecation(version: string, message: string, ignoreDepth = 3): void\n{\n // Ignore duplicat\n if (warnings[message])\n {\n return;\n }\n\n /* eslint-disable no-console */\n let stack = new Error().stack;\n\n // Handle IE < 10 and Safari < 6\n if (typeof stack === 'undefined')\n {\n console.warn('PixiJS Deprecation Warning: ', `${message}\\nDeprecated since v${version}`);\n }\n else\n {\n // chop off the stack trace which includes PixiJS internal calls\n stack = stack.split('\\n').splice(ignoreDepth).join('\\n');\n\n if (console.groupCollapsed)\n {\n console.groupCollapsed(\n '%cPixiJS Deprecation Warning: %c%s',\n 'color:#614108;background:#fffbe6',\n 'font-weight:normal;color:#614108;background:#fffbe6',\n `${message}\\nDeprecated since v${version}`\n );\n console.warn(stack);\n console.groupEnd();\n }\n else\n {\n console.warn('PixiJS Deprecation Warning: ', `${message}\\nDeprecated since v${version}`);\n console.warn(stack);\n }\n }\n /* eslint-enable no-console */\n\n warnings[message] = true;\n}\n", "import { settings } from '../settings';\n\nlet supported: boolean | undefined;\n\n/**\n * Helper for checking for WebGL support.\n * @memberof PIXI.utils\n * @function isWebGLSupported\n * @returns {boolean} Is WebGL supported.\n */\nexport function isWebGLSupported(): boolean\n{\n if (typeof supported === 'undefined')\n {\n supported = (function supported(): boolean\n {\n const contextOptions = {\n stencil: true,\n failIfMajorPerformanceCaveat: settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT,\n };\n\n try\n {\n if (!settings.ADAPTER.getWebGLRenderingContext())\n {\n return false;\n }\n\n const canvas = settings.ADAPTER.createCanvas();\n let gl = (\n canvas.getContext('webgl', contextOptions)\n || canvas.getContext('experimental-webgl', contextOptions)\n ) as WebGLRenderingContext | null;\n\n const success = !!gl?.getContextAttributes()?.stencil;\n\n if (gl)\n {\n const loseContext = gl.getExtension('WEBGL_lose_context');\n\n if (loseContext)\n {\n loseContext.loseContext();\n }\n }\n\n gl = null;\n\n return success;\n }\n catch (e)\n {\n return false;\n }\n })();\n }\n\n return supported;\n}\n", "var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return\"string\"==typeof r?r.length>0:\"number\"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?\"0\"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i,p=/^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s+([+-]?\\d*\\.?\\d+)%\\s+([+-]?\\d*\\.?\\d+)%\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i,v=/^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i,m=/^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},\"hex\"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},\"rgb\"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u=\"deg\"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},\"hsl\"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},\"rgb\"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},\"hsl\"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},\"hsv\"]]},N=function(r,t){for(var n=0;n=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):\"\",\"#\"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?\"rgba(\"+t+\", \"+n+\", \"+e+\", \"+u+\")\":\"rgb(\"+t+\", \"+n+\", \"+e+\")\";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?\"hsla(\"+t+\", \"+n+\"%, \"+e+\"%, \"+u+\")\":\"hsl(\"+t+\", \"+n+\"%, \"+e+\"%)\";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return\"number\"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return\"number\"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};export{j as Colord,w as colord,k as extend,I as getFormat,E as random};\n", "export default function(e,f){var a={white:\"#ffffff\",bisque:\"#ffe4c4\",blue:\"#0000ff\",cadetblue:\"#5f9ea0\",chartreuse:\"#7fff00\",chocolate:\"#d2691e\",coral:\"#ff7f50\",antiquewhite:\"#faebd7\",aqua:\"#00ffff\",azure:\"#f0ffff\",whitesmoke:\"#f5f5f5\",papayawhip:\"#ffefd5\",plum:\"#dda0dd\",blanchedalmond:\"#ffebcd\",black:\"#000000\",gold:\"#ffd700\",goldenrod:\"#daa520\",gainsboro:\"#dcdcdc\",cornsilk:\"#fff8dc\",cornflowerblue:\"#6495ed\",burlywood:\"#deb887\",aquamarine:\"#7fffd4\",beige:\"#f5f5dc\",crimson:\"#dc143c\",cyan:\"#00ffff\",darkblue:\"#00008b\",darkcyan:\"#008b8b\",darkgoldenrod:\"#b8860b\",darkkhaki:\"#bdb76b\",darkgray:\"#a9a9a9\",darkgreen:\"#006400\",darkgrey:\"#a9a9a9\",peachpuff:\"#ffdab9\",darkmagenta:\"#8b008b\",darkred:\"#8b0000\",darkorchid:\"#9932cc\",darkorange:\"#ff8c00\",darkslateblue:\"#483d8b\",gray:\"#808080\",darkslategray:\"#2f4f4f\",darkslategrey:\"#2f4f4f\",deeppink:\"#ff1493\",deepskyblue:\"#00bfff\",wheat:\"#f5deb3\",firebrick:\"#b22222\",floralwhite:\"#fffaf0\",ghostwhite:\"#f8f8ff\",darkviolet:\"#9400d3\",magenta:\"#ff00ff\",green:\"#008000\",dodgerblue:\"#1e90ff\",grey:\"#808080\",honeydew:\"#f0fff0\",hotpink:\"#ff69b4\",blueviolet:\"#8a2be2\",forestgreen:\"#228b22\",lawngreen:\"#7cfc00\",indianred:\"#cd5c5c\",indigo:\"#4b0082\",fuchsia:\"#ff00ff\",brown:\"#a52a2a\",maroon:\"#800000\",mediumblue:\"#0000cd\",lightcoral:\"#f08080\",darkturquoise:\"#00ced1\",lightcyan:\"#e0ffff\",ivory:\"#fffff0\",lightyellow:\"#ffffe0\",lightsalmon:\"#ffa07a\",lightseagreen:\"#20b2aa\",linen:\"#faf0e6\",mediumaquamarine:\"#66cdaa\",lemonchiffon:\"#fffacd\",lime:\"#00ff00\",khaki:\"#f0e68c\",mediumseagreen:\"#3cb371\",limegreen:\"#32cd32\",mediumspringgreen:\"#00fa9a\",lightskyblue:\"#87cefa\",lightblue:\"#add8e6\",midnightblue:\"#191970\",lightpink:\"#ffb6c1\",mistyrose:\"#ffe4e1\",moccasin:\"#ffe4b5\",mintcream:\"#f5fffa\",lightslategray:\"#778899\",lightslategrey:\"#778899\",navajowhite:\"#ffdead\",navy:\"#000080\",mediumvioletred:\"#c71585\",powderblue:\"#b0e0e6\",palegoldenrod:\"#eee8aa\",oldlace:\"#fdf5e6\",paleturquoise:\"#afeeee\",mediumturquoise:\"#48d1cc\",mediumorchid:\"#ba55d3\",rebeccapurple:\"#663399\",lightsteelblue:\"#b0c4de\",mediumslateblue:\"#7b68ee\",thistle:\"#d8bfd8\",tan:\"#d2b48c\",orchid:\"#da70d6\",mediumpurple:\"#9370db\",purple:\"#800080\",pink:\"#ffc0cb\",skyblue:\"#87ceeb\",springgreen:\"#00ff7f\",palegreen:\"#98fb98\",red:\"#ff0000\",yellow:\"#ffff00\",slateblue:\"#6a5acd\",lavenderblush:\"#fff0f5\",peru:\"#cd853f\",palevioletred:\"#db7093\",violet:\"#ee82ee\",teal:\"#008080\",slategray:\"#708090\",slategrey:\"#708090\",aliceblue:\"#f0f8ff\",darkseagreen:\"#8fbc8f\",darkolivegreen:\"#556b2f\",greenyellow:\"#adff2f\",seagreen:\"#2e8b57\",seashell:\"#fff5ee\",tomato:\"#ff6347\",silver:\"#c0c0c0\",sienna:\"#a0522d\",lavender:\"#e6e6fa\",lightgreen:\"#90ee90\",orange:\"#ffa500\",orangered:\"#ff4500\",steelblue:\"#4682b4\",royalblue:\"#4169e1\",turquoise:\"#40e0d0\",yellowgreen:\"#9acd32\",salmon:\"#fa8072\",saddlebrown:\"#8b4513\",sandybrown:\"#f4a460\",rosybrown:\"#bc8f8f\",darksalmon:\"#e9967a\",lightgoldenrodyellow:\"#fafad2\",snow:\"#fffafa\",lightgrey:\"#d3d3d3\",lightgray:\"#d3d3d3\",dimgray:\"#696969\",dimgrey:\"#696969\",olivedrab:\"#6b8e23\",olive:\"#808000\"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return\"transparent\";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b=\"black\";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u | null;\n\n /** Normalized rgba component, floats from 0-1 */\n private _components: Float32Array;\n\n /** Cache color as number */\n private _int: number;\n\n /**\n * @param {PIXI.ColorSource} value - Optional value to use, if not provided, white is used.\n */\n constructor(value: ColorSource = 0xffffff)\n {\n this._value = null;\n this._components = new Float32Array(4);\n this._components.fill(1);\n this._int = 0xffffff;\n this.value = value;\n }\n\n /** Get red component (0 - 1) */\n get red(): number\n {\n return this._components[0];\n }\n\n /** Get green component (0 - 1) */\n get green(): number\n {\n return this._components[1];\n }\n\n /** Get blue component (0 - 1) */\n get blue(): number\n {\n return this._components[2];\n }\n\n /** Get alpha component (0 - 1) */\n get alpha(): number\n {\n return this._components[3];\n }\n\n /**\n * Set the value, suitable for chaining\n * @param value\n * @see PIXI.Color.value\n */\n setValue(value: ColorSource): this\n {\n this.value = value;\n\n return this;\n }\n\n /**\n * The current color source.\n *\n * When setting:\n * - Setting to an instance of `Color` will copy its color source and components.\n * - Otherwise, `Color` will try to normalize the color source and set the components.\n * If the color source is invalid, an `Error` will be thrown and the `Color` will left unchanged.\n *\n * Note: The `null` in the setter's parameter type is added to match the TypeScript rule: return type of getter\n * must be assignable to its setter's parameter type. Setting `value` to `null` will throw an `Error`.\n *\n * When getting:\n * - A return value of `null` means the previous value was overridden (e.g., {@link PIXI.Color.multiply multiply},\n * {@link PIXI.Color.premultiply premultiply} or {@link PIXI.Color.round round}).\n * - Otherwise, the color source used when setting is returned.\n * @type {PIXI.ColorSource}\n */\n set value(value: ColorSource | null)\n {\n // Support copying from other Color objects\n if (value instanceof Color)\n {\n this._value = this.cloneSource(value._value);\n this._int = value._int;\n this._components.set(value._components);\n }\n else if (value === null)\n {\n throw new Error('Cannot set PIXI.Color#value to null');\n }\n else if (this._value === null || !this.isSourceEqual(this._value, value))\n {\n this.normalize(value);\n this._value = this.cloneSource(value);\n }\n }\n get value(): Exclude | null\n {\n return this._value;\n }\n\n /**\n * Copy a color source internally.\n * @param value - Color source\n */\n private cloneSource(value: Exclude | null): Exclude | null\n {\n if (typeof value === 'string' || typeof value === 'number' || value instanceof Number || value === null)\n {\n return value;\n }\n else if (Array.isArray(value) || ArrayBuffer.isView(value))\n {\n return value.slice(0);\n }\n else if (typeof value === 'object' && value !== null)\n {\n return { ...value };\n }\n\n return value;\n }\n\n /**\n * Equality check for color sources.\n * @param value1 - First color source\n * @param value2 - Second color source\n * @returns `true` if the color sources are equal, `false` otherwise.\n */\n private isSourceEqual(value1: Exclude, value2: Exclude): boolean\n {\n const type1 = typeof value1;\n const type2 = typeof value2;\n\n // Mismatched types\n if (type1 !== type2)\n {\n return false;\n }\n // Handle numbers/strings and things that extend Number\n // important to do the instanceof Number first, as this is \"object\" type\n else if (type1 === 'number' || type1 === 'string' || value1 instanceof Number)\n {\n return value1 === value2;\n }\n // Handle Arrays and TypedArrays\n else if ((Array.isArray(value1) && Array.isArray(value2))\n || (ArrayBuffer.isView(value1) && ArrayBuffer.isView(value2)))\n {\n if (value1.length !== value2.length)\n {\n return false;\n }\n\n return value1.every((v, i) => v === value2[i]);\n }\n // Handle Objects\n else if (value1 !== null && value2 !== null)\n {\n const keys1 = Object.keys(value1) as (keyof typeof value1)[];\n const keys2 = Object.keys(value2) as (keyof typeof value2)[];\n\n if (keys1.length !== keys2.length)\n {\n return false;\n }\n\n return keys1.every((key) => value1[key] === value2[key]);\n }\n\n return value1 === value2;\n }\n\n /**\n * Convert to a RGBA color object.\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toRgb(); // returns { r: 1, g: 1, b: 1, a: 1 }\n */\n toRgba(): RgbaColor\n {\n const [r, g, b, a] = this._components;\n\n return { r, g, b, a };\n }\n\n /**\n * Convert to a RGB color object.\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toRgb(); // returns { r: 1, g: 1, b: 1 }\n */\n toRgb(): RgbColor\n {\n const [r, g, b] = this._components;\n\n return { r, g, b };\n }\n\n /** Convert to a CSS-style rgba string: `rgba(255,255,255,1.0)`. */\n toRgbaString(): string\n {\n const [r, g, b] = this.toUint8RgbArray();\n\n return `rgba(${r},${g},${b},${this.alpha})`;\n }\n\n /**\n * Convert to an [R, G, B] array of clamped uint8 values (0 to 255).\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toUint8RgbArray(); // returns [255, 255, 255]\n * @param {number[]|Uint8Array|Uint8ClampedArray} [out] - Output array\n */\n toUint8RgbArray(): number[];\n toUint8RgbArray(out: T): T;\n toUint8RgbArray(out?: T): T\n {\n const [r, g, b] = this._components;\n\n out = out ?? [] as number[] as T;\n\n out[0] = Math.round(r * 255);\n out[1] = Math.round(g * 255);\n out[2] = Math.round(b * 255);\n\n return out;\n }\n\n /**\n * Convert to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0).\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toRgbArray(); // returns [1, 1, 1]\n * @param {number[]|Float32Array} [out] - Output array\n */\n toRgbArray(): number[];\n toRgbArray(out: T): T;\n toRgbArray(out?: T): T\n {\n out = out ?? [] as number[] as T;\n const [r, g, b] = this._components;\n\n out[0] = r;\n out[1] = g;\n out[2] = b;\n\n return out;\n }\n\n /**\n * Convert to a hexadecimal number.\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toNumber(); // returns 16777215\n */\n toNumber(): number\n {\n return this._int;\n }\n\n /**\n * Convert to a hexadecimal number in little endian format (e.g., BBGGRR).\n * @example\n * import { Color } from 'pixi.js';\n * new Color(0xffcc99).toLittleEndianNumber(); // returns 0x99ccff\n * @returns {number} - The color as a number in little endian format.\n */\n toLittleEndianNumber(): number\n {\n const value = this._int;\n\n return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16);\n }\n\n /**\n * Multiply with another color. This action is destructive, and will\n * override the previous `value` property to be `null`.\n * @param {PIXI.ColorSource} value - The color to multiply by.\n */\n multiply(value: ColorSource): this\n {\n const [r, g, b, a] = Color.temp.setValue(value)._components;\n\n this._components[0] *= r;\n this._components[1] *= g;\n this._components[2] *= b;\n this._components[3] *= a;\n\n this.refreshInt();\n this._value = null;\n\n return this;\n }\n\n /**\n * Converts color to a premultiplied alpha format. This action is destructive, and will\n * override the previous `value` property to be `null`.\n * @param alpha - The alpha to multiply by.\n * @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels.\n * @returns {PIXI.Color} - Itself.\n */\n premultiply(alpha: number, applyToRGB = true): this\n {\n if (applyToRGB)\n {\n this._components[0] *= alpha;\n this._components[1] *= alpha;\n this._components[2] *= alpha;\n }\n this._components[3] = alpha;\n\n this.refreshInt();\n this._value = null;\n\n return this;\n }\n\n /**\n * Premultiplies alpha with current color.\n * @param {number} alpha - The alpha to multiply by.\n * @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels.\n * @returns {number} tint multiplied by alpha\n */\n toPremultiplied(alpha: number, applyToRGB = true): number\n {\n if (alpha === 1.0)\n {\n return (0xFF << 24) + this._int;\n }\n if (alpha === 0.0)\n {\n return applyToRGB ? 0 : this._int;\n }\n let r = ((this._int >> 16) & 0xFF);\n let g = ((this._int >> 8) & 0xFF);\n let b = (this._int & 0xFF);\n\n if (applyToRGB)\n {\n r = ((r * alpha) + 0.5) | 0;\n g = ((g * alpha) + 0.5) | 0;\n b = ((b * alpha) + 0.5) | 0;\n }\n\n return (alpha * 255 << 24) + (r << 16) + (g << 8) + b;\n }\n\n /**\n * Convert to a hexidecimal string.\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toHex(); // returns \"#ffffff\"\n */\n toHex(): string\n {\n const hexString = this._int.toString(16);\n\n return `#${'000000'.substring(0, 6 - hexString.length) + hexString}`;\n }\n\n /**\n * Convert to a hexidecimal string with alpha.\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toHexa(); // returns \"#ffffffff\"\n */\n toHexa(): string\n {\n const alphaValue = Math.round(this._components[3] * 255);\n const alphaString = alphaValue.toString(16);\n\n return this.toHex() + '00'.substring(0, 2 - alphaString.length) + alphaString;\n }\n\n /**\n * Set alpha, suitable for chaining.\n * @param alpha\n */\n setAlpha(alpha: number): this\n {\n this._components[3] = this._clamp(alpha);\n\n return this;\n }\n\n /**\n * Rounds the specified color according to the step. This action is destructive, and will\n * override the previous `value` property to be `null`. The alpha component is not rounded.\n * @param steps - Number of steps which will be used as a cap when rounding colors\n */\n round(steps: number): this\n {\n const [r, g, b] = this._components;\n\n this._components[0] = Math.round(r * steps) / steps;\n this._components[1] = Math.round(g * steps) / steps;\n this._components[2] = Math.round(b * steps) / steps;\n this.refreshInt();\n this._value = null;\n\n return this;\n }\n\n /**\n * Convert to an [R, G, B, A] array of normalized floats (numbers from 0.0 to 1.0).\n * @example\n * import { Color } from 'pixi.js';\n * new Color('white').toArray(); // returns [1, 1, 1, 1]\n * @param {number[]|Float32Array} [out] - Output array\n */\n toArray(): number[];\n toArray(out: T): T;\n toArray(out?: T): T\n {\n out = out ?? [] as number[] as T;\n const [r, g, b, a] = this._components;\n\n out[0] = r;\n out[1] = g;\n out[2] = b;\n out[3] = a;\n\n return out;\n }\n\n /**\n * Normalize the input value into rgba\n * @param value - Input value\n */\n private normalize(value: Exclude): void\n {\n let r: number | undefined;\n let g: number | undefined;\n let b: number | undefined;\n let a: number | undefined;\n\n // Number is a primative so typeof works fine, but in the case\n // that someone creates a class that extends Number, we also\n // need to check for instanceof Number\n if ((typeof value === 'number' || value instanceof Number) && value >= 0 && value <= 0xffffff)\n {\n const int = value as number; // cast required because instanceof Number is ambiguous for TS\n\n r = ((int >> 16) & 0xFF) / 255;\n g = ((int >> 8) & 0xFF) / 255;\n b = (int & 0xFF) / 255;\n a = 1.0;\n }\n else if ((Array.isArray(value) || value instanceof Float32Array)\n // Can be rgb or rgba\n && value.length >= 3 && value.length <= 4)\n {\n // make sure all values are 0 - 1\n value = this._clamp(value);\n [r, g, b, a = 1.0] = value;\n }\n else if ((value instanceof Uint8Array || value instanceof Uint8ClampedArray)\n // Can be rgb or rgba\n && value.length >= 3 && value.length <= 4)\n {\n // make sure all values are 0 - 255\n value = this._clamp(value, 0, 255);\n [r, g, b, a = 255] = value;\n r /= 255;\n g /= 255;\n b /= 255;\n a /= 255;\n }\n else if (typeof value === 'string' || typeof value === 'object')\n {\n if (typeof value === 'string')\n {\n const match = Color.HEX_PATTERN.exec(value);\n\n if (match)\n {\n // Normalize hex string, remove 0x or # prefix\n value = `#${match[2]}`;\n }\n }\n\n const color = colord(value as AnyColor);\n\n if (color.isValid())\n {\n ({ r, g, b, a } = color.rgba);\n r /= 255;\n g /= 255;\n b /= 255;\n }\n }\n\n // Cache normalized values for rgba and hex integer\n if (r !== undefined)\n {\n this._components[0] = r as number;\n this._components[1] = g as number;\n this._components[2] = b as number;\n this._components[3] = a as number;\n this.refreshInt();\n }\n else\n {\n throw new Error(`Unable to convert color ${value}`);\n }\n }\n\n /** Refresh the internal color rgb number */\n private refreshInt(): void\n {\n // Clamp values to 0 - 1\n this._clamp(this._components);\n\n const [r, g, b] = this._components;\n\n this._int = (((r * 255) << 16) + ((g * 255) << 8) + (b * 255 | 0));\n }\n\n /**\n * Clamps values to a range. Will override original values\n * @param value - Value(s) to clamp\n * @param min - Minimum value\n * @param max - Maximum value\n */\n private _clamp(value: T, min = 0, max = 1): T\n {\n if (typeof value === 'number')\n {\n return Math.min(Math.max(value, min), max) as T;\n }\n\n value.forEach((v, i) =>\n {\n value[i] = Math.min(Math.max(v, min), max);\n });\n\n return value;\n }\n}\n", "import { Color } from '@pixi/color';\nimport { BLEND_MODES } from '@pixi/constants';\nimport { deprecation } from '../logging/deprecation';\n\n/**\n * Corrects PixiJS blend, takes premultiplied alpha into account\n * @memberof PIXI.utils\n * @function mapPremultipliedBlendModes\n * @private\n * @returns {Array} Mapped modes.\n */\nfunction mapPremultipliedBlendModes(): number[][]\n{\n const pm = [];\n const npm = [];\n\n for (let i = 0; i < 32; i++)\n {\n pm[i] = i;\n npm[i] = i;\n }\n\n pm[BLEND_MODES.NORMAL_NPM] = BLEND_MODES.NORMAL;\n pm[BLEND_MODES.ADD_NPM] = BLEND_MODES.ADD;\n pm[BLEND_MODES.SCREEN_NPM] = BLEND_MODES.SCREEN;\n\n npm[BLEND_MODES.NORMAL] = BLEND_MODES.NORMAL_NPM;\n npm[BLEND_MODES.ADD] = BLEND_MODES.ADD_NPM;\n npm[BLEND_MODES.SCREEN] = BLEND_MODES.SCREEN_NPM;\n\n const array: number[][] = [];\n\n array.push(npm);\n array.push(pm);\n\n return array;\n}\n\n/**\n * maps premultiply flag and blendMode to adjusted blendMode\n * @memberof PIXI.utils\n * @type {Array}\n */\nexport const premultiplyBlendMode = mapPremultipliedBlendModes();\n\n/**\n * changes blendMode according to texture format\n * @memberof PIXI.utils\n * @function correctBlendMode\n * @param {number} blendMode - supposed blend mode\n * @param {boolean} premultiplied - whether source is premultiplied\n * @returns {number} true blend mode for this texture\n */\nexport function correctBlendMode(blendMode: number, premultiplied: boolean): number\n{\n return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode];\n}\n\n/**\n * @memberof PIXI.utils\n * @function premultiplyRgba\n * @deprecated since 7.2.0\n * @see PIXI.Color.premultiply\n * @param {Float32Array|number[]} rgb -\n * @param {number} alpha -\n * @param {Float32Array} [out] -\n * @param {boolean} [premultiply=true] -\n */\nexport function premultiplyRgba(\n rgb: Float32Array | number[],\n alpha: number,\n out?: Float32Array,\n premultiply = true\n): Float32Array\n{\n // #if _DEBUG\n deprecation('7.2.0', `utils.premultiplyRgba has moved to Color.premultiply`);\n // #endif\n\n return Color.shared\n .setValue(rgb)\n .premultiply(alpha, premultiply)\n .toArray(out ?? new Float32Array(4));\n}\n\n/**\n * @memberof PIXI.utils\n * @function premultiplyTint\n * @deprecated since 7.2.0\n * @see PIXI.Color.toPremultiplied\n * @param {number} tint -\n * @param {number} alpha -\n */\nexport function premultiplyTint(tint: number, alpha: number): number\n{\n // #if _DEBUG\n deprecation('7.2.0', `utils.premultiplyTint has moved to Color.toPremultiplied`);\n // #endif\n\n return Color.shared\n .setValue(tint)\n .toPremultiplied(alpha);\n}\n\n/**\n * @memberof PIXI.utils\n * @function premultiplyTintToRgba\n * @deprecated since 7.2.0\n * @see PIXI.Color.premultiply\n * @param {number} tint -\n * @param {number} alpha -\n * @param {Float32Array} [out] -\n * @param {boolean} [premultiply=true] -\n */\nexport function premultiplyTintToRgba(tint: number, alpha: number, out?: Float32Array, premultiply = true): Float32Array\n{\n // #if _DEBUG\n deprecation('7.2.0', `utils.premultiplyTintToRgba has moved to Color.premultiply`);\n // #endif\n\n return Color.shared\n .setValue(tint)\n .premultiply(alpha, premultiply)\n .toArray(out ?? new Float32Array(4));\n}\n", "import type { ITypedArray } from '@pixi/core';\n\nexport function getBufferType(\n array: ITypedArray\n): 'Float32Array' | 'Uint32Array' | 'Int32Array' | 'Uint16Array' | 'Uint8Array' | null\n{\n if (array.BYTES_PER_ELEMENT === 4)\n {\n if (array instanceof Float32Array)\n {\n return 'Float32Array';\n }\n else if (array instanceof Uint32Array)\n {\n return 'Uint32Array';\n }\n\n return 'Int32Array';\n }\n else if (array.BYTES_PER_ELEMENT === 2)\n {\n if (array instanceof Uint16Array)\n {\n return 'Uint16Array';\n }\n }\n else if (array.BYTES_PER_ELEMENT === 1)\n {\n if (array instanceof Uint8Array)\n {\n return 'Uint8Array';\n }\n }\n\n // TODO map out the rest of the array elements!\n return null;\n}\n", "// Taken from the bit-twiddle package\n\n/**\n * Rounds to next power of two.\n * @function nextPow2\n * @memberof PIXI.utils\n * @param {number} v - input value\n * @returns {number} - next rounded power of two\n */\nexport function nextPow2(v: number): number\n{\n v += v === 0 ? 1 : 0;\n --v;\n v |= v >>> 1;\n v |= v >>> 2;\n v |= v >>> 4;\n v |= v >>> 8;\n v |= v >>> 16;\n\n return v + 1;\n}\n\n/**\n * Checks if a number is a power of two.\n * @function isPow2\n * @memberof PIXI.utils\n * @param {number} v - input value\n * @returns {boolean} `true` if value is power of two\n */\nexport function isPow2(v: number): boolean\n{\n return !(v & (v - 1)) && (!!v);\n}\n\n/**\n * Computes ceil of log base 2\n * @function log2\n * @memberof PIXI.utils\n * @param {number} v - input value\n * @returns {number} logarithm base 2\n */\nexport function log2(v: number): number\n{\n let r = (v > 0xFFFF ? 1 : 0) << 4;\n\n v >>>= r;\n\n let shift = (v > 0xFF ? 1 : 0) << 3;\n\n v >>>= shift; r |= shift;\n shift = (v > 0xF ? 1 : 0) << 2;\n v >>>= shift; r |= shift;\n shift = (v > 0x3 ? 1 : 0) << 1;\n v >>>= shift; r |= shift;\n\n return r | (v >> 1);\n}\n", "/**\n * Remove items from a javascript array without generating garbage\n * @function removeItems\n * @memberof PIXI.utils\n * @param {Array} arr - Array to remove elements from\n * @param {number} startIdx - starting index\n * @param {number} removeCount - how many to remove\n */\nexport function removeItems(arr: any[], startIdx: number, removeCount: number): void\n{\n const length = arr.length;\n let i;\n\n if (startIdx >= length || removeCount === 0)\n {\n return;\n }\n\n removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount);\n\n const len = length - removeCount;\n\n for (i = startIdx; i < len; ++i)\n {\n arr[i] = arr[i + removeCount];\n }\n\n arr.length = len;\n}\n", "let nextUid = 0;\n\n/**\n * Gets the next unique identifier\n * @memberof PIXI.utils\n * @function uid\n * @returns {number} The next unique identifier to use.\n */\nexport function uid(): number\n{\n return ++nextUid;\n}\n", "/**\n * A rectangular bounding box describing the boundary of an area.\n * @memberof PIXI.utils\n * @since 7.1.0\n */\nexport class BoundingBox\n{\n /** The left coordinate value of the bounding box. */\n left: number;\n /** The top coordinate value of the bounding box. */\n top: number;\n /** The right coordinate value of the bounding box. */\n right: number;\n /** The bottom coordinate value of the bounding box. */\n bottom: number;\n\n /**\n * @param left - The left coordinate value of the bounding box.\n * @param top - The top coordinate value of the bounding box.\n * @param right - The right coordinate value of the bounding box.\n * @param bottom - The bottom coordinate value of the bounding box.\n */\n constructor(left: number, top: number, right: number, bottom: number)\n {\n this.left = left;\n this.top = top;\n this.right = right;\n this.bottom = bottom;\n }\n\n /** The width of the bounding box. */\n get width(): number { return this.right - this.left; }\n /** The height of the bounding box. */\n get height(): number { return this.bottom - this.top; }\n\n /** Determines whether the BoundingBox is empty. */\n isEmpty(): boolean\n {\n return this.left === this.right || this.top === this.bottom;\n }\n\n /**\n * An empty BoundingBox.\n * @type {PIXI.utils.BoundingBox}\n */\n public static readonly EMPTY = new BoundingBox(0, 0, 0, 0);\n}\n", "import type { BaseTexture, Program, Texture } from '@pixi/core';\n\n/**\n * @todo Describe property usage\n * @static\n * @name ProgramCache\n * @memberof PIXI.utils\n * @type {Record}\n */\nexport const ProgramCache: {[key: string]: Program} = {};\n\n/**\n * @todo Describe property usage\n * @static\n * @name TextureCache\n * @memberof PIXI.utils\n * @type {Record}\n */\nexport const TextureCache: {[key: string]: Texture} = Object.create(null);\n\n/**\n * @todo Describe property usage\n * @static\n * @name BaseTextureCache\n * @memberof PIXI.utils\n * @type {Record}\n */\nexport const BaseTextureCache: {[key: string]: BaseTexture} = Object.create(null);\n\n/**\n * Destroys all texture in the cache\n * @memberof PIXI.utils\n * @function destroyTextureCache\n */\nexport function destroyTextureCache(): void\n{\n let key;\n\n for (key in TextureCache)\n {\n TextureCache[key].destroy();\n }\n for (key in BaseTextureCache)\n {\n BaseTextureCache[key].destroy();\n }\n}\n\n/**\n * Removes all textures from cache, but does not destroy them\n * @memberof PIXI.utils\n * @function clearTextureCache\n */\nexport function clearTextureCache(): void\n{\n let key;\n\n for (key in TextureCache)\n {\n delete TextureCache[key];\n }\n for (key in BaseTextureCache)\n {\n delete BaseTextureCache[key];\n }\n}\n", "import { url as _url } from '../url';\n\nlet tempAnchor: HTMLAnchorElement | undefined;\n\n/**\n * Sets the `crossOrigin` property for this resource based on if the url\n * for this resource is cross-origin. If crossOrigin was manually set, this\n * function does nothing.\n * Nipped from the resource loader!\n * @ignore\n * @param {string} url - The url to test.\n * @param {object} [loc=window.location] - The location object to test against.\n * @returns {string} The crossOrigin value to use (or empty string for none).\n */\nexport function determineCrossOrigin(url: string, loc: Location = globalThis.location): string\n{\n // data: and javascript: urls are considered same-origin\n if (url.startsWith('data:'))\n {\n return '';\n }\n\n // default is window.location\n loc = loc || globalThis.location;\n\n if (!tempAnchor)\n {\n tempAnchor = document.createElement('a');\n }\n\n // let the browser determine the full href for the url of this resource and then\n // parse with the node url lib, we can't use the properties of the anchor element\n // because they don't work in IE9 :(\n tempAnchor.href = url;\n const parsedUrl = _url.parse(tempAnchor.href);\n\n const samePort = (!parsedUrl.port && loc.port === '') || (parsedUrl.port === loc.port);\n\n // if cross origin\n if (parsedUrl.hostname !== loc.hostname || !samePort || parsedUrl.protocol !== loc.protocol)\n {\n return 'anonymous';\n }\n\n return '';\n}\n", "import { settings } from '../settings';\n\n/**\n * get the resolution / device pixel ratio of an asset by looking for the prefix\n * used by spritesheets and image urls\n * @memberof PIXI.utils\n * @function getResolutionOfUrl\n * @param {string} url - the image path\n * @param {number} [defaultValue=1] - the defaultValue if no filename prefix is set.\n * @returns {number} resolution / device pixel ratio of an asset\n */\nexport function getResolutionOfUrl(url: string, defaultValue = 1): number\n{\n const resolution = settings.RETINA_PREFIX?.exec(url);\n\n if (resolution)\n {\n return parseFloat(resolution[1]);\n }\n\n return defaultValue;\n}\n", "/**\n * Collection of valid extension types.\n * @memberof PIXI\n * @property {string} Application - Application plugins\n * @property {string} RendererPlugin - Plugins for Renderer\n * @property {string} CanvasRendererPlugin - Plugins for CanvasRenderer\n * @property {string} Loader - Plugins to use with Loader\n * @property {string} LoadParser - Parsers for Assets loader.\n * @property {string} ResolveParser - Parsers for Assets resolvers.\n * @property {string} CacheParser - Parsers for Assets cache.\n */\nenum ExtensionType\n// eslint-disable-next-line @typescript-eslint/indent\n{\n Renderer = 'renderer',\n Application = 'application',\n RendererSystem = 'renderer-webgl-system',\n RendererPlugin = 'renderer-webgl-plugin',\n CanvasRendererSystem = 'renderer-canvas-system',\n CanvasRendererPlugin = 'renderer-canvas-plugin',\n Asset = 'asset',\n LoadParser = 'load-parser',\n ResolveParser = 'resolve-parser',\n CacheParser = 'cache-parser',\n DetectionParser = 'detection-parser',\n}\n\ninterface ExtensionMetadataDetails\n{\n type: ExtensionType | ExtensionType[];\n name?: string;\n priority?: number;\n}\n\ntype ExtensionMetadata = ExtensionType | ExtensionMetadataDetails;\n\n/**\n * Format when registering an extension. Generally, the extension\n * should have these values as `extension` static property,\n * but you can override name or type by providing an object.\n * @memberof PIXI\n */\ninterface ExtensionFormatLoose\n{\n /** The extension type, can be multiple types */\n type: ExtensionType | ExtensionType[];\n /** Optional. Some plugins provide an API name/property, such as Renderer plugins */\n name?: string;\n /** Optional, used for sorting the plugins in a particular order */\n priority?: number;\n /** Reference to the plugin object/class */\n ref: any;\n}\n\n/**\n * Strict extension format that is used internally for registrations.\n * @memberof PIXI\n */\ninterface ExtensionFormat extends ExtensionFormatLoose\n{\n /** The extension type, always expressed as multiple, even if a single */\n type: ExtensionType[];\n}\n\ntype ExtensionHandler = (extension: ExtensionFormat) => void;\n\n/**\n * Convert input into extension format data.\n * @ignore\n */\nconst normalizeExtension = (ext: ExtensionFormatLoose | any): ExtensionFormat =>\n{\n // Class/Object submission, use extension object\n if (typeof ext === 'function' || (typeof ext === 'object' && ext.extension))\n {\n // #if _DEBUG\n if (!ext.extension)\n {\n throw new Error('Extension class must have an extension object');\n }\n // #endif\n const metadata: ExtensionMetadataDetails = (typeof ext.extension !== 'object')\n ? { type: ext.extension }\n : ext.extension;\n\n ext = { ...metadata, ref: ext };\n }\n if (typeof ext === 'object')\n {\n ext = { ...ext };\n }\n else\n {\n throw new Error('Invalid extension type');\n }\n\n if (typeof ext.type === 'string')\n {\n ext.type = [ext.type];\n }\n\n return ext;\n};\n\n/**\n * Get the priority for an extension.\n * @ignore\n * @param ext - Any extension\n * @param defaultPriority - Fallback priority if none is defined.\n * @returns The priority for the extension.\n */\nconst normalizePriority = (ext: ExtensionFormatLoose | any, defaultPriority: number): number =>\n normalizeExtension(ext).priority ?? defaultPriority;\n\n/**\n * Global registration of all PixiJS extensions. One-stop-shop for extensibility.\n * @memberof PIXI\n * @namespace extensions\n */\nconst extensions = {\n\n /** @ignore */\n _addHandlers: {} as Record,\n\n /** @ignore */\n _removeHandlers: {} as Record,\n\n /** @ignore */\n _queue: {} as Record,\n\n /**\n * Remove extensions from PixiJS.\n * @param extensions - Extensions to be removed.\n * @returns {PIXI.extensions} For chaining.\n */\n remove(...extensions: Array)\n {\n extensions.map(normalizeExtension).forEach((ext) =>\n {\n ext.type.forEach((type) => this._removeHandlers[type]?.(ext));\n });\n\n return this;\n },\n\n /**\n * Register new extensions with PixiJS.\n * @param extensions - The spread of extensions to add to PixiJS.\n * @returns {PIXI.extensions} For chaining.\n */\n add(...extensions: Array)\n {\n // Handle any extensions either passed as class w/ data or as data\n extensions.map(normalizeExtension).forEach((ext) =>\n {\n ext.type.forEach((type) =>\n {\n const handlers = this._addHandlers;\n const queue = this._queue;\n\n if (!handlers[type])\n {\n queue[type] = queue[type] || [];\n queue[type].push(ext);\n }\n else\n {\n handlers[type](ext);\n }\n });\n });\n\n return this;\n },\n\n /**\n * Internal method to handle extensions by name.\n * @param type - The extension type.\n * @param onAdd - Function for handling when extensions are added/registered passes {@link PIXI.ExtensionFormat}.\n * @param onRemove - Function for handling when extensions are removed/unregistered passes {@link PIXI.ExtensionFormat}.\n * @returns {PIXI.extensions} For chaining.\n */\n handle(type: ExtensionType, onAdd: ExtensionHandler, onRemove: ExtensionHandler)\n {\n const addHandlers = this._addHandlers;\n const removeHandlers = this._removeHandlers;\n\n // #if _DEBUG\n if (addHandlers[type] || removeHandlers[type])\n {\n throw new Error(`Extension type ${type} already has a handler`);\n }\n // #endif\n\n addHandlers[type] = onAdd;\n removeHandlers[type] = onRemove;\n\n // Process the queue\n const queue = this._queue;\n\n // Process any plugins that have been registered before the handler\n if (queue[type])\n {\n queue[type].forEach((ext) => onAdd(ext));\n delete queue[type];\n }\n\n return this;\n },\n\n /**\n * Handle a type, but using a map by `name` property.\n * @param type - Type of extension to handle.\n * @param map - The object map of named extensions.\n * @returns {PIXI.extensions} For chaining.\n */\n handleByMap(type: ExtensionType, map: Record)\n {\n return this.handle(type,\n (extension) =>\n {\n map[extension.name] = extension.ref;\n },\n (extension) =>\n {\n delete map[extension.name];\n }\n );\n },\n\n /**\n * Handle a type, but using a list of extensions.\n * @param type - Type of extension to handle.\n * @param list - The list of extensions.\n * @param defaultPriority - The default priority to use if none is specified.\n * @returns {PIXI.extensions} For chaining.\n */\n handleByList(type: ExtensionType, list: any[], defaultPriority = -1)\n {\n return this.handle(\n type,\n (extension) =>\n {\n if (list.includes(extension.ref))\n {\n return;\n }\n\n list.push(extension.ref);\n list.sort((a, b) => normalizePriority(b, defaultPriority) - normalizePriority(a, defaultPriority));\n },\n (extension) =>\n {\n const index = list.indexOf(extension.ref);\n\n if (index !== -1)\n {\n list.splice(index, 1);\n }\n }\n );\n },\n};\n\nexport {\n extensions,\n ExtensionType,\n};\nexport type {\n ExtensionFormat,\n ExtensionFormatLoose,\n ExtensionHandler,\n ExtensionMetadata,\n};\n", "import type { ITypedArray } from './Buffer';\n\n/**\n * Flexible wrapper around `ArrayBuffer` that also provides typed array views on demand.\n * @memberof PIXI\n */\nexport class ViewableBuffer\n{\n public size: number;\n\n /** Underlying `ArrayBuffer` that holds all the data and is of capacity `this.size`. */\n public rawBinaryData: ArrayBuffer;\n\n /** View on the raw binary data as a `Uint32Array`. */\n public uint32View: Uint32Array;\n\n /** View on the raw binary data as a `Float32Array`. */\n public float32View: Float32Array;\n\n private _int8View: Int8Array;\n private _uint8View: Uint8Array;\n private _int16View: Int16Array;\n private _uint16View: Uint16Array;\n private _int32View: Int32Array;\n\n /**\n * @param length - The size of the buffer in bytes.\n */\n constructor(length: number);\n\n /**\n * @param arrayBuffer - The source array buffer.\n */\n constructor(arrayBuffer: ArrayBuffer);\n\n constructor(sizeOrBuffer: number | ArrayBuffer | Uint8Array)\n {\n if (typeof sizeOrBuffer === 'number')\n {\n this.rawBinaryData = new ArrayBuffer(sizeOrBuffer);\n }\n else if (sizeOrBuffer instanceof Uint8Array)\n {\n this.rawBinaryData = sizeOrBuffer.buffer;\n }\n else\n {\n this.rawBinaryData = sizeOrBuffer;\n }\n\n this.uint32View = new Uint32Array(this.rawBinaryData);\n this.float32View = new Float32Array(this.rawBinaryData);\n }\n\n /** View on the raw binary data as a `Int8Array`. */\n get int8View(): Int8Array\n {\n if (!this._int8View)\n {\n this._int8View = new Int8Array(this.rawBinaryData);\n }\n\n return this._int8View;\n }\n\n /** View on the raw binary data as a `Uint8Array`. */\n get uint8View(): Uint8Array\n {\n if (!this._uint8View)\n {\n this._uint8View = new Uint8Array(this.rawBinaryData);\n }\n\n return this._uint8View;\n }\n\n /** View on the raw binary data as a `Int16Array`. */\n get int16View(): Int16Array\n {\n if (!this._int16View)\n {\n this._int16View = new Int16Array(this.rawBinaryData);\n }\n\n return this._int16View;\n }\n\n /** View on the raw binary data as a `Uint16Array`. */\n get uint16View(): Uint16Array\n {\n if (!this._uint16View)\n {\n this._uint16View = new Uint16Array(this.rawBinaryData);\n }\n\n return this._uint16View;\n }\n\n /** View on the raw binary data as a `Int32Array`. */\n get int32View(): Int32Array\n {\n if (!this._int32View)\n {\n this._int32View = new Int32Array(this.rawBinaryData);\n }\n\n return this._int32View;\n }\n\n /**\n * Returns the view of the given type.\n * @param type - One of `int8`, `uint8`, `int16`,\n * `uint16`, `int32`, `uint32`, and `float32`.\n * @returns - typed array of given type\n */\n view(type: string): ITypedArray\n {\n return (this as any)[`${type}View`];\n }\n\n /** Destroys all buffer references. Do not use after calling this. */\n destroy(): void\n {\n this.rawBinaryData = null;\n this._int8View = null;\n this._uint8View = null;\n this._int16View = null;\n this._uint16View = null;\n this._int32View = null;\n this.uint32View = null;\n this.float32View = null;\n }\n\n static sizeOf(type: string): number\n {\n switch (type)\n {\n case 'int8':\n case 'uint8':\n return 1;\n case 'int16':\n case 'uint16':\n return 2;\n case 'int32':\n case 'uint32':\n case 'float32':\n return 4;\n default:\n throw new Error(`${type} isn't a valid view type`);\n }\n }\n}\n", "import type { IRenderingContext } from '../../IRenderer';\n\nconst fragTemplate = [\n 'precision mediump float;',\n 'void main(void){',\n 'float test = 0.1;',\n '%forloop%',\n 'gl_FragColor = vec4(0.0);',\n '}',\n].join('\\n');\n\nfunction generateIfTestSrc(maxIfs: number): string\n{\n let src = '';\n\n for (let i = 0; i < maxIfs; ++i)\n {\n if (i > 0)\n {\n src += '\\nelse ';\n }\n\n if (i < maxIfs - 1)\n {\n src += `if(test == ${i}.0){}`;\n }\n }\n\n return src;\n}\n\nexport function checkMaxIfStatementsInShader(maxIfs: number, gl: IRenderingContext): number\n{\n if (maxIfs === 0)\n {\n throw new Error('Invalid value of `0` passed to `checkMaxIfStatementsInShader`');\n }\n\n const shader = gl.createShader(gl.FRAGMENT_SHADER);\n\n while (true) // eslint-disable-line no-constant-condition\n {\n const fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs));\n\n gl.shaderSource(shader, fragmentSrc);\n gl.compileShader(shader);\n\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))\n {\n maxIfs = (maxIfs / 2) | 0;\n }\n else\n {\n // valid!\n break;\n }\n }\n\n return maxIfs;\n}\n", "import { BLEND_MODES } from '@pixi/constants';\n\n/* eslint-disable max-len */\n\nconst BLEND = 0;\nconst OFFSET = 1;\nconst CULLING = 2;\nconst DEPTH_TEST = 3;\nconst WINDING = 4;\nconst DEPTH_MASK = 5;\n\n/**\n * This is a WebGL state, and is is passed to {@link PIXI.StateSystem}.\n *\n * Each mesh rendered may require WebGL to be in a different state.\n * For example you may want different blend mode or to enable polygon offsets\n * @memberof PIXI\n */\nexport class State\n{\n data: number;\n _blendMode: BLEND_MODES;\n _polygonOffset: number;\n\n constructor()\n {\n this.data = 0;\n\n this.blendMode = BLEND_MODES.NORMAL;\n this.polygonOffset = 0;\n\n this.blend = true;\n this.depthMask = true;\n // this.depthTest = true;\n }\n\n /**\n * Activates blending of the computed fragment color values.\n * @default true\n */\n get blend(): boolean\n {\n return !!(this.data & (1 << BLEND));\n }\n\n set blend(value: boolean)\n {\n if (!!(this.data & (1 << BLEND)) !== value)\n {\n this.data ^= (1 << BLEND);\n }\n }\n\n /**\n * Activates adding an offset to depth values of polygon's fragments\n * @default false\n */\n get offsets(): boolean\n {\n return !!(this.data & (1 << OFFSET));\n }\n\n set offsets(value: boolean)\n {\n if (!!(this.data & (1 << OFFSET)) !== value)\n {\n this.data ^= (1 << OFFSET);\n }\n }\n\n /**\n * Activates culling of polygons.\n * @default false\n */\n get culling(): boolean\n {\n return !!(this.data & (1 << CULLING));\n }\n\n set culling(value: boolean)\n {\n if (!!(this.data & (1 << CULLING)) !== value)\n {\n this.data ^= (1 << CULLING);\n }\n }\n\n /**\n * Activates depth comparisons and updates to the depth buffer.\n * @default false\n */\n get depthTest(): boolean\n {\n return !!(this.data & (1 << DEPTH_TEST));\n }\n\n set depthTest(value: boolean)\n {\n if (!!(this.data & (1 << DEPTH_TEST)) !== value)\n {\n this.data ^= (1 << DEPTH_TEST);\n }\n }\n\n /**\n * Enables or disables writing to the depth buffer.\n * @default true\n */\n get depthMask(): boolean\n {\n return !!(this.data & (1 << DEPTH_MASK));\n }\n\n set depthMask(value: boolean)\n {\n if (!!(this.data & (1 << DEPTH_MASK)) !== value)\n {\n this.data ^= (1 << DEPTH_MASK);\n }\n }\n\n /**\n * Specifies whether or not front or back-facing polygons can be culled.\n * @default false\n */\n get clockwiseFrontFace(): boolean\n {\n return !!(this.data & (1 << WINDING));\n }\n\n set clockwiseFrontFace(value: boolean)\n {\n if (!!(this.data & (1 << WINDING)) !== value)\n {\n this.data ^= (1 << WINDING);\n }\n }\n\n /**\n * The blend mode to be applied when this state is set. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.\n * Setting this mode to anything other than NO_BLEND will automatically switch blending on.\n * @default PIXI.BLEND_MODES.NORMAL\n */\n get blendMode(): BLEND_MODES\n {\n return this._blendMode;\n }\n\n set blendMode(value: BLEND_MODES)\n {\n this.blend = (value !== BLEND_MODES.NONE);\n this._blendMode = value;\n }\n\n /**\n * The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill.\n * @default 0\n */\n get polygonOffset(): number\n {\n return this._polygonOffset;\n }\n\n set polygonOffset(value: number)\n {\n this.offsets = !!value;\n this._polygonOffset = value;\n }\n\n // #if _DEBUG\n toString(): string\n {\n return `[@pixi/core:State `\n + `blendMode=${this.blendMode} `\n + `clockwiseFrontFace=${this.clockwiseFrontFace} `\n + `culling=${this.culling} `\n + `depthMask=${this.depthMask} `\n + `polygonOffset=${this.polygonOffset}`\n + `]`;\n }\n // #endif\n\n static for2d(): State\n {\n const state = new State();\n\n state.depthTest = false;\n state.blend = true;\n\n return state;\n }\n}\n\n", "import type { ISize } from '@pixi/math';\nimport type { ICubeResourceOptions } from './CubeResource';\nimport type { IImageResourceOptions } from './ImageResource';\nimport type { Resource } from './Resource';\nimport type { ISVGResourceOptions } from './SVGResource';\nimport type { IVideoResourceOptions } from './VideoResource';\n\n/*\n * Allow flexible options for resource plugins\n */\nexport type IResourcePluginOptions = { [key: string]: any };\n\n/*\n * All allowable options for autoDetectResource\n */\nexport type IAutoDetectOptions = ISize\n| ICubeResourceOptions\n| IImageResourceOptions\n| ISVGResourceOptions\n| IVideoResourceOptions\n| IResourcePluginOptions;\n\n/**\n * Shape of supported resource plugins\n * @memberof PIXI\n */\nexport interface IResourcePlugin\n{\n test(source: unknown, extension: string): boolean;\n new (source: any, options?: RO): R;\n}\n\n/**\n * Collection of installed resource types, class must extend {@link PIXI.Resource}.\n * @example\n * class CustomResource extends PIXI.Resource {\n * // MUST have source, options constructor signature\n * // for auto-detected resources to be created.\n * constructor(source, options) {\n * super();\n * }\n * upload(renderer, baseTexture, glTexture) {\n * // Upload with GL\n * return true;\n * }\n * // Used to auto-detect resource\n * static test(source, extension) {\n * return extension === 'xyz' || source instanceof SomeClass;\n * }\n * }\n * // Install the new resource type\n * PIXI.INSTALLED.push(CustomResource);\n * @memberof PIXI\n * @type {Array}\n * @static\n * @readonly\n */\nexport const INSTALLED: Array> = [];\n\n/**\n * Create a resource element from a single source element. This\n * auto-detects which type of resource to create. All resources that\n * are auto-detectable must have a static `test` method and a constructor\n * with the arguments `(source, options?)`. Currently, the supported\n * resources for auto-detection include:\n * - {@link PIXI.ImageResource}\n * - {@link PIXI.CanvasResource}\n * - {@link PIXI.VideoResource}\n * - {@link PIXI.SVGResource}\n * - {@link PIXI.BufferResource}\n * @static\n * @memberof PIXI\n * @function autoDetectResource\n * @param {string|*} source - Resource source, this can be the URL to the resource,\n * a typed-array (for BufferResource), HTMLVideoElement, SVG data-uri\n * or any other resource that can be auto-detected. If not resource is\n * detected, it's assumed to be an ImageResource.\n * @param {object} [options] - Pass-through options to use for Resource\n * @param {number} [options.width] - Width of BufferResource or SVG rasterization\n * @param {number} [options.height] - Height of BufferResource or SVG rasterization\n * @param {boolean} [options.autoLoad=true] - Image, SVG and Video flag to start loading\n * @param {number} [options.scale=1] - SVG source scale. Overridden by width, height\n * @param {boolean} [options.createBitmap=PIXI.settings.CREATE_IMAGE_BITMAP] - Image option to create Bitmap object\n * @param {boolean} [options.crossorigin=true] - Image and Video option to set crossOrigin\n * @param {boolean} [options.autoPlay=true] - Video option to start playing video immediately\n * @param {number} [options.updateFPS=0] - Video option to update how many times a second the\n * texture should be updated from the video. Leave at 0 to update at every render\n * @returns {PIXI.Resource} The created resource.\n */\nexport function autoDetectResource(source: unknown, options?: RO): R\n{\n if (!source)\n {\n return null;\n }\n\n let extension = '';\n\n if (typeof source === 'string')\n {\n // search for file extension: period, 3-4 chars, then ?, # or EOL\n const result = (/\\.(\\w{3,4})(?:$|\\?|#)/i).exec(source);\n\n if (result)\n {\n extension = result[1].toLowerCase();\n }\n }\n\n for (let i = INSTALLED.length - 1; i >= 0; --i)\n {\n const ResourcePlugin = INSTALLED[i] as IResourcePlugin;\n\n if (ResourcePlugin.test && ResourcePlugin.test(source, extension))\n {\n return new ResourcePlugin(source, options);\n }\n }\n\n throw new Error('Unrecognized source type to auto-detect Resource');\n}\n", "/**\n * A Runner is a highly performant and simple alternative to signals. Best used in situations\n * where events are dispatched to many objects at high frequency (say every frame!)\n *\n * Like a signal:\n *\n * ```js\n * import { Runner } from '@pixi/runner';\n *\n * const myObject = {\n * loaded: new Runner('loaded'),\n * };\n *\n * const listener = {\n * loaded: function() {\n * // Do something when loaded\n * }\n * };\n *\n * myObject.loaded.add(listener);\n *\n * myObject.loaded.emit();\n * ```\n *\n * Or for handling calling the same function on many items:\n *\n * ```js\n * import { Runner } from '@pixi/runner';\n *\n * const myGame = {\n * update: new Runner('update'),\n * };\n *\n * const gameObject = {\n * update: function(time) {\n * // Update my gamey state\n * },\n * };\n *\n * myGame.update.add(gameObject);\n *\n * myGame.update.emit(time);\n * ```\n * @memberof PIXI\n */\nexport class Runner\n{\n public items: any[];\n private _name: string;\n private _aliasCount: number;\n\n /**\n * @param name - The function name that will be executed on the listeners added to this Runner.\n */\n constructor(name: string)\n {\n this.items = [];\n this._name = name;\n this._aliasCount = 0;\n }\n\n /* eslint-disable jsdoc/require-param, jsdoc/check-param-names */\n /**\n * Dispatch/Broadcast Runner to all listeners added to the queue.\n * @param {...any} params - (optional) parameters to pass to each listener\n */\n /* eslint-enable jsdoc/require-param, jsdoc/check-param-names */\n public emit(a0?: unknown, a1?: unknown, a2?: unknown, a3?: unknown,\n a4?: unknown, a5?: unknown, a6?: unknown, a7?: unknown): this\n {\n if (arguments.length > 8)\n {\n throw new Error('max arguments reached');\n }\n\n const { name, items } = this;\n\n this._aliasCount++;\n\n for (let i = 0, len = items.length; i < len; i++)\n {\n items[i][name](a0, a1, a2, a3, a4, a5, a6, a7);\n }\n\n if (items === this.items)\n {\n this._aliasCount--;\n }\n\n return this;\n }\n\n private ensureNonAliasedItems(): void\n {\n if (this._aliasCount > 0 && this.items.length > 1)\n {\n this._aliasCount = 0;\n this.items = this.items.slice(0);\n }\n }\n\n /**\n * Add a listener to the Runner\n *\n * Runners do not need to have scope or functions passed to them.\n * All that is required is to pass the listening object and ensure that it has contains a function that has the same name\n * as the name provided to the Runner when it was created.\n *\n * E.g. A listener passed to this Runner will require a 'complete' function.\n *\n * ```js\n * import { Runner } from '@pixi/runner';\n *\n * const complete = new Runner('complete');\n * ```\n *\n * The scope used will be the object itself.\n * @param {any} item - The object that will be listening.\n */\n public add(item: unknown): this\n {\n if ((item as any)[this._name])\n {\n this.ensureNonAliasedItems();\n this.remove(item);\n this.items.push(item);\n }\n\n return this;\n }\n\n /**\n * Remove a single listener from the dispatch queue.\n * @param {any} item - The listener that you would like to remove.\n */\n public remove(item: unknown): this\n {\n const index = this.items.indexOf(item);\n\n if (index !== -1)\n {\n this.ensureNonAliasedItems();\n this.items.splice(index, 1);\n }\n\n return this;\n }\n\n /**\n * Check to see if the listener is already in the Runner\n * @param {any} item - The listener that you would like to check.\n */\n public contains(item: unknown): boolean\n {\n return this.items.includes(item);\n }\n\n /** Remove all listeners from the Runner */\n public removeAll(): this\n {\n this.ensureNonAliasedItems();\n this.items.length = 0;\n\n return this;\n }\n\n /** Remove all references, don't use after this. */\n public destroy(): void\n {\n this.removeAll();\n this.items = null;\n this._name = null;\n }\n\n /**\n * `true` if there are no this Runner contains no listeners\n * @readonly\n */\n public get empty(): boolean\n {\n return this.items.length === 0;\n }\n\n /**\n * The name of the runner.\n * @readonly\n */\n public get name(): string\n {\n return this._name;\n }\n}\n\nObject.defineProperties(Runner.prototype, {\n /**\n * Alias for `emit`\n * @memberof PIXI.Runner#\n * @method dispatch\n * @see PIXI.Runner#emit\n */\n dispatch: { value: Runner.prototype.emit },\n /**\n * Alias for `emit`\n * @memberof PIXI.Runner#\n * @method run\n * @see PIXI.Runner#emit\n */\n run: { value: Runner.prototype.emit },\n});\n", "import { Runner } from '@pixi/runner';\n\nimport type { Renderer } from '../../Renderer';\nimport type { BaseTexture } from '../BaseTexture';\nimport type { GLTexture } from '../GLTexture';\n\n/**\n * Base resource class for textures that manages validation and uploading, depending on its type.\n *\n * Uploading of a base texture to the GPU is required.\n * @memberof PIXI\n */\nexport abstract class Resource\n{\n /** The url of the resource */\n public src: string;\n\n /**\n * If resource has been destroyed.\n * @readonly\n * @default false\n */\n public destroyed: boolean;\n\n /**\n * `true` if resource is created by BaseTexture\n * useful for doing cleanup with BaseTexture destroy\n * and not cleaning up resources that were created\n * externally.\n */\n public internal: boolean;\n\n /** Internal width of the resource. */\n protected _width: number;\n\n /** Internal height of the resource. */\n protected _height: number;\n\n /**\n * Mini-runner for handling resize events\n * accepts 2 parameters: width, height\n * @member {Runner}\n * @private\n */\n protected onResize: Runner; // TODO: Should this be private? It doesn't seem to be used anywhere else.\n\n /**\n * Mini-runner for handling update events\n * @member {Runner}\n * @private\n */\n protected onUpdate: Runner;\n\n /**\n * Handle internal errors, such as loading errors\n * accepts 1 param: error\n * @member {Runner}\n * @private\n */\n protected onError: Runner;\n\n /**\n * @param width - Width of the resource\n * @param height - Height of the resource\n */\n constructor(width = 0, height = 0)\n {\n this._width = width;\n this._height = height;\n\n this.destroyed = false;\n this.internal = false;\n\n this.onResize = new Runner('setRealSize');\n this.onUpdate = new Runner('update');\n this.onError = new Runner('onError');\n }\n\n /**\n * Bind to a parent BaseTexture\n * @param baseTexture - Parent texture\n */\n bind(baseTexture: BaseTexture): void\n {\n this.onResize.add(baseTexture);\n this.onUpdate.add(baseTexture);\n this.onError.add(baseTexture);\n\n // Call a resize immediate if we already\n // have the width and height of the resource\n if (this._width || this._height)\n {\n this.onResize.emit(this._width, this._height);\n }\n }\n\n /**\n * Unbind to a parent BaseTexture\n * @param baseTexture - Parent texture\n */\n unbind(baseTexture: BaseTexture): void\n {\n this.onResize.remove(baseTexture);\n this.onUpdate.remove(baseTexture);\n this.onError.remove(baseTexture);\n }\n\n /**\n * Trigger a resize event\n * @param width - X dimension\n * @param height - Y dimension\n */\n resize(width: number, height: number): void\n {\n if (width !== this._width || height !== this._height)\n {\n this._width = width;\n this._height = height;\n this.onResize.emit(width, height);\n }\n }\n\n /**\n * Has been validated\n * @readonly\n */\n get valid(): boolean\n {\n return !!this._width && !!this._height;\n }\n\n /** Has been updated trigger event. */\n update(): void\n {\n if (!this.destroyed)\n {\n this.onUpdate.emit();\n }\n }\n\n /**\n * This can be overridden to start preloading a resource\n * or do any other prepare step.\n * @protected\n * @returns Handle the validate event\n */\n load(): Promise\n {\n return Promise.resolve(this);\n }\n\n /**\n * The width of the resource.\n * @readonly\n */\n get width(): number\n {\n return this._width;\n }\n\n /**\n * The height of the resource.\n * @readonly\n */\n get height(): number\n {\n return this._height;\n }\n\n /**\n * Uploads the texture or returns false if it cant for some reason. Override this.\n * @param renderer - yeah, renderer!\n * @param baseTexture - the texture\n * @param glTexture - texture instance for this webgl context\n * @returns - true is success\n */\n abstract upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean;\n\n /**\n * Set the style, optional to override\n * @param _renderer - yeah, renderer!\n * @param _baseTexture - the texture\n * @param _glTexture - texture instance for this webgl context\n * @returns - `true` is success\n */\n style(_renderer: Renderer, _baseTexture: BaseTexture, _glTexture: GLTexture): boolean\n {\n return false;\n }\n\n /** Clean up anything, this happens when destroying is ready. */\n dispose(): void\n {\n // override\n }\n\n /**\n * Call when destroying resource, unbind any BaseTexture object\n * before calling this method, as reference counts are maintained\n * internally.\n */\n destroy(): void\n {\n if (!this.destroyed)\n {\n this.destroyed = true;\n this.dispose();\n this.onError.removeAll();\n this.onError = null;\n this.onResize.removeAll();\n this.onResize = null;\n this.onUpdate.removeAll();\n this.onUpdate = null;\n }\n }\n\n /**\n * Abstract, used to auto-detect resource type.\n * @param {*} _source - The source object\n * @param {string} _extension - The extension of source, if set\n */\n static test(_source: unknown, _extension?: string): boolean\n {\n return false;\n }\n}\n", "import { ALPHA_MODES } from '@pixi/constants';\nimport { Resource } from './Resource';\n\nimport type { ISize } from '@pixi/math';\nimport type { Renderer } from '../../Renderer';\nimport type { BaseTexture } from '../BaseTexture';\nimport type { GLTexture } from '../GLTexture';\n\n/**\n * Buffer resource with data of typed array.\n * @memberof PIXI\n */\nexport class BufferResource extends Resource\n{\n /** Source array Cannot be {@code ClampedUint8Array} because it cant be uploaded to WebGL */\n data: Float32Array | Uint8Array | Uint16Array | Int32Array | Uint32Array;\n\n /**\n * @param source - Source buffer\n * @param options - Options\n * @param {number} options.width - Width of the texture\n * @param {number} options.height - Height of the texture\n */\n constructor(source: Float32Array | Uint8Array | Uint16Array | Int32Array | Uint32Array, options: ISize)\n {\n const { width, height } = options || {};\n\n if (!width || !height)\n {\n throw new Error('BufferResource width or height invalid');\n }\n\n super(width, height);\n\n this.data = source;\n }\n\n /**\n * Upload the texture to the GPU.\n * @param renderer - Upload to the renderer\n * @param baseTexture - Reference to parent texture\n * @param glTexture - glTexture\n * @returns - true is success\n */\n upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean\n {\n const gl = renderer.gl;\n\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);\n\n const width = baseTexture.realWidth;\n const height = baseTexture.realHeight;\n\n if (glTexture.width === width && glTexture.height === height)\n {\n gl.texSubImage2D(\n baseTexture.target,\n 0,\n 0,\n 0,\n width,\n height,\n baseTexture.format,\n glTexture.type,\n this.data\n );\n }\n else\n {\n glTexture.width = width;\n glTexture.height = height;\n\n gl.texImage2D(\n baseTexture.target,\n 0,\n glTexture.internalFormat,\n width,\n height,\n 0,\n baseTexture.format,\n glTexture.type,\n this.data\n );\n }\n\n return true;\n }\n\n /** Destroy and don't use after this. */\n dispose(): void\n {\n this.data = null;\n }\n\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @returns {boolean} `true` if \\