@frybynite/image-cloud 0.4.2 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/ImageCloud.d.ts +99 -0
  2. package/dist/ImageCloud.d.ts.map +1 -0
  3. package/dist/config/adapter.d.ts +50 -0
  4. package/dist/config/adapter.d.ts.map +1 -0
  5. package/dist/config/defaults.d.ts +118 -0
  6. package/dist/config/defaults.d.ts.map +1 -0
  7. package/dist/config/types.d.ts +599 -0
  8. package/dist/config/types.d.ts.map +1 -0
  9. package/dist/engines/AnimationEngine.d.ts +82 -0
  10. package/dist/engines/AnimationEngine.d.ts.map +1 -0
  11. package/dist/engines/EntryAnimationEngine.d.ts +161 -0
  12. package/dist/engines/EntryAnimationEngine.d.ts.map +1 -0
  13. package/dist/engines/LayoutEngine.d.ts +68 -0
  14. package/dist/engines/LayoutEngine.d.ts.map +1 -0
  15. package/dist/engines/PathAnimator.d.ts +50 -0
  16. package/dist/engines/PathAnimator.d.ts.map +1 -0
  17. package/dist/engines/SwipeEngine.d.ts +53 -0
  18. package/dist/engines/SwipeEngine.d.ts.map +1 -0
  19. package/dist/engines/ZoomEngine.d.ts +139 -0
  20. package/dist/engines/ZoomEngine.d.ts.map +1 -0
  21. package/dist/image-cloud-auto-init.d.ts +14 -0
  22. package/dist/image-cloud-auto-init.d.ts.map +1 -0
  23. package/dist/image-cloud-auto-init.js +215 -244
  24. package/dist/image-cloud-auto-init.js.map +1 -1
  25. package/dist/image-cloud.js +235 -264
  26. package/dist/image-cloud.js.map +1 -1
  27. package/dist/image-cloud.umd.js +3 -3
  28. package/dist/image-cloud.umd.js.map +1 -1
  29. package/dist/index.d.ts +23 -1637
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/layouts/ClusterPlacementLayout.d.ts +40 -0
  32. package/dist/layouts/ClusterPlacementLayout.d.ts.map +1 -0
  33. package/dist/layouts/GridPlacementLayout.d.ts +27 -0
  34. package/dist/layouts/GridPlacementLayout.d.ts.map +1 -0
  35. package/dist/layouts/RadialPlacementLayout.d.ts +33 -0
  36. package/dist/layouts/RadialPlacementLayout.d.ts.map +1 -0
  37. package/dist/layouts/RandomPlacementLayout.d.ts +26 -0
  38. package/dist/layouts/RandomPlacementLayout.d.ts.map +1 -0
  39. package/dist/layouts/SpiralPlacementLayout.d.ts +43 -0
  40. package/dist/layouts/SpiralPlacementLayout.d.ts.map +1 -0
  41. package/dist/layouts/WavePlacementLayout.d.ts +48 -0
  42. package/dist/layouts/WavePlacementLayout.d.ts.map +1 -0
  43. package/dist/loaders/CompositeLoader.d.ts +37 -0
  44. package/dist/loaders/CompositeLoader.d.ts.map +1 -0
  45. package/dist/loaders/GoogleDriveLoader.d.ts +90 -0
  46. package/dist/loaders/GoogleDriveLoader.d.ts.map +1 -0
  47. package/dist/loaders/ImageFilter.d.ts +26 -0
  48. package/dist/loaders/ImageFilter.d.ts.map +1 -0
  49. package/dist/loaders/StaticImageLoader.d.ts +85 -0
  50. package/dist/loaders/StaticImageLoader.d.ts.map +1 -0
  51. package/dist/react/index.d.ts +16 -0
  52. package/dist/react/index.d.ts.map +1 -0
  53. package/dist/react.d.ts +1 -0
  54. package/dist/react.js +3227 -0
  55. package/dist/react.js.map +1 -0
  56. package/dist/styles/functionalStyles.d.ts +11 -0
  57. package/dist/styles/functionalStyles.d.ts.map +1 -0
  58. package/dist/utils/styleUtils.d.ts +54 -0
  59. package/dist/utils/styleUtils.d.ts.map +1 -0
  60. package/dist/vue/index.d.ts +18 -0
  61. package/dist/vue/index.d.ts.map +1 -0
  62. package/dist/vue.d.ts +1 -0
  63. package/dist/vue.js +3241 -0
  64. package/dist/vue.js.map +1 -0
  65. package/dist/web-component/index.d.ts +15 -0
  66. package/dist/web-component/index.d.ts.map +1 -0
  67. package/dist/web-component.d.ts +1 -0
  68. package/dist/web-component.js +3265 -0
  69. package/dist/web-component.js.map +1 -0
  70. package/package.json +38 -4
@@ -13,7 +13,7 @@ const Dt = ".fbn-ic-gallery{--fbn-ic-bg-primary: #05060F;--fbn-ic-bg-secondary:
13
13
  bouncy: Object.freeze({ stiffness: 300, damping: 15, mass: 1, oscillations: 4 }),
14
14
  wobbly: Object.freeze({ stiffness: 180, damping: 12, mass: 1.5, oscillations: 5 }),
15
15
  snappy: Object.freeze({ stiffness: 400, damping: 25, mass: 0.8, oscillations: 2 })
16
- }), Et = Object.freeze({
16
+ }), St = Object.freeze({
17
17
  gentle: Object.freeze({ amplitude: 30, frequency: 1.5, decay: !0, decayRate: 0.9, phase: 0 }),
18
18
  playful: Object.freeze({ amplitude: 50, frequency: 2.5, decay: !0, decayRate: 0.7, phase: 0 }),
19
19
  serpentine: Object.freeze({ amplitude: 60, frequency: 3, decay: !1, decayRate: 1, phase: 0 }),
@@ -24,7 +24,7 @@ const Dt = ".fbn-ic-gallery{--fbn-ic-bg-primary: #05060F;--fbn-ic-bg-secondary:
24
24
  mode: "none"
25
25
  }), yt = Object.freeze({
26
26
  mode: "none"
27
- }), Ct = Object.freeze({
27
+ }), At = Object.freeze({
28
28
  default: Object.freeze({
29
29
  border: Object.freeze({
30
30
  width: 0,
@@ -77,15 +77,15 @@ const Dt = ".fbn-ic-gallery{--fbn-ic-bg-primary: #05060F;--fbn-ic-bg-secondary:
77
77
  min: -15,
78
78
  max: 15
79
79
  })
80
- }), Tt = Object.freeze({
80
+ }), Ct = Object.freeze({
81
81
  sizing: Ut,
82
82
  rotation: Pt
83
- }), Rt = Object.freeze({
83
+ }), Tt = Object.freeze({
84
84
  validateUrls: !0,
85
85
  validationTimeout: 5e3,
86
86
  validationMethod: "head",
87
87
  allowedExtensions: ["jpg", "jpeg", "png", "gif", "webp", "bmp"]
88
- }), At = Object.freeze({
88
+ }), Rt = Object.freeze({
89
89
  enabled: !1,
90
90
  centers: !1,
91
91
  loaders: !1
@@ -94,11 +94,11 @@ const Dt = ".fbn-ic-gallery{--fbn-ic-bg-primary: #05060F;--fbn-ic-bg-secondary:
94
94
  loaders: [],
95
95
  // Shared loader settings and debug config
96
96
  config: Object.freeze({
97
- loaders: Rt,
98
- debug: At
97
+ loaders: Tt,
98
+ debug: Rt
99
99
  }),
100
100
  // Image sizing and rotation configuration
101
- image: Tt,
101
+ image: Ct,
102
102
  // Pattern-based layout configuration
103
103
  layout: Object.freeze({
104
104
  algorithm: "radial",
@@ -219,7 +219,7 @@ const Dt = ".fbn-ic-gallery{--fbn-ic-bg-primary: #05060F;--fbn-ic-bg-secondary:
219
219
  })
220
220
  }),
221
221
  // Image styling
222
- styling: Ct
222
+ styling: At
223
223
  });
224
224
  function Z(n, t) {
225
225
  if (!n) return t || {};
@@ -242,7 +242,7 @@ function _t(n, t) {
242
242
  focused: o
243
243
  };
244
244
  }
245
- function Ht(n, t) {
245
+ function Nt(n, t) {
246
246
  if (!t) return { ...n };
247
247
  const e = { ...n };
248
248
  if (t.sizing !== void 0 && (e.sizing = {
@@ -261,7 +261,7 @@ function Ht(n, t) {
261
261
  }
262
262
  return e;
263
263
  }
264
- function Nt(n) {
264
+ function Ht(n) {
265
265
  const t = n.layout?.rotation;
266
266
  if (t && "enabled" in t)
267
267
  return {
@@ -283,7 +283,7 @@ function kt(n) {
283
283
  };
284
284
  }
285
285
  function jt(n = {}) {
286
- const t = Nt(n), e = kt(n);
286
+ const t = Ht(n), e = kt(n);
287
287
  let i = n.image;
288
288
  (t || e) && (i = {
289
289
  ...e || {},
@@ -301,18 +301,18 @@ function jt(n = {}) {
301
301
  });
302
302
  const r = {
303
303
  loaders: {
304
- ...Rt,
304
+ ...Tt,
305
305
  ...n.config?.loaders ?? {}
306
306
  }
307
307
  }, a = {
308
308
  loaders: o,
309
309
  config: r,
310
- image: Ht(Tt, i),
310
+ image: Nt(Ct, i),
311
311
  layout: { ...y.layout },
312
312
  animation: { ...y.animation },
313
313
  interaction: { ...y.interaction },
314
314
  rendering: { ...y.rendering },
315
- styling: _t(Ct, n.styling)
315
+ styling: _t(At, n.styling)
316
316
  };
317
317
  return n.layout && (a.layout = {
318
318
  ...y.layout,
@@ -375,18 +375,18 @@ function jt(n = {}) {
375
375
  ...y.rendering.performance,
376
376
  ...n.rendering.performance
377
377
  })), a.config.debug = {
378
- ...At,
378
+ ...Rt,
379
379
  ...n.config?.debug ?? {}
380
380
  }, a;
381
381
  }
382
- function Wt(n, t) {
382
+ function Gt(n, t) {
383
383
  return { ...n ? wt[n] : wt.playful, ...t };
384
384
  }
385
- function Gt(n, t) {
385
+ function Wt(n, t) {
386
386
  return { ...n ? xt[n] : xt.gentle, ...t };
387
387
  }
388
388
  function qt(n, t) {
389
- return { ...n ? Et[n] : Et.gentle, ...t };
389
+ return { ...n ? St[n] : St.gentle, ...t };
390
390
  }
391
391
  class Yt {
392
392
  constructor(t) {
@@ -562,7 +562,7 @@ function Xt(n, t, e, i) {
562
562
  u = ot(p);
563
563
  else {
564
564
  const m = 1 + (c.find(
565
- (E, v) => E.time > l && v > 0 && c[v - 1].isOvershoot
565
+ (S, v) => S.time > l && v > 0 && c[v - 1].isOvershoot
566
566
  )?.overshoot || f);
567
567
  u = V(m, 1, ot(p));
568
568
  }
@@ -647,30 +647,30 @@ function te(n) {
647
647
  startRotation: d,
648
648
  scaleConfig: f,
649
649
  startScale: b
650
- } = n, p = o.type, g = d !== void 0 && d !== h, m = l?.mode === "wobble", E = l?.wobble || { amplitude: 15, frequency: 3, decay: !0 }, v = g || m, w = b !== void 0 && b !== c, S = f?.mode === "pop", x = f?.pop || { overshoot: 1.2, bounces: 1 };
651
- if ((p === "linear" || p === "arc") && !v && !(w || S)) {
650
+ } = n, p = o.type, g = d !== void 0 && d !== h, m = l?.mode === "wobble", S = l?.wobble || { amplitude: 15, frequency: 3, decay: !0 }, v = g || m, w = b !== void 0 && b !== c, E = f?.mode === "pop", x = f?.pop || { overshoot: 1.2, bounces: 1 };
651
+ if ((p === "linear" || p === "arc") && !v && !(w || E)) {
652
652
  u && u();
653
653
  return;
654
654
  }
655
- const z = performance.now(), M = -r / 2, P = -a / 2;
655
+ const L = performance.now(), z = -r / 2, P = -a / 2;
656
656
  function _(Y) {
657
- const N = Y - z, T = Math.min(N / s, 1);
657
+ const H = Y - L, C = Math.min(H / s, 1);
658
658
  let D;
659
659
  switch (p) {
660
660
  case "bounce": {
661
- const O = Wt(
661
+ const O = Gt(
662
662
  o.bouncePreset,
663
663
  o.bounce
664
664
  );
665
- D = Xt(T, e, i, O);
665
+ D = Xt(C, e, i, O);
666
666
  break;
667
667
  }
668
668
  case "elastic": {
669
- const O = Gt(
669
+ const O = Wt(
670
670
  o.elasticPreset,
671
671
  o.elastic
672
672
  );
673
- D = Jt(T, e, i, O);
673
+ D = Jt(C, e, i, O);
674
674
  break;
675
675
  }
676
676
  case "wave": {
@@ -678,20 +678,20 @@ function te(n) {
678
678
  o.wavePreset,
679
679
  o.wave
680
680
  );
681
- D = Vt(T, e, i, O);
681
+ D = Vt(C, e, i, O);
682
682
  break;
683
683
  }
684
684
  default:
685
685
  D = {
686
- x: V(e.x, i.x, T),
687
- y: V(e.y, i.y, T)
686
+ x: V(e.x, i.x, C),
687
+ y: V(e.y, i.y, C)
688
688
  };
689
689
  }
690
- const j = D.x - i.x, H = D.y - i.y;
691
- let A;
692
- m ? A = Zt(T, h, E) : g ? A = V(d, h, T) : A = h;
690
+ const j = D.x - i.x, N = D.y - i.y;
693
691
  let R;
694
- S ? R = Qt(T, c, x) : w ? R = V(b, c, T) : R = c, t.style.transform = `translate(${M}px, ${P}px) translate(${j}px, ${H}px) rotate(${A}deg) scale(${R})`, T < 1 ? requestAnimationFrame(_) : (t.style.transform = `translate(${M}px, ${P}px) rotate(${h}deg) scale(${c})`, u && u());
692
+ m ? R = Zt(C, h, S) : g ? R = V(d, h, C) : R = h;
693
+ let T;
694
+ E ? T = Qt(C, c, x) : w ? T = V(b, c, C) : T = c, t.style.transform = `translate(${z}px, ${P}px) translate(${j}px, ${N}px) rotate(${R}deg) scale(${T})`, C < 1 ? requestAnimationFrame(_) : (t.style.transform = `translate(${z}px, ${P}px) rotate(${h}deg) scale(${c})`, u && u());
695
695
  }
696
696
  requestAnimationFrame(_);
697
697
  }
@@ -1062,13 +1062,13 @@ class oe {
1062
1062
  * @returns Array of layout objects with position, rotation, scale
1063
1063
  */
1064
1064
  generate(t, e, i = {}) {
1065
- const o = [], { width: s, height: r } = e, a = this.config.spacing.padding, h = i.fixedHeight ?? 200, c = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, l = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, f = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || f !== 1, g = h * 1.5 / 2, m = h / 2, E = s - a - g, v = r - a - m, w = a + g, S = a + m;
1065
+ const o = [], { width: s, height: r } = e, a = this.config.spacing.padding, h = i.fixedHeight ?? 200, c = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, l = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, f = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || f !== 1, g = h * 1.5 / 2, m = h / 2, S = s - a - g, v = r - a - m, w = a + g, E = a + m;
1066
1066
  for (let x = 0; x < t; x++) {
1067
- const C = this.random(w, E), z = this.random(S, v), M = c === "random" ? this.random(u, l) : 0, P = b ? this.random(d, f) : 1, _ = h * P, Y = {
1067
+ const A = this.random(w, S), L = this.random(E, v), z = c === "random" ? this.random(u, l) : 0, P = b ? this.random(d, f) : 1, _ = h * P, Y = {
1068
1068
  id: x,
1069
- x: C,
1070
- y: z,
1071
- rotation: M,
1069
+ x: A,
1070
+ y: L,
1071
+ rotation: z,
1072
1072
  scale: P,
1073
1073
  baseSize: _
1074
1074
  };
@@ -1098,16 +1098,16 @@ class se {
1098
1098
  * @returns Array of layout objects with position, rotation, scale
1099
1099
  */
1100
1100
  generate(t, e, i = {}) {
1101
- const o = [], { width: s, height: r } = e, a = i.fixedHeight ?? 200, h = this.imageConfig.rotation?.mode ?? "none", c = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, l = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, f = l !== 1 || d !== 1, b = this.config.scaleDecay ?? 0, p = i.fixedHeight ?? a, g = s / 2, m = r / 2, E = Math.ceil(Math.sqrt(t));
1101
+ const o = [], { width: s, height: r } = e, a = i.fixedHeight ?? 200, h = this.imageConfig.rotation?.mode ?? "none", c = this.imageConfig.rotation?.range?.min ?? -15, u = this.imageConfig.rotation?.range?.max ?? 15, l = this.imageConfig.sizing?.variance?.min ?? 1, d = this.imageConfig.sizing?.variance?.max ?? 1, f = l !== 1 || d !== 1, b = this.config.scaleDecay ?? 0, p = i.fixedHeight ?? a, g = s / 2, m = r / 2, S = Math.ceil(Math.sqrt(t));
1102
1102
  if (t > 0) {
1103
- const S = f ? this.random(l, d) : 1, x = p * S;
1103
+ const E = f ? this.random(l, d) : 1, x = p * E;
1104
1104
  o.push({
1105
1105
  id: 0,
1106
1106
  x: g,
1107
1107
  y: m,
1108
1108
  rotation: h === "random" ? this.random(c * 0.33, u * 0.33) : 0,
1109
1109
  // Less rotation for center
1110
- scale: S,
1110
+ scale: E,
1111
1111
  baseSize: x,
1112
1112
  zIndex: 100
1113
1113
  // Center image is highest
@@ -1115,25 +1115,25 @@ class se {
1115
1115
  }
1116
1116
  let v = 1, w = 1;
1117
1117
  for (; v < t; ) {
1118
- const S = w / E, x = b > 0 ? 1 - S * b * 0.5 : 1, C = w * (p * 0.8), z = C * 1.5, M = Math.PI * (3 * (z + C) - Math.sqrt((3 * z + C) * (z + 3 * C))), P = this.estimateWidth(p), _ = Math.floor(M / (P * 0.7));
1118
+ const E = w / S, x = b > 0 ? 1 - E * b * 0.5 : 1, A = w * (p * 0.8), L = A * 1.5, z = Math.PI * (3 * (L + A) - Math.sqrt((3 * L + A) * (L + 3 * A))), P = this.estimateWidth(p), _ = Math.floor(z / (P * 0.7));
1119
1119
  if (_ === 0) {
1120
1120
  w++;
1121
1121
  continue;
1122
1122
  }
1123
- const Y = 2 * Math.PI / _, N = w * (20 * Math.PI / 180);
1124
- for (let T = 0; T < _ && v < t; T++) {
1125
- const D = T * Y + N, j = f ? this.random(l, d) : 1, H = x * j, A = p * H;
1126
- let R = g + Math.cos(D) * z, O = m + Math.sin(D) * C;
1127
- const $ = this.config.spacing.padding ?? 50, U = A * 1.5 / 2, L = A / 2;
1128
- R - U < $ ? R = $ + U : R + U > s - $ && (R = s - $ - U), O - L < $ ? O = $ + L : O + L > r - $ && (O = r - $ - L);
1129
- const W = h === "random" ? this.random(c, u) : 0;
1123
+ const Y = 2 * Math.PI / _, H = w * (20 * Math.PI / 180);
1124
+ for (let C = 0; C < _ && v < t; C++) {
1125
+ const D = C * Y + H, j = f ? this.random(l, d) : 1, N = x * j, R = p * N;
1126
+ let T = g + Math.cos(D) * L, O = m + Math.sin(D) * A;
1127
+ const $ = this.config.spacing.padding ?? 50, U = R * 1.5 / 2, M = R / 2;
1128
+ T - U < $ ? T = $ + U : T + U > s - $ && (T = s - $ - U), O - M < $ ? O = $ + M : O + M > r - $ && (O = r - $ - M);
1129
+ const G = h === "random" ? this.random(c, u) : 0;
1130
1130
  o.push({
1131
1131
  id: v,
1132
- x: R,
1132
+ x: T,
1133
1133
  y: O,
1134
- rotation: W,
1135
- scale: H,
1136
- baseSize: A,
1134
+ rotation: G,
1135
+ scale: N,
1136
+ baseSize: R,
1137
1137
  zIndex: Math.max(1, 100 - w)
1138
1138
  // Outer rings have lower z-index
1139
1139
  }), v++;
@@ -1171,7 +1171,7 @@ const ae = {
1171
1171
  alignment: "center",
1172
1172
  gap: 10,
1173
1173
  overflowOffset: 0.25
1174
- }, St = [
1174
+ }, Et = [
1175
1175
  { x: 1, y: 1 },
1176
1176
  // bottom-right
1177
1177
  { x: -1, y: -1 },
@@ -1207,52 +1207,52 @@ class re {
1207
1207
  p,
1208
1208
  c,
1209
1209
  a
1210
- ), E = a.stagger === "row", v = a.stagger === "column", w = E ? g + 0.5 : g, S = v ? m + 0.5 : m, x = (b - a.gap * (g - 1)) / w, C = (p - a.gap * (m - 1)) / S, z = E ? x / 2 : 0, M = v ? C / 2 : 0, P = 1 + a.overlap, _ = Math.min(x, C) * P, Y = i.fixedHeight ? Math.min(i.fixedHeight, _) : _, N = g * x + (g - 1) * a.gap + z, T = m * C + (m - 1) * a.gap + M, D = h + (b - N) / 2, j = h + (p - T) / 2, H = g * m, A = a.columns !== "auto" && a.rows !== "auto", R = A && t > H;
1210
+ ), S = a.stagger === "row", v = a.stagger === "column", w = S ? g + 0.5 : g, E = v ? m + 0.5 : m, x = (b - a.gap * (g - 1)) / w, A = (p - a.gap * (m - 1)) / E, L = S ? x / 2 : 0, z = v ? A / 2 : 0, P = 1 + a.overlap, _ = Math.min(x, A) * P, Y = i.fixedHeight ? Math.min(i.fixedHeight, _) : _, H = g * x + (g - 1) * a.gap + L, C = m * A + (m - 1) * a.gap + z, D = h + (b - H) / 2, j = h + (p - C) / 2, N = g * m, R = a.columns !== "auto" && a.rows !== "auto", T = R && t > N;
1211
1211
  typeof window < "u" && (window.__gridOverflowDebug = {
1212
1212
  gridConfigColumns: a.columns,
1213
1213
  gridConfigRows: a.rows,
1214
1214
  columns: g,
1215
1215
  rows: m,
1216
- cellCount: H,
1217
- hasFixedGrid: A,
1216
+ cellCount: N,
1217
+ hasFixedGrid: R,
1218
1218
  imageCount: t,
1219
- isOverflowMode: R
1219
+ isOverflowMode: T
1220
1220
  });
1221
- const O = R ? new Array(H).fill(0) : [], $ = Math.min(x, C) * a.overflowOffset;
1221
+ const O = T ? new Array(N).fill(0) : [], $ = Math.min(x, A) * a.overflowOffset;
1222
1222
  for (let F = 0; F < t; F++) {
1223
- let U, L, W = 0;
1224
- if (R && F >= H) {
1225
- const q = F - H, k = q % H;
1226
- W = Math.floor(q / H) + 1, O[k]++, a.fillDirection === "row" ? (U = k % g, L = Math.floor(k / g)) : (L = k % m, U = Math.floor(k / m));
1223
+ let U, M, G = 0;
1224
+ if (T && F >= N) {
1225
+ const q = F - N, k = q % N;
1226
+ G = Math.floor(q / N) + 1, O[k]++, a.fillDirection === "row" ? (U = k % g, M = Math.floor(k / g)) : (M = k % m, U = Math.floor(k / m));
1227
1227
  } else
1228
- a.fillDirection === "row" ? (U = F % g, L = Math.floor(F / g)) : (L = F % m, U = Math.floor(F / m));
1229
- let G = D + U * (x + a.gap) + x / 2, X = j + L * (C + a.gap) + C / 2;
1230
- if (a.stagger === "row" && L % 2 === 1 ? G += x / 2 : a.stagger === "column" && U % 2 === 1 && (X += C / 2), W > 0) {
1231
- const q = (W - 1) % St.length, k = St[q];
1232
- G += k.x * $, X += k.y * $;
1228
+ a.fillDirection === "row" ? (U = F % g, M = Math.floor(F / g)) : (M = F % m, U = Math.floor(F / m));
1229
+ let W = D + U * (x + a.gap) + x / 2, X = j + M * (A + a.gap) + A / 2;
1230
+ if (a.stagger === "row" && M % 2 === 1 ? W += x / 2 : a.stagger === "column" && U % 2 === 1 && (X += A / 2), G > 0) {
1231
+ const q = (G - 1) % Et.length, k = Et[q];
1232
+ W += k.x * $, X += k.y * $;
1233
1233
  }
1234
1234
  if (a.jitter > 0) {
1235
- const q = x / 2 * a.jitter, k = C / 2 * a.jitter;
1236
- G += this.random(-q, q), X += this.random(-k, k);
1235
+ const q = x / 2 * a.jitter, k = A / 2 * a.jitter;
1236
+ W += this.random(-q, q), X += this.random(-k, k);
1237
1237
  }
1238
- let B = G, J = X;
1239
- if (!R && a.fillDirection === "row") {
1238
+ let B = W, J = X;
1239
+ if (!T && a.fillDirection === "row") {
1240
1240
  const q = t % g || g;
1241
- if (L === Math.floor((t - 1) / g) && q < g) {
1241
+ if (M === Math.floor((t - 1) / g) && q < g) {
1242
1242
  const vt = q * x + (q - 1) * a.gap;
1243
1243
  let gt = 0;
1244
- a.alignment === "center" ? gt = (N - vt) / 2 : a.alignment === "end" && (gt = N - vt), B += gt;
1244
+ a.alignment === "center" ? gt = (H - vt) / 2 : a.alignment === "end" && (gt = H - vt), B += gt;
1245
1245
  }
1246
1246
  }
1247
- const rt = f ? this.random(l, d) : 1, K = Y * rt, it = K * 1.5 / 2, nt = K / 2, lt = h + it, ht = s - h - it, Mt = h + nt, Ft = r - h - nt;
1248
- B = Math.max(lt, Math.min(B, ht)), J = Math.max(Mt, Math.min(J, Ft));
1247
+ const rt = f ? this.random(l, d) : 1, K = Y * rt, it = K * 1.5 / 2, nt = K / 2, lt = h + it, ht = s - h - it, zt = h + nt, Ft = r - h - nt;
1248
+ B = Math.max(lt, Math.min(B, ht)), J = Math.max(zt, Math.min(J, Ft));
1249
1249
  let dt = 0;
1250
1250
  if (u === "random") {
1251
1251
  const q = this.imageConfig.rotation?.range?.min ?? -15, k = this.imageConfig.rotation?.range?.max ?? 15;
1252
1252
  a.jitter > 0 ? dt = this.random(q * a.jitter, k * a.jitter) : dt = this.random(q, k);
1253
1253
  }
1254
1254
  let ut;
1255
- R && W > 0 ? ut = 50 - W : ut = R ? 100 + F : F + 1, o.push({
1255
+ T && G > 0 ? ut = 50 - G : ut = T ? 100 + F : F + 1, o.push({
1256
1256
  id: F,
1257
1257
  x: B,
1258
1258
  y: J,
@@ -1308,36 +1308,36 @@ class he {
1308
1308
  * @returns Array of layout objects with position, rotation, scale
1309
1309
  */
1310
1310
  generate(t, e, i = {}) {
1311
- const o = [], { width: s, height: r } = e, a = { ...le, ...this.config.spiral }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", l = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, f = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = f !== 1 || b !== 1, g = this.config.scaleDecay ?? a.scaleDecay, m = s / 2, E = r / 2, v = Math.min(
1311
+ const o = [], { width: s, height: r } = e, a = { ...le, ...this.config.spiral }, h = this.config.spacing.padding, c = i.fixedHeight ?? 200, u = this.imageConfig.rotation?.mode ?? "none", l = this.imageConfig.rotation?.range?.min ?? -15, d = this.imageConfig.rotation?.range?.max ?? 15, f = this.imageConfig.sizing?.variance?.min ?? 1, b = this.imageConfig.sizing?.variance?.max ?? 1, p = f !== 1 || b !== 1, g = this.config.scaleDecay ?? a.scaleDecay, m = s / 2, S = r / 2, v = Math.min(
1312
1312
  m - h - c / 2,
1313
- E - h - c / 2
1313
+ S - h - c / 2
1314
1314
  ), w = a.direction === "clockwise" ? -1 : 1;
1315
- for (let S = 0; S < t; S++) {
1316
- let x, C;
1315
+ for (let E = 0; E < t; E++) {
1316
+ let x, A;
1317
1317
  if (a.spiralType === "golden")
1318
- x = S * ce * w + a.startAngle, C = this.calculateGoldenRadius(S, t, v, a.tightness);
1318
+ x = E * ce * w + a.startAngle, A = this.calculateGoldenRadius(E, t, v, a.tightness);
1319
1319
  else if (a.spiralType === "archimedean") {
1320
- const G = S * 0.5 * a.tightness;
1321
- x = G * w + a.startAngle, C = this.calculateArchimedeanRadius(G, t, v, a.tightness);
1320
+ const W = E * 0.5 * a.tightness;
1321
+ x = W * w + a.startAngle, A = this.calculateArchimedeanRadius(W, t, v, a.tightness);
1322
1322
  } else {
1323
- const G = S * 0.3 * a.tightness;
1324
- x = G * w + a.startAngle, C = this.calculateLogarithmicRadius(G, t, v, a.tightness);
1323
+ const W = E * 0.3 * a.tightness;
1324
+ x = W * w + a.startAngle, A = this.calculateLogarithmicRadius(W, t, v, a.tightness);
1325
1325
  }
1326
- const z = m + Math.cos(x) * C, M = E + Math.sin(x) * C, P = C / v, _ = g > 0 ? 1 - P * g * 0.5 : 1, Y = p ? this.random(f, b) : 1, N = _ * Y, T = c * N, j = T * 1.5 / 2, H = T / 2, A = h + j, R = s - h - j, O = h + H, $ = r - h - H, F = Math.max(A, Math.min(z, R)), U = Math.max(O, Math.min(M, $));
1327
- let L = 0;
1326
+ const L = m + Math.cos(x) * A, z = S + Math.sin(x) * A, P = A / v, _ = g > 0 ? 1 - P * g * 0.5 : 1, Y = p ? this.random(f, b) : 1, H = _ * Y, C = c * H, j = C * 1.5 / 2, N = C / 2, R = h + j, T = s - h - j, O = h + N, $ = r - h - N, F = Math.max(R, Math.min(L, T)), U = Math.max(O, Math.min(z, $));
1327
+ let M = 0;
1328
1328
  if (u === "random") {
1329
- const G = x * 180 / Math.PI % 360, X = this.random(l, d);
1330
- L = a.spiralType === "golden" ? X : G * 0.1 + X * 0.9;
1331
- } else u === "tangent" && (L = this.calculateSpiralTangent(x, C, a));
1332
- const W = t - S;
1329
+ const W = x * 180 / Math.PI % 360, X = this.random(l, d);
1330
+ M = a.spiralType === "golden" ? X : W * 0.1 + X * 0.9;
1331
+ } else u === "tangent" && (M = this.calculateSpiralTangent(x, A, a));
1332
+ const G = t - E;
1333
1333
  o.push({
1334
- id: S,
1334
+ id: E,
1335
1335
  x: F,
1336
1336
  y: U,
1337
- rotation: L,
1338
- scale: N,
1339
- baseSize: T,
1340
- zIndex: W
1337
+ rotation: M,
1338
+ scale: H,
1339
+ baseSize: C,
1340
+ zIndex: G
1341
1341
  });
1342
1342
  }
1343
1343
  return o;
@@ -1422,34 +1422,34 @@ class ue {
1422
1422
  r,
1423
1423
  h,
1424
1424
  a
1425
- ), E = new Array(g).fill(0);
1425
+ ), S = new Array(g).fill(0);
1426
1426
  for (let w = 0; w < t; w++)
1427
- E[w % g]++;
1427
+ S[w % g]++;
1428
1428
  let v = 0;
1429
1429
  for (let w = 0; w < g; w++) {
1430
- const S = m[w], x = E[w];
1431
- for (let C = 0; C < x; C++) {
1432
- let z, M;
1430
+ const E = m[w], x = S[w];
1431
+ for (let A = 0; A < x; A++) {
1432
+ let L, z;
1433
1433
  if (a.distribution === "gaussian")
1434
- z = this.gaussianRandom() * S.spread, M = this.gaussianRandom() * S.spread;
1434
+ L = this.gaussianRandom() * E.spread, z = this.gaussianRandom() * E.spread;
1435
1435
  else {
1436
- const L = this.random(0, Math.PI * 2), W = this.random(0, S.spread);
1437
- z = Math.cos(L) * W, M = Math.sin(L) * W;
1436
+ const M = this.random(0, Math.PI * 2), G = this.random(0, E.spread);
1437
+ L = Math.cos(M) * G, z = Math.sin(M) * G;
1438
1438
  }
1439
1439
  const P = 1 + a.overlap * 0.5, _ = 1 + a.overlap * 0.3;
1440
- z /= P, M /= P;
1441
- const Y = p ? this.random(f, b) : 1, N = _ * Y, T = c * N;
1442
- let D = S.x + z, j = S.y + M;
1443
- const A = T * 1.5 / 2, R = T / 2;
1444
- D = Math.max(h + A, Math.min(D, s - h - A)), j = Math.max(h + R, Math.min(j, r - h - R));
1445
- const O = u === "random" ? this.random(l, d) : 0, F = Math.sqrt(z * z + M * M) / S.spread, U = Math.round((1 - F) * 50) + 1;
1440
+ L /= P, z /= P;
1441
+ const Y = p ? this.random(f, b) : 1, H = _ * Y, C = c * H;
1442
+ let D = E.x + L, j = E.y + z;
1443
+ const R = C * 1.5 / 2, T = C / 2;
1444
+ D = Math.max(h + R, Math.min(D, s - h - R)), j = Math.max(h + T, Math.min(j, r - h - T));
1445
+ const O = u === "random" ? this.random(l, d) : 0, F = Math.sqrt(L * L + z * z) / E.spread, U = Math.round((1 - F) * 50) + 1;
1446
1446
  o.push({
1447
1447
  id: v,
1448
1448
  x: D,
1449
1449
  y: j,
1450
1450
  rotation: O,
1451
- scale: N,
1452
- baseSize: T,
1451
+ scale: H,
1452
+ baseSize: C,
1453
1453
  zIndex: U
1454
1454
  }), v++;
1455
1455
  }
@@ -1481,9 +1481,9 @@ class ue {
1481
1481
  spread: this.calculateClusterSpread(s)
1482
1482
  };
1483
1483
  let m = 1 / 0;
1484
- for (const E of r) {
1485
- const v = g.x - E.x, w = g.y - E.y, S = Math.sqrt(v * v + w * w);
1486
- m = Math.min(m, S);
1484
+ for (const S of r) {
1485
+ const v = g.x - S.x, w = g.y - S.y, E = Math.sqrt(v * v + w * w);
1486
+ m = Math.min(m, E);
1487
1487
  }
1488
1488
  if ((r.length === 0 || m > b) && (f = g, b = m), m >= s.clusterSpacing)
1489
1489
  break;
@@ -1531,26 +1531,26 @@ class ge {
1531
1531
  const o = [], { width: s, height: r } = e, a = i.fixedHeight ?? 200, h = this.config.spacing.padding ?? 50, c = this.imageConfig.rotation?.mode ?? "none", u = this.imageConfig.rotation?.range?.min ?? -15, l = this.imageConfig.rotation?.range?.max ?? 15, d = this.imageConfig.sizing?.variance?.min ?? 1, f = this.imageConfig.sizing?.variance?.max ?? 1, b = d !== 1 || f !== 1, p = i.fixedHeight ?? a, g = {
1532
1532
  ...Ot,
1533
1533
  ...this.config.wave
1534
- }, { rows: m, amplitude: E, frequency: v, phaseShift: w, synchronization: S } = g, x = Math.ceil(t / m), M = p * 1.5 / 2, P = h + M, _ = s - h - M, Y = _ - P, N = x > 1 ? Y / (x - 1) : 0, T = h + E + p / 2, D = r - h - E - p / 2, j = D - T, H = m > 1 ? j / (m - 1) : 0;
1535
- let A = 0;
1536
- for (let R = 0; R < m && A < t; R++) {
1537
- const O = m === 1 ? (T + D) / 2 : T + R * H;
1534
+ }, { rows: m, amplitude: S, frequency: v, phaseShift: w, synchronization: E } = g, x = Math.ceil(t / m), z = p * 1.5 / 2, P = h + z, _ = s - h - z, Y = _ - P, H = x > 1 ? Y / (x - 1) : 0, C = h + S + p / 2, D = r - h - S - p / 2, j = D - C, N = m > 1 ? j / (m - 1) : 0;
1535
+ let R = 0;
1536
+ for (let T = 0; T < m && R < t; T++) {
1537
+ const O = m === 1 ? (C + D) / 2 : C + T * N;
1538
1538
  let $ = 0;
1539
- S === "offset" ? $ = R * w : S === "alternating" && ($ = R * Math.PI);
1540
- for (let F = 0; F < x && A < t; F++) {
1541
- const U = x === 1 ? (P + _) / 2 : P + F * N, L = this.calculateWaveY(U, s, E, v, $), W = U, G = O + L, X = b ? this.random(d, f) : 1, B = p * X;
1539
+ E === "offset" ? $ = T * w : E === "alternating" && ($ = T * Math.PI);
1540
+ for (let F = 0; F < x && R < t; F++) {
1541
+ const U = x === 1 ? (P + _) / 2 : P + F * H, M = this.calculateWaveY(U, s, S, v, $), G = U, W = O + M, X = b ? this.random(d, f) : 1, B = p * X;
1542
1542
  let J = 0;
1543
- c === "tangent" ? J = this.calculateRotation(U, s, E, v, $) : c === "random" && (J = this.random(u, l));
1543
+ c === "tangent" ? J = this.calculateRotation(U, s, S, v, $) : c === "random" && (J = this.random(u, l));
1544
1544
  const K = B * 1.5 / 2, ct = B / 2, it = h + K, nt = s - h - K, lt = h + ct, ht = r - h - ct;
1545
1545
  o.push({
1546
- id: A,
1547
- x: Math.max(it, Math.min(W, nt)),
1548
- y: Math.max(lt, Math.min(G, ht)),
1546
+ id: R,
1547
+ x: Math.max(it, Math.min(G, nt)),
1548
+ y: Math.max(lt, Math.min(W, ht)),
1549
1549
  rotation: J,
1550
1550
  scale: X,
1551
1551
  baseSize: B,
1552
- zIndex: A + 1
1553
- }), A++;
1552
+ zIndex: R + 1
1553
+ }), R++;
1554
1554
  }
1555
1555
  }
1556
1556
  return o;
@@ -1699,12 +1699,12 @@ class fe {
1699
1699
  const a = s?.minSize ?? 50, h = s?.maxSize ?? 400, c = this.config.targetCoverage ?? 0.6, u = this.config.densityFactor ?? 1, { width: l, height: d } = t, p = l * d * c / e;
1700
1700
  let m = Math.sqrt(p / 1.4);
1701
1701
  m *= u, m = Math.min(m, i);
1702
- let E = this.clamp(m, a, h);
1703
- if (E === a && m < a) {
1702
+ let S = this.clamp(m, a, h);
1703
+ if (S === a && m < a) {
1704
1704
  const v = Math.max(a * 0.05, 20);
1705
- E = Math.max(v, m);
1705
+ S = Math.max(v, m);
1706
1706
  }
1707
- return { height: E };
1707
+ return { height: S };
1708
1708
  }
1709
1709
  /**
1710
1710
  * Utility: Clamp a value between min and max
@@ -1760,17 +1760,17 @@ function st(n) {
1760
1760
  function tt(n, t) {
1761
1761
  t.borderRadius !== void 0 && (n.style.borderRadius = t.borderRadius), t.borderTopLeftRadius !== void 0 && (n.style.borderTopLeftRadius = t.borderTopLeftRadius), t.borderTopRightRadius !== void 0 && (n.style.borderTopRightRadius = t.borderTopRightRadius), t.borderBottomRightRadius !== void 0 && (n.style.borderBottomRightRadius = t.borderBottomRightRadius), t.borderBottomLeftRadius !== void 0 && (n.style.borderBottomLeftRadius = t.borderBottomLeftRadius), t.border !== void 0 && (n.style.border = t.border), t.borderTop !== void 0 && (n.style.borderTop = t.borderTop), t.borderRight !== void 0 && (n.style.borderRight = t.borderRight), t.borderBottom !== void 0 && (n.style.borderBottom = t.borderBottom), t.borderLeft !== void 0 && (n.style.borderLeft = t.borderLeft), t.boxShadow !== void 0 && (n.style.boxShadow = t.boxShadow), t.filter !== void 0 && (n.style.filter = t.filter), t.opacity !== void 0 && (n.style.opacity = t.opacity), t.cursor !== void 0 && (n.style.cursor = t.cursor), t.outline !== void 0 && (n.style.outline = t.outline), t.outlineOffset !== void 0 && (n.style.outlineOffset = t.outlineOffset), t.objectFit !== void 0 && (n.style.objectFit = t.objectFit), t.aspectRatio !== void 0 && (n.style.aspectRatio = t.aspectRatio);
1762
1762
  }
1763
- function Lt(n) {
1763
+ function Mt(n) {
1764
1764
  return n ? Array.isArray(n) ? n.join(" ") : n : "";
1765
1765
  }
1766
1766
  function et(n, t) {
1767
- const e = Lt(t);
1767
+ const e = Mt(t);
1768
1768
  e && e.split(" ").forEach((i) => {
1769
1769
  i.trim() && n.classList.add(i.trim());
1770
1770
  });
1771
1771
  }
1772
- function zt(n, t) {
1773
- const e = Lt(t);
1772
+ function Lt(n, t) {
1773
+ const e = Mt(t);
1774
1774
  e && e.split(" ").forEach((i) => {
1775
1775
  i.trim() && n.classList.remove(i.trim());
1776
1776
  });
@@ -1872,7 +1872,7 @@ class ye {
1872
1872
  * Remove focused styling from an element
1873
1873
  */
1874
1874
  removeFocusedStyling(t, e) {
1875
- t.style.zIndex = e, t.classList.remove("fbn-ic-focused"), zt(t, this.focusedClassName), tt(t, this.defaultStyles), et(t, this.defaultClassName);
1875
+ t.style.zIndex = e, t.classList.remove("fbn-ic-focused"), Lt(t, this.focusedClassName), tt(t, this.defaultStyles), et(t, this.defaultClassName);
1876
1876
  }
1877
1877
  /**
1878
1878
  * Start focus animation for an image using dimension-based zoom
@@ -1965,6 +1965,27 @@ class ye {
1965
1965
  originalHeight: u
1966
1966
  };
1967
1967
  }
1968
+ /**
1969
+ * Capture the current visual state of an element mid-animation, BEFORE cancelling.
1970
+ *
1971
+ * The computed matrix.e/f include the -50%/-50% centering offset resolved to pixels.
1972
+ * buildDimensionZoomTransform prepends its own translate(-50%,-50%), so passing raw
1973
+ * matrix.e/f doubles the centering and produces the wrong starting position.
1974
+ *
1975
+ * This method extracts the PURE positional offset (pureX = matrix.e + 0.5*midWidth)
1976
+ * and commits width/height/transform to inline styles before the animation is cancelled,
1977
+ * preventing any visual snap.
1978
+ *
1979
+ * Must be called while the animation is still running (offsetWidth reflects animated size).
1980
+ * Caller is responsible for calling animationEngine.cancelAllAnimations() afterwards.
1981
+ */
1982
+ captureMidAnimationState(t) {
1983
+ const e = getComputedStyle(t), i = new DOMMatrix(e.transform), o = t.offsetWidth, s = t.offsetHeight, r = i.e + o * 0.5, a = i.f + s * 0.5, h = Math.atan2(i.b, i.a) * (180 / Math.PI);
1984
+ return t.style.width = `${o}px`, t.style.height = `${s}px`, t.style.transform = `translate(-50%, -50%) translate(${r}px, ${a}px) rotate(${h}deg)`, t.style.transition = "none", {
1985
+ transform: { x: r, y: a, rotation: h, scale: 1 },
1986
+ dimensions: { width: o, height: s }
1987
+ };
1988
+ }
1968
1989
  /**
1969
1990
  * Handle animation completion
1970
1991
  */
@@ -1990,21 +2011,12 @@ class ye {
1990
2011
  if (this.currentFocus === t && this.state === I.FOCUSED)
1991
2012
  return this.unfocusImage();
1992
2013
  if (this.incoming?.element === t && this.state === I.FOCUSING) {
1993
- const s = this.animationEngine.cancelAnimation(this.incoming.animationHandle, !0), r = {
1994
- x: s.x,
1995
- y: s.y,
1996
- rotation: s.rotation,
1997
- scale: 1
1998
- // No scale transform - using dimensions
1999
- }, a = {
2000
- width: t.offsetWidth,
2001
- height: t.offsetHeight
2002
- };
2003
- this.outgoing = this.startUnfocusAnimation(
2014
+ const { transform: s, dimensions: r } = this.captureMidAnimationState(t);
2015
+ this.animationEngine.cancelAllAnimations(t), this.outgoing = this.startUnfocusAnimation(
2004
2016
  t,
2005
2017
  this.incoming.originalState,
2006
- r,
2007
- a
2018
+ s,
2019
+ r
2008
2020
  ), this.incoming = null, this.state = I.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.removeFocusedStyling(this.outgoing.element, this.focusData?.originalZIndex || ""), this.outgoing = null, this.currentFocus = null, this.focusData = null, this.state = I.IDLE;
2009
2021
  return;
2010
2022
  }
@@ -2046,36 +2058,18 @@ class ye {
2046
2058
  if (this.incoming?.element === t)
2047
2059
  return;
2048
2060
  if (this.outgoing?.element === t) {
2049
- const s = this.animationEngine.cancelAnimation(this.outgoing.animationHandle, !0), r = {
2050
- x: s.x,
2051
- y: s.y,
2052
- rotation: s.rotation,
2053
- scale: 1
2054
- // No scale - using dimensions
2055
- }, a = {
2056
- width: t.offsetWidth,
2057
- height: t.offsetHeight
2058
- };
2059
- if (this.incoming) {
2060
- const h = this.animationEngine.cancelAnimation(this.incoming.animationHandle, !0), c = {
2061
- x: h.x,
2062
- y: h.y,
2063
- rotation: h.rotation,
2064
- scale: 1
2065
- // No scale - using dimensions
2066
- }, u = {
2067
- width: this.incoming.element.offsetWidth,
2068
- height: this.incoming.element.offsetHeight
2069
- };
2070
- this.outgoing = this.startUnfocusAnimation(
2061
+ const { transform: s, dimensions: r } = this.captureMidAnimationState(t);
2062
+ if (this.animationEngine.cancelAllAnimations(t), this.incoming) {
2063
+ const { transform: a, dimensions: h } = this.captureMidAnimationState(this.incoming.element);
2064
+ this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
2071
2065
  this.incoming.element,
2072
2066
  this.incoming.originalState,
2073
- c,
2074
- u
2067
+ a,
2068
+ h
2075
2069
  );
2076
2070
  } else
2077
2071
  this.outgoing = null;
2078
- if (this.incoming = this.startFocusAnimation(t, e, i, r, a), await Promise.all([
2072
+ if (this.incoming = this.startFocusAnimation(t, e, i, s, r), await Promise.all([
2079
2073
  this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
2080
2074
  this.waitForAnimation(this.incoming.animationHandle)
2081
2075
  ]), this.focusGeneration !== o) return;
@@ -2089,21 +2083,12 @@ class ye {
2089
2083
  this.outgoing.originalWidth,
2090
2084
  this.outgoing.originalHeight
2091
2085
  ), this.outgoing = null), this.incoming) {
2092
- const s = this.animationEngine.cancelAnimation(this.incoming.animationHandle, !0), r = {
2093
- x: s.x,
2094
- y: s.y,
2095
- rotation: s.rotation,
2096
- scale: 1
2097
- // No scale - using dimensions
2098
- }, a = {
2099
- width: this.incoming.element.offsetWidth,
2100
- height: this.incoming.element.offsetHeight
2101
- };
2102
- this.outgoing = this.startUnfocusAnimation(
2086
+ const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
2087
+ this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
2103
2088
  this.incoming.element,
2104
2089
  this.incoming.originalState,
2105
- r,
2106
- a
2090
+ s,
2091
+ r
2107
2092
  );
2108
2093
  }
2109
2094
  if (this.incoming = this.startFocusAnimation(t, e, i), await Promise.all([
@@ -2118,50 +2103,36 @@ class ye {
2118
2103
  * Unfocus current image, returning it to original position
2119
2104
  */
2120
2105
  async unfocusImage() {
2106
+ if (this.state === I.UNFOCUSING)
2107
+ return;
2121
2108
  const t = ++this.focusGeneration;
2122
2109
  if (!this.currentFocus || !this.focusData) {
2123
2110
  if (this.incoming && this.state === I.FOCUSING) {
2124
- const s = this.animationEngine.cancelAnimation(this.incoming.animationHandle, !0), r = {
2125
- x: s.x,
2126
- y: s.y,
2127
- rotation: s.rotation,
2128
- scale: 1
2129
- // No scale - using dimensions
2130
- }, a = {
2131
- width: this.incoming.element.offsetWidth,
2132
- height: this.incoming.element.offsetHeight
2133
- };
2134
- if (this.outgoing = this.startUnfocusAnimation(
2111
+ const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
2112
+ if (this.animationEngine.cancelAllAnimations(this.incoming.element), this.outgoing = this.startUnfocusAnimation(
2135
2113
  this.incoming.element,
2136
2114
  this.incoming.originalState,
2137
- r,
2138
- a
2115
+ s,
2116
+ r
2139
2117
  ), this.incoming = null, this.state = I.UNFOCUSING, await this.waitForAnimation(this.outgoing.animationHandle), this.focusGeneration !== t) return;
2140
2118
  this.removeFocusedStyling(this.outgoing.element, this.focusData?.originalZIndex || ""), this.outgoing = null, this.focusData = null, this.state = I.IDLE;
2141
2119
  }
2142
2120
  return;
2143
2121
  }
2144
2122
  if (this.state === I.CROSS_ANIMATING && this.incoming) {
2145
- const s = this.animationEngine.cancelAnimation(this.incoming.animationHandle, !0), r = {
2146
- x: s.x,
2147
- y: s.y,
2148
- rotation: s.rotation,
2149
- scale: 1
2150
- // No scale - using dimensions
2151
- }, a = {
2152
- width: this.incoming.element.offsetWidth,
2153
- height: this.incoming.element.offsetHeight
2154
- }, h = this.startUnfocusAnimation(
2123
+ const { transform: s, dimensions: r } = this.captureMidAnimationState(this.incoming.element);
2124
+ this.animationEngine.cancelAllAnimations(this.incoming.element);
2125
+ const a = this.startUnfocusAnimation(
2155
2126
  this.incoming.element,
2156
2127
  this.incoming.originalState,
2157
- r,
2158
- a
2128
+ s,
2129
+ r
2159
2130
  );
2160
2131
  if (await Promise.all([
2161
2132
  this.outgoing ? this.waitForAnimation(this.outgoing.animationHandle) : Promise.resolve(),
2162
- this.waitForAnimation(h.animationHandle)
2133
+ this.waitForAnimation(a.animationHandle)
2163
2134
  ]), this.focusGeneration !== t) return;
2164
- this.outgoing && this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || ""), this.removeFocusedStyling(h.element, this.incoming.originalState.zIndex?.toString() || ""), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state = I.IDLE;
2135
+ this.outgoing && this.removeFocusedStyling(this.outgoing.element, this.outgoing.originalState.zIndex?.toString() || ""), this.removeFocusedStyling(a.element, this.incoming.originalState.zIndex?.toString() || ""), this.outgoing = null, this.incoming = null, this.currentFocus = null, this.focusData = null, this.state = I.IDLE;
2165
2136
  return;
2166
2137
  }
2167
2138
  this.state = I.UNFOCUSING;
@@ -2248,7 +2219,7 @@ class ye {
2248
2219
  ), this.state = I.IDLE, this.currentFocus = null, this.focusData = null, this.outgoing = null, this.incoming = null;
2249
2220
  }
2250
2221
  }
2251
- const ve = 50, we = 0.5, xe = 20, Ee = 0.3, Se = 150, Ie = 30, at = class at {
2222
+ const ve = 50, we = 0.5, xe = 20, Se = 0.3, Ee = 150, Ie = 30, at = class at {
2252
2223
  constructor(t, e) {
2253
2224
  this.enabled = !1, this.touchState = null, this.recentTouchTimestamp = 0, this.container = t, this.callbacks = e, this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), this.boundTouchCancel = this.handleTouchCancel.bind(this);
2254
2225
  }
@@ -2299,7 +2270,7 @@ const ve = 50, we = 0.5, xe = 20, Ee = 0.3, Se = 150, Ie = 30, at = class at {
2299
2270
  }
2300
2271
  if (this.touchState.isHorizontalSwipe !== !1 && this.touchState.isHorizontalSwipe === !0) {
2301
2272
  t.preventDefault(), this.touchState.isDragging = !0, this.touchState.currentX = e.clientX;
2302
- const s = i * Ee;
2273
+ const s = i * Se;
2303
2274
  this.callbacks.onDragOffset(s);
2304
2275
  }
2305
2276
  }
@@ -2316,7 +2287,7 @@ const ve = 50, we = 0.5, xe = 20, Ee = 0.3, Se = 150, Ie = 30, at = class at {
2316
2287
  };
2317
2288
  at.TOUCH_CLICK_DELAY = 300;
2318
2289
  let mt = at;
2319
- class Ce {
2290
+ class Ae {
2320
2291
  constructor(t) {
2321
2292
  if (this._prepared = !1, this._discoveredUrls = [], this.apiKey = t.apiKey ?? "", this.apiEndpoint = t.apiEndpoint ?? "https://www.googleapis.com/drive/v3/files", this.debugLogging = t.debugLogging ?? !1, this.sources = t.sources ?? [], !this.sources || this.sources.length === 0)
2322
2293
  throw new Error("GoogleDriveLoader requires at least one source to be configured");
@@ -2537,7 +2508,7 @@ class Ce {
2537
2508
  this.debugLogging && typeof console < "u" && console.log(...t);
2538
2509
  }
2539
2510
  }
2540
- class Te {
2511
+ class Ce {
2541
2512
  constructor(t) {
2542
2513
  if (this._prepared = !1, this._discoveredUrls = [], this.validateUrls = t.validateUrls !== !1, this.validationTimeout = t.validationTimeout ?? 5e3, this.validationMethod = t.validationMethod ?? "head", this.debugLogging = t.debugLogging ?? !1, this.sources = t.sources ?? [], !this.sources || this.sources.length === 0)
2543
2514
  throw new Error("StaticImageLoader requires at least one source to be configured");
@@ -2717,7 +2688,7 @@ class Te {
2717
2688
  this.debugLogging && typeof console < "u" && console.log(...t);
2718
2689
  }
2719
2690
  }
2720
- class Re {
2691
+ class Te {
2721
2692
  constructor(t) {
2722
2693
  if (this._prepared = !1, this._discoveredUrls = [], this.loaders = t.loaders, this.debugLogging = t.debugLogging ?? !1, !this.loaders || this.loaders.length === 0)
2723
2694
  throw new Error("CompositeLoader requires at least one loader to be configured");
@@ -2774,7 +2745,7 @@ class Re {
2774
2745
  this.debugLogging && typeof console < "u" && console.log("[CompositeLoader]", ...t);
2775
2746
  }
2776
2747
  }
2777
- class Ae {
2748
+ class Re {
2778
2749
  /**
2779
2750
  * Create a new ImageFilter
2780
2751
  * @param extensions - Array of allowed file extensions (without dots)
@@ -2811,7 +2782,7 @@ class Ae {
2811
2782
  // isAllowedDate(date: Date): boolean
2812
2783
  // isAllowedDimensions(width: number, height: number): boolean
2813
2784
  }
2814
- const Le = `
2785
+ const Me = `
2815
2786
  .fbn-ic-gallery {
2816
2787
  position: relative;
2817
2788
  width: 100%;
@@ -2861,14 +2832,14 @@ const Le = `
2861
2832
  display: none !important;
2862
2833
  }
2863
2834
  `;
2864
- function ze() {
2835
+ function Le() {
2865
2836
  if (typeof document > "u") return;
2866
2837
  const n = "fbn-ic-functional-styles";
2867
2838
  if (document.getElementById(n)) return;
2868
2839
  const t = document.createElement("style");
2869
- t.id = n, t.textContent = Le, document.head.appendChild(t);
2840
+ t.id = n, t.textContent = Me, document.head.appendChild(t);
2870
2841
  }
2871
- class Me {
2842
+ class ze {
2872
2843
  constructor(t = {}) {
2873
2844
  this.fullConfig = jt(t), t.container instanceof HTMLElement ? (this.containerRef = t.container, this.containerId = null) : (this.containerRef = null, this.containerId = t.container || "imageCloud"), this.imagesLoaded = !1, this.imageElements = [], this.imageLayouts = [], this.currentImageHeight = 225, this.currentFocusIndex = null, this.hoveredImage = null, this.resizeTimeout = null, this.displayQueue = [], this.queueInterval = null, this.loadGeneration = 0, this.loadingElAutoCreated = !1, this.errorElAutoCreated = !1, this.counterEl = null, this.counterElAutoCreated = !1, this.animationEngine = new Yt(this.fullConfig.animation), this.layoutEngine = new fe({
2874
2845
  layout: this.fullConfig.layout,
@@ -2885,7 +2856,7 @@ class Me {
2885
2856
  */
2886
2857
  createImageFilter() {
2887
2858
  const t = this.fullConfig.config.loaders?.allowedExtensions;
2888
- return new Ae(t);
2859
+ return new Re(t);
2889
2860
  }
2890
2861
  /**
2891
2862
  * Create appropriate image loader based on config
@@ -2896,7 +2867,7 @@ class Me {
2896
2867
  if (!t || t.length === 0)
2897
2868
  throw new Error("No loaders configured. Provide `images`, `loaders`, or both.");
2898
2869
  const i = t.map((o) => this.createLoaderFromEntry(o, e));
2899
- return i.length === 1 ? i[0] : new Re({
2870
+ return i.length === 1 ? i[0] : new Te({
2900
2871
  loaders: i,
2901
2872
  debugLogging: this.fullConfig.config.debug?.loaders
2902
2873
  });
@@ -2914,14 +2885,14 @@ class Me {
2914
2885
  allowedExtensions: i.allowedExtensions ?? e.allowedExtensions,
2915
2886
  debugLogging: i.debugLogging ?? this.fullConfig.config.debug?.loaders
2916
2887
  };
2917
- return new Te(o);
2888
+ return new Ce(o);
2918
2889
  } else if ("googleDrive" in t) {
2919
2890
  const i = t.googleDrive, o = {
2920
2891
  ...i,
2921
2892
  allowedExtensions: i.allowedExtensions ?? e.allowedExtensions,
2922
2893
  debugLogging: i.debugLogging ?? this.fullConfig.config.debug?.loaders
2923
2894
  };
2924
- return new Ce(o);
2895
+ return new Ae(o);
2925
2896
  } else
2926
2897
  throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`);
2927
2898
  }
@@ -2930,7 +2901,7 @@ class Me {
2930
2901
  */
2931
2902
  async init() {
2932
2903
  try {
2933
- if (ze(), this.containerRef)
2904
+ if (Le(), this.containerRef)
2934
2905
  this.containerEl = this.containerRef;
2935
2906
  else if (this.containerEl = document.getElementById(this.containerId), !this.containerEl)
2936
2907
  throw new Error(`Container #${this.containerId} not found`);
@@ -2939,7 +2910,7 @@ class Me {
2939
2910
  onPrev: () => this.navigateToPreviousImage(),
2940
2911
  onDragOffset: (t) => this.zoomEngine.setDragOffset(t),
2941
2912
  onDragEnd: (t) => {
2942
- t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0, Se);
2913
+ t ? this.zoomEngine.clearDragOffset(!1) : this.zoomEngine.clearDragOffset(!0, Ee);
2943
2914
  }
2944
2915
  }), this.setupUI(), this.setupEventListeners(), this.logDebug("ImageCloud initialized"), await this.loadImages();
2945
2916
  } catch (t) {
@@ -3069,7 +3040,7 @@ class Me {
3069
3040
  }, f = {
3070
3041
  x: parseFloat(c.dataset.endX),
3071
3042
  y: parseFloat(c.dataset.endY)
3072
- }, b = parseFloat(c.dataset.imageWidth), p = parseFloat(c.dataset.imageHeight), g = parseFloat(c.dataset.rotation), m = parseFloat(c.dataset.scale), E = c.dataset.startRotation ? parseFloat(c.dataset.startRotation) : g, v = c.dataset.startScale ? parseFloat(c.dataset.startScale) : m, w = this.entryAnimationEngine.getTiming();
3043
+ }, b = parseFloat(c.dataset.imageWidth), p = parseFloat(c.dataset.imageHeight), g = parseFloat(c.dataset.rotation), m = parseFloat(c.dataset.scale), S = c.dataset.startRotation ? parseFloat(c.dataset.startRotation) : g, v = c.dataset.startScale ? parseFloat(c.dataset.startScale) : m, w = this.entryAnimationEngine.getTiming();
3073
3044
  te({
3074
3045
  element: c,
3075
3046
  startPosition: d,
@@ -3081,7 +3052,7 @@ class Me {
3081
3052
  rotation: g,
3082
3053
  scale: m,
3083
3054
  rotationConfig: this.entryAnimationEngine.getRotationConfig(),
3084
- startRotation: E,
3055
+ startRotation: S,
3085
3056
  scaleConfig: this.entryAnimationEngine.getScaleConfig(),
3086
3057
  startScale: v
3087
3058
  });
@@ -3145,7 +3116,7 @@ class Me {
3145
3116
  l.style.position = "absolute", l.style.width = "auto", l.style.height = `${e}px`, l.style.left = `${d.x}px`, l.style.top = `${d.y}px`, d.zIndex && (l.style.zIndex = String(d.zIndex)), tt(l, this.defaultStyles), et(l, this.defaultClassName), l.addEventListener("mouseenter", () => {
3146
3117
  this.hoveredImage = { element: l, layout: d }, this.zoomEngine.isInvolved(l) || (tt(l, this.hoverStyles), et(l, this.hoverClassName));
3147
3118
  }), l.addEventListener("mouseleave", () => {
3148
- this.hoveredImage = null, this.zoomEngine.isInvolved(l) || (tt(l, this.defaultStyles), zt(l, this.hoverClassName), et(l, this.defaultClassName));
3119
+ this.hoveredImage = null, this.zoomEngine.isInvolved(l) || (tt(l, this.defaultStyles), Lt(l, this.hoverClassName), et(l, this.defaultClassName));
3149
3120
  }), l.addEventListener("click", (f) => {
3150
3121
  f.stopPropagation(), this.handleImageClick(l, d);
3151
3122
  }), l.style.opacity = "0", l.style.transition = this.entryAnimationEngine.getTransitionCSS(), l.onload = () => {
@@ -3159,19 +3130,19 @@ class Me {
3159
3130
  i,
3160
3131
  u,
3161
3132
  t.length
3162
- ), E = this.entryAnimationEngine.calculateStartRotation(d.rotation), v = this.entryAnimationEngine.calculateStartScale(d.scale), w = this.entryAnimationEngine.buildFinalTransform(
3133
+ ), S = this.entryAnimationEngine.calculateStartRotation(d.rotation), v = this.entryAnimationEngine.calculateStartScale(d.scale), w = this.entryAnimationEngine.buildFinalTransform(
3163
3134
  d.rotation,
3164
3135
  d.scale,
3165
3136
  b,
3166
3137
  e
3167
- ), S = this.entryAnimationEngine.buildStartTransform(
3138
+ ), E = this.entryAnimationEngine.buildStartTransform(
3168
3139
  m,
3169
3140
  p,
3170
3141
  d.rotation,
3171
3142
  d.scale,
3172
3143
  b,
3173
3144
  e,
3174
- E,
3145
+ S,
3175
3146
  v
3176
3147
  );
3177
3148
  this.fullConfig.config.debug?.enabled && u < 3 && console.log(`Image ${u}:`, {
@@ -3182,7 +3153,7 @@ class Me {
3182
3153
  finalTransform: w,
3183
3154
  renderedWidth: b,
3184
3155
  renderedHeight: e
3185
- }), l.style.transform = S, l.dataset.finalTransform = w, (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || E !== d.rotation || v !== d.scale) && (l.dataset.startX = String(m.x), l.dataset.startY = String(m.y), l.dataset.endX = String(p.x), l.dataset.endY = String(p.y), l.dataset.imageWidth = String(b), l.dataset.imageHeight = String(e), l.dataset.rotation = String(d.rotation), l.dataset.scale = String(d.scale), l.dataset.startRotation = String(E), l.dataset.startScale = String(v)), this.displayQueue.push(l);
3156
+ }), l.style.transform = E, l.dataset.finalTransform = w, (this.entryAnimationEngine.requiresJSAnimation() || this.entryAnimationEngine.requiresJSRotation() || this.entryAnimationEngine.requiresJSScale() || S !== d.rotation || v !== d.scale) && (l.dataset.startX = String(m.x), l.dataset.startY = String(m.y), l.dataset.endX = String(p.x), l.dataset.endY = String(p.y), l.dataset.imageWidth = String(b), l.dataset.imageHeight = String(e), l.dataset.rotation = String(d.rotation), l.dataset.scale = String(d.scale), l.dataset.startRotation = String(S), l.dataset.startScale = String(v)), this.displayQueue.push(l);
3186
3157
  }, l.onerror = () => r++, l.src = c;
3187
3158
  });
3188
3159
  }
@@ -3265,7 +3236,7 @@ function De() {
3265
3236
  console.error(`ImageCloud: Missing configuration for #${i.id}. Add data-config='{...}' attribute.`);
3266
3237
  return;
3267
3238
  }
3268
- new Me(s).init().catch((a) => {
3239
+ new ze(s).init().catch((a) => {
3269
3240
  console.error("ImageCloud initialization failed:", a);
3270
3241
  });
3271
3242
  });
@@ -3274,8 +3245,8 @@ function De() {
3274
3245
  }
3275
3246
  De();
3276
3247
  export {
3277
- Me as ImageCloud,
3278
- Me as ImageGallery,
3248
+ ze as ImageCloud,
3249
+ ze as ImageGallery,
3279
3250
  De as autoInitialize
3280
3251
  };
3281
3252
  //# sourceMappingURL=image-cloud-auto-init.js.map