lighteningcards 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -15124,9 +15124,9 @@ class AbstractBitmapFont extends EventEmitter {
15124
15124
  /**
15125
15125
  * tiny-lru
15126
15126
  *
15127
- * @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
15127
+ * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
15128
15128
  * @license BSD-3-Clause
15129
- * @version 11.4.5
15129
+ * @version 11.4.7
15130
15130
  */
15131
15131
  /**
15132
15132
  * A high-performance Least Recently Used (LRU) cache implementation with optional TTL support.
@@ -15249,7 +15249,13 @@ class LRU {
15249
15249
  * @since 11.1.0
15250
15250
  */
15251
15251
  entries (keys = this.keys()) {
15252
- return keys.map(key => [key, this.get(key)]);
15252
+ const result = new Array(keys.length);
15253
+ for (let i = 0; i < keys.length; i++) {
15254
+ const key = keys[i];
15255
+ result[i] = [key, this.get(key)];
15256
+ }
15257
+
15258
+ return result;
15253
15259
  }
15254
15260
 
15255
15261
  /**
@@ -15426,11 +15432,12 @@ class LRU {
15426
15432
  * @since 9.0.0
15427
15433
  */
15428
15434
  keys () {
15429
- const result = [];
15435
+ const result = new Array(this.size);
15430
15436
  let x = this.first;
15437
+ let i = 0;
15431
15438
 
15432
15439
  while (x !== null) {
15433
- result.push(x.key);
15440
+ result[i++] = x.key;
15434
15441
  x = x.next;
15435
15442
  }
15436
15443
 
@@ -15559,7 +15566,12 @@ class LRU {
15559
15566
  * @since 11.1.0
15560
15567
  */
15561
15568
  values (keys = this.keys()) {
15562
- return keys.map(key => this.get(key));
15569
+ const result = new Array(keys.length);
15570
+ for (let i = 0; i < keys.length; i++) {
15571
+ result[i] = this.get(keys[i]);
15572
+ }
15573
+
15574
+ return result;
15563
15575
  }
15564
15576
  }
15565
15577
 
@@ -44197,12 +44209,6 @@ const useLightening = () => {
44197
44209
  animatedSprite.scale.set(spriteScale);
44198
44210
  animatedSprite.anchor.set(0.5);
44199
44211
  animatedSprite.allowChildren = true;
44200
-
44201
- // Position horizontally, centered
44202
- const totalWidth = (numCards - 1) * spacing;
44203
- animatedSprite.x = -totalWidth / 2 + i * spacing;
44204
- animatedSprite.y = 0; // Centered in container
44205
-
44206
44212
  animatedSprite.play();
44207
44213
 
44208
44214
  // Add multiplier text
@@ -44225,16 +44231,22 @@ const useLightening = () => {
44225
44231
 
44226
44232
  // Suit icon
44227
44233
  let suit_url = "";
44228
- switch ((_card$suit = card.suit) === null || _card$suit === void 0 ? void 0 : _card$suit.toLowerCase()) {
44234
+ const suit = (_card$suit = card.suit) === null || _card$suit === void 0 ? void 0 : _card$suit.toLowerCase();
44235
+ switch (suit) {
44229
44236
  case "hearts":
44237
+ case "heart":
44230
44238
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/SuitHearts.svg/60px-SuitHearts.svg.png";
44231
44239
  break;
44232
44240
  case "clubs":
44241
+ case "club":
44233
44242
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/SuitClubs.svg/60px-SuitClubs.svg.png";
44234
44243
  break;
44235
44244
  case "diamonds":
44245
+ case "diamond":
44236
44246
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/db/SuitDiamonds.svg/60px-SuitDiamonds.svg.png";
44237
44247
  break;
44248
+ case "spades":
44249
+ case "spade":
44238
44250
  default:
44239
44251
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/SuitSpades.svg/60px-SuitSpades.svg.png";
44240
44252
  break;
@@ -44264,18 +44276,36 @@ const useLightening = () => {
44264
44276
  suitContainer.addChild(card_suit_sprite);
44265
44277
  suitContainer.position.set(0, 35);
44266
44278
  animatedSprite.addChild(suitContainer);
44267
- return animatedSprite;
44279
+
44280
+ // Create container for this card with background
44281
+ const cardContainer = new Container();
44282
+
44283
+ // Load and add background sprite for this card
44284
+ try {
44285
+ const bg_tex = await Assets.load("/card_bg.svg");
44286
+ const bg_sprite = new Sprite(bg_tex);
44287
+ bg_sprite.scale.set(window.innerWidth < 768 ? 0.65 : 0.75);
44288
+ bg_sprite.anchor.set(0.5);
44289
+ bg_sprite.x = 0;
44290
+ bg_sprite.y = 0;
44291
+ cardContainer.addChild(bg_sprite);
44292
+ } catch (bgError) {
44293
+ // Background is optional, continue without it
44294
+ console.log("Background not found for card, continuing without it");
44295
+ }
44296
+
44297
+ // Add the animated sprite on top of background
44298
+ cardContainer.addChild(animatedSprite);
44299
+
44300
+ // Position the card container horizontally, centered
44301
+ const totalWidth = (numCards - 1) * spacing;
44302
+ cardContainer.x = -totalWidth / 2 + i * spacing;
44303
+ cardContainer.y = 0;
44304
+ return cardContainer;
44268
44305
  });
44269
44306
 
44270
44307
  // After all sprites are loaded, add them to the container and stage
44271
44308
  Promise.all(spritePromises).then(async sprites => {
44272
- const bg_tex = await Assets.load("/card_bg.svg");
44273
- const bg_sprite = new Sprite(bg_tex);
44274
- bg_sprite.scale.set(window.innerWidth < 768 ? 0.65 : 0.75);
44275
- bg_sprite.anchor.set(0.5);
44276
- bg_sprite.x = 0;
44277
- bg_sprite.y = 0;
44278
- cardsContainer.addChild(bg_sprite);
44279
44309
  cardsContainer.label = "card_container";
44280
44310
  sprites.forEach(sprite => cardsContainer.addChild(sprite));
44281
44311
  cardsContainer.x = this.appRef.current.renderer.width / 2;
@@ -44403,12 +44433,6 @@ const useLighteningStart = () => {
44403
44433
  animatedSprite.scale.set(spriteScale);
44404
44434
  animatedSprite.anchor.set(0.5);
44405
44435
  animatedSprite.allowChildren = true;
44406
-
44407
- // Position horizontally, centered
44408
- const totalWidth = (numCards - 1) * spacing;
44409
- animatedSprite.x = -totalWidth / 2 + i * spacing;
44410
- animatedSprite.y = 0; // Centered in container
44411
-
44412
44436
  animatedSprite.play();
44413
44437
 
44414
44438
  // Add multiplier text
@@ -44431,16 +44455,22 @@ const useLighteningStart = () => {
44431
44455
 
44432
44456
  // Suit icon
44433
44457
  let suit_url = "";
44434
- switch ((_card$suit = card.suit) === null || _card$suit === void 0 ? void 0 : _card$suit.toLowerCase()) {
44458
+ const suit = (_card$suit = card.suit) === null || _card$suit === void 0 ? void 0 : _card$suit.toLowerCase();
44459
+ switch (suit) {
44435
44460
  case "hearts":
44461
+ case "heart":
44436
44462
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/SuitHearts.svg/60px-SuitHearts.svg.png";
44437
44463
  break;
44438
44464
  case "clubs":
44465
+ case "club":
44439
44466
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/SuitClubs.svg/60px-SuitClubs.svg.png";
44440
44467
  break;
44441
44468
  case "diamonds":
44469
+ case "diamond":
44442
44470
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/db/SuitDiamonds.svg/60px-SuitDiamonds.svg.png";
44443
44471
  break;
44472
+ case "spades":
44473
+ case "spade":
44444
44474
  default:
44445
44475
  suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/SuitSpades.svg/60px-SuitSpades.svg.png";
44446
44476
  break;
@@ -44470,18 +44500,36 @@ const useLighteningStart = () => {
44470
44500
  suitContainer.addChild(card_suit_sprite);
44471
44501
  suitContainer.position.set(0, 35);
44472
44502
  animatedSprite.addChild(suitContainer);
44473
- return animatedSprite;
44503
+
44504
+ // Create container for this card with background
44505
+ const cardContainer = new Container();
44506
+
44507
+ // Load and add background sprite for this card
44508
+ try {
44509
+ const bg_tex = await Assets.load("/card_bg.svg");
44510
+ const bg_sprite = new Sprite(bg_tex);
44511
+ bg_sprite.scale.set(window.innerWidth < 768 ? 0.65 : 0.75);
44512
+ bg_sprite.anchor.set(0.5);
44513
+ bg_sprite.x = 0;
44514
+ bg_sprite.y = 0;
44515
+ cardContainer.addChild(bg_sprite);
44516
+ } catch (bgError) {
44517
+ // Background is optional, continue without it
44518
+ console.log("Background not found for card, continuing without it");
44519
+ }
44520
+
44521
+ // Add the animated sprite on top of background
44522
+ cardContainer.addChild(animatedSprite);
44523
+
44524
+ // Position the card container horizontally, centered
44525
+ const totalWidth = (numCards - 1) * spacing;
44526
+ cardContainer.x = -totalWidth / 2 + i * spacing;
44527
+ cardContainer.y = 0;
44528
+ return cardContainer;
44474
44529
  });
44475
44530
 
44476
44531
  // After all sprites are loaded, add them to the container and stage
44477
44532
  Promise.all(spritePromises).then(async sprites => {
44478
- const bg_tex = await Assets.load("/card_bg.svg");
44479
- const bg_sprite = new Sprite(bg_tex);
44480
- bg_sprite.scale.set(window.innerWidth < 768 ? 0.65 : 0.75);
44481
- bg_sprite.anchor.set(0.5);
44482
- bg_sprite.x = 0;
44483
- bg_sprite.y = 0;
44484
- cardsContainer.addChild(bg_sprite);
44485
44533
  cardsContainer.label = "card_container";
44486
44534
  sprites.forEach(sprite => cardsContainer.addChild(sprite));
44487
44535
  // Center the container in the canvas
@@ -44496,6 +44544,541 @@ const useLighteningStart = () => {
44496
44544
  };
44497
44545
  };
44498
44546
 
44547
+ /**
44548
+ * Generates SVG code for a baccarat card
44549
+ * @param {string} rank - The card rank (e.g., "A", "K", "Q", "J", "10", "9", etc.)
44550
+ * @param {string} suit - The card suit (e.g., "hearts", "diamonds", "clubs", "spades")
44551
+ * @param {number} width - Card width (default: 200)
44552
+ * @param {number} height - Card height (default: 280)
44553
+ * @returns {string} SVG code as a string
44554
+ */
44555
+ const generateBaccaratCardSVG = (rank, suit, width = 200, height = 280) => {
44556
+ // Format rank for display
44557
+ const formatRank = r => {
44558
+ if (!r) return "";
44559
+ const rankUpper = r.toUpperCase();
44560
+ const rankMap = {
44561
+ ACE: "A",
44562
+ KING: "K",
44563
+ QUEEN: "Q",
44564
+ JACK: "J",
44565
+ JOKER: "J"
44566
+ };
44567
+ return rankMap[rankUpper] || r;
44568
+ };
44569
+ const displayRank = formatRank(rank);
44570
+ const suitLower = (suit || "").toLowerCase();
44571
+
44572
+ // Get suit symbol/color
44573
+ const getSuitInfo = s => {
44574
+ switch (s) {
44575
+ case "hearts":
44576
+ case "heart":
44577
+ return {
44578
+ symbol: "♥",
44579
+ color: "#7a3030"
44580
+ };
44581
+ case "diamonds":
44582
+ case "diamond":
44583
+ return {
44584
+ symbol: "♦",
44585
+ color: "#7a3030"
44586
+ };
44587
+ case "clubs":
44588
+ case "club":
44589
+ return {
44590
+ symbol: "♣",
44591
+ color: "#756957"
44592
+ };
44593
+ case "spades":
44594
+ case "spade":
44595
+ return {
44596
+ symbol: "♠",
44597
+ color: "#756957"
44598
+ };
44599
+ default:
44600
+ return {
44601
+ symbol: "♠",
44602
+ color: "#756957"
44603
+ };
44604
+ }
44605
+ };
44606
+ const suitInfo = getSuitInfo(suitLower);
44607
+ const cornerRadius = 12; // Rounded corners
44608
+ const topBottomPadding = 12; // Top and bottom padding
44609
+ const leftRightPadding = 5; // Left and right padding from border
44610
+
44611
+ // Reduced font sizes to keep rank and suit inside the border
44612
+ const rankFontSize = 55; // Smaller rank size
44613
+ const suitFontSize = 55; // Smaller suit size
44614
+
44615
+ // Vertical offset - same for top and bottom
44616
+ const verticalOffset = 10;
44617
+ return `
44618
+ <svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
44619
+ <defs>
44620
+ <!-- Glow effect for border -->
44621
+ <filter id="glow">
44622
+ <feGaussianBlur stdDeviation="3" result="coloredBlur"/>
44623
+ <feMerge>
44624
+ <feMergeNode in="coloredBlur"/>
44625
+ <feMergeNode in="SourceGraphic"/>
44626
+ </feMerge>
44627
+ </filter>
44628
+ </defs>
44629
+ <!-- Card background with rounded corners - transparent background -->
44630
+ <rect
44631
+ x="5"
44632
+ y="5"
44633
+ width="${width - 10}"
44634
+ height="${height - 10}"
44635
+ rx="${cornerRadius}"
44636
+ ry="${cornerRadius}"
44637
+ fill="none"
44638
+ stroke="#D4AF37"
44639
+ stroke-width="3"
44640
+ filter="url(#glow)"
44641
+ />
44642
+
44643
+ <!-- Inner border for card frame effect -->
44644
+ <rect
44645
+ x="8"
44646
+ y="8"
44647
+ width="${width - 16}"
44648
+ height="${height - 16}"
44649
+ rx="${cornerRadius - 2}"
44650
+ ry="${cornerRadius - 2}"
44651
+ fill="none"
44652
+ stroke="#F5E6D3"
44653
+ stroke-width="1"
44654
+ />
44655
+
44656
+ <!-- Rank at top left corner -->
44657
+ <text
44658
+ x="${topBottomPadding + leftRightPadding}"
44659
+ y="${topBottomPadding + verticalOffset}"
44660
+ font-family="Arial, sans-serif"
44661
+ font-size="${rankFontSize}"
44662
+ font-weight="bold"
44663
+ fill="${suitInfo.color}"
44664
+ text-anchor="start"
44665
+ dominant-baseline="hanging"
44666
+ stroke="#000000"
44667
+ stroke-width="1.5"
44668
+ >
44669
+ ${displayRank}
44670
+ </text>
44671
+
44672
+ <!-- Rank at bottom right corner (not inverted) -->
44673
+ <text
44674
+ x="${width - topBottomPadding - leftRightPadding}"
44675
+ y="${height - topBottomPadding - verticalOffset}"
44676
+ font-family="Arial, sans-serif"
44677
+ font-size="${rankFontSize}"
44678
+ font-weight="bold"
44679
+ fill="${suitInfo.color}"
44680
+ text-anchor="end"
44681
+ dominant-baseline="baseline"
44682
+ stroke="#000000"
44683
+ stroke-width="1.5"
44684
+ >
44685
+ ${displayRank}
44686
+ </text>
44687
+
44688
+ <!-- Suit at top right corner -->
44689
+ <text
44690
+ x="${width - topBottomPadding - leftRightPadding}"
44691
+ y="${topBottomPadding + verticalOffset}"
44692
+ font-family="Arial, sans-serif"
44693
+ font-size="${suitFontSize}"
44694
+ font-weight="bold"
44695
+ fill="${suitInfo.color}"
44696
+ text-anchor="end"
44697
+ dominant-baseline="hanging"
44698
+ stroke="#000000"
44699
+ stroke-width="1"
44700
+ >
44701
+ ${suitInfo.symbol}
44702
+ </text>
44703
+
44704
+ <!-- Suit at bottom left corner (not inverted) -->
44705
+ <text
44706
+ x="${topBottomPadding + leftRightPadding}"
44707
+ y="${height - topBottomPadding - verticalOffset}"
44708
+ font-family="Arial, sans-serif"
44709
+ font-size="${suitFontSize}"
44710
+ font-weight="bold"
44711
+ fill="${suitInfo.color}"
44712
+ text-anchor="start"
44713
+ dominant-baseline="baseline"
44714
+ stroke="#000000"
44715
+ stroke-width="1"
44716
+ >
44717
+ ${suitInfo.symbol}
44718
+ </text>
44719
+ </svg>
44720
+ `.trim();
44721
+ };
44722
+
44723
+ const useBaccaratCard = () => {
44724
+ class BaccaratCard {
44725
+ constructor(cards, appRef) {
44726
+ this.cards = cards;
44727
+ this.appRef = appRef;
44728
+ this.initiateAnimation();
44729
+ }
44730
+ async initiateAnimation() {
44731
+ // Validate cards array
44732
+ if (!this.cards || !Array.isArray(this.cards) || this.cards.length === 0) {
44733
+ console.warn("BaccaratCard: No cards provided or cards array is empty");
44734
+ return;
44735
+ }
44736
+
44737
+ // Create a container to hold all cards
44738
+ const cardsContainer = new Container();
44739
+
44740
+ // Calculate layout: arrange cards horizontally, centered
44741
+ const numCards = this.cards.length;
44742
+ // Smaller SVG dimensions to fit within card_bg.svg
44743
+ const cardWidth = 120;
44744
+ const cardHeight = 160;
44745
+ const spacing = 77.6 * 0.5 + 20; // space between cards (match other hooks)
44746
+ const rowSpacing = 200; // Vertical spacing between rows
44747
+ // Scale for the card_bg.svg background
44748
+ const bgScale = window.innerWidth < 768 ? 0.65 : 0.75;
44749
+ // Smaller scale for the baccarat SVG to fit within the frame
44750
+ const cardScale = window.innerWidth < 768 ? 0.25 : 0.3;
44751
+
44752
+ // Load background texture once for all cards
44753
+ let bgTexture;
44754
+ try {
44755
+ bgTexture = await Assets.load("/card_bg.svg");
44756
+ } catch (bgError) {
44757
+ console.log("Background not found, continuing without it");
44758
+ }
44759
+
44760
+ // Create SVG cards with individual backgrounds
44761
+ const cardPromises = this.cards.map(async (card, i) => {
44762
+ try {
44763
+ var _card$multiplier;
44764
+ // Generate SVG for this card (without multiplier)
44765
+ const svgString = generateBaccaratCardSVG(card.rank, card.suit, cardWidth, cardHeight);
44766
+
44767
+ // Convert SVG string to data URL
44768
+ const svgDataUrl = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgString)}`;
44769
+
44770
+ // Create texture from data URL using Image
44771
+ const img = new Image();
44772
+ img.src = svgDataUrl;
44773
+ await new Promise((resolve, reject) => {
44774
+ img.onload = resolve;
44775
+ img.onerror = reject;
44776
+ });
44777
+
44778
+ // Create texture from the loaded image
44779
+ const cardTexture = Texture.from(img);
44780
+ const cardSprite = new Sprite(cardTexture);
44781
+
44782
+ // Create container for this card with background
44783
+ const cardContainer = new Container();
44784
+
44785
+ // Add background sprite if available (card_bg.svg frame)
44786
+ let bg_sprite = null;
44787
+ if (bgTexture) {
44788
+ bg_sprite = new Sprite(bgTexture);
44789
+ bg_sprite.scale.set(bgScale);
44790
+ bg_sprite.anchor.set(0.5);
44791
+ bg_sprite.x = 0;
44792
+ bg_sprite.y = 0;
44793
+ cardContainer.addChild(bg_sprite);
44794
+ }
44795
+
44796
+ // Add the card sprite on top of background (smaller, fits within frame)
44797
+ // Position it downward in the frame
44798
+ cardSprite.scale.set(cardScale);
44799
+ cardSprite.anchor.set(0.5);
44800
+ cardSprite.x = 0;
44801
+ // Move card sprite downward
44802
+ if (bg_sprite) {
44803
+ const bgHeight = bg_sprite.height;
44804
+ cardSprite.y = bgHeight * 0.1; // Move down from center
44805
+ } else {
44806
+ cardSprite.y = cardHeight * cardScale * 0.15; // Fallback position
44807
+ }
44808
+ cardContainer.addChild(cardSprite);
44809
+
44810
+ // Add multiplier text separately at top center with small font size
44811
+ const multiplier = (_card$multiplier = card.multiplier) !== null && _card$multiplier !== void 0 ? _card$multiplier : card.multplier;
44812
+ if (multiplier !== null && multiplier !== undefined) {
44813
+ const multiplierText = new Text({
44814
+ text: `${multiplier}x`,
44815
+ style: {
44816
+ fontFamily: "Arial, sans-serif",
44817
+ fontSize: 14,
44818
+ // Small font size
44819
+ fontWeight: "bold",
44820
+ fill: "#D4AF37",
44821
+ // Golden color
44822
+ align: "center",
44823
+ stroke: "#000000",
44824
+ strokeThickness: 1
44825
+ }
44826
+ });
44827
+ multiplierText.anchor.set(0.5);
44828
+ // Position at very top center of the card container
44829
+ multiplierText.x = 0;
44830
+ if (bg_sprite) {
44831
+ // Use the sprite's scaled height to position at the very top
44832
+ const bgHeight = bg_sprite.height;
44833
+ multiplierText.y = -bgHeight / 2 + 12; // Increased top padding for multiplier
44834
+ } else {
44835
+ // Fallback if no background
44836
+ multiplierText.y = -cardHeight * cardScale / 2 + 8;
44837
+ }
44838
+ cardContainer.addChild(multiplierText);
44839
+ }
44840
+
44841
+ // Calculate multi-row layout for 5 cards: 3 in first row, 2 in second row
44842
+ let rowIndex = 0;
44843
+ let colIndex = i;
44844
+ let cardsInRow = numCards;
44845
+ if (numCards === 5) {
44846
+ // First 3 cards in row 0, remaining 2 in row 1
44847
+ if (i < 3) {
44848
+ rowIndex = 0;
44849
+ colIndex = i;
44850
+ cardsInRow = 3;
44851
+ } else {
44852
+ rowIndex = 1;
44853
+ colIndex = i - 3;
44854
+ cardsInRow = 2;
44855
+ }
44856
+ }
44857
+
44858
+ // Calculate horizontal position within the row
44859
+ const rowWidth = (cardsInRow - 1) * spacing;
44860
+ cardContainer.x = -rowWidth / 2 + colIndex * spacing;
44861
+
44862
+ // Calculate vertical position based on row
44863
+ cardContainer.y = rowIndex * rowSpacing;
44864
+ return cardContainer;
44865
+ } catch (error) {
44866
+ console.error(`Error creating baccarat card ${i}:`, error);
44867
+ return null;
44868
+ }
44869
+ });
44870
+
44871
+ // After all cards are loaded, add them to the container and stage
44872
+ Promise.all(cardPromises).then(async sprites => {
44873
+ // Filter out any null sprites (from failed card creation)
44874
+ const validSprites = sprites.filter(sprite => sprite !== null);
44875
+ if (validSprites.length === 0) {
44876
+ console.error("BaccaratCard: No valid cards were created");
44877
+ return;
44878
+ }
44879
+ try {
44880
+ cardsContainer.label = "baccarat_card_container";
44881
+ validSprites.forEach(sprite => cardsContainer.addChild(sprite));
44882
+
44883
+ // Center the container in the canvas
44884
+ cardsContainer.x = this.appRef.current.renderer.width / 2;
44885
+ // Adjust vertical centering for multi-row layout
44886
+ const verticalOffset = numCards === 5 ? -rowSpacing / 2 : 0;
44887
+ cardsContainer.y = this.appRef.current.renderer.height / 2 + verticalOffset;
44888
+ this.appRef.current.stage.addChild(cardsContainer);
44889
+ } catch (error) {
44890
+ console.error("Error adding cards to stage:", error);
44891
+ }
44892
+ }).catch(error => {
44893
+ console.error("Error in card promises:", error);
44894
+ });
44895
+ }
44896
+ }
44897
+ return {
44898
+ BaccaratCard
44899
+ };
44900
+ };
44901
+
44902
+ const useBaccaratCardStart = () => {
44903
+ class BaccaratCardStart {
44904
+ constructor(cards, appRef) {
44905
+ this.cards = cards;
44906
+ this.appRef = appRef;
44907
+ this.initiateAnimation();
44908
+ }
44909
+ async initiateAnimation() {
44910
+ // Validate cards array
44911
+ if (!this.cards || !Array.isArray(this.cards) || this.cards.length === 0) {
44912
+ console.warn("BaccaratCardStart: No cards provided or cards array is empty");
44913
+ return;
44914
+ }
44915
+
44916
+ // Create a container to hold all cards
44917
+ const cardsContainer = new Container();
44918
+
44919
+ // Calculate layout: arrange cards horizontally, centered
44920
+ const numCards = this.cards.length;
44921
+ // Smaller SVG dimensions to fit within card_bg.svg
44922
+ const cardWidth = 120;
44923
+ const cardHeight = 160;
44924
+ const spacing = 77.6 * 0.5 + 20; // space between cards (match other hooks)
44925
+ const rowSpacing = 200; // Vertical spacing between rows
44926
+ // Scale for the card_bg.svg background
44927
+ const bgScale = window.innerWidth < 768 ? 0.65 : 0.75;
44928
+ // Smaller scale for the baccarat SVG to fit within the frame
44929
+ const cardScale = window.innerWidth < 768 ? 0.25 : 0.3;
44930
+
44931
+ // Load background texture once for all cards
44932
+ let bgTexture;
44933
+ try {
44934
+ bgTexture = await Assets.load("/card_bg.svg");
44935
+ } catch (bgError) {
44936
+ console.log("Background not found, continuing without it");
44937
+ }
44938
+
44939
+ // Create SVG cards with individual backgrounds
44940
+ const cardPromises = this.cards.map(async (card, i) => {
44941
+ try {
44942
+ var _card$multiplier;
44943
+ // Generate SVG for this card (without multiplier)
44944
+ const svgString = generateBaccaratCardSVG(card.rank, card.suit, cardWidth, cardHeight);
44945
+
44946
+ // Convert SVG string to data URL
44947
+ const svgDataUrl = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgString)}`;
44948
+
44949
+ // Create texture from data URL using Image
44950
+ const img = new Image();
44951
+ img.src = svgDataUrl;
44952
+ await new Promise((resolve, reject) => {
44953
+ img.onload = resolve;
44954
+ img.onerror = reject;
44955
+ });
44956
+
44957
+ // Create texture from the loaded image
44958
+ const cardTexture = Texture.from(img);
44959
+ const cardSprite = new Sprite(cardTexture);
44960
+ cardSprite.label = "starting_baccarat_card";
44961
+
44962
+ // Create container for this card with background
44963
+ const cardContainer = new Container();
44964
+
44965
+ // Add background sprite if available (card_bg.svg frame)
44966
+ let bg_sprite = null;
44967
+ if (bgTexture) {
44968
+ bg_sprite = new Sprite(bgTexture);
44969
+ bg_sprite.scale.set(bgScale);
44970
+ bg_sprite.anchor.set(0.5);
44971
+ bg_sprite.x = 0;
44972
+ bg_sprite.y = 0;
44973
+ cardContainer.addChild(bg_sprite);
44974
+ }
44975
+
44976
+ // Add the card sprite on top of background (smaller, fits within frame)
44977
+ // Position it downward in the frame
44978
+ cardSprite.scale.set(cardScale);
44979
+ cardSprite.anchor.set(0.5);
44980
+ cardSprite.x = 0;
44981
+ // Move card sprite downward
44982
+ if (bg_sprite) {
44983
+ const bgHeight = bg_sprite.height;
44984
+ cardSprite.y = bgHeight * 0.1; // Move down from center
44985
+ } else {
44986
+ cardSprite.y = cardHeight * cardScale * 0.15; // Fallback position
44987
+ }
44988
+ cardContainer.addChild(cardSprite);
44989
+
44990
+ // Add multiplier text separately at top center with small font size
44991
+ const multiplier = (_card$multiplier = card.multiplier) !== null && _card$multiplier !== void 0 ? _card$multiplier : card.multplier;
44992
+ if (multiplier !== null && multiplier !== undefined) {
44993
+ const multiplierText = new Text({
44994
+ text: `${multiplier}x`,
44995
+ style: {
44996
+ fontFamily: "Arial, sans-serif",
44997
+ fontSize: 14,
44998
+ // Small font size
44999
+ fontWeight: "bold",
45000
+ fill: "#D4AF37",
45001
+ // Golden color
45002
+ align: "center",
45003
+ stroke: "#000000",
45004
+ strokeThickness: 1
45005
+ }
45006
+ });
45007
+ multiplierText.anchor.set(0.5);
45008
+ // Position at very top center of the card container
45009
+ multiplierText.x = 0;
45010
+ if (bg_sprite) {
45011
+ // Use the sprite's scaled height to position at the very top
45012
+ const bgHeight = bg_sprite.height;
45013
+ multiplierText.y = -bgHeight / 2 + 12; // Increased top padding for multiplier
45014
+ } else {
45015
+ // Fallback if no background
45016
+ multiplierText.y = -cardHeight * cardScale / 2 + 8;
45017
+ }
45018
+ cardContainer.addChild(multiplierText);
45019
+ }
45020
+
45021
+ // Calculate multi-row layout for 5 cards: 3 in first row, 2 in second row
45022
+ let rowIndex = 0;
45023
+ let colIndex = i;
45024
+ let cardsInRow = numCards;
45025
+ if (numCards === 5) {
45026
+ // First 3 cards in row 0, remaining 2 in row 1
45027
+ if (i < 3) {
45028
+ rowIndex = 0;
45029
+ colIndex = i;
45030
+ cardsInRow = 3;
45031
+ } else {
45032
+ rowIndex = 1;
45033
+ colIndex = i - 3;
45034
+ cardsInRow = 2;
45035
+ }
45036
+ }
45037
+
45038
+ // Calculate horizontal position within the row
45039
+ const rowWidth = (cardsInRow - 1) * spacing;
45040
+ cardContainer.x = -rowWidth / 2 + colIndex * spacing;
45041
+
45042
+ // Calculate vertical position based on row
45043
+ cardContainer.y = rowIndex * rowSpacing;
45044
+ return cardContainer;
45045
+ } catch (error) {
45046
+ console.error(`Error creating baccarat card ${i}:`, error);
45047
+ return null;
45048
+ }
45049
+ });
45050
+
45051
+ // After all cards are loaded, add them to the container and stage
45052
+ Promise.all(cardPromises).then(async sprites => {
45053
+ // Filter out any null sprites (from failed card creation)
45054
+ const validSprites = sprites.filter(sprite => sprite !== null);
45055
+ if (validSprites.length === 0) {
45056
+ console.error("BaccaratCardStart: No valid cards were created");
45057
+ return;
45058
+ }
45059
+ try {
45060
+ cardsContainer.label = "baccarat_card_start_container";
45061
+ validSprites.forEach(sprite => cardsContainer.addChild(sprite));
45062
+
45063
+ // Center the container in the canvas
45064
+ cardsContainer.x = this.appRef.current.renderer.width / 2;
45065
+ // Adjust vertical centering for multi-row layout
45066
+ const verticalOffset = numCards === 5 ? -rowSpacing / 2 : 0;
45067
+ cardsContainer.y = this.appRef.current.renderer.height / 2 + verticalOffset;
45068
+ this.appRef.current.stage.addChild(cardsContainer);
45069
+ } catch (error) {
45070
+ console.error("Error adding cards to stage:", error);
45071
+ }
45072
+ }).catch(error => {
45073
+ console.error("Error in card promises:", error);
45074
+ });
45075
+ }
45076
+ }
45077
+ return {
45078
+ BaccaratCardStart
45079
+ };
45080
+ };
45081
+
44499
45082
  // CSS is provided separately via the style field in package.json
44500
45083
 
44501
45084
  const thunder_left = "https://babylonbetst.evo-games.com/frontend/evo/mini/images/lightnings.f9848fb7.webp";
@@ -44505,7 +45088,9 @@ const border_start = "https://babylonbetst.evo-games.com/frontend/evo/mini/image
44505
45088
  const border_loop = "https://babylonbetst.evo-games.com/frontend/evo/mini/images/borderloop.c55570cc.webp";
44506
45089
  const LighteningCard = ({
44507
45090
  roundStatus,
44508
- cards
45091
+ cards,
45092
+ showRank = false,
45093
+ gameType
44509
45094
  }) => {
44510
45095
  const containerRef = React.useRef(null);
44511
45096
  const appRef = React.useRef(null);
@@ -44524,6 +45109,12 @@ const LighteningCard = ({
44524
45109
  const {
44525
45110
  LighteningStart
44526
45111
  } = useLighteningStart();
45112
+ const {
45113
+ BaccaratCard
45114
+ } = useBaccaratCard();
45115
+ const {
45116
+ BaccaratCardStart
45117
+ } = useBaccaratCardStart();
44527
45118
  const initiatePixiApplication = async () => {
44528
45119
  appRef.current = new Application();
44529
45120
  await appRef.current.init({
@@ -44538,8 +45129,28 @@ const LighteningCard = ({
44538
45129
  ["NO_MORE_BETS", "LIGHTNING", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new LeftThunder(thunder_left, appRef);
44539
45130
  ["NO_MORE_BETS", "LIGHTNING", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new RightThunder(thunder_right, appRef);
44540
45131
  ["NO_MORE_BETS", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new MiddleThunder(thunder_middle, appRef);
44541
- ["LIGHTNING"].includes(roundStatus) && new LighteningStart(cards, border_start, appRef);
44542
- ["NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new Lightening(cards, border_loop, appRef);
45132
+
45133
+ // Debug logging
45134
+ console.log("LighteningCard render:", {
45135
+ roundStatus,
45136
+ showRank,
45137
+ gameType,
45138
+ cardsCount: (cards === null || cards === void 0 ? void 0 : cards.length) || 0,
45139
+ cards: cards
45140
+ });
45141
+
45142
+ // Check if this is baccarat game - use SVG cards
45143
+ // Use baccarat SVG cards when gameType is baccarat OR when showRank is true (baccarat-style display)
45144
+ const isBaccarat = (gameType === null || gameType === void 0 ? void 0 : gameType.toLowerCase()) === "baccarat" || showRank === true;
45145
+ if (isBaccarat) {
45146
+ // Use baccarat SVG cards (no PNGs, uses SVG suit symbols)
45147
+ ["LIGHTNING"].includes(roundStatus) && new BaccaratCardStart(cards, appRef);
45148
+ ["NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new BaccaratCard(cards, appRef);
45149
+ } else {
45150
+ // Use suit-only display (with PNG suit images)
45151
+ ["LIGHTNING"].includes(roundStatus) && new LighteningStart(cards, border_start, appRef);
45152
+ ["NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new Lightening(cards, border_loop, appRef);
45153
+ }
44543
45154
  };
44544
45155
  React.useEffect(() => {
44545
45156
  if (!containerRef.current) return;
@@ -44552,7 +45163,7 @@ const LighteningCard = ({
44552
45163
  appRef.current = null;
44553
45164
  }
44554
45165
  };
44555
- }, [roundStatus]);
45166
+ }, [roundStatus, showRank, cards, gameType]);
44556
45167
  return /*#__PURE__*/React.createElement("div", {
44557
45168
  className: "lightening-card",
44558
45169
  ref: containerRef
@@ -44565,12 +45176,17 @@ LighteningCard.propTypes = {
44565
45176
  rank: PropTypes.string,
44566
45177
  suit: PropTypes.string
44567
45178
  })),
45179
+ showRank: PropTypes.bool,
45180
+ // If true, displays rank at center and suit at top-left. If false, displays suit only.
45181
+ gameType: PropTypes.string,
45182
+ // Game type (e.g., "baccarat") - if "baccarat", uses SVG cards
44568
45183
  assetPath: PropTypes.string,
44569
45184
  // Path to the animation asset
44570
45185
  onAnimationReady: PropTypes.func // Callback when animation is ready
44571
45186
  };
44572
45187
  LighteningCard.defaultProps = {
44573
- cards: []
45188
+ cards: [],
45189
+ showRank: false // Default to suit-only display
44574
45190
  };
44575
45191
 
44576
45192
  extensions.add(AccessibilitySystem);