@eva/plugin-renderer-spine36 2.0.2 → 2.1.0-beta.10

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.
@@ -4,24 +4,106 @@ globalThis.EVA.plugin = globalThis.EVA.plugin || {};
4
4
  globalThis.EVA.plugin.renderer = globalThis.EVA.plugin.renderer || {};
5
5
  var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
6
6
  'use strict';
7
-
8
- function getIDEPropsPropertyObj(target, propertyKey) {
9
- if (!target.constructor.IDEProps) {
10
- target.constructor.IDEProps = {};
7
+ function __rest(s, e) {
8
+ var t = {};
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
10
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
11
12
  }
12
- if (!target.constructor.IDEProps[propertyKey]) {
13
- target.constructor.IDEProps[propertyKey] = {};
13
+ return t;
14
+ }
15
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
16
+ var e = new Error(message);
17
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
18
+ };
19
+ class SymbolKeysNotSupportedError extends Error {
20
+ constructor() {
21
+ super('Symbol keys are not supported yet!');
22
+ Object.setPrototypeOf(this, new.target.prototype);
14
23
  }
15
- var propertyObj = target.constructor.IDEProps[propertyKey];
16
- return propertyObj;
24
+ }
25
+ const IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
26
+ function transformBasicType(type) {
27
+ if (type === String) {
28
+ return 'string';
29
+ }
30
+ if (type === Number) {
31
+ return 'number';
32
+ }
33
+ if (type === Boolean) {
34
+ return 'boolean';
35
+ }
36
+ return 'unknown';
37
+ }
38
+ function defineLegacyIDEProp(target, propertyKey, patch) {
39
+ const constructor = target.constructor;
40
+ const current = constructor.IDEProps || {};
41
+ current[propertyKey] = _extends(_extends({
42
+ key: propertyKey
43
+ }, current[propertyKey]), patch);
44
+ constructor.IDEProps = current;
45
+ }
46
+ function defineTypes(target, key, options, returnTypeFunction) {
47
+ let type = Reflect.getMetadata('design:type', target, key);
48
+ let isArray = type === Array;
49
+ const str = transformBasicType(type);
50
+ if (str !== 'unknown') {
51
+ type = str;
52
+ }
53
+ if (returnTypeFunction) {
54
+ const returnType = returnTypeFunction();
55
+ if (Array.isArray(returnType)) {
56
+ isArray = true;
57
+ type = returnType[0];
58
+ } else {
59
+ type = returnType;
60
+ }
61
+ }
62
+ const properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
63
+ const current = properties[key] || {};
64
+ const property = _extends(_extends(_extends({}, current), {
65
+ type,
66
+ isArray: isArray
67
+ }), options);
68
+ properties[key] = property;
69
+ Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
70
+ const legacyProperty = __rest(property, ["isArray"]);
71
+ defineLegacyIDEProp(target, key, legacyProperty);
17
72
  }
18
73
  function type(type) {
19
- return function (target, propertyKey) {
20
- var prop = getIDEPropsPropertyObj(target, propertyKey);
21
- prop.key = propertyKey;
22
- prop.type = type;
74
+ return Field({
75
+ type
76
+ });
77
+ }
78
+ function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
79
+ if (typeof returnTypeFuncOrOptions === 'function') {
80
+ return {
81
+ returnTypeFunc: returnTypeFuncOrOptions,
82
+ options: maybeOptions || {}
83
+ };
84
+ }
85
+ return {
86
+ options: returnTypeFuncOrOptions || {}
87
+ };
88
+ }
89
+ function Field(returnTypeFunction, maybeOptions) {
90
+ return (target, propertyKey) => {
91
+ if (typeof propertyKey === 'symbol') {
92
+ throw new SymbolKeysNotSupportedError();
93
+ }
94
+ const {
95
+ options,
96
+ returnTypeFunc
97
+ } = getTypeDecoratorParams(returnTypeFunction, maybeOptions);
98
+ defineTypes(target, propertyKey, options, returnTypeFunc);
23
99
  };
24
100
  }
101
+ var ExecuteMode;
102
+ (function (ExecuteMode) {
103
+ ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
104
+ ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
105
+ ExecuteMode[ExecuteMode["All"] = 6] = "All";
106
+ })(ExecuteMode || (ExecuteMode = {}));
25
107
  function __decorate(decorators, target, key, desc) {
26
108
  var c = arguments.length,
27
109
  r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
@@ -29,6 +111,9 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
29
111
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30
112
  return c > 3 && r && Object.defineProperty(target, key, r), r;
31
113
  }
114
+ function __metadata(metadataKey, metadataValue) {
115
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
116
+ }
32
117
  function __awaiter(thisArg, _arguments, P, generator) {
33
118
  function adopt(value) {
34
119
  return value instanceof P ? value : new P(function (resolve) {
@@ -61,20 +146,27 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
61
146
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
62
147
  };
63
148
  class Spine$2 extends eva_js.Component {
64
- constructor() {
65
- super(...arguments);
149
+ constructor(params) {
150
+ super(params);
66
151
  this.resource = '';
67
152
  this.scale = 1;
68
153
  this.animationName = '';
69
154
  this.autoPlay = true;
70
155
  this.keepResource = false;
156
+ this.timeScale = 1;
157
+ this.skin = '';
71
158
  this._slotGameObjects = new Map();
72
159
  this._pendingSlotObjects = [];
73
160
  this.waitExecuteInfos = [];
161
+ this.listenerBound = false;
162
+ this.paused = false;
163
+ this.init(params);
74
164
  }
75
165
  set armature(val) {
76
166
  this._armature = val;
77
167
  if (!val) return;
168
+ this.applyTimeScale();
169
+ if (this.skin) this.setSkin(this.skin);
78
170
  if (this.autoPlay) {
79
171
  this.play(this.animationName);
80
172
  }
@@ -96,12 +188,59 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
96
188
  return this._armature;
97
189
  }
98
190
  init(obj) {
99
- if (!obj) return;
100
- _extends(this, obj);
191
+ if (obj) _extends(this, obj);
192
+ if (!this.listenerBound) {
193
+ this.listenerBound = true;
194
+ this.on('start', event => {
195
+ var _a;
196
+ (_a = this.onStart) === null || _a === void 0 ? void 0 : _a.call(this, event);
197
+ });
198
+ this.on('complete', event => {
199
+ var _a;
200
+ (_a = this.onComplete) === null || _a === void 0 ? void 0 : _a.call(this, event);
201
+ });
202
+ this.on('event', (track, event) => {
203
+ var _a;
204
+ (_a = this.onEvent) === null || _a === void 0 ? void 0 : _a.call(this, track, event);
205
+ });
206
+ }
101
207
  }
102
208
  onDestroy() {
103
209
  this.destroied = true;
104
210
  }
211
+ load() {
212
+ return this.armature;
213
+ }
214
+ destroy() {
215
+ this.onDestroy();
216
+ if (this.armature && !this.armature.destroyed) {
217
+ this._destroySlotGameObjects();
218
+ this.armature.destroy({
219
+ children: true
220
+ });
221
+ }
222
+ this.armature = null;
223
+ }
224
+ pause() {
225
+ this.paused = true;
226
+ this.applyTimeScale();
227
+ }
228
+ resume() {
229
+ this.paused = false;
230
+ this.applyTimeScale();
231
+ }
232
+ setSkin(name) {
233
+ var _a, _b, _c, _d, _e;
234
+ this.skin = name;
235
+ if (!((_a = this.armature) === null || _a === void 0 ? void 0 : _a.skeleton)) return;
236
+ if (this.armature.skeleton.setSkinByName) {
237
+ this.armature.skeleton.setSkinByName(name);
238
+ } else if (this.armature.skeleton.setSkin) {
239
+ const skin = ((_c = (_b = this.armature.skeleton.data) === null || _b === void 0 ? void 0 : _b.findSkin) === null || _c === void 0 ? void 0 : _c.call(_b, name)) || name;
240
+ this.armature.skeleton.setSkin(skin);
241
+ }
242
+ (_e = (_d = this.armature.skeleton).setSlotsToSetupPose) === null || _e === void 0 ? void 0 : _e.call(_d);
243
+ }
105
244
  play(name, loopAnimation, track) {
106
245
  try {
107
246
  const loop = loopAnimation !== null && loopAnimation !== void 0 ? loopAnimation : this.autoPlay;
@@ -117,6 +256,7 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
117
256
  if (track === undefined) {
118
257
  track = 0;
119
258
  }
259
+ this.applyTimeScale();
120
260
  this.armature.state.setAnimation(track, this.animationName, loop);
121
261
  }
122
262
  } catch (e) {
@@ -136,6 +276,11 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
136
276
  }
137
277
  this.armature.state.setEmptyAnimation(track, 0);
138
278
  }
279
+ applyTimeScale() {
280
+ var _a;
281
+ if (!((_a = this.armature) === null || _a === void 0 ? void 0 : _a.state)) return;
282
+ this.armature.state.timeScale = this.paused ? 0 : this.timeScale;
283
+ }
139
284
  addAnimation(name, delay, loop, track) {
140
285
  try {
141
286
  if (!this.armature) {} else {
@@ -266,12 +411,20 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
266
411
  }
267
412
  }
268
413
  Spine$2.componentName = 'Spine';
269
- __decorate([type('string')], Spine$2.prototype, "resource", void 0);
270
- __decorate([type('number')], Spine$2.prototype, "scale", void 0);
271
- __decorate([type('string')], Spine$2.prototype, "animationName", void 0);
272
- __decorate([type('boolean')], Spine$2.prototype, "autoPlay", void 0);
273
- __decorate([type('boolean')], Spine$2.prototype, "keepResource", void 0);
414
+ __decorate([type('string'), __metadata("design:type", String)], Spine$2.prototype, "resource", void 0);
415
+ __decorate([type('number'), __metadata("design:type", Number)], Spine$2.prototype, "scale", void 0);
416
+ __decorate([type('string'), __metadata("design:type", String)], Spine$2.prototype, "animationName", void 0);
417
+ __decorate([type('boolean'), __metadata("design:type", Boolean)], Spine$2.prototype, "autoPlay", void 0);
418
+ __decorate([type('boolean'), __metadata("design:type", Boolean)], Spine$2.prototype, "keepResource", void 0);
419
+ __decorate([type('number'), __metadata("design:type", Number)], Spine$2.prototype, "timeScale", void 0);
420
+ __decorate([type('string'), __metadata("design:type", String)], Spine$2.prototype, "skin", void 0);
274
421
  let dataMap = {};
422
+ function resolveImageSrc(image) {
423
+ var _a, _b, _c, _d, _e;
424
+ if (!image) return '';
425
+ if (typeof image === 'string') return image;
426
+ return image.label || ((_a = image.source) === null || _a === void 0 ? void 0 : _a.label) || ((_c = (_b = image.source) === null || _b === void 0 ? void 0 : _b.resource) === null || _c === void 0 ? void 0 : _c.src) || ((_d = image.source) === null || _d === void 0 ? void 0 : _d._sourceOrigin) || image.src || ((_e = image.baseTexture) === null || _e === void 0 ? void 0 : _e.cacheId) || '';
427
+ }
275
428
  function createSpineData(name, data, scale, pixiSpine) {
276
429
  const skeletonAsset = data.ske;
277
430
  const atlasAsset = data.atlas;
@@ -282,7 +435,7 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
282
435
  const obj = {
283
436
  spineData: skeletonData,
284
437
  ref: 0,
285
- imageSrc: data.image.label
438
+ imageSrc: resolveImageSrc(data.image)
286
439
  };
287
440
  dataMap[name] = obj;
288
441
  return obj;
@@ -363,13 +516,25 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
363
516
  }, false);
364
517
  }
365
518
  update(e) {
519
+ super.update();
366
520
  for (let key in this.armatures) {
367
- this.armatures[key].update(e.deltaTime * 0.001);
521
+ const armature = this.armatures[key];
522
+ const component = this._spineComponents[key];
523
+ if (!armature || armature.destroyed || (component === null || component === void 0 ? void 0 : component.destroied)) {
524
+ delete this.armatures[key];
525
+ delete this._spineComponents[key];
526
+ continue;
527
+ }
528
+ armature.update(e.deltaTime * 0.001);
368
529
  }
369
530
  for (let key in this._spineComponents) {
370
- this._spineComponents[key]._flushPendingSlotObjects();
531
+ const component = this._spineComponents[key];
532
+ if (!component || component.destroied) {
533
+ delete this._spineComponents[key];
534
+ continue;
535
+ }
536
+ component._flushPendingSlotObjects();
371
537
  }
372
- super.update();
373
538
  }
374
539
  componentChanged(changed) {
375
540
  return __awaiter(this, void 0, void 0, function* () {
@@ -396,12 +561,12 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
396
561
  const gameObjectId = changed.gameObject.id;
397
562
  const asyncId = this.increaseAsyncId(gameObjectId);
398
563
  const res = yield eva_js.resource.getResource(component.resource);
399
- if (!this.validateAsyncId(gameObjectId, asyncId)) return;
564
+ if (!this.validateAsyncId(gameObjectId, asyncId) || component.destroied || changed.gameObject.destroyed) return;
400
565
  const spineData = yield getSpineData(res, component.scale, this.pixiSpine);
401
- if (!this.validateAsyncId(gameObjectId, asyncId)) return;
566
+ if (!this.validateAsyncId(gameObjectId, asyncId) || component.destroied || changed.gameObject.destroyed) return;
402
567
  if (!spineData) {
403
568
  component.addHandler = setTimeout(() => {
404
- if (!component.destroied) {
569
+ if (!component.destroied && !changed.gameObject.destroyed) {
405
570
  if (count === undefined) {
406
571
  count = MaxRetryCount;
407
572
  }
@@ -417,7 +582,7 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
417
582
  }
418
583
  this.remove(changed);
419
584
  const container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
420
- if (!container) {
585
+ if (!container || component.destroied || changed.gameObject.destroyed) {
421
586
  return;
422
587
  }
423
588
  component.lastResource = component.resource;
@@ -477,28 +642,36 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
477
642
  remove(changed) {
478
643
  var _a, _b, _c, _d, _e, _f;
479
644
  return __awaiter(this, void 0, void 0, function* () {
480
- this.increaseAsyncId(changed.gameObject.id);
645
+ const gameObjectId = changed.gameObject.id;
646
+ this.increaseAsyncId(gameObjectId);
481
647
  const component = changed.component;
482
648
  clearTimeout(component.addHandler);
483
- const armature = this.armatures[changed.gameObject.id];
484
- const container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
649
+ const armature = this.armatures[gameObjectId];
650
+ const container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(gameObjectId);
485
651
  if (container && armature) {
486
652
  container.removeChild(armature);
487
653
  }
488
- if (component.armature) {
654
+ const componentArmature = component.armature;
655
+ component.armature = null;
656
+ delete this.armatures[gameObjectId];
657
+ delete this._spineComponents[gameObjectId];
658
+ if (componentArmature) {
489
659
  component._destroySlotGameObjects();
490
- component.armature.destroy({
491
- children: true
492
- });
493
- if (!component.keepResource) {
494
- const res = yield eva_js.resource.getResource(component.lastResource);
495
- ((_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src) || ((_f = (_e = res.data) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.label);
496
- releaseSpineData(res);
660
+ if (!componentArmature.destroyed) {
661
+ componentArmature.destroy({
662
+ children: true
663
+ });
664
+ }
665
+ if (!component.keepResource && component.lastResource) {
666
+ try {
667
+ const res = yield eva_js.resource.getResource(component.lastResource);
668
+ const imageSrc = ((_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src) || ((_f = (_e = res.data) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.label);
669
+ releaseSpineData(res, imageSrc);
670
+ } catch (error) {
671
+ console.warn('Failed to release Spine resource', component.lastResource, error);
672
+ }
497
673
  }
498
674
  }
499
- component.armature = null;
500
- delete this.armatures[changed.gameObject.id];
501
- delete this._spineComponents[changed.gameObject.id];
502
675
  if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
503
676
  });
504
677
  }
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_spine36=function(t,e,s,i){"use strict";function n(t){return function(e,s){var i=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,s);i.key=s,i.type=t}}function r(t,e,s,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(a=(r<3?n(a):r>3?n(e,s,a):n(e,s))||a);return r>3&&a&&Object.defineProperty(e,s,a),a}function a(t,e,s,i){return new(s||(s=Promise))(function(n,r){function a(t){try{l(i.next(t))}catch(t){r(t)}}function o(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(a,o)}l((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class o extends e.Component{constructor(){super(...arguments),this.resource="",this.scale=1,this.animationName="",this.autoPlay=!0,this.keepResource=!1,this._slotGameObjects=new Map,this._pendingSlotObjects=[],this.waitExecuteInfos=[]}set armature(t){if(this._armature=t,t){this.autoPlay&&this.play(this.animationName);for(const t of this.waitExecuteInfos)if(t.playType){const{name:e,loop:s,track:i}=t;this.play(e,s,i)}else this.stop(t.track);this.waitExecuteInfos=[]}}get armature(){return this._armature}init(t){t&&_extends(this,t)}onDestroy(){this.destroied=!0}play(t,e,s){try{const i=null!=e?e:this.autoPlay;t&&(this.animationName=t),this.armature?(void 0===s&&(s=0),this.armature.state.setAnimation(s,this.animationName,i)):this.waitExecuteInfos.push({playType:!0,name:t,loop:i,track:s})}catch(t){console.log(t)}}stop(t){this.armature?(void 0===t&&(t=0),this.armature.state.setEmptyAnimation(t,0)):this.waitExecuteInfos.push({playType:!1,track:t})}addAnimation(t,e,s,i){try{this.armature&&(void 0===i&&(i=0),this.armature.state.addAnimation(i,t,s,e))}catch(t){console.log(t)}}setMix(t,e,s){this.armature&&this.armature.state.data.setMix(t,e,s)}getAnim(t=0){try{if(this.armature)return this.armature.state.tracks[t].animation.name}catch(t){console.log(t)}}setDefaultMix(t){this.armature&&(this.armature.state.data.defaultMix=t)}setAttachment(t,e){this.armature&&this.armature.skeleton.setAttachment(t,e)}getBone(t){if(this.armature)return this.armature.skeleton.findBone(t)}addSlotObject(t,e,s){if(!this.armature)return void console.warn("Spine armature is not ready, cannot addSlotObject");if(!this._containerManager)return void console.warn("ContainerManager is not available");const i=this._containerManager.getContainer(e.id);i?this._doAddSlotObject(t,e,i,s):this._pendingSlotObjects.push({slot:t,gameObject:e,options:s})}_doAddSlotObject(t,e,s,n){const r=new i.Container;r.addChild(s),this.armature.addSlotObject(t,r,n),this._slotGameObjects.set(e,{slot:t,wrapper:r}),this._syncTransformTree(e)}_syncTransformTree(t){var e;if(this._containerManager&&(this._containerManager.updateTransform({name:t.id,transform:t.transform}),null===(e=t.transform)||void 0===e?void 0:e.children))for(const e of t.transform.children)e.gameObject&&this._syncTransformTree(e.gameObject)}_flushPendingSlotObjects(){if(0===this._pendingSlotObjects.length)return;if(!this.armature||!this._containerManager)return;const t=[];for(const e of this._pendingSlotObjects){const s=this._containerManager.getContainer(e.gameObject.id);s?this._doAddSlotObject(e.slot,e.gameObject,s,e.options):t.push(e)}this._pendingSlotObjects=t}removeSlotObject(t){this._pendingSlotObjects=this._pendingSlotObjects.filter(e=>e.gameObject!==t);const e=this._slotGameObjects.get(t);e&&this.armature&&(this.armature.removeSlotObject(e.wrapper),e.wrapper.destroy({children:!1})),this._slotGameObjects.delete(t)}_destroySlotGameObjects(){for(const[t,e]of this._slotGameObjects)t.destroyed||(this.armature&&this.armature.removeSlotObject(e.wrapper),e.wrapper.destroy({children:!1}),t.destroy());this._slotGameObjects.clear(),this._pendingSlotObjects=[]}}o.componentName="Spine",r([n("string")],o.prototype,"resource",void 0),r([n("number")],o.prototype,"scale",void 0),r([n("string")],o.prototype,"animationName",void 0),r([n("boolean")],o.prototype,"autoPlay",void 0),r([n("boolean")],o.prototype,"keepResource",void 0);let l={};function h(t,e,s){return a(this,void 0,void 0,function*(){let i=l[t.name];if(!i)if(t.complete)i=function(t,e,s,i){const n=e.ske,r=e.atlas,a=new i.AtlasAttachmentLoader(r),o=n instanceof Uint8Array?new i.SkeletonBinary(a):new i.SkeletonJson(a);o.scale=s||1;const h={spineData:o.readSkeletonData(n),ref:0,imageSrc:e.image.label};return l[t]=h,h}(t.name,t.data,e,s);else if(!i)return;return i.ref++,i.spineData})}let d=class extends s.Renderer{constructor(){super(...arguments),this.armatures={},this._spineComponents={}}init({pixiSpine:t}){this.renderSystem=this.game.getSystem(s.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=t,this.game.canvas.addEventListener("webglcontextrestored",()=>{const t=this.game.gameObjects;let s=[];for(let i in this.armatures){const n=+i;for(let i=0;i<t.length;++i){let r=t[i];if(r.id===n){let t=r.getComponent(o);t&&(this.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:r,component:t,componentName:o.componentName}),s.push({type:e.OBSERVER_TYPE.ADD,gameObject:r,component:t,componentName:o.componentName}));break}}}setTimeout(()=>{s.forEach(t=>{this.add(t)})},1e3)},!1)}update(t){for(let e in this.armatures)this.armatures[e].update(.001*t.deltaTime);for(let t in this._spineComponents)this._spineComponents[t]._flushPendingSlotObjects();super.update()}componentChanged(t){return a(this,void 0,void 0,function*(){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE){if("resource"===t.prop.prop[0])this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t)})}add(t,s){var i,n,r;return a(this,void 0,void 0,function*(){const a=t.component;clearTimeout(a.addHandler);const o=t.gameObject.id,l=this.increaseAsyncId(o),d=yield e.resource.getResource(a.resource);if(!this.validateAsyncId(o,l))return;const c=yield h(d,a.scale,this.pixiSpine);if(!this.validateAsyncId(o,l))return;if(!c)return void(a.addHandler=setTimeout(()=>{a.destroied||(void 0===s&&(s=20),--s>0?this.add(t,s):console.log("retry exceed max times",a.resource))},1e3));this.remove(t);const u=null===(n=null===(i=this.renderSystem)||void 0===i?void 0:i.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id);if(!u)return;a.lastResource=a.resource;const p=new this.pixiSpine.Spine({skeletonData:c,autoUpdate:!1});if(this.armatures[t.gameObject.id]=p,this._spineComponents[t.gameObject.id]=a,t.gameObject&&t.gameObject.transform){const e=t.gameObject.transform;p.x=e.size.width*e.origin.x,p.y=e.size.height*e.origin.y}u.addChildAt(p,0),p.update(),a._containerManager=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager,a.armature=p,a.emit("loaded",{resource:a.resource}),p.state.addListener({start:(t,e)=>{a.emit("start",{track:t,name:t.animation.name})},complete:(t,e)=>{a.emit("complete",{track:t,name:t.animation.name})},interrupt:(t,e)=>{a.emit("interrupt",{track:t,name:t.animation.name})},end:(t,e)=>{a.emit("end",{track:t,name:t.animation.name})},event:(t,e)=>{a.emit("event",t,e)}})})}change(t){this.remove(t),this.add(t)}remove(t){var s,i,n,r,o,h;return a(this,void 0,void 0,function*(){this.increaseAsyncId(t.gameObject.id);const d=t.component;clearTimeout(d.addHandler);const c=this.armatures[t.gameObject.id],u=null===(i=null===(s=this.renderSystem)||void 0===s?void 0:s.containerManager)||void 0===i?void 0:i.getContainer(t.gameObject.id);if(u&&c&&u.removeChild(c),d.armature&&(d._destroySlotGameObjects(),d.armature.destroy({children:!0}),!d.keepResource)){const t=yield e.resource.getResource(d.lastResource);(null===(r=null===(n=t.data)||void 0===n?void 0:n.image)||void 0===r?void 0:r.src)||null===(h=null===(o=t.data)||void 0===o?void 0:o.image)||void 0===h||h.label,function(t){const s=t.name,i=l[s];i&&(i.ref--,setTimeout(()=>a(this,void 0,void 0,function*(){i.ref<=0&&(e.resource.destroy(s),delete l[s])}),100))}(t)}d.armature=null,delete this.armatures[t.gameObject.id],delete this._spineComponents[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE})}};d.systemName="SpineSystem",d=r([e.decorators.componentObserver({Spine:["resource"]})],d);var c=d;e.resource.registerResourceType("SPINE");var u=Object.defineProperty,p=Object.defineProperties,m=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,w=(t,e,s)=>e in t?u(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,b=(t,e)=>{for(var s in e||(e={}))f.call(e,s)&&w(t,s,e[s]);if(g)for(var s of g(e))x.call(e,s)&&w(t,s,e[s]);return t},y=(t,e)=>p(t,m(e)),E=(t,e,s)=>w(t,"symbol"!=typeof e?e+"":e,s),T=(t,e,s)=>new Promise((i,n)=>{var r=t=>{try{o(s.next(t))}catch(t){n(t)}},a=t=>{try{o(s.throw(t))}catch(t){n(t)}},o=t=>t.done?i(t.value):Promise.resolve(t.value).then(r,a);o((s=s.apply(t,e)).next())});if("undefined"!=typeof window&&window.PIXI){const t=window.require;window.require=e=>t?t(e):e.startsWith("@pixi/")||e.startsWith("pixi.js")?window.PIXI:void 0}class A{constructor(t){if(E(this,"name"),null==t)throw new Error("name cannot be null.");this.name=t}}const C=class t extends A{constructor(e){super(e),E(this,"id",(65535&t.nextID++)<<11),E(this,"bones"),E(this,"vertices"),E(this,"worldVerticesLength",0)}computeWorldVertices(t,e,s,i,n,r){s=n+(s>>1)*r;let a=t.bone.skeleton,o=t.attachmentVertices,l=this.vertices,h=this.bones;if(null==h){o.length>0&&(l=o);let a=t.bone,h=a.worldX,d=a.worldY,c=a.a,u=a.b,p=a.c,m=a.d;for(let t=e,a=n;a<s;t+=2,a+=r){let e=l[t],s=l[t+1];i[a]=e*c+s*u+h,i[a+1]=e*p+s*m+d}return}let d=0,c=0;for(let t=0;t<e;t+=2){let t=h[d];d+=t+1,c+=t}let u=a.bones;if(0==o.length)for(let t=n,e=3*c;t<s;t+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,e+=3){let t=u[h[d]],i=l[e],r=l[e+1],a=l[e+2];s+=(i*t.a+r*t.b+t.worldX)*a,n+=(i*t.c+r*t.d+t.worldY)*a}i[t]=s,i[t+1]=n}else{let t=o;for(let e=n,a=3*c,o=c<<1;e<s;e+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,a+=3,o+=2){let e=u[h[d]],i=l[a]+t[o],r=l[a+1]+t[o+1],c=l[a+2];s+=(i*e.a+r*e.b+e.worldX)*c,n+=(i*e.c+r*e.d+e.worldY)*c}i[e]=s,i[e+1]=n}}}applyDeform(t){return this==t}};E(C,"nextID",0);let S=C;class M{constructor(){E(this,"array",new Array)}add(t){let e=this.contains(t);return this.array[0|t]=0|t,!e}contains(t){return null!=this.array[0|t]}remove(t){this.array[0|t]=void 0}clear(){this.array.length=0}}const v=class{constructor(t=0,e=0,s=0,i=0){this.r=t,this.g=e,this.b=s,this.a=i}set(t,e,s,i){return this.r=t,this.g=e,this.b=s,this.a=i,this.clamp(),this}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=(8!=t.length?255:parseInt(t.substr(6,2),16))/255,this}add(t,e,s,i){return this.r+=t,this.g+=e,this.b+=s,this.a+=i,this.clamp(),this}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}};E(v,"WHITE",new v(1,1,1,1)),E(v,"RED",new v(1,0,0,1)),E(v,"GREEN",new v(0,1,0,1)),E(v,"BLUE",new v(0,0,1,1)),E(v,"MAGENTA",new v(1,0,1,1));let R=v;const P=class t{static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(e){return Math.cos(e*t.degRad)}static sinDeg(e){return Math.sin(e*t.degRad)}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(e,s){return t.randomTriangularWith(e,s,.5*(e+s))}static randomTriangularWith(t,e,s){let i=Math.random(),n=e-t;return i<=(s-t)/n?t+Math.sqrt(i*n*(s-t)):e-Math.sqrt((1-i)*n*(e-s))}};E(P,"PI",3.1415927),E(P,"PI2",2*P.PI),E(P,"radiansToDegrees",180/P.PI),E(P,"radDeg",P.radiansToDegrees),E(P,"degreesToRadians",P.PI/180),E(P,"degRad",P.degreesToRadians);let I=P;class k{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class V extends k{constructor(t){super(),E(this,"power",2),this.power=t}applyInternal(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow(2*(t-1),this.power)/(this.power%2==0?-2:2)+1}}class _ extends V{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}}const D=class t{static arrayCopy(t,e,s,i,n){for(let r=e,a=i;r<e+n;r++,a++)s[a]=t[r]}static setArraySize(t,e,s=0){let i=t.length;if(i==e)return t;if(t.length=e,i<e)for(let n=i;n<e;n++)t[n]=s;return t}static ensureArrayCapacity(e,s,i=0){return e.length>=s?e:t.setArraySize(e,s,i)}static newArray(t,e){let s=new Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static newShortArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static toFloatArray(e){return t.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e}static toSinglePrecision(e){return t.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e}static webkit602BugfixHelper(t,e){}};E(D,"SUPPORTS_TYPED_ARRAYS","undefined"!=typeof Float32Array);let N=D;class O{constructor(t){E(this,"items",new Array),E(this,"instantiator"),this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset&&t.reset(),this.items.push(t)}freeAll(t){for(let e=0;e<t.length;e++)t[e].reset&&t[e].reset(),this.items[e]=t[e]}clear(){this.items.length=0}}class L{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){let t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){let t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this}}class Y{constructor(t,e,s){if(E(this,"name"),E(this,"timelines"),E(this,"duration"),null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.duration=s}apply(t,e,s,i,n,r,a,o){if(null==t)throw new Error("skeleton cannot be null.");i&&0!=this.duration&&(s%=this.duration,e>0&&(e%=this.duration));let l=this.timelines;for(let i=0,h=l.length;i<h;i++)l[i].apply(t,e,s,n,r,a,o)}static binarySearch(t,e,s=1){let i=0,n=t.length/s-2;if(0==n)return s;let r=n>>>1;for(;;){if(t[(r+1)*s]<=e?i=r+1:n=r,i==n)return(i+1)*s;r=i+n>>>1}}static linearSearch(t,e,s){for(let i=0,n=t.length-s;i<=n;i+=s)if(t[i]>e)return i;return-1}}var F,X,B,j=((F=j||{})[F.setup=0]="setup",F[F.current=1]="current",F[F.currentLayered=2]="currentLayered",F),W=((X=W||{})[X.in=0]="in",X[X.out=1]="out",X),U=((B=U||{})[B.rotate=0]="rotate",B[B.translate=1]="translate",B[B.scale=2]="scale",B[B.shear=3]="shear",B[B.attachment=4]="attachment",B[B.color=5]="color",B[B.deform=6]="deform",B[B.event=7]="event",B[B.drawOrder=8]="drawOrder",B[B.ikConstraint=9]="ikConstraint",B[B.transformConstraint=10]="transformConstraint",B[B.pathConstraintPosition=11]="pathConstraintPosition",B[B.pathConstraintSpacing=12]="pathConstraintSpacing",B[B.pathConstraintMix=13]="pathConstraintMix",B[B.twoColor=14]="twoColor",B);const q=class t{constructor(e){if(E(this,"curves"),e<=0)throw new Error("frameCount must be > 0: "+e);this.curves=N.newFloatArray((e-1)*t.BEZIER_SIZE)}getFrameCount(){return this.curves.length/t.BEZIER_SIZE+1}setLinear(e){this.curves[e*t.BEZIER_SIZE]=t.LINEAR}setStepped(e){this.curves[e*t.BEZIER_SIZE]=t.STEPPED}getCurveType(e){let s=e*t.BEZIER_SIZE;if(s==this.curves.length)return t.LINEAR;let i=this.curves[s];return i==t.LINEAR?t.LINEAR:i==t.STEPPED?t.STEPPED:t.BEZIER}setCurve(e,s,i,n,r){let a=.03*(2*-s+n),o=.03*(2*-i+r),l=.006*(3*(s-n)+1),h=.006*(3*(i-r)+1),d=2*a+l,c=2*o+h,u=.3*s+a+.16666667*l,p=.3*i+o+.16666667*h,m=e*t.BEZIER_SIZE,g=this.curves;g[m++]=t.BEZIER;let f=u,x=p;for(let e=m+t.BEZIER_SIZE-1;m<e;m+=2)g[m]=f,g[m+1]=x,u+=d,p+=c,d+=l,c+=h,f+=u,x+=p}getCurvePercent(e,s){s=I.clamp(s,0,1);let i=this.curves,n=e*t.BEZIER_SIZE,r=i[n];if(r==t.LINEAR)return s;if(r==t.STEPPED)return 0;n++;let a=0;for(let e=n,r=n+t.BEZIER_SIZE-1;n<r;n+=2)if(a=i[n],a>=s){let t,r;return n==e?(t=0,r=0):(t=i[n-2],r=i[n-1]),r+(i[n+1]-r)*(s-t)/(a-t)}let o=i[n-1];return o+(1-o)*(s-a)/(1-a)}};E(q,"LINEAR",0),E(q,"STEPPED",1),E(q,"BEZIER",2),E(q,"BEZIER_SIZE",19);let G=q;const $=class t extends G{constructor(t){super(t),E(this,"boneIndex"),E(this,"frames"),this.frames=N.newFloatArray(t<<1)}getPropertyId(){return 0+this.boneIndex}setFrame(e,s,i){e<<=1,this.frames[e]=s,this.frames[e+t.ROTATION]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return void(h.rotation=h.data.rotation);case 1:let t=h.data.rotation-h.rotation;t-=360*(16384-(16384.499999999996-t/360|0)),h.rotation+=t*r}return}if(i>=l[l.length-t.ENTRIES]){if(0==a)h.rotation=h.data.rotation+l[l.length+t.PREV_ROTATION]*r;else{let e=h.data.rotation+l[l.length+t.PREV_ROTATION]-h.rotation;e-=360*(16384-(16384.499999999996-e/360|0)),h.rotation+=e*r}return}let d=Y.binarySearch(l,i,t.ENTRIES),c=l[d+t.PREV_ROTATION],u=l[d],p=this.getCurvePercent((d>>1)-1,1-(i-u)/(l[d+t.PREV_TIME]-u)),m=l[d+t.ROTATION]-c;m-=360*(16384-(16384.499999999996-m/360|0)),m=c+m*p,0==a?(m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation=h.data.rotation+m*r):(m=h.data.rotation+m-h.rotation,m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation+=m*r)}};E($,"ENTRIES",2),E($,"PREV_TIME",-2),E($,"PREV_ROTATION",-1),E($,"ROTATION",1);let z=$;const H=class t extends G{constructor(e){super(e),E(this,"boneIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(1<<24)+this.boneIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.X]=i,this.frames[e+t.Y]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return h.x=h.data.x,void(h.y=h.data.y);case 1:h.x+=(h.data.x-h.x)*r,h.y+=(h.data.y-h.y)*r}return}let d=0,c=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_X],c=l[l.length+t.PREV_Y];else{let e=Y.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_X],c=l[e+t.PREV_Y];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.X]-d)*n,c+=(l[e+t.Y]-c)*n}0==a?(h.x=h.data.x+d*r,h.y=h.data.y+c*r):(h.x+=(h.data.x+d-h.x)*r,h.y+=(h.data.y+c-h.y)*r)}};E(H,"ENTRIES",3),E(H,"PREV_TIME",-3),E(H,"PREV_X",-2),E(H,"PREV_Y",-1),E(H,"X",1),E(H,"Y",2);let Z=H;class Q extends Z{constructor(t){super(t)}getPropertyId(){return(2<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.scaleX=l.data.scaleX,void(l.scaleY=l.data.scaleY);case 1:l.scaleX+=(l.data.scaleX-l.scaleX)*n,l.scaleY+=(l.data.scaleY-l.scaleY)*n}return}let h=0,d=0;if(s>=o[o.length-Q.ENTRIES])h=o[o.length+Q.PREV_X]*l.data.scaleX,d=o[o.length+Q.PREV_Y]*l.data.scaleY;else{let t=Y.binarySearch(o,s,Q.ENTRIES);h=o[t+Q.PREV_X],d=o[t+Q.PREV_Y];let e=o[t],i=this.getCurvePercent(t/Q.ENTRIES-1,1-(s-e)/(o[t+Q.PREV_TIME]-e));h=(h+(o[t+Q.X]-h)*i)*l.data.scaleX,d=(d+(o[t+Q.Y]-d)*i)*l.data.scaleY}if(1==n)l.scaleX=h,l.scaleY=d;else{let t=0,e=0;0==r?(t=l.data.scaleX,e=l.data.scaleY):(t=l.scaleX,e=l.scaleY),1==a?(h=Math.abs(h)*I.signum(t),d=Math.abs(d)*I.signum(e)):(t=Math.abs(t)*I.signum(h),e=Math.abs(e)*I.signum(d)),l.scaleX=t+(h-t)*n,l.scaleY=e+(d-e)*n}}}class J extends Z{constructor(t){super(t)}getPropertyId(){return(3<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.shearX=l.data.shearX,void(l.shearY=l.data.shearY);case 1:l.shearX+=(l.data.shearX-l.shearX)*n,l.shearY+=(l.data.shearY-l.shearY)*n}return}let h=0,d=0;if(s>=o[o.length-J.ENTRIES])h=o[o.length+J.PREV_X],d=o[o.length+J.PREV_Y];else{let t=Y.binarySearch(o,s,J.ENTRIES);h=o[t+J.PREV_X],d=o[t+J.PREV_Y];let e=o[t],i=this.getCurvePercent(t/J.ENTRIES-1,1-(s-e)/(o[t+J.PREV_TIME]-e));h+=(o[t+J.X]-h)*i,d+=(o[t+J.Y]-d)*i}0==r?(l.shearX=l.data.shearX+h*n,l.shearY=l.data.shearY+d*n):(l.shearX+=(l.data.shearX+h-l.shearX)*n,l.shearY+=(l.data.shearY+d-l.shearY)*n)}}const K=class t extends G{constructor(e){super(e),E(this,"slotIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(5<<24)+this.slotIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return void l.color.setFromColor(l.data.color);case 1:let t=l.color,e=l.data.color;t.add((e.r-t.r)*r,(e.g-t.g)*r,(e.b-t.b)*r,(e.a-t.a)*r)}return}let d=0,c=0,u=0,p=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A]}else{let e=Y.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,c+=(h[e+t.G]-c)*n,u+=(h[e+t.B]-u)*n,p+=(h[e+t.A]-p)*n}if(1==r)l.color.set(d,c,u,p);else{let t=l.color;0==a&&t.setFromColor(l.data.color),t.add((d-t.r)*r,(c-t.g)*r,(u-t.b)*r,(p-t.a)*r)}}};E(K,"ENTRIES",5),E(K,"PREV_TIME",-5),E(K,"PREV_R",-4),E(K,"PREV_G",-3),E(K,"PREV_B",-2),E(K,"PREV_A",-1),E(K,"R",1),E(K,"G",2),E(K,"B",3),E(K,"A",4);let tt=K;const et=class t extends G{constructor(e){super(e),E(this,"slotIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(14<<24)+this.slotIndex}setFrame(e,s,i,n,r,a,o,l,h){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a,this.frames[e+t.R2]=o,this.frames[e+t.G2]=l,this.frames[e+t.B2]=h}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return l.color.setFromColor(l.data.color),void l.darkColor.setFromColor(l.data.darkColor);case 1:let t=l.color,e=l.darkColor,s=l.data.color,i=l.data.darkColor;t.add((s.r-t.r)*r,(s.g-t.g)*r,(s.b-t.b)*r,(s.a-t.a)*r),e.add((i.r-e.r)*r,(i.g-e.g)*r,(i.b-e.b)*r,0)}return}let d=0,c=0,u=0,p=0,m=0,g=0,f=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2]}else{let e=Y.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,c+=(h[e+t.G]-c)*n,u+=(h[e+t.B]-u)*n,p+=(h[e+t.A]-p)*n,m+=(h[e+t.R2]-m)*n,g+=(h[e+t.G2]-g)*n,f+=(h[e+t.B2]-f)*n}if(1==r)l.color.set(d,c,u,p),l.darkColor.set(m,g,f,1);else{let t=l.color,e=l.darkColor;0==a&&(t.setFromColor(l.data.color),e.setFromColor(l.data.darkColor)),t.add((d-t.r)*r,(c-t.g)*r,(u-t.b)*r,(p-t.a)*r),e.add((m-e.r)*r,(g-e.g)*r,(f-e.b)*r,0)}}};E(et,"ENTRIES",8),E(et,"PREV_TIME",-8),E(et,"PREV_R",-7),E(et,"PREV_G",-6),E(et,"PREV_B",-5),E(et,"PREV_A",-4),E(et,"PREV_R2",-3),E(et,"PREV_G2",-2),E(et,"PREV_B2",-1),E(et,"R",1),E(et,"G",2),E(et,"B",3),E(et,"A",4),E(et,"R2",5),E(et,"G2",6),E(et,"B2",7);let st=et;class it{constructor(t){E(this,"slotIndex"),E(this,"frames"),E(this,"attachmentNames"),this.frames=N.newFloatArray(t),this.attachmentNames=new Array(t)}getPropertyId(){return(4<<24)+this.slotIndex}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex];if(1==a&&0==r){let e=o.data.attachmentName;return void o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}let l=this.frames;if(s<l[0]){if(0==r){let e=o.data.attachmentName;o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}return}let h=0;h=s>=l[l.length-1]?l.length-1:Y.binarySearch(l,s,1)-1;let d=this.attachmentNames[h];t.slots[this.slotIndex].setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}var nt=null;class rt extends G{constructor(t){super(t),E(this,"slotIndex"),E(this,"attachment"),E(this,"frames"),E(this,"frameVertices"),this.frames=N.newFloatArray(t),this.frameVertices=new Array(t),null==nt&&(nt=N.newFloatArray(64))}getPropertyId(){return(6<<27)+ +this.attachment.id+this.slotIndex}setFrame(t,e,s){this.frames[t]=e,this.frameVertices[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex],l=o.getAttachment();if(!(l instanceof S&&l.applyDeform(this.attachment)))return;let h=o.attachmentVertices;0==h.length&&(n=1);let d=this.frameVertices,c=d[0].length,u=this.frames;if(s<u[0]){let t=l;switch(r){case 0:return void(h.length=0);case 1:if(1==n){h.length=0;break}let e=N.setArraySize(h,c);if(null==t.bones)for(var p=t.vertices,m=0;m<c;m++)e[m]+=(p[m]-e[m])*n;else{n=1-n;for(m=0;m<c;m++)e[m]*=n}}return}let g=N.setArraySize(h,c);if(s>=u[u.length-1]){let t=d[u.length-1];if(1==n)N.arrayCopy(t,0,g,0,c);else if(0==r){let e=l;if(null==e.bones){let s=e.vertices;for(let e=0;e<c;e++){let i=s[e];g[e]=i+(t[e]-i)*n}}else for(let e=0;e<c;e++)g[e]=t[e]*n}else for(let e=0;e<c;e++)g[e]+=(t[e]-g[e])*n;return}let f=Y.binarySearch(u,s),x=d[f-1],w=d[f],b=u[f],y=this.getCurvePercent(f-1,1-(s-b)/(u[f-1]-b));if(1==n)for(let t=0;t<c;t++){let e=x[t];g[t]=e+(w[t]-e)*y}else if(0==r){let t=l;if(null==t.bones){let e=t.vertices;for(let t=0;t<c;t++){let s=x[t],i=e[t];g[t]=i+(s+(w[t]-s)*y-i)*n}}else for(let t=0;t<c;t++){let e=x[t];g[t]=(e+(w[t]-e)*y)*n}}else for(let t=0;t<c;t++){let e=x[t];g[t]+=(e+(w[t]-e)*y-g[t])*n}}}class at{constructor(t){E(this,"frames"),E(this,"events"),this.frames=N.newFloatArray(t),this.events=new Array(t)}getPropertyId(){return 7<<24}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e.time,this.events[t]=e}apply(t,e,s,i,n,r,a){if(null==i)return;let o=this.frames,l=this.frames.length;if(e>s)this.apply(t,e,Number.MAX_VALUE,i,n,r,a),e=-1;else if(e>=o[l-1])return;if(s<o[0])return;let h=0;if(e<o[0])h=0;else{h=Y.binarySearch(o,e);let t=o[h];for(;h>0&&o[h-1]==t;)h--}for(;h<l&&s>=o[h];h++)i.push(this.events[h])}}class ot{constructor(t){E(this,"frames"),E(this,"drawOrders"),this.frames=N.newFloatArray(t),this.drawOrders=new Array(t)}getPropertyId(){return 8<<24}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(t,e,s,i,n,r,a){let o=t.drawOrder,l=t.slots;if(1==a&&0==r)return void N.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length);let h=this.frames;if(s<h[0])return void(0==r&&N.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length));let d=0;d=s>=h[h.length-1]?h.length-1:Y.binarySearch(h,s)-1;let c=this.drawOrders[d];if(null==c)N.arrayCopy(l,0,o,0,l.length);else for(let t=0,e=c.length;t<e;t++)o[t]=l[c[t]]}}const lt=class t extends G{constructor(e){super(e),E(this,"ikConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(9<<24)+this.ikConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.MIX]=i,this.frames[e+t.BEND_DIRECTION]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.ikConstraints[this.ikConstraintIndex];if(i<l[0]){switch(a){case 0:return h.mix=h.data.mix,void(h.bendDirection=h.data.bendDirection);case 1:h.mix+=(h.data.mix-h.mix)*r,h.bendDirection=h.data.bendDirection}return}if(i>=l[l.length-t.ENTRIES])return void(0==a?(h.mix=h.data.mix+(l[l.length+t.PREV_MIX]-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[l.length+t.PREV_BEND_DIRECTION]):(h.mix+=(l[l.length+t.PREV_MIX]-h.mix)*r,0==o&&(h.bendDirection=l[l.length+t.PREV_BEND_DIRECTION])));let d=Y.binarySearch(l,i,t.ENTRIES),c=l[d+t.PREV_MIX],u=l[d],p=this.getCurvePercent(d/t.ENTRIES-1,1-(i-u)/(l[d+t.PREV_TIME]-u));0==a?(h.mix=h.data.mix+(c+(l[d+t.MIX]-c)*p-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[d+t.PREV_BEND_DIRECTION]):(h.mix+=(c+(l[d+t.MIX]-c)*p-h.mix)*r,0==o&&(h.bendDirection=l[d+t.PREV_BEND_DIRECTION]))}};E(lt,"ENTRIES",3),E(lt,"PREV_TIME",-3),E(lt,"PREV_MIX",-2),E(lt,"PREV_BEND_DIRECTION",-1),E(lt,"MIX",1),E(lt,"BEND_DIRECTION",2);let ht=lt;const dt=class t extends G{constructor(e){super(e),E(this,"transformConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(10<<24)+this.transformConstraintIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n,this.frames[e+t.SCALE]=r,this.frames[e+t.SHEAR]=a}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.transformConstraints[this.transformConstraintIndex];if(i<l[0]){let t=h.data;switch(a){case 0:return h.rotateMix=t.rotateMix,h.translateMix=t.translateMix,h.scaleMix=t.scaleMix,void(h.shearMix=t.shearMix);case 1:h.rotateMix+=(t.rotateMix-h.rotateMix)*r,h.translateMix+=(t.translateMix-h.translateMix)*r,h.scaleMix+=(t.scaleMix-h.scaleMix)*r,h.shearMix+=(t.shearMix-h.shearMix)*r}return}let d=0,c=0,u=0,p=0;if(i>=l[l.length-t.ENTRIES]){let e=l.length;d=l[e+t.PREV_ROTATE],c=l[e+t.PREV_TRANSLATE],u=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR]}else{let e=Y.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],c=l[e+t.PREV_TRANSLATE],u=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,c+=(l[e+t.TRANSLATE]-c)*n,u+=(l[e+t.SCALE]-u)*n,p+=(l[e+t.SHEAR]-p)*n}if(0==a){let t=h.data;h.rotateMix=t.rotateMix+(d-t.rotateMix)*r,h.translateMix=t.translateMix+(c-t.translateMix)*r,h.scaleMix=t.scaleMix+(u-t.scaleMix)*r,h.shearMix=t.shearMix+(p-t.shearMix)*r}else h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(c-h.translateMix)*r,h.scaleMix+=(u-h.scaleMix)*r,h.shearMix+=(p-h.shearMix)*r}};E(dt,"ENTRIES",5),E(dt,"PREV_TIME",-5),E(dt,"PREV_ROTATE",-4),E(dt,"PREV_TRANSLATE",-3),E(dt,"PREV_SCALE",-2),E(dt,"PREV_SHEAR",-1),E(dt,"ROTATE",1),E(dt,"TRANSLATE",2),E(dt,"SCALE",3),E(dt,"SHEAR",4);let ct=dt;const ut=class t extends G{constructor(e){super(e),E(this,"pathConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(11<<24)+this.pathConstraintIndex}setFrame(e,s,i){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.VALUE]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return void(h.position=h.data.position);case 1:h.position+=(h.data.position-h.position)*r}return}let d=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_VALUE];else{let e=Y.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_VALUE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.VALUE]-d)*n}0==a?h.position=h.data.position+(d-h.data.position)*r:h.position+=(d-h.position)*r}};E(ut,"ENTRIES",2),E(ut,"PREV_TIME",-2),E(ut,"PREV_VALUE",-1),E(ut,"VALUE",1);let pt=ut;class mt extends pt{constructor(t){super(t)}getPropertyId(){return(12<<24)+this.pathConstraintIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(s<o[0]){switch(r){case 0:return void(l.spacing=l.data.spacing);case 1:l.spacing+=(l.data.spacing-l.spacing)*n}return}let h=0;if(s>=o[o.length-mt.ENTRIES])h=o[o.length+mt.PREV_VALUE];else{let t=Y.binarySearch(o,s,mt.ENTRIES);h=o[t+mt.PREV_VALUE];let e=o[t],i=this.getCurvePercent(t/mt.ENTRIES-1,1-(s-e)/(o[t+mt.PREV_TIME]-e));h+=(o[t+mt.VALUE]-h)*i}0==r?l.spacing=l.data.spacing+(h-l.data.spacing)*n:l.spacing+=(h-l.spacing)*n}}const gt=class t extends G{constructor(e){super(e),E(this,"pathConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(13<<24)+this.pathConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return h.rotateMix=h.data.rotateMix,void(h.translateMix=h.data.translateMix);case 1:h.rotateMix+=(h.data.rotateMix-h.rotateMix)*r,h.translateMix+=(h.data.translateMix-h.translateMix)*r}return}let d=0,c=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_ROTATE],c=l[l.length+t.PREV_TRANSLATE];else{let e=Y.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],c=l[e+t.PREV_TRANSLATE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,c+=(l[e+t.TRANSLATE]-c)*n}0==a?(h.rotateMix=h.data.rotateMix+(d-h.data.rotateMix)*r,h.translateMix=h.data.translateMix+(c-h.data.translateMix)*r):(h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(c-h.translateMix)*r)}};E(gt,"ENTRIES",3),E(gt,"PREV_TIME",-3),E(gt,"PREV_ROTATE",-2),E(gt,"PREV_TRANSLATE",-1),E(gt,"ROTATE",1),E(gt,"TRANSLATE",2);let ft=gt;const xt=class t{constructor(t){E(this,"data"),E(this,"tracks",new Array),E(this,"events",new Array),E(this,"listeners",new Array),E(this,"queue",new yt(this)),E(this,"propertyIDs",new M),E(this,"mixingTo",new Array),E(this,"animationsChanged",!1),E(this,"timeScale",1),E(this,"trackEntryPool",new O(()=>new bt)),this.data=t}update(t){t*=this.timeScale;let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(null==i)continue;i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast;let n=t*i.timeScale;if(i.delay>0){if(i.delay-=n,i.delay>0)continue;n=-i.delay,i.delay=0}let r=i.next;if(null!=r){let e=i.trackLast-r.delay;if(e>=0){for(r.delay=0,r.trackTime=e+t*r.timeScale,i.trackTime+=n,this.setCurrent(s,r,!0);null!=r.mixingFrom;)r.mixTime+=n,r=r.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&null==i.mixingFrom){e[s]=null,this.queue.end(i),this.disposeNext(i);continue}if(null!=i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null;null!=t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=n}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(null==s)return!0;let i=this.updateMixingFrom(s,e);return s.animationLast=s.nextAnimationLast,s.trackLast=s.nextTrackLast,t.mixTime>0&&(t.mixTime>=t.mixDuration||0==t.timeScale)?(0!=s.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=s.mixingFrom,t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e*t.timeScale,!1)}apply(e){if(null==e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,n=!1;for(let r=0,a=i.length;r<a;r++){let a=i[r];if(null==a||a.delay>0)continue;n=!0;let o=0==r?j.current:j.currentLayered,l=a.alpha;null!=a.mixingFrom?l*=this.applyMixingFrom(a,e,o):a.trackTime>=a.trackEnd&&null==a.next&&(l=0);let h=a.animationLast,d=a.getAnimationTime(),c=a.animation.timelines.length,u=a.animation.timelines;if(1==l)for(let t=0;t<c;t++)u[t].apply(e,h,d,s,1,j.setup,W.in);else{let i=a.timelineData,n=0==a.timelinesRotation.length;n&&N.setArraySize(a.timelinesRotation,c<<1,null);let r=a.timelinesRotation;for(let a=0;a<c;a++){let c=u[a],p=i[a]>=t.FIRST?j.setup:o;c instanceof z?this.applyRotateTimeline(c,e,d,l,p,r,a<<1,n):(N.webkit602BugfixHelper(l,p),c.apply(e,h,d,s,l,p,W.in))}}this.queueEvents(a,d),s.length=0,a.nextAnimationLast=d,a.nextTrackLast=a.trackTime}return this.queue.drain(),n}applyMixingFrom(e,s,i){let n=e.mixingFrom;null!=n.mixingFrom&&this.applyMixingFrom(n,s,i);let r=0;0==e.mixDuration?(r=1,i=j.setup):(r=e.mixTime/e.mixDuration,r>1&&(r=1));let a=r<n.eventThreshold?this.events:null,o=r<n.attachmentThreshold,l=r<n.drawOrderThreshold,h=n.animationLast,d=n.getAnimationTime(),c=n.animation.timelines.length,u=n.animation.timelines,p=n.timelineData,m=n.timelineDipMix,g=0==n.timelinesRotation.length;g&&N.setArraySize(n.timelinesRotation,c<<1,null);let f,x=n.timelinesRotation,w=n.alpha*e.interruptAlpha,b=w*(1-r),y=0;n.totalAlpha=0;for(var E=0;E<c;E++){let e=u[E];switch(p[E]){case t.SUBSEQUENT:if(!o&&e instanceof it)continue;if(!l&&e instanceof ot)continue;f=i,y=b;break;case t.FIRST:f=j.setup,y=b;break;case t.DIP:f=j.setup,y=w;break;default:f=j.setup,y=w;let s=m[E];y*=Math.max(0,1-s.mixTime/s.mixDuration)}n.totalAlpha+=y,e instanceof z?this.applyRotateTimeline(e,s,d,y,f,x,E<<1,g):(N.webkit602BugfixHelper(y,f),e.apply(s,h,d,a,y,f,W.out))}return e.mixDuration>0&&this.queueEvents(n,d),this.events.length=0,n.nextAnimationLast=d,n.nextTrackLast=n.trackTime,r}applyRotateTimeline(t,e,s,i,n,r,a,o){if(o&&(r[a]=0),1==i)return void t.apply(e,0,s,null,1,n,W.in);let l=t,h=l.frames,d=e.bones[l.boneIndex];if(s<h[0])return void(n==j.setup&&(d.rotation=d.data.rotation));let c=0;if(s>=h[h.length-z.ENTRIES])c=d.data.rotation+h[h.length+z.PREV_ROTATION];else{let t=Y.binarySearch(h,s,z.ENTRIES),e=h[t+z.PREV_ROTATION],i=h[t],n=l.getCurvePercent((t>>1)-1,1-(s-i)/(h[t+z.PREV_TIME]-i));c=h[t+z.ROTATION]-e,c-=360*(16384-(16384.499999999996-c/360|0)),c=e+c*n+d.data.rotation,c-=360*(16384-(16384.499999999996-c/360|0))}let u=n==j.setup?d.data.rotation:d.rotation,p=0,m=c-u;if(0==m)p=r[a];else{m-=360*(16384-(16384.499999999996-m/360|0));let t=0,e=0;o?(t=0,e=m):(t=r[a],e=r[a+1]);let s=m>0,i=t>=0;I.signum(e)!=I.signum(m)&&Math.abs(e)<=90&&(Math.abs(t)>180&&(t+=360*I.signum(t)),i=s),p=m+t-t%360,i!=s&&(p+=360*I.signum(t)),r[a]=p}r[a+1]=m,u+=p*i,d.rotation=u-360*(16384-(16384.499999999996-u/360|0))}queueEvents(t,e){let s=t.animationStart,i=t.animationEnd,n=i-s,r=t.trackLast%n,a=this.events,o=0,l=a.length;for(;o<l;o++){let e=a[o];if(e.time<r)break;e.time>i||this.queue.event(t,e)}for((t.loop?0==n||r>t.trackTime%n:e>=i&&t.animationLast<i)&&this.queue.complete(t);o<l;o++){a[o].time<s||this.queue.event(t,a[o])}}clearTracks(){let t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let t=0,e=this.tracks.length;t<e;t++)this.clearTrack(t);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()}clearTrack(t){if(t>=this.tracks.length)return;let e=this.tracks[t];if(null==e)return;this.queue.end(e),this.disposeNext(e);let s=e;for(;;){let t=s.mixingFrom;if(null==t)break;this.queue.end(t),s.mixingFrom=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,null!=i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,e.mixTime=0,null!=i.mixingFrom&&i.mixDuration>0&&(e.interruptAlpha*=Math.min(1,i.mixTime/i.mixDuration)),i.timelinesRotation.length=0),this.queue.start(e)}setAnimation(t,e,s){let i=this.data.skeletonData.findAnimation(e);if(null==i)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s){if(null==e)throw new Error("animation cannot be null.");let i=!0,n=this.expandToIndex(t);null!=n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.disposeNext(n),n=n.mixingFrom,i=!1):this.disposeNext(n));let r=this.trackEntry(t,e,s,n);return this.setCurrent(t,r,i),this.queue.drain(),r}addAnimation(t,e,s,i){let n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,s,i)}addAnimationWith(t,e,s,i){if(null==e)throw new Error("animation cannot be null.");let n=this.expandToIndex(t);if(null!=n)for(;null!=n.next;)n=n.next;let r=this.trackEntry(t,e,s,n);if(null==n)this.setCurrent(t,r,!0),this.queue.drain();else if(n.next=r,i<=0){let t=n.animationEnd-n.animationStart;0!=t?(n.loop?i+=t*(1+(n.trackTime/t|0)):i+=t,i-=this.data.getMix(n.animation,e)):i=0}return r.delay=i,r}setEmptyAnimation(e,s){let i=this.setAnimationWith(e,t.emptyAnimation,!1);return i.mixDuration=s,i.trackEnd=s,i}addEmptyAnimation(e,s,i){i<=0&&(i-=s);let n=this.addAnimationWith(e,t.emptyAnimation,!1,i);return n.mixDuration=s,n.trackEnd=s,n}setEmptyAnimations(t){let e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let e=0,s=this.tracks.length;e<s;e++){let s=this.tracks[e];null!=s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(N.ensureArrayCapacity(this.tracks,t-this.tracks.length+1,null),this.tracks.length=t+1,null)}trackEntry(t,e,s,i){let n=this.trackEntryPool.obtain();return n.trackIndex=t,n.animation=e,n.loop=s,n.eventThreshold=0,n.attachmentThreshold=0,n.drawOrderThreshold=0,n.animationStart=0,n.animationEnd=e.duration,n.animationLast=-1,n.nextAnimationLast=-1,n.delay=0,n.trackTime=0,n.trackLast=-1,n.nextTrackLast=-1,n.trackEnd=Number.MAX_VALUE,n.timeScale=1,n.alpha=1,n.interruptAlpha=1,n.mixTime=0,n.mixDuration=null==i?0:this.data.getMix(i.animation,e),n}disposeNext(t){let e=t.next;for(;null!=e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1;let t=this.propertyIDs;t.clear();let e=this.mixingTo;for(var s=0,i=this.tracks.length;s<i;s++){let i=this.tracks[s];null!=i&&i.setTimelineData(null,e,t)}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(null==t)throw new Error("listener cannot be null.");this.listeners.push(t)}removeListener(t){let e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}};E(xt,"emptyAnimation",new Y("<empty>",[],0)),E(xt,"SUBSEQUENT",0),E(xt,"FIRST",1),E(xt,"DIP",2),E(xt,"DIP_MIX",3);let wt=xt;class bt{constructor(){E(this,"animation"),E(this,"next"),E(this,"mixingFrom"),E(this,"listener"),E(this,"trackIndex"),E(this,"loop"),E(this,"eventThreshold"),E(this,"attachmentThreshold"),E(this,"drawOrderThreshold"),E(this,"animationStart"),E(this,"animationEnd"),E(this,"animationLast"),E(this,"nextAnimationLast"),E(this,"delay"),E(this,"trackTime"),E(this,"trackLast"),E(this,"nextTrackLast"),E(this,"trackEnd"),E(this,"timeScale"),E(this,"alpha"),E(this,"mixTime"),E(this,"mixDuration"),E(this,"interruptAlpha"),E(this,"totalAlpha"),E(this,"timelineData",new Array),E(this,"timelineDipMix",new Array),E(this,"timelinesRotation",new Array)}reset(){this.next=null,this.mixingFrom=null,this.animation=null,this.listener=null,this.timelineData.length=0,this.timelineDipMix.length=0,this.timelinesRotation.length=0}setTimelineData(t,e,s){null!=t&&e.push(t);let i=null!=this.mixingFrom?this.mixingFrom.setTimelineData(this,e,s):this;null!=t&&e.pop();let n=e,r=e.length-1,a=this.animation.timelines,o=this.animation.timelines.length,l=N.setArraySize(this.timelineData,o);this.timelineDipMix.length=0;let h=N.setArraySize(this.timelineDipMix,o);t:for(var d=0;d<o;d++){let e=a[d].getPropertyId();if(s.add(e))if(null!=t&&t.hasTimeline(e)){for(var c=r;c>=0;c--){let t=n[c];if(!t.hasTimeline(e)&&t.mixDuration>0){l[d]=wt.DIP_MIX,h[d]=t;continue t}}l[d]=wt.DIP}else l[d]=wt.FIRST;else l[d]=wt.SUBSEQUENT}return i}hasTimeline(t){let e=this.animation.timelines;for(var s=0,i=e.length;s<i;s++)if(e[s].getPropertyId()==t)return!0;return!1}getAnimationTime(){if(this.loop){let t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}}class yt{constructor(t){E(this,"objects",[]),E(this,"drainDisabled",!1),E(this,"animState"),this.animState=t}start(t){this.objects.push(0),this.objects.push(t),this.animState.animationsChanged=!0}interrupt(t){this.objects.push(1),this.objects.push(t)}end(t){this.objects.push(2),this.objects.push(t),this.animState.animationsChanged=!0}dispose(t){this.objects.push(3),this.objects.push(t)}complete(t){this.objects.push(4),this.objects.push(t)}event(t,e){this.objects.push(5),this.objects.push(t),this.objects.push(e)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let t=this.objects,e=this.animState.listeners;for(let s=0;s<t.length;s+=2){let i=t[s],n=t[s+1];switch(i){case 0:null!=n.listener&&n.listener.start&&n.listener.start(n);for(let t=0;t<e.length;t++)e[t].start&&e[t].start(n);break;case 1:null!=n.listener&&n.listener.interrupt&&n.listener.interrupt(n);for(let t=0;t<e.length;t++)e[t].interrupt&&e[t].interrupt(n);break;case 2:null!=n.listener&&n.listener.end&&n.listener.end(n);for(let t=0;t<e.length;t++)e[t].end&&e[t].end(n);case 3:null!=n.listener&&n.listener.dispose&&n.listener.dispose(n);for(let t=0;t<e.length;t++)e[t].dispose&&e[t].dispose(n);this.animState.trackEntryPool.free(n);break;case 4:null!=n.listener&&n.listener.complete&&n.listener.complete(n);for(let t=0;t<e.length;t++)e[t].complete&&e[t].complete(n);break;case 5:let i=t[2+s++];null!=n.listener&&n.listener.event&&n.listener.event(n,i);for(let t=0;t<e.length;t++)e[t].event&&e[t].event(n,i)}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}var Et,Tt=((Et=Tt||{})[Et.start=0]="start",Et[Et.interrupt=1]="interrupt",Et[Et.end=2]="end",Et[Et.dispose=3]="dispose",Et[Et.complete=4]="complete",Et[Et.event=5]="event",Et);class At{constructor(t){if(E(this,"skeletonData"),E(this,"animationToMixTime",{}),E(this,"defaultMix",0),null==t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(null==i)throw new Error("Animation not found: "+t);let n=this.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);this.setMixWith(i,n,s)}setMixWith(t,e,s){if(null==t)throw new Error("from cannot be null.");if(null==e)throw new Error("to cannot be null.");let i=t.name+"."+e.name;this.animationToMixTime[i]=s}getMix(t,e){let s=t.name+"."+e.name,i=this.animationToMixTime[s];return void 0===i?this.defaultMix:i}}class Ct extends S{constructor(t){super(t),E(this,"color",new R(1,1,1,1))}}class St extends S{constructor(t){super(t),E(this,"endSlot"),E(this,"color",new R(.2275,.2275,.8078,1))}}class Mt extends S{constructor(t){super(t),E(this,"region"),E(this,"path"),E(this,"regionUVs"),E(this,"uvs"),E(this,"triangles"),E(this,"color",new R(1,1,1,1)),E(this,"hullLength"),E(this,"parentMesh"),E(this,"inheritDeform",!1),E(this,"tempColor",new R(0,0,0,0))}updateUVs(){let t=0,e=0,s=0,i=0;null==this.region?(t=e=0,s=i=1):(t=this.region.u,e=this.region.v,s=this.region.u2-t,i=this.region.v2-e);let n=this.regionUVs;null!=this.uvs&&this.uvs.length==n.length||(this.uvs=N.newFloatArray(n.length));let r=this.uvs;if(this.region.rotate)for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a+1]*s,r[a+1]=e+i-n[a]*i;else for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a]*s,r[a+1]=e+n[a+1]*i}applyDeform(t){return this==t||this.inheritDeform&&this.parentMesh==t}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,null!=t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)}}class vt extends S{constructor(t){super(t),E(this,"lengths"),E(this,"closed",!1),E(this,"constantSpeed",!1),E(this,"color",new R(1,1,1,1))}}class Rt extends S{constructor(t){super(t),E(this,"x"),E(this,"y"),E(this,"rotation"),E(this,"color",new R(.38,.94,0,1))}computeWorldPosition(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e}computeWorldRotation(t){let e=I.cosDeg(this.rotation),s=I.sinDeg(this.rotation),i=e*t.a+s*t.b,n=e*t.c+s*t.d;return Math.atan2(n,i)*I.radDeg}}const Pt=class t extends A{constructor(t){super(t),E(this,"x",0),E(this,"y",0),E(this,"scaleX",1),E(this,"scaleY",1),E(this,"rotation",0),E(this,"width",0),E(this,"height",0),E(this,"color",new R(1,1,1,1)),E(this,"path"),E(this,"rendererObject"),E(this,"region"),E(this,"offset",N.newFloatArray(8)),E(this,"uvs",N.newFloatArray(8)),E(this,"tempColor",new R(1,1,1,1))}updateOffset(){let e=this.width/this.region.originalWidth*this.scaleX,s=this.height/this.region.originalHeight*this.scaleY,i=-this.width/2*this.scaleX+this.region.offsetX*e,n=-this.height/2*this.scaleY+this.region.offsetY*s,r=i+this.region.width*e,a=n+this.region.height*s,o=this.rotation*Math.PI/180,l=Math.cos(o),h=Math.sin(o),d=i*l+this.x,c=i*h,u=n*l+this.y,p=n*h,m=r*l+this.x,g=r*h,f=a*l+this.y,x=a*h,w=this.offset;w[t.OX1]=d-p,w[t.OY1]=u+c,w[t.OX2]=d-x,w[t.OY2]=f+c,w[t.OX3]=m-x,w[t.OY3]=f+g,w[t.OX4]=m-p,w[t.OY4]=u+g}setRegion(t){this.region=t;let e=this.uvs;t.rotate?(e[0]=t.u2,e[1]=t.v2,e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)}computeWorldVertices(e,s,i,n){let r=this.offset,a=e.worldX,o=e.worldY,l=e.a,h=e.b,d=e.c,c=e.d,u=0,p=0;u=r[t.OX1],p=r[t.OY1],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o,i+=n,u=r[t.OX2],p=r[t.OY2],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o,i+=n,u=r[t.OX3],p=r[t.OY3],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o,i+=n,u=r[t.OX4],p=r[t.OY4],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o}};E(Pt,"OX1",0),E(Pt,"OY1",1),E(Pt,"OX2",2),E(Pt,"OY2",3),E(Pt,"OX3",4),E(Pt,"OY3",5),E(Pt,"OX4",6),E(Pt,"OY4",7),E(Pt,"X1",0),E(Pt,"Y1",1),E(Pt,"C1R",2),E(Pt,"C1G",3),E(Pt,"C1B",4),E(Pt,"C1A",5),E(Pt,"U1",6),E(Pt,"V1",7),E(Pt,"X2",8),E(Pt,"Y2",9),E(Pt,"C2R",10),E(Pt,"C2G",11),E(Pt,"C2B",12),E(Pt,"C2A",13),E(Pt,"U2",14),E(Pt,"V2",15),E(Pt,"X3",16),E(Pt,"Y3",17),E(Pt,"C3R",18),E(Pt,"C3G",19),E(Pt,"C3B",20),E(Pt,"C3A",21),E(Pt,"U3",22),E(Pt,"V3",23),E(Pt,"X4",24),E(Pt,"Y4",25),E(Pt,"C4R",26),E(Pt,"C4G",27),E(Pt,"C4B",28),E(Pt,"C4A",29),E(Pt,"U4",30),E(Pt,"V4",31);let It=Pt;class kt{constructor(t){E(this,"atlas"),this.atlas=t}newRegionAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (region attachment: "+e+")");i.renderObject=i;let n=new It(e);return n.setRegion(i),n}newMeshAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");i.renderObject=i;let n=new Mt(e);return n.region=i,n}newBoundingBoxAttachment(t,e){return new Ct(e)}newPathAttachment(t,e){return new vt(e)}newPointAttachment(t,e){return new Rt(e)}newClippingAttachment(t,e){return new St(e)}}class Vt{constructor(t,e,s){if(E(this,"index"),E(this,"name"),E(this,"parent"),E(this,"length"),E(this,"x",0),E(this,"y",0),E(this,"rotation",0),E(this,"scaleX",1),E(this,"scaleY",1),E(this,"shearX",0),E(this,"shearY",0),E(this,"transformMode",0),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}var _t,Dt=((_t=Dt||{})[_t.Normal=0]="Normal",_t[_t.OnlyTranslation=1]="OnlyTranslation",_t[_t.NoRotationOrReflection=2]="NoRotationOrReflection",_t[_t.NoScale=3]="NoScale",_t[_t.NoScaleOrReflection=4]="NoScaleOrReflection",_t);class Nt{constructor(t,e,s){if(E(this,"data"),E(this,"skeleton"),E(this,"parent"),E(this,"children",new Array),E(this,"x",0),E(this,"y",0),E(this,"rotation",0),E(this,"scaleX",0),E(this,"scaleY",0),E(this,"shearX",0),E(this,"shearY",0),E(this,"ax",0),E(this,"ay",0),E(this,"arotation",0),E(this,"ascaleX",0),E(this,"ascaleY",0),E(this,"ashearX",0),E(this,"ashearY",0),E(this,"appliedValid",!1),E(this,"a",0),E(this,"b",0),E(this,"worldX",0),E(this,"c",0),E(this,"d",0),E(this,"worldY",0),E(this,"sorted",!1),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}update(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(t,e,s,i,n,r,a){this.ax=t,this.ay=e,this.arotation=s,this.ascaleX=i,this.ascaleY=n,this.ashearX=r,this.ashearY=a,this.appliedValid=!0;let o=this.parent;if(null==o){let o=s+90+a,l=I.cosDeg(s+r)*i,h=I.cosDeg(o)*n,d=I.sinDeg(s+r)*i,c=I.sinDeg(o)*n,u=this.skeleton;return u.flipX&&(t=-t,l=-l,h=-h),u.flipY&&(e=-e,d=-d,c=-c),this.a=l,this.b=h,this.c=d,this.d=c,this.worldX=t+u.x,void(this.worldY=e+u.y)}let l=o.a,h=o.b,d=o.c,c=o.d;switch(this.worldX=l*t+h*e+o.worldX,this.worldY=d*t+c*e+o.worldY,this.data.transformMode){case Dt.Normal:{let t=s+90+a,e=I.cosDeg(s+r)*i,o=I.cosDeg(t)*n,u=I.sinDeg(s+r)*i,p=I.sinDeg(t)*n;return this.a=l*e+h*u,this.b=l*o+h*p,this.c=d*e+c*u,void(this.d=d*o+c*p)}case Dt.OnlyTranslation:{let t=s+90+a;this.a=I.cosDeg(s+r)*i,this.b=I.cosDeg(t)*n,this.c=I.sinDeg(s+r)*i,this.d=I.sinDeg(t)*n;break}case Dt.NoRotationOrReflection:{let t=l*l+d*d,e=0;t>1e-4?(t=Math.abs(l*c-h*d)/t,h=d*t,c=l*t,e=Math.atan2(d,l)*I.radDeg):(l=0,d=0,e=90-Math.atan2(c,h)*I.radDeg);let o=s+r-e,u=s+a-e+90,p=I.cosDeg(o)*i,m=I.cosDeg(u)*n,g=I.sinDeg(o)*i,f=I.sinDeg(u)*n;this.a=l*p-h*g,this.b=l*m-h*f,this.c=d*p+c*g,this.d=d*m+c*f;break}case Dt.NoScale:case Dt.NoScaleOrReflection:{let t=I.cosDeg(s),e=I.sinDeg(s),o=l*t+h*e,u=d*t+c*e,p=Math.sqrt(o*o+u*u);p>1e-5&&(p=1/p),o*=p,u*=p,p=Math.sqrt(o*o+u*u);let m=Math.PI/2+Math.atan2(u,o),g=Math.cos(m)*p,f=Math.sin(m)*p,x=I.cosDeg(r)*i,w=I.cosDeg(90+a)*n,b=I.sinDeg(r)*i,y=I.sinDeg(90+a)*n;return(this.data.transformMode!=Dt.NoScaleOrReflection?l*c-h*d<0:this.skeleton.flipX!=this.skeleton.flipY)&&(g=-g,f=-f),this.a=o*x+g*b,this.b=o*w+g*y,this.c=u*x+f*b,void(this.d=u*w+f*y)}}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b),this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)}setToSetupPose(){let t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY}getWorldRotationX(){return Math.atan2(this.c,this.a)*I.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*I.radDeg}getWorldScaleX(){return Math.sqrt(this.a*this.a+this.c*this.c)}getWorldScaleY(){return Math.sqrt(this.b*this.b+this.d*this.d)}updateAppliedTransform(){this.appliedValid=!0;let t=this.parent;if(null==t)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*I.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*I.radDeg);let e=t.a,s=t.b,i=t.c,n=t.d,r=1/(e*n-s*i),a=this.worldX-t.worldX,o=this.worldY-t.worldY;this.ax=a*n*r-o*s*r,this.ay=o*e*r-a*i*r;let l=r*n,h=r*e,d=r*s,c=r*i,u=l*this.a-d*this.c,p=l*this.b-d*this.d,m=h*this.c-c*this.a,g=h*this.d-c*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(u*u+m*m),this.ascaleX>1e-4){let t=u*g-p*m;this.ascaleY=t/this.ascaleX,this.ashearY=Math.atan2(u*p+m*g,t)*I.radDeg,this.arotation=Math.atan2(m,u)*I.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(p*p+g*g),this.ashearY=0,this.arotation=90-Math.atan2(g,p)*I.radDeg}worldToLocal(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=1/(e*n-s*i),a=t.x-this.worldX,o=t.y-this.worldY;return t.x=a*n*r-o*s*r,t.y=o*e*r-a*i*r,t}localToWorld(t){let e=t.x,s=t.y;return t.x=e*this.a+s*this.b+this.worldX,t.y=e*this.c+s*this.d+this.worldY,t}worldToLocalRotation(t){let e=I.sinDeg(t),s=I.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*I.radDeg}localToWorldRotation(t){let e=I.sinDeg(t),s=I.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*I.radDeg}rotateWorld(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=I.cosDeg(t),a=I.sinDeg(t);this.a=r*e-a*i,this.b=r*s-a*n,this.c=a*e+r*i,this.d=a*s+r*n,this.appliedValid=!1}}class Ot{constructor(t){E(this,"_image"),this._image=t}getImage(){return this._image}static filterFromString(t){switch(t.toLowerCase()){case"nearest":return 9728;case"linear":return 9729;case"mipmap":case"mipmaplinearlinear":return 9987;case"mipmapnearestnearest":return 9984;case"mipmaplinearnearest":return 9985;case"mipmapnearestlinear":return 9986;default:throw new Error(`Unknown texture filter ${t}`)}}static wrapFromString(t){switch(t.toLowerCase()){case"mirroredtepeat":return 33648;case"clamptoedge":return 33071;case"repeat":return 10497;default:throw new Error(`Unknown texture wrap ${t}`)}}}var Lt,Yt,Ft=((Lt=Ft||{})[Lt.Nearest=9728]="Nearest",Lt[Lt.Linear=9729]="Linear",Lt[Lt.MipMap=9987]="MipMap",Lt[Lt.MipMapNearestNearest=9984]="MipMapNearestNearest",Lt[Lt.MipMapLinearNearest=9985]="MipMapLinearNearest",Lt[Lt.MipMapNearestLinear=9986]="MipMapNearestLinear",Lt[Lt.MipMapLinearLinear=9987]="MipMapLinearLinear",Lt),Xt=((Yt=Xt||{})[Yt.MirroredRepeat=33648]="MirroredRepeat",Yt[Yt.ClampToEdge=33071]="ClampToEdge",Yt[Yt.Repeat=10497]="Repeat",Yt);class Bt{constructor(){E(this,"renderObject"),E(this,"u",0),E(this,"v",0),E(this,"u2",0),E(this,"v2",0),E(this,"width",0),E(this,"height",0),E(this,"rotate",!1),E(this,"offsetX",0),E(this,"offsetY",0),E(this,"originalWidth",0),E(this,"originalHeight",0),E(this,"texture")}}class jt extends Ot{setFilters(t,e){}setWraps(t,e){}dispose(){}}class Wt{constructor(t,e){E(this,"pages",new Array),E(this,"regions",new Array),this.load(t,e)}load(t,e){if(null==e)throw new Error("textureLoader cannot be null.");let s=new Ut(t),i=new Array(4),n=null;for(;;){let t=s.readLine();if(null==t)break;if(t=t.trim(),0==t.length)n=null;else if(n){let e=new Gt;e.name=t,e.page=n,e.rotate="true"==s.readValue(),s.readTuple(i);let r=parseInt(i[0]),a=parseInt(i[1]);s.readTuple(i);let o=parseInt(i[0]),l=parseInt(i[1]);e.u=r/n.width,e.v=a/n.height,e.rotate?(e.u2=(r+l)/n.width,e.v2=(a+o)/n.height):(e.u2=(r+o)/n.width,e.v2=(a+l)/n.height),e.x=r,e.y=a,e.width=Math.abs(o),e.height=Math.abs(l),4==s.readTuple(i)&&4==s.readTuple(i)&&s.readTuple(i),e.originalWidth=parseInt(i[0]),e.originalHeight=parseInt(i[1]),s.readTuple(i),e.offsetX=parseInt(i[0]),e.offsetY=parseInt(i[1]),e.index=parseInt(s.readValue()),e.texture=n.texture,this.regions.push(e)}else{n=new qt,n.name=t,2==s.readTuple(i)&&(n.width=parseInt(i[0]),n.height=parseInt(i[1]),s.readTuple(i)),s.readTuple(i),n.minFilter=Ot.filterFromString(i[0]),n.magFilter=Ot.filterFromString(i[1]);let r=s.readValue();n.uWrap=Xt.ClampToEdge,n.vWrap=Xt.ClampToEdge,"x"==r?n.uWrap=Xt.Repeat:"y"==r?n.vWrap=Xt.Repeat:"xy"==r&&(n.uWrap=n.vWrap=Xt.Repeat),n.texture=e(t),n.texture.setFilters(n.minFilter,n.magFilter),n.texture.setWraps(n.uWrap,n.vWrap),n.width=n.texture.getImage().width,n.height=n.texture.getImage().height,this.pages.push(n)}}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture.dispose()}}class Ut{constructor(t){E(this,"lines"),E(this,"index",0),this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readValue(){let t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()}readTuple(t){let e=this.readLine(),s=e.indexOf(":");if(-1==s)throw new Error("Invalid line: "+e);let i=0,n=s+1;for(;i<3;i++){let s=e.indexOf(",",n);if(-1==s)break;t[i]=e.substr(n,s-n).trim(),n=s+1}return t[i]=e.substring(n).trim(),i+1}}class qt{constructor(){E(this,"name"),E(this,"minFilter"),E(this,"magFilter"),E(this,"uWrap"),E(this,"vWrap"),E(this,"texture"),E(this,"width"),E(this,"height")}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap),this.width=this.texture.getImage().width,this.height=this.texture.getImage().height}}class Gt extends Bt{constructor(){super(...arguments),E(this,"page"),E(this,"name"),E(this,"x"),E(this,"y"),E(this,"index"),E(this,"rotate"),E(this,"texture")}}class $t{constructor(t,e=""){E(this,"pathPrefix"),E(this,"textureLoader"),E(this,"assets",{}),E(this,"errors",{}),E(this,"toLoad",0),E(this,"loaded",0),this.textureLoader=t,this.pathPrefix=e}static downloadText(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.onload=()=>{200==i.status?e(i.responseText):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}static downloadBinary(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status?e(new Uint8Array(i.response)):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}loadText(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++,$t.downloadText(t,s=>{this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++},(e,i)=>{this.errors[t]=`Couldn't load text ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load text ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++})}loadTexture(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++;let i=new Image;i.crossOrigin="anonymous",i.onload=s=>{let n=this.textureLoader(i);this.assets[t]=n,this.toLoad--,this.loaded++,e&&e(t,i)},i.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,s&&s(t,`Couldn't load image ${t}`)},i.src=t}loadTextureData(t,e,s=null,i=null){t=this.pathPrefix+t,this.toLoad++;let n=new Image;n.onload=e=>{let i=this.textureLoader(n);this.assets[t]=i,this.toLoad--,this.loaded++,s&&s(t,n)},n.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,i&&i(t,`Couldn't load image ${t}`)},n.src=e}loadTextureAtlas(t,e=null,s=null){let i=t.lastIndexOf("/")>=0?t.substring(0,t.lastIndexOf("/")):"";t=this.pathPrefix+t,this.toLoad++,$t.downloadText(t,n=>{var r={count:0},a=new Array;try{new Wt(n,t=>{a.push(i+"/"+t);let e=document.createElement("img");return e.width=16,e.height=16,new jt(e)})}catch(e){let i=e;return this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,void this.loaded++}for(let o of a){let l=!1;this.loadTexture(o,(o,h)=>{if(r.count++,r.count==a.length)if(l)this.errors[t]=`Couldn't load texture atlas page ${o}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${o} of atlas ${t}`),this.toLoad--,this.loaded++;else try{let s=new Wt(n,t=>this.get(i+"/"+t));this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++}catch(e){let i=e;this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,this.loaded++}},(e,i)=>{l=!0,r.count++,r.count==a.length&&(this.errors[t]=`Couldn't load texture atlas page ${e}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${e} of atlas ${t}`),this.toLoad--,this.loaded++)})}},(e,i)=>{this.errors[t]=`Couldn't load texture atlas ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load texture atlas ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++})}get(t){return t=this.pathPrefix+t,this.assets[t]}remove(t){t=this.pathPrefix+t;let e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null}removeAll(){for(let t in this.assets){let e=this.assets[t];e.dispose&&e.dispose()}this.assets={}}isLoadingComplete(){return 0==this.toLoad}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}}class zt{constructor(t,e){if(E(this,"data"),E(this,"intValue"),E(this,"floatValue"),E(this,"stringValue"),E(this,"time"),null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}}class Ht{constructor(t){E(this,"name"),E(this,"intValue"),E(this,"floatValue"),E(this,"stringValue"),this.name=t}}class Zt{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"mix",1),E(this,"bendDirection",0),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}getOrder(){return this.data.order}apply(){this.update()}update(){let t=this.target,e=this.bones;switch(e.length){case 1:this.apply1(e[0],t.worldX,t.worldY,this.mix);break;case 2:this.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.mix)}}apply1(t,e,s,i){t.appliedValid||t.updateAppliedTransform();let n=t.parent,r=1/(n.a*n.d-n.b*n.c),a=e-n.worldX,o=s-n.worldY,l=(a*n.d-o*n.b)*r-t.ax,h=(o*n.a-a*n.c)*r-t.ay,d=Math.atan2(h,l)*I.radDeg-t.ashearX-t.arotation;t.ascaleX<0&&(d+=180),d>180?d-=360:d<-180&&(d+=360),t.updateWorldTransformWith(t.ax,t.ay,t.arotation+d*i,t.ascaleX,t.ascaleY,t.ashearX,t.ashearY)}apply2(t,e,s,i,n,r){if(0==r)return void e.updateWorldTransform();t.appliedValid||t.updateAppliedTransform(),e.appliedValid||e.updateAppliedTransform();let a=t.ax,o=t.ay,l=t.ascaleX,h=t.ascaleY,d=e.ascaleX,c=0,u=0,p=0;l<0?(l=-l,c=180,p=-1):(c=0,p=1),h<0&&(h=-h,p=-p),d<0?(d=-d,u=180):u=0;let m=e.ax,g=0,f=0,x=0,w=t.a,b=t.b,y=t.c,E=t.d,T=Math.abs(l-h)<=1e-4;T?(g=e.ay,f=w*m+b*g+t.worldX,x=y*m+E*g+t.worldY):(g=0,f=w*m+t.worldX,x=y*m+t.worldY);let A=t.parent;w=A.a,b=A.b,y=A.c,E=A.d;let C=1/(w*E-b*y),S=s-A.worldX,M=i-A.worldY,v=(S*E-M*b)*C-a,R=(M*w-S*y)*C-o;S=f-A.worldX,M=x-A.worldY;let P=(S*E-M*b)*C-a,k=(M*w-S*y)*C-o,V=Math.sqrt(P*P+k*k),_=e.data.length*d,D=0,N=0;t:if(T){_*=l;let t=(v*v+R*R-V*V-_*_)/(2*V*_);t<-1?t=-1:t>1&&(t=1),N=Math.acos(t)*n,w=V+_*t,b=_*Math.sin(N),D=Math.atan2(R*w-v*b,v*w+R*b)}else{w=l*_,b=h*_;let t=w*w,e=b*b,s=v*v+R*R,i=Math.atan2(R,v);y=e*V*V+t*s-t*e;let r=-2*e*V,a=e-t;if(E=r*r-4*a*y,E>=0){let t=Math.sqrt(E);r<0&&(t=-t),t=-(r+t)/2;let e=t/a,o=y/t,d=Math.abs(e)<Math.abs(o)?e:o;if(d*d<=s){M=Math.sqrt(s-d*d)*n,D=i-Math.atan2(M,d),N=Math.atan2(M/h,(d-V)/l);break t}}let o=I.PI,d=V-w,c=d*d,u=0,p=0,m=V+w,g=m*m,f=0;y=-w*V/(t-e),y>=-1&&y<=1&&(y=Math.acos(y),S=w*Math.cos(y)+V,M=b*Math.sin(y),E=S*S+M*M,E<c&&(o=y,c=E,d=S,u=M),E>g&&(p=y,g=E,m=S,f=M)),s<=(c+g)/2?(D=i-Math.atan2(u*n,d),N=o*n):(D=i-Math.atan2(f*n,m),N=p*n)}let O=Math.atan2(g,m)*p,L=t.arotation;D=(D-O)*I.radDeg+c-L,D>180?D-=360:D<-180&&(D+=360),t.updateWorldTransformWith(a,o,L+D*r,t.ascaleX,t.ascaleY,0,0),L=e.arotation,N=((N+O)*I.radDeg-e.ashearX)*p+u-L,N>180?N-=360:N<-180&&(N+=360),e.updateWorldTransformWith(m,g,L+N*r,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)}}class Qt{constructor(t){E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"bendDirection",1),E(this,"mix",1),this.name=t}}class Jt{constructor(t){E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"positionMode"),E(this,"spacingMode"),E(this,"rotateMode"),E(this,"offsetRotation"),E(this,"position"),E(this,"spacing"),E(this,"rotateMix"),E(this,"translateMix"),this.name=t}}var Kt,te,ee,se=((Kt=se||{})[Kt.Fixed=0]="Fixed",Kt[Kt.Percent=1]="Percent",Kt),ie=((te=ie||{})[te.Length=0]="Length",te[te.Fixed=1]="Fixed",te[te.Percent=2]="Percent",te),ne=((ee=ne||{})[ee.Tangent=0]="Tangent",ee[ee.Chain=1]="Chain",ee[ee.ChainScale=2]="ChainScale",ee);const re=class t{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"position",0),E(this,"spacing",0),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"spaces",new Array),E(this,"positions",new Array),E(this,"world",new Array),E(this,"curves",new Array),E(this,"lengths",new Array),E(this,"segments",new Array),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0,i=t.bones.length;s<i;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findSlot(t.target.name),this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix}apply(){this.update()}update(){let e=this.target.getAttachment();if(!(e instanceof vt))return;let s=this.rotateMix,i=this.translateMix,n=s>0;if(!(i>0)&&!n)return;let r=this.data,a=r.spacingMode,o=a==ie.Length,l=r.rotateMode,h=l==ne.Tangent,d=l==ne.ChainScale,c=this.bones.length,u=h?c:c+1,p=this.bones,m=N.setArraySize(this.spaces,u),g=null,f=this.spacing;if(d||o){d&&(g=N.setArraySize(this.lengths,c));for(let e=0,s=u-1;e<s;){let s=p[e],i=s.data.length;if(i<t.epsilon)d&&(g[e]=0),m[++e]=0;else{let t=i*s.a,n=i*s.c,r=Math.sqrt(t*t+n*n);d&&(g[e]=r),m[++e]=(o?i+f:f)*r/i}}}else for(let t=1;t<u;t++)m[t]=f;let x=this.computeWorldPositions(e,u,h,r.positionMode==se.Percent,a==ie.Percent),w=x[0],b=x[1],y=r.offsetRotation,E=!1;if(0==y)E=l==ne.Chain;else{E=!1;let t=this.target.bone;y*=t.a*t.d-t.b*t.c>0?I.degRad:-I.degRad}for(let t=0,e=3;t<c;t++,e+=3){let r=p[t];r.worldX+=(w-r.worldX)*i,r.worldY+=(b-r.worldY)*i;let a=x[e],o=x[e+1],l=a-w,c=o-b;if(d){let e=g[t];if(0!=e){let t=(Math.sqrt(l*l+c*c)/e-1)*s+1;r.a*=t,r.c*=t}}if(w=a,b=o,n){let i=r.a,n=r.b,a=r.c,o=r.d,d=0,u=0,p=0;if(d=h?x[e-1]:0==m[t+1]?x[e+2]:Math.atan2(c,l),d-=Math.atan2(a,i),E){u=Math.cos(d),p=Math.sin(d);let t=r.data.length;w+=(t*(u*i-p*a)-l)*s,b+=(t*(p*i+u*a)-c)*s}else d+=y;d>I.PI?d-=I.PI2:d<-I.PI&&(d+=I.PI2),d*=s,u=Math.cos(d),p=Math.sin(d),r.a=u*i-p*a,r.b=u*n-p*o,r.c=p*i+u*a,r.d=p*n+u*o}r.appliedValid=!1}}computeWorldPositions(e,s,i,n,r){let a=this.target,o=this.position,l=this.spaces,h=N.setArraySize(this.positions,3*s+2),d=null,c=e.closed,u=e.worldVerticesLength,p=u/6,m=t.NONE;if(!e.constantSpeed){let g=e.lengths;p-=c?1:2;let f=g[p];if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;d=N.setArraySize(this.world,8);for(let n=0,r=0,x=0;n<s;n++,r+=3){let s=l[n];o+=s;let w=o;if(c)w%=f,w<0&&(w+=f),x=0;else{if(w<0){m!=t.BEFORE&&(m=t.BEFORE,e.computeWorldVertices(a,2,4,d,0,2)),this.addBeforePosition(w,d,0,h,r);continue}if(w>f){m!=t.AFTER&&(m=t.AFTER,e.computeWorldVertices(a,u-6,4,d,0,2)),this.addAfterPosition(w-f,d,0,h,r);continue}}for(;;x++){let t=g[x];if(!(w>t)){if(0==x)w/=t;else{let e=g[x-1];w=(w-e)/(t-e)}break}}x!=m&&(m=x,c&&x==p?(e.computeWorldVertices(a,u-4,4,d,0,2),e.computeWorldVertices(a,0,4,d,4,2)):e.computeWorldVertices(a,6*x+2,8,d,0,2)),this.addCurvePosition(w,d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],h,r,i||n>0&&0==s)}return h}c?(u+=2,d=N.setArraySize(this.world,u),e.computeWorldVertices(a,2,u-4,d,0,2),e.computeWorldVertices(a,0,2,d,u-4,2),d[u-2]=d[0],d[u-1]=d[1]):(p--,u-=4,d=N.setArraySize(this.world,u),e.computeWorldVertices(a,2,u,d,0,2));let g=N.setArraySize(this.curves,p),f=0,x=d[0],w=d[1],b=0,y=0,E=0,T=0,A=0,C=0,S=0,M=0,v=0,R=0,P=0,I=0,k=0,V=0;for(let t=0,e=2;t<p;t++,e+=6)b=d[e],y=d[e+1],E=d[e+2],T=d[e+3],A=d[e+4],C=d[e+5],S=.1875*(x-2*b+E),M=.1875*(w-2*y+T),v=.09375*(3*(b-E)-x+A),R=.09375*(3*(y-T)-w+C),P=2*S+v,I=2*M+R,k=.75*(b-x)+S+.16666667*v,V=.75*(y-w)+M+.16666667*R,f+=Math.sqrt(k*k+V*V),k+=P,V+=I,P+=v,I+=R,f+=Math.sqrt(k*k+V*V),k+=P,V+=I,f+=Math.sqrt(k*k+V*V),k+=P+v,V+=I+R,f+=Math.sqrt(k*k+V*V),g[t]=f,x=A,w=C;if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;let _=this.segments,D=0;for(let t=0,e=0,n=0,r=0;t<s;t++,e+=3){let s=l[t];o+=s;let a=o;if(c)a%=f,a<0&&(a+=f),n=0;else{if(a<0){this.addBeforePosition(a,d,0,h,e);continue}if(a>f){this.addAfterPosition(a-f,d,u-4,h,e);continue}}for(;;n++){let t=g[n];if(!(a>t)){if(0==n)a/=t;else{let e=g[n-1];a=(a-e)/(t-e)}break}}if(n!=m){m=n;let t=6*n;for(x=d[t],w=d[t+1],b=d[t+2],y=d[t+3],E=d[t+4],T=d[t+5],A=d[t+6],C=d[t+7],S=.03*(x-2*b+E),M=.03*(w-2*y+T),v=.006*(3*(b-E)-x+A),R=.006*(3*(y-T)-w+C),P=2*S+v,I=2*M+R,k=.3*(b-x)+S+.16666667*v,V=.3*(y-w)+M+.16666667*R,D=Math.sqrt(k*k+V*V),_[0]=D,t=1;t<8;t++)k+=P,V+=I,P+=v,I+=R,D+=Math.sqrt(k*k+V*V),_[t]=D;k+=P,V+=I,D+=Math.sqrt(k*k+V*V),_[8]=D,k+=P+v,V+=I+R,D+=Math.sqrt(k*k+V*V),_[9]=D,r=0}for(a*=D;;r++){let t=_[r];if(!(a>t)){if(0==r)a/=t;else{let e=_[r-1];a=r+(a-e)/(t-e)}break}}this.addCurvePosition(.1*a,x,w,b,y,E,T,A,C,h,e,i||t>0&&0==s)}return h}addBeforePosition(t,e,s,i,n){let r=e[s],a=e[s+1],o=e[s+2]-r,l=e[s+3]-a,h=Math.atan2(l,o);i[n]=r+t*Math.cos(h),i[n+1]=a+t*Math.sin(h),i[n+2]=h}addAfterPosition(t,e,s,i,n){let r=e[s+2],a=e[s+3],o=r-e[s],l=a-e[s+1],h=Math.atan2(l,o);i[n]=r+t*Math.cos(h),i[n+1]=a+t*Math.sin(h),i[n+2]=h}addCurvePosition(t,e,s,i,n,r,a,o,l,h,d,c){(0==t||isNaN(t))&&(t=1e-4);let u=t*t,p=u*t,m=1-t,g=m*m,f=g*m,x=m*t,w=3*x,b=m*w,y=w*t,E=e*f+i*b+r*y+o*p,T=s*f+n*b+a*y+l*p;h[d]=E,h[d+1]=T,c&&(h[d+2]=Math.atan2(T-(s*g+n*x*2+a*u),E-(e*g+i*x*2+r*u)))}getOrder(){return this.data.order}};E(re,"NONE",-1),E(re,"BEFORE",-2),E(re,"AFTER",-3),E(re,"epsilon",1e-5);let ae=re;class oe{constructor(t,e){if(E(this,"data"),E(this,"bone"),E(this,"color"),E(this,"darkColor"),E(this,"attachment"),E(this,"attachmentTime"),E(this,"attachmentVertices",new Array),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new R,this.darkColor=null==t.darkColor?null:new R,this.setToSetupPose()}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(this.attachment=t,this.attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0)}setAttachmentTime(t){this.attachmentTime=this.bone.skeleton.time-t}getAttachmentTime(){return this.bone.skeleton.time-this.attachmentTime}setToSetupPose(){this.color.setFromColor(this.data.color),null!=this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))}}class le{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"scaleMix",0),E(this,"shearMix",0),E(this,"temp",new L),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.scaleMix=t.scaleMix,this.shearMix=t.shearMix,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}apply(){this.update()}update(){this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld()}applyAbsoluteWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?I.degRad:-I.degRad,d=this.data.offsetRotation*h,c=this.data.offsetShearY*h,u=this.bones;for(let h=0,p=u.length;h<p;h++){let p=u[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)-Math.atan2(i,e)+d;a>I.PI?a-=I.PI2:a<-I.PI&&(a+=I.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=(t.x-p.worldX)*e,p.worldY+=(t.y-p.worldY)*e,m=!0}if(s>0){let t=Math.sqrt(p.a*p.a+p.c*p.c),e=Math.sqrt(r*r+o*o);t>1e-5&&(t=(t+(e-t+this.data.offsetScaleX)*s)/t),p.a*=t,p.c*=t,t=Math.sqrt(p.b*p.b+p.d*p.d),e=Math.sqrt(a*a+l*l),t>1e-5&&(t=(t+(e-t+this.data.offsetScaleY)*s)/t),p.b*=t,p.d*=t,m=!0}if(i>0){let t=p.b,e=p.d,s=Math.atan2(e,t),n=Math.atan2(l,a)-Math.atan2(o,r)-(s-Math.atan2(p.c,p.a));n>I.PI?n-=I.PI2:n<-I.PI&&(n+=I.PI2),n=s+(n+c)*i;let h=Math.sqrt(t*t+e*e);p.b=Math.cos(n)*h,p.d=Math.sin(n)*h,m=!0}m&&(p.appliedValid=!1)}}applyRelativeWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?I.degRad:-I.degRad,d=this.data.offsetRotation*h,c=this.data.offsetShearY*h,u=this.bones;for(let h=0,p=u.length;h<p;h++){let p=u[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)+d;a>I.PI?a-=I.PI2:a<-I.PI&&(a+=I.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=t.x*e,p.worldY+=t.y*e,m=!0}if(s>0){let t=(Math.sqrt(r*r+o*o)-1+this.data.offsetScaleX)*s+1;p.a*=t,p.c*=t,t=(Math.sqrt(a*a+l*l)-1+this.data.offsetScaleY)*s+1,p.b*=t,p.d*=t,m=!0}if(i>0){let t=Math.atan2(l,a)-Math.atan2(o,r);t>I.PI?t-=I.PI2:t<-I.PI&&(t+=I.PI2);let e=p.b,s=p.d;t=Math.atan2(s,e)+(t-I.PI/2+c)*i;let n=Math.sqrt(e*e+s*s);p.b=Math.cos(t)*n,p.d=Math.sin(t)*n,m=!0}m&&(p.appliedValid=!1)}}applyAbsoluteLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;if(0!=t){let e=n.arotation-l+this.data.offsetRotation;e-=360*(16384-(16384.499999999996-e/360|0)),l+=e*t}let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax-h+this.data.offsetX)*e,d+=(n.ay-d+this.data.offsetY)*e);let c=o.ascaleX,u=o.ascaleY;s>0&&(c>1e-5&&(c=(c+(n.ascaleX-c+this.data.offsetScaleX)*s)/c),u>1e-5&&(u=(u+(n.ascaleY-u+this.data.offsetScaleY)*s)/u));let p=o.ashearY;if(i>0){let t=n.ashearY-p+this.data.offsetShearY;t-=360*(16384-(16384.499999999996-t/360|0)),o.shearY+=t*i}o.updateWorldTransformWith(h,d,l,c,u,o.ashearX,p)}}applyRelativeLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;0!=t&&(l+=(n.arotation+this.data.offsetRotation)*t);let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax+this.data.offsetX)*e,d+=(n.ay+this.data.offsetY)*e);let c=o.ascaleX,u=o.ascaleY;s>0&&(c>1e-5&&(c*=(n.ascaleX-1+this.data.offsetScaleX)*s+1),u>1e-5&&(u*=(n.ascaleY-1+this.data.offsetScaleY)*s+1));let p=o.ashearY;i>0&&(p+=(n.ashearY+this.data.offsetShearY)*i),o.updateWorldTransformWith(h,d,l,c,u,o.ashearX,p)}}getOrder(){return this.data.order}}class he{constructor(t){if(E(this,"data"),E(this,"bones"),E(this,"slots"),E(this,"drawOrder"),E(this,"ikConstraints"),E(this,"transformConstraints"),E(this,"pathConstraints"),E(this,"_updateCache",new Array),E(this,"updateCacheReset",new Array),E(this,"skin"),E(this,"color"),E(this,"time",0),E(this,"flipX",!1),E(this,"flipY",!1),E(this,"x",0),E(this,"y",0),null==t)throw new Error("data cannot be null.");this.data=t,this.bones=new Array;for(let e=0;e<t.bones.length;e++){let s,i=t.bones[e];if(null==i.parent)s=new Nt(i,this,null);else{let t=this.bones[i.parent.index];s=new Nt(i,this,t),t.children.push(s)}this.bones.push(s)}this.slots=new Array,this.drawOrder=new Array;for(let e=0;e<t.slots.length;e++){let s=t.slots[e],i=this.bones[s.boneData.index],n=new oe(s,i);this.slots.push(n),this.drawOrder.push(n)}this.ikConstraints=new Array;for(let e=0;e<t.ikConstraints.length;e++){let s=t.ikConstraints[e];this.ikConstraints.push(new Zt(s,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new le(s,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new ae(s,this))}this.color=new R(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0,this.updateCacheReset.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].sorted=!1;let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,n=e.length,r=s.length,a=i.length,o=n+r+a;t:for(let t=0;t<o;t++){for(let s=0;s<n;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<r;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<a;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),s.length>1){let t=s[s.length-1];this._updateCache.indexOf(t)>-1||this.updateCacheReset.push(t)}this._updateCache.push(t),this.sortReset(i.children),s[s.length-1].sorted=!0}sortPathConstraint(t){let e=t.target,s=e.data.index,i=e.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,s,i);for(let t=0,e=this.data.skins.length;t<e;t++)this.sortPathConstraintAttachment(this.data.skins[t],s,i);let n=e.getAttachment();n instanceof vt&&this.sortPathConstraintAttachmentWith(n,i);let r=t.bones,a=r.length;for(let t=0;t<a;t++)this.sortBone(r[t]);this._updateCache.push(t);for(let t=0;t<a;t++)this.sortReset(r[t].children);for(let t=0;t<a;t++)r[t].sorted=!0}sortTransformConstraint(t){this.sortBone(t.target);let e=t.bones,s=e.length;if(t.data.local)for(let t=0;t<s;t++){let s=e[t];this.sortBone(s.parent),this._updateCache.indexOf(s)>-1||this.updateCacheReset.push(s)}else for(let t=0;t<s;t++)this.sortBone(e[t]);this._updateCache.push(t);for(let t=0;t<s;t++)this.sortReset(e[t].children);for(let t=0;t<s;t++)e[t].sorted=!0}sortPathConstraintAttachment(t,e,s){let i=t.attachments[e];if(i)for(let t in i)this.sortPathConstraintAttachmentWith(i[t],s)}sortPathConstraintAttachmentWith(t,e){if(!(t instanceof vt))return;let s=t.bones;if(null==s)this.sortBone(e);else{let t=this.bones,e=0;for(;e<s.length;){let i=s[e++];for(let n=e+i;e<n;e++){let i=s[e];this.sortBone(t[i])}}}}sortBone(t){if(t.sorted)return;let e=t.parent;null!=e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let e=0,s=t.length;e<s;e++){let s=t[e];s.sorted&&this.sortReset(s.children),s.sorted=!1}}updateWorldTransform(){let t=this.updateCacheReset;for(let e=0,s=t.length;e<s;e++){let s=t[e];s.ax=s.x,s.ay=s.y,s.arotation=s.rotation,s.ascaleX=s.scaleX,s.ascaleY=s.scaleY,s.ashearX=s.shearX,s.ashearY=s.shearY,s.appliedValid=!0}let e=this._updateCache;for(let t=0,s=e.length;t<s;t++)e[t].update()}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose();let e=this.ikConstraints;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.bendDirection=s.data.bendDirection,s.mix=s.data.mix}let s=this.transformConstraints;for(let t=0,e=s.length;t<e;t++){let e=s[t],i=e.data;e.rotateMix=i.rotateMix,e.translateMix=i.translateMix,e.scaleMix=i.scaleMix,e.shearMix=i.shearMix}let i=this.pathConstraints;for(let t=0,e=i.length;t<e;t++){let e=i[t],s=e.data;e.position=s.position,e.spacing=s.spacing,e.rotateMix=s.rotateMix,e.translateMix=s.translateMix}}setSlotsToSetupPose(){let t=this.slots;N.arrayCopy(t,0,this.drawOrder,0,t.length);for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose()}getRootBone(){return 0==this.bones.length?null:this.bones[0]}findBone(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}findSlot(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}setSkinByName(t){let e=this.data.findSkin(t);if(null==e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(null!=t)if(null!=this.skin)t.attachAll(this,this.skin);else{let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s],n=i.data.attachmentName;if(null!=n){let e=t.getAttachment(s,n);null!=e&&i.setAttachment(e)}}}this.skin=t}getAttachmentByName(t,e){return this.getAttachment(this.data.findSlotIndex(t),e)}getAttachment(t,e){if(null==e)throw new Error("attachmentName cannot be null.");if(null!=this.skin){let s=this.skin.getAttachment(t,e);if(null!=s)return s}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(null==t)throw new Error("slotName cannot be null.");let s=this.slots;for(let i=0,n=s.length;i<n;i++){let n=s[i];if(n.data.name==t){let s=null;if(null!=e&&(s=this.getAttachment(i,e),null==s))throw new Error("Attachment not found: "+e+", for slot: "+t);return void n.setAttachment(s)}}throw new Error("Slot not found: "+t)}findIkConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findTransformConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findPathConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}getBounds(t,e,s){if(null==t)throw new Error("offset cannot be null.");if(null==e)throw new Error("size cannot be null.");let i=this.drawOrder,n=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let t=0,e=i.length;t<e;t++){let e=i[t],l=0,h=null,d=e.getAttachment();if(d instanceof It)l=8,h=N.setArraySize(s,l,0),d.computeWorldVertices(e.bone,h,0,2);else if(d instanceof Mt){let t=d;l=t.worldVerticesLength,h=N.setArraySize(s,l,0),t.computeWorldVertices(e,0,l,h,0,2)}if(null!=h)for(let t=0,e=h.length;t<e;t+=2){let e=h[t],s=h[t+1];n=Math.min(n,e),r=Math.min(r,s),a=Math.max(a,e),o=Math.max(o,s)}}t.set(n,r),e.set(a-n,o-r)}update(t){this.time+=t}}class de{constructor(){E(this,"minX",0),E(this,"minY",0),E(this,"maxX",0),E(this,"maxY",0),E(this,"boundingBoxes",new Array),E(this,"polygons",new Array),E(this,"polygonPool",new O(()=>N.newFloatArray(16)))}update(t,e){if(null==t)throw new Error("skeleton cannot be null.");let s=this.boundingBoxes,i=this.polygons,n=this.polygonPool,r=t.slots,a=r.length;s.length=0,n.freeAll(i),i.length=0;for(let t=0;t<a;t++){let e=r[t],a=e.getAttachment();if(a instanceof Ct){let t=a;s.push(t);let r=n.obtain();r.length!=t.worldVerticesLength&&(r=N.newFloatArray(t.worldVerticesLength)),i.push(r),t.computeWorldVertices(e,0,t.worldVerticesLength,r,0,2)}}e?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=this.polygons;for(let r=0,a=n.length;r<a;r++){let a=n[r],o=a;for(let n=0,r=a.length;n<r;n+=2){let r=o[n],a=o[n+1];t=Math.min(t,r),e=Math.min(e,a),s=Math.max(s,r),i=Math.max(i,a)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,i){let n=this.minX,r=this.minY,a=this.maxX,o=this.maxY;if(t<=n&&s<=n||e<=r&&i<=r||t>=a&&s>=a||e>=o&&i>=o)return!1;let l=(i-e)/(s-t),h=l*(n-t)+e;if(h>r&&h<o)return!0;if(h=l*(a-t)+e,h>r&&h<o)return!0;let d=(r-e)/l+t;return d>n&&d<a||(d=(o-e)/l+t,d>n&&d<a)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){let s=this.polygons;for(let i=0,n=s.length;i<n;i++)if(this.containsPointPolygon(s[i],t,e))return this.boundingBoxes[i];return null}containsPointPolygon(t,e,s){let i=t,n=t.length,r=n-2,a=!1;for(let t=0;t<n;t+=2){let n=i[t+1],o=i[r+1];if(n<s&&o>=s||o<s&&n>=s){let l=i[t];l+(s-n)/(o-n)*(i[r]-l)<e&&(a=!a)}r=t}return a}intersectsSegment(t,e,s,i){let n=this.polygons;for(let r=0,a=n.length;r<a;r++)if(this.intersectsSegmentPolygon(n[r],t,e,s,i))return this.boundingBoxes[r];return null}intersectsSegmentPolygon(t,e,s,i,n){let r=t,a=t.length,o=e-i,l=s-n,h=e*n-s*i,d=r[a-2],c=r[a-1];for(let t=0;t<a;t+=2){let a=r[t],u=r[t+1],p=d*u-c*a,m=d-a,g=c-u,f=o*g-l*m,x=(h*m-o*p)/f;if((x>=d&&x<=a||x>=a&&x<=d)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(h*g-l*p)/f;if((t>=c&&t<=u||t>=u&&t<=c)&&(t>=s&&t<=n||t>=n&&t<=s))return!0}d=a,c=u}return!1}getPolygon(t){if(null==t)throw new Error("boundingBox cannot be null.");let e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}}class ce{constructor(){E(this,"convexPolygons",new Array),E(this,"convexPolygonsIndices",new Array),E(this,"indicesArray",new Array),E(this,"isConcaveArray",new Array),E(this,"triangles",new Array),E(this,"polygonPool",new O(()=>new Array)),E(this,"polygonIndicesPool",new O(()=>new Array))}triangulate(t){let e=t,s=t.length>>1,i=this.indicesArray;i.length=0;for(let t=0;t<s;t++)i[t]=t;let n=this.isConcaveArray;n.length=0;for(let t=0,r=s;t<r;++t)n[t]=ce.isConcave(t,s,e,i);let r=this.triangles;for(r.length=0;s>3;){let t=s-1,a=0,o=1;for(;;){t:if(!n[a]){let r=i[t]<<1,l=i[a]<<1,h=i[o]<<1,d=e[r],c=e[r+1],u=e[l],p=e[l+1],m=e[h],g=e[h+1];for(let r=(o+1)%s;r!=t;r=(r+1)%s){if(!n[r])continue;let t=i[r]<<1,s=e[t],a=e[t+1];if(ce.positiveArea(m,g,d,c,s,a)&&ce.positiveArea(d,c,u,p,s,a)&&ce.positiveArea(u,p,m,g,s,a))break t}break}if(0==o){do{if(!n[a])break;a--}while(a>0);break}t=a,a=o,o=(o+1)%s}r.push(i[(s+a-1)%s]),r.push(i[a]),r.push(i[(a+1)%s]),i.splice(a,1),n.splice(a,1),s--;let l=(s+a-1)%s,h=a==s?0:a;n[l]=ce.isConcave(l,s,e,i),n[h]=ce.isConcave(h,s,e,i)}return 3==s&&(r.push(i[2]),r.push(i[0]),r.push(i[1])),r}decompose(t,e){let s=t,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;let n=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(n),n.length=0;let r=this.polygonIndicesPool.obtain();r.length=0;let a=this.polygonPool.obtain();a.length=0;let o=-1,l=0;for(let t=0,h=e.length;t<h;t+=3){let h=e[t]<<1,d=e[t+1]<<1,c=e[t+2]<<1,u=s[h],p=s[h+1],m=s[d],g=s[d+1],f=s[c],x=s[c+1],w=!1;if(o==h){let t=a.length-4,e=ce.winding(a[t],a[t+1],a[t+2],a[t+3],f,x),s=ce.winding(f,x,a[0],a[1],a[2],a[3]);e==l&&s==l&&(a.push(f),a.push(x),r.push(c),w=!0)}w||(a.length>0?(i.push(a),n.push(r)):(this.polygonPool.free(a),this.polygonIndicesPool.free(r)),a=this.polygonPool.obtain(),a.length=0,a.push(u),a.push(p),a.push(m),a.push(g),a.push(f),a.push(x),r=this.polygonIndicesPool.obtain(),r.length=0,r.push(h),r.push(d),r.push(c),l=ce.winding(u,p,m,g,f,x),o=h)}a.length>0&&(i.push(a),n.push(r));for(let t=0,e=i.length;t<e;t++){if(r=n[t],0==r.length)continue;let s=r[0],o=r[r.length-1];a=i[t];let l=a.length-4,h=a[l],d=a[l+1],c=a[l+2],u=a[l+3],p=a[0],m=a[1],g=a[2],f=a[3],x=ce.winding(h,d,c,u,p,m);for(let l=0;l<e;l++){if(l==t)continue;let e=n[l];if(3!=e.length)continue;let w=e[0],b=e[1],y=e[2],E=i[l],T=E[E.length-2],A=E[E.length-1];if(w!=s||b!=o)continue;let C=ce.winding(h,d,c,u,T,A),S=ce.winding(T,A,p,m,g,f);C==x&&S==x&&(E.length=0,e.length=0,a.push(T),a.push(A),r.push(y),h=c,d=u,c=T,u=A,l=0)}}for(let t=i.length-1;t>=0;t--)a=i[t],0==a.length&&(i.splice(t,1),this.polygonPool.free(a),r=n[t],n.splice(t,1),this.polygonIndicesPool.free(r));return i}static isConcave(t,e,s,i){let n=i[(e+t-1)%e]<<1,r=i[t]<<1,a=i[(t+1)%e]<<1;return!this.positiveArea(s[n],s[n+1],s[r],s[r+1],s[a],s[a+1])}static positiveArea(t,e,s,i,n,r){return t*(r-i)+s*(e-r)+n*(i-e)>=0}static winding(t,e,s,i,n,r){let a=s-t,o=i-e;return n*o-r*a+a*e-t*o>=0?1:-1}}class ue{constructor(){E(this,"triangulator",new ce),E(this,"clippingPolygon",new Array),E(this,"clipOutput",new Array),E(this,"clippedVertices",new Array),E(this,"clippedUVs",new Array),E(this,"clippedTriangles",new Array),E(this,"scratch",new Array),E(this,"clipAttachment"),E(this,"clippingPolygons")}clipStart(t,e){if(null!=this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=N.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let n=this.clippingPolygon;ue.makeClockwise(n);let r=this.clippingPolygons=this.triangulator.decompose(n,this.triangulator.triangulate(n));for(let t=0,e=r.length;t<e;t++){let e=r[t];ue.makeClockwise(e),e.push(e[0]),e.push(e[1])}return r.length}clipEndWithSlot(t){null!=this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){null!=this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)}isClipping(){return null!=this.clipAttachment}clipTriangles(t,e,s,i,n,r,a,o){let l=this.clipOutput,h=this.clippedVertices,d=this.clippedTriangles,c=this.clippingPolygons,u=this.clippingPolygons.length,p=o?12:8,m=0;h.length=0,d.length=0;t:for(let e=0;e<i;e+=3){let i=s[e]<<1,g=t[i],f=t[i+1],x=n[i],w=n[i+1];i=s[e+1]<<1;let b=t[i],y=t[i+1],E=n[i],T=n[i+1];i=s[e+2]<<1;let A=t[i],C=t[i+1],S=n[i],M=n[i+1];for(let t=0;t<u;t++){let e=h.length;if(!this.clip(g,f,b,y,A,C,c[t],l)){let t=N.setArraySize(h,e+3*p);t[e]=g,t[e+1]=f,t[e+2]=r.r,t[e+3]=r.g,t[e+4]=r.b,t[e+5]=r.a,o?(t[e+6]=x,t[e+7]=w,t[e+8]=a.r,t[e+9]=a.g,t[e+10]=a.b,t[e+11]=a.a,t[e+12]=b,t[e+13]=y,t[e+14]=r.r,t[e+15]=r.g,t[e+16]=r.b,t[e+17]=r.a,t[e+18]=E,t[e+19]=T,t[e+20]=a.r,t[e+21]=a.g,t[e+22]=a.b,t[e+23]=a.a,t[e+24]=A,t[e+25]=C,t[e+26]=r.r,t[e+27]=r.g,t[e+28]=r.b,t[e+29]=r.a,t[e+30]=S,t[e+31]=M,t[e+32]=a.r,t[e+33]=a.g,t[e+34]=a.b,t[e+35]=a.a):(t[e+6]=x,t[e+7]=w,t[e+8]=b,t[e+9]=y,t[e+10]=r.r,t[e+11]=r.g,t[e+12]=r.b,t[e+13]=r.a,t[e+14]=E,t[e+15]=T,t[e+16]=A,t[e+17]=C,t[e+18]=r.r,t[e+19]=r.g,t[e+20]=r.b,t[e+21]=r.a,t[e+22]=S,t[e+23]=M),e=d.length;let s=N.setArraySize(d,e+3);s[e]=m,s[e+1]=m+1,s[e+2]=m+2,m+=3;continue t}{let t=l.length;if(0==t)continue;let s=y-C,i=A-b,n=g-A,c=C-f,u=1/(s*n+i*(f-C)),v=t>>1,R=this.clipOutput,P=N.setArraySize(h,e+v*p);for(let l=0;l<t;l+=2){let t=R[l],h=R[l+1];P[e]=t,P[e+1]=h,P[e+2]=r.r,P[e+3]=r.g,P[e+4]=r.b,P[e+5]=r.a;let d=t-A,m=h-C,g=(s*d+i*m)*u,f=(c*d+n*m)*u,b=1-g-f;P[e+6]=x*g+E*f+S*b,P[e+7]=w*g+T*f+M*b,o&&(P[e+8]=a.r,P[e+9]=a.g,P[e+10]=a.b,P[e+11]=a.a),e+=p}e=d.length;let I=N.setArraySize(d,e+3*(v-2));v--;for(let t=1;t<v;t++)I[e]=m,I[e+1]=m+t,I[e+2]=m+t+1,e+=3;m+=v+1}}}}clipTrianglesUnpacked(t,e,s,i){let n=this.clipOutput,r=this.clippedVertices,a=this.clippedUVs,o=this.clippedTriangles,l=this.clippingPolygons,h=l.length,d=0;r.length=0,a.length=0,o.length=0;for(let c=0;c<s;c+=3){let s=e[c]<<1,u=t[s],p=t[s+1],m=i[s],g=i[s+1];s=e[c+1]<<1;let f=t[s],x=t[s+1],w=i[s],b=i[s+1];s=e[c+2]<<1;let y=t[s],E=t[s+1],T=i[s],A=i[s+1];for(let t=0;t<h;t++){let e=r.length;if(!this.clip(u,p,f,x,y,E,l[t],n)){let t=N.setArraySize(r,e+6);t[e]=u,t[e+1]=p,t[e+2]=f,t[e+3]=x,t[e+4]=y,t[e+5]=E;let s=N.setArraySize(a,e+6);s[e]=m,s[e+1]=g,s[e+2]=w,s[e+3]=b,s[e+4]=T,s[e+5]=A,e=o.length;let i=N.setArraySize(o,e+3);i[e]=d,i[e+1]=d+1,i[e+2]=d+2,d+=3;break}{let t=n.length;if(0==t)continue;let s=x-E,i=y-f,l=u-y,h=E-p,c=1/(s*l+i*(p-E)),C=t>>1,S=this.clipOutput,M=N.setArraySize(r,e+2*C),v=N.setArraySize(a,e+2*C);for(let n=0;n<t;n+=2,e+=2){let t=S[n],r=S[n+1];M[e]=t,M[e+1]=r;let a=t-y,o=r-E,d=(s*a+i*o)*c,u=(h*a+l*o)*c,p=1-d-u;v[e]=m*d+w*u+T*p,v[e+1]=g*d+b*u+A*p}e=o.length;let R=N.setArraySize(o,e+3*(C-2));C--;for(let t=1;t<C;t++,e+=3)R[e]=d,R[e+1]=d+t,R[e+2]=d+t+1;d+=C+1}}}}clip(t,e,s,i,n,r,a,o){let l=o,h=!1,d=null;a.length%4>=2?(d=o,o=this.scratch):d=this.scratch,d.length=0,d.push(t),d.push(e),d.push(s),d.push(i),d.push(n),d.push(r),d.push(t),d.push(e),o.length=0;let c=a,u=a.length-4;for(let t=0;;t+=2){let e=c[t],s=c[t+1],i=c[t+2],n=c[t+3],r=e-i,a=s-n,p=d,m=d.length-2,g=o.length;for(let t=0;t<m;t+=2){let l=p[t],d=p[t+1],c=p[t+2],u=p[t+3],m=r*(u-n)-a*(c-i)>0;if(r*(d-n)-a*(l-i)>0){if(m){o.push(c),o.push(u);continue}let t=u-d,r=c-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s)}else if(m){let t=u-d,r=c-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s);o.push(c),o.push(u)}h=!0}if(g==o.length)return l.length=0,!0;if(o.push(o[0]),o.push(o[1]),t==u)break;let f=o;(o=d).length=0,d=f}if(l!=o){l.length=0;for(let t=0,e=o.length-2;t<e;t++)l[t]=o[t]}else l.length=l.length-2;return h}static makeClockwise(t){let e=t,s=t.length,i=e[s-2]*e[1]-e[0]*e[s-1],n=0,r=0,a=0,o=0;for(let t=0,l=s-3;t<l;t+=2)n=e[t],r=e[t+1],a=e[t+2],o=e[t+3],i+=n*o-a*r;if(!(i<0))for(let t=0,i=s-2,n=s>>1;t<n;t+=2){let s=e[t],n=e[t+1],r=i-t;e[t]=e[r],e[t+1]=e[r+1],e[r]=s,e[r+1]=n}}}class pe{constructor(){E(this,"name"),E(this,"bones",new Array),E(this,"slots",new Array),E(this,"skins",new Array),E(this,"defaultSkin"),E(this,"events",new Array),E(this,"animations",new Array),E(this,"ikConstraints",new Array),E(this,"transformConstraints",new Array),E(this,"pathConstraints",new Array),E(this,"width"),E(this,"height"),E(this,"version"),E(this,"hash"),E(this,"fps",0),E(this,"imagesPath")}findBone(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSlot(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSkin(t){if(null==t)throw new Error("skinName cannot be null.");let e=this.skins;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findEvent(t){if(null==t)throw new Error("eventDataName cannot be null.");let e=this.events;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findAnimation(t){if(null==t)throw new Error("animationName cannot be null.");let e=this.animations;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findIkConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findTransformConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findPathConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findPathConstraintIndex(t){if(null==t)throw new Error("pathConstraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}}var me,ge,fe=((me=fe||{})[me.Normal=0]="Normal",me[me.Additive=1]="Additive",me[me.Multiply=2]="Multiply",me[me.Screen=3]="Screen",me);class xe{constructor(t){if(E(this,"name"),E(this,"attachments",new Array),null==t)throw new Error("name cannot be null.");this.name=t}addAttachment(t,e,s){if(null==s)throw new Error("attachment cannot be null.");let i=this.attachments;t>=i.length&&(i.length=t+1),i[t]||(i[t]={}),i[t][e]=s}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}attachAll(t,e){let s=0;for(let i=0;i<t.slots.length;i++){let n=t.slots[i],r=n.getAttachment();if(r&&s<e.attachments.length){let t=e.attachments[s];for(let e in t){if(r==t[e]){let t=this.getAttachment(s,e);null!=t&&n.setAttachment(t);break}}}s++}}}class we{constructor(t,e,s){if(E(this,"index"),E(this,"name"),E(this,"boneData"),E(this,"color",new R(1,1,1,1)),E(this,"darkColor"),E(this,"attachmentName"),E(this,"blendMode"),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");if(null==s)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}class be{constructor(t){if(E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"scaleMix",0),E(this,"shearMix",0),E(this,"offsetRotation",0),E(this,"offsetX",0),E(this,"offsetY",0),E(this,"offsetScaleX",0),E(this,"offsetScaleY",0),E(this,"offsetShearY",0),E(this,"relative",!1),E(this,"local",!1),null==t)throw new Error("name cannot be null.");this.name=t}}class ye{constructor(t){E(this,"attachmentLoader"),E(this,"scale",1),E(this,"linkedMeshes",new Array),this.attachmentLoader=t}readSkeletonData(t){let e=this.scale,s=new pe,i="string"==typeof t?JSON.parse(t):t,n=i.skeleton;if(null!=n&&(s.hash=n.hash,s.version=n.spine,s.width=n.width,s.height=n.height,s.fps=n.fps,s.imagesPath=n.images),i.bones)for(let t=0;t<i.bones.length;t++){let n=i.bones[t],r=null,a=this.getValue(n,"parent",null);if(null!=a&&(r=s.findBone(a),null==r))throw new Error("Parent bone not found: "+a);let o=new Vt(s.bones.length,n.name,r);o.length=this.getValue(n,"length",0)*e,o.x=this.getValue(n,"x",0)*e,o.y=this.getValue(n,"y",0)*e,o.rotation=this.getValue(n,"rotation",0),o.scaleX=this.getValue(n,"scaleX",1),o.scaleY=this.getValue(n,"scaleY",1),o.shearX=this.getValue(n,"shearX",0),o.shearY=this.getValue(n,"shearY",0),o.transformMode=ye.transformModeFromString(this.getValue(n,"transform","normal")),s.bones.push(o)}if(i.slots)for(let t=0;t<i.slots.length;t++){let e=i.slots[t],n=e.name,r=e.bone,a=s.findBone(r);if(null==a)throw new Error("Slot bone not found: "+r);let o=new we(s.slots.length,n,a),l=this.getValue(e,"color",null);null!=l&&o.color.setFromString(l);let h=this.getValue(e,"dark",null);null!=h&&(o.darkColor=new R(1,1,1,1),o.darkColor.setFromString(h)),o.attachmentName=this.getValue(e,"attachment",null),o.blendMode=ye.blendModeFromString(this.getValue(e,"blend","normal")),s.slots.push(o)}if(i.ik)for(let t=0;t<i.ik.length;t++){let e=i.ik[t],n=new Qt(e.name);n.order=this.getValue(e,"order",0);for(let t=0;t<e.bones.length;t++){let i=e.bones[t],r=s.findBone(i);if(null==r)throw new Error("IK bone not found: "+i);n.bones.push(r)}let r=e.target;if(n.target=s.findBone(r),null==n.target)throw new Error("IK target bone not found: "+r);n.bendDirection=this.getValue(e,"bendPositive",!0)?1:-1,n.mix=this.getValue(e,"mix",1),s.ikConstraints.push(n)}if(i.transform)for(let t=0;t<i.transform.length;t++){let n=i.transform[t],r=new be(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findBone(a),null==r.target)throw new Error("Transform constraint target bone not found: "+a);r.local=this.getValue(n,"local",!1),r.relative=this.getValue(n,"relative",!1),r.offsetRotation=this.getValue(n,"rotation",0),r.offsetX=this.getValue(n,"x",0)*e,r.offsetY=this.getValue(n,"y",0)*e,r.offsetScaleX=this.getValue(n,"scaleX",0),r.offsetScaleY=this.getValue(n,"scaleY",0),r.offsetShearY=this.getValue(n,"shearY",0),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),r.scaleMix=this.getValue(n,"scaleMix",1),r.shearMix=this.getValue(n,"shearMix",1),s.transformConstraints.push(r)}if(i.path)for(let t=0;t<i.path.length;t++){let n=i.path[t],r=new Jt(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findSlot(a),null==r.target)throw new Error("Path target slot not found: "+a);r.positionMode=ye.positionModeFromString(this.getValue(n,"positionMode","percent")),r.spacingMode=ye.spacingModeFromString(this.getValue(n,"spacingMode","length")),r.rotateMode=ye.rotateModeFromString(this.getValue(n,"rotateMode","tangent")),r.offsetRotation=this.getValue(n,"rotation",0),r.position=this.getValue(n,"position",0),r.positionMode==se.Fixed&&(r.position*=e),r.spacing=this.getValue(n,"spacing",0),r.spacingMode!=ie.Length&&r.spacingMode!=ie.Fixed||(r.spacing*=e),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),s.pathConstraints.push(r)}if(i.skins)for(let t in i.skins){let e=i.skins[t],n=new xe(t);for(let t in e){let i=s.findSlotIndex(t);if(-1==i)throw new Error("Slot not found: "+t);let r=e[t];for(let t in r){let e=this.readAttachment(r[t],n,i,t,s);null!=e&&n.addAttachment(i,t,e)}}s.skins.push(n),"default"==n.name&&(s.defaultSkin=n)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],i=null==e.skin?s.defaultSkin:s.findSkin(e.skin);if(null==i)throw new Error("Skin not found: "+e.skin);let n=i.getAttachment(e.slotIndex,e.parent);if(null==n)throw new Error("Parent mesh not found: "+e.parent);e.mesh.setParentMesh(n),e.mesh.updateUVs()}if(this.linkedMeshes.length=0,i.events)for(let t in i.events){let e=i.events[t],n=new Ht(t);n.intValue=this.getValue(e,"int",0),n.floatValue=this.getValue(e,"float",0),n.stringValue=this.getValue(e,"string",""),s.events.push(n)}if(i.animations)for(let t in i.animations){let e=i.animations[t];this.readAnimation(e,t,s)}return s}readAttachment(t,e,s,i,n){let r=this.scale;switch(i=this.getValue(t,"name",i),this.getValue(t,"type","region")){case"region":{let s=this.getValue(t,"path",i),n=this.attachmentLoader.newRegionAttachment(e,i,s);if(null==n)return null;n.path=s,n.x=this.getValue(t,"x",0)*r,n.y=this.getValue(t,"y",0)*r,n.scaleX=this.getValue(t,"scaleX",1),n.scaleY=this.getValue(t,"scaleY",1),n.rotation=this.getValue(t,"rotation",0),n.width=t.width*r,n.height=t.height*r;let a=this.getValue(t,"color",null);return null!=a&&n.color.setFromString(a),n.updateOffset(),n}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(null==s)return null;this.readVertices(t,s,t.vertexCount<<1);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"mesh":case"linkedmesh":{let n=this.getValue(t,"path",i),r=this.attachmentLoader.newMeshAttachment(e,i,n);if(null==r)return null;r.path=n;let a=this.getValue(t,"color",null);null!=a&&r.color.setFromString(a);let o=this.getValue(t,"parent",null);if(null!=o)return r.inheritDeform=this.getValue(t,"deform",!0),this.linkedMeshes.push(new Ee(r,this.getValue(t,"skin",null),s,o)),r;let l=t.uvs;return this.readVertices(t,r,l.length),r.triangles=t.triangles,r.regionUVs=l,r.updateUVs(),r.hullLength=2*this.getValue(t,"hull",0),r}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(null==s)return null;s.closed=this.getValue(t,"closed",!1),s.constantSpeed=this.getValue(t,"constantSpeed",!0);let n=t.vertexCount;this.readVertices(t,s,n<<1);let a=N.newArray(n/3,0);for(let e=0;e<t.lengths.length;e++)a[e]=t.lengths[e]*r;s.lengths=a;let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(null==s)return null;s.x=this.getValue(t,"x",0)*r,s.y=this.getValue(t,"y",0)*r,s.rotation=this.getValue(t,"rotation",0);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(null==s)return null;let r=this.getValue(t,"end",null);if(null!=r){let t=n.findSlot(r);if(null==t)throw new Error("Clipping end slot not found: "+r);s.endSlot=t}let a=t.vertexCount;this.readVertices(t,s,a<<1);let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}}return null}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let n=t.vertices;if(s==n.length){let t=N.toFloatArray(n);if(1!=i)for(let e=0,s=n.length;e<s;e++)t[e]*=i;return void(e.vertices=t)}let r=new Array,a=new Array;for(let t=0,e=n.length;t<e;){let e=n[t++];a.push(e);for(let s=t+4*e;t<s;t+=4)a.push(n[t]),r.push(n[t+1]*i),r.push(n[t+2]*i),r.push(n[t+3])}e.bones=a,e.vertices=N.toFloatArray(r)}readAnimation(t,e,s){let i=this.scale,n=new Array,r=0;if(t.slots)for(let e in t.slots){let i=t.slots[e],a=s.findSlotIndex(e);if(-1==a)throw new Error("Slot not found: "+e);for(let t in i){let s=i[t];if("attachment"==t){let t=new it(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e++,n.time,n.name)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}else if("color"==t){let t=new tt(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new R;r.setFromString(n.color),t.setFrame(e,n.time,r.r,r.g,r.b,r.a),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*tt.ENTRIES])}else{if("twoColor"!=t)throw new Error("Invalid timeline type for a slot: "+t+" ("+e+")");{let t=new st(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new R,a=new R;r.setFromString(n.light),a.setFromString(n.dark),t.setFrame(e,n.time,r.r,r.g,r.b,r.a,a.r,a.g,a.b),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*st.ENTRIES])}}}}if(t.bones)for(let e in t.bones){let a=t.bones[e],o=s.findBoneIndex(e);if(-1==o)throw new Error("Bone not found: "+e);for(let t in a){let s=a[t];if("rotate"===t){let t=new z(s.length);t.boneIndex=o;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e,n.time,n.angle),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*z.ENTRIES])}else{if("translate"!==t&&"scale"!==t&&"shear"!==t)throw new Error("Invalid timeline type for a bone: "+t+" ("+e+")");{let e=null,a=1;"scale"===t?e=new Q(s.length):"shear"===t?e=new J(s.length):(e=new Z(s.length),a=i),e.boneIndex=o;let l=0;for(let t=0;t<s.length;t++){let i=s[t],n=this.getValue(i,"x",0),r=this.getValue(i,"y",0);e.setFrame(l,i.time,n*a,r*a),this.readCurve(i,e,l),l++}n.push(e),r=Math.max(r,e.frames[(e.getFrameCount()-1)*Z.ENTRIES])}}}}if(t.ik)for(let e in t.ik){let i=t.ik[e],a=s.findIkConstraint(e),o=new ht(i.length);o.ikConstraintIndex=s.ikConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"mix",1),this.getValue(e,"bendPositive",!0)?1:-1),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*ht.ENTRIES])}if(t.transform)for(let e in t.transform){let i=t.transform[e],a=s.findTransformConstraint(e),o=new ct(i.length);o.transformConstraintIndex=s.transformConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"rotateMix",1),this.getValue(e,"translateMix",1),this.getValue(e,"scaleMix",1),this.getValue(e,"shearMix",1)),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*ct.ENTRIES])}if(t.paths)for(let e in t.paths){let a=t.paths[e],o=s.findPathConstraintIndex(e);if(-1==o)throw new Error("Path constraint not found: "+e);let l=s.pathConstraints[o];for(let t in a){let e=a[t];if("position"===t||"spacing"===t){let s=null,a=1;"spacing"===t?(s=new mt(e.length),l.spacingMode!=ie.Length&&l.spacingMode!=ie.Fixed||(a=i)):(s=new pt(e.length),l.positionMode==se.Fixed&&(a=i)),s.pathConstraintIndex=o;let h=0;for(let i=0;i<e.length;i++){let n=e[i];s.setFrame(h,n.time,this.getValue(n,t,0)*a),this.readCurve(n,s,h),h++}n.push(s),r=Math.max(r,s.frames[(s.getFrameCount()-1)*pt.ENTRIES])}else if("mix"===t){let t=new ft(e.length);t.pathConstraintIndex=o;let s=0;for(let i=0;i<e.length;i++){let n=e[i];t.setFrame(s,n.time,this.getValue(n,"rotateMix",1),this.getValue(n,"translateMix",1)),this.readCurve(n,t,s),s++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*ft.ENTRIES])}}}if(t.deform)for(let e in t.deform){let a=t.deform[e],o=s.findSkin(e);if(null==o)throw new Error("Skin not found: "+e);for(let t in a){let e=a[t],l=s.findSlotIndex(t);if(-1==l)throw new Error("Slot not found: "+e.name);for(let t in e){let s=e[t],a=o.getAttachment(l,t);if(null==a)throw new Error("Deform attachment not found: "+s.name);let h=null!=a.bones,d=a.vertices,c=h?d.length/3*2:d.length,u=new rt(s.length);u.slotIndex=l,u.attachment=a;let p=0;for(let t=0;t<s.length;t++){let e,n=s[t],r=this.getValue(n,"vertices",null);if(null==r)e=h?N.newFloatArray(c):d;else{e=N.newFloatArray(c);let t=this.getValue(n,"offset",0);if(N.arrayCopy(r,0,e,t,r.length),1!=i)for(let s=t,n=s+r.length;s<n;s++)e[s]*=i;if(!h)for(let t=0;t<c;t++)e[t]+=d[t]}u.setFrame(p,n.time,e),this.readCurve(n,u,p),p++}n.push(u),r=Math.max(r,u.frames[u.getFrameCount()-1])}}}let a=t.drawOrder;if(null==a&&(a=t.draworder),null!=a){let t=new ot(a.length),e=s.slots.length,i=0;for(let n=0;n<a.length;n++){let r=a[n],o=null,l=this.getValue(r,"offsets",null);if(null!=l){o=N.newArray(e,-1);let t=N.newArray(e-l.length,0),i=0,n=0;for(let e=0;e<l.length;e++){let r=l[e],a=s.findSlotIndex(r.slot);if(-1==a)throw new Error("Slot not found: "+r.slot);for(;i!=a;)t[n++]=i++;o[i+r.offset]=i++}for(;i<e;)t[n++]=i++;for(let s=e-1;s>=0;s--)-1==o[s]&&(o[s]=t[--n])}t.setFrame(i++,r.time,o)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}if(t.events){let e=new at(t.events.length),i=0;for(let n=0;n<t.events.length;n++){let r=t.events[n],a=s.findEvent(r.name);if(null==a)throw new Error("Event not found: "+r.name);let o=new zt(N.toSinglePrecision(r.time),a);o.intValue=this.getValue(r,"int",a.intValue),o.floatValue=this.getValue(r,"float",a.floatValue),o.stringValue=this.getValue(r,"string",a.stringValue),e.setFrame(i++,o)}n.push(e),r=Math.max(r,e.frames[e.getFrameCount()-1])}if(isNaN(r))throw new Error("Error while parsing animation, duration is NaN");s.animations.push(new Y(e,n,r))}readCurve(t,e,s){if(t.curve)if("stepped"===t.curve)e.setStepped(s);else if("[object Array]"===Object.prototype.toString.call(t.curve)){let i=t.curve;e.setCurve(s,i[0],i[1],i[2],i[3])}}getValue(t,e,s){return void 0!==t[e]?t[e]:s}static blendModeFromString(t){if("normal"==(t=t.toLowerCase()))return fe.Normal;if("additive"==t)return fe.Additive;if("multiply"==t)return fe.Multiply;if("screen"==t)return fe.Screen;throw new Error(`Unknown blend mode: ${t}`)}static positionModeFromString(t){if("fixed"==(t=t.toLowerCase()))return se.Fixed;if("percent"==t)return se.Percent;throw new Error(`Unknown position mode: ${t}`)}static spacingModeFromString(t){if("length"==(t=t.toLowerCase()))return ie.Length;if("fixed"==t)return ie.Fixed;if("percent"==t)return ie.Percent;throw new Error(`Unknown position mode: ${t}`)}static rotateModeFromString(t){if("tangent"==(t=t.toLowerCase()))return ne.Tangent;if("chain"==t)return ne.Chain;if("chainscale"==t)return ne.ChainScale;throw new Error(`Unknown rotate mode: ${t}`)}static transformModeFromString(t){if("normal"==(t=t.toLowerCase()))return Dt.Normal;if("onlytranslation"==t)return Dt.OnlyTranslation;if("norotationorreflection"==t)return Dt.NoRotationOrReflection;if("noscale"==t)return Dt.NoScale;if("noscaleorreflection"==t)return Dt.NoScaleOrReflection;throw new Error(`Unknown transform mode: ${t}`)}}class Ee{constructor(t,e,s,i){E(this,"parent"),E(this,"skin"),E(this,"slotIndex"),E(this,"mesh"),this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i}}Math.fround||(Math.fround=(ge=new Float32Array(1),function(t){return ge[0]=t,ge[0]}));class Te{constructor(t){E(this,"clientId"),E(this,"toLoad",new Array),E(this,"assets",{}),E(this,"textureLoader"),this.clientId=t}loaded(){var t=0;for(var e in this.assets)t++;return t}}const Ae=class t{constructor(t){E(this,"centerX",0),E(this,"centerY",0),E(this,"radius",0),E(this,"angle",0),E(this,"worldX",0),E(this,"worldY",0),this.radius=t}begin(t){this.worldX=t.x+this.centerX,this.worldY=t.y+this.centerY}transform(e,s,i,n){let r=this.angle*I.degreesToRadians,a=e.x-this.worldX,o=e.y-this.worldY,l=Math.sqrt(a*a+o*o);if(l<this.radius){let s=t.interpolation.apply(0,r,(this.radius-l)/this.radius),i=Math.cos(s),n=Math.sin(s);e.x=i*a-n*o+this.worldX,e.y=n*a+i*o+this.worldY}}end(){}};E(Ae,"interpolation",new _(2));let Ce=Ae;const Se=class t extends Ot{constructor(t){super(t.resource),E(this,"texture"),this.texture=i.Texture.from(t)}static from(e){return t.textureMap.has(e)?t.textureMap.get(e):new t(e)}setFilters(e,s){if(!this.texture||!this.texture.source||!this.texture.source.style)return;const i=this.texture.source.style;i.minFilter=t.toPixiTextureFilter(e),i.magFilter=t.toPixiTextureFilter(s),this.texture.source.autoGenerateMipmaps=t.toPixiMipMap(e),this.texture.source.updateMipmaps()}setWraps(e,s){if(!this.texture||!this.texture.source||!this.texture.source.style)return;const i=this.texture.source.style;i.addressModeU=t.toPixiTextureWrap(e),i.addressModeV=t.toPixiTextureWrap(s)}dispose(){this.texture.destroy()}static toPixiMipMap(t){switch(t){case Ft.Nearest:case Ft.Linear:return!1;case Ft.MipMapNearestLinear:case Ft.MipMapNearestNearest:case Ft.MipMapLinearLinear:case Ft.MipMapLinearNearest:return!0;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureFilter(t){switch(t){case Ft.Nearest:case Ft.MipMapNearestLinear:case Ft.MipMapNearestNearest:return"nearest";case Ft.Linear:case Ft.MipMapLinearLinear:case Ft.MipMapLinearNearest:return"linear";default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureWrap(t){switch(t){case Xt.ClampToEdge:return"clamp-to-edge";case Xt.MirroredRepeat:return"mirror-repeat";case Xt.Repeat:return"repeat";default:throw new Error(`Unknown texture wrap: ${String(t)}`)}}static toPixiBlending(t){switch(t){case fe.Normal:return"normal";case fe.Additive:return"add";case fe.Multiply:return"multiply";case fe.Screen:return"screen";default:throw new Error(`Unknown blendMode: ${String(t)}`)}}};E(Se,"textureMap",new Map);let Me=Se;const ve={extension:i.ExtensionType.Asset,resolver:{test:t=>i.checkExtension(t,".atlas"),parse:t=>{var e,s,n;const r=t.split(".");return{resolution:parseFloat(null!=(n=null==(s=null==(e=i.Resolver.RETINA_PREFIX)?void 0:e.exec(t))?void 0:s[1])?n:"1"),format:r[r.length-2],src:t}}},loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineTextureAtlasLoader"},test:t=>i.checkExtension(t,".atlas"),load(t){return T(this,null,function*(){const e=yield i.DOMAdapter.get().fetch(t);return yield e.text()})},testParse(t,e){const s=i.checkExtension(e.src,".atlas"),n="string"==typeof t;return Promise.resolve(s&&n)},unload(t){t.dispose()},parse(t,e,s){return T(this,null,function*(){var n;const r=e.data||{};let a=i.path.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");const o=new Wt(t,t=>Me.from(e.data.imageTexture.source));if(r.images instanceof i.TextureSource||"string"==typeof r.images){const t=r.images;r.images={},r.images[o.pages[0].name]=t}const l=[];for(const t of o.pages){if(r.resolve){const e=null==(n=r.resolve())?void 0:n.then(e=>{e&&t.setTexture(Me.from(e.source))});l.push(e);continue}const o=t.name,h=(null==r?void 0:r.images)?r.images[o]:void 0;if(h instanceof i.TextureSource)t.setTexture(Me.from(h));else{const n=null!=h?h:i.path.normalize([...a.split(i.path.sep),o].join(i.path.sep)),d={src:i.copySearchParams(n,e.src),data:y(b({},r.imageMetadata),{alphaMode:t.pma?"premultiplied-alpha":"premultiply-alpha-on-upload"})},c=s.load(d).then(e=>{t.setTexture(Me.from(e.source))});l.push(c)}}return yield Promise.all(l),o})}}};i.extensions.add(ve);const Re={extension:i.ExtensionType.Asset,loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineSkeletonLoader"},test:t=>i.checkExtension(t,".skel"),load(t){return T(this,null,function*(){const e=yield i.DOMAdapter.get().fetch(t);return new Uint8Array(yield e.arrayBuffer())})},testParse(t,e){const s=i.checkExtension(e.src,".json")&&(n=t,Object.prototype.hasOwnProperty.call(n,"bones"));var n;const r=i.checkExtension(e.src,".skel")&&function(t){return t instanceof Uint8Array}(t);return Promise.resolve(s||r)}}};i.extensions.add(Re);const Pe=new Float32Array(1),Ie=new Uint32Array(1);class ke extends i.Geometry{constructor(){const t=new i.Buffer({data:Pe,label:"attribute-batch-buffer",usage:i.BufferUsage.VERTEX|i.BufferUsage.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:28,offset:0},aUV:{buffer:t,format:"float32x2",stride:28,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:28,offset:16},aDarkColor:{buffer:t,format:"unorm8x4",stride:28,offset:20},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:28,offset:24}},indexBuffer:new i.Buffer({data:Ie,label:"index-batch-buffer",usage:i.BufferUsage.INDEX|i.BufferUsage.COPY_DST,shrinkToFit:!1})})}}const Ve={name:"color-bit",vertex:{header:"\n @in aDarkColor: vec4<f32>;\n @out vDarkColor: vec4<f32>;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n @in vDarkColor: vec4<f32>;\n ",end:"\n\n let alpha = outColor.a * vColor.a;\n let rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n\n finalColor = vec4<f32>(rgb, alpha);\n\n "}},_e={name:"color-bit",vertex:{header:"\n in vec4 aDarkColor;\n out vec4 vDarkColor;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n in vec4 vDarkColor;\n ",end:"\n\n finalColor.a = outColor.a * vColor.a;\n finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n "}};class De extends i.Shader{constructor(t){super({glProgram:i.compileHighShaderGlProgram({name:"dark-tint-batch",bits:[i.colorBitGl,_e,i.generateTextureBatchBitGl(t),i.roundPixelsBitGl]}),gpuProgram:i.compileHighShaderGpuProgram({name:"dark-tint-batch",bits:[i.colorBit,Ve,i.generateTextureBatchBit(t),i.roundPixelsBit]}),resources:{batchSamplers:i.getBatchSamplersUniformGroup(t)}})}}let Ne=null;const Oe=class t extends i.Batcher{constructor(){super(...arguments),E(this,"geometry",new ke),E(this,"shader",Ne||(Ne=new De(this.maxTextures))),E(this,"name",t.extension.name),E(this,"vertexSize",7)}packAttributes(t,e,s,n,r){const a=r<<16|65535&t.roundPixels,o=t.transform,l=o.a,h=o.b,d=o.c,c=o.d,u=o.tx,p=o.ty,{positions:m,uvs:g}=t,f=t.color,x=(f>>24&255)/255,w=i.Color.shared.setValue(t.darkColor).premultiply(x,!0).toPremultiplied(1,!1),b=t.attributeOffset,y=b+t.attributeSize;for(let t=b;t<y;t++){const i=2*t,r=m[i],o=m[i+1];e[n++]=l*r+d*o+u,e[n++]=c*o+h*r+p,e[n++]=g[i],e[n++]=g[i+1],s[n++]=f,s[n++]=w,s[n++]=a}}packQuadAttributes(t,e,s,i,n){const r=t.texture,a=t.transform,o=a.a,l=a.b,h=a.c,d=a.d,c=a.tx,u=a.ty,p=t.bounds,m=p.maxX,g=p.minX,f=p.maxY,x=p.minY,w=r.uvs,b=t.color,y=t.darkColor,E=n<<16|65535&t.roundPixels;e[i+0]=o*g+h*x+c,e[i+1]=d*x+l*g+u,e[i+2]=w.x0,e[i+3]=w.y0,s[i+4]=b,s[i+5]=y,s[i+6]=E,e[i+7]=o*m+h*x+c,e[i+8]=d*x+l*m+u,e[i+9]=w.x1,e[i+10]=w.y1,s[i+11]=b,s[i+12]=y,s[i+13]=E,e[i+14]=o*m+h*f+c,e[i+15]=d*f+l*m+u,e[i+16]=w.x2,e[i+17]=w.y2,s[i+18]=b,s[i+19]=y,s[i+20]=E,e[i+21]=o*g+h*f+c,e[i+22]=d*f+l*g+u,e[i+23]=w.x3,e[i+24]=w.y3,s[i+25]=b,s[i+26]=y,s[i+27]=E}};E(Oe,"extension",{type:[i.ExtensionType.Batcher],name:"darkTint"});let Le=Oe;i.extensions.add(Le);const Ye=class t{constructor(t){E(this,"ctx"),E(this,"clipper",new ue),E(this,"triangleRendering",!1),E(this,"debugRendering",!1),E(this,"vertices",N.newFloatArray(8192)),E(this,"tempColor",new R),this.ctx=t}draw(t){this.triangleRendering?this.drawTriangles(t):this.drawImages(t)}drawImages(t){let e=this.ctx,s=t.drawOrder;this.debugRendering&&(e.strokeStyle="green"),e.save();for(let t=0,i=s.length;t<i;t++){let i=s[t],n=i.getAttachment(),r=null,a=null,o=null;if(!(n instanceof It))continue;r=n,a=r.region,o=a.texture.getImage();let l=i.bone.skeleton.color,h=i.color,d=r.color,c=l.a*h.a*d.a,u=this.tempColor;u.set(l.r*h.r*d.r,l.g*h.g*d.g,l.b*h.b*d.b,c);let p=n,m=i.bone,g=a.width,f=a.height;e.save(),e.transform(m.a,m.c,m.b,m.d,m.worldX,m.worldY),e.translate(n.offset[0],n.offset[1]),e.rotate(n.rotation*Math.PI/180);let x=p.width/g;if(e.scale(x*n.scaleX,x*n.scaleY),e.translate(g/2,f/2),n.region.rotate){let t=g;g=f,f=t,e.rotate(-Math.PI/2)}e.scale(1,-1),e.translate(-g/2,-f/2),e.globalAlpha=u.a,e.drawImage(o,a.x,a.y,g,f,0,0,g,f),this.debugRendering&&e.strokeRect(0,0,g,f),e.restore()}e.restore()}drawTriangles(e){let s=this.vertices,i=null,n=e.drawOrder,r=this.clipper;for(let e=0,o=n.length;e<o;e++){let o=n[e],l=o.getAttachment(),h=null,d=null;if(l instanceof St)r.clipStart(o,l);else{if(l instanceof It){let e=l;s=this.computeRegionVertices(o,e,!1),i=t.QUAD_TRIANGLES,d=e.region,h=d.texture.getImage()}else{if(!(l instanceof Mt)){r.clipEndWithSlot(o);continue}{let t=l;s=this.computeMeshVertices(o,t,!1),i=t.triangles,h=t.region.renderObject.texture.getImage()}}if(null!=h){o.data.blendMode;let t=o.bone.skeleton.color,e=o.color,n=l.color,d=t.a*e.a*n.a,c=this.tempColor;c.set(t.r*e.r*n.r,t.g*e.g*n.g,t.b*e.b*n.b,d);let u=this.ctx;if(u.globalAlpha=c.a,r.isClipping()){let t=s.length/8,e=new Float32Array(2*t),n=new Float32Array(2*t);for(let i=0;i<t;i++)e[2*i]=s[8*i],e[2*i+1]=s[8*i+1],n[2*i]=s[8*i+6],n[2*i+1]=s[8*i+7];r.clipTrianglesUnpacked(e,i,i.length,n);let o=r.clippedVertices,l=r.clippedUVs,d=r.clippedTriangles;for(var a=0;a<d.length;a+=3){let t=2*d[a],e=2*d[a+1],s=2*d[a+2],i=o[t],n=o[t+1],r=l[t],c=l[t+1],p=o[e],m=o[e+1],g=l[e],f=l[e+1],x=o[s],w=o[s+1],b=l[s],y=l[s+1];this.drawTriangle(h,i,n,r,c,p,m,g,f,x,w,b,y),this.debugRendering&&(u.strokeStyle="green",u.beginPath(),u.moveTo(i,n),u.lineTo(p,m),u.lineTo(x,w),u.lineTo(i,n),u.stroke())}}else for(a=0;a<i.length;a+=3){let t=8*i[a],e=8*i[a+1],n=8*i[a+2],r=s[t],o=s[t+1],l=s[t+6],d=s[t+7],c=s[e],p=s[e+1],m=s[e+6],g=s[e+7],f=s[n],x=s[n+1],w=s[n+6],b=s[n+7];this.drawTriangle(h,r,o,l,d,c,p,m,g,f,x,w,b),this.debugRendering&&(u.strokeStyle="green",u.beginPath(),u.moveTo(r,o),u.lineTo(c,p),u.lineTo(f,x),u.lineTo(r,o),u.stroke())}}r.clipEndWithSlot(o)}}r.clipEnd(),this.ctx.globalAlpha=1}drawTriangle(t,e,s,i,n,r,a,o,l,h,d,c,u){let p=this.ctx;i*=t.width,n*=t.height,o*=t.width,l*=t.height,c*=t.width,u*=t.height,p.beginPath(),p.moveTo(e,s),p.lineTo(r,a),p.lineTo(h,d),p.closePath();var m=1/((o-=i)*(u-=n)-(c-=i)*(l-=n)),g=(u*(r-=e)-l*(h-=e))*m,f=(u*(a-=s)-l*(d-=s))*m,x=(o*h-c*r)*m,w=(o*d-c*a)*m,b=e-g*i-x*n,y=s-f*i-w*n;p.save(),p.transform(g,f,x,w,b,y),p.clip(),p.drawImage(t,0,0),p.restore()}computeRegionVertices(e,s,i){let n=e.bone.skeleton.color,r=e.color,a=s.color,o=n.a*r.a*a.a,l=i?o:1,h=this.tempColor;h.set(n.r*r.r*a.r*l,n.g*r.g*a.g*l,n.b*r.b*a.b*l,o),s.computeWorldVertices(e.bone,this.vertices,0,t.VERTEX_SIZE);let d=this.vertices,c=s.uvs;return d[It.C1R]=h.r,d[It.C1G]=h.g,d[It.C1B]=h.b,d[It.C1A]=h.a,d[It.U1]=c[0],d[It.V1]=c[1],d[It.C2R]=h.r,d[It.C2G]=h.g,d[It.C2B]=h.b,d[It.C2A]=h.a,d[It.U2]=c[2],d[It.V2]=c[3],d[It.C3R]=h.r,d[It.C3G]=h.g,d[It.C3B]=h.b,d[It.C3A]=h.a,d[It.U3]=c[4],d[It.V3]=c[5],d[It.C4R]=h.r,d[It.C4G]=h.g,d[It.C4B]=h.b,d[It.C4A]=h.a,d[It.U4]=c[6],d[It.V4]=c[7],d}computeMeshVertices(e,s,i){let n=e.bone.skeleton.color,r=e.color,a=s.color,o=n.a*r.a*a.a,l=i?o:1,h=this.tempColor;h.set(n.r*r.r*a.r*l,n.g*r.g*a.g*l,n.b*r.b*a.b*l,o);let d=s.worldVerticesLength/2;this.vertices.length<s.worldVerticesLength&&(this.vertices=N.newFloatArray(s.worldVerticesLength));let c=this.vertices;s.computeWorldVertices(e,0,s.worldVerticesLength,c,0,t.VERTEX_SIZE);let u=s.uvs;for(let t=0,e=d,s=0,i=2;t<e;t++)c[i++]=h.r,c[i++]=h.g,c[i++]=h.b,c[i++]=h.a,c[i++]=u[s++],c[i++]=u[s++],i+=2;return c}};E(Ye,"QUAD_TRIANGLES",[0,1,2,2,3,0]),E(Ye,"VERTEX_SIZE",8);let Fe=Ye;class Xe{constructor(){E(this,"indexOffset",0),E(this,"attributeOffset",0),E(this,"indexSize"),E(this,"attributeSize"),E(this,"batcherName","darkTint"),E(this,"topology","triangle-list"),E(this,"packAsQuad",!1),E(this,"renderable"),E(this,"positions"),E(this,"indices"),E(this,"uvs"),E(this,"roundPixels"),E(this,"data"),E(this,"blendMode"),E(this,"darkTint"),E(this,"texture"),E(this,"transform"),E(this,"_textureId"),E(this,"_attributeStart"),E(this,"_indexStart"),E(this,"_batcher"),E(this,"_batch")}get color(){const t=this.data.color,e=this.renderable.groupColor,s=this.renderable.groupAlpha;let i;const n=t.a*s*255;if(16777215!==e){const s=e>>16&255,r=e>>8&255,a=255&e,o=t.r*a,l=t.g*r;i=n<<24|t.b*s<<16|l<<8|o}else i=n<<24|255*t.b<<16|255*t.g<<8|255*t.r;return i}get darkColor(){const t=this.data.darkColor;return 255*t.b<<16|255*t.g<<8|255*t.r}get groupTransform(){return this.renderable.groupTransform}setData(t,e,s,i){if(this.renderable=t,this.transform=t.groupTransform,this.data=e,e.clipped){const t=e.clippedData;this.indexSize=t.indicesCount,this.attributeSize=t.vertexCount,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs}else this.indexSize=e.indices.length,this.attributeSize=e.vertices.length/2,this.positions=e.vertices,this.indices=e.indices,this.uvs=e.uvs;this.texture=e.texture,this.roundPixels=i,this.blendMode=s,this.batcherName=e.darkTint?"darkTint":"default"}}const Be={0:"normal",1:"add",2:"multiply",3:"screen"};class je{constructor(t){E(this,"renderer"),E(this,"canvasSkeletonRenderer"),E(this,"gpuSpineData",{}),E(this,"_destroyRenderableBound",this.destroyRenderable.bind(this)),this.renderer=t}validateRenderable(t){if(this.renderer.type===i.RendererType.CANVAS)return!0;if(t._validateAndTransformAttachments(),t.spineAttachmentsDirty)return!0;if(t.spineTexturesDirty){const e=t.skeleton.drawOrder,s=this.gpuSpineData[t.uid];for(let i=0,n=e.length;i<n;i++){const n=e[i],r=n.getAttachment();if(r instanceof It||r instanceof Mt){const e=t._getCachedData(n,r),i=s.slotBatches[e.id],a=e.texture;if(a!==(null==i?void 0:i.texture)&&!(null==i?void 0:i._batcher.checkAndUpdateTexture(i,a)))return!0}}}return!1}execute(t){if(this.renderer.type===i.RendererType.CANVAS){const e=this.renderer,s=(t.groupColorAlpha>>>24&255)/255,i=e.canvasContext,n=i.activeContext;n.save(),this.canvasSkeletonRenderer||(this.canvasSkeletonRenderer=new Fe(n),this.canvasSkeletonRenderer.triangleRendering=!0),i.setContextTransform(t.groupTransform,1===(e._roundPixels|t._roundPixels));const r=t.skeleton.color.a;t.skeleton.color.a*=s,this.canvasSkeletonRenderer.draw(t.skeleton),t.skeleton.color.a=r,n.restore()}}addRenderable(t,e){var s,n;if(this.renderer.type===i.RendererType.CANVAS)return this.renderer.renderPipes.batch.break(e),void e.add(t);const r=this._getSpineData(t),a=this.renderer.renderPipes.batch,o=t.skeleton.drawOrder,l=this.renderer._roundPixels|t._roundPixels;t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;for(let i=0,h=o.length;i<h;i++){const h=o[i],d=h.getAttachment(),c=Be[h.data.blendMode];let u=!1;if(d instanceof It||d instanceof Mt){const i=t._getCachedData(h,d),o=(s=r.slotBatches)[n=i.id]||(s[n]=new Xe);o.setData(t,i,c,l),u=i.skipRender,u||a.addToBatch(o,e)}const p=t._slotsObject[h.data.name];if(p){const t=p.container;u||(t.includeInBuild=!0,t.collectRenderables(e,this.renderer,null)),t.includeInBuild=!1}}}updateRenderable(t){var e;const s=this.gpuSpineData[t.uid];t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;const i=t.skeleton.drawOrder;for(let n=0,r=i.length;n<r;n++){const r=i[n],a=r.getAttachment();if(a instanceof It||a instanceof Mt){const i=t._getCachedData(r,a);if(!i.skipRender){const t=s.slotBatches[i.id];null==(e=null==t?void 0:t._batcher)||e.updateElement(t)}}}}destroyRenderable(t){this.gpuSpineData[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null,this.canvasSkeletonRenderer=null}_getSpineData(t){return this.gpuSpineData[t.uid]||this._initMeshData(t)}_initMeshData(t){return this.gpuSpineData[t.uid]={slotBatches:{}},t.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[t.uid]}}E(je,"extension",{type:[i.ExtensionType.WebGLPipes,i.ExtensionType.WebGPUPipes,i.ExtensionType.CanvasPipes],name:"spine"}),i.extensions.add(je);const We=new L,Ue=new ue,qe=new O(()=>new i.Graphics);class Ge extends i.ViewContainer{constructor(t){var e;t instanceof pe&&(t={skeletonData:t}),super({}),E(this,"batched",!0),E(this,"buildId",0),E(this,"renderPipeId","spine"),E(this,"_didSpineUpdate",!1),E(this,"beforeUpdateWorldTransforms",()=>{}),E(this,"afterUpdateWorldTransforms",()=>{}),E(this,"skeleton"),E(this,"state"),E(this,"skeletonBounds"),E(this,"darkTint",!1),E(this,"_debug"),E(this,"_slotsObject",Object.create(null)),E(this,"clippingSlotToPixiMasks",Object.create(null)),E(this,"spineAttachmentsDirty",!0),E(this,"spineTexturesDirty",!0),E(this,"_lastAttachments",[]),E(this,"_stateChanged",!0),E(this,"attachmentCacheData",[]),E(this,"_autoUpdate",!1),E(this,"hasNeverUpdated",!0),E(this,"currentClippingSlot");const s=t instanceof pe?t:t.skeletonData;this.skeleton=new he(s),this.skeleton.flipY=!0,this.state=new wt(new At(s)),this.autoUpdate=null==(e=null==t?void 0:t.autoUpdate)||e,this.darkTint=void 0===(null==t?void 0:t.darkTint)?this.skeleton.slots.some(t=>!!t.data.darkColor):null==t?void 0:t.darkTint;const i=this.skeleton.slots;for(let t=0;t<i.length;t++)this.attachmentCacheData[t]=Object.create(null)}getSlotFromRef(t){let e;if(e="number"==typeof t?this.skeleton.slots[t]:"string"==typeof t?this.skeleton.findSlot(t):t,!e)throw new Error(`No slot found with the given slot reference: ${t}`);return e}get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t&&!this._autoUpdate?i.Ticker.shared.add(this.internalUpdate,this):i.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=t}update(t){this.internalUpdate(0,t)}internalUpdate(t,e){this._updateAndApplyState(null!=e?e:i.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(t,e){const s=t;if("string"==typeof t&&(t=this.skeleton.findBone(t)),!t)throw Error(`Cant set bone position, bone ${String(s)} not found`);if(We.set(e.x,e.y),t.parent){const e=t.parent.worldToLocal(We);t.x=e.x,t.y=-e.y}else t.x=We.x,t.y=We.y}getBonePosition(t,e){const s=t;return"string"==typeof t&&(t=this.skeleton.findBone(t)),t?(e||(e={x:0,y:0}),e.x=t.worldX,e.y=t.worldY,e):(console.error(`Cant set bone position! Bone ${String(s)} not found`),e)}_updateAndApplyState(t){this.hasNeverUpdated=!1,this.state.update(t),this.skeleton.update(t);const{skeleton:e}=this;this.state.apply(e),this.beforeUpdateWorldTransforms(this),e.updateWorldTransform(),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this._boundsDirty=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const t=this.skeleton.drawOrder,e=this._lastAttachments;let s=0,i=!1;for(let n=0;n<t.length;n++){const r=t[n].getAttachment();r&&(r!==e[s]&&(i=!0,e[s]=r),s++)}s!==e.length&&(i=!0,e.length=s),this.spineAttachmentsDirty=i}updateAndSetPixiMask(t,e){var s,i;const n=t.attachment;if(n&&n instanceof St){return((s=this.clippingSlotToPixiMasks)[i=t.data.name]||(s[i]={slot:t,vertices:new Array})).maskComputed=!1,void(this.currentClippingSlot=this.clippingSlotToPixiMasks[t.data.name])}let r=this.currentClippingSlot,a=this._slotsObject[t.data.name];if(r&&a){let t=r.slot,e=t.attachment,s=r.mask;if(s||(s=qe.obtain(),r.mask=s,this.addChild(s)),!r.maskComputed){r.maskComputed=!0;const i=e.worldVerticesLength,n=r.vertices;e.computeWorldVertices(t,0,i,n,0,2),s.clear().poly(n).stroke({width:0}).fill({alpha:.25})}a.container.mask=s}else(null==a?void 0:a.container.mask)&&(a.container.mask=null);if(r&&r.slot.attachment.endSlot==t.data&&(this.currentClippingSlot=void 0),e)for(const t in this.clippingSlotToPixiMasks){const e=this.clippingSlotToPixiMasks[t];e.slot.attachment instanceof St&&e.maskComputed||!e.mask||(this.removeChild(e.mask),qe.free(e.mask),e.mask=void 0)}}transformAttachments(){var t;const e=this.skeleton.drawOrder;for(let s=0;s<e.length;s++){const n=e[s];this.updateAndSetPixiMask(n,s===e.length-1);const r=n.getAttachment();if(r)if(r instanceof Mt||r instanceof It){const e=this._getCachedData(n,r);r instanceof It?r.computeWorldVertices(n.bone,e.vertices,0,2):r.computeWorldVertices(n,0,r.worldVerticesLength,e.vertices,0,2),e.uvs.length<r.uvs.length&&(e.uvs=new Float32Array(r.uvs.length)),i.fastCopy(r.uvs.buffer,e.uvs.buffer);const s=n.bone.skeleton.color,a=n.color,o=r.color;e.color.set(s.r*a.r*o.r,s.g*a.g*o.g,s.b*a.b*o.b,s.a*a.a*o.a),n.darkColor&&e.darkColor.setFromColor(n.darkColor),e.skipRender=e.clipped=!1;const l=(null==(t=r.region)?void 0:t.texture.texture)||i.Texture.EMPTY;e.texture!==l&&(e.texture=l,this.spineTexturesDirty=!0),Ue.isClipping()&&this.updateClippingData(e)}else if(r instanceof St){Ue.clipStart(n,r);continue}Ue.clipEndWithSlot(n)}Ue.clipEnd()}updateClippingData(t){t.clipped=!0,Ue.clipTrianglesUnpacked(t.vertices,t.indices,t.indices.length,t.uvs);const{clippedVertices:e,clippedUVs:s,clippedTriangles:i}=Ue,n=e.length/2,r=i.length;t.clippedData||(t.clippedData={vertices:new Float32Array(2*n),uvs:new Float32Array(2*n),vertexCount:n,indices:new Uint16Array(r),indicesCount:r},this.spineAttachmentsDirty=!0);const a=t.clippedData,o=a.vertexCount!==n||r!==a.indicesCount;t.skipRender=0===n,o&&(this.spineAttachmentsDirty=!0,a.vertexCount<n&&(a.vertices=new Float32Array(2*n),a.uvs=new Float32Array(2*n)),a.indices.length<r&&(a.indices=new Uint16Array(r)));const{vertices:l,uvs:h,indices:d}=a;for(let t=0;t<n;t++)l[2*t]=e[2*t],l[2*t+1]=e[2*t+1],h[2*t]=s[2*t],h[2*t+1]=s[2*t+1];a.vertexCount=n;for(let t=0;t<r;t++)d[t]!==i[t]&&(this.spineAttachmentsDirty=!0,d[t]=i[t]);a.indicesCount=r}updateSlotObjects(){for(const t in this._slotsObject){const e=this._slotsObject[t];e&&this.updateSlotObject(e)}}updateSlotObject(t){const{slot:e,container:s}=t;if(s.visible=this.skeleton.drawOrder.includes(e),s.visible){const t=e.bone;s.position.set(t.worldX,t.worldY),s.scale.x=t.getWorldScaleX(),s.scale.y=t.getWorldScaleY(),s.rotation=t.getWorldRotationX()*i.DEG_TO_RAD,s.alpha=this.skeleton.color.a*e.color.a}}_getCachedData(t,e){return this.attachmentCacheData[t.data.index][e.name]||this.initCachedData(t,e)}initCachedData(t,e){var s,i;let n;return e instanceof It?(n=new Float32Array(8),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(e.uvs.length),color:new R(1,1,1,1),darkColor:new R(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(s=e.region)?void 0:s.texture.texture}):(n=new Float32Array(e.worldVerticesLength),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:e.triangles,uvs:new Float32Array(e.uvs.length),color:new R(1,1,1,1),darkColor:new R(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(i=e.region)?void 0:i.texture.texture}),this.attachmentCacheData[t.data.index][e.name]}onViewUpdate(){var t;if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this),null==(t=this.debug)||t.renderDebug(this)}addSlotObject(t,e){var s;t=this.getSlotFromRef(t);for(const t in this._slotsObject)(null==(s=this._slotsObject[t])?void 0:s.container)===e&&this.removeSlotObject(this._slotsObject[t].slot);this.removeSlotObject(t),e.includeInBuild=!1,this.addChild(e);const i={container:e,slot:t};this._slotsObject[t.data.name]=i,this.updateSlotObject(i)}removeSlotObject(t){var e,s;let n;if(t instanceof i.Container){for(const s in this._slotsObject)if((null==(e=this._slotsObject[s])?void 0:e.container)===t){this._slotsObject[s]=null,n=t;break}}else{const e=this.getSlotFromRef(t);n=null==(s=this._slotsObject[e.data.name])?void 0:s.container,this._slotsObject[e.data.name]=null}n&&(this.removeChild(n),n.includeInBuild=!0)}getSlotObject(t){var e;return t=this.getSlotFromRef(t),null==(e=this._slotsObject[t.data.name])?void 0:e.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||(this.skeletonBounds=new de);const t=this.skeletonBounds;if(t.update(this.skeleton,!0),t.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const t=this.skeleton.drawOrder,e=this._bounds;e.clear();for(let s=0;s<t.length;s++){const i=t[s],n=i.getAttachment();if(n&&(n instanceof It||n instanceof Mt)){const t=this._getCachedData(i,n);e.addVertexData(t.vertices,0,t.vertices.length)}}}else this._bounds.minX=t.minX,this._bounds.minY=t.minY,this._bounds.maxX=t.maxX,this._bounds.maxY=t.maxY}addBounds(t){t.addBounds(this.bounds)}destroy(t=!1){super.destroy(t),i.Ticker.shared.remove(this.internalUpdate,this),this.state.clearListeners(),this.debug=void 0,this.skeleton=null,this.state=null,this._slotsObject=null,this._lastAttachments.length=0,this.attachmentCacheData=null}skeletonToPixiWorldCoordinates(t){this.worldTransform.apply(t,t)}pixiWorldCoordinatesToSkeleton(t){this.worldTransform.applyInverse(t,t)}pixiWorldCoordinatesToBone(t,e){this.pixiWorldCoordinatesToSkeleton(t),e.parent?e.parent.worldToLocal(t):e.worldToLocal(t)}static from({skeleton:t,atlas:e,scale:s=1,darkTint:n,autoUpdate:r=!0}){const a=`${t}-${e}-${s}`;if(i.Cache.has(a))return new Ge(i.Cache.get(a));const o=i.Assets.get(t),l=i.Assets.get(e),h=new kt(l),d=new ye(h).readSkeletonData(o);return i.Cache.set(a,d),new Ge({skeletonData:d,darkTint:n,autoUpdate:r})}}var $e=Object.freeze({__proto__:null,Animation:Y,AnimationState:wt,AnimationStateAdapter2:class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},AnimationStateData:At,AssetManager:$t,AtlasAttachmentLoader:kt,Attachment:A,AttachmentTimeline:it,BlendMode:fe,Bone:Nt,BoneData:Vt,BoundingBoxAttachment:Ct,ClippingAttachment:St,Color:R,ColorTimeline:tt,CurveTimeline:G,DebugUtils:class{static logBones(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e];console.log(s.data.name+", "+s.a+", "+s.b+", "+s.c+", "+s.d+", "+s.worldX+", "+s.worldY)}}},DeformTimeline:rt,DrawOrderTimeline:ot,Event:zt,EventData:Ht,EventQueue:yt,EventTimeline:at,EventType:Tt,FakeTexture:jt,IkConstraint:Zt,IkConstraintData:Qt,IkConstraintTimeline:ht,IntSet:M,Interpolation:k,JitterEffect:class{constructor(t,e){E(this,"jitterX",0),E(this,"jitterY",0),this.jitterX=t,this.jitterY=e}begin(t){}transform(t,e,s,i){t.x+=I.randomTriangular(-this.jitterX,this.jitterY),t.y+=I.randomTriangular(-this.jitterX,this.jitterY)}end(){}},MathUtils:I,MeshAttachment:Mt,MixDirection:W,MixPose:j,PathAttachment:vt,PathConstraint:ae,PathConstraintData:Jt,PathConstraintMixTimeline:ft,PathConstraintPositionTimeline:pt,PathConstraintSpacingTimeline:mt,PointAttachment:Rt,Pool:O,PositionMode:se,Pow:V,PowOut:_,RegionAttachment:It,RotateMode:ne,RotateTimeline:z,ScaleTimeline:Q,SharedAssetManager:class{constructor(t=""){E(this,"pathPrefix"),E(this,"clientAssets",{}),E(this,"queuedAssets",{}),E(this,"rawAssets",{}),E(this,"errors",{}),this.pathPrefix=t}queueAsset(t,e,s){var i=this.clientAssets[t];return null==i&&(i=new Te(t),this.clientAssets[t]=i),null!==e&&(i.textureLoader=e),i.toLoad.push(s),this.queuedAssets[s]!==s&&(this.queuedAssets[s]=s,!0)}loadText(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=s.responseText:this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadJson(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=JSON.parse(s.responseText):this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadTexture(t,e,s){if(s=this.pathPrefix+s,!this.queueAsset(t,e,s))return;let i=new Image;i.src=s,i.crossOrigin="anonymous",i.onload=t=>{this.rawAssets[s]=i},i.onerror=t=>{this.errors[s]=`Couldn't load image ${s}`}}get(t,e){e=this.pathPrefix+e;var s=this.clientAssets[t];return null==s||s.assets[e]}updateClientAssets(t){for(var e=0;e<t.toLoad.length;e++){var s=t.toLoad[e],i=t.assets[s];if(null==i){var n=this.rawAssets[s];if(null==n)continue;n instanceof HTMLImageElement?t.assets[s]=t.textureLoader(n):t.assets[s]=n}}}isLoadingComplete(t){var e=this.clientAssets[t];return null==e||(this.updateClientAssets(e),e.toLoad.length==e.loaded())}dispose(){}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},ShearTimeline:J,Skeleton:he,SkeletonBounds:de,SkeletonClipping:ue,SkeletonData:pe,SkeletonJson:ye,Skin:xe,Slot:oe,SlotData:we,SpacingMode:ie,Spine:Ge,SpineDebugRenderer:class{constructor(){E(this,"registeredSpines",new Map),E(this,"drawMeshHull",!0),E(this,"drawMeshTriangles",!0),E(this,"drawBones",!0),E(this,"drawPaths",!0),E(this,"drawBoundingBoxes",!0),E(this,"drawClipping",!0),E(this,"drawRegionAttachments",!0),E(this,"drawEvents",!0),E(this,"lineWidth",1),E(this,"regionAttachmentsColor",30975),E(this,"meshHullColor",30975),E(this,"meshTrianglesColor",16763904),E(this,"clippingPolygonColor",16711935),E(this,"boundingBoxesRectColor",65280),E(this,"boundingBoxesPolygonColor",65280),E(this,"boundingBoxesCircleColor",65280),E(this,"pathsCurveColor",16711680),E(this,"pathsLineColor",16711935),E(this,"skeletonXYColor",16711680),E(this,"bonesColor",61132),E(this,"eventFontSize",24),E(this,"eventFontColor",0)}registerSpine(t){if(this.registeredSpines.has(t))return void console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",t);const e={parentDebugContainer:new i.Container,bones:new i.Container,skeletonXY:new i.Graphics,regionAttachmentsShape:new i.Graphics,meshTrianglesLine:new i.Graphics,meshHullLine:new i.Graphics,clippingPolygon:new i.Graphics,boundingBoxesRect:new i.Graphics,boundingBoxesCircle:new i.Graphics,boundingBoxesPolygon:new i.Graphics,pathsCurve:new i.Graphics,pathsLine:new i.Graphics,eventText:new i.Container,eventCallback:{event:(s,n)=>{if(this.drawEvents){const s=Math.abs(t.scale.x||t.scale.y||1),r=new i.Text({text:n.data.name,style:{fontSize:this.eventFontSize/s,fill:this.eventFontColor,fontFamily:"monospace"}});r.scale.x=Math.sign(t.scale.x),r.anchor.set(.5),e.eventText.addChild(r),setTimeout(()=>{r.destroyed||r.destroy()},250)}}}};e.parentDebugContainer.addChild(e.bones),e.parentDebugContainer.addChild(e.skeletonXY),e.parentDebugContainer.addChild(e.regionAttachmentsShape),e.parentDebugContainer.addChild(e.meshTrianglesLine),e.parentDebugContainer.addChild(e.meshHullLine),e.parentDebugContainer.addChild(e.clippingPolygon),e.parentDebugContainer.addChild(e.boundingBoxesRect),e.parentDebugContainer.addChild(e.boundingBoxesCircle),e.parentDebugContainer.addChild(e.boundingBoxesPolygon),e.parentDebugContainer.addChild(e.pathsCurve),e.parentDebugContainer.addChild(e.pathsLine),e.parentDebugContainer.addChild(e.eventText),e.parentDebugContainer.zIndex=9999999,e.parentDebugContainer.accessibleChildren=!1,e.parentDebugContainer.eventMode="none",e.parentDebugContainer.interactiveChildren=!1,t.addChild(e.parentDebugContainer),t.state.addListener(e.eventCallback),this.registeredSpines.set(t,e)}renderDebug(t){this.registeredSpines.has(t)||this.registerSpine(t);const e=this.registeredSpines.get(t);if(!e)return;t.addChild(e.parentDebugContainer),e.skeletonXY.clear(),e.regionAttachmentsShape.clear(),e.meshTrianglesLine.clear(),e.meshHullLine.clear(),e.clippingPolygon.clear(),e.boundingBoxesRect.clear(),e.boundingBoxesCircle.clear(),e.boundingBoxesPolygon.clear(),e.pathsCurve.clear(),e.pathsLine.clear();for(let t=e.bones.children.length;t>0;t--)e.bones.children[t-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(t.scale.x||t.scale.y||1),i=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(t,e,i,s),this.drawPaths&&this.drawPathsFunc(t,e,i),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(t,e,i),this.drawClipping&&this.drawClippingFunc(t,e,i),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(t,e,i),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(t,e,i),this.drawEvents)for(const t of e.eventText.children)t.alpha-=.05,t.y-=2}drawBonesFunc(t,e,s,n){const r=t.skeleton,a=r.x,o=r.y,l=r.bones;e.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let t=0,r=l.length;t<r;t++){const r=l[t],h=r.data.length,d=a+r.worldX,c=o+r.worldY,u=a+h*r.a+r.worldX,p=o+h*r.b+r.worldY;if("root"===r.data.name||null===r.data.parent)continue;const m=Math.abs(d-u),g=Math.abs(c-p),f=Math.pow(m,2),x=g,w=Math.pow(g,2),b=Math.sqrt(f+w),y=Math.pow(b,2),E=Math.PI/180,T=Math.acos((y+w-f)/(2*x*b))||0;if(0===b)continue;const A=new i.Graphics;e.bones.addChild(A);const C=b/50/n;A.context.poly([0,0,0-C,b-3*C,0,b-C,0+C,b-3*C]).fill(this.bonesColor),A.x=d,A.y=c,A.pivot.y=b;let S=0;d<u&&c<p?S=180*E-T:d>u&&c<p?S=180*E+T:d>u&&c>p?S=-T:d<u&&c>p?S=T:c===p&&d<u?S=90*E:c===p&&d>u?S=-90*E:d===u&&c<p?S=180*E:d===u&&c>p&&(S=0),A.rotation=S,A.circle(0,b,1.2*C).fill({color:0,alpha:.6}).stroke({width:s+C/2.4,color:this.bonesColor})}const h=3*s;e.skeletonXY.context.moveTo(a-h,o-h).lineTo(a+h,o+h).moveTo(a+h,o-h).lineTo(a-h,o+h).stroke()}drawRegionAttachmentsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t],n=s.getAttachment();if(null===n||!(n instanceof It))continue;const r=n,a=new Float32Array(8);r.computeWorldVertices(s.bone,a,0,2),e.regionAttachmentsShape.poly(Array.from(a.slice(0,8)))}e.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof Mt))continue;const r=n,a=new Float32Array(r.worldVerticesLength),o=r.triangles;let l=r.hullLength;if(r.computeWorldVertices(s,0,r.worldVerticesLength,a,0,2),this.drawMeshTriangles)for(let t=0,s=o.length;t<s;t+=3){const s=2*o[t],i=2*o[t+1],n=2*o[t+2];e.meshTrianglesLine.context.moveTo(a[s],a[s+1]).lineTo(a[i],a[i+1]).lineTo(a[n],a[n+1])}if(this.drawMeshHull&&l>0){l=2*(l>>1);let t=a[l-2],s=a[l-1];for(let i=0,n=l;i<n;i+=2){const n=a[i],r=a[i+1];e.meshHullLine.context.moveTo(n,r).lineTo(t,s),t=n,s=r}}}e.meshHullLine.stroke({width:s,color:this.meshHullColor}),e.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof St))continue;const r=n,a=r.worldVerticesLength,o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2),e.clippingPolygon.poly(Array.from(o))}e.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(t,e,s){const i=new de;i.update(t.skeleton,!0),i.minX!==1/0&&e.boundingBoxesRect.rect(i.minX,i.minY,i.getWidth(),i.getHeight()).stroke({width:s,color:this.boundingBoxesRectColor});const n=i.polygons,r=(t,i,n)=>{if(n<3)throw new Error("Polygon must contain at least 3 vertices");const r=[],a=2*s;for(let s=0,i=t.length;s<i;s+=2){const i=t[s],n=t[s+1];e.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),e.boundingBoxesCircle.drawCircle(i,n,a),e.boundingBoxesCircle.fill(0),e.boundingBoxesCircle.circle(i,n,a).fill({color:this.boundingBoxesCircleColor}),r.push(i,n)}e.boundingBoxesPolygon.poly(r).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let t=0,e=n.length;t<e;t++){const e=n[t];r(e,0,e.length)}}drawPathsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof vt))continue;const r=n;let a=r.worldVerticesLength;const o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2);let l=o[2],h=o[3],d=0,c=0;if(r.closed){const t=o[0],s=o[1],i=o[a-2],n=o[a-1];d=o[a-4],c=o[a-3],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(t,s,i,n,d,c),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(t,s),e.pathsLine.moveTo(d,c),e.pathsLine.lineTo(i,n)}a-=4;for(let t=4;t<a;t+=6){const s=o[t],i=o[t+1],n=o[t+2],r=o[t+3];d=o[t+4],c=o[t+5],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(s,i,n,r,d,c),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(s,i),e.pathsLine.moveTo(d,c),e.pathsLine.lineTo(n,r),l=d,h=c}}e.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),e.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(t){this.registeredSpines.has(t)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",t);const e=this.registeredSpines.get(t);e&&(t.state.removeListener(e.eventCallback),e.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(t))}},SpinePipe:je,SpineTexture:Me,SwirlEffect:Ce,Texture:Ot,TextureAtlas:Wt,TextureAtlasPage:qt,TextureAtlasRegion:Gt,TextureFilter:Ft,TextureRegion:Bt,TextureWrap:Xt,TimeKeeper:class{constructor(){E(this,"maxDelta",.064),E(this,"framesPerSecond",0),E(this,"delta",0),E(this,"totalTime",0),E(this,"lastTime",Date.now()/1e3),E(this,"frameCount",0),E(this,"frameTime",0)}update(){var t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)}},TimelineType:U,TrackEntry:bt,TransformConstraint:le,TransformConstraintData:be,TransformConstraintTimeline:ct,TransformMode:Dt,TranslateTimeline:Z,Triangulator:ce,TwoColorTimeline:st,Utils:N,Vector2:L,VertexAttachment:S,WindowedMean:class{constructor(t=32){E(this,"values"),E(this,"addedValues",0),E(this,"lastValue",0),E(this,"mean",0),E(this,"dirty",!0),this.values=new Array(t)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let t=0;for(let e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0}}});return t.Spine=class extends o{},t.SpineSystem=class extends c{init(){super.init({pixiSpine:$e})}},t.pixiSpine=$e,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,PIXI);globalThis.EVA.plugin.renderer.spine36=globalThis.EVA.plugin.renderer.spine36||_EVA_IIFE_spine36;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_spine36=function(t,e,s,i){"use strict";"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const r="IDE_PROPERTY_METADATA";function a(t,e,s,i){let n=Reflect.getMetadata("design:type",t,e),a=n===Array;const o=function(t){return t===String?"string":t===Number?"number":t===Boolean?"boolean":"unknown"}(n);if("unknown"!==o&&(n=o),i){const t=i();Array.isArray(t)?(a=!0,n=t[0]):n=t}const l=Reflect.getMetadata(r,t.constructor)||{},h=_extends(_extends(_extends({},l[e]||{}),{type:n,isArray:a}),s);l[e]=h,Reflect.defineMetadata(r,l,t.constructor);!function(t,e,s){const i=t.constructor,n=i.IDEProps||{};n[e]=_extends(_extends({key:e},n[e]),s),i.IDEProps=n}(t,e,function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(s[i[n]]=t[i[n]])}return s}(h,["isArray"]))}function o(t){return e={type:t},(t,i)=>{if("symbol"==typeof i)throw new n;const{options:r,returnTypeFunc:o}=function(t,e){return"function"==typeof t?{returnTypeFunc:t,options:e||{}}:{options:t||{}}}(e,s);a(t,i,r,o)};var e,s}var l;function h(t,e,s,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(a=(r<3?n(a):r>3?n(e,s,a):n(e,s))||a);return r>3&&a&&Object.defineProperty(e,s,a),a}function d(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,s,i){return new(s||(s=Promise))(function(n,r){function a(t){try{l(i.next(t))}catch(t){r(t)}}function o(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(a,o)}l((i=i.apply(t,e||[])).next())})}!function(t){t[t.Edit=2]="Edit",t[t.Game=4]="Game",t[t.All=6]="All"}(l||(l={})),"function"==typeof SuppressedError&&SuppressedError;class u extends e.Component{constructor(t){super(t),this.resource="",this.scale=1,this.animationName="",this.autoPlay=!0,this.keepResource=!1,this.timeScale=1,this.skin="",this._slotGameObjects=new Map,this._pendingSlotObjects=[],this.waitExecuteInfos=[],this.listenerBound=!1,this.paused=!1,this.init(t)}set armature(t){if(this._armature=t,t){this.applyTimeScale(),this.skin&&this.setSkin(this.skin),this.autoPlay&&this.play(this.animationName);for(const t of this.waitExecuteInfos)if(t.playType){const{name:e,loop:s,track:i}=t;this.play(e,s,i)}else this.stop(t.track);this.waitExecuteInfos=[]}}get armature(){return this._armature}init(t){t&&_extends(this,t),this.listenerBound||(this.listenerBound=!0,this.on("start",t=>{var e;null===(e=this.onStart)||void 0===e||e.call(this,t)}),this.on("complete",t=>{var e;null===(e=this.onComplete)||void 0===e||e.call(this,t)}),this.on("event",(t,e)=>{var s;null===(s=this.onEvent)||void 0===s||s.call(this,t,e)}))}onDestroy(){this.destroied=!0}load(){return this.armature}destroy(){this.onDestroy(),this.armature&&!this.armature.destroyed&&(this._destroySlotGameObjects(),this.armature.destroy({children:!0})),this.armature=null}pause(){this.paused=!0,this.applyTimeScale()}resume(){this.paused=!1,this.applyTimeScale()}setSkin(t){var e,s,i,n,r;if(this.skin=t,null===(e=this.armature)||void 0===e?void 0:e.skeleton){if(this.armature.skeleton.setSkinByName)this.armature.skeleton.setSkinByName(t);else if(this.armature.skeleton.setSkin){const e=(null===(i=null===(s=this.armature.skeleton.data)||void 0===s?void 0:s.findSkin)||void 0===i?void 0:i.call(s,t))||t;this.armature.skeleton.setSkin(e)}null===(r=(n=this.armature.skeleton).setSlotsToSetupPose)||void 0===r||r.call(n)}}play(t,e,s){try{const i=null!=e?e:this.autoPlay;t&&(this.animationName=t),this.armature?(void 0===s&&(s=0),this.applyTimeScale(),this.armature.state.setAnimation(s,this.animationName,i)):this.waitExecuteInfos.push({playType:!0,name:t,loop:i,track:s})}catch(t){console.log(t)}}stop(t){this.armature?(void 0===t&&(t=0),this.armature.state.setEmptyAnimation(t,0)):this.waitExecuteInfos.push({playType:!1,track:t})}applyTimeScale(){var t;(null===(t=this.armature)||void 0===t?void 0:t.state)&&(this.armature.state.timeScale=this.paused?0:this.timeScale)}addAnimation(t,e,s,i){try{this.armature&&(void 0===i&&(i=0),this.armature.state.addAnimation(i,t,s,e))}catch(t){console.log(t)}}setMix(t,e,s){this.armature&&this.armature.state.data.setMix(t,e,s)}getAnim(t=0){try{if(this.armature)return this.armature.state.tracks[t].animation.name}catch(t){console.log(t)}}setDefaultMix(t){this.armature&&(this.armature.state.data.defaultMix=t)}setAttachment(t,e){this.armature&&this.armature.skeleton.setAttachment(t,e)}getBone(t){if(this.armature)return this.armature.skeleton.findBone(t)}addSlotObject(t,e,s){if(!this.armature)return void console.warn("Spine armature is not ready, cannot addSlotObject");if(!this._containerManager)return void console.warn("ContainerManager is not available");const i=this._containerManager.getContainer(e.id);i?this._doAddSlotObject(t,e,i,s):this._pendingSlotObjects.push({slot:t,gameObject:e,options:s})}_doAddSlotObject(t,e,s,n){const r=new i.Container;r.addChild(s),this.armature.addSlotObject(t,r,n),this._slotGameObjects.set(e,{slot:t,wrapper:r}),this._syncTransformTree(e)}_syncTransformTree(t){var e;if(this._containerManager&&(this._containerManager.updateTransform({name:t.id,transform:t.transform}),null===(e=t.transform)||void 0===e?void 0:e.children))for(const e of t.transform.children)e.gameObject&&this._syncTransformTree(e.gameObject)}_flushPendingSlotObjects(){if(0===this._pendingSlotObjects.length)return;if(!this.armature||!this._containerManager)return;const t=[];for(const e of this._pendingSlotObjects){const s=this._containerManager.getContainer(e.gameObject.id);s?this._doAddSlotObject(e.slot,e.gameObject,s,e.options):t.push(e)}this._pendingSlotObjects=t}removeSlotObject(t){this._pendingSlotObjects=this._pendingSlotObjects.filter(e=>e.gameObject!==t);const e=this._slotGameObjects.get(t);e&&this.armature&&(this.armature.removeSlotObject(e.wrapper),e.wrapper.destroy({children:!1})),this._slotGameObjects.delete(t)}_destroySlotGameObjects(){for(const[t,e]of this._slotGameObjects)t.destroyed||(this.armature&&this.armature.removeSlotObject(e.wrapper),e.wrapper.destroy({children:!1}),t.destroy());this._slotGameObjects.clear(),this._pendingSlotObjects=[]}}u.componentName="Spine",h([o("string"),d("design:type",String)],u.prototype,"resource",void 0),h([o("number"),d("design:type",Number)],u.prototype,"scale",void 0),h([o("string"),d("design:type",String)],u.prototype,"animationName",void 0),h([o("boolean"),d("design:type",Boolean)],u.prototype,"autoPlay",void 0),h([o("boolean"),d("design:type",Boolean)],u.prototype,"keepResource",void 0),h([o("number"),d("design:type",Number)],u.prototype,"timeScale",void 0),h([o("string"),d("design:type",String)],u.prototype,"skin",void 0);let p={};function m(t,e,s){return c(this,void 0,void 0,function*(){let i=p[t.name];if(!i)if(t.complete)i=function(t,e,s,i){const n=e.ske,r=e.atlas,a=new i.AtlasAttachmentLoader(r),o=n instanceof Uint8Array?new i.SkeletonBinary(a):new i.SkeletonJson(a);o.scale=s||1;const l={spineData:o.readSkeletonData(n),ref:0,imageSrc:(h=e.image,h?"string"==typeof h?h:h.label||(null===(d=h.source)||void 0===d?void 0:d.label)||(null===(u=null===(c=h.source)||void 0===c?void 0:c.resource)||void 0===u?void 0:u.src)||(null===(m=h.source)||void 0===m?void 0:m._sourceOrigin)||h.src||(null===(g=h.baseTexture)||void 0===g?void 0:g.cacheId)||"":"")};var h,d,c,u,m,g;return p[t]=l,l}(t.name,t.data,e,s);else if(!i)return;return i.ref++,i.spineData})}let g=class extends s.Renderer{constructor(){super(...arguments),this.armatures={},this._spineComponents={}}init({pixiSpine:t}){this.renderSystem=this.game.getSystem(s.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=t,this.game.canvas.addEventListener("webglcontextrestored",()=>{const t=this.game.gameObjects;let s=[];for(let i in this.armatures){const n=+i;for(let i=0;i<t.length;++i){let r=t[i];if(r.id===n){let t=r.getComponent(u);t&&(this.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:r,component:t,componentName:u.componentName}),s.push({type:e.OBSERVER_TYPE.ADD,gameObject:r,component:t,componentName:u.componentName}));break}}}setTimeout(()=>{s.forEach(t=>{this.add(t)})},1e3)},!1)}update(t){super.update();for(let e in this.armatures){const s=this.armatures[e],i=this._spineComponents[e];!s||s.destroyed||(null==i?void 0:i.destroied)?(delete this.armatures[e],delete this._spineComponents[e]):s.update(.001*t.deltaTime)}for(let t in this._spineComponents){const e=this._spineComponents[t];e&&!e.destroied?e._flushPendingSlotObjects():delete this._spineComponents[t]}}componentChanged(t){return c(this,void 0,void 0,function*(){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE){if("resource"===t.prop.prop[0])this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t)})}add(t,s){var i,n,r;return c(this,void 0,void 0,function*(){const a=t.component;clearTimeout(a.addHandler);const o=t.gameObject.id,l=this.increaseAsyncId(o),h=yield e.resource.getResource(a.resource);if(!this.validateAsyncId(o,l)||a.destroied||t.gameObject.destroyed)return;const d=yield m(h,a.scale,this.pixiSpine);if(!this.validateAsyncId(o,l)||a.destroied||t.gameObject.destroyed)return;if(!d)return void(a.addHandler=setTimeout(()=>{a.destroied||t.gameObject.destroyed||(void 0===s&&(s=20),--s>0?this.add(t,s):console.log("retry exceed max times",a.resource))},1e3));this.remove(t);const c=null===(n=null===(i=this.renderSystem)||void 0===i?void 0:i.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id);if(!c||a.destroied||t.gameObject.destroyed)return;a.lastResource=a.resource;const u=new this.pixiSpine.Spine({skeletonData:d,autoUpdate:!1});if(this.armatures[t.gameObject.id]=u,this._spineComponents[t.gameObject.id]=a,t.gameObject&&t.gameObject.transform){const e=t.gameObject.transform;u.x=e.size.width*e.origin.x,u.y=e.size.height*e.origin.y}c.addChildAt(u,0),u.update(),a._containerManager=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager,a.armature=u,a.emit("loaded",{resource:a.resource}),u.state.addListener({start:(t,e)=>{a.emit("start",{track:t,name:t.animation.name})},complete:(t,e)=>{a.emit("complete",{track:t,name:t.animation.name})},interrupt:(t,e)=>{a.emit("interrupt",{track:t,name:t.animation.name})},end:(t,e)=>{a.emit("end",{track:t,name:t.animation.name})},event:(t,e)=>{a.emit("event",t,e)}})})}change(t){this.remove(t),this.add(t)}remove(t){var s,i,n,r,a,o;return c(this,void 0,void 0,function*(){const l=t.gameObject.id;this.increaseAsyncId(l);const h=t.component;clearTimeout(h.addHandler);const d=this.armatures[l],u=null===(i=null===(s=this.renderSystem)||void 0===s?void 0:s.containerManager)||void 0===i?void 0:i.getContainer(l);u&&d&&u.removeChild(d);const m=h.armature;if(h.armature=null,delete this.armatures[l],delete this._spineComponents[l],m&&(h._destroySlotGameObjects(),m.destroyed||m.destroy({children:!0}),!h.keepResource&&h.lastResource))try{const t=yield e.resource.getResource(h.lastResource);(null===(r=null===(n=t.data)||void 0===n?void 0:n.image)||void 0===r?void 0:r.src)||(null===(o=null===(a=t.data)||void 0===a?void 0:a.image)||void 0===o||o.label);!function(t){const s=t.name,i=p[s];i&&(i.ref--,setTimeout(()=>c(this,void 0,void 0,function*(){i.ref<=0&&(e.resource.destroy(s),delete p[s])}),100))}(t)}catch(t){console.warn("Failed to release Spine resource",h.lastResource,t)}t.type,e.OBSERVER_TYPE.CHANGE})}};g.systemName="SpineSystem",g=h([e.decorators.componentObserver({Spine:["resource"]})],g);var f=g;e.resource.registerResourceType("SPINE");var x=Object.defineProperty,w=Object.defineProperties,b=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,E=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,A=(t,e,s)=>e in t?x(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,S=(t,e)=>{for(var s in e||(e={}))E.call(e,s)&&A(t,s,e[s]);if(y)for(var s of y(e))T.call(e,s)&&A(t,s,e[s]);return t},C=(t,e)=>w(t,b(e)),v=(t,e,s)=>A(t,"symbol"!=typeof e?e+"":e,s),M=(t,e,s)=>new Promise((i,n)=>{var r=t=>{try{o(s.next(t))}catch(t){n(t)}},a=t=>{try{o(s.throw(t))}catch(t){n(t)}},o=t=>t.done?i(t.value):Promise.resolve(t.value).then(r,a);o((s=s.apply(t,e)).next())});if("undefined"!=typeof window&&window.PIXI){const t=window.require;window.require=e=>t?t(e):e.startsWith("@pixi/")||e.startsWith("pixi.js")?window.PIXI:void 0}class R{constructor(t){if(v(this,"name"),null==t)throw new Error("name cannot be null.");this.name=t}}const k=class t extends R{constructor(e){super(e),v(this,"id",(65535&t.nextID++)<<11),v(this,"bones"),v(this,"vertices"),v(this,"worldVerticesLength",0)}computeWorldVertices(t,e,s,i,n,r){s=n+(s>>1)*r;let a=t.bone.skeleton,o=t.attachmentVertices,l=this.vertices,h=this.bones;if(null==h){o.length>0&&(l=o);let a=t.bone,h=a.worldX,d=a.worldY,c=a.a,u=a.b,p=a.c,m=a.d;for(let t=e,a=n;a<s;t+=2,a+=r){let e=l[t],s=l[t+1];i[a]=e*c+s*u+h,i[a+1]=e*p+s*m+d}return}let d=0,c=0;for(let t=0;t<e;t+=2){let t=h[d];d+=t+1,c+=t}let u=a.bones;if(0==o.length)for(let t=n,e=3*c;t<s;t+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,e+=3){let t=u[h[d]],i=l[e],r=l[e+1],a=l[e+2];s+=(i*t.a+r*t.b+t.worldX)*a,n+=(i*t.c+r*t.d+t.worldY)*a}i[t]=s,i[t+1]=n}else{let t=o;for(let e=n,a=3*c,o=c<<1;e<s;e+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,a+=3,o+=2){let e=u[h[d]],i=l[a]+t[o],r=l[a+1]+t[o+1],c=l[a+2];s+=(i*e.a+r*e.b+e.worldX)*c,n+=(i*e.c+r*e.d+e.worldY)*c}i[e]=s,i[e+1]=n}}}applyDeform(t){return this==t}};v(k,"nextID",0);let P=k;class I{constructor(){v(this,"array",new Array)}add(t){let e=this.contains(t);return this.array[0|t]=0|t,!e}contains(t){return null!=this.array[0|t]}remove(t){this.array[0|t]=void 0}clear(){this.array.length=0}}const V=class{constructor(t=0,e=0,s=0,i=0){this.r=t,this.g=e,this.b=s,this.a=i}set(t,e,s,i){return this.r=t,this.g=e,this.b=s,this.a=i,this.clamp(),this}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=(8!=t.length?255:parseInt(t.substr(6,2),16))/255,this}add(t,e,s,i){return this.r+=t,this.g+=e,this.b+=s,this.a+=i,this.clamp(),this}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}};v(V,"WHITE",new V(1,1,1,1)),v(V,"RED",new V(1,0,0,1)),v(V,"GREEN",new V(0,1,0,1)),v(V,"BLUE",new V(0,0,1,1)),v(V,"MAGENTA",new V(1,0,1,1));let _=V;const D=class t{static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(e){return Math.cos(e*t.degRad)}static sinDeg(e){return Math.sin(e*t.degRad)}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(e,s){return t.randomTriangularWith(e,s,.5*(e+s))}static randomTriangularWith(t,e,s){let i=Math.random(),n=e-t;return i<=(s-t)/n?t+Math.sqrt(i*n*(s-t)):e-Math.sqrt((1-i)*n*(e-s))}};v(D,"PI",3.1415927),v(D,"PI2",2*D.PI),v(D,"radiansToDegrees",180/D.PI),v(D,"radDeg",D.radiansToDegrees),v(D,"degreesToRadians",D.PI/180),v(D,"degRad",D.degreesToRadians);let N=D;class O{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class L extends O{constructor(t){super(),v(this,"power",2),this.power=t}applyInternal(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow(2*(t-1),this.power)/(this.power%2==0?-2:2)+1}}class Y extends L{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}}const F=class t{static arrayCopy(t,e,s,i,n){for(let r=e,a=i;r<e+n;r++,a++)s[a]=t[r]}static setArraySize(t,e,s=0){let i=t.length;if(i==e)return t;if(t.length=e,i<e)for(let n=i;n<e;n++)t[n]=s;return t}static ensureArrayCapacity(e,s,i=0){return e.length>=s?e:t.setArraySize(e,s,i)}static newArray(t,e){let s=new Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static newShortArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static toFloatArray(e){return t.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e}static toSinglePrecision(e){return t.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e}static webkit602BugfixHelper(t,e){}};v(F,"SUPPORTS_TYPED_ARRAYS","undefined"!=typeof Float32Array);let X=F;class B{constructor(t){v(this,"items",new Array),v(this,"instantiator"),this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset&&t.reset(),this.items.push(t)}freeAll(t){for(let e=0;e<t.length;e++)t[e].reset&&t[e].reset(),this.items[e]=t[e]}clear(){this.items.length=0}}class j{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){let t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){let t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this}}class W{constructor(t,e,s){if(v(this,"name"),v(this,"timelines"),v(this,"duration"),null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.duration=s}apply(t,e,s,i,n,r,a,o){if(null==t)throw new Error("skeleton cannot be null.");i&&0!=this.duration&&(s%=this.duration,e>0&&(e%=this.duration));let l=this.timelines;for(let i=0,h=l.length;i<h;i++)l[i].apply(t,e,s,n,r,a,o)}static binarySearch(t,e,s=1){let i=0,n=t.length/s-2;if(0==n)return s;let r=n>>>1;for(;;){if(t[(r+1)*s]<=e?i=r+1:n=r,i==n)return(i+1)*s;r=i+n>>>1}}static linearSearch(t,e,s){for(let i=0,n=t.length-s;i<=n;i+=s)if(t[i]>e)return i;return-1}}var U,q,G,$=((U=$||{})[U.setup=0]="setup",U[U.current=1]="current",U[U.currentLayered=2]="currentLayered",U),z=((q=z||{})[q.in=0]="in",q[q.out=1]="out",q),H=((G=H||{})[G.rotate=0]="rotate",G[G.translate=1]="translate",G[G.scale=2]="scale",G[G.shear=3]="shear",G[G.attachment=4]="attachment",G[G.color=5]="color",G[G.deform=6]="deform",G[G.event=7]="event",G[G.drawOrder=8]="drawOrder",G[G.ikConstraint=9]="ikConstraint",G[G.transformConstraint=10]="transformConstraint",G[G.pathConstraintPosition=11]="pathConstraintPosition",G[G.pathConstraintSpacing=12]="pathConstraintSpacing",G[G.pathConstraintMix=13]="pathConstraintMix",G[G.twoColor=14]="twoColor",G);const Z=class t{constructor(e){if(v(this,"curves"),e<=0)throw new Error("frameCount must be > 0: "+e);this.curves=X.newFloatArray((e-1)*t.BEZIER_SIZE)}getFrameCount(){return this.curves.length/t.BEZIER_SIZE+1}setLinear(e){this.curves[e*t.BEZIER_SIZE]=t.LINEAR}setStepped(e){this.curves[e*t.BEZIER_SIZE]=t.STEPPED}getCurveType(e){let s=e*t.BEZIER_SIZE;if(s==this.curves.length)return t.LINEAR;let i=this.curves[s];return i==t.LINEAR?t.LINEAR:i==t.STEPPED?t.STEPPED:t.BEZIER}setCurve(e,s,i,n,r){let a=.03*(2*-s+n),o=.03*(2*-i+r),l=.006*(3*(s-n)+1),h=.006*(3*(i-r)+1),d=2*a+l,c=2*o+h,u=.3*s+a+.16666667*l,p=.3*i+o+.16666667*h,m=e*t.BEZIER_SIZE,g=this.curves;g[m++]=t.BEZIER;let f=u,x=p;for(let e=m+t.BEZIER_SIZE-1;m<e;m+=2)g[m]=f,g[m+1]=x,u+=d,p+=c,d+=l,c+=h,f+=u,x+=p}getCurvePercent(e,s){s=N.clamp(s,0,1);let i=this.curves,n=e*t.BEZIER_SIZE,r=i[n];if(r==t.LINEAR)return s;if(r==t.STEPPED)return 0;n++;let a=0;for(let e=n,r=n+t.BEZIER_SIZE-1;n<r;n+=2)if(a=i[n],a>=s){let t,r;return n==e?(t=0,r=0):(t=i[n-2],r=i[n-1]),r+(i[n+1]-r)*(s-t)/(a-t)}let o=i[n-1];return o+(1-o)*(s-a)/(1-a)}};v(Z,"LINEAR",0),v(Z,"STEPPED",1),v(Z,"BEZIER",2),v(Z,"BEZIER_SIZE",19);let Q=Z;const J=class t extends Q{constructor(t){super(t),v(this,"boneIndex"),v(this,"frames"),this.frames=X.newFloatArray(t<<1)}getPropertyId(){return 0+this.boneIndex}setFrame(e,s,i){e<<=1,this.frames[e]=s,this.frames[e+t.ROTATION]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return void(h.rotation=h.data.rotation);case 1:let t=h.data.rotation-h.rotation;t-=360*(16384-(16384.499999999996-t/360|0)),h.rotation+=t*r}return}if(i>=l[l.length-t.ENTRIES]){if(0==a)h.rotation=h.data.rotation+l[l.length+t.PREV_ROTATION]*r;else{let e=h.data.rotation+l[l.length+t.PREV_ROTATION]-h.rotation;e-=360*(16384-(16384.499999999996-e/360|0)),h.rotation+=e*r}return}let d=W.binarySearch(l,i,t.ENTRIES),c=l[d+t.PREV_ROTATION],u=l[d],p=this.getCurvePercent((d>>1)-1,1-(i-u)/(l[d+t.PREV_TIME]-u)),m=l[d+t.ROTATION]-c;m-=360*(16384-(16384.499999999996-m/360|0)),m=c+m*p,0==a?(m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation=h.data.rotation+m*r):(m=h.data.rotation+m-h.rotation,m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation+=m*r)}};v(J,"ENTRIES",2),v(J,"PREV_TIME",-2),v(J,"PREV_ROTATION",-1),v(J,"ROTATION",1);let K=J;const tt=class t extends Q{constructor(e){super(e),v(this,"boneIndex"),v(this,"frames"),this.frames=X.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(1<<24)+this.boneIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.X]=i,this.frames[e+t.Y]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return h.x=h.data.x,void(h.y=h.data.y);case 1:h.x+=(h.data.x-h.x)*r,h.y+=(h.data.y-h.y)*r}return}let d=0,c=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_X],c=l[l.length+t.PREV_Y];else{let e=W.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_X],c=l[e+t.PREV_Y];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.X]-d)*n,c+=(l[e+t.Y]-c)*n}0==a?(h.x=h.data.x+d*r,h.y=h.data.y+c*r):(h.x+=(h.data.x+d-h.x)*r,h.y+=(h.data.y+c-h.y)*r)}};v(tt,"ENTRIES",3),v(tt,"PREV_TIME",-3),v(tt,"PREV_X",-2),v(tt,"PREV_Y",-1),v(tt,"X",1),v(tt,"Y",2);let et=tt;class st extends et{constructor(t){super(t)}getPropertyId(){return(2<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.scaleX=l.data.scaleX,void(l.scaleY=l.data.scaleY);case 1:l.scaleX+=(l.data.scaleX-l.scaleX)*n,l.scaleY+=(l.data.scaleY-l.scaleY)*n}return}let h=0,d=0;if(s>=o[o.length-st.ENTRIES])h=o[o.length+st.PREV_X]*l.data.scaleX,d=o[o.length+st.PREV_Y]*l.data.scaleY;else{let t=W.binarySearch(o,s,st.ENTRIES);h=o[t+st.PREV_X],d=o[t+st.PREV_Y];let e=o[t],i=this.getCurvePercent(t/st.ENTRIES-1,1-(s-e)/(o[t+st.PREV_TIME]-e));h=(h+(o[t+st.X]-h)*i)*l.data.scaleX,d=(d+(o[t+st.Y]-d)*i)*l.data.scaleY}if(1==n)l.scaleX=h,l.scaleY=d;else{let t=0,e=0;0==r?(t=l.data.scaleX,e=l.data.scaleY):(t=l.scaleX,e=l.scaleY),1==a?(h=Math.abs(h)*N.signum(t),d=Math.abs(d)*N.signum(e)):(t=Math.abs(t)*N.signum(h),e=Math.abs(e)*N.signum(d)),l.scaleX=t+(h-t)*n,l.scaleY=e+(d-e)*n}}}class it extends et{constructor(t){super(t)}getPropertyId(){return(3<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.shearX=l.data.shearX,void(l.shearY=l.data.shearY);case 1:l.shearX+=(l.data.shearX-l.shearX)*n,l.shearY+=(l.data.shearY-l.shearY)*n}return}let h=0,d=0;if(s>=o[o.length-it.ENTRIES])h=o[o.length+it.PREV_X],d=o[o.length+it.PREV_Y];else{let t=W.binarySearch(o,s,it.ENTRIES);h=o[t+it.PREV_X],d=o[t+it.PREV_Y];let e=o[t],i=this.getCurvePercent(t/it.ENTRIES-1,1-(s-e)/(o[t+it.PREV_TIME]-e));h+=(o[t+it.X]-h)*i,d+=(o[t+it.Y]-d)*i}0==r?(l.shearX=l.data.shearX+h*n,l.shearY=l.data.shearY+d*n):(l.shearX+=(l.data.shearX+h-l.shearX)*n,l.shearY+=(l.data.shearY+d-l.shearY)*n)}}const nt=class t extends Q{constructor(e){super(e),v(this,"slotIndex"),v(this,"frames"),this.frames=X.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(5<<24)+this.slotIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return void l.color.setFromColor(l.data.color);case 1:let t=l.color,e=l.data.color;t.add((e.r-t.r)*r,(e.g-t.g)*r,(e.b-t.b)*r,(e.a-t.a)*r)}return}let d=0,c=0,u=0,p=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A]}else{let e=W.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,c+=(h[e+t.G]-c)*n,u+=(h[e+t.B]-u)*n,p+=(h[e+t.A]-p)*n}if(1==r)l.color.set(d,c,u,p);else{let t=l.color;0==a&&t.setFromColor(l.data.color),t.add((d-t.r)*r,(c-t.g)*r,(u-t.b)*r,(p-t.a)*r)}}};v(nt,"ENTRIES",5),v(nt,"PREV_TIME",-5),v(nt,"PREV_R",-4),v(nt,"PREV_G",-3),v(nt,"PREV_B",-2),v(nt,"PREV_A",-1),v(nt,"R",1),v(nt,"G",2),v(nt,"B",3),v(nt,"A",4);let rt=nt;const at=class t extends Q{constructor(e){super(e),v(this,"slotIndex"),v(this,"frames"),this.frames=X.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(14<<24)+this.slotIndex}setFrame(e,s,i,n,r,a,o,l,h){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a,this.frames[e+t.R2]=o,this.frames[e+t.G2]=l,this.frames[e+t.B2]=h}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return l.color.setFromColor(l.data.color),void l.darkColor.setFromColor(l.data.darkColor);case 1:let t=l.color,e=l.darkColor,s=l.data.color,i=l.data.darkColor;t.add((s.r-t.r)*r,(s.g-t.g)*r,(s.b-t.b)*r,(s.a-t.a)*r),e.add((i.r-e.r)*r,(i.g-e.g)*r,(i.b-e.b)*r,0)}return}let d=0,c=0,u=0,p=0,m=0,g=0,f=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2]}else{let e=W.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],c=h[e+t.PREV_G],u=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,c+=(h[e+t.G]-c)*n,u+=(h[e+t.B]-u)*n,p+=(h[e+t.A]-p)*n,m+=(h[e+t.R2]-m)*n,g+=(h[e+t.G2]-g)*n,f+=(h[e+t.B2]-f)*n}if(1==r)l.color.set(d,c,u,p),l.darkColor.set(m,g,f,1);else{let t=l.color,e=l.darkColor;0==a&&(t.setFromColor(l.data.color),e.setFromColor(l.data.darkColor)),t.add((d-t.r)*r,(c-t.g)*r,(u-t.b)*r,(p-t.a)*r),e.add((m-e.r)*r,(g-e.g)*r,(f-e.b)*r,0)}}};v(at,"ENTRIES",8),v(at,"PREV_TIME",-8),v(at,"PREV_R",-7),v(at,"PREV_G",-6),v(at,"PREV_B",-5),v(at,"PREV_A",-4),v(at,"PREV_R2",-3),v(at,"PREV_G2",-2),v(at,"PREV_B2",-1),v(at,"R",1),v(at,"G",2),v(at,"B",3),v(at,"A",4),v(at,"R2",5),v(at,"G2",6),v(at,"B2",7);let ot=at;class lt{constructor(t){v(this,"slotIndex"),v(this,"frames"),v(this,"attachmentNames"),this.frames=X.newFloatArray(t),this.attachmentNames=new Array(t)}getPropertyId(){return(4<<24)+this.slotIndex}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex];if(1==a&&0==r){let e=o.data.attachmentName;return void o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}let l=this.frames;if(s<l[0]){if(0==r){let e=o.data.attachmentName;o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}return}let h=0;h=s>=l[l.length-1]?l.length-1:W.binarySearch(l,s,1)-1;let d=this.attachmentNames[h];t.slots[this.slotIndex].setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}var ht=null;class dt extends Q{constructor(t){super(t),v(this,"slotIndex"),v(this,"attachment"),v(this,"frames"),v(this,"frameVertices"),this.frames=X.newFloatArray(t),this.frameVertices=new Array(t),null==ht&&(ht=X.newFloatArray(64))}getPropertyId(){return(6<<27)+ +this.attachment.id+this.slotIndex}setFrame(t,e,s){this.frames[t]=e,this.frameVertices[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex],l=o.getAttachment();if(!(l instanceof P&&l.applyDeform(this.attachment)))return;let h=o.attachmentVertices;0==h.length&&(n=1);let d=this.frameVertices,c=d[0].length,u=this.frames;if(s<u[0]){let t=l;switch(r){case 0:return void(h.length=0);case 1:if(1==n){h.length=0;break}let e=X.setArraySize(h,c);if(null==t.bones)for(var p=t.vertices,m=0;m<c;m++)e[m]+=(p[m]-e[m])*n;else{n=1-n;for(m=0;m<c;m++)e[m]*=n}}return}let g=X.setArraySize(h,c);if(s>=u[u.length-1]){let t=d[u.length-1];if(1==n)X.arrayCopy(t,0,g,0,c);else if(0==r){let e=l;if(null==e.bones){let s=e.vertices;for(let e=0;e<c;e++){let i=s[e];g[e]=i+(t[e]-i)*n}}else for(let e=0;e<c;e++)g[e]=t[e]*n}else for(let e=0;e<c;e++)g[e]+=(t[e]-g[e])*n;return}let f=W.binarySearch(u,s),x=d[f-1],w=d[f],b=u[f],y=this.getCurvePercent(f-1,1-(s-b)/(u[f-1]-b));if(1==n)for(let t=0;t<c;t++){let e=x[t];g[t]=e+(w[t]-e)*y}else if(0==r){let t=l;if(null==t.bones){let e=t.vertices;for(let t=0;t<c;t++){let s=x[t],i=e[t];g[t]=i+(s+(w[t]-s)*y-i)*n}}else for(let t=0;t<c;t++){let e=x[t];g[t]=(e+(w[t]-e)*y)*n}}else for(let t=0;t<c;t++){let e=x[t];g[t]+=(e+(w[t]-e)*y-g[t])*n}}}class ct{constructor(t){v(this,"frames"),v(this,"events"),this.frames=X.newFloatArray(t),this.events=new Array(t)}getPropertyId(){return 7<<24}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e.time,this.events[t]=e}apply(t,e,s,i,n,r,a){if(null==i)return;let o=this.frames,l=this.frames.length;if(e>s)this.apply(t,e,Number.MAX_VALUE,i,n,r,a),e=-1;else if(e>=o[l-1])return;if(s<o[0])return;let h=0;if(e<o[0])h=0;else{h=W.binarySearch(o,e);let t=o[h];for(;h>0&&o[h-1]==t;)h--}for(;h<l&&s>=o[h];h++)i.push(this.events[h])}}class ut{constructor(t){v(this,"frames"),v(this,"drawOrders"),this.frames=X.newFloatArray(t),this.drawOrders=new Array(t)}getPropertyId(){return 8<<24}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(t,e,s,i,n,r,a){let o=t.drawOrder,l=t.slots;if(1==a&&0==r)return void X.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length);let h=this.frames;if(s<h[0])return void(0==r&&X.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length));let d=0;d=s>=h[h.length-1]?h.length-1:W.binarySearch(h,s)-1;let c=this.drawOrders[d];if(null==c)X.arrayCopy(l,0,o,0,l.length);else for(let t=0,e=c.length;t<e;t++)o[t]=l[c[t]]}}const pt=class t extends Q{constructor(e){super(e),v(this,"ikConstraintIndex"),v(this,"frames"),this.frames=X.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(9<<24)+this.ikConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.MIX]=i,this.frames[e+t.BEND_DIRECTION]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.ikConstraints[this.ikConstraintIndex];if(i<l[0]){switch(a){case 0:return h.mix=h.data.mix,void(h.bendDirection=h.data.bendDirection);case 1:h.mix+=(h.data.mix-h.mix)*r,h.bendDirection=h.data.bendDirection}return}if(i>=l[l.length-t.ENTRIES])return void(0==a?(h.mix=h.data.mix+(l[l.length+t.PREV_MIX]-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[l.length+t.PREV_BEND_DIRECTION]):(h.mix+=(l[l.length+t.PREV_MIX]-h.mix)*r,0==o&&(h.bendDirection=l[l.length+t.PREV_BEND_DIRECTION])));let d=W.binarySearch(l,i,t.ENTRIES),c=l[d+t.PREV_MIX],u=l[d],p=this.getCurvePercent(d/t.ENTRIES-1,1-(i-u)/(l[d+t.PREV_TIME]-u));0==a?(h.mix=h.data.mix+(c+(l[d+t.MIX]-c)*p-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[d+t.PREV_BEND_DIRECTION]):(h.mix+=(c+(l[d+t.MIX]-c)*p-h.mix)*r,0==o&&(h.bendDirection=l[d+t.PREV_BEND_DIRECTION]))}};v(pt,"ENTRIES",3),v(pt,"PREV_TIME",-3),v(pt,"PREV_MIX",-2),v(pt,"PREV_BEND_DIRECTION",-1),v(pt,"MIX",1),v(pt,"BEND_DIRECTION",2);let mt=pt;const gt=class t extends Q{constructor(e){super(e),v(this,"transformConstraintIndex"),v(this,"frames"),this.frames=X.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(10<<24)+this.transformConstraintIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n,this.frames[e+t.SCALE]=r,this.frames[e+t.SHEAR]=a}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.transformConstraints[this.transformConstraintIndex];if(i<l[0]){let t=h.data;switch(a){case 0:return h.rotateMix=t.rotateMix,h.translateMix=t.translateMix,h.scaleMix=t.scaleMix,void(h.shearMix=t.shearMix);case 1:h.rotateMix+=(t.rotateMix-h.rotateMix)*r,h.translateMix+=(t.translateMix-h.translateMix)*r,h.scaleMix+=(t.scaleMix-h.scaleMix)*r,h.shearMix+=(t.shearMix-h.shearMix)*r}return}let d=0,c=0,u=0,p=0;if(i>=l[l.length-t.ENTRIES]){let e=l.length;d=l[e+t.PREV_ROTATE],c=l[e+t.PREV_TRANSLATE],u=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR]}else{let e=W.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],c=l[e+t.PREV_TRANSLATE],u=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,c+=(l[e+t.TRANSLATE]-c)*n,u+=(l[e+t.SCALE]-u)*n,p+=(l[e+t.SHEAR]-p)*n}if(0==a){let t=h.data;h.rotateMix=t.rotateMix+(d-t.rotateMix)*r,h.translateMix=t.translateMix+(c-t.translateMix)*r,h.scaleMix=t.scaleMix+(u-t.scaleMix)*r,h.shearMix=t.shearMix+(p-t.shearMix)*r}else h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(c-h.translateMix)*r,h.scaleMix+=(u-h.scaleMix)*r,h.shearMix+=(p-h.shearMix)*r}};v(gt,"ENTRIES",5),v(gt,"PREV_TIME",-5),v(gt,"PREV_ROTATE",-4),v(gt,"PREV_TRANSLATE",-3),v(gt,"PREV_SCALE",-2),v(gt,"PREV_SHEAR",-1),v(gt,"ROTATE",1),v(gt,"TRANSLATE",2),v(gt,"SCALE",3),v(gt,"SHEAR",4);let ft=gt;const xt=class t extends Q{constructor(e){super(e),v(this,"pathConstraintIndex"),v(this,"frames"),this.frames=X.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(11<<24)+this.pathConstraintIndex}setFrame(e,s,i){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.VALUE]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return void(h.position=h.data.position);case 1:h.position+=(h.data.position-h.position)*r}return}let d=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_VALUE];else{let e=W.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_VALUE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.VALUE]-d)*n}0==a?h.position=h.data.position+(d-h.data.position)*r:h.position+=(d-h.position)*r}};v(xt,"ENTRIES",2),v(xt,"PREV_TIME",-2),v(xt,"PREV_VALUE",-1),v(xt,"VALUE",1);let wt=xt;class bt extends wt{constructor(t){super(t)}getPropertyId(){return(12<<24)+this.pathConstraintIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(s<o[0]){switch(r){case 0:return void(l.spacing=l.data.spacing);case 1:l.spacing+=(l.data.spacing-l.spacing)*n}return}let h=0;if(s>=o[o.length-bt.ENTRIES])h=o[o.length+bt.PREV_VALUE];else{let t=W.binarySearch(o,s,bt.ENTRIES);h=o[t+bt.PREV_VALUE];let e=o[t],i=this.getCurvePercent(t/bt.ENTRIES-1,1-(s-e)/(o[t+bt.PREV_TIME]-e));h+=(o[t+bt.VALUE]-h)*i}0==r?l.spacing=l.data.spacing+(h-l.data.spacing)*n:l.spacing+=(h-l.spacing)*n}}const yt=class t extends Q{constructor(e){super(e),v(this,"pathConstraintIndex"),v(this,"frames"),this.frames=X.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(13<<24)+this.pathConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return h.rotateMix=h.data.rotateMix,void(h.translateMix=h.data.translateMix);case 1:h.rotateMix+=(h.data.rotateMix-h.rotateMix)*r,h.translateMix+=(h.data.translateMix-h.translateMix)*r}return}let d=0,c=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_ROTATE],c=l[l.length+t.PREV_TRANSLATE];else{let e=W.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],c=l[e+t.PREV_TRANSLATE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,c+=(l[e+t.TRANSLATE]-c)*n}0==a?(h.rotateMix=h.data.rotateMix+(d-h.data.rotateMix)*r,h.translateMix=h.data.translateMix+(c-h.data.translateMix)*r):(h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(c-h.translateMix)*r)}};v(yt,"ENTRIES",3),v(yt,"PREV_TIME",-3),v(yt,"PREV_ROTATE",-2),v(yt,"PREV_TRANSLATE",-1),v(yt,"ROTATE",1),v(yt,"TRANSLATE",2);let Et=yt;const Tt=class t{constructor(t){v(this,"data"),v(this,"tracks",new Array),v(this,"events",new Array),v(this,"listeners",new Array),v(this,"queue",new Ct(this)),v(this,"propertyIDs",new I),v(this,"mixingTo",new Array),v(this,"animationsChanged",!1),v(this,"timeScale",1),v(this,"trackEntryPool",new B(()=>new St)),this.data=t}update(t){t*=this.timeScale;let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(null==i)continue;i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast;let n=t*i.timeScale;if(i.delay>0){if(i.delay-=n,i.delay>0)continue;n=-i.delay,i.delay=0}let r=i.next;if(null!=r){let e=i.trackLast-r.delay;if(e>=0){for(r.delay=0,r.trackTime=e+t*r.timeScale,i.trackTime+=n,this.setCurrent(s,r,!0);null!=r.mixingFrom;)r.mixTime+=n,r=r.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&null==i.mixingFrom){e[s]=null,this.queue.end(i),this.disposeNext(i);continue}if(null!=i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null;null!=t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=n}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(null==s)return!0;let i=this.updateMixingFrom(s,e);return s.animationLast=s.nextAnimationLast,s.trackLast=s.nextTrackLast,t.mixTime>0&&(t.mixTime>=t.mixDuration||0==t.timeScale)?(0!=s.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=s.mixingFrom,t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e*t.timeScale,!1)}apply(e){if(null==e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,n=!1;for(let r=0,a=i.length;r<a;r++){let a=i[r];if(null==a||a.delay>0)continue;n=!0;let o=0==r?$.current:$.currentLayered,l=a.alpha;null!=a.mixingFrom?l*=this.applyMixingFrom(a,e,o):a.trackTime>=a.trackEnd&&null==a.next&&(l=0);let h=a.animationLast,d=a.getAnimationTime(),c=a.animation.timelines.length,u=a.animation.timelines;if(1==l)for(let t=0;t<c;t++)u[t].apply(e,h,d,s,1,$.setup,z.in);else{let i=a.timelineData,n=0==a.timelinesRotation.length;n&&X.setArraySize(a.timelinesRotation,c<<1,null);let r=a.timelinesRotation;for(let a=0;a<c;a++){let c=u[a],p=i[a]>=t.FIRST?$.setup:o;c instanceof K?this.applyRotateTimeline(c,e,d,l,p,r,a<<1,n):(X.webkit602BugfixHelper(l,p),c.apply(e,h,d,s,l,p,z.in))}}this.queueEvents(a,d),s.length=0,a.nextAnimationLast=d,a.nextTrackLast=a.trackTime}return this.queue.drain(),n}applyMixingFrom(e,s,i){let n=e.mixingFrom;null!=n.mixingFrom&&this.applyMixingFrom(n,s,i);let r=0;0==e.mixDuration?(r=1,i=$.setup):(r=e.mixTime/e.mixDuration,r>1&&(r=1));let a=r<n.eventThreshold?this.events:null,o=r<n.attachmentThreshold,l=r<n.drawOrderThreshold,h=n.animationLast,d=n.getAnimationTime(),c=n.animation.timelines.length,u=n.animation.timelines,p=n.timelineData,m=n.timelineDipMix,g=0==n.timelinesRotation.length;g&&X.setArraySize(n.timelinesRotation,c<<1,null);let f,x=n.timelinesRotation,w=n.alpha*e.interruptAlpha,b=w*(1-r),y=0;n.totalAlpha=0;for(var E=0;E<c;E++){let e=u[E];switch(p[E]){case t.SUBSEQUENT:if(!o&&e instanceof lt)continue;if(!l&&e instanceof ut)continue;f=i,y=b;break;case t.FIRST:f=$.setup,y=b;break;case t.DIP:f=$.setup,y=w;break;default:f=$.setup,y=w;let s=m[E];y*=Math.max(0,1-s.mixTime/s.mixDuration)}n.totalAlpha+=y,e instanceof K?this.applyRotateTimeline(e,s,d,y,f,x,E<<1,g):(X.webkit602BugfixHelper(y,f),e.apply(s,h,d,a,y,f,z.out))}return e.mixDuration>0&&this.queueEvents(n,d),this.events.length=0,n.nextAnimationLast=d,n.nextTrackLast=n.trackTime,r}applyRotateTimeline(t,e,s,i,n,r,a,o){if(o&&(r[a]=0),1==i)return void t.apply(e,0,s,null,1,n,z.in);let l=t,h=l.frames,d=e.bones[l.boneIndex];if(s<h[0])return void(n==$.setup&&(d.rotation=d.data.rotation));let c=0;if(s>=h[h.length-K.ENTRIES])c=d.data.rotation+h[h.length+K.PREV_ROTATION];else{let t=W.binarySearch(h,s,K.ENTRIES),e=h[t+K.PREV_ROTATION],i=h[t],n=l.getCurvePercent((t>>1)-1,1-(s-i)/(h[t+K.PREV_TIME]-i));c=h[t+K.ROTATION]-e,c-=360*(16384-(16384.499999999996-c/360|0)),c=e+c*n+d.data.rotation,c-=360*(16384-(16384.499999999996-c/360|0))}let u=n==$.setup?d.data.rotation:d.rotation,p=0,m=c-u;if(0==m)p=r[a];else{m-=360*(16384-(16384.499999999996-m/360|0));let t=0,e=0;o?(t=0,e=m):(t=r[a],e=r[a+1]);let s=m>0,i=t>=0;N.signum(e)!=N.signum(m)&&Math.abs(e)<=90&&(Math.abs(t)>180&&(t+=360*N.signum(t)),i=s),p=m+t-t%360,i!=s&&(p+=360*N.signum(t)),r[a]=p}r[a+1]=m,u+=p*i,d.rotation=u-360*(16384-(16384.499999999996-u/360|0))}queueEvents(t,e){let s=t.animationStart,i=t.animationEnd,n=i-s,r=t.trackLast%n,a=this.events,o=0,l=a.length;for(;o<l;o++){let e=a[o];if(e.time<r)break;e.time>i||this.queue.event(t,e)}for((t.loop?0==n||r>t.trackTime%n:e>=i&&t.animationLast<i)&&this.queue.complete(t);o<l;o++){a[o].time<s||this.queue.event(t,a[o])}}clearTracks(){let t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let t=0,e=this.tracks.length;t<e;t++)this.clearTrack(t);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()}clearTrack(t){if(t>=this.tracks.length)return;let e=this.tracks[t];if(null==e)return;this.queue.end(e),this.disposeNext(e);let s=e;for(;;){let t=s.mixingFrom;if(null==t)break;this.queue.end(t),s.mixingFrom=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,null!=i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,e.mixTime=0,null!=i.mixingFrom&&i.mixDuration>0&&(e.interruptAlpha*=Math.min(1,i.mixTime/i.mixDuration)),i.timelinesRotation.length=0),this.queue.start(e)}setAnimation(t,e,s){let i=this.data.skeletonData.findAnimation(e);if(null==i)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s){if(null==e)throw new Error("animation cannot be null.");let i=!0,n=this.expandToIndex(t);null!=n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.disposeNext(n),n=n.mixingFrom,i=!1):this.disposeNext(n));let r=this.trackEntry(t,e,s,n);return this.setCurrent(t,r,i),this.queue.drain(),r}addAnimation(t,e,s,i){let n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,s,i)}addAnimationWith(t,e,s,i){if(null==e)throw new Error("animation cannot be null.");let n=this.expandToIndex(t);if(null!=n)for(;null!=n.next;)n=n.next;let r=this.trackEntry(t,e,s,n);if(null==n)this.setCurrent(t,r,!0),this.queue.drain();else if(n.next=r,i<=0){let t=n.animationEnd-n.animationStart;0!=t?(n.loop?i+=t*(1+(n.trackTime/t|0)):i+=t,i-=this.data.getMix(n.animation,e)):i=0}return r.delay=i,r}setEmptyAnimation(e,s){let i=this.setAnimationWith(e,t.emptyAnimation,!1);return i.mixDuration=s,i.trackEnd=s,i}addEmptyAnimation(e,s,i){i<=0&&(i-=s);let n=this.addAnimationWith(e,t.emptyAnimation,!1,i);return n.mixDuration=s,n.trackEnd=s,n}setEmptyAnimations(t){let e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let e=0,s=this.tracks.length;e<s;e++){let s=this.tracks[e];null!=s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(X.ensureArrayCapacity(this.tracks,t-this.tracks.length+1,null),this.tracks.length=t+1,null)}trackEntry(t,e,s,i){let n=this.trackEntryPool.obtain();return n.trackIndex=t,n.animation=e,n.loop=s,n.eventThreshold=0,n.attachmentThreshold=0,n.drawOrderThreshold=0,n.animationStart=0,n.animationEnd=e.duration,n.animationLast=-1,n.nextAnimationLast=-1,n.delay=0,n.trackTime=0,n.trackLast=-1,n.nextTrackLast=-1,n.trackEnd=Number.MAX_VALUE,n.timeScale=1,n.alpha=1,n.interruptAlpha=1,n.mixTime=0,n.mixDuration=null==i?0:this.data.getMix(i.animation,e),n}disposeNext(t){let e=t.next;for(;null!=e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1;let t=this.propertyIDs;t.clear();let e=this.mixingTo;for(var s=0,i=this.tracks.length;s<i;s++){let i=this.tracks[s];null!=i&&i.setTimelineData(null,e,t)}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(null==t)throw new Error("listener cannot be null.");this.listeners.push(t)}removeListener(t){let e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}};v(Tt,"emptyAnimation",new W("<empty>",[],0)),v(Tt,"SUBSEQUENT",0),v(Tt,"FIRST",1),v(Tt,"DIP",2),v(Tt,"DIP_MIX",3);let At=Tt;class St{constructor(){v(this,"animation"),v(this,"next"),v(this,"mixingFrom"),v(this,"listener"),v(this,"trackIndex"),v(this,"loop"),v(this,"eventThreshold"),v(this,"attachmentThreshold"),v(this,"drawOrderThreshold"),v(this,"animationStart"),v(this,"animationEnd"),v(this,"animationLast"),v(this,"nextAnimationLast"),v(this,"delay"),v(this,"trackTime"),v(this,"trackLast"),v(this,"nextTrackLast"),v(this,"trackEnd"),v(this,"timeScale"),v(this,"alpha"),v(this,"mixTime"),v(this,"mixDuration"),v(this,"interruptAlpha"),v(this,"totalAlpha"),v(this,"timelineData",new Array),v(this,"timelineDipMix",new Array),v(this,"timelinesRotation",new Array)}reset(){this.next=null,this.mixingFrom=null,this.animation=null,this.listener=null,this.timelineData.length=0,this.timelineDipMix.length=0,this.timelinesRotation.length=0}setTimelineData(t,e,s){null!=t&&e.push(t);let i=null!=this.mixingFrom?this.mixingFrom.setTimelineData(this,e,s):this;null!=t&&e.pop();let n=e,r=e.length-1,a=this.animation.timelines,o=this.animation.timelines.length,l=X.setArraySize(this.timelineData,o);this.timelineDipMix.length=0;let h=X.setArraySize(this.timelineDipMix,o);t:for(var d=0;d<o;d++){let e=a[d].getPropertyId();if(s.add(e))if(null!=t&&t.hasTimeline(e)){for(var c=r;c>=0;c--){let t=n[c];if(!t.hasTimeline(e)&&t.mixDuration>0){l[d]=At.DIP_MIX,h[d]=t;continue t}}l[d]=At.DIP}else l[d]=At.FIRST;else l[d]=At.SUBSEQUENT}return i}hasTimeline(t){let e=this.animation.timelines;for(var s=0,i=e.length;s<i;s++)if(e[s].getPropertyId()==t)return!0;return!1}getAnimationTime(){if(this.loop){let t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}}class Ct{constructor(t){v(this,"objects",[]),v(this,"drainDisabled",!1),v(this,"animState"),this.animState=t}start(t){this.objects.push(0),this.objects.push(t),this.animState.animationsChanged=!0}interrupt(t){this.objects.push(1),this.objects.push(t)}end(t){this.objects.push(2),this.objects.push(t),this.animState.animationsChanged=!0}dispose(t){this.objects.push(3),this.objects.push(t)}complete(t){this.objects.push(4),this.objects.push(t)}event(t,e){this.objects.push(5),this.objects.push(t),this.objects.push(e)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let t=this.objects,e=this.animState.listeners;for(let s=0;s<t.length;s+=2){let i=t[s],n=t[s+1];switch(i){case 0:null!=n.listener&&n.listener.start&&n.listener.start(n);for(let t=0;t<e.length;t++)e[t].start&&e[t].start(n);break;case 1:null!=n.listener&&n.listener.interrupt&&n.listener.interrupt(n);for(let t=0;t<e.length;t++)e[t].interrupt&&e[t].interrupt(n);break;case 2:null!=n.listener&&n.listener.end&&n.listener.end(n);for(let t=0;t<e.length;t++)e[t].end&&e[t].end(n);case 3:null!=n.listener&&n.listener.dispose&&n.listener.dispose(n);for(let t=0;t<e.length;t++)e[t].dispose&&e[t].dispose(n);this.animState.trackEntryPool.free(n);break;case 4:null!=n.listener&&n.listener.complete&&n.listener.complete(n);for(let t=0;t<e.length;t++)e[t].complete&&e[t].complete(n);break;case 5:let i=t[2+s++];null!=n.listener&&n.listener.event&&n.listener.event(n,i);for(let t=0;t<e.length;t++)e[t].event&&e[t].event(n,i)}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}var vt,Mt=((vt=Mt||{})[vt.start=0]="start",vt[vt.interrupt=1]="interrupt",vt[vt.end=2]="end",vt[vt.dispose=3]="dispose",vt[vt.complete=4]="complete",vt[vt.event=5]="event",vt);class Rt{constructor(t){if(v(this,"skeletonData"),v(this,"animationToMixTime",{}),v(this,"defaultMix",0),null==t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(null==i)throw new Error("Animation not found: "+t);let n=this.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);this.setMixWith(i,n,s)}setMixWith(t,e,s){if(null==t)throw new Error("from cannot be null.");if(null==e)throw new Error("to cannot be null.");let i=t.name+"."+e.name;this.animationToMixTime[i]=s}getMix(t,e){let s=t.name+"."+e.name,i=this.animationToMixTime[s];return void 0===i?this.defaultMix:i}}class kt extends P{constructor(t){super(t),v(this,"color",new _(1,1,1,1))}}class Pt extends P{constructor(t){super(t),v(this,"endSlot"),v(this,"color",new _(.2275,.2275,.8078,1))}}class It extends P{constructor(t){super(t),v(this,"region"),v(this,"path"),v(this,"regionUVs"),v(this,"uvs"),v(this,"triangles"),v(this,"color",new _(1,1,1,1)),v(this,"hullLength"),v(this,"parentMesh"),v(this,"inheritDeform",!1),v(this,"tempColor",new _(0,0,0,0))}updateUVs(){let t=0,e=0,s=0,i=0;null==this.region?(t=e=0,s=i=1):(t=this.region.u,e=this.region.v,s=this.region.u2-t,i=this.region.v2-e);let n=this.regionUVs;null!=this.uvs&&this.uvs.length==n.length||(this.uvs=X.newFloatArray(n.length));let r=this.uvs;if(this.region.rotate)for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a+1]*s,r[a+1]=e+i-n[a]*i;else for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a]*s,r[a+1]=e+n[a+1]*i}applyDeform(t){return this==t||this.inheritDeform&&this.parentMesh==t}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,null!=t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)}}class Vt extends P{constructor(t){super(t),v(this,"lengths"),v(this,"closed",!1),v(this,"constantSpeed",!1),v(this,"color",new _(1,1,1,1))}}class _t extends P{constructor(t){super(t),v(this,"x"),v(this,"y"),v(this,"rotation"),v(this,"color",new _(.38,.94,0,1))}computeWorldPosition(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e}computeWorldRotation(t){let e=N.cosDeg(this.rotation),s=N.sinDeg(this.rotation),i=e*t.a+s*t.b,n=e*t.c+s*t.d;return Math.atan2(n,i)*N.radDeg}}const Dt=class t extends R{constructor(t){super(t),v(this,"x",0),v(this,"y",0),v(this,"scaleX",1),v(this,"scaleY",1),v(this,"rotation",0),v(this,"width",0),v(this,"height",0),v(this,"color",new _(1,1,1,1)),v(this,"path"),v(this,"rendererObject"),v(this,"region"),v(this,"offset",X.newFloatArray(8)),v(this,"uvs",X.newFloatArray(8)),v(this,"tempColor",new _(1,1,1,1))}updateOffset(){let e=this.width/this.region.originalWidth*this.scaleX,s=this.height/this.region.originalHeight*this.scaleY,i=-this.width/2*this.scaleX+this.region.offsetX*e,n=-this.height/2*this.scaleY+this.region.offsetY*s,r=i+this.region.width*e,a=n+this.region.height*s,o=this.rotation*Math.PI/180,l=Math.cos(o),h=Math.sin(o),d=i*l+this.x,c=i*h,u=n*l+this.y,p=n*h,m=r*l+this.x,g=r*h,f=a*l+this.y,x=a*h,w=this.offset;w[t.OX1]=d-p,w[t.OY1]=u+c,w[t.OX2]=d-x,w[t.OY2]=f+c,w[t.OX3]=m-x,w[t.OY3]=f+g,w[t.OX4]=m-p,w[t.OY4]=u+g}setRegion(t){this.region=t;let e=this.uvs;t.rotate?(e[0]=t.u2,e[1]=t.v2,e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)}computeWorldVertices(e,s,i,n){let r=this.offset,a=e.worldX,o=e.worldY,l=e.a,h=e.b,d=e.c,c=e.d,u=0,p=0;u=r[t.OX1],p=r[t.OY1],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o,i+=n,u=r[t.OX2],p=r[t.OY2],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o,i+=n,u=r[t.OX3],p=r[t.OY3],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o,i+=n,u=r[t.OX4],p=r[t.OY4],s[i]=u*l+p*h+a,s[i+1]=u*d+p*c+o}};v(Dt,"OX1",0),v(Dt,"OY1",1),v(Dt,"OX2",2),v(Dt,"OY2",3),v(Dt,"OX3",4),v(Dt,"OY3",5),v(Dt,"OX4",6),v(Dt,"OY4",7),v(Dt,"X1",0),v(Dt,"Y1",1),v(Dt,"C1R",2),v(Dt,"C1G",3),v(Dt,"C1B",4),v(Dt,"C1A",5),v(Dt,"U1",6),v(Dt,"V1",7),v(Dt,"X2",8),v(Dt,"Y2",9),v(Dt,"C2R",10),v(Dt,"C2G",11),v(Dt,"C2B",12),v(Dt,"C2A",13),v(Dt,"U2",14),v(Dt,"V2",15),v(Dt,"X3",16),v(Dt,"Y3",17),v(Dt,"C3R",18),v(Dt,"C3G",19),v(Dt,"C3B",20),v(Dt,"C3A",21),v(Dt,"U3",22),v(Dt,"V3",23),v(Dt,"X4",24),v(Dt,"Y4",25),v(Dt,"C4R",26),v(Dt,"C4G",27),v(Dt,"C4B",28),v(Dt,"C4A",29),v(Dt,"U4",30),v(Dt,"V4",31);let Nt=Dt;class Ot{constructor(t){v(this,"atlas"),this.atlas=t}newRegionAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (region attachment: "+e+")");i.renderObject=i;let n=new Nt(e);return n.setRegion(i),n}newMeshAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");i.renderObject=i;let n=new It(e);return n.region=i,n}newBoundingBoxAttachment(t,e){return new kt(e)}newPathAttachment(t,e){return new Vt(e)}newPointAttachment(t,e){return new _t(e)}newClippingAttachment(t,e){return new Pt(e)}}class Lt{constructor(t,e,s){if(v(this,"index"),v(this,"name"),v(this,"parent"),v(this,"length"),v(this,"x",0),v(this,"y",0),v(this,"rotation",0),v(this,"scaleX",1),v(this,"scaleY",1),v(this,"shearX",0),v(this,"shearY",0),v(this,"transformMode",0),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}var Yt,Ft=((Yt=Ft||{})[Yt.Normal=0]="Normal",Yt[Yt.OnlyTranslation=1]="OnlyTranslation",Yt[Yt.NoRotationOrReflection=2]="NoRotationOrReflection",Yt[Yt.NoScale=3]="NoScale",Yt[Yt.NoScaleOrReflection=4]="NoScaleOrReflection",Yt);class Xt{constructor(t,e,s){if(v(this,"data"),v(this,"skeleton"),v(this,"parent"),v(this,"children",new Array),v(this,"x",0),v(this,"y",0),v(this,"rotation",0),v(this,"scaleX",0),v(this,"scaleY",0),v(this,"shearX",0),v(this,"shearY",0),v(this,"ax",0),v(this,"ay",0),v(this,"arotation",0),v(this,"ascaleX",0),v(this,"ascaleY",0),v(this,"ashearX",0),v(this,"ashearY",0),v(this,"appliedValid",!1),v(this,"a",0),v(this,"b",0),v(this,"worldX",0),v(this,"c",0),v(this,"d",0),v(this,"worldY",0),v(this,"sorted",!1),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}update(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(t,e,s,i,n,r,a){this.ax=t,this.ay=e,this.arotation=s,this.ascaleX=i,this.ascaleY=n,this.ashearX=r,this.ashearY=a,this.appliedValid=!0;let o=this.parent;if(null==o){let o=s+90+a,l=N.cosDeg(s+r)*i,h=N.cosDeg(o)*n,d=N.sinDeg(s+r)*i,c=N.sinDeg(o)*n,u=this.skeleton;return u.flipX&&(t=-t,l=-l,h=-h),u.flipY&&(e=-e,d=-d,c=-c),this.a=l,this.b=h,this.c=d,this.d=c,this.worldX=t+u.x,void(this.worldY=e+u.y)}let l=o.a,h=o.b,d=o.c,c=o.d;switch(this.worldX=l*t+h*e+o.worldX,this.worldY=d*t+c*e+o.worldY,this.data.transformMode){case Ft.Normal:{let t=s+90+a,e=N.cosDeg(s+r)*i,o=N.cosDeg(t)*n,u=N.sinDeg(s+r)*i,p=N.sinDeg(t)*n;return this.a=l*e+h*u,this.b=l*o+h*p,this.c=d*e+c*u,void(this.d=d*o+c*p)}case Ft.OnlyTranslation:{let t=s+90+a;this.a=N.cosDeg(s+r)*i,this.b=N.cosDeg(t)*n,this.c=N.sinDeg(s+r)*i,this.d=N.sinDeg(t)*n;break}case Ft.NoRotationOrReflection:{let t=l*l+d*d,e=0;t>1e-4?(t=Math.abs(l*c-h*d)/t,h=d*t,c=l*t,e=Math.atan2(d,l)*N.radDeg):(l=0,d=0,e=90-Math.atan2(c,h)*N.radDeg);let o=s+r-e,u=s+a-e+90,p=N.cosDeg(o)*i,m=N.cosDeg(u)*n,g=N.sinDeg(o)*i,f=N.sinDeg(u)*n;this.a=l*p-h*g,this.b=l*m-h*f,this.c=d*p+c*g,this.d=d*m+c*f;break}case Ft.NoScale:case Ft.NoScaleOrReflection:{let t=N.cosDeg(s),e=N.sinDeg(s),o=l*t+h*e,u=d*t+c*e,p=Math.sqrt(o*o+u*u);p>1e-5&&(p=1/p),o*=p,u*=p,p=Math.sqrt(o*o+u*u);let m=Math.PI/2+Math.atan2(u,o),g=Math.cos(m)*p,f=Math.sin(m)*p,x=N.cosDeg(r)*i,w=N.cosDeg(90+a)*n,b=N.sinDeg(r)*i,y=N.sinDeg(90+a)*n;return(this.data.transformMode!=Ft.NoScaleOrReflection?l*c-h*d<0:this.skeleton.flipX!=this.skeleton.flipY)&&(g=-g,f=-f),this.a=o*x+g*b,this.b=o*w+g*y,this.c=u*x+f*b,void(this.d=u*w+f*y)}}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b),this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)}setToSetupPose(){let t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY}getWorldRotationX(){return Math.atan2(this.c,this.a)*N.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*N.radDeg}getWorldScaleX(){return Math.sqrt(this.a*this.a+this.c*this.c)}getWorldScaleY(){return Math.sqrt(this.b*this.b+this.d*this.d)}updateAppliedTransform(){this.appliedValid=!0;let t=this.parent;if(null==t)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*N.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*N.radDeg);let e=t.a,s=t.b,i=t.c,n=t.d,r=1/(e*n-s*i),a=this.worldX-t.worldX,o=this.worldY-t.worldY;this.ax=a*n*r-o*s*r,this.ay=o*e*r-a*i*r;let l=r*n,h=r*e,d=r*s,c=r*i,u=l*this.a-d*this.c,p=l*this.b-d*this.d,m=h*this.c-c*this.a,g=h*this.d-c*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(u*u+m*m),this.ascaleX>1e-4){let t=u*g-p*m;this.ascaleY=t/this.ascaleX,this.ashearY=Math.atan2(u*p+m*g,t)*N.radDeg,this.arotation=Math.atan2(m,u)*N.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(p*p+g*g),this.ashearY=0,this.arotation=90-Math.atan2(g,p)*N.radDeg}worldToLocal(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=1/(e*n-s*i),a=t.x-this.worldX,o=t.y-this.worldY;return t.x=a*n*r-o*s*r,t.y=o*e*r-a*i*r,t}localToWorld(t){let e=t.x,s=t.y;return t.x=e*this.a+s*this.b+this.worldX,t.y=e*this.c+s*this.d+this.worldY,t}worldToLocalRotation(t){let e=N.sinDeg(t),s=N.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*N.radDeg}localToWorldRotation(t){let e=N.sinDeg(t),s=N.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*N.radDeg}rotateWorld(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=N.cosDeg(t),a=N.sinDeg(t);this.a=r*e-a*i,this.b=r*s-a*n,this.c=a*e+r*i,this.d=a*s+r*n,this.appliedValid=!1}}class Bt{constructor(t){v(this,"_image"),this._image=t}getImage(){return this._image}static filterFromString(t){switch(t.toLowerCase()){case"nearest":return 9728;case"linear":return 9729;case"mipmap":case"mipmaplinearlinear":return 9987;case"mipmapnearestnearest":return 9984;case"mipmaplinearnearest":return 9985;case"mipmapnearestlinear":return 9986;default:throw new Error(`Unknown texture filter ${t}`)}}static wrapFromString(t){switch(t.toLowerCase()){case"mirroredtepeat":return 33648;case"clamptoedge":return 33071;case"repeat":return 10497;default:throw new Error(`Unknown texture wrap ${t}`)}}}var jt,Wt,Ut=((jt=Ut||{})[jt.Nearest=9728]="Nearest",jt[jt.Linear=9729]="Linear",jt[jt.MipMap=9987]="MipMap",jt[jt.MipMapNearestNearest=9984]="MipMapNearestNearest",jt[jt.MipMapLinearNearest=9985]="MipMapLinearNearest",jt[jt.MipMapNearestLinear=9986]="MipMapNearestLinear",jt[jt.MipMapLinearLinear=9987]="MipMapLinearLinear",jt),qt=((Wt=qt||{})[Wt.MirroredRepeat=33648]="MirroredRepeat",Wt[Wt.ClampToEdge=33071]="ClampToEdge",Wt[Wt.Repeat=10497]="Repeat",Wt);class Gt{constructor(){v(this,"renderObject"),v(this,"u",0),v(this,"v",0),v(this,"u2",0),v(this,"v2",0),v(this,"width",0),v(this,"height",0),v(this,"rotate",!1),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"originalWidth",0),v(this,"originalHeight",0),v(this,"texture")}}class $t extends Bt{setFilters(t,e){}setWraps(t,e){}dispose(){}}class zt{constructor(t,e){v(this,"pages",new Array),v(this,"regions",new Array),this.load(t,e)}load(t,e){if(null==e)throw new Error("textureLoader cannot be null.");let s=new Ht(t),i=new Array(4),n=null;for(;;){let t=s.readLine();if(null==t)break;if(t=t.trim(),0==t.length)n=null;else if(n){let e=new Qt;e.name=t,e.page=n,e.rotate="true"==s.readValue(),s.readTuple(i);let r=parseInt(i[0]),a=parseInt(i[1]);s.readTuple(i);let o=parseInt(i[0]),l=parseInt(i[1]);e.u=r/n.width,e.v=a/n.height,e.rotate?(e.u2=(r+l)/n.width,e.v2=(a+o)/n.height):(e.u2=(r+o)/n.width,e.v2=(a+l)/n.height),e.x=r,e.y=a,e.width=Math.abs(o),e.height=Math.abs(l),4==s.readTuple(i)&&4==s.readTuple(i)&&s.readTuple(i),e.originalWidth=parseInt(i[0]),e.originalHeight=parseInt(i[1]),s.readTuple(i),e.offsetX=parseInt(i[0]),e.offsetY=parseInt(i[1]),e.index=parseInt(s.readValue()),e.texture=n.texture,this.regions.push(e)}else{n=new Zt,n.name=t,2==s.readTuple(i)&&(n.width=parseInt(i[0]),n.height=parseInt(i[1]),s.readTuple(i)),s.readTuple(i),n.minFilter=Bt.filterFromString(i[0]),n.magFilter=Bt.filterFromString(i[1]);let r=s.readValue();n.uWrap=qt.ClampToEdge,n.vWrap=qt.ClampToEdge,"x"==r?n.uWrap=qt.Repeat:"y"==r?n.vWrap=qt.Repeat:"xy"==r&&(n.uWrap=n.vWrap=qt.Repeat),n.texture=e(t),n.texture.setFilters(n.minFilter,n.magFilter),n.texture.setWraps(n.uWrap,n.vWrap),n.width=n.texture.getImage().width,n.height=n.texture.getImage().height,this.pages.push(n)}}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture.dispose()}}class Ht{constructor(t){v(this,"lines"),v(this,"index",0),this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readValue(){let t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()}readTuple(t){let e=this.readLine(),s=e.indexOf(":");if(-1==s)throw new Error("Invalid line: "+e);let i=0,n=s+1;for(;i<3;i++){let s=e.indexOf(",",n);if(-1==s)break;t[i]=e.substr(n,s-n).trim(),n=s+1}return t[i]=e.substring(n).trim(),i+1}}class Zt{constructor(){v(this,"name"),v(this,"minFilter"),v(this,"magFilter"),v(this,"uWrap"),v(this,"vWrap"),v(this,"texture"),v(this,"width"),v(this,"height")}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap),this.width=this.texture.getImage().width,this.height=this.texture.getImage().height}}class Qt extends Gt{constructor(){super(...arguments),v(this,"page"),v(this,"name"),v(this,"x"),v(this,"y"),v(this,"index"),v(this,"rotate"),v(this,"texture")}}class Jt{constructor(t,e=""){v(this,"pathPrefix"),v(this,"textureLoader"),v(this,"assets",{}),v(this,"errors",{}),v(this,"toLoad",0),v(this,"loaded",0),this.textureLoader=t,this.pathPrefix=e}static downloadText(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.onload=()=>{200==i.status?e(i.responseText):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}static downloadBinary(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status?e(new Uint8Array(i.response)):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}loadText(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++,Jt.downloadText(t,s=>{this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++},(e,i)=>{this.errors[t]=`Couldn't load text ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load text ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++})}loadTexture(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++;let i=new Image;i.crossOrigin="anonymous",i.onload=s=>{let n=this.textureLoader(i);this.assets[t]=n,this.toLoad--,this.loaded++,e&&e(t,i)},i.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,s&&s(t,`Couldn't load image ${t}`)},i.src=t}loadTextureData(t,e,s=null,i=null){t=this.pathPrefix+t,this.toLoad++;let n=new Image;n.onload=e=>{let i=this.textureLoader(n);this.assets[t]=i,this.toLoad--,this.loaded++,s&&s(t,n)},n.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,i&&i(t,`Couldn't load image ${t}`)},n.src=e}loadTextureAtlas(t,e=null,s=null){let i=t.lastIndexOf("/")>=0?t.substring(0,t.lastIndexOf("/")):"";t=this.pathPrefix+t,this.toLoad++,Jt.downloadText(t,n=>{var r={count:0},a=new Array;try{new zt(n,t=>{a.push(i+"/"+t);let e=document.createElement("img");return e.width=16,e.height=16,new $t(e)})}catch(e){let i=e;return this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,void this.loaded++}for(let o of a){let l=!1;this.loadTexture(o,(o,h)=>{if(r.count++,r.count==a.length)if(l)this.errors[t]=`Couldn't load texture atlas page ${o}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${o} of atlas ${t}`),this.toLoad--,this.loaded++;else try{let s=new zt(n,t=>this.get(i+"/"+t));this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++}catch(e){let i=e;this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,this.loaded++}},(e,i)=>{l=!0,r.count++,r.count==a.length&&(this.errors[t]=`Couldn't load texture atlas page ${e}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${e} of atlas ${t}`),this.toLoad--,this.loaded++)})}},(e,i)=>{this.errors[t]=`Couldn't load texture atlas ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load texture atlas ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++})}get(t){return t=this.pathPrefix+t,this.assets[t]}remove(t){t=this.pathPrefix+t;let e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null}removeAll(){for(let t in this.assets){let e=this.assets[t];e.dispose&&e.dispose()}this.assets={}}isLoadingComplete(){return 0==this.toLoad}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}}class Kt{constructor(t,e){if(v(this,"data"),v(this,"intValue"),v(this,"floatValue"),v(this,"stringValue"),v(this,"time"),null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}}class te{constructor(t){v(this,"name"),v(this,"intValue"),v(this,"floatValue"),v(this,"stringValue"),this.name=t}}class ee{constructor(t,e){if(v(this,"data"),v(this,"bones"),v(this,"target"),v(this,"mix",1),v(this,"bendDirection",0),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}getOrder(){return this.data.order}apply(){this.update()}update(){let t=this.target,e=this.bones;switch(e.length){case 1:this.apply1(e[0],t.worldX,t.worldY,this.mix);break;case 2:this.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.mix)}}apply1(t,e,s,i){t.appliedValid||t.updateAppliedTransform();let n=t.parent,r=1/(n.a*n.d-n.b*n.c),a=e-n.worldX,o=s-n.worldY,l=(a*n.d-o*n.b)*r-t.ax,h=(o*n.a-a*n.c)*r-t.ay,d=Math.atan2(h,l)*N.radDeg-t.ashearX-t.arotation;t.ascaleX<0&&(d+=180),d>180?d-=360:d<-180&&(d+=360),t.updateWorldTransformWith(t.ax,t.ay,t.arotation+d*i,t.ascaleX,t.ascaleY,t.ashearX,t.ashearY)}apply2(t,e,s,i,n,r){if(0==r)return void e.updateWorldTransform();t.appliedValid||t.updateAppliedTransform(),e.appliedValid||e.updateAppliedTransform();let a=t.ax,o=t.ay,l=t.ascaleX,h=t.ascaleY,d=e.ascaleX,c=0,u=0,p=0;l<0?(l=-l,c=180,p=-1):(c=0,p=1),h<0&&(h=-h,p=-p),d<0?(d=-d,u=180):u=0;let m=e.ax,g=0,f=0,x=0,w=t.a,b=t.b,y=t.c,E=t.d,T=Math.abs(l-h)<=1e-4;T?(g=e.ay,f=w*m+b*g+t.worldX,x=y*m+E*g+t.worldY):(g=0,f=w*m+t.worldX,x=y*m+t.worldY);let A=t.parent;w=A.a,b=A.b,y=A.c,E=A.d;let S=1/(w*E-b*y),C=s-A.worldX,v=i-A.worldY,M=(C*E-v*b)*S-a,R=(v*w-C*y)*S-o;C=f-A.worldX,v=x-A.worldY;let k=(C*E-v*b)*S-a,P=(v*w-C*y)*S-o,I=Math.sqrt(k*k+P*P),V=e.data.length*d,_=0,D=0;t:if(T){V*=l;let t=(M*M+R*R-I*I-V*V)/(2*I*V);t<-1?t=-1:t>1&&(t=1),D=Math.acos(t)*n,w=I+V*t,b=V*Math.sin(D),_=Math.atan2(R*w-M*b,M*w+R*b)}else{w=l*V,b=h*V;let t=w*w,e=b*b,s=M*M+R*R,i=Math.atan2(R,M);y=e*I*I+t*s-t*e;let r=-2*e*I,a=e-t;if(E=r*r-4*a*y,E>=0){let t=Math.sqrt(E);r<0&&(t=-t),t=-(r+t)/2;let e=t/a,o=y/t,d=Math.abs(e)<Math.abs(o)?e:o;if(d*d<=s){v=Math.sqrt(s-d*d)*n,_=i-Math.atan2(v,d),D=Math.atan2(v/h,(d-I)/l);break t}}let o=N.PI,d=I-w,c=d*d,u=0,p=0,m=I+w,g=m*m,f=0;y=-w*I/(t-e),y>=-1&&y<=1&&(y=Math.acos(y),C=w*Math.cos(y)+I,v=b*Math.sin(y),E=C*C+v*v,E<c&&(o=y,c=E,d=C,u=v),E>g&&(p=y,g=E,m=C,f=v)),s<=(c+g)/2?(_=i-Math.atan2(u*n,d),D=o*n):(_=i-Math.atan2(f*n,m),D=p*n)}let O=Math.atan2(g,m)*p,L=t.arotation;_=(_-O)*N.radDeg+c-L,_>180?_-=360:_<-180&&(_+=360),t.updateWorldTransformWith(a,o,L+_*r,t.ascaleX,t.ascaleY,0,0),L=e.arotation,D=((D+O)*N.radDeg-e.ashearX)*p+u-L,D>180?D-=360:D<-180&&(D+=360),e.updateWorldTransformWith(m,g,L+D*r,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)}}class se{constructor(t){v(this,"name"),v(this,"order",0),v(this,"bones",new Array),v(this,"target"),v(this,"bendDirection",1),v(this,"mix",1),this.name=t}}class ie{constructor(t){v(this,"name"),v(this,"order",0),v(this,"bones",new Array),v(this,"target"),v(this,"positionMode"),v(this,"spacingMode"),v(this,"rotateMode"),v(this,"offsetRotation"),v(this,"position"),v(this,"spacing"),v(this,"rotateMix"),v(this,"translateMix"),this.name=t}}var ne,re,ae,oe=((ne=oe||{})[ne.Fixed=0]="Fixed",ne[ne.Percent=1]="Percent",ne),le=((re=le||{})[re.Length=0]="Length",re[re.Fixed=1]="Fixed",re[re.Percent=2]="Percent",re),he=((ae=he||{})[ae.Tangent=0]="Tangent",ae[ae.Chain=1]="Chain",ae[ae.ChainScale=2]="ChainScale",ae);const de=class t{constructor(t,e){if(v(this,"data"),v(this,"bones"),v(this,"target"),v(this,"position",0),v(this,"spacing",0),v(this,"rotateMix",0),v(this,"translateMix",0),v(this,"spaces",new Array),v(this,"positions",new Array),v(this,"world",new Array),v(this,"curves",new Array),v(this,"lengths",new Array),v(this,"segments",new Array),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0,i=t.bones.length;s<i;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findSlot(t.target.name),this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix}apply(){this.update()}update(){let e=this.target.getAttachment();if(!(e instanceof Vt))return;let s=this.rotateMix,i=this.translateMix,n=s>0;if(!(i>0)&&!n)return;let r=this.data,a=r.spacingMode,o=a==le.Length,l=r.rotateMode,h=l==he.Tangent,d=l==he.ChainScale,c=this.bones.length,u=h?c:c+1,p=this.bones,m=X.setArraySize(this.spaces,u),g=null,f=this.spacing;if(d||o){d&&(g=X.setArraySize(this.lengths,c));for(let e=0,s=u-1;e<s;){let s=p[e],i=s.data.length;if(i<t.epsilon)d&&(g[e]=0),m[++e]=0;else{let t=i*s.a,n=i*s.c,r=Math.sqrt(t*t+n*n);d&&(g[e]=r),m[++e]=(o?i+f:f)*r/i}}}else for(let t=1;t<u;t++)m[t]=f;let x=this.computeWorldPositions(e,u,h,r.positionMode==oe.Percent,a==le.Percent),w=x[0],b=x[1],y=r.offsetRotation,E=!1;if(0==y)E=l==he.Chain;else{E=!1;let t=this.target.bone;y*=t.a*t.d-t.b*t.c>0?N.degRad:-N.degRad}for(let t=0,e=3;t<c;t++,e+=3){let r=p[t];r.worldX+=(w-r.worldX)*i,r.worldY+=(b-r.worldY)*i;let a=x[e],o=x[e+1],l=a-w,c=o-b;if(d){let e=g[t];if(0!=e){let t=(Math.sqrt(l*l+c*c)/e-1)*s+1;r.a*=t,r.c*=t}}if(w=a,b=o,n){let i=r.a,n=r.b,a=r.c,o=r.d,d=0,u=0,p=0;if(d=h?x[e-1]:0==m[t+1]?x[e+2]:Math.atan2(c,l),d-=Math.atan2(a,i),E){u=Math.cos(d),p=Math.sin(d);let t=r.data.length;w+=(t*(u*i-p*a)-l)*s,b+=(t*(p*i+u*a)-c)*s}else d+=y;d>N.PI?d-=N.PI2:d<-N.PI&&(d+=N.PI2),d*=s,u=Math.cos(d),p=Math.sin(d),r.a=u*i-p*a,r.b=u*n-p*o,r.c=p*i+u*a,r.d=p*n+u*o}r.appliedValid=!1}}computeWorldPositions(e,s,i,n,r){let a=this.target,o=this.position,l=this.spaces,h=X.setArraySize(this.positions,3*s+2),d=null,c=e.closed,u=e.worldVerticesLength,p=u/6,m=t.NONE;if(!e.constantSpeed){let g=e.lengths;p-=c?1:2;let f=g[p];if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;d=X.setArraySize(this.world,8);for(let n=0,r=0,x=0;n<s;n++,r+=3){let s=l[n];o+=s;let w=o;if(c)w%=f,w<0&&(w+=f),x=0;else{if(w<0){m!=t.BEFORE&&(m=t.BEFORE,e.computeWorldVertices(a,2,4,d,0,2)),this.addBeforePosition(w,d,0,h,r);continue}if(w>f){m!=t.AFTER&&(m=t.AFTER,e.computeWorldVertices(a,u-6,4,d,0,2)),this.addAfterPosition(w-f,d,0,h,r);continue}}for(;;x++){let t=g[x];if(!(w>t)){if(0==x)w/=t;else{let e=g[x-1];w=(w-e)/(t-e)}break}}x!=m&&(m=x,c&&x==p?(e.computeWorldVertices(a,u-4,4,d,0,2),e.computeWorldVertices(a,0,4,d,4,2)):e.computeWorldVertices(a,6*x+2,8,d,0,2)),this.addCurvePosition(w,d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],h,r,i||n>0&&0==s)}return h}c?(u+=2,d=X.setArraySize(this.world,u),e.computeWorldVertices(a,2,u-4,d,0,2),e.computeWorldVertices(a,0,2,d,u-4,2),d[u-2]=d[0],d[u-1]=d[1]):(p--,u-=4,d=X.setArraySize(this.world,u),e.computeWorldVertices(a,2,u,d,0,2));let g=X.setArraySize(this.curves,p),f=0,x=d[0],w=d[1],b=0,y=0,E=0,T=0,A=0,S=0,C=0,v=0,M=0,R=0,k=0,P=0,I=0,V=0;for(let t=0,e=2;t<p;t++,e+=6)b=d[e],y=d[e+1],E=d[e+2],T=d[e+3],A=d[e+4],S=d[e+5],C=.1875*(x-2*b+E),v=.1875*(w-2*y+T),M=.09375*(3*(b-E)-x+A),R=.09375*(3*(y-T)-w+S),k=2*C+M,P=2*v+R,I=.75*(b-x)+C+.16666667*M,V=.75*(y-w)+v+.16666667*R,f+=Math.sqrt(I*I+V*V),I+=k,V+=P,k+=M,P+=R,f+=Math.sqrt(I*I+V*V),I+=k,V+=P,f+=Math.sqrt(I*I+V*V),I+=k+M,V+=P+R,f+=Math.sqrt(I*I+V*V),g[t]=f,x=A,w=S;if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;let _=this.segments,D=0;for(let t=0,e=0,n=0,r=0;t<s;t++,e+=3){let s=l[t];o+=s;let a=o;if(c)a%=f,a<0&&(a+=f),n=0;else{if(a<0){this.addBeforePosition(a,d,0,h,e);continue}if(a>f){this.addAfterPosition(a-f,d,u-4,h,e);continue}}for(;;n++){let t=g[n];if(!(a>t)){if(0==n)a/=t;else{let e=g[n-1];a=(a-e)/(t-e)}break}}if(n!=m){m=n;let t=6*n;for(x=d[t],w=d[t+1],b=d[t+2],y=d[t+3],E=d[t+4],T=d[t+5],A=d[t+6],S=d[t+7],C=.03*(x-2*b+E),v=.03*(w-2*y+T),M=.006*(3*(b-E)-x+A),R=.006*(3*(y-T)-w+S),k=2*C+M,P=2*v+R,I=.3*(b-x)+C+.16666667*M,V=.3*(y-w)+v+.16666667*R,D=Math.sqrt(I*I+V*V),_[0]=D,t=1;t<8;t++)I+=k,V+=P,k+=M,P+=R,D+=Math.sqrt(I*I+V*V),_[t]=D;I+=k,V+=P,D+=Math.sqrt(I*I+V*V),_[8]=D,I+=k+M,V+=P+R,D+=Math.sqrt(I*I+V*V),_[9]=D,r=0}for(a*=D;;r++){let t=_[r];if(!(a>t)){if(0==r)a/=t;else{let e=_[r-1];a=r+(a-e)/(t-e)}break}}this.addCurvePosition(.1*a,x,w,b,y,E,T,A,S,h,e,i||t>0&&0==s)}return h}addBeforePosition(t,e,s,i,n){let r=e[s],a=e[s+1],o=e[s+2]-r,l=e[s+3]-a,h=Math.atan2(l,o);i[n]=r+t*Math.cos(h),i[n+1]=a+t*Math.sin(h),i[n+2]=h}addAfterPosition(t,e,s,i,n){let r=e[s+2],a=e[s+3],o=r-e[s],l=a-e[s+1],h=Math.atan2(l,o);i[n]=r+t*Math.cos(h),i[n+1]=a+t*Math.sin(h),i[n+2]=h}addCurvePosition(t,e,s,i,n,r,a,o,l,h,d,c){(0==t||isNaN(t))&&(t=1e-4);let u=t*t,p=u*t,m=1-t,g=m*m,f=g*m,x=m*t,w=3*x,b=m*w,y=w*t,E=e*f+i*b+r*y+o*p,T=s*f+n*b+a*y+l*p;h[d]=E,h[d+1]=T,c&&(h[d+2]=Math.atan2(T-(s*g+n*x*2+a*u),E-(e*g+i*x*2+r*u)))}getOrder(){return this.data.order}};v(de,"NONE",-1),v(de,"BEFORE",-2),v(de,"AFTER",-3),v(de,"epsilon",1e-5);let ce=de;class ue{constructor(t,e){if(v(this,"data"),v(this,"bone"),v(this,"color"),v(this,"darkColor"),v(this,"attachment"),v(this,"attachmentTime"),v(this,"attachmentVertices",new Array),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new _,this.darkColor=null==t.darkColor?null:new _,this.setToSetupPose()}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(this.attachment=t,this.attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0)}setAttachmentTime(t){this.attachmentTime=this.bone.skeleton.time-t}getAttachmentTime(){return this.bone.skeleton.time-this.attachmentTime}setToSetupPose(){this.color.setFromColor(this.data.color),null!=this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))}}class pe{constructor(t,e){if(v(this,"data"),v(this,"bones"),v(this,"target"),v(this,"rotateMix",0),v(this,"translateMix",0),v(this,"scaleMix",0),v(this,"shearMix",0),v(this,"temp",new j),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.scaleMix=t.scaleMix,this.shearMix=t.shearMix,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}apply(){this.update()}update(){this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld()}applyAbsoluteWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?N.degRad:-N.degRad,d=this.data.offsetRotation*h,c=this.data.offsetShearY*h,u=this.bones;for(let h=0,p=u.length;h<p;h++){let p=u[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)-Math.atan2(i,e)+d;a>N.PI?a-=N.PI2:a<-N.PI&&(a+=N.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=(t.x-p.worldX)*e,p.worldY+=(t.y-p.worldY)*e,m=!0}if(s>0){let t=Math.sqrt(p.a*p.a+p.c*p.c),e=Math.sqrt(r*r+o*o);t>1e-5&&(t=(t+(e-t+this.data.offsetScaleX)*s)/t),p.a*=t,p.c*=t,t=Math.sqrt(p.b*p.b+p.d*p.d),e=Math.sqrt(a*a+l*l),t>1e-5&&(t=(t+(e-t+this.data.offsetScaleY)*s)/t),p.b*=t,p.d*=t,m=!0}if(i>0){let t=p.b,e=p.d,s=Math.atan2(e,t),n=Math.atan2(l,a)-Math.atan2(o,r)-(s-Math.atan2(p.c,p.a));n>N.PI?n-=N.PI2:n<-N.PI&&(n+=N.PI2),n=s+(n+c)*i;let h=Math.sqrt(t*t+e*e);p.b=Math.cos(n)*h,p.d=Math.sin(n)*h,m=!0}m&&(p.appliedValid=!1)}}applyRelativeWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?N.degRad:-N.degRad,d=this.data.offsetRotation*h,c=this.data.offsetShearY*h,u=this.bones;for(let h=0,p=u.length;h<p;h++){let p=u[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)+d;a>N.PI?a-=N.PI2:a<-N.PI&&(a+=N.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=t.x*e,p.worldY+=t.y*e,m=!0}if(s>0){let t=(Math.sqrt(r*r+o*o)-1+this.data.offsetScaleX)*s+1;p.a*=t,p.c*=t,t=(Math.sqrt(a*a+l*l)-1+this.data.offsetScaleY)*s+1,p.b*=t,p.d*=t,m=!0}if(i>0){let t=Math.atan2(l,a)-Math.atan2(o,r);t>N.PI?t-=N.PI2:t<-N.PI&&(t+=N.PI2);let e=p.b,s=p.d;t=Math.atan2(s,e)+(t-N.PI/2+c)*i;let n=Math.sqrt(e*e+s*s);p.b=Math.cos(t)*n,p.d=Math.sin(t)*n,m=!0}m&&(p.appliedValid=!1)}}applyAbsoluteLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;if(0!=t){let e=n.arotation-l+this.data.offsetRotation;e-=360*(16384-(16384.499999999996-e/360|0)),l+=e*t}let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax-h+this.data.offsetX)*e,d+=(n.ay-d+this.data.offsetY)*e);let c=o.ascaleX,u=o.ascaleY;s>0&&(c>1e-5&&(c=(c+(n.ascaleX-c+this.data.offsetScaleX)*s)/c),u>1e-5&&(u=(u+(n.ascaleY-u+this.data.offsetScaleY)*s)/u));let p=o.ashearY;if(i>0){let t=n.ashearY-p+this.data.offsetShearY;t-=360*(16384-(16384.499999999996-t/360|0)),o.shearY+=t*i}o.updateWorldTransformWith(h,d,l,c,u,o.ashearX,p)}}applyRelativeLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;0!=t&&(l+=(n.arotation+this.data.offsetRotation)*t);let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax+this.data.offsetX)*e,d+=(n.ay+this.data.offsetY)*e);let c=o.ascaleX,u=o.ascaleY;s>0&&(c>1e-5&&(c*=(n.ascaleX-1+this.data.offsetScaleX)*s+1),u>1e-5&&(u*=(n.ascaleY-1+this.data.offsetScaleY)*s+1));let p=o.ashearY;i>0&&(p+=(n.ashearY+this.data.offsetShearY)*i),o.updateWorldTransformWith(h,d,l,c,u,o.ashearX,p)}}getOrder(){return this.data.order}}class me{constructor(t){if(v(this,"data"),v(this,"bones"),v(this,"slots"),v(this,"drawOrder"),v(this,"ikConstraints"),v(this,"transformConstraints"),v(this,"pathConstraints"),v(this,"_updateCache",new Array),v(this,"updateCacheReset",new Array),v(this,"skin"),v(this,"color"),v(this,"time",0),v(this,"flipX",!1),v(this,"flipY",!1),v(this,"x",0),v(this,"y",0),null==t)throw new Error("data cannot be null.");this.data=t,this.bones=new Array;for(let e=0;e<t.bones.length;e++){let s,i=t.bones[e];if(null==i.parent)s=new Xt(i,this,null);else{let t=this.bones[i.parent.index];s=new Xt(i,this,t),t.children.push(s)}this.bones.push(s)}this.slots=new Array,this.drawOrder=new Array;for(let e=0;e<t.slots.length;e++){let s=t.slots[e],i=this.bones[s.boneData.index],n=new ue(s,i);this.slots.push(n),this.drawOrder.push(n)}this.ikConstraints=new Array;for(let e=0;e<t.ikConstraints.length;e++){let s=t.ikConstraints[e];this.ikConstraints.push(new ee(s,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new pe(s,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new ce(s,this))}this.color=new _(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0,this.updateCacheReset.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].sorted=!1;let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,n=e.length,r=s.length,a=i.length,o=n+r+a;t:for(let t=0;t<o;t++){for(let s=0;s<n;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<r;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<a;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),s.length>1){let t=s[s.length-1];this._updateCache.indexOf(t)>-1||this.updateCacheReset.push(t)}this._updateCache.push(t),this.sortReset(i.children),s[s.length-1].sorted=!0}sortPathConstraint(t){let e=t.target,s=e.data.index,i=e.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,s,i);for(let t=0,e=this.data.skins.length;t<e;t++)this.sortPathConstraintAttachment(this.data.skins[t],s,i);let n=e.getAttachment();n instanceof Vt&&this.sortPathConstraintAttachmentWith(n,i);let r=t.bones,a=r.length;for(let t=0;t<a;t++)this.sortBone(r[t]);this._updateCache.push(t);for(let t=0;t<a;t++)this.sortReset(r[t].children);for(let t=0;t<a;t++)r[t].sorted=!0}sortTransformConstraint(t){this.sortBone(t.target);let e=t.bones,s=e.length;if(t.data.local)for(let t=0;t<s;t++){let s=e[t];this.sortBone(s.parent),this._updateCache.indexOf(s)>-1||this.updateCacheReset.push(s)}else for(let t=0;t<s;t++)this.sortBone(e[t]);this._updateCache.push(t);for(let t=0;t<s;t++)this.sortReset(e[t].children);for(let t=0;t<s;t++)e[t].sorted=!0}sortPathConstraintAttachment(t,e,s){let i=t.attachments[e];if(i)for(let t in i)this.sortPathConstraintAttachmentWith(i[t],s)}sortPathConstraintAttachmentWith(t,e){if(!(t instanceof Vt))return;let s=t.bones;if(null==s)this.sortBone(e);else{let t=this.bones,e=0;for(;e<s.length;){let i=s[e++];for(let n=e+i;e<n;e++){let i=s[e];this.sortBone(t[i])}}}}sortBone(t){if(t.sorted)return;let e=t.parent;null!=e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let e=0,s=t.length;e<s;e++){let s=t[e];s.sorted&&this.sortReset(s.children),s.sorted=!1}}updateWorldTransform(){let t=this.updateCacheReset;for(let e=0,s=t.length;e<s;e++){let s=t[e];s.ax=s.x,s.ay=s.y,s.arotation=s.rotation,s.ascaleX=s.scaleX,s.ascaleY=s.scaleY,s.ashearX=s.shearX,s.ashearY=s.shearY,s.appliedValid=!0}let e=this._updateCache;for(let t=0,s=e.length;t<s;t++)e[t].update()}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose();let e=this.ikConstraints;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.bendDirection=s.data.bendDirection,s.mix=s.data.mix}let s=this.transformConstraints;for(let t=0,e=s.length;t<e;t++){let e=s[t],i=e.data;e.rotateMix=i.rotateMix,e.translateMix=i.translateMix,e.scaleMix=i.scaleMix,e.shearMix=i.shearMix}let i=this.pathConstraints;for(let t=0,e=i.length;t<e;t++){let e=i[t],s=e.data;e.position=s.position,e.spacing=s.spacing,e.rotateMix=s.rotateMix,e.translateMix=s.translateMix}}setSlotsToSetupPose(){let t=this.slots;X.arrayCopy(t,0,this.drawOrder,0,t.length);for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose()}getRootBone(){return 0==this.bones.length?null:this.bones[0]}findBone(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}findSlot(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}setSkinByName(t){let e=this.data.findSkin(t);if(null==e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(null!=t)if(null!=this.skin)t.attachAll(this,this.skin);else{let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s],n=i.data.attachmentName;if(null!=n){let e=t.getAttachment(s,n);null!=e&&i.setAttachment(e)}}}this.skin=t}getAttachmentByName(t,e){return this.getAttachment(this.data.findSlotIndex(t),e)}getAttachment(t,e){if(null==e)throw new Error("attachmentName cannot be null.");if(null!=this.skin){let s=this.skin.getAttachment(t,e);if(null!=s)return s}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(null==t)throw new Error("slotName cannot be null.");let s=this.slots;for(let i=0,n=s.length;i<n;i++){let n=s[i];if(n.data.name==t){let s=null;if(null!=e&&(s=this.getAttachment(i,e),null==s))throw new Error("Attachment not found: "+e+", for slot: "+t);return void n.setAttachment(s)}}throw new Error("Slot not found: "+t)}findIkConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findTransformConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findPathConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}getBounds(t,e,s){if(null==t)throw new Error("offset cannot be null.");if(null==e)throw new Error("size cannot be null.");let i=this.drawOrder,n=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let t=0,e=i.length;t<e;t++){let e=i[t],l=0,h=null,d=e.getAttachment();if(d instanceof Nt)l=8,h=X.setArraySize(s,l,0),d.computeWorldVertices(e.bone,h,0,2);else if(d instanceof It){let t=d;l=t.worldVerticesLength,h=X.setArraySize(s,l,0),t.computeWorldVertices(e,0,l,h,0,2)}if(null!=h)for(let t=0,e=h.length;t<e;t+=2){let e=h[t],s=h[t+1];n=Math.min(n,e),r=Math.min(r,s),a=Math.max(a,e),o=Math.max(o,s)}}t.set(n,r),e.set(a-n,o-r)}update(t){this.time+=t}}class ge{constructor(){v(this,"minX",0),v(this,"minY",0),v(this,"maxX",0),v(this,"maxY",0),v(this,"boundingBoxes",new Array),v(this,"polygons",new Array),v(this,"polygonPool",new B(()=>X.newFloatArray(16)))}update(t,e){if(null==t)throw new Error("skeleton cannot be null.");let s=this.boundingBoxes,i=this.polygons,n=this.polygonPool,r=t.slots,a=r.length;s.length=0,n.freeAll(i),i.length=0;for(let t=0;t<a;t++){let e=r[t],a=e.getAttachment();if(a instanceof kt){let t=a;s.push(t);let r=n.obtain();r.length!=t.worldVerticesLength&&(r=X.newFloatArray(t.worldVerticesLength)),i.push(r),t.computeWorldVertices(e,0,t.worldVerticesLength,r,0,2)}}e?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=this.polygons;for(let r=0,a=n.length;r<a;r++){let a=n[r],o=a;for(let n=0,r=a.length;n<r;n+=2){let r=o[n],a=o[n+1];t=Math.min(t,r),e=Math.min(e,a),s=Math.max(s,r),i=Math.max(i,a)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,i){let n=this.minX,r=this.minY,a=this.maxX,o=this.maxY;if(t<=n&&s<=n||e<=r&&i<=r||t>=a&&s>=a||e>=o&&i>=o)return!1;let l=(i-e)/(s-t),h=l*(n-t)+e;if(h>r&&h<o)return!0;if(h=l*(a-t)+e,h>r&&h<o)return!0;let d=(r-e)/l+t;return d>n&&d<a||(d=(o-e)/l+t,d>n&&d<a)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){let s=this.polygons;for(let i=0,n=s.length;i<n;i++)if(this.containsPointPolygon(s[i],t,e))return this.boundingBoxes[i];return null}containsPointPolygon(t,e,s){let i=t,n=t.length,r=n-2,a=!1;for(let t=0;t<n;t+=2){let n=i[t+1],o=i[r+1];if(n<s&&o>=s||o<s&&n>=s){let l=i[t];l+(s-n)/(o-n)*(i[r]-l)<e&&(a=!a)}r=t}return a}intersectsSegment(t,e,s,i){let n=this.polygons;for(let r=0,a=n.length;r<a;r++)if(this.intersectsSegmentPolygon(n[r],t,e,s,i))return this.boundingBoxes[r];return null}intersectsSegmentPolygon(t,e,s,i,n){let r=t,a=t.length,o=e-i,l=s-n,h=e*n-s*i,d=r[a-2],c=r[a-1];for(let t=0;t<a;t+=2){let a=r[t],u=r[t+1],p=d*u-c*a,m=d-a,g=c-u,f=o*g-l*m,x=(h*m-o*p)/f;if((x>=d&&x<=a||x>=a&&x<=d)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(h*g-l*p)/f;if((t>=c&&t<=u||t>=u&&t<=c)&&(t>=s&&t<=n||t>=n&&t<=s))return!0}d=a,c=u}return!1}getPolygon(t){if(null==t)throw new Error("boundingBox cannot be null.");let e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}}class fe{constructor(){v(this,"convexPolygons",new Array),v(this,"convexPolygonsIndices",new Array),v(this,"indicesArray",new Array),v(this,"isConcaveArray",new Array),v(this,"triangles",new Array),v(this,"polygonPool",new B(()=>new Array)),v(this,"polygonIndicesPool",new B(()=>new Array))}triangulate(t){let e=t,s=t.length>>1,i=this.indicesArray;i.length=0;for(let t=0;t<s;t++)i[t]=t;let n=this.isConcaveArray;n.length=0;for(let t=0,r=s;t<r;++t)n[t]=fe.isConcave(t,s,e,i);let r=this.triangles;for(r.length=0;s>3;){let t=s-1,a=0,o=1;for(;;){t:if(!n[a]){let r=i[t]<<1,l=i[a]<<1,h=i[o]<<1,d=e[r],c=e[r+1],u=e[l],p=e[l+1],m=e[h],g=e[h+1];for(let r=(o+1)%s;r!=t;r=(r+1)%s){if(!n[r])continue;let t=i[r]<<1,s=e[t],a=e[t+1];if(fe.positiveArea(m,g,d,c,s,a)&&fe.positiveArea(d,c,u,p,s,a)&&fe.positiveArea(u,p,m,g,s,a))break t}break}if(0==o){do{if(!n[a])break;a--}while(a>0);break}t=a,a=o,o=(o+1)%s}r.push(i[(s+a-1)%s]),r.push(i[a]),r.push(i[(a+1)%s]),i.splice(a,1),n.splice(a,1),s--;let l=(s+a-1)%s,h=a==s?0:a;n[l]=fe.isConcave(l,s,e,i),n[h]=fe.isConcave(h,s,e,i)}return 3==s&&(r.push(i[2]),r.push(i[0]),r.push(i[1])),r}decompose(t,e){let s=t,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;let n=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(n),n.length=0;let r=this.polygonIndicesPool.obtain();r.length=0;let a=this.polygonPool.obtain();a.length=0;let o=-1,l=0;for(let t=0,h=e.length;t<h;t+=3){let h=e[t]<<1,d=e[t+1]<<1,c=e[t+2]<<1,u=s[h],p=s[h+1],m=s[d],g=s[d+1],f=s[c],x=s[c+1],w=!1;if(o==h){let t=a.length-4,e=fe.winding(a[t],a[t+1],a[t+2],a[t+3],f,x),s=fe.winding(f,x,a[0],a[1],a[2],a[3]);e==l&&s==l&&(a.push(f),a.push(x),r.push(c),w=!0)}w||(a.length>0?(i.push(a),n.push(r)):(this.polygonPool.free(a),this.polygonIndicesPool.free(r)),a=this.polygonPool.obtain(),a.length=0,a.push(u),a.push(p),a.push(m),a.push(g),a.push(f),a.push(x),r=this.polygonIndicesPool.obtain(),r.length=0,r.push(h),r.push(d),r.push(c),l=fe.winding(u,p,m,g,f,x),o=h)}a.length>0&&(i.push(a),n.push(r));for(let t=0,e=i.length;t<e;t++){if(r=n[t],0==r.length)continue;let s=r[0],o=r[r.length-1];a=i[t];let l=a.length-4,h=a[l],d=a[l+1],c=a[l+2],u=a[l+3],p=a[0],m=a[1],g=a[2],f=a[3],x=fe.winding(h,d,c,u,p,m);for(let l=0;l<e;l++){if(l==t)continue;let e=n[l];if(3!=e.length)continue;let w=e[0],b=e[1],y=e[2],E=i[l],T=E[E.length-2],A=E[E.length-1];if(w!=s||b!=o)continue;let S=fe.winding(h,d,c,u,T,A),C=fe.winding(T,A,p,m,g,f);S==x&&C==x&&(E.length=0,e.length=0,a.push(T),a.push(A),r.push(y),h=c,d=u,c=T,u=A,l=0)}}for(let t=i.length-1;t>=0;t--)a=i[t],0==a.length&&(i.splice(t,1),this.polygonPool.free(a),r=n[t],n.splice(t,1),this.polygonIndicesPool.free(r));return i}static isConcave(t,e,s,i){let n=i[(e+t-1)%e]<<1,r=i[t]<<1,a=i[(t+1)%e]<<1;return!this.positiveArea(s[n],s[n+1],s[r],s[r+1],s[a],s[a+1])}static positiveArea(t,e,s,i,n,r){return t*(r-i)+s*(e-r)+n*(i-e)>=0}static winding(t,e,s,i,n,r){let a=s-t,o=i-e;return n*o-r*a+a*e-t*o>=0?1:-1}}class xe{constructor(){v(this,"triangulator",new fe),v(this,"clippingPolygon",new Array),v(this,"clipOutput",new Array),v(this,"clippedVertices",new Array),v(this,"clippedUVs",new Array),v(this,"clippedTriangles",new Array),v(this,"scratch",new Array),v(this,"clipAttachment"),v(this,"clippingPolygons")}clipStart(t,e){if(null!=this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=X.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let n=this.clippingPolygon;xe.makeClockwise(n);let r=this.clippingPolygons=this.triangulator.decompose(n,this.triangulator.triangulate(n));for(let t=0,e=r.length;t<e;t++){let e=r[t];xe.makeClockwise(e),e.push(e[0]),e.push(e[1])}return r.length}clipEndWithSlot(t){null!=this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){null!=this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)}isClipping(){return null!=this.clipAttachment}clipTriangles(t,e,s,i,n,r,a,o){let l=this.clipOutput,h=this.clippedVertices,d=this.clippedTriangles,c=this.clippingPolygons,u=this.clippingPolygons.length,p=o?12:8,m=0;h.length=0,d.length=0;t:for(let e=0;e<i;e+=3){let i=s[e]<<1,g=t[i],f=t[i+1],x=n[i],w=n[i+1];i=s[e+1]<<1;let b=t[i],y=t[i+1],E=n[i],T=n[i+1];i=s[e+2]<<1;let A=t[i],S=t[i+1],C=n[i],v=n[i+1];for(let t=0;t<u;t++){let e=h.length;if(!this.clip(g,f,b,y,A,S,c[t],l)){let t=X.setArraySize(h,e+3*p);t[e]=g,t[e+1]=f,t[e+2]=r.r,t[e+3]=r.g,t[e+4]=r.b,t[e+5]=r.a,o?(t[e+6]=x,t[e+7]=w,t[e+8]=a.r,t[e+9]=a.g,t[e+10]=a.b,t[e+11]=a.a,t[e+12]=b,t[e+13]=y,t[e+14]=r.r,t[e+15]=r.g,t[e+16]=r.b,t[e+17]=r.a,t[e+18]=E,t[e+19]=T,t[e+20]=a.r,t[e+21]=a.g,t[e+22]=a.b,t[e+23]=a.a,t[e+24]=A,t[e+25]=S,t[e+26]=r.r,t[e+27]=r.g,t[e+28]=r.b,t[e+29]=r.a,t[e+30]=C,t[e+31]=v,t[e+32]=a.r,t[e+33]=a.g,t[e+34]=a.b,t[e+35]=a.a):(t[e+6]=x,t[e+7]=w,t[e+8]=b,t[e+9]=y,t[e+10]=r.r,t[e+11]=r.g,t[e+12]=r.b,t[e+13]=r.a,t[e+14]=E,t[e+15]=T,t[e+16]=A,t[e+17]=S,t[e+18]=r.r,t[e+19]=r.g,t[e+20]=r.b,t[e+21]=r.a,t[e+22]=C,t[e+23]=v),e=d.length;let s=X.setArraySize(d,e+3);s[e]=m,s[e+1]=m+1,s[e+2]=m+2,m+=3;continue t}{let t=l.length;if(0==t)continue;let s=y-S,i=A-b,n=g-A,c=S-f,u=1/(s*n+i*(f-S)),M=t>>1,R=this.clipOutput,k=X.setArraySize(h,e+M*p);for(let l=0;l<t;l+=2){let t=R[l],h=R[l+1];k[e]=t,k[e+1]=h,k[e+2]=r.r,k[e+3]=r.g,k[e+4]=r.b,k[e+5]=r.a;let d=t-A,m=h-S,g=(s*d+i*m)*u,f=(c*d+n*m)*u,b=1-g-f;k[e+6]=x*g+E*f+C*b,k[e+7]=w*g+T*f+v*b,o&&(k[e+8]=a.r,k[e+9]=a.g,k[e+10]=a.b,k[e+11]=a.a),e+=p}e=d.length;let P=X.setArraySize(d,e+3*(M-2));M--;for(let t=1;t<M;t++)P[e]=m,P[e+1]=m+t,P[e+2]=m+t+1,e+=3;m+=M+1}}}}clipTrianglesUnpacked(t,e,s,i){let n=this.clipOutput,r=this.clippedVertices,a=this.clippedUVs,o=this.clippedTriangles,l=this.clippingPolygons,h=l.length,d=0;r.length=0,a.length=0,o.length=0;for(let c=0;c<s;c+=3){let s=e[c]<<1,u=t[s],p=t[s+1],m=i[s],g=i[s+1];s=e[c+1]<<1;let f=t[s],x=t[s+1],w=i[s],b=i[s+1];s=e[c+2]<<1;let y=t[s],E=t[s+1],T=i[s],A=i[s+1];for(let t=0;t<h;t++){let e=r.length;if(!this.clip(u,p,f,x,y,E,l[t],n)){let t=X.setArraySize(r,e+6);t[e]=u,t[e+1]=p,t[e+2]=f,t[e+3]=x,t[e+4]=y,t[e+5]=E;let s=X.setArraySize(a,e+6);s[e]=m,s[e+1]=g,s[e+2]=w,s[e+3]=b,s[e+4]=T,s[e+5]=A,e=o.length;let i=X.setArraySize(o,e+3);i[e]=d,i[e+1]=d+1,i[e+2]=d+2,d+=3;break}{let t=n.length;if(0==t)continue;let s=x-E,i=y-f,l=u-y,h=E-p,c=1/(s*l+i*(p-E)),S=t>>1,C=this.clipOutput,v=X.setArraySize(r,e+2*S),M=X.setArraySize(a,e+2*S);for(let n=0;n<t;n+=2,e+=2){let t=C[n],r=C[n+1];v[e]=t,v[e+1]=r;let a=t-y,o=r-E,d=(s*a+i*o)*c,u=(h*a+l*o)*c,p=1-d-u;M[e]=m*d+w*u+T*p,M[e+1]=g*d+b*u+A*p}e=o.length;let R=X.setArraySize(o,e+3*(S-2));S--;for(let t=1;t<S;t++,e+=3)R[e]=d,R[e+1]=d+t,R[e+2]=d+t+1;d+=S+1}}}}clip(t,e,s,i,n,r,a,o){let l=o,h=!1,d=null;a.length%4>=2?(d=o,o=this.scratch):d=this.scratch,d.length=0,d.push(t),d.push(e),d.push(s),d.push(i),d.push(n),d.push(r),d.push(t),d.push(e),o.length=0;let c=a,u=a.length-4;for(let t=0;;t+=2){let e=c[t],s=c[t+1],i=c[t+2],n=c[t+3],r=e-i,a=s-n,p=d,m=d.length-2,g=o.length;for(let t=0;t<m;t+=2){let l=p[t],d=p[t+1],c=p[t+2],u=p[t+3],m=r*(u-n)-a*(c-i)>0;if(r*(d-n)-a*(l-i)>0){if(m){o.push(c),o.push(u);continue}let t=u-d,r=c-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s)}else if(m){let t=u-d,r=c-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s);o.push(c),o.push(u)}h=!0}if(g==o.length)return l.length=0,!0;if(o.push(o[0]),o.push(o[1]),t==u)break;let f=o;(o=d).length=0,d=f}if(l!=o){l.length=0;for(let t=0,e=o.length-2;t<e;t++)l[t]=o[t]}else l.length=l.length-2;return h}static makeClockwise(t){let e=t,s=t.length,i=e[s-2]*e[1]-e[0]*e[s-1],n=0,r=0,a=0,o=0;for(let t=0,l=s-3;t<l;t+=2)n=e[t],r=e[t+1],a=e[t+2],o=e[t+3],i+=n*o-a*r;if(!(i<0))for(let t=0,i=s-2,n=s>>1;t<n;t+=2){let s=e[t],n=e[t+1],r=i-t;e[t]=e[r],e[t+1]=e[r+1],e[r]=s,e[r+1]=n}}}class we{constructor(){v(this,"name"),v(this,"bones",new Array),v(this,"slots",new Array),v(this,"skins",new Array),v(this,"defaultSkin"),v(this,"events",new Array),v(this,"animations",new Array),v(this,"ikConstraints",new Array),v(this,"transformConstraints",new Array),v(this,"pathConstraints",new Array),v(this,"width"),v(this,"height"),v(this,"version"),v(this,"hash"),v(this,"fps",0),v(this,"imagesPath")}findBone(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSlot(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSkin(t){if(null==t)throw new Error("skinName cannot be null.");let e=this.skins;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findEvent(t){if(null==t)throw new Error("eventDataName cannot be null.");let e=this.events;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findAnimation(t){if(null==t)throw new Error("animationName cannot be null.");let e=this.animations;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findIkConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findTransformConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findPathConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findPathConstraintIndex(t){if(null==t)throw new Error("pathConstraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}}var be,ye,Ee=((be=Ee||{})[be.Normal=0]="Normal",be[be.Additive=1]="Additive",be[be.Multiply=2]="Multiply",be[be.Screen=3]="Screen",be);class Te{constructor(t){if(v(this,"name"),v(this,"attachments",new Array),null==t)throw new Error("name cannot be null.");this.name=t}addAttachment(t,e,s){if(null==s)throw new Error("attachment cannot be null.");let i=this.attachments;t>=i.length&&(i.length=t+1),i[t]||(i[t]={}),i[t][e]=s}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}attachAll(t,e){let s=0;for(let i=0;i<t.slots.length;i++){let n=t.slots[i],r=n.getAttachment();if(r&&s<e.attachments.length){let t=e.attachments[s];for(let e in t){if(r==t[e]){let t=this.getAttachment(s,e);null!=t&&n.setAttachment(t);break}}}s++}}}class Ae{constructor(t,e,s){if(v(this,"index"),v(this,"name"),v(this,"boneData"),v(this,"color",new _(1,1,1,1)),v(this,"darkColor"),v(this,"attachmentName"),v(this,"blendMode"),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");if(null==s)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}class Se{constructor(t){if(v(this,"name"),v(this,"order",0),v(this,"bones",new Array),v(this,"target"),v(this,"rotateMix",0),v(this,"translateMix",0),v(this,"scaleMix",0),v(this,"shearMix",0),v(this,"offsetRotation",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"offsetScaleX",0),v(this,"offsetScaleY",0),v(this,"offsetShearY",0),v(this,"relative",!1),v(this,"local",!1),null==t)throw new Error("name cannot be null.");this.name=t}}class Ce{constructor(t){v(this,"attachmentLoader"),v(this,"scale",1),v(this,"linkedMeshes",new Array),this.attachmentLoader=t}readSkeletonData(t){let e=this.scale,s=new we,i="string"==typeof t?JSON.parse(t):t,n=i.skeleton;if(null!=n&&(s.hash=n.hash,s.version=n.spine,s.width=n.width,s.height=n.height,s.fps=n.fps,s.imagesPath=n.images),i.bones)for(let t=0;t<i.bones.length;t++){let n=i.bones[t],r=null,a=this.getValue(n,"parent",null);if(null!=a&&(r=s.findBone(a),null==r))throw new Error("Parent bone not found: "+a);let o=new Lt(s.bones.length,n.name,r);o.length=this.getValue(n,"length",0)*e,o.x=this.getValue(n,"x",0)*e,o.y=this.getValue(n,"y",0)*e,o.rotation=this.getValue(n,"rotation",0),o.scaleX=this.getValue(n,"scaleX",1),o.scaleY=this.getValue(n,"scaleY",1),o.shearX=this.getValue(n,"shearX",0),o.shearY=this.getValue(n,"shearY",0),o.transformMode=Ce.transformModeFromString(this.getValue(n,"transform","normal")),s.bones.push(o)}if(i.slots)for(let t=0;t<i.slots.length;t++){let e=i.slots[t],n=e.name,r=e.bone,a=s.findBone(r);if(null==a)throw new Error("Slot bone not found: "+r);let o=new Ae(s.slots.length,n,a),l=this.getValue(e,"color",null);null!=l&&o.color.setFromString(l);let h=this.getValue(e,"dark",null);null!=h&&(o.darkColor=new _(1,1,1,1),o.darkColor.setFromString(h)),o.attachmentName=this.getValue(e,"attachment",null),o.blendMode=Ce.blendModeFromString(this.getValue(e,"blend","normal")),s.slots.push(o)}if(i.ik)for(let t=0;t<i.ik.length;t++){let e=i.ik[t],n=new se(e.name);n.order=this.getValue(e,"order",0);for(let t=0;t<e.bones.length;t++){let i=e.bones[t],r=s.findBone(i);if(null==r)throw new Error("IK bone not found: "+i);n.bones.push(r)}let r=e.target;if(n.target=s.findBone(r),null==n.target)throw new Error("IK target bone not found: "+r);n.bendDirection=this.getValue(e,"bendPositive",!0)?1:-1,n.mix=this.getValue(e,"mix",1),s.ikConstraints.push(n)}if(i.transform)for(let t=0;t<i.transform.length;t++){let n=i.transform[t],r=new Se(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findBone(a),null==r.target)throw new Error("Transform constraint target bone not found: "+a);r.local=this.getValue(n,"local",!1),r.relative=this.getValue(n,"relative",!1),r.offsetRotation=this.getValue(n,"rotation",0),r.offsetX=this.getValue(n,"x",0)*e,r.offsetY=this.getValue(n,"y",0)*e,r.offsetScaleX=this.getValue(n,"scaleX",0),r.offsetScaleY=this.getValue(n,"scaleY",0),r.offsetShearY=this.getValue(n,"shearY",0),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),r.scaleMix=this.getValue(n,"scaleMix",1),r.shearMix=this.getValue(n,"shearMix",1),s.transformConstraints.push(r)}if(i.path)for(let t=0;t<i.path.length;t++){let n=i.path[t],r=new ie(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findSlot(a),null==r.target)throw new Error("Path target slot not found: "+a);r.positionMode=Ce.positionModeFromString(this.getValue(n,"positionMode","percent")),r.spacingMode=Ce.spacingModeFromString(this.getValue(n,"spacingMode","length")),r.rotateMode=Ce.rotateModeFromString(this.getValue(n,"rotateMode","tangent")),r.offsetRotation=this.getValue(n,"rotation",0),r.position=this.getValue(n,"position",0),r.positionMode==oe.Fixed&&(r.position*=e),r.spacing=this.getValue(n,"spacing",0),r.spacingMode!=le.Length&&r.spacingMode!=le.Fixed||(r.spacing*=e),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),s.pathConstraints.push(r)}if(i.skins)for(let t in i.skins){let e=i.skins[t],n=new Te(t);for(let t in e){let i=s.findSlotIndex(t);if(-1==i)throw new Error("Slot not found: "+t);let r=e[t];for(let t in r){let e=this.readAttachment(r[t],n,i,t,s);null!=e&&n.addAttachment(i,t,e)}}s.skins.push(n),"default"==n.name&&(s.defaultSkin=n)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],i=null==e.skin?s.defaultSkin:s.findSkin(e.skin);if(null==i)throw new Error("Skin not found: "+e.skin);let n=i.getAttachment(e.slotIndex,e.parent);if(null==n)throw new Error("Parent mesh not found: "+e.parent);e.mesh.setParentMesh(n),e.mesh.updateUVs()}if(this.linkedMeshes.length=0,i.events)for(let t in i.events){let e=i.events[t],n=new te(t);n.intValue=this.getValue(e,"int",0),n.floatValue=this.getValue(e,"float",0),n.stringValue=this.getValue(e,"string",""),s.events.push(n)}if(i.animations)for(let t in i.animations){let e=i.animations[t];this.readAnimation(e,t,s)}return s}readAttachment(t,e,s,i,n){let r=this.scale;switch(i=this.getValue(t,"name",i),this.getValue(t,"type","region")){case"region":{let s=this.getValue(t,"path",i),n=this.attachmentLoader.newRegionAttachment(e,i,s);if(null==n)return null;n.path=s,n.x=this.getValue(t,"x",0)*r,n.y=this.getValue(t,"y",0)*r,n.scaleX=this.getValue(t,"scaleX",1),n.scaleY=this.getValue(t,"scaleY",1),n.rotation=this.getValue(t,"rotation",0),n.width=t.width*r,n.height=t.height*r;let a=this.getValue(t,"color",null);return null!=a&&n.color.setFromString(a),n.updateOffset(),n}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(null==s)return null;this.readVertices(t,s,t.vertexCount<<1);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"mesh":case"linkedmesh":{let n=this.getValue(t,"path",i),r=this.attachmentLoader.newMeshAttachment(e,i,n);if(null==r)return null;r.path=n;let a=this.getValue(t,"color",null);null!=a&&r.color.setFromString(a);let o=this.getValue(t,"parent",null);if(null!=o)return r.inheritDeform=this.getValue(t,"deform",!0),this.linkedMeshes.push(new ve(r,this.getValue(t,"skin",null),s,o)),r;let l=t.uvs;return this.readVertices(t,r,l.length),r.triangles=t.triangles,r.regionUVs=l,r.updateUVs(),r.hullLength=2*this.getValue(t,"hull",0),r}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(null==s)return null;s.closed=this.getValue(t,"closed",!1),s.constantSpeed=this.getValue(t,"constantSpeed",!0);let n=t.vertexCount;this.readVertices(t,s,n<<1);let a=X.newArray(n/3,0);for(let e=0;e<t.lengths.length;e++)a[e]=t.lengths[e]*r;s.lengths=a;let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(null==s)return null;s.x=this.getValue(t,"x",0)*r,s.y=this.getValue(t,"y",0)*r,s.rotation=this.getValue(t,"rotation",0);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(null==s)return null;let r=this.getValue(t,"end",null);if(null!=r){let t=n.findSlot(r);if(null==t)throw new Error("Clipping end slot not found: "+r);s.endSlot=t}let a=t.vertexCount;this.readVertices(t,s,a<<1);let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}}return null}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let n=t.vertices;if(s==n.length){let t=X.toFloatArray(n);if(1!=i)for(let e=0,s=n.length;e<s;e++)t[e]*=i;return void(e.vertices=t)}let r=new Array,a=new Array;for(let t=0,e=n.length;t<e;){let e=n[t++];a.push(e);for(let s=t+4*e;t<s;t+=4)a.push(n[t]),r.push(n[t+1]*i),r.push(n[t+2]*i),r.push(n[t+3])}e.bones=a,e.vertices=X.toFloatArray(r)}readAnimation(t,e,s){let i=this.scale,n=new Array,r=0;if(t.slots)for(let e in t.slots){let i=t.slots[e],a=s.findSlotIndex(e);if(-1==a)throw new Error("Slot not found: "+e);for(let t in i){let s=i[t];if("attachment"==t){let t=new lt(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e++,n.time,n.name)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}else if("color"==t){let t=new rt(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new _;r.setFromString(n.color),t.setFrame(e,n.time,r.r,r.g,r.b,r.a),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*rt.ENTRIES])}else{if("twoColor"!=t)throw new Error("Invalid timeline type for a slot: "+t+" ("+e+")");{let t=new ot(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new _,a=new _;r.setFromString(n.light),a.setFromString(n.dark),t.setFrame(e,n.time,r.r,r.g,r.b,r.a,a.r,a.g,a.b),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*ot.ENTRIES])}}}}if(t.bones)for(let e in t.bones){let a=t.bones[e],o=s.findBoneIndex(e);if(-1==o)throw new Error("Bone not found: "+e);for(let t in a){let s=a[t];if("rotate"===t){let t=new K(s.length);t.boneIndex=o;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e,n.time,n.angle),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*K.ENTRIES])}else{if("translate"!==t&&"scale"!==t&&"shear"!==t)throw new Error("Invalid timeline type for a bone: "+t+" ("+e+")");{let e=null,a=1;"scale"===t?e=new st(s.length):"shear"===t?e=new it(s.length):(e=new et(s.length),a=i),e.boneIndex=o;let l=0;for(let t=0;t<s.length;t++){let i=s[t],n=this.getValue(i,"x",0),r=this.getValue(i,"y",0);e.setFrame(l,i.time,n*a,r*a),this.readCurve(i,e,l),l++}n.push(e),r=Math.max(r,e.frames[(e.getFrameCount()-1)*et.ENTRIES])}}}}if(t.ik)for(let e in t.ik){let i=t.ik[e],a=s.findIkConstraint(e),o=new mt(i.length);o.ikConstraintIndex=s.ikConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"mix",1),this.getValue(e,"bendPositive",!0)?1:-1),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*mt.ENTRIES])}if(t.transform)for(let e in t.transform){let i=t.transform[e],a=s.findTransformConstraint(e),o=new ft(i.length);o.transformConstraintIndex=s.transformConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"rotateMix",1),this.getValue(e,"translateMix",1),this.getValue(e,"scaleMix",1),this.getValue(e,"shearMix",1)),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*ft.ENTRIES])}if(t.paths)for(let e in t.paths){let a=t.paths[e],o=s.findPathConstraintIndex(e);if(-1==o)throw new Error("Path constraint not found: "+e);let l=s.pathConstraints[o];for(let t in a){let e=a[t];if("position"===t||"spacing"===t){let s=null,a=1;"spacing"===t?(s=new bt(e.length),l.spacingMode!=le.Length&&l.spacingMode!=le.Fixed||(a=i)):(s=new wt(e.length),l.positionMode==oe.Fixed&&(a=i)),s.pathConstraintIndex=o;let h=0;for(let i=0;i<e.length;i++){let n=e[i];s.setFrame(h,n.time,this.getValue(n,t,0)*a),this.readCurve(n,s,h),h++}n.push(s),r=Math.max(r,s.frames[(s.getFrameCount()-1)*wt.ENTRIES])}else if("mix"===t){let t=new Et(e.length);t.pathConstraintIndex=o;let s=0;for(let i=0;i<e.length;i++){let n=e[i];t.setFrame(s,n.time,this.getValue(n,"rotateMix",1),this.getValue(n,"translateMix",1)),this.readCurve(n,t,s),s++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*Et.ENTRIES])}}}if(t.deform)for(let e in t.deform){let a=t.deform[e],o=s.findSkin(e);if(null==o)throw new Error("Skin not found: "+e);for(let t in a){let e=a[t],l=s.findSlotIndex(t);if(-1==l)throw new Error("Slot not found: "+e.name);for(let t in e){let s=e[t],a=o.getAttachment(l,t);if(null==a)throw new Error("Deform attachment not found: "+s.name);let h=null!=a.bones,d=a.vertices,c=h?d.length/3*2:d.length,u=new dt(s.length);u.slotIndex=l,u.attachment=a;let p=0;for(let t=0;t<s.length;t++){let e,n=s[t],r=this.getValue(n,"vertices",null);if(null==r)e=h?X.newFloatArray(c):d;else{e=X.newFloatArray(c);let t=this.getValue(n,"offset",0);if(X.arrayCopy(r,0,e,t,r.length),1!=i)for(let s=t,n=s+r.length;s<n;s++)e[s]*=i;if(!h)for(let t=0;t<c;t++)e[t]+=d[t]}u.setFrame(p,n.time,e),this.readCurve(n,u,p),p++}n.push(u),r=Math.max(r,u.frames[u.getFrameCount()-1])}}}let a=t.drawOrder;if(null==a&&(a=t.draworder),null!=a){let t=new ut(a.length),e=s.slots.length,i=0;for(let n=0;n<a.length;n++){let r=a[n],o=null,l=this.getValue(r,"offsets",null);if(null!=l){o=X.newArray(e,-1);let t=X.newArray(e-l.length,0),i=0,n=0;for(let e=0;e<l.length;e++){let r=l[e],a=s.findSlotIndex(r.slot);if(-1==a)throw new Error("Slot not found: "+r.slot);for(;i!=a;)t[n++]=i++;o[i+r.offset]=i++}for(;i<e;)t[n++]=i++;for(let s=e-1;s>=0;s--)-1==o[s]&&(o[s]=t[--n])}t.setFrame(i++,r.time,o)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}if(t.events){let e=new ct(t.events.length),i=0;for(let n=0;n<t.events.length;n++){let r=t.events[n],a=s.findEvent(r.name);if(null==a)throw new Error("Event not found: "+r.name);let o=new Kt(X.toSinglePrecision(r.time),a);o.intValue=this.getValue(r,"int",a.intValue),o.floatValue=this.getValue(r,"float",a.floatValue),o.stringValue=this.getValue(r,"string",a.stringValue),e.setFrame(i++,o)}n.push(e),r=Math.max(r,e.frames[e.getFrameCount()-1])}if(isNaN(r))throw new Error("Error while parsing animation, duration is NaN");s.animations.push(new W(e,n,r))}readCurve(t,e,s){if(t.curve)if("stepped"===t.curve)e.setStepped(s);else if("[object Array]"===Object.prototype.toString.call(t.curve)){let i=t.curve;e.setCurve(s,i[0],i[1],i[2],i[3])}}getValue(t,e,s){return void 0!==t[e]?t[e]:s}static blendModeFromString(t){if("normal"==(t=t.toLowerCase()))return Ee.Normal;if("additive"==t)return Ee.Additive;if("multiply"==t)return Ee.Multiply;if("screen"==t)return Ee.Screen;throw new Error(`Unknown blend mode: ${t}`)}static positionModeFromString(t){if("fixed"==(t=t.toLowerCase()))return oe.Fixed;if("percent"==t)return oe.Percent;throw new Error(`Unknown position mode: ${t}`)}static spacingModeFromString(t){if("length"==(t=t.toLowerCase()))return le.Length;if("fixed"==t)return le.Fixed;if("percent"==t)return le.Percent;throw new Error(`Unknown position mode: ${t}`)}static rotateModeFromString(t){if("tangent"==(t=t.toLowerCase()))return he.Tangent;if("chain"==t)return he.Chain;if("chainscale"==t)return he.ChainScale;throw new Error(`Unknown rotate mode: ${t}`)}static transformModeFromString(t){if("normal"==(t=t.toLowerCase()))return Ft.Normal;if("onlytranslation"==t)return Ft.OnlyTranslation;if("norotationorreflection"==t)return Ft.NoRotationOrReflection;if("noscale"==t)return Ft.NoScale;if("noscaleorreflection"==t)return Ft.NoScaleOrReflection;throw new Error(`Unknown transform mode: ${t}`)}}class ve{constructor(t,e,s,i){v(this,"parent"),v(this,"skin"),v(this,"slotIndex"),v(this,"mesh"),this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i}}Math.fround||(Math.fround=(ye=new Float32Array(1),function(t){return ye[0]=t,ye[0]}));class Me{constructor(t){v(this,"clientId"),v(this,"toLoad",new Array),v(this,"assets",{}),v(this,"textureLoader"),this.clientId=t}loaded(){var t=0;for(var e in this.assets)t++;return t}}const Re=class t{constructor(t){v(this,"centerX",0),v(this,"centerY",0),v(this,"radius",0),v(this,"angle",0),v(this,"worldX",0),v(this,"worldY",0),this.radius=t}begin(t){this.worldX=t.x+this.centerX,this.worldY=t.y+this.centerY}transform(e,s,i,n){let r=this.angle*N.degreesToRadians,a=e.x-this.worldX,o=e.y-this.worldY,l=Math.sqrt(a*a+o*o);if(l<this.radius){let s=t.interpolation.apply(0,r,(this.radius-l)/this.radius),i=Math.cos(s),n=Math.sin(s);e.x=i*a-n*o+this.worldX,e.y=n*a+i*o+this.worldY}}end(){}};v(Re,"interpolation",new Y(2));let ke=Re;const Pe=class t extends Bt{constructor(t){super(t.resource),v(this,"texture"),this.texture=i.Texture.from(t)}static from(e){return t.textureMap.has(e)?t.textureMap.get(e):new t(e)}setFilters(e,s){if(!this.texture||!this.texture.source||!this.texture.source.style)return;const i=this.texture.source.style;i.minFilter=t.toPixiTextureFilter(e),i.magFilter=t.toPixiTextureFilter(s),this.texture.source.autoGenerateMipmaps=t.toPixiMipMap(e),this.texture.source.updateMipmaps()}setWraps(e,s){if(!this.texture||!this.texture.source||!this.texture.source.style)return;const i=this.texture.source.style;i.addressModeU=t.toPixiTextureWrap(e),i.addressModeV=t.toPixiTextureWrap(s)}dispose(){this.texture.destroy()}static toPixiMipMap(t){switch(t){case Ut.Nearest:case Ut.Linear:return!1;case Ut.MipMapNearestLinear:case Ut.MipMapNearestNearest:case Ut.MipMapLinearLinear:case Ut.MipMapLinearNearest:return!0;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureFilter(t){switch(t){case Ut.Nearest:case Ut.MipMapNearestLinear:case Ut.MipMapNearestNearest:return"nearest";case Ut.Linear:case Ut.MipMapLinearLinear:case Ut.MipMapLinearNearest:return"linear";default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureWrap(t){switch(t){case qt.ClampToEdge:return"clamp-to-edge";case qt.MirroredRepeat:return"mirror-repeat";case qt.Repeat:return"repeat";default:throw new Error(`Unknown texture wrap: ${String(t)}`)}}static toPixiBlending(t){switch(t){case Ee.Normal:return"normal";case Ee.Additive:return"add";case Ee.Multiply:return"multiply";case Ee.Screen:return"screen";default:throw new Error(`Unknown blendMode: ${String(t)}`)}}};v(Pe,"textureMap",new Map);let Ie=Pe;const Ve={extension:i.ExtensionType.Asset,resolver:{test:t=>i.checkExtension(t,".atlas"),parse:t=>{var e,s,n;const r=t.split(".");return{resolution:parseFloat(null!=(n=null==(s=null==(e=i.Resolver.RETINA_PREFIX)?void 0:e.exec(t))?void 0:s[1])?n:"1"),format:r[r.length-2],src:t}}},loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineTextureAtlasLoader"},test:t=>i.checkExtension(t,".atlas"),load(t){return M(this,null,function*(){const e=yield i.DOMAdapter.get().fetch(t);return yield e.text()})},testParse(t,e){const s=i.checkExtension(e.src,".atlas"),n="string"==typeof t;return Promise.resolve(s&&n)},unload(t){t.dispose()},parse(t,e,s){return M(this,null,function*(){var n;const r=e.data||{};let a=i.path.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");const o=new zt(t,t=>Ie.from(e.data.imageTexture.source));if(r.images instanceof i.TextureSource||"string"==typeof r.images){const t=r.images;r.images={},r.images[o.pages[0].name]=t}const l=[];for(const t of o.pages){if(r.resolve){const e=null==(n=r.resolve())?void 0:n.then(e=>{e&&t.setTexture(Ie.from(e.source))});l.push(e);continue}const o=t.name,h=(null==r?void 0:r.images)?r.images[o]:void 0;if(h instanceof i.TextureSource)t.setTexture(Ie.from(h));else{const n=null!=h?h:i.path.normalize([...a.split(i.path.sep),o].join(i.path.sep)),d={src:i.copySearchParams(n,e.src),data:C(S({},r.imageMetadata),{alphaMode:t.pma?"premultiplied-alpha":"premultiply-alpha-on-upload"})},c=s.load(d).then(e=>{t.setTexture(Ie.from(e.source))});l.push(c)}}return yield Promise.all(l),o})}}};i.extensions.add(Ve);const _e={extension:i.ExtensionType.Asset,loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineSkeletonLoader"},test:t=>i.checkExtension(t,".skel"),load(t){return M(this,null,function*(){const e=yield i.DOMAdapter.get().fetch(t);return new Uint8Array(yield e.arrayBuffer())})},testParse(t,e){const s=i.checkExtension(e.src,".json")&&(n=t,Object.prototype.hasOwnProperty.call(n,"bones"));var n;const r=i.checkExtension(e.src,".skel")&&function(t){return t instanceof Uint8Array}(t);return Promise.resolve(s||r)}}};i.extensions.add(_e);const De=new Float32Array(1),Ne=new Uint32Array(1);class Oe extends i.Geometry{constructor(){const t=new i.Buffer({data:De,label:"attribute-batch-buffer",usage:i.BufferUsage.VERTEX|i.BufferUsage.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:28,offset:0},aUV:{buffer:t,format:"float32x2",stride:28,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:28,offset:16},aDarkColor:{buffer:t,format:"unorm8x4",stride:28,offset:20},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:28,offset:24}},indexBuffer:new i.Buffer({data:Ne,label:"index-batch-buffer",usage:i.BufferUsage.INDEX|i.BufferUsage.COPY_DST,shrinkToFit:!1})})}}const Le={name:"color-bit",vertex:{header:"\n @in aDarkColor: vec4<f32>;\n @out vDarkColor: vec4<f32>;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n @in vDarkColor: vec4<f32>;\n ",end:"\n\n let alpha = outColor.a * vColor.a;\n let rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n\n finalColor = vec4<f32>(rgb, alpha);\n\n "}},Ye={name:"color-bit",vertex:{header:"\n in vec4 aDarkColor;\n out vec4 vDarkColor;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n in vec4 vDarkColor;\n ",end:"\n\n finalColor.a = outColor.a * vColor.a;\n finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n "}};class Fe extends i.Shader{constructor(t){super({glProgram:i.compileHighShaderGlProgram({name:"dark-tint-batch",bits:[i.colorBitGl,Ye,i.generateTextureBatchBitGl(t),i.roundPixelsBitGl]}),gpuProgram:i.compileHighShaderGpuProgram({name:"dark-tint-batch",bits:[i.colorBit,Le,i.generateTextureBatchBit(t),i.roundPixelsBit]}),resources:{batchSamplers:i.getBatchSamplersUniformGroup(t)}})}}let Xe=null;const Be=class t extends i.Batcher{constructor(){super(...arguments),v(this,"geometry",new Oe),v(this,"shader",Xe||(Xe=new Fe(this.maxTextures))),v(this,"name",t.extension.name),v(this,"vertexSize",7)}packAttributes(t,e,s,n,r){const a=r<<16|65535&t.roundPixels,o=t.transform,l=o.a,h=o.b,d=o.c,c=o.d,u=o.tx,p=o.ty,{positions:m,uvs:g}=t,f=t.color,x=(f>>24&255)/255,w=i.Color.shared.setValue(t.darkColor).premultiply(x,!0).toPremultiplied(1,!1),b=t.attributeOffset,y=b+t.attributeSize;for(let t=b;t<y;t++){const i=2*t,r=m[i],o=m[i+1];e[n++]=l*r+d*o+u,e[n++]=c*o+h*r+p,e[n++]=g[i],e[n++]=g[i+1],s[n++]=f,s[n++]=w,s[n++]=a}}packQuadAttributes(t,e,s,i,n){const r=t.texture,a=t.transform,o=a.a,l=a.b,h=a.c,d=a.d,c=a.tx,u=a.ty,p=t.bounds,m=p.maxX,g=p.minX,f=p.maxY,x=p.minY,w=r.uvs,b=t.color,y=t.darkColor,E=n<<16|65535&t.roundPixels;e[i+0]=o*g+h*x+c,e[i+1]=d*x+l*g+u,e[i+2]=w.x0,e[i+3]=w.y0,s[i+4]=b,s[i+5]=y,s[i+6]=E,e[i+7]=o*m+h*x+c,e[i+8]=d*x+l*m+u,e[i+9]=w.x1,e[i+10]=w.y1,s[i+11]=b,s[i+12]=y,s[i+13]=E,e[i+14]=o*m+h*f+c,e[i+15]=d*f+l*m+u,e[i+16]=w.x2,e[i+17]=w.y2,s[i+18]=b,s[i+19]=y,s[i+20]=E,e[i+21]=o*g+h*f+c,e[i+22]=d*f+l*g+u,e[i+23]=w.x3,e[i+24]=w.y3,s[i+25]=b,s[i+26]=y,s[i+27]=E}};v(Be,"extension",{type:[i.ExtensionType.Batcher],name:"darkTint"});let je=Be;i.extensions.add(je);const We=class t{constructor(t){v(this,"ctx"),v(this,"clipper",new xe),v(this,"triangleRendering",!1),v(this,"debugRendering",!1),v(this,"vertices",X.newFloatArray(8192)),v(this,"tempColor",new _),this.ctx=t}draw(t){this.triangleRendering?this.drawTriangles(t):this.drawImages(t)}drawImages(t){let e=this.ctx,s=t.drawOrder;this.debugRendering&&(e.strokeStyle="green"),e.save();for(let t=0,i=s.length;t<i;t++){let i=s[t],n=i.getAttachment(),r=null,a=null,o=null;if(!(n instanceof Nt))continue;r=n,a=r.region,o=a.texture.getImage();let l=i.bone.skeleton.color,h=i.color,d=r.color,c=l.a*h.a*d.a,u=this.tempColor;u.set(l.r*h.r*d.r,l.g*h.g*d.g,l.b*h.b*d.b,c);let p=n,m=i.bone,g=a.width,f=a.height;e.save(),e.transform(m.a,m.c,m.b,m.d,m.worldX,m.worldY),e.translate(n.offset[0],n.offset[1]),e.rotate(n.rotation*Math.PI/180);let x=p.width/g;if(e.scale(x*n.scaleX,x*n.scaleY),e.translate(g/2,f/2),n.region.rotate){let t=g;g=f,f=t,e.rotate(-Math.PI/2)}e.scale(1,-1),e.translate(-g/2,-f/2),e.globalAlpha=u.a,e.drawImage(o,a.x,a.y,g,f,0,0,g,f),this.debugRendering&&e.strokeRect(0,0,g,f),e.restore()}e.restore()}drawTriangles(e){let s=this.vertices,i=null,n=e.drawOrder,r=this.clipper;for(let e=0,o=n.length;e<o;e++){let o=n[e],l=o.getAttachment(),h=null,d=null;if(l instanceof Pt)r.clipStart(o,l);else{if(l instanceof Nt){let e=l;s=this.computeRegionVertices(o,e,!1),i=t.QUAD_TRIANGLES,d=e.region,h=d.texture.getImage()}else{if(!(l instanceof It)){r.clipEndWithSlot(o);continue}{let t=l;s=this.computeMeshVertices(o,t,!1),i=t.triangles,h=t.region.renderObject.texture.getImage()}}if(null!=h){o.data.blendMode;let t=o.bone.skeleton.color,e=o.color,n=l.color,d=t.a*e.a*n.a,c=this.tempColor;c.set(t.r*e.r*n.r,t.g*e.g*n.g,t.b*e.b*n.b,d);let u=this.ctx;if(u.globalAlpha=c.a,r.isClipping()){let t=s.length/8,e=new Float32Array(2*t),n=new Float32Array(2*t);for(let i=0;i<t;i++)e[2*i]=s[8*i],e[2*i+1]=s[8*i+1],n[2*i]=s[8*i+6],n[2*i+1]=s[8*i+7];r.clipTrianglesUnpacked(e,i,i.length,n);let o=r.clippedVertices,l=r.clippedUVs,d=r.clippedTriangles;for(var a=0;a<d.length;a+=3){let t=2*d[a],e=2*d[a+1],s=2*d[a+2],i=o[t],n=o[t+1],r=l[t],c=l[t+1],p=o[e],m=o[e+1],g=l[e],f=l[e+1],x=o[s],w=o[s+1],b=l[s],y=l[s+1];this.drawTriangle(h,i,n,r,c,p,m,g,f,x,w,b,y),this.debugRendering&&(u.strokeStyle="green",u.beginPath(),u.moveTo(i,n),u.lineTo(p,m),u.lineTo(x,w),u.lineTo(i,n),u.stroke())}}else for(a=0;a<i.length;a+=3){let t=8*i[a],e=8*i[a+1],n=8*i[a+2],r=s[t],o=s[t+1],l=s[t+6],d=s[t+7],c=s[e],p=s[e+1],m=s[e+6],g=s[e+7],f=s[n],x=s[n+1],w=s[n+6],b=s[n+7];this.drawTriangle(h,r,o,l,d,c,p,m,g,f,x,w,b),this.debugRendering&&(u.strokeStyle="green",u.beginPath(),u.moveTo(r,o),u.lineTo(c,p),u.lineTo(f,x),u.lineTo(r,o),u.stroke())}}r.clipEndWithSlot(o)}}r.clipEnd(),this.ctx.globalAlpha=1}drawTriangle(t,e,s,i,n,r,a,o,l,h,d,c,u){let p=this.ctx;i*=t.width,n*=t.height,o*=t.width,l*=t.height,c*=t.width,u*=t.height,p.beginPath(),p.moveTo(e,s),p.lineTo(r,a),p.lineTo(h,d),p.closePath();var m=1/((o-=i)*(u-=n)-(c-=i)*(l-=n)),g=(u*(r-=e)-l*(h-=e))*m,f=(u*(a-=s)-l*(d-=s))*m,x=(o*h-c*r)*m,w=(o*d-c*a)*m,b=e-g*i-x*n,y=s-f*i-w*n;p.save(),p.transform(g,f,x,w,b,y),p.clip(),p.drawImage(t,0,0),p.restore()}computeRegionVertices(e,s,i){let n=e.bone.skeleton.color,r=e.color,a=s.color,o=n.a*r.a*a.a,l=i?o:1,h=this.tempColor;h.set(n.r*r.r*a.r*l,n.g*r.g*a.g*l,n.b*r.b*a.b*l,o),s.computeWorldVertices(e.bone,this.vertices,0,t.VERTEX_SIZE);let d=this.vertices,c=s.uvs;return d[Nt.C1R]=h.r,d[Nt.C1G]=h.g,d[Nt.C1B]=h.b,d[Nt.C1A]=h.a,d[Nt.U1]=c[0],d[Nt.V1]=c[1],d[Nt.C2R]=h.r,d[Nt.C2G]=h.g,d[Nt.C2B]=h.b,d[Nt.C2A]=h.a,d[Nt.U2]=c[2],d[Nt.V2]=c[3],d[Nt.C3R]=h.r,d[Nt.C3G]=h.g,d[Nt.C3B]=h.b,d[Nt.C3A]=h.a,d[Nt.U3]=c[4],d[Nt.V3]=c[5],d[Nt.C4R]=h.r,d[Nt.C4G]=h.g,d[Nt.C4B]=h.b,d[Nt.C4A]=h.a,d[Nt.U4]=c[6],d[Nt.V4]=c[7],d}computeMeshVertices(e,s,i){let n=e.bone.skeleton.color,r=e.color,a=s.color,o=n.a*r.a*a.a,l=i?o:1,h=this.tempColor;h.set(n.r*r.r*a.r*l,n.g*r.g*a.g*l,n.b*r.b*a.b*l,o);let d=s.worldVerticesLength/2;this.vertices.length<s.worldVerticesLength&&(this.vertices=X.newFloatArray(s.worldVerticesLength));let c=this.vertices;s.computeWorldVertices(e,0,s.worldVerticesLength,c,0,t.VERTEX_SIZE);let u=s.uvs;for(let t=0,e=d,s=0,i=2;t<e;t++)c[i++]=h.r,c[i++]=h.g,c[i++]=h.b,c[i++]=h.a,c[i++]=u[s++],c[i++]=u[s++],i+=2;return c}};v(We,"QUAD_TRIANGLES",[0,1,2,2,3,0]),v(We,"VERTEX_SIZE",8);let Ue=We;class qe{constructor(){v(this,"indexOffset",0),v(this,"attributeOffset",0),v(this,"indexSize"),v(this,"attributeSize"),v(this,"batcherName","darkTint"),v(this,"topology","triangle-list"),v(this,"packAsQuad",!1),v(this,"renderable"),v(this,"positions"),v(this,"indices"),v(this,"uvs"),v(this,"roundPixels"),v(this,"data"),v(this,"blendMode"),v(this,"darkTint"),v(this,"texture"),v(this,"transform"),v(this,"_textureId"),v(this,"_attributeStart"),v(this,"_indexStart"),v(this,"_batcher"),v(this,"_batch")}get color(){const t=this.data.color,e=this.renderable.groupColor,s=this.renderable.groupAlpha;let i;const n=t.a*s*255;if(16777215!==e){const s=e>>16&255,r=e>>8&255,a=255&e,o=t.r*a,l=t.g*r;i=n<<24|t.b*s<<16|l<<8|o}else i=n<<24|255*t.b<<16|255*t.g<<8|255*t.r;return i}get darkColor(){const t=this.data.darkColor;return 255*t.b<<16|255*t.g<<8|255*t.r}get groupTransform(){return this.renderable.groupTransform}setData(t,e,s,i){if(this.renderable=t,this.transform=t.groupTransform,this.data=e,e.clipped){const t=e.clippedData;this.indexSize=t.indicesCount,this.attributeSize=t.vertexCount,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs}else this.indexSize=e.indices.length,this.attributeSize=e.vertices.length/2,this.positions=e.vertices,this.indices=e.indices,this.uvs=e.uvs;this.texture=e.texture,this.roundPixels=i,this.blendMode=s,this.batcherName=e.darkTint?"darkTint":"default"}}const Ge={0:"normal",1:"add",2:"multiply",3:"screen"};class $e{constructor(t){v(this,"renderer"),v(this,"canvasSkeletonRenderer"),v(this,"gpuSpineData",{}),v(this,"_destroyRenderableBound",this.destroyRenderable.bind(this)),this.renderer=t}validateRenderable(t){if(this.renderer.type===i.RendererType.CANVAS)return!0;if(t._validateAndTransformAttachments(),t.spineAttachmentsDirty)return!0;if(t.spineTexturesDirty){const e=t.skeleton.drawOrder,s=this.gpuSpineData[t.uid];for(let i=0,n=e.length;i<n;i++){const n=e[i],r=n.getAttachment();if(r instanceof Nt||r instanceof It){const e=t._getCachedData(n,r),i=s.slotBatches[e.id],a=e.texture;if(a!==(null==i?void 0:i.texture)&&!(null==i?void 0:i._batcher.checkAndUpdateTexture(i,a)))return!0}}}return!1}execute(t){if(this.renderer.type===i.RendererType.CANVAS){const e=this.renderer,s=(t.groupColorAlpha>>>24&255)/255,i=e.canvasContext,n=i.activeContext;n.save(),this.canvasSkeletonRenderer||(this.canvasSkeletonRenderer=new Ue(n),this.canvasSkeletonRenderer.triangleRendering=!0),i.setContextTransform(t.groupTransform,1===(e._roundPixels|t._roundPixels));const r=t.skeleton.color.a;t.skeleton.color.a*=s,this.canvasSkeletonRenderer.draw(t.skeleton),t.skeleton.color.a=r,n.restore()}}addRenderable(t,e){var s,n;if(this.renderer.type===i.RendererType.CANVAS)return this.renderer.renderPipes.batch.break(e),void e.add(t);const r=this._getSpineData(t),a=this.renderer.renderPipes.batch,o=t.skeleton.drawOrder,l=this.renderer._roundPixels|t._roundPixels;t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;for(let i=0,h=o.length;i<h;i++){const h=o[i],d=h.getAttachment(),c=Ge[h.data.blendMode];let u=!1;if(d instanceof Nt||d instanceof It){const i=t._getCachedData(h,d),o=(s=r.slotBatches)[n=i.id]||(s[n]=new qe);o.setData(t,i,c,l),u=i.skipRender,u||a.addToBatch(o,e)}const p=t._slotsObject[h.data.name];if(p){const t=p.container;u||(t.includeInBuild=!0,t.collectRenderables(e,this.renderer,null)),t.includeInBuild=!1}}}updateRenderable(t){var e;const s=this.gpuSpineData[t.uid];t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;const i=t.skeleton.drawOrder;for(let n=0,r=i.length;n<r;n++){const r=i[n],a=r.getAttachment();if(a instanceof Nt||a instanceof It){const i=t._getCachedData(r,a);if(!i.skipRender){const t=s.slotBatches[i.id];null==(e=null==t?void 0:t._batcher)||e.updateElement(t)}}}}destroyRenderable(t){this.gpuSpineData[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null,this.canvasSkeletonRenderer=null}_getSpineData(t){return this.gpuSpineData[t.uid]||this._initMeshData(t)}_initMeshData(t){return this.gpuSpineData[t.uid]={slotBatches:{}},t.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[t.uid]}}v($e,"extension",{type:[i.ExtensionType.WebGLPipes,i.ExtensionType.WebGPUPipes,i.ExtensionType.CanvasPipes],name:"spine"}),i.extensions.add($e);const ze=new j,He=new xe,Ze=new B(()=>new i.Graphics);class Qe extends i.ViewContainer{constructor(t){var e;t instanceof we&&(t={skeletonData:t}),super({}),v(this,"batched",!0),v(this,"buildId",0),v(this,"renderPipeId","spine"),v(this,"_didSpineUpdate",!1),v(this,"beforeUpdateWorldTransforms",()=>{}),v(this,"afterUpdateWorldTransforms",()=>{}),v(this,"skeleton"),v(this,"state"),v(this,"skeletonBounds"),v(this,"darkTint",!1),v(this,"_debug"),v(this,"_slotsObject",Object.create(null)),v(this,"clippingSlotToPixiMasks",Object.create(null)),v(this,"spineAttachmentsDirty",!0),v(this,"spineTexturesDirty",!0),v(this,"_lastAttachments",[]),v(this,"_stateChanged",!0),v(this,"attachmentCacheData",[]),v(this,"_autoUpdate",!1),v(this,"hasNeverUpdated",!0),v(this,"currentClippingSlot");const s=t instanceof we?t:t.skeletonData;this.skeleton=new me(s),this.skeleton.flipY=!0,this.state=new At(new Rt(s)),this.autoUpdate=null==(e=null==t?void 0:t.autoUpdate)||e,this.darkTint=void 0===(null==t?void 0:t.darkTint)?this.skeleton.slots.some(t=>!!t.data.darkColor):null==t?void 0:t.darkTint;const i=this.skeleton.slots;for(let t=0;t<i.length;t++)this.attachmentCacheData[t]=Object.create(null)}getSlotFromRef(t){let e;if(e="number"==typeof t?this.skeleton.slots[t]:"string"==typeof t?this.skeleton.findSlot(t):t,!e)throw new Error(`No slot found with the given slot reference: ${t}`);return e}get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t&&!this._autoUpdate?i.Ticker.shared.add(this.internalUpdate,this):i.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=t}update(t){this.internalUpdate(0,t)}internalUpdate(t,e){this._updateAndApplyState(null!=e?e:i.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(t,e){const s=t;if("string"==typeof t&&(t=this.skeleton.findBone(t)),!t)throw Error(`Cant set bone position, bone ${String(s)} not found`);if(ze.set(e.x,e.y),t.parent){const e=t.parent.worldToLocal(ze);t.x=e.x,t.y=-e.y}else t.x=ze.x,t.y=ze.y}getBonePosition(t,e){const s=t;return"string"==typeof t&&(t=this.skeleton.findBone(t)),t?(e||(e={x:0,y:0}),e.x=t.worldX,e.y=t.worldY,e):(console.error(`Cant set bone position! Bone ${String(s)} not found`),e)}_updateAndApplyState(t){this.hasNeverUpdated=!1,this.state.update(t),this.skeleton.update(t);const{skeleton:e}=this;this.state.apply(e),this.beforeUpdateWorldTransforms(this),e.updateWorldTransform(),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this._boundsDirty=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const t=this.skeleton.drawOrder,e=this._lastAttachments;let s=0,i=!1;for(let n=0;n<t.length;n++){const r=t[n].getAttachment();r&&(r!==e[s]&&(i=!0,e[s]=r),s++)}s!==e.length&&(i=!0,e.length=s),this.spineAttachmentsDirty=i}updateAndSetPixiMask(t,e){var s,i;const n=t.attachment;if(n&&n instanceof Pt){return((s=this.clippingSlotToPixiMasks)[i=t.data.name]||(s[i]={slot:t,vertices:new Array})).maskComputed=!1,void(this.currentClippingSlot=this.clippingSlotToPixiMasks[t.data.name])}let r=this.currentClippingSlot,a=this._slotsObject[t.data.name];if(r&&a){let t=r.slot,e=t.attachment,s=r.mask;if(s||(s=Ze.obtain(),r.mask=s,this.addChild(s)),!r.maskComputed){r.maskComputed=!0;const i=e.worldVerticesLength,n=r.vertices;e.computeWorldVertices(t,0,i,n,0,2),s.clear().poly(n).stroke({width:0}).fill({alpha:.25})}a.container.mask=s}else(null==a?void 0:a.container.mask)&&(a.container.mask=null);if(r&&r.slot.attachment.endSlot==t.data&&(this.currentClippingSlot=void 0),e)for(const t in this.clippingSlotToPixiMasks){const e=this.clippingSlotToPixiMasks[t];e.slot.attachment instanceof Pt&&e.maskComputed||!e.mask||(this.removeChild(e.mask),Ze.free(e.mask),e.mask=void 0)}}transformAttachments(){var t;const e=this.skeleton.drawOrder;for(let s=0;s<e.length;s++){const n=e[s];this.updateAndSetPixiMask(n,s===e.length-1);const r=n.getAttachment();if(r)if(r instanceof It||r instanceof Nt){const e=this._getCachedData(n,r);r instanceof Nt?r.computeWorldVertices(n.bone,e.vertices,0,2):r.computeWorldVertices(n,0,r.worldVerticesLength,e.vertices,0,2),e.uvs.length<r.uvs.length&&(e.uvs=new Float32Array(r.uvs.length)),i.fastCopy(r.uvs.buffer,e.uvs.buffer);const s=n.bone.skeleton.color,a=n.color,o=r.color;e.color.set(s.r*a.r*o.r,s.g*a.g*o.g,s.b*a.b*o.b,s.a*a.a*o.a),n.darkColor&&e.darkColor.setFromColor(n.darkColor),e.skipRender=e.clipped=!1;const l=(null==(t=r.region)?void 0:t.texture.texture)||i.Texture.EMPTY;e.texture!==l&&(e.texture=l,this.spineTexturesDirty=!0),He.isClipping()&&this.updateClippingData(e)}else if(r instanceof Pt){He.clipStart(n,r);continue}He.clipEndWithSlot(n)}He.clipEnd()}updateClippingData(t){t.clipped=!0,He.clipTrianglesUnpacked(t.vertices,t.indices,t.indices.length,t.uvs);const{clippedVertices:e,clippedUVs:s,clippedTriangles:i}=He,n=e.length/2,r=i.length;t.clippedData||(t.clippedData={vertices:new Float32Array(2*n),uvs:new Float32Array(2*n),vertexCount:n,indices:new Uint16Array(r),indicesCount:r},this.spineAttachmentsDirty=!0);const a=t.clippedData,o=a.vertexCount!==n||r!==a.indicesCount;t.skipRender=0===n,o&&(this.spineAttachmentsDirty=!0,a.vertexCount<n&&(a.vertices=new Float32Array(2*n),a.uvs=new Float32Array(2*n)),a.indices.length<r&&(a.indices=new Uint16Array(r)));const{vertices:l,uvs:h,indices:d}=a;for(let t=0;t<n;t++)l[2*t]=e[2*t],l[2*t+1]=e[2*t+1],h[2*t]=s[2*t],h[2*t+1]=s[2*t+1];a.vertexCount=n;for(let t=0;t<r;t++)d[t]!==i[t]&&(this.spineAttachmentsDirty=!0,d[t]=i[t]);a.indicesCount=r}updateSlotObjects(){for(const t in this._slotsObject){const e=this._slotsObject[t];e&&this.updateSlotObject(e)}}updateSlotObject(t){const{slot:e,container:s}=t;if(s.visible=this.skeleton.drawOrder.includes(e),s.visible){const t=e.bone;s.position.set(t.worldX,t.worldY),s.scale.x=t.getWorldScaleX(),s.scale.y=t.getWorldScaleY(),s.rotation=t.getWorldRotationX()*i.DEG_TO_RAD,s.alpha=this.skeleton.color.a*e.color.a}}_getCachedData(t,e){return this.attachmentCacheData[t.data.index][e.name]||this.initCachedData(t,e)}initCachedData(t,e){var s,i;let n;return e instanceof Nt?(n=new Float32Array(8),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(e.uvs.length),color:new _(1,1,1,1),darkColor:new _(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(s=e.region)?void 0:s.texture.texture}):(n=new Float32Array(e.worldVerticesLength),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:e.triangles,uvs:new Float32Array(e.uvs.length),color:new _(1,1,1,1),darkColor:new _(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(i=e.region)?void 0:i.texture.texture}),this.attachmentCacheData[t.data.index][e.name]}onViewUpdate(){var t;if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this),null==(t=this.debug)||t.renderDebug(this)}addSlotObject(t,e){var s;t=this.getSlotFromRef(t);for(const t in this._slotsObject)(null==(s=this._slotsObject[t])?void 0:s.container)===e&&this.removeSlotObject(this._slotsObject[t].slot);this.removeSlotObject(t),e.includeInBuild=!1,this.addChild(e);const i={container:e,slot:t};this._slotsObject[t.data.name]=i,this.updateSlotObject(i)}removeSlotObject(t){var e,s;let n;if(t instanceof i.Container){for(const s in this._slotsObject)if((null==(e=this._slotsObject[s])?void 0:e.container)===t){this._slotsObject[s]=null,n=t;break}}else{const e=this.getSlotFromRef(t);n=null==(s=this._slotsObject[e.data.name])?void 0:s.container,this._slotsObject[e.data.name]=null}n&&(this.removeChild(n),n.includeInBuild=!0)}getSlotObject(t){var e;return t=this.getSlotFromRef(t),null==(e=this._slotsObject[t.data.name])?void 0:e.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||(this.skeletonBounds=new ge);const t=this.skeletonBounds;if(t.update(this.skeleton,!0),t.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const t=this.skeleton.drawOrder,e=this._bounds;e.clear();for(let s=0;s<t.length;s++){const i=t[s],n=i.getAttachment();if(n&&(n instanceof Nt||n instanceof It)){const t=this._getCachedData(i,n);e.addVertexData(t.vertices,0,t.vertices.length)}}}else this._bounds.minX=t.minX,this._bounds.minY=t.minY,this._bounds.maxX=t.maxX,this._bounds.maxY=t.maxY}addBounds(t){t.addBounds(this.bounds)}destroy(t=!1){super.destroy(t),i.Ticker.shared.remove(this.internalUpdate,this),this.state.clearListeners(),this.debug=void 0,this.skeleton=null,this.state=null,this._slotsObject=null,this._lastAttachments.length=0,this.attachmentCacheData=null}skeletonToPixiWorldCoordinates(t){this.worldTransform.apply(t,t)}pixiWorldCoordinatesToSkeleton(t){this.worldTransform.applyInverse(t,t)}pixiWorldCoordinatesToBone(t,e){this.pixiWorldCoordinatesToSkeleton(t),e.parent?e.parent.worldToLocal(t):e.worldToLocal(t)}static from({skeleton:t,atlas:e,scale:s=1,darkTint:n,autoUpdate:r=!0}){const a=`${t}-${e}-${s}`;if(i.Cache.has(a))return new Qe(i.Cache.get(a));const o=i.Assets.get(t),l=i.Assets.get(e),h=new Ot(l),d=new Ce(h).readSkeletonData(o);return i.Cache.set(a,d),new Qe({skeletonData:d,darkTint:n,autoUpdate:r})}}var Je=Object.freeze({__proto__:null,Animation:W,AnimationState:At,AnimationStateAdapter2:class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},AnimationStateData:Rt,AssetManager:Jt,AtlasAttachmentLoader:Ot,Attachment:R,AttachmentTimeline:lt,BlendMode:Ee,Bone:Xt,BoneData:Lt,BoundingBoxAttachment:kt,ClippingAttachment:Pt,Color:_,ColorTimeline:rt,CurveTimeline:Q,DebugUtils:class{static logBones(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e];console.log(s.data.name+", "+s.a+", "+s.b+", "+s.c+", "+s.d+", "+s.worldX+", "+s.worldY)}}},DeformTimeline:dt,DrawOrderTimeline:ut,Event:Kt,EventData:te,EventQueue:Ct,EventTimeline:ct,EventType:Mt,FakeTexture:$t,IkConstraint:ee,IkConstraintData:se,IkConstraintTimeline:mt,IntSet:I,Interpolation:O,JitterEffect:class{constructor(t,e){v(this,"jitterX",0),v(this,"jitterY",0),this.jitterX=t,this.jitterY=e}begin(t){}transform(t,e,s,i){t.x+=N.randomTriangular(-this.jitterX,this.jitterY),t.y+=N.randomTriangular(-this.jitterX,this.jitterY)}end(){}},MathUtils:N,MeshAttachment:It,MixDirection:z,MixPose:$,PathAttachment:Vt,PathConstraint:ce,PathConstraintData:ie,PathConstraintMixTimeline:Et,PathConstraintPositionTimeline:wt,PathConstraintSpacingTimeline:bt,PointAttachment:_t,Pool:B,PositionMode:oe,Pow:L,PowOut:Y,RegionAttachment:Nt,RotateMode:he,RotateTimeline:K,ScaleTimeline:st,SharedAssetManager:class{constructor(t=""){v(this,"pathPrefix"),v(this,"clientAssets",{}),v(this,"queuedAssets",{}),v(this,"rawAssets",{}),v(this,"errors",{}),this.pathPrefix=t}queueAsset(t,e,s){var i=this.clientAssets[t];return null==i&&(i=new Me(t),this.clientAssets[t]=i),null!==e&&(i.textureLoader=e),i.toLoad.push(s),this.queuedAssets[s]!==s&&(this.queuedAssets[s]=s,!0)}loadText(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=s.responseText:this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadJson(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=JSON.parse(s.responseText):this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadTexture(t,e,s){if(s=this.pathPrefix+s,!this.queueAsset(t,e,s))return;let i=new Image;i.src=s,i.crossOrigin="anonymous",i.onload=t=>{this.rawAssets[s]=i},i.onerror=t=>{this.errors[s]=`Couldn't load image ${s}`}}get(t,e){e=this.pathPrefix+e;var s=this.clientAssets[t];return null==s||s.assets[e]}updateClientAssets(t){for(var e=0;e<t.toLoad.length;e++){var s=t.toLoad[e],i=t.assets[s];if(null==i){var n=this.rawAssets[s];if(null==n)continue;n instanceof HTMLImageElement?t.assets[s]=t.textureLoader(n):t.assets[s]=n}}}isLoadingComplete(t){var e=this.clientAssets[t];return null==e||(this.updateClientAssets(e),e.toLoad.length==e.loaded())}dispose(){}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},ShearTimeline:it,Skeleton:me,SkeletonBounds:ge,SkeletonClipping:xe,SkeletonData:we,SkeletonJson:Ce,Skin:Te,Slot:ue,SlotData:Ae,SpacingMode:le,Spine:Qe,SpineDebugRenderer:class{constructor(){v(this,"registeredSpines",new Map),v(this,"drawMeshHull",!0),v(this,"drawMeshTriangles",!0),v(this,"drawBones",!0),v(this,"drawPaths",!0),v(this,"drawBoundingBoxes",!0),v(this,"drawClipping",!0),v(this,"drawRegionAttachments",!0),v(this,"drawEvents",!0),v(this,"lineWidth",1),v(this,"regionAttachmentsColor",30975),v(this,"meshHullColor",30975),v(this,"meshTrianglesColor",16763904),v(this,"clippingPolygonColor",16711935),v(this,"boundingBoxesRectColor",65280),v(this,"boundingBoxesPolygonColor",65280),v(this,"boundingBoxesCircleColor",65280),v(this,"pathsCurveColor",16711680),v(this,"pathsLineColor",16711935),v(this,"skeletonXYColor",16711680),v(this,"bonesColor",61132),v(this,"eventFontSize",24),v(this,"eventFontColor",0)}registerSpine(t){if(this.registeredSpines.has(t))return void console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",t);const e={parentDebugContainer:new i.Container,bones:new i.Container,skeletonXY:new i.Graphics,regionAttachmentsShape:new i.Graphics,meshTrianglesLine:new i.Graphics,meshHullLine:new i.Graphics,clippingPolygon:new i.Graphics,boundingBoxesRect:new i.Graphics,boundingBoxesCircle:new i.Graphics,boundingBoxesPolygon:new i.Graphics,pathsCurve:new i.Graphics,pathsLine:new i.Graphics,eventText:new i.Container,eventCallback:{event:(s,n)=>{if(this.drawEvents){const s=Math.abs(t.scale.x||t.scale.y||1),r=new i.Text({text:n.data.name,style:{fontSize:this.eventFontSize/s,fill:this.eventFontColor,fontFamily:"monospace"}});r.scale.x=Math.sign(t.scale.x),r.anchor.set(.5),e.eventText.addChild(r),setTimeout(()=>{r.destroyed||r.destroy()},250)}}}};e.parentDebugContainer.addChild(e.bones),e.parentDebugContainer.addChild(e.skeletonXY),e.parentDebugContainer.addChild(e.regionAttachmentsShape),e.parentDebugContainer.addChild(e.meshTrianglesLine),e.parentDebugContainer.addChild(e.meshHullLine),e.parentDebugContainer.addChild(e.clippingPolygon),e.parentDebugContainer.addChild(e.boundingBoxesRect),e.parentDebugContainer.addChild(e.boundingBoxesCircle),e.parentDebugContainer.addChild(e.boundingBoxesPolygon),e.parentDebugContainer.addChild(e.pathsCurve),e.parentDebugContainer.addChild(e.pathsLine),e.parentDebugContainer.addChild(e.eventText),e.parentDebugContainer.zIndex=9999999,e.parentDebugContainer.accessibleChildren=!1,e.parentDebugContainer.eventMode="none",e.parentDebugContainer.interactiveChildren=!1,t.addChild(e.parentDebugContainer),t.state.addListener(e.eventCallback),this.registeredSpines.set(t,e)}renderDebug(t){this.registeredSpines.has(t)||this.registerSpine(t);const e=this.registeredSpines.get(t);if(!e)return;t.addChild(e.parentDebugContainer),e.skeletonXY.clear(),e.regionAttachmentsShape.clear(),e.meshTrianglesLine.clear(),e.meshHullLine.clear(),e.clippingPolygon.clear(),e.boundingBoxesRect.clear(),e.boundingBoxesCircle.clear(),e.boundingBoxesPolygon.clear(),e.pathsCurve.clear(),e.pathsLine.clear();for(let t=e.bones.children.length;t>0;t--)e.bones.children[t-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(t.scale.x||t.scale.y||1),i=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(t,e,i,s),this.drawPaths&&this.drawPathsFunc(t,e,i),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(t,e,i),this.drawClipping&&this.drawClippingFunc(t,e,i),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(t,e,i),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(t,e,i),this.drawEvents)for(const t of e.eventText.children)t.alpha-=.05,t.y-=2}drawBonesFunc(t,e,s,n){const r=t.skeleton,a=r.x,o=r.y,l=r.bones;e.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let t=0,r=l.length;t<r;t++){const r=l[t],h=r.data.length,d=a+r.worldX,c=o+r.worldY,u=a+h*r.a+r.worldX,p=o+h*r.b+r.worldY;if("root"===r.data.name||null===r.data.parent)continue;const m=Math.abs(d-u),g=Math.abs(c-p),f=Math.pow(m,2),x=g,w=Math.pow(g,2),b=Math.sqrt(f+w),y=Math.pow(b,2),E=Math.PI/180,T=Math.acos((y+w-f)/(2*x*b))||0;if(0===b)continue;const A=new i.Graphics;e.bones.addChild(A);const S=b/50/n;A.context.poly([0,0,0-S,b-3*S,0,b-S,0+S,b-3*S]).fill(this.bonesColor),A.x=d,A.y=c,A.pivot.y=b;let C=0;d<u&&c<p?C=180*E-T:d>u&&c<p?C=180*E+T:d>u&&c>p?C=-T:d<u&&c>p?C=T:c===p&&d<u?C=90*E:c===p&&d>u?C=-90*E:d===u&&c<p?C=180*E:d===u&&c>p&&(C=0),A.rotation=C,A.circle(0,b,1.2*S).fill({color:0,alpha:.6}).stroke({width:s+S/2.4,color:this.bonesColor})}const h=3*s;e.skeletonXY.context.moveTo(a-h,o-h).lineTo(a+h,o+h).moveTo(a+h,o-h).lineTo(a-h,o+h).stroke()}drawRegionAttachmentsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t],n=s.getAttachment();if(null===n||!(n instanceof Nt))continue;const r=n,a=new Float32Array(8);r.computeWorldVertices(s.bone,a,0,2),e.regionAttachmentsShape.poly(Array.from(a.slice(0,8)))}e.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof It))continue;const r=n,a=new Float32Array(r.worldVerticesLength),o=r.triangles;let l=r.hullLength;if(r.computeWorldVertices(s,0,r.worldVerticesLength,a,0,2),this.drawMeshTriangles)for(let t=0,s=o.length;t<s;t+=3){const s=2*o[t],i=2*o[t+1],n=2*o[t+2];e.meshTrianglesLine.context.moveTo(a[s],a[s+1]).lineTo(a[i],a[i+1]).lineTo(a[n],a[n+1])}if(this.drawMeshHull&&l>0){l=2*(l>>1);let t=a[l-2],s=a[l-1];for(let i=0,n=l;i<n;i+=2){const n=a[i],r=a[i+1];e.meshHullLine.context.moveTo(n,r).lineTo(t,s),t=n,s=r}}}e.meshHullLine.stroke({width:s,color:this.meshHullColor}),e.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof Pt))continue;const r=n,a=r.worldVerticesLength,o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2),e.clippingPolygon.poly(Array.from(o))}e.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(t,e,s){const i=new ge;i.update(t.skeleton,!0),i.minX!==1/0&&e.boundingBoxesRect.rect(i.minX,i.minY,i.getWidth(),i.getHeight()).stroke({width:s,color:this.boundingBoxesRectColor});const n=i.polygons,r=(t,i,n)=>{if(n<3)throw new Error("Polygon must contain at least 3 vertices");const r=[],a=2*s;for(let s=0,i=t.length;s<i;s+=2){const i=t[s],n=t[s+1];e.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),e.boundingBoxesCircle.drawCircle(i,n,a),e.boundingBoxesCircle.fill(0),e.boundingBoxesCircle.circle(i,n,a).fill({color:this.boundingBoxesCircleColor}),r.push(i,n)}e.boundingBoxesPolygon.poly(r).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let t=0,e=n.length;t<e;t++){const e=n[t];r(e,0,e.length)}}drawPathsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof Vt))continue;const r=n;let a=r.worldVerticesLength;const o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2);let l=o[2],h=o[3],d=0,c=0;if(r.closed){const t=o[0],s=o[1],i=o[a-2],n=o[a-1];d=o[a-4],c=o[a-3],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(t,s,i,n,d,c),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(t,s),e.pathsLine.moveTo(d,c),e.pathsLine.lineTo(i,n)}a-=4;for(let t=4;t<a;t+=6){const s=o[t],i=o[t+1],n=o[t+2],r=o[t+3];d=o[t+4],c=o[t+5],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(s,i,n,r,d,c),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(s,i),e.pathsLine.moveTo(d,c),e.pathsLine.lineTo(n,r),l=d,h=c}}e.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),e.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(t){this.registeredSpines.has(t)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",t);const e=this.registeredSpines.get(t);e&&(t.state.removeListener(e.eventCallback),e.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(t))}},SpinePipe:$e,SpineTexture:Ie,SwirlEffect:ke,Texture:Bt,TextureAtlas:zt,TextureAtlasPage:Zt,TextureAtlasRegion:Qt,TextureFilter:Ut,TextureRegion:Gt,TextureWrap:qt,TimeKeeper:class{constructor(){v(this,"maxDelta",.064),v(this,"framesPerSecond",0),v(this,"delta",0),v(this,"totalTime",0),v(this,"lastTime",Date.now()/1e3),v(this,"frameCount",0),v(this,"frameTime",0)}update(){var t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)}},TimelineType:H,TrackEntry:St,TransformConstraint:pe,TransformConstraintData:Se,TransformConstraintTimeline:ft,TransformMode:Ft,TranslateTimeline:et,Triangulator:fe,TwoColorTimeline:ot,Utils:X,Vector2:j,VertexAttachment:P,WindowedMean:class{constructor(t=32){v(this,"values"),v(this,"addedValues",0),v(this,"lastValue",0),v(this,"mean",0),v(this,"dirty",!0),this.values=new Array(t)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let t=0;for(let e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0}}});return t.Spine=class extends u{},t.SpineSystem=class extends f{init(){super.init({pixiSpine:Je})}},t.pixiSpine=Je,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,PIXI);globalThis.EVA.plugin.renderer.spine36=globalThis.EVA.plugin.renderer.spine36||_EVA_IIFE_spine36;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-spine36",
3
- "version": "2.0.2",
3
+ "version": "2.1.0-beta.10",
4
4
  "description": "@eva/plugin-renderer-spine36",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-spine36.esm.js",
@@ -18,10 +18,10 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "2.0.2",
22
- "@eva/inspector-decorator": "^0.0.5",
23
- "@eva/plugin-renderer": "2.0.2",
24
- "@eva/spine-base": "2.0.2",
21
+ "@eva/eva.js": "2.1.0-beta.10",
22
+ "@eva/inspector-decorator": "^2.0.0-beta.0",
23
+ "@eva/plugin-renderer": "2.1.0-beta.10",
24
+ "@eva/spine-base": "2.1.0-beta.10",
25
25
  "pixi.js": "^8.17.0"
26
26
  }
27
27
  }