wulf.js 1.8.4 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +18 -14
  2. package/changelog.md +55 -0
  3. package/dist/index.cjs.js +590 -54
  4. package/dist/index.cjs.js.map +3 -3
  5. package/dist/index.esm.js +590 -54
  6. package/dist/index.esm.js.map +3 -3
  7. package/dist/index.global.js +590 -54
  8. package/dist/index.global.js.map +3 -3
  9. package/dist/index.global.min.js +1 -1
  10. package/dist/index.global.min.js.map +4 -4
  11. package/dist/mask.cjs.js +231 -31
  12. package/dist/mask.cjs.js.map +2 -2
  13. package/dist/mask.css +1 -1
  14. package/dist/mask.css.map +2 -2
  15. package/dist/mask.esm.js +231 -31
  16. package/dist/mask.esm.js.map +2 -2
  17. package/dist/mask.global.js +231 -31
  18. package/dist/mask.global.js.map +2 -2
  19. package/dist/mask.global.min.js +1 -1
  20. package/dist/mask.global.min.js.map +3 -3
  21. package/dist/masonry.cjs.js +220 -9
  22. package/dist/masonry.cjs.js.map +3 -3
  23. package/dist/masonry.esm.js +220 -9
  24. package/dist/masonry.esm.js.map +3 -3
  25. package/dist/masonry.global.js +220 -9
  26. package/dist/masonry.global.js.map +3 -3
  27. package/dist/masonry.global.min.js +1 -1
  28. package/dist/masonry.global.min.js.map +4 -4
  29. package/dist/scroll.cjs.js +256 -8
  30. package/dist/scroll.cjs.js.map +3 -3
  31. package/dist/scroll.esm.js +256 -8
  32. package/dist/scroll.esm.js.map +3 -3
  33. package/dist/scroll.global.js +256 -8
  34. package/dist/scroll.global.js.map +3 -3
  35. package/dist/scroll.global.min.js +1 -1
  36. package/dist/scroll.global.min.js.map +4 -4
  37. package/dist/toast.cjs.js +199 -6
  38. package/dist/toast.cjs.js.map +3 -3
  39. package/dist/toast.css +1 -1
  40. package/dist/toast.css.map +2 -2
  41. package/dist/toast.esm.js +199 -6
  42. package/dist/toast.esm.js.map +3 -3
  43. package/dist/toast.global.js +199 -6
  44. package/dist/toast.global.js.map +3 -3
  45. package/dist/toast.global.min.js +1 -1
  46. package/dist/toast.global.min.js.map +4 -4
  47. package/dist/types/common/LocalizedComponent.d.ts +53 -0
  48. package/dist/types/common/i18n.d.ts +39 -0
  49. package/dist/types/index.d.ts +2 -0
  50. package/dist/types/mask/BaseInputMask.d.ts +1 -0
  51. package/dist/types/mask/EmailEngine.d.ts +24 -2
  52. package/dist/types/mask/InputEmailMask.d.ts +8 -0
  53. package/dist/types/mask/InputMask.d.ts +8 -0
  54. package/dist/types/masonry/Masonry.d.ts +11 -1
  55. package/dist/types/masonry/i18n/en.d.ts +2 -0
  56. package/dist/types/masonry/i18n/fr.d.ts +2 -0
  57. package/dist/types/masonry/i18n/index.d.ts +9 -0
  58. package/dist/types/masonry/i18n/types.d.ts +7 -0
  59. package/dist/types/masonry/index.d.ts +1 -0
  60. package/dist/types/masonry/types.d.ts +8 -3
  61. package/dist/types/scroll/ScrollBlock.d.ts +14 -1
  62. package/dist/types/scroll/i18n/en.d.ts +2 -0
  63. package/dist/types/scroll/i18n/fr.d.ts +2 -0
  64. package/dist/types/scroll/i18n/index.d.ts +9 -0
  65. package/dist/types/scroll/i18n/types.d.ts +11 -0
  66. package/dist/types/scroll/index.d.ts +2 -0
  67. package/dist/types/scroll/types.d.ts +6 -1
  68. package/dist/types/toast/Toast.d.ts +5 -1
  69. package/dist/types/toast/i18n/en.d.ts +2 -0
  70. package/dist/types/toast/i18n/fr.d.ts +2 -0
  71. package/dist/types/toast/i18n/index.d.ts +9 -0
  72. package/dist/types/toast/i18n/types.d.ts +7 -0
  73. package/dist/types/toast/index.d.ts +1 -0
  74. package/dist/types/toast/types.d.ts +9 -1
  75. package/package.json +1 -1
@@ -22,8 +22,13 @@ var Wulf = (() => {
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
24
  LayoutEngine: () => LayoutEngine,
25
+ LocalizedComponent: () => LocalizedComponent,
25
26
  Masonry: () => Masonry,
26
- default: () => index_default
27
+ createI18nManager: () => createI18nManager,
28
+ default: () => index_default,
29
+ masonryEn: () => masonryEn,
30
+ masonryFr: () => masonryFr,
31
+ masonryI18n: () => masonryI18n
27
32
  });
28
33
 
29
34
  // src/masonry/LayoutEngine.ts
@@ -213,9 +218,185 @@ var Wulf = (() => {
213
218
  }
214
219
  };
215
220
 
221
+ // src/common/LocalizedComponent.ts
222
+ var LocalizedComponent = class {
223
+ /**
224
+ * Définit la langue globale du composant (ex: 'fr', 'en', 'es').
225
+ */
226
+ static setLocale(locale) {
227
+ if (this._i18n) {
228
+ this._i18n.setLocale(locale);
229
+ }
230
+ }
231
+ /**
232
+ * Retourne la langue globale active du composant.
233
+ */
234
+ static getLocale() {
235
+ return this._i18n ? this._i18n.getLocale() : "";
236
+ }
237
+ /**
238
+ * Enregistre un dictionnaire de traduction pour une langue donnée.
239
+ */
240
+ static registerLocale(locale, translations) {
241
+ if (this._i18n) {
242
+ this._i18n.registerLocale(locale, translations);
243
+ }
244
+ }
245
+ /**
246
+ * Surcharge les libellés globalement pour ce composant.
247
+ */
248
+ static setI18n(overrides) {
249
+ if (this._i18n) {
250
+ this._i18n.setI18n(overrides);
251
+ }
252
+ }
253
+ /**
254
+ * Retourne l'ensemble des libellés actifs résolus du composant.
255
+ */
256
+ static getI18n() {
257
+ return this._i18n ? this._i18n.getAll() : {};
258
+ }
259
+ /**
260
+ * Réinitialise les réglages de langue et surcharges globales.
261
+ */
262
+ static resetI18n() {
263
+ if (this._i18n) {
264
+ this._i18n.reset();
265
+ }
266
+ }
267
+ /**
268
+ * Résout une clé au niveau statique de la classe.
269
+ */
270
+ static t(key, instanceOverride) {
271
+ return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
272
+ }
273
+ constructor(i18nOverrides) {
274
+ this.i18nOverrides = i18nOverrides;
275
+ }
276
+ /**
277
+ * Traduit une clé en tenant compte automatiquement des surcharges de l'instance courante.
278
+ */
279
+ t(key) {
280
+ const ctor = this.constructor;
281
+ return ctor._i18n ? ctor._i18n.t(key, this.i18nOverrides) : String(key);
282
+ }
283
+ };
284
+
285
+ // src/common/i18n.ts
286
+ function normalizeLocaleCode(locale) {
287
+ return locale.trim().toLowerCase().replace(/_/g, "-");
288
+ }
289
+ function getPrimaryLanguage(normalizedLocale) {
290
+ const dashIndex = normalizedLocale.indexOf("-");
291
+ return dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
292
+ }
293
+ function assignDefined(target, source) {
294
+ if (!source) return target;
295
+ for (const key of Object.keys(source)) {
296
+ if (source[key] !== void 0) {
297
+ target[key] = source[key];
298
+ }
299
+ }
300
+ return target;
301
+ }
302
+ function createI18nManager(defaultLocale, locales) {
303
+ const fallbackLocale = normalizeLocaleCode(defaultLocale);
304
+ const initialLocales = {};
305
+ for (const [loc, dict] of Object.entries(locales)) {
306
+ initialLocales[normalizeLocaleCode(loc)] = { ...dict };
307
+ }
308
+ let currentLocale = fallbackLocale;
309
+ let activeLocales = { ...initialLocales };
310
+ let globalOverrides = {};
311
+ function resolveActiveDictionaries() {
312
+ const dicts = [];
313
+ const exact = activeLocales[currentLocale];
314
+ if (exact) dicts.push(exact);
315
+ const primary = getPrimaryLanguage(currentLocale);
316
+ if (primary && activeLocales[primary]) {
317
+ dicts.push(activeLocales[primary]);
318
+ }
319
+ return dicts;
320
+ }
321
+ return {
322
+ setLocale(locale) {
323
+ if (locale && locale.trim()) {
324
+ currentLocale = normalizeLocaleCode(locale);
325
+ }
326
+ },
327
+ getLocale() {
328
+ return currentLocale;
329
+ },
330
+ registerLocale(locale, translations) {
331
+ if (!locale || !locale.trim() || !translations) return;
332
+ const norm = normalizeLocaleCode(locale);
333
+ activeLocales[norm] = assignDefined({ ...activeLocales[norm] || {} }, translations);
334
+ },
335
+ setI18n(overrides) {
336
+ if (!overrides) return;
337
+ globalOverrides = assignDefined({ ...globalOverrides }, overrides);
338
+ },
339
+ t(key, instanceOverride) {
340
+ if (instanceOverride && instanceOverride[key] !== void 0) {
341
+ return String(instanceOverride[key]);
342
+ }
343
+ if (globalOverrides[key] !== void 0) {
344
+ return String(globalOverrides[key]);
345
+ }
346
+ for (const dict of resolveActiveDictionaries()) {
347
+ if (dict[key] !== void 0) {
348
+ return String(dict[key]);
349
+ }
350
+ }
351
+ const fallbackDict = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
352
+ if (fallbackDict && fallbackDict[key] !== void 0) {
353
+ return String(fallbackDict[key]);
354
+ }
355
+ return String(key);
356
+ },
357
+ getAll(instanceOverride) {
358
+ const result = {};
359
+ const fallback = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
360
+ assignDefined(result, fallback);
361
+ const activeDicts = resolveActiveDictionaries().reverse();
362
+ for (const dict of activeDicts) {
363
+ assignDefined(result, dict);
364
+ }
365
+ assignDefined(result, globalOverrides);
366
+ assignDefined(result, instanceOverride);
367
+ return result;
368
+ },
369
+ reset() {
370
+ currentLocale = fallbackLocale;
371
+ globalOverrides = {};
372
+ activeLocales = {};
373
+ for (const [loc, dict] of Object.entries(initialLocales)) {
374
+ activeLocales[loc] = { ...dict };
375
+ }
376
+ }
377
+ };
378
+ }
379
+
380
+ // src/masonry/i18n/fr.ts
381
+ var masonryFr = {
382
+ gallery: "Galerie en grille asym\xE9trique"
383
+ };
384
+
385
+ // src/masonry/i18n/en.ts
386
+ var masonryEn = {
387
+ gallery: "Masonry grid gallery"
388
+ };
389
+
390
+ // src/masonry/i18n/index.ts
391
+ var masonryI18n = createI18nManager("fr", {
392
+ fr: masonryFr,
393
+ en: masonryEn
394
+ });
395
+
216
396
  // src/masonry/Masonry.ts
217
- var Masonry = class {
397
+ var Masonry = class extends LocalizedComponent {
218
398
  constructor(target, options = {}) {
399
+ super(options.i18n);
219
400
  this.isNativeCSSGrid = false;
220
401
  this._items = [];
221
402
  this.resizeObserver = null;
@@ -224,6 +405,8 @@ var Wulf = (() => {
224
405
  this.isDestroyed = false;
225
406
  this.wasRoleInferred = false;
226
407
  this.wasAriaLabelInferred = false;
408
+ this.hasExplicitAriaLabel = false;
409
+ this.lastInferredAriaLabel = "";
227
410
  this.removeTimers = /* @__PURE__ */ new Set();
228
411
  this.pendingImageListeners = [];
229
412
  if (typeof target === "string") {
@@ -241,11 +424,12 @@ var Wulf = (() => {
241
424
  height: this.root.style.height,
242
425
  width: this.root.style.width
243
426
  };
427
+ this.hasExplicitAriaLabel = Boolean(options.ariaLabel);
244
428
  this.options = {
245
429
  itemSelector: options.itemSelector || "> *",
246
430
  columnWidth: options.columnWidth ?? 0,
247
431
  gutter: options.gutter ?? 0,
248
- percentPosition: options.percentPosition !== false,
432
+ percentPosition: Boolean(options.percentPosition),
249
433
  fitWidth: Boolean(options.fitWidth),
250
434
  horizontalOrder: Boolean(options.horizontalOrder),
251
435
  transitionDuration: options.transitionDuration !== void 0 ? options.transitionDuration : 300,
@@ -254,7 +438,8 @@ var Wulf = (() => {
254
438
  autoImages: options.autoImages !== false,
255
439
  useNativeCSSGrid: options.useNativeCSSGrid !== false,
256
440
  ariaRole: options.ariaRole || "region",
257
- ariaLabel: options.ariaLabel || "Galerie en grille asym\xE9trique",
441
+ ariaLabel: options.ariaLabel || this.t("gallery"),
442
+ i18n: options.i18n || {},
258
443
  onLayout: options.onLayout || (() => {
259
444
  }),
260
445
  onItemPlaced: options.onItemPlaced || (() => {
@@ -285,11 +470,27 @@ var Wulf = (() => {
285
470
  this.root.setAttribute("role", this.options.ariaRole);
286
471
  this.wasRoleInferred = true;
287
472
  }
288
- if (this.options.ariaLabel && !this.root.hasAttribute("aria-label")) {
289
- this.root.setAttribute("aria-label", this.options.ariaLabel);
473
+ const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("gallery");
474
+ if (label && !this.root.hasAttribute("aria-label")) {
475
+ this.root.setAttribute("aria-label", label);
476
+ this.lastInferredAriaLabel = label;
290
477
  this.wasAriaLabelInferred = true;
291
478
  }
292
479
  }
480
+ /**
481
+ * Synchronise dynamiquement le libellé ARIA si la langue globale change après montage.
482
+ */
483
+ syncAccessibilityLabels() {
484
+ if (this.wasAriaLabelInferred && !this.hasExplicitAriaLabel) {
485
+ const currentAttr = this.root.getAttribute("aria-label");
486
+ if (currentAttr === this.lastInferredAriaLabel) {
487
+ const nextLabel = this.t("gallery");
488
+ this.root.setAttribute("aria-label", nextLabel);
489
+ this.lastInferredAriaLabel = nextLabel;
490
+ this.options.ariaLabel = nextLabel;
491
+ }
492
+ }
493
+ }
293
494
  /**
294
495
  * Configure les variables CSS de transition sur le conteneur.
295
496
  */
@@ -396,6 +597,7 @@ var Wulf = (() => {
396
597
  */
397
598
  layout() {
398
599
  if (this.isDestroyed) return;
600
+ this.syncAccessibilityLabels();
399
601
  if (this.isNativeCSSGrid) {
400
602
  this.options.onLayout([]);
401
603
  return;
@@ -410,10 +612,16 @@ var Wulf = (() => {
410
612
  this.root.classList.remove("wulf-masonry--fit-width");
411
613
  }
412
614
  const stagger = this.options.stagger;
615
+ const usePercent = this.options.percentPosition && result.containerWidth > 0;
413
616
  for (let i = 0; i < result.positions.length; i++) {
414
617
  const pos = result.positions[i];
415
618
  const item = pos.element;
416
- item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
619
+ if (usePercent) {
620
+ const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
621
+ item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
622
+ } else {
623
+ item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
624
+ }
417
625
  item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
418
626
  item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
419
627
  if (stagger > 0) {
@@ -533,7 +741,7 @@ var Wulf = (() => {
533
741
  if (this.wasRoleInferred && this.root.getAttribute("role") === this.options.ariaRole) {
534
742
  this.root.removeAttribute("role");
535
743
  }
536
- if (this.wasAriaLabelInferred && this.root.getAttribute("aria-label") === this.options.ariaLabel) {
744
+ if (this.wasAriaLabelInferred && this.root.getAttribute("aria-label") === this.lastInferredAriaLabel) {
537
745
  this.root.removeAttribute("aria-label");
538
746
  }
539
747
  this.root.style.removeProperty("--wulf-masonry-duration");
@@ -557,6 +765,8 @@ var Wulf = (() => {
557
765
  this._items = [];
558
766
  }
559
767
  };
768
+ Masonry._i18n = masonryI18n;
769
+ Masonry.i18n = masonryI18n;
560
770
 
561
771
  // src/masonry/index.ts
562
772
  var index_default = Masonry;
@@ -566,7 +776,8 @@ var Wulf = (() => {
566
776
  win.Wulf = wulfNamespace;
567
777
  wulfNamespace.Masonry = Object.assign(Masonry, {
568
778
  Masonry,
569
- LayoutEngine
779
+ LayoutEngine,
780
+ i18n: masonryI18n
570
781
  });
571
782
  }
572
783
  return __toCommonJS(index_exports);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/masonry/index.ts", "../src/masonry/LayoutEngine.ts", "../src/masonry/Masonry.ts"],
4
- "sourcesContent": ["import { Masonry } from './Masonry';\nimport { LayoutEngine } from './LayoutEngine';\n\nexport * from './types';\nexport * from './LayoutEngine';\nexport * from './Masonry';\n\nexport { Masonry, LayoutEngine };\nexport default Masonry;\n\n// Attachement namespace global dans les environnements de navigation (IIFE / Vanilla)\nif (typeof window !== 'undefined') {\n const win = window as unknown as Record<string, unknown>;\n const wulfNamespace = ((win.Wulf as Record<string, unknown>) || {}) as Record<string, unknown>;\n win.Wulf = wulfNamespace;\n\n // Namespace sp\u00E9cifique et exclusif \u00E0 la librairie Masonry : Wulf.Masonry\n wulfNamespace.Masonry = Object.assign(Masonry, {\n Masonry,\n LayoutEngine\n });\n}\n", "import { MasonryGutter, MasonryItemPosition, MasonryOptions } from './types';\n\nexport interface LayoutCalculationResult {\n cols: number;\n colWidth: number;\n gutterX: number;\n gutterY: number;\n containerHeight: number;\n containerWidth: number;\n fittedWidth?: number;\n positions: MasonryItemPosition[];\n}\n\nexport class LayoutEngine {\n /**\n * Normalise les goutti\u00E8res horizontales et verticales.\n */\n public static parseGutter(gutterOption?: number | MasonryGutter): MasonryGutter {\n if (typeof gutterOption === 'number') {\n return { x: Math.max(0, gutterOption), y: Math.max(0, gutterOption) };\n }\n if (gutterOption && typeof gutterOption === 'object') {\n return {\n x: Math.max(0, Number(gutterOption.x) || 0),\n y: Math.max(0, Number(gutterOption.y) || 0)\n };\n }\n return { x: 0, y: 0 };\n }\n\n /**\n * R\u00E9sout la largeur effective d'une colonne en pixels.\n */\n public static resolveColumnWidth(\n container: HTMLElement,\n firstItem: HTMLElement | null,\n columnWidthOption?: number | string | HTMLElement\n ): number {\n if (typeof columnWidthOption === 'number' && columnWidthOption > 0) {\n return columnWidthOption;\n }\n\n if (typeof columnWidthOption === 'string') {\n const el = container.querySelector<HTMLElement>(columnWidthOption);\n if (el) {\n const w = el.getBoundingClientRect().width;\n if (w > 0) return w;\n }\n const parsed = parseFloat(columnWidthOption);\n if (!isNaN(parsed) && parsed > 0) {\n if (columnWidthOption.endsWith('%')) {\n const containerW = container.getBoundingClientRect().width;\n return (containerW * parsed) / 100;\n }\n return parsed;\n }\n }\n\n if (columnWidthOption instanceof HTMLElement) {\n const w = columnWidthOption.getBoundingClientRect().width;\n if (w > 0) return w;\n }\n\n if (firstItem) {\n const w = firstItem.getBoundingClientRect().width;\n if (w > 0) return w;\n }\n\n const containerW = container.getBoundingClientRect().width;\n return containerW > 0 ? containerW : 200;\n }\n\n /**\n * Extrait le facteur d'\u00E9talement (span) d'un item sur plusieurs colonnes.\n */\n public static getItemSpan(item: HTMLElement, colWidth: number, gutterX: number, maxCols: number): number {\n const dataSpan = item.getAttribute('data-masonry-span') || item.dataset.masonrySpan;\n if (dataSpan) {\n const parsed = parseInt(dataSpan, 10);\n if (!isNaN(parsed) && parsed > 0) {\n return Math.min(maxCols, parsed);\n }\n }\n\n // D\u00E9tection par classe utilitaire (ex: span-2, col-span-2)\n const match = item.className.match(/(?:^|\\s)(?:span|col-span)-(\\d+)(?:\\s|$)/);\n if (match && match[1]) {\n const parsed = parseInt(match[1], 10);\n if (!isNaN(parsed) && parsed > 0) {\n return Math.min(maxCols, parsed);\n }\n }\n\n return 1;\n }\n\n /**\n * Calcule les positions optimales de tous les items.\n */\n public static calculate(\n container: HTMLElement,\n items: HTMLElement[],\n options: MasonryOptions\n ): LayoutCalculationResult {\n const containerRect = container.getBoundingClientRect();\n const containerWidth = containerRect.width;\n const { x: gutterX, y: gutterY } = this.parseGutter(options.gutter);\n\n if (containerWidth <= 0 || items.length === 0) {\n return {\n cols: 1,\n colWidth: containerWidth,\n gutterX,\n gutterY,\n containerHeight: 0,\n containerWidth,\n positions: []\n };\n }\n\n const firstItem = items[0] || null;\n let colWidth = this.resolveColumnWidth(container, firstItem, options.columnWidth);\n\n // Calcul du nombre de colonnes possibles\n // (cols * colWidth) + (cols - 1) * gutterX <= containerWidth\n let cols = Math.floor((containerWidth + gutterX) / (colWidth + gutterX));\n cols = Math.max(1, cols);\n\n // Si percentPosition ou fitWidth, ajustement pr\u00E9cis de la largeur de colonne pour remplir l'espace\n if (!options.columnWidth && cols > 1) {\n colWidth = (containerWidth - (cols - 1) * gutterX) / cols;\n }\n\n const fittedWidth = options.fitWidth ? cols * colWidth + (cols - 1) * gutterX : undefined;\n\n // Tableau de suivi des hauteurs cumul\u00E9es pour chaque colonne\n const colHeights = new Array(cols).fill(0);\n const positions: MasonryItemPosition[] = [];\n\n // Mesure par lot pr\u00E9alable (Batch Read) de toutes les hauteurs d'items pour \u00E9viter le layout thrashing\n const itemHeights = items.map((item) => {\n // Si l'\u00E9l\u00E9ment a d\u00E9j\u00E0 une hauteur calcul\u00E9e\n const h = item.getBoundingClientRect().height;\n return h > 0 ? h : 50;\n });\n\n let currentHCol = 0; // Pointeur pour le mode horizontalOrder\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const itemH = itemHeights[i];\n const span = this.getItemSpan(item, colWidth, gutterX, cols);\n\n let targetCol = 0;\n let targetY = 0;\n\n if (options.horizontalOrder) {\n // Mode respectant l'ordre naturel gauche -> droite\n if (currentHCol + span > cols) {\n currentHCol = 0;\n }\n targetCol = currentHCol;\n\n // Calcul de la hauteur maximale sous le span requis\n let maxY = 0;\n for (let s = 0; s < span; s++) {\n if (colHeights[targetCol + s] > maxY) {\n maxY = colHeights[targetCol + s];\n }\n }\n targetY = maxY;\n currentHCol = (targetCol + span) % cols;\n } else {\n // Mode shortest-column classique (optimisation de tassement)\n if (span === 1) {\n let minH = colHeights[0];\n targetCol = 0;\n for (let c = 1; c < cols; c++) {\n if (colHeights[c] < minH) {\n minH = colHeights[c];\n targetCol = c;\n }\n }\n targetY = minH;\n } else {\n // Pour un item multi-colonnes, trouve le groupe de colonnes cons\u00E9cutives dont le max est minimal\n let bestMax = Infinity;\n targetCol = 0;\n for (let c = 0; c <= cols - span; c++) {\n let maxInSpan = 0;\n for (let s = 0; s < span; s++) {\n if (colHeights[c + s] > maxInSpan) {\n maxInSpan = colHeights[c + s];\n }\n }\n if (maxInSpan < bestMax) {\n bestMax = maxInSpan;\n targetCol = c;\n }\n }\n targetY = bestMax;\n }\n }\n\n const itemW = span * colWidth + (span - 1) * gutterX;\n const targetX = targetCol * (colWidth + gutterX);\n\n positions.push({\n element: item,\n x: targetX,\n y: targetY,\n width: itemW,\n height: itemH,\n column: targetCol,\n span\n });\n\n // Mise \u00E0 jour des hauteurs pour toutes les colonnes occup\u00E9es par ce span\n const nextY = targetY + itemH + gutterY;\n for (let s = 0; s < span; s++) {\n colHeights[targetCol + s] = nextY;\n }\n }\n\n // Hauteur totale du conteneur (la plus haute colonne, moins la derni\u00E8re marge)\n let maxColH = 0;\n for (let c = 0; c < cols; c++) {\n if (colHeights[c] > maxColH) {\n maxColH = colHeights[c];\n }\n }\n const containerHeight = Math.max(0, maxColH > 0 ? maxColH - gutterY : 0);\n\n return {\n cols,\n colWidth,\n gutterX,\n gutterY,\n containerHeight,\n containerWidth,\n fittedWidth,\n positions\n };\n }\n}\n", "import { IMasonry, MasonryItemPosition, MasonryOptions } from './types';\nimport { LayoutEngine } from './LayoutEngine';\n\nexport class Masonry implements IMasonry {\n public readonly root: HTMLElement;\n public readonly isNativeCSSGrid: boolean = false;\n private _items: HTMLElement[] = [];\n private options: Required<MasonryOptions>;\n\n private resizeObserver: ResizeObserver | null = null;\n private itemResizeObserver: ResizeObserver | null = null;\n private layoutRafId: number | null = null;\n private isDestroyed: boolean = false;\n private wasRoleInferred: boolean = false;\n private wasAriaLabelInferred: boolean = false;\n private removeTimers: Set<number> = new Set();\n private pendingImageListeners: Array<{ img: HTMLImageElement; handler: () => void }> = [];\n\n private originalContainerStyles: {\n height: string;\n width: string;\n };\n\n constructor(target: HTMLElement | string, options: MasonryOptions = {}) {\n if (typeof target === 'string') {\n const el = document.querySelector<HTMLElement>(target);\n if (!el) {\n throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\u00E9lecteur : \"${target}\"`);\n }\n this.root = el;\n } else if (target instanceof HTMLElement) {\n this.root = target;\n } else {\n throw new Error('[Wulf.Masonry] Cible invalide : fournissez un \u00E9l\u00E9ment HTMLElement ou un s\u00E9lecteur valide.');\n }\n\n // Sauvegarde des styles initiaux pour destruction propre\n this.originalContainerStyles = {\n height: this.root.style.height,\n width: this.root.style.width\n };\n\n // Fusion avec les options par d\u00E9faut\n this.options = {\n itemSelector: options.itemSelector || '> *',\n columnWidth: options.columnWidth ?? 0,\n gutter: options.gutter ?? 0,\n percentPosition: options.percentPosition !== false,\n fitWidth: Boolean(options.fitWidth),\n horizontalOrder: Boolean(options.horizontalOrder),\n transitionDuration: options.transitionDuration !== undefined ? options.transitionDuration : 300,\n stagger: options.stagger || 0,\n resize: options.resize !== false,\n autoImages: options.autoImages !== false,\n useNativeCSSGrid: options.useNativeCSSGrid !== false,\n ariaRole: options.ariaRole || 'region',\n ariaLabel: options.ariaLabel || 'Galerie en grille asym\u00E9trique',\n onLayout: options.onLayout || (() => {}),\n onItemPlaced: options.onItemPlaced || (() => {})\n };\n\n // D\u00E9tection de la compatibilit\u00E9 CSS Grid Level 3 masonry\n const supportsNativeCSS =\n typeof CSS !== 'undefined' &&\n typeof CSS.supports === 'function' &&\n CSS.supports('grid-template-rows', 'masonry');\n\n if (this.options.useNativeCSSGrid && supportsNativeCSS) {\n this.isNativeCSSGrid = true;\n this.root.classList.add('wulf-masonry', 'wulf-masonry--native');\n } else {\n this.root.classList.add('wulf-masonry');\n }\n\n this.initAccessibility();\n this.applyTransitionDuration();\n this.reloadItems();\n this.initObservers();\n this.initImages();\n\n // Premier calcul de disposition\n this.layout();\n }\n\n public get items(): HTMLElement[] {\n return [...this._items];\n }\n\n /**\n * Initialise les attributs WAI-ARIA du conteneur.\n */\n private initAccessibility(): void {\n if (this.options.ariaRole && !this.root.hasAttribute('role')) {\n this.root.setAttribute('role', this.options.ariaRole);\n this.wasRoleInferred = true;\n }\n if (this.options.ariaLabel && !this.root.hasAttribute('aria-label')) {\n this.root.setAttribute('aria-label', this.options.ariaLabel);\n this.wasAriaLabelInferred = true;\n }\n }\n\n /**\n * Configure les variables CSS de transition sur le conteneur.\n */\n private applyTransitionDuration(): void {\n const dur = this.options.transitionDuration;\n const durValue = typeof dur === 'number' ? `${dur}ms` : dur;\n this.root.style.setProperty('--wulf-masonry-duration', durValue);\n }\n\n /**\n * R\u00E9indexe les \u00E9l\u00E9ments enfants cibl\u00E9s par la disposition.\n */\n public reloadItems(): void {\n if (this.isDestroyed) return;\n\n let matched: HTMLElement[] = [];\n if (this.options.itemSelector === '> *') {\n matched = Array.from(this.root.children).filter(\n (el): el is HTMLElement => el instanceof HTMLElement && !el.hasAttribute('data-masonry-ignore')\n );\n } else {\n try {\n matched = Array.from(this.root.querySelectorAll<HTMLElement>(this.options.itemSelector)).filter(\n (el) => el.parentElement === this.root && !el.hasAttribute('data-masonry-ignore')\n );\n } catch {\n matched = Array.from(this.root.children).filter(\n (el): el is HTMLElement => el instanceof HTMLElement && !el.hasAttribute('data-masonry-ignore')\n );\n }\n }\n\n this._items = matched;\n\n // Association de la classe d'item et observation\n for (const item of this._items) {\n item.classList.add('wulf-masonry-item');\n if (this.itemResizeObserver) {\n this.itemResizeObserver.observe(item);\n }\n }\n }\n\n /**\n * Active ResizeObserver sur le conteneur et les \u00E9l\u00E9ments individuels.\n */\n private initObservers(): void {\n if (!this.options.resize || typeof ResizeObserver === 'undefined') return;\n\n // Surveillance de la largeur du conteneur\n let prevWidth = this.root.getBoundingClientRect().width;\n this.resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const currentWidth = entry.contentRect.width;\n if (Math.abs(currentWidth - prevWidth) >= 1) {\n prevWidth = currentWidth;\n this.scheduleLayout();\n }\n }\n });\n this.resizeObserver.observe(this.root);\n\n // Surveillance des changements de hauteur internes des items\n this.itemResizeObserver = new ResizeObserver(() => {\n this.scheduleLayout();\n });\n\n for (const item of this._items) {\n this.itemResizeObserver.observe(item);\n }\n }\n\n /**\n * D\u00E9tecte les balises <img> sans dimensions pr\u00E9d\u00E9finies et attend leur d\u00E9codage/chargement.\n */\n private initImages(): void {\n if (!this.options.autoImages) return;\n\n const images = Array.from(this.root.querySelectorAll<HTMLImageElement>('img'));\n for (const img of images) {\n if (!img.complete) {\n const attachLoadListener = () => {\n const onLoad = () => {\n this.pendingImageListeners = this.pendingImageListeners.filter((l) => l.handler !== onLoad);\n if (!this.isDestroyed) this.scheduleLayout();\n };\n this.pendingImageListeners.push({ img, handler: onLoad });\n img.addEventListener('load', onLoad, { once: true });\n };\n\n if (typeof img.decode === 'function') {\n img.decode().then(() => {\n if (!this.isDestroyed) this.scheduleLayout();\n }).catch(() => {\n attachLoadListener();\n });\n } else {\n attachLoadListener();\n }\n }\n }\n }\n\n /**\n * Planifie un recalcul au prochain tick d'animation via requestAnimationFrame.\n */\n private scheduleLayout(): void {\n if (this.isDestroyed) return;\n if (this.layoutRafId !== null) {\n cancelAnimationFrame(this.layoutRafId);\n }\n this.layoutRafId = requestAnimationFrame(() => {\n this.layoutRafId = null;\n this.layout();\n });\n }\n\n /**\n * Calcule et applique les nouvelles coordonn\u00E9es GPU de chaque item.\n */\n public layout(): void {\n if (this.isDestroyed) return;\n\n // Si d\u00E9l\u00E9gation native CSS active, pas de positionnement JS requis\n if (this.isNativeCSSGrid) {\n this.options.onLayout([]);\n return;\n }\n\n this.root.setAttribute('aria-busy', 'true');\n\n // \u00C9tape 1 : Lecture group\u00E9e (Batch Read via LayoutEngine)\n const result = LayoutEngine.calculate(this.root, this._items, this.options);\n\n // \u00C9tape 2 : \u00C9criture group\u00E9e (Batch Write)\n this.root.style.height = `${result.containerHeight}px`;\n\n if (this.options.fitWidth && result.fittedWidth !== undefined) {\n this.root.style.width = `${result.fittedWidth}px`;\n this.root.classList.add('wulf-masonry--fit-width');\n } else {\n this.root.classList.remove('wulf-masonry--fit-width');\n }\n\n const stagger = this.options.stagger;\n\n for (let i = 0; i < result.positions.length; i++) {\n const pos = result.positions[i];\n const item = pos.element;\n\n item.style.setProperty('--wulf-masonry-w', `${pos.width}px`);\n item.style.setProperty('--wulf-masonry-x', `${pos.x}px`);\n item.style.setProperty('--wulf-masonry-y', `${pos.y}px`);\n\n if (stagger > 0) {\n item.style.transitionDelay = `${i * stagger}ms`;\n } else {\n item.style.removeProperty('transition-delay');\n }\n\n item.classList.remove('wulf-masonry-item--hidden');\n this.options.onItemPlaced(item, pos);\n }\n\n this.root.setAttribute('aria-busy', 'false');\n this.options.onLayout(result.positions);\n }\n\n /**\n * Ajoute de nouveaux \u00E9l\u00E9ments \u00E0 la fin du conteneur.\n */\n public append(elements: HTMLElement | HTMLElement[]): void {\n if (this.isDestroyed) return;\n const list = Array.isArray(elements) ? elements : [elements];\n if (list.length === 0) return;\n\n const frag = document.createDocumentFragment();\n for (const el of list) {\n el.classList.add('wulf-masonry-item', 'wulf-masonry-item--hidden');\n frag.appendChild(el);\n }\n this.root.appendChild(frag);\n\n this.reloadItems();\n this.initImages();\n this.layout();\n }\n\n /**\n * Ajoute de nouveaux \u00E9l\u00E9ments au d\u00E9but du conteneur.\n */\n public prepend(elements: HTMLElement | HTMLElement[]): void {\n if (this.isDestroyed) return;\n const list = Array.isArray(elements) ? elements : [elements];\n if (list.length === 0) return;\n\n const first = this.root.firstChild;\n const frag = document.createDocumentFragment();\n for (const el of list) {\n el.classList.add('wulf-masonry-item', 'wulf-masonry-item--hidden');\n frag.appendChild(el);\n }\n this.root.insertBefore(frag, first);\n\n this.reloadItems();\n this.initImages();\n this.layout();\n }\n\n /**\n * Supprime des \u00E9l\u00E9ments avec animation de fondu/sortie.\n */\n public remove(elements: HTMLElement | HTMLElement[]): void {\n if (this.isDestroyed) return;\n const list = Array.isArray(elements) ? elements : [elements];\n if (list.length === 0) return;\n\n for (const el of list) {\n el.classList.add('wulf-masonry-item--hidden');\n }\n\n const dur = typeof this.options.transitionDuration === 'number' ? this.options.transitionDuration : 300;\n\n if (dur <= 0) {\n for (const el of list) {\n if (el.parentElement === this.root) {\n if (this.itemResizeObserver) {\n this.itemResizeObserver.unobserve(el);\n }\n this.root.removeChild(el);\n }\n }\n this.reloadItems();\n this.layout();\n return;\n }\n\n const timerId = window.setTimeout(() => {\n this.removeTimers.delete(timerId);\n if (this.isDestroyed) return;\n for (const el of list) {\n if (el.parentElement === this.root) {\n if (this.itemResizeObserver) {\n this.itemResizeObserver.unobserve(el);\n }\n this.root.removeChild(el);\n }\n }\n this.reloadItems();\n this.layout();\n }, dur);\n this.removeTimers.add(timerId);\n }\n\n /**\n * Lib\u00E8re les ressources, d\u00E9connecte les observateurs et nettoie les styles inject\u00E9s.\n */\n public destroy(): void {\n if (this.isDestroyed) return;\n this.isDestroyed = true;\n\n for (const timerId of this.removeTimers) {\n clearTimeout(timerId);\n }\n this.removeTimers.clear();\n\n for (const { img, handler } of this.pendingImageListeners) {\n img.removeEventListener('load', handler);\n }\n this.pendingImageListeners = [];\n\n if (this.layoutRafId !== null) {\n cancelAnimationFrame(this.layoutRafId);\n this.layoutRafId = null;\n }\n\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = null;\n }\n\n if (this.itemResizeObserver) {\n this.itemResizeObserver.disconnect();\n this.itemResizeObserver = null;\n }\n\n // Nettoyage des classes et attributs sur le conteneur\n this.root.classList.remove('wulf-masonry', 'wulf-masonry--native', 'wulf-masonry--fit-width');\n this.root.removeAttribute('aria-busy');\n if (this.wasRoleInferred && this.root.getAttribute('role') === this.options.ariaRole) {\n this.root.removeAttribute('role');\n }\n if (this.wasAriaLabelInferred && this.root.getAttribute('aria-label') === this.options.ariaLabel) {\n this.root.removeAttribute('aria-label');\n }\n this.root.style.removeProperty('--wulf-masonry-duration');\n\n if (this.originalContainerStyles.height) {\n this.root.style.height = this.originalContainerStyles.height;\n } else {\n this.root.style.removeProperty('height');\n }\n\n if (this.originalContainerStyles.width) {\n this.root.style.width = this.originalContainerStyles.width;\n } else {\n this.root.style.removeProperty('width');\n }\n\n // Nettoyage des styles sur les items\n for (const item of this._items) {\n item.classList.remove('wulf-masonry-item', 'wulf-masonry-item--hidden');\n item.style.removeProperty('--wulf-masonry-w');\n item.style.removeProperty('--wulf-masonry-x');\n item.style.removeProperty('--wulf-masonry-y');\n item.style.removeProperty('transition-delay');\n }\n\n this._items = [];\n }\n}\n\nexport default Masonry;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,MAAM,eAAN,MAAmB;AAAA;AAAA;AAAA;AAAA,IAIxB,OAAc,YAAY,cAAsD;AAC9E,UAAI,OAAO,iBAAiB,UAAU;AACpC,eAAO,EAAE,GAAG,KAAK,IAAI,GAAG,YAAY,GAAG,GAAG,KAAK,IAAI,GAAG,YAAY,EAAE;AAAA,MACtE;AACA,UAAI,gBAAgB,OAAO,iBAAiB,UAAU;AACpD,eAAO;AAAA,UACL,GAAG,KAAK,IAAI,GAAG,OAAO,aAAa,CAAC,KAAK,CAAC;AAAA,UAC1C,GAAG,KAAK,IAAI,GAAG,OAAO,aAAa,CAAC,KAAK,CAAC;AAAA,QAC5C;AAAA,MACF;AACA,aAAO,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,IACtB;AAAA;AAAA;AAAA;AAAA,IAKA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F,WAAK,KAAK,gBAAgB,WAAW;AACrC,UAAI,KAAK,mBAAmB,KAAK,KAAK,aAAa,MAAM,MAAM,KAAK,QAAQ,UAAU;AACpF,aAAK,KAAK,gBAAgB,MAAM;AAAA,MAClC;AACA,UAAI,KAAK,wBAAwB,KAAK,KAAK,aAAa,YAAY,MAAM,KAAK,QAAQ,WAAW;AAChG,aAAK,KAAK,gBAAgB,YAAY;AAAA,MACxC;AACA,WAAK,KAAK,MAAM,eAAe,yBAAyB;AAExD,UAAI,KAAK,wBAAwB,QAAQ;AACvC,aAAK,KAAK,MAAM,SAAS,KAAK,wBAAwB;AAAA,MACxD,OAAO;AACL,aAAK,KAAK,MAAM,eAAe,QAAQ;AAAA,MACzC;AAEA,UAAI,KAAK,wBAAwB,OAAO;AACtC,aAAK,KAAK,MAAM,QAAQ,KAAK,wBAAwB;AAAA,MACvD,OAAO;AACL,aAAK,KAAK,MAAM,eAAe,OAAO;AAAA,MACxC;AAGA,iBAAW,QAAQ,KAAK,QAAQ;AAC9B,aAAK,UAAU,OAAO,qBAAqB,2BAA2B;AACtE,aAAK,MAAM,eAAe,kBAAkB;AAC5C,aAAK,MAAM,eAAe,kBAAkB;AAC5C,aAAK,MAAM,eAAe,kBAAkB;AAC5C,aAAK,MAAM,eAAe,kBAAkB;AAAA,MAC9C;AAEA,WAAK,SAAS,CAAC;AAAA,IACjB;AAAA,EACF;;;AF9ZA,MAAO,gBAAQ;AAGf,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,MAAM;AACZ,UAAM,gBAAkB,IAAI,QAAoC,CAAC;AACjE,QAAI,OAAO;AAGX,kBAAc,UAAU,OAAO,OAAO,SAAS;AAAA,MAC7C;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;",
3
+ "sources": ["../src/masonry/index.ts", "../src/masonry/LayoutEngine.ts", "../src/common/LocalizedComponent.ts", "../src/common/i18n.ts", "../src/masonry/i18n/fr.ts", "../src/masonry/i18n/en.ts", "../src/masonry/i18n/index.ts", "../src/masonry/Masonry.ts"],
4
+ "sourcesContent": ["import { Masonry } from './Masonry';\nimport { LayoutEngine } from './LayoutEngine';\nimport { masonryI18n } from './i18n';\n\nexport * from './types';\nexport * from './LayoutEngine';\nexport * from './Masonry';\nexport * from './i18n';\n\nexport { Masonry, LayoutEngine };\nexport default Masonry;\n\n// Attachement namespace global dans les environnements de navigation (IIFE / Vanilla)\nif (typeof window !== 'undefined') {\n const win = window as unknown as Record<string, unknown>;\n const wulfNamespace = ((win.Wulf as Record<string, unknown>) || {}) as Record<string, unknown>;\n win.Wulf = wulfNamespace;\n\n // Namespace sp\u00E9cifique et exclusif \u00E0 la librairie Masonry : Wulf.Masonry\n wulfNamespace.Masonry = Object.assign(Masonry, {\n Masonry,\n LayoutEngine,\n i18n: masonryI18n\n });\n}\n", "import { MasonryGutter, MasonryItemPosition, MasonryOptions } from './types';\n\nexport interface LayoutCalculationResult {\n cols: number;\n colWidth: number;\n gutterX: number;\n gutterY: number;\n containerHeight: number;\n containerWidth: number;\n fittedWidth?: number;\n positions: MasonryItemPosition[];\n}\n\nexport class LayoutEngine {\n /**\n * Normalise les goutti\u00E8res horizontales et verticales.\n */\n public static parseGutter(gutterOption?: number | MasonryGutter): MasonryGutter {\n if (typeof gutterOption === 'number') {\n return { x: Math.max(0, gutterOption), y: Math.max(0, gutterOption) };\n }\n if (gutterOption && typeof gutterOption === 'object') {\n return {\n x: Math.max(0, Number(gutterOption.x) || 0),\n y: Math.max(0, Number(gutterOption.y) || 0)\n };\n }\n return { x: 0, y: 0 };\n }\n\n /**\n * R\u00E9sout la largeur effective d'une colonne en pixels.\n */\n public static resolveColumnWidth(\n container: HTMLElement,\n firstItem: HTMLElement | null,\n columnWidthOption?: number | string | HTMLElement\n ): number {\n if (typeof columnWidthOption === 'number' && columnWidthOption > 0) {\n return columnWidthOption;\n }\n\n if (typeof columnWidthOption === 'string') {\n const el = container.querySelector<HTMLElement>(columnWidthOption);\n if (el) {\n const w = el.getBoundingClientRect().width;\n if (w > 0) return w;\n }\n const parsed = parseFloat(columnWidthOption);\n if (!isNaN(parsed) && parsed > 0) {\n if (columnWidthOption.endsWith('%')) {\n const containerW = container.getBoundingClientRect().width;\n return (containerW * parsed) / 100;\n }\n return parsed;\n }\n }\n\n if (columnWidthOption instanceof HTMLElement) {\n const w = columnWidthOption.getBoundingClientRect().width;\n if (w > 0) return w;\n }\n\n if (firstItem) {\n const w = firstItem.getBoundingClientRect().width;\n if (w > 0) return w;\n }\n\n const containerW = container.getBoundingClientRect().width;\n return containerW > 0 ? containerW : 200;\n }\n\n /**\n * Extrait le facteur d'\u00E9talement (span) d'un item sur plusieurs colonnes.\n */\n public static getItemSpan(item: HTMLElement, colWidth: number, gutterX: number, maxCols: number): number {\n const dataSpan = item.getAttribute('data-masonry-span') || item.dataset.masonrySpan;\n if (dataSpan) {\n const parsed = parseInt(dataSpan, 10);\n if (!isNaN(parsed) && parsed > 0) {\n return Math.min(maxCols, parsed);\n }\n }\n\n // D\u00E9tection par classe utilitaire (ex: span-2, col-span-2)\n const match = item.className.match(/(?:^|\\s)(?:span|col-span)-(\\d+)(?:\\s|$)/);\n if (match && match[1]) {\n const parsed = parseInt(match[1], 10);\n if (!isNaN(parsed) && parsed > 0) {\n return Math.min(maxCols, parsed);\n }\n }\n\n return 1;\n }\n\n /**\n * Calcule les positions optimales de tous les items.\n */\n public static calculate(\n container: HTMLElement,\n items: HTMLElement[],\n options: MasonryOptions\n ): LayoutCalculationResult {\n const containerRect = container.getBoundingClientRect();\n const containerWidth = containerRect.width;\n const { x: gutterX, y: gutterY } = this.parseGutter(options.gutter);\n\n if (containerWidth <= 0 || items.length === 0) {\n return {\n cols: 1,\n colWidth: containerWidth,\n gutterX,\n gutterY,\n containerHeight: 0,\n containerWidth,\n positions: []\n };\n }\n\n const firstItem = items[0] || null;\n let colWidth = this.resolveColumnWidth(container, firstItem, options.columnWidth);\n\n // Calcul du nombre de colonnes possibles\n // (cols * colWidth) + (cols - 1) * gutterX <= containerWidth\n let cols = Math.floor((containerWidth + gutterX) / (colWidth + gutterX));\n cols = Math.max(1, cols);\n\n // Si percentPosition ou fitWidth, ajustement pr\u00E9cis de la largeur de colonne pour remplir l'espace\n if (!options.columnWidth && cols > 1) {\n colWidth = (containerWidth - (cols - 1) * gutterX) / cols;\n }\n\n const fittedWidth = options.fitWidth ? cols * colWidth + (cols - 1) * gutterX : undefined;\n\n // Tableau de suivi des hauteurs cumul\u00E9es pour chaque colonne\n const colHeights = new Array(cols).fill(0);\n const positions: MasonryItemPosition[] = [];\n\n // Mesure par lot pr\u00E9alable (Batch Read) de toutes les hauteurs d'items pour \u00E9viter le layout thrashing\n const itemHeights = items.map((item) => {\n // Si l'\u00E9l\u00E9ment a d\u00E9j\u00E0 une hauteur calcul\u00E9e\n const h = item.getBoundingClientRect().height;\n return h > 0 ? h : 50;\n });\n\n let currentHCol = 0; // Pointeur pour le mode horizontalOrder\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const itemH = itemHeights[i];\n const span = this.getItemSpan(item, colWidth, gutterX, cols);\n\n let targetCol = 0;\n let targetY = 0;\n\n if (options.horizontalOrder) {\n // Mode respectant l'ordre naturel gauche -> droite\n if (currentHCol + span > cols) {\n currentHCol = 0;\n }\n targetCol = currentHCol;\n\n // Calcul de la hauteur maximale sous le span requis\n let maxY = 0;\n for (let s = 0; s < span; s++) {\n if (colHeights[targetCol + s] > maxY) {\n maxY = colHeights[targetCol + s];\n }\n }\n targetY = maxY;\n currentHCol = (targetCol + span) % cols;\n } else {\n // Mode shortest-column classique (optimisation de tassement)\n if (span === 1) {\n let minH = colHeights[0];\n targetCol = 0;\n for (let c = 1; c < cols; c++) {\n if (colHeights[c] < minH) {\n minH = colHeights[c];\n targetCol = c;\n }\n }\n targetY = minH;\n } else {\n // Pour un item multi-colonnes, trouve le groupe de colonnes cons\u00E9cutives dont le max est minimal\n let bestMax = Infinity;\n targetCol = 0;\n for (let c = 0; c <= cols - span; c++) {\n let maxInSpan = 0;\n for (let s = 0; s < span; s++) {\n if (colHeights[c + s] > maxInSpan) {\n maxInSpan = colHeights[c + s];\n }\n }\n if (maxInSpan < bestMax) {\n bestMax = maxInSpan;\n targetCol = c;\n }\n }\n targetY = bestMax;\n }\n }\n\n const itemW = span * colWidth + (span - 1) * gutterX;\n const targetX = targetCol * (colWidth + gutterX);\n\n positions.push({\n element: item,\n x: targetX,\n y: targetY,\n width: itemW,\n height: itemH,\n column: targetCol,\n span\n });\n\n // Mise \u00E0 jour des hauteurs pour toutes les colonnes occup\u00E9es par ce span\n const nextY = targetY + itemH + gutterY;\n for (let s = 0; s < span; s++) {\n colHeights[targetCol + s] = nextY;\n }\n }\n\n // Hauteur totale du conteneur (la plus haute colonne, moins la derni\u00E8re marge)\n let maxColH = 0;\n for (let c = 0; c < cols; c++) {\n if (colHeights[c] > maxColH) {\n maxColH = colHeights[c];\n }\n }\n const containerHeight = Math.max(0, maxColH > 0 ? maxColH - gutterY : 0);\n\n return {\n cols,\n colWidth,\n gutterX,\n gutterY,\n containerHeight,\n containerWidth,\n fittedWidth,\n positions\n };\n }\n}\n", "import { I18nManager } from './i18n';\n\n/**\n * Classe de base abstraite factorisant l'ensemble des m\u00E9thodes statiques\n * de localisation et l'initialisation des surcharges d'instance pour tout composant.\n */\nexport abstract class LocalizedComponent<TI18n extends object = any> {\n protected static _i18n: I18nManager<any>;\n\n /**\n * D\u00E9finit la langue globale du composant (ex: 'fr', 'en', 'es').\n */\n public static setLocale(locale: string): void {\n if (this._i18n) {\n this._i18n.setLocale(locale);\n }\n }\n\n /**\n * Retourne la langue globale active du composant.\n */\n public static getLocale(): string {\n return this._i18n ? this._i18n.getLocale() : '';\n }\n\n /**\n * Enregistre un dictionnaire de traduction pour une langue donn\u00E9e.\n */\n public static registerLocale<T extends object>(\n this: { _i18n: I18nManager<T> },\n locale: string,\n translations: Partial<T>\n ): void {\n if (this._i18n) {\n this._i18n.registerLocale(locale, translations);\n }\n }\n\n /**\n * Surcharge les libell\u00E9s globalement pour ce composant.\n */\n public static setI18n<T extends object>(\n this: { _i18n: I18nManager<T> },\n overrides: Partial<T>\n ): void {\n if (this._i18n) {\n this._i18n.setI18n(overrides);\n }\n }\n\n /**\n * Retourne l'ensemble des libell\u00E9s actifs r\u00E9solus du composant.\n */\n public static getI18n<T extends object>(this: { _i18n: I18nManager<T> }): T {\n return this._i18n ? this._i18n.getAll() : ({} as T);\n }\n\n /**\n * R\u00E9initialise les r\u00E9glages de langue et surcharges globales.\n */\n public static resetI18n(): void {\n if (this._i18n) {\n this._i18n.reset();\n }\n }\n\n /**\n * R\u00E9sout une cl\u00E9 au niveau statique de la classe.\n */\n public static t<T extends object>(\n this: { _i18n: I18nManager<T> },\n key: keyof T,\n instanceOverride?: Partial<T>\n ): string {\n return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);\n }\n\n /**\n * Surcharges de localisation sp\u00E9cifiques \u00E0 cette instance.\n */\n protected i18nOverrides?: Partial<TI18n>;\n\n constructor(i18nOverrides?: Partial<TI18n>) {\n this.i18nOverrides = i18nOverrides;\n }\n\n /**\n * Traduit une cl\u00E9 en tenant compte automatiquement des surcharges de l'instance courante.\n */\n protected t(key: keyof TI18n): string {\n const ctor = this.constructor as typeof LocalizedComponent;\n return ctor._i18n ? ctor._i18n.t(key as any, this.i18nOverrides) : String(key);\n }\n}\n\n", "/**\n * Micro-moteur i18n g\u00E9n\u00E9rique, ultra-l\u00E9ger et modulaire.\n * Con\u00E7u pour \u00EAtre r\u00E9utilis\u00E9 ind\u00E9pendamment par chaque librairie (tree-shaking et isolation totale).\n */\n\nexport interface I18nManager<T> {\n /**\n * D\u00E9finit la langue active (ex: 'fr', 'en', 'es').\n */\n setLocale(locale: string): void;\n\n /**\n * Renvoie la langue active courante.\n */\n getLocale(): string;\n\n /**\n * Enregistre ou met \u00E0 jour les traductions pour une langue donn\u00E9e.\n */\n registerLocale(locale: string, translations: Partial<T>): void;\n\n /**\n * Applique des surcharges globales prioritaires sur les libell\u00E9s actuels.\n */\n setI18n(overrides: Partial<T>): void;\n\n /**\n * R\u00E9sout une cl\u00E9 de traduction en cascade :\n * 1. Surcharge d'instance locale\n * 2. Surcharges globales (setI18n)\n * 3. Dictionnaire de la langue active\n * 4. Dictionnaire de repli (fallbackLocale)\n */\n t(key: keyof T, instanceOverride?: Partial<T>): string;\n\n /**\n * Renvoie l'int\u00E9gralit\u00E9 du dictionnaire r\u00E9solu.\n */\n getAll(instanceOverride?: Partial<T>): T;\n\n /**\n * R\u00E9initialise l'\u00E9tat aux r\u00E9glages initiaux (langue de base, sans surcharges).\n */\n reset(): void;\n}\n\nfunction normalizeLocaleCode(locale: string): string {\n return locale.trim().toLowerCase().replace(/_/g, '-');\n}\n\nfunction getPrimaryLanguage(normalizedLocale: string): string | null {\n const dashIndex = normalizedLocale.indexOf('-');\n return dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;\n}\n\nfunction assignDefined<T extends object>(target: Partial<T>, source?: Partial<T>): Partial<T> {\n if (!source) return target;\n for (const key of Object.keys(source) as Array<keyof T>) {\n if (source[key] !== undefined) {\n target[key] = source[key];\n }\n }\n return target;\n}\n\nexport function createI18nManager<T extends object>(\n defaultLocale: string,\n locales: Record<string, T>\n): I18nManager<T> {\n const fallbackLocale = normalizeLocaleCode(defaultLocale);\n const initialLocales: Record<string, T> = {};\n for (const [loc, dict] of Object.entries(locales)) {\n initialLocales[normalizeLocaleCode(loc)] = { ...dict };\n }\n\n let currentLocale = fallbackLocale;\n let activeLocales: Record<string, Partial<T>> = { ...initialLocales };\n let globalOverrides: Partial<T> = {};\n\n function resolveActiveDictionaries(): Array<Partial<T>> {\n const dicts: Array<Partial<T>> = [];\n const exact = activeLocales[currentLocale];\n if (exact) dicts.push(exact);\n\n const primary = getPrimaryLanguage(currentLocale);\n if (primary && activeLocales[primary]) {\n dicts.push(activeLocales[primary]);\n }\n return dicts;\n }\n\n return {\n setLocale(locale: string): void {\n if (locale && locale.trim()) {\n currentLocale = normalizeLocaleCode(locale);\n }\n },\n\n getLocale(): string {\n return currentLocale;\n },\n\n registerLocale(locale: string, translations: Partial<T>): void {\n if (!locale || !locale.trim() || !translations) return;\n const norm = normalizeLocaleCode(locale);\n activeLocales[norm] = assignDefined({ ...(activeLocales[norm] || {}) }, translations);\n },\n\n setI18n(overrides: Partial<T>): void {\n if (!overrides) return;\n globalOverrides = assignDefined({ ...globalOverrides }, overrides);\n },\n\n t(key: keyof T, instanceOverride?: Partial<T>): string {\n // 1. Priorit\u00E9 instance\n if (instanceOverride && instanceOverride[key] !== undefined) {\n return String(instanceOverride[key]);\n }\n\n // 2. Priorit\u00E9 surcharge globale\n if (globalOverrides[key] !== undefined) {\n return String(globalOverrides[key]);\n }\n\n // 3. Langue active (exacte ex: 'en-us', puis primaire ex: 'en')\n for (const dict of resolveActiveDictionaries()) {\n if (dict[key] !== undefined) {\n return String(dict[key]);\n }\n }\n\n // 4. Langue de repli (fallback)\n const fallbackDict = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];\n if (fallbackDict && fallbackDict[key] !== undefined) {\n return String(fallbackDict[key]);\n }\n\n return String(key);\n },\n\n getAll(instanceOverride ?: Partial<T>): T {\n const result: Partial<T> = {};\n const fallback = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];\n assignDefined(result, fallback);\n\n // Du moins sp\u00E9cifique (langue primaire) au plus sp\u00E9cifique (locale exacte)\n const activeDicts = resolveActiveDictionaries().reverse();\n for (const dict of activeDicts) {\n assignDefined(result, dict);\n }\n\n assignDefined(result, globalOverrides);\n assignDefined(result, instanceOverride);\n return result as T;\n },\n\n reset(): void {\n currentLocale = fallbackLocale;\n globalOverrides = {};\n activeLocales = {};\n for(const [loc, dict] of Object.entries(initialLocales)) {\n activeLocales[loc] = { ...dict };\n }\n }\n };\n}\n", "import { MasonryI18n } from './types';\n\nexport const masonryFr: MasonryI18n = {\n gallery: 'Galerie en grille asym\u00E9trique'\n};\n\n", "import { MasonryI18n } from './types';\n\nexport const masonryEn: MasonryI18n = {\n gallery: 'Masonry grid gallery'\n};\n\n", "import { createI18nManager, I18nManager } from '../../common/i18n';\nimport { LocalizedComponent } from '../../common/LocalizedComponent';\nimport { MasonryI18n } from './types';\nimport { masonryFr } from './fr';\nimport { masonryEn } from './en';\n\nexport type { I18nManager };\nexport { createI18nManager, LocalizedComponent };\nexport * from './types';\nexport * from './fr';\nexport * from './en';\n\nexport const masonryI18n: I18nManager<MasonryI18n> = createI18nManager<MasonryI18n>('fr', {\n fr: masonryFr,\n en: masonryEn\n});\n\n", "import { IMasonry, MasonryOptions } from './types';\nimport { LayoutEngine } from './LayoutEngine';\nimport { LocalizedComponent } from '../common/LocalizedComponent';\nimport { masonryI18n, MasonryI18n } from './i18n';\n\nexport class Masonry extends LocalizedComponent<MasonryI18n> implements IMasonry {\n protected static override _i18n = masonryI18n;\n public static readonly i18n = masonryI18n;\n\n public readonly root: HTMLElement;\n public readonly isNativeCSSGrid: boolean = false;\n private _items: HTMLElement[] = [];\n private options: Required<MasonryOptions>;\n\n private resizeObserver: ResizeObserver | null = null;\n private itemResizeObserver: ResizeObserver | null = null;\n private layoutRafId: number | null = null;\n private isDestroyed: boolean = false;\n private wasRoleInferred: boolean = false;\n private wasAriaLabelInferred: boolean = false;\n private hasExplicitAriaLabel: boolean = false;\n private lastInferredAriaLabel: string = '';\n private removeTimers: Set<number> = new Set();\n private pendingImageListeners: Array<{ img: HTMLImageElement; handler: () => void }> = [];\n\n private originalContainerStyles: {\n height: string;\n width: string;\n };\n\n constructor(target: HTMLElement | string, options: MasonryOptions = {}) {\n super(options.i18n);\n\n if (typeof target === 'string') {\n const el = document.querySelector<HTMLElement>(target);\n if (!el) {\n throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\u00E9lecteur : \"${target}\"`);\n }\n this.root = el;\n } else if (target instanceof HTMLElement) {\n this.root = target;\n } else {\n throw new Error('[Wulf.Masonry] Cible invalide : fournissez un \u00E9l\u00E9ment HTMLElement ou un s\u00E9lecteur valide.');\n }\n\n // Sauvegarde des styles initiaux pour destruction propre\n this.originalContainerStyles = {\n height: this.root.style.height,\n width: this.root.style.width\n };\n\n this.hasExplicitAriaLabel = Boolean(options.ariaLabel);\n\n // Fusion avec les options par d\u00E9faut\n this.options = {\n itemSelector: options.itemSelector || '> *',\n columnWidth: options.columnWidth ?? 0,\n gutter: options.gutter ?? 0,\n percentPosition: Boolean(options.percentPosition),\n fitWidth: Boolean(options.fitWidth),\n horizontalOrder: Boolean(options.horizontalOrder),\n transitionDuration: options.transitionDuration !== undefined ? options.transitionDuration : 300,\n stagger: options.stagger || 0,\n resize: options.resize !== false,\n autoImages: options.autoImages !== false,\n useNativeCSSGrid: options.useNativeCSSGrid !== false,\n ariaRole: options.ariaRole || 'region',\n ariaLabel: options.ariaLabel || this.t('gallery'),\n i18n: options.i18n || {},\n onLayout: options.onLayout || (() => { }),\n onItemPlaced: options.onItemPlaced || (() => { })\n };\n\n // D\u00E9tection de la compatibilit\u00E9 CSS Grid Level 3 masonry\n const supportsNativeCSS =\n typeof CSS !== 'undefined' &&\n typeof CSS.supports === 'function' &&\n CSS.supports('grid-template-rows', 'masonry');\n\n if (this.options.useNativeCSSGrid && supportsNativeCSS) {\n this.isNativeCSSGrid = true;\n this.root.classList.add('wulf-masonry', 'wulf-masonry--native');\n } else {\n this.root.classList.add('wulf-masonry');\n }\n\n this.initAccessibility();\n this.applyTransitionDuration();\n this.reloadItems();\n this.initObservers();\n this.initImages();\n\n // Premier calcul de disposition\n this.layout();\n }\n\n public get items(): HTMLElement[] {\n return [...this._items];\n }\n\n /**\n * Initialise les attributs WAI-ARIA du conteneur.\n */\n private initAccessibility(): void {\n if (this.options.ariaRole && !this.root.hasAttribute('role')) {\n this.root.setAttribute('role', this.options.ariaRole);\n this.wasRoleInferred = true;\n }\n const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t('gallery');\n if (label && !this.root.hasAttribute('aria-label')) {\n this.root.setAttribute('aria-label', label);\n this.lastInferredAriaLabel = label;\n this.wasAriaLabelInferred = true;\n }\n }\n\n /**\n * Synchronise dynamiquement le libell\u00E9 ARIA si la langue globale change apr\u00E8s montage.\n */\n private syncAccessibilityLabels(): void {\n if (this.wasAriaLabelInferred && !this.hasExplicitAriaLabel) {\n const currentAttr = this.root.getAttribute('aria-label');\n if (currentAttr === this.lastInferredAriaLabel) {\n const nextLabel = this.t('gallery');\n this.root.setAttribute('aria-label', nextLabel);\n this.lastInferredAriaLabel = nextLabel;\n this.options.ariaLabel = nextLabel;\n }\n }\n }\n\n /**\n * Configure les variables CSS de transition sur le conteneur.\n */\n private applyTransitionDuration(): void {\n const dur = this.options.transitionDuration;\n const durValue = typeof dur === 'number' ? `${dur}ms` : dur;\n this.root.style.setProperty('--wulf-masonry-duration', durValue);\n }\n\n /**\n * R\u00E9indexe les \u00E9l\u00E9ments enfants cibl\u00E9s par la disposition.\n */\n public reloadItems(): void {\n if (this.isDestroyed) return;\n\n let matched: HTMLElement[] = [];\n if (this.options.itemSelector === '> *') {\n matched = Array.from(this.root.children).filter(\n (el): el is HTMLElement => el instanceof HTMLElement && !el.hasAttribute('data-masonry-ignore')\n );\n } else {\n try {\n matched = Array.from(this.root.querySelectorAll<HTMLElement>(this.options.itemSelector)).filter(\n (el) => el.parentElement === this.root && !el.hasAttribute('data-masonry-ignore')\n );\n } catch {\n matched = Array.from(this.root.children).filter(\n (el): el is HTMLElement => el instanceof HTMLElement && !el.hasAttribute('data-masonry-ignore')\n );\n }\n }\n\n this._items = matched;\n\n // Association de la classe d'item et observation\n for (const item of this._items) {\n item.classList.add('wulf-masonry-item');\n if (this.itemResizeObserver) {\n this.itemResizeObserver.observe(item);\n }\n }\n }\n\n /**\n * Active ResizeObserver sur le conteneur et les \u00E9l\u00E9ments individuels.\n */\n private initObservers(): void {\n if (!this.options.resize || typeof ResizeObserver === 'undefined') return;\n\n // Surveillance de la largeur du conteneur\n let prevWidth = this.root.getBoundingClientRect().width;\n this.resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const currentWidth = entry.contentRect.width;\n if (Math.abs(currentWidth - prevWidth) >= 1) {\n prevWidth = currentWidth;\n this.scheduleLayout();\n }\n }\n });\n this.resizeObserver.observe(this.root);\n\n // Surveillance des changements de hauteur internes des items\n this.itemResizeObserver = new ResizeObserver(() => {\n this.scheduleLayout();\n });\n\n for (const item of this._items) {\n this.itemResizeObserver.observe(item);\n }\n }\n\n /**\n * D\u00E9tecte les balises <img> sans dimensions pr\u00E9d\u00E9finies et attend leur d\u00E9codage/chargement.\n */\n private initImages(): void {\n if (!this.options.autoImages) return;\n\n const images = Array.from(this.root.querySelectorAll<HTMLImageElement>('img'));\n for (const img of images) {\n if (!img.complete) {\n const attachLoadListener = () => {\n const onLoad = () => {\n this.pendingImageListeners = this.pendingImageListeners.filter((l) => l.handler !== onLoad);\n if (!this.isDestroyed) this.scheduleLayout();\n };\n this.pendingImageListeners.push({ img, handler: onLoad });\n img.addEventListener('load', onLoad, { once: true });\n };\n\n if (typeof img.decode === 'function') {\n img.decode().then(() => {\n if (!this.isDestroyed) this.scheduleLayout();\n }).catch(() => {\n attachLoadListener();\n });\n } else {\n attachLoadListener();\n }\n }\n }\n }\n\n /**\n * Planifie un recalcul au prochain tick d'animation via requestAnimationFrame.\n */\n private scheduleLayout(): void {\n if (this.isDestroyed) return;\n if (this.layoutRafId !== null) {\n cancelAnimationFrame(this.layoutRafId);\n }\n this.layoutRafId = requestAnimationFrame(() => {\n this.layoutRafId = null;\n this.layout();\n });\n }\n\n /**\n * Calcule et applique les nouvelles coordonn\u00E9es GPU de chaque item.\n */\n public layout(): void {\n if (this.isDestroyed) return;\n\n this.syncAccessibilityLabels();\n\n // Si d\u00E9l\u00E9gation native CSS active, pas de positionnement JS requis\n if (this.isNativeCSSGrid) {\n this.options.onLayout([]);\n return;\n }\n\n this.root.setAttribute('aria-busy', 'true');\n\n // \u00C9tape 1 : Lecture group\u00E9e (Batch Read via LayoutEngine)\n const result = LayoutEngine.calculate(this.root, this._items, this.options);\n\n // \u00C9tape 2 : \u00C9criture group\u00E9e (Batch Write)\n this.root.style.height = `${result.containerHeight}px`;\n\n if (this.options.fitWidth && result.fittedWidth !== undefined) {\n this.root.style.width = `${result.fittedWidth}px`;\n this.root.classList.add('wulf-masonry--fit-width');\n } else {\n this.root.classList.remove('wulf-masonry--fit-width');\n }\n\n const stagger = this.options.stagger;\n const usePercent = this.options.percentPosition && result.containerWidth > 0;\n\n for (let i = 0; i < result.positions.length; i++) {\n const pos = result.positions[i];\n const item = pos.element;\n\n if (usePercent) {\n const wPct = Number(((pos.width / result.containerWidth) * 100).toFixed(4));\n item.style.setProperty('--wulf-masonry-w', `${wPct}%`);\n } else {\n item.style.setProperty('--wulf-masonry-w', `${pos.width}px`);\n }\n item.style.setProperty('--wulf-masonry-x', `${pos.x}px`);\n item.style.setProperty('--wulf-masonry-y', `${pos.y}px`);\n\n if (stagger > 0) {\n item.style.transitionDelay = `${i * stagger}ms`;\n } else {\n item.style.removeProperty('transition-delay');\n }\n\n item.classList.remove('wulf-masonry-item--hidden');\n this.options.onItemPlaced(item, pos);\n }\n\n this.root.setAttribute('aria-busy', 'false');\n this.options.onLayout(result.positions);\n }\n\n /**\n * Ajoute de nouveaux \u00E9l\u00E9ments \u00E0 la fin du conteneur.\n */\n public append(elements: HTMLElement | HTMLElement[]): void {\n if (this.isDestroyed) return;\n const list = Array.isArray(elements) ? elements : [elements];\n if (list.length === 0) return;\n\n const frag = document.createDocumentFragment();\n for (const el of list) {\n el.classList.add('wulf-masonry-item', 'wulf-masonry-item--hidden');\n frag.appendChild(el);\n }\n this.root.appendChild(frag);\n\n this.reloadItems();\n this.initImages();\n this.layout();\n }\n\n /**\n * Ajoute de nouveaux \u00E9l\u00E9ments au d\u00E9but du conteneur.\n */\n public prepend(elements: HTMLElement | HTMLElement[]): void {\n if (this.isDestroyed) return;\n const list = Array.isArray(elements) ? elements : [elements];\n if (list.length === 0) return;\n\n const first = this.root.firstChild;\n const frag = document.createDocumentFragment();\n for (const el of list) {\n el.classList.add('wulf-masonry-item', 'wulf-masonry-item--hidden');\n frag.appendChild(el);\n }\n this.root.insertBefore(frag, first);\n\n this.reloadItems();\n this.initImages();\n this.layout();\n }\n\n /**\n * Supprime des \u00E9l\u00E9ments avec animation de fondu/sortie.\n */\n public remove(elements: HTMLElement | HTMLElement[]): void {\n if (this.isDestroyed) return;\n const list = Array.isArray(elements) ? elements : [elements];\n if (list.length === 0) return;\n\n for (const el of list) {\n el.classList.add('wulf-masonry-item--hidden');\n }\n\n const dur = typeof this.options.transitionDuration === 'number' ? this.options.transitionDuration : 300;\n\n if (dur <= 0) {\n for (const el of list) {\n if (el.parentElement === this.root) {\n if (this.itemResizeObserver) {\n this.itemResizeObserver.unobserve(el);\n }\n this.root.removeChild(el);\n }\n }\n this.reloadItems();\n this.layout();\n return;\n }\n\n const timerId = window.setTimeout(() => {\n this.removeTimers.delete(timerId);\n if (this.isDestroyed) return;\n for (const el of list) {\n if (el.parentElement === this.root) {\n if (this.itemResizeObserver) {\n this.itemResizeObserver.unobserve(el);\n }\n this.root.removeChild(el);\n }\n }\n this.reloadItems();\n this.layout();\n }, dur);\n this.removeTimers.add(timerId);\n }\n\n /**\n * Lib\u00E8re les ressources, d\u00E9connecte les observateurs et nettoie les styles inject\u00E9s.\n */\n public destroy(): void {\n if (this.isDestroyed) return;\n this.isDestroyed = true;\n\n for (const timerId of this.removeTimers) {\n clearTimeout(timerId);\n }\n this.removeTimers.clear();\n\n for (const { img, handler } of this.pendingImageListeners) {\n img.removeEventListener('load', handler);\n }\n this.pendingImageListeners = [];\n\n if (this.layoutRafId !== null) {\n cancelAnimationFrame(this.layoutRafId);\n this.layoutRafId = null;\n }\n\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = null;\n }\n\n if (this.itemResizeObserver) {\n this.itemResizeObserver.disconnect();\n this.itemResizeObserver = null;\n }\n\n // Nettoyage des classes et attributs sur le conteneur\n this.root.classList.remove('wulf-masonry', 'wulf-masonry--native', 'wulf-masonry--fit-width');\n this.root.removeAttribute('aria-busy');\n if (this.wasRoleInferred && this.root.getAttribute('role') === this.options.ariaRole) {\n this.root.removeAttribute('role');\n }\n if (this.wasAriaLabelInferred && this.root.getAttribute('aria-label') === this.lastInferredAriaLabel) {\n this.root.removeAttribute('aria-label');\n }\n this.root.style.removeProperty('--wulf-masonry-duration');\n\n if (this.originalContainerStyles.height) {\n this.root.style.height = this.originalContainerStyles.height;\n } else {\n this.root.style.removeProperty('height');\n }\n\n if (this.originalContainerStyles.width) {\n this.root.style.width = this.originalContainerStyles.width;\n } else {\n this.root.style.removeProperty('width');\n }\n\n // Nettoyage des styles sur les items\n for (const item of this._items) {\n item.classList.remove('wulf-masonry-item', 'wulf-masonry-item--hidden');\n item.style.removeProperty('--wulf-masonry-w');\n item.style.removeProperty('--wulf-masonry-x');\n item.style.removeProperty('--wulf-masonry-y');\n item.style.removeProperty('transition-delay');\n }\n\n this._items = [];\n }\n }\n\nexport default Masonry;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,MAAM,eAAN,MAAmB;AAAA;AAAA;AAAA;AAAA,IAIxB,OAAc,YAAY,cAAsD;AAC9E,UAAI,OAAO,iBAAiB,UAAU;AACpC,eAAO,EAAE,GAAG,KAAK,IAAI,GAAG,YAAY,GAAG,GAAG,KAAK,IAAI,GAAG,YAAY,EAAE;AAAA,MACtE;AACA,UAAI,gBAAgB,OAAO,iBAAiB,UAAU;AACpD,eAAO;AAAA,UACL,GAAG,KAAK,IAAI,GAAG,OAAO,aAAa,CAAC,KAAK,CAAC;AAAA,UAC1C,GAAG,KAAK,IAAI,GAAG,OAAO,aAAa,CAAC,KAAK,CAAC;AAAA,QAC5C;AAAA,MACF;AACA,aAAO,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,IACtB;AAAA;AAAA;AAAA;AAAA,IAKA,OAAc,mBACZ,WACA,WACA,mBACQ;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BAAuB;AACpG,aAAK,KAAK,gBAAgB,YAAY;AAAA,MACxC;AACA,WAAK,KAAK,MAAM,eAAe,yBAAyB;AAExD,UAAI,KAAK,wBAAwB,QAAQ;AACvC,aAAK,KAAK,MAAM,SAAS,KAAK,wBAAwB;AAAA,MACxD,OAAO;AACL,aAAK,KAAK,MAAM,eAAe,QAAQ;AAAA,MACzC;AAEA,UAAI,KAAK,wBAAwB,OAAO;AACtC,aAAK,KAAK,MAAM,QAAQ,KAAK,wBAAwB;AAAA,MACvD,OAAO;AACL,aAAK,KAAK,MAAM,eAAe,OAAO;AAAA,MACxC;AAGA,iBAAW,QAAQ,KAAK,QAAQ;AAC9B,aAAK,UAAU,OAAO,qBAAqB,2BAA2B;AACtE,aAAK,MAAM,eAAe,kBAAkB;AAC5C,aAAK,MAAM,eAAe,kBAAkB;AAC5C,aAAK,MAAM,eAAe,kBAAkB;AAC5C,aAAK,MAAM,eAAe,kBAAkB;AAAA,MAC9C;AAEA,WAAK,SAAS,CAAC;AAAA,IACjB;AAAA,EACF;AArcA,EADW,QACe,QAAQ;AAClC,EAFW,QAEY,OAAO;;;APGhC,MAAO,gBAAQ;AAGf,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,MAAM;AACZ,UAAM,gBAAkB,IAAI,QAAoC,CAAC;AACjE,QAAI,OAAO;AAGX,kBAAc,UAAU,OAAO,OAAO,SAAS;AAAA,MAC7C;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACR,CAAC;AAAA,EACH;",
6
6
  "names": ["containerW"]
7
7
  }
@@ -1,3 +1,3 @@
1
- "use strict";var Wulf=(()=>{var R=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var N=(u,t)=>{for(var e in t)R(u,e,{get:t[e],enumerable:!0})},G=(u,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of P(t))!O.call(u,s)&&s!==e&&R(u,s,{get:()=>t[s],enumerable:!(r=W(t,s))||r.enumerable});return u};var B=u=>G(R({},"__esModule",{value:!0}),u);var _={};N(_,{LayoutEngine:()=>p,Masonry:()=>b,default:()=>$});var p=class{static parseGutter(t){return typeof t=="number"?{x:Math.max(0,t),y:Math.max(0,t)}:t&&typeof t=="object"?{x:Math.max(0,Number(t.x)||0),y:Math.max(0,Number(t.y)||0)}:{x:0,y:0}}static resolveColumnWidth(t,e,r){if(typeof r=="number"&&r>0)return r;if(typeof r=="string"){let i=t.querySelector(r);if(i){let n=i.getBoundingClientRect().width;if(n>0)return n}let o=parseFloat(r);if(!isNaN(o)&&o>0)return r.endsWith("%")?t.getBoundingClientRect().width*o/100:o}if(r instanceof HTMLElement){let i=r.getBoundingClientRect().width;if(i>0)return i}if(e){let i=e.getBoundingClientRect().width;if(i>0)return i}let s=t.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(t,e,r,s){let i=t.getAttribute("data-masonry-span")||t.dataset.masonrySpan;if(i){let n=parseInt(i,10);if(!isNaN(n)&&n>0)return Math.min(s,n)}let o=t.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(o&&o[1]){let n=parseInt(o[1],10);if(!isNaN(n)&&n>0)return Math.min(s,n)}return 1}static calculate(t,e,r){let i=t.getBoundingClientRect().width,{x:o,y:n}=this.parseGutter(r.gutter);if(i<=0||e.length===0)return{cols:1,colWidth:i,gutterX:o,gutterY:n,containerHeight:0,containerWidth:i,positions:[]};let C=e[0]||null,y=this.resolveColumnWidth(t,C,r.columnWidth),l=Math.floor((i+o)/(y+o));l=Math.max(1,l),!r.columnWidth&&l>1&&(y=(i-(l-1)*o)/l);let T=r.fitWidth?l*y+(l-1)*o:void 0,f=new Array(l).fill(0),S=[],A=e.map(m=>{let g=m.getBoundingClientRect().height;return g>0?g:50}),w=0;for(let m=0;m<e.length;m++){let g=e[m],H=A[m],c=this.getItemSpan(g,y,o,l),d=0,v=0;if(r.horizontalOrder){w+c>l&&(w=0),d=w;let h=0;for(let a=0;a<c;a++)f[d+a]>h&&(h=f[d+a]);v=h,w=(d+c)%l}else if(c===1){let h=f[0];d=0;for(let a=1;a<l;a++)f[a]<h&&(h=f[a],d=a);v=h}else{let h=1/0;d=0;for(let a=0;a<=l-c;a++){let M=0;for(let I=0;I<c;I++)f[a+I]>M&&(M=f[a+I]);M<h&&(h=M,d=a)}v=h}let x=c*y+(c-1)*o,z=d*(y+o);S.push({element:g,x:z,y:v,width:x,height:H,column:d,span:c});let D=v+H+n;for(let h=0;h<c;h++)f[d+h]=D}let L=0;for(let m=0;m<l;m++)f[m]>L&&(L=f[m]);let E=Math.max(0,L>0?L-n:0);return{cols:l,colWidth:y,gutterX:o,gutterY:n,containerHeight:E,containerWidth:i,fittedWidth:T,positions:S}}};var b=class{constructor(t,e={}){this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof t=="string"){let s=document.querySelector(t);if(!s)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=s}else if(t instanceof HTMLElement)this.root=t;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.options={itemSelector:e.itemSelector||"> *",columnWidth:e.columnWidth??0,gutter:e.gutter??0,percentPosition:e.percentPosition!==!1,fitWidth:!!e.fitWidth,horizontalOrder:!!e.horizontalOrder,transitionDuration:e.transitionDuration!==void 0?e.transitionDuration:300,stagger:e.stagger||0,resize:e.resize!==!1,autoImages:e.autoImages!==!1,useNativeCSSGrid:e.useNativeCSSGrid!==!1,ariaRole:e.ariaRole||"region",ariaLabel:e.ariaLabel||"Galerie en grille asym\xE9trique",onLayout:e.onLayout||(()=>{}),onItemPlaced:e.onItemPlaced||(()=>{})};let r=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&r?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout()}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0),this.options.ariaLabel&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",this.options.ariaLabel),this.wasAriaLabelInferred=!0)}applyTransitionDuration(){let t=this.options.transitionDuration,e=typeof t=="number"?`${t}ms`:t;this.root.style.setProperty("--wulf-masonry-duration",e)}reloadItems(){if(this.isDestroyed)return;let t=[];if(this.options.itemSelector==="> *")t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"));else try{t=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(e=>e.parentElement===this.root&&!e.hasAttribute("data-masonry-ignore"))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(e)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let r of e){let s=r.contentRect.width;Math.abs(s-t)>=1&&(t=s,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e)}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete){let r=()=>{let s=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(i=>i.handler!==s),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:e,handler:s}),e.addEventListener("load",s,{once:!0})};typeof e.decode=="function"?e.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{r()}):r()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let t=p.calculate(this.root,this._items,this.options);this.root.style.height=`${t.containerHeight}px`,this.options.fitWidth&&t.fittedWidth!==void 0?(this.root.style.width=`${t.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let e=this.options.stagger;for(let r=0;r<t.positions.length;r++){let s=t.positions[r],i=s.element;i.style.setProperty("--wulf-masonry-w",`${s.width}px`),i.style.setProperty("--wulf-masonry-x",`${s.x}px`),i.style.setProperty("--wulf-masonry-y",`${s.y}px`),e>0?i.style.transitionDelay=`${r*e}ms`:i.style.removeProperty("transition-delay"),i.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(i,s)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(t.positions)}append(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let r=document.createDocumentFragment();for(let s of e)s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),r.appendChild(s);this.root.appendChild(r),this.reloadItems(),this.initImages(),this.layout()}prepend(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let r=this.root.firstChild,s=document.createDocumentFragment();for(let i of e)i.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(i);this.root.insertBefore(s,r),this.reloadItems(),this.initImages(),this.layout()}remove(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;for(let i of e)i.classList.add("wulf-masonry-item--hidden");let r=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(r<=0){for(let i of e)i.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(i),this.root.removeChild(i));this.reloadItems(),this.layout();return}let s=window.setTimeout(()=>{if(this.removeTimers.delete(s),!this.isDestroyed){for(let i of e)i.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(i),this.root.removeChild(i));this.reloadItems(),this.layout()}},r);this.removeTimers.add(s)}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let t of this.removeTimers)clearTimeout(t);this.removeTimers.clear();for(let{img:t,handler:e}of this.pendingImageListeners)t.removeEventListener("load",e);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.options.ariaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let t of this._items)t.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),t.style.removeProperty("--wulf-masonry-w"),t.style.removeProperty("--wulf-masonry-x"),t.style.removeProperty("--wulf-masonry-y"),t.style.removeProperty("transition-delay");this._items=[]}}};var $=b;if(typeof window<"u"){let u=window,t=u.Wulf||{};u.Wulf=t,t.Masonry=Object.assign(b,{Masonry:b,LayoutEngine:p})}return B(_);})();
1
+ "use strict";var Wulf=(()=>{var E=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var q=(h,i)=>{for(var e in i)E(h,e,{get:i[e],enumerable:!0})},k=(h,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of $(i))!F.call(h,n)&&n!==e&&E(h,n,{get:()=>i[n],enumerable:!(t=G(i,n))||t.enumerable});return h};var Y=h=>k(E({},"__esModule",{value:!0}),h);var J={};q(J,{LayoutEngine:()=>b,LocalizedComponent:()=>L,Masonry:()=>g,createI18nManager:()=>C,default:()=>V,masonryEn:()=>z,masonryFr:()=>H,masonryI18n:()=>w});var b=class{static parseGutter(i){return typeof i=="number"?{x:Math.max(0,i),y:Math.max(0,i)}:i&&typeof i=="object"?{x:Math.max(0,Number(i.x)||0),y:Math.max(0,Number(i.y)||0)}:{x:0,y:0}}static resolveColumnWidth(i,e,t){if(typeof t=="number"&&t>0)return t;if(typeof t=="string"){let r=i.querySelector(t);if(r){let a=r.getBoundingClientRect().width;if(a>0)return a}let s=parseFloat(t);if(!isNaN(s)&&s>0)return t.endsWith("%")?i.getBoundingClientRect().width*s/100:s}if(t instanceof HTMLElement){let r=t.getBoundingClientRect().width;if(r>0)return r}if(e){let r=e.getBoundingClientRect().width;if(r>0)return r}let n=i.getBoundingClientRect().width;return n>0?n:200}static getItemSpan(i,e,t,n){let r=i.getAttribute("data-masonry-span")||i.dataset.masonrySpan;if(r){let a=parseInt(r,10);if(!isNaN(a)&&a>0)return Math.min(n,a)}let s=i.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(s&&s[1]){let a=parseInt(s[1],10);if(!isNaN(a)&&a>0)return Math.min(n,a)}return 1}static calculate(i,e,t){let r=i.getBoundingClientRect().width,{x:s,y:a}=this.parseGutter(t.gutter);if(r<=0||e.length===0)return{cols:1,colWidth:r,gutterX:s,gutterY:a,containerHeight:0,containerWidth:r,positions:[]};let o=e[0]||null,c=this.resolveColumnWidth(i,o,t.columnWidth),l=Math.floor((r+s)/(c+s));l=Math.max(1,l),!t.columnWidth&&l>1&&(c=(r-(l-1)*s)/l);let v=t.fitWidth?l*c+(l-1)*s:void 0,d=new Array(l).fill(0),_=[],D=e.map(m=>{let T=m.getBoundingClientRect().height;return T>0?T:50}),x=0;for(let m=0;m<e.length;m++){let T=e[m],O=D[m],p=this.getItemSpan(T,c,s,l),y=0,M=0;if(t.horizontalOrder){x+p>l&&(x=0),y=x;let f=0;for(let u=0;u<p;u++)d[y+u]>f&&(f=d[y+u]);M=f,x=(y+p)%l}else if(p===1){let f=d[0];y=0;for(let u=1;u<l;u++)d[u]<f&&(f=d[u],y=u);M=f}else{let f=1/0;y=0;for(let u=0;u<=l-p;u++){let R=0;for(let S=0;S<p;S++)d[u+S]>R&&(R=d[u+S]);R<f&&(f=R,y=u)}M=f}let N=p*c+(p-1)*s,B=y*(c+s);_.push({element:T,x:B,y:M,width:N,height:O,column:y,span:p});let j=M+O+a;for(let f=0;f<p;f++)d[y+f]=j}let A=0;for(let m=0;m<l;m++)d[m]>A&&(A=d[m]);let W=Math.max(0,A>0?A-a:0);return{cols:l,colWidth:c,gutterX:s,gutterY:a,containerHeight:W,containerWidth:r,fittedWidth:v,positions:_}}};var L=class{static setLocale(i){this._i18n&&this._i18n.setLocale(i)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(i,e){this._i18n&&this._i18n.registerLocale(i,e)}static setI18n(i){this._i18n&&this._i18n.setI18n(i)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(i,e){return this._i18n?this._i18n.t(i,e):String(i)}constructor(i){this.i18nOverrides=i}t(i){let e=this.constructor;return e._i18n?e._i18n.t(i,this.i18nOverrides):String(i)}};function P(h){return h.trim().toLowerCase().replace(/_/g,"-")}function X(h){let i=h.indexOf("-");return i>0?h.slice(0,i):null}function I(h,i){if(!i)return h;for(let e of Object.keys(i))i[e]!==void 0&&(h[e]=i[e]);return h}function C(h,i){let e=P(h),t={};for(let[o,c]of Object.entries(i))t[P(o)]={...c};let n=e,r={...t},s={};function a(){let o=[],c=r[n];c&&o.push(c);let l=X(n);return l&&r[l]&&o.push(r[l]),o}return{setLocale(o){o&&o.trim()&&(n=P(o))},getLocale(){return n},registerLocale(o,c){if(!o||!o.trim()||!c)return;let l=P(o);r[l]=I({...r[l]||{}},c)},setI18n(o){o&&(s=I({...s},o))},t(o,c){if(c&&c[o]!==void 0)return String(c[o]);if(s[o]!==void 0)return String(s[o]);for(let v of a())if(v[o]!==void 0)return String(v[o]);let l=r[e]||t[e];return l&&l[o]!==void 0?String(l[o]):String(o)},getAll(o){let c={},l=r[e]||t[e];I(c,l);let v=a().reverse();for(let d of v)I(c,d);return I(c,s),I(c,o),c},reset(){n=e,s={},r={};for(let[o,c]of Object.entries(t))r[o]={...c}}}}var H={gallery:"Galerie en grille asym\xE9trique"};var z={gallery:"Masonry grid gallery"};var w=C("fr",{fr:H,en:z});var g=class extends L{constructor(e,t={}){super(t.i18n);this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${e}"`);this.root=r}else if(e instanceof HTMLElement)this.root=e;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.hasExplicitAriaLabel=!!t.ariaLabel,this.options={itemSelector:t.itemSelector||"> *",columnWidth:t.columnWidth??0,gutter:t.gutter??0,percentPosition:!!t.percentPosition,fitWidth:!!t.fitWidth,horizontalOrder:!!t.horizontalOrder,transitionDuration:t.transitionDuration!==void 0?t.transitionDuration:300,stagger:t.stagger||0,resize:t.resize!==!1,autoImages:t.autoImages!==!1,useNativeCSSGrid:t.useNativeCSSGrid!==!1,ariaRole:t.ariaRole||"region",ariaLabel:t.ariaLabel||this.t("gallery"),i18n:t.i18n||{},onLayout:t.onLayout||(()=>{}),onItemPlaced:t.onItemPlaced||(()=>{})};let n=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&n?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout()}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0);let e=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("gallery");e&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.wasAriaLabelInferred=!0)}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel){let t=this.t("gallery");this.root.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.options.ariaLabel=t}}applyTransitionDuration(){let e=this.options.transitionDuration,t=typeof e=="number"?`${e}ms`:e;this.root.style.setProperty("--wulf-masonry-duration",t)}reloadItems(){if(this.isDestroyed)return;let e=[];if(this.options.itemSelector==="> *")e=Array.from(this.root.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-masonry-ignore"));else try{e=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(t=>t.parentElement===this.root&&!t.hasAttribute("data-masonry-ignore"))}catch{e=Array.from(this.root.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-masonry-ignore"))}this._items=e;for(let t of this._items)t.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(t)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let e=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(t=>{for(let n of t){let r=n.contentRect.width;Math.abs(r-e)>=1&&(e=r,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let t of this._items)this.itemResizeObserver.observe(t)}initImages(){if(!this.options.autoImages)return;let e=Array.from(this.root.querySelectorAll("img"));for(let t of e)if(!t.complete){let n=()=>{let r=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(s=>s.handler!==r),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:t,handler:r}),t.addEventListener("load",r,{once:!0})};typeof t.decode=="function"?t.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{n()}):n()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.syncAccessibilityLabels(),this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let e=b.calculate(this.root,this._items,this.options);this.root.style.height=`${e.containerHeight}px`,this.options.fitWidth&&e.fittedWidth!==void 0?(this.root.style.width=`${e.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let t=this.options.stagger,n=this.options.percentPosition&&e.containerWidth>0;for(let r=0;r<e.positions.length;r++){let s=e.positions[r],a=s.element;if(n){let o=Number((s.width/e.containerWidth*100).toFixed(4));a.style.setProperty("--wulf-masonry-w",`${o}%`)}else a.style.setProperty("--wulf-masonry-w",`${s.width}px`);a.style.setProperty("--wulf-masonry-x",`${s.x}px`),a.style.setProperty("--wulf-masonry-y",`${s.y}px`),t>0?a.style.transitionDelay=`${r*t}ms`:a.style.removeProperty("transition-delay"),a.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(a,s)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(e.positions)}append(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;let n=document.createDocumentFragment();for(let r of t)r.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),n.appendChild(r);this.root.appendChild(n),this.reloadItems(),this.initImages(),this.layout()}prepend(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;let n=this.root.firstChild,r=document.createDocumentFragment();for(let s of t)s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),r.appendChild(s);this.root.insertBefore(r,n),this.reloadItems(),this.initImages(),this.layout()}remove(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;for(let s of t)s.classList.add("wulf-masonry-item--hidden");let n=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(n<=0){for(let s of t)s.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(s),this.root.removeChild(s));this.reloadItems(),this.layout();return}let r=window.setTimeout(()=>{if(this.removeTimers.delete(r),!this.isDestroyed){for(let s of t)s.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(s),this.root.removeChild(s));this.reloadItems(),this.layout()}},n);this.removeTimers.add(r)}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let e of this.removeTimers)clearTimeout(e);this.removeTimers.clear();for(let{img:e,handler:t}of this.pendingImageListeners)e.removeEventListener("load",t);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let e of this._items)e.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),e.style.removeProperty("--wulf-masonry-w"),e.style.removeProperty("--wulf-masonry-x"),e.style.removeProperty("--wulf-masonry-y"),e.style.removeProperty("transition-delay");this._items=[]}}};g._i18n=w,g.i18n=w;var V=g;if(typeof window<"u"){let h=window,i=h.Wulf||{};h.Wulf=i,i.Masonry=Object.assign(g,{Masonry:g,LayoutEngine:b,i18n:w})}return Y(J);})();
2
2
  if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
3
3
  //# sourceMappingURL=masonry.global.min.js.map