@taole/giftstage-plugin-multi-gift 0.0.58 → 0.1.0

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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@taole/giftstage";
2
- const ge = 0.42, Z = 8192, de = "LOTTIE_EFFECT_PARTICLE_CAPACITY_EXCEEDED", ve = Object.freeze([
2
+ const we = 0.42, Z = 8192, me = "LOTTIE_EFFECT_PARTICLE_CAPACITY_EXCEEDED", Te = Object.freeze([
3
3
  Object.freeze({ batch: "main", rate: 105, phase: "launch" }),
4
4
  Object.freeze({ batch: "main", rate: 78, phase: "launch" }),
5
5
  Object.freeze({ batch: "main", rate: 48, phase: "launch" }),
@@ -11,45 +11,45 @@ const ge = 0.42, Z = 8192, de = "LOTTIE_EFFECT_PARTICLE_CAPACITY_EXCEEDED", ve =
11
11
  Object.freeze({ batch: "main", rate: 175, phase: "secondary" }),
12
12
  Object.freeze({ batch: "main", rate: 48, phase: "secondary" })
13
13
  ]);
14
- function Je(e, t, i) {
14
+ function qe(e, t, i) {
15
15
  return Math.max(t, Math.min(i, e));
16
16
  }
17
17
  function $e(e = {}) {
18
18
  const t = e.quality ?? "auto";
19
- if (typeof t == "number") return Je(t, 0.25, 1.25);
19
+ if (typeof t == "number") return qe(t, 0.25, 1.25);
20
20
  if (t === "low") return 0.46;
21
21
  if (t === "medium") return 0.72;
22
22
  if (t === "high") return 1;
23
- const i = Number.isFinite(e.deviceMemory) ? e.deviceMemory : 8, s = Number.isFinite(e.hardwareConcurrency) ? e.hardwareConcurrency : 8;
24
- return i <= 4 || s <= 4 ? 0.52 : /Android|iPhone|iPad|iPod/i.test(e.userAgent || "") ? 0.72 : 1;
23
+ const i = Number.isFinite(e.deviceMemory) ? e.deviceMemory : 8, r = Number.isFinite(e.hardwareConcurrency) ? e.hardwareConcurrency : 8;
24
+ return i <= 4 || r <= 4 ? 0.52 : /Android|iPhone|iPad|iPod/i.test(e.userAgent || "") ? 0.72 : 1;
25
25
  }
26
- function Ue({
26
+ function je({
27
27
  launchDuration: e,
28
28
  density: t = 1,
29
29
  resolvedQualityScale: i = 1
30
30
  }) {
31
31
  if (!Number.isFinite(e) || e < 0 || !Number.isFinite(t) || t < 0 || !Number.isFinite(i) || i < 0)
32
32
  throw new Error("firework 粒子数量规划参数必须是有限非负数");
33
- const s = t * i;
34
- if (!Number.isFinite(s))
33
+ const r = t * i;
34
+ if (!Number.isFinite(r))
35
35
  throw new Error("firework 粒子数量规划结果不是有限数值");
36
- const r = {
36
+ const s = {
37
37
  launch: e * 0.84,
38
38
  burst: 0.11,
39
39
  secondary: 0.14
40
- }, n = ve.map(({ rate: o, phase: c }) => Math.max(1, Math.round(o * r[c] * s)));
41
- let l = 0, a = 0;
42
- return n.forEach((o, c) => {
43
- ve[c].batch === "smoke" ? l += o : a += o;
40
+ }, n = Te.map(({ rate: o, phase: l }) => Math.max(1, Math.round(o * s[l] * r)));
41
+ let c = 0, a = 0;
42
+ return n.forEach((o, l) => {
43
+ Te[l].batch === "smoke" ? c += o : a += o;
44
44
  }), Object.freeze({
45
45
  emitterCounts: Object.freeze(n),
46
- smokeCount: l,
46
+ smokeCount: c,
47
47
  mainCount: a,
48
- totalCount: l + a,
48
+ totalCount: c + a,
49
49
  flashCount: 1
50
50
  });
51
51
  }
52
- function je(e, t = Z) {
52
+ function Ge(e, t = Z) {
53
53
  if (!Number.isSafeInteger(e == null ? void 0 : e.smokeCount) || e.smokeCount < 0 || !Number.isSafeInteger(e == null ? void 0 : e.mainCount) || e.mainCount < 0)
54
54
  throw new Error("firework smoke/main 粒子数量必须是非负安全整数");
55
55
  if (!Number.isSafeInteger(t) || t < 1)
@@ -58,51 +58,51 @@ function je(e, t = Z) {
58
58
  const i = new RangeError(
59
59
  `firework 粒子批次超过上限 ${t}(smoke=${e.smokeCount}, main=${e.mainCount})`
60
60
  );
61
- throw i.code = de, i.counts = e, i.maxInstancesPerBatch = t, i;
61
+ throw i.code = me, i.counts = e, i.maxInstancesPerBatch = t, i;
62
62
  }
63
63
  return e;
64
64
  }
65
- function Ge({
65
+ function Ye({
66
66
  frameRate: e,
67
67
  dismissFrame: t,
68
- durationSeconds: i = ge
68
+ durationSeconds: i = we
69
69
  }) {
70
70
  if (!Number.isFinite(e) || !(e > 0) || !Number.isFinite(t) || !Number.isFinite(i) || !(i > 0))
71
71
  throw new Error("firework dismissDuration 必须生成有限且严格递增的毫秒区间");
72
- const s = t / e, r = s * 1e3, n = (s + i) * 1e3;
73
- if (!Number.isFinite(r) || !Number.isFinite(n) || !(n > r))
72
+ const r = t / e, s = r * 1e3, n = (r + i) * 1e3;
73
+ if (!Number.isFinite(s) || !Number.isFinite(n) || !(n > s))
74
74
  throw new Error("firework dismissDuration 必须生成有限且严格递增的毫秒区间");
75
- return Object.freeze({ durationSeconds: i, startSeconds: s, startMs: r, endMs: n });
75
+ return Object.freeze({ durationSeconds: i, startSeconds: r, startMs: s, endMs: n });
76
76
  }
77
- const Te = 150, Re = /* @__PURE__ */ new WeakMap();
78
- function te(e, t) {
77
+ const Re = 150, Ae = /* @__PURE__ */ new WeakMap();
78
+ function ie(e, t) {
79
79
  return Array.isArray(e) ? e : e != null ? [e] : Array.isArray(t) ? t : [t];
80
80
  }
81
- function oe(e, t, i) {
82
- const s = e == null ? void 0 : e[t];
83
- if (!s) return null;
84
- if (Array.isArray(s))
85
- return { x: s[0], y: s[1] ?? s[0] };
86
- if (typeof s == "object") {
87
- const r = (a) => {
88
- const o = s[a];
81
+ function ce(e, t, i) {
82
+ const r = e == null ? void 0 : e[t];
83
+ if (!r) return null;
84
+ if (Array.isArray(r))
85
+ return { x: r[0], y: r[1] ?? r[0] };
86
+ if (typeof r == "object") {
87
+ const s = (a) => {
88
+ const o = r[a];
89
89
  return o == null ? null : Array.isArray(o) ? o[i] ?? o[0] : o;
90
- }, n = r("x"), l = r("y");
91
- return n == null || l == null ? null : { x: n, y: l };
90
+ }, n = s("x"), c = s("y");
91
+ return n == null || c == null ? null : { x: n, y: c };
92
92
  }
93
93
  return null;
94
94
  }
95
- function qe(e, t, i) {
96
- const s = 1 - e;
97
- return 3 * s * s * e * t + 3 * s * e * e * i + e * e * e;
95
+ function He(e, t, i) {
96
+ const r = 1 - e;
97
+ return 3 * r * r * e * t + 3 * r * e * e * i + e * e * e;
98
98
  }
99
99
  function Ze(e, t, i) {
100
- const s = 1 - e;
101
- return 3 * s * s * e * t + 3 * s * e * e * i + e * e * e;
100
+ const r = 1 - e;
101
+ return 3 * r * r * e * t + 3 * r * e * e * i + e * e * e;
102
102
  }
103
- class ae extends Error {
104
- constructor(t, i, s = [], r = !1) {
105
- super(i), this.name = "MultiGiftValidationError", this.code = t, this.findings = s, this.recoverable = r;
103
+ class le extends Error {
104
+ constructor(t, i, r = [], s = !1) {
105
+ super(i), this.name = "MultiGiftValidationError", this.code = t, this.findings = r, this.recoverable = s;
106
106
  }
107
107
  }
108
108
  function F(e, t, i = {}) {
@@ -115,312 +115,312 @@ function F(e, t, i = {}) {
115
115
  ...Number.isInteger(i.effectIndex) ? { effectIndex: i.effectIndex } : {}
116
116
  };
117
117
  }
118
- function L(e, t) {
118
+ function x(e, t) {
119
119
  e.some((i) => i.code === t.code && i.where === t.where) || e.push(t);
120
120
  }
121
- function ie(e) {
121
+ function re(e) {
122
122
  return !e || typeof e != "object" ? [] : e.a === 1 ? Array.isArray(e.k) ? e.k.flatMap((t) => [t == null ? void 0 : t.s, t == null ? void 0 : t.e]).filter((t) => t !== void 0) : [] : e.k === void 0 ? [] : [e.k];
123
123
  }
124
- function V(e) {
124
+ function B(e) {
125
125
  const t = Array.isArray(e) ? e : [e];
126
126
  return t.length > 0 && t.every(Number.isFinite) ? t : null;
127
127
  }
128
- function Ye(e, t = /* @__PURE__ */ new Set()) {
129
- return !e || typeof e != "object" || t.has(e) ? !1 : (t.add(e), typeof e.x == "string" ? !0 : Object.values(e).some((i) => Ye(i, t)));
128
+ function We(e, t = /* @__PURE__ */ new Set()) {
129
+ return !e || typeof e != "object" || t.has(e) ? !1 : (t.add(e), typeof e.x == "string" ? !0 : Object.values(e).some((i) => We(i, t)));
130
130
  }
131
- function B(e, t, i, s, r) {
131
+ function J(e, t, i, r, s) {
132
132
  if (e == null) return;
133
- const n = () => L(i, F("LOTTIE_INVALID_KEYFRAME", t, { layer: s }));
133
+ const n = () => x(i, F("LOTTIE_INVALID_KEYFRAME", t, { layer: r }));
134
134
  if (typeof e != "object" || e.k === void 0) {
135
135
  n();
136
136
  return;
137
137
  }
138
- if (typeof e.x == "string" && L(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${t}.x`, { layer: s })), e.a !== 1) {
139
- const o = V(e.k);
140
- (!o || !r.includes(o.length)) && n();
138
+ if (typeof e.x == "string" && x(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${t}.x`, { layer: r })), e.a !== 1) {
139
+ const o = B(e.k);
140
+ (!o || !s.includes(o.length)) && n();
141
141
  return;
142
142
  }
143
143
  if (!Array.isArray(e.k) || e.k.length === 0) {
144
144
  n();
145
145
  return;
146
146
  }
147
- let l = -1 / 0, a = null;
147
+ let c = -1 / 0, a = null;
148
148
  for (let o = 0; o < e.k.length; o += 1) {
149
- const c = e.k[o];
150
- if (!c || !Number.isFinite(c.t) || c.t < l) {
149
+ const l = e.k[o];
150
+ if (!l || !Number.isFinite(l.t) || l.t < c) {
151
151
  n();
152
152
  return;
153
153
  }
154
- l = c.t;
155
- const u = [c.s, c.e].filter((m) => m !== void 0);
156
- if (c.s === void 0 || u.length === 0) {
154
+ c = l.t;
155
+ const d = [l.s, l.e].filter((m) => m !== void 0);
156
+ if (l.s === void 0 || d.length === 0) {
157
157
  n();
158
158
  return;
159
159
  }
160
- for (const m of u) {
161
- const p = V(m);
162
- if (!p || !r.includes(p.length)) {
160
+ for (const m of d) {
161
+ const g = B(m);
162
+ if (!g || !s.includes(g.length)) {
163
163
  n();
164
164
  return;
165
165
  }
166
- if (a == null && (a = p.length), a !== p.length) {
166
+ if (a == null && (a = g.length), a !== g.length) {
167
167
  n();
168
168
  return;
169
169
  }
170
170
  }
171
171
  }
172
172
  }
173
- function ue(e) {
174
- var n, l, a, o, c, u;
175
- const t = [], i = e.nm || `ind_${e.ind}`, s = { layer: i };
176
- e.parent !== void 0 && t.push(F("LOTTIE_UNSUPPORTED_PARENT", i, s)), e.ddd === 1 && t.push(F("LOTTIE_UNSUPPORTED_3D", i, s));
177
- const r = (n = e.ks) == null ? void 0 : n.p;
178
- return r && (r.s === !0 || r.x !== void 0 || r.y !== void 0) && t.push(F("LOTTIE_UNSUPPORTED_SPLIT_POSITION", i, s)), (((l = e.ks) == null ? void 0 : l.rx) !== void 0 || ((a = e.ks) == null ? void 0 : a.ry) !== void 0 || ((o = e.ks) == null ? void 0 : o.or) !== void 0 || ((c = e.ks) == null ? void 0 : c.sk) !== void 0 || ((u = e.ks) == null ? void 0 : u.sa) !== void 0 || e.ao === 1 || e.sr !== void 0 && e.sr !== 1 || e.st !== void 0 && e.st !== 0 || e.tm !== void 0 || e.bm !== void 0 && e.bm !== 0 || e.tt !== void 0 || e.td !== void 0 || e.hasMask === !0 || Array.isArray(e.masksProperties) && e.masksProperties.length > 0 || Array.isArray(e.ef) && e.ef.length > 0 || Ye(e)) && t.push(F("LOTTIE_UNSUPPORTED_TRANSFORM", i, s)), (r == null ? void 0 : r.a) === 1 && Array.isArray(r.k) && r.k.forEach((m, p) => {
179
- var w;
180
- const v = (m == null ? void 0 : m.to) !== void 0, y = (m == null ? void 0 : m.ti) !== void 0;
181
- if (!v && !y) return;
182
- const b = m == null ? void 0 : m.s, g = (m == null ? void 0 : m.e) ?? ((w = r.k[p + 1]) == null ? void 0 : w.s), h = Array.isArray(b) ? b.length : -1, d = (k) => Array.isArray(k) && k.length === h && k.every(Number.isFinite);
183
- (!d(b) || !d(g) || !d(m.to) || !d(m.ti)) && t.push(F("LOTTIE_INVALID_KEYFRAME", `${i}.ks.p[${p}]`, s));
173
+ function ge(e) {
174
+ var n, c, a, o, l, d;
175
+ const t = [], i = e.nm || `ind_${e.ind}`, r = { layer: i };
176
+ e.parent !== void 0 && t.push(F("LOTTIE_UNSUPPORTED_PARENT", i, r)), e.ddd === 1 && t.push(F("LOTTIE_UNSUPPORTED_3D", i, r));
177
+ const s = (n = e.ks) == null ? void 0 : n.p;
178
+ return s && (s.s === !0 || s.x !== void 0 || s.y !== void 0) && t.push(F("LOTTIE_UNSUPPORTED_SPLIT_POSITION", i, r)), (((c = e.ks) == null ? void 0 : c.rx) !== void 0 || ((a = e.ks) == null ? void 0 : a.ry) !== void 0 || ((o = e.ks) == null ? void 0 : o.or) !== void 0 || ((l = e.ks) == null ? void 0 : l.sk) !== void 0 || ((d = e.ks) == null ? void 0 : d.sa) !== void 0 || e.ao === 1 || e.sr !== void 0 && e.sr !== 1 || e.st !== void 0 && e.st !== 0 || e.tm !== void 0 || e.bm !== void 0 && e.bm !== 0 || e.tt !== void 0 || e.td !== void 0 || e.hasMask === !0 || Array.isArray(e.masksProperties) && e.masksProperties.length > 0 || Array.isArray(e.ef) && e.ef.length > 0 || We(e)) && t.push(F("LOTTIE_UNSUPPORTED_TRANSFORM", i, r)), (s == null ? void 0 : s.a) === 1 && Array.isArray(s.k) && s.k.forEach((m, g) => {
179
+ var p;
180
+ const v = (m == null ? void 0 : m.to) !== void 0, b = (m == null ? void 0 : m.ti) !== void 0;
181
+ if (!v && !b) return;
182
+ const w = m == null ? void 0 : m.s, k = (m == null ? void 0 : m.e) ?? ((p = s.k[g + 1]) == null ? void 0 : p.s), f = Array.isArray(w) ? w.length : -1, h = (M) => Array.isArray(M) && M.length === f && M.every(Number.isFinite);
183
+ (!h(w) || !h(k) || !h(m.to) || !h(m.ti)) && t.push(F("LOTTIE_INVALID_KEYFRAME", `${i}.ks.p[${g}]`, r));
184
184
  }), t;
185
185
  }
186
- function He(e, t, i) {
187
- let s = 0, r = 1;
188
- for (let l = 0; l < 32; l += 1) {
189
- const a = (s + r) / 2;
190
- qe(a, t.x, i.x) < e ? s = a : r = a;
186
+ function Qe(e, t, i) {
187
+ let r = 0, s = 1;
188
+ for (let c = 0; c < 32; c += 1) {
189
+ const a = (r + s) / 2;
190
+ He(a, t.x, i.x) < e ? r = a : s = a;
191
191
  }
192
- const n = (s + r) / 2;
192
+ const n = (r + s) / 2;
193
193
  return Ze(n, t.y, i.y);
194
194
  }
195
- function _t(e) {
196
- return ((e == null ? void 0 : e.layers) || []).flatMap(ue);
195
+ function Ct(e) {
196
+ return ((e == null ? void 0 : e.layers) || []).flatMap(ge);
197
197
  }
198
- function Qe(e, t = {}) {
199
- var u, m, p, v, y, b, g;
200
- const i = [], s = Array.isArray(e == null ? void 0 : e.layers) ? e.layers : [];
198
+ function et(e, t = {}) {
199
+ var d, m, g, v, b, w, k;
200
+ const i = [], r = Array.isArray(e == null ? void 0 : e.layers) ? e.layers : [];
201
201
  (!Number.isFinite(e == null ? void 0 : e.w) || e.w <= 0 || !Number.isFinite(e == null ? void 0 : e.h) || e.h <= 0 || !Number.isFinite(e == null ? void 0 : e.fr) || e.fr <= 0 || !Number.isFinite(e == null ? void 0 : e.ip) || !Number.isFinite(e == null ? void 0 : e.op) || e.op <= e.ip) && i.push(F("LOTTIE_INVALID_COMPOSITION", "composition", {
202
202
  scope: "composition"
203
203
  }));
204
- const r = /^(slot|img_slot)_(\d+)$/, n = s.filter((h) => r.test((h == null ? void 0 : h.nm) || ""));
205
- n.filter((h) => /^slot_\d+$/.test(h.nm)).length === 0 && i.push(F("LOTTIE_SLOT_MISSING", "layers", { scope: "composition" }));
206
- for (const h of ["slot", "img_slot"]) {
207
- const d = n.filter((O) => O.nm.startsWith(`${h}_`)), w = /* @__PURE__ */ new Set(), k = [];
208
- for (const O of d)
209
- w.has(O.nm) && L(i, F("LOTTIE_SLOT_DUPLICATED", O.nm, {
204
+ const s = /^(slot|img_slot)_(\d+)$/, n = r.filter((f) => s.test((f == null ? void 0 : f.nm) || ""));
205
+ n.filter((f) => /^slot_\d+$/.test(f.nm)).length === 0 && i.push(F("LOTTIE_SLOT_MISSING", "layers", { scope: "composition" }));
206
+ for (const f of ["slot", "img_slot"]) {
207
+ const h = n.filter((I) => I.nm.startsWith(`${f}_`)), p = /* @__PURE__ */ new Set(), M = [];
208
+ for (const I of h)
209
+ p.has(I.nm) && x(i, F("LOTTIE_SLOT_DUPLICATED", I.nm, {
210
210
  scope: "composition"
211
- })), w.add(O.nm), k.push(Number((u = r.exec(O.nm)) == null ? void 0 : u[2]));
212
- Array.from(new Set(k)).sort((O, C) => O - C).some((O, C) => O !== C + 1) && i.push(F("LOTTIE_SLOT_INDEX_GAP", h, { scope: "composition" }));
211
+ })), p.add(I.nm), M.push(Number((d = s.exec(I.nm)) == null ? void 0 : d[2]));
212
+ Array.from(new Set(M)).sort((I, _) => I - _).some((I, _) => I !== _ + 1) && i.push(F("LOTTIE_SLOT_INDEX_GAP", f, { scope: "composition" }));
213
213
  }
214
- for (const h of n) {
215
- const d = h.nm;
216
- for (const M of ue(h)) L(i, M);
217
- h.ty !== 3 && L(i, F("LOTTIE_UNSUPPORTED_LAYER_TYPE", d, {
218
- layer: d
219
- })), (!Number.isFinite(h.ip) || !Number.isFinite(h.op) || h.op <= h.ip) && L(i, F("LOTTIE_INVALID_KEYFRAME", `${d}.ip/op`, {
220
- layer: d
214
+ for (const f of n) {
215
+ const h = f.nm;
216
+ for (const S of ge(f)) x(i, S);
217
+ f.ty !== 3 && x(i, F("LOTTIE_UNSUPPORTED_LAYER_TYPE", h, {
218
+ layer: h
219
+ })), (!Number.isFinite(f.ip) || !Number.isFinite(f.op) || f.op <= f.ip) && x(i, F("LOTTIE_INVALID_KEYFRAME", `${h}.ip/op`, {
220
+ layer: h
221
221
  }));
222
- const w = h.ks || {};
223
- B(w.p, `${d}.ks.p`, i, d, [2, 3]), B(w.s, `${d}.ks.s`, i, d, [2, 3]), B(w.r, `${d}.ks.r`, i, d, [1]), B(w.rz, `${d}.ks.rz`, i, d, [1]), B(w.o, `${d}.ks.o`, i, d, [1]), w.r !== void 0 && w.rz !== void 0 && L(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${d}.ks.r/rz`, {
224
- layer: d
222
+ const p = f.ks || {};
223
+ J(p.p, `${h}.ks.p`, i, h, [2, 3]), J(p.s, `${h}.ks.s`, i, h, [2, 3]), J(p.r, `${h}.ks.r`, i, h, [1]), J(p.rz, `${h}.ks.rz`, i, h, [1]), J(p.o, `${h}.ks.o`, i, h, [1]), p.r !== void 0 && p.rz !== void 0 && x(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${h}.ks.r/rz`, {
224
+ layer: h
225
225
  }));
226
- const k = w.a, E = ie(k);
227
- ((k == null ? void 0 : k.a) === 1 || E.some((M) => {
228
- const T = V(M);
229
- return !T || T.some((R) => R !== 0);
230
- })) && L(i, F("LOTTIE_UNSUPPORTED_ANCHOR", `${d}.ks.a`, {
231
- layer: d
232
- })), ie(w.p).some((M) => {
233
- const T = V(M);
234
- return !!T && T.length > 2 && T[2] !== 0;
235
- }) && L(i, F("LOTTIE_UNSUPPORTED_3D", `${d}.ks.p`, {
236
- layer: d
237
- })), ie(w.s).some((M) => {
238
- const T = V(M);
239
- return !!T && (T[0] < 0 || T[1] < 0 || T.length > 2 && T[2] !== 100);
240
- }) && L(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${d}.ks.s`, {
241
- layer: d
226
+ const M = p.a, y = re(M);
227
+ ((M == null ? void 0 : M.a) === 1 || y.some((S) => {
228
+ const R = B(S);
229
+ return !R || R.some((O) => O !== 0);
230
+ })) && x(i, F("LOTTIE_UNSUPPORTED_ANCHOR", `${h}.ks.a`, {
231
+ layer: h
232
+ })), re(p.p).some((S) => {
233
+ const R = B(S);
234
+ return !!R && R.length > 2 && R[2] !== 0;
235
+ }) && x(i, F("LOTTIE_UNSUPPORTED_3D", `${h}.ks.p`, {
236
+ layer: h
237
+ })), re(p.s).some((S) => {
238
+ const R = B(S);
239
+ return !!R && (R[0] < 0 || R[1] < 0 || R.length > 2 && R[2] !== 100);
240
+ }) && x(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${h}.ks.s`, {
241
+ layer: h
242
242
  }));
243
243
  }
244
- const a = pe(e == null ? void 0 : e.markers, "target_flight");
244
+ const a = be(e == null ? void 0 : e.markers, "target_flight");
245
245
  (!a || !Number.isFinite(a.tm) || !Number.isFinite(a.dr) || a.dr <= 0 || a.tm < e.ip || a.tm + a.dr > e.op) && i.push(F("LOTTIE_TARGET_MARKER_MISSING", "markers.target_flight", {
246
246
  scope: "composition",
247
247
  severity: "warning"
248
248
  }));
249
- const o = new Map(((e == null ? void 0 : e.markers) || []).map((h) => [h == null ? void 0 : h.cm, h])), c = new Map(s.map((h) => [h == null ? void 0 : h.nm, h]));
250
- for (const [h, d] of (t.effects || []).entries()) {
251
- if ((d == null ? void 0 : d.type) !== "firework") continue;
252
- for (const R of ["launch", "burst"]) {
253
- const S = (m = d.anchors) == null ? void 0 : m[R], N = c.get(S);
254
- if (!S || !((p = N == null ? void 0 : N.ks) != null && p.p)) {
255
- L(i, F(
249
+ const o = new Map(((e == null ? void 0 : e.markers) || []).map((f) => [f == null ? void 0 : f.cm, f])), l = new Map(r.map((f) => [f == null ? void 0 : f.nm, f]));
250
+ for (const [f, h] of (t.effects || []).entries()) {
251
+ if ((h == null ? void 0 : h.type) !== "firework") continue;
252
+ for (const O of ["launch", "burst"]) {
253
+ const A = (m = h.anchors) == null ? void 0 : m[O], T = l.get(A);
254
+ if (!A || !((g = T == null ? void 0 : T.ks) != null && g.p)) {
255
+ x(i, F(
256
256
  "LOTTIE_EFFECT_ANCHOR_MISSING",
257
- `effects[${h}].anchors.${R}`,
258
- { scope: "effect", severity: "warning", effectIndex: h }
257
+ `effects[${f}].anchors.${O}`,
258
+ { scope: "effect", severity: "warning", effectIndex: f }
259
259
  ));
260
260
  continue;
261
261
  }
262
- const z = ue(N), P = [];
263
- B(
264
- N.ks.p,
265
- `${S}.ks.p`,
266
- P,
267
- S,
262
+ const L = ge(T), C = [];
263
+ J(
264
+ T.ks.p,
265
+ `${A}.ks.p`,
266
+ C,
267
+ A,
268
268
  [2, 3]
269
- ), ie(N.ks.p).some((f) => {
270
- const A = V(f);
271
- return !!A && A.length > 2 && A[2] !== 0;
272
- }) && z.push(F("LOTTIE_UNSUPPORTED_3D", `${S}.ks.p`, {
273
- layer: S
269
+ ), re(T.ks.p).some((E) => {
270
+ const u = B(E);
271
+ return !!u && u.length > 2 && u[2] !== 0;
272
+ }) && L.push(F("LOTTIE_UNSUPPORTED_3D", `${A}.ks.p`, {
273
+ layer: A
274
274
  }));
275
- for (const [f, A] of [
275
+ for (const [E, u] of [
276
276
  ["s", [100, 100, 100]],
277
277
  ["r", [0]],
278
278
  ["rz", [0]],
279
279
  ["o", [100]],
280
280
  ["a", [0, 0, 0]]
281
281
  ]) {
282
- const _ = N.ks[f];
283
- if (_ == null) continue;
284
- const D = ie(_);
285
- _.a !== 1 && D.length > 0 && D.every((Y) => {
286
- const W = V(Y);
287
- return !!W && W.length === A.length && W.every((X, $) => X === A[$]);
288
- }) || z.push(F(
282
+ const N = T.ks[E];
283
+ if (N == null) continue;
284
+ const z = re(N);
285
+ N.a !== 1 && z.length > 0 && z.every((W) => {
286
+ const j = B(W);
287
+ return !!j && j.length === u.length && j.every((X, V) => X === u[V]);
288
+ }) || L.push(F(
289
289
  "LOTTIE_UNSUPPORTED_TRANSFORM",
290
- `${S}.ks.${f}`,
291
- { layer: S }
290
+ `${A}.ks.${E}`,
291
+ { layer: A }
292
292
  ));
293
293
  }
294
- N.ty !== 3 && z.push(F("LOTTIE_UNSUPPORTED_LAYER_TYPE", S, {
295
- layer: S
294
+ T.ty !== 3 && L.push(F("LOTTIE_UNSUPPORTED_LAYER_TYPE", A, {
295
+ layer: A
296
296
  }));
297
- for (const f of [...z, ...P])
298
- L(i, F(f.code, f.where, {
297
+ for (const E of [...L, ...C])
298
+ x(i, F(E.code, E.where, {
299
299
  scope: "effect",
300
300
  severity: "warning",
301
- effectIndex: h,
302
- layer: S
301
+ effectIndex: f,
302
+ layer: A
303
303
  }));
304
304
  }
305
- for (const R of ["launch", "burst", "dismiss"]) {
306
- const S = (v = d.markers) == null ? void 0 : v[R], N = o.get(S);
307
- !S || !N ? L(i, F(
305
+ for (const O of ["launch", "burst", "dismiss"]) {
306
+ const A = (v = h.markers) == null ? void 0 : v[O], T = o.get(A);
307
+ !A || !T ? x(i, F(
308
308
  "LOTTIE_EFFECT_MARKER_MISSING",
309
- `effects[${h}].markers.${R}`,
310
- { scope: "effect", severity: "warning", effectIndex: h }
311
- )) : (!Number.isFinite(N.tm) || !Number.isFinite(N.dr) || N.dr < 0 || R === "launch" && N.dr <= 0) && L(i, F(
309
+ `effects[${f}].markers.${O}`,
310
+ { scope: "effect", severity: "warning", effectIndex: f }
311
+ )) : (!Number.isFinite(T.tm) || !Number.isFinite(T.dr) || T.dr < 0 || O === "launch" && T.dr <= 0) && x(i, F(
312
312
  "LOTTIE_EFFECT_MARKER_INVALID",
313
- `effects[${h}].markers.${R}`,
314
- { scope: "effect", severity: "warning", effectIndex: h }
313
+ `effects[${f}].markers.${O}`,
314
+ { scope: "effect", severity: "warning", effectIndex: f }
315
315
  ));
316
316
  }
317
- const w = o.get((y = d.markers) == null ? void 0 : y.launch), k = o.get((b = d.markers) == null ? void 0 : b.burst), E = o.get((g = d.markers) == null ? void 0 : g.dismiss), O = d.dismissDuration ?? ge, C = Number.isFinite(O) && O > 0;
318
- let M = null, T = C;
319
- if (C && E && Number.isFinite(E.tm) && Number.isFinite(e.fr) && e.fr > 0)
317
+ const p = o.get((b = h.markers) == null ? void 0 : b.launch), M = o.get((w = h.markers) == null ? void 0 : w.burst), y = o.get((k = h.markers) == null ? void 0 : k.dismiss), I = h.dismissDuration ?? we, _ = Number.isFinite(I) && I > 0;
318
+ let S = null, R = _;
319
+ if (_ && y && Number.isFinite(y.tm) && Number.isFinite(e.fr) && e.fr > 0)
320
320
  try {
321
- M = Ge({
321
+ S = Ye({
322
322
  frameRate: e.fr,
323
- dismissFrame: E.tm,
324
- durationSeconds: O
323
+ dismissFrame: y.tm,
324
+ durationSeconds: I
325
325
  });
326
326
  } catch {
327
- T = !1;
327
+ R = !1;
328
328
  }
329
- if (T || L(i, F(
329
+ if (R || x(i, F(
330
330
  "LOTTIE_EFFECT_DISMISS_DURATION_INVALID",
331
- `effects[${h}].dismissDuration`,
332
- { scope: "effect", severity: "warning", effectIndex: h }
333
- )), w && Number.isFinite(w.dr) && w.dr > 0 && Number.isFinite(e.fr) && e.fr > 0)
331
+ `effects[${f}].dismissDuration`,
332
+ { scope: "effect", severity: "warning", effectIndex: f }
333
+ )), p && Number.isFinite(p.dr) && p.dr > 0 && Number.isFinite(e.fr) && e.fr > 0)
334
334
  try {
335
- const R = t.fireworkEnvironment || {}, S = $e({
336
- ...R,
337
- quality: d.quality ?? R.quality ?? "auto"
335
+ const O = t.fireworkEnvironment || {}, A = $e({
336
+ ...O,
337
+ quality: h.quality ?? O.quality ?? "auto"
338
338
  });
339
- je(
340
- Ue({
341
- launchDuration: w.dr / e.fr,
342
- density: d.density ?? 1,
343
- resolvedQualityScale: S
339
+ Ge(
340
+ je({
341
+ launchDuration: p.dr / e.fr,
342
+ density: h.density ?? 1,
343
+ resolvedQualityScale: A
344
344
  }),
345
345
  t.maxInstancesPerBatch ?? Z
346
346
  );
347
- } catch (R) {
348
- L(i, F(
349
- (R == null ? void 0 : R.code) === de ? de : "LOTTIE_EFFECT_PARTICLE_CONFIG_INVALID",
350
- `effects[${h}]`,
351
- { scope: "effect", severity: "warning", effectIndex: h }
347
+ } catch (O) {
348
+ x(i, F(
349
+ (O == null ? void 0 : O.code) === me ? me : "LOTTIE_EFFECT_PARTICLE_CONFIG_INVALID",
350
+ `effects[${f}]`,
351
+ { scope: "effect", severity: "warning", effectIndex: f }
352
352
  ));
353
353
  }
354
- w && k && E && Number.isFinite(w.tm) && Number.isFinite(k.tm) && Number.isFinite(E.tm) && Number.isFinite(e.fr) && e.fr > 0 && M && !(w.tm / e.fr * 1e3 <= k.tm / e.fr * 1e3 && k.tm / e.fr * 1e3 < M.endMs) && L(i, F(
354
+ p && M && y && Number.isFinite(p.tm) && Number.isFinite(M.tm) && Number.isFinite(y.tm) && Number.isFinite(e.fr) && e.fr > 0 && S && !(p.tm / e.fr * 1e3 <= M.tm / e.fr * 1e3 && M.tm / e.fr * 1e3 < S.endMs) && x(i, F(
355
355
  "LOTTIE_EFFECT_TIMING_INVALID",
356
- `effects[${h}].markers`,
357
- { scope: "effect", severity: "warning", effectIndex: h }
356
+ `effects[${f}].markers`,
357
+ { scope: "effect", severity: "warning", effectIndex: f }
358
358
  ));
359
359
  }
360
360
  return i;
361
361
  }
362
- function Ke(e, t, i, s) {
363
- const r = Math.max(e.length, t.length, i.length, s.length), n = [];
364
- let l = 0, a = null;
365
- for (let o = 0; o < Te; o += 1) {
366
- const c = o / (Te - 1), u = 1 - c, m = Array.from({ length: r }, (v, y) => {
367
- const b = e[y] ?? 0, g = t[y] ?? b, h = b + (i[y] ?? 0), d = g + (s[y] ?? 0);
368
- return u ** 3 * b + 3 * u ** 2 * c * h + 3 * u * c ** 2 * d + c ** 3 * g;
369
- }), p = a ? Math.sqrt(m.reduce(
370
- (v, y, b) => v + (y - a[b]) ** 2,
362
+ function Ke(e, t, i, r) {
363
+ const s = Math.max(e.length, t.length, i.length, r.length), n = [];
364
+ let c = 0, a = null;
365
+ for (let o = 0; o < Re; o += 1) {
366
+ const l = o / (Re - 1), d = 1 - l, m = Array.from({ length: s }, (v, b) => {
367
+ const w = e[b] ?? 0, k = t[b] ?? w, f = w + (i[b] ?? 0), h = k + (r[b] ?? 0);
368
+ return d ** 3 * w + 3 * d ** 2 * l * f + 3 * d * l ** 2 * h + l ** 3 * k;
369
+ }), g = a ? Math.sqrt(m.reduce(
370
+ (v, b, w) => v + (b - a[w]) ** 2,
371
371
  0
372
372
  )) : 0;
373
- l += p, n.push({ partialLength: p, point: m }), a = m;
373
+ c += g, n.push({ partialLength: g, point: m }), a = m;
374
374
  }
375
- return { points: n, segmentLength: l };
375
+ return { points: n, segmentLength: c };
376
376
  }
377
- function et(e, t, i) {
378
- let s = Re.get(e);
379
- return s || (s = Ke(t, i, e.to, e.ti), Re.set(e, s)), s;
377
+ function tt(e, t, i) {
378
+ let r = Ae.get(e);
379
+ return r || (r = Ke(t, i, e.to, e.ti), Ae.set(e, r)), r;
380
380
  }
381
- function We(e, t) {
382
- const i = Math.max(0, Math.min(1, e)), s = t.segmentLength * i;
383
- let r = 0;
381
+ function Xe(e, t) {
382
+ const i = Math.max(0, Math.min(1, e)), r = t.segmentLength * i;
383
+ let s = 0;
384
384
  for (let n = 0; n < t.points.length; n += 1) {
385
- const l = t.points[n];
386
- if (r += l.partialLength, s === 0 || i === 0 || n === t.points.length - 1)
387
- return l.point.slice();
385
+ const c = t.points[n];
386
+ if (s += c.partialLength, r === 0 || i === 0 || n === t.points.length - 1)
387
+ return c.point.slice();
388
388
  const a = t.points[n + 1];
389
- if (s >= r && s < r + a.partialLength) {
390
- const o = (s - r) / a.partialLength;
391
- return l.point.map(
392
- (c, u) => c + (a.point[u] - c) * o
389
+ if (r >= s && r < s + a.partialLength) {
390
+ const o = (r - s) / a.partialLength;
391
+ return c.point.map(
392
+ (l, d) => l + (a.point[d] - l) * o
393
393
  );
394
394
  }
395
395
  }
396
396
  return t.points[t.points.length - 1].point.slice();
397
397
  }
398
- function Ct(e, t, i, s, r) {
399
- return We(
398
+ function Lt(e, t, i, r, s) {
399
+ return Xe(
400
400
  e,
401
- Ke(t, i, s, r)
401
+ Ke(t, i, r, s)
402
402
  );
403
403
  }
404
- function q(e, t, i) {
405
- if (!e || e.a === 0) return te(e == null ? void 0 : e.k, i);
406
- const s = e.k, r = s.findIndex((v, y) => {
407
- const b = s[y + 1];
408
- return !b || t < b.t;
409
- }), n = s[Math.max(r, 0)], l = s[r + 1];
410
- if (!l || t <= n.t || n.h === 1) return te(n.s, i);
411
- const a = te(n.s, i), o = te(n.e || l.s, a), c = Math.max(0, Math.min(1, (t - n.t) / (l.t - n.t))), u = oe(n, "o", 0), m = oe(n, "i", 0) || oe(l, "i", 0), p = u && m ? He(c, u, m) : c;
412
- return Array.isArray(n.to) && Array.isArray(n.ti) ? We(p, et(n, a, o)) : a.map((v, y) => v + ((o[y] ?? v) - v) * p);
413
- }
414
- function tt(e) {
404
+ function H(e, t, i) {
405
+ if (!e || e.a === 0) return ie(e == null ? void 0 : e.k, i);
406
+ const r = e.k, s = r.findIndex((v, b) => {
407
+ const w = r[b + 1];
408
+ return !w || t < w.t;
409
+ }), n = r[Math.max(s, 0)], c = r[s + 1];
410
+ if (!c || t <= n.t || n.h === 1) return ie(n.s, i);
411
+ const a = ie(n.s, i), o = ie(n.e || c.s, a), l = Math.max(0, Math.min(1, (t - n.t) / (c.t - n.t))), d = ce(n, "o", 0), m = ce(n, "i", 0) || ce(c, "i", 0), g = d && m ? Qe(l, d, m) : l;
412
+ return Array.isArray(n.to) && Array.isArray(n.ti) ? Xe(g, tt(n, a, o)) : a.map((v, b) => v + ((o[b] ?? v) - v) * g);
413
+ }
414
+ function it(e) {
415
415
  return 1 - (1 - e) ** 3;
416
416
  }
417
- function Pt(e) {
417
+ function zt(e) {
418
418
  return e < 0.5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2;
419
419
  }
420
- function pe(e, t) {
420
+ function be(e, t) {
421
421
  return e == null ? void 0 : e.find((i) => i.cm === t);
422
422
  }
423
- const le = Math.PI * 2, it = Object.freeze({
423
+ const fe = Math.PI * 2, rt = Object.freeze({
424
424
  glow: [22, 22],
425
425
  spark: [10, 22],
426
426
  star: [24, 24],
@@ -428,30 +428,30 @@ const le = Math.PI * 2, it = Object.freeze({
428
428
  petal: [18, 24],
429
429
  flash: [96, 96]
430
430
  });
431
- function st(e, { type: t, color: i, width: s, height: r }, n = 0, l = 0) {
432
- e.save(), e.translate(n, l);
433
- const a = s / 2, o = r / 2;
431
+ function st(e, { type: t, color: i, width: r, height: s }, n = 0, c = 0) {
432
+ e.save(), e.translate(n, c);
433
+ const a = r / 2, o = s / 2;
434
434
  if (t === "glow" || t === "smoke" || t === "flash") {
435
- const c = e.createRadialGradient(a, o, 0, a, o, s / 2);
436
- c.addColorStop(0, t === "smoke" ? i : "#ffffff"), c.addColorStop(t === "flash" ? 0.22 : 0.3, i), c.addColorStop(1, "rgba(255,255,255,0)"), e.fillStyle = c, e.fillRect(0, 0, s, r);
435
+ const l = e.createRadialGradient(a, o, 0, a, o, r / 2);
436
+ l.addColorStop(0, t === "smoke" ? i : "#ffffff"), l.addColorStop(t === "flash" ? 0.22 : 0.3, i), l.addColorStop(1, "rgba(255,255,255,0)"), e.fillStyle = l, e.fillRect(0, 0, r, s);
437
437
  } else if (t === "spark") {
438
- const c = e.createLinearGradient(a, r, a, 0);
439
- c.addColorStop(0, "rgba(255,255,255,0)"), c.addColorStop(0.46, i), c.addColorStop(1, "rgba(255,255,255,0)"), e.fillStyle = c, e.fillRect(0, 0, s, r), e.fillStyle = "#ffffff", e.beginPath(), e.arc(a, o * 0.72, 5, 0, le), e.fill();
438
+ const l = e.createLinearGradient(a, s, a, 0);
439
+ l.addColorStop(0, "rgba(255,255,255,0)"), l.addColorStop(0.46, i), l.addColorStop(1, "rgba(255,255,255,0)"), e.fillStyle = l, e.fillRect(0, 0, r, s), e.fillStyle = "#ffffff", e.beginPath(), e.arc(a, o * 0.72, 5, 0, fe), e.fill();
440
440
  } else if (t === "star")
441
- e.strokeStyle = i, e.fillStyle = "#ffffff", e.lineCap = "round", e.lineWidth = 2, e.beginPath(), e.moveTo(a, 1), e.lineTo(a, r - 1), e.moveTo(1, o), e.lineTo(s - 1, o), e.moveTo(5, 5), e.lineTo(s - 5, r - 5), e.moveTo(s - 5, 5), e.lineTo(5, r - 5), e.stroke(), e.beginPath(), e.arc(a, o, 4, 0, le), e.fill();
441
+ e.strokeStyle = i, e.fillStyle = "#ffffff", e.lineCap = "round", e.lineWidth = 2, e.beginPath(), e.moveTo(a, 1), e.lineTo(a, s - 1), e.moveTo(1, o), e.lineTo(r - 1, o), e.moveTo(5, 5), e.lineTo(r - 5, s - 5), e.moveTo(r - 5, 5), e.lineTo(5, s - 5), e.stroke(), e.beginPath(), e.arc(a, o, 4, 0, fe), e.fill();
442
442
  else if (t === "petal") {
443
443
  e.save(), e.translate(a, o), e.rotate(-0.32), e.scale(0.72, 1);
444
- const c = e.createLinearGradient(0, -r / 2, 0, r / 2);
445
- c.addColorStop(0, "#ffffff"), c.addColorStop(0.42, i), c.addColorStop(1, "rgba(105, 0, 25, 0.5)"), e.fillStyle = c, e.beginPath(), e.ellipse(0, 0, 8, 15, 0, 0, le), e.fill(), e.restore();
444
+ const l = e.createLinearGradient(0, -s / 2, 0, s / 2);
445
+ l.addColorStop(0, "#ffffff"), l.addColorStop(0.42, i), l.addColorStop(1, "rgba(105, 0, 25, 0.5)"), e.fillStyle = l, e.beginPath(), e.ellipse(0, 0, 8, 15, 0, 0, fe), e.fill(), e.restore();
446
446
  } else
447
447
  throw e.restore(), new Error(`未知 firework texture 类型:${t}`);
448
448
  e.restore();
449
449
  }
450
- const K = Math.PI * 2, rt = Object.freeze(["#ff385c", "#ffad38", "#ffe095"]), nt = 20260808;
451
- function ot(e, t = 0, i = 1) {
450
+ const K = Math.PI * 2, nt = Object.freeze(["#ff385c", "#ffad38", "#ffe095"]), ot = 20260808;
451
+ function at(e, t = 0, i = 1) {
452
452
  return Math.max(t, Math.min(i, e));
453
453
  }
454
- function at(e) {
454
+ function ct(e) {
455
455
  let t = e >>> 0;
456
456
  return () => {
457
457
  t += 1831565813;
@@ -460,69 +460,69 @@ function at(e) {
460
460
  };
461
461
  }
462
462
  function lt(e) {
463
- const t = e ?? nt;
463
+ const t = e ?? ot;
464
464
  if (!Number.isInteger(t) || t < 0 || t > 4294967295)
465
465
  throw new Error("firework seed 必须是 0 到 4294967295 之间的整数");
466
466
  return t;
467
467
  }
468
- function Ae(e, t, i = 1, s = !1) {
468
+ function Oe(e, t, i = 1, r = !1) {
469
469
  if (!Number.isFinite(t)) throw new Error("firework envelope 时间必须是有限毫秒值");
470
470
  if (!(e != null && e.length)) return i;
471
- const r = s ? t - 1e-6 : t;
472
- if (r < e[0].startMs) return e[0].from;
471
+ const s = r ? t - 1e-6 : t;
472
+ if (s < e[0].startMs) return e[0].from;
473
473
  let n = e[0].from;
474
- for (const l of e) {
475
- if (r < l.startMs) return n;
476
- if (r < l.endMs) {
477
- if (l.interpolation === "hold") return l.from;
478
- const a = (r - l.startMs) / (l.endMs - l.startMs);
479
- return l.from + (l.to - l.from) * a;
474
+ for (const c of e) {
475
+ if (s < c.startMs) return n;
476
+ if (s < c.endMs) {
477
+ if (c.interpolation === "hold") return c.from;
478
+ const a = (s - c.startMs) / (c.endMs - c.startMs);
479
+ return c.from + (c.to - c.from) * a;
480
480
  }
481
- n = l.to;
481
+ n = c.to;
482
482
  }
483
483
  return n;
484
484
  }
485
- function ct(e, t, i, s, r) {
486
- const n = 1 - r, l = n ** 3, a = 3 * n * n * r, o = 3 * n * r * r, c = r ** 3;
485
+ function ft(e, t, i, r, s) {
486
+ const n = 1 - s, c = n ** 3, a = 3 * n * n * s, o = 3 * n * s * s, l = s ** 3;
487
487
  return {
488
- x: l * e.x + a * t.x + o * i.x + c * s.x,
489
- y: l * e.y + a * t.y + o * i.y + c * s.y
488
+ x: c * e.x + a * t.x + o * i.x + l * r.x,
489
+ y: c * e.y + a * t.y + o * i.y + l * r.y
490
490
  };
491
491
  }
492
- function ce(e, t) {
493
- var r;
494
- const i = e.markers || ((r = e.lottie) == null ? void 0 : r.markers) || [], s = i instanceof Map ? i.get(t) : pe(i, t);
495
- if (!s) throw new Error(`Lottie 中缺少效果 marker:${t}`);
496
- return s;
492
+ function he(e, t) {
493
+ var s;
494
+ const i = e.markers || ((s = e.lottie) == null ? void 0 : s.markers) || [], r = i instanceof Map ? i.get(t) : be(i, t);
495
+ if (!r) throw new Error(`Lottie 中缺少效果 marker:${t}`);
496
+ return r;
497
497
  }
498
- function Oe(e, t, i, s) {
498
+ function Ie(e, t, i, r) {
499
499
  var a, o;
500
500
  if (typeof e.resolveAnchor == "function") {
501
- const c = e.resolveAnchor(t, i);
501
+ const l = e.resolveAnchor(t, i);
502
502
  return {
503
- x: c.x * s.scale + s.offsetX,
504
- y: c.y * s.scale + s.offsetY
503
+ x: l.x * r.scale + r.offsetX,
504
+ y: l.y * r.scale + r.offsetY
505
505
  };
506
506
  }
507
- const r = (a = e.layers) == null ? void 0 : a.get(t);
508
- if (!((o = r == null ? void 0 : r.ks) != null && o.p)) throw new Error(`Lottie 中缺少效果锚点图层:${t}`);
509
- const [n, l] = q(r.ks.p, i, [0, 0, 0]);
507
+ const s = (a = e.layers) == null ? void 0 : a.get(t);
508
+ if (!((o = s == null ? void 0 : s.ks) != null && o.p)) throw new Error(`Lottie 中缺少效果锚点图层:${t}`);
509
+ const [n, c] = H(s.ks.p, i, [0, 0, 0]);
510
510
  return {
511
- x: n * s.scale + s.offsetX,
512
- y: l * s.scale + s.offsetY
511
+ x: n * r.scale + r.offsetX,
512
+ y: c * r.scale + r.offsetY
513
513
  };
514
514
  }
515
- function me(e, t) {
515
+ function pe(e, t) {
516
516
  return `${e}:${String(t).trim().toLowerCase()}`;
517
517
  }
518
- function Xe(e) {
519
- return Object.freeze(rt.map((t, i) => {
520
- const s = e == null ? void 0 : e[i];
521
- return typeof s == "string" && s.trim() ? s.trim() : t;
518
+ function Ve(e) {
519
+ return Object.freeze(nt.map((t, i) => {
520
+ const r = e == null ? void 0 : e[i];
521
+ return typeof r == "string" && r.trim() ? r.trim() : t;
522
522
  }));
523
523
  }
524
- function Ve(e = {}) {
525
- const t = Xe(e.colors), i = [
524
+ function Be(e = {}) {
525
+ const t = Ve(e.colors), i = [
526
526
  ["glow", "#ffffff"],
527
527
  ["spark", t[1]],
528
528
  ["glow", t[0]],
@@ -532,23 +532,23 @@ function Ve(e = {}) {
532
532
  ["glow", t[2] || t[1]],
533
533
  ["petal", t[0]],
534
534
  ["flash", t[0]]
535
- ], s = [], r = /* @__PURE__ */ new Set();
536
- for (const [n, l] of i) {
537
- const a = me(n, l);
538
- if (r.has(a)) continue;
539
- r.add(a);
540
- const [o, c] = it[n];
541
- s.push(Object.freeze({ key: a, type: n, color: l, width: o, height: c }));
535
+ ], r = [], s = /* @__PURE__ */ new Set();
536
+ for (const [n, c] of i) {
537
+ const a = pe(n, c);
538
+ if (s.has(a)) continue;
539
+ s.add(a);
540
+ const [o, l] = rt[n];
541
+ r.push(Object.freeze({ key: a, type: n, color: c, width: o, height: l }));
542
542
  }
543
543
  return Object.freeze({
544
- key: JSON.stringify(s.map(({ key: n, width: l, height: a }) => [n, l, a])),
545
- cells: Object.freeze(s)
544
+ key: JSON.stringify(r.map(({ key: n, width: c, height: a }) => [n, c, a])),
545
+ cells: Object.freeze(r)
546
546
  });
547
547
  }
548
- function ft({ startMs: e, endMs: t }) {
548
+ function ht({ startMs: e, endMs: t }) {
549
549
  return Object.freeze([Object.freeze({ startMs: e, endMs: t, from: 1, to: 0, interpolation: "linear" })]);
550
550
  }
551
- function ht(e) {
551
+ function dt(e) {
552
552
  const t = e * 1e3;
553
553
  return Object.freeze([
554
554
  Object.freeze({ startMs: t, endMs: t + 28.8, from: 0, to: 1, interpolation: "linear" }),
@@ -556,7 +556,7 @@ function ht(e) {
556
556
  Object.freeze({ startMs: t + 100.8, endMs: t + 360, from: 0.5184, to: 0, interpolation: "linear" })
557
557
  ]);
558
558
  }
559
- function dt(e) {
559
+ function ut(e) {
560
560
  const t = e * 1e3;
561
561
  return Object.freeze([
562
562
  Object.freeze({ startMs: t, endMs: t + 43.2, from: 0.18, to: 1.35, interpolation: "linear" }),
@@ -564,150 +564,189 @@ function dt(e) {
564
564
  Object.freeze({ startMs: t + 115.2, endMs: t + 360, from: 0.78, to: 2.25, interpolation: "linear" })
565
565
  ]);
566
566
  }
567
- function ut({
567
+ function mt({
568
568
  effect: e,
569
569
  composition: t,
570
570
  layout: i = { scale: 1, offsetX: 0, offsetY: 0 },
571
- resolvedQualityScale: s = 1,
572
- seed: r = e == null ? void 0 : e.seed,
571
+ resolvedQualityScale: r = 1,
572
+ seed: s = e == null ? void 0 : e.seed,
573
573
  maxParticleCount: n = Z * 2,
574
- maxInstancesPerBatch: l = Z
574
+ maxInstancesPerBatch: c = Z
575
575
  }) {
576
- var X, $, se, we, be, ye, Ee;
577
- const a = lt(r), o = t.frameRate ?? ((X = t.lottie) == null ? void 0 : X.fr);
578
- if (![o, i.scale, i.offsetX, i.offsetY, s].every(Number.isFinite) || !(o > 0)) throw new Error("firework 编译参数包含非有限数值");
579
- const c = ce(t, ($ = e.markers) == null ? void 0 : $.launch), u = ce(t, (se = e.markers) == null ? void 0 : se.burst), m = ce(t, (we = e.markers) == null ? void 0 : we.dismiss);
580
- for (const U of [c, u, m])
581
- if (!Number.isFinite(U.tm) || !Number.isFinite(U.dr) || U.dr < 0)
582
- throw new Error(`firework marker 无效:${U.cm}`);
583
- const p = e.dismissDuration ?? ge, v = e.density ?? 1, y = e.formationRadius ?? 200;
584
- if (!Number.isFinite(p) || p <= 0 || !Number.isFinite(v) || v < 0 || !Number.isFinite(y) || y < 0) throw new Error("firework dismissDuration 必须是正数,其他效果参数必须是有限非负数");
585
- const b = c.tm / o, g = c.dr / o, h = u.tm / o, d = Ge({
576
+ var X, V, Y, se, ye, Ee, Se;
577
+ const a = lt(s), o = t.frameRate ?? ((X = t.lottie) == null ? void 0 : X.fr);
578
+ if (![o, i.scale, i.offsetX, i.offsetY, r].every(Number.isFinite) || !(o > 0)) throw new Error("firework 编译参数包含非有限数值");
579
+ const l = he(t, (V = e.markers) == null ? void 0 : V.launch), d = he(t, (Y = e.markers) == null ? void 0 : Y.burst), m = he(t, (se = e.markers) == null ? void 0 : se.dismiss);
580
+ for (const $ of [l, d, m])
581
+ if (!Number.isFinite($.tm) || !Number.isFinite($.dr) || $.dr < 0)
582
+ throw new Error(`firework marker 无效:${$.cm}`);
583
+ const g = e.dismissDuration ?? we, v = e.density ?? 1, b = e.formationRadius ?? 200;
584
+ if (!Number.isFinite(g) || g <= 0 || !Number.isFinite(v) || v < 0 || !Number.isFinite(b) || b < 0) throw new Error("firework dismissDuration 必须是正数,其他效果参数必须是有限非负数");
585
+ const w = l.tm / o, k = l.dr / o, f = d.tm / o, h = Ye({
586
586
  frameRate: o,
587
587
  dismissFrame: m.tm,
588
- durationSeconds: p
589
- }), w = d.startSeconds;
590
- if (!(b <= h && h * 1e3 < d.endMs))
588
+ durationSeconds: g
589
+ }), p = h.startSeconds;
590
+ if (!(w <= f && f * 1e3 < h.endMs))
591
591
  throw new Error("firework marker 时间顺序无效");
592
- const k = Oe(t, (be = e.anchors) == null ? void 0 : be.launch, c.tm, i), E = Oe(t, (ye = e.anchors) == null ? void 0 : ye.burst, u.tm, i), O = (t.width ?? ((Ee = t.lottie) == null ? void 0 : Ee.w) ?? 0) * i.scale, C = y * i.scale, M = Xe(e.colors), T = v * s;
593
- if (!Number.isFinite(T)) throw new Error("firework quality 参数无效");
594
- const R = je(
595
- Ue({
596
- launchDuration: g,
592
+ const M = Ie(t, (ye = e.anchors) == null ? void 0 : ye.launch, l.tm, i), y = Ie(t, (Ee = e.anchors) == null ? void 0 : Ee.burst, d.tm, i), I = (t.width ?? ((Se = t.lottie) == null ? void 0 : Se.w) ?? 0) * i.scale, _ = b * i.scale, S = Ve(e.colors), R = v * r;
593
+ if (!Number.isFinite(R)) throw new Error("firework quality 参数无效");
594
+ const O = Ge(
595
+ je({
596
+ launchDuration: k,
597
597
  density: v,
598
- resolvedQualityScale: s
598
+ resolvedQualityScale: r
599
599
  }),
600
- l
600
+ c
601
601
  );
602
- if (R.totalCount > n)
602
+ if (O.totalCount > n)
603
603
  throw new Error(`firework 粒子数量超过安全上限:${n}`);
604
- const S = at(a), N = [], z = (U) => {
605
- const I = ot((U - b) / Math.max(g, 1e-3)), ne = I * I, Q = Math.min(O * 0.08, 30 * i.scale), ee = Math.abs(k.y - E.y);
606
- return ct(
607
- k,
608
- { x: k.x - Q, y: k.y - ee * 0.34 },
609
- { x: E.x + Q * 0.55, y: E.y + ee * 0.28 },
610
- E,
611
- ne
604
+ const A = ct(a), T = [], L = ($) => {
605
+ const P = at(($ - w) / Math.max(k, 1e-3)), ae = P * P, ee = Math.min(I * 0.08, 30 * i.scale), te = Math.abs(M.y - y.y);
606
+ return ft(
607
+ M,
608
+ { x: M.x - ee, y: M.y - te * 0.34 },
609
+ { x: y.x + ee * 0.55, y: y.y + te * 0.28 },
610
+ y,
611
+ ae
612
612
  );
613
- }, P = (U, I) => {
614
- const ne = R.emitterCounts[U];
615
- for (let Q = 0; Q < ne; Q += 1) {
616
- const ee = I.start + S() * (I.end - I.start), Se = I.angle + (S() - 0.5) * I.angleRange, ke = Math.max(0, I.velocity + (S() - 0.5) * 2 * I.velocityRange), Me = I.origin(ee);
617
- N.push(Object.freeze({
618
- emitterIndex: U,
619
- type: I.type,
620
- color: I.color,
621
- cellKey: me(I.type, I.color),
622
- blend: I.blend,
623
- birthTime: ee,
624
- lifetime: Math.max(0.08, I.lifetime + (S() - 0.5) * 2 * I.lifetimeRange),
625
- x: Me.x,
626
- y: Me.y,
627
- vx: Math.cos(Se) * ke,
628
- vy: Math.sin(Se) * ke,
629
- ax: I.gravityX || 0,
630
- ay: I.gravityY || 0,
631
- scale: Math.max(0.08, I.scale + (S() - 0.5) * 2 * (I.scaleRange || 0)),
632
- scaleSpeed: I.scaleSpeed || -0.16,
633
- rotation: S() * K,
634
- spin: (I.spin || 0) + (S() - 0.5) * 2 * (I.spinRange || 0)
613
+ }, C = ($, P) => {
614
+ const ae = O.emitterCounts[$];
615
+ for (let ee = 0; ee < ae; ee += 1) {
616
+ const te = P.start + A() * (P.end - P.start), Me = P.angle + (A() - 0.5) * P.angleRange, ke = Math.max(0, P.velocity + (A() - 0.5) * 2 * P.velocityRange), ve = P.origin(te);
617
+ T.push(Object.freeze({
618
+ emitterIndex: $,
619
+ type: P.type,
620
+ color: P.color,
621
+ cellKey: pe(P.type, P.color),
622
+ blend: P.blend,
623
+ birthTime: te,
624
+ lifetime: Math.max(0.08, P.lifetime + (A() - 0.5) * 2 * P.lifetimeRange),
625
+ x: ve.x,
626
+ y: ve.y,
627
+ vx: Math.cos(Me) * ke,
628
+ vy: Math.sin(Me) * ke,
629
+ ax: P.gravityX || 0,
630
+ ay: P.gravityY || 0,
631
+ scale: Math.max(0.08, P.scale + (A() - 0.5) * 2 * (P.scaleRange || 0)),
632
+ scaleSpeed: P.scaleSpeed || -0.16,
633
+ rotation: A() * K,
634
+ spin: (P.spin || 0) + (A() - 0.5) * 2 * (P.spinRange || 0)
635
635
  }));
636
636
  }
637
- }, j = b + g * 0.84;
638
- P(0, { type: "glow", color: "#ffffff", blend: "lighter", rate: 105, start: b, end: j, lifetime: 0.24, lifetimeRange: 0.08, velocity: 24 * i.scale, velocityRange: 10 * i.scale, angle: 0, angleRange: K, gravityY: 0, scale: 0.72, scaleRange: 0.24, origin: z }), P(1, { type: "spark", color: M[1], blend: "lighter", rate: 78, start: b, end: j, lifetime: 0.42, lifetimeRange: 0.12, velocity: 38 * i.scale, velocityRange: 18 * i.scale, angle: Math.PI / 2, angleRange: Math.PI * 0.72, gravityY: 38 * i.scale, scale: 0.9, scaleRange: 0.32, spin: 1.4, spinRange: 2.8, origin: z }), P(2, { type: "glow", color: M[0], blend: "lighter", rate: 48, start: b, end: j, lifetime: 0.5, lifetimeRange: 0.16, velocity: 30 * i.scale, velocityRange: 16 * i.scale, angle: Math.PI / 2, angleRange: Math.PI * 0.88, gravityY: 32 * i.scale, scale: 0.5, scaleRange: 0.2, origin: z }), P(3, { type: "smoke", color: "rgba(184, 184, 184, 0.24)", blend: "source-over", rate: 18, start: b, end: j, lifetime: 0.72, lifetimeRange: 0.18, velocity: 18 * i.scale, velocityRange: 9 * i.scale, angle: 0, angleRange: K, gravityY: -8 * i.scale, scale: 0.9, scaleRange: 0.32, scaleSpeed: 0.24, origin: z });
639
- const f = Math.max(C * 1.22, 118 * i.scale);
640
- P(4, { type: "spark", color: M[1], blend: "lighter", rate: 390, start: h, end: h + 0.11, lifetime: 1.18, lifetimeRange: 0.28, velocity: f, velocityRange: f * 0.42, angle: 0, angleRange: K, gravityY: 72 * i.scale, scale: 0.5, scaleRange: 0.19, scaleSpeed: -0.1, spin: 1.8, spinRange: 4.2, origin: () => E }), P(5, { type: "spark", color: M[0], blend: "lighter", rate: 275, start: h, end: h + 0.11, lifetime: 1.38, lifetimeRange: 0.34, velocity: f * 0.82, velocityRange: f * 0.46, angle: 0, angleRange: K, gravityY: 84 * i.scale, scale: 0.4, scaleRange: 0.15, scaleSpeed: -0.1, spin: -1.2, spinRange: 4.8, origin: () => E }), P(6, { type: "glow", color: "#ffffff", blend: "lighter", rate: 145, start: h, end: h + 0.11, lifetime: 0.62, lifetimeRange: 0.12, velocity: f * 0.68, velocityRange: f * 0.26, angle: 0, angleRange: K, gravityY: 46 * i.scale, scale: 0.44, scaleRange: 0.17, scaleSpeed: -0.1, origin: () => E });
641
- const A = h + 0.12, _ = Math.max(C * 0.74, 76 * i.scale);
642
- P(7, { type: "star", color: "#ffffff", blend: "lighter", rate: 265, start: A, end: A + 0.14, lifetime: 1.5, lifetimeRange: 0.38, velocity: _, velocityRange: _ * 0.48, angle: 0, angleRange: K, gravityY: 62 * i.scale, scale: 0.4, scaleRange: 0.18, scaleSpeed: -0.055, spin: 1.8, spinRange: 5.6, origin: () => E }), P(8, { type: "glow", color: M[2] || M[1], blend: "lighter", rate: 175, start: A, end: A + 0.14, lifetime: 1.72, lifetimeRange: 0.42, velocity: _ * 0.72, velocityRange: _ * 0.5, angle: 0, angleRange: K, gravityY: 74 * i.scale, scale: 0.24, scaleRange: 0.12, scaleSpeed: -0.035, origin: () => E }), P(9, { type: "petal", color: M[0], blend: "lighter", rate: 48, start: A, end: A + 0.14, lifetime: 1.55, lifetimeRange: 0.32, velocity: _ * 0.62, velocityRange: _ * 0.38, angle: 0, angleRange: K, gravityX: 5 * i.scale, gravityY: 86 * i.scale, scale: 0.62, scaleRange: 0.26, scaleSpeed: -0.08, spin: 2.4, spinRange: 6.2, origin: () => E });
643
- const D = [], G = [];
644
- for (const U of N) (U.blend === "source-over" ? D : G).push(U);
645
- const Y = ft(d), W = Object.freeze({
637
+ }, U = w + k * 0.84;
638
+ C(0, { type: "glow", color: "#ffffff", blend: "lighter", rate: 105, start: w, end: U, lifetime: 0.24, lifetimeRange: 0.08, velocity: 24 * i.scale, velocityRange: 10 * i.scale, angle: 0, angleRange: K, gravityY: 0, scale: 0.72, scaleRange: 0.24, origin: L }), C(1, { type: "spark", color: S[1], blend: "lighter", rate: 78, start: w, end: U, lifetime: 0.42, lifetimeRange: 0.12, velocity: 38 * i.scale, velocityRange: 18 * i.scale, angle: Math.PI / 2, angleRange: Math.PI * 0.72, gravityY: 38 * i.scale, scale: 0.9, scaleRange: 0.32, spin: 1.4, spinRange: 2.8, origin: L }), C(2, { type: "glow", color: S[0], blend: "lighter", rate: 48, start: w, end: U, lifetime: 0.5, lifetimeRange: 0.16, velocity: 30 * i.scale, velocityRange: 16 * i.scale, angle: Math.PI / 2, angleRange: Math.PI * 0.88, gravityY: 32 * i.scale, scale: 0.5, scaleRange: 0.2, origin: L }), C(3, { type: "smoke", color: "rgba(184, 184, 184, 0.24)", blend: "source-over", rate: 18, start: w, end: U, lifetime: 0.72, lifetimeRange: 0.18, velocity: 18 * i.scale, velocityRange: 9 * i.scale, angle: 0, angleRange: K, gravityY: -8 * i.scale, scale: 0.9, scaleRange: 0.32, scaleSpeed: 0.24, origin: L });
639
+ const E = Math.max(_ * 1.22, 118 * i.scale);
640
+ C(4, { type: "spark", color: S[1], blend: "lighter", rate: 390, start: f, end: f + 0.11, lifetime: 1.18, lifetimeRange: 0.28, velocity: E, velocityRange: E * 0.42, angle: 0, angleRange: K, gravityY: 72 * i.scale, scale: 0.5, scaleRange: 0.19, scaleSpeed: -0.1, spin: 1.8, spinRange: 4.2, origin: () => y }), C(5, { type: "spark", color: S[0], blend: "lighter", rate: 275, start: f, end: f + 0.11, lifetime: 1.38, lifetimeRange: 0.34, velocity: E * 0.82, velocityRange: E * 0.46, angle: 0, angleRange: K, gravityY: 84 * i.scale, scale: 0.4, scaleRange: 0.15, scaleSpeed: -0.1, spin: -1.2, spinRange: 4.8, origin: () => y }), C(6, { type: "glow", color: "#ffffff", blend: "lighter", rate: 145, start: f, end: f + 0.11, lifetime: 0.62, lifetimeRange: 0.12, velocity: E * 0.68, velocityRange: E * 0.26, angle: 0, angleRange: K, gravityY: 46 * i.scale, scale: 0.44, scaleRange: 0.17, scaleSpeed: -0.1, origin: () => y });
641
+ const u = f + 0.12, N = Math.max(_ * 0.74, 76 * i.scale);
642
+ C(7, { type: "star", color: "#ffffff", blend: "lighter", rate: 265, start: u, end: u + 0.14, lifetime: 1.5, lifetimeRange: 0.38, velocity: N, velocityRange: N * 0.48, angle: 0, angleRange: K, gravityY: 62 * i.scale, scale: 0.4, scaleRange: 0.18, scaleSpeed: -0.055, spin: 1.8, spinRange: 5.6, origin: () => y }), C(8, { type: "glow", color: S[2] || S[1], blend: "lighter", rate: 175, start: u, end: u + 0.14, lifetime: 1.72, lifetimeRange: 0.42, velocity: N * 0.72, velocityRange: N * 0.5, angle: 0, angleRange: K, gravityY: 74 * i.scale, scale: 0.24, scaleRange: 0.12, scaleSpeed: -0.035, origin: () => y }), C(9, { type: "petal", color: S[0], blend: "lighter", rate: 48, start: u, end: u + 0.14, lifetime: 1.55, lifetimeRange: 0.32, velocity: N * 0.62, velocityRange: N * 0.38, angle: 0, angleRange: K, gravityX: 5 * i.scale, gravityY: 86 * i.scale, scale: 0.62, scaleRange: 0.26, scaleSpeed: -0.08, spin: 2.4, spinRange: 6.2, origin: () => y });
643
+ const z = [], G = [];
644
+ for (const $ of T) ($.blend === "source-over" ? z : G).push($);
645
+ const W = ht(h), j = Object.freeze({
646
646
  type: "flash",
647
- color: M[0],
648
- cellKey: me("flash", M[0]),
649
- x: E.x,
650
- y: E.y,
651
- birthTime: h,
647
+ color: S[0],
648
+ cellKey: pe("flash", S[0]),
649
+ x: y.x,
650
+ y: y.y,
651
+ birthTime: f,
652
652
  lifetime: 0.36,
653
- opacityEnvelope: ht(h),
654
- sizeEnvelope: dt(h)
653
+ opacityEnvelope: dt(f),
654
+ sizeEnvelope: ut(f)
655
655
  });
656
656
  return Object.freeze({
657
657
  seed: a,
658
- palette: M,
659
- atlasRecipeKey: Ve(e).key,
660
- timeline: Object.freeze({ launchStart: b, launchDuration: g, burstStart: h, dismissStart: w, dismissDuration: p }),
661
- launchPoint: Object.freeze(k),
662
- burstPoint: Object.freeze(E),
663
- particles: Object.freeze(N),
664
- smoke: Object.freeze(D),
658
+ palette: S,
659
+ atlasRecipeKey: Be(e).key,
660
+ timeline: Object.freeze({ launchStart: w, launchDuration: k, burstStart: f, dismissStart: p, dismissDuration: g }),
661
+ launchPoint: Object.freeze(M),
662
+ burstPoint: Object.freeze(y),
663
+ particles: Object.freeze(T),
664
+ smoke: Object.freeze(z),
665
665
  main: Object.freeze(G),
666
- flash: W,
667
- dismissEnvelope: Y
666
+ flash: j,
667
+ dismissEnvelope: W
668
668
  });
669
669
  }
670
670
  function Fe(e) {
671
671
  return typeof e == "string" ? e.trim() : "";
672
672
  }
673
- function mt(e = {}) {
674
- const t = e.playConfig || e, i = t.multiGiftEffect || {}, s = t.giftUrl || t.assetUrl || "", r = t.giftRealSize || t.giftBodySize || null;
673
+ function ne() {
674
+ const e = new Error("圆角图片处理已取消");
675
+ return e.name = "AbortError", e;
676
+ }
677
+ async function gt(e, t, i, r, s) {
678
+ if (typeof e != "string" || !e.trim() || !r || r <= 0)
679
+ return typeof e == "string" ? e.trim() : "";
680
+ if (s != null && s.aborted) throw ne();
681
+ if (typeof document > "u" || typeof Image > "u")
682
+ return e.trim();
683
+ try {
684
+ const n = await new Promise((I, _) => {
685
+ const S = new Image();
686
+ let R = !1;
687
+ const O = () => {
688
+ S.onload = null, S.onerror = null, s == null || s.removeEventListener("abort", T);
689
+ }, A = (L, C) => {
690
+ R || (R = !0, O(), L(C));
691
+ }, T = () => {
692
+ S.src = "", A(_, ne());
693
+ };
694
+ S.crossOrigin = "anonymous", S.onload = () => A(I, S), S.onerror = () => A(_, new Error(`图片加载失败: ${e}`)), s == null || s.addEventListener("abort", T, { once: !0 }), S.src = e;
695
+ });
696
+ if (s != null && s.aborted) throw ne();
697
+ const c = t || n.naturalWidth || n.width || 100, a = i || n.naturalHeight || n.height || 100, o = 2, l = document.createElement("canvas");
698
+ l.width = Math.round(c * o), l.height = Math.round(a * o);
699
+ const d = l.getContext("2d");
700
+ if (!d) return e;
701
+ const m = l.width, g = l.height, v = Math.min(r * o, m / 2, g / 2);
702
+ d.beginPath(), typeof d.roundRect == "function" ? d.roundRect(0, 0, m, g, v) : (d.moveTo(v, 0), d.arcTo(m, 0, m, g, v), d.arcTo(m, g, 0, g, v), d.arcTo(0, g, 0, 0, v), d.arcTo(0, 0, m, 0, v), d.closePath()), d.clip();
703
+ const b = n.naturalWidth || n.width || m, w = n.naturalHeight || n.height || g, k = b / w, f = m / g;
704
+ let h = 0, p = 0, M = b, y = w;
705
+ if (k > f ? (M = w * f, h = (b - M) / 2) : (y = b / f, p = (w - y) / 2), d.drawImage(n, h, p, M, y, 0, 0, m, g), s != null && s.aborted) throw ne();
706
+ return l.toDataURL("image/png");
707
+ } catch (n) {
708
+ if ((n == null ? void 0 : n.name) === "AbortError") throw n;
709
+ return e;
710
+ }
711
+ }
712
+ function pt(e = {}) {
713
+ const t = e.playConfig || e, i = t.multiGiftEffect || {}, r = t.giftUrl || t.assetUrl || "", s = t.giftRealSize || t.giftBodySize || null;
675
714
  let n = t.assetType;
676
- n || (s === "box" ? n = "box" : typeof s == "string" && (/\.(png|jpe?g|webp|gif|bmp)($|\?)/i.test(s) || s.startsWith("data:image/")) ? n = "image" : n = "svga");
677
- const l = i.lottie || t.lottieUrl || t.lottie, a = i.slotSize || t.slotSize || { width: 60, height: 60 }, o = Array.isArray(i.effects) ? i.effects : Array.isArray(t.effects) ? t.effects : [], c = Array.isArray(i.imgs) ? i.imgs : Array.isArray(t.imgs) ? t.imgs : [], u = e.imageSlots && e.imageSlots.length ? e.imageSlots : c.map((p) => ({
678
- slot: p.slot,
679
- width: p.width,
680
- height: p.height,
681
- radius: p.radius
715
+ n || (r === "box" ? n = "box" : typeof r == "string" && (/\.(png|jpe?g|webp|gif|bmp)($|\?)/i.test(r) || r.startsWith("data:image/")) ? n = "image" : n = "svga");
716
+ const c = i.lottie || t.lottieUrl || t.lottie, a = i.slotSize || t.slotSize || { width: 60, height: 60 }, o = Array.isArray(i.effects) ? i.effects : Array.isArray(t.effects) ? t.effects : [], l = Array.isArray(i.imgs) ? i.imgs : Array.isArray(t.imgs) ? t.imgs : [], d = e.imageSlots && e.imageSlots.length ? e.imageSlots : l.map((g) => ({
717
+ slot: g.slot,
718
+ width: g.width,
719
+ height: g.height,
720
+ radius: g.radius
682
721
  })), m = {
683
722
  ...e.imageUrls || {},
684
723
  ...Object.fromEntries(
685
- c.filter((p) => p.url !== void 0 && p.url !== null).map((p) => [p.slot, p.url])
724
+ l.filter((g) => g.url !== void 0 && g.url !== null).map((g) => [g.slot, g.url])
686
725
  )
687
726
  };
688
727
  return {
689
- giftUrl: s,
690
- giftRealSize: r,
691
- giftBodySize: r,
728
+ giftUrl: r,
729
+ giftRealSize: s,
730
+ giftBodySize: s,
692
731
  assetType: n,
693
- assetUrl: s,
694
- lottie: l,
695
- lottieUrl: l,
732
+ assetUrl: r,
733
+ lottie: c,
734
+ lottieUrl: c,
696
735
  slotSize: a,
697
736
  effects: o,
698
- imgs: c,
699
- imageSlots: u,
737
+ imgs: l,
738
+ imageSlots: d,
700
739
  imageUrls: m
701
740
  };
702
741
  }
703
- const gt = 16, Ie = 24;
704
- function fe(e, t, i) {
742
+ const wt = 16, Ne = 24;
743
+ function de(e, t, i) {
705
744
  if (!Number.isFinite(t) || t < 1)
706
745
  throw new Error("firework GPU capability maxInstancesPerBatch 无效");
707
746
  if (e > t)
708
747
  throw new Error(`${i} 粒子数量超过 GPU batch 上限:${t}`);
709
748
  }
710
- function pt(e, t, i) {
749
+ function bt(e, t, i) {
711
750
  e.set([
712
751
  i.birthTime,
713
752
  i.lifetime,
@@ -727,70 +766,70 @@ function pt(e, t, i) {
727
766
  1
728
767
  ], t);
729
768
  }
730
- function he(e, t, i) {
731
- const s = new Float32Array(e.length * Ie);
732
- return e.forEach((r, n) => {
733
- const l = t.get(r.cellKey);
734
- if (!l) throw new Error(`firework atlas 缺少 cell:${r.cellKey}`);
735
- const a = n * Ie;
736
- pt(s, a, r), s.set([
737
- l.width * i,
738
- l.height * i,
769
+ function ue(e, t, i) {
770
+ const r = new Float32Array(e.length * Ne);
771
+ return e.forEach((s, n) => {
772
+ const c = t.get(s.cellKey);
773
+ if (!c) throw new Error(`firework atlas 缺少 cell:${s.cellKey}`);
774
+ const a = n * Ne;
775
+ bt(r, a, s), r.set([
776
+ c.width * i,
777
+ c.height * i,
739
778
  0.5,
740
779
  0.5,
741
- l.u0,
742
- l.v0,
743
- l.u1,
744
- l.v1
745
- ], a + gt);
746
- }), s;
747
- }
748
- function wt(e, t) {
780
+ c.u0,
781
+ c.v0,
782
+ c.u1,
783
+ c.v1
784
+ ], a + wt);
785
+ }), r;
786
+ }
787
+ function yt(e, t) {
749
788
  var a, o;
750
- const i = ((a = e[0]) == null ? void 0 : a.startMs) ?? 1 / 0, s = ((o = e.at(-1)) == null ? void 0 : o.endMs) ?? -1 / 0;
751
- if (!Number.isFinite(i) || !Number.isFinite(s) || !(s > i)) return [];
752
- const r = /* @__PURE__ */ new Set([i, s]);
753
- for (const c of [...e, ...t])
754
- c.startMs > i && c.startMs < s && r.add(c.startMs), c.endMs > i && c.endMs < s && r.add(c.endMs);
755
- const n = [...r].sort((c, u) => c - u), l = [];
756
- for (let c = 0; c < n.length - 1; c += 1) {
757
- const u = n[c], m = n[c + 1];
758
- if (!(m > u)) continue;
759
- const p = (d, w = !1) => Ae(e, d, 1, w) * Ae(t, d, 1, w), v = p(u), y = p(m, !0), b = (u + m) * 0.5, h = Math.abs(p(b) - (v + y) * 0.5) > 1e-6 ? 4 : m - u;
760
- for (let d = u; d < m; d += h) {
761
- const w = Math.min(m, d + h);
762
- l.push({
763
- startMs: d,
764
- endMs: w,
765
- from: p(d),
766
- to: p(w, !0),
789
+ const i = ((a = e[0]) == null ? void 0 : a.startMs) ?? 1 / 0, r = ((o = e.at(-1)) == null ? void 0 : o.endMs) ?? -1 / 0;
790
+ if (!Number.isFinite(i) || !Number.isFinite(r) || !(r > i)) return [];
791
+ const s = /* @__PURE__ */ new Set([i, r]);
792
+ for (const l of [...e, ...t])
793
+ l.startMs > i && l.startMs < r && s.add(l.startMs), l.endMs > i && l.endMs < r && s.add(l.endMs);
794
+ const n = [...s].sort((l, d) => l - d), c = [];
795
+ for (let l = 0; l < n.length - 1; l += 1) {
796
+ const d = n[l], m = n[l + 1];
797
+ if (!(m > d)) continue;
798
+ const g = (h, p = !1) => Oe(e, h, 1, p) * Oe(t, h, 1, p), v = g(d), b = g(m, !0), w = (d + m) * 0.5, f = Math.abs(g(w) - (v + b) * 0.5) > 1e-6 ? 4 : m - d;
799
+ for (let h = d; h < m; h += f) {
800
+ const p = Math.min(m, h + f);
801
+ c.push({
802
+ startMs: h,
803
+ endMs: p,
804
+ from: g(h),
805
+ to: g(p, !0),
767
806
  interpolation: "linear"
768
807
  });
769
808
  }
770
809
  }
771
- return l;
810
+ return c;
772
811
  }
773
- function bt({
812
+ function Et({
774
813
  effect: e,
775
814
  composition: t,
776
815
  layout: i,
777
- resolvedQualityScale: s,
778
- seed: r,
816
+ resolvedQualityScale: r,
817
+ seed: s,
779
818
  atlas: n,
780
- atlasCells: l,
819
+ atlasCells: c,
781
820
  maxInstancesPerBatch: a
782
821
  }) {
783
- const o = ut({
822
+ const o = mt({
784
823
  effect: e,
785
824
  composition: t,
786
825
  layout: i,
787
- resolvedQualityScale: s,
788
- seed: r,
826
+ resolvedQualityScale: r,
827
+ seed: s,
789
828
  maxParticleCount: a * 2,
790
829
  maxInstancesPerBatch: a
791
830
  });
792
- fe(o.smoke.length, a, "firework smoke"), fe(o.main.length, a, "firework main"), fe(1, a, "firework flash");
793
- const c = {
831
+ de(o.smoke.length, a, "firework smoke"), de(o.main.length, a, "firework main"), de(1, a, "firework flash");
832
+ const l = {
794
833
  birthTime: o.flash.birthTime,
795
834
  lifetime: o.flash.lifetime,
796
835
  x: o.flash.x,
@@ -804,7 +843,7 @@ function bt({
804
843
  rotation: 0,
805
844
  spin: 0,
806
845
  cellKey: o.flash.cellKey
807
- }, u = {
846
+ }, d = {
808
847
  format: "sprite-v2",
809
848
  atlas: n,
810
849
  opacity: 1,
@@ -814,9 +853,9 @@ function bt({
814
853
  model: o,
815
854
  descriptors: Object.freeze([
816
855
  Object.freeze({
817
- ...u,
856
+ ...d,
818
857
  count: o.smoke.length,
819
- instances: he(o.smoke, l, i.scale),
858
+ instances: ue(o.smoke, c, i.scale),
820
859
  fadeMode: "lifetime",
821
860
  envelope: { opacity: o.dismissEnvelope },
822
861
  zIndex: 0,
@@ -824,9 +863,9 @@ function bt({
824
863
  label: "multi-gift-firework-smoke"
825
864
  }),
826
865
  Object.freeze({
827
- ...u,
866
+ ...d,
828
867
  count: o.main.length,
829
- instances: he(o.main, l, i.scale),
868
+ instances: ue(o.main, c, i.scale),
830
869
  fadeMode: "lifetime",
831
870
  envelope: { opacity: o.dismissEnvelope },
832
871
  zIndex: 1,
@@ -834,12 +873,12 @@ function bt({
834
873
  label: "multi-gift-firework-main"
835
874
  }),
836
875
  Object.freeze({
837
- ...u,
876
+ ...d,
838
877
  count: 1,
839
- instances: he([c], l, i.scale),
878
+ instances: ue([l], c, i.scale),
840
879
  fadeMode: "none",
841
880
  envelope: {
842
- opacity: wt(o.flash.opacityEnvelope, o.dismissEnvelope),
881
+ opacity: yt(o.flash.opacityEnvelope, o.dismissEnvelope),
843
882
  size: o.flash.sizeEnvelope
844
883
  },
845
884
  zIndex: 2,
@@ -849,82 +888,82 @@ function bt({
849
888
  ])
850
889
  });
851
890
  }
852
- const re = 4, x = 256;
853
- function yt(e, t, i) {
891
+ const oe = 4, D = 256;
892
+ function St(e, t, i) {
854
893
  if (i) return i(e, t);
855
894
  if (typeof OffscreenCanvas < "u") return new OffscreenCanvas(e, t);
856
895
  if (typeof document < "u") {
857
- const s = document.createElement("canvas");
858
- return s.width = e, s.height = t, s;
896
+ const r = document.createElement("canvas");
897
+ return r.width = e, r.height = t, r;
859
898
  }
860
899
  throw new Error("当前环境无法生成 firework sprite atlas");
861
900
  }
862
- function Et(e) {
901
+ function Mt(e) {
863
902
  const t = /* @__PURE__ */ new Map();
864
- let i = 0, s = 0, r = 0;
903
+ let i = 0, r = 0, s = 0;
865
904
  for (const n of e.cells) {
866
- const l = n.width + re * 2, a = n.height + re * 2;
867
- if (i + l > x && (i = 0, s += r, r = 0), s + a > x) throw new Error("firework atlas recipe exceeds 256x256");
868
- const o = i + re, c = s + re;
905
+ const c = n.width + oe * 2, a = n.height + oe * 2;
906
+ if (i + c > D && (i = 0, r += s, s = 0), r + a > D) throw new Error("firework atlas recipe exceeds 256x256");
907
+ const o = i + oe, l = r + oe;
869
908
  t.set(n.key, Object.freeze({
870
909
  ...n,
871
910
  x: o,
872
- y: c,
911
+ y: l,
873
912
  // Use cell-edge coordinates. GPU raster pixel centres then sample the
874
913
  // corresponding Canvas pixel centres without shrinking the sprite.
875
- u0: o / x,
876
- v0: c / x,
877
- u1: (o + n.width) / x,
878
- v1: (c + n.height) / x
879
- })), i += l, r = Math.max(r, a);
914
+ u0: o / D,
915
+ v0: l / D,
916
+ u1: (o + n.width) / D,
917
+ v1: (l + n.height) / D
918
+ })), i += c, s = Math.max(s, a);
880
919
  }
881
920
  return t;
882
921
  }
883
- function St(e, t = {}) {
884
- const i = Ve(e), s = Et(i), r = yt(x, x, t.canvasFactory);
885
- r.width = x, r.height = x;
886
- const n = r.getContext("2d", { willReadFrequently: !0 });
922
+ function kt(e, t = {}) {
923
+ const i = Be(e), r = Mt(i), s = St(D, D, t.canvasFactory);
924
+ s.width = D, s.height = D;
925
+ const n = s.getContext("2d", { willReadFrequently: !0 });
887
926
  if (!n) throw new Error("无法创建 firework atlas Canvas2D context");
888
- n.clearRect(0, 0, x, x);
889
- for (const o of s.values()) st(n, o, o.x, o.y);
890
- const l = n.getImageData(0, 0, x, x), a = new Uint8Array(l.data.length);
891
- for (let o = 0; o < l.data.length; o += 4) {
892
- const c = l.data[o + 3];
893
- a[o + 3] = c, c === 0 ? (a[o] = 0, a[o + 1] = 0, a[o + 2] = 0) : (a[o] = Math.round(l.data[o] * c / 255), a[o + 1] = Math.round(l.data[o + 1] * c / 255), a[o + 2] = Math.round(l.data[o + 2] * c / 255));
927
+ n.clearRect(0, 0, D, D);
928
+ for (const o of r.values()) st(n, o, o.x, o.y);
929
+ const c = n.getImageData(0, 0, D, D), a = new Uint8Array(c.data.length);
930
+ for (let o = 0; o < c.data.length; o += 4) {
931
+ const l = c.data[o + 3];
932
+ a[o + 3] = l, l === 0 ? (a[o] = 0, a[o + 1] = 0, a[o + 2] = 0) : (a[o] = Math.round(c.data[o] * l / 255), a[o + 1] = Math.round(c.data[o + 1] * l / 255), a[o + 2] = Math.round(c.data[o + 2] * l / 255));
894
933
  }
895
934
  return Object.freeze({
896
935
  key: i.key,
897
- width: x,
898
- height: x,
936
+ width: D,
937
+ height: D,
899
938
  pixels: a,
900
- cells: s
939
+ cells: r
901
940
  });
902
941
  }
903
- const Ne = 8, _e = 10;
904
- function kt(e) {
942
+ const Pe = 8, _e = 10;
943
+ function vt(e) {
905
944
  const t = new RegExp(`^${e}_(\\d+)$`);
906
- return (i, s) => {
907
- var l, a;
908
- const r = Number(((l = t.exec(i.nm)) == null ? void 0 : l[1]) ?? Number.MAX_SAFE_INTEGER), n = Number(((a = t.exec(s.nm)) == null ? void 0 : a[1]) ?? Number.MAX_SAFE_INTEGER);
909
- return r - n;
945
+ return (i, r) => {
946
+ var c, a;
947
+ const s = Number(((c = t.exec(i.nm)) == null ? void 0 : c[1]) ?? Number.MAX_SAFE_INTEGER), n = Number(((a = t.exec(r.nm)) == null ? void 0 : a[1]) ?? Number.MAX_SAFE_INTEGER);
948
+ return s - n;
910
949
  };
911
950
  }
912
- function Ce(e, t, i, s) {
913
- return !e || !t || !i || !s ? 1 : Math.min(i / e, s / t);
951
+ function Ce(e, t, i, r) {
952
+ return !e || !t || !i || !r ? 1 : Math.min(i / e, r / t);
914
953
  }
915
- function Mt(e) {
954
+ function Tt(e) {
916
955
  return Number.isFinite(e == null ? void 0 : e.x) && Number.isFinite(e == null ? void 0 : e.y) ? { x: e.x, y: e.y } : null;
917
956
  }
918
- function J(e) {
957
+ function q(e) {
919
958
  const t = new Error(e);
920
959
  return t.name = "AbortError", t;
921
960
  }
922
- function Pe(e) {
923
- var i, s, r, n;
961
+ function Le(e) {
962
+ var i, r, s, n;
924
963
  const t = (i = e == null ? void 0 : e.capabilities) == null ? void 0 : i.particles;
925
- return (t == null ? void 0 : t.backend) === "unavailable" || !((s = t == null ? void 0 : t.formats) != null && s.includes("sprite-v2")) || ((r = t == null ? void 0 : t.spriteAtlas) == null ? void 0 : r.source) !== "rgba8-premultiplied" || !((n = t == null ? void 0 : t.compositeLayers) != null && n.includes("behind-media")) || (t == null ? void 0 : t.batchEnvelope) !== !0 || (t == null ? void 0 : t.atomicBatchGroup) !== !0 || !Number.isFinite(t == null ? void 0 : t.maxInstancesPerBatch) || typeof (e == null ? void 0 : e.createParticleAtlas) != "function" ? null : t;
964
+ return (t == null ? void 0 : t.backend) === "unavailable" || !((r = t == null ? void 0 : t.formats) != null && r.includes("sprite-v2")) || ((s = t == null ? void 0 : t.spriteAtlas) == null ? void 0 : s.source) !== "rgba8-premultiplied" || !((n = t == null ? void 0 : t.compositeLayers) != null && n.includes("behind-media")) || (t == null ? void 0 : t.batchEnvelope) !== !0 || (t == null ? void 0 : t.atomicBatchGroup) !== !0 || !Number.isFinite(t == null ? void 0 : t.maxInstancesPerBatch) || typeof (e == null ? void 0 : e.createParticleAtlas) != "function" ? null : t;
926
965
  }
927
- function Le(e) {
966
+ function ze(e) {
928
967
  const t = typeof navigator < "u" ? navigator : {};
929
968
  return {
930
969
  quality: e,
@@ -933,20 +972,20 @@ function Le(e) {
933
972
  userAgent: t.userAgent
934
973
  };
935
974
  }
936
- function vt(e, t) {
975
+ function Rt(e, t) {
937
976
  if (!Number.isFinite(e)) return t;
938
977
  let i = t;
939
978
  for (; i - e > Math.PI; ) i -= Math.PI * 2;
940
979
  for (; i - e < -Math.PI; ) i += Math.PI * 2;
941
980
  return i;
942
981
  }
943
- async function Tt(e, t) {
982
+ async function At(e, t) {
944
983
  if (e && typeof e == "object") return e;
945
984
  if (typeof e == "string" && e.trim().startsWith("{"))
946
985
  try {
947
986
  return JSON.parse(e);
948
- } catch (s) {
949
- throw new Error(`Lottie JSON 解析失败:${s.message || "格式错误"}`);
987
+ } catch (r) {
988
+ throw new Error(`Lottie JSON 解析失败:${r.message || "格式错误"}`);
950
989
  }
951
990
  if (typeof e != "string" || !e.trim())
952
991
  throw new Error("未提供有效的 Lottie 轨迹配置");
@@ -954,12 +993,12 @@ async function Tt(e, t) {
954
993
  if (!i.ok) throw new Error(`Lottie 加载失败 (${i.status})`);
955
994
  return i.json();
956
995
  }
957
- function ze(e, t, i) {
958
- var l;
959
- const s = (l = e == null ? void 0 : e.capabilities) == null ? void 0 : l.motionTrack, r = (s == null ? void 0 : s.gpuMediaTypes) || [];
960
- return (s == null ? void 0 : s.mode) === "gpu-table" && t === "svga" && r.includes(t) ? "gpu-table" : "cpu-reference";
996
+ function xe(e, t, i) {
997
+ var c;
998
+ const r = (c = e == null ? void 0 : e.capabilities) == null ? void 0 : c.motionTrack, s = (r == null ? void 0 : r.gpuMediaTypes) || [];
999
+ return (r == null ? void 0 : r.mode) === "gpu-table" && t === "svga" && s.includes(t) ? "gpu-table" : "cpu-reference";
961
1000
  }
962
- function Rt(e) {
1001
+ function Ot(e) {
963
1002
  if (!e || typeof e.getRenderInfo != "function") return null;
964
1003
  try {
965
1004
  return e.getRenderInfo();
@@ -967,18 +1006,18 @@ function Rt(e) {
967
1006
  return null;
968
1007
  }
969
1008
  }
970
- function At(e, t) {
971
- var s, r;
1009
+ function It(e, t) {
1010
+ var r, s;
972
1011
  const i = [];
973
- return e.forEach((n, l) => {
1012
+ return e.forEach((n, c) => {
974
1013
  if (n.kind !== "svga") return;
975
- const a = t[l], o = Rt(a), c = {
1014
+ const a = t[c], o = Ot(a), l = {
976
1015
  slotId: n.id,
977
1016
  giftId: (a == null ? void 0 : a.id) ?? n.id,
978
1017
  svgaFramePath: (o == null ? void 0 : o.svgaFramePath) ?? (o == null ? void 0 : o.selectedPath) ?? (o == null ? void 0 : o.path) ?? null
979
1018
  };
980
- o != null && o.parentMotionMode && (c.parentMotionMode = o.parentMotionMode);
981
- for (const u of [
1019
+ o != null && o.parentMotionMode && (l.parentMotionMode = o.parentMotionMode);
1020
+ for (const d of [
982
1021
  "backend",
983
1022
  "pathState",
984
1023
  "frameTableBytes",
@@ -987,19 +1026,19 @@ function At(e, t) {
987
1026
  "drawCompatibleInstanceCount",
988
1027
  "fallbackReasons"
989
1028
  ])
990
- (o == null ? void 0 : o[u]) != null && (c[u] = o[u]);
991
- i.push(c);
1029
+ (o == null ? void 0 : o[d]) != null && (l[d] = o[d]);
1030
+ i.push(l);
992
1031
  }), {
993
1032
  // A formation uses one shared resource, so this is the primary path. The
994
1033
  // per-slot list remains available for mixed/future resource plans.
995
- svgaFramePath: ((s = i.find((n) => n.svgaFramePath != null)) == null ? void 0 : s.svgaFramePath) ?? null,
996
- parentMotionMode: ((r = i.find((n) => n.parentMotionMode != null)) == null ? void 0 : r.parentMotionMode) ?? null,
1034
+ svgaFramePath: ((r = i.find((n) => n.svgaFramePath != null)) == null ? void 0 : r.svgaFramePath) ?? null,
1035
+ parentMotionMode: ((s = i.find((n) => n.parentMotionMode != null)) == null ? void 0 : s.parentMotionMode) ?? null,
997
1036
  svgaFramePaths: i
998
1037
  };
999
1038
  }
1000
- class Ot {
1001
- constructor(t, i, s, r, n) {
1002
- this.id = t, this.scope = i, this.completion = s, this.onStop = r, this.diagnosticsProvider = n;
1039
+ class Ft {
1040
+ constructor(t, i, r, s, n) {
1041
+ this.id = t, this.scope = i, this.completion = r, this.onStop = s, this.diagnosticsProvider = n;
1003
1042
  }
1004
1043
  get diagnostics() {
1005
1044
  return this.diagnosticsProvider();
@@ -1023,7 +1062,7 @@ class Ot {
1023
1062
  this.onStop();
1024
1063
  }
1025
1064
  }
1026
- class Ft {
1065
+ class Nt {
1027
1066
  constructor(t, i = {}) {
1028
1067
  this.host = t, this.options = i, this.sampleRate = Math.max(30, Math.min(120, i.sampleRate || 60)), this.onStateChange = i.onStateChange || (() => {
1029
1068
  }), this.onRenderFrame = i.onRenderFrame || (() => {
@@ -1036,324 +1075,334 @@ class Ft {
1036
1075
  return this._preloadDiagnostics;
1037
1076
  }
1038
1077
  async preload(t = this.options.playConfig, i = !1) {
1039
- var v, y, b;
1078
+ var b, w, k;
1040
1079
  if (this.assertAlive(), !t) throw new Error("未提供 playConfig");
1041
1080
  this.cancelPlayback(!i), this.releaseLeases(), this.playConfig = null, this.composition = null, this._preloadDiagnostics = null;
1042
- const s = mt({ ...this.options, playConfig: t });
1043
- if (s.assetType !== "svga" && s.assetType !== "image")
1044
- throw new Error(`GiftStage 插件不支持的礼物类型:${s.assetType}`);
1081
+ const r = pt({ ...this.options, playConfig: t });
1082
+ if (r.assetType !== "svga" && r.assetType !== "image")
1083
+ throw new Error(`GiftStage 插件不支持的礼物类型:${r.assetType}`);
1045
1084
  this.emitStateChange({ status: "loading", message: "正在预加载 Lottie 与共享礼物资源" });
1046
- const r = new AbortController();
1047
- (v = this.preloadController) == null || v.abort(), this.preloadController = r;
1085
+ const s = new AbortController();
1086
+ (b = this.preloadController) == null || b.abort(), this.preloadController = s;
1048
1087
  const n = ++this.preloadEpoch;
1049
- let l = null, a = /* @__PURE__ */ new Map(), o = null, c = null, u = null, m = 1, p = !1;
1088
+ let c = null, a = /* @__PURE__ */ new Map();
1089
+ const o = { ...r.imageUrls };
1090
+ let l = null, d = null, m = null, g = 1, v = !1;
1050
1091
  try {
1051
- const g = await Tt(s.lottieUrl, r.signal);
1052
- this.assertCurrentPreload(r, n);
1053
- const h = Pe(this.host), d = Qe(g, {
1054
- effects: s.effects,
1055
- fireworkEnvironment: Le("auto"),
1092
+ const f = await At(r.lottieUrl, s.signal);
1093
+ this.assertCurrentPreload(s, n);
1094
+ const h = Le(this.host), p = et(f, {
1095
+ effects: r.effects,
1096
+ fireworkEnvironment: ze("auto"),
1056
1097
  maxInstancesPerBatch: Math.min(
1057
1098
  Z,
1058
1099
  (h == null ? void 0 : h.maxInstancesPerBatch) ?? Z
1059
1100
  )
1060
1101
  });
1061
- d.length && this.emitStateChange({ validationFindings: d });
1062
- const w = d.find((f) => f.code === "LOTTIE_TARGET_MARKER_MISSING");
1063
- if (w)
1102
+ p.length && this.emitStateChange({ validationFindings: p });
1103
+ const M = p.find((u) => u.code === "LOTTIE_TARGET_MARKER_MISSING");
1104
+ if (M)
1064
1105
  throw this.emitStateChange({
1065
1106
  status: "fallback",
1066
- reason: w.code,
1107
+ reason: M.code,
1067
1108
  message: "多礼物编排缺少 target_flight,交由宿主降级普通单礼物"
1068
- }), new ae(
1069
- w.code,
1109
+ }), new le(
1110
+ M.code,
1070
1111
  "Lottie 中缺少有效的 target_flight marker",
1071
- d,
1112
+ p,
1072
1113
  !0
1073
1114
  );
1074
- const k = d.filter(
1075
- (f) => f.scope === "composition" && f.severity === "error"
1115
+ const y = p.filter(
1116
+ (u) => u.scope === "composition" && u.severity === "error"
1076
1117
  );
1077
- if (k.length)
1078
- throw new ae(
1079
- k[0].code,
1080
- `Lottie 合成校验失败:${k.map((f) => `${f.code}@${f.where}`).join(", ")}`,
1081
- d
1118
+ if (y.length)
1119
+ throw new le(
1120
+ y[0].code,
1121
+ `Lottie 合成校验失败:${y.map((u) => `${u.code}@${u.where}`).join(", ")}`,
1122
+ p
1082
1123
  );
1083
- const E = new Set(d.filter((f) => f.scope === "slot" && f.severity === "error" && f.layer).map((f) => f.layer)), O = new Set(d.filter((f) => f.scope === "effect" && Number.isInteger(f.effectIndex)).map((f) => f.effectIndex)), C = new Map((g.layers || []).map((f) => [f.nm, f])), M = (g.layers || []).filter((f) => /^slot_\d+$/.test(f.nm) && f.ks && !E.has(f.nm)).sort(kt("slot"));
1084
- if (!M.length)
1085
- throw new ae(
1124
+ const I = new Set(p.filter((u) => u.scope === "slot" && u.severity === "error" && u.layer).map((u) => u.layer)), _ = new Set(p.filter((u) => u.scope === "effect" && Number.isInteger(u.effectIndex)).map((u) => u.effectIndex)), S = new Map((f.layers || []).map((u) => [u.nm, u])), R = (f.layers || []).filter((u) => /^slot_\d+$/.test(u.nm) && u.ks && !I.has(u.nm)).sort(vt("slot"));
1125
+ if (!R.length)
1126
+ throw new le(
1086
1127
  "LOTTIE_SLOT_MISSING",
1087
1128
  "Lottie 中没有可播放的 slot_N 礼物插槽图层",
1088
- d
1129
+ p
1089
1130
  );
1090
- const T = pe(g.markers, "target_flight"), R = s.effects.filter((f, A) => !O.has(A));
1091
- l = await this.host.preload(
1092
- s.assetType,
1093
- s.assetUrl,
1094
- r.signal
1095
- ), this.assertCurrentPreload(r, n);
1096
- for (const f of s.imageSlots) {
1097
- const A = Fe(s.imageUrls[f.slot]);
1098
- if (!A || !((y = C.get(f.slot)) != null && y.ks) || E.has(f.slot)) continue;
1099
- const _ = await this.host.preload("image", A, r.signal);
1100
- (b = a.get(f.slot)) == null || b.release(), a.set(f.slot, _), this.assertCurrentPreload(r, n);
1131
+ const O = be(f.markers, "target_flight"), A = r.effects.filter((u, N) => !_.has(N));
1132
+ c = await this.host.preload(
1133
+ r.assetType,
1134
+ r.assetUrl,
1135
+ s.signal
1136
+ ), this.assertCurrentPreload(s, n);
1137
+ for (const u of r.imageSlots) {
1138
+ const N = Fe(r.imageUrls[u.slot]);
1139
+ let z = N;
1140
+ if (N && u.radius > 0 && (z = await gt(
1141
+ N,
1142
+ u.width,
1143
+ u.height,
1144
+ u.radius,
1145
+ s.signal
1146
+ ), this.assertCurrentPreload(s, n)), !z || !((w = S.get(u.slot)) != null && w.ks) || I.has(u.slot)) continue;
1147
+ o[u.slot] = z;
1148
+ const G = await this.host.preload("image", z, s.signal);
1149
+ (k = a.get(u.slot)) == null || k.release(), a.set(u.slot, G), this.assertCurrentPreload(s, n);
1101
1150
  }
1102
- const S = {
1103
- startFrame: T.tm,
1104
- endFrame: T.tm + T.dr
1105
- }, N = new Map(M.map((f) => {
1106
- var W, X;
1107
- const A = ((X = (W = f.ks) == null ? void 0 : W.s) == null ? void 0 : X.a) === 1 && Array.isArray(f.ks.s.k) ? f.ks.s.k.filter(($) => Number.isFinite($ == null ? void 0 : $.t) && $.t >= S.startFrame && $.t <= S.endFrame).sort(($, se) => $.t - se.t) : [], _ = A[0], D = A[A.length - 1];
1108
- let G = Number.isFinite(_ == null ? void 0 : _.t) ? _.t : S.startFrame, Y = Number.isFinite(D == null ? void 0 : D.t) ? D.t : S.endFrame;
1109
- return G = Math.max(S.startFrame, Math.min(S.endFrame, G)), Y = Math.max(S.startFrame, Math.min(S.endFrame, Y)), Y > G || (G = S.startFrame, Y = S.endFrame), [f.nm, { start: G, end: Y }];
1110
- })), z = {
1111
- lottie: g,
1112
- width: g.w,
1113
- height: g.h,
1114
- frameRate: g.fr,
1115
- inFrame: g.ip,
1116
- outFrame: g.op,
1117
- durationMs: (g.op - g.ip) / g.fr * 1e3,
1118
- layers: C,
1119
- timeline: M,
1120
- targetFlight: S,
1121
- flightWindows: N
1122
- }, P = R.find((f) => f.type === "firework");
1123
- if (P && h) {
1124
- m = $e(
1125
- Le(P.quality ?? "auto")
1151
+ const T = {
1152
+ startFrame: O.tm,
1153
+ endFrame: O.tm + O.dr
1154
+ }, L = new Map(R.map((u) => {
1155
+ var X, V;
1156
+ const N = ((V = (X = u.ks) == null ? void 0 : X.s) == null ? void 0 : V.a) === 1 && Array.isArray(u.ks.s.k) ? u.ks.s.k.filter((Y) => Number.isFinite(Y == null ? void 0 : Y.t) && Y.t >= T.startFrame && Y.t <= T.endFrame).sort((Y, se) => Y.t - se.t) : [], z = N[0], G = N[N.length - 1];
1157
+ let W = Number.isFinite(z == null ? void 0 : z.t) ? z.t : T.startFrame, j = Number.isFinite(G == null ? void 0 : G.t) ? G.t : T.endFrame;
1158
+ return W = Math.max(T.startFrame, Math.min(T.endFrame, W)), j = Math.max(T.startFrame, Math.min(T.endFrame, j)), j > W || (W = T.startFrame, j = T.endFrame), [u.nm, { start: W, end: j }];
1159
+ })), C = {
1160
+ lottie: f,
1161
+ width: f.w,
1162
+ height: f.h,
1163
+ frameRate: f.fr,
1164
+ inFrame: f.ip,
1165
+ outFrame: f.op,
1166
+ durationMs: (f.op - f.ip) / f.fr * 1e3,
1167
+ layers: S,
1168
+ timeline: R,
1169
+ targetFlight: T,
1170
+ flightWindows: L
1171
+ }, U = A.find((u) => u.type === "firework");
1172
+ if (U && h) {
1173
+ g = $e(
1174
+ ze(U.quality ?? "auto")
1126
1175
  );
1127
- const f = St(P);
1128
- if (f.width > h.spriteAtlas.maxSize || f.height > h.spriteAtlas.maxSize) throw new Error("firework atlas 超过当前 GPU capability");
1129
- o = await this.host.createParticleAtlas({
1130
- width: f.width,
1131
- height: f.height,
1132
- pixels: f.pixels,
1176
+ const u = kt(U);
1177
+ if (u.width > h.spriteAtlas.maxSize || u.height > h.spriteAtlas.maxSize) throw new Error("firework atlas 超过当前 GPU capability");
1178
+ l = await this.host.createParticleAtlas({
1179
+ width: u.width,
1180
+ height: u.height,
1181
+ pixels: u.pixels,
1133
1182
  colorSpace: "srgb",
1134
1183
  alphaMode: "premultiplied",
1135
1184
  filter: "linear",
1136
- label: `multi-gift-firework:${f.key}`
1137
- }), c = f.cells, u = f.key, this.assertCurrentPreload(r, n);
1185
+ label: `multi-gift-firework:${u.key}`
1186
+ }), d = u.cells, m = u.key, this.assertCurrentPreload(s, n);
1138
1187
  }
1139
- this.assertCurrentPreload(r, n), this.playConfig = { ...s, effects: R }, this.assetLease = l, this.imageLeases = a, this.composition = z, this.fireworkAtlas = o, this.fireworkAtlasCells = c, this.fireworkAtlasRecipeKey = u, this.fireworkQualityScale = m, p = !0;
1140
- const j = ze(
1188
+ this.assertCurrentPreload(s, n), this.playConfig = { ...r, effects: A, imageUrls: o }, this.assetLease = c, this.imageLeases = a, this.composition = C, this.fireworkAtlas = l, this.fireworkAtlasCells = d, this.fireworkAtlasRecipeKey = m, this.fireworkQualityScale = g, v = !0;
1189
+ const E = xe(
1141
1190
  this.host,
1142
- s.assetType,
1143
- l.metadata
1191
+ r.assetType,
1192
+ c.metadata
1144
1193
  );
1145
1194
  this._preloadDiagnostics = Object.freeze({
1146
- parentMotionMode: j,
1195
+ parentMotionMode: E,
1147
1196
  // Compatibility alias retained for existing host diagnostics.
1148
- motionMode: j
1197
+ motionMode: E
1149
1198
  }), this.emitStateChange({
1150
1199
  status: "ready",
1151
- message: `${M.length} 个礼物轨道已就绪`,
1152
- slotCount: M.length,
1200
+ message: `${R.length} 个礼物轨道已就绪`,
1201
+ slotCount: R.length,
1153
1202
  backend: this.host.capabilities.backend,
1154
1203
  ...this._preloadDiagnostics
1155
1204
  });
1156
- } catch (g) {
1157
- if (!p) {
1158
- l == null || l.release();
1205
+ } catch (f) {
1206
+ if (!v) {
1207
+ c == null || c.release();
1159
1208
  for (const h of a.values()) h.release();
1160
- o == null || o.destroy();
1209
+ l == null || l.destroy();
1161
1210
  }
1162
- throw (g == null ? void 0 : g.name) === "AbortError" || this.destroyed || this.preloadEpoch !== n || r.signal.aborted ? J("多礼物资源预加载已取消") : g;
1211
+ throw (f == null ? void 0 : f.name) === "AbortError" || this.destroyed || this.preloadEpoch !== n || s.signal.aborted ? q("多礼物资源预加载已取消") : f;
1163
1212
  } finally {
1164
- this.preloadController === r && (this.preloadController = null);
1213
+ this.preloadController === s && (this.preloadController = null);
1165
1214
  }
1166
1215
  }
1167
1216
  async play(t = {}) {
1168
- var v, y, b;
1217
+ var v, b, w;
1169
1218
  if (this.assertAlive(), !Object.prototype.hasOwnProperty.call(t, "target"))
1170
1219
  throw new Error("play() 必须显式传入 target,值可为 null 或 undefined");
1171
1220
  const i = ++this.playIntentEpoch;
1172
1221
  if (!this.composition && (await this.preload(void 0, !0), this.playIntentEpoch !== i) || (this.assertAlive(), this.playIntentEpoch !== i))
1173
- throw J("多礼物播放已取消");
1222
+ throw q("多礼物播放已取消");
1174
1223
  this.cancelPlayback(!1);
1175
- const s = this.composition, r = this.playConfig, n = Mt(t.target), l = this.host.getViewport(), a = s.width > 0 ? l.width / s.width : 1, o = 0, c = (l.height - s.height * a) * 0.5, u = this.host.createPlaybackScope(`multi-gift-${Date.now()}`), m = this.playEpoch;
1176
- this.pendingScope = { scope: u, playEpoch: m };
1177
- const p = s.timeline.map((g, h) => {
1178
- var d, w, k, E, O, C, M, T;
1224
+ const r = this.composition, s = this.playConfig, n = Tt(t.target), c = this.host.getViewport(), a = r.width > 0 ? c.width / r.width : 1, o = 0, l = (c.height - r.height * a) * 0.5, d = this.host.createPlaybackScope(`multi-gift-${Date.now()}`), m = this.playEpoch;
1225
+ this.pendingScope = { scope: d, playEpoch: m };
1226
+ const g = r.timeline.map((k, f) => {
1227
+ var h, p, M, y, I, _, S, R;
1179
1228
  return {
1180
- id: g.nm,
1181
- layer: g,
1182
- kind: r.assetType,
1183
- source: r.assetUrl,
1229
+ id: k.nm,
1230
+ layer: k,
1231
+ kind: s.assetType,
1232
+ source: s.assetUrl,
1184
1233
  width: this.assetLease.metadata.width * Ce(
1185
- (d = r.giftBodySize) == null ? void 0 : d.width,
1186
- (w = r.giftBodySize) == null ? void 0 : w.height,
1187
- (k = r.slotSize) == null ? void 0 : k.width,
1188
- (E = r.slotSize) == null ? void 0 : E.height
1234
+ (h = s.giftBodySize) == null ? void 0 : h.width,
1235
+ (p = s.giftBodySize) == null ? void 0 : p.height,
1236
+ (M = s.slotSize) == null ? void 0 : M.width,
1237
+ (y = s.slotSize) == null ? void 0 : y.height
1189
1238
  ) * a,
1190
1239
  height: this.assetLease.metadata.height * Ce(
1191
- (O = r.giftBodySize) == null ? void 0 : O.width,
1192
- (C = r.giftBodySize) == null ? void 0 : C.height,
1193
- (M = r.slotSize) == null ? void 0 : M.width,
1194
- (T = r.slotSize) == null ? void 0 : T.height
1240
+ (I = s.giftBodySize) == null ? void 0 : I.width,
1241
+ (_ = s.giftBodySize) == null ? void 0 : _.height,
1242
+ (S = s.slotSize) == null ? void 0 : S.width,
1243
+ (R = s.slotSize) == null ? void 0 : R.height
1195
1244
  ) * a,
1196
- zIndex: _e + h,
1245
+ zIndex: _e + f,
1197
1246
  redirect: !0
1198
1247
  };
1199
1248
  });
1200
- for (const g of r.imageSlots) {
1201
- const h = this.imageLeases.get(g.slot), d = s.layers.get(g.slot);
1202
- !h || !(d != null && d.ks) || p.push({
1203
- id: g.slot,
1204
- layer: d,
1249
+ for (const k of s.imageSlots) {
1250
+ const f = this.imageLeases.get(k.slot), h = r.layers.get(k.slot);
1251
+ !f || !(h != null && h.ks) || g.push({
1252
+ id: k.slot,
1253
+ layer: h,
1205
1254
  kind: "image",
1206
- source: Fe(r.imageUrls[g.slot]),
1207
- width: g.width * a,
1208
- height: g.height * a,
1209
- zIndex: _e + p.length,
1255
+ source: Fe(s.imageUrls[k.slot]),
1256
+ width: k.width * a,
1257
+ height: k.height * a,
1258
+ zIndex: _e + g.length,
1210
1259
  redirect: !1
1211
1260
  });
1212
1261
  }
1213
1262
  try {
1214
- const g = await Promise.all(p.map((f) => u.addGift({
1215
- type: f.kind,
1216
- source: f.source,
1263
+ const k = await Promise.all(g.map((E) => d.addGift({
1264
+ type: E.kind,
1265
+ source: E.source,
1217
1266
  x: 0,
1218
1267
  y: 0,
1219
- width: f.width,
1220
- height: f.height,
1221
- zIndex: f.zIndex,
1268
+ width: E.width,
1269
+ height: E.height,
1270
+ zIndex: E.zIndex,
1222
1271
  opacity: 0,
1223
- loop: f.kind === "svga" ? 0 : void 0,
1272
+ loop: E.kind === "svga" ? 0 : void 0,
1224
1273
  // A formation may contain dozens of copies of the same SVGA. The plugin owns visual
1225
1274
  // composition only, so embedded audio is muted to prevent N identical tracks stacking.
1226
- mute: f.kind === "svga" ? !0 : void 0,
1275
+ mute: E.kind === "svga" ? !0 : void 0,
1227
1276
  clearsAfterStop: !1
1228
1277
  })));
1229
- this.assertCurrentPlay(u, m);
1230
- const h = this.compileMotionTrack(p, n, {
1278
+ this.assertCurrentPlay(d, m);
1279
+ const f = this.compileMotionTrack(g, n, {
1231
1280
  scale: a,
1232
1281
  offsetX: o,
1233
- offsetY: c
1234
- }), d = u.createMotionTrack(h);
1235
- g.forEach((f, A) => u.bindMotion(f, d, A));
1236
- const w = () => {
1237
- var _, D;
1238
- const f = At(p, g), A = f.parentMotionMode ?? ((_ = this._preloadDiagnostics) == null ? void 0 : _.parentMotionMode) ?? ze(this.host, r.assetType, (D = this.assetLease) == null ? void 0 : D.metadata);
1282
+ offsetY: l
1283
+ }), h = d.createMotionTrack(f);
1284
+ k.forEach((E, u) => d.bindMotion(E, h, u));
1285
+ const p = () => {
1286
+ var N, z;
1287
+ const E = It(g, k), u = E.parentMotionMode ?? ((N = this._preloadDiagnostics) == null ? void 0 : N.parentMotionMode) ?? xe(this.host, s.assetType, (z = this.assetLease) == null ? void 0 : z.metadata);
1239
1288
  return Object.freeze({
1240
- ...f,
1241
- parentMotionMode: A,
1242
- motionMode: A
1289
+ ...E,
1290
+ parentMotionMode: u,
1291
+ motionMode: u
1243
1292
  });
1244
- }, k = w(), E = (v = r.effects) == null ? void 0 : v.find((f) => f.type === "firework"), O = Pe(this.host);
1245
- if (E && O && this.fireworkAtlas && this.fireworkAtlasCells && typeof u.createParticleBatchGroup == "function")
1293
+ }, M = p(), y = (v = s.effects) == null ? void 0 : v.find((E) => E.type === "firework"), I = Le(this.host);
1294
+ if (y && I && this.fireworkAtlas && this.fireworkAtlasCells && typeof d.createParticleBatchGroup == "function")
1246
1295
  try {
1247
- const f = bt({
1248
- effect: E,
1249
- composition: s,
1250
- layout: { scale: a, offsetX: o, offsetY: c },
1296
+ const E = Et({
1297
+ effect: y,
1298
+ composition: r,
1299
+ layout: { scale: a, offsetX: o, offsetY: l },
1251
1300
  resolvedQualityScale: this.fireworkQualityScale,
1252
- seed: E.seed,
1301
+ seed: y.seed,
1253
1302
  atlas: this.fireworkAtlas,
1254
1303
  atlasCells: this.fireworkAtlasCells,
1255
- maxInstancesPerBatch: O.maxInstancesPerBatch
1304
+ maxInstancesPerBatch: I.maxInstancesPerBatch
1256
1305
  });
1257
- u.createParticleBatchGroup(f.descriptors);
1258
- } catch (f) {
1306
+ d.createParticleBatchGroup(E.descriptors);
1307
+ } catch (E) {
1259
1308
  this.emitStateChange({
1260
- effectWarning: `firework 编译失败,已跳过:${f instanceof Error ? f.message : String(f)}`
1309
+ effectWarning: `firework 编译失败,已跳过:${E instanceof Error ? E.message : String(E)}`
1261
1310
  });
1262
1311
  }
1263
- else E && (this.particleCapabilityWarningEmitted || (this.particleCapabilityWarningEmitted = !0, this.emitStateChange({
1312
+ else y && (this.particleCapabilityWarningEmitted || (this.particleCapabilityWarningEmitted = !0, this.emitStateChange({
1264
1313
  effectWarning: "当前核心缺少 sprite-v2/atlas/envelope/atomic group 能力,已跳过 firework;未创建 Canvas2D 后端"
1265
1314
  })));
1266
- let C;
1267
- const M = new Promise((f) => {
1268
- C = f;
1315
+ let _;
1316
+ const S = new Promise((E) => {
1317
+ _ = E;
1269
1318
  });
1270
- let T = !1, R;
1271
- const S = (f) => {
1272
- T || (T = !0, C({ status: f }));
1273
- }, N = () => {
1274
- u.state !== "destroyed" && u.destroy(), this.activePlayback === R && (this.activePlayback = null), T || (this.emitStateChange({ status: "stopped", message: "播放已停止" }), S("stopped"));
1319
+ let R = !1, O;
1320
+ const A = (E) => {
1321
+ R || (R = !0, _({ status: E }));
1322
+ }, T = () => {
1323
+ d.state !== "destroyed" && d.destroy(), this.activePlayback === O && (this.activePlayback = null), R || (this.emitStateChange({ status: "stopped", message: "播放已停止" }), A("stopped"));
1275
1324
  };
1276
- R = new Ot(
1277
- u.id,
1278
- u,
1279
- M,
1280
- N,
1281
- w
1282
- ), this.assertCurrentPlay(u, m), this.pendingScope = null, this.activePlayback = R;
1283
- let z = 0, P = 0, j = !1;
1284
- return u.onFrame(({ nowMs: f, deltaMs: A }) => {
1285
- const _ = Math.min(
1286
- s.outFrame,
1287
- s.inFrame + f * s.frameRate / 1e3
1325
+ O = new Ft(
1326
+ d.id,
1327
+ d,
1328
+ S,
1329
+ T,
1330
+ p
1331
+ ), this.assertCurrentPlay(d, m), this.pendingScope = null, this.activePlayback = O;
1332
+ let L = 0, C = 0, U = !1;
1333
+ return d.onFrame(({ nowMs: E, deltaMs: u }) => {
1334
+ const N = Math.min(
1335
+ r.outFrame,
1336
+ r.inFrame + E * r.frameRate / 1e3
1288
1337
  );
1289
- this.emitRenderFrame(_), j || (j = !0, this.emitStateChange({
1338
+ this.emitRenderFrame(N), U || (U = !0, this.emitStateChange({
1290
1339
  status: "playing",
1291
1340
  diagnosticsRefreshed: !0,
1292
- ...R.diagnostics
1293
- })), z += A, P += 1, z >= 500 && (this.emitStateChange({ fps: Math.round(P * 1e3 / z) }), z = 0, P = 0);
1294
- }), u.onFinish(() => {
1295
- T || (this.activePlayback === R && (this.activePlayback = null), u.destroy(), this.emitStateChange({ status: "finished", message: "本轮编排播放完成" }), S("finished"));
1296
- }), u.start({ durationMs: s.durationMs }), this.emitStateChange({
1341
+ ...O.diagnostics
1342
+ })), L += u, C += 1, L >= 500 && (this.emitStateChange({ fps: Math.round(C * 1e3 / L) }), L = 0, C = 0);
1343
+ }), d.onFinish(() => {
1344
+ R || (this.activePlayback === O && (this.activePlayback = null), d.destroy(), this.emitStateChange({ status: "finished", message: "本轮编排播放完成" }), A("finished"));
1345
+ }), d.start({ durationMs: r.durationMs }), this.emitStateChange({
1297
1346
  status: "playing",
1298
- message: `${g.length} 个实例由 GiftStage 统一时钟驱动`,
1299
- ...k
1300
- }), R;
1301
- } catch (g) {
1302
- throw ((y = this.pendingScope) == null ? void 0 : y.scope) === u && (this.pendingScope = null), ((b = this.activePlayback) == null ? void 0 : b.scope) === u ? this.activePlayback.stop() : u.state !== "destroyed" && u.destroy(), (g == null ? void 0 : g.name) === "AbortError" || this.destroyed || this.playEpoch !== m ? J("多礼物播放已取消") : g;
1347
+ message: `${k.length} 个实例由 GiftStage 统一时钟驱动`,
1348
+ ...M
1349
+ }), O;
1350
+ } catch (k) {
1351
+ throw ((b = this.pendingScope) == null ? void 0 : b.scope) === d && (this.pendingScope = null), ((w = this.activePlayback) == null ? void 0 : w.scope) === d ? this.activePlayback.stop() : d.state !== "destroyed" && d.destroy(), (k == null ? void 0 : k.name) === "AbortError" || this.destroyed || this.playEpoch !== m ? q("多礼物播放已取消") : k;
1303
1352
  }
1304
1353
  }
1305
- compileMotionTrack(t, i, s) {
1306
- const r = this.composition, n = 1e3 / this.sampleRate, l = Math.ceil(r.durationMs / n) + 1, a = new Float32Array(t.length * l * Ne);
1307
- return t.forEach((o, c) => {
1308
- let u = Number.NaN;
1309
- for (let m = 0; m < l; m += 1) {
1310
- const p = Math.min(r.durationMs, m * n), v = r.inFrame + p * r.frameRate / 1e3, y = this.evaluateLayer(o, v, i, s);
1311
- y.rotation = vt(u, y.rotation), u = y.rotation;
1312
- const b = (c * l + m) * Ne;
1313
- a[b] = y.x, a[b + 1] = y.y, a[b + 2] = y.scaleX, a[b + 3] = y.scaleY, a[b + 4] = y.rotation, a[b + 5] = y.opacity, a[b + 6] = y.visible ? 1 : 0, a[b + 7] = m + 1 < l && y.interpolateToNext ? 1 : 0;
1354
+ compileMotionTrack(t, i, r) {
1355
+ const s = this.composition, n = 1e3 / this.sampleRate, c = Math.ceil(s.durationMs / n) + 1, a = new Float32Array(t.length * c * Pe);
1356
+ return t.forEach((o, l) => {
1357
+ let d = Number.NaN;
1358
+ for (let m = 0; m < c; m += 1) {
1359
+ const g = Math.min(s.durationMs, m * n), v = s.inFrame + g * s.frameRate / 1e3, b = this.evaluateLayer(o, v, i, r);
1360
+ b.rotation = Rt(d, b.rotation), d = b.rotation;
1361
+ const w = (l * c + m) * Pe;
1362
+ a[w] = b.x, a[w + 1] = b.y, a[w + 2] = b.scaleX, a[w + 3] = b.scaleY, a[w + 4] = b.rotation, a[w + 5] = b.opacity, a[w + 6] = b.visible ? 1 : 0, a[w + 7] = m + 1 < c && b.interpolateToNext ? 1 : 0;
1314
1363
  }
1315
1364
  }), {
1316
1365
  trackCount: t.length,
1317
- sampleCount: l,
1366
+ sampleCount: c,
1318
1367
  sampleIntervalMs: n,
1319
- durationMs: r.durationMs,
1368
+ durationMs: s.durationMs,
1320
1369
  samples: a,
1321
1370
  label: "lottie-multi-gift"
1322
1371
  };
1323
1372
  }
1324
- evaluateLayer(t, i, s, r) {
1373
+ evaluateLayer(t, i, r, s) {
1325
1374
  const n = t.layer;
1326
- let [l, a] = q(n.ks.p, i, [0, 0, 0]);
1327
- const [o, c] = q(n.ks.s, i, [100, 100, 100]), u = n.ks.r ?? n.ks.rz, [m] = q(u, i, [0]), [p] = q(n.ks.o, i, [100]), v = i >= n.ip && i < n.op && p > 0 && !this.disabledSlotIds.has(t.id);
1328
- let y = l * r.scale + r.offsetX, b = a * r.scale + r.offsetY;
1375
+ let [c, a] = H(n.ks.p, i, [0, 0, 0]);
1376
+ const [o, l] = H(n.ks.s, i, [100, 100, 100]), d = n.ks.r ?? n.ks.rz, [m] = H(d, i, [0]), [g] = H(n.ks.o, i, [100]), v = i >= n.ip && i < n.op && g > 0 && !this.disabledSlotIds.has(t.id);
1377
+ let b = c * s.scale + s.offsetX, w = a * s.scale + s.offsetY;
1329
1378
  if (t.redirect) {
1330
- const h = this.composition.flightWindows.get(n.nm) || this.composition.targetFlight;
1331
- if (i >= h.start) {
1332
- const [d, w] = q(n.ks.p, h.start, [l, a, 0]), k = d * r.scale + r.offsetX, E = w * r.scale + r.offsetY;
1333
- if (s) {
1334
- const O = h.end - h.start, C = O > 0 ? Math.max(0, Math.min(1, (i - h.start) / O)) : 0, M = tt(C);
1335
- y = k + (s.x - k) * M, b = E + (s.y - E) * M;
1379
+ const f = this.composition.flightWindows.get(n.nm) || this.composition.targetFlight;
1380
+ if (i >= f.start) {
1381
+ const [h, p] = H(n.ks.p, f.start, [c, a, 0]), M = h * s.scale + s.offsetX, y = p * s.scale + s.offsetY;
1382
+ if (r) {
1383
+ const I = f.end - f.start, _ = I > 0 ? Math.max(0, Math.min(1, (i - f.start) / I)) : 0, S = it(_);
1384
+ b = M + (r.x - M) * S, w = y + (r.y - y) * S;
1336
1385
  } else
1337
- y = k, b = E;
1386
+ b = M, w = y;
1338
1387
  }
1339
1388
  }
1340
- const g = [n.ks.p, n.ks.s, u, n.ks.o].some((h) => {
1341
- if ((h == null ? void 0 : h.a) !== 1) return !1;
1342
- const d = h.k || [];
1343
- return d.some((w, k) => {
1344
- const E = d[k + 1];
1345
- return E && i >= w.t && i < E.t && w.h === 1;
1389
+ const k = [n.ks.p, n.ks.s, d, n.ks.o].some((f) => {
1390
+ if ((f == null ? void 0 : f.a) !== 1) return !1;
1391
+ const h = f.k || [];
1392
+ return h.some((p, M) => {
1393
+ const y = h[M + 1];
1394
+ return y && i >= p.t && i < y.t && p.h === 1;
1346
1395
  });
1347
1396
  });
1348
1397
  return {
1349
- x: y,
1350
- y: b,
1398
+ x: b,
1399
+ y: w,
1351
1400
  scaleX: o / 100,
1352
- scaleY: c / 100,
1401
+ scaleY: l / 100,
1353
1402
  rotation: m * Math.PI / 180,
1354
- opacity: Math.max(0, Math.min(1, p / 100)),
1403
+ opacity: Math.max(0, Math.min(1, g / 100)),
1355
1404
  visible: v,
1356
- interpolateToNext: !g
1405
+ interpolateToNext: !k
1357
1406
  };
1358
1407
  }
1359
1408
  setDisabledSlots(t = []) {
@@ -1366,8 +1415,8 @@ class Ft {
1366
1415
  t && (this.playIntentEpoch += 1), this.playEpoch += 1;
1367
1416
  const i = this.pendingScope;
1368
1417
  this.pendingScope = null, i && i.scope.state !== "destroyed" && i.scope.destroy();
1369
- const s = this.activePlayback;
1370
- this.activePlayback = null, s == null || s.stop();
1418
+ const r = this.activePlayback;
1419
+ this.activePlayback = null, r == null || r.stop();
1371
1420
  }
1372
1421
  destroy() {
1373
1422
  var t;
@@ -1376,7 +1425,7 @@ class Ft {
1376
1425
  releaseLeases() {
1377
1426
  var t, i;
1378
1427
  (t = this.assetLease) == null || t.release(), this.assetLease = null;
1379
- for (const s of this.imageLeases.values()) s.release();
1428
+ for (const r of this.imageLeases.values()) r.release();
1380
1429
  this.imageLeases.clear(), (i = this.fireworkAtlas) == null || i.destroy(), this.fireworkAtlas = null, this.fireworkAtlasCells = null, this.fireworkAtlasRecipeKey = null;
1381
1430
  }
1382
1431
  assertAlive() {
@@ -1395,119 +1444,119 @@ class Ft {
1395
1444
  }
1396
1445
  }
1397
1446
  assertCurrentPlay(t, i) {
1398
- var s;
1399
- if (this.destroyed || this.playEpoch !== i || ((s = this.pendingScope) == null ? void 0 : s.scope) !== t || t.state === "destroyed")
1400
- throw J("多礼物播放已取消");
1447
+ var r;
1448
+ if (this.destroyed || this.playEpoch !== i || ((r = this.pendingScope) == null ? void 0 : r.scope) !== t || t.state === "destroyed")
1449
+ throw q("多礼物播放已取消");
1401
1450
  }
1402
1451
  assertCurrentPreload(t, i) {
1403
1452
  if (this.destroyed || t.signal.aborted || this.preloadEpoch !== i || this.preloadController !== t)
1404
- throw J("多礼物资源预加载已取消");
1453
+ throw q("多礼物资源预加载已取消");
1405
1454
  }
1406
1455
  }
1407
- function Lt(e = {}) {
1456
+ function xt(e = {}) {
1408
1457
  return {
1409
1458
  name: "giftstage-plugin-multi-gift",
1410
1459
  apiVersion: 1,
1411
1460
  setup(t) {
1412
- return new Ft(t, e);
1461
+ return new Nt(t, e);
1413
1462
  }
1414
1463
  };
1415
1464
  }
1416
- function H(e) {
1465
+ function Q(e) {
1417
1466
  return e !== null && typeof e == "object" && !Array.isArray(e);
1418
1467
  }
1419
- function xe(e, t) {
1468
+ function De(e, t) {
1420
1469
  let i;
1421
1470
  try {
1422
1471
  i = JSON.parse(e);
1423
1472
  } catch {
1424
1473
  throw new Error(`${t}不是合法 JSON`);
1425
1474
  }
1426
- if (!H(i)) throw new Error(`${t}必须是 JSON 对象`);
1475
+ if (!Q(i)) throw new Error(`${t}必须是 JSON 对象`);
1427
1476
  return i;
1428
1477
  }
1429
- function Be(e, t) {
1430
- if (!H(e) || !Number.isFinite(e.width) || e.width <= 0 || !Number.isFinite(e.height) || e.height <= 0)
1478
+ function Je(e, t) {
1479
+ if (!Q(e) || !Number.isFinite(e.width) || e.width <= 0 || !Number.isFinite(e.height) || e.height <= 0)
1431
1480
  throw new Error(`${t}必须包含大于 0 的 width 和 height`);
1432
1481
  return { width: e.width, height: e.height };
1433
1482
  }
1434
- function It(e) {
1483
+ function Pt(e) {
1435
1484
  if (e === void 0) return [];
1436
1485
  if (!Array.isArray(e)) throw new Error("multiGiftEffect.imgs 必须是数组");
1437
1486
  return e.map((t, i) => {
1438
- if (!H(t) || typeof t.slot != "string" || !/^img_slot_\d+$/.test(t.slot))
1487
+ if (!Q(t) || typeof t.slot != "string" || !/^img_slot_\d+$/.test(t.slot))
1439
1488
  throw new Error(`multiGiftEffect.imgs[${i}].slot 必须是 img_slot_xx`);
1440
- if (Be(t, `multiGiftEffect.imgs[${i}]`), t.radius !== void 0 && (!Number.isFinite(t.radius) || t.radius < 0))
1489
+ if (Je(t, `multiGiftEffect.imgs[${i}]`), t.radius !== void 0 && (!Number.isFinite(t.radius) || t.radius < 0))
1441
1490
  throw new Error(`multiGiftEffect.imgs[${i}].radius 必须是大于等于 0 的数字`);
1442
1491
  return { ...t };
1443
1492
  });
1444
1493
  }
1445
- function De(e) {
1446
- if (!H(e) || !Array.isArray(e.layers))
1494
+ function Ue(e) {
1495
+ if (!Q(e) || !Array.isArray(e.layers))
1447
1496
  throw new Error("multiGiftEffect.lottie 必须包含 layers 数组");
1448
1497
  let t = 0;
1449
1498
  for (const i of e.layers) {
1450
- const s = /^slot_(\d+)$/.exec((i == null ? void 0 : i.nm) || "");
1451
- s && (t = Math.max(t, Number(s[1])));
1499
+ const r = /^slot_(\d+)$/.exec((i == null ? void 0 : i.nm) || "");
1500
+ r && (t = Math.max(t, Number(r[1])));
1452
1501
  }
1453
1502
  if (!t) throw new Error("multiGiftEffect.lottie 中至少需要一个 slot_xx 礼物插槽");
1454
1503
  return t;
1455
1504
  }
1456
- function zt(e) {
1457
- const t = typeof e == "string" ? xe(e, "本地特效配置") : e;
1458
- if (!H(t)) throw new Error("本地特效配置必须是 JSON 对象");
1505
+ function Dt(e) {
1506
+ const t = typeof e == "string" ? De(e, "本地特效配置") : e;
1507
+ if (!Q(t)) throw new Error("本地特效配置必须是 JSON 对象");
1459
1508
  if (!Object.prototype.hasOwnProperty.call(t, "lottie"))
1460
1509
  throw Array.isArray(t.layers) ? new Error("请上传 multiGiftEffect 配置,不能直接上传纯 Lottie JSON") : new Error("multiGiftEffect.lottie 不能为空");
1461
- let i, s;
1462
- if (H(t.lottie))
1510
+ let i, r;
1511
+ if (Q(t.lottie))
1463
1512
  i = t.lottie;
1464
1513
  else if (typeof t.lottie == "string" && t.lottie.trim()) {
1465
- const l = t.lottie.trim();
1466
- l.startsWith("{") ? i = xe(l, "multiGiftEffect.lottie") : s = l;
1514
+ const c = t.lottie.trim();
1515
+ c.startsWith("{") ? i = De(c, "multiGiftEffect.lottie") : r = c;
1467
1516
  } else
1468
1517
  throw new Error("multiGiftEffect.lottie 必须是 Lottie JSON 对象、JSON 字符串或 URL");
1469
- const r = Be(t.slotSize, "multiGiftEffect.slotSize"), n = t.effects === void 0 ? [] : t.effects;
1518
+ const s = Je(t.slotSize, "multiGiftEffect.slotSize"), n = t.effects === void 0 ? [] : t.effects;
1470
1519
  if (!Array.isArray(n)) throw new Error("multiGiftEffect.effects 必须是数组");
1471
1520
  return {
1472
1521
  lottieJson: i,
1473
- lottieUrl: s,
1474
- slotSize: r,
1475
- effects: n.map((l) => ({ ...l })),
1476
- imgs: It(t.imgs)
1522
+ lottieUrl: r,
1523
+ slotSize: s,
1524
+ effects: n.map((c) => ({ ...c })),
1525
+ imgs: Pt(t.imgs)
1477
1526
  };
1478
1527
  }
1479
- async function xt(e, t = fetch) {
1528
+ async function Ut(e, t = fetch) {
1480
1529
  if (e.lottieJson)
1481
- return { lottieJson: e.lottieJson, slotCount: De(e.lottieJson) };
1530
+ return { lottieJson: e.lottieJson, slotCount: Ue(e.lottieJson) };
1482
1531
  let i;
1483
1532
  try {
1484
1533
  i = await t(e.lottieUrl);
1485
- } catch (r) {
1486
- throw new Error(`无法加载 lottie URL:${r.message || "网络错误"}`);
1534
+ } catch (s) {
1535
+ throw new Error(`无法加载 lottie URL:${s.message || "网络错误"}`);
1487
1536
  }
1488
1537
  if (!i.ok) throw new Error(`无法加载 lottie URL(${i.status})`);
1489
- let s;
1538
+ let r;
1490
1539
  try {
1491
- s = await i.json();
1540
+ r = await i.json();
1492
1541
  } catch {
1493
1542
  throw new Error("lottie URL 返回的内容不是合法 JSON");
1494
1543
  }
1495
- return { lottieJson: s, slotCount: De(s) };
1544
+ return { lottieJson: r, slotCount: Ue(r) };
1496
1545
  }
1497
1546
  export {
1498
- Ft as GiftStageMultiGiftPluginApi,
1499
- ae as MultiGiftValidationError,
1500
- He as bezierEase,
1501
- Lt as createGiftStageMultiGiftPlugin,
1502
- Lt as default,
1503
- Pt as easeInOutCubic,
1504
- tt as easeOutCubic,
1505
- pe as findMarker,
1506
- _t as findUnsupportedCapabilities,
1507
- xt as inspectLocalLottie,
1508
- mt as normalizePlayConfig,
1509
- zt as parseLocalMultiGiftEffect,
1510
- Ct as spatialBezierPoint,
1511
- Qe as validateMultiGiftComposition,
1512
- q as valueAt
1547
+ Nt as GiftStageMultiGiftPluginApi,
1548
+ le as MultiGiftValidationError,
1549
+ Qe as bezierEase,
1550
+ xt as createGiftStageMultiGiftPlugin,
1551
+ xt as default,
1552
+ zt as easeInOutCubic,
1553
+ it as easeOutCubic,
1554
+ be as findMarker,
1555
+ Ct as findUnsupportedCapabilities,
1556
+ Ut as inspectLocalLottie,
1557
+ pt as normalizePlayConfig,
1558
+ Dt as parseLocalMultiGiftEffect,
1559
+ Lt as spatialBezierPoint,
1560
+ et as validateMultiGiftComposition,
1561
+ H as valueAt
1513
1562
  };