openspecui 1.5.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cli.mjs +251 -20
  2. package/dist/index.mjs +1 -1
  3. package/dist/{src-16GA3our.mjs → src-CVJCbdiP.mjs} +166 -24
  4. package/package.json +3 -3
  5. package/web/assets/{BufferResource-Bn1UWy0D.js → BufferResource-BFEntdoN.js} +1 -1
  6. package/web/assets/{CanvasRenderer-D8NiU8la.js → CanvasRenderer-ZQxN8ITJ.js} +1 -1
  7. package/web/assets/{Filter-CRwq487x.js → Filter-trCu1CQG.js} +1 -1
  8. package/web/assets/{RenderTargetSystem-CtoB_qTm.js → RenderTargetSystem-DHoDBu3v.js} +1 -1
  9. package/web/assets/{WebGLRenderer-BgKO8R0a.js → WebGLRenderer-DYS9LSzA.js} +1 -1
  10. package/web/assets/{WebGPURenderer-CQeL2efC.js → WebGPURenderer-CDj9ZzDs.js} +1 -1
  11. package/web/assets/{browserAll-DP6sOYev.js → browserAll-B8FBs1Rt.js} +1 -1
  12. package/web/assets/{ghostty-web-evxujSxm.js → ghostty-web-C6hNf21K.js} +1 -1
  13. package/web/assets/{index-B147AOgf.js → index-BByfw4ws.js} +1 -1
  14. package/web/assets/{index-D2Tp4F9B.js → index-BDu-q_RJ.js} +1 -1
  15. package/web/assets/{index-B0IbsqHi.js → index-BRrJSB9v.js} +1 -1
  16. package/web/assets/{index-CBCPR3Qb.js → index-CFiXnV5n.js} +1 -1
  17. package/web/assets/{index-D6ardy54.js → index-CLKNqdA1.js} +1 -1
  18. package/web/assets/{index-BPZ3nG0r.js → index-Cja7GFdu.js} +1 -1
  19. package/web/assets/{index-DcXyAs0z.js → index-Cq8vn29r.js} +1 -1
  20. package/web/assets/{index-f0QdJSzm.js → index-CqDTsKqD.js} +1 -1
  21. package/web/assets/{index-DTeOcXKn.js → index-CxCFae0J.js} +1 -1
  22. package/web/assets/{index-dSf1u0YV.js → index-CxF-jUR9.js} +1 -1
  23. package/web/assets/{index-BMashGQn.js → index-Dj2t_cJN.js} +1 -1
  24. package/web/assets/{index-BnT52DZ8.js → index-Drwn-PWd.js} +1 -1
  25. package/web/assets/index-DzNp3fwv.css +1 -0
  26. package/web/assets/{index-BejnsZfY.js → index-FMaDFama.js} +1 -1
  27. package/web/assets/index-YEDqrGu6.js +1540 -0
  28. package/web/assets/{index-DJqmTRAR.js → index-hID85NKg.js} +1 -1
  29. package/web/assets/{index-4MAU81Qk.js → index-vJWwTEOs.js} +1 -1
  30. package/web/assets/{webworkerAll-DA2HufNb.js → webworkerAll-Pgv9S8Bp.js} +1 -1
  31. package/web/index.html +2 -2
  32. package/web/assets/index-T8xoxmUb.js +0 -1516
  33. package/web/assets/index-Ys2MTD3W.css +0 -1
@@ -1817,47 +1817,50 @@ var OpenSpecAdapter = class {
1817
1817
  }
1818
1818
  /**
1819
1819
  * List changes with metadata (id, name, progress, and time info)
1820
- * Only returns changes that have valid proposal.md
1820
+ * Returns every change directory, including schema-specific layouts that
1821
+ * don't use proposal.md/tasks.md.
1821
1822
  * Sorted by updatedAt descending (most recent first)
1822
1823
  */
1823
1824
  async listChangesWithMeta() {
1824
1825
  const ids = await this.listChanges();
1825
1826
  return (await Promise.all(ids.map(async (id) => {
1826
1827
  const change = await this.readChange(id);
1827
- if (!change) return null;
1828
- const proposalPath = join(this.changesDir, id, "proposal.md");
1829
- const timeInfo = await this.getFileTimeInfo(proposalPath);
1828
+ const changeDir = join(this.changesDir, id);
1829
+ const timeInfo = await this.getFileTimeInfo(changeDir);
1830
1830
  return {
1831
1831
  id,
1832
- name: change.name,
1833
- progress: change.progress,
1832
+ name: change?.name ?? id,
1833
+ progress: change?.progress ?? {
1834
+ total: 0,
1835
+ completed: 0
1836
+ },
1834
1837
  createdAt: timeInfo?.createdAt ?? 0,
1835
1838
  updatedAt: timeInfo?.updatedAt ?? 0
1836
1839
  };
1837
- }))).filter((r) => r !== null).sort((a, b) => b.updatedAt - a.updatedAt);
1840
+ }))).sort((a, b) => b.updatedAt - a.updatedAt);
1838
1841
  }
1839
1842
  async listArchivedChanges() {
1840
1843
  return reactiveReadDir(this.archiveDir, { directoriesOnly: true });
1841
1844
  }
1842
1845
  /**
1843
1846
  * List archived changes with metadata and time info
1844
- * Only returns archives that have valid proposal.md
1847
+ * Returns every archive directory, including schema-specific layouts that
1848
+ * don't use proposal.md/tasks.md.
1845
1849
  * Sorted by updatedAt descending (most recent first)
1846
1850
  */
1847
1851
  async listArchivedChangesWithMeta() {
1848
1852
  const ids = await this.listArchivedChanges();
1849
1853
  return (await Promise.all(ids.map(async (id) => {
1850
1854
  const change = await this.readArchivedChange(id);
1851
- if (!change) return null;
1852
- const proposalPath = join(this.archiveDir, id, "proposal.md");
1853
- const timeInfo = await this.getFileTimeInfo(proposalPath);
1855
+ const archiveDir = join(this.archiveDir, id);
1856
+ const timeInfo = await this.getFileTimeInfo(archiveDir);
1854
1857
  return {
1855
1858
  id,
1856
- name: change.name,
1859
+ name: change?.name ?? id,
1857
1860
  createdAt: timeInfo?.createdAt ?? 0,
1858
1861
  updatedAt: timeInfo?.updatedAt ?? 0
1859
1862
  };
1860
- }))).filter((r) => r !== null).sort((a, b) => b.updatedAt - a.updatedAt);
1863
+ }))).sort((a, b) => b.updatedAt - a.updatedAt);
1861
1864
  }
1862
1865
  /**
1863
1866
  * Read project.md content (reactive)
@@ -5939,8 +5942,18 @@ const CURSOR_STYLE_VALUES = [
5939
5942
  "underline",
5940
5943
  "bar"
5941
5944
  ];
5945
+ const CODE_EDITOR_THEME_VALUES = [
5946
+ "github",
5947
+ "material",
5948
+ "vscode",
5949
+ "tokyo",
5950
+ "gruvbox",
5951
+ "monokai",
5952
+ "nord"
5953
+ ];
5942
5954
  const TERMINAL_RENDERER_ENGINE_VALUES = ["xterm", "ghostty"];
5943
5955
  const TerminalRendererEngineSchema = enumType(TERMINAL_RENDERER_ENGINE_VALUES);
5956
+ const CodeEditorThemeSchema = enumType(CODE_EDITOR_THEME_VALUES);
5944
5957
  const BASE_PACKAGE_MANAGER_RUNNERS = [
5945
5958
  {
5946
5959
  id: "npx",
@@ -6282,6 +6295,7 @@ const TerminalConfigSchema = objectType({
6282
6295
  rendererEngine: stringType().default("xterm")
6283
6296
  });
6284
6297
  const DashboardConfigSchema = objectType({ trendPointLimit: numberType().int().min(20).max(500).default(100) });
6298
+ const CodeEditorConfigSchema = objectType({ theme: CodeEditorThemeSchema.default("github") });
6285
6299
  /**
6286
6300
  * OpenSpecUI 配置 Schema
6287
6301
  *
@@ -6293,6 +6307,7 @@ const OpenSpecUIConfigSchema = objectType({
6293
6307
  args: arrayType(stringType()).optional()
6294
6308
  }).default({}),
6295
6309
  theme: enumType(THEME_VALUES).default("system"),
6310
+ codeEditor: CodeEditorConfigSchema.default(CodeEditorConfigSchema.parse({})),
6296
6311
  terminal: TerminalConfigSchema.default(TerminalConfigSchema.parse({})),
6297
6312
  dashboard: DashboardConfigSchema.default(DashboardConfigSchema.parse({}))
6298
6313
  });
@@ -6300,6 +6315,7 @@ const OpenSpecUIConfigSchema = objectType({
6300
6315
  const DEFAULT_CONFIG = {
6301
6316
  cli: {},
6302
6317
  theme: "system",
6318
+ codeEditor: CodeEditorConfigSchema.parse({}),
6303
6319
  terminal: TerminalConfigSchema.parse({}),
6304
6320
  dashboard: DashboardConfigSchema.parse({})
6305
6321
  };
@@ -6364,6 +6380,10 @@ var ConfigManager = class {
6364
6380
  ...current,
6365
6381
  cli: nextCli,
6366
6382
  theme: config.theme ?? current.theme,
6383
+ codeEditor: {
6384
+ ...current.codeEditor,
6385
+ ...config.codeEditor
6386
+ },
6367
6387
  terminal: {
6368
6388
  ...current.terminal,
6369
6389
  ...config.terminal
@@ -7094,6 +7114,68 @@ const DASHBOARD_METRIC_KEYS = [
7094
7114
  "taskCompletionPercent"
7095
7115
  ];
7096
7116
 
7117
+ //#endregion
7118
+ //#region ../core/src/opsx-display-path.ts
7119
+ const VIRTUAL_PROJECT_DIRNAME = "project";
7120
+ const WINDOWS_DRIVE_PREFIX = /^[A-Za-z]:\//;
7121
+ function normalizeFsPath(path$1) {
7122
+ return path$1.replace(/\\/g, "/").replace(/\/+$/g, "");
7123
+ }
7124
+ function isAbsolutePath(path$1) {
7125
+ return path$1.startsWith("/") || WINDOWS_DRIVE_PREFIX.test(path$1);
7126
+ }
7127
+ function stripRelativePrefix(path$1) {
7128
+ return path$1.replace(/^\.?\//, "");
7129
+ }
7130
+ function splitSegments(path$1) {
7131
+ return normalizeFsPath(path$1).split("/").filter(Boolean);
7132
+ }
7133
+ function toNpmSpecifier(path$1) {
7134
+ const normalized = normalizeFsPath(path$1);
7135
+ const match$1 = /(?:^|\/)node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(@[^/]+\/[^/]+|[^/]+)(\/.*)?/.exec(normalized);
7136
+ const pkgName = match$1?.[1];
7137
+ if (!pkgName) return null;
7138
+ return `npm:${pkgName}${match$1[2] ?? ""}`;
7139
+ }
7140
+ function toVirtualProjectPath(path$1) {
7141
+ return `${VIRTUAL_PROJECT_DIRNAME}:${stripRelativePrefix(path$1)}`;
7142
+ }
7143
+ function isPathInside(root, target) {
7144
+ const normalizedRoot = normalizeFsPath(root);
7145
+ const normalizedTarget = normalizeFsPath(target);
7146
+ const rootLower = normalizedRoot.toLowerCase();
7147
+ const targetLower = normalizedTarget.toLowerCase();
7148
+ return targetLower === rootLower || targetLower.startsWith(`${rootLower}/`);
7149
+ }
7150
+ function toRelativeFromRoot(root, target) {
7151
+ const rootSegments = splitSegments(root);
7152
+ const targetSegments = splitSegments(target);
7153
+ let index = 0;
7154
+ while (index < rootSegments.length && index < targetSegments.length) {
7155
+ if (rootSegments[index]?.toLowerCase() !== targetSegments[index]?.toLowerCase()) break;
7156
+ index += 1;
7157
+ }
7158
+ return targetSegments.slice(index).join("/");
7159
+ }
7160
+ function findOpspecSlice(path$1) {
7161
+ const segments = splitSegments(path$1);
7162
+ const idx = segments.lastIndexOf("openspec");
7163
+ if (idx < 0) return null;
7164
+ return segments.slice(idx).join("/");
7165
+ }
7166
+ function toOpsxDisplayPath(absoluteOrRelativePath, options) {
7167
+ const normalized = normalizeFsPath(absoluteOrRelativePath);
7168
+ const npmSpecifier = toNpmSpecifier(normalized);
7169
+ if (options?.source === "package" || npmSpecifier) {
7170
+ if (npmSpecifier) return npmSpecifier;
7171
+ }
7172
+ if (!isAbsolutePath(normalized)) return toVirtualProjectPath(normalized);
7173
+ if (options?.projectDir && isPathInside(options.projectDir, normalized)) return toVirtualProjectPath(toRelativeFromRoot(options.projectDir, normalized));
7174
+ const openspecSlice = findOpspecSlice(normalized);
7175
+ if (openspecSlice) return toVirtualProjectPath(openspecSlice);
7176
+ return toVirtualProjectPath(splitSegments(normalized).slice(-4).join("/"));
7177
+ }
7178
+
7097
7179
  //#endregion
7098
7180
  //#region ../core/src/opsx-types.ts
7099
7181
  const ArtifactStatusSchema = objectType({
@@ -7177,17 +7259,20 @@ const SchemaResolutionSchema = objectType({
7177
7259
  "package"
7178
7260
  ]),
7179
7261
  path: stringType(),
7262
+ displayPath: stringType().optional(),
7180
7263
  shadows: arrayType(objectType({
7181
7264
  source: enumType([
7182
7265
  "project",
7183
7266
  "user",
7184
7267
  "package"
7185
7268
  ]),
7186
- path: stringType()
7269
+ path: stringType(),
7270
+ displayPath: stringType().optional()
7187
7271
  }))
7188
7272
  });
7189
7273
  const TemplatesSchema = recordType(objectType({
7190
7274
  path: stringType(),
7275
+ displayPath: stringType().optional(),
7191
7276
  source: enumType([
7192
7277
  "project",
7193
7278
  "user",
@@ -13884,6 +13969,12 @@ function parseCliJson(raw$1, schema$6, label) {
13884
13969
  function toRelativePath(root, absolutePath) {
13885
13970
  return relative$1(root, absolutePath).split(sep).join("/");
13886
13971
  }
13972
+ function isAbsoluteFsPath(path$1) {
13973
+ return path$1.startsWith("/") || /^[A-Za-z]:\//.test(path$1);
13974
+ }
13975
+ function toAbsoluteProjectPath(projectDir, path$1) {
13976
+ return isAbsoluteFsPath(path$1.replace(/\\/g, "/")) ? path$1 : resolve$1(projectDir, path$1);
13977
+ }
13887
13978
  async function readEntriesUnderRoot(root) {
13888
13979
  if (!(await reactiveStat(root))?.isDirectory) return [];
13889
13980
  const collectEntries = async (dir) => {
@@ -14322,7 +14413,21 @@ var OpsxKernel = class {
14322
14413
  await touchOpsxProjectDeps(this.projectDir);
14323
14414
  const result = await this.cliExecutor.schemaWhich(name);
14324
14415
  if (!result.success) throw new Error(result.stderr || `openspec schema which failed (exit ${result.exitCode ?? "null"})`);
14325
- return parseCliJson(result.stdout, SchemaResolutionSchema, "openspec schema which");
14416
+ const parsed = parseCliJson(result.stdout, SchemaResolutionSchema, "openspec schema which");
14417
+ return {
14418
+ ...parsed,
14419
+ displayPath: toOpsxDisplayPath(parsed.path, {
14420
+ source: parsed.source,
14421
+ projectDir: this.projectDir
14422
+ }),
14423
+ shadows: parsed.shadows.map((shadow) => ({
14424
+ ...shadow,
14425
+ displayPath: toOpsxDisplayPath(shadow.path, {
14426
+ source: shadow.source,
14427
+ projectDir: this.projectDir
14428
+ })
14429
+ }))
14430
+ };
14326
14431
  }
14327
14432
  async fetchSchemaDetail(name) {
14328
14433
  await touchOpsxProjectDeps(this.projectDir);
@@ -14346,7 +14451,15 @@ var OpsxKernel = class {
14346
14451
  await touchOpsxProjectDeps(this.projectDir);
14347
14452
  const result = await this.cliExecutor.templates(schema$6);
14348
14453
  if (!result.success) throw new Error(result.stderr || `openspec templates failed (exit ${result.exitCode ?? "null"})`);
14349
- return parseCliJson(result.stdout, TemplatesSchema, "openspec templates");
14454
+ const templates = parseCliJson(result.stdout, TemplatesSchema, "openspec templates");
14455
+ return Object.fromEntries(Object.entries(templates).map(([artifactId, info]) => [artifactId, {
14456
+ ...info,
14457
+ path: toAbsoluteProjectPath(this.projectDir, info.path),
14458
+ displayPath: toOpsxDisplayPath(info.path, {
14459
+ source: info.source,
14460
+ projectDir: this.projectDir
14461
+ })
14462
+ }]));
14350
14463
  }
14351
14464
  async fetchTemplateContents(schema$6) {
14352
14465
  await this.ensureTemplates(schema$6);
@@ -14355,6 +14468,10 @@ var OpsxKernel = class {
14355
14468
  return [artifactId, {
14356
14469
  content: await reactiveReadFile(info.path),
14357
14470
  path: info.path,
14471
+ displayPath: info.displayPath ?? toOpsxDisplayPath(info.path, {
14472
+ source: info.source,
14473
+ projectDir: this.projectDir
14474
+ }),
14358
14475
  source: info.source
14359
14476
  }];
14360
14477
  }));
@@ -24048,6 +24165,35 @@ async function fetchDashboardOverview(ctx, reason = "dashboard-refresh") {
24048
24165
  ctx.adapter.listChangesWithMeta(),
24049
24166
  ctx.adapter.listArchivedChangesWithMeta()
24050
24167
  ]);
24168
+ await ctx.kernel.waitForWarmup();
24169
+ await ctx.kernel.ensureStatusList();
24170
+ const statusList = ctx.kernel.getStatusList();
24171
+ const changeMetaMap = new Map(changeMetas.map((change) => [change.id, change]));
24172
+ const activeChangeIds = new Set([...changeMetas.map((change) => change.id), ...statusList.map((status) => status.changeName)]);
24173
+ const statusByChange = new Map(statusList.map((status) => [status.changeName, status]));
24174
+ const activeChanges = (await Promise.all([...activeChangeIds].map(async (changeId) => {
24175
+ const status = statusByChange.get(changeId);
24176
+ const changeMeta = changeMetaMap.get(changeId);
24177
+ const statInfo = await reactiveStat(join$1(ctx.projectDir, "openspec", "changes", changeId));
24178
+ let progress = changeMeta?.progress ?? {
24179
+ total: 0,
24180
+ completed: 0
24181
+ };
24182
+ if (status) try {
24183
+ await ctx.kernel.ensureApplyInstructions(changeId, status.schemaName);
24184
+ const apply = ctx.kernel.getApplyInstructions(changeId, status.schemaName);
24185
+ progress = {
24186
+ total: apply.progress.total,
24187
+ completed: apply.progress.complete
24188
+ };
24189
+ } catch {}
24190
+ return {
24191
+ id: changeId,
24192
+ name: changeMeta?.name ?? changeId,
24193
+ progress,
24194
+ updatedAt: changeMeta?.updatedAt ?? statInfo?.mtime ?? 0
24195
+ };
24196
+ }))).sort((a, b) => b.updatedAt - a.updatedAt);
24051
24197
  const archivedChanges = (await Promise.all(archiveMetas.map(async (meta) => {
24052
24198
  const change = await ctx.adapter.readArchivedChange(meta.id);
24053
24199
  if (!change) return null;
@@ -24068,12 +24214,6 @@ async function fetchDashboardOverview(ctx, reason = "dashboard-refresh") {
24068
24214
  updatedAt: meta.updatedAt
24069
24215
  };
24070
24216
  }))).filter((item) => item !== null).sort((a, b) => b.requirements - a.requirements || b.updatedAt - a.updatedAt);
24071
- const activeChanges = changeMetas.map((change) => ({
24072
- id: change.id,
24073
- name: change.name,
24074
- progress: change.progress,
24075
- updatedAt: change.updatedAt
24076
- }));
24077
24217
  const requirements = specifications.reduce((sum, spec) => sum + spec.requirements, 0);
24078
24218
  const tasksTotal = activeChanges.reduce((sum, change) => sum + change.progress.total, 0);
24079
24219
  const tasksCompleted = activeChanges.reduce((sum, change) => sum + change.progress.completed, 0);
@@ -24404,6 +24544,7 @@ const configRouter = router({
24404
24544
  "dark",
24405
24545
  "system"
24406
24546
  ]).optional(),
24547
+ codeEditor: objectType({ theme: CodeEditorThemeSchema.optional() }).optional(),
24407
24548
  terminal: TerminalConfigSchema.omit({ rendererEngine: true }).partial().extend({ rendererEngine: TerminalRendererEngineSchema.optional() }).optional(),
24408
24549
  dashboard: DashboardConfigSchema.partial().optional()
24409
24550
  })).mutation(async ({ ctx, input }) => {
@@ -24411,8 +24552,9 @@ const configRouter = router({
24411
24552
  const hasCliArgs = input.cli !== void 0 && Object.prototype.hasOwnProperty.call(input.cli, "args");
24412
24553
  if (hasCliCommand && !hasCliArgs) {
24413
24554
  await ctx.configManager.setCliCommand(input.cli?.command ?? "");
24414
- if (input.theme !== void 0 || input.terminal !== void 0 || input.dashboard !== void 0) await ctx.configManager.writeConfig({
24555
+ if (input.theme !== void 0 || input.codeEditor !== void 0 || input.terminal !== void 0 || input.dashboard !== void 0) await ctx.configManager.writeConfig({
24415
24556
  theme: input.theme,
24557
+ codeEditor: input.codeEditor,
24416
24558
  terminal: input.terminal,
24417
24559
  dashboard: input.dashboard
24418
24560
  });
@@ -25370,4 +25512,4 @@ async function startServer$1(options = {}) {
25370
25512
  }
25371
25513
 
25372
25514
  //#endregion
25373
- export { SchemaInfoSchema as a, CliExecutor as c, OpenSpecAdapter as d, __commonJS$1 as f, SchemaDetailSchema as i, ConfigManager as l, createServer$2 as n, SchemaResolutionSchema as o, __toESM$1 as p, require_dist as r, TemplatesSchema as s, startServer$1 as t, DEFAULT_CONFIG as u };
25515
+ export { SchemaInfoSchema as a, toOpsxDisplayPath as c, DEFAULT_CONFIG as d, OpenSpecAdapter as f, SchemaDetailSchema as i, CliExecutor as l, __toESM$1 as m, createServer$2 as n, SchemaResolutionSchema as o, __commonJS$1 as p, require_dist as r, TemplatesSchema as s, startServer$1 as t, ConfigManager as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openspecui",
3
- "version": "1.5.1",
3
+ "version": "1.6.2",
4
4
  "description": "OpenSpec UI - Visual interface for spec-driven development",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -33,8 +33,8 @@
33
33
  "typescript": "^5.7.2",
34
34
  "vitest": "^2.1.8",
35
35
  "yargs": "^18.0.0",
36
- "@openspecui/web": "1.5.0",
37
- "@openspecui/server": "1.5.0"
36
+ "@openspecui/server": "1.6.2",
37
+ "@openspecui/web": "1.6.2"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "pnpm run build:web && pnpm run build:copy-web && tsdown",
@@ -1,4 +1,4 @@
1
- import{y as U,z as g,A as c,B as S,D as _,F as m,H as I,J as p}from"./index-T8xoxmUb.js";const x={name:"local-uniform-bit",vertex:{header:`
1
+ import{y as U,z as g,A as c,B as S,D as _,F as m,H as I,J as p}from"./index-YEDqrGu6.js";const x={name:"local-uniform-bit",vertex:{header:`
2
2
 
3
3
  struct LocalUniforms {
4
4
  uTransformMatrix:mat3x3<f32>,
@@ -1 +1 @@
1
- import{K as U,M as A,O as K,P as be,Q as ne,R as O,T as S,U as qe,y as Le,V as we,W as Ye,X as Ne,Y as Xe,Z as je,_ as $e,$ as Ke,a0 as Qe,a1 as ze,a2 as se}from"./index-T8xoxmUb.js";import{R as Je,S as Ze,B as et,a as tt,b as nt,c as at,A as st,C as ot}from"./RenderTargetSystem-CtoB_qTm.js";import"./Filter-CRwq487x.js";let $;function Me(s){const e=U.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=s,t.fillRect(0,0,6,1),e}function Se(){if($!==void 0)return $;try{const s=Me("#ff00ff"),e=Me("#ffff00"),a=U.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(s,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)$=!1;else{const o=n.data;$=o[0]===255&&o[1]===0&&o[2]===0}}catch{$=!1}return $}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Se(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const e=s.source,t=e?.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,o=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||o!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),u=l.data,m=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let v=0;v<u.length&&v+3<m.length;v+=4)u[v]=m[v+2],u[v+1]=m[v+1],u[v+2]=m[v],u[v+3]=m[v+3];else u.set(m.subarray(0,u.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=U.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let u=0;u<l.length;u+=4){const m=l[u+3];if(m>0){const v=255/m;l[u]=Math.min(255,l[u]*v+.5),l[u+1]=Math.min(255,l[u+1]*v+.5),l[u+2]=Math.min(255,l[u+2]*v+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(s,e)=>{const t=s.texture,a=K.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),o=n[a],r=t.source._resourceId;if(o?.tintId===r)return o;const i=o&&"getContext"in o?o:U.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(s,e)=>{const t=K.shared.setValue(e).toHex(),a=s.patternCache||(s.patternCache={}),n=s.source._resourceId;let o=a[t];return o?.tintId===n||(d.canvas||(d.canvas=U.get().createCanvas()),d.tintMethod(s,e,d.canvas),o=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),o.tintId=n,a[t]=o),o},applyPatternTransform:(s,e,t=!0)=>{if(!e)return;const a=s;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const o=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?o.inverse():o)},tintWithMultiply:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const u=e>>16&255,m=e>>8&255,v=e&255,k=a.getImageData(0,0,c,h),T=k.data;for(let C=0;C<T.length;C+=4)T[C]=T[C]*u/255,T[C+1]=T[C+1]*m/255,T[C+2]=T[C+2]*v/255;a.putImageData(k,0,0)},_applyInverseRotation:(s,e,t,a)=>{const n=A.inv(e),o=A.uX(n),r=A.uY(n),i=A.vX(n),c=A.vY(n),h=-Math.min(0,o*t,i*a,o*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);s.transform(o,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const fe=class L{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){const a=t.elements;if(!a||!a.length)return;const n=e.renderer,o=n.canvasContext,r=o.activeContext;for(let i=0;i<a.length;i++){const c=a[i];if(!c.packAsQuad)continue;const h=c,l=h.texture,u=l?d.getCanvasSource(l):null;if(!u)continue;const m=l.source.style,v=o.smoothProperty,k=m.scaleMode!=="nearest";r[v]!==k&&(r[v]=k),o.setBlendMode(t.blendMode);const T=n.globalUniforms.globalUniformData?.worldColor??4294967295,C=h.color,B=(T>>>24&255)/255,P=(C>>>24&255)/255,H=n.filter?.alphaMultiplier??1,V=B*P*H;if(V<=0)continue;r.globalAlpha=V;const J=T&16777215,b=C&16777215,F=be(ne(b,J)),W=l.frame,Q=m.addressModeU??m.addressMode,Y=m.addressModeV??m.addressMode,g=L._getPatternRepeat(Q,Y),y=l.source._resolution??l.source.resolution??1,x=h.renderable?.renderGroup?.isCachedAsTexture,G=W.x*y,N=W.y*y,w=W.width*y,E=W.height*y,_=h.bounds,I=n.renderTarget.renderTarget.isRoot,R=_.minX,z=_.minY,q=_.maxX-_.minX,D=_.maxY-_.minY,M=l.rotate,p=l.uvs,oe=Math.min(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),Ee=Math.max(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),ge=g!=="no-repeat"&&(oe<0||Ee>1),re=M&&!(!ge&&(F!==16777215||M));re?(L._tempPatternMatrix.copyFrom(h.transform),A.matrixAppendRotationInv(L._tempPatternMatrix,M,R,z,q,D),o.setContextTransform(L._tempPatternMatrix,h.roundPixels===1,void 0,x&&I)):o.setContextTransform(h.transform,h.roundPixels===1,void 0,x&&I);const Z=re?0:R,ee=re?0:z,ie=q,ce=D;if(ge){let le=u;const X=F!==16777215&&!M,j=W.width<=l.source.width&&W.height<=l.source.height;X&&j&&(le=d.getTintedCanvas({texture:l},F));const he=r.createPattern(le,g);if(!he)continue;const me=ie,ve=ce;if(me===0||ve===0)continue;const ye=1/me,Ce=1/ve,xe=(p.x1-p.x0)*ye,Te=(p.y1-p.y0)*ye,Pe=(p.x3-p.x0)*Ce,_e=(p.y3-p.y0)*Ce,Ve=p.x0-xe*Z-Pe*ee,Fe=p.y0-Te*Z-_e*ee,de=l.source.pixelWidth,pe=l.source.pixelHeight;L._tempPatternMatrix.set(xe*de,Te*pe,Pe*de,_e*pe,Ve*de,Fe*pe),d.applyPatternTransform(he,L._tempPatternMatrix),r.fillStyle=he,r.fillRect(Z,ee,ie,ce)}else{const X=F!==16777215||M?d.getTintedCanvas({texture:l},F):u,j=X!==u;r.drawImage(X,j?0:G,j?0:N,j?X.width:w,j?X.height:E,Z,ee,ie,ce)}}}};fe._tempPatternMatrix=new O;fe.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let rt=fe;class ke{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}ke.extension={type:[S.CanvasPipes],name:"colorMask"};function it(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function Ie(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;it(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.moveTo(t.x+t.radius,t.y),s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?(s.moveTo(t.x+t.halfWidth,t.y),s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.moveTo(1,0),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function ct(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ie(s,a.shape),o&&s.restore()}return!0}class Re{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a?.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const o=e.mask.mask;if(!(o instanceof qe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=o,i=r.context?.instructions;if(!i?.length){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let l=0;l<i.length;l++){const u=i[l],m=u.action;if(m!=="fill"&&m!=="stroke")continue;const k=u.data?.path?.shapePath;if(!k?.shapePrimitives?.length)continue;const T=k.shapePrimitives;for(let C=0;C<T.length;C++){const B=T[C];if(!B?.shape)continue;const P=B.transform,H=P&&!P.isIdentity();H&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),Ie(n,B.shape),h=ct(n,B.holes)||h,c=!0,H&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),Le(t))}}Re.extension={type:[S.CanvasPipes],name:"stencilMask"};const f="source-over";function lt(){const s=Se(),e=Object.create(null);return e.inherit=f,e.none=f,e.normal="source-over",e.add="lighter",e.multiply=s?"multiply":f,e.screen=s?"screen":f,e.overlay=s?"overlay":f,e.darken=s?"darken":f,e.lighten=s?"lighten":f,e["color-dodge"]=s?"color-dodge":f,e["color-burn"]=s?"color-burn":f,e["hard-light"]=s?"hard-light":f,e["soft-light"]=s?"soft-light":f,e.difference=s?"difference":f,e.exclusion=s?"exclusion":f,e.saturation=s?"saturation":f,e.color=s?"color":f,e.luminosity=s?"luminosity":f,e["linear-burn"]=s?"color-burn":f,e["linear-dodge"]=s?"color-dodge":f,e["linear-light"]=s?"hard-light":f,e["pin-light"]=s?"hard-light":f,e["vivid-light"]=s?"hard-light":f,e["hard-mix"]=f,e.negation=s?"difference":f,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=f,e.divide=f,e.min=f,e.max=f,e}const ht=new O;class Ae{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=lt(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){const o=n?O.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||O.IDENTITY;let r=ht;r.copyFrom(o),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const h=O.shared;h.copyFrom(r),h.prepend(i),r=h}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const o=K.shared.setValue(e);a.globalAlpha=t??o.alpha,a.fillStyle=o.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ae.extension={type:[S.CanvasSystem],name:"canvasContext"};class Be{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Be.extension={type:[S.CanvasSystem],name:"limits"};const dt="#808080",te=new O,pt=new O,ut=new O,ue=new O;function ft(s,e,t){s.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,o=t[a+1]*2,r=t[a+2]*2;s.moveTo(e[n],e[n+1]),s.lineTo(e[o],e[o+1]),s.lineTo(e[r],e[r+1]),s.closePath()}s.fill()}function gt(s){return`#${(s&16777215).toString(16).padStart(6,"0")}`}function mt(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function ae(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;mt(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function vt(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ae(s,a.shape),o&&s.restore()}return!0}function yt(s,e,t,a){const n=s.fill;if(n instanceof je){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?ue.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):ue.copyFrom(n.transform);return a&&!s.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof $e){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const o=s.texture;if(o&&o!==we.WHITE){if(!o.source.resource)return dt;const r=d.getTintedPattern(o,e),i=t?ue.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):s.matrix;return d.applyPatternTransform(r,i),r}return gt(e)}class He{constructor(){this.shader=null}contextChange(e){}execute(e,t){const a=e.renderer,n=a.canvasContext,o=n.activeContext,r=t.groupTransform,i=a.globalUniforms.globalUniformData?.worldColor??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,u=a.filter?.alphaMultiplier??1,m=h*l*u;if(m<=0)return;const v=i&16777215,k=c&16777215,T=be(ne(k,v)),C=a._roundPixels|t._roundPixels;o.save(),n.setContextTransform(r,C===1),n.setBlendMode(t.groupBlendMode);const B=t.context.instructions;for(let P=0;P<B.length;P++){const H=B[P];if(H.action==="texture"){const g=H.data,y=g.image,x=y?d.getCanvasSource(y):null;if(!x)continue;const G=g.alpha*m;if(G<=0)continue;const N=ne(g.style,T);o.globalAlpha=G;let w=x;N!==16777215&&(w=d.getTintedCanvas({texture:y},N));const E=y.frame,_=y.source._resolution??y.source.resolution??1;let I=E.x*_,R=E.y*_;const z=E.width*_,q=E.height*_;w!==x&&(I=0,R=0);const D=g.transform,M=D&&!D.isIdentity(),p=y.rotate;M||p?(te.copyFrom(r),M&&te.append(D),p&&A.matrixAppendRotationInv(te,p,g.dx,g.dy,g.dw,g.dh),n.setContextTransform(te,C===1)):n.setContextTransform(r,C===1),o.drawImage(w,I,R,w===x?z:w.width,w===x?q:w.height,p?0:g.dx,p?0:g.dy,g.dw,g.dh),(M||p)&&n.setContextTransform(r,C===1);continue}const V=H.data,J=V?.path?.shapePath;if(!J?.shapePrimitives?.length)continue;const b=V.style,F=ne(b.color,T),W=b.alpha*m;if(W<=0)continue;const Q=H.action==="stroke";if(o.globalAlpha=W,Q){const g=b;o.lineWidth=g.width,o.lineCap=g.cap,o.lineJoin=g.join,o.miterLimit=g.miterLimit}const Y=J.shapePrimitives;if(!Q&&V.hole?.shapePath?.shapePrimitives?.length){const g=Y[Y.length-1];g.holes=V.hole.shapePath.shapePrimitives}for(let g=0;g<Y.length;g++){const y=Y[g];if(!y?.shape)continue;const x=y.transform,G=x&&!x.isIdentity(),N=b.texture&&b.texture!==we.WHITE,w=b.textureSpace==="global"?x:null,E=N?Ye(pt,b,y.shape,w):null,_=G?ut.copyFrom(r).append(x):r,I=yt(b,F,E,_);if(G&&(o.save(),o.transform(x.a,x.b,x.c,x.d,x.tx,x.ty)),Q){const R=b;if(R.alignment!==.5&&!R.pixelLine){const q=[],D=[],M=[];if(Ne[y.shape.type]?.build(y.shape,q)){const oe=y.shape.closePath??!0;Xe(q,R,!1,oe,D,M),o.fillStyle=I,ft(o,D,M)}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.fillStyle=I,o.beginPath(),ae(o,y.shape),vt(o,y.holes)?o.fill("evenodd"):o.fill();G&&o.restore()}}o.restore()}destroy(){this.shader=null}}He.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class Ct{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const o=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=o.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=K.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,o){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=o?.x??0,u=o?.y??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,u,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Ke.test(t))&&(t=U.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class We extends Je{constructor(e){super(e),this.adaptor=new Ct,this.adaptor.init(e,this)}}We.extension={type:[S.CanvasSystem],name:"renderTarget"};class De{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=U.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const o=e.frame,r=e.source._resolution??e.source.resolution??1,i=o.x*r,c=o.y*r,h=o.width*r,l=o.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}De.extension={type:[S.CanvasSystem],name:"texture"};const xt=[...Ze,Ae,Be,De,We],Tt=[et,tt,nt,at,st,Re,ke,ot],Pt=[rt,He],Ue=[],Oe=[],Ge=[];se.handleByNamedList(S.CanvasSystem,Ue);se.handleByNamedList(S.CanvasPipes,Oe);se.handleByNamedList(S.CanvasPipesAdaptor,Ge);se.add(...xt,...Tt,...Pt);class St extends Qe{constructor(){const e={name:"canvas",type:ze.CANVAS,systems:Ue,renderPipes:Oe,renderPipeAdaptors:Ge};super(e)}}export{St as CanvasRenderer};
1
+ import{K as U,M as A,O as K,P as be,Q as ne,R as O,T as S,U as qe,y as Le,V as we,W as Ye,X as Ne,Y as Xe,Z as je,_ as $e,$ as Ke,a0 as Qe,a1 as ze,a2 as se}from"./index-YEDqrGu6.js";import{R as Je,S as Ze,B as et,a as tt,b as nt,c as at,A as st,C as ot}from"./RenderTargetSystem-DHoDBu3v.js";import"./Filter-trCu1CQG.js";let $;function Me(s){const e=U.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=s,t.fillRect(0,0,6,1),e}function Se(){if($!==void 0)return $;try{const s=Me("#ff00ff"),e=Me("#ffff00"),a=U.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(s,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)$=!1;else{const o=n.data;$=o[0]===255&&o[1]===0&&o[2]===0}}catch{$=!1}return $}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Se(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const e=s.source,t=e?.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,o=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||o!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),u=l.data,m=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let v=0;v<u.length&&v+3<m.length;v+=4)u[v]=m[v+2],u[v+1]=m[v+1],u[v+2]=m[v],u[v+3]=m[v+3];else u.set(m.subarray(0,u.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=U.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let u=0;u<l.length;u+=4){const m=l[u+3];if(m>0){const v=255/m;l[u]=Math.min(255,l[u]*v+.5),l[u+1]=Math.min(255,l[u+1]*v+.5),l[u+2]=Math.min(255,l[u+2]*v+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(s,e)=>{const t=s.texture,a=K.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),o=n[a],r=t.source._resourceId;if(o?.tintId===r)return o;const i=o&&"getContext"in o?o:U.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(s,e)=>{const t=K.shared.setValue(e).toHex(),a=s.patternCache||(s.patternCache={}),n=s.source._resourceId;let o=a[t];return o?.tintId===n||(d.canvas||(d.canvas=U.get().createCanvas()),d.tintMethod(s,e,d.canvas),o=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),o.tintId=n,a[t]=o),o},applyPatternTransform:(s,e,t=!0)=>{if(!e)return;const a=s;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const o=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?o.inverse():o)},tintWithMultiply:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const u=e>>16&255,m=e>>8&255,v=e&255,k=a.getImageData(0,0,c,h),T=k.data;for(let C=0;C<T.length;C+=4)T[C]=T[C]*u/255,T[C+1]=T[C+1]*m/255,T[C+2]=T[C+2]*v/255;a.putImageData(k,0,0)},_applyInverseRotation:(s,e,t,a)=>{const n=A.inv(e),o=A.uX(n),r=A.uY(n),i=A.vX(n),c=A.vY(n),h=-Math.min(0,o*t,i*a,o*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);s.transform(o,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const fe=class L{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){const a=t.elements;if(!a||!a.length)return;const n=e.renderer,o=n.canvasContext,r=o.activeContext;for(let i=0;i<a.length;i++){const c=a[i];if(!c.packAsQuad)continue;const h=c,l=h.texture,u=l?d.getCanvasSource(l):null;if(!u)continue;const m=l.source.style,v=o.smoothProperty,k=m.scaleMode!=="nearest";r[v]!==k&&(r[v]=k),o.setBlendMode(t.blendMode);const T=n.globalUniforms.globalUniformData?.worldColor??4294967295,C=h.color,B=(T>>>24&255)/255,P=(C>>>24&255)/255,H=n.filter?.alphaMultiplier??1,V=B*P*H;if(V<=0)continue;r.globalAlpha=V;const J=T&16777215,b=C&16777215,F=be(ne(b,J)),W=l.frame,Q=m.addressModeU??m.addressMode,Y=m.addressModeV??m.addressMode,g=L._getPatternRepeat(Q,Y),y=l.source._resolution??l.source.resolution??1,x=h.renderable?.renderGroup?.isCachedAsTexture,G=W.x*y,N=W.y*y,w=W.width*y,E=W.height*y,_=h.bounds,I=n.renderTarget.renderTarget.isRoot,R=_.minX,z=_.minY,q=_.maxX-_.minX,D=_.maxY-_.minY,M=l.rotate,p=l.uvs,oe=Math.min(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),Ee=Math.max(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),ge=g!=="no-repeat"&&(oe<0||Ee>1),re=M&&!(!ge&&(F!==16777215||M));re?(L._tempPatternMatrix.copyFrom(h.transform),A.matrixAppendRotationInv(L._tempPatternMatrix,M,R,z,q,D),o.setContextTransform(L._tempPatternMatrix,h.roundPixels===1,void 0,x&&I)):o.setContextTransform(h.transform,h.roundPixels===1,void 0,x&&I);const Z=re?0:R,ee=re?0:z,ie=q,ce=D;if(ge){let le=u;const X=F!==16777215&&!M,j=W.width<=l.source.width&&W.height<=l.source.height;X&&j&&(le=d.getTintedCanvas({texture:l},F));const he=r.createPattern(le,g);if(!he)continue;const me=ie,ve=ce;if(me===0||ve===0)continue;const ye=1/me,Ce=1/ve,xe=(p.x1-p.x0)*ye,Te=(p.y1-p.y0)*ye,Pe=(p.x3-p.x0)*Ce,_e=(p.y3-p.y0)*Ce,Ve=p.x0-xe*Z-Pe*ee,Fe=p.y0-Te*Z-_e*ee,de=l.source.pixelWidth,pe=l.source.pixelHeight;L._tempPatternMatrix.set(xe*de,Te*pe,Pe*de,_e*pe,Ve*de,Fe*pe),d.applyPatternTransform(he,L._tempPatternMatrix),r.fillStyle=he,r.fillRect(Z,ee,ie,ce)}else{const X=F!==16777215||M?d.getTintedCanvas({texture:l},F):u,j=X!==u;r.drawImage(X,j?0:G,j?0:N,j?X.width:w,j?X.height:E,Z,ee,ie,ce)}}}};fe._tempPatternMatrix=new O;fe.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let rt=fe;class ke{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}ke.extension={type:[S.CanvasPipes],name:"colorMask"};function it(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function Ie(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;it(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.moveTo(t.x+t.radius,t.y),s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?(s.moveTo(t.x+t.halfWidth,t.y),s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.moveTo(1,0),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function ct(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ie(s,a.shape),o&&s.restore()}return!0}class Re{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a?.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const o=e.mask.mask;if(!(o instanceof qe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=o,i=r.context?.instructions;if(!i?.length){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let l=0;l<i.length;l++){const u=i[l],m=u.action;if(m!=="fill"&&m!=="stroke")continue;const k=u.data?.path?.shapePath;if(!k?.shapePrimitives?.length)continue;const T=k.shapePrimitives;for(let C=0;C<T.length;C++){const B=T[C];if(!B?.shape)continue;const P=B.transform,H=P&&!P.isIdentity();H&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),Ie(n,B.shape),h=ct(n,B.holes)||h,c=!0,H&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),Le(t))}}Re.extension={type:[S.CanvasPipes],name:"stencilMask"};const f="source-over";function lt(){const s=Se(),e=Object.create(null);return e.inherit=f,e.none=f,e.normal="source-over",e.add="lighter",e.multiply=s?"multiply":f,e.screen=s?"screen":f,e.overlay=s?"overlay":f,e.darken=s?"darken":f,e.lighten=s?"lighten":f,e["color-dodge"]=s?"color-dodge":f,e["color-burn"]=s?"color-burn":f,e["hard-light"]=s?"hard-light":f,e["soft-light"]=s?"soft-light":f,e.difference=s?"difference":f,e.exclusion=s?"exclusion":f,e.saturation=s?"saturation":f,e.color=s?"color":f,e.luminosity=s?"luminosity":f,e["linear-burn"]=s?"color-burn":f,e["linear-dodge"]=s?"color-dodge":f,e["linear-light"]=s?"hard-light":f,e["pin-light"]=s?"hard-light":f,e["vivid-light"]=s?"hard-light":f,e["hard-mix"]=f,e.negation=s?"difference":f,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=f,e.divide=f,e.min=f,e.max=f,e}const ht=new O;class Ae{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=lt(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){const o=n?O.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||O.IDENTITY;let r=ht;r.copyFrom(o),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const h=O.shared;h.copyFrom(r),h.prepend(i),r=h}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const o=K.shared.setValue(e);a.globalAlpha=t??o.alpha,a.fillStyle=o.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ae.extension={type:[S.CanvasSystem],name:"canvasContext"};class Be{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Be.extension={type:[S.CanvasSystem],name:"limits"};const dt="#808080",te=new O,pt=new O,ut=new O,ue=new O;function ft(s,e,t){s.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,o=t[a+1]*2,r=t[a+2]*2;s.moveTo(e[n],e[n+1]),s.lineTo(e[o],e[o+1]),s.lineTo(e[r],e[r+1]),s.closePath()}s.fill()}function gt(s){return`#${(s&16777215).toString(16).padStart(6,"0")}`}function mt(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function ae(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;mt(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function vt(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ae(s,a.shape),o&&s.restore()}return!0}function yt(s,e,t,a){const n=s.fill;if(n instanceof je){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?ue.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):ue.copyFrom(n.transform);return a&&!s.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof $e){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const o=s.texture;if(o&&o!==we.WHITE){if(!o.source.resource)return dt;const r=d.getTintedPattern(o,e),i=t?ue.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):s.matrix;return d.applyPatternTransform(r,i),r}return gt(e)}class He{constructor(){this.shader=null}contextChange(e){}execute(e,t){const a=e.renderer,n=a.canvasContext,o=n.activeContext,r=t.groupTransform,i=a.globalUniforms.globalUniformData?.worldColor??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,u=a.filter?.alphaMultiplier??1,m=h*l*u;if(m<=0)return;const v=i&16777215,k=c&16777215,T=be(ne(k,v)),C=a._roundPixels|t._roundPixels;o.save(),n.setContextTransform(r,C===1),n.setBlendMode(t.groupBlendMode);const B=t.context.instructions;for(let P=0;P<B.length;P++){const H=B[P];if(H.action==="texture"){const g=H.data,y=g.image,x=y?d.getCanvasSource(y):null;if(!x)continue;const G=g.alpha*m;if(G<=0)continue;const N=ne(g.style,T);o.globalAlpha=G;let w=x;N!==16777215&&(w=d.getTintedCanvas({texture:y},N));const E=y.frame,_=y.source._resolution??y.source.resolution??1;let I=E.x*_,R=E.y*_;const z=E.width*_,q=E.height*_;w!==x&&(I=0,R=0);const D=g.transform,M=D&&!D.isIdentity(),p=y.rotate;M||p?(te.copyFrom(r),M&&te.append(D),p&&A.matrixAppendRotationInv(te,p,g.dx,g.dy,g.dw,g.dh),n.setContextTransform(te,C===1)):n.setContextTransform(r,C===1),o.drawImage(w,I,R,w===x?z:w.width,w===x?q:w.height,p?0:g.dx,p?0:g.dy,g.dw,g.dh),(M||p)&&n.setContextTransform(r,C===1);continue}const V=H.data,J=V?.path?.shapePath;if(!J?.shapePrimitives?.length)continue;const b=V.style,F=ne(b.color,T),W=b.alpha*m;if(W<=0)continue;const Q=H.action==="stroke";if(o.globalAlpha=W,Q){const g=b;o.lineWidth=g.width,o.lineCap=g.cap,o.lineJoin=g.join,o.miterLimit=g.miterLimit}const Y=J.shapePrimitives;if(!Q&&V.hole?.shapePath?.shapePrimitives?.length){const g=Y[Y.length-1];g.holes=V.hole.shapePath.shapePrimitives}for(let g=0;g<Y.length;g++){const y=Y[g];if(!y?.shape)continue;const x=y.transform,G=x&&!x.isIdentity(),N=b.texture&&b.texture!==we.WHITE,w=b.textureSpace==="global"?x:null,E=N?Ye(pt,b,y.shape,w):null,_=G?ut.copyFrom(r).append(x):r,I=yt(b,F,E,_);if(G&&(o.save(),o.transform(x.a,x.b,x.c,x.d,x.tx,x.ty)),Q){const R=b;if(R.alignment!==.5&&!R.pixelLine){const q=[],D=[],M=[];if(Ne[y.shape.type]?.build(y.shape,q)){const oe=y.shape.closePath??!0;Xe(q,R,!1,oe,D,M),o.fillStyle=I,ft(o,D,M)}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.fillStyle=I,o.beginPath(),ae(o,y.shape),vt(o,y.holes)?o.fill("evenodd"):o.fill();G&&o.restore()}}o.restore()}destroy(){this.shader=null}}He.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class Ct{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const o=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=o.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=K.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,o){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=o?.x??0,u=o?.y??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,u,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Ke.test(t))&&(t=U.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class We extends Je{constructor(e){super(e),this.adaptor=new Ct,this.adaptor.init(e,this)}}We.extension={type:[S.CanvasSystem],name:"renderTarget"};class De{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=U.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const o=e.frame,r=e.source._resolution??e.source.resolution??1,i=o.x*r,c=o.y*r,h=o.width*r,l=o.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}De.extension={type:[S.CanvasSystem],name:"texture"};const xt=[...Ze,Ae,Be,De,We],Tt=[et,tt,nt,at,st,Re,ke,ot],Pt=[rt,He],Ue=[],Oe=[],Ge=[];se.handleByNamedList(S.CanvasSystem,Ue);se.handleByNamedList(S.CanvasPipes,Oe);se.handleByNamedList(S.CanvasPipesAdaptor,Ge);se.add(...xt,...Tt,...Pt);class St extends Qe{constructor(){const e={name:"canvas",type:ze.CANVAS,systems:Ue,renderPipes:Oe,renderPipeAdaptors:Ge};super(e)}}export{St as CanvasRenderer};
@@ -1 +1 @@
1
- import{S as n,r as u,G as o,u as f}from"./index-T8xoxmUb.js";const s=class i extends n{constructor(e){e={...i.defaultOptions,...e},super(e),this.enabled=!0,this._state=u.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,a,r){e.applyFilter(this,t,a,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:a,...r}=e;let l,d;return t&&(l=o.from(t)),a&&(d=f.from(a)),new i({gpuProgram:l,glProgram:d,...r})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let b=s;export{b as F};
1
+ import{S as n,r as u,G as o,u as f}from"./index-YEDqrGu6.js";const s=class i extends n{constructor(e){e={...i.defaultOptions,...e},super(e),this.enabled=!0,this._state=u.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,a,r){e.applyFilter(this,t,a,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:a,...r}=e;let l,d;return t&&(l=o.from(t)),a&&(d=f.from(a)),new i({gpuProgram:l,glProgram:d,...r})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let b=s;export{b as F};
@@ -1,4 +1,4 @@
1
- import{al as Ve,af as oe,R as m,G as Ne,u as je,r as $e,am as le,T as l,a2 as W,an as w,ao as qe,ap as z,aq as T,a1 as V,ar as de,as as Ke,V as f,A as g,ad as D,at as ue,y as ce,au as ee,av as he,aw as pe,ax as fe,ay as me,a7 as P,az as Ye,O as E,K as N,ae as y,aA as G,aB as Je,a5 as Xe,aC as Qe,ab as Ze,a3 as te,aD as re,aE as p,J as et,$ as O,aF as tt,aG as rt,aH as st,aI as nt}from"./index-T8xoxmUb.js";import{F as at}from"./Filter-CRwq487x.js";var it=`in vec2 vMaskCoord;
1
+ import{al as Ve,af as oe,R as m,G as Ne,u as je,r as $e,am as le,T as l,a2 as W,an as w,ao as qe,ap as z,aq as T,a1 as V,ar as de,as as Ke,V as f,A as g,ad as D,at as ue,y as ce,au as ee,av as he,aw as pe,ax as fe,ay as me,a7 as P,az as Ye,O as E,K as N,ae as y,aA as G,aB as Je,a5 as Xe,aC as Qe,ab as Ze,a3 as te,aD as re,aE as p,J as et,$ as O,aF as tt,aG as rt,aH as st,aI as nt}from"./index-YEDqrGu6.js";import{F as at}from"./Filter-trCu1CQG.js";var it=`in vec2 vMaskCoord;
2
2
  in vec2 vTextureCoord;
3
3
 
4
4
  uniform sampler2D uTexture;
@@ -1,4 +1,4 @@
1
- import{K as R,r as F,T as d,a9 as P,F as B,y as b,z,u as Be,S as O,V as S,aJ as ye,ae as q,aK as Ne,A as g,aA as V,$ as y,ad as N,af as M,R as Z,aL as J,aM as Ce,aN as De,aO as Q,aP as Ie,a0 as Ge,a1 as Ue,a2 as A}from"./index-T8xoxmUb.js";import{e as Fe,G as Pe,c as Oe,b as Me,U as Le,B as ee,d as C,f as te,g as we}from"./BufferResource-Bn1UWy0D.js";import{R as He,S as Ve,d as Xe}from"./RenderTargetSystem-CtoB_qTm.js";import"./Filter-CRwq487x.js";function ke(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,a=this._didUploadHash[n.uid];s.shader.bind(n,a),a||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let a=0;a<r.textures.count;a++)n.texture.bind(s[a],a);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class We{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const a=this._boundBufferBases[s];if(a&&a._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:a}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,a.bindBufferRange(a.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,a=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,a)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,a)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new We(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(b("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,a=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:a,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&b("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&b("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,a=this.extensions;n.uint32Indices=s||!!a.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!a.vertexArrayObject,n.srgbTextures=s||!!a.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||b("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let je=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const X={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function Ke(t){return X[t]??X.float32}const $e={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Ye{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ae{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,a,i,o)=>{n.drawArraysInstancedANGLE(s,a,i,o)},e.drawElementsInstanced=(s,a,i,o,c)=>{n.drawElementsInstancedANGLE(s,a,i,o,c)},e.vertexAttribDivisor=(s,a)=>n.vertexAttribDivisorANGLE(s,a)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const a in s)if(!n[a])throw new Error(`shader and geometry incompatible, geometry missing the "${a}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,a=["g",e.uid];for(const i in n)s[i]&&a.push(i,s[i].location);return a.join("-")}getVao(e,r){return e._gpuData[this._renderer.uid]?.vaoCache[r._key]||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,a=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const i=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new Ye,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const c=o.vaoCache;let u=c[i];if(u)return c[r._key]=u,u;Fe(e,r._attributeData);const _=e.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let f=0;f<_.length;f++){const h=_[f];a.bind(h)}return this.activateVao(e,r),c[r._key]=u,c[i]=u,s.bindVertexArray(null),u}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const a in s)this._activeVao!==s[a]&&this.resetState(),this.gl.deleteVertexArray(s[a])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){const n=this._renderer.gl,s=this._renderer.buffer,a=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let i=null;for(const o in a){const c=a[o],u=c.buffer,_=s.getGlBuffer(u),f=r._attributeData[o];if(f){i!==_&&(s.bind(u),i=_);const h=f.location;n.enableVertexAttribArray(h);const m=z(c.format),p=Ke(c.format);if(f.format?.substring(1,4)==="int"?n.vertexAttribIPointer(h,m.size,p,c.stride,c.offset):n.vertexAttribPointer(h,m.size,p,m.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const E=c.divisor??1;n.vertexAttribDivisor(h,E)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:a}=this._renderer,i=this._activeGeometry,o=$e[e||i.topology];if(s??(s=i.instanceCount),i.indexBuffer){const c=i.indexBuffer.data.BYTES_PER_ELEMENT,u=c===2?a.UNSIGNED_SHORT:a.UNSIGNED_INT;s!==1?a.drawElementsInstanced(o,r||i.indexBuffer.data.length,u,(n||0)*c,s):a.drawElements(o,r||i.indexBuffer.data.length,u,(n||0)*c)}else s!==1?a.drawArraysInstanced(o,n||0,r||i.getSize(),s):a.drawArrays(o,n||0,r||i.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ae.extension={type:[d.WebGLSystem],name:"geometry"};const ze=new ye({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ie{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ie.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(b("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new Be({vertex:`
1
+ import{K as R,r as F,T as d,a9 as P,F as B,y as b,z,u as Be,S as O,V as S,aJ as ye,ae as q,aK as Ne,A as g,aA as V,$ as y,ad as N,af as M,R as Z,aL as J,aM as Ce,aN as De,aO as Q,aP as Ie,a0 as Ge,a1 as Ue,a2 as A}from"./index-YEDqrGu6.js";import{e as Fe,G as Pe,c as Oe,b as Me,U as Le,B as ee,d as C,f as te,g as we}from"./BufferResource-BFEntdoN.js";import{R as He,S as Ve,d as Xe}from"./RenderTargetSystem-DHoDBu3v.js";import"./Filter-trCu1CQG.js";function ke(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,a=this._didUploadHash[n.uid];s.shader.bind(n,a),a||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let a=0;a<r.textures.count;a++)n.texture.bind(s[a],a);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class We{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const a=this._boundBufferBases[s];if(a&&a._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:a}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,a.bindBufferRange(a.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,a=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,a)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,a)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new We(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(b("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,a=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:a,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&b("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&b("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,a=this.extensions;n.uint32Indices=s||!!a.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!a.vertexArrayObject,n.srgbTextures=s||!!a.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||b("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let je=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const X={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function Ke(t){return X[t]??X.float32}const $e={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Ye{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ae{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,a,i,o)=>{n.drawArraysInstancedANGLE(s,a,i,o)},e.drawElementsInstanced=(s,a,i,o,c)=>{n.drawElementsInstancedANGLE(s,a,i,o,c)},e.vertexAttribDivisor=(s,a)=>n.vertexAttribDivisorANGLE(s,a)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const a in s)if(!n[a])throw new Error(`shader and geometry incompatible, geometry missing the "${a}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,a=["g",e.uid];for(const i in n)s[i]&&a.push(i,s[i].location);return a.join("-")}getVao(e,r){return e._gpuData[this._renderer.uid]?.vaoCache[r._key]||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,a=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const i=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new Ye,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const c=o.vaoCache;let u=c[i];if(u)return c[r._key]=u,u;Fe(e,r._attributeData);const _=e.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let f=0;f<_.length;f++){const h=_[f];a.bind(h)}return this.activateVao(e,r),c[r._key]=u,c[i]=u,s.bindVertexArray(null),u}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const a in s)this._activeVao!==s[a]&&this.resetState(),this.gl.deleteVertexArray(s[a])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){const n=this._renderer.gl,s=this._renderer.buffer,a=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let i=null;for(const o in a){const c=a[o],u=c.buffer,_=s.getGlBuffer(u),f=r._attributeData[o];if(f){i!==_&&(s.bind(u),i=_);const h=f.location;n.enableVertexAttribArray(h);const m=z(c.format),p=Ke(c.format);if(f.format?.substring(1,4)==="int"?n.vertexAttribIPointer(h,m.size,p,c.stride,c.offset):n.vertexAttribPointer(h,m.size,p,m.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const E=c.divisor??1;n.vertexAttribDivisor(h,E)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:a}=this._renderer,i=this._activeGeometry,o=$e[e||i.topology];if(s??(s=i.instanceCount),i.indexBuffer){const c=i.indexBuffer.data.BYTES_PER_ELEMENT,u=c===2?a.UNSIGNED_SHORT:a.UNSIGNED_INT;s!==1?a.drawElementsInstanced(o,r||i.indexBuffer.data.length,u,(n||0)*c,s):a.drawElements(o,r||i.indexBuffer.data.length,u,(n||0)*c)}else s!==1?a.drawArraysInstanced(o,n||0,r||i.getSize(),s):a.drawArrays(o,n||0,r||i.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ae.extension={type:[d.WebGLSystem],name:"geometry"};const ze=new ye({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ie{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ie.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(b("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new Be({vertex:`
2
2
  attribute vec2 aPosition;
3
3
  out vec2 vUv;
4
4