@betorigami/games 2.6.0 → 2.6.1

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.d.ts CHANGED
@@ -7808,7 +7808,11 @@ declare abstract class ChipTableGameComponent extends GameComponent {
7808
7808
  protected handleUndo: () => void;
7809
7809
  protected handleClear: () => void;
7810
7810
  protected handleAdjustTotalBet: (action: "half" | "double") => void;
7811
- protected getChipTableHotkeys(manualEl?: HTMLElement, autoEl?: HTMLElement): HotkeyDefinition[];
7811
+ /**
7812
+ * Return the set of hotkey definitions used for chip-table controls. Callbacks are used for manual & auto bet button elements, as `@query`
7813
+ * elements are undefined within component constructors.
7814
+ */
7815
+ protected getChipTableHotkeys(getManualEl: () => HTMLElement | undefined, getAutoEl: () => HTMLElement | undefined): HotkeyDefinition[];
7812
7816
  }
7813
7817
  export declare class RouletteGame extends ChipTableGameComponent {
7814
7818
  static styles: import("lit").CSSResult[];
package/dist/index.mjs CHANGED
@@ -15423,7 +15423,7 @@ var Zs=Object.create;var{getPrototypeOf:Ks,defineProperty:Xt,getOwnPropertyNames
15423
15423
  :host {
15424
15424
  height: 100%;
15425
15425
  }
15426
- `;class ai extends Ha{constructor(){super(...arguments);this.perClickAmount="1";this.chipEvents=[]}get canUndo(){return this.chipEvents.length>0}firstUpdated(){this.perClickAmount=this.gameData?.minBet?.toString()??"1"}get canClear(){return this.derivedChips.size>0}get derivedChips(){return u1.deriveState(this.chipEvents,Z(this.gameData?.maxBet??0))}get totalBetAmount(){let a=Z(0);for(let e of this.derivedChips.values())a=a.plus(e);return Number(a.toFixed(4))}get maxPerClickAmount(){let a=Z(this.gameData?.maxBet??0),e=Z(this.gameData?.balance??0).minus(this.totalBetAmount),i=ne(a,e);return i.lt(0)?"0":i.toString()}get isDoubleDisabled(){let a=Z(this.totalBetAmount).times(2),e=a.gt(this.gameData?.balance??0),i=a.gt(this.gameData?.maxBet??0);return e||i}watchDerivedChips(a,e){if(!this.gameData?.updateBetAmount)return;let i=Array.from(this.derivedChips.values()).reduce((n,t)=>n.plus(t),Z(0)),r=this.gameData.currencyDecimals??0;this.gameData.updateBetAmount(Z(i.toFixed(r)))}onBetAmountChange=(a,e)=>{if(Z(a).eq(0))return;let i=Z(e).div(Z(a));this.chipEvents=[...this.chipEvents,{type:"multiplier-change",multiplier:i.toNumber()}]};adjustPerClickAmount(a){let e=Z(this.perClickAmount||"0"),i=this.gameData?.currencyDecimals??2,r=Z(this.gameData?.minBet??0),n=Z(this.maxPerClickAmount),t;if(a==="reset")t=r;else if(a==="half"){if(e.lte(0))return;t=ve(r,ne(e.div(2),n))}else if(e.eq(0))t=r.gt(0)?r:Z(1).div(10**i);else t=ve(r,ne(e.mul(2),n));this.perClickAmount=t.toFixed(i),E1(this.gameData,0.5)}handlePerClickAmountChange=(a)=>{this.perClickAmount=a.detail.amount};addChip(a,e){let i=parseFloat(e)||0;if(i<=0)return;this.chipEvents=[...this.chipEvents,{type:"add",position:a,amount:i}],E1(this.gameData,0.5)}handleChipInteraction(a,e=!1){let i=parseFloat(this.perClickAmount)||0;if(i<=0)return;if(e){if(!this.derivedChips.has(a))return;this.chipEvents=[...this.chipEvents,{type:"add",position:a,amount:-i}],E1(this.gameData,0.5);return}if(Z(i).gt(this.maxPerClickAmount))return;let r=(o,l)=>{if(o==="COLOR_BLACK"&&l.has("COLOR_RED"))return!0;if(o==="COLOR_RED"&&l.has("COLOR_BLACK"))return!0;if(o==="PARITY_EVEN"&&l.has("PARITY_ODD"))return!0;if(o==="PARITY_ODD"&&l.has("PARITY_EVEN"))return!0;if(o==="HALF_LOW"&&l.has("HALF_HIGH"))return!0;if(o==="HALF_HIGH"&&l.has("HALF_LOW"))return!0;if(o==="DOZEN_FIRST"&&l.has("DOZEN_SECOND")&&l.has("DOZEN_THIRD"))return!0;if(o==="DOZEN_SECOND"&&l.has("DOZEN_FIRST")&&l.has("DOZEN_THIRD"))return!0;if(o==="DOZEN_THIRD"&&l.has("DOZEN_FIRST")&&l.has("DOZEN_SECOND"))return!0;if(o==="COLUMN_TOP"&&l.has("COLUMN_MIDDLE")&&l.has("COLUMN_BOTTOM"))return!0;if(o==="COLUMN_MIDDLE"&&l.has("COLUMN_TOP")&&l.has("COLUMN_BOTTOM"))return!0;if(o==="COLUMN_BOTTOM"&&l.has("COLUMN_TOP")&&l.has("COLUMN_MIDDLE"))return!0;return!1};if(this.gameData.roulettePreventOppositeBets&&r(a,this.derivedChips)){this.showError(R("errors.roulette.oppositeBet",this.gameData?.language||W));return}let n=(o,l)=>{if(o==="PLAYER"&&l.has("BANKER"))return!0;if(o==="BANKER"&&l.has("PLAYER"))return!0;return!1};if(this.gameData.baccaratPreventOppositeBets&&n(a,this.derivedChips)){this.showError(R("errors.roulette.oppositeBet",this.gameData?.language||W));return}let t=Z(this.gameData?.maxBet??0);if(Z(this.totalBetAmount).plus(i).gt(t)){this.showError(Va("alerts.betAmountAboveMaxBet",this.gameData?.language||W,{value:t.toString()}));return}if(this.isMaxPayoutExceeded([...this.chipEvents,{type:"add",position:a,amount:i}])){this.showError(R("alerts.maxPayoutExceeded",this.gameData?.language||W));return}if(Z(this.totalBetAmount).plus(i).gt(this.gameData?.balance??0))return;this.addChip(a,this.perClickAmount)}handleUndo=()=>{this.chipEvents=u1.undoEvent(this.chipEvents)};handleClear=()=>{this.chipEvents=[]};handleAdjustTotalBet=(a)=>{if(this.derivedChips.size===0)return;let e=[...this.chipEvents,{type:"multiplier-change",multiplier:a==="half"?0.5:2}];if(a==="double"){let i=Z(this.gameData?.maxBet??0);if(Z(this.totalBetAmount).times(2).gt(i)){this.showError(Va("alerts.betAmountAboveMaxBet",this.gameData?.language||W,{value:i.toString()}));return}}if(this.isMaxPayoutExceeded(e)){this.showError(R("alerts.maxPayoutExceeded",this.gameData?.language||W));return}if(this.chipEvents=e,this.totalBetAmount===0)this.chipEvents=[]};getChipTableHotkeys(a,e){return[{key:" ",callback:()=>ba.clickBetButton(this.manualOrAuto,a,e),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return ba.isBetButtonDisabled(this.manualOrAuto,a,e)}}},{key:"q",callback:()=>this.adjustPerClickAmount("double"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"r",callback:()=>this.adjustPerClickAmount("half"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"e",callback:()=>this.adjustPerClickAmount("reset"),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"w",callback:l1(()=>this.gameData,()=>this.handleClear()),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0}},{key:"a",callback:l1(()=>this.gameData,()=>this.handleAdjustTotalBet("half")),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0}},{key:"s",callback:l1(()=>this.gameData,()=>this.handleAdjustTotalBet("double")),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0||this.isDoubleDisabled}},{key:"d",callback:l1(()=>this.gameData,()=>this.handleClear()),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0}},{key:"z",callback:l1(()=>this.gameData,()=>this.handleUndo()),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||!this.canUndo}}]}}h([F()],ai.prototype,"perClickAmount",void 0),h([F()],ai.prototype,"chipEvents",void 0),h([ma("chipEvents")],ai.prototype,"watchDerivedChips",null);var dd=500;class E0 extends ai{static styles=[...ai.styles,hs];newBalance=null;ballLandResolver=null;constructor(){super();this.isManualPlaying=!1;this.betResult=null;this.history=[];this.hitNumber=null;this.showMobileOverlay=!1;this.displayedHitNumber=null;this.lastResultNumber=null;this.showWinPopup=!1;new Aa(this,[...this.getChipTableHotkeys(this._manualEl,this._autoEl)])}get rouletteType(){if(Number(this.gameData?.edge)===5.3)return da.AMERICAN;return da.EUROPEAN}get rouletteApi(){return this.isDemoMode?new xt:new yt(this.gameData.authToken,this.gameData.baseUrl)}get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get maxPossiblePayout(){return Qa.findMaxPayoutTile(this.derivedChips,this.rouletteType).maxPayout}isMaxPayoutExceeded(a){let{maxPayout:e}=Qa.findMaxPayoutTile(u1.deriveState(a,Z(this.gameData?.maxBet??0)),this.rouletteType);return Z(e).gt(this.gameData?.maxPayout??0)}handleGridClick=(a)=>{let{position:e,remove:i}=a.detail;this.handleChipInteraction(e,!!i)};addToHistory(a,e,i,r){this.history=[...this.history.filter((n)=>n.id!==i),{multiplier:a,won:e,id:i,hitNumber:r}]}extractHitNumberFromActions(a){for(let e=a.length-1;e>=0;e--){let r=a[e]?.data?.ROULETTE?.result?.[0];if(typeof r==="number")return r}return null}applyBetResult(a){this.betResult=a;let e=this.extractHitNumberFromActions(a.betActions);if(e!==null)this.hitNumber=e;let i=Number(a.multiplier??0),r=i>=1;if(this.addToHistory(i,r,a.id??"",e??0),this.updateHistoryWithBet(a),this.showWinPopup=r,i>1)this.playWinFeedback();this.displayedHitNumber=this.hitNumber??e,this.lastResultNumber=this.displayedHitNumber}async waitForAutobetDisplay(a){await this.ensureMinimumDisplayTime(a,500,350),await ga(this.getAutobetDelay())}async handleBetExecution(a){if(!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};let e=this.derivedChips;if(e.size===0)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};let i=c0(e,this.rouletteType),r=Z(this.gameData.balance);try{if(this.isDemoMode&&r.lt(this.totalBetAmount))throw new Error(R("alerts.insufficientBalance",this.gameData?.language||W));if(this.isMaxPayoutExceeded(this.chipEvents))throw new Error(R("alerts.maxPayoutExceeded",this.gameData?.language||W));let n=await this.rouletteApi.startBet({currency:this.gameData.currency,language:this.gameData.language,gameInputs:i,meta:a?Ga(a):void 0});if(n.success){let{data:t}=n;return this.betResult=t,this.hitNumber=this.extractHitNumberFromActions(t.betActions),this.newBalance=this.isDemoMode?r.minus(t.amount??0).plus(t.payout??0):Z(t.afterBalance??0),n}else throw new Error(n.error)}catch(n){let t=n instanceof Error?n.message:R("alerts.gameError",this.gameData?.language||W);return this.showError(t),{success:!1,error:t}}}handleBallLand=()=>{if(this.ballLandResolver)this.ballLandResolver(),this.ballLandResolver=null;if(this.betResult)this.applyBetResult(this.betResult);let a=(this.gameData?.mainWidth??0)<768,e=this.gameData?.instantBetEnabled??!1;if(a&&!e)setTimeout(()=>{this.isManualPlaying=!1,this.showMobileOverlay=!1},dd);else this.isManualPlaying=!1,this.showMobileOverlay=!1;if(this.newBalance)this.gameData.updateBalance(this.newBalance),this.newBalance=null};async roulettePlay(){this.isManualPlaying=!0,this.hitNumber=null,this.betResult=null,this.showWinPopup=!1;let a=this.gameData?.instantBetEnabled??!1;if(!a)this.showMobileOverlay=!0;if(!(await this.handleBetExecution()).success){this.isManualPlaying=!1,this.showMobileOverlay=!1;return}if(a)this.handleBallLand()}async executeAutobet(a,e){try{this.hitNumber=null,this.betResult=null,this.showWinPopup=!1;let i=this.gameData?.instantBetEnabled??!1;if(i)await this.forceUIUpdate();let r=null;if(!i)r=new Promise((m)=>{this.ballLandResolver=m}),this.showMobileOverlay=!0;let n=await this.handleBetExecution(a);if(!n.success)return this.ballLandResolver=null,this.showMobileOverlay=!1,{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:n.error||R("alerts.errorProcessingBet",this.gameData?.language||W)};let t=n.data,o=Z(t.payout??0).minus(t.amount??0),l=Number(t.multiplier),s=Na(l),u=l>=1,c=this.extractHitNumberFromActions(t.betActions);if(c!==null)this.hitNumber=c;if(this.betResult=t,await this.executeInstantOrAnimated(async()=>{this.applyBetResult(t),this.showMobileOverlay=!1},async()=>{if(r)await r}),this.newBalance)this.gameData.updateBalance(this.newBalance),this.newBalance=null;return await this.waitForAutobetDisplay(u),this.showWinPopup=!1,{pnl:o,gameOutcome:s,hasError:!1}}catch(i){return console.error("Error in executeAutobet:",i),this.ballLandResolver=null,this.showMobileOverlay=!1,{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData?.language||W)}}}render(){let a=this.gameData?.mainWidth>=768,e=this.totalBetAmount===0,i=Ja(this.gameData);return x`
15426
+ `;class ai extends Ha{constructor(){super(...arguments);this.perClickAmount="1";this.chipEvents=[]}get canUndo(){return this.chipEvents.length>0}firstUpdated(){this.perClickAmount=this.gameData?.minBet?.toString()??"1"}get canClear(){return this.derivedChips.size>0}get derivedChips(){return u1.deriveState(this.chipEvents,Z(this.gameData?.maxBet??0))}get totalBetAmount(){let a=Z(0);for(let e of this.derivedChips.values())a=a.plus(e);return Number(a.toFixed(4))}get maxPerClickAmount(){let a=Z(this.gameData?.maxBet??0),e=Z(this.gameData?.balance??0).minus(this.totalBetAmount),i=ne(a,e);return i.lt(0)?"0":i.toString()}get isDoubleDisabled(){let a=Z(this.totalBetAmount).times(2),e=a.gt(this.gameData?.balance??0),i=a.gt(this.gameData?.maxBet??0);return e||i}watchDerivedChips(a,e){if(!this.gameData?.updateBetAmount)return;let i=Array.from(this.derivedChips.values()).reduce((n,t)=>n.plus(t),Z(0)),r=this.gameData.currencyDecimals??0;this.gameData.updateBetAmount(Z(i.toFixed(r)))}onBetAmountChange=(a,e)=>{if(Z(a).eq(0))return;let i=Z(e).div(Z(a));this.chipEvents=[...this.chipEvents,{type:"multiplier-change",multiplier:i.toNumber()}]};adjustPerClickAmount(a){let e=Z(this.perClickAmount||"0"),i=this.gameData?.currencyDecimals??2,r=Z(this.gameData?.minBet??0),n=Z(this.maxPerClickAmount),t;if(a==="reset")t=r;else if(a==="half"){if(e.lte(0))return;t=ve(r,ne(e.div(2),n))}else if(e.eq(0))t=r.gt(0)?r:Z(1).div(10**i);else t=ve(r,ne(e.mul(2),n));this.perClickAmount=t.toFixed(i),E1(this.gameData,0.5)}handlePerClickAmountChange=(a)=>{this.perClickAmount=a.detail.amount};addChip(a,e){let i=parseFloat(e)||0;if(i<=0)return;this.chipEvents=[...this.chipEvents,{type:"add",position:a,amount:i}],E1(this.gameData,0.5)}handleChipInteraction(a,e=!1){let i=parseFloat(this.perClickAmount)||0;if(i<=0)return;if(e){if(!this.derivedChips.has(a))return;this.chipEvents=[...this.chipEvents,{type:"add",position:a,amount:-i}],E1(this.gameData,0.5);return}if(Z(i).gt(this.maxPerClickAmount))return;let r=(o,l)=>{if(o==="COLOR_BLACK"&&l.has("COLOR_RED"))return!0;if(o==="COLOR_RED"&&l.has("COLOR_BLACK"))return!0;if(o==="PARITY_EVEN"&&l.has("PARITY_ODD"))return!0;if(o==="PARITY_ODD"&&l.has("PARITY_EVEN"))return!0;if(o==="HALF_LOW"&&l.has("HALF_HIGH"))return!0;if(o==="HALF_HIGH"&&l.has("HALF_LOW"))return!0;if(o==="DOZEN_FIRST"&&l.has("DOZEN_SECOND")&&l.has("DOZEN_THIRD"))return!0;if(o==="DOZEN_SECOND"&&l.has("DOZEN_FIRST")&&l.has("DOZEN_THIRD"))return!0;if(o==="DOZEN_THIRD"&&l.has("DOZEN_FIRST")&&l.has("DOZEN_SECOND"))return!0;if(o==="COLUMN_TOP"&&l.has("COLUMN_MIDDLE")&&l.has("COLUMN_BOTTOM"))return!0;if(o==="COLUMN_MIDDLE"&&l.has("COLUMN_TOP")&&l.has("COLUMN_BOTTOM"))return!0;if(o==="COLUMN_BOTTOM"&&l.has("COLUMN_TOP")&&l.has("COLUMN_MIDDLE"))return!0;return!1};if(this.gameData.roulettePreventOppositeBets&&r(a,this.derivedChips)){this.showError(R("errors.roulette.oppositeBet",this.gameData?.language||W));return}let n=(o,l)=>{if(o==="PLAYER"&&l.has("BANKER"))return!0;if(o==="BANKER"&&l.has("PLAYER"))return!0;return!1};if(this.gameData.baccaratPreventOppositeBets&&n(a,this.derivedChips)){this.showError(R("errors.roulette.oppositeBet",this.gameData?.language||W));return}let t=Z(this.gameData?.maxBet??0);if(Z(this.totalBetAmount).plus(i).gt(t)){this.showError(Va("alerts.betAmountAboveMaxBet",this.gameData?.language||W,{value:t.toString()}));return}if(this.isMaxPayoutExceeded([...this.chipEvents,{type:"add",position:a,amount:i}])){this.showError(R("alerts.maxPayoutExceeded",this.gameData?.language||W));return}if(Z(this.totalBetAmount).plus(i).gt(this.gameData?.balance??0))return;this.addChip(a,this.perClickAmount)}handleUndo=()=>{this.chipEvents=u1.undoEvent(this.chipEvents)};handleClear=()=>{this.chipEvents=[]};handleAdjustTotalBet=(a)=>{if(this.derivedChips.size===0)return;let e=[...this.chipEvents,{type:"multiplier-change",multiplier:a==="half"?0.5:2}];if(a==="double"){let i=Z(this.gameData?.maxBet??0);if(Z(this.totalBetAmount).times(2).gt(i)){this.showError(Va("alerts.betAmountAboveMaxBet",this.gameData?.language||W,{value:i.toString()}));return}}if(this.isMaxPayoutExceeded(e)){this.showError(R("alerts.maxPayoutExceeded",this.gameData?.language||W));return}if(this.chipEvents=e,this.totalBetAmount===0)this.chipEvents=[]};getChipTableHotkeys(a,e){return[{key:" ",callback:()=>ba.clickBetButton(this.manualOrAuto,a(),e()),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return ba.isBetButtonDisabled(this.manualOrAuto,a(),e())}}},{key:"q",callback:()=>this.adjustPerClickAmount("double"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"r",callback:()=>this.adjustPerClickAmount("half"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"e",callback:()=>this.adjustPerClickAmount("reset"),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"w",callback:l1(()=>this.gameData,()=>this.handleClear()),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0}},{key:"a",callback:l1(()=>this.gameData,()=>this.handleAdjustTotalBet("half")),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0}},{key:"s",callback:l1(()=>this.gameData,()=>this.handleAdjustTotalBet("double")),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0||this.isDoubleDisabled}},{key:"d",callback:l1(()=>this.gameData,()=>this.handleClear()),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||this.derivedChips.size===0}},{key:"z",callback:l1(()=>this.gameData,()=>this.handleUndo()),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled||!this.canUndo}}]}}h([F()],ai.prototype,"perClickAmount",void 0),h([F()],ai.prototype,"chipEvents",void 0),h([ma("chipEvents")],ai.prototype,"watchDerivedChips",null);var dd=500;class E0 extends ai{static styles=[...ai.styles,hs];newBalance=null;ballLandResolver=null;constructor(){super();this.isManualPlaying=!1;this.betResult=null;this.history=[];this.hitNumber=null;this.showMobileOverlay=!1;this.displayedHitNumber=null;this.lastResultNumber=null;this.showWinPopup=!1;new Aa(this,[...this.getChipTableHotkeys(()=>this._manualEl,()=>this._autoEl)])}get rouletteType(){if(Number(this.gameData?.edge)===5.3)return da.AMERICAN;return da.EUROPEAN}get rouletteApi(){return this.isDemoMode?new xt:new yt(this.gameData.authToken,this.gameData.baseUrl)}get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get maxPossiblePayout(){return Qa.findMaxPayoutTile(this.derivedChips,this.rouletteType).maxPayout}isMaxPayoutExceeded(a){let{maxPayout:e}=Qa.findMaxPayoutTile(u1.deriveState(a,Z(this.gameData?.maxBet??0)),this.rouletteType);return Z(e).gt(this.gameData?.maxPayout??0)}handleGridClick=(a)=>{let{position:e,remove:i}=a.detail;this.handleChipInteraction(e,!!i)};addToHistory(a,e,i,r){this.history=[...this.history.filter((n)=>n.id!==i),{multiplier:a,won:e,id:i,hitNumber:r}]}extractHitNumberFromActions(a){for(let e=a.length-1;e>=0;e--){let r=a[e]?.data?.ROULETTE?.result?.[0];if(typeof r==="number")return r}return null}applyBetResult(a){this.betResult=a;let e=this.extractHitNumberFromActions(a.betActions);if(e!==null)this.hitNumber=e;let i=Number(a.multiplier??0),r=i>=1;if(this.addToHistory(i,r,a.id??"",e??0),this.updateHistoryWithBet(a),this.showWinPopup=r,i>1)this.playWinFeedback();this.displayedHitNumber=this.hitNumber??e,this.lastResultNumber=this.displayedHitNumber}async waitForAutobetDisplay(a){await this.ensureMinimumDisplayTime(a,500,350),await ga(this.getAutobetDelay())}async handleBetExecution(a){if(!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};let e=this.derivedChips;if(e.size===0)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};let i=c0(e,this.rouletteType),r=Z(this.gameData.balance);try{if(this.isDemoMode&&r.lt(this.totalBetAmount))throw new Error(R("alerts.insufficientBalance",this.gameData?.language||W));if(this.isMaxPayoutExceeded(this.chipEvents))throw new Error(R("alerts.maxPayoutExceeded",this.gameData?.language||W));let n=await this.rouletteApi.startBet({currency:this.gameData.currency,language:this.gameData.language,gameInputs:i,meta:a?Ga(a):void 0});if(n.success){let{data:t}=n;return this.betResult=t,this.hitNumber=this.extractHitNumberFromActions(t.betActions),this.newBalance=this.isDemoMode?r.minus(t.amount??0).plus(t.payout??0):Z(t.afterBalance??0),n}else throw new Error(n.error)}catch(n){let t=n instanceof Error?n.message:R("alerts.gameError",this.gameData?.language||W);return this.showError(t),{success:!1,error:t}}}handleBallLand=()=>{if(this.ballLandResolver)this.ballLandResolver(),this.ballLandResolver=null;if(this.betResult)this.applyBetResult(this.betResult);let a=(this.gameData?.mainWidth??0)<768,e=this.gameData?.instantBetEnabled??!1;if(a&&!e)setTimeout(()=>{this.isManualPlaying=!1,this.showMobileOverlay=!1},dd);else this.isManualPlaying=!1,this.showMobileOverlay=!1;if(this.newBalance)this.gameData.updateBalance(this.newBalance),this.newBalance=null};async roulettePlay(){this.isManualPlaying=!0,this.hitNumber=null,this.betResult=null,this.showWinPopup=!1;let a=this.gameData?.instantBetEnabled??!1;if(!a)this.showMobileOverlay=!0;if(!(await this.handleBetExecution()).success){this.isManualPlaying=!1,this.showMobileOverlay=!1;return}if(a)this.handleBallLand()}async executeAutobet(a,e){try{this.hitNumber=null,this.betResult=null,this.showWinPopup=!1;let i=this.gameData?.instantBetEnabled??!1;if(i)await this.forceUIUpdate();let r=null;if(!i)r=new Promise((m)=>{this.ballLandResolver=m}),this.showMobileOverlay=!0;let n=await this.handleBetExecution(a);if(!n.success)return this.ballLandResolver=null,this.showMobileOverlay=!1,{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:n.error||R("alerts.errorProcessingBet",this.gameData?.language||W)};let t=n.data,o=Z(t.payout??0).minus(t.amount??0),l=Number(t.multiplier),s=Na(l),u=l>=1,c=this.extractHitNumberFromActions(t.betActions);if(c!==null)this.hitNumber=c;if(this.betResult=t,await this.executeInstantOrAnimated(async()=>{this.applyBetResult(t),this.showMobileOverlay=!1},async()=>{if(r)await r}),this.newBalance)this.gameData.updateBalance(this.newBalance),this.newBalance=null;return await this.waitForAutobetDisplay(u),this.showWinPopup=!1,{pnl:o,gameOutcome:s,hasError:!1}}catch(i){return console.error("Error in executeAutobet:",i),this.ballLandResolver=null,this.showMobileOverlay=!1,{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData?.language||W)}}}render(){let a=this.gameData?.mainWidth>=768,e=this.totalBetAmount===0,i=Ja(this.gameData);return x`
15427
15427
  <origami-game-layout
15428
15428
  footer-position="below"
15429
15429
  style="${i} --season-corner-display: none;"
@@ -16009,7 +16009,7 @@ var Zs=Object.create;var{getPrototypeOf:Ks,defineProperty:Xt,getOwnPropertyNames
16009
16009
  :host {
16010
16010
  height: 100%;
16011
16011
  }
16012
- `;var ms=()=>({getRandomInt:({min:a,max:e})=>{let i=Math.floor(Math.random()*(e-a+1))+a;return{value:i,values:[i],count:1,min:a,max:e,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:a,max:e,count:i})=>{let r=[];while(r.length<i){let n=Math.floor(Math.random()*(e-a+1))+a;if(!r.includes(n))r.push(n)}return{values:r,count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:a,max:e,count:i})=>{return{values:Array.from({length:i},()=>Math.floor(Math.random()*(e-a+1))+a),count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}}}),Tt=(a)=>{let e=0,i=(r)=>{let n=[];for(let t=0;t<r;t++){if(e>=a.length)throw new Error("Random sequence exhausted - not enough values provided for this action");n.push(a[e]),e++}return n};return{getRandomInt:({min:r,max:n})=>{let t=i(1);return{value:t[0],values:t,count:1,min:r,max:n,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}}}};class Et{async startBet(a){let{amount:e,selections:i}=a,r={bets:i.map((u)=>({type:u.position,amount:Z(u.amount)}))},t=new T3().getGameResult({generator:ms(),edge:1,gameInputs:r}),o=L3(r),l=o.mul(t.payoutMultiplier);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"baccarat",currency:a.currency??"USD",amount:o.toString(),payout:l.toString(),afterBalance:"1000",multiplier:t.payoutMultiplier.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),type:"START_BET",betAmount:e,payoutAmount:null,actionIndex:0,data:{BACCARAT:r}},{id:crypto.randomUUID(),type:"END_BET",betAmount:null,payoutAmount:l.toString(),actionIndex:1,data:{BACCARAT:t.outputs}}]}}}}class V0 extends ai{static styles=[...ai.styles,fs];constructor(){super();this.isManualPlaying=!1;this.resultMultiplier=null;this.history=[];this.gameWinPopupShowing=!1;this.payout=null;this.instantModeForCurrentBet=!1;this.slowRevealEnabled=!1;this.currentRound=null;new Aa(this,[...this.getChipTableHotkeys(this._baccaratManualEl,this._baccaratAutoEl),{key:"p",callback:()=>this.handleChipInteraction("PLAYER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"b",callback:()=>this.handleChipInteraction("BANKER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"t",callback:()=>this.handleChipInteraction("TIE"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}}])}get baccaratApi(){return this.isDemoMode?new Et:new Mt(this.gameData.authToken,this.gameData.baseUrl??"")}get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get isSlowRevealActive(){return this.slowRevealEnabled&&this.manualOrAuto==="Manual"&&!this.instantModeForCurrentBet}isMaxPayoutExceeded(a){let e=u1.deriveState(a,Z(this.gameData?.maxBet??0));return ja.getMaxPossiblePayoutFromChips(e).gt(this.gameData?.maxPayout??0)}handleGridClick=(a)=>{let{position:e,remove:i}=a.detail;this.handleChipInteraction(e,!!i)};handleSlowRevealChange=(a)=>{this.slowRevealEnabled=a.detail.enabled};resetRound(){this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null}onManualOrAutoChange(){this.resetRound()}addToHistory(a,e,i){this.history=[...this.history.filter((r)=>r.id!==i),{multiplier:a,won:e,id:i}].slice(-Jl)}onDealSound=()=>{this.gameData?.soundEffects?.play(ua.cardSlide())};onCardFlip=()=>{this.gameData?.soundEffects?.play(ua.cardFlip())};async processBetResult(a,e,i){let n=a.betActions.find((u)=>u.type==="END_BET")?.data.BACCARAT;if(!n)throw new Error("No baccarat data found");let t=ja.createGameRound(a,n);this.currentRound=t,await X1(this,"baccarat-dealing-complete",()=>!0,this.isSlowRevealActive?void 0:Vl);let o=this.isDemoMode?e.minus(i).plus(a.payout??0):Z(a.afterBalance??0);this.gameData.updateBalance(o);let l=t.multiplier,s=l>=1;if(this.resultMultiplier=l,this.betId=t.betId,this.payout=t.payout,this.gameWinPopupShowing=s,l>1)this.playWinFeedback();this.addToHistory(l,s,t.betId),this.updateHistoryWithBet(a)}async handleBetExecution(){if(this.instantModeForCurrentBet=this.gameData?.instantBetEnabled??!1,!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};if(this.derivedChips.size===0)return{success:!1,error:R("games.baccarat.selectChip",this.gameData?.language||W)};if(this.isMaxPayoutExceeded(this.chipEvents))return{success:!1,error:R("alerts.maxPayoutExceeded",this.gameData?.language||W)};let{selections:a,totalAmount:e}=ja.buildSelectionsAndTotal(this.derivedChips),i=e.toFixed(8);this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null;let r=Z(this.gameData.balance);try{if(this.isDemoMode&&r.lt(e))return{success:!1,error:R("alerts.insufficientBalance",this.gameData?.language||W)};this.gameData.updateBalance(r.minus(e));let n=await this.baccaratApi.startBet({language:this.gameData.language,amount:i,currency:this.gameData.currency,selections:a});if(!n.success)throw new Error(n.error);return await this.processBetResult(n.data,r,e),n}catch(n){return{success:!1,error:n instanceof Error?n.message:R("alerts.gameError",this.gameData?.language||W)}}}async toggleAutobet(a){if(this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}if(!this.autobetInProgress)this.emit("show-alert",{detail:{id:"autobet-started",type:"info",message:R("autobet.startAutobet",this.gameData?.language||W),autoCloseDelay:5000}});await super.toggleAutobet(a)}async baccaratPlay(){if(this.gameWinPopupShowing=!1,this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}this.isManualPlaying=!0;let a=await this.handleBetExecution();if(!a.success)this.showError(a.error);this.isManualPlaying=!1}async executeAutobet(a,e){try{if(this.gameWinPopupShowing=!1,this.derivedChips.size===0)return{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("games.baccarat.selectChip",this.gameData?.language||W)};let i=await this.handleBetExecution();if(!i.success)return{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||R("alerts.errorProcessingBet",this.gameData?.language||W)};let r=i.data,n=Z(r.payout??0).minus(r.amount??0),t=Na(Number(r.multiplier));if(!this.instantModeForCurrentBet){if(await ga(this.getDelay(200)),t==="Win")await ga(this.getDelay(150));await ga(300)}return await ga(this.getAutobetDelay()),this.gameWinPopupShowing=!1,{pnl:n,gameOutcome:t,hasError:!1}}catch(i){return console.error("Error in executeAutobet:",i),{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData?.language||W)}}}render(){let a=this.gameData?.mainWidth>=768,e=Ja(this.gameData),i=this.totalBetAmount===0;return x`
16012
+ `;var ms=()=>({getRandomInt:({min:a,max:e})=>{let i=Math.floor(Math.random()*(e-a+1))+a;return{value:i,values:[i],count:1,min:a,max:e,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:a,max:e,count:i})=>{let r=[];while(r.length<i){let n=Math.floor(Math.random()*(e-a+1))+a;if(!r.includes(n))r.push(n)}return{values:r,count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:a,max:e,count:i})=>{return{values:Array.from({length:i},()=>Math.floor(Math.random()*(e-a+1))+a),count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}}}),Tt=(a)=>{let e=0,i=(r)=>{let n=[];for(let t=0;t<r;t++){if(e>=a.length)throw new Error("Random sequence exhausted - not enough values provided for this action");n.push(a[e]),e++}return n};return{getRandomInt:({min:r,max:n})=>{let t=i(1);return{value:t[0],values:t,count:1,min:r,max:n,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}}}};class Et{async startBet(a){let{amount:e,selections:i}=a,r={bets:i.map((u)=>({type:u.position,amount:Z(u.amount)}))},t=new T3().getGameResult({generator:ms(),edge:1,gameInputs:r}),o=L3(r),l=o.mul(t.payoutMultiplier);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"baccarat",currency:a.currency??"USD",amount:o.toString(),payout:l.toString(),afterBalance:"1000",multiplier:t.payoutMultiplier.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),type:"START_BET",betAmount:e,payoutAmount:null,actionIndex:0,data:{BACCARAT:r}},{id:crypto.randomUUID(),type:"END_BET",betAmount:null,payoutAmount:l.toString(),actionIndex:1,data:{BACCARAT:t.outputs}}]}}}}class V0 extends ai{static styles=[...ai.styles,fs];constructor(){super();this.isManualPlaying=!1;this.resultMultiplier=null;this.history=[];this.gameWinPopupShowing=!1;this.payout=null;this.instantModeForCurrentBet=!1;this.slowRevealEnabled=!1;this.currentRound=null;new Aa(this,[...this.getChipTableHotkeys(()=>this._baccaratManualEl,()=>this._baccaratAutoEl),{key:"p",callback:()=>this.handleChipInteraction("PLAYER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"b",callback:()=>this.handleChipInteraction("BANKER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"t",callback:()=>this.handleChipInteraction("TIE"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}}])}get baccaratApi(){return this.isDemoMode?new Et:new Mt(this.gameData.authToken,this.gameData.baseUrl??"")}get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get isSlowRevealActive(){return this.slowRevealEnabled&&this.manualOrAuto==="Manual"&&!this.instantModeForCurrentBet}isMaxPayoutExceeded(a){let e=u1.deriveState(a,Z(this.gameData?.maxBet??0));return ja.getMaxPossiblePayoutFromChips(e).gt(this.gameData?.maxPayout??0)}handleGridClick=(a)=>{let{position:e,remove:i}=a.detail;this.handleChipInteraction(e,!!i)};handleSlowRevealChange=(a)=>{this.slowRevealEnabled=a.detail.enabled};resetRound(){this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null}onManualOrAutoChange(){this.resetRound()}addToHistory(a,e,i){this.history=[...this.history.filter((r)=>r.id!==i),{multiplier:a,won:e,id:i}].slice(-Jl)}onDealSound=()=>{this.gameData?.soundEffects?.play(ua.cardSlide())};onCardFlip=()=>{this.gameData?.soundEffects?.play(ua.cardFlip())};async processBetResult(a,e,i){let n=a.betActions.find((u)=>u.type==="END_BET")?.data.BACCARAT;if(!n)throw new Error("No baccarat data found");let t=ja.createGameRound(a,n);this.currentRound=t,await X1(this,"baccarat-dealing-complete",()=>!0,this.isSlowRevealActive?void 0:Vl);let o=this.isDemoMode?e.minus(i).plus(a.payout??0):Z(a.afterBalance??0);this.gameData.updateBalance(o);let l=t.multiplier,s=l>=1;if(this.resultMultiplier=l,this.betId=t.betId,this.payout=t.payout,this.gameWinPopupShowing=s,l>1)this.playWinFeedback();this.addToHistory(l,s,t.betId),this.updateHistoryWithBet(a)}async handleBetExecution(){if(this.instantModeForCurrentBet=this.gameData?.instantBetEnabled??!1,!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};if(this.derivedChips.size===0)return{success:!1,error:R("games.baccarat.selectChip",this.gameData?.language||W)};if(this.isMaxPayoutExceeded(this.chipEvents))return{success:!1,error:R("alerts.maxPayoutExceeded",this.gameData?.language||W)};let{selections:a,totalAmount:e}=ja.buildSelectionsAndTotal(this.derivedChips),i=e.toFixed(8);this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null;let r=Z(this.gameData.balance);try{if(this.isDemoMode&&r.lt(e))return{success:!1,error:R("alerts.insufficientBalance",this.gameData?.language||W)};this.gameData.updateBalance(r.minus(e));let n=await this.baccaratApi.startBet({language:this.gameData.language,amount:i,currency:this.gameData.currency,selections:a});if(!n.success)throw new Error(n.error);return await this.processBetResult(n.data,r,e),n}catch(n){return{success:!1,error:n instanceof Error?n.message:R("alerts.gameError",this.gameData?.language||W)}}}async toggleAutobet(a){if(this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}if(!this.autobetInProgress)this.emit("show-alert",{detail:{id:"autobet-started",type:"info",message:R("autobet.startAutobet",this.gameData?.language||W),autoCloseDelay:5000}});await super.toggleAutobet(a)}async baccaratPlay(){if(this.gameWinPopupShowing=!1,this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}this.isManualPlaying=!0;let a=await this.handleBetExecution();if(!a.success)this.showError(a.error);this.isManualPlaying=!1}async executeAutobet(a,e){try{if(this.gameWinPopupShowing=!1,this.derivedChips.size===0)return{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("games.baccarat.selectChip",this.gameData?.language||W)};let i=await this.handleBetExecution();if(!i.success)return{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||R("alerts.errorProcessingBet",this.gameData?.language||W)};let r=i.data,n=Z(r.payout??0).minus(r.amount??0),t=Na(Number(r.multiplier));if(!this.instantModeForCurrentBet){if(await ga(this.getDelay(200)),t==="Win")await ga(this.getDelay(150));await ga(300)}return await ga(this.getAutobetDelay()),this.gameWinPopupShowing=!1,{pnl:n,gameOutcome:t,hasError:!1}}catch(i){return console.error("Error in executeAutobet:",i),{pnl:Z(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData?.language||W)}}}render(){let a=this.gameData?.mainWidth>=768,e=Ja(this.gameData),i=this.totalBetAmount===0;return x`
16013
16013
  <origami-game-layout style=${e} .gameType=${"BACCARAT"} data-is-desktop=${a}>
16014
16014
  <origami-game-sidebar
16015
16015
  slot="control-panel"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/games",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",