@betorigami/game-calculations 6.0.2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- var Xr=Object.create;var{getPrototypeOf:Qr,defineProperty:g,getOwnPropertyNames:ba,getOwnPropertyDescriptor:gr}=Object,ja=Object.prototype.hasOwnProperty;var H=(t,a,r)=>{r=t!=null?Xr(Qr(t)):{};let e=a||!t||!t.__esModule?g(r,"default",{value:t,enumerable:!0}):r;for(let n of ba(t))if(!ja.call(e,n))g(e,n,{get:()=>t[n],enumerable:!0});return e},Pa=new WeakMap,Wr=(t)=>{var a=Pa.get(t),r;if(a)return a;if(a=g({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")ba(t).map((e)=>!ja.call(a,e)&&g(a,e,{get:()=>t[e],enumerable:!(r=gr(t,e))||r.enumerable}));return Pa.set(t,a),a};var Lr=(t,a)=>{for(var r in a)g(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(e)=>a[r]=()=>e})};var Le={};Lr(Le,{validateRouletteGameInputs:()=>Ha,validateAdvancedDiceInputs:()=>ae,rtp99Multipliers:()=>Pr,rtp98Multipliers:()=>br,rtp97Multipliers:()=>jr,rtp96Multipliers:()=>Tr,rtp92Multipliers:()=>Rr,plinkoMultipliers:()=>ua,nCr:()=>Nt,kenoMultipliers:()=>ia,isTileCount:()=>oa,hasDiceWon:()=>hr,hasBlitzWon:()=>sr,getMaxMultiplierForDifficulty:()=>He,getBlitzDefaults:()=>pe,diamondsMultipliers:()=>fr,calculateRouletteBetAmount:()=>ze,calculateDiceWinChance:()=>Dr,calculateBlitzWinChance:()=>pr,calculateBaccaratBetAmount:()=>Ya,calculateAdvancedDiceWinChance:()=>Gt,bigMin:()=>la,bigMax:()=>ca,advancedDiceIsWithinBoundsInclusive:()=>wa,advancedDiceIsWithinBoundsExclusive:()=>pt,advancedDiceGetInclusiveBoundsRange:()=>Va,advancedDiceGetExclusiveBoundsRange:()=>At,WheelSegments:()=>Q,WheelRiskLevel:()=>X,Wheel:()=>qr,WIN_MULTIPLIER:()=>qa,VALID_SUITS:()=>re,VALID_RANKS:()=>ee,VALID_EUROPEAN_STREETS:()=>Ba,VALID_EUROPEAN_STRAIGHTS:()=>wt,VALID_EUROPEAN_SPLITS:()=>pa,VALID_EUROPEAN_DOUBLE_STREETS:()=>Oa,VALID_EUROPEAN_CORNERS:()=>Ea,VALID_AMERICAN_STREETS:()=>ma,VALID_AMERICAN_STRAIGHTS:()=>sa,VALID_AMERICAN_SPLITS:()=>Aa,VALID_AMERICAN_DOUBLE_STREETS:()=>Sa,VALID_AMERICAN_CORNERS:()=>ya,ThreeCardBonusType:()=>Ht,TOP_COLUMN:()=>kr,TILE_COUNTS:()=>xr,THREE_CARD_BONUS_PAYOUTS:()=>$t,SingleActionGame:()=>A,SPLIT_BET_SIZE_FACTOR:()=>V,RouletteType:()=>Vt,Roulette:()=>xa,RollType:()=>Ia,RandomValuePool:()=>et,RED_NUMBERS:()=>Fr,RANDOM_MIN_VALUE:()=>W,RANDOM_MAX_VALUE:()=>L,PlinkoRiskLevel:()=>da,Plinko:()=>Ur,Parity:()=>Z,PairBonusType:()=>St,PUSH_MULTIPLIER:()=>Xa,PLINKO_ROW_COUNTS:()=>Re,PAYOUT_MULTIPLIERS:()=>Zr,PAIR_BONUS_PAYOUTS:()=>Yt,OrigamiGame:()=>f,MultiplierCalculator:()=>P,MultiActionGame:()=>Pt,Mines:()=>Vr,MIN_WIN_CHANCE:()=>_a,MIDDLE_COLUMN:()=>Gr,MAX_WIN_CHANCE:()=>Na,MAX_CARDS_PER_ROUND:()=>ht,Limbo:()=>wr,LOSE_MULTIPLIER:()=>Qa,KenoRiskLevel:()=>na,Keno:()=>Nr,InsuranceOutcome:()=>ft,INSURANCE_WIN_PAYOUT:()=>Ct,INSURANCE_BET_SIZE_FACTOR:()=>J,INSURANCE_BET_MULTIPLIER:()=>ie,Half:()=>G,GameErrorCode:()=>Ta,GameError:()=>l,FACE_CARD_VALUE:()=>Jt,EuropeanRoulette:()=>ha,EUROPEAN_HOUSE_EDGE:()=>z,EFFECTIVE_RANGE:()=>Zt,Dozen:()=>F,DiceDirection:()=>Sr,Dice:()=>Cr,DiamondsResultType:()=>yr,Diamonds:()=>Or,Darts:()=>mr,DOUBLE_DOWN_BET_SIZE_FACTOR:()=>j,DICE_MIN_ROLL:()=>ea,DICE_MAX_ROLL:()=>_t,DICE_EFFECTIVE_RANGE:()=>Hr,DEALER_STAND_VALUE:()=>Ft,DARTS_MIN_VALUE:()=>ta,DARTS_MAX_VALUE:()=>jt,DARTS_DIFFICULTY_LEVEL:()=>aa,DARTS_BOARD_CONFIGS:()=>Tt,Column:()=>M,Color:()=>k,CARDS_PER_SUIT:()=>ce,Blitz:()=>Ar,BlackjackOutcome:()=>yt,BlackjackActionType:()=>Ot,Blackjack:()=>ur,BaccaratOutcome:()=>Fa,BaccaratBetType:()=>Ja,Baccarat:()=>$a,BUST_VALUE:()=>Dt,BOTTOM_COLUMN:()=>Mr,BLITZ_RANDOM_NUMBER_COUNT:()=>Kt,BLITZ_MIN_CARD_RANGE:()=>Wt,BLITZ_MAX_CARD_RANGE:()=>Lt,BLITZ_CARD_COUNT:()=>Y,BLACK_NUMBERS:()=>Jr,BLACKJACK_VALUE:()=>D,BLACKJACK_MULTIPLIER:()=>za,BASE_PAYOUT_MULTIPLIERS:()=>K,AmericanRoulette:()=>Ca,AdvancedDice:()=>Ua,AMERICAN_HOUSE_EDGE:()=>q,AMERICAN_BASKET:()=>fa,ACE_SOFT_BONUS:()=>xt});module.exports=Wr(Le);var Ta;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(Ta||={});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 Ra=require("@betorigami/guard");class A{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Ra.Guard.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}var kt=require("big.js");var ut=H(require("big.js"));class P{static withMultiplier(t,a){return new ut.default(t).times(new ut.default(100-a).div(100))}static withWinChance(t,a){return ut.default(100-t).div(a)}}var W=0,L=1e4,Zt=L-W+1,_a=0.01,Na=98,Kr=(t)=>{if(t<W)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${W}`)},vr=(t)=>{if(t>L)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${L}`)},st=(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")},wa=(t,a)=>a>=t.lower&&a<=t.upper,Va=(t)=>t.upper-t.lower+1,pt=(t,a)=>a>t.lower&&a<t.upper,At=(t)=>t.upper-t.lower-1,Ia;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Ia||={});var Gt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return st(t.bounds),At(t.bounds);case"ROLL_OUTSIDE":return st(t.bounds),Zt-Va(t.bounds);case"ROLL_BETWEEN_TWO":return st(t.firstBounds),st(t.secondBounds),te(t.firstBounds,t.secondBounds),At(t.firstBounds)+At(t.secondBounds)}})(),e=kt.Big(r).div(Zt).mul(100);if(e.lt(_a))throw l.createValidationError("Win chance too low");if(e.gt(Na))throw l.createValidationError("Win chance too high");return e},ae=(t)=>{Gt(t)};class Ua extends A{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=Gt(r),n=t.getRandomInt({min:W,max:L}),o=n.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return pt(r.bounds,o);case"ROLL_OUTSIDE":return!wa(r.bounds,o);case"ROLL_BETWEEN_TWO":return pt(r.firstBounds,o)||pt(r.secondBounds,o)}})()?P.withWinChance(a,e):new kt.Big(0),outputs:{result:n.values},randomValues:n}}}var w=H(require("big.js"));var Et=require("@betorigami/guard");var Za=0,ka=51,Bt=Array.from({length:52},(t,a)=>a),Ga=["Spades","Hearts","Diamonds","Clubs"],mt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Ma=["Jack","Queen","King"],Mt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class N{value;constructor(t){let a=Bt[t];Et.Guard.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Ga[t];return Et.Guard.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=mt[t];return Et.Guard.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}var re=["Clubs","Diamonds","Hearts","Spades"],ee=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],ne={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},Fa;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(Fa||={});var Ja;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(Ja||={});var oe={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Ya=(t)=>{return new w.default(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new w.default(0)))};class $a 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),dt=this.mapRandomValueToCardValue(y);i.push(x),c=(c+dt)%10}let u=[],d=0;for(let y of o.slice(0,2)){let x=this.mapRandomValueToCard(y),dt=this.mapRandomValueToCardValue(y);u.push(x),d=(d+dt)%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=Ya(a),{betType:E,multiplier:B}=oe[s],_=new w.default(0);if(_=_.add(a.bets.filter((y)=>y.type===E).reduce((y,x)=>y.add(x.amount.mul(B)),new w.default(0))),s==="TIE")_=_.add(a.bets.filter((y)=>y.type==="PLAYER"||y.type==="BANKER").reduce((y,x)=>y.add(x.amount),new w.default(0)));return{isFinished:!0,payoutMultiplier:p.gt(0)?_.div(p):new w.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=new N(t);return{suit:a.suit,rank:ne[a.rank]}}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;((n)=>{n.WIN="WIN";n.LOSE="LOSE";n.PUSH="PUSH";n.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(yt||={});var ft;((r)=>{r.WON="WON";r.LOST="LOST"})(ft||={});var Ot;((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"})(Ot||={});var St;((n)=>{n.EXACT_PAIR="EXACT_PAIR";n.COLORED_PAIR="COLORED_PAIR";n.MIXED_PAIR="MIXED_PAIR";n.LOSS="LOSS"})(St||={});var Ht;((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"})(Ht||={});var za=2.5,qa=2,Xa=1,Qa=0,Ft=17,Dt=21,D=21,ht=63,ie=1.5,J=0.5,Ct=1.5,j=1,V=1,ce=13,xt=10,Jt=10,K={PLAYER_BLACKJACK:za,WIN:qa,PUSH:Xa,LOSE:Qa},Yt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},$t={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"),lr=require("@xstate/store");var ga=require("@betorigami/guard");class O extends N{get numericRank(){if(Ma.includes(this.rank))return Jt;return mt.indexOf(this.rank)+1}static fromValue(t){return ga.Guard.against(!Bt.includes(t),`Invalid card value: ${t}`),new O(t)}}class v{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<=Dt)this.softHandValue=this.hardHandValue+xt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>Dt}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===D}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class tt{cards;value;constructor(t){this.cards=t.map((a)=>O.fromValue(a)),this.value=new v(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 at extends tt{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 at(t.upCard,t.holeCard)}addDrawnCards(t){return new at(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new v([this.upCard]).highestHandValue}}}class I extends tt{static withInitialDeal(t){return new I(t)}addDrawnCards(t){return new I([...this.rawValues,...t])}}var rt=require("@betorigami/guard");class et{source;index=0;constructor(t){this.source=t}static from(t,a){return rt.Guard.against(a<=0,`Count must be positive, got ${a}`),rt.Guard.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.Guard.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){rt.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 zt=require("@betorigami/guard"),Wa=H(require("fast-deep-equal"));class Pt{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)zt.Guard.against(!Wa.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);zt.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 bt=require("@betorigami/guard");var La=(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)},Ka=(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(J):h.default(0),o=a.plus(e).mul(K[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(Ct):h.default(0),c=La(t.sideBetResults),u=o.plus(i).plus(c),d=a.plus(n).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);bt.Guard.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);bt.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(V);break}return{multiplier:s,additionalBetAmount:p}},va=(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(J):h.default(0),o=a.plus(r).mul(K[t.mainOutcome]),i=a.plus(e).mul(K[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(Ct):h.default(0),u=La(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);bt.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(V);break}return{multiplier:p,additionalBetAmount:E}};var ar=require("@betorigami/guard"),qt=(t)=>t.every((a)=>a===t[0]),tr=(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 ar.Guard.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},rr={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},le={...rr,Ace:14},de=(t)=>tr(t.map((a)=>rr[a]))||tr(t.map((a)=>le[a])),er=(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(Mt[r.suit]===Mt[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},nr=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Yt[a]}),or=(t,a,r)=>{let e=O.fromValue(t),n=O.fromValue(a),o=O.fromValue(r),i=[e.rank,n.rank,o.rank],c=qt([e.suit,n.suit,o.suit]),u=qt(i),d=de(i);if(qt([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"},ir=(t,a)=>({betAmount:t,result:a,payoutMultiplier:$t[a]});var ue={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 se(t){m.Guard.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function cr(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 dr=(t,a)=>{let r=a;while(r.highestHandValue<Ft)r=r.addDrawnCards([S(t.takeOne())]);return r},gt=(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}=Ka({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=dr(t.randomValuePool,t.dealerHand),r=gt(t.playerHand,a);return C({...t,dealerHand:a,outcome:r})},T=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:dr(t.randomValuePool,t.dealerHand),e=gt(t.mainHand,r),n=gt(t.splitHand,r),{multiplier:o,additionalBetAmount:i}=va({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 ur extends Pt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return et.from(t.getRandomIntsWithReplacement({min:Za,max:ka,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:m.Guard.againstNever(a,"Invalid state received")}}createGameStore(){return lr.createStore({context:ue,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=I.withInitialDeal([e,n]),u=at.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)?nr(a.pairBonusAmount,er(e,n)):null,threeCardBonus:R.default(a.threeCardBonusAmount).gt(0)?ir(a.threeCardBonusAmount,or(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;cr(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(J)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;cr(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;se(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=I.withInitialDeal([i.value,u]),p=I.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(V)};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(V)}}}})}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 $=H(require("big.js")),vt=require("@betorigami/guard");var Wt=0,Lt=51,Y=52,Kt=52;var pe=()=>({minPicks:5,maxPicks:36}),sr=(t)=>t.length===new Set(t).size,pr=(t)=>{let a=$.default(1),r=$.default(Y);for(let e=0;e<t;e+=1)a=a.mul($.default(Y-e).div(r));return a};class Ar extends A{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a,edge:r}){vt.Guard.against(a.pickCount<1||a.pickCount>Y,`pickCount must be between 1 and ${Y}`),vt.Guard.againstNonInteger(a.pickCount,"pickCount must be an integer");let e=t.getRandomIntsWithReplacement({min:Wt,max:Lt,count:Kt}),n=e.values.slice(0,a.pickCount),o=sr(n),i=pr(a.pickCount);return{isFinished:!0,payoutMultiplier:o?P.withMultiplier($.default(1).div(i),r):$.default(0),outputs:{result:e.values,cards:n.map((u)=>new N(u).toDto())},randomValues:e}}}var ta=0,jt=4294967295,aa;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(aa||={});var Ae=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Be={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:Ae},me=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Ee={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:me},ye=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],fe={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:ye},Oe=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Se={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:Oe},He=(t)=>{let a=Tt[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)},Tt={EASY:Be,MEDIUM:Ee,HARD:fe,EXPERT:Se};var Rt=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:ta,max:jt,count:2}),e=r.values[0],n=r.values[1];Rt.Guard.againstUndefined(e,"Random number generator returned no value for clockWiseRotation"),Rt.Guard.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let o=a.difficultyLevel;return{isFinished:!0,payoutMultiplier:Br.default(De(o,e,n)),outputs:{result:r.values},randomValues:r}}}var De=(t,a,r)=>{let e=Tt[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 he(e,a);return o.ringFour},he=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(jt+1)*r),n=t.segments[e];return Rt.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 Ce={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},xe={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},Pe={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},be={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},je={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,Ce],[2,xe],[3,Pe],[4,be],[8,je]])),Te={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=Te[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 ra=H(require("big.js"));var Sr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Sr||={});var ea=0,_t=1e4,Hr=_t-ea+1,Dr=(t)=>{let a=t.direction==="ABOVE"?_t-t.selectedValue:t.selectedValue;return new ra.default(a).div(Hr).mul(100)},hr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class Cr 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:ea,max:_t}),n=Dr(r);return{isFinished:!0,payoutMultiplier:hr(r,e.value)?P.withWinChance(a,n):new ra.default(0),outputs:{result:e.values},randomValues:e}}}var _r=H(require("big.js"));var nt=require("@betorigami/guard");var na;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(na||={});var xr=[1,2,3,4,5,6,7,8,9,10],oa=(t)=>{return xr.includes(t)};var Pr={[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]}},br={[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]}},jr={[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.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,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]}},ia=new b(new Map([[1,Pr],[2,br],[3,jr],[4,Tr],[8,Rr]]));class Nr extends A{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){nt.Guard.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),nt.Guard.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let p of r.selectedNumbers)nt.Guard.againstNonInteger(p,()=>l.createValidationError("Only integers can be selected")),nt.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(!oa(o))throw new Error(`Invalid tile count: ${o}`);let d=ia.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 _r.default(d),outputs:{result:e.values},randomValues:e}}}var U=H(require("big.js"));var ca=(t,a)=>{return t.gt(a)?t:a};var la=(t,a)=>{return t.lt(a)?t:a};class wr 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 U.default(16777216),i=new U.default(1),c=new U.default(1e6),u=e.value,d=new U.default(u-1).div(n),s=(100-a)/100,p=o.div(d.mul(o).plus(1)).mul(s),E=ca(i,la(p,c));return{isFinished:!0,payoutMultiplier:E.gte(r.targetMultiplier)?new U.default(r.targetMultiplier):new U.default(0),outputs:{randomMultiplier:E,result:e.values},randomValues:e}}}var ot=H(require("big.js"));var Nt=(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")}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.default(Nt(25-r.minesCount,r.selectedTiles.length)).div(new ot.default(Nt(25,r.selectedTiles.length))),E=r.hasCashedOut&&!c?new ot.default(d).div(s):new ot.default(0);return{isFinished:u,payoutMultiplier:E,outputs:{result:i.values},randomValues:i}}}var Ir=require("big.js");var da;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(da||={});var Re=[8,9,10,11,12,13,14,15,16],_e={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]}},Ne={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]}},we={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]}},Ve={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]}},Ie={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]}},ua=new b(new Map([[1,_e],[2,Ne],[3,we],[4,Ve],[8,Ie]]));class Ur 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=ua.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:Ir.Big(s),outputs:{result:c.values},randomValues:c}}}var lt=require("big.js");var wt=[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],sa=[37,...wt],pa=[[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]],Aa=[[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]],Ba=[[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]],ma=[[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]],Ea=[[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]],ya=[[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]],fa=[0,1,2,3,37],Oa=[[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]],Sa=[[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]],Z;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(Z||={});var k;((r)=>{r.RED="RED";r.BLACK="BLACK"})(k||={});var G;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(G||={});var M;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(M||={});var F;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(F||={});var Vt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Vt||={});var z=2.7,q=5.3;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)&&it(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.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(Z).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(F).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},it=(t)=>{return wt.includes(t)},Ue=(t)=>{if(t.length!==2)return!1;if(!t.every(it))return!1;return pa.some(([a,r])=>a===t[0]&&r===t[1])},Ze=(t)=>{if(t.length!==3)return!1;if(!t.every(it))return!1;return Ba.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},ke=(t)=>{if(t.length!==4)return!1;if(!t.every(it))return!1;return Ea.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(it))return!1;return Oa.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 Ut=(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)&&ct(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Me(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Fe(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Je(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)&&Ye(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(F).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},ct=(t)=>{return sa.includes(t)};function Me(t){if(t.length!==2)return!1;if(!t.every(ct))return!1;return Aa.some(([a,r])=>a===t[0]&&r===t[1])}var Fe=(t)=>{if(t.length!==3)return!1;if(!t.every(ct))return!1;return ma.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},Je=(t)=>{if(t.length!==4)return!1;if(!t.every(ct))return!1;return ya.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},Ye=(t)=>{if(t.length!==6)return!1;if(!t.every(ct))return!1;return Sa.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 $e=(t,a)=>{let r=a===z&&t.type==="EUROPEAN",e=a===q&&t.type==="AMERICAN";if(!r&&!e)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Ha=(t,a)=>{if($e(t,a),t.type==="EUROPEAN")It(t.inputs);else Ut(t.inputs)};var Zr={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},kr=[3,6,9,12,15,18,21,24,27,30,33,36],Gr=[2,5,8,11,14,17,20,23,26,29,32,35],Mr=[1,4,7,10,13,16,19,22,25,28,31,34],Fr=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Jr=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Da 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.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 lt.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 Fr.includes(a)&&r.color==="RED"||Jr.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 kr.includes(a)&&r.column==="TOP"||Gr.includes(a)&&r.column==="MIDDLE"||Mr.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.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=Zr[r];return a.plus(e.mul(o||0))},new lt.Big(0))}}class ha extends Da{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[z]}validateInputs(t){It(t)}}class Ca extends Da{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[q]}validateInputs(t){Ut(t)}isWinningBasketBet(t,a){return fa.some((r)=>r===a)}}class xa extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new ha,this.americanGame=new Ca}get supportedEdgeConfigurations(){return[z,q]}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(Ha(a,t.edge),a.type==="EUROPEAN"){let o=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:i}=o.outputs;return{...o,outputs:{type:"european",betOutcomes:i,result:o.outputs.result}}}let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:n,result:e.outputs.result}}}}var ze=(t)=>{return new xa().getBetAmount(t)};var zr=require("big.js");var X;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(X||={});var Q;((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"})(Q||={});var qe={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}}},Qe={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}}},ge={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}}},We={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 b(new Map([[1,qe],[2,Xe],[3,Qe],[4,ge],[8,We]]));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 qr extends A{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(Q).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(X).includes(a.riskLevel))throw new Error("Invalid risk level");let n=Yr.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=$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 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 zr.Big(s),outputs:{result:u.values},randomValues:u}}}
1
+ var Qr=Object.create;var{getPrototypeOf:qr,defineProperty:W,getOwnPropertyNames:ba,getOwnPropertyDescriptor:Wr}=Object,Ta=Object.prototype.hasOwnProperty;var H=(t,a,r)=>{r=t!=null?Qr(qr(t)):{};let n=a||!t||!t.__esModule?W(r,"default",{value:t,enumerable:!0}):r;for(let o of ba(t))if(!Ta.call(n,o))W(n,o,{get:()=>t[o],enumerable:!0});return n},ja=new WeakMap,Lr=(t)=>{var a=ja.get(t),r;if(a)return a;if(a=W({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")ba(t).map((n)=>!Ta.call(a,n)&&W(a,n,{get:()=>t[n],enumerable:!(r=Wr(t,n))||r.enumerable}));return ja.set(t,a),a};var gr=(t,a)=>{for(var r in a)W(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(n)=>a[r]=()=>n})};var Kn={};gr(Kn,{validateRouletteGameInputs:()=>Da,validateAdvancedDiceInputs:()=>an,rtp99Multipliers:()=>Pr,rtp98Multipliers:()=>jr,rtp97Multipliers:()=>br,rtp96Multipliers:()=>Tr,rtp92Multipliers:()=>_r,plinkoMultipliers:()=>sa,nCr:()=>Rt,kenoMultipliers:()=>ia,isTileCount:()=>ca,hasDiceWon:()=>hr,hasBlitzWon:()=>sr,getMaxMultiplierForDifficulty:()=>Dn,getBlitzDefaults:()=>Bn,diamondsMultipliers:()=>fr,calculateRouletteBetAmount:()=>Xn,calculateDiceWinChance:()=>Dr,calculateBlitzWinChance:()=>Ar,calculateBaccaratBetAmount:()=>Ft,calculateAdvancedDiceWinChance:()=>Mt,bigMin:()=>da,bigMax:()=>la,advancedDiceIsWithinBoundsInclusive:()=>Va,advancedDiceIsWithinBoundsExclusive:()=>At,advancedDiceGetInclusiveBoundsRange:()=>Ua,advancedDiceGetExclusiveBoundsRange:()=>Bt,WheelSegments:()=>q,WheelRiskLevel:()=>Q,Wheel:()=>Xr,WIN_MULTIPLIER:()=>Xa,VALID_SUITS:()=>rn,VALID_RANKS:()=>nn,VALID_EUROPEAN_STREETS:()=>Ea,VALID_EUROPEAN_STRAIGHTS:()=>wt,VALID_EUROPEAN_SPLITS:()=>Ba,VALID_EUROPEAN_DOUBLE_STREETS:()=>Sa,VALID_EUROPEAN_CORNERS:()=>ma,VALID_AMERICAN_STREETS:()=>ya,VALID_AMERICAN_STRAIGHTS:()=>Aa,VALID_AMERICAN_SPLITS:()=>pa,VALID_AMERICAN_DOUBLE_STREETS:()=>Ha,VALID_AMERICAN_CORNERS:()=>fa,ThreeCardBonusType:()=>Ht,TOP_COLUMN:()=>Ir,TILE_COUNTS:()=>xr,THREE_CARD_BONUS_PAYOUTS:()=>zt,SingleActionGame:()=>B,SPLIT_BET_SIZE_FACTOR:()=>V,RouletteType:()=>Vt,Roulette:()=>Pa,RollType:()=>Za,RandomValuePool:()=>nt,RED_NUMBERS:()=>Fr,RANDOM_MIN_VALUE:()=>L,RANDOM_MAX_VALUE:()=>g,PlinkoRiskLevel:()=>ua,Plinko:()=>Zr,Parity:()=>k,PairBonusType:()=>St,PUSH_MULTIPLIER:()=>Qa,PLINKO_ROW_COUNTS:()=>Nn,PAYOUT_MULTIPLIERS:()=>kr,PAIR_BONUS_PAYOUTS:()=>$t,OrigamiGame:()=>f,MultiplierCalculator:()=>P,MultiActionGame:()=>Pt,Mines:()=>Vr,MIN_WIN_CHANCE:()=>Ra,MIDDLE_COLUMN:()=>Mr,MAX_WIN_CHANCE:()=>wa,MAX_CARDS_PER_ROUND:()=>ht,Limbo:()=>wr,LOSE_MULTIPLIER:()=>qa,KenoRiskLevel:()=>ea,Keno:()=>Rr,InsuranceOutcome:()=>ft,INSURANCE_WIN_PAYOUT:()=>Ct,INSURANCE_BET_SIZE_FACTOR:()=>J,INSURANCE_BET_MULTIPLIER:()=>cn,Half:()=>M,GameErrorCode:()=>_a,GameError:()=>l,FACE_CARD_VALUE:()=>Yt,EuropeanRoulette:()=>Ca,EUROPEAN_HOUSE_EDGE:()=>z,EFFECTIVE_RANGE:()=>kt,Dozen:()=>F,DiceDirection:()=>Sr,Dice:()=>Cr,DiamondsResultType:()=>mr,Diamonds:()=>Or,Darts:()=>Er,DOUBLE_DOWN_BET_SIZE_FACTOR:()=>b,DICE_MIN_ROLL:()=>oa,DICE_MAX_ROLL:()=>Nt,DICE_EFFECTIVE_RANGE:()=>Hr,DEALER_STAND_VALUE:()=>Jt,DARTS_MIN_VALUE:()=>aa,DARTS_MAX_VALUE:()=>bt,DARTS_DIFFICULTY_LEVEL:()=>ra,DARTS_BOARD_CONFIGS:()=>Tt,Column:()=>G,Color:()=>I,CARDS_PER_SUIT:()=>ln,Blitz:()=>Br,BlackjackOutcome:()=>mt,BlackjackActionType:()=>Ot,Blackjack:()=>ur,BaccaratOutcome:()=>Ja,BaccaratBetType:()=>Ya,Baccarat:()=>$a,BUST_VALUE:()=>Dt,BOTTOM_COLUMN:()=>Gr,BLITZ_RANDOM_NUMBER_COUNT:()=>vt,BLITZ_MIN_CARD_RANGE:()=>gt,BLITZ_MAX_CARD_RANGE:()=>Kt,BLITZ_CARD_COUNT:()=>Y,BLACK_NUMBERS:()=>Jr,BLACKJACK_VALUE:()=>D,BLACKJACK_MULTIPLIER:()=>za,BASE_PAYOUT_MULTIPLIERS:()=>K,AmericanRoulette:()=>xa,AdvancedDice:()=>ka,AMERICAN_HOUSE_EDGE:()=>X,AMERICAN_BASKET:()=>Oa,ACE_SOFT_BONUS:()=>xt});module.exports=Lr(Kn);var _a;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(_a||={});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;((p)=>{p.DICE="DICE";p.MINES="MINES";p.KENO="KENO";p.LIMBO="LIMBO";p.ADVANCED_DICE="ADVANCED_DICE";p.BACCARAT="BACCARAT";p.DIAMONDS="DIAMONDS";p.PLINKO="PLINKO";p.ROULETTE="ROULETTE";p.WHEEL="WHEEL";p.BLACKJACK="BLACKJACK";p.BLITZ="BLITZ";p.DARTS="DARTS"})(f||={});var Na=require("@betorigami/guard");class B{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Na.Guard.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}var It=require("big.js");var ut=H(require("big.js"));class P{static withMultiplier(t,a){return new ut.default(t).times(new ut.default(100-a).div(100))}static withWinChance(t,a){return ut.default(100-t).div(a)}}var L=0,g=1e4,kt=g-L+1,Ra=0.01,wa=98,Kr=(t)=>{if(t<L)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${L}`)},vr=(t)=>{if(t>g)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${g}`)},st=(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}`)},tn=(t,a)=>{let[r,n]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>n.lower)throw l.createValidationError("Bounds must not overlap")},Va=(t,a)=>a>=t.lower&&a<=t.upper,Ua=(t)=>t.upper-t.lower+1,At=(t,a)=>a>t.lower&&a<t.upper,Bt=(t)=>t.upper-t.lower-1,Za;((n)=>{n.ROLL_BETWEEN="ROLL_BETWEEN";n.ROLL_OUTSIDE="ROLL_OUTSIDE";n.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Za||={});var Mt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return st(t.bounds),Bt(t.bounds);case"ROLL_OUTSIDE":return st(t.bounds),kt-Ua(t.bounds);case"ROLL_BETWEEN_TWO":return st(t.firstBounds),st(t.secondBounds),tn(t.firstBounds,t.secondBounds),Bt(t.firstBounds)+Bt(t.secondBounds)}})(),n=It.Big(r).div(kt).mul(100);if(n.lt(Ra))throw l.createValidationError("Win chance too low");if(n.gt(wa))throw l.createValidationError("Win chance too high");return n},an=(t)=>{Mt(t)};class ka extends B{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=Mt(r),o=t.getRandomInt({min:L,max:g}),e=o.value,i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return At(r.bounds,e);case"ROLL_OUTSIDE":return!Va(r.bounds,e);case"ROLL_BETWEEN_TWO":return At(r.firstBounds,e)||At(r.secondBounds,e)}})()?P.withWinChance(a,n):new It.Big(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:o.values},randomValues:o}}}var w=H(require("big.js"));var yt=require("@betorigami/guard");var Ia=0,Ma=51,pt=Array.from({length:52},(t,a)=>a),Ga=["Spades","Hearts","Diamonds","Clubs"],Et=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Fa=["Jack","Queen","King"],Gt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class R{value;constructor(t){let a=pt[t];yt.Guard.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Ga[t];return yt.Guard.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=Et[t];return yt.Guard.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}var rn=["Clubs","Diamonds","Hearts","Spades"],nn=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],on={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},Ja;((n)=>{n.PLAYER_WIN="PLAYER_WIN";n.TIE="TIE";n.BANKER_WIN="BANKER_WIN"})(Ja||={});var Ya;((n)=>{n.PLAYER="PLAYER";n.TIE="TIE";n.BANKER="BANKER"})(Ya||={});var en={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Ft=(t)=>{return new w.default(0).add(t.bets.reduce((r,n)=>r.add(n.amount),new w.default(0)))};class $a extends B{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}getBetAmount(t){return Ft(t)}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),n=r.values,o=n.slice(0,3),e=n.slice(3,6),c=[],i=0;for(let m of o.slice(0,2)){let x=this.mapRandomValueToCard(m),dt=this.mapRandomValueToCardValue(m);c.push(x),i=(i+dt)%10}let u=[],d=0;for(let m of e.slice(0,2)){let x=this.mapRandomValueToCard(m),dt=this.mapRandomValueToCardValue(m);u.push(x),d=(d+dt)%10}if(!this.isNaturalWin(i,d)){let m=this.shouldDrawThirdPlayerCard(i),x=null;if(m)x=this.mapRandomValueToCardValue(o[2]),c.push(this.mapRandomValueToCard(o[2])),i=(i+x)%10;if(this.shouldDrawThirdBankerCard(d,x))u.push(this.mapRandomValueToCard(e[2])),d=(d+this.mapRandomValueToCardValue(e[2]))%10}let s;if(i===d)s="TIE";else s=i>d?"PLAYER_WIN":"BANKER_WIN";let A=Ft(a),{betType:y,multiplier:p}=en[s],N=new w.default(0);if(N=N.add(a.bets.filter((m)=>m.type===y).reduce((m,x)=>m.add(x.amount.mul(p)),new w.default(0))),s==="TIE")N=N.add(a.bets.filter((m)=>m.type==="PLAYER"||m.type==="BANKER").reduce((m,x)=>m.add(x.amount),new w.default(0)));return{isFinished:!0,payoutMultiplier:A.gt(0)?N.div(A):new w.default(0),outputs:{playerCards:c,playerHandValue:i,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=new R(t);return{suit:a.suit,rank:on[a.rank]}}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 mt;((o)=>{o.WIN="WIN";o.LOSE="LOSE";o.PUSH="PUSH";o.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(mt||={});var ft;((r)=>{r.WON="WON";r.LOST="LOST"})(ft||={});var Ot;((i)=>{i.START="START";i.HIT="BLACKJACK_HIT";i.STAND="BLACKJACK_STAND";i.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";i.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";i.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";i.SPLIT="BLACKJACK_SPLIT"})(Ot||={});var St;((o)=>{o.EXACT_PAIR="EXACT_PAIR";o.COLORED_PAIR="COLORED_PAIR";o.MIXED_PAIR="MIXED_PAIR";o.LOSS="LOSS"})(St||={});var Ht;((c)=>{c.SUITED_TRIPS="SUITED_TRIPS";c.STRAIGHT_FLUSH="STRAIGHT_FLUSH";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.STRAIGHT="STRAIGHT";c.FLUSH="FLUSH";c.LOSS="LOSS"})(Ht||={});var za=2.5,Xa=2,Qa=1,qa=0,Jt=17,Dt=21,D=21,ht=63,cn=1.5,J=0.5,Ct=1.5,b=1,V=1,ln=13,xt=10,Yt=10,K={PLAYER_BLACKJACK:za,WIN:Xa,PUSH:Qa,LOSE:qa},$t={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},zt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var _=H(require("big.js")),E=require("@betorigami/guard"),lr=require("@xstate/store");var Wa=require("@betorigami/guard");class O extends R{get numericRank(){if(Fa.includes(this.rank))return Yt;return Et.indexOf(this.rank)+1}static fromValue(t){return Wa.Guard.against(!pt.includes(t),`Invalid card value: ${t}`),new O(t)}}class v{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,n)=>r+n.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+xt<=Dt)this.softHandValue=this.hardHandValue+xt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>Dt}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===D}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class tt{cards;value;constructor(t){this.cards=t.map((a)=>O.fromValue(a)),this.value=new v(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 at extends tt{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 at(t.upCard,t.holeCard)}addDrawnCards(t){return new at(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new v([this.upCard]).highestHandValue}}}class U extends tt{static withInitialDeal(t){return new U(t)}addDrawnCards(t){return new U([...this.rawValues,...t])}}var rt=require("@betorigami/guard");class nt{source;index=0;constructor(t){this.source=t}static from(t,a){return rt.Guard.against(a<=0,`Count must be positive, got ${a}`),rt.Guard.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new nt(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.Guard.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){rt.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 Xt=require("@betorigami/guard"),La=H(require("fast-deep-equal"));class Pt{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let n=this.createGameStore(),o=this.generateRandomValues(t),e=o.toMultipleRandomValues();for(let u of r)n.send({...u.playerArgument,randomValuePool:o});let c=r[r.length-1];if(c)Xt.Guard.against(!La.default(c.state,this.toExternalState(n.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");n.send({...a,randomValuePool:o});let i=n.getSnapshot().context;return{playerArgument:i.playerArgument,state:this.toExternalState(i.state),config:i.config,additionalBetAmount:i.additionalBetAmount,proof:{proofHash:e.proofHash,proofString:e.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);Xt.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 jt=require("@betorigami/guard");var ga=(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)},Ka=(t)=>{let a=t.betAmounts.mainBetAmount,n=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(b):h.default(0),o=t.insuranceOutcome!==void 0?a.mul(J):h.default(0),e=a.plus(n).mul(K[t.outcome]),c=t.insuranceOutcome==="WON"?a.mul(Ct):h.default(0),i=ga(t.sideBetResults),u=e.plus(c).plus(i),d=a.plus(o).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);jt.Guard.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);jt.Guard.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let A;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":A=n;break;case"BLACKJACK_BUY_INSURANCE":A=o;break;case"BLACKJACK_SPLIT":A=a.mul(V);break}return{multiplier:s,additionalBetAmount:A}},va=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(b):h.default(0),n=t.splitHandDoubledDown?a.mul(b):h.default(0),o=t.insuranceOutcome!==void 0?a.mul(J):h.default(0),e=a.plus(r).mul(K[t.mainOutcome]),c=a.plus(n).mul(K[t.splitOutcome]),i=t.insuranceOutcome==="WON"?a.mul(Ct):h.default(0),u=ga(t.sideBetResults),d=e.plus(c).plus(i).plus(u),s=a.plus(a).plus(o).plus(r).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);jt.Guard.against(s.eq(0),"Total bet amount cannot be zero");let A=d.div(s),y;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":y=a.mul(b);break;case"BLACKJACK_SPLIT":y=a.mul(V);break}return{multiplier:A,additionalBetAmount:y}};var ar=require("@betorigami/guard"),Qt=(t)=>t.every((a)=>a===t[0]),tr=(t)=>{let a=[...t].sort((r,n)=>r-n);return a.every((r,n)=>{let o=a[n-1];if(n===0)return!0;return ar.Guard.againstUndefined(o,"Previous value cannot be undefined"),r===o+1})},rr={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},dn={...rr,Ace:14},un=(t)=>tr(t.map((a)=>rr[a]))||tr(t.map((a)=>dn[a])),nr=(t,a)=>{let r=O.fromValue(t),n=O.fromValue(a);if(r.rank!==n.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Gt[r.suit]===Gt[n.suit])return"COLORED_PAIR";return"MIXED_PAIR"},or=(t,a)=>({betAmount:t,result:a,payoutMultiplier:$t[a]}),er=(t,a,r)=>{let n=O.fromValue(t),o=O.fromValue(a),e=O.fromValue(r),c=[n.rank,o.rank,e.rank],i=Qt([n.suit,o.suit,e.suit]),u=Qt(c),d=un(c);if(Qt([t,a,r]))return"SUITED_TRIPS";if(i&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(i)return"FLUSH";return"LOSS"},cr=(t,a)=>({betAmount:t,result:a,payoutMultiplier:zt[a]});var sn={state:{isFinished:!1,phase:"uninitialised",multiplier:_.default(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>O.fromValue(t).value;function An(t){E.Guard.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function ir(t){E.Guard.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function qt(t){E.Guard.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var dr=(t,a)=>{let r=a;while(r.highestHandValue<Jt)r=r.addDrawnCards([S(t.takeOne())]);return r},Lt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,n=a.highestHandValue;if(r>n)return"WIN";if(r<n)return"LOSE";return"PUSH"},C=(t)=>{let{multiplier:a,additionalBetAmount:r}=Ka({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}},Wt=(t)=>{let a=dr(t.randomValuePool,t.dealerHand),r=Lt(t.playerHand,a);return C({...t,dealerHand:a,outcome:r})},T=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:dr(t.randomValuePool,t.dealerHand),n=Lt(t.mainHand,r),o=Lt(t.splitHand,r),{multiplier:e,additionalBetAmount:c}=va({hasSplit:!0,mainOutcome:n,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:n,splitOutcome:o,multiplier:e,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:c}};class ur extends Pt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return nt.from(t.getRandomIntsWithReplacement({min:Ia,max:Ma,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:E.Guard.againstNever(a,"Invalid state received")}}createGameStore(){return lr.createStore({context:sn,on:{START:(t,a)=>{let{state:r}=t;E.Guard.against(r.phase!=="uninitialised","START action requires a fresh game");let n=S(a.randomValuePool.takeOne()),o=S(a.randomValuePool.takeOne()),e=S(a.randomValuePool.takeOne()),c=S(a.randomValuePool.takeOne()),i=U.withInitialDeal([n,o]),u=at.withInitialDeal({upCard:e,holeCard:c}),d={mainBetAmount:_.default(a.mainBetAmount),pairBonusAmount:_.default(a.pairBonusAmount),threeCardBonusAmount:_.default(a.threeCardBonusAmount)},s={pairBonus:_.default(a.pairBonusAmount).gt(0)?or(a.pairBonusAmount,nr(n,o)):null,threeCardBonus:_.default(a.threeCardBonusAmount).gt(0)?cr(a.threeCardBonusAmount,er(n,o,e)):null},A={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:i,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:A};let y={playerHand:i,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:A,betAmounts:d,sideBetResults:s};if(i.isBlackjack&&u.isBlackjack)return C({...y,outcome:"PUSH"});if(i.isBlackjack)return C({...y,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return C({...y,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:i,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:A}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;ir(r);let{playerHand:n,dealerHand:o,betAmounts:e,sideBetResults:c}=r,i={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:e,sideBetResults:c};if(n.isBlackjack&&o.isBlackjack)return C({...i,outcome:"PUSH",insuranceOutcome:"WON"});if(n.isBlackjack)return C({...i,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(o.isBlackjack)return C({...i,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:e.mainBetAmount.mul(J)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;ir(r);let{playerHand:n,dealerHand:o,betAmounts:e,sideBetResults:c}=r,i={playerHand:n,dealerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:e,sideBetResults:c};if(n.isBlackjack&&o.isBlackjack)return C({...i,outcome:"PUSH"});if(n.isBlackjack)return C({...i,outcome:"PLAYER_BLACKJACK"});if(o.isBlackjack)return C({...i,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(qt(r),r.phase){case"playing-main-hand":{let n=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted||n.highestHandValue===D){if(r.splitHand.highestHandValue===D)return T({...r,mainHand:n,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:n,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:n},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let n=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted||n.highestHandValue===D)return T({...r,splitHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:n},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let n=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted)return C({...r,playerHand:n,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(n.highestHandValue===D)return Wt({...r,playerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:n},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:E.Guard.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(qt(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 Wt({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:E.Guard.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(qt(r),r.phase){case"playing-main-hand":{E.Guard.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let n=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]),{betAmounts:o}=r;if(r.splitHand.highestHandValue===D)return T({...r,mainHand:n,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:n,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:o.mainBetAmount.mul(b)}}case"playing-split-hand":{E.Guard.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let n=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);return T({...r,splitHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{E.Guard.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let n=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted)return C({...r,playerHand:n,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return Wt({...r,playerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:E.Guard.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;An(r);let{playerHand:n,betAmounts:o,sideBetResults:e}=r;E.Guard.against(n.cards.length!==2,"Split is only allowed with exactly 2 cards");let c=n.cards[0],i=n.cards[1];E.Guard.againstUndefined(c,"First card is missing"),E.Guard.againstUndefined(i,"Second card is missing"),E.Guard.against(c.rank!==i.rank,"Split requires two cards of the same rank");let u=S(a.randomValuePool.takeOne()),d=S(a.randomValuePool.takeOne()),s=U.withInitialDeal([c.value,u]),A=U.withInitialDeal([i.value,d]);if(c.rank==="Ace")return T({...r,mainHand:s,splitHand:A,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let p=s.highestHandValue===D,N=A.highestHandValue===D;if(p&&N)return T({mainHand:s,splitHand:A,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:o,sideBetResults:e});if(p)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:A,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(V)};return{state:{...r,phase:"playing-main-hand",multiplier:_.default(0),mainHand:s,splitHand:A,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(V)}}}})}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],n=t.playerHand.cards[1];if(E.Guard.againstUndefined(r,"First player card is missing"),E.Guard.againstUndefined(n,"Second player card is missing"),r.rank===n.rank)a.push("BLACKJACK_SPLIT")}return a}default:E.Guard.againstNever(t,"Invalid phase for getting valid actions")}}}var $=H(require("big.js")),ta=require("@betorigami/guard");var gt=0,Kt=51,Y=52,vt=52;var Bn=()=>({minPicks:5,maxPicks:36}),sr=(t)=>t.length===new Set(t).size,Ar=(t)=>{let a=$.default(1),r=$.default(Y);for(let n=0;n<t;n+=1)a=a.mul($.default(Y-n).div(r));return a};class Br extends B{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){ta.Guard.against(a.pickCount<1||a.pickCount>Y,`pickCount must be between 1 and ${Y}`),ta.Guard.againstNonInteger(a.pickCount,"pickCount must be an integer");let n=t.getRandomIntsWithReplacement({min:gt,max:Kt,count:vt}),o=n.values.slice(0,a.pickCount),e=sr(o),c=Ar(a.pickCount),i=e?P.withMultiplier($.default(1).div(c),r):$.default(0);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:n.values,cards:o.map((u)=>new R(u).toDto())},randomValues:n}}}var aa=0,bt=4294967295,ra;((o)=>{o.EASY="EASY";o.MEDIUM="MEDIUM";o.HARD="HARD";o.EXPERT="EXPERT"})(ra||={});var pn=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],En={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:pn},yn=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],mn={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:yn},fn=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],On={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:fn},Sn=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Hn={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:Sn},Dn=(t)=>{let a=Tt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((n,o)=>o>n?o:n)},Tt={EASY:En,MEDIUM:mn,HARD:On,EXPERT:Hn};var _t=require("@betorigami/guard"),pr=H(require("big.js"));class Er extends B{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:aa,max:bt,count:2}),n=r.values[0],o=r.values[1];_t.Guard.againstUndefined(n,"Random number generator returned no value for clockWiseRotation"),_t.Guard.againstUndefined(o,"Random number generator returned no value for distanceFromCentre");let e=a.difficultyLevel,c=pr.default(hn(e,n,o));return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}}var hn=(t,a,r)=>{let n=Tt[t],{distanceBoundaries:o,multipliers:e}=n;if(r<o.bullseye)return e.bullseye;if(r<o.ringOne)return e.ringOne;if(r<o.ringTwo)return e.ringTwo;if(r<o.ringThree)return Cn(n,a);return e.ringFour},Cn=(t,a)=>{let r=t.segments.length,n=Math.floor(a/(bt+1)*r),o=t.segments[n];return _t.Guard.againstUndefined(o,`Segment index ${n} out of bounds`),t.multipliers.ringThree[o]};var yr=H(require("big.js"));class j{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 mr;((c)=>{c.PAIR="PAIR";c.TWO_PAIR="TWO_PAIR";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.FULL_HOUSE="FULL_HOUSE";c.FOUR_OF_A_KIND="FOUR_OF_A_KIND";c.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(mr||={});var xn={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},Pn={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},jn={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},bn={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},Tn={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 j(new Map([[1,xn],[2,Pn],[3,jn],[4,bn],[8,Tn]])),_n={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Or extends B{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),o=fr.getMultipliers(a),e=n.values,c=yr.default(this.calculatePayoutMultiplier(o,e));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:n.values},randomValues:n}}calculatePayoutMultiplier(t,a){let r=new Map;for(let e of a){let c=r.get(e)||0;r.set(e,c+1)}let n=[...r.values()].filter((e)=>e>1),o=this.classifyResult(n);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 n=_n[a];if(n===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return n}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}var na=H(require("big.js"));var Sr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Sr||={});var oa=0,Nt=1e4,Hr=Nt-oa+1,Dr=(t)=>{let a=t.direction==="ABOVE"?Nt-t.selectedValue:t.selectedValue;return new na.default(a).div(Hr).mul(100)},hr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class Cr extends B{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:oa,max:Nt}),o=Dr(r),c=hr(r,n.value)?P.withWinChance(a,o):new na.default(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:n.values},randomValues:n}}}var Nr=H(require("big.js"));var ot=require("@betorigami/guard");var ea;((o)=>{o.CLASSIC="CLASSIC";o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(ea||={});var xr=[1,2,3,4,5,6,7,8,9,10],ca=(t)=>{return xr.includes(t)};var Pr={[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]}},jr={[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]}},Tr={[1]:{CLASSIC:[0,3.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1000]}},_r={[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]}},ia=new j(new Map([[1,Pr],[2,jr],[3,br],[4,Tr],[8,_r]]));class Rr extends B{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){ot.Guard.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),ot.Guard.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let A of r.selectedNumbers)ot.Guard.againstNonInteger(A,()=>l.createValidationError("Only integers can be selected")),ot.Guard.against(A<0||A>39,()=>l.createValidationError("Invalid number selected"));let n=t.getUniqueRandomInts({min:0,max:39,count:10}),o=r.selectedNumbers.filter((A)=>n.values.includes(A)),e=r.selectedNumbers.length;if(!ca(e))throw new Error(`Invalid tile count: ${e}`);let d=ia.getMultipliers(a)[e][r.riskLevel][o.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${o.length}`);let s=new Nr.default(d);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:n.values},randomValues:n}}}var Z=H(require("big.js"));var la=(t,a)=>{return t.gt(a)?t:a};var da=(t,a)=>{return t.lt(a)?t:a};class wr extends B{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:1,max:4294967295}),o=n.max,e=new Z.default(16777216),c=new Z.default(1),i=new Z.default(1e6),u=n.value,d=new Z.default(u-1).div(o),s=(100-a)/100,A=e.div(d.mul(e).plus(1)).mul(s),y=la(c,da(A,i)),p=y.gte(r.targetMultiplier)?new Z.default(r.targetMultiplier):new Z.default(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:y,result:n.values},randomValues:n}}}var et=H(require("big.js"));var Rt=(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 n=1;n<=a;n++)r=r*(t-n+1)/n;return r};class Vr extends B{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}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 c=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),i=c.values.some((p)=>r.selectedTiles.includes(p)),u=r.hasCashedOut||i,d=(100-a)/100,s=new et.default(Rt(25-r.minesCount,r.selectedTiles.length)).div(new et.default(Rt(25,r.selectedTiles.length))),y=r.hasCashedOut&&!i?new et.default(d).div(s):new et.default(0);return{isFinished:u,payout:{legs:[{amount:r.betAmount.mul(y)}]},payoutMultiplier:y,outputs:{result:c.values},randomValues:c}}}var Ur=require("big.js");var ua;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(ua||={});var Nn=[8,9,10,11,12,13,14,15,16],Rn={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]}},wn={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]}},Vn={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]}},Un={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]}},Zn={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]}},sa=new j(new Map([[1,Rn],[2,wn],[3,Vn],[4,Un],[8,Zn]]));class Zr extends B{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}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 n=a.numberOfRows,c=sa.getMultipliers(r)[a.riskLevel][n],i=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=i.values.reduce((y,p)=>y+p,0),s=c[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);let A=Ur.Big(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:i.values},randomValues:i}}}var lt=require("big.js");var wt=[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],Aa=[37,...wt],Ba=[[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]],pa=[[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]],Ea=[[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]],ya=[[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]],ma=[[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]],fa=[[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]],Oa=[0,1,2,3,37],Sa=[[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]],Ha=[[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]],k;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(k||={});var I;((r)=>{r.RED="RED";r.BLACK="BLACK"})(I||={});var M;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(M||={});var G;((n)=>{n.TOP="TOP";n.MIDDLE="MIDDLE";n.BOTTOM="BOTTOM"})(G||={});var F;((n)=>{n.FIRST="FIRST";n.SECOND="SECOND";n.THIRD="THIRD"})(F||={});var Vt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Vt||={});var z=2.7,X=5.3;var Ut=(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)&&ct(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&kn(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&In(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Mn(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Gn(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(M).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(F).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},ct=(t)=>{return wt.includes(t)},kn=(t)=>{if(t.length!==2)return!1;if(!t.every(ct))return!1;return Ba.some(([a,r])=>a===t[0]&&r===t[1])},In=(t)=>{if(t.length!==3)return!1;if(!t.every(ct))return!1;return Ea.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},Mn=(t)=>{if(t.length!==4)return!1;if(!t.every(ct))return!1;return ma.some(([a,r,n,o])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3])},Gn=(t)=>{if(t.length!==6)return!1;if(!t.every(ct))return!1;return Sa.some(([a,r,n,o,e,c])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3]&&e===t[4]&&c===t[5])};var Zt=(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)&&it(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Fn(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Jn(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Yn(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)&&$n(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(M).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(F).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},it=(t)=>{return Aa.includes(t)};function Fn(t){if(t.length!==2)return!1;if(!t.every(it))return!1;return pa.some(([a,r])=>a===t[0]&&r===t[1])}var Jn=(t)=>{if(t.length!==3)return!1;if(!t.every(it))return!1;return ya.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},Yn=(t)=>{if(t.length!==4)return!1;if(!t.every(it))return!1;return fa.some(([a,r,n,o])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3])},$n=(t)=>{if(t.length!==6)return!1;if(!t.every(it))return!1;return Ha.some(([a,r,n,o,e,c])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3]&&e===t[4]&&c===t[5])};var zn=(t,a)=>{let r=a===z&&t.type==="EUROPEAN",n=a===X&&t.type==="AMERICAN";if(!r&&!n)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Da=(t,a)=>{if(zn(t,a),t.type==="EUROPEAN")Ut(t.inputs);else Zt(t.inputs)};var kr={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Ir=[3,6,9,12,15,18,21,24,27,30,33,36],Mr=[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],Fr=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Jr=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class ha extends B{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),n=r.value,o=this.determineBetOutcomes(a,n),{payoutMultiplier:e}=this.getPayoutDetails(a,n);return{outputs:{betOutcomes:o,result:r.values},payoutMultiplier:e,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),n=this.getBetTotals(t),o=this.getBetTotals(r.winningBets),e=this.calculateTotalBetAmount(n),c=this.calculateTotalPayout(o);return{payoutMultiplier:e.gt(0)?c.div(e):new lt.Big(0),payoutAmount:c}}determineBetOutcomes(t,a){let r={},n={};for(let o of Object.keys(t)){let e=t[o],c=this.betPredicates[o],{winning:i,losing:u}=this.partitionBets(e,c,a);r[o]=i,n[o]=u}return{winningBets:r,losingBets:n}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new lt.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 Fr.includes(a)&&r.color==="RED"||Jr.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 Ir.includes(a)&&r.column==="TOP"||Mr.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 n=a%2===0?"EVEN":"ODD";return r.parity===n}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.Big(0))}partitionBets(t,a,r){return{winning:t.filter((n)=>a(n,r)),losing:t.filter((n)=>!a(n,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,n])=>{let e=kr[r];return a.plus(n.mul(e||0))},new lt.Big(0))}}class Ca extends ha{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[z]}validateInputs(t){Ut(t)}}class xa extends ha{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[X]}validateInputs(t){Zt(t)}isWinningBasketBet(t,a){return Oa.some((r)=>r===a)}}class Pa extends B{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Ca,this.americanGame=new xa}get supportedEdgeConfigurations(){return[z,X]}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(Da(a,t.edge),a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}let n=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=n.outputs;return{...n,outputs:{type:"american",betOutcomes:o,result:n.outputs.result}}}}var Xn=(t)=>{return new Pa().getBetAmount(t)};var zr=require("big.js");var Q;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(Q||={});var q;((e)=>{e[e.TEN=10]="TEN";e[e.TWENTY=20]="TWENTY";e[e.THIRTY=30]="THIRTY";e[e.FORTY=40]="FORTY";e[e.FIFTY=50]="FIFTY"})(q||={});var Qn={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}}},qn={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}}},Wn={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}}},Ln={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}}},gn={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 j(new Map([[1,Qn],[2,qn],[3,Wn],[4,Ln],[8,gn]]));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 B{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(q).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(Q).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 e=o[a.segments];if(e===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let c=$r[a.riskLevel];if(c===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let i=c[a.segments];if(i===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:i.length-1}),d=i[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=e[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);let A=new zr.Big(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:u.values},randomValues:u}}}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
3
  import Big$1 from 'big.js';
4
- import { Big as Big$1, Big as Big$2, Big as Big$3 } from 'big.js';
4
+ import { Big as Big$1, Big as Big$2, Big as Big$3, Big as Big$4, Big as Big$5 } from 'big.js';
5
5
  import { ReadonlyDeep, Simplify } from 'type-fest';
6
6
 
7
7
  export declare enum GameErrorCode {
@@ -70,6 +70,27 @@ export interface RandomNumberGenerator {
70
70
  count: number;
71
71
  }): MultipleRandomValues;
72
72
  }
73
+ /**
74
+ * A single exact payout amount from a game round.
75
+ *
76
+ * A round returns zero or more legs. Neither their order nor their count is
77
+ * significant: a leg is not tied to a particular bet, an amount may be zero,
78
+ * and the number of legs need not match the number of bets placed. The only
79
+ * supported operation is summing them.
80
+ *
81
+ * Amounts are gross — they include returned stake — and unrounded. Rounding to
82
+ * a currency's precision is the consuming service's decision, not this
83
+ * package's.
84
+ */
85
+ export type PayoutLeg = Readonly<{
86
+ amount: Big$1;
87
+ }>;
88
+ /**
89
+ * A round's payout, expressed as its constituent legs.
90
+ */
91
+ export type Payout = Readonly<{
92
+ legs: readonly PayoutLeg[];
93
+ }>;
73
94
  export type EmptyGameOutput = {};
74
95
  export interface GetGameResultRequest<TGameInputs> {
75
96
  generator: RandomNumberGenerator;
@@ -78,6 +99,12 @@ export interface GetGameResultRequest<TGameInputs> {
78
99
  }
79
100
  export interface GameResult<TGameOutputs = EmptyGameOutput> {
80
101
  isFinished: boolean;
102
+ /**
103
+ * Optional only while payout legs are being rolled out across games: the
104
+ * single-bet games populate it, the multi-bet games do not yet. It becomes
105
+ * required once every game emits it.
106
+ */
107
+ payout?: Payout;
81
108
  payoutMultiplier: Big$1;
82
109
  outputs: TGameOutputs & {
83
110
  result: number[];
@@ -91,6 +118,7 @@ export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = Empty
91
118
  number,
92
119
  ...number[]
93
120
  ];
121
+ abstract getBetAmount(gameInputs: TGameInputs): Big$1;
94
122
  getGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
95
123
  protected abstract determineGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
96
124
  }
@@ -115,25 +143,30 @@ export declare enum RollType {
115
143
  export type RollBetween = {
116
144
  mode: RollType.ROLL_BETWEEN;
117
145
  bounds: Bounds;
146
+ betAmount: Big$1.Big;
118
147
  };
119
148
  export type RollOutside = {
120
149
  mode: RollType.ROLL_OUTSIDE;
121
150
  bounds: Bounds;
151
+ betAmount: Big$1.Big;
122
152
  };
123
153
  export type RollBetweenTwo = {
124
154
  mode: RollType.ROLL_BETWEEN_TWO;
125
155
  firstBounds: Bounds;
126
156
  secondBounds: Bounds;
157
+ betAmount: Big$1.Big;
127
158
  };
128
159
  export type AdvancedDiceInputs = RollBetween | RollOutside | RollBetweenTwo;
129
- export declare const calculateAdvancedDiceWinChance: (gameInputs: AdvancedDiceInputs) => Big$1.Big;
130
- export declare const validateAdvancedDiceInputs: (gameInputs: AdvancedDiceInputs) => void;
160
+ export type AdvancedDiceSelection = Pick<RollBetween, "mode" | "bounds"> | Pick<RollOutside, "mode" | "bounds"> | Pick<RollBetweenTwo, "mode" | "firstBounds" | "secondBounds">;
161
+ export declare const calculateAdvancedDiceWinChance: (gameInputs: AdvancedDiceSelection) => Big$1.Big;
162
+ export declare const validateAdvancedDiceInputs: (gameInputs: AdvancedDiceSelection) => void;
131
163
  export declare class AdvancedDice extends SingleActionGame<AdvancedDiceInputs> {
132
164
  constructor();
133
165
  get supportedEdgeConfigurations(): [
134
166
  number,
135
167
  ...number[]
136
168
  ];
169
+ getBetAmount(gameInputs: AdvancedDiceInputs): Big$1.Big;
137
170
  protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<AdvancedDiceInputs>): GameResult;
138
171
  }
139
172
  export interface Bet {
@@ -194,6 +227,7 @@ export declare class Baccarat extends SingleActionGame<BaccaratGameInputs, Bacca
194
227
  number,
195
228
  ...number[]
196
229
  ];
230
+ getBetAmount(gameInputs: BaccaratGameInputs): Big$1;
197
231
  protected determineGameResult({ generator, gameInputs }: GetGameResultRequest<BaccaratGameInputs>): GameResult<BaccaratGameOutputs>;
198
232
  private validateGameInputs;
199
233
  private mapRandomValueToCard;
@@ -552,6 +586,7 @@ export declare class Blackjack extends MultiActionGame<BlackjackInternalState, B
552
586
  }
553
587
  export interface BlitzGameInputs {
554
588
  pickCount: number;
589
+ betAmount: Big$1;
555
590
  }
556
591
  export interface BlitzGameOutputs {
557
592
  cards: CardDto[];
@@ -570,6 +605,7 @@ export declare class Blitz extends SingleActionGame<BlitzGameInputs, BlitzGameOu
570
605
  number,
571
606
  ...number[]
572
607
  ];
608
+ getBetAmount(gameInputs: BlitzGameInputs): Big$1;
573
609
  protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<BlitzGameInputs>): GameResult<BlitzGameOutputs>;
574
610
  }
575
611
  export declare const BLITZ_MIN_CARD_RANGE = 0;
@@ -586,6 +622,7 @@ export declare enum DARTS_DIFFICULTY_LEVEL {
586
622
  }
587
623
  export interface DartsGameInputs {
588
624
  difficultyLevel: DARTS_DIFFICULTY_LEVEL;
625
+ betAmount: Big$1;
589
626
  }
590
627
  export declare class Darts extends SingleActionGame<DartsGameInputs> {
591
628
  constructor();
@@ -593,6 +630,7 @@ export declare class Darts extends SingleActionGame<DartsGameInputs> {
593
630
  number,
594
631
  ...number[]
595
632
  ];
633
+ getBetAmount(gameInputs: DartsGameInputs): Big$1;
596
634
  protected determineGameResult({ generator, gameInputs }: GetGameResultRequest<DartsGameInputs>): GameResult;
597
635
  }
598
636
  export type Segment = "YELLOW" | "ORANGE" | "RED";
@@ -624,6 +662,7 @@ declare class MultiplierContainer<TMultipliers> {
624
662
  }[];
625
663
  }
626
664
  export interface DiamondsGameInputs {
665
+ betAmount: Big$1;
627
666
  }
628
667
  export declare enum DiamondsResultType {
629
668
  PAIR = "PAIR",
@@ -641,7 +680,8 @@ export declare class Diamonds extends SingleActionGame<DiamondsGameInputs> {
641
680
  number,
642
681
  ...number[]
643
682
  ];
644
- protected determineGameResult({ generator, edge }: GetGameResultRequest<DiamondsGameInputs>): GameResult;
683
+ getBetAmount(gameInputs: DiamondsGameInputs): Big$1;
684
+ protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<DiamondsGameInputs>): GameResult;
645
685
  private calculatePayoutMultiplier;
646
686
  private classifyResult;
647
687
  }
@@ -652,18 +692,21 @@ export declare enum DiceDirection {
652
692
  export interface DiceGameInputs {
653
693
  direction: DiceDirection;
654
694
  selectedValue: number;
695
+ betAmount: Big$1;
655
696
  }
697
+ export type DiceSelection = Pick<DiceGameInputs, "direction" | "selectedValue">;
656
698
  export declare const DICE_MIN_ROLL = 0;
657
699
  export declare const DICE_MAX_ROLL = 10000;
658
700
  export declare const DICE_EFFECTIVE_RANGE: number;
659
- export declare const calculateDiceWinChance: (gameInputs: DiceGameInputs) => Big$1;
660
- export declare const hasDiceWon: (gameInputs: DiceGameInputs, rolledValue: number) => boolean;
701
+ export declare const calculateDiceWinChance: (gameInputs: DiceSelection) => Big$1;
702
+ export declare const hasDiceWon: (gameInputs: DiceSelection, rolledValue: number) => boolean;
661
703
  export declare class Dice extends SingleActionGame<DiceGameInputs> {
662
704
  constructor();
663
705
  get supportedEdgeConfigurations(): [
664
706
  number,
665
707
  ...number[]
666
708
  ];
709
+ getBetAmount(gameInputs: DiceGameInputs): Big$1;
667
710
  protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<DiceGameInputs>): GameResult;
668
711
  }
669
712
  export declare enum KenoRiskLevel {
@@ -689,6 +732,7 @@ export declare const isTileCount: (value: number) => value is TileCount;
689
732
  export interface KenoGameInputs {
690
733
  riskLevel: KenoRiskLevel;
691
734
  selectedNumbers: number[];
735
+ betAmount: Big$1;
692
736
  }
693
737
  export declare class Keno extends SingleActionGame<KenoGameInputs> {
694
738
  constructor();
@@ -696,6 +740,7 @@ export declare class Keno extends SingleActionGame<KenoGameInputs> {
696
740
  number,
697
741
  ...number[]
698
742
  ];
743
+ getBetAmount(gameInputs: KenoGameInputs): Big$1;
699
744
  protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<KenoGameInputs>): GameResult;
700
745
  }
701
746
  export type KenoMultipliers = Record<TileCount, Record<KenoRiskLevel, number[]>>;
@@ -707,6 +752,7 @@ export declare const rtp92Multipliers: KenoMultipliers;
707
752
  export declare const kenoMultipliers: MultiplierContainer<KenoMultipliers>;
708
753
  export interface LimboGameInputs {
709
754
  targetMultiplier: number;
755
+ betAmount: Big$1;
710
756
  }
711
757
  export interface LimboGameOutputs {
712
758
  randomMultiplier: Big$1;
@@ -717,12 +763,14 @@ export declare class Limbo extends SingleActionGame<LimboGameInputs, LimboGameOu
717
763
  number,
718
764
  ...number[]
719
765
  ];
766
+ getBetAmount(gameInputs: LimboGameInputs): Big$1;
720
767
  protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<LimboGameInputs>): GameResult<LimboGameOutputs>;
721
768
  }
722
769
  export interface MinesGameInputs {
723
770
  minesCount: number;
724
771
  selectedTiles: number[];
725
772
  hasCashedOut: boolean;
773
+ betAmount: Big$1;
726
774
  }
727
775
  export declare class Mines extends SingleActionGame<MinesGameInputs> {
728
776
  constructor();
@@ -730,6 +778,7 @@ export declare class Mines extends SingleActionGame<MinesGameInputs> {
730
778
  number,
731
779
  ...number[]
732
780
  ];
781
+ getBetAmount(gameInputs: MinesGameInputs): Big$1;
733
782
  protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<MinesGameInputs>): GameResult;
734
783
  }
735
784
  export declare enum PlinkoRiskLevel {
@@ -740,6 +789,7 @@ export declare enum PlinkoRiskLevel {
740
789
  export interface PlinkoGameInputs {
741
790
  numberOfRows: number;
742
791
  riskLevel: PlinkoRiskLevel;
792
+ betAmount: Big$1.Big;
743
793
  }
744
794
  export declare class Plinko extends SingleActionGame<PlinkoGameInputs> {
745
795
  constructor();
@@ -747,6 +797,7 @@ export declare class Plinko extends SingleActionGame<PlinkoGameInputs> {
747
797
  number,
748
798
  ...number[]
749
799
  ];
800
+ getBetAmount(gameInputs: PlinkoGameInputs): Big$1.Big;
750
801
  protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<PlinkoGameInputs>): GameResult;
751
802
  }
752
803
  export declare const PLINKO_ROW_COUNTS: readonly [
@@ -2186,6 +2237,7 @@ export declare enum WheelSegments {
2186
2237
  export interface WheelGameInputs {
2187
2238
  segments: WheelSegments;
2188
2239
  riskLevel: WheelRiskLevel;
2240
+ betAmount: Big$1.Big;
2189
2241
  }
2190
2242
  export declare class Wheel extends SingleActionGame<WheelGameInputs> {
2191
2243
  constructor();
@@ -2193,6 +2245,7 @@ export declare class Wheel extends SingleActionGame<WheelGameInputs> {
2193
2245
  number,
2194
2246
  ...number[]
2195
2247
  ];
2248
+ getBetAmount(gameInputs: WheelGameInputs): Big$1.Big;
2196
2249
  protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
2197
2250
  }
2198
2251
  export declare const bigMax: (a: Big$1, b: Big$1) => Big$1;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var Fa;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(Fa||={});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 Ja}from"@betorigami/guard";class A{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Ja.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}import{Big as Jt}from"big.js";import At from"big.js";class x{static withMultiplier(t,a){return new At(t).times(new At(100-a).div(100))}static withWinChance(t,a){return At(100-t).div(a)}}var at=0,rt=1e4,Ft=rt-at+1,Ya=0.01,$a=98,za=(t)=>{if(t<at)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${at}`)},qa=(t)=>{if(t>rt)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${rt}`)},tt=(t)=>{if(za(t.lower),qa(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},Xa=(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")},Qa=(t,a)=>a>=t.lower&&a<=t.upper,ga=(t)=>t.upper-t.lower+1,Bt=(t,a)=>a>t.lower&&a<t.upper,mt=(t)=>t.upper-t.lower-1,Wa;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Wa||={});var Yt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return tt(t.bounds),mt(t.bounds);case"ROLL_OUTSIDE":return tt(t.bounds),Ft-ga(t.bounds);case"ROLL_BETWEEN_TWO":return tt(t.firstBounds),tt(t.secondBounds),Xa(t.firstBounds,t.secondBounds),mt(t.firstBounds)+mt(t.secondBounds)}})(),e=Jt(r).div(Ft).mul(100);if(e.lt(Ya))throw l.createValidationError("Win chance too low");if(e.gt($a))throw l.createValidationError("Win chance too high");return e},Xe=(t)=>{Yt(t)};class La extends A{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=Yt(r),n=t.getRandomInt({min:at,max:rt}),o=n.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return Bt(r.bounds,o);case"ROLL_OUTSIDE":return!Qa(r.bounds,o);case"ROLL_BETWEEN_TWO":return Bt(r.firstBounds,o)||Bt(r.secondBounds,o)}})()?x.withWinChance(a,e):new Jt(0),outputs:{result:n.values},randomValues:n}}}import w from"big.js";import{Guard as yt}from"@betorigami/guard";var $t=0,zt=51,et=Array.from({length:52},(t,a)=>a),qt=["Spades","Hearts","Diamonds","Clubs"],nt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Xt=["Jack","Queen","King"],Et={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class T{value;constructor(t){let a=et[t];yt.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=qt[t];return yt.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=nt[t];return yt.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}var on=["Clubs","Diamonds","Hearts","Spades"],cn=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],Ka={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},va;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(va||={});var tr;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(tr||={});var ar={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},rr=(t)=>{return new w(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new w(0)))};class er 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),v=this.mapRandomValueToCardValue(y);i.push(D),c=(c+v)%10}let u=[],d=0;for(let y of o.slice(0,2)){let D=this.mapRandomValueToCard(y),v=this.mapRandomValueToCardValue(y);u.push(D),d=(d+v)%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=rr(a),{betType:E,multiplier:B}=ar[s],j=new w(0);if(j=j.add(a.bets.filter((y)=>y.type===E).reduce((y,D)=>y.add(D.amount.mul(B)),new w(0))),s==="TIE")j=j.add(a.bets.filter((y)=>y.type==="PLAYER"||y.type==="BANKER").reduce((y,D)=>y.add(D.amount),new w(0)));return{isFinished:!0,payoutMultiplier:p.gt(0)?j.div(p):new w(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=new T(t);return{suit:a.suit,rank:Ka[a.rank]}}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 ft;((n)=>{n.WIN="WIN";n.LOSE="LOSE";n.PUSH="PUSH";n.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(ft||={});var Ot;((r)=>{r.WON="WON";r.LOST="LOST"})(Ot||={});var St;((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"})(St||={});var Ht;((n)=>{n.EXACT_PAIR="EXACT_PAIR";n.COLORED_PAIR="COLORED_PAIR";n.MIXED_PAIR="MIXED_PAIR";n.LOSS="LOSS"})(Ht||={});var Dt;((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"})(Dt||={});var nr=2.5,or=2,ir=1,cr=0,Qt=17,ht=21,h=21,Ct=63,An=1.5,F=0.5,xt=1.5,R=1,V=1,Bn=13,Pt=10,gt=10,ot={PLAYER_BLACKJACK:nr,WIN:or,PUSH:ir,LOSE:cr},Wt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Lt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};import N from"big.js";import{Guard as m}from"@betorigami/guard";import{createStore as Ar}from"@xstate/store";import{Guard as lr}from"@betorigami/guard";class f extends T{get numericRank(){if(Xt.includes(this.rank))return gt;return nt.indexOf(this.rank)+1}static fromValue(t){return lr.against(!et.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+Pt<=ht)this.softHandValue=this.hardHandValue+Pt}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===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 _ extends Y{static withInitialDeal(t){return new _(t)}addDrawnCards(t){return new _([...this.rawValues,...t])}}import{Guard as it}from"@betorigami/guard";class ct{source;index=0;constructor(t){this.source=t}static from(t,a){return it.against(a<=0,`Count must be positive, got ${a}`),it.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new ct(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return it.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){it.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 Kt}from"@betorigami/guard";import dr from"fast-deep-equal";class bt{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)Kt.against(!dr(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);Kt.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 jt}from"@betorigami/guard";var vt=(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)},ta=(t)=>{let a=t.betAmounts.mainBetAmount,e=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(R):C(0),n=t.insuranceOutcome!==void 0?a.mul(F):C(0),o=a.plus(e).mul(ot[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(xt):C(0),c=vt(t.sideBetResults),u=o.plus(i).plus(c),d=a.plus(n).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);jt.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);jt.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(V);break}return{multiplier:s,additionalBetAmount:p}},aa=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(R):C(0),e=t.splitHandDoubledDown?a.mul(R):C(0),n=t.insuranceOutcome!==void 0?a.mul(F):C(0),o=a.plus(r).mul(ot[t.mainOutcome]),i=a.plus(e).mul(ot[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(xt):C(0),u=vt(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);jt.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(R);break;case"BLACKJACK_SPLIT":E=a.mul(V);break}return{multiplier:p,additionalBetAmount:E}};import{Guard as ur}from"@betorigami/guard";var Tt=(t)=>t.every((a)=>a===t[0]),ra=(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 ur.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},ea={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},sr={...ea,Ace:14},pr=(t)=>ra(t.map((a)=>ea[a]))||ra(t.map((a)=>sr[a])),na=(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(Et[r.suit]===Et[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},oa=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Wt[a]}),ia=(t,a,r)=>{let e=f.fromValue(t),n=f.fromValue(a),o=f.fromValue(r),i=[e.rank,n.rank,o.rank],c=Tt([e.suit,n.suit,o.suit]),u=Tt(i),d=pr(i);if(Tt([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"},ca=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Lt[a]});var Br={state:{isFinished:!1,phase:"uninitialised",multiplier:N(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>f.fromValue(t).value;function mr(t){m.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function la(t){m.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function Rt(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 da=(t,a)=>{let r=a;while(r.highestHandValue<Qt)r=r.addDrawnCards([S(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}=ta({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=da(t.randomValuePool,t.dealerHand),r=Nt(t.playerHand,a);return H({...t,dealerHand:a,outcome:r})},b=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:da(t.randomValuePool,t.dealerHand),e=Nt(t.mainHand,r),n=Nt(t.splitHand,r),{multiplier:o,additionalBetAmount:i}=aa({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 Er extends bt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return ct.from(t.getRandomIntsWithReplacement({min:$t,max:zt,count:Ct}),Ct)}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 Ar({context:Br,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=_.withInitialDeal([e,n]),u=$.withInitialDeal({upCard:o,holeCard:i}),d={mainBetAmount:N(a.mainBetAmount),pairBonusAmount:N(a.pairBonusAmount),threeCardBonusAmount:N(a.threeCardBonusAmount)},s={pairBonus:N(a.pairBonusAmount).gt(0)?oa(a.pairBonusAmount,na(e,n)):null,threeCardBonus:N(a.threeCardBonusAmount).gt(0)?ca(a.threeCardBonusAmount,ia(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;la(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(F)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;la(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(Rt(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 _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:m.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(Rt(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 _t({...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(Rt(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(R)}}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 _t({...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;mr(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=_.withInitialDeal([i.value,u]),p=_.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(V)};return{state:{...r,phase:"playing-main-hand",multiplier:N(0),mainHand:s,splitHand:p,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(V)}}}})}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 q from"big.js";import{Guard as Aa}from"@betorigami/guard";var ua=0,sa=51,z=52,pa=52;var ho=()=>({minPicks:5,maxPicks:36}),yr=(t)=>t.length===new Set(t).size,fr=(t)=>{let a=q(1),r=q(z);for(let e=0;e<t;e+=1)a=a.mul(q(z-e).div(r));return a};class Or extends A{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a,edge:r}){Aa.against(a.pickCount<1||a.pickCount>z,`pickCount must be between 1 and ${z}`),Aa.againstNonInteger(a.pickCount,"pickCount must be an integer");let e=t.getRandomIntsWithReplacement({min:ua,max:sa,count:pa}),n=e.values.slice(0,a.pickCount),o=yr(n),i=fr(a.pickCount);return{isFinished:!0,payoutMultiplier:o?x.withMultiplier(q(1).div(i),r):q(0),outputs:{result:e.values,cards:n.map((u)=>new T(u).toDto())},randomValues:e}}}var Ba=0,wt=4294967295,ma;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(ma||={});var Sr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Hr={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:Sr},Dr=["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:Dr},Cr=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],xr={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:Cr},Pr=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],br={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:Pr},Ro=(t)=>{let a=Vt[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)},Vt={EASY:Hr,MEDIUM:hr,HARD:xr,EXPERT:br};import{Guard as It}from"@betorigami/guard";import jr from"big.js";class Tr extends A{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:Ba,max:wt,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:jr(Rr(o,e,n)),outputs:{result:r.values},randomValues:r}}}var Rr=(t,a,r)=>{let e=Vt[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 _r(e,a);return o.ringFour},_r=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(wt+1)*r),n=t.segments[e];return It.againstUndefined(n,`Segment index ${e} out of bounds`),t.multipliers.ringThree[n]};import Nr 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 wr;((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"})(wr||={});var Vr={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},Ir={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},Ur={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},Zr={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},kr={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},Gr=new P(new Map([[1,Vr],[2,Ir],[3,Ur],[4,Zr],[8,kr]])),Mr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Fr 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=Gr.getMultipliers(a),n=r.values,o=this.calculatePayoutMultiplier(e,n);return{isFinished:!0,payoutMultiplier:Nr(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=Mr[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 Ea from"big.js";var Jr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Jr||={});var ya=0,Ut=1e4,Yr=Ut-ya+1,$r=(t)=>{let a=t.direction==="ABOVE"?Ut-t.selectedValue:t.selectedValue;return new Ea(a).div(Yr).mul(100)},zr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class qr 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:ya,max:Ut}),n=$r(r);return{isFinished:!0,payoutMultiplier:zr(r,e.value)?x.withWinChance(a,n):new Ea(0),outputs:{result:e.values},randomValues:e}}}import vr from"big.js";import{Guard as lt}from"@betorigami/guard";var fa;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(fa||={});var Xr=[1,2,3,4,5,6,7,8,9,10],Oa=(t)=>{return Xr.includes(t)};var Qr={[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]}},gr={[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]}},Wr={[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]}},Lr={[1]:{CLASSIC:[0,3.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1000]}},Kr={[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]}},Sa=new P(new Map([[1,Qr],[2,gr],[3,Wr],[4,Lr],[8,Kr]]));class te extends A{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){lt.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),lt.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let p of r.selectedNumbers)lt.againstNonInteger(p,()=>l.createValidationError("Only integers can be selected")),lt.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(!Oa(o))throw new Error(`Invalid tile count: ${o}`);let d=Sa.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 vr(d),outputs:{result:e.values},randomValues:e}}}import I from"big.js";var Ha=(t,a)=>{return t.gt(a)?t:a};var Da=(t,a)=>{return t.lt(a)?t:a};class ae 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 I(16777216),i=new I(1),c=new I(1e6),u=e.value,d=new I(u-1).div(n),s=(100-a)/100,p=o.div(d.mul(o).plus(1)).mul(s),E=Ha(i,Da(p,c));return{isFinished:!0,payoutMultiplier:E.gte(r.targetMultiplier)?new I(r.targetMultiplier):new I(0),outputs:{randomMultiplier:E,result:e.values},randomValues:e}}}import dt from"big.js";var Zt=(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 re 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 dt(Zt(25-r.minesCount,r.selectedTiles.length)).div(new dt(Zt(25,r.selectedTiles.length))),E=r.hasCashedOut&&!c?new dt(d).div(s):new dt(0);return{isFinished:u,payoutMultiplier:E,outputs:{result:i.values},randomValues:i}}}import{Big as le}from"big.js";var ha;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(ha||={});var Ji=[8,9,10,11,12,13,14,15,16],ee={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]}},ne={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]}},oe={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]}},ie={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]}},ce={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 P(new Map([[1,ee],[2,ne],[3,oe],[4,ie],[8,ce]]));class de 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=Ca.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:le(s),outputs:{result:c.values},randomValues:c}}}import{Big as pt}from"big.js";var kt=[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],xa=[37,...kt],Pa=[[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]],ba=[[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]],ja=[[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]],Ta=[[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]],Ra=[[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]],_a=[[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]],Na=[0,1,2,3,37],wa=[[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]],Va=[[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 Gt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Gt||={});var X=2.7,Q=5.3;var ut=(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)&&g(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)&&se(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&pe(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Ae(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.")},g=(t)=>{return kt.includes(t)},ue=(t)=>{if(t.length!==2)return!1;if(!t.every(g))return!1;return Pa.some(([a,r])=>a===t[0]&&r===t[1])},se=(t)=>{if(t.length!==3)return!1;if(!t.every(g))return!1;return ja.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},pe=(t)=>{if(t.length!==4)return!1;if(!t.every(g))return!1;return Ra.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},Ae=(t)=>{if(t.length!==6)return!1;if(!t.every(g))return!1;return wa.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 st=(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)&&W(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Be(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&me(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Ee(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)&&ye(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.")},W=(t)=>{return xa.includes(t)};function Be(t){if(t.length!==2)return!1;if(!t.every(W))return!1;return ba.some(([a,r])=>a===t[0]&&r===t[1])}var me=(t)=>{if(t.length!==3)return!1;if(!t.every(W))return!1;return Ta.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},Ee=(t)=>{if(t.length!==4)return!1;if(!t.every(W))return!1;return _a.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},ye=(t)=>{if(t.length!==6)return!1;if(!t.every(W))return!1;return Va.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 fe=(t,a)=>{let r=a===X&&t.type==="EUROPEAN",e=a===Q&&t.type==="AMERICAN";if(!r&&!e)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Ia=(t,a)=>{if(fe(t,a),t.type==="EUROPEAN")ut(t.inputs);else st(t.inputs)};var Oe={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Se=[3,6,9,12,15,18,21,24,27,30,33,36],He=[2,5,8,11,14,17,20,23,26,29,32,35],De=[1,4,7,10,13,16,19,22,25,28,31,34],he=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Ce=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Mt 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 pt(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 pt(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 he.includes(a)&&r.color==="RED"||Ce.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 Se.includes(a)&&r.column==="TOP"||He.includes(a)&&r.column==="MIDDLE"||De.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 pt(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=Oe[r];return a.plus(e.mul(o||0))},new pt(0))}}class Ua extends Mt{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[X]}validateInputs(t){ut(t)}}class Za extends Mt{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[Q]}validateInputs(t){st(t)}isWinningBasketBet(t,a){return Na.some((r)=>r===a)}}class ka extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Ua,this.americanGame=new Za}get supportedEdgeConfigurations(){return[X,Q]}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(Ia(a,t.edge),a.type==="EUROPEAN"){let o=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:i}=o.outputs;return{...o,outputs:{type:"european",betOutcomes:i,result:o.outputs.result}}}let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:n,result:e.outputs.result}}}}var fc=(t)=>{return new ka().getBetAmount(t)};import{Big as Re}from"big.js";var L;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(L||={});var K;((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"})(K||={});var xe={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}}},Pe={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}}},be={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}}},je={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}}},Ga=new P(new Map([[1,xe],[2,Pe],[3,be],[4,je],[8,Te]]));var Ma={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 _e extends A{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(K).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(L).includes(a.riskLevel))throw new Error("Invalid risk level");let n=Ga.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=Ma[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 Re(s),outputs:{result:u.values},randomValues:u}}}export{Ia as validateRouletteGameInputs,Xe as validateAdvancedDiceInputs,Qr as rtp99Multipliers,gr as rtp98Multipliers,Wr as rtp97Multipliers,Lr as rtp96Multipliers,Kr as rtp92Multipliers,Ca as plinkoMultipliers,Zt as nCr,Sa as kenoMultipliers,Oa as isTileCount,zr as hasDiceWon,yr as hasBlitzWon,Ro as getMaxMultiplierForDifficulty,ho as getBlitzDefaults,Gr as diamondsMultipliers,fc as calculateRouletteBetAmount,$r as calculateDiceWinChance,fr as calculateBlitzWinChance,rr as calculateBaccaratBetAmount,Yt as calculateAdvancedDiceWinChance,Da as bigMin,Ha as bigMax,Qa as advancedDiceIsWithinBoundsInclusive,Bt as advancedDiceIsWithinBoundsExclusive,ga as advancedDiceGetInclusiveBoundsRange,mt as advancedDiceGetExclusiveBoundsRange,K as WheelSegments,L as WheelRiskLevel,_e as Wheel,or as WIN_MULTIPLIER,on as VALID_SUITS,cn as VALID_RANKS,ja as VALID_EUROPEAN_STREETS,kt as VALID_EUROPEAN_STRAIGHTS,Pa as VALID_EUROPEAN_SPLITS,wa as VALID_EUROPEAN_DOUBLE_STREETS,Ra as VALID_EUROPEAN_CORNERS,Ta as VALID_AMERICAN_STREETS,xa as VALID_AMERICAN_STRAIGHTS,ba as VALID_AMERICAN_SPLITS,Va as VALID_AMERICAN_DOUBLE_STREETS,_a as VALID_AMERICAN_CORNERS,Dt as ThreeCardBonusType,Se as TOP_COLUMN,Xr as TILE_COUNTS,Lt as THREE_CARD_BONUS_PAYOUTS,A as SingleActionGame,V as SPLIT_BET_SIZE_FACTOR,Gt as RouletteType,ka as Roulette,Wa as RollType,ct as RandomValuePool,he as RED_NUMBERS,at as RANDOM_MIN_VALUE,rt as RANDOM_MAX_VALUE,ha as PlinkoRiskLevel,de as Plinko,U as Parity,Ht as PairBonusType,ir as PUSH_MULTIPLIER,Ji as PLINKO_ROW_COUNTS,Oe as PAYOUT_MULTIPLIERS,Wt as PAIR_BONUS_PAYOUTS,O as OrigamiGame,x as MultiplierCalculator,bt as MultiActionGame,re as Mines,Ya as MIN_WIN_CHANCE,He as MIDDLE_COLUMN,$a as MAX_WIN_CHANCE,Ct as MAX_CARDS_PER_ROUND,ae as Limbo,cr as LOSE_MULTIPLIER,fa as KenoRiskLevel,te as Keno,Ot as InsuranceOutcome,xt as INSURANCE_WIN_PAYOUT,F as INSURANCE_BET_SIZE_FACTOR,An as INSURANCE_BET_MULTIPLIER,k as Half,Fa as GameErrorCode,l as GameError,gt as FACE_CARD_VALUE,Ua as EuropeanRoulette,X as EUROPEAN_HOUSE_EDGE,Ft as EFFECTIVE_RANGE,M as Dozen,Jr as DiceDirection,qr as Dice,wr as DiamondsResultType,Fr as Diamonds,Tr as Darts,R as DOUBLE_DOWN_BET_SIZE_FACTOR,ya as DICE_MIN_ROLL,Ut as DICE_MAX_ROLL,Yr as DICE_EFFECTIVE_RANGE,Qt as DEALER_STAND_VALUE,Ba as DARTS_MIN_VALUE,wt as DARTS_MAX_VALUE,ma as DARTS_DIFFICULTY_LEVEL,Vt as DARTS_BOARD_CONFIGS,G as Column,Z as Color,Bn as CARDS_PER_SUIT,Or as Blitz,ft as BlackjackOutcome,St as BlackjackActionType,Er as Blackjack,va as BaccaratOutcome,tr as BaccaratBetType,er as Baccarat,ht as BUST_VALUE,De as BOTTOM_COLUMN,pa as BLITZ_RANDOM_NUMBER_COUNT,ua as BLITZ_MIN_CARD_RANGE,sa as BLITZ_MAX_CARD_RANGE,z as BLITZ_CARD_COUNT,Ce as BLACK_NUMBERS,h as BLACKJACK_VALUE,nr as BLACKJACK_MULTIPLIER,ot as BASE_PAYOUT_MULTIPLIERS,Za as AmericanRoulette,La as AdvancedDice,Q as AMERICAN_HOUSE_EDGE,Na as AMERICAN_BASKET,Pt as ACE_SOFT_BONUS};
1
+ var Ja;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(Ja||={});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;((p)=>{p.DICE="DICE";p.MINES="MINES";p.KENO="KENO";p.LIMBO="LIMBO";p.ADVANCED_DICE="ADVANCED_DICE";p.BACCARAT="BACCARAT";p.DIAMONDS="DIAMONDS";p.PLINKO="PLINKO";p.ROULETTE="ROULETTE";p.WHEEL="WHEEL";p.BLACKJACK="BLACKJACK";p.BLITZ="BLITZ";p.DARTS="DARTS"})(O||={});import{Guard as Ya}from"@betorigami/guard";class B{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Ya.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}import{Big as Jt}from"big.js";import Bt from"big.js";class x{static withMultiplier(t,a){return new Bt(t).times(new Bt(100-a).div(100))}static withWinChance(t,a){return Bt(100-t).div(a)}}var at=0,rt=1e4,Ft=rt-at+1,$a=0.01,za=98,Xa=(t)=>{if(t<at)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${at}`)},Qa=(t)=>{if(t>rt)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${rt}`)},tt=(t)=>{if(Xa(t.lower),Qa(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},qa=(t,a)=>{let[r,n]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>n.lower)throw l.createValidationError("Bounds must not overlap")},Wa=(t,a)=>a>=t.lower&&a<=t.upper,La=(t)=>t.upper-t.lower+1,pt=(t,a)=>a>t.lower&&a<t.upper,Et=(t)=>t.upper-t.lower-1,ga;((n)=>{n.ROLL_BETWEEN="ROLL_BETWEEN";n.ROLL_OUTSIDE="ROLL_OUTSIDE";n.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(ga||={});var Yt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return tt(t.bounds),Et(t.bounds);case"ROLL_OUTSIDE":return tt(t.bounds),Ft-La(t.bounds);case"ROLL_BETWEEN_TWO":return tt(t.firstBounds),tt(t.secondBounds),qa(t.firstBounds,t.secondBounds),Et(t.firstBounds)+Et(t.secondBounds)}})(),n=Jt(r).div(Ft).mul(100);if(n.lt($a))throw l.createValidationError("Win chance too low");if(n.gt(za))throw l.createValidationError("Win chance too high");return n},qn=(t)=>{Yt(t)};class Ka extends B{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=Yt(r),o=t.getRandomInt({min:at,max:rt}),e=o.value,i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return pt(r.bounds,e);case"ROLL_OUTSIDE":return!Wa(r.bounds,e);case"ROLL_BETWEEN_TWO":return pt(r.firstBounds,e)||pt(r.secondBounds,e)}})()?x.withWinChance(a,n):new Jt(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:o.values},randomValues:o}}}import w from"big.js";import{Guard as mt}from"@betorigami/guard";var $t=0,zt=51,nt=Array.from({length:52},(t,a)=>a),Xt=["Spades","Hearts","Diamonds","Clubs"],ot=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Qt=["Jack","Queen","King"],yt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class T{value;constructor(t){let a=nt[t];mt.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Xt[t];return mt.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=ot[t];return mt.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}var co=["Clubs","Diamonds","Hearts","Spades"],io=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],va={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},tr;((n)=>{n.PLAYER_WIN="PLAYER_WIN";n.TIE="TIE";n.BANKER_WIN="BANKER_WIN"})(tr||={});var ar;((n)=>{n.PLAYER="PLAYER";n.TIE="TIE";n.BANKER="BANKER"})(ar||={});var rr={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},qt=(t)=>{return new w(0).add(t.bets.reduce((r,n)=>r.add(n.amount),new w(0)))};class nr extends B{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}getBetAmount(t){return qt(t)}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),n=r.values,o=n.slice(0,3),e=n.slice(3,6),c=[],i=0;for(let m of o.slice(0,2)){let D=this.mapRandomValueToCard(m),v=this.mapRandomValueToCardValue(m);c.push(D),i=(i+v)%10}let u=[],d=0;for(let m of e.slice(0,2)){let D=this.mapRandomValueToCard(m),v=this.mapRandomValueToCardValue(m);u.push(D),d=(d+v)%10}if(!this.isNaturalWin(i,d)){let m=this.shouldDrawThirdPlayerCard(i),D=null;if(m)D=this.mapRandomValueToCardValue(o[2]),c.push(this.mapRandomValueToCard(o[2])),i=(i+D)%10;if(this.shouldDrawThirdBankerCard(d,D))u.push(this.mapRandomValueToCard(e[2])),d=(d+this.mapRandomValueToCardValue(e[2]))%10}let s;if(i===d)s="TIE";else s=i>d?"PLAYER_WIN":"BANKER_WIN";let A=qt(a),{betType:E,multiplier:p}=rr[s],b=new w(0);if(b=b.add(a.bets.filter((m)=>m.type===E).reduce((m,D)=>m.add(D.amount.mul(p)),new w(0))),s==="TIE")b=b.add(a.bets.filter((m)=>m.type==="PLAYER"||m.type==="BANKER").reduce((m,D)=>m.add(D.amount),new w(0)));return{isFinished:!0,payoutMultiplier:A.gt(0)?b.div(A):new w(0),outputs:{playerCards:c,playerHandValue:i,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=new T(t);return{suit:a.suit,rank:va[a.rank]}}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 ft;((o)=>{o.WIN="WIN";o.LOSE="LOSE";o.PUSH="PUSH";o.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(ft||={});var Ot;((r)=>{r.WON="WON";r.LOST="LOST"})(Ot||={});var St;((i)=>{i.START="START";i.HIT="BLACKJACK_HIT";i.STAND="BLACKJACK_STAND";i.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";i.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";i.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";i.SPLIT="BLACKJACK_SPLIT"})(St||={});var Ht;((o)=>{o.EXACT_PAIR="EXACT_PAIR";o.COLORED_PAIR="COLORED_PAIR";o.MIXED_PAIR="MIXED_PAIR";o.LOSS="LOSS"})(Ht||={});var Dt;((c)=>{c.SUITED_TRIPS="SUITED_TRIPS";c.STRAIGHT_FLUSH="STRAIGHT_FLUSH";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.STRAIGHT="STRAIGHT";c.FLUSH="FLUSH";c.LOSS="LOSS"})(Dt||={});var or=2.5,er=2,cr=1,ir=0,Wt=17,ht=21,h=21,Ct=63,po=1.5,F=0.5,xt=1.5,_=1,V=1,Eo=13,Pt=10,Lt=10,et={PLAYER_BLACKJACK:or,WIN:er,PUSH:cr,LOSE:ir},gt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Kt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};import R from"big.js";import{Guard as y}from"@betorigami/guard";import{createStore as Br}from"@xstate/store";import{Guard as lr}from"@betorigami/guard";class f extends T{get numericRank(){if(Qt.includes(this.rank))return Lt;return ot.indexOf(this.rank)+1}static fromValue(t){return lr.against(!nt.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,n)=>r+n.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+Pt<=ht)this.softHandValue=this.hardHandValue+Pt}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===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 N extends Y{static withInitialDeal(t){return new N(t)}addDrawnCards(t){return new N([...this.rawValues,...t])}}import{Guard as ct}from"@betorigami/guard";class it{source;index=0;constructor(t){this.source=t}static from(t,a){return ct.against(a<=0,`Count must be positive, got ${a}`),ct.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new it(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return ct.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){ct.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 vt}from"@betorigami/guard";import dr from"fast-deep-equal";class jt{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let n=this.createGameStore(),o=this.generateRandomValues(t),e=o.toMultipleRandomValues();for(let u of r)n.send({...u.playerArgument,randomValuePool:o});let c=r[r.length-1];if(c)vt.against(!dr(c.state,this.toExternalState(n.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");n.send({...a,randomValuePool:o});let i=n.getSnapshot().context;return{playerArgument:i.playerArgument,state:this.toExternalState(i.state),config:i.config,additionalBetAmount:i.additionalBetAmount,proof:{proofHash:e.proofHash,proofString:e.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);vt.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 bt}from"@betorigami/guard";var ta=(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)},aa=(t)=>{let a=t.betAmounts.mainBetAmount,n=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(_):C(0),o=t.insuranceOutcome!==void 0?a.mul(F):C(0),e=a.plus(n).mul(et[t.outcome]),c=t.insuranceOutcome==="WON"?a.mul(xt):C(0),i=ta(t.sideBetResults),u=e.plus(c).plus(i),d=a.plus(o).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);bt.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);bt.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let A;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":A=n;break;case"BLACKJACK_BUY_INSURANCE":A=o;break;case"BLACKJACK_SPLIT":A=a.mul(V);break}return{multiplier:s,additionalBetAmount:A}},ra=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(_):C(0),n=t.splitHandDoubledDown?a.mul(_):C(0),o=t.insuranceOutcome!==void 0?a.mul(F):C(0),e=a.plus(r).mul(et[t.mainOutcome]),c=a.plus(n).mul(et[t.splitOutcome]),i=t.insuranceOutcome==="WON"?a.mul(xt):C(0),u=ta(t.sideBetResults),d=e.plus(c).plus(i).plus(u),s=a.plus(a).plus(o).plus(r).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);bt.against(s.eq(0),"Total bet amount cannot be zero");let A=d.div(s),E;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":E=a.mul(_);break;case"BLACKJACK_SPLIT":E=a.mul(V);break}return{multiplier:A,additionalBetAmount:E}};import{Guard as ur}from"@betorigami/guard";var Tt=(t)=>t.every((a)=>a===t[0]),na=(t)=>{let a=[...t].sort((r,n)=>r-n);return a.every((r,n)=>{let o=a[n-1];if(n===0)return!0;return ur.againstUndefined(o,"Previous value cannot be undefined"),r===o+1})},oa={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},sr={...oa,Ace:14},Ar=(t)=>na(t.map((a)=>oa[a]))||na(t.map((a)=>sr[a])),ea=(t,a)=>{let r=f.fromValue(t),n=f.fromValue(a);if(r.rank!==n.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(yt[r.suit]===yt[n.suit])return"COLORED_PAIR";return"MIXED_PAIR"},ca=(t,a)=>({betAmount:t,result:a,payoutMultiplier:gt[a]}),ia=(t,a,r)=>{let n=f.fromValue(t),o=f.fromValue(a),e=f.fromValue(r),c=[n.rank,o.rank,e.rank],i=Tt([n.suit,o.suit,e.suit]),u=Tt(c),d=Ar(c);if(Tt([t,a,r]))return"SUITED_TRIPS";if(i&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(i)return"FLUSH";return"LOSS"},la=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Kt[a]});var pr={state:{isFinished:!1,phase:"uninitialised",multiplier:R(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>f.fromValue(t).value;function Er(t){y.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function da(t){y.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function _t(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 ua=(t,a)=>{let r=a;while(r.highestHandValue<Wt)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,n=a.highestHandValue;if(r>n)return"WIN";if(r<n)return"LOSE";return"PUSH"},H=(t)=>{let{multiplier:a,additionalBetAmount:r}=aa({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}},Nt=(t)=>{let a=ua(t.randomValuePool,t.dealerHand),r=Rt(t.playerHand,a);return H({...t,dealerHand:a,outcome:r})},j=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:ua(t.randomValuePool,t.dealerHand),n=Rt(t.mainHand,r),o=Rt(t.splitHand,r),{multiplier:e,additionalBetAmount:c}=ra({hasSplit:!0,mainOutcome:n,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:n,splitOutcome:o,multiplier:e,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:c}};class yr extends jt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return it.from(t.getRandomIntsWithReplacement({min:$t,max:zt,count:Ct}),Ct)}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 Br({context:pr,on:{START:(t,a)=>{let{state:r}=t;y.against(r.phase!=="uninitialised","START action requires a fresh game");let n=S(a.randomValuePool.takeOne()),o=S(a.randomValuePool.takeOne()),e=S(a.randomValuePool.takeOne()),c=S(a.randomValuePool.takeOne()),i=N.withInitialDeal([n,o]),u=$.withInitialDeal({upCard:e,holeCard:c}),d={mainBetAmount:R(a.mainBetAmount),pairBonusAmount:R(a.pairBonusAmount),threeCardBonusAmount:R(a.threeCardBonusAmount)},s={pairBonus:R(a.pairBonusAmount).gt(0)?ca(a.pairBonusAmount,ea(n,o)):null,threeCardBonus:R(a.threeCardBonusAmount).gt(0)?la(a.threeCardBonusAmount,ia(n,o,e)):null},A={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:i,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:A};let E={playerHand:i,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:A,betAmounts:d,sideBetResults:s};if(i.isBlackjack&&u.isBlackjack)return H({...E,outcome:"PUSH"});if(i.isBlackjack)return H({...E,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return H({...E,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:i,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:A}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;da(r);let{playerHand:n,dealerHand:o,betAmounts:e,sideBetResults:c}=r,i={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:e,sideBetResults:c};if(n.isBlackjack&&o.isBlackjack)return H({...i,outcome:"PUSH",insuranceOutcome:"WON"});if(n.isBlackjack)return H({...i,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(o.isBlackjack)return H({...i,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:e.mainBetAmount.mul(F)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;da(r);let{playerHand:n,dealerHand:o,betAmounts:e,sideBetResults:c}=r,i={playerHand:n,dealerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:e,sideBetResults:c};if(n.isBlackjack&&o.isBlackjack)return H({...i,outcome:"PUSH"});if(n.isBlackjack)return H({...i,outcome:"PLAYER_BLACKJACK"});if(o.isBlackjack)return H({...i,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(_t(r),r.phase){case"playing-main-hand":{let n=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted||n.highestHandValue===h){if(r.splitHand.highestHandValue===h)return j({...r,mainHand:n,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:n,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:n},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let n=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted||n.highestHandValue===h)return j({...r,splitHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:n},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let n=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted)return H({...r,playerHand:n,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(n.highestHandValue===h)return Nt({...r,playerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:n},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:y.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(_t(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 Nt({...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(_t(r),r.phase){case"playing-main-hand":{y.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let n=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]),{betAmounts:o}=r;if(r.splitHand.highestHandValue===h)return j({...r,mainHand:n,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:n,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:o.mainBetAmount.mul(_)}}case"playing-split-hand":{y.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let n=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);return j({...r,splitHand:n,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 n=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(n.isBusted)return H({...r,playerHand:n,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return Nt({...r,playerHand:n,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;Er(r);let{playerHand:n,betAmounts:o,sideBetResults:e}=r;y.against(n.cards.length!==2,"Split is only allowed with exactly 2 cards");let c=n.cards[0],i=n.cards[1];y.againstUndefined(c,"First card is missing"),y.againstUndefined(i,"Second card is missing"),y.against(c.rank!==i.rank,"Split requires two cards of the same rank");let u=S(a.randomValuePool.takeOne()),d=S(a.randomValuePool.takeOne()),s=N.withInitialDeal([c.value,u]),A=N.withInitialDeal([i.value,d]);if(c.rank==="Ace")return j({...r,mainHand:s,splitHand:A,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let p=s.highestHandValue===h,b=A.highestHandValue===h;if(p&&b)return j({mainHand:s,splitHand:A,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:o,sideBetResults:e});if(p)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:A,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(V)};return{state:{...r,phase:"playing-main-hand",multiplier:R(0),mainHand:s,splitHand:A,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:o.mainBetAmount.mul(V)}}}})}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],n=t.playerHand.cards[1];if(y.againstUndefined(r,"First player card is missing"),y.againstUndefined(n,"Second player card is missing"),r.rank===n.rank)a.push("BLACKJACK_SPLIT")}return a}default:y.againstNever(t,"Invalid phase for getting valid actions")}}}import X from"big.js";import{Guard as pa}from"@betorigami/guard";var sa=0,Aa=51,z=52,Ba=52;var he=()=>({minPicks:5,maxPicks:36}),mr=(t)=>t.length===new Set(t).size,fr=(t)=>{let a=X(1),r=X(z);for(let n=0;n<t;n+=1)a=a.mul(X(z-n).div(r));return a};class Or extends B{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){pa.against(a.pickCount<1||a.pickCount>z,`pickCount must be between 1 and ${z}`),pa.againstNonInteger(a.pickCount,"pickCount must be an integer");let n=t.getRandomIntsWithReplacement({min:sa,max:Aa,count:Ba}),o=n.values.slice(0,a.pickCount),e=mr(o),c=fr(a.pickCount),i=e?x.withMultiplier(X(1).div(c),r):X(0);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:n.values,cards:o.map((u)=>new T(u).toDto())},randomValues:n}}}var Ea=0,wt=4294967295,ya;((o)=>{o.EASY="EASY";o.MEDIUM="MEDIUM";o.HARD="HARD";o.EXPERT="EXPERT"})(ya||={});var Sr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Hr={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:Sr},Dr=["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:Dr},Cr=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],xr={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:Cr},Pr=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],jr={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:Pr},_e=(t)=>{let a=Vt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((n,o)=>o>n?o:n)},Vt={EASY:Hr,MEDIUM:hr,HARD:xr,EXPERT:jr};import{Guard as Ut}from"@betorigami/guard";import br from"big.js";class Tr extends B{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:Ea,max:wt,count:2}),n=r.values[0],o=r.values[1];Ut.againstUndefined(n,"Random number generator returned no value for clockWiseRotation"),Ut.againstUndefined(o,"Random number generator returned no value for distanceFromCentre");let e=a.difficultyLevel,c=br(_r(e,n,o));return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}}var _r=(t,a,r)=>{let n=Vt[t],{distanceBoundaries:o,multipliers:e}=n;if(r<o.bullseye)return e.bullseye;if(r<o.ringOne)return e.ringOne;if(r<o.ringTwo)return e.ringTwo;if(r<o.ringThree)return Nr(n,a);return e.ringFour},Nr=(t,a)=>{let r=t.segments.length,n=Math.floor(a/(wt+1)*r),o=t.segments[n];return Ut.againstUndefined(o,`Segment index ${n} out of bounds`),t.multipliers.ringThree[o]};import Rr 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 wr;((c)=>{c.PAIR="PAIR";c.TWO_PAIR="TWO_PAIR";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.FULL_HOUSE="FULL_HOUSE";c.FOUR_OF_A_KIND="FOUR_OF_A_KIND";c.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(wr||={});var Vr={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},Ur={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},Zr={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},kr={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},Ir={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},Mr=new P(new Map([[1,Vr],[2,Ur],[3,Zr],[4,kr],[8,Ir]])),Gr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Fr extends B{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),o=Mr.getMultipliers(a),e=n.values,c=Rr(this.calculatePayoutMultiplier(o,e));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:n.values},randomValues:n}}calculatePayoutMultiplier(t,a){let r=new Map;for(let e of a){let c=r.get(e)||0;r.set(e,c+1)}let n=[...r.values()].filter((e)=>e>1),o=this.classifyResult(n);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 n=Gr[a];if(n===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return n}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}import ma from"big.js";var Jr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Jr||={});var fa=0,Zt=1e4,Yr=Zt-fa+1,$r=(t)=>{let a=t.direction==="ABOVE"?Zt-t.selectedValue:t.selectedValue;return new ma(a).div(Yr).mul(100)},zr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class Xr extends B{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:fa,max:Zt}),o=$r(r),c=zr(r,n.value)?x.withWinChance(a,o):new ma(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:n.values},randomValues:n}}}import vr from"big.js";import{Guard as lt}from"@betorigami/guard";var Oa;((o)=>{o.CLASSIC="CLASSIC";o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(Oa||={});var Qr=[1,2,3,4,5,6,7,8,9,10],Sa=(t)=>{return Qr.includes(t)};var qr={[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]}},Wr={[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]}},Lr={[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.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1000]}},Kr={[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]}},Ha=new P(new Map([[1,qr],[2,Wr],[3,Lr],[4,gr],[8,Kr]]));class tn extends B{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){lt.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),lt.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let A of r.selectedNumbers)lt.againstNonInteger(A,()=>l.createValidationError("Only integers can be selected")),lt.against(A<0||A>39,()=>l.createValidationError("Invalid number selected"));let n=t.getUniqueRandomInts({min:0,max:39,count:10}),o=r.selectedNumbers.filter((A)=>n.values.includes(A)),e=r.selectedNumbers.length;if(!Sa(e))throw new Error(`Invalid tile count: ${e}`);let d=Ha.getMultipliers(a)[e][r.riskLevel][o.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${o.length}`);let s=new vr(d);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:n.values},randomValues:n}}}import U from"big.js";var Da=(t,a)=>{return t.gt(a)?t:a};var ha=(t,a)=>{return t.lt(a)?t:a};class an extends B{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:1,max:4294967295}),o=n.max,e=new U(16777216),c=new U(1),i=new U(1e6),u=n.value,d=new U(u-1).div(o),s=(100-a)/100,A=e.div(d.mul(e).plus(1)).mul(s),E=Da(c,ha(A,i)),p=E.gte(r.targetMultiplier)?new U(r.targetMultiplier):new U(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:E,result:n.values},randomValues:n}}}import dt from"big.js";var kt=(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 n=1;n<=a;n++)r=r*(t-n+1)/n;return r};class rn extends B{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}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 c=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),i=c.values.some((p)=>r.selectedTiles.includes(p)),u=r.hasCashedOut||i,d=(100-a)/100,s=new dt(kt(25-r.minesCount,r.selectedTiles.length)).div(new dt(kt(25,r.selectedTiles.length))),E=r.hasCashedOut&&!i?new dt(d).div(s):new dt(0);return{isFinished:u,payout:{legs:[{amount:r.betAmount.mul(E)}]},payoutMultiplier:E,outputs:{result:c.values},randomValues:c}}}import{Big as dn}from"big.js";var Ca;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(Ca||={});var Jc=[8,9,10,11,12,13,14,15,16],nn={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]}},on={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]}},en={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]}},cn={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]}},ln={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]}},xa=new P(new Map([[1,nn],[2,on],[3,en],[4,cn],[8,ln]]));class un extends B{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}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 n=a.numberOfRows,c=xa.getMultipliers(r)[a.riskLevel][n],i=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=i.values.reduce((E,p)=>E+p,0),s=c[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);let A=dn(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:i.values},randomValues:i}}}import{Big as At}from"big.js";var It=[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],Pa=[37,...It],ja=[[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]],ba=[[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]],Ta=[[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]],_a=[[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]],Na=[[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]],wa=[0,1,2,3,37],Va=[[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]],Ua=[[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]],Z;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(Z||={});var k;((r)=>{r.RED="RED";r.BLACK="BLACK"})(k||={});var I;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(I||={});var M;((n)=>{n.TOP="TOP";n.MIDDLE="MIDDLE";n.BOTTOM="BOTTOM"})(M||={});var G;((n)=>{n.FIRST="FIRST";n.SECOND="SECOND";n.THIRD="THIRD"})(G||={});var Mt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Mt||={});var Q=2.7,q=5.3;var ut=(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)&&W(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&sn(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&An(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Bn(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&pn(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(M).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.")},W=(t)=>{return It.includes(t)},sn=(t)=>{if(t.length!==2)return!1;if(!t.every(W))return!1;return ja.some(([a,r])=>a===t[0]&&r===t[1])},An=(t)=>{if(t.length!==3)return!1;if(!t.every(W))return!1;return Ta.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},Bn=(t)=>{if(t.length!==4)return!1;if(!t.every(W))return!1;return Na.some(([a,r,n,o])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3])},pn=(t)=>{if(t.length!==6)return!1;if(!t.every(W))return!1;return Va.some(([a,r,n,o,e,c])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3]&&e===t[4]&&c===t[5])};var st=(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)&&L(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&En(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&yn(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&mn(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)&&fn(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(M).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.")},L=(t)=>{return Pa.includes(t)};function En(t){if(t.length!==2)return!1;if(!t.every(L))return!1;return ba.some(([a,r])=>a===t[0]&&r===t[1])}var yn=(t)=>{if(t.length!==3)return!1;if(!t.every(L))return!1;return _a.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},mn=(t)=>{if(t.length!==4)return!1;if(!t.every(L))return!1;return Ra.some(([a,r,n,o])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3])},fn=(t)=>{if(t.length!==6)return!1;if(!t.every(L))return!1;return Ua.some(([a,r,n,o,e,c])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3]&&e===t[4]&&c===t[5])};var On=(t,a)=>{let r=a===Q&&t.type==="EUROPEAN",n=a===q&&t.type==="AMERICAN";if(!r&&!n)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Za=(t,a)=>{if(On(t,a),t.type==="EUROPEAN")ut(t.inputs);else st(t.inputs)};var Sn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Hn=[3,6,9,12,15,18,21,24,27,30,33,36],Dn=[2,5,8,11,14,17,20,23,26,29,32,35],hn=[1,4,7,10,13,16,19,22,25,28,31,34],Cn=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],xn=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Gt extends B{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),n=r.value,o=this.determineBetOutcomes(a,n),{payoutMultiplier:e}=this.getPayoutDetails(a,n);return{outputs:{betOutcomes:o,result:r.values},payoutMultiplier:e,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),n=this.getBetTotals(t),o=this.getBetTotals(r.winningBets),e=this.calculateTotalBetAmount(n),c=this.calculateTotalPayout(o);return{payoutMultiplier:e.gt(0)?c.div(e):new At(0),payoutAmount:c}}determineBetOutcomes(t,a){let r={},n={};for(let o of Object.keys(t)){let e=t[o],c=this.betPredicates[o],{winning:i,losing:u}=this.partitionBets(e,c,a);r[o]=i,n[o]=u}return{winningBets:r,losingBets:n}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new At(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 Cn.includes(a)&&r.color==="RED"||xn.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 Hn.includes(a)&&r.column==="TOP"||Dn.includes(a)&&r.column==="MIDDLE"||hn.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 n=a%2===0?"EVEN":"ODD";return r.parity===n}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 At(0))}partitionBets(t,a,r){return{winning:t.filter((n)=>a(n,r)),losing:t.filter((n)=>!a(n,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,n])=>{let e=Sn[r];return a.plus(n.mul(e||0))},new At(0))}}class ka 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[Q]}validateInputs(t){ut(t)}}class Ia 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[q]}validateInputs(t){st(t)}isWinningBasketBet(t,a){return wa.some((r)=>r===a)}}class Ma extends B{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new ka,this.americanGame=new Ia}get supportedEdgeConfigurations(){return[Q,q]}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(Za(a,t.edge),a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}let n=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=n.outputs;return{...n,outputs:{type:"american",betOutcomes:o,result:n.outputs.result}}}}var fi=(t)=>{return new Ma().getBetAmount(t)};import{Big as Nn}from"big.js";var g;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(g||={});var K;((e)=>{e[e.TEN=10]="TEN";e[e.TWENTY=20]="TWENTY";e[e.THIRTY=30]="THIRTY";e[e.FORTY=40]="FORTY";e[e.FIFTY=50]="FIFTY"})(K||={});var Pn={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}}},jn={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}}},bn={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}}},Tn={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}}},_n={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}}},Ga=new P(new Map([[1,Pn],[2,jn],[3,bn],[4,Tn],[8,_n]]));var Fa={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 Rn extends B{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(K).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(g).includes(a.riskLevel))throw new Error("Invalid risk level");let o=Ga.getMultipliers(r)[a.riskLevel];if(o===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let e=o[a.segments];if(e===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let c=Fa[a.riskLevel];if(c===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let i=c[a.segments];if(i===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:i.length-1}),d=i[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=e[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);let A=new Nn(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:u.values},randomValues:u}}}export{Za as validateRouletteGameInputs,qn as validateAdvancedDiceInputs,qr as rtp99Multipliers,Wr as rtp98Multipliers,Lr as rtp97Multipliers,gr as rtp96Multipliers,Kr as rtp92Multipliers,xa as plinkoMultipliers,kt as nCr,Ha as kenoMultipliers,Sa as isTileCount,zr as hasDiceWon,mr as hasBlitzWon,_e as getMaxMultiplierForDifficulty,he as getBlitzDefaults,Mr as diamondsMultipliers,fi as calculateRouletteBetAmount,$r as calculateDiceWinChance,fr as calculateBlitzWinChance,qt as calculateBaccaratBetAmount,Yt as calculateAdvancedDiceWinChance,ha as bigMin,Da as bigMax,Wa as advancedDiceIsWithinBoundsInclusive,pt as advancedDiceIsWithinBoundsExclusive,La as advancedDiceGetInclusiveBoundsRange,Et as advancedDiceGetExclusiveBoundsRange,K as WheelSegments,g as WheelRiskLevel,Rn as Wheel,er as WIN_MULTIPLIER,co as VALID_SUITS,io as VALID_RANKS,Ta as VALID_EUROPEAN_STREETS,It as VALID_EUROPEAN_STRAIGHTS,ja as VALID_EUROPEAN_SPLITS,Va as VALID_EUROPEAN_DOUBLE_STREETS,Na as VALID_EUROPEAN_CORNERS,_a as VALID_AMERICAN_STREETS,Pa as VALID_AMERICAN_STRAIGHTS,ba as VALID_AMERICAN_SPLITS,Ua as VALID_AMERICAN_DOUBLE_STREETS,Ra as VALID_AMERICAN_CORNERS,Dt as ThreeCardBonusType,Hn as TOP_COLUMN,Qr as TILE_COUNTS,Kt as THREE_CARD_BONUS_PAYOUTS,B as SingleActionGame,V as SPLIT_BET_SIZE_FACTOR,Mt as RouletteType,Ma as Roulette,ga as RollType,it as RandomValuePool,Cn as RED_NUMBERS,at as RANDOM_MIN_VALUE,rt as RANDOM_MAX_VALUE,Ca as PlinkoRiskLevel,un as Plinko,Z as Parity,Ht as PairBonusType,cr as PUSH_MULTIPLIER,Jc as PLINKO_ROW_COUNTS,Sn as PAYOUT_MULTIPLIERS,gt as PAIR_BONUS_PAYOUTS,O as OrigamiGame,x as MultiplierCalculator,jt as MultiActionGame,rn as Mines,$a as MIN_WIN_CHANCE,Dn as MIDDLE_COLUMN,za as MAX_WIN_CHANCE,Ct as MAX_CARDS_PER_ROUND,an as Limbo,ir as LOSE_MULTIPLIER,Oa as KenoRiskLevel,tn as Keno,Ot as InsuranceOutcome,xt as INSURANCE_WIN_PAYOUT,F as INSURANCE_BET_SIZE_FACTOR,po as INSURANCE_BET_MULTIPLIER,I as Half,Ja as GameErrorCode,l as GameError,Lt as FACE_CARD_VALUE,ka as EuropeanRoulette,Q as EUROPEAN_HOUSE_EDGE,Ft as EFFECTIVE_RANGE,G as Dozen,Jr as DiceDirection,Xr as Dice,wr as DiamondsResultType,Fr as Diamonds,Tr as Darts,_ as DOUBLE_DOWN_BET_SIZE_FACTOR,fa as DICE_MIN_ROLL,Zt as DICE_MAX_ROLL,Yr as DICE_EFFECTIVE_RANGE,Wt as DEALER_STAND_VALUE,Ea as DARTS_MIN_VALUE,wt as DARTS_MAX_VALUE,ya as DARTS_DIFFICULTY_LEVEL,Vt as DARTS_BOARD_CONFIGS,M as Column,k as Color,Eo as CARDS_PER_SUIT,Or as Blitz,ft as BlackjackOutcome,St as BlackjackActionType,yr as Blackjack,tr as BaccaratOutcome,ar as BaccaratBetType,nr as Baccarat,ht as BUST_VALUE,hn as BOTTOM_COLUMN,Ba as BLITZ_RANDOM_NUMBER_COUNT,sa as BLITZ_MIN_CARD_RANGE,Aa as BLITZ_MAX_CARD_RANGE,z as BLITZ_CARD_COUNT,xn as BLACK_NUMBERS,h as BLACKJACK_VALUE,or as BLACKJACK_MULTIPLIER,et as BASE_PAYOUT_MULTIPLIERS,Ia as AmericanRoulette,Ka as AdvancedDice,q as AMERICAN_HOUSE_EDGE,wa as AMERICAN_BASKET,Pt as ACE_SOFT_BONUS};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/game-calculations",
3
- "version": "6.0.2",
3
+ "version": "7.0.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",