lighteningcards 2.1.1 → 2.1.2

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