@mirage-engine/core 0.3.15 → 0.3.16

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.
@@ -2,16 +2,16 @@ var Oe = Object.defineProperty, Xe = Object.defineProperties;
2
2
  var _e = Object.getOwnPropertyDescriptors;
3
3
  var xe = Object.getOwnPropertySymbols;
4
4
  var Ne = Object.prototype.hasOwnProperty, ze = Object.prototype.propertyIsEnumerable;
5
- var ve = (i, e, t) => e in i ? Oe(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, te = (i, e) => {
5
+ var ve = (r, e, t) => e in r ? Oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, te = (r, e) => {
6
6
  for (var t in e || (e = {}))
7
- Ne.call(e, t) && ve(i, t, e[t]);
7
+ Ne.call(e, t) && ve(r, t, e[t]);
8
8
  if (xe)
9
9
  for (var t of xe(e))
10
- ze.call(e, t) && ve(i, t, e[t]);
11
- return i;
12
- }, Se = (i, e) => Xe(i, _e(e));
13
- var p = (i, e, t) => (ve(i, typeof e != "symbol" ? e + "" : e, t), t);
14
- var Ee = (i, e, t) => new Promise((r, s) => {
10
+ ze.call(e, t) && ve(r, t, e[t]);
11
+ return r;
12
+ }, Se = (r, e) => Xe(r, _e(e));
13
+ var p = (r, e, t) => (ve(r, typeof e != "symbol" ? e + "" : e, t), t);
14
+ var Ee = (r, e, t) => new Promise((i, s) => {
15
15
  var c = (n) => {
16
16
  try {
17
17
  a(t.next(n));
@@ -24,8 +24,8 @@ var Ee = (i, e, t) => new Promise((r, s) => {
24
24
  } catch (l) {
25
25
  s(l);
26
26
  }
27
- }, a = (n) => n.done ? r(n.value) : Promise.resolve(n.value).then(c, o);
28
- a((t = t.apply(i, e)).next());
27
+ }, a = (n) => n.done ? i(n.value) : Promise.resolve(n.value).then(c, o);
28
+ a((t = t.apply(r, e)).next());
29
29
  });
30
30
  import * as w from "three";
31
31
  const De = {
@@ -77,22 +77,22 @@ const De = {
77
77
  FRONT: "front"
78
78
  }
79
79
  }, ue = 0, re = 1, he = 2, Ye = 4, fe = 8, we = 16;
80
- function We(i) {
81
- const e = i.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
80
+ function We(r) {
81
+ const e = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
82
82
  return e ? {
83
83
  r: parseInt(e[1]) / 255,
84
84
  g: parseInt(e[2]) / 255,
85
85
  b: parseInt(e[3]) / 255
86
86
  } : { r: 1, g: 1, b: 1 };
87
87
  }
88
- function Pe(i) {
88
+ function Pe(r) {
89
89
  const e = {};
90
- if (i.opacity && (e.opacity = parseFloat(i.opacity)), i.backgroundColor && i.backgroundColor !== "rgba(0, 0, 0, 0)") {
91
- const t = We(i.backgroundColor);
90
+ if (r.opacity && (e.opacity = parseFloat(r.opacity)), r.backgroundColor && r.backgroundColor !== "rgba(0, 0, 0, 0)") {
91
+ const t = We(r.backgroundColor);
92
92
  e.backgroundColor = [t.r, t.g, t.b];
93
93
  }
94
- if (i.backgroundImage ? e.backgroundImage = i.backgroundImage : i.background && (e.backgroundImage = i.background), i.borderRadius && (e.borderRadius = parseFloat(i.borderRadius)), i.width && (e.width = parseFloat(i.width)), i.height && (e.height = parseFloat(i.height)), i.transform && i.transform !== "none") {
95
- const t = new DOMMatrix(i.transform);
94
+ if (r.backgroundImage ? e.backgroundImage = r.backgroundImage : r.background && (e.backgroundImage = r.background), r.boxShadow && (e.boxShadow = r.boxShadow), r.borderRadius && (e.borderRadius = parseFloat(r.borderRadius)), r.width && (e.width = parseFloat(r.width)), r.height && (e.height = parseFloat(r.height)), r.transform && r.transform !== "none") {
95
+ const t = new DOMMatrix(r.transform);
96
96
  e.x = t.m41, e.y = t.m42, e.z = t.m43;
97
97
  }
98
98
  return e;
@@ -136,20 +136,20 @@ class He {
136
136
  p(this, "renderLoop", () => {
137
137
  if (!this.isRunning)
138
138
  return;
139
- this.onBeforeRender.forEach((r) => r()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((r) => r(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = ue);
139
+ this.onBeforeRender.forEach((i) => i()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((i) => i(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = ue);
140
140
  const e = window.scrollX, t = window.scrollY;
141
- (e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((r) => r(e, t)), this.lastScrollX = e, this.lastScrollY = t, this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
141
+ (e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((i) => i(e, t)), this.lastScrollX = e, this.lastScrollY = t, this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
142
142
  this.pendingMask |= re, this.isDomDirty = !0, this.scrollTimer = null;
143
- }, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
143
+ }, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((i) => i(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((i) => i()), requestAnimationFrame(this.renderLoop);
144
144
  });
145
145
  var s, c;
146
146
  this.target = e;
147
- const r = (s = t.resizeDebounce) != null ? s : !0;
148
- r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
147
+ const i = (s = t.resizeDebounce) != null ? s : !0;
148
+ i === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : i === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
149
149
  enabled: !0,
150
- delay: (c = r.delay) != null ? c : 150,
151
- onStart: r.onStart,
152
- onEnd: r.onEnd
150
+ delay: (c = i.delay) != null ? c : 150,
151
+ onStart: i.onStart,
152
+ onEnd: i.onEnd
153
153
  }, this.observer = new MutationObserver((o) => {
154
154
  let a = ue;
155
155
  for (const n of o)
@@ -195,7 +195,7 @@ class He {
195
195
  const q = 1, ae = 2, ht = 0, F = {
196
196
  BASE: 0,
197
197
  SELECTED: 1,
198
- getCaptureLayer: (i) => 31 - i,
198
+ getCaptureLayer: (r) => 31 - r,
199
199
  HIDDEN: 31
200
200
  }, Te = Object.values(G.VALUES);
201
201
  class Ae {
@@ -213,15 +213,15 @@ class Ae {
213
213
  static calculateBaselineFromDOM(e) {
214
214
  if (typeof document == "undefined")
215
215
  return 0;
216
- const t = document.createElement("div"), r = document.createElement("span"), s = document.createElement("img");
217
- t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", r.style.margin = "0", r.style.padding = "0", r.style.border = "none", r.style.lineHeight = "normal", s.width = 1, s.height = 1, s.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(s), document.body.appendChild(t);
218
- const c = s.offsetTop - r.offsetTop;
216
+ const t = document.createElement("div"), i = document.createElement("span"), s = document.createElement("img");
217
+ t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", i.style.margin = "0", i.style.padding = "0", i.style.border = "none", i.style.lineHeight = "normal", s.width = 1, s.height = 1, s.style.verticalAlign = "baseline", i.appendChild(document.createTextNode("Hidden Text")), t.appendChild(i), t.appendChild(s), document.body.appendChild(t);
218
+ const c = s.offsetTop - i.offsetTop;
219
219
  return document.body.removeChild(t), c;
220
220
  }
221
221
  }
222
222
  p(Ae, "cache", /* @__PURE__ */ new Map());
223
223
  class Ge extends w.MeshBasicMaterial {
224
- constructor(t, r, s, c, o = 2) {
224
+ constructor(t, i, s, c, o = 2) {
225
225
  super({
226
226
  transparent: !0,
227
227
  side: w.FrontSide,
@@ -232,9 +232,9 @@ class Ge extends w.MeshBasicMaterial {
232
232
  p(this, "qualityFactor");
233
233
  if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
234
234
  throw new Error("[Mirage] Failed to create canvas context");
235
- this.qualityFactor = o, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t, r, s, c);
235
+ this.qualityFactor = o, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t, i, s, c);
236
236
  }
237
- wrapText(t, r) {
237
+ wrapText(t, i) {
238
238
  const s = t.split(`
239
239
  `), c = [];
240
240
  return s.forEach((o) => {
@@ -246,54 +246,54 @@ class Ge extends w.MeshBasicMaterial {
246
246
  let n = a[0];
247
247
  for (let l = 1; l < a.length; l++) {
248
248
  const d = a[l];
249
- this.ctx.measureText(n + d).width <= r + 2 ? n += d : (n && c.push(n), n = d.trimStart());
249
+ this.ctx.measureText(n + d).width <= i + 2 ? n += d : (n && c.push(n), n = d.trimStart());
250
250
  }
251
251
  n && c.push(n);
252
252
  }), c;
253
253
  }
254
- updateText(t, r, s, c, o) {
254
+ updateText(t, i, s, c, o) {
255
255
  o !== void 0 && (this.qualityFactor = o);
256
256
  const n = (window.devicePixelRatio || 1) * this.qualityFactor, l = s * n, d = c * n;
257
- this.canvas.width !== l || this.canvas.height !== d ? (this.canvas.width = l, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(n, 0, 0, n, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
258
- const h = this.wrapText(t, s), u = r.lineHeight, f = Ae.getBaseline(r.font);
257
+ this.canvas.width !== l || this.canvas.height !== d ? (this.canvas.width = l, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(n, 0, 0, n, 0, 0), this.ctx.font = i.font, this.ctx.fillStyle = i.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
258
+ const h = this.wrapText(t, s), u = i.lineHeight, f = Ae.getBaseline(i.font);
259
259
  h.forEach((g, v) => {
260
260
  const b = v * u + f;
261
261
  let C = 0;
262
- r.textAlign === "center" ? C = s / 2 : r.textAlign === "right" && (C = s), this.ctx.textAlign = r.textAlign, this.ctx.fillText(g, C, b);
262
+ i.textAlign === "center" ? C = s / 2 : i.textAlign === "right" && (C = s), this.ctx.textAlign = i.textAlign, this.ctx.fillText(g, C, b);
263
263
  }), this.map && (this.map.needsUpdate = !0);
264
264
  }
265
265
  dispose() {
266
266
  this.map && this.map.dispose(), super.dispose();
267
267
  }
268
268
  }
269
- function ne(i, e = 0) {
270
- if (typeof i == "number")
271
- return i;
272
- const t = parseFloat(i) || 0;
273
- return typeof i == "string" && i.includes("%") ? t / 100 * e : t;
269
+ function ne(r, e = 0) {
270
+ if (typeof r == "number")
271
+ return r;
272
+ const t = parseFloat(r) || 0;
273
+ return typeof r == "string" && r.includes("%") ? t / 100 * e : t;
274
274
  }
275
- function le(i) {
276
- if (!i || i === "transparent")
275
+ function le(r) {
276
+ if (!r || r === "transparent")
277
277
  return { color: new w.Color(16777215), alpha: 0 };
278
- const e = i.match(
278
+ const e = r.match(
279
279
  /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
280
280
  );
281
281
  if (e) {
282
- const t = parseInt(e[1], 10), r = parseInt(e[2], 10), s = parseInt(e[3], 10), c = e[4] !== void 0 ? parseFloat(e[4]) : 1;
283
- return { color: new w.Color(`rgb(${t}, ${r}, ${s})`), alpha: c };
282
+ const t = parseInt(e[1], 10), i = parseInt(e[2], 10), s = parseInt(e[3], 10), c = e[4] !== void 0 ? parseFloat(e[4]) : 1;
283
+ return { color: new w.Color(`rgb(${t}, ${i}, ${s})`), alpha: c };
284
284
  }
285
- return { color: new w.Color(i), alpha: 1 };
285
+ return { color: new w.Color(r), alpha: 1 };
286
286
  }
287
- function Ie(i) {
287
+ function Ie(r) {
288
288
  const e = [];
289
- let t = "", r = 0;
290
- for (let s = 0; s < i.length; s++) {
291
- const c = i[s];
289
+ let t = "", i = 0;
290
+ for (let s = 0; s < r.length; s++) {
291
+ const c = r[s];
292
292
  if (c === "(")
293
- r++;
293
+ i++;
294
294
  else if (c === ")")
295
- r--;
296
- else if (c === "," && r === 0) {
295
+ i--;
296
+ else if (c === "," && i === 0) {
297
297
  e.push(t.trim()), t = "";
298
298
  continue;
299
299
  }
@@ -301,15 +301,15 @@ function Ie(i) {
301
301
  }
302
302
  return t && e.push(t.trim()), e;
303
303
  }
304
- function qe(i) {
305
- if (!i || typeof i != "string" || !i.includes("linear-gradient"))
304
+ function qe(r) {
305
+ if (!r || typeof r != "string" || !r.includes("linear-gradient"))
306
306
  return null;
307
- const e = i.match(/linear-gradient\((.*)\)/);
307
+ const e = r.match(/linear-gradient\((.*)\)/);
308
308
  if (!e)
309
309
  return null;
310
- const t = e[1], r = Ie(t);
310
+ const t = e[1], i = Ie(t);
311
311
  let s = Math.PI, c = 0;
312
- const o = r[0].trim();
312
+ const o = i[0].trim();
313
313
  if (o.startsWith("to "))
314
314
  o === "to top" ? s = 0 : o === "to right" ? s = Math.PI / 2 : o === "to bottom" ? s = Math.PI : o === "to left" ? s = Math.PI * 1.5 : o === "to top right" || o === "to right top" ? s = Math.PI / 4 : o === "to bottom right" || o === "to right bottom" ? s = Math.PI * 0.75 : o === "to bottom left" || o === "to left bottom" ? s = Math.PI * 1.25 : (o === "to top left" || o === "to left top") && (s = Math.PI * 1.75), c = 1;
315
315
  else if (o.endsWith("deg") || o.endsWith("rad") || o.endsWith("turn")) {
@@ -317,8 +317,8 @@ function qe(i) {
317
317
  o.endsWith("deg") ? s = n * (Math.PI / 180) : o.endsWith("rad") ? s = n : o.endsWith("turn") && (s = n * Math.PI * 2), c = 1;
318
318
  }
319
319
  const a = [];
320
- for (let n = c; n < r.length && !(a.length >= 8); n++) {
321
- const l = r[n].trim(), d = l.lastIndexOf(" ");
320
+ for (let n = c; n < i.length && !(a.length >= 8); n++) {
321
+ const l = i[n].trim(), d = l.lastIndexOf(" ");
322
322
  let h = l, u = null;
323
323
  if (d !== -1 && !l.endsWith(")")) {
324
324
  const g = l.substring(d + 1);
@@ -350,13 +350,13 @@ function qe(i) {
350
350
  }
351
351
  return { angle: s, stops: a };
352
352
  }
353
- function $e(i) {
354
- if (!i || i === "none")
353
+ function $e(r) {
354
+ if (!r || r === "none")
355
355
  return null;
356
- const e = Ie(i);
356
+ const e = Ie(r);
357
357
  if (e.length === 0)
358
358
  return null;
359
- const t = e[0].trim(), r = /(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/, s = t.match(r);
359
+ const t = e[0].trim(), i = /(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/, s = t.match(i);
360
360
  let c = "transparent", o = t;
361
361
  if (s && s[1] !== "inset") {
362
362
  const f = s[1];
@@ -546,9 +546,9 @@ baseColor = blendSrcOver(baseColor, texColor);`, Re = {
546
546
  uvChunk: Ze,
547
547
  baseColorChunk: Qe
548
548
  };
549
- function et(i, e, t, r = null, s) {
549
+ function et(r, e, t, i = null, s) {
550
550
  var S;
551
- const c = r !== null || !!i.imageSrc;
551
+ const c = i !== null || !!r.imageSrc;
552
552
  let o = "";
553
553
  const a = {};
554
554
  if (s != null && s.uniforms)
@@ -561,10 +561,10 @@ function et(i, e, t, r = null, s) {
561
561
  `, a[R] = { value: E });
562
562
  const n = s !== void 0, l = (c || n ? Me.declChunk : "") + `
563
563
  ` + o, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
564
- `, h = i.isTraveler ? `vec2 resultUv = screenUv;
564
+ `, h = r.isTraveler ? `vec2 resultUv = screenUv;
565
565
  ` : `vec2 localUv = (p / uSize) + 0.5;
566
566
  vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
567
- `, u = c || n ? d + h + ((s == null ? void 0 : s.uvModifier) || "") : "", f = c || n ? Me.baseColorChunk : "", g = (s == null ? void 0 : s.colorModifier) || "", v = Re.fragmentShader.replace("#INJECT_DECLARATIONS", l).replace("#INJECT_UV_MODIFIER", u).replace("#INJECT_BASE_COLOR", f).replace("#INJECT_COLOR_MODIFIER", g), b = le(i.backgroundColor), C = le(i.borderColor), I = {
567
+ `, u = c || n ? d + h + ((s == null ? void 0 : s.uvModifier) || "") : "", f = c || n ? Me.baseColorChunk : "", g = (s == null ? void 0 : s.colorModifier) || "", v = Re.fragmentShader.replace("#INJECT_DECLARATIONS", l).replace("#INJECT_UV_MODIFIER", u).replace("#INJECT_BASE_COLOR", f).replace("#INJECT_COLOR_MODIFIER", g), b = le(r.backgroundColor), C = le(r.borderColor), I = {
568
568
  uSize: { value: new w.Vector2(e, t) },
569
569
  uMeshSize: { value: new w.Vector2(e, t) },
570
570
  uShadowColor: { value: new w.Vector4(0, 0, 0, 0) },
@@ -588,8 +588,8 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
588
588
  )
589
589
  },
590
590
  uBorderRadius: { value: new w.Vector4(0, 0, 0, 0) },
591
- uBorderWidth: { value: ne(i.borderWidth) },
592
- uOpacity: { value: (S = i.opacity) != null ? S : 1 },
591
+ uBorderWidth: { value: ne(r.borderWidth) },
592
+ uOpacity: { value: (S = r.opacity) != null ? S : 1 },
593
593
  uTexture: { value: null },
594
594
  uTextureRepeat: { value: new w.Vector2(1, 1) },
595
595
  uTextureOffset: { value: new w.Vector2(0, 0) },
@@ -600,7 +600,7 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
600
600
  },
601
601
  uGradientStops: { value: new Float32Array(8) }
602
602
  };
603
- ke(I.uBorderRadius.value, i.borderRadius, Math.min(e, t)), c && (I.uTexture.value = r);
603
+ ke(I.uBorderRadius.value, r.borderRadius, Math.min(e, t)), c && (I.uTexture.value = i);
604
604
  const D = new w.ShaderMaterial({
605
605
  uniforms: te(te({}, I), a),
606
606
  vertexShader: Re.vertexShader,
@@ -609,13 +609,13 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
609
609
  side: w.FrontSide
610
610
  // for better performance
611
611
  });
612
- return i.backgroundImage && be(D, { backgroundImage: i.backgroundImage }), D;
612
+ return r.backgroundImage && be(D, { backgroundImage: r.backgroundImage }), D;
613
613
  }
614
- function tt(i, e, t, r, s) {
614
+ function tt(r, e, t, i, s) {
615
615
  const c = ne(e.borderWidth);
616
- be(i, {
616
+ be(r, {
617
617
  width: t,
618
- height: r,
618
+ height: i,
619
619
  borderRadius: e.borderRadius,
620
620
  borderWidth: c,
621
621
  backgroundColor: e.backgroundColor,
@@ -626,24 +626,24 @@ function tt(i, e, t, r, s) {
626
626
  boxShadow: e.boxShadow
627
627
  });
628
628
  }
629
- function be(i, e) {
630
- var r, s, c;
629
+ function be(r, e) {
630
+ var i, s, c;
631
631
  if (e.boxShadow !== void 0) {
632
632
  const o = $e(e.boxShadow);
633
- o ? (i.uniforms.uShadowColor.value.set(o.color.r, o.color.g, o.color.b, o.alpha), i.uniforms.uShadowOffset.value.set(o.offsetX, o.offsetY), i.uniforms.uShadowBlur.value = o.blurRadius, i.uniforms.uShadowSpread.value = o.spreadRadius, i.userData.shadowPadding = o.blurRadius + o.spreadRadius + Math.max(Math.abs(o.offsetX), Math.abs(o.offsetY))) : (i.uniforms.uShadowColor.value.w = 0, i.userData.shadowPadding = 0);
633
+ o ? (r.uniforms.uShadowColor.value.set(o.color.r, o.color.g, o.color.b, o.alpha), r.uniforms.uShadowOffset.value.set(o.offsetX, o.offsetY), r.uniforms.uShadowBlur.value = o.blurRadius, r.uniforms.uShadowSpread.value = o.spreadRadius, r.userData.shadowPadding = o.blurRadius + o.spreadRadius + Math.max(Math.abs(o.offsetX), Math.abs(o.offsetY))) : (r.uniforms.uShadowColor.value.w = 0, r.userData.shadowPadding = 0);
634
634
  }
635
- if (e.width !== void 0 && e.height !== void 0 && i.uniforms.uSize.value.set(e.width, e.height), i.uniforms.uMeshSize) {
636
- const o = i.userData.shadowPadding || 0, a = e.width !== void 0 ? e.width : i.uniforms.uSize.value.x, n = e.height !== void 0 ? e.height : i.uniforms.uSize.value.y;
637
- i.uniforms.uMeshSize.value.set(a + o * 2, n + o * 2);
635
+ if (e.width !== void 0 && e.height !== void 0 && r.uniforms.uSize.value.set(e.width, e.height), r.uniforms.uMeshSize) {
636
+ const o = r.userData.shadowPadding || 0, a = e.width !== void 0 ? e.width : r.uniforms.uSize.value.x, n = e.height !== void 0 ? e.height : r.uniforms.uSize.value.y;
637
+ r.uniforms.uMeshSize.value.set(a + o * 2, n + o * 2);
638
638
  }
639
639
  if (e.borderRadius !== void 0) {
640
- const o = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(i.uniforms.uSize.value.x, i.uniforms.uSize.value.y);
641
- ke(i.uniforms.uBorderRadius.value, e.borderRadius, o);
640
+ const o = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(r.uniforms.uSize.value.x, r.uniforms.uSize.value.y);
641
+ ke(r.uniforms.uBorderRadius.value, e.borderRadius, o);
642
642
  }
643
- if (e.borderWidth !== void 0 && (i.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
643
+ if (e.borderWidth !== void 0 && (r.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
644
644
  if (Array.isArray(e.backgroundColor)) {
645
- const o = i.uniforms.uBgColor.value.w;
646
- i.uniforms.uBgColor.value.set(
645
+ const o = r.uniforms.uBgColor.value.w;
646
+ r.uniforms.uBgColor.value.set(
647
647
  e.backgroundColor[0],
648
648
  e.backgroundColor[1],
649
649
  e.backgroundColor[2],
@@ -651,15 +651,15 @@ function be(i, e) {
651
651
  );
652
652
  } else if (typeof e.backgroundColor == "string") {
653
653
  const o = le(e.backgroundColor);
654
- i.uniforms.uBgColor.value.set(
654
+ r.uniforms.uBgColor.value.set(
655
655
  o.color.r,
656
656
  o.color.g,
657
657
  o.color.b,
658
658
  o.alpha
659
659
  );
660
660
  } else {
661
- const o = i.uniforms.uBgColor.value.w;
662
- i.uniforms.uBgColor.value.set(
661
+ const o = r.uniforms.uBgColor.value.w;
662
+ r.uniforms.uBgColor.value.set(
663
663
  e.backgroundColor.r,
664
664
  e.backgroundColor.g,
665
665
  e.backgroundColor.b,
@@ -668,8 +668,8 @@ function be(i, e) {
668
668
  }
669
669
  if (e.borderColor !== void 0)
670
670
  if (Array.isArray(e.borderColor)) {
671
- const o = i.uniforms.uBorderColor.value.w;
672
- i.uniforms.uBorderColor.value.set(
671
+ const o = r.uniforms.uBorderColor.value.w;
672
+ r.uniforms.uBorderColor.value.set(
673
673
  e.borderColor[0],
674
674
  e.borderColor[1],
675
675
  e.borderColor[2],
@@ -677,108 +677,108 @@ function be(i, e) {
677
677
  );
678
678
  } else if (typeof e.borderColor == "string") {
679
679
  const o = le(e.borderColor);
680
- i.uniforms.uBorderColor.value.set(
680
+ r.uniforms.uBorderColor.value.set(
681
681
  o.color.r,
682
682
  o.color.g,
683
683
  o.color.b,
684
684
  o.alpha
685
685
  );
686
686
  } else {
687
- const o = i.uniforms.uBorderColor.value.w;
688
- i.uniforms.uBorderColor.value.set(
687
+ const o = r.uniforms.uBorderColor.value.w;
688
+ r.uniforms.uBorderColor.value.set(
689
689
  e.borderColor.r,
690
690
  e.borderColor.g,
691
691
  e.borderColor.b,
692
692
  o
693
693
  );
694
694
  }
695
- e.opacity !== void 0 && (i.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (i.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (i.uniforms.uBorderColor.value.w = e.borderOpacity), i.uniforms.uTexture && e.texture !== void 0 && (i.uniforms.uTexture.value = e.texture);
696
- const t = e.texture !== void 0 ? e.texture : (r = i.uniforms.uTexture) == null ? void 0 : r.value;
695
+ e.opacity !== void 0 && (r.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (r.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (r.uniforms.uBorderColor.value.w = e.borderOpacity), r.uniforms.uTexture && e.texture !== void 0 && (r.uniforms.uTexture.value = e.texture);
696
+ const t = e.texture !== void 0 ? e.texture : (i = r.uniforms.uTexture) == null ? void 0 : i.value;
697
697
  if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
698
- const o = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, n = (s = e.width) != null ? s : i.uniforms.uSize.value.x, l = (c = e.height) != null ? c : i.uniforms.uSize.value.y;
698
+ const o = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, n = (s = e.width) != null ? s : r.uniforms.uSize.value.x, l = (c = e.height) != null ? c : r.uniforms.uSize.value.y;
699
699
  if (o && a && n && l) {
700
700
  const d = o / a, h = n / l;
701
701
  if (d > h) {
702
702
  const u = h / d;
703
- i.uniforms.uTextureRepeat.value.set(u, 1), i.uniforms.uTextureOffset.value.set((1 - u) / 2, 0);
703
+ r.uniforms.uTextureRepeat.value.set(u, 1), r.uniforms.uTextureOffset.value.set((1 - u) / 2, 0);
704
704
  } else {
705
705
  const u = d / h;
706
- i.uniforms.uTextureRepeat.value.set(1, u), i.uniforms.uTextureOffset.value.set(0, (1 - u) / 2);
706
+ r.uniforms.uTextureRepeat.value.set(1, u), r.uniforms.uTextureOffset.value.set(0, (1 - u) / 2);
707
707
  }
708
708
  }
709
709
  } else
710
- i.uniforms.uTextureRepeat && (i.uniforms.uTextureRepeat.value.set(1, 1), i.uniforms.uTextureOffset.value.set(0, 0));
710
+ r.uniforms.uTextureRepeat && (r.uniforms.uTextureRepeat.value.set(1, 1), r.uniforms.uTextureOffset.value.set(0, 0));
711
711
  if (e.backgroundImage !== void 0) {
712
712
  const o = qe(e.backgroundImage);
713
713
  if (o) {
714
- i.uniforms.uGradientCount.value = o.stops.length, i.uniforms.uGradientAngle.value = o.angle;
714
+ r.uniforms.uGradientCount.value = o.stops.length, r.uniforms.uGradientAngle.value = o.angle;
715
715
  for (let a = 0; a < 8; a++)
716
716
  if (a < o.stops.length) {
717
717
  const n = o.stops[a];
718
- i.uniforms.uGradientColors.value[a].set(
718
+ r.uniforms.uGradientColors.value[a].set(
719
719
  n.color.r,
720
720
  n.color.g,
721
721
  n.color.b,
722
722
  n.alpha
723
- ), i.uniforms.uGradientStops.value[a] = n.stop;
723
+ ), r.uniforms.uGradientStops.value[a] = n.stop;
724
724
  } else
725
- i.uniforms.uGradientColors.value[a].set(0, 0, 0, 0), i.uniforms.uGradientStops.value[a] = 1;
725
+ r.uniforms.uGradientColors.value[a].set(0, 0, 0, 0), r.uniforms.uGradientStops.value[a] = 1;
726
726
  } else
727
- i.uniforms.uGradientCount.value = 0;
727
+ r.uniforms.uGradientCount.value = 0;
728
728
  }
729
729
  for (const o of Object.keys(e))
730
- o !== "width" && o !== "height" && o !== "borderRadius" && o !== "borderWidth" && o !== "backgroundColor" && o !== "borderColor" && o !== "opacity" && o !== "bgOpacity" && o !== "borderOpacity" && o !== "texture" && o !== "backgroundImage" && o !== "boxShadow" && i.uniforms[o] !== void 0 && (i.uniforms[o].value !== void 0 && i.uniforms[o].value !== null && typeof i.uniforms[o].value.set == "function" ? Array.isArray(e[o]) ? i.uniforms[o].value.set(...e[o]) : e[o] !== void 0 && (e[o].copy ? i.uniforms[o].value.copy(e[o]) : i.uniforms[o].value = e[o]) : i.uniforms[o].value = e[o]);
730
+ o !== "width" && o !== "height" && o !== "borderRadius" && o !== "borderWidth" && o !== "backgroundColor" && o !== "borderColor" && o !== "opacity" && o !== "bgOpacity" && o !== "borderOpacity" && o !== "texture" && o !== "backgroundImage" && o !== "boxShadow" && r.uniforms[o] !== void 0 && (r.uniforms[o].value !== void 0 && r.uniforms[o].value !== null && typeof r.uniforms[o].value.set == "function" ? Array.isArray(e[o]) ? r.uniforms[o].value.set(...e[o]) : e[o] !== void 0 && (e[o].copy ? r.uniforms[o].value.copy(e[o]) : r.uniforms[o].value = e[o]) : r.uniforms[o].value = e[o]);
731
731
  }
732
- function ke(i, e, t = 0) {
732
+ function ke(r, e, t = 0) {
733
733
  var n, l, d, h;
734
734
  if (e == null) {
735
- i.set(0, 0, 0, 0);
735
+ r.set(0, 0, 0, 0);
736
736
  return;
737
737
  }
738
738
  if (typeof e == "number") {
739
- i.set(e, e, e, e);
739
+ r.set(e, e, e, e);
740
740
  return;
741
741
  }
742
742
  if (Array.isArray(e)) {
743
- i.set(e[0], e[1], e[2], e[3]);
743
+ r.set(e[0], e[1], e[2], e[3]);
744
744
  return;
745
745
  }
746
- const r = e.split("/")[0].trim().split(/\s+/), s = ne(r[0], t), c = ne((n = r[1]) != null ? n : r[0], t), o = ne((l = r[2]) != null ? l : r[0], t), a = ne((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
747
- i.set(s, c, o, a);
746
+ const i = e.split("/")[0].trim().split(/\s+/), s = ne(i[0], t), c = ne((n = i[1]) != null ? n : i[0], t), o = ne((l = i[2]) != null ? l : i[0], t), a = ne((h = (d = i[3]) != null ? d : i[1]) != null ? h : i[0], t);
747
+ r.set(s, c, o, a);
748
748
  }
749
749
  const W = {
750
- create(i, e, t, r, s, c = 2, o = null, a) {
751
- return i === "BOX" ? et(
750
+ create(r, e, t, i, s, c = 2, o = null, a) {
751
+ return r === "BOX" ? et(
752
752
  e,
753
- r,
753
+ i,
754
754
  s,
755
755
  o,
756
756
  a
757
- ) : i === "TEXT" ? new Ge(
757
+ ) : r === "TEXT" ? new Ge(
758
758
  t || "",
759
759
  e,
760
- r,
760
+ i,
761
761
  s,
762
762
  c
763
763
  ) : new w.MeshBasicMaterial({ visible: !1 });
764
764
  },
765
- update(i, e, t, r, s, c, o = 2, a) {
765
+ update(r, e, t, i, s, c, o = 2, a) {
766
766
  e === "BOX" ? tt(
767
- i,
767
+ r,
768
768
  t,
769
769
  s,
770
770
  c,
771
771
  a
772
- ) : e === "TEXT" && i.updateText(
773
- r || "",
772
+ ) : e === "TEXT" && r.updateText(
773
+ i || "",
774
774
  t,
775
775
  s,
776
776
  c,
777
777
  o
778
778
  );
779
779
  },
780
- forceUpdateUniforms(i, e) {
781
- be(i, e);
780
+ forceUpdateUniforms(r, e) {
781
+ be(r, e);
782
782
  }
783
783
  };
784
784
  class rt {
@@ -789,8 +789,8 @@ class rt {
789
789
  p(this, "elementUrls", /* @__PURE__ */ new WeakMap());
790
790
  p(this, "onUpdate");
791
791
  this.onUpdate = e, t && (this.observer = new IntersectionObserver(
792
- (r) => {
793
- for (const s of r) {
792
+ (i) => {
793
+ for (const s of i) {
794
794
  const c = s.target;
795
795
  s.isIntersecting ? this.loadTexture(c) : this.disposeTexture(c);
796
796
  }
@@ -814,24 +814,24 @@ class rt {
814
814
  if (t) {
815
815
  this.loadStatus.set(e, !0);
816
816
  try {
817
- let r;
817
+ let i;
818
818
  if (t.startsWith("data:image/svg+xml"))
819
- r = yield new Promise((c, o) => {
819
+ i = yield new Promise((c, o) => {
820
820
  const a = new Image();
821
821
  a.onload = () => c(a), a.onerror = o, a.src = t;
822
822
  });
823
823
  else {
824
824
  const o = yield (yield fetch(t)).blob();
825
- r = yield createImageBitmap(o, { imageOrientation: "flipY" });
825
+ i = yield createImageBitmap(o, { imageOrientation: "flipY" });
826
826
  }
827
827
  if (this.elementUrls.get(e) !== t) {
828
- "close" in r && r.close();
828
+ "close" in i && i.close();
829
829
  return;
830
830
  }
831
- const s = new w.Texture(r);
832
- r instanceof HTMLImageElement || (s.flipY = !1), s.colorSpace = w.LinearSRGBColorSpace, s.needsUpdate = !0, this.textures.set(e, s), this.onUpdate(e, s);
833
- } catch (r) {
834
- console.warn("[MirageEngine] Failed to load texture:", t, r);
831
+ const s = new w.Texture(i);
832
+ i instanceof HTMLImageElement || (s.flipY = !1), s.colorSpace = w.LinearSRGBColorSpace, s.needsUpdate = !0, this.textures.set(e, s), this.onUpdate(e, s);
833
+ } catch (i) {
834
+ console.warn("[MirageEngine] Failed to load texture:", t, i);
835
835
  } finally {
836
836
  this.elementUrls.has(e) && this.loadStatus.set(e, !1);
837
837
  }
@@ -850,7 +850,7 @@ class rt {
850
850
  }
851
851
  }
852
852
  class it {
853
- constructor(e, t, r, s) {
853
+ constructor(e, t, i, s) {
854
854
  p(this, "canvas");
855
855
  p(this, "scene");
856
856
  p(this, "camera");
@@ -875,7 +875,7 @@ class it {
875
875
  // private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
876
876
  p(this, "fixedMeshes", /* @__PURE__ */ new Set());
877
877
  var a, n, l, d, h;
878
- this.target = e, this.mountContainer = r, this.registry = s, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (n = t.canvasSize) != null ? n : "viewport", this.clipArea = (l = t.travelerClipArea) != null ? l : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new rt((u, f) => {
878
+ this.target = e, this.mountContainer = i, this.registry = s, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (n = t.canvasSize) != null ? n : "viewport", this.clipArea = (l = t.travelerClipArea) != null ? l : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new rt((u, f) => {
879
879
  const g = this.registry.get(u);
880
880
  g && g.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(g.material, { texture: f });
881
881
  }, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new w.Scene(), this.targetRect = this.target.getBoundingClientRect();
@@ -903,11 +903,11 @@ class it {
903
903
  }
904
904
  createRenderTarget() {
905
905
  for (let e = 0; e < _.MAX_LAYERS; e++) {
906
- const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, r = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
906
+ const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, i = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
907
907
  this.renderTargets.push(
908
908
  new w.WebGLRenderTarget(
909
909
  t * this.qualityFactor,
910
- r * this.qualityFactor,
910
+ i * this.qualityFactor,
911
911
  {
912
912
  minFilter: w.LinearFilter,
913
913
  magFilter: w.LinearFilter,
@@ -947,13 +947,13 @@ class it {
947
947
  this.canvas.style.width = `${e}px`, this.canvas.style.height = `${t}px`, this.mode === "duplicate" ? (this.canvas.style.position = "", this.canvas.style.top = "", this.canvas.style.left = "", this.canvas.style.display = "block") : (this.canvas.style.position = this.isViewport ? "fixed" : "absolute", this.canvas.style.top = this.isViewport ? `-${this.overscan}px` : `${this.target.offsetTop}px`, this.canvas.style.left = this.isViewport ? `-${this.overscan}px` : `${this.target.offsetLeft}px`, this.canvas.style.display = "block");
948
948
  }
949
949
  updateUniforms(e, t) {
950
- const r = this.registry.get(e);
951
- r && (r.traverse((s) => {
950
+ const i = this.registry.get(e);
951
+ i && (i.traverse((s) => {
952
952
  s.isMesh && s.material && W.forceUpdateUniforms(
953
953
  s.material,
954
954
  t
955
955
  );
956
- }), r.userData.nativeMesh && r.userData.nativeMesh.traverse((s) => {
956
+ }), i.userData.nativeMesh && i.userData.nativeMesh.traverse((s) => {
957
957
  s.isMesh && s.material && W.forceUpdateUniforms(
958
958
  s.material,
959
959
  t
@@ -965,13 +965,13 @@ class it {
965
965
  }
966
966
  setSize(e, t) {
967
967
  this.renderer.setSize(e, t);
968
- for (const r of this.renderTargets)
969
- r.setSize(e * this.qualityFactor, t * this.qualityFactor);
968
+ for (const i of this.renderTargets)
969
+ i.setSize(e * this.qualityFactor, t * this.qualityFactor);
970
970
  this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
971
971
  }
972
972
  syncScene(e, t) {
973
- const r = this.target.getBoundingClientRect(), s = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, o = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, n = Math.abs(s - o) > 0.1 || Math.abs(c - a) > 0.1, l = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
974
- n ? (this.targetRect = r, this.setSize(s, c), this.updateCanvasLayout()) : l ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
973
+ const i = this.target.getBoundingClientRect(), s = this.isViewport ? window.innerWidth + this.overscan * 2 : i.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : i.height, o = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, n = Math.abs(s - o) > 0.1 || Math.abs(c - a) > 0.1, l = this.mode === "overlay" && (Math.abs(i.top - this.targetRect.top) > 0.1 || Math.abs(i.left - this.targetRect.left) > 0.1);
974
+ n ? (this.targetRect = i, this.setSize(s, c), this.updateCanvasLayout()) : l ? (this.targetRect = i, this.updateCanvasLayout()) : this.targetRect = i, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
975
975
  const h = this.registry.get(d);
976
976
  if (h) {
977
977
  this.scene.remove(h);
@@ -992,8 +992,8 @@ class it {
992
992
  reconcileNode(e) {
993
993
  var s, c;
994
994
  let t = this.registry.get(e.element);
995
- const r = JSON.stringify(e.shaderHooks || null);
996
- if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof w.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
995
+ const i = JSON.stringify(e.shaderHooks || null);
996
+ if (t && t.userData.shaderHash !== i && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof w.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
997
997
  const o = new w.PlaneGeometry(1, 1), a = e.isTraveler ? (s = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : s.texture : this.textureManager.get(e.element), n = W.create(
998
998
  "BOX",
999
999
  e.styles,
@@ -1004,7 +1004,7 @@ class it {
1004
1004
  a,
1005
1005
  e.shaderHooks
1006
1006
  );
1007
- t = new w.Mesh(o, n), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = n, t.userData.domElement = e.element, t.userData.shaderHash = r;
1007
+ t = new w.Mesh(o, n), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = n, t.userData.domElement = e.element, t.userData.shaderHash = i;
1008
1008
  }
1009
1009
  if ((c = e.nativeStyles) != null && c.transform ? t.userData.nativeTransform = e.nativeStyles.transform : t.userData.nativeTransform = void 0, this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
1010
1010
  for (let o = 0; o < _.MAX_LAYERS; o++)
@@ -1022,11 +1022,11 @@ class it {
1022
1022
  !0
1023
1023
  ));
1024
1024
  }
1025
- reconcileTextChild(e, t, r) {
1025
+ reconcileTextChild(e, t, i) {
1026
1026
  var l;
1027
1027
  const s = t.textLines || [
1028
1028
  { text: t.textContent || "", rect: t.rect }
1029
- ], c = r ? t.nativeStyles : t.textStyles, o = JSON.stringify(c) + t.textContent + s.map((d) => d.text).join("|"), a = (l = e.userData) == null ? void 0 : l.textChildStyleHash;
1029
+ ], c = i ? t.nativeStyles : t.textStyles, o = JSON.stringify(c) + t.textContent + s.map((d) => d.text).join("|"), a = (l = e.userData) == null ? void 0 : l.textChildStyleHash;
1030
1030
  if (t.dirtyMask & we || o !== a) {
1031
1031
  e.children.filter(
1032
1032
  (g) => g.name.startsWith("TEXT_CHILD")
@@ -1060,12 +1060,12 @@ class it {
1060
1060
  if (!d.name.startsWith("TEXT_CHILD"))
1061
1061
  return;
1062
1062
  const h = d;
1063
- if (r && t.nativeLayer !== void 0)
1063
+ if (i && t.nativeLayer !== void 0)
1064
1064
  h.layers.set(F.HIDDEN), t.visibility & q && h.layers.enable(F.getCaptureLayer(t.nativeLayer));
1065
1065
  else {
1066
1066
  const u = t.visibility & q ? F.BASE : F.HIDDEN;
1067
1067
  if (h.layers.set(u), t.visibility & ae && h.layers.enable(F.SELECTED), t.visibility & q)
1068
- if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
1068
+ if (!i && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
1069
1069
  for (let f = t.captureLayer; f <= _.MAX_LAYERS + 1; f++)
1070
1070
  f !== t.nativeLayer && h.layers.enable(F.getCaptureLayer(f));
1071
1071
  else
@@ -1076,32 +1076,32 @@ class it {
1076
1076
  }
1077
1077
  updateMeshProperties(e, t) {
1078
1078
  var S, R, E, V, N;
1079
- const { rect: r, styles: s } = t, c = this.renderer.getPixelRatio(), o = this.renderer.domElement.width / c, a = this.renderer.domElement.height / c;
1079
+ const { rect: i, styles: s } = t, c = this.renderer.getPixelRatio(), o = this.renderer.domElement.width / c, a = this.renderer.domElement.height / c;
1080
1080
  e.material = e.userData.baseMaterial;
1081
1081
  let n = ((S = e.material.userData) == null ? void 0 : S.shadowPadding) || 0;
1082
- e.scale.set(r.width + n * 2, r.height + n * 2, 1), e.userData.domRect = {
1083
- x: r.x,
1084
- y: r.y,
1085
- width: r.width,
1086
- height: r.height
1082
+ e.scale.set(i.width + n * 2, i.height + n * 2, 1), e.userData.domRect = {
1083
+ x: i.x,
1084
+ y: i.y,
1085
+ width: i.width,
1086
+ height: i.height
1087
1087
  };
1088
1088
  const l = 1e-3;
1089
1089
  this.renderOrder++;
1090
1090
  const d = this.targetRect.left + window.scrollX, h = this.targetRect.top + window.scrollY;
1091
1091
  let u, f;
1092
1092
  if (this.isViewport)
1093
- u = r.x - window.innerWidth / 2 + r.width / 2, f = -r.y + window.innerHeight / 2 - r.height / 2;
1093
+ u = i.x - window.innerWidth / 2 + i.width / 2, f = -i.y + window.innerHeight / 2 - i.height / 2;
1094
1094
  else {
1095
- const M = r.x - d, P = r.y - h;
1096
- u = M - o / 2 + r.width / 2, f = -P + a / 2 - r.height / 2;
1095
+ const M = i.x - d, P = i.y - h;
1096
+ u = M - o / 2 + i.width / 2, f = -P + a / 2 - i.height / 2;
1097
1097
  }
1098
1098
  e.position.set(
1099
1099
  u,
1100
1100
  f,
1101
1101
  s.zIndex + this.renderOrder * l
1102
1102
  );
1103
- const g = r.x, v = r.y;
1104
- e.userData.basePosition = { x: u, y: f }, e.userData.originalBasePosition = { x: u, y: f }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: g, y: v }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
1103
+ const g = i.x, v = i.y;
1104
+ e.userData.basePosition = { x: u, y: f }, e.userData.originalBasePosition = { x: u, y: f }, e.userData.baseSize = { width: i.width, height: i.height }, e.userData.baseDOM = { x: g, y: v }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
1105
1105
  const b = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, C = window.getComputedStyle(b);
1106
1106
  let I = 0, D = 0;
1107
1107
  if (C.transform && C.transform !== "none") {
@@ -1113,8 +1113,8 @@ class it {
1113
1113
  "BOX",
1114
1114
  s,
1115
1115
  "",
1116
- r.width,
1117
- r.height,
1116
+ i.width,
1117
+ i.height,
1118
1118
  this.qualityFactor,
1119
1119
  t.isTraveler ? (R = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : R.texture : this.textureManager.get(t.element)
1120
1120
  ), t.nativeStyles && t.nativeRect) {
@@ -1196,8 +1196,8 @@ class it {
1196
1196
  e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof w.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
1197
1197
  }
1198
1198
  updateMeshLayers(e, t) {
1199
- const r = t.visibility & q ? F.BASE : F.HIDDEN;
1200
- if (e.layers.set(r), t.visibility & ae && e.layers.enable(F.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1199
+ const i = t.visibility & q ? F.BASE : F.HIDDEN;
1200
+ if (e.layers.set(i), t.visibility & ae && e.layers.enable(F.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
1201
1201
  const s = e.userData.nativeMesh;
1202
1202
  if (s.layers.set(F.HIDDEN), t.visibility & q) {
1203
1203
  s.layers.enable(F.getCaptureLayer(t.nativeLayer));
@@ -1208,11 +1208,11 @@ class it {
1208
1208
  for (let s = t.captureLayer; s <= _.MAX_LAYERS + 1; s++)
1209
1209
  e.layers.enable(F.getCaptureLayer(s));
1210
1210
  }
1211
- captureRenderTarget(e, t, r) {
1212
- if (e.size === 0 || !r)
1211
+ captureRenderTarget(e, t, i) {
1212
+ if (e.size === 0 || !i)
1213
1213
  return;
1214
1214
  const s = new w.Color(), c = this.renderer.getClearAlpha();
1215
- this.renderer.getClearColor(s), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(r), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
1215
+ this.renderer.getClearColor(s), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(i), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
1216
1216
  const o = new w.Vector3(), a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, l = this.renderer.getPixelRatio();
1217
1217
  for (const d of e) {
1218
1218
  o.setFromMatrixPosition(d.matrixWorld), o.project(this.camera);
@@ -1236,7 +1236,7 @@ class it {
1236
1236
  this.renderer.render(this.scene, this.camera);
1237
1237
  }
1238
1238
  syncMeshesByDOM() {
1239
- const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), s = this.renderer.domElement.width / r, c = this.renderer.domElement.height / r;
1239
+ const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, i = this.renderer.getPixelRatio(), s = this.renderer.domElement.width / i, c = this.renderer.domElement.height / i;
1240
1240
  this.scene.children.forEach((o) => {
1241
1241
  var h, u;
1242
1242
  const a = o;
@@ -1321,32 +1321,32 @@ class it {
1321
1321
  });
1322
1322
  }
1323
1323
  }
1324
- function st(i) {
1325
- const e = i.textContent || "", t = [];
1326
- let r = "", s = null, c = -1;
1324
+ function st(r) {
1325
+ const e = r.textContent || "", t = [];
1326
+ let i = "", s = null, c = -1;
1327
1327
  const o = (l, d) => {
1328
1328
  for (let h = 0; h < l.length; h++) {
1329
1329
  const u = l[h], f = document.createRange();
1330
- f.setStart(i, d + h), f.setEnd(i, d + h + 1);
1330
+ f.setStart(r, d + h), f.setEnd(r, d + h + 1);
1331
1331
  const g = f.getBoundingClientRect();
1332
1332
  if (g.width === 0 && g.height === 0) {
1333
- r += u;
1333
+ i += u;
1334
1334
  continue;
1335
1335
  }
1336
- c === -1 || Math.abs(g.top - c) > g.height / 2 ? (r && s && t.push({
1337
- text: r,
1336
+ c === -1 || Math.abs(g.top - c) > g.height / 2 ? (i && s && t.push({
1337
+ text: i,
1338
1338
  rect: {
1339
1339
  left: s.left,
1340
1340
  top: s.top,
1341
1341
  width: s.right - s.left,
1342
1342
  height: s.bottom - s.top
1343
1343
  }
1344
- }), r = u, s = {
1344
+ }), i = u, s = {
1345
1345
  left: g.left,
1346
1346
  top: g.top,
1347
1347
  right: g.right,
1348
1348
  bottom: g.bottom
1349
- }, c = g.top) : (r += u, s && (s.left = Math.min(s.left, g.left), s.top = Math.min(s.top, g.top), s.right = Math.max(s.right, g.right), s.bottom = Math.max(
1349
+ }, c = g.top) : (i += u, s && (s.left = Math.min(s.left, g.left), s.top = Math.min(s.top, g.top), s.right = Math.max(s.right, g.right), s.bottom = Math.max(
1350
1350
  s.bottom,
1351
1351
  g.bottom
1352
1352
  )));
@@ -1355,38 +1355,38 @@ function st(i) {
1355
1355
  let n = 0;
1356
1356
  for (const l of a) {
1357
1357
  const d = document.createRange();
1358
- d.setStart(i, n), d.setEnd(i, n + l.length);
1358
+ d.setStart(r, n), d.setEnd(r, n + l.length);
1359
1359
  const h = d.getClientRects();
1360
1360
  if (h.length > 1)
1361
1361
  o(l, n);
1362
1362
  else {
1363
1363
  const u = h.length === 1 ? h[0] : d.getBoundingClientRect();
1364
1364
  if (u.width === 0 && u.height === 0) {
1365
- r += l, n += l.length;
1365
+ i += l, n += l.length;
1366
1366
  continue;
1367
1367
  }
1368
- c === -1 || Math.abs(u.top - c) > u.height / 2 ? (r && s && t.push({
1369
- text: r,
1368
+ c === -1 || Math.abs(u.top - c) > u.height / 2 ? (i && s && t.push({
1369
+ text: i,
1370
1370
  rect: {
1371
1371
  left: s.left,
1372
1372
  top: s.top,
1373
1373
  width: s.right - s.left,
1374
1374
  height: s.bottom - s.top
1375
1375
  }
1376
- }), r = l, s = {
1376
+ }), i = l, s = {
1377
1377
  left: u.left,
1378
1378
  top: u.top,
1379
1379
  right: u.right,
1380
1380
  bottom: u.bottom
1381
- }, c = u.top) : (r += l, s && (s.left = Math.min(s.left, u.left), s.top = Math.min(s.top, u.top), s.right = Math.max(s.right, u.right), s.bottom = Math.max(
1381
+ }, c = u.top) : (i += l, s && (s.left = Math.min(s.left, u.left), s.top = Math.min(s.top, u.top), s.right = Math.max(s.right, u.right), s.bottom = Math.max(
1382
1382
  s.bottom,
1383
1383
  u.bottom
1384
1384
  )));
1385
1385
  }
1386
1386
  n += l.length;
1387
1387
  }
1388
- return r && s && t.push({
1389
- text: r,
1388
+ return i && s && t.push({
1389
+ text: i,
1390
1390
  rect: {
1391
1391
  left: s.left,
1392
1392
  top: s.top,
@@ -1397,26 +1397,26 @@ function st(i) {
1397
1397
  (l) => l.text.trim().length > 0 && l.rect.width > 0 && l.rect.height > 0
1398
1398
  );
1399
1399
  }
1400
- function Le(i) {
1401
- const e = parseFloat(i.fontSize);
1402
- let t = parseFloat(i.lineHeight);
1400
+ function Le(r) {
1401
+ const e = parseFloat(r.fontSize);
1402
+ let t = parseFloat(r.lineHeight);
1403
1403
  isNaN(t) && (t = e * 1.2);
1404
- let r = parseFloat(i.letterSpacing);
1405
- return isNaN(r) && (r = 0), {
1406
- font: `${i.fontStyle} ${i.fontWeight} ${i.fontSize} ${i.fontFamily}`,
1407
- fontSize: i.fontSize,
1408
- color: i.color,
1409
- textAlign: i.textAlign || "start",
1404
+ let i = parseFloat(r.letterSpacing);
1405
+ return isNaN(i) && (i = 0), {
1406
+ font: `${r.fontStyle} ${r.fontWeight} ${r.fontSize} ${r.fontFamily}`,
1407
+ fontSize: r.fontSize,
1408
+ color: r.color,
1409
+ textAlign: r.textAlign || "start",
1410
1410
  textBaseline: "alphabetic",
1411
- direction: i.direction || "inherit",
1411
+ direction: r.direction || "inherit",
1412
1412
  lineHeight: t,
1413
- letterSpacing: r
1413
+ letterSpacing: i
1414
1414
  };
1415
1415
  }
1416
- function Ue(i, e = re | he | Ye | we | fe, t, r = 1, s = 0, c = 2, o, a) {
1416
+ function Ue(r, e = re | he | Ye | we | fe, t, i = 1, s = 0, c = 2, o, a) {
1417
1417
  var B, $, K, z, Y, ie, se;
1418
- if (i.nodeType === Node.TEXT_NODE) {
1419
- const m = i;
1418
+ if (r.nodeType === Node.TEXT_NODE) {
1419
+ const m = r;
1420
1420
  if (!m.textContent || !m.textContent.trim())
1421
1421
  return null;
1422
1422
  const A = m.textContent.replace(/\s+/g, " ");
@@ -1463,7 +1463,7 @@ function Ue(i, e = re | he | Ye | we | fe, t, r = 1, s = 0, c = 2, o, a) {
1463
1463
  dirtyMask: e,
1464
1464
  visibility: t,
1465
1465
  isTraveler: !1,
1466
- captureLayer: r,
1466
+ captureLayer: i,
1467
1467
  isFixed: x.position === "fixed",
1468
1468
  nativeLayer: o,
1469
1469
  nativeStyles: a ? te(te({
@@ -1485,9 +1485,9 @@ function Ue(i, e = re | he | Ye | we | fe, t, r = 1, s = 0, c = 2, o, a) {
1485
1485
  children: []
1486
1486
  };
1487
1487
  }
1488
- if (i.nodeType !== Node.ELEMENT_NODE)
1488
+ if (r.nodeType !== Node.ELEMENT_NODE)
1489
1489
  return null;
1490
- const n = i, l = n.dataset[G.KEY];
1490
+ const n = r, l = n.dataset[G.KEY];
1491
1491
  let d = t, h = t;
1492
1492
  if (l) {
1493
1493
  const m = new Set(l.split(/\s+/));
@@ -1570,11 +1570,11 @@ function Ue(i, e = re | he | Ye | we | fe, t, r = 1, s = 0, c = 2, o, a) {
1570
1570
  }
1571
1571
  if (X) {
1572
1572
  const k = m + 1;
1573
- if (k < r)
1573
+ if (k < i)
1574
1574
  throw new Error(
1575
- `[MirageEngine] Traveler layer (${m}) cannot be smaller than inherited capture layer (${r - 1}).`
1575
+ `[MirageEngine] Traveler layer (${m}) cannot be smaller than inherited capture layer (${i - 1}).`
1576
1576
  );
1577
- r = Math.min(k, _.MAX_LAYERS + 1);
1577
+ i = Math.min(k, _.MAX_LAYERS + 1);
1578
1578
  }
1579
1579
  }
1580
1580
  const C = n.dataset[Ve.KEY];
@@ -1633,7 +1633,7 @@ function Ue(i, e = re | he | Ye | we | fe, t, r = 1, s = 0, c = 2, o, a) {
1633
1633
  m,
1634
1634
  e,
1635
1635
  A,
1636
- r,
1636
+ i,
1637
1637
  V,
1638
1638
  c,
1639
1639
  m.nodeType === Node.TEXT_NODE ? b : void 0,
@@ -1656,7 +1656,7 @@ function Ue(i, e = re | he | Ye | we | fe, t, r = 1, s = 0, c = 2, o, a) {
1656
1656
  dirtyMask: e,
1657
1657
  visibility: h,
1658
1658
  isTraveler: g,
1659
- captureLayer: r,
1659
+ captureLayer: i,
1660
1660
  nativeLayer: b,
1661
1661
  nativeStyles: b !== void 0 ? Se(te({}, M), {
1662
1662
  backgroundColor: (B = v.backgroundColor) != null ? B : M.backgroundColor,
@@ -1681,32 +1681,34 @@ function Ue(i, e = re | he | Ye | we | fe, t, r = 1, s = 0, c = 2, o, a) {
1681
1681
  shaderHooks: I
1682
1682
  };
1683
1683
  }
1684
- function ot(i, e) {
1685
- e.size !== 0 && e.forEach((t, r) => {
1684
+ function ot(r, e) {
1685
+ e.size !== 0 && e.forEach((t, i) => {
1686
1686
  var c, o, a, n;
1687
- const s = i.get(r);
1687
+ const s = r.get(i);
1688
1688
  !s || !s.userData.basePosition || (W.forceUpdateUniforms(s.material, {
1689
1689
  backgroundColor: t.backgroundColor,
1690
1690
  backgroundImage: t.backgroundImage,
1691
+ boxShadow: t.boxShadow,
1691
1692
  opacity: t.opacity,
1692
1693
  borderRadius: (o = t.borderRadius) != null ? o : (c = s.userData.baseStyles) == null ? void 0 : c.borderRadius
1693
1694
  // width and height are no longer updated here, they are updated in syncMeshesByDOM
1694
1695
  }), s.userData.nativeMesh && W.forceUpdateUniforms(s.userData.nativeMesh.material, {
1695
1696
  backgroundColor: t.backgroundColor,
1696
1697
  backgroundImage: t.backgroundImage,
1698
+ boxShadow: t.boxShadow,
1697
1699
  opacity: t.opacity,
1698
1700
  borderRadius: (n = t.borderRadius) != null ? n : (a = s.userData.baseStyles) == null ? void 0 : a.borderRadius
1699
1701
  }));
1700
1702
  });
1701
1703
  }
1702
1704
  class at {
1703
- constructor(e, t, r, s) {
1705
+ constructor(e, t, i, s) {
1704
1706
  p(this, "target");
1705
1707
  p(this, "renderer");
1706
1708
  p(this, "registry");
1707
1709
  p(this, "isTravelEnabled", !1);
1708
1710
  p(this, "tracker");
1709
- this.target = e, this.renderer = t, this.registry = r, this.tracker = new He(e, {
1711
+ this.target = e, this.renderer = t, this.registry = i, this.tracker = new He(e, {
1710
1712
  resizeDebounce: s.resizeDebounce
1711
1713
  }), this.tracker.onLayoutChange.add((c, o) => {
1712
1714
  document.querySelector(`[${_.NAME}~='${_.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
@@ -1772,13 +1774,13 @@ class dt {
1772
1774
  }
1773
1775
  `, document.head.appendChild(a);
1774
1776
  }
1775
- let r;
1776
- if (t.mode === "duplicate" ? r = (c = (s = t.container) != null ? s : this.target.parentElement) != null ? c : void 0 : r = (o = this.target.parentElement) != null ? o : void 0, !r)
1777
+ let i;
1778
+ if (t.mode === "duplicate" ? i = (c = (s = t.container) != null ? s : this.target.parentElement) != null ? c : void 0 : i = (o = this.target.parentElement) != null ? o : void 0, !i)
1777
1779
  throw new Error("[Mirage] Cannot find a container (parent or option).");
1778
1780
  this.renderer = new it(
1779
1781
  this.target,
1780
1782
  t,
1781
- r,
1783
+ i,
1782
1784
  this.registry
1783
1785
  ), this.renderer.mount(), this.syncer = new at(this.target, this.renderer, this.registry, t);
1784
1786
  }
@@ -1817,8 +1819,8 @@ class dt {
1817
1819
  }), window.addEventListener("keyup", (c) => {
1818
1820
  t[c.key] !== void 0 && (t[c.key] = !1);
1819
1821
  });
1820
- const r = 2, s = () => {
1821
- requestAnimationFrame(s), t.ArrowRight && e.position.setX(e.position.x + r), t.ArrowLeft && e.position.setX(e.position.x - r), t.ArrowUp && e.position.setY(e.position.y + r), t.ArrowDown && e.position.setY(e.position.y - r);
1822
+ const i = 2, s = () => {
1823
+ requestAnimationFrame(s), t.ArrowRight && e.position.setX(e.position.x + i), t.ArrowLeft && e.position.setX(e.position.x - i), t.ArrowUp && e.position.setY(e.position.y + i), t.ArrowDown && e.position.setY(e.position.y - i);
1822
1824
  };
1823
1825
  s();
1824
1826
  }