@betorigami/game-calculations 5.1.0 → 5.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 +1 -1
- package/dist/index.d.ts +84 -8
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var qr=Object.create;var{getPrototypeOf:Qr,defineProperty:q,getOwnPropertyNames:Da,getOwnPropertyDescriptor:gr}=Object,xa=Object.prototype.hasOwnProperty;var H=(t,a,r)=>{r=t!=null?qr(Qr(t)):{};let e=a||!t||!t.__esModule?q(r,"default",{value:t,enumerable:!0}):r;for(let o of Da(t))if(!xa.call(e,o))q(e,o,{get:()=>t[o],enumerable:!0});return e},ha=new WeakMap,Wr=(t)=>{var a=ha.get(t),r;if(a)return a;if(a=q({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")Da(t).map((e)=>!xa.call(a,e)&&q(a,e,{get:()=>t[e],enumerable:!(r=gr(t,e))||r.enumerable}));return ha.set(t,a),a};var Lr=(t,a)=>{for(var r in a)q(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(e)=>a[r]=()=>e})};var Qe={};Lr(Qe,{validateRouletteGameInputs:()=>Je,validateAdvancedDiceInputs:()=>ae,rtp99Multipliers:()=>xr,rtp98Multipliers:()=>Cr,rtp97Multipliers:()=>Pr,rtp96Multipliers:()=>Tr,rtp92Multipliers:()=>Rr,plinkoMultipliers:()=>ca,nCr:()=>bt,kenoMultipliers:()=>ea,isTileCount:()=>ra,hasDiceWon:()=>Hr,hasBlitzWon:()=>ur,getMaxMultiplierForDifficulty:()=>fe,getBlitzDefaults:()=>de,diamondsMultipliers:()=>Er,calculateRouletteBetAmount:()=>Fe,calculateDiceWinChance:()=>Or,calculateBlitzWinChance:()=>sr,calculateBaccaratBetAmount:()=>Ua,calculateAdvancedDiceWinChance:()=>kt,bigMin:()=>na,bigMax:()=>oa,advancedDiceIsWithinBoundsInclusive:()=>Ra,advancedDiceIsWithinBoundsExclusive:()=>dt,advancedDiceGetInclusiveBoundsRange:()=>ja,advancedDiceGetExclusiveBoundsRange:()=>ut,WheelSegments:()=>z,WheelRiskLevel:()=>$,Wheel:()=>Xr,WIN_MULTIPLIER:()=>Ga,VALID_SUITS:()=>Na,VALID_RANKS:()=>Va,VALID_EUROPEAN_STREETS:()=>sa,VALID_EUROPEAN_STRAIGHTS:()=>_t,VALID_EUROPEAN_SPLITS:()=>da,VALID_EUROPEAN_DOUBLE_STREETS:()=>ya,VALID_EUROPEAN_CORNERS:()=>Aa,VALID_AMERICAN_STREETS:()=>pa,VALID_AMERICAN_STRAIGHTS:()=>la,VALID_AMERICAN_SPLITS:()=>ua,VALID_AMERICAN_DOUBLE_STREETS:()=>Ea,VALID_AMERICAN_CORNERS:()=>Ba,ThreeCardBonusType:()=>Et,TOP_COLUMN:()=>Ur,TILE_COUNTS:()=>Dr,THREE_CARD_BONUS_PAYOUTS:()=>Jt,SingleActionGame:()=>A,SPLIT_BET_SIZE_FACTOR:()=>N,RouletteType:()=>Nt,Roulette:()=>Ha,RollType:()=>ba,RandomValuePool:()=>tt,RED_NUMBERS:()=>Gr,RANDOM_MIN_VALUE:()=>st,RANDOM_MAX_VALUE:()=>pt,PlinkoRiskLevel:()=>ia,Plinko:()=>Ir,Parity:()=>w,PairBonusType:()=>yt,PUSH_MULTIPLIER:()=>Ma,PLINKO_ROW_COUNTS:()=>Te,PAYOUT_MULTIPLIERS:()=>wr,PAIR_BONUS_PAYOUTS:()=>Ft,OrigamiGame:()=>f,MultiplierCalculator:()=>P,MultiActionGame:()=>Ct,Mines:()=>Nr,MIN_WIN_CHANCE:()=>Pa,MIDDLE_COLUMN:()=>Zr,MAX_WIN_CHANCE:()=>Ta,MAX_CARDS_PER_ROUND:()=>St,Limbo:()=>_r,LOSE_MULTIPLIER:()=>Fa,KenoRiskLevel:()=>aa,Keno:()=>br,InsuranceOutcome:()=>Bt,INSURANCE_WIN_PAYOUT:()=>Ot,INSURANCE_BET_SIZE_FACTOR:()=>F,INSURANCE_BET_MULTIPLIER:()=>ee,Half:()=>Z,GameErrorCode:()=>Ca,GameError:()=>l,Game:()=>M,FACE_CARD_VALUE:()=>Mt,EuropeanRoulette:()=>Sa,EUROPEAN_HOUSE_EDGE:()=>Fr,EFFECTIVE_RANGE:()=>Ut,Dozen:()=>G,DiceDirection:()=>Sr,Dice:()=>hr,DiamondsResultType:()=>yr,Diamonds:()=>fr,Darts:()=>Br,DOUBLE_DOWN_BET_SIZE_FACTOR:()=>R,DICE_EFFECTIVE_RANGE:()=>vt,DEALER_STAND_VALUE:()=>Gt,DARTS_MIN_VALUE:()=>Lt,DARTS_MAX_VALUE:()=>Tt,DARTS_DIFFICULTY_LEVEL:()=>Kt,DARTS_BOARD_CONFIGS:()=>Rt,Column:()=>k,Color:()=>U,CARDS_PER_SUIT:()=>oe,Blitz:()=>pr,BlackjackOutcome:()=>At,BlackjackActionType:()=>mt,Blackjack:()=>lr,BaccaratOutcome:()=>Ia,BaccaratBetType:()=>wa,Baccarat:()=>Za,BUST_VALUE:()=>ft,BOTTOM_COLUMN:()=>kr,BLITZ_RANDOM_NUMBER_COUNT:()=>Wt,BLITZ_MIN_CARD_RANGE:()=>Qt,BLITZ_MAX_CARD_RANGE:()=>gt,BLITZ_CARD_COUNT:()=>J,BLACK_NUMBERS:()=>Mr,BLACKJACK_VALUE:()=>h,BLACKJACK_MULTIPLIER:()=>ka,BASE_PAYOUT_MULTIPLIERS:()=>Q,AmericanRoulette:()=>Oa,AdvancedDice:()=>_a,AMERICAN_HOUSE_EDGE:()=>Jr,AMERICAN_BASKET:()=>ma,ACE_SOFT_BONUS:()=>Ht});module.exports=Wr(Qe);var Ca;((a)=>a.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(Ca||={});class l extends Error{static createValidationError(t){return new l("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof l}errorCode;constructor(t,a){super(a);this.errorCode=t}}var f;((B)=>{B.DICE="DICE";B.MINES="MINES";B.KENO="KENO";B.LIMBO="LIMBO";B.ADVANCED_DICE="ADVANCED_DICE";B.BACCARAT="BACCARAT";B.DIAMONDS="DIAMONDS";B.PLINKO="PLINKO";B.ROULETTE="ROULETTE";B.WHEEL="WHEEL";B.BLACKJACK="BLACKJACK";B.BLITZ="BLITZ";B.DARTS="DARTS"})(f||={});class M{gameId;constructor(t){this.gameId=t}}class A extends M{constructor(t){super(t)}getGameResult(t){return this.determineGameResult(t)}}var Zt=require("big.js");var ct=H(require("big.js"));class P{static withMultiplier(t,a){return new ct.default(t).times(new ct.default(100-a).div(100))}static withWinChance(t,a){return ct.default(100-t).div(a)}}var st=0,pt=1e4,Ut=10001,Pa=0.01,Ta=98,Kr=(t)=>{if(t<st)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${st}`)},vr=(t)=>{if(t>pt)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${pt}`)},lt=(t)=>{if(Kr(t.lower),vr(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},te=(t,a)=>{let[r,e]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>e.lower)throw l.createValidationError("Bounds must not overlap")},Ra=(t,a)=>a>=t.lower&&a<=t.upper,ja=(t)=>t.upper-t.lower+1,dt=(t,a)=>a>t.lower&&a<t.upper,ut=(t)=>t.upper-t.lower-1,ba;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(ba||={});var kt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return lt(t.bounds),ut(t.bounds);case"ROLL_OUTSIDE":return lt(t.bounds),Ut-ja(t.bounds);case"ROLL_BETWEEN_TWO":return lt(t.firstBounds),lt(t.secondBounds),te(t.firstBounds,t.secondBounds),ut(t.firstBounds)+ut(t.secondBounds)}})(),e=Zt.Big(r).div(Ut).mul(100);if(e.lt(Pa))throw l.createValidationError("Win chance too low");if(e.gt(Ta))throw l.createValidationError("Win chance too high");return e},ae=(t)=>{kt(t)};class _a extends A{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=kt(r),o=t.getRandomInt({min:st,max:pt}),n=o.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return dt(r.bounds,n);case"ROLL_OUTSIDE":return!Ra(r.bounds,n);case"ROLL_BETWEEN_TWO":return dt(r.firstBounds,n)||dt(r.secondBounds,n)}})()?P.withWinChance(a,e):new Zt.Big(0),outputs:{result:o.values},randomValues:o}}}var _=H(require("big.js"));var Na=["Clubs","Diamonds","Hearts","Spades"],Va=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],Ia;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(Ia||={});var wa;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(wa||={});var re={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Ua=(t)=>{return new _.default(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new _.default(0)))};class Za extends A{constructor(){super("BACCARAT")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(r!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(a);let e=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),o=e.values,n=o.slice(0,3),i=o.slice(3,6),c=[],d=0;for(let E of n.slice(0,2)){let C=this.mapRandomValueToCard(E),it=this.mapRandomValueToCardValue(E);c.push(C),d=(d+it)%10}let p=[],u=0;for(let E of i.slice(0,2)){let C=this.mapRandomValueToCard(E),it=this.mapRandomValueToCardValue(E);p.push(C),u=(u+it)%10}if(!this.isNaturalWin(d,u)){let E=this.shouldDrawThirdPlayerCard(d),C=null;if(E)C=this.mapRandomValueToCardValue(n[2]),c.push(this.mapRandomValueToCard(n[2])),d=(d+C)%10;if(this.shouldDrawThirdBankerCard(u,C))p.push(this.mapRandomValueToCard(i[2])),u=(u+this.mapRandomValueToCardValue(i[2]))%10}let s;if(d===u)s="TIE";else s=d>u?"PLAYER_WIN":"BANKER_WIN";let y=Ua(a),{betType:B,multiplier:wt}=re[s],X=new _.default(0);if(X=X.add(a.bets.filter((E)=>E.type===B).reduce((E,C)=>E.add(C.amount.mul(wt)),new _.default(0))),s==="TIE")X=X.add(a.bets.filter((E)=>E.type==="PLAYER"||E.type==="BANKER").reduce((E,C)=>E.add(C.amount),new _.default(0)));return{isFinished:!0,payoutMultiplier:y.gt(0)?X.div(y):new _.default(0),outputs:{playerCards:c,playerHandValue:d,bankerCards:p,bankerHandValue:u,gameOutcome:s,result:e.values},randomValues:e}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=Na[Math.floor(t/13)],r=Va[t%13];return{suit:a,rank:r}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var At;((o)=>{o.WIN="WIN";o.LOSE="LOSE";o.PUSH="PUSH";o.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(At||={});var Bt;((r)=>{r.WON="WON";r.LOST="LOST"})(Bt||={});var mt;((c)=>{c.START="START";c.HIT="BLACKJACK_HIT";c.STAND="BLACKJACK_STAND";c.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";c.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";c.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";c.SPLIT="BLACKJACK_SPLIT"})(mt||={});var yt;((o)=>{o.EXACT_PAIR="EXACT_PAIR";o.COLORED_PAIR="COLORED_PAIR";o.MIXED_PAIR="MIXED_PAIR";o.LOSS="LOSS"})(yt||={});var Et;((i)=>{i.SUITED_TRIPS="SUITED_TRIPS";i.STRAIGHT_FLUSH="STRAIGHT_FLUSH";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.STRAIGHT="STRAIGHT";i.FLUSH="FLUSH";i.LOSS="LOSS"})(Et||={});var ka=2.5,Ga=2,Ma=1,Fa=0,Gt=17,ft=21,h=21,St=63,ee=1.5,F=0.5,Ot=1.5,R=1,N=1,oe=13,Ht=10,Mt=10,Q={PLAYER_BLACKJACK:ka,WIN:Ga,PUSH:Ma,LOSE:Fa},Ft={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Jt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var b=H(require("big.js")),m=require("@betorigami/guard"),ir=require("@xstate/store");var Ja=0,Ya=51,ht=Array.from({length:52},(t,a)=>a),$a=["Spades","Hearts","Diamonds","Clubs"],Dt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],za=["Jack","Queen","King"],Yt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};var Xa=require("@betorigami/guard");var xt=require("@betorigami/guard");class g{value;constructor(t){let a=ht[t];xt.Guard.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=$a[t];return xt.Guard.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=Dt[t];return xt.Guard.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}class S extends g{get numericRank(){if(za.includes(this.rank))return Mt;return Dt.indexOf(this.rank)+1}static fromValue(t){return Xa.Guard.against(!ht.includes(t),`Invalid card value: ${t}`),new S(t)}}class W{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,e)=>r+e.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+Ht<=ft)this.softHandValue=this.hardHandValue+Ht}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>ft}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===h}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class L{cards;value;constructor(t){this.cards=t.map((a)=>S.fromValue(a)),this.value=new W(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class K extends L{otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=S.fromValue(t),this.holeCard=S.fromValue(a)}static withInitialDeal(t){return new K(t.upCard,t.holeCard)}addDrawnCards(t){return new K(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new W([this.upCard]).highestHandValue}}}class V extends L{static withInitialDeal(t){return new V(t)}addDrawnCards(t){return new V([...this.rawValues,...t])}}var v=require("@betorigami/guard");class tt{source;index=0;constructor(t){this.source=t}static from(t,a){return v.Guard.against(a<=0,`Count must be positive, got ${a}`),v.Guard.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new tt(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return v.Guard.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){v.Guard.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}var qa=require("@betorigami/guard"),Qa=H(require("fast-deep-equal"));class Ct extends M{edge;constructor(t,a){super(t);this.edge=a}play(t,a,r=[]){let e=this.createGameStore(),o=this.generateRandomValues(t),n=o.toMultipleRandomValues();for(let d of r)e.send({...d.playerArgument,randomValuePool:o});let i=r[r.length-1];if(i)qa.Guard.against(!Qa.default(i.state,this.toExternalState(e.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");e.send({...a,randomValuePool:o});let c=e.getSnapshot().context;return{playerArgument:c.playerArgument,state:this.toExternalState(c.state),config:c.config,additionalBetAmount:c.additionalBetAmount,proof:{proofHash:n.proofHash,proofString:n.proofString}}}}var D=H(require("big.js"));var Pt=require("@betorigami/guard");var ga=(t)=>{let a=t.pairBonus!==null?D.default(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier):D.default(0),r=t.threeCardBonus!==null?D.default(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier):D.default(0);return a.plus(r)},Wa=(t)=>{let a=t.betAmounts.mainBetAmount,e=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(R):D.default(0),o=t.insuranceOutcome!==void 0?a.mul(F):D.default(0),n=a.plus(e).mul(Q[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(Ot):D.default(0),c=ga(t.sideBetResults),d=n.plus(i).plus(c),p=a.plus(o).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Pt.Guard.against(p.eq(0),"Total bet amount cannot be zero");let u=d.div(p);Pt.Guard.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let s;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":s=e;break;case"BLACKJACK_BUY_INSURANCE":s=o;break;case"BLACKJACK_SPLIT":s=a.mul(N);break}return{multiplier:u,additionalBetAmount:s}},La=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(R):D.default(0),e=t.splitHandDoubledDown?a.mul(R):D.default(0),o=t.insuranceOutcome!==void 0?a.mul(F):D.default(0),n=a.plus(r).mul(Q[t.mainOutcome]),i=a.plus(e).mul(Q[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(Ot):D.default(0),d=ga(t.sideBetResults),p=n.plus(i).plus(c).plus(d),u=a.plus(a).plus(o).plus(r).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Pt.Guard.against(u.eq(0),"Total bet amount cannot be zero");let s=p.div(u),y;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":y=a.mul(R);break;case"BLACKJACK_SPLIT":y=a.mul(N);break}return{multiplier:s,additionalBetAmount:y}};var va=require("@betorigami/guard"),$t=(t)=>t.every((a)=>a===t[0]),Ka=(t)=>{let a=[...t].sort((r,e)=>r-e);return a.every((r,e)=>{let o=a[e-1];if(e===0)return!0;return va.Guard.againstUndefined(o,"Previous value cannot be undefined"),r===o+1})},tr={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},ne={...tr,Ace:14},ie=(t)=>Ka(t.map((a)=>tr[a]))||Ka(t.map((a)=>ne[a])),ar=(t,a)=>{let r=S.fromValue(t),e=S.fromValue(a);if(r.rank!==e.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Yt[r.suit]===Yt[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},rr=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Ft[a]}),er=(t,a,r)=>{let e=S.fromValue(t),o=S.fromValue(a),n=S.fromValue(r),i=[e.rank,o.rank,n.rank],c=$t([e.suit,o.suit,n.suit]),d=$t(i),p=ie(i);if($t([t,a,r]))return"SUITED_TRIPS";if(c&&p)return"STRAIGHT_FLUSH";if(d)return"THREE_OF_A_KIND";if(p)return"STRAIGHT";if(c)return"FLUSH";return"LOSS"},or=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Jt[a]});var ce={state:{isFinished:!1,phase:"uninitialised",multiplier:b.default(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},O=(t)=>S.fromValue(t).value;function le(t){m.Guard.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function nr(t){m.Guard.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function zt(t){m.Guard.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var cr=(t,a)=>{let r=a;while(r.highestHandValue<Gt)r=r.addDrawnCards([O(t.takeOne())]);return r},qt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,e=a.highestHandValue;if(r>e)return"WIN";if(r<e)return"LOSE";return"PUSH"},x=(t)=>{let{multiplier:a,additionalBetAmount:r}=Wa({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,multiplier:a,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:r}},Xt=(t)=>{let a=cr(t.randomValuePool,t.dealerHand),r=qt(t.playerHand,a);return x({...t,dealerHand:a,outcome:r})},j=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:cr(t.randomValuePool,t.dealerHand),e=qt(t.mainHand,r),o=qt(t.splitHand,r),{multiplier:n,additionalBetAmount:i}=La({hasSplit:!0,mainOutcome:e,splitOutcome:o,insuranceOutcome:t.insuranceOutcome,mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:e,splitOutcome:o,multiplier:n,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class lr extends Ct{constructor(t){super("BLACKJACK",t)}generateRandomValues(t){return tt.from(t.getRandomIntsWithReplacement({min:Ja,max:Ya,count:St}),St)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:m.Guard.againstNever(a,"Invalid state received")}}createGameStore(){return ir.createStore({context:ce,on:{START:(t,a)=>{let{state:r}=t;m.Guard.against(r.phase!=="uninitialised","START action requires a fresh game");let e=O(a.randomValuePool.takeOne()),o=O(a.randomValuePool.takeOne()),n=O(a.randomValuePool.takeOne()),i=O(a.randomValuePool.takeOne()),c=V.withInitialDeal([e,o]),d=K.withInitialDeal({upCard:n,holeCard:i}),p={mainBetAmount:b.default(a.mainBetAmount),pairBonusAmount:b.default(a.pairBonusAmount),threeCardBonusAmount:b.default(a.threeCardBonusAmount)},u={pairBonus:b.default(a.pairBonusAmount).gt(0)?rr(a.pairBonusAmount,ar(e,o)):null,threeCardBonus:b.default(a.threeCardBonusAmount).gt(0)?or(a.threeCardBonusAmount,er(e,o,n)):null},s={type:"START",mainBetAmount:a.mainBetAmount,pairBonusAmount:a.pairBonusAmount,threeCardBonusAmount:a.threeCardBonusAmount};if(d.upCard.rank==="Ace")return{state:{...r,isFinished:!1,phase:"awaiting-insurance",playerHand:c,dealerHand:d,betAmounts:p,sideBetResults:u},config:{},playerArgument:s};let y={playerHand:c,dealerHand:d,randomValuePool:a.randomValuePool,playerArgument:s,betAmounts:p,sideBetResults:u};if(c.isBlackjack&&d.isBlackjack)return x({...y,outcome:"PUSH"});if(c.isBlackjack)return x({...y,outcome:"PLAYER_BLACKJACK"});if(d.isBlackjack)return x({...y,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:c,dealerHand:d,insuranceOutcome:void 0,betAmounts:p,sideBetResults:u},config:{},playerArgument:s}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;nr(r);let{playerHand:e,dealerHand:o,betAmounts:n,sideBetResults:i}=r,c={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:n,sideBetResults:i};if(e.isBlackjack&&o.isBlackjack)return x({...c,outcome:"PUSH",insuranceOutcome:"WON"});if(e.isBlackjack)return x({...c,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(o.isBlackjack)return x({...c,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:n.mainBetAmount.mul(F)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;nr(r);let{playerHand:e,dealerHand:o,betAmounts:n,sideBetResults:i}=r,c={playerHand:e,dealerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:n,sideBetResults:i};if(e.isBlackjack&&o.isBlackjack)return x({...c,outcome:"PUSH"});if(e.isBlackjack)return x({...c,outcome:"PLAYER_BLACKJACK"});if(o.isBlackjack)return x({...c,outcome:"LOSE"});return{state:{...r,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(t,a)=>{let{state:r}=t;switch(zt(r),r.phase){case"playing-main-hand":{let e=r.mainHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===h){if(r.splitHand.highestHandValue===h)return j({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let e=r.splitHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===h)return j({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let e=r.playerHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted)return x({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(e.highestHandValue===h)return Xt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:m.Guard.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(zt(r),r.phase){case"playing-main-hand":{if(r.splitHand.highestHandValue===h)return j({...r,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...r,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return j({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return Xt({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:m.Guard.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(zt(r),r.phase){case"playing-main-hand":{m.Guard.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.mainHand.addDrawnCards([O(a.randomValuePool.takeOne())]),{betAmounts:o}=r;if(r.splitHand.highestHandValue===h)return j({...r,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:o.mainBetAmount.mul(R)}}case"playing-split-hand":{m.Guard.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.splitHand.addDrawnCards([O(a.randomValuePool.takeOne())]);return j({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{m.Guard.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.playerHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted)return x({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return Xt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:m.Guard.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;le(r);let{playerHand:e,betAmounts:o,sideBetResults:n}=r;m.Guard.against(e.cards.length!==2,"Split is only allowed with exactly 2 cards");let i=e.cards[0],c=e.cards[1];m.Guard.againstUndefined(i,"First card is missing"),m.Guard.againstUndefined(c,"Second card is missing"),m.Guard.against(i.rank!==c.rank,"Split requires two cards of the same rank");let d=O(a.randomValuePool.takeOne()),p=O(a.randomValuePool.takeOne()),u=V.withInitialDeal([i.value,d]),s=V.withInitialDeal([c.value,p]);if(i.rank==="Ace")return j({...r,mainHand:u,splitHand:s,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let B=u.highestHandValue===h,wt=s.highestHandValue===h;if(B&&wt)return j({mainHand:u,splitHand:s,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:o,sideBetResults:n});if(B)return{state:{...r,phase:"playing-split-hand",mainHand:u,splitHand:s,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(N)};return{state:{...r,phase:"playing-main-hand",multiplier:b.default(0),mainHand:u,splitHand:s,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(N)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],e=t.playerHand.cards[1];if(m.Guard.againstUndefined(r,"First player card is missing"),m.Guard.againstUndefined(e,"Second player card is missing"),r.rank===e.rank)a.push("BLACKJACK_SPLIT")}return a}default:m.Guard.againstNever(t,"Invalid phase for getting valid actions")}}}var Y=H(require("big.js")),dr=require("@betorigami/guard");var Qt=0,gt=51,J=52,Wt=52;var de=()=>({minPicks:5,maxPicks:36}),ur=(t)=>t.length===new Set(t).size,sr=(t)=>{let a=Y.default(1),r=Y.default(J);for(let e=0;e<t;e+=1)a=a.mul(Y.default(J-e).div(r));return a};class pr extends A{constructor(){super("BLITZ")}determineGameResult({generator:t,gameInputs:a,edge:r}){dr.Guard.against(a.pickCount<1||a.pickCount>J,`pickCount must be between 1 and ${J}`);let e=t.getRandomIntsWithReplacement({min:Qt,max:gt,count:Wt}),o=e.values.slice(0,a.pickCount),n=ur(o),i=sr(a.pickCount);return{isFinished:!0,payoutMultiplier:n?P.withMultiplier(Y.default(1).div(i),r):Y.default(0),outputs:{result:e.values,cards:o.map((d)=>new g(d).toDto())},randomValues:e}}}var Lt=0,Tt=4294967295,Kt;((o)=>{o.EASY="EASY";o.MEDIUM="MEDIUM";o.HARD="HARD";o.EXPERT="EXPERT"})(Kt||={});var ue=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],se={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:ue},pe=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Ae={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:pe},Be=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],me={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:Be},ye=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Ee={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:ye},fe=(t)=>{let a=Rt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((e,o)=>o>e?o:e)},Rt={EASY:se,MEDIUM:Ae,HARD:me,EXPERT:Ee};var jt=require("@betorigami/guard"),Ar=H(require("big.js"));class Br extends A{constructor(){super("DARTS")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(r!==2)throw new Error("Darts is only available at 2% edge");let e=t.getRandomIntsWithReplacement({min:Lt,max:Tt,count:2}),o=e.values[0],n=e.values[1];jt.Guard.againstUndefined(o,"Random number generator returned no value for clockWiseRotation"),jt.Guard.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let i=a.difficultyLevel;return{isFinished:!0,payoutMultiplier:Ar.default(Se(i,o,n)),outputs:{result:e.values},randomValues:e}}}var Se=(t,a,r)=>{let e=Rt[t],{distanceBoundaries:o,multipliers:n}=e;if(r<o.bullseye)return n.bullseye;if(r<o.ringOne)return n.ringOne;if(r<o.ringTwo)return n.ringTwo;if(r<o.ringThree)return Oe(e,a);return n.ringFour},Oe=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(Tt+1)*r),o=t.segments[e];return jt.Guard.againstUndefined(o,`Segment index ${e} out of bounds`),t.multipliers.ringThree[o]};var mr=H(require("big.js"));class T{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var yr;((i)=>{i.PAIR="PAIR";i.TWO_PAIR="TWO_PAIR";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.FULL_HOUSE="FULL_HOUSE";i.FOUR_OF_A_KIND="FOUR_OF_A_KIND";i.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(yr||={});var He={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},he={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},De={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},xe={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},Ce={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},Er=new T(new Map([[1,He],[2,he],[3,De],[4,xe],[8,Ce]])),Pe={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class fr extends A{constructor(){super("DIAMONDS")}determineGameResult({generator:t,edge:a}){let r=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=Er.getMultipliers(a),o=r.values,n=this.calculatePayoutMultiplier(e,o);return{isFinished:!0,payoutMultiplier:mr.default(n),outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(t,a){let r=new Map;for(let n of a){let i=r.get(n)||0;r.set(n,i+1)}let e=[...r.values()].filter((n)=>n>1),o=this.classifyResult(e);return o===null?0:t[o]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let e=Pe[a];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return e}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}var ta=H(require("big.js"));var Sr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Sr||={});var vt=1e4,Or=(t)=>{let a=t.direction==="ABOVE"?vt-t.selectedValue:t.selectedValue;return new ta.default(a).div(vt).mul(100)},Hr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class hr extends A{constructor(){super("DICE")}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:0,max:1e4}),o=Or(r);return{isFinished:!0,payoutMultiplier:Hr(r,e.value)?P.withWinChance(a,o):new ta.default(0),outputs:{result:e.values},randomValues:e}}}var jr=H(require("big.js"));var at=require("@betorigami/guard");var aa;((o)=>{o.CLASSIC="CLASSIC";o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(aa||={});var Dr=[1,2,3,4,5,6,7,8,9,10],ra=(t)=>{return Dr.includes(t)};var xr={[1]:{CLASSIC:[0,3.96],LOW_RISK:[0.7,1.85],MEDIUM_RISK:[0.4,2.75],HIGH_RISK:[0,3.96]},[2]:{CLASSIC:[0,1.9,4.5],LOW_RISK:[0,2,3.8],MEDIUM_RISK:[0,1.8,5.1],HIGH_RISK:[0,0,17.1]},[3]:{CLASSIC:[0,1,3.1,10.4],LOW_RISK:[0,1.1,1.38,26],MEDIUM_RISK:[0,0,2.8,50],HIGH_RISK:[0,0,0,81.5]},[4]:{CLASSIC:[0,0.8,1.8,5,22.5],LOW_RISK:[0,0,2.2,7.9,90],MEDIUM_RISK:[0,0,1.7,10,100],HIGH_RISK:[0,0,0,10,259]},[5]:{CLASSIC:[0,0.25,1.4,4.1,16.5,36],LOW_RISK:[0,0,1.5,4.2,13,300],MEDIUM_RISK:[0,0,1.4,4,14,390],HIGH_RISK:[0,0,0,4.5,48,450]},[6]:{CLASSIC:[0,0,1,3.68,7,16.5,40],LOW_RISK:[0,0,1.1,2,6.2,100,700],MEDIUM_RISK:[0,0,0,3,9,180,710],HIGH_RISK:[0,0,0,0,11,350,710]},[7]:{CLASSIC:[0,0,0.47,3,4.5,14,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,15,225,700],MEDIUM_RISK:[0,0,0,2,7,30,400,800],HIGH_RISK:[0,0,0,0,7,90,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,13,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,5.5,39,100,800],MEDIUM_RISK:[0,0,0,2,4,11,67,400,900],HIGH_RISK:[0,0,0,0,5,20,270,600,900]},[9]:{CLASSIC:[0,0,0,1.55,3,8,15,44,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1000],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1000]}},Cr={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},Pr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},Tr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.68,1.84],MEDIUM_RISK:[0.38,2.74],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,1.96,3.75],MEDIUM_RISK:[0,1.77,5],HIGH_RISK:[0,0,16.82]},[3]:{CLASSIC:[0,1,3.05,9.35],LOW_RISK:[0,1.07,1.37,25.7],MEDIUM_RISK:[0,0,2.74,49],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.72,4.95,22.3],LOW_RISK:[0,0,2.15,7.86,87],MEDIUM_RISK:[0,0,1.67,9.7,100],HIGH_RISK:[0,0,0,9.7,256]},[5]:{CLASSIC:[0,0.24,1.38,4,16.3,35.5],LOW_RISK:[0,0,1.48,4.1,12.43,300],MEDIUM_RISK:[0,0,1.35,3.96,13.8,389],HIGH_RISK:[0,0,0,4.4,47,444]},[6]:{CLASSIC:[0,0,1,3.57,6.8,16.2,37],LOW_RISK:[0,0,1.06,1.96,6.16,99,700],MEDIUM_RISK:[0,0,0,2.9,8.9,178,709],HIGH_RISK:[0,0,0,0,10.4,347,709]},[7]:{CLASSIC:[0,0,0.45,2.95,4.44,13.85,30,60],LOW_RISK:[0,0,1.07,1.57,3.47,14.57,225,700],MEDIUM_RISK:[0,0,0,1.95,6.8,29.8,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.15,3.9,12.9,21.9,55,70],LOW_RISK:[0,0,1.08,1.45,1.98,5.48,38.8,100,800],MEDIUM_RISK:[0,0,0,1.95,3.96,10.6,66.9,396,896],HIGH_RISK:[0,0,0,0,4.9,19.2,269,599,896]},[9]:{CLASSIC:[0,0,0,1.5,2.95,7.96,14.96,44,60,85],LOW_RISK:[0,0,1.05,1.29,1.69,2.49,7.49,49,250,1000],MEDIUM_RISK:[0,0,0,1.95,2.47,4.9,14.9,99,500,1000],HIGH_RISK:[0,0,0,0,3.96,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.45,7.7,16.7,50,80,100],LOW_RISK:[0,0,1.08,1.18,1.28,1.76,3.4,12.9,50,250,1000],MEDIUM_RISK:[0,0,0,1.57,1.95,3.96,6.9,25.5,100,500,1000],HIGH_RISK:[0,0,0,0,3.43,7.9,12.5,60,500,800,1000]}},Rr={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},ea=new T(new Map([[1,xr],[2,Cr],[3,Pr],[4,Tr],[8,Rr]]));class br extends A{constructor(){super("KENO")}determineGameResult({generator:t,edge:a,gameInputs:r}){at.Guard.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),at.Guard.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let s of r.selectedNumbers)at.Guard.againstNonInteger(s,()=>l.createValidationError("Only integers can be selected")),at.Guard.against(s<0||s>39,()=>l.createValidationError("Invalid number selected"));let e=t.getUniqueRandomInts({min:0,max:39,count:10}),o=r.selectedNumbers.filter((s)=>e.values.includes(s)),n=r.selectedNumbers.length;if(!ra(n))throw new Error(`Invalid tile count: ${n}`);let p=ea.getMultipliers(a)[n][r.riskLevel][o.length];if(p===void 0)throw new Error(`No multiplier found for matching tile count ${o.length}`);return{isFinished:!0,payoutMultiplier:new jr.default(p),outputs:{result:e.values},randomValues:e}}}var I=H(require("big.js"));var oa=(t,a)=>{return t.gt(a)?t:a};var na=(t,a)=>{return t.lt(a)?t:a};class _r extends A{constructor(){super("LIMBO")}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:1,max:4294967295}),o=e.max,n=new I.default(16777216),i=new I.default(1),c=new I.default(1e6),d=e.value,p=new I.default(d-1).div(o),u=(100-a)/100,s=n.div(p.mul(n).plus(1)).mul(u),y=oa(i,na(s,c));return{isFinished:!0,payoutMultiplier:y.gte(r.targetMultiplier)?new I.default(r.targetMultiplier):new I.default(0),outputs:{randomMultiplier:y,result:e.values},randomValues:e}}}var rt=H(require("big.js"));var bt=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let e=1;e<=a;e++)r=r*(t-e+1)/e;return r};class Nr extends A{constructor(){super("MINES")}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let i=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),c=i.values.some((B)=>r.selectedTiles.includes(B)),d=r.hasCashedOut||c,p=(100-a)/100,u=new rt.default(bt(25-r.minesCount,r.selectedTiles.length)).div(new rt.default(bt(25,r.selectedTiles.length))),y=r.hasCashedOut&&!c?new rt.default(p).div(u):new rt.default(0);return{isFinished:d,payoutMultiplier:y,outputs:{result:i.values},randomValues:i}}}var Vr=require("big.js");var ia;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(ia||={});var Te=[8,9,10,11,12,13,14,15,16],Re={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},je={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},be={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},_e={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},Ne={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},ca=new T(new Map([[1,Re],[2,je],[3,be],[4,_e],[8,Ne]]));class Ir extends A{constructor(){super("PLINKO")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=a.numberOfRows,i=ca.getMultipliers(r)[a.riskLevel][e],c=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),p=c.values.reduce((s,y)=>s+y,0),u=i[p];if(u===void 0)throw new Error(`No payout found for end position ${p}`);return{isFinished:!0,payoutMultiplier:Vr.Big(u),outputs:{result:c.values},randomValues:c}}}var nt=require("big.js");var _t=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],la=[37,..._t],da=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],ua=[[0,1],[0,37],[3,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],sa=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],pa=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],Aa=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Ba=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],ma=[0,1,2,3,37],ya=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],Ea=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],w;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(w||={});var U;((r)=>{r.RED="RED";r.BLACK="BLACK"})(U||={});var Z;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(Z||={});var k;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(k||={});var G;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(G||={});var Nt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Nt||={});var Vt=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&et(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Ve(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Ie(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&we(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Ue(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(w).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},et=(t)=>{return _t.includes(t)},Ve=(t)=>{if(t.length!==2)return!1;if(!t.every(et))return!1;return da.some(([a,r])=>a===t[0]&&r===t[1])},Ie=(t)=>{if(t.length!==3)return!1;if(!t.every(et))return!1;return sa.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},we=(t)=>{if(t.length!==4)return!1;if(!t.every(et))return!1;return Aa.some(([a,r,e,o])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3])},Ue=(t)=>{if(t.length!==6)return!1;if(!t.every(et))return!1;return ya.some(([a,r,e,o,n,i])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3]&&n===t[4]&&i===t[5])};var It=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&ot(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Ze(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&ke(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Ge(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw l.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Me(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(w).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},ot=(t)=>{return la.includes(t)};function Ze(t){if(t.length!==2)return!1;if(!t.every(ot))return!1;return ua.some(([a,r])=>a===t[0]&&r===t[1])}var ke=(t)=>{if(t.length!==3)return!1;if(!t.every(ot))return!1;return pa.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},Ge=(t)=>{if(t.length!==4)return!1;if(!t.every(ot))return!1;return Ba.some(([a,r,e,o])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3])},Me=(t)=>{if(t.length!==6)return!1;if(!t.every(ot))return!1;return Ea.some(([a,r,e,o,n,i])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3]&&n===t[4]&&i===t[5])};var wr={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Ur=[3,6,9,12,15,18,21,24,27,30,33,36],Zr=[2,5,8,11,14,17,20,23,26,29,32,35],kr=[1,4,7,10,13,16,19,22,25,28,31,34],Gr=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Mr=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35],Fr=2.7,Jr=5.3;class fa extends A{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),e=r.value,o=this.determineBetOutcomes(a,e),{payoutMultiplier:n}=this.getPayoutDetails(a,e);return{outputs:{betOutcomes:o,result:r.values},payoutMultiplier:n,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),e=this.getBetTotals(t),o=this.getBetTotals(r.winningBets),n=this.calculateTotalBetAmount(e),i=this.calculateTotalPayout(o);return{payoutMultiplier:n.gt(0)?i.div(n):new nt.Big(0),payoutAmount:i}}determineBetOutcomes(t,a){let r={},e={};for(let o of Object.keys(t)){let n=t[o],i=this.betPredicates[o],{winning:c,losing:d}=this.partitionBets(n,i,a);r[o]=c,e[o]=d}return{winningBets:r,losingBets:e}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new nt.Big(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return Gr.includes(a)&&r.color==="RED"||Mr.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return Ur.includes(a)&&r.column==="TOP"||Zr.includes(a)&&r.column==="MIDDLE"||kr.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let e=a%2===0?"EVEN":"ODD";return r.parity===e}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new nt.Big(0))}partitionBets(t,a,r){return{winning:t.filter((e)=>a(e,r)),losing:t.filter((e)=>!a(e,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,e])=>{let n=wr[r];return a.plus(e.mul(n||0))},new nt.Big(0))}}class Sa extends fa{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};validateInputs(t){Vt(t)}}class Oa extends fa{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};validateInputs(t){It(t)}isWinningBasketBet(t,a){return ma.some((r)=>r===a)}}class Ha extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Sa,this.americanGame=new Oa}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(t.edge===Fr&&a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:o,result:e.outputs.result}}}if(t.edge===Jr&&a.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:o,result:e.outputs.result}}}throw l.createValidationError(`Attempted to play ${a.type} roulette on edge ${t.edge}`)}}var Fe=(t)=>{return new Ha().getBetAmount(t)};var Je=(t)=>{if(t.type==="EUROPEAN")Vt(t.inputs);else It(t.inputs)};var zr=require("big.js");var $;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})($||={});var z;((n)=>{n[n.TEN=10]="TEN";n[n.TWENTY=20]="TWENTY";n[n.THIRTY=30]="THIRTY";n[n.FORTY=40]="FORTY";n[n.FIFTY=50]="FIFTY"})(z||={});var Ye={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.5},20:{ZERO:0,A:1.2,B:1.5},30:{ZERO:0,A:1.2,B:1.5},40:{ZERO:0,A:1.2,B:1.5},50:{ZERO:0,A:1.2,B:1.5}},MEDIUM_RISK:{10:{ZERO:0,A:1.5,B:1.9,C:2,D:3},20:{ZERO:0,A:1.5,B:1.8,C:2,D:3},30:{ZERO:0,A:1.5,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:3},50:{ZERO:0,A:1.5,B:2,C:3,D:5}},HIGH_RISK:{10:{ZERO:0,A:9.9},20:{ZERO:0,A:19.8},30:{ZERO:0,A:29.7},40:{ZERO:0,A:39.6},50:{ZERO:0,A:49.5}}},$e={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.4},20:{ZERO:0,A:1.2,B:1.4},30:{ZERO:0,A:1.2,B:1.4},40:{ZERO:0,A:1.2,B:1.4},50:{ZERO:0,A:1.2,B:1.4}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3.1},20:{ZERO:0,A:1.5,B:1.8,C:1.9,D:3.4},30:{ZERO:0,A:1.5,B:1.7,C:1.9,D:3,E:4.3},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.9},50:{ZERO:0,A:1.5,B:2,C:3,D:4.5}},HIGH_RISK:{10:{ZERO:0,A:9.8},20:{ZERO:0,A:19.6},30:{ZERO:0,A:29.4},40:{ZERO:0,A:39.2},50:{ZERO:0,A:49}}},ze={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.65},20:{ZERO:0,A:1.15,B:1.65},30:{ZERO:0,A:1.15,B:1.65},40:{ZERO:0,A:1.15,B:1.65},50:{ZERO:0,A:1.15,B:1.65}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3},20:{ZERO:0,A:1.4,B:1.6,C:2,D:3},30:{ZERO:0,A:1.4,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.8},50:{ZERO:0,A:1.5,B:2,C:2.7,D:4.9}},HIGH_RISK:{10:{ZERO:0,A:9.7},20:{ZERO:0,A:19.4},30:{ZERO:0,A:29.1},40:{ZERO:0,A:38.8},50:{ZERO:0,A:48.5}}},Xe={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.55},20:{ZERO:0,A:1.15,B:1.55},30:{ZERO:0,A:1.15,B:1.55},40:{ZERO:0,A:1.15,B:1.55},50:{ZERO:0,A:1.15,B:1.55}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.8,C:2,D:3},20:{ZERO:0,A:1.3,B:1.5,C:2,D:3},30:{ZERO:0,A:1.4,B:1.6,C:2,D:2.9,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.7},50:{ZERO:0,A:1.5,B:2,C:2.6,D:4.8}},HIGH_RISK:{10:{ZERO:0,A:9.6},20:{ZERO:0,A:19.2},30:{ZERO:0,A:28.8},40:{ZERO:0,A:38.4},50:{ZERO:0,A:48}}},qe={LOW_RISK:{10:{ZERO:0,A:1.1,B:1.5},20:{ZERO:0,A:1.1,B:1.5},30:{ZERO:0,A:1.1,B:1.45},40:{ZERO:0,A:1.1,B:1.45},50:{ZERO:0,A:1.1,B:1.45}},MEDIUM_RISK:{10:{ZERO:0,A:1.3,B:1.7,C:1.9,D:3},20:{ZERO:0,A:1.3,B:1.4,C:1.9,D:3},30:{ZERO:0,A:1.3,B:1.7,C:1.9,D:2.8,E:3.8},40:{ZERO:0,A:1.4,B:1.8,C:1.9,D:2.6},50:{ZERO:0,A:1.4,B:1.9,C:2.6,D:4.6}},HIGH_RISK:{10:{ZERO:0,A:9.2},20:{ZERO:0,A:18.4},30:{ZERO:0,A:27.6},40:{ZERO:0,A:36.8},50:{ZERO:0,A:46}}},Yr=new T(new Map([[1,Ye],[2,$e],[3,ze],[4,Xe],[8,qe]]));var $r={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class Xr extends A{constructor(){super("WHEEL")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(z).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values($).includes(a.riskLevel))throw new Error("Invalid risk level");let o=Yr.getMultipliers(r)[a.riskLevel];if(o===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let n=o[a.segments];if(n===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let i=$r[a.riskLevel];if(i===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let c=i[a.segments];if(c===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let d=t.getRandomInt({min:0,max:c.length-1}),p=c[d.value];if(p===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${d.value}`);let u=n[p];if(u===void 0)throw new Error(`No payout found for picked segment ${p}`);return{isFinished:!0,payoutMultiplier:new zr.Big(u),outputs:{result:d.values},randomValues:d}}}
|
|
1
|
+
var Xr=Object.create;var{getPrototypeOf:qr,defineProperty:X,getOwnPropertyNames:Ca,getOwnPropertyDescriptor:Qr}=Object,xa=Object.prototype.hasOwnProperty;var H=(t,a,r)=>{r=t!=null?Xr(qr(t)):{};let e=a||!t||!t.__esModule?X(r,"default",{value:t,enumerable:!0}):r;for(let n of Ca(t))if(!xa.call(e,n))X(e,n,{get:()=>t[n],enumerable:!0});return e},ha=new WeakMap,gr=(t)=>{var a=ha.get(t),r;if(a)return a;if(a=X({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")Ca(t).map((e)=>!xa.call(a,e)&&X(a,e,{get:()=>t[e],enumerable:!(r=Qr(t,e))||r.enumerable}));return ha.set(t,a),a};var Wr=(t,a)=>{for(var r in a)X(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(e)=>a[r]=()=>e})};var qe={};Wr(qe,{validateRouletteGameInputs:()=>Fe,validateAdvancedDiceInputs:()=>te,rtp99Multipliers:()=>xr,rtp98Multipliers:()=>Pr,rtp97Multipliers:()=>br,rtp96Multipliers:()=>jr,rtp92Multipliers:()=>Tr,plinkoMultipliers:()=>la,nCr:()=>Tt,kenoMultipliers:()=>na,isTileCount:()=>ea,hasDiceWon:()=>Dr,hasBlitzWon:()=>sr,getMaxMultiplierForDifficulty:()=>ye,getBlitzDefaults:()=>le,diamondsMultipliers:()=>fr,calculateRouletteBetAmount:()=>Me,calculateDiceWinChance:()=>Hr,calculateBlitzWinChance:()=>pr,calculateBaccaratBetAmount:()=>ka,calculateAdvancedDiceWinChance:()=>kt,bigMin:()=>ia,bigMax:()=>oa,advancedDiceIsWithinBoundsInclusive:()=>Ra,advancedDiceIsWithinBoundsExclusive:()=>lt,advancedDiceGetInclusiveBoundsRange:()=>_a,advancedDiceGetExclusiveBoundsRange:()=>dt,WheelSegments:()=>z,WheelRiskLevel:()=>$,Wheel:()=>zr,WIN_MULTIPLIER:()=>Fa,VALID_SUITS:()=>wa,VALID_RANKS:()=>Va,VALID_EUROPEAN_STREETS:()=>pa,VALID_EUROPEAN_STRAIGHTS:()=>Rt,VALID_EUROPEAN_SPLITS:()=>ua,VALID_EUROPEAN_DOUBLE_STREETS:()=>ya,VALID_EUROPEAN_CORNERS:()=>Ba,VALID_AMERICAN_STREETS:()=>Aa,VALID_AMERICAN_STRAIGHTS:()=>da,VALID_AMERICAN_SPLITS:()=>sa,VALID_AMERICAN_DOUBLE_STREETS:()=>fa,VALID_AMERICAN_CORNERS:()=>ma,ThreeCardBonusType:()=>Et,TOP_COLUMN:()=>Zr,TILE_COUNTS:()=>Cr,THREE_CARD_BONUS_PAYOUTS:()=>Jt,SingleActionGame:()=>A,SPLIT_BET_SIZE_FACTOR:()=>I,RouletteType:()=>_t,Roulette:()=>Da,RollType:()=>Na,RandomValuePool:()=>v,RED_NUMBERS:()=>Mr,RANDOM_MIN_VALUE:()=>ut,RANDOM_MAX_VALUE:()=>st,PlinkoRiskLevel:()=>ca,Plinko:()=>Vr,Parity:()=>U,PairBonusType:()=>mt,PUSH_MULTIPLIER:()=>Ja,PLINKO_ROW_COUNTS:()=>Pe,PAYOUT_MULTIPLIERS:()=>Ur,PAIR_BONUS_PAYOUTS:()=>Ft,OrigamiGame:()=>f,MultiplierCalculator:()=>P,MultiActionGame:()=>Ct,Mines:()=>Ir,MIN_WIN_CHANCE:()=>ja,MIDDLE_COLUMN:()=>kr,MAX_WIN_CHANCE:()=>Ta,MAX_CARDS_PER_ROUND:()=>ft,Limbo:()=>Nr,LOSE_MULTIPLIER:()=>Ya,KenoRiskLevel:()=>ra,Keno:()=>_r,InsuranceOutcome:()=>At,INSURANCE_WIN_PAYOUT:()=>Ot,INSURANCE_BET_SIZE_FACTOR:()=>F,INSURANCE_BET_MULTIPLIER:()=>re,Half:()=>k,GameErrorCode:()=>Pa,GameError:()=>l,FACE_CARD_VALUE:()=>Mt,EuropeanRoulette:()=>Sa,EUROPEAN_HOUSE_EDGE:()=>wt,EFFECTIVE_RANGE:()=>Ut,Dozen:()=>M,DiceDirection:()=>Sr,Dice:()=>hr,DiamondsResultType:()=>yr,Diamonds:()=>Or,Darts:()=>mr,DOUBLE_DOWN_BET_SIZE_FACTOR:()=>j,DICE_EFFECTIVE_RANGE:()=>ta,DEALER_STAND_VALUE:()=>Gt,DARTS_MIN_VALUE:()=>Kt,DARTS_MAX_VALUE:()=>Pt,DARTS_DIFFICULTY_LEVEL:()=>vt,DARTS_BOARD_CONFIGS:()=>bt,Column:()=>G,Color:()=>Z,CARDS_PER_SUIT:()=>ee,Blitz:()=>Ar,BlackjackOutcome:()=>pt,BlackjackActionType:()=>Bt,Blackjack:()=>dr,BaccaratOutcome:()=>Ua,BaccaratBetType:()=>Za,Baccarat:()=>Ga,BUST_VALUE:()=>yt,BOTTOM_COLUMN:()=>Gr,BLITZ_RANDOM_NUMBER_COUNT:()=>Lt,BLITZ_MIN_CARD_RANGE:()=>gt,BLITZ_MAX_CARD_RANGE:()=>Wt,BLITZ_CARD_COUNT:()=>J,BLACK_NUMBERS:()=>Fr,BLACKJACK_VALUE:()=>D,BLACKJACK_MULTIPLIER:()=>Ma,BASE_PAYOUT_MULTIPLIERS:()=>q,AmericanRoulette:()=>Ha,AdvancedDice:()=>Ia,AMERICAN_HOUSE_EDGE:()=>Vt,AMERICAN_BASKET:()=>Ea,ACE_SOFT_BONUS:()=>St});module.exports=gr(qe);var Pa;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(Pa||={});class l extends Error{static createUnsupportedEdgeError(t){return new l("UNSUPPORTED_EDGE",t)}static createValidationError(t){return new l("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof l}errorCode;constructor(t,a){super(a);this.errorCode=t}}var f;((B)=>{B.DICE="DICE";B.MINES="MINES";B.KENO="KENO";B.LIMBO="LIMBO";B.ADVANCED_DICE="ADVANCED_DICE";B.BACCARAT="BACCARAT";B.DIAMONDS="DIAMONDS";B.PLINKO="PLINKO";B.ROULETTE="ROULETTE";B.WHEEL="WHEEL";B.BLACKJACK="BLACKJACK";B.BLITZ="BLITZ";B.DARTS="DARTS"})(f||={});var ba=require("@betorigami/guard");class A{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return ba.Guard.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}var Zt=require("big.js");var it=H(require("big.js"));class P{static withMultiplier(t,a){return new it.default(t).times(new it.default(100-a).div(100))}static withWinChance(t,a){return it.default(100-t).div(a)}}var ut=0,st=1e4,Ut=10001,ja=0.01,Ta=98,Lr=(t)=>{if(t<ut)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${ut}`)},Kr=(t)=>{if(t>st)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${st}`)},ct=(t)=>{if(Lr(t.lower),Kr(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},vr=(t,a)=>{let[r,e]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>e.lower)throw l.createValidationError("Bounds must not overlap")},Ra=(t,a)=>a>=t.lower&&a<=t.upper,_a=(t)=>t.upper-t.lower+1,lt=(t,a)=>a>t.lower&&a<t.upper,dt=(t)=>t.upper-t.lower-1,Na;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Na||={});var kt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return ct(t.bounds),dt(t.bounds);case"ROLL_OUTSIDE":return ct(t.bounds),Ut-_a(t.bounds);case"ROLL_BETWEEN_TWO":return ct(t.firstBounds),ct(t.secondBounds),vr(t.firstBounds,t.secondBounds),dt(t.firstBounds)+dt(t.secondBounds)}})(),e=Zt.Big(r).div(Ut).mul(100);if(e.lt(ja))throw l.createValidationError("Win chance too low");if(e.gt(Ta))throw l.createValidationError("Win chance too high");return e},te=(t)=>{kt(t)};class Ia extends A{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=kt(r),n=t.getRandomInt({min:ut,max:st}),o=n.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return lt(r.bounds,o);case"ROLL_OUTSIDE":return!Ra(r.bounds,o);case"ROLL_BETWEEN_TWO":return lt(r.firstBounds,o)||lt(r.secondBounds,o)}})()?P.withWinChance(a,e):new Zt.Big(0),outputs:{result:n.values},randomValues:n}}}var N=H(require("big.js"));var wa=["Clubs","Diamonds","Hearts","Spades"],Va=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],Ua;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(Ua||={});var Za;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(Za||={});var ae={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},ka=(t)=>{return new N.default(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new N.default(0)))};class Ga extends A{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),e=r.values,n=e.slice(0,3),o=e.slice(3,6),i=[],c=0;for(let y of n.slice(0,2)){let x=this.mapRandomValueToCard(y),ot=this.mapRandomValueToCardValue(y);i.push(x),c=(c+ot)%10}let u=[],d=0;for(let y of o.slice(0,2)){let x=this.mapRandomValueToCard(y),ot=this.mapRandomValueToCardValue(y);u.push(x),d=(d+ot)%10}if(!this.isNaturalWin(c,d)){let y=this.shouldDrawThirdPlayerCard(c),x=null;if(y)x=this.mapRandomValueToCardValue(n[2]),i.push(this.mapRandomValueToCard(n[2])),c=(c+x)%10;if(this.shouldDrawThirdBankerCard(d,x))u.push(this.mapRandomValueToCard(o[2])),d=(d+this.mapRandomValueToCardValue(o[2]))%10}let s;if(c===d)s="TIE";else s=c>d?"PLAYER_WIN":"BANKER_WIN";let p=ka(a),{betType:E,multiplier:B}=ae[s],_=new N.default(0);if(_=_.add(a.bets.filter((y)=>y.type===E).reduce((y,x)=>y.add(x.amount.mul(B)),new N.default(0))),s==="TIE")_=_.add(a.bets.filter((y)=>y.type==="PLAYER"||y.type==="BANKER").reduce((y,x)=>y.add(x.amount),new N.default(0)));return{isFinished:!0,payoutMultiplier:p.gt(0)?_.div(p):new N.default(0),outputs:{playerCards:i,playerHandValue:c,bankerCards:u,bankerHandValue:d,gameOutcome:s,result:r.values},randomValues:r}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=wa[Math.floor(t/13)],r=Va[t%13];return{suit:a,rank:r}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var pt;((n)=>{n.WIN="WIN";n.LOSE="LOSE";n.PUSH="PUSH";n.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(pt||={});var At;((r)=>{r.WON="WON";r.LOST="LOST"})(At||={});var Bt;((c)=>{c.START="START";c.HIT="BLACKJACK_HIT";c.STAND="BLACKJACK_STAND";c.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";c.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";c.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";c.SPLIT="BLACKJACK_SPLIT"})(Bt||={});var mt;((n)=>{n.EXACT_PAIR="EXACT_PAIR";n.COLORED_PAIR="COLORED_PAIR";n.MIXED_PAIR="MIXED_PAIR";n.LOSS="LOSS"})(mt||={});var Et;((i)=>{i.SUITED_TRIPS="SUITED_TRIPS";i.STRAIGHT_FLUSH="STRAIGHT_FLUSH";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.STRAIGHT="STRAIGHT";i.FLUSH="FLUSH";i.LOSS="LOSS"})(Et||={});var Ma=2.5,Fa=2,Ja=1,Ya=0,Gt=17,yt=21,D=21,ft=63,re=1.5,F=0.5,Ot=1.5,j=1,I=1,ee=13,St=10,Mt=10,q={PLAYER_BLACKJACK:Ma,WIN:Fa,PUSH:Ja,LOSE:Ya},Ft={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Jt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var R=H(require("big.js")),m=require("@betorigami/guard"),cr=require("@xstate/store");var $a=0,za=51,Ht=Array.from({length:52},(t,a)=>a),Xa=["Spades","Hearts","Diamonds","Clubs"],Dt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],qa=["Jack","Queen","King"],Yt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};var Qa=require("@betorigami/guard");var ht=require("@betorigami/guard");class Q{value;constructor(t){let a=Ht[t];ht.Guard.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Xa[t];return ht.Guard.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=Dt[t];return ht.Guard.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}class O extends Q{get numericRank(){if(qa.includes(this.rank))return Mt;return Dt.indexOf(this.rank)+1}static fromValue(t){return Qa.Guard.against(!Ht.includes(t),`Invalid card value: ${t}`),new O(t)}}class g{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,e)=>r+e.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+St<=yt)this.softHandValue=this.hardHandValue+St}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>yt}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===D}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class W{cards;value;constructor(t){this.cards=t.map((a)=>O.fromValue(a)),this.value=new g(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class L extends W{otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=O.fromValue(t),this.holeCard=O.fromValue(a)}static withInitialDeal(t){return new L(t.upCard,t.holeCard)}addDrawnCards(t){return new L(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new g([this.upCard]).highestHandValue}}}class w extends W{static withInitialDeal(t){return new w(t)}addDrawnCards(t){return new w([...this.rawValues,...t])}}var K=require("@betorigami/guard");class v{source;index=0;constructor(t){this.source=t}static from(t,a){return K.Guard.against(a<=0,`Count must be positive, got ${a}`),K.Guard.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new v(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return K.Guard.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){K.Guard.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}var $t=require("@betorigami/guard"),ga=H(require("fast-deep-equal"));class Ct{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let e=this.createGameStore(),n=this.generateRandomValues(t),o=n.toMultipleRandomValues();for(let u of r)e.send({...u.playerArgument,randomValuePool:n});let i=r[r.length-1];if(i)$t.Guard.against(!ga.default(i.state,this.toExternalState(e.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");e.send({...a,randomValuePool:n});let c=e.getSnapshot().context;return{playerArgument:c.playerArgument,state:this.toExternalState(c.state),config:c.config,additionalBetAmount:c.additionalBetAmount,proof:{proofHash:o.proofHash,proofString:o.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);$t.Guard.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}}var h=H(require("big.js"));var xt=require("@betorigami/guard");var Wa=(t)=>{let a=t.pairBonus!==null?h.default(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier):h.default(0),r=t.threeCardBonus!==null?h.default(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier):h.default(0);return a.plus(r)},La=(t)=>{let a=t.betAmounts.mainBetAmount,e=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(j):h.default(0),n=t.insuranceOutcome!==void 0?a.mul(F):h.default(0),o=a.plus(e).mul(q[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(Ot):h.default(0),c=Wa(t.sideBetResults),u=o.plus(i).plus(c),d=a.plus(n).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);xt.Guard.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);xt.Guard.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=e;break;case"BLACKJACK_BUY_INSURANCE":p=n;break;case"BLACKJACK_SPLIT":p=a.mul(I);break}return{multiplier:s,additionalBetAmount:p}},Ka=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(j):h.default(0),e=t.splitHandDoubledDown?a.mul(j):h.default(0),n=t.insuranceOutcome!==void 0?a.mul(F):h.default(0),o=a.plus(r).mul(q[t.mainOutcome]),i=a.plus(e).mul(q[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(Ot):h.default(0),u=Wa(t.sideBetResults),d=o.plus(i).plus(c).plus(u),s=a.plus(a).plus(n).plus(r).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);xt.Guard.against(s.eq(0),"Total bet amount cannot be zero");let p=d.div(s),E;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":E=a.mul(j);break;case"BLACKJACK_SPLIT":E=a.mul(I);break}return{multiplier:p,additionalBetAmount:E}};var tr=require("@betorigami/guard"),zt=(t)=>t.every((a)=>a===t[0]),va=(t)=>{let a=[...t].sort((r,e)=>r-e);return a.every((r,e)=>{let n=a[e-1];if(e===0)return!0;return tr.Guard.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},ar={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},ne={...ar,Ace:14},oe=(t)=>va(t.map((a)=>ar[a]))||va(t.map((a)=>ne[a])),rr=(t,a)=>{let r=O.fromValue(t),e=O.fromValue(a);if(r.rank!==e.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Yt[r.suit]===Yt[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},er=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Ft[a]}),nr=(t,a,r)=>{let e=O.fromValue(t),n=O.fromValue(a),o=O.fromValue(r),i=[e.rank,n.rank,o.rank],c=zt([e.suit,n.suit,o.suit]),u=zt(i),d=oe(i);if(zt([t,a,r]))return"SUITED_TRIPS";if(c&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(c)return"FLUSH";return"LOSS"},or=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Jt[a]});var ie={state:{isFinished:!1,phase:"uninitialised",multiplier:R.default(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>O.fromValue(t).value;function ce(t){m.Guard.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function ir(t){m.Guard.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function Xt(t){m.Guard.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var lr=(t,a)=>{let r=a;while(r.highestHandValue<Gt)r=r.addDrawnCards([S(t.takeOne())]);return r},Qt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,e=a.highestHandValue;if(r>e)return"WIN";if(r<e)return"LOSE";return"PUSH"},C=(t)=>{let{multiplier:a,additionalBetAmount:r}=La({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,multiplier:a,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:r}},qt=(t)=>{let a=lr(t.randomValuePool,t.dealerHand),r=Qt(t.playerHand,a);return C({...t,dealerHand:a,outcome:r})},T=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:lr(t.randomValuePool,t.dealerHand),e=Qt(t.mainHand,r),n=Qt(t.splitHand,r),{multiplier:o,additionalBetAmount:i}=Ka({hasSplit:!0,mainOutcome:e,splitOutcome:n,insuranceOutcome:t.insuranceOutcome,mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:e,splitOutcome:n,multiplier:o,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class dr extends Ct{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return v.from(t.getRandomIntsWithReplacement({min:$a,max:za,count:ft}),ft)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:m.Guard.againstNever(a,"Invalid state received")}}createGameStore(){return cr.createStore({context:ie,on:{START:(t,a)=>{let{state:r}=t;m.Guard.against(r.phase!=="uninitialised","START action requires a fresh game");let e=S(a.randomValuePool.takeOne()),n=S(a.randomValuePool.takeOne()),o=S(a.randomValuePool.takeOne()),i=S(a.randomValuePool.takeOne()),c=w.withInitialDeal([e,n]),u=L.withInitialDeal({upCard:o,holeCard:i}),d={mainBetAmount:R.default(a.mainBetAmount),pairBonusAmount:R.default(a.pairBonusAmount),threeCardBonusAmount:R.default(a.threeCardBonusAmount)},s={pairBonus:R.default(a.pairBonusAmount).gt(0)?er(a.pairBonusAmount,rr(e,n)):null,threeCardBonus:R.default(a.threeCardBonusAmount).gt(0)?or(a.threeCardBonusAmount,nr(e,n,o)):null},p={type:"START",mainBetAmount:a.mainBetAmount,pairBonusAmount:a.pairBonusAmount,threeCardBonusAmount:a.threeCardBonusAmount};if(u.upCard.rank==="Ace")return{state:{...r,isFinished:!1,phase:"awaiting-insurance",playerHand:c,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:p};let E={playerHand:c,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:p,betAmounts:d,sideBetResults:s};if(c.isBlackjack&&u.isBlackjack)return C({...E,outcome:"PUSH"});if(c.isBlackjack)return C({...E,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return C({...E,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:c,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:p}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;ir(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return C({...c,outcome:"PUSH",insuranceOutcome:"WON"});if(e.isBlackjack)return C({...c,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(n.isBlackjack)return C({...c,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:o.mainBetAmount.mul(F)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;ir(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={playerHand:e,dealerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return C({...c,outcome:"PUSH"});if(e.isBlackjack)return C({...c,outcome:"PLAYER_BLACKJACK"});if(n.isBlackjack)return C({...c,outcome:"LOSE"});return{state:{...r,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(t,a)=>{let{state:r}=t;switch(Xt(r),r.phase){case"playing-main-hand":{let e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===D){if(r.splitHand.highestHandValue===D)return T({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===D)return T({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return C({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(e.highestHandValue===D)return qt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:m.Guard.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(Xt(r),r.phase){case"playing-main-hand":{if(r.splitHand.highestHandValue===D)return T({...r,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...r,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return T({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return qt({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:m.Guard.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(Xt(r),r.phase){case"playing-main-hand":{m.Guard.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]),{betAmounts:n}=r;if(r.splitHand.highestHandValue===D)return T({...r,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:n.mainBetAmount.mul(j)}}case"playing-split-hand":{m.Guard.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);return T({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{m.Guard.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return C({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return qt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:m.Guard.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;ce(r);let{playerHand:e,betAmounts:n,sideBetResults:o}=r;m.Guard.against(e.cards.length!==2,"Split is only allowed with exactly 2 cards");let i=e.cards[0],c=e.cards[1];m.Guard.againstUndefined(i,"First card is missing"),m.Guard.againstUndefined(c,"Second card is missing"),m.Guard.against(i.rank!==c.rank,"Split requires two cards of the same rank");let u=S(a.randomValuePool.takeOne()),d=S(a.randomValuePool.takeOne()),s=w.withInitialDeal([i.value,u]),p=w.withInitialDeal([c.value,d]);if(i.rank==="Ace")return T({...r,mainHand:s,splitHand:p,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let B=s.highestHandValue===D,_=p.highestHandValue===D;if(B&&_)return T({mainHand:s,splitHand:p,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:n,sideBetResults:o});if(B)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:p,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(I)};return{state:{...r,phase:"playing-main-hand",multiplier:R.default(0),mainHand:s,splitHand:p,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(I)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],e=t.playerHand.cards[1];if(m.Guard.againstUndefined(r,"First player card is missing"),m.Guard.againstUndefined(e,"Second player card is missing"),r.rank===e.rank)a.push("BLACKJACK_SPLIT")}return a}default:m.Guard.againstNever(t,"Invalid phase for getting valid actions")}}}var Y=H(require("big.js")),ur=require("@betorigami/guard");var gt=0,Wt=51,J=52,Lt=52;var le=()=>({minPicks:5,maxPicks:36}),sr=(t)=>t.length===new Set(t).size,pr=(t)=>{let a=Y.default(1),r=Y.default(J);for(let e=0;e<t;e+=1)a=a.mul(Y.default(J-e).div(r));return a};class Ar extends A{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a,edge:r}){ur.Guard.against(a.pickCount<1||a.pickCount>J,`pickCount must be between 1 and ${J}`);let e=t.getRandomIntsWithReplacement({min:gt,max:Wt,count:Lt}),n=e.values.slice(0,a.pickCount),o=sr(n),i=pr(a.pickCount);return{isFinished:!0,payoutMultiplier:o?P.withMultiplier(Y.default(1).div(i),r):Y.default(0),outputs:{result:e.values,cards:n.map((u)=>new Q(u).toDto())},randomValues:e}}}var Kt=0,Pt=4294967295,vt;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(vt||={});var de=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],ue={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:de},se=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],pe={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:se},Ae=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Be={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:Ae},me=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Ee={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:me},ye=(t)=>{let a=bt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((e,n)=>n>e?n:e)},bt={EASY:ue,MEDIUM:pe,HARD:Be,EXPERT:Ee};var jt=require("@betorigami/guard"),Br=H(require("big.js"));class mr extends A{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:Kt,max:Pt,count:2}),e=r.values[0],n=r.values[1];jt.Guard.againstUndefined(e,"Random number generator returned no value for clockWiseRotation"),jt.Guard.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let o=a.difficultyLevel;return{isFinished:!0,payoutMultiplier:Br.default(fe(o,e,n)),outputs:{result:r.values},randomValues:r}}}var fe=(t,a,r)=>{let e=bt[t],{distanceBoundaries:n,multipliers:o}=e;if(r<n.bullseye)return o.bullseye;if(r<n.ringOne)return o.ringOne;if(r<n.ringTwo)return o.ringTwo;if(r<n.ringThree)return Oe(e,a);return o.ringFour},Oe=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(Pt+1)*r),n=t.segments[e];return jt.Guard.againstUndefined(n,`Segment index ${e} out of bounds`),t.multipliers.ringThree[n]};var Er=H(require("big.js"));class b{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var yr;((i)=>{i.PAIR="PAIR";i.TWO_PAIR="TWO_PAIR";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.FULL_HOUSE="FULL_HOUSE";i.FOUR_OF_A_KIND="FOUR_OF_A_KIND";i.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(yr||={});var Se={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},He={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},De={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},he={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},Ce={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},fr=new b(new Map([[1,Se],[2,He],[3,De],[4,he],[8,Ce]])),xe={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Or extends A{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a}){let r=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=fr.getMultipliers(a),n=r.values,o=this.calculatePayoutMultiplier(e,n);return{isFinished:!0,payoutMultiplier:Er.default(o),outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(t,a){let r=new Map;for(let o of a){let i=r.get(o)||0;r.set(o,i+1)}let e=[...r.values()].filter((o)=>o>1),n=this.classifyResult(e);return n===null?0:t[n]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let e=xe[a];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return e}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}var aa=H(require("big.js"));var Sr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Sr||={});var ta=1e4,Hr=(t)=>{let a=t.direction==="ABOVE"?ta-t.selectedValue:t.selectedValue;return new aa.default(a).div(ta).mul(100)},Dr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class hr extends A{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:0,max:1e4}),n=Hr(r);return{isFinished:!0,payoutMultiplier:Dr(r,e.value)?P.withWinChance(a,n):new aa.default(0),outputs:{result:e.values},randomValues:e}}}var Rr=H(require("big.js"));var tt=require("@betorigami/guard");var ra;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(ra||={});var Cr=[1,2,3,4,5,6,7,8,9,10],ea=(t)=>{return Cr.includes(t)};var xr={[1]:{CLASSIC:[0,3.96],LOW_RISK:[0.7,1.85],MEDIUM_RISK:[0.4,2.75],HIGH_RISK:[0,3.96]},[2]:{CLASSIC:[0,1.9,4.5],LOW_RISK:[0,2,3.8],MEDIUM_RISK:[0,1.8,5.1],HIGH_RISK:[0,0,17.1]},[3]:{CLASSIC:[0,1,3.1,10.4],LOW_RISK:[0,1.1,1.38,26],MEDIUM_RISK:[0,0,2.8,50],HIGH_RISK:[0,0,0,81.5]},[4]:{CLASSIC:[0,0.8,1.8,5,22.5],LOW_RISK:[0,0,2.2,7.9,90],MEDIUM_RISK:[0,0,1.7,10,100],HIGH_RISK:[0,0,0,10,259]},[5]:{CLASSIC:[0,0.25,1.4,4.1,16.5,36],LOW_RISK:[0,0,1.5,4.2,13,300],MEDIUM_RISK:[0,0,1.4,4,14,390],HIGH_RISK:[0,0,0,4.5,48,450]},[6]:{CLASSIC:[0,0,1,3.68,7,16.5,40],LOW_RISK:[0,0,1.1,2,6.2,100,700],MEDIUM_RISK:[0,0,0,3,9,180,710],HIGH_RISK:[0,0,0,0,11,350,710]},[7]:{CLASSIC:[0,0,0.47,3,4.5,14,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,15,225,700],MEDIUM_RISK:[0,0,0,2,7,30,400,800],HIGH_RISK:[0,0,0,0,7,90,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,13,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,5.5,39,100,800],MEDIUM_RISK:[0,0,0,2,4,11,67,400,900],HIGH_RISK:[0,0,0,0,5,20,270,600,900]},[9]:{CLASSIC:[0,0,0,1.55,3,8,15,44,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1000],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1000]}},Pr={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},br={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},jr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.68,1.84],MEDIUM_RISK:[0.38,2.74],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,1.96,3.75],MEDIUM_RISK:[0,1.77,5],HIGH_RISK:[0,0,16.82]},[3]:{CLASSIC:[0,1,3.05,9.35],LOW_RISK:[0,1.07,1.37,25.7],MEDIUM_RISK:[0,0,2.74,49],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.72,4.95,22.3],LOW_RISK:[0,0,2.15,7.86,87],MEDIUM_RISK:[0,0,1.67,9.7,100],HIGH_RISK:[0,0,0,9.7,256]},[5]:{CLASSIC:[0,0.24,1.38,4,16.3,35.5],LOW_RISK:[0,0,1.48,4.1,12.43,300],MEDIUM_RISK:[0,0,1.35,3.96,13.8,389],HIGH_RISK:[0,0,0,4.4,47,444]},[6]:{CLASSIC:[0,0,1,3.57,6.8,16.2,37],LOW_RISK:[0,0,1.06,1.96,6.16,99,700],MEDIUM_RISK:[0,0,0,2.9,8.9,178,709],HIGH_RISK:[0,0,0,0,10.4,347,709]},[7]:{CLASSIC:[0,0,0.45,2.95,4.44,13.85,30,60],LOW_RISK:[0,0,1.07,1.57,3.47,14.57,225,700],MEDIUM_RISK:[0,0,0,1.95,6.8,29.8,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.15,3.9,12.9,21.9,55,70],LOW_RISK:[0,0,1.08,1.45,1.98,5.48,38.8,100,800],MEDIUM_RISK:[0,0,0,1.95,3.96,10.6,66.9,396,896],HIGH_RISK:[0,0,0,0,4.9,19.2,269,599,896]},[9]:{CLASSIC:[0,0,0,1.5,2.95,7.96,14.96,44,60,85],LOW_RISK:[0,0,1.05,1.29,1.69,2.49,7.49,49,250,1000],MEDIUM_RISK:[0,0,0,1.95,2.47,4.9,14.9,99,500,1000],HIGH_RISK:[0,0,0,0,3.96,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.45,7.7,16.7,50,80,100],LOW_RISK:[0,0,1.08,1.18,1.28,1.76,3.4,12.9,50,250,1000],MEDIUM_RISK:[0,0,0,1.57,1.95,3.96,6.9,25.5,100,500,1000],HIGH_RISK:[0,0,0,0,3.43,7.9,12.5,60,500,800,1000]}},Tr={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},na=new b(new Map([[1,xr],[2,Pr],[3,br],[4,jr],[8,Tr]]));class _r extends A{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){tt.Guard.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),tt.Guard.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let p of r.selectedNumbers)tt.Guard.againstNonInteger(p,()=>l.createValidationError("Only integers can be selected")),tt.Guard.against(p<0||p>39,()=>l.createValidationError("Invalid number selected"));let e=t.getUniqueRandomInts({min:0,max:39,count:10}),n=r.selectedNumbers.filter((p)=>e.values.includes(p)),o=r.selectedNumbers.length;if(!ea(o))throw new Error(`Invalid tile count: ${o}`);let d=na.getMultipliers(a)[o][r.riskLevel][n.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${n.length}`);return{isFinished:!0,payoutMultiplier:new Rr.default(d),outputs:{result:e.values},randomValues:e}}}var V=H(require("big.js"));var oa=(t,a)=>{return t.gt(a)?t:a};var ia=(t,a)=>{return t.lt(a)?t:a};class Nr extends A{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:1,max:4294967295}),n=e.max,o=new V.default(16777216),i=new V.default(1),c=new V.default(1e6),u=e.value,d=new V.default(u-1).div(n),s=(100-a)/100,p=o.div(d.mul(o).plus(1)).mul(s),E=oa(i,ia(p,c));return{isFinished:!0,payoutMultiplier:E.gte(r.targetMultiplier)?new V.default(r.targetMultiplier):new V.default(0),outputs:{randomMultiplier:E,result:e.values},randomValues:e}}}var at=H(require("big.js"));var Tt=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let e=1;e<=a;e++)r=r*(t-e+1)/e;return r};class Ir extends A{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let i=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),c=i.values.some((B)=>r.selectedTiles.includes(B)),u=r.hasCashedOut||c,d=(100-a)/100,s=new at.default(Tt(25-r.minesCount,r.selectedTiles.length)).div(new at.default(Tt(25,r.selectedTiles.length))),E=r.hasCashedOut&&!c?new at.default(d).div(s):new at.default(0);return{isFinished:u,payoutMultiplier:E,outputs:{result:i.values},randomValues:i}}}var wr=require("big.js");var ca;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(ca||={});var Pe=[8,9,10,11,12,13,14,15,16],be={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},je={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},Te={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},Re={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},_e={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},la=new b(new Map([[1,be],[2,je],[3,Te],[4,Re],[8,_e]]));class Vr extends A{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=a.numberOfRows,i=la.getMultipliers(r)[a.riskLevel][e],c=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=c.values.reduce((p,E)=>p+E,0),s=i[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);return{isFinished:!0,payoutMultiplier:wr.Big(s),outputs:{result:c.values},randomValues:c}}}var nt=require("big.js");var Rt=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],da=[37,...Rt],ua=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],sa=[[0,1],[0,37],[3,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],pa=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],Aa=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],Ba=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],ma=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Ea=[0,1,2,3,37],ya=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],fa=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],U;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(U||={});var Z;((r)=>{r.RED="RED";r.BLACK="BLACK"})(Z||={});var k;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(k||={});var G;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(G||={});var M;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(M||={});var _t;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(_t||={});var Nt=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&rt(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Ne(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Ie(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&we(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Ve(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},rt=(t)=>{return Rt.includes(t)},Ne=(t)=>{if(t.length!==2)return!1;if(!t.every(rt))return!1;return ua.some(([a,r])=>a===t[0]&&r===t[1])},Ie=(t)=>{if(t.length!==3)return!1;if(!t.every(rt))return!1;return pa.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},we=(t)=>{if(t.length!==4)return!1;if(!t.every(rt))return!1;return Ba.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},Ve=(t)=>{if(t.length!==6)return!1;if(!t.every(rt))return!1;return ya.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===t[5])};var It=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&et(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Ue(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Ze(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&ke(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw l.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Ge(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},et=(t)=>{return da.includes(t)};function Ue(t){if(t.length!==2)return!1;if(!t.every(et))return!1;return sa.some(([a,r])=>a===t[0]&&r===t[1])}var Ze=(t)=>{if(t.length!==3)return!1;if(!t.every(et))return!1;return Aa.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},ke=(t)=>{if(t.length!==4)return!1;if(!t.every(et))return!1;return ma.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},Ge=(t)=>{if(t.length!==6)return!1;if(!t.every(et))return!1;return fa.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===t[5])};var Ur={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Zr=[3,6,9,12,15,18,21,24,27,30,33,36],kr=[2,5,8,11,14,17,20,23,26,29,32,35],Gr=[1,4,7,10,13,16,19,22,25,28,31,34],Mr=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Fr=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35],wt=2.7,Vt=5.3;class Oa extends A{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),e=r.value,n=this.determineBetOutcomes(a,e),{payoutMultiplier:o}=this.getPayoutDetails(a,e);return{outputs:{betOutcomes:n,result:r.values},payoutMultiplier:o,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),e=this.getBetTotals(t),n=this.getBetTotals(r.winningBets),o=this.calculateTotalBetAmount(e),i=this.calculateTotalPayout(n);return{payoutMultiplier:o.gt(0)?i.div(o):new nt.Big(0),payoutAmount:i}}determineBetOutcomes(t,a){let r={},e={};for(let n of Object.keys(t)){let o=t[n],i=this.betPredicates[n],{winning:c,losing:u}=this.partitionBets(o,i,a);r[n]=c,e[n]=u}return{winningBets:r,losingBets:e}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new nt.Big(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return Mr.includes(a)&&r.color==="RED"||Fr.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return Zr.includes(a)&&r.column==="TOP"||kr.includes(a)&&r.column==="MIDDLE"||Gr.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let e=a%2===0?"EVEN":"ODD";return r.parity===e}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new nt.Big(0))}partitionBets(t,a,r){return{winning:t.filter((e)=>a(e,r)),losing:t.filter((e)=>!a(e,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,e])=>{let o=Ur[r];return a.plus(e.mul(o||0))},new nt.Big(0))}}class Sa extends Oa{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[wt]}validateInputs(t){Nt(t)}}class Ha extends Oa{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[Vt]}validateInputs(t){It(t)}isWinningBasketBet(t,a){return Ea.some((r)=>r===a)}}class Da extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Sa,this.americanGame=new Ha}get supportedEdgeConfigurations(){return[wt,Vt]}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(t.edge===wt&&a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:n,result:e.outputs.result}}}if(t.edge===Vt&&a.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:n,result:e.outputs.result}}}throw l.createValidationError(`Attempted to play ${a.type} roulette on edge ${t.edge}`)}}var Me=(t)=>{return new Da().getBetAmount(t)};var Fe=(t)=>{if(t.type==="EUROPEAN")Nt(t.inputs);else It(t.inputs)};var $r=require("big.js");var $;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})($||={});var z;((o)=>{o[o.TEN=10]="TEN";o[o.TWENTY=20]="TWENTY";o[o.THIRTY=30]="THIRTY";o[o.FORTY=40]="FORTY";o[o.FIFTY=50]="FIFTY"})(z||={});var Je={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.5},20:{ZERO:0,A:1.2,B:1.5},30:{ZERO:0,A:1.2,B:1.5},40:{ZERO:0,A:1.2,B:1.5},50:{ZERO:0,A:1.2,B:1.5}},MEDIUM_RISK:{10:{ZERO:0,A:1.5,B:1.9,C:2,D:3},20:{ZERO:0,A:1.5,B:1.8,C:2,D:3},30:{ZERO:0,A:1.5,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:3},50:{ZERO:0,A:1.5,B:2,C:3,D:5}},HIGH_RISK:{10:{ZERO:0,A:9.9},20:{ZERO:0,A:19.8},30:{ZERO:0,A:29.7},40:{ZERO:0,A:39.6},50:{ZERO:0,A:49.5}}},Ye={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.4},20:{ZERO:0,A:1.2,B:1.4},30:{ZERO:0,A:1.2,B:1.4},40:{ZERO:0,A:1.2,B:1.4},50:{ZERO:0,A:1.2,B:1.4}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3.1},20:{ZERO:0,A:1.5,B:1.8,C:1.9,D:3.4},30:{ZERO:0,A:1.5,B:1.7,C:1.9,D:3,E:4.3},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.9},50:{ZERO:0,A:1.5,B:2,C:3,D:4.5}},HIGH_RISK:{10:{ZERO:0,A:9.8},20:{ZERO:0,A:19.6},30:{ZERO:0,A:29.4},40:{ZERO:0,A:39.2},50:{ZERO:0,A:49}}},$e={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.65},20:{ZERO:0,A:1.15,B:1.65},30:{ZERO:0,A:1.15,B:1.65},40:{ZERO:0,A:1.15,B:1.65},50:{ZERO:0,A:1.15,B:1.65}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3},20:{ZERO:0,A:1.4,B:1.6,C:2,D:3},30:{ZERO:0,A:1.4,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.8},50:{ZERO:0,A:1.5,B:2,C:2.7,D:4.9}},HIGH_RISK:{10:{ZERO:0,A:9.7},20:{ZERO:0,A:19.4},30:{ZERO:0,A:29.1},40:{ZERO:0,A:38.8},50:{ZERO:0,A:48.5}}},ze={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.55},20:{ZERO:0,A:1.15,B:1.55},30:{ZERO:0,A:1.15,B:1.55},40:{ZERO:0,A:1.15,B:1.55},50:{ZERO:0,A:1.15,B:1.55}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.8,C:2,D:3},20:{ZERO:0,A:1.3,B:1.5,C:2,D:3},30:{ZERO:0,A:1.4,B:1.6,C:2,D:2.9,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.7},50:{ZERO:0,A:1.5,B:2,C:2.6,D:4.8}},HIGH_RISK:{10:{ZERO:0,A:9.6},20:{ZERO:0,A:19.2},30:{ZERO:0,A:28.8},40:{ZERO:0,A:38.4},50:{ZERO:0,A:48}}},Xe={LOW_RISK:{10:{ZERO:0,A:1.1,B:1.5},20:{ZERO:0,A:1.1,B:1.5},30:{ZERO:0,A:1.1,B:1.45},40:{ZERO:0,A:1.1,B:1.45},50:{ZERO:0,A:1.1,B:1.45}},MEDIUM_RISK:{10:{ZERO:0,A:1.3,B:1.7,C:1.9,D:3},20:{ZERO:0,A:1.3,B:1.4,C:1.9,D:3},30:{ZERO:0,A:1.3,B:1.7,C:1.9,D:2.8,E:3.8},40:{ZERO:0,A:1.4,B:1.8,C:1.9,D:2.6},50:{ZERO:0,A:1.4,B:1.9,C:2.6,D:4.6}},HIGH_RISK:{10:{ZERO:0,A:9.2},20:{ZERO:0,A:18.4},30:{ZERO:0,A:27.6},40:{ZERO:0,A:36.8},50:{ZERO:0,A:46}}},Jr=new b(new Map([[1,Je],[2,Ye],[3,$e],[4,ze],[8,Xe]]));var Yr={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class zr extends A{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(z).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values($).includes(a.riskLevel))throw new Error("Invalid risk level");let n=Jr.getMultipliers(r)[a.riskLevel];if(n===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let o=n[a.segments];if(o===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let i=Yr[a.riskLevel];if(i===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let c=i[a.segments];if(c===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:c.length-1}),d=c[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=o[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);return{isFinished:!0,payoutMultiplier:new $r.Big(s),outputs:{result:u.values},randomValues:u}}}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,11 @@ import { Big as Big$1, Big as Big$2, Big as Big$3 } from 'big.js';
|
|
|
5
5
|
import { ReadonlyDeep, Simplify } from 'type-fest';
|
|
6
6
|
|
|
7
7
|
export declare enum GameErrorCode {
|
|
8
|
+
UNSUPPORTED_EDGE = "UNSUPPORTED_EDGE",
|
|
8
9
|
INPUT_VALIDATION_ERROR = "INPUT_VALIDATION_ERROR"
|
|
9
10
|
}
|
|
10
11
|
export declare class GameError extends Error {
|
|
12
|
+
static createUnsupportedEdgeError(message: string): GameError;
|
|
11
13
|
static createValidationError(message: string): GameError;
|
|
12
14
|
static isGameError(error: unknown): error is GameError;
|
|
13
15
|
errorCode: GameErrorCode;
|
|
@@ -28,9 +30,12 @@ export declare enum OrigamiGame {
|
|
|
28
30
|
BLITZ = "BLITZ",
|
|
29
31
|
DARTS = "DARTS"
|
|
30
32
|
}
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
export interface Game {
|
|
34
|
+
gameId: OrigamiGame;
|
|
35
|
+
supportedEdgeConfigurations: [
|
|
36
|
+
number,
|
|
37
|
+
...number[]
|
|
38
|
+
];
|
|
34
39
|
}
|
|
35
40
|
export type Proof = {
|
|
36
41
|
proofHash: string;
|
|
@@ -79,8 +84,13 @@ export interface GameResult<TGameOutputs = EmptyGameOutput> {
|
|
|
79
84
|
};
|
|
80
85
|
randomValues: SingleRandomValue | MultipleRandomValues;
|
|
81
86
|
}
|
|
82
|
-
export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = EmptyGameOutput>
|
|
87
|
+
export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = EmptyGameOutput> implements Game {
|
|
88
|
+
readonly gameId: OrigamiGame;
|
|
83
89
|
protected constructor(gameId: OrigamiGame);
|
|
90
|
+
abstract get supportedEdgeConfigurations(): [
|
|
91
|
+
number,
|
|
92
|
+
...number[]
|
|
93
|
+
];
|
|
84
94
|
getGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
85
95
|
protected abstract determineGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
86
96
|
}
|
|
@@ -120,6 +130,10 @@ export declare const calculateAdvancedDiceWinChance: (gameInputs: AdvancedDiceIn
|
|
|
120
130
|
export declare const validateAdvancedDiceInputs: (gameInputs: AdvancedDiceInputs) => void;
|
|
121
131
|
export declare class AdvancedDice extends SingleActionGame<AdvancedDiceInputs> {
|
|
122
132
|
constructor();
|
|
133
|
+
get supportedEdgeConfigurations(): [
|
|
134
|
+
number,
|
|
135
|
+
...number[]
|
|
136
|
+
];
|
|
123
137
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<AdvancedDiceInputs>): GameResult;
|
|
124
138
|
}
|
|
125
139
|
export interface Bet {
|
|
@@ -176,7 +190,11 @@ export interface BaccaratGameOutputs {
|
|
|
176
190
|
export declare const calculateBaccaratBetAmount: (gameInputs: BaccaratGameInputs) => Big$1;
|
|
177
191
|
export declare class Baccarat extends SingleActionGame<BaccaratGameInputs, BaccaratGameOutputs> {
|
|
178
192
|
constructor();
|
|
179
|
-
|
|
193
|
+
get supportedEdgeConfigurations(): [
|
|
194
|
+
number,
|
|
195
|
+
...number[]
|
|
196
|
+
];
|
|
197
|
+
protected determineGameResult({ generator, gameInputs }: GetGameResultRequest<BaccaratGameInputs>): GameResult<BaccaratGameOutputs>;
|
|
180
198
|
private validateGameInputs;
|
|
181
199
|
private mapRandomValueToCard;
|
|
182
200
|
private isNaturalWin;
|
|
@@ -386,9 +404,14 @@ export interface GameStore<TInternalState extends BaseGameState, TAction, TConfi
|
|
|
386
404
|
}
|
|
387
405
|
export declare abstract class MultiActionGame<TInternalState extends BaseGameState, TExternalState extends BaseGameState, TAction extends {
|
|
388
406
|
readonly type: string;
|
|
389
|
-
}, TConfig>
|
|
407
|
+
}, TConfig> implements Game {
|
|
408
|
+
readonly gameId: OrigamiGame;
|
|
390
409
|
readonly edge: number;
|
|
391
|
-
constructor(gameId: OrigamiGame, edge: number);
|
|
410
|
+
protected constructor(gameId: OrigamiGame, edge: number);
|
|
411
|
+
abstract get supportedEdgeConfigurations(): [
|
|
412
|
+
number,
|
|
413
|
+
...number[]
|
|
414
|
+
];
|
|
392
415
|
abstract getValidNextActionTypes(state: TExternalState): ReadonlyArray<TAction["type"]>;
|
|
393
416
|
protected abstract createGameStore(): GameStore<TInternalState, TAction, TConfig>;
|
|
394
417
|
protected abstract generateRandomValues(generator: RandomNumberGenerator): RandomValuePool;
|
|
@@ -396,6 +419,7 @@ export declare abstract class MultiActionGame<TInternalState extends BaseGameSta
|
|
|
396
419
|
play(generator: RandomNumberGenerator, action: {
|
|
397
420
|
readonly type: string;
|
|
398
421
|
} & Record<string, unknown>, previousActions?: readonly UntypedGameContext[]): PlayResult;
|
|
422
|
+
private validateEdge;
|
|
399
423
|
}
|
|
400
424
|
export type BlackjackStartAction = Readonly<{
|
|
401
425
|
type: BlackjackActionType.START;
|
|
@@ -517,6 +541,10 @@ export type BlackjackInternalState = BlackjackInternalUninitialisedState | Black
|
|
|
517
541
|
export type BlackjackGameContext = GameContext<BlackjackAction, BlackjackState, BlackjackConfig>;
|
|
518
542
|
export declare class Blackjack extends MultiActionGame<BlackjackInternalState, BlackjackState, BlackjackAction, BlackjackConfig> {
|
|
519
543
|
constructor(edge: number);
|
|
544
|
+
get supportedEdgeConfigurations(): [
|
|
545
|
+
number,
|
|
546
|
+
...number[]
|
|
547
|
+
];
|
|
520
548
|
protected generateRandomValues(generator: RandomNumberGenerator): RandomValuePool;
|
|
521
549
|
protected toExternalState(internal: BlackjackInternalState): BlackjackState;
|
|
522
550
|
protected createGameStore(): GameStore<BlackjackInternalState, BlackjackAction, BlackjackConfig>;
|
|
@@ -538,6 +566,10 @@ export declare const hasBlitzWon: (drawnCards: number[]) => boolean;
|
|
|
538
566
|
export declare const calculateBlitzWinChance: (picks: number) => Big$1;
|
|
539
567
|
export declare class Blitz extends SingleActionGame<BlitzGameInputs, BlitzGameOutputs> {
|
|
540
568
|
constructor();
|
|
569
|
+
get supportedEdgeConfigurations(): [
|
|
570
|
+
number,
|
|
571
|
+
...number[]
|
|
572
|
+
];
|
|
541
573
|
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<BlitzGameInputs>): GameResult<BlitzGameOutputs>;
|
|
542
574
|
}
|
|
543
575
|
export declare const BLITZ_MIN_CARD_RANGE = 0;
|
|
@@ -557,7 +589,11 @@ export interface DartsGameInputs {
|
|
|
557
589
|
}
|
|
558
590
|
export declare class Darts extends SingleActionGame<DartsGameInputs> {
|
|
559
591
|
constructor();
|
|
560
|
-
|
|
592
|
+
get supportedEdgeConfigurations(): [
|
|
593
|
+
number,
|
|
594
|
+
...number[]
|
|
595
|
+
];
|
|
596
|
+
protected determineGameResult({ generator, gameInputs }: GetGameResultRequest<DartsGameInputs>): GameResult;
|
|
561
597
|
}
|
|
562
598
|
export type Segment = "YELLOW" | "ORANGE" | "RED";
|
|
563
599
|
export type DartboardConfig = ReadonlyDeep<{
|
|
@@ -601,6 +637,10 @@ export type DiamondsMultipliers = Record<keyof typeof DiamondsResultType, number
|
|
|
601
637
|
export declare const diamondsMultipliers: MultiplierContainer<DiamondsMultipliers>;
|
|
602
638
|
export declare class Diamonds extends SingleActionGame<DiamondsGameInputs> {
|
|
603
639
|
constructor();
|
|
640
|
+
get supportedEdgeConfigurations(): [
|
|
641
|
+
number,
|
|
642
|
+
...number[]
|
|
643
|
+
];
|
|
604
644
|
protected determineGameResult({ generator, edge }: GetGameResultRequest<DiamondsGameInputs>): GameResult;
|
|
605
645
|
private calculatePayoutMultiplier;
|
|
606
646
|
private classifyResult;
|
|
@@ -618,6 +658,10 @@ export declare const calculateDiceWinChance: (gameInputs: DiceGameInputs) => Big
|
|
|
618
658
|
export declare const hasDiceWon: (gameInputs: DiceGameInputs, rolledValue: number) => boolean;
|
|
619
659
|
export declare class Dice extends SingleActionGame<DiceGameInputs> {
|
|
620
660
|
constructor();
|
|
661
|
+
get supportedEdgeConfigurations(): [
|
|
662
|
+
number,
|
|
663
|
+
...number[]
|
|
664
|
+
];
|
|
621
665
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<DiceGameInputs>): GameResult;
|
|
622
666
|
}
|
|
623
667
|
export declare enum KenoRiskLevel {
|
|
@@ -646,6 +690,10 @@ export interface KenoGameInputs {
|
|
|
646
690
|
}
|
|
647
691
|
export declare class Keno extends SingleActionGame<KenoGameInputs> {
|
|
648
692
|
constructor();
|
|
693
|
+
get supportedEdgeConfigurations(): [
|
|
694
|
+
number,
|
|
695
|
+
...number[]
|
|
696
|
+
];
|
|
649
697
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<KenoGameInputs>): GameResult;
|
|
650
698
|
}
|
|
651
699
|
export type KenoMultipliers = Record<TileCount, Record<KenoRiskLevel, number[]>>;
|
|
@@ -663,6 +711,10 @@ export interface LimboGameOutputs {
|
|
|
663
711
|
}
|
|
664
712
|
export declare class Limbo extends SingleActionGame<LimboGameInputs, LimboGameOutputs> {
|
|
665
713
|
constructor();
|
|
714
|
+
get supportedEdgeConfigurations(): [
|
|
715
|
+
number,
|
|
716
|
+
...number[]
|
|
717
|
+
];
|
|
666
718
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<LimboGameInputs>): GameResult<LimboGameOutputs>;
|
|
667
719
|
}
|
|
668
720
|
export interface MinesGameInputs {
|
|
@@ -672,6 +724,10 @@ export interface MinesGameInputs {
|
|
|
672
724
|
}
|
|
673
725
|
export declare class Mines extends SingleActionGame<MinesGameInputs> {
|
|
674
726
|
constructor();
|
|
727
|
+
get supportedEdgeConfigurations(): [
|
|
728
|
+
number,
|
|
729
|
+
...number[]
|
|
730
|
+
];
|
|
675
731
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<MinesGameInputs>): GameResult;
|
|
676
732
|
}
|
|
677
733
|
export declare enum PlinkoRiskLevel {
|
|
@@ -685,6 +741,10 @@ export interface PlinkoGameInputs {
|
|
|
685
741
|
}
|
|
686
742
|
export declare class Plinko extends SingleActionGame<PlinkoGameInputs> {
|
|
687
743
|
constructor();
|
|
744
|
+
get supportedEdgeConfigurations(): [
|
|
745
|
+
number,
|
|
746
|
+
...number[]
|
|
747
|
+
];
|
|
688
748
|
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<PlinkoGameInputs>): GameResult;
|
|
689
749
|
}
|
|
690
750
|
export declare const PLINKO_ROW_COUNTS: readonly [
|
|
@@ -2080,11 +2140,19 @@ declare abstract class BaseRoulette<TInputs extends {
|
|
|
2080
2140
|
export declare class EuropeanRoulette extends BaseRoulette<EuropeanRouletteGameInputs, EuropeanRouletteGameOutputs> {
|
|
2081
2141
|
protected readonly maxNumber = 36;
|
|
2082
2142
|
protected readonly betPredicates: Record<keyof EuropeanRouletteGameInputs, BetPredicate>;
|
|
2143
|
+
get supportedEdgeConfigurations(): [
|
|
2144
|
+
number,
|
|
2145
|
+
...number[]
|
|
2146
|
+
];
|
|
2083
2147
|
protected validateInputs(inputs: EuropeanRouletteGameInputs): void;
|
|
2084
2148
|
}
|
|
2085
2149
|
export declare class AmericanRoulette extends BaseRoulette<AmericanRouletteGameInputs, AmericanRouletteGameOutputs> {
|
|
2086
2150
|
protected readonly maxNumber = 37;
|
|
2087
2151
|
protected readonly betPredicates: Record<keyof AmericanRouletteGameInputs, BetPredicate>;
|
|
2152
|
+
get supportedEdgeConfigurations(): [
|
|
2153
|
+
number,
|
|
2154
|
+
...number[]
|
|
2155
|
+
];
|
|
2088
2156
|
protected validateInputs(inputs: AmericanRouletteGameInputs): void;
|
|
2089
2157
|
protected isWinningBasketBet(_bet: BaseBet, gameResult: number): boolean;
|
|
2090
2158
|
}
|
|
@@ -2092,6 +2160,10 @@ export declare class Roulette extends SingleActionGame<RouletteGameInputs, Roule
|
|
|
2092
2160
|
private readonly europeanGame;
|
|
2093
2161
|
private readonly americanGame;
|
|
2094
2162
|
constructor();
|
|
2163
|
+
get supportedEdgeConfigurations(): [
|
|
2164
|
+
number,
|
|
2165
|
+
...number[]
|
|
2166
|
+
];
|
|
2095
2167
|
getBetAmount(gameInputs: RouletteGameInputs): Big$1.Big;
|
|
2096
2168
|
protected determineGameResult(request: GetGameResultRequest<RouletteGameInputs>): GameResult<RouletteGameOutputs>;
|
|
2097
2169
|
}
|
|
@@ -2115,6 +2187,10 @@ export interface WheelGameInputs {
|
|
|
2115
2187
|
}
|
|
2116
2188
|
export declare class Wheel extends SingleActionGame<WheelGameInputs> {
|
|
2117
2189
|
constructor();
|
|
2190
|
+
get supportedEdgeConfigurations(): [
|
|
2191
|
+
number,
|
|
2192
|
+
...number[]
|
|
2193
|
+
];
|
|
2118
2194
|
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
|
|
2119
2195
|
}
|
|
2120
2196
|
export declare const bigMax: (a: Big$1, b: Big$1) => Big$1;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Za;((a)=>a.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(Za||={});class l extends Error{static createValidationError(t){return new l("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof l}errorCode;constructor(t,a){super(a);this.errorCode=t}}var S;((B)=>{B.DICE="DICE";B.MINES="MINES";B.KENO="KENO";B.LIMBO="LIMBO";B.ADVANCED_DICE="ADVANCED_DICE";B.BACCARAT="BACCARAT";B.DIAMONDS="DIAMONDS";B.PLINKO="PLINKO";B.ROULETTE="ROULETTE";B.WHEEL="WHEEL";B.BLACKJACK="BLACKJACK";B.BLITZ="BLITZ";B.DARTS="DARTS"})(S||={});class M{gameId;constructor(t){this.gameId=t}}class A extends M{constructor(t){super(t)}getGameResult(t){return this.determineGameResult(t)}}import{Big as Ft}from"big.js";import st from"big.js";class C{static withMultiplier(t,a){return new st(t).times(new st(100-a).div(100))}static withWinChance(t,a){return st(100-t).div(a)}}var Bt=0,mt=1e4,Mt=10001,ka=0.01,Ga=98,Ma=(t)=>{if(t<Bt)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${Bt}`)},Fa=(t)=>{if(t>mt)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${mt}`)},v=(t)=>{if(Ma(t.lower),Fa(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},Ja=(t,a)=>{let[r,e]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>e.lower)throw l.createValidationError("Bounds must not overlap")},Ya=(t,a)=>a>=t.lower&&a<=t.upper,$a=(t)=>t.upper-t.lower+1,pt=(t,a)=>a>t.lower&&a<t.upper,At=(t)=>t.upper-t.lower-1,za;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(za||={});var Jt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return v(t.bounds),At(t.bounds);case"ROLL_OUTSIDE":return v(t.bounds),Mt-$a(t.bounds);case"ROLL_BETWEEN_TWO":return v(t.firstBounds),v(t.secondBounds),Ja(t.firstBounds,t.secondBounds),At(t.firstBounds)+At(t.secondBounds)}})(),e=Ft(r).div(Mt).mul(100);if(e.lt(ka))throw l.createValidationError("Win chance too low");if(e.gt(Ga))throw l.createValidationError("Win chance too high");return e},$e=(t)=>{Jt(t)};class Xa extends A{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=Jt(r),o=t.getRandomInt({min:Bt,max:mt}),n=o.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return pt(r.bounds,n);case"ROLL_OUTSIDE":return!Ya(r.bounds,n);case"ROLL_BETWEEN_TWO":return pt(r.firstBounds,n)||pt(r.secondBounds,n)}})()?C.withWinChance(a,e):new Ft(0),outputs:{result:o.values},randomValues:o}}}import _ from"big.js";var qa=["Clubs","Diamonds","Hearts","Spades"],Qa=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],ga;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(ga||={});var Wa;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(Wa||={});var La={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Ka=(t)=>{return new _(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new _(0)))};class va extends A{constructor(){super("BACCARAT")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(r!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(a);let e=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),o=e.values,n=o.slice(0,3),i=o.slice(3,6),c=[],d=0;for(let E of n.slice(0,2)){let h=this.mapRandomValueToCard(E),K=this.mapRandomValueToCardValue(E);c.push(h),d=(d+K)%10}let p=[],u=0;for(let E of i.slice(0,2)){let h=this.mapRandomValueToCard(E),K=this.mapRandomValueToCardValue(E);p.push(h),u=(u+K)%10}if(!this.isNaturalWin(d,u)){let E=this.shouldDrawThirdPlayerCard(d),h=null;if(E)h=this.mapRandomValueToCardValue(n[2]),c.push(this.mapRandomValueToCard(n[2])),d=(d+h)%10;if(this.shouldDrawThirdBankerCard(u,h))p.push(this.mapRandomValueToCard(i[2])),u=(u+this.mapRandomValueToCardValue(i[2]))%10}let s;if(d===u)s="TIE";else s=d>u?"PLAYER_WIN":"BANKER_WIN";let m=Ka(a),{betType:B,multiplier:ut}=La[s],G=new _(0);if(G=G.add(a.bets.filter((E)=>E.type===B).reduce((E,h)=>E.add(h.amount.mul(ut)),new _(0))),s==="TIE")G=G.add(a.bets.filter((E)=>E.type==="PLAYER"||E.type==="BANKER").reduce((E,h)=>E.add(h.amount),new _(0)));return{isFinished:!0,payoutMultiplier:m.gt(0)?G.div(m):new _(0),outputs:{playerCards:c,playerHandValue:d,bankerCards:p,bankerHandValue:u,gameOutcome:s,result:e.values},randomValues:e}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=qa[Math.floor(t/13)],r=Qa[t%13];return{suit:a,rank:r}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var yt;((o)=>{o.WIN="WIN";o.LOSE="LOSE";o.PUSH="PUSH";o.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(yt||={});var Et;((r)=>{r.WON="WON";r.LOST="LOST"})(Et||={});var ft;((c)=>{c.START="START";c.HIT="BLACKJACK_HIT";c.STAND="BLACKJACK_STAND";c.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";c.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";c.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";c.SPLIT="BLACKJACK_SPLIT"})(ft||={});var St;((o)=>{o.EXACT_PAIR="EXACT_PAIR";o.COLORED_PAIR="COLORED_PAIR";o.MIXED_PAIR="MIXED_PAIR";o.LOSS="LOSS"})(St||={});var Ot;((i)=>{i.SUITED_TRIPS="SUITED_TRIPS";i.STRAIGHT_FLUSH="STRAIGHT_FLUSH";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.STRAIGHT="STRAIGHT";i.FLUSH="FLUSH";i.LOSS="LOSS"})(Ot||={});var tr=2.5,ar=2,rr=1,er=0,Yt=17,Ht=21,D=21,ht=63,ro=1.5,F=0.5,Dt=1.5,R=1,N=1,eo=13,xt=10,$t=10,tt={PLAYER_BLACKJACK:tr,WIN:ar,PUSH:rr,LOSE:er},zt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Xt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};import b from"big.js";import{Guard as y}from"@betorigami/guard";import{createStore as ur}from"@xstate/store";var qt=0,Qt=51,at=Array.from({length:52},(t,a)=>a),gt=["Spades","Hearts","Diamonds","Clubs"],rt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Wt=["Jack","Queen","King"],Ct={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};import{Guard as or}from"@betorigami/guard";import{Guard as Pt}from"@betorigami/guard";class J{value;constructor(t){let a=at[t];Pt.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=gt[t];return Pt.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=rt[t];return Pt.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}class f extends J{get numericRank(){if(Wt.includes(this.rank))return $t;return rt.indexOf(this.rank)+1}static fromValue(t){return or.against(!at.includes(t),`Invalid card value: ${t}`),new f(t)}}class Y{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,e)=>r+e.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+xt<=Ht)this.softHandValue=this.hardHandValue+xt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>Ht}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===D}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class ${cards;value;constructor(t){this.cards=t.map((a)=>f.fromValue(a)),this.value=new Y(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class z extends ${otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=f.fromValue(t),this.holeCard=f.fromValue(a)}static withInitialDeal(t){return new z(t.upCard,t.holeCard)}addDrawnCards(t){return new z(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new Y([this.upCard]).highestHandValue}}}class j extends ${static withInitialDeal(t){return new j(t)}addDrawnCards(t){return new j([...this.rawValues,...t])}}import{Guard as et}from"@betorigami/guard";class ot{source;index=0;constructor(t){this.source=t}static from(t,a){return et.against(a<=0,`Count must be positive, got ${a}`),et.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new ot(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return et.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){et.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}import{Guard as nr}from"@betorigami/guard";import ir from"fast-deep-equal";class Tt extends M{edge;constructor(t,a){super(t);this.edge=a}play(t,a,r=[]){let e=this.createGameStore(),o=this.generateRandomValues(t),n=o.toMultipleRandomValues();for(let d of r)e.send({...d.playerArgument,randomValuePool:o});let i=r[r.length-1];if(i)nr.against(!ir(i.state,this.toExternalState(e.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");e.send({...a,randomValuePool:o});let c=e.getSnapshot().context;return{playerArgument:c.playerArgument,state:this.toExternalState(c.state),config:c.config,additionalBetAmount:c.additionalBetAmount,proof:{proofHash:n.proofHash,proofString:n.proofString}}}}import x from"big.js";import{Guard as Rt}from"@betorigami/guard";var Lt=(t)=>{let a=t.pairBonus!==null?x(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier):x(0),r=t.threeCardBonus!==null?x(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier):x(0);return a.plus(r)},Kt=(t)=>{let a=t.betAmounts.mainBetAmount,e=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(R):x(0),o=t.insuranceOutcome!==void 0?a.mul(F):x(0),n=a.plus(e).mul(tt[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(Dt):x(0),c=Lt(t.sideBetResults),d=n.plus(i).plus(c),p=a.plus(o).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Rt.against(p.eq(0),"Total bet amount cannot be zero");let u=d.div(p);Rt.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let s;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":s=e;break;case"BLACKJACK_BUY_INSURANCE":s=o;break;case"BLACKJACK_SPLIT":s=a.mul(N);break}return{multiplier:u,additionalBetAmount:s}},vt=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(R):x(0),e=t.splitHandDoubledDown?a.mul(R):x(0),o=t.insuranceOutcome!==void 0?a.mul(F):x(0),n=a.plus(r).mul(tt[t.mainOutcome]),i=a.plus(e).mul(tt[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(Dt):x(0),d=Lt(t.sideBetResults),p=n.plus(i).plus(c).plus(d),u=a.plus(a).plus(o).plus(r).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Rt.against(u.eq(0),"Total bet amount cannot be zero");let s=p.div(u),m;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":m=a.mul(R);break;case"BLACKJACK_SPLIT":m=a.mul(N);break}return{multiplier:s,additionalBetAmount:m}};import{Guard as cr}from"@betorigami/guard";var jt=(t)=>t.every((a)=>a===t[0]),ta=(t)=>{let a=[...t].sort((r,e)=>r-e);return a.every((r,e)=>{let o=a[e-1];if(e===0)return!0;return cr.againstUndefined(o,"Previous value cannot be undefined"),r===o+1})},aa={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},lr={...aa,Ace:14},dr=(t)=>ta(t.map((a)=>aa[a]))||ta(t.map((a)=>lr[a])),ra=(t,a)=>{let r=f.fromValue(t),e=f.fromValue(a);if(r.rank!==e.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Ct[r.suit]===Ct[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},ea=(t,a)=>({betAmount:t,result:a,payoutMultiplier:zt[a]}),oa=(t,a,r)=>{let e=f.fromValue(t),o=f.fromValue(a),n=f.fromValue(r),i=[e.rank,o.rank,n.rank],c=jt([e.suit,o.suit,n.suit]),d=jt(i),p=dr(i);if(jt([t,a,r]))return"SUITED_TRIPS";if(c&&p)return"STRAIGHT_FLUSH";if(d)return"THREE_OF_A_KIND";if(p)return"STRAIGHT";if(c)return"FLUSH";return"LOSS"},na=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Xt[a]});var sr={state:{isFinished:!1,phase:"uninitialised",multiplier:b(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},O=(t)=>f.fromValue(t).value;function pr(t){y.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function ia(t){y.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function bt(t){y.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var ca=(t,a)=>{let r=a;while(r.highestHandValue<Yt)r=r.addDrawnCards([O(t.takeOne())]);return r},Nt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,e=a.highestHandValue;if(r>e)return"WIN";if(r<e)return"LOSE";return"PUSH"},H=(t)=>{let{multiplier:a,additionalBetAmount:r}=Kt({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,multiplier:a,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:r}},_t=(t)=>{let a=ca(t.randomValuePool,t.dealerHand),r=Nt(t.playerHand,a);return H({...t,dealerHand:a,outcome:r})},T=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:ca(t.randomValuePool,t.dealerHand),e=Nt(t.mainHand,r),o=Nt(t.splitHand,r),{multiplier:n,additionalBetAmount:i}=vt({hasSplit:!0,mainOutcome:e,splitOutcome:o,insuranceOutcome:t.insuranceOutcome,mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:e,splitOutcome:o,multiplier:n,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class Ar extends Tt{constructor(t){super("BLACKJACK",t)}generateRandomValues(t){return ot.from(t.getRandomIntsWithReplacement({min:qt,max:Qt,count:ht}),ht)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:y.againstNever(a,"Invalid state received")}}createGameStore(){return ur({context:sr,on:{START:(t,a)=>{let{state:r}=t;y.against(r.phase!=="uninitialised","START action requires a fresh game");let e=O(a.randomValuePool.takeOne()),o=O(a.randomValuePool.takeOne()),n=O(a.randomValuePool.takeOne()),i=O(a.randomValuePool.takeOne()),c=j.withInitialDeal([e,o]),d=z.withInitialDeal({upCard:n,holeCard:i}),p={mainBetAmount:b(a.mainBetAmount),pairBonusAmount:b(a.pairBonusAmount),threeCardBonusAmount:b(a.threeCardBonusAmount)},u={pairBonus:b(a.pairBonusAmount).gt(0)?ea(a.pairBonusAmount,ra(e,o)):null,threeCardBonus:b(a.threeCardBonusAmount).gt(0)?na(a.threeCardBonusAmount,oa(e,o,n)):null},s={type:"START",mainBetAmount:a.mainBetAmount,pairBonusAmount:a.pairBonusAmount,threeCardBonusAmount:a.threeCardBonusAmount};if(d.upCard.rank==="Ace")return{state:{...r,isFinished:!1,phase:"awaiting-insurance",playerHand:c,dealerHand:d,betAmounts:p,sideBetResults:u},config:{},playerArgument:s};let m={playerHand:c,dealerHand:d,randomValuePool:a.randomValuePool,playerArgument:s,betAmounts:p,sideBetResults:u};if(c.isBlackjack&&d.isBlackjack)return H({...m,outcome:"PUSH"});if(c.isBlackjack)return H({...m,outcome:"PLAYER_BLACKJACK"});if(d.isBlackjack)return H({...m,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:c,dealerHand:d,insuranceOutcome:void 0,betAmounts:p,sideBetResults:u},config:{},playerArgument:s}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;ia(r);let{playerHand:e,dealerHand:o,betAmounts:n,sideBetResults:i}=r,c={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:n,sideBetResults:i};if(e.isBlackjack&&o.isBlackjack)return H({...c,outcome:"PUSH",insuranceOutcome:"WON"});if(e.isBlackjack)return H({...c,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(o.isBlackjack)return H({...c,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:n.mainBetAmount.mul(F)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;ia(r);let{playerHand:e,dealerHand:o,betAmounts:n,sideBetResults:i}=r,c={playerHand:e,dealerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:n,sideBetResults:i};if(e.isBlackjack&&o.isBlackjack)return H({...c,outcome:"PUSH"});if(e.isBlackjack)return H({...c,outcome:"PLAYER_BLACKJACK"});if(o.isBlackjack)return H({...c,outcome:"LOSE"});return{state:{...r,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(t,a)=>{let{state:r}=t;switch(bt(r),r.phase){case"playing-main-hand":{let e=r.mainHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===D){if(r.splitHand.highestHandValue===D)return T({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let e=r.splitHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===D)return T({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let e=r.playerHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted)return H({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(e.highestHandValue===D)return _t({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:y.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(bt(r),r.phase){case"playing-main-hand":{if(r.splitHand.highestHandValue===D)return T({...r,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...r,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return T({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return _t({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:y.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(bt(r),r.phase){case"playing-main-hand":{y.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.mainHand.addDrawnCards([O(a.randomValuePool.takeOne())]),{betAmounts:o}=r;if(r.splitHand.highestHandValue===D)return T({...r,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:o.mainBetAmount.mul(R)}}case"playing-split-hand":{y.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.splitHand.addDrawnCards([O(a.randomValuePool.takeOne())]);return T({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{y.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.playerHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(e.isBusted)return H({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return _t({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:y.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;pr(r);let{playerHand:e,betAmounts:o,sideBetResults:n}=r;y.against(e.cards.length!==2,"Split is only allowed with exactly 2 cards");let i=e.cards[0],c=e.cards[1];y.againstUndefined(i,"First card is missing"),y.againstUndefined(c,"Second card is missing"),y.against(i.rank!==c.rank,"Split requires two cards of the same rank");let d=O(a.randomValuePool.takeOne()),p=O(a.randomValuePool.takeOne()),u=j.withInitialDeal([i.value,d]),s=j.withInitialDeal([c.value,p]);if(i.rank==="Ace")return T({...r,mainHand:u,splitHand:s,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let B=u.highestHandValue===D,ut=s.highestHandValue===D;if(B&&ut)return T({mainHand:u,splitHand:s,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:o,sideBetResults:n});if(B)return{state:{...r,phase:"playing-split-hand",mainHand:u,splitHand:s,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(N)};return{state:{...r,phase:"playing-main-hand",multiplier:b(0),mainHand:u,splitHand:s,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(N)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],e=t.playerHand.cards[1];if(y.againstUndefined(r,"First player card is missing"),y.againstUndefined(e,"Second player card is missing"),r.rank===e.rank)a.push("BLACKJACK_SPLIT")}return a}default:y.againstNever(t,"Invalid phase for getting valid actions")}}}import q from"big.js";import{Guard as Br}from"@betorigami/guard";var la=0,da=51,X=52,ua=52;var En=()=>({minPicks:5,maxPicks:36}),mr=(t)=>t.length===new Set(t).size,yr=(t)=>{let a=q(1),r=q(X);for(let e=0;e<t;e+=1)a=a.mul(q(X-e).div(r));return a};class Er extends A{constructor(){super("BLITZ")}determineGameResult({generator:t,gameInputs:a,edge:r}){Br.against(a.pickCount<1||a.pickCount>X,`pickCount must be between 1 and ${X}`);let e=t.getRandomIntsWithReplacement({min:la,max:da,count:ua}),o=e.values.slice(0,a.pickCount),n=mr(o),i=yr(a.pickCount);return{isFinished:!0,payoutMultiplier:n?C.withMultiplier(q(1).div(i),r):q(0),outputs:{result:e.values,cards:o.map((d)=>new J(d).toDto())},randomValues:e}}}var sa=0,Vt=4294967295,pa;((o)=>{o.EASY="EASY";o.MEDIUM="MEDIUM";o.HARD="HARD";o.EXPERT="EXPERT"})(pa||={});var fr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Sr={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:fr},Or=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Hr={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:Or},hr=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Dr={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:hr},xr=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Cr={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:xr},xn=(t)=>{let a=It[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((e,o)=>o>e?o:e)},It={EASY:Sr,MEDIUM:Hr,HARD:Dr,EXPERT:Cr};import{Guard as wt}from"@betorigami/guard";import Pr from"big.js";class Tr extends A{constructor(){super("DARTS")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(r!==2)throw new Error("Darts is only available at 2% edge");let e=t.getRandomIntsWithReplacement({min:sa,max:Vt,count:2}),o=e.values[0],n=e.values[1];wt.againstUndefined(o,"Random number generator returned no value for clockWiseRotation"),wt.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let i=a.difficultyLevel;return{isFinished:!0,payoutMultiplier:Pr(Rr(i,o,n)),outputs:{result:e.values},randomValues:e}}}var Rr=(t,a,r)=>{let e=It[t],{distanceBoundaries:o,multipliers:n}=e;if(r<o.bullseye)return n.bullseye;if(r<o.ringOne)return n.ringOne;if(r<o.ringTwo)return n.ringTwo;if(r<o.ringThree)return jr(e,a);return n.ringFour},jr=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(Vt+1)*r),o=t.segments[e];return wt.againstUndefined(o,`Segment index ${e} out of bounds`),t.multipliers.ringThree[o]};import br from"big.js";class P{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var _r;((i)=>{i.PAIR="PAIR";i.TWO_PAIR="TWO_PAIR";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.FULL_HOUSE="FULL_HOUSE";i.FOUR_OF_A_KIND="FOUR_OF_A_KIND";i.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(_r||={});var Nr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},Vr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},Ir={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},wr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},Ur={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},Zr=new P(new Map([[1,Nr],[2,Vr],[3,Ir],[4,wr],[8,Ur]])),kr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Gr extends A{constructor(){super("DIAMONDS")}determineGameResult({generator:t,edge:a}){let r=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=Zr.getMultipliers(a),o=r.values,n=this.calculatePayoutMultiplier(e,o);return{isFinished:!0,payoutMultiplier:br(n),outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(t,a){let r=new Map;for(let n of a){let i=r.get(n)||0;r.set(n,i+1)}let e=[...r.values()].filter((n)=>n>1),o=this.classifyResult(e);return o===null?0:t[o]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let e=kr[a];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return e}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}import Ba from"big.js";var Mr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Mr||={});var Aa=1e4,Fr=(t)=>{let a=t.direction==="ABOVE"?Aa-t.selectedValue:t.selectedValue;return new Ba(a).div(Aa).mul(100)},Jr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class Yr extends A{constructor(){super("DICE")}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:0,max:1e4}),o=Fr(r);return{isFinished:!0,payoutMultiplier:Jr(r,e.value)?C.withWinChance(a,o):new Ba(0),outputs:{result:e.values},randomValues:e}}}import Wr from"big.js";import{Guard as nt}from"@betorigami/guard";var ma;((o)=>{o.CLASSIC="CLASSIC";o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(ma||={});var $r=[1,2,3,4,5,6,7,8,9,10],ya=(t)=>{return $r.includes(t)};var zr={[1]:{CLASSIC:[0,3.96],LOW_RISK:[0.7,1.85],MEDIUM_RISK:[0.4,2.75],HIGH_RISK:[0,3.96]},[2]:{CLASSIC:[0,1.9,4.5],LOW_RISK:[0,2,3.8],MEDIUM_RISK:[0,1.8,5.1],HIGH_RISK:[0,0,17.1]},[3]:{CLASSIC:[0,1,3.1,10.4],LOW_RISK:[0,1.1,1.38,26],MEDIUM_RISK:[0,0,2.8,50],HIGH_RISK:[0,0,0,81.5]},[4]:{CLASSIC:[0,0.8,1.8,5,22.5],LOW_RISK:[0,0,2.2,7.9,90],MEDIUM_RISK:[0,0,1.7,10,100],HIGH_RISK:[0,0,0,10,259]},[5]:{CLASSIC:[0,0.25,1.4,4.1,16.5,36],LOW_RISK:[0,0,1.5,4.2,13,300],MEDIUM_RISK:[0,0,1.4,4,14,390],HIGH_RISK:[0,0,0,4.5,48,450]},[6]:{CLASSIC:[0,0,1,3.68,7,16.5,40],LOW_RISK:[0,0,1.1,2,6.2,100,700],MEDIUM_RISK:[0,0,0,3,9,180,710],HIGH_RISK:[0,0,0,0,11,350,710]},[7]:{CLASSIC:[0,0,0.47,3,4.5,14,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,15,225,700],MEDIUM_RISK:[0,0,0,2,7,30,400,800],HIGH_RISK:[0,0,0,0,7,90,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,13,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,5.5,39,100,800],MEDIUM_RISK:[0,0,0,2,4,11,67,400,900],HIGH_RISK:[0,0,0,0,5,20,270,600,900]},[9]:{CLASSIC:[0,0,0,1.55,3,8,15,44,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1000],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1000]}},Xr={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},qr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},Qr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.68,1.84],MEDIUM_RISK:[0.38,2.74],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,1.96,3.75],MEDIUM_RISK:[0,1.77,5],HIGH_RISK:[0,0,16.82]},[3]:{CLASSIC:[0,1,3.05,9.35],LOW_RISK:[0,1.07,1.37,25.7],MEDIUM_RISK:[0,0,2.74,49],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.72,4.95,22.3],LOW_RISK:[0,0,2.15,7.86,87],MEDIUM_RISK:[0,0,1.67,9.7,100],HIGH_RISK:[0,0,0,9.7,256]},[5]:{CLASSIC:[0,0.24,1.38,4,16.3,35.5],LOW_RISK:[0,0,1.48,4.1,12.43,300],MEDIUM_RISK:[0,0,1.35,3.96,13.8,389],HIGH_RISK:[0,0,0,4.4,47,444]},[6]:{CLASSIC:[0,0,1,3.57,6.8,16.2,37],LOW_RISK:[0,0,1.06,1.96,6.16,99,700],MEDIUM_RISK:[0,0,0,2.9,8.9,178,709],HIGH_RISK:[0,0,0,0,10.4,347,709]},[7]:{CLASSIC:[0,0,0.45,2.95,4.44,13.85,30,60],LOW_RISK:[0,0,1.07,1.57,3.47,14.57,225,700],MEDIUM_RISK:[0,0,0,1.95,6.8,29.8,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.15,3.9,12.9,21.9,55,70],LOW_RISK:[0,0,1.08,1.45,1.98,5.48,38.8,100,800],MEDIUM_RISK:[0,0,0,1.95,3.96,10.6,66.9,396,896],HIGH_RISK:[0,0,0,0,4.9,19.2,269,599,896]},[9]:{CLASSIC:[0,0,0,1.5,2.95,7.96,14.96,44,60,85],LOW_RISK:[0,0,1.05,1.29,1.69,2.49,7.49,49,250,1000],MEDIUM_RISK:[0,0,0,1.95,2.47,4.9,14.9,99,500,1000],HIGH_RISK:[0,0,0,0,3.96,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.45,7.7,16.7,50,80,100],LOW_RISK:[0,0,1.08,1.18,1.28,1.76,3.4,12.9,50,250,1000],MEDIUM_RISK:[0,0,0,1.57,1.95,3.96,6.9,25.5,100,500,1000],HIGH_RISK:[0,0,0,0,3.43,7.9,12.5,60,500,800,1000]}},gr={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},Ea=new P(new Map([[1,zr],[2,Xr],[3,qr],[4,Qr],[8,gr]]));class Lr extends A{constructor(){super("KENO")}determineGameResult({generator:t,edge:a,gameInputs:r}){nt.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),nt.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let s of r.selectedNumbers)nt.againstNonInteger(s,()=>l.createValidationError("Only integers can be selected")),nt.against(s<0||s>39,()=>l.createValidationError("Invalid number selected"));let e=t.getUniqueRandomInts({min:0,max:39,count:10}),o=r.selectedNumbers.filter((s)=>e.values.includes(s)),n=r.selectedNumbers.length;if(!ya(n))throw new Error(`Invalid tile count: ${n}`);let p=Ea.getMultipliers(a)[n][r.riskLevel][o.length];if(p===void 0)throw new Error(`No multiplier found for matching tile count ${o.length}`);return{isFinished:!0,payoutMultiplier:new Wr(p),outputs:{result:e.values},randomValues:e}}}import V from"big.js";var fa=(t,a)=>{return t.gt(a)?t:a};var Sa=(t,a)=>{return t.lt(a)?t:a};class Kr extends A{constructor(){super("LIMBO")}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:1,max:4294967295}),o=e.max,n=new V(16777216),i=new V(1),c=new V(1e6),d=e.value,p=new V(d-1).div(o),u=(100-a)/100,s=n.div(p.mul(n).plus(1)).mul(u),m=fa(i,Sa(s,c));return{isFinished:!0,payoutMultiplier:m.gte(r.targetMultiplier)?new V(r.targetMultiplier):new V(0),outputs:{randomMultiplier:m,result:e.values},randomValues:e}}}import it from"big.js";var Ut=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let e=1;e<=a;e++)r=r*(t-e+1)/e;return r};class vr extends A{constructor(){super("MINES")}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let i=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),c=i.values.some((B)=>r.selectedTiles.includes(B)),d=r.hasCashedOut||c,p=(100-a)/100,u=new it(Ut(25-r.minesCount,r.selectedTiles.length)).div(new it(Ut(25,r.selectedTiles.length))),m=r.hasCashedOut&&!c?new it(p).div(u):new it(0);return{isFinished:d,payoutMultiplier:m,outputs:{result:i.values},randomValues:i}}}import{Big as ne}from"big.js";var Oa;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(Oa||={});var Ui=[8,9,10,11,12,13,14,15,16],te={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},ae={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},re={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},ee={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},oe={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},Ha=new P(new Map([[1,te],[2,ae],[3,re],[4,ee],[8,oe]]));class ie extends A{constructor(){super("PLINKO")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=a.numberOfRows,i=Ha.getMultipliers(r)[a.riskLevel][e],c=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),p=c.values.reduce((s,m)=>s+m,0),u=i[p];if(u===void 0)throw new Error(`No payout found for end position ${p}`);return{isFinished:!0,payoutMultiplier:ne(u),outputs:{result:c.values},randomValues:c}}}import{Big as dt}from"big.js";var Zt=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],ha=[37,...Zt],Da=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],xa=[[0,1],[0,37],[3,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],Ca=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],Pa=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],Ta=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Ra=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],ja=[0,1,2,3,37],ba=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],_a=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],I;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(I||={});var w;((r)=>{r.RED="RED";r.BLACK="BLACK"})(w||={});var U;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(U||={});var Z;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(Z||={});var k;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(k||={});var kt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(kt||={});var ct=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&Q(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&ce(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&le(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&de(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&ue(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(w).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},Q=(t)=>{return Zt.includes(t)},ce=(t)=>{if(t.length!==2)return!1;if(!t.every(Q))return!1;return Da.some(([a,r])=>a===t[0]&&r===t[1])},le=(t)=>{if(t.length!==3)return!1;if(!t.every(Q))return!1;return Ca.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},de=(t)=>{if(t.length!==4)return!1;if(!t.every(Q))return!1;return Ta.some(([a,r,e,o])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3])},ue=(t)=>{if(t.length!==6)return!1;if(!t.every(Q))return!1;return ba.some(([a,r,e,o,n,i])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3]&&n===t[4]&&i===t[5])};var lt=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&g(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&se(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&pe(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Ae(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw l.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Be(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(w).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},g=(t)=>{return ha.includes(t)};function se(t){if(t.length!==2)return!1;if(!t.every(g))return!1;return xa.some(([a,r])=>a===t[0]&&r===t[1])}var pe=(t)=>{if(t.length!==3)return!1;if(!t.every(g))return!1;return Pa.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},Ae=(t)=>{if(t.length!==4)return!1;if(!t.every(g))return!1;return Ra.some(([a,r,e,o])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3])},Be=(t)=>{if(t.length!==6)return!1;if(!t.every(g))return!1;return _a.some(([a,r,e,o,n,i])=>a===t[0]&&r===t[1]&&e===t[2]&&o===t[3]&&n===t[4]&&i===t[5])};var me={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},ye=[3,6,9,12,15,18,21,24,27,30,33,36],Ee=[2,5,8,11,14,17,20,23,26,29,32,35],fe=[1,4,7,10,13,16,19,22,25,28,31,34],Se=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Oe=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35],He=2.7,he=5.3;class Gt extends A{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),e=r.value,o=this.determineBetOutcomes(a,e),{payoutMultiplier:n}=this.getPayoutDetails(a,e);return{outputs:{betOutcomes:o,result:r.values},payoutMultiplier:n,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),e=this.getBetTotals(t),o=this.getBetTotals(r.winningBets),n=this.calculateTotalBetAmount(e),i=this.calculateTotalPayout(o);return{payoutMultiplier:n.gt(0)?i.div(n):new dt(0),payoutAmount:i}}determineBetOutcomes(t,a){let r={},e={};for(let o of Object.keys(t)){let n=t[o],i=this.betPredicates[o],{winning:c,losing:d}=this.partitionBets(n,i,a);r[o]=c,e[o]=d}return{winningBets:r,losingBets:e}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new dt(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return Se.includes(a)&&r.color==="RED"||Oe.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return ye.includes(a)&&r.column==="TOP"||Ee.includes(a)&&r.column==="MIDDLE"||fe.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let e=a%2===0?"EVEN":"ODD";return r.parity===e}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new dt(0))}partitionBets(t,a,r){return{winning:t.filter((e)=>a(e,r)),losing:t.filter((e)=>!a(e,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,e])=>{let n=me[r];return a.plus(e.mul(n||0))},new dt(0))}}class Na extends Gt{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};validateInputs(t){ct(t)}}class Va extends Gt{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};validateInputs(t){lt(t)}isWinningBasketBet(t,a){return ja.some((r)=>r===a)}}class Ia extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Na,this.americanGame=new Va}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(t.edge===He&&a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:o,result:e.outputs.result}}}if(t.edge===he&&a.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:o,result:e.outputs.result}}}throw l.createValidationError(`Attempted to play ${a.type} roulette on edge ${t.edge}`)}}var cc=(t)=>{return new Ia().getBetAmount(t)};var pc=(t)=>{if(t.type==="EUROPEAN")ct(t.inputs);else lt(t.inputs)};import{Big as Re}from"big.js";var W;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(W||={});var L;((n)=>{n[n.TEN=10]="TEN";n[n.TWENTY=20]="TWENTY";n[n.THIRTY=30]="THIRTY";n[n.FORTY=40]="FORTY";n[n.FIFTY=50]="FIFTY"})(L||={});var De={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.5},20:{ZERO:0,A:1.2,B:1.5},30:{ZERO:0,A:1.2,B:1.5},40:{ZERO:0,A:1.2,B:1.5},50:{ZERO:0,A:1.2,B:1.5}},MEDIUM_RISK:{10:{ZERO:0,A:1.5,B:1.9,C:2,D:3},20:{ZERO:0,A:1.5,B:1.8,C:2,D:3},30:{ZERO:0,A:1.5,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:3},50:{ZERO:0,A:1.5,B:2,C:3,D:5}},HIGH_RISK:{10:{ZERO:0,A:9.9},20:{ZERO:0,A:19.8},30:{ZERO:0,A:29.7},40:{ZERO:0,A:39.6},50:{ZERO:0,A:49.5}}},xe={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.4},20:{ZERO:0,A:1.2,B:1.4},30:{ZERO:0,A:1.2,B:1.4},40:{ZERO:0,A:1.2,B:1.4},50:{ZERO:0,A:1.2,B:1.4}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3.1},20:{ZERO:0,A:1.5,B:1.8,C:1.9,D:3.4},30:{ZERO:0,A:1.5,B:1.7,C:1.9,D:3,E:4.3},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.9},50:{ZERO:0,A:1.5,B:2,C:3,D:4.5}},HIGH_RISK:{10:{ZERO:0,A:9.8},20:{ZERO:0,A:19.6},30:{ZERO:0,A:29.4},40:{ZERO:0,A:39.2},50:{ZERO:0,A:49}}},Ce={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.65},20:{ZERO:0,A:1.15,B:1.65},30:{ZERO:0,A:1.15,B:1.65},40:{ZERO:0,A:1.15,B:1.65},50:{ZERO:0,A:1.15,B:1.65}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3},20:{ZERO:0,A:1.4,B:1.6,C:2,D:3},30:{ZERO:0,A:1.4,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.8},50:{ZERO:0,A:1.5,B:2,C:2.7,D:4.9}},HIGH_RISK:{10:{ZERO:0,A:9.7},20:{ZERO:0,A:19.4},30:{ZERO:0,A:29.1},40:{ZERO:0,A:38.8},50:{ZERO:0,A:48.5}}},Pe={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.55},20:{ZERO:0,A:1.15,B:1.55},30:{ZERO:0,A:1.15,B:1.55},40:{ZERO:0,A:1.15,B:1.55},50:{ZERO:0,A:1.15,B:1.55}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.8,C:2,D:3},20:{ZERO:0,A:1.3,B:1.5,C:2,D:3},30:{ZERO:0,A:1.4,B:1.6,C:2,D:2.9,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.7},50:{ZERO:0,A:1.5,B:2,C:2.6,D:4.8}},HIGH_RISK:{10:{ZERO:0,A:9.6},20:{ZERO:0,A:19.2},30:{ZERO:0,A:28.8},40:{ZERO:0,A:38.4},50:{ZERO:0,A:48}}},Te={LOW_RISK:{10:{ZERO:0,A:1.1,B:1.5},20:{ZERO:0,A:1.1,B:1.5},30:{ZERO:0,A:1.1,B:1.45},40:{ZERO:0,A:1.1,B:1.45},50:{ZERO:0,A:1.1,B:1.45}},MEDIUM_RISK:{10:{ZERO:0,A:1.3,B:1.7,C:1.9,D:3},20:{ZERO:0,A:1.3,B:1.4,C:1.9,D:3},30:{ZERO:0,A:1.3,B:1.7,C:1.9,D:2.8,E:3.8},40:{ZERO:0,A:1.4,B:1.8,C:1.9,D:2.6},50:{ZERO:0,A:1.4,B:1.9,C:2.6,D:4.6}},HIGH_RISK:{10:{ZERO:0,A:9.2},20:{ZERO:0,A:18.4},30:{ZERO:0,A:27.6},40:{ZERO:0,A:36.8},50:{ZERO:0,A:46}}},wa=new P(new Map([[1,De],[2,xe],[3,Ce],[4,Pe],[8,Te]]));var Ua={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class je extends A{constructor(){super("WHEEL")}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(L).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(W).includes(a.riskLevel))throw new Error("Invalid risk level");let o=wa.getMultipliers(r)[a.riskLevel];if(o===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let n=o[a.segments];if(n===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let i=Ua[a.riskLevel];if(i===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let c=i[a.segments];if(c===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let d=t.getRandomInt({min:0,max:c.length-1}),p=c[d.value];if(p===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${d.value}`);let u=n[p];if(u===void 0)throw new Error(`No payout found for picked segment ${p}`);return{isFinished:!0,payoutMultiplier:new Re(u),outputs:{result:d.values},randomValues:d}}}export{pc as validateRouletteGameInputs,$e as validateAdvancedDiceInputs,zr as rtp99Multipliers,Xr as rtp98Multipliers,qr as rtp97Multipliers,Qr as rtp96Multipliers,gr as rtp92Multipliers,Ha as plinkoMultipliers,Ut as nCr,Ea as kenoMultipliers,ya as isTileCount,Jr as hasDiceWon,mr as hasBlitzWon,xn as getMaxMultiplierForDifficulty,En as getBlitzDefaults,Zr as diamondsMultipliers,cc as calculateRouletteBetAmount,Fr as calculateDiceWinChance,yr as calculateBlitzWinChance,Ka as calculateBaccaratBetAmount,Jt as calculateAdvancedDiceWinChance,Sa as bigMin,fa as bigMax,Ya as advancedDiceIsWithinBoundsInclusive,pt as advancedDiceIsWithinBoundsExclusive,$a as advancedDiceGetInclusiveBoundsRange,At as advancedDiceGetExclusiveBoundsRange,L as WheelSegments,W as WheelRiskLevel,je as Wheel,ar as WIN_MULTIPLIER,qa as VALID_SUITS,Qa as VALID_RANKS,Ca as VALID_EUROPEAN_STREETS,Zt as VALID_EUROPEAN_STRAIGHTS,Da as VALID_EUROPEAN_SPLITS,ba as VALID_EUROPEAN_DOUBLE_STREETS,Ta as VALID_EUROPEAN_CORNERS,Pa as VALID_AMERICAN_STREETS,ha as VALID_AMERICAN_STRAIGHTS,xa as VALID_AMERICAN_SPLITS,_a as VALID_AMERICAN_DOUBLE_STREETS,Ra as VALID_AMERICAN_CORNERS,Ot as ThreeCardBonusType,ye as TOP_COLUMN,$r as TILE_COUNTS,Xt as THREE_CARD_BONUS_PAYOUTS,A as SingleActionGame,N as SPLIT_BET_SIZE_FACTOR,kt as RouletteType,Ia as Roulette,za as RollType,ot as RandomValuePool,Se as RED_NUMBERS,Bt as RANDOM_MIN_VALUE,mt as RANDOM_MAX_VALUE,Oa as PlinkoRiskLevel,ie as Plinko,I as Parity,St as PairBonusType,rr as PUSH_MULTIPLIER,Ui as PLINKO_ROW_COUNTS,me as PAYOUT_MULTIPLIERS,zt as PAIR_BONUS_PAYOUTS,S as OrigamiGame,C as MultiplierCalculator,Tt as MultiActionGame,vr as Mines,ka as MIN_WIN_CHANCE,Ee as MIDDLE_COLUMN,Ga as MAX_WIN_CHANCE,ht as MAX_CARDS_PER_ROUND,Kr as Limbo,er as LOSE_MULTIPLIER,ma as KenoRiskLevel,Lr as Keno,Et as InsuranceOutcome,Dt as INSURANCE_WIN_PAYOUT,F as INSURANCE_BET_SIZE_FACTOR,ro as INSURANCE_BET_MULTIPLIER,U as Half,Za as GameErrorCode,l as GameError,M as Game,$t as FACE_CARD_VALUE,Na as EuropeanRoulette,He as EUROPEAN_HOUSE_EDGE,Mt as EFFECTIVE_RANGE,k as Dozen,Mr as DiceDirection,Yr as Dice,_r as DiamondsResultType,Gr as Diamonds,Tr as Darts,R as DOUBLE_DOWN_BET_SIZE_FACTOR,Aa as DICE_EFFECTIVE_RANGE,Yt as DEALER_STAND_VALUE,sa as DARTS_MIN_VALUE,Vt as DARTS_MAX_VALUE,pa as DARTS_DIFFICULTY_LEVEL,It as DARTS_BOARD_CONFIGS,Z as Column,w as Color,eo as CARDS_PER_SUIT,Er as Blitz,yt as BlackjackOutcome,ft as BlackjackActionType,Ar as Blackjack,ga as BaccaratOutcome,Wa as BaccaratBetType,va as Baccarat,Ht as BUST_VALUE,fe as BOTTOM_COLUMN,ua as BLITZ_RANDOM_NUMBER_COUNT,la as BLITZ_MIN_CARD_RANGE,da as BLITZ_MAX_CARD_RANGE,X as BLITZ_CARD_COUNT,Oe as BLACK_NUMBERS,D as BLACKJACK_VALUE,tr as BLACKJACK_MULTIPLIER,tt as BASE_PAYOUT_MULTIPLIERS,Va as AmericanRoulette,Xa as AdvancedDice,he as AMERICAN_HOUSE_EDGE,ja as AMERICAN_BASKET,xt as ACE_SOFT_BONUS};
|
|
1
|
+
var ka;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(ka||={});class l extends Error{static createUnsupportedEdgeError(t){return new l("UNSUPPORTED_EDGE",t)}static createValidationError(t){return new l("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof l}errorCode;constructor(t,a){super(a);this.errorCode=t}}var O;((B)=>{B.DICE="DICE";B.MINES="MINES";B.KENO="KENO";B.LIMBO="LIMBO";B.ADVANCED_DICE="ADVANCED_DICE";B.BACCARAT="BACCARAT";B.DIAMONDS="DIAMONDS";B.PLINKO="PLINKO";B.ROULETTE="ROULETTE";B.WHEEL="WHEEL";B.BLACKJACK="BLACKJACK";B.BLITZ="BLITZ";B.DARTS="DARTS"})(O||={});import{Guard as Ga}from"@betorigami/guard";class A{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Ga.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}import{Big as Ft}from"big.js";import dt from"big.js";class x{static withMultiplier(t,a){return new dt(t).times(new dt(100-a).div(100))}static withWinChance(t,a){return dt(100-t).div(a)}}var pt=0,At=1e4,Mt=10001,Ma=0.01,Fa=98,Ja=(t)=>{if(t<pt)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${pt}`)},Ya=(t)=>{if(t>At)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${At}`)},K=(t)=>{if(Ja(t.lower),Ya(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},$a=(t,a)=>{let[r,e]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>e.lower)throw l.createValidationError("Bounds must not overlap")},za=(t,a)=>a>=t.lower&&a<=t.upper,Xa=(t)=>t.upper-t.lower+1,ut=(t,a)=>a>t.lower&&a<t.upper,st=(t)=>t.upper-t.lower-1,qa;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(qa||={});var Jt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return K(t.bounds),st(t.bounds);case"ROLL_OUTSIDE":return K(t.bounds),Mt-Xa(t.bounds);case"ROLL_BETWEEN_TWO":return K(t.firstBounds),K(t.secondBounds),$a(t.firstBounds,t.secondBounds),st(t.firstBounds)+st(t.secondBounds)}})(),e=Ft(r).div(Mt).mul(100);if(e.lt(Ma))throw l.createValidationError("Win chance too low");if(e.gt(Fa))throw l.createValidationError("Win chance too high");return e},$e=(t)=>{Jt(t)};class Qa extends A{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=Jt(r),n=t.getRandomInt({min:pt,max:At}),o=n.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return ut(r.bounds,o);case"ROLL_OUTSIDE":return!za(r.bounds,o);case"ROLL_BETWEEN_TWO":return ut(r.firstBounds,o)||ut(r.secondBounds,o)}})()?x.withWinChance(a,e):new Ft(0),outputs:{result:n.values},randomValues:n}}}import N from"big.js";var ga=["Clubs","Diamonds","Hearts","Spades"],Wa=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],La;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(La||={});var Ka;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(Ka||={});var va={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},tr=(t)=>{return new N(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new N(0)))};class ar extends A{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),e=r.values,n=e.slice(0,3),o=e.slice(3,6),i=[],c=0;for(let y of n.slice(0,2)){let D=this.mapRandomValueToCard(y),L=this.mapRandomValueToCardValue(y);i.push(D),c=(c+L)%10}let u=[],d=0;for(let y of o.slice(0,2)){let D=this.mapRandomValueToCard(y),L=this.mapRandomValueToCardValue(y);u.push(D),d=(d+L)%10}if(!this.isNaturalWin(c,d)){let y=this.shouldDrawThirdPlayerCard(c),D=null;if(y)D=this.mapRandomValueToCardValue(n[2]),i.push(this.mapRandomValueToCard(n[2])),c=(c+D)%10;if(this.shouldDrawThirdBankerCard(d,D))u.push(this.mapRandomValueToCard(o[2])),d=(d+this.mapRandomValueToCardValue(o[2]))%10}let s;if(c===d)s="TIE";else s=c>d?"PLAYER_WIN":"BANKER_WIN";let p=tr(a),{betType:E,multiplier:B}=va[s],j=new N(0);if(j=j.add(a.bets.filter((y)=>y.type===E).reduce((y,D)=>y.add(D.amount.mul(B)),new N(0))),s==="TIE")j=j.add(a.bets.filter((y)=>y.type==="PLAYER"||y.type==="BANKER").reduce((y,D)=>y.add(D.amount),new N(0)));return{isFinished:!0,payoutMultiplier:p.gt(0)?j.div(p):new N(0),outputs:{playerCards:i,playerHandValue:c,bankerCards:u,bankerHandValue:d,gameOutcome:s,result:r.values},randomValues:r}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=ga[Math.floor(t/13)],r=Wa[t%13];return{suit:a,rank:r}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var Bt;((n)=>{n.WIN="WIN";n.LOSE="LOSE";n.PUSH="PUSH";n.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(Bt||={});var mt;((r)=>{r.WON="WON";r.LOST="LOST"})(mt||={});var Et;((c)=>{c.START="START";c.HIT="BLACKJACK_HIT";c.STAND="BLACKJACK_STAND";c.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";c.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";c.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";c.SPLIT="BLACKJACK_SPLIT"})(Et||={});var yt;((n)=>{n.EXACT_PAIR="EXACT_PAIR";n.COLORED_PAIR="COLORED_PAIR";n.MIXED_PAIR="MIXED_PAIR";n.LOSS="LOSS"})(yt||={});var ft;((i)=>{i.SUITED_TRIPS="SUITED_TRIPS";i.STRAIGHT_FLUSH="STRAIGHT_FLUSH";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.STRAIGHT="STRAIGHT";i.FLUSH="FLUSH";i.LOSS="LOSS"})(ft||={});var rr=2.5,er=2,nr=1,or=0,Yt=17,Ot=21,h=21,St=63,rn=1.5,M=0.5,Ht=1.5,T=1,I=1,en=13,Dt=10,$t=10,v={PLAYER_BLACKJACK:rr,WIN:er,PUSH:nr,LOSE:or},zt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Xt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};import _ from"big.js";import{Guard as m}from"@betorigami/guard";import{createStore as sr}from"@xstate/store";var qt=0,Qt=51,tt=Array.from({length:52},(t,a)=>a),gt=["Spades","Hearts","Diamonds","Clubs"],at=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Wt=["Jack","Queen","King"],ht={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};import{Guard as ir}from"@betorigami/guard";import{Guard as Ct}from"@betorigami/guard";class F{value;constructor(t){let a=tt[t];Ct.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=gt[t];return Ct.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=at[t];return Ct.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}class f extends F{get numericRank(){if(Wt.includes(this.rank))return $t;return at.indexOf(this.rank)+1}static fromValue(t){return ir.against(!tt.includes(t),`Invalid card value: ${t}`),new f(t)}}class J{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,e)=>r+e.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+Dt<=Ot)this.softHandValue=this.hardHandValue+Dt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>Ot}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===h}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class Y{cards;value;constructor(t){this.cards=t.map((a)=>f.fromValue(a)),this.value=new J(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class $ extends Y{otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=f.fromValue(t),this.holeCard=f.fromValue(a)}static withInitialDeal(t){return new $(t.upCard,t.holeCard)}addDrawnCards(t){return new $(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new J([this.upCard]).highestHandValue}}}class R extends Y{static withInitialDeal(t){return new R(t)}addDrawnCards(t){return new R([...this.rawValues,...t])}}import{Guard as rt}from"@betorigami/guard";class et{source;index=0;constructor(t){this.source=t}static from(t,a){return rt.against(a<=0,`Count must be positive, got ${a}`),rt.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new et(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return rt.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){rt.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}import{Guard as Lt}from"@betorigami/guard";import cr from"fast-deep-equal";class xt{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let e=this.createGameStore(),n=this.generateRandomValues(t),o=n.toMultipleRandomValues();for(let u of r)e.send({...u.playerArgument,randomValuePool:n});let i=r[r.length-1];if(i)Lt.against(!cr(i.state,this.toExternalState(e.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");e.send({...a,randomValuePool:n});let c=e.getSnapshot().context;return{playerArgument:c.playerArgument,state:this.toExternalState(c.state),config:c.config,additionalBetAmount:c.additionalBetAmount,proof:{proofHash:o.proofHash,proofString:o.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);Lt.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}}import C from"big.js";import{Guard as Pt}from"@betorigami/guard";var Kt=(t)=>{let a=t.pairBonus!==null?C(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier):C(0),r=t.threeCardBonus!==null?C(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier):C(0);return a.plus(r)},vt=(t)=>{let a=t.betAmounts.mainBetAmount,e=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(T):C(0),n=t.insuranceOutcome!==void 0?a.mul(M):C(0),o=a.plus(e).mul(v[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(Ht):C(0),c=Kt(t.sideBetResults),u=o.plus(i).plus(c),d=a.plus(n).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Pt.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);Pt.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=e;break;case"BLACKJACK_BUY_INSURANCE":p=n;break;case"BLACKJACK_SPLIT":p=a.mul(I);break}return{multiplier:s,additionalBetAmount:p}},ta=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(T):C(0),e=t.splitHandDoubledDown?a.mul(T):C(0),n=t.insuranceOutcome!==void 0?a.mul(M):C(0),o=a.plus(r).mul(v[t.mainOutcome]),i=a.plus(e).mul(v[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(Ht):C(0),u=Kt(t.sideBetResults),d=o.plus(i).plus(c).plus(u),s=a.plus(a).plus(n).plus(r).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Pt.against(s.eq(0),"Total bet amount cannot be zero");let p=d.div(s),E;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":E=a.mul(T);break;case"BLACKJACK_SPLIT":E=a.mul(I);break}return{multiplier:p,additionalBetAmount:E}};import{Guard as lr}from"@betorigami/guard";var bt=(t)=>t.every((a)=>a===t[0]),aa=(t)=>{let a=[...t].sort((r,e)=>r-e);return a.every((r,e)=>{let n=a[e-1];if(e===0)return!0;return lr.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},ra={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},dr={...ra,Ace:14},ur=(t)=>aa(t.map((a)=>ra[a]))||aa(t.map((a)=>dr[a])),ea=(t,a)=>{let r=f.fromValue(t),e=f.fromValue(a);if(r.rank!==e.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(ht[r.suit]===ht[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},na=(t,a)=>({betAmount:t,result:a,payoutMultiplier:zt[a]}),oa=(t,a,r)=>{let e=f.fromValue(t),n=f.fromValue(a),o=f.fromValue(r),i=[e.rank,n.rank,o.rank],c=bt([e.suit,n.suit,o.suit]),u=bt(i),d=ur(i);if(bt([t,a,r]))return"SUITED_TRIPS";if(c&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(c)return"FLUSH";return"LOSS"},ia=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Xt[a]});var pr={state:{isFinished:!1,phase:"uninitialised",multiplier:_(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>f.fromValue(t).value;function Ar(t){m.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function ca(t){m.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function jt(t){m.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var la=(t,a)=>{let r=a;while(r.highestHandValue<Yt)r=r.addDrawnCards([S(t.takeOne())]);return r},Rt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,e=a.highestHandValue;if(r>e)return"WIN";if(r<e)return"LOSE";return"PUSH"},H=(t)=>{let{multiplier:a,additionalBetAmount:r}=vt({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,multiplier:a,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:r}},Tt=(t)=>{let a=la(t.randomValuePool,t.dealerHand),r=Rt(t.playerHand,a);return H({...t,dealerHand:a,outcome:r})},b=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:la(t.randomValuePool,t.dealerHand),e=Rt(t.mainHand,r),n=Rt(t.splitHand,r),{multiplier:o,additionalBetAmount:i}=ta({hasSplit:!0,mainOutcome:e,splitOutcome:n,insuranceOutcome:t.insuranceOutcome,mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:e,splitOutcome:n,multiplier:o,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class Br extends xt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return et.from(t.getRandomIntsWithReplacement({min:qt,max:Qt,count:St}),St)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:m.againstNever(a,"Invalid state received")}}createGameStore(){return sr({context:pr,on:{START:(t,a)=>{let{state:r}=t;m.against(r.phase!=="uninitialised","START action requires a fresh game");let e=S(a.randomValuePool.takeOne()),n=S(a.randomValuePool.takeOne()),o=S(a.randomValuePool.takeOne()),i=S(a.randomValuePool.takeOne()),c=R.withInitialDeal([e,n]),u=$.withInitialDeal({upCard:o,holeCard:i}),d={mainBetAmount:_(a.mainBetAmount),pairBonusAmount:_(a.pairBonusAmount),threeCardBonusAmount:_(a.threeCardBonusAmount)},s={pairBonus:_(a.pairBonusAmount).gt(0)?na(a.pairBonusAmount,ea(e,n)):null,threeCardBonus:_(a.threeCardBonusAmount).gt(0)?ia(a.threeCardBonusAmount,oa(e,n,o)):null},p={type:"START",mainBetAmount:a.mainBetAmount,pairBonusAmount:a.pairBonusAmount,threeCardBonusAmount:a.threeCardBonusAmount};if(u.upCard.rank==="Ace")return{state:{...r,isFinished:!1,phase:"awaiting-insurance",playerHand:c,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:p};let E={playerHand:c,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:p,betAmounts:d,sideBetResults:s};if(c.isBlackjack&&u.isBlackjack)return H({...E,outcome:"PUSH"});if(c.isBlackjack)return H({...E,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return H({...E,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:c,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:p}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;ca(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return H({...c,outcome:"PUSH",insuranceOutcome:"WON"});if(e.isBlackjack)return H({...c,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(n.isBlackjack)return H({...c,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:o.mainBetAmount.mul(M)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;ca(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={playerHand:e,dealerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return H({...c,outcome:"PUSH"});if(e.isBlackjack)return H({...c,outcome:"PLAYER_BLACKJACK"});if(n.isBlackjack)return H({...c,outcome:"LOSE"});return{state:{...r,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(t,a)=>{let{state:r}=t;switch(jt(r),r.phase){case"playing-main-hand":{let e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===h){if(r.splitHand.highestHandValue===h)return b({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===h)return b({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return H({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(e.highestHandValue===h)return Tt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:m.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(jt(r),r.phase){case"playing-main-hand":{if(r.splitHand.highestHandValue===h)return b({...r,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...r,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return b({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return Tt({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:m.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(jt(r),r.phase){case"playing-main-hand":{m.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]),{betAmounts:n}=r;if(r.splitHand.highestHandValue===h)return b({...r,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:n.mainBetAmount.mul(T)}}case"playing-split-hand":{m.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);return b({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{m.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return H({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return Tt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:m.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;Ar(r);let{playerHand:e,betAmounts:n,sideBetResults:o}=r;m.against(e.cards.length!==2,"Split is only allowed with exactly 2 cards");let i=e.cards[0],c=e.cards[1];m.againstUndefined(i,"First card is missing"),m.againstUndefined(c,"Second card is missing"),m.against(i.rank!==c.rank,"Split requires two cards of the same rank");let u=S(a.randomValuePool.takeOne()),d=S(a.randomValuePool.takeOne()),s=R.withInitialDeal([i.value,u]),p=R.withInitialDeal([c.value,d]);if(i.rank==="Ace")return b({...r,mainHand:s,splitHand:p,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let B=s.highestHandValue===h,j=p.highestHandValue===h;if(B&&j)return b({mainHand:s,splitHand:p,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:n,sideBetResults:o});if(B)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:p,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(I)};return{state:{...r,phase:"playing-main-hand",multiplier:_(0),mainHand:s,splitHand:p,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(I)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],e=t.playerHand.cards[1];if(m.againstUndefined(r,"First player card is missing"),m.againstUndefined(e,"Second player card is missing"),r.rank===e.rank)a.push("BLACKJACK_SPLIT")}return a}default:m.againstNever(t,"Invalid phase for getting valid actions")}}}import X from"big.js";import{Guard as mr}from"@betorigami/guard";var da=0,ua=51,z=52,sa=52;var yo=()=>({minPicks:5,maxPicks:36}),Er=(t)=>t.length===new Set(t).size,yr=(t)=>{let a=X(1),r=X(z);for(let e=0;e<t;e+=1)a=a.mul(X(z-e).div(r));return a};class fr extends A{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a,edge:r}){mr.against(a.pickCount<1||a.pickCount>z,`pickCount must be between 1 and ${z}`);let e=t.getRandomIntsWithReplacement({min:da,max:ua,count:sa}),n=e.values.slice(0,a.pickCount),o=Er(n),i=yr(a.pickCount);return{isFinished:!0,payoutMultiplier:o?x.withMultiplier(X(1).div(i),r):X(0),outputs:{result:e.values,cards:n.map((u)=>new F(u).toDto())},randomValues:e}}}var pa=0,_t=4294967295,Aa;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(Aa||={});var Or=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Sr={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:Or},Hr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Dr={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:Hr},hr=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Cr={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:hr},xr=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Pr={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:xr},Co=(t)=>{let a=Nt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((e,n)=>n>e?n:e)},Nt={EASY:Sr,MEDIUM:Dr,HARD:Cr,EXPERT:Pr};import{Guard as It}from"@betorigami/guard";import br from"big.js";class jr extends A{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:pa,max:_t,count:2}),e=r.values[0],n=r.values[1];It.againstUndefined(e,"Random number generator returned no value for clockWiseRotation"),It.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let o=a.difficultyLevel;return{isFinished:!0,payoutMultiplier:br(Tr(o,e,n)),outputs:{result:r.values},randomValues:r}}}var Tr=(t,a,r)=>{let e=Nt[t],{distanceBoundaries:n,multipliers:o}=e;if(r<n.bullseye)return o.bullseye;if(r<n.ringOne)return o.ringOne;if(r<n.ringTwo)return o.ringTwo;if(r<n.ringThree)return Rr(e,a);return o.ringFour},Rr=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(_t+1)*r),n=t.segments[e];return It.againstUndefined(n,`Segment index ${e} out of bounds`),t.multipliers.ringThree[n]};import _r from"big.js";class P{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var Nr;((i)=>{i.PAIR="PAIR";i.TWO_PAIR="TWO_PAIR";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.FULL_HOUSE="FULL_HOUSE";i.FOUR_OF_A_KIND="FOUR_OF_A_KIND";i.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(Nr||={});var Ir={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},wr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},Vr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},Ur={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},Zr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},kr=new P(new Map([[1,Ir],[2,wr],[3,Vr],[4,Ur],[8,Zr]])),Gr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Mr extends A{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a}){let r=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=kr.getMultipliers(a),n=r.values,o=this.calculatePayoutMultiplier(e,n);return{isFinished:!0,payoutMultiplier:_r(o),outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(t,a){let r=new Map;for(let o of a){let i=r.get(o)||0;r.set(o,i+1)}let e=[...r.values()].filter((o)=>o>1),n=this.classifyResult(e);return n===null?0:t[n]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let e=Gr[a];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return e}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}import ma from"big.js";var Fr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Fr||={});var Ba=1e4,Jr=(t)=>{let a=t.direction==="ABOVE"?Ba-t.selectedValue:t.selectedValue;return new ma(a).div(Ba).mul(100)},Yr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class $r extends A{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:0,max:1e4}),n=Jr(r);return{isFinished:!0,payoutMultiplier:Yr(r,e.value)?x.withWinChance(a,n):new ma(0),outputs:{result:e.values},randomValues:e}}}import Lr from"big.js";import{Guard as nt}from"@betorigami/guard";var Ea;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(Ea||={});var zr=[1,2,3,4,5,6,7,8,9,10],ya=(t)=>{return zr.includes(t)};var Xr={[1]:{CLASSIC:[0,3.96],LOW_RISK:[0.7,1.85],MEDIUM_RISK:[0.4,2.75],HIGH_RISK:[0,3.96]},[2]:{CLASSIC:[0,1.9,4.5],LOW_RISK:[0,2,3.8],MEDIUM_RISK:[0,1.8,5.1],HIGH_RISK:[0,0,17.1]},[3]:{CLASSIC:[0,1,3.1,10.4],LOW_RISK:[0,1.1,1.38,26],MEDIUM_RISK:[0,0,2.8,50],HIGH_RISK:[0,0,0,81.5]},[4]:{CLASSIC:[0,0.8,1.8,5,22.5],LOW_RISK:[0,0,2.2,7.9,90],MEDIUM_RISK:[0,0,1.7,10,100],HIGH_RISK:[0,0,0,10,259]},[5]:{CLASSIC:[0,0.25,1.4,4.1,16.5,36],LOW_RISK:[0,0,1.5,4.2,13,300],MEDIUM_RISK:[0,0,1.4,4,14,390],HIGH_RISK:[0,0,0,4.5,48,450]},[6]:{CLASSIC:[0,0,1,3.68,7,16.5,40],LOW_RISK:[0,0,1.1,2,6.2,100,700],MEDIUM_RISK:[0,0,0,3,9,180,710],HIGH_RISK:[0,0,0,0,11,350,710]},[7]:{CLASSIC:[0,0,0.47,3,4.5,14,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,15,225,700],MEDIUM_RISK:[0,0,0,2,7,30,400,800],HIGH_RISK:[0,0,0,0,7,90,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,13,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,5.5,39,100,800],MEDIUM_RISK:[0,0,0,2,4,11,67,400,900],HIGH_RISK:[0,0,0,0,5,20,270,600,900]},[9]:{CLASSIC:[0,0,0,1.55,3,8,15,44,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1000],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1000]}},qr={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},Qr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},gr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.68,1.84],MEDIUM_RISK:[0.38,2.74],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,1.96,3.75],MEDIUM_RISK:[0,1.77,5],HIGH_RISK:[0,0,16.82]},[3]:{CLASSIC:[0,1,3.05,9.35],LOW_RISK:[0,1.07,1.37,25.7],MEDIUM_RISK:[0,0,2.74,49],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.72,4.95,22.3],LOW_RISK:[0,0,2.15,7.86,87],MEDIUM_RISK:[0,0,1.67,9.7,100],HIGH_RISK:[0,0,0,9.7,256]},[5]:{CLASSIC:[0,0.24,1.38,4,16.3,35.5],LOW_RISK:[0,0,1.48,4.1,12.43,300],MEDIUM_RISK:[0,0,1.35,3.96,13.8,389],HIGH_RISK:[0,0,0,4.4,47,444]},[6]:{CLASSIC:[0,0,1,3.57,6.8,16.2,37],LOW_RISK:[0,0,1.06,1.96,6.16,99,700],MEDIUM_RISK:[0,0,0,2.9,8.9,178,709],HIGH_RISK:[0,0,0,0,10.4,347,709]},[7]:{CLASSIC:[0,0,0.45,2.95,4.44,13.85,30,60],LOW_RISK:[0,0,1.07,1.57,3.47,14.57,225,700],MEDIUM_RISK:[0,0,0,1.95,6.8,29.8,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.15,3.9,12.9,21.9,55,70],LOW_RISK:[0,0,1.08,1.45,1.98,5.48,38.8,100,800],MEDIUM_RISK:[0,0,0,1.95,3.96,10.6,66.9,396,896],HIGH_RISK:[0,0,0,0,4.9,19.2,269,599,896]},[9]:{CLASSIC:[0,0,0,1.5,2.95,7.96,14.96,44,60,85],LOW_RISK:[0,0,1.05,1.29,1.69,2.49,7.49,49,250,1000],MEDIUM_RISK:[0,0,0,1.95,2.47,4.9,14.9,99,500,1000],HIGH_RISK:[0,0,0,0,3.96,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.45,7.7,16.7,50,80,100],LOW_RISK:[0,0,1.08,1.18,1.28,1.76,3.4,12.9,50,250,1000],MEDIUM_RISK:[0,0,0,1.57,1.95,3.96,6.9,25.5,100,500,1000],HIGH_RISK:[0,0,0,0,3.43,7.9,12.5,60,500,800,1000]}},Wr={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},fa=new P(new Map([[1,Xr],[2,qr],[3,Qr],[4,gr],[8,Wr]]));class Kr extends A{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){nt.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),nt.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let p of r.selectedNumbers)nt.againstNonInteger(p,()=>l.createValidationError("Only integers can be selected")),nt.against(p<0||p>39,()=>l.createValidationError("Invalid number selected"));let e=t.getUniqueRandomInts({min:0,max:39,count:10}),n=r.selectedNumbers.filter((p)=>e.values.includes(p)),o=r.selectedNumbers.length;if(!ya(o))throw new Error(`Invalid tile count: ${o}`);let d=fa.getMultipliers(a)[o][r.riskLevel][n.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${n.length}`);return{isFinished:!0,payoutMultiplier:new Lr(d),outputs:{result:e.values},randomValues:e}}}import w from"big.js";var Oa=(t,a)=>{return t.gt(a)?t:a};var Sa=(t,a)=>{return t.lt(a)?t:a};class vr extends A{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:1,max:4294967295}),n=e.max,o=new w(16777216),i=new w(1),c=new w(1e6),u=e.value,d=new w(u-1).div(n),s=(100-a)/100,p=o.div(d.mul(o).plus(1)).mul(s),E=Oa(i,Sa(p,c));return{isFinished:!0,payoutMultiplier:E.gte(r.targetMultiplier)?new w(r.targetMultiplier):new w(0),outputs:{randomMultiplier:E,result:e.values},randomValues:e}}}import ot from"big.js";var wt=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let e=1;e<=a;e++)r=r*(t-e+1)/e;return r};class te extends A{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let i=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),c=i.values.some((B)=>r.selectedTiles.includes(B)),u=r.hasCashedOut||c,d=(100-a)/100,s=new ot(wt(25-r.minesCount,r.selectedTiles.length)).div(new ot(wt(25,r.selectedTiles.length))),E=r.hasCashedOut&&!c?new ot(d).div(s):new ot(0);return{isFinished:u,payoutMultiplier:E,outputs:{result:i.values},randomValues:i}}}import{Big as ie}from"big.js";var Ha;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(Ha||={});var Ui=[8,9,10,11,12,13,14,15,16],ae={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},re={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},ee={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},ne={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},oe={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},Da=new P(new Map([[1,ae],[2,re],[3,ee],[4,ne],[8,oe]]));class ce extends A{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=a.numberOfRows,i=Da.getMultipliers(r)[a.riskLevel][e],c=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=c.values.reduce((p,E)=>p+E,0),s=i[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);return{isFinished:!0,payoutMultiplier:ie(s),outputs:{result:c.values},randomValues:c}}}import{Big as lt}from"big.js";var Vt=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],ha=[37,...Vt],Ca=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],xa=[[0,1],[0,37],[3,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],Pa=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],ba=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],ja=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Ta=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Ra=[0,1,2,3,37],_a=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],Na=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],V;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(V||={});var U;((r)=>{r.RED="RED";r.BLACK="BLACK"})(U||={});var Z;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(Z||={});var k;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(k||={});var G;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(G||={});var Ut;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Ut||={});var it=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&q(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&le(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&de(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&ue(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&se(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(V).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},q=(t)=>{return Vt.includes(t)},le=(t)=>{if(t.length!==2)return!1;if(!t.every(q))return!1;return Ca.some(([a,r])=>a===t[0]&&r===t[1])},de=(t)=>{if(t.length!==3)return!1;if(!t.every(q))return!1;return Pa.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},ue=(t)=>{if(t.length!==4)return!1;if(!t.every(q))return!1;return ja.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},se=(t)=>{if(t.length!==6)return!1;if(!t.every(q))return!1;return _a.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===t[5])};var ct=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&Q(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&pe(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Ae(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Be(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw l.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&me(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(V).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},Q=(t)=>{return ha.includes(t)};function pe(t){if(t.length!==2)return!1;if(!t.every(Q))return!1;return xa.some(([a,r])=>a===t[0]&&r===t[1])}var Ae=(t)=>{if(t.length!==3)return!1;if(!t.every(Q))return!1;return ba.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},Be=(t)=>{if(t.length!==4)return!1;if(!t.every(Q))return!1;return Ta.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},me=(t)=>{if(t.length!==6)return!1;if(!t.every(Q))return!1;return Na.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===t[5])};var Ee={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},ye=[3,6,9,12,15,18,21,24,27,30,33,36],fe=[2,5,8,11,14,17,20,23,26,29,32,35],Oe=[1,4,7,10,13,16,19,22,25,28,31,34],Se=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],He=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35],Zt=2.7,kt=5.3;class Gt extends A{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),e=r.value,n=this.determineBetOutcomes(a,e),{payoutMultiplier:o}=this.getPayoutDetails(a,e);return{outputs:{betOutcomes:n,result:r.values},payoutMultiplier:o,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),e=this.getBetTotals(t),n=this.getBetTotals(r.winningBets),o=this.calculateTotalBetAmount(e),i=this.calculateTotalPayout(n);return{payoutMultiplier:o.gt(0)?i.div(o):new lt(0),payoutAmount:i}}determineBetOutcomes(t,a){let r={},e={};for(let n of Object.keys(t)){let o=t[n],i=this.betPredicates[n],{winning:c,losing:u}=this.partitionBets(o,i,a);r[n]=c,e[n]=u}return{winningBets:r,losingBets:e}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new lt(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return Se.includes(a)&&r.color==="RED"||He.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return ye.includes(a)&&r.column==="TOP"||fe.includes(a)&&r.column==="MIDDLE"||Oe.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let e=a%2===0?"EVEN":"ODD";return r.parity===e}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new lt(0))}partitionBets(t,a,r){return{winning:t.filter((e)=>a(e,r)),losing:t.filter((e)=>!a(e,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,e])=>{let o=Ee[r];return a.plus(e.mul(o||0))},new lt(0))}}class Ia extends Gt{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[Zt]}validateInputs(t){it(t)}}class wa extends Gt{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[kt]}validateInputs(t){ct(t)}isWinningBasketBet(t,a){return Ra.some((r)=>r===a)}}class Va extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Ia,this.americanGame=new wa}get supportedEdgeConfigurations(){return[Zt,kt]}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(t.edge===Zt&&a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:n,result:e.outputs.result}}}if(t.edge===kt&&a.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:n,result:e.outputs.result}}}throw l.createValidationError(`Attempted to play ${a.type} roulette on edge ${t.edge}`)}}var cc=(t)=>{return new Va().getBetAmount(t)};var pc=(t)=>{if(t.type==="EUROPEAN")it(t.inputs);else ct(t.inputs)};import{Big as be}from"big.js";var g;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(g||={});var W;((o)=>{o[o.TEN=10]="TEN";o[o.TWENTY=20]="TWENTY";o[o.THIRTY=30]="THIRTY";o[o.FORTY=40]="FORTY";o[o.FIFTY=50]="FIFTY"})(W||={});var De={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.5},20:{ZERO:0,A:1.2,B:1.5},30:{ZERO:0,A:1.2,B:1.5},40:{ZERO:0,A:1.2,B:1.5},50:{ZERO:0,A:1.2,B:1.5}},MEDIUM_RISK:{10:{ZERO:0,A:1.5,B:1.9,C:2,D:3},20:{ZERO:0,A:1.5,B:1.8,C:2,D:3},30:{ZERO:0,A:1.5,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:3},50:{ZERO:0,A:1.5,B:2,C:3,D:5}},HIGH_RISK:{10:{ZERO:0,A:9.9},20:{ZERO:0,A:19.8},30:{ZERO:0,A:29.7},40:{ZERO:0,A:39.6},50:{ZERO:0,A:49.5}}},he={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.4},20:{ZERO:0,A:1.2,B:1.4},30:{ZERO:0,A:1.2,B:1.4},40:{ZERO:0,A:1.2,B:1.4},50:{ZERO:0,A:1.2,B:1.4}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3.1},20:{ZERO:0,A:1.5,B:1.8,C:1.9,D:3.4},30:{ZERO:0,A:1.5,B:1.7,C:1.9,D:3,E:4.3},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.9},50:{ZERO:0,A:1.5,B:2,C:3,D:4.5}},HIGH_RISK:{10:{ZERO:0,A:9.8},20:{ZERO:0,A:19.6},30:{ZERO:0,A:29.4},40:{ZERO:0,A:39.2},50:{ZERO:0,A:49}}},Ce={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.65},20:{ZERO:0,A:1.15,B:1.65},30:{ZERO:0,A:1.15,B:1.65},40:{ZERO:0,A:1.15,B:1.65},50:{ZERO:0,A:1.15,B:1.65}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3},20:{ZERO:0,A:1.4,B:1.6,C:2,D:3},30:{ZERO:0,A:1.4,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.8},50:{ZERO:0,A:1.5,B:2,C:2.7,D:4.9}},HIGH_RISK:{10:{ZERO:0,A:9.7},20:{ZERO:0,A:19.4},30:{ZERO:0,A:29.1},40:{ZERO:0,A:38.8},50:{ZERO:0,A:48.5}}},xe={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.55},20:{ZERO:0,A:1.15,B:1.55},30:{ZERO:0,A:1.15,B:1.55},40:{ZERO:0,A:1.15,B:1.55},50:{ZERO:0,A:1.15,B:1.55}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.8,C:2,D:3},20:{ZERO:0,A:1.3,B:1.5,C:2,D:3},30:{ZERO:0,A:1.4,B:1.6,C:2,D:2.9,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.7},50:{ZERO:0,A:1.5,B:2,C:2.6,D:4.8}},HIGH_RISK:{10:{ZERO:0,A:9.6},20:{ZERO:0,A:19.2},30:{ZERO:0,A:28.8},40:{ZERO:0,A:38.4},50:{ZERO:0,A:48}}},Pe={LOW_RISK:{10:{ZERO:0,A:1.1,B:1.5},20:{ZERO:0,A:1.1,B:1.5},30:{ZERO:0,A:1.1,B:1.45},40:{ZERO:0,A:1.1,B:1.45},50:{ZERO:0,A:1.1,B:1.45}},MEDIUM_RISK:{10:{ZERO:0,A:1.3,B:1.7,C:1.9,D:3},20:{ZERO:0,A:1.3,B:1.4,C:1.9,D:3},30:{ZERO:0,A:1.3,B:1.7,C:1.9,D:2.8,E:3.8},40:{ZERO:0,A:1.4,B:1.8,C:1.9,D:2.6},50:{ZERO:0,A:1.4,B:1.9,C:2.6,D:4.6}},HIGH_RISK:{10:{ZERO:0,A:9.2},20:{ZERO:0,A:18.4},30:{ZERO:0,A:27.6},40:{ZERO:0,A:36.8},50:{ZERO:0,A:46}}},Ua=new P(new Map([[1,De],[2,he],[3,Ce],[4,xe],[8,Pe]]));var Za={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class je extends A{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(W).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(g).includes(a.riskLevel))throw new Error("Invalid risk level");let n=Ua.getMultipliers(r)[a.riskLevel];if(n===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let o=n[a.segments];if(o===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let i=Za[a.riskLevel];if(i===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let c=i[a.segments];if(c===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:c.length-1}),d=c[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=o[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);return{isFinished:!0,payoutMultiplier:new be(s),outputs:{result:u.values},randomValues:u}}}export{pc as validateRouletteGameInputs,$e as validateAdvancedDiceInputs,Xr as rtp99Multipliers,qr as rtp98Multipliers,Qr as rtp97Multipliers,gr as rtp96Multipliers,Wr as rtp92Multipliers,Da as plinkoMultipliers,wt as nCr,fa as kenoMultipliers,ya as isTileCount,Yr as hasDiceWon,Er as hasBlitzWon,Co as getMaxMultiplierForDifficulty,yo as getBlitzDefaults,kr as diamondsMultipliers,cc as calculateRouletteBetAmount,Jr as calculateDiceWinChance,yr as calculateBlitzWinChance,tr as calculateBaccaratBetAmount,Jt as calculateAdvancedDiceWinChance,Sa as bigMin,Oa as bigMax,za as advancedDiceIsWithinBoundsInclusive,ut as advancedDiceIsWithinBoundsExclusive,Xa as advancedDiceGetInclusiveBoundsRange,st as advancedDiceGetExclusiveBoundsRange,W as WheelSegments,g as WheelRiskLevel,je as Wheel,er as WIN_MULTIPLIER,ga as VALID_SUITS,Wa as VALID_RANKS,Pa as VALID_EUROPEAN_STREETS,Vt as VALID_EUROPEAN_STRAIGHTS,Ca as VALID_EUROPEAN_SPLITS,_a as VALID_EUROPEAN_DOUBLE_STREETS,ja as VALID_EUROPEAN_CORNERS,ba as VALID_AMERICAN_STREETS,ha as VALID_AMERICAN_STRAIGHTS,xa as VALID_AMERICAN_SPLITS,Na as VALID_AMERICAN_DOUBLE_STREETS,Ta as VALID_AMERICAN_CORNERS,ft as ThreeCardBonusType,ye as TOP_COLUMN,zr as TILE_COUNTS,Xt as THREE_CARD_BONUS_PAYOUTS,A as SingleActionGame,I as SPLIT_BET_SIZE_FACTOR,Ut as RouletteType,Va as Roulette,qa as RollType,et as RandomValuePool,Se as RED_NUMBERS,pt as RANDOM_MIN_VALUE,At as RANDOM_MAX_VALUE,Ha as PlinkoRiskLevel,ce as Plinko,V as Parity,yt as PairBonusType,nr as PUSH_MULTIPLIER,Ui as PLINKO_ROW_COUNTS,Ee as PAYOUT_MULTIPLIERS,zt as PAIR_BONUS_PAYOUTS,O as OrigamiGame,x as MultiplierCalculator,xt as MultiActionGame,te as Mines,Ma as MIN_WIN_CHANCE,fe as MIDDLE_COLUMN,Fa as MAX_WIN_CHANCE,St as MAX_CARDS_PER_ROUND,vr as Limbo,or as LOSE_MULTIPLIER,Ea as KenoRiskLevel,Kr as Keno,mt as InsuranceOutcome,Ht as INSURANCE_WIN_PAYOUT,M as INSURANCE_BET_SIZE_FACTOR,rn as INSURANCE_BET_MULTIPLIER,Z as Half,ka as GameErrorCode,l as GameError,$t as FACE_CARD_VALUE,Ia as EuropeanRoulette,Zt as EUROPEAN_HOUSE_EDGE,Mt as EFFECTIVE_RANGE,G as Dozen,Fr as DiceDirection,$r as Dice,Nr as DiamondsResultType,Mr as Diamonds,jr as Darts,T as DOUBLE_DOWN_BET_SIZE_FACTOR,Ba as DICE_EFFECTIVE_RANGE,Yt as DEALER_STAND_VALUE,pa as DARTS_MIN_VALUE,_t as DARTS_MAX_VALUE,Aa as DARTS_DIFFICULTY_LEVEL,Nt as DARTS_BOARD_CONFIGS,k as Column,U as Color,en as CARDS_PER_SUIT,fr as Blitz,Bt as BlackjackOutcome,Et as BlackjackActionType,Br as Blackjack,La as BaccaratOutcome,Ka as BaccaratBetType,ar as Baccarat,Ot as BUST_VALUE,Oe as BOTTOM_COLUMN,sa as BLITZ_RANDOM_NUMBER_COUNT,da as BLITZ_MIN_CARD_RANGE,ua as BLITZ_MAX_CARD_RANGE,z as BLITZ_CARD_COUNT,He as BLACK_NUMBERS,h as BLACKJACK_VALUE,rr as BLACKJACK_MULTIPLIER,v as BASE_PAYOUT_MULTIPLIERS,wa as AmericanRoulette,Qa as AdvancedDice,kt as AMERICAN_HOUSE_EDGE,Ra as AMERICAN_BASKET,Dt as ACE_SOFT_BONUS};
|