@betorigami/game-calculations 9.0.1 → 10.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 +1 -1
- package/dist/index.d.cts +2 -266
- package/dist/index.d.ts +2 -266
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@betorigami/guard"),l=require("big.js");l=s(l,1);let u=require("@xstate/store"),d=require("fast-deep-equal");d=s(d,1);let f=function(e){return e.UNSUPPORTED_EDGE=`UNSUPPORTED_EDGE`,e.INPUT_VALIDATION_ERROR=`INPUT_VALIDATION_ERROR`,e}({});var p=class e extends Error{static createUnsupportedEdgeError(t){return new e(`UNSUPPORTED_EDGE`,t)}static createValidationError(t){return new e(`INPUT_VALIDATION_ERROR`,t)}static isGameError(t){return t instanceof e}errorCode;constructor(e,t){super(t),this.errorCode=e}};let m=function(e){return e.DICE=`DICE`,e.MINES=`MINES`,e.KENO=`KENO`,e.LIMBO=`LIMBO`,e.ADVANCED_DICE=`ADVANCED_DICE`,e.BACCARAT=`BACCARAT`,e.DIAMONDS=`DIAMONDS`,e.PLINKO=`PLINKO`,e.ROULETTE=`ROULETTE`,e.WHEEL=`WHEEL`,e.BLACKJACK=`BLACKJACK`,e.BLITZ=`BLITZ`,e.DARTS=`DARTS`,e}({});var h=class{gameId;constructor(e){this.gameId=e}getGameResult(e){let t=this.supportedEdgeConfigurations.includes(e.edge);return c.Guard.against(!t,()=>p.createUnsupportedEdgeError(`${this.gameId} does not support ${e.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(e)}},g=class{static withMultiplier(e,t){return new l.default(e).times(new l.default(100-t).div(100))}static withWinChance(e,t){return(0,l.default)(100-e).div(t)}};const _=1e4,v=10001,ee=e=>{if(e<0)throw p.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},te=e=>{if(e>1e4)throw p.createValidationError(`Upper bound ${e} is above maximum allowed value ${_}`)},y=e=>{if(ee(e.lower),te(e.upper),e.lower>=e.upper)throw p.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ne=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw p.createValidationError(`Bounds must not overlap`)},re=(e,t)=>t>=e.lower&&t<=e.upper,ie=e=>e.upper-e.lower+1,b=(e,t)=>t>e.lower&&t<e.upper,x=e=>e.upper-e.lower-1;let ae=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const S=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return y(e.bounds),x(e.bounds);case`ROLL_OUTSIDE`:return y(e.bounds),v-ie(e.bounds);case`ROLL_BETWEEN_TWO`:return y(e.firstBounds),y(e.secondBounds),ne(e.firstBounds,e.secondBounds),x(e.firstBounds)+x(e.secondBounds)}})(),n=(0,l.Big)(t).div(v).mul(100);if(n.lt(.01))throw p.createValidationError(`Win chance too low`);if(n.gt(98))throw p.createValidationError(`Win chance too high`);return n},oe=e=>{S(e)};var se=class extends h{constructor(){super(`ADVANCED_DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=S(n),i=e.getRandomInt({min:0,max:_}),a=i.value,o=(()=>{switch(n.mode){case`ROLL_BETWEEN`:return b(n.bounds,a);case`ROLL_OUTSIDE`:return!re(n.bounds,a);case`ROLL_BETWEEN_TWO`:return b(n.firstBounds,a)||b(n.secondBounds,a)}})()?g.withWinChance(t,r):new l.Big(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}};const ce=Array.from({length:52},(e,t)=>t),le=[`Spades`,`Hearts`,`Diamonds`,`Clubs`],ue=[`Ace`,`Two`,`Three`,`Four`,`Five`,`Six`,`Seven`,`Eight`,`Nine`,`Ten`,`Jack`,`Queen`,`King`],de=[`Jack`,`Queen`,`King`],fe={Hearts:`red`,Diamonds:`red`,Spades:`black`,Clubs:`black`};var C=class{value;constructor(e){let t=ce[e];c.Guard.againstNullOrUndefined(t,`Invalid card value: ${e}`),this.value=t}get suit(){let e=Math.floor(this.value/13),t=le[e];return c.Guard.againstNullOrUndefined(t,`Invalid suit index: ${e}`),t}get rank(){let e=this.value%13,t=ue[e];return c.Guard.againstNullOrUndefined(t,`Invalid rank index: ${e}`),t}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}};const w=e=>e.legs.reduce((e,t)=>e.add(t.amount),new l.default(`0`)),pe=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],me=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],he={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`};let ge=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),_e=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const ve={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},T=e=>new l.default(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new l.default(0))),ye=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var be=class extends h{constructor(){super(`BACCARAT`)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return T(e)}determineGameResult({generator:e,gameInputs:t}){this.validateGameInputs(t);let n=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),r=n.values,i=r.slice(0,3),a=r.slice(3,6),o=[],s=0;for(let e of i.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);o.push(t),s=(s+n)%10}let c=[],u=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);c.push(t),u=(u+n)%10}if(!this.isNaturalWin(s,u)){let e=this.shouldDrawThirdPlayerCard(s),t=null;e&&(t=this.mapRandomValueToCardValue(i[2]),o.push(this.mapRandomValueToCard(i[2])),s=(s+t)%10),this.shouldDrawThirdBankerCard(u,t)&&(c.push(this.mapRandomValueToCard(a[2])),u=(u+this.mapRandomValueToCardValue(a[2]))%10)}let d;d=s===u?`TIE`:s>u?`PLAYER_WIN`:`BANKER_WIN`;let f=T(t),{betType:p,multiplier:m}=ve[d],h={legs:t.bets.map(e=>e.type===p?{amount:e.amount.mul(m)}:{amount:ye(d,e.type)?e.amount:new l.default(`0`)})},g=w(h);return{isFinished:!0,payout:h,payoutMultiplier:f.gt(0)?g.div(f):new l.default(0),outputs:{playerCards:o,playerHandValue:s,bankerCards:c,bankerHandValue:u,gameOutcome:d,result:n.values},randomValues:n}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new C(e);return{suit:t.suit,rank:he[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let xe=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),Se=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),Ce=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),we=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),Te=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const E=2.5,D=.5,O={PLAYER_BLACKJACK:E,WIN:2,PUSH:1,LOSE:0},k={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Ee={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var A=class e extends C{get numericRank(){return de.includes(this.rank)?10:ue.indexOf(this.rank)+1}static fromValue(t){return c.Guard.against(!ce.includes(t),`Invalid card value: ${t}`),new e(t)}},j=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},M=class{cards;value;constructor(e){this.cards=e.map(e=>A.fromValue(e)),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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},De=class e extends M{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=A.fromValue(e),this.holeCard=A.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new j([this.upCard]).highestHandValue}}},N=class e extends M{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}},Oe=class e{source;index=0;constructor(e){this.source=e}static from(t,n){return c.Guard.against(n<=0,`Count must be positive, got ${n}`),c.Guard.against(t.values.length!==n,`Expected ${n} values, got ${t.values.length}`),new e(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let e=this.source.values[this.index];return c.Guard.againstUndefined(e,`RandomValuePool exhausted`),this.index+=1,e}take(e){c.Guard.against(this.index+e>this.source.values.length,`RandomValuePool exhausted: requested ${e} but only ${this.source.values.length-this.index} remain`);let t=this.source.values.slice(this.index,this.index+e);return this.index+=e,t}},ke=class{gameId;edge;constructor(e,t){this.gameId=e,this.edge=t,this.validateEdge(t)}play(e,t,n=[]){let r=this.createGameStore(),i=this.generateRandomValues(e),a=i.toMultipleRandomValues();for(let e of n)r.send({...e.playerArgument,randomValuePool:i});let o=n[n.length-1];o&&c.Guard.against(!(0,d.default)(o.state,this.toExternalState(r.getSnapshot().context.state)),`The final state of the game does not match the expected state based on the previous actions`),r.send({...t,randomValuePool:i});let s=r.getSnapshot().context;return{playerArgument:s.playerArgument,state:this.toExternalState(s.state),config:s.config,additionalBetAmount:s.additionalBetAmount,proof:{proofHash:a.proofHash,proofString:a.proofString}}}validateEdge(e){let t=this.supportedEdgeConfigurations.includes(e);c.Guard.against(!t,()=>p.createUnsupportedEdgeError(`${this.gameId} does not support ${e}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}};const Ae=e=>[e.pairBonus===null?null:{amount:(0,l.default)(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:(0,l.default)(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),je=e=>{let t=e.betAmounts.mainBetAmount,n=e.actionType===`BLACKJACK_DOUBLE_DOWN`?t.mul(1):(0,l.default)(0),r=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,i=t.plus(n).mul(O[e.outcome]),a=e.insuranceOutcome===`WON`?r.mul(3):(0,l.default)(0),o=Ae(e.sideBetResults),s=[{amount:i},...e.insuranceOutcome===void 0?[]:[{amount:a}],...o],u=w({legs:s}),d=t.plus(r).plus(n).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);c.Guard.against(d.eq(0),`Total bet amount cannot be zero`);let f=u.div(d);c.Guard.against(e.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let p;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:p=n;break;case`BLACKJACK_BUY_INSURANCE`:p=e.insuranceStake;break;case`BLACKJACK_SPLIT`:p=t.mul(1)}return{payouts:s,totalBetAmount:d,multiplier:f,additionalBetAmount:p}},Me=e=>{let t=e.betAmounts.mainBetAmount,n=e.mainHandDoubledDown?t.mul(1):(0,l.default)(0),r=e.splitHandDoubledDown?t.mul(1):(0,l.default)(0),i=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,a=t.plus(n).mul(O[e.mainOutcome]),o=t.plus(r).mul(O[e.splitOutcome]),s=e.insuranceOutcome===`WON`?i.mul(3):(0,l.default)(0),u=Ae(e.sideBetResults),d=[{amount:a},{amount:o},...e.insuranceOutcome===void 0?[]:[{amount:s}],...u],f=w({legs:d}),p=t.plus(t).plus(i).plus(n).plus(r).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);c.Guard.against(p.eq(0),`Total bet amount cannot be zero`);let m=f.div(p),h;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:h=t.mul(1);break;case`BLACKJACK_SPLIT`:h=t.mul(1)}return{payouts:d,totalBetAmount:p,multiplier:m,additionalBetAmount:h}},Ne=(e,t)=>t(e.mul(D)),P=e=>e.every(t=>t===e[0]),Pe=e=>{let t=[...e].sort((e,t)=>e-t);return t.every((e,n)=>{let r=t[n-1];return n===0||(c.Guard.againstUndefined(r,`Previous value cannot be undefined`),e===r+1)})},Fe={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},Ie={...Fe,Ace:14},Le=e=>Pe(e.map(e=>Fe[e]))||Pe(e.map(e=>Ie[e])),Re=(e,t)=>{let n=A.fromValue(e),r=A.fromValue(t);return n.rank===r.rank?e===t?`EXACT_PAIR`:fe[n.suit]===fe[r.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},ze=(e,t)=>({betAmount:e,result:t,payoutMultiplier:k[t]}),Be=(e,t,n)=>{let r=A.fromValue(e),i=A.fromValue(t),a=A.fromValue(n),o=[r.rank,i.rank,a.rank],s=P([r.suit,i.suit,a.suit]),c=P(o),l=Le(o);return P([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Ve=(e,t)=>({betAmount:e,result:t,payoutMultiplier:Ee[t]}),He={state:{isFinished:!1,phase:`uninitialised`,multiplier:(0,l.default)(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},F=e=>A.fromValue(e).value;function Ue(e){c.Guard.against(e.phase!==`in-progress`,`Expected a started, in-progress game state`)}function We(e){c.Guard.against(e.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function I(e){c.Guard.against(e.phase!==`in-progress`&&e.phase!==`playing-main-hand`&&e.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const Ge=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([F(e.takeOne())]);return n},L=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},Ke=e=>e.insuranceOutcome===void 0?(0,l.default)(0):e.calculateStake(e.betAmounts.mainBetAmount),qe=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=je({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:Ke(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},Je=e=>{let t=Ge(e.randomValuePool,e.dealerHand),n=L(e.playerHand,t);return qe({...e,dealerHand:t,outcome:n})},Ye=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:Ge(e.randomValuePool,e.dealerHand),n=L(e.mainHand,t),r=L(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=Me({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:Ke(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var Xe=class extends ke{roundInsuranceStake;constructor(e,t){super(`BLACKJACK`,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return Oe.from(e.getRandomIntsWithReplacement({min:0,max:51,count:63}),63)}toExternalState(e){let t=e.phase;switch(t){case`awaiting-insurance`:return{isFinished:!1,phase:`awaiting-insurance`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`in-progress`:return{isFinished:!1,phase:`player-turn`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-main-hand`:return{isFinished:!1,phase:`playing-main-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-split-hand`:return{isFinished:!1,phase:`playing-split-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,outcome:e.outcome,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`split-finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,mainOutcome:e.mainOutcome,splitOutcome:e.splitOutcome,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`uninitialised`:throw Error(`Cannot convert uninitialised state to external state`);default:c.Guard.againstNever(t,`Invalid state received`)}}createGameStore(){let e=e=>{let t=Ne(e,this.roundInsuranceStake);return c.Guard.against(e.gt(0)&&t.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),t},t=t=>qe({...t,calculateStake:e}),n=t=>Je({...t,calculateStake:e}),r=t=>Ye({...t,calculateStake:e});return(0,u.createStore)({context:He,on:{START:(e,n)=>{let{state:r}=e;c.Guard.against(r.phase!==`uninitialised`,`START action requires a fresh game`);let i=F(n.randomValuePool.takeOne()),a=F(n.randomValuePool.takeOne()),o=F(n.randomValuePool.takeOne()),s=F(n.randomValuePool.takeOne()),u=N.withInitialDeal([i,a]),d=De.withInitialDeal({upCard:o,holeCard:s}),f={mainBetAmount:(0,l.default)(n.mainBetAmount),pairBonusAmount:(0,l.default)(n.pairBonusAmount),threeCardBonusAmount:(0,l.default)(n.threeCardBonusAmount)},p={pairBonus:(0,l.default)(n.pairBonusAmount).gt(0)?ze(n.pairBonusAmount,Re(i,a)):null,threeCardBonus:(0,l.default)(n.threeCardBonusAmount).gt(0)?Ve(n.threeCardBonusAmount,Be(i,a,o)):null},m={type:`START`,mainBetAmount:n.mainBetAmount,pairBonusAmount:n.pairBonusAmount,threeCardBonusAmount:n.threeCardBonusAmount};if(d.upCard.rank===`Ace`)return{state:{...r,isFinished:!1,phase:`awaiting-insurance`,playerHand:u,dealerHand:d,betAmounts:f,sideBetResults:p},config:{},playerArgument:m};let h={playerHand:u,dealerHand:d,randomValuePool:n.randomValuePool,playerArgument:m,betAmounts:f,sideBetResults:p};return u.isBlackjack&&d.isBlackjack?t({...h,outcome:`PUSH`}):u.isBlackjack?t({...h,outcome:`PLAYER_BLACKJACK`}):d.isBlackjack?t({...h,outcome:`LOSE`}):{state:{...r,isFinished:!1,phase:`in-progress`,playerHand:u,dealerHand:d,insuranceOutcome:void 0,betAmounts:f,sideBetResults:p},config:{},playerArgument:m}},BLACKJACK_BUY_INSURANCE:(n,r)=>{let{state:i}=n;We(i);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=i,l={...i,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?t({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?t({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?t({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...i,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:e(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,n)=>{let{state:r}=e;We(r);let{playerHand:i,dealerHand:a,betAmounts:o,sideBetResults:s}=r,c={playerHand:i,dealerHand:a,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return i.isBlackjack&&a.isBlackjack?t({...c,outcome:`PUSH`}):i.isBlackjack?t({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?t({...c,outcome:`LOSE`}):{state:{...r,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(e,i)=>{let{state:a}=e;switch(I(a),a.phase){case`playing-main-hand`:{let e=a.mainHand.addDrawnCards([F(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?a.splitHand.highestHandValue===21?r({...a,mainHand:e,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...a,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=a.splitHand.addDrawnCards([F(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=a.playerHand.addDrawnCards([F(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:c.Guard.againstNever(a,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(e,t)=>{let{state:i}=e;switch(I(i),i.phase){case`playing-main-hand`:return i.splitHand.highestHandValue===21?r({...i,splitHandDoubledDown:!1,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...i,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return r({...i,splitHandDoubledDown:i.splitHandDoubledDown,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return n({...i,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:c.Guard.againstNever(i,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(e,i)=>{let{state:a}=e;switch(I(a),a.phase){case`playing-main-hand`:{c.Guard.against(a.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.mainHand.addDrawnCards([F(i.randomValuePool.takeOne())]),{betAmounts:t}=a;return a.splitHand.highestHandValue===21?r({...a,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:t.mainBetAmount.mul(1)}}case`playing-split-hand`:{c.Guard.against(a.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.splitHand.addDrawnCards([F(i.randomValuePool.takeOne())]);return r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},splitHandDoubledDown:!0})}case`in-progress`:{c.Guard.against(a.playerHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.playerHand.addDrawnCards([F(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:c.Guard.againstNever(a,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(e,t)=>{let{state:n}=e;Ue(n);let{playerHand:i,betAmounts:a,sideBetResults:o}=n;c.Guard.against(i.cards.length!==2,`Split is only allowed with exactly 2 cards`);let s=i.cards[0],u=i.cards[1];c.Guard.againstUndefined(s,`First card is missing`),c.Guard.againstUndefined(u,`Second card is missing`),c.Guard.against(s.rank!==u.rank,`Split requires two cards of the same rank`);let d=F(t.randomValuePool.takeOne()),f=F(t.randomValuePool.takeOne()),p=N.withInitialDeal([s.value,d]),m=N.withInitialDeal([u.value,f]);if(s.rank===`Ace`)return r({...n,mainHand:p,splitHand:m,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let h=p.highestHandValue===21,g=m.highestHandValue===21;return h&&g?r({mainHand:p,splitHand:m,dealerHand:n.dealerHand,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:n.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:a,sideBetResults:o}):h?{state:{...n,phase:`playing-split-hand`,mainHand:p,splitHand:m,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}:{state:{...n,phase:`playing-main-hand`,multiplier:(0,l.default)(0),mainHand:p,splitHand:m,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(e){if(e.isFinished)return[];switch(e.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.mainHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`playing-split-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.splitHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`player-turn`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(e.playerHand.cards.length===2){t.push(`BLACKJACK_DOUBLE_DOWN`);let n=e.playerHand.cards[0],r=e.playerHand.cards[1];c.Guard.againstUndefined(n,`First player card is missing`),c.Guard.againstUndefined(r,`Second player card is missing`),n.rank===r.rank&&t.push(`BLACKJACK_SPLIT`)}return t}default:c.Guard.againstNever(e,`Invalid phase for getting valid actions`)}}};const Ze=()=>({minPicks:5,maxPicks:36}),Qe=e=>e.length===new Set(e).size,$e=e=>{let t=(0,l.default)(1),n=(0,l.default)(52);for(let r=0;r<e;r+=1)t=t.mul((0,l.default)(52-r).div(n));return t};var et=class extends h{constructor(){super(`BLITZ`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){c.Guard.against(t.pickCount<1||t.pickCount>52,`pickCount must be between 1 and 52`),c.Guard.againstNonInteger(t.pickCount,`pickCount must be an integer`);let r=e.getRandomIntsWithReplacement({min:0,max:51,count:52}),i=r.values.slice(0,t.pickCount),a=Qe(i),o=$e(t.pickCount),s=a?g.withMultiplier((0,l.default)(1).div(o),n):(0,l.default)(0);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values,cards:i.map(e=>new C(e).toDto())},randomValues:r}}};const tt=4294967295;let nt=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const rt={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},it={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},at={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},ot={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},st=e=>{let t=R[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},R={EASY:rt,MEDIUM:it,HARD:at,EXPERT:ot};var ct=class extends h{constructor(){super(`DARTS`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t}){let n=e.getRandomIntsWithReplacement({min:0,max:tt,count:2}),r=n.values[0],i=n.values[1];c.Guard.againstUndefined(r,`Random number generator returned no value for clockWiseRotation`),c.Guard.againstUndefined(i,`Random number generator returned no value for distanceFromCentre`);let a=t.difficultyLevel,o=(0,l.default)(lt(a,r,i));return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}};const lt=(e,t,n)=>{let r=R[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?ut(r,t):a.ringFour},ut=(e,t)=>{let n=e.segments.length,r=Math.floor(t/4294967296*n),i=e.segments[r];return c.Guard.againstUndefined(i,`Segment index ${r} out of bounds`),e.multipliers.ringThree[i]};var z=class{multipliers;constructor(e){this.multipliers=e}getMultipliers(e){let t=this.multipliers.get(e);if(t===void 0)throw Error(`Multipliers for ${e} not found`);return t}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([e,t])=>({edge:e,multipliers:t}))}};let dt=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const ft=new z(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),pt={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var mt=class extends h{constructor(){super(`DIAMONDS`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),i=ft.getMultipliers(t),a=r.values,o=(0,l.default)(this.calculatePayoutMultiplier(i,a));return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=pt[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let ht=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const B=1e4,gt=10001,_t=e=>{let t=e.direction===`ABOVE`?B-e.selectedValue:e.selectedValue;return new l.default(t).div(gt).mul(100)},vt=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var yt=class extends h{constructor(){super(`DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:0,max:B}),i=_t(n),a=vt(n,r.value)?g.withWinChance(t,i):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(a)}]},payoutMultiplier:a,outputs:{result:r.values},randomValues:r}}};let bt=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const xt=[1,2,3,4,5,6,7,8,9,10],St=e=>xt.includes(e),Ct={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},wt={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},Tt={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},Et={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},Dt={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},Ot=new z(new Map([[1,Ct],[2,wt],[3,Tt],[4,Et],[8,Dt]]));var kt=class extends h{constructor(){super(`KENO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){c.Guard.againstEmptyArray(n.selectedNumbers,()=>p.createValidationError(`No numbers selected`)),c.Guard.against(n.selectedNumbers.length>10,()=>p.createValidationError(`Maximum of 10 numbers can be selected`));for(let e of n.selectedNumbers)c.Guard.againstNonInteger(e,()=>p.createValidationError(`Only integers can be selected`)),c.Guard.against(e<0||e>39,()=>p.createValidationError(`Invalid number selected`));let r=e.getUniqueRandomInts({min:0,max:39,count:10}),i=n.selectedNumbers.filter(e=>r.values.includes(e)),a=n.selectedNumbers.length;if(!St(a))throw Error(`Invalid tile count: ${a}`);let o=Ot.getMultipliers(t)[a][n.riskLevel][i.length];if(o===void 0)throw Error(`No multiplier found for matching tile count ${i.length}`);let s=new l.default(o);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values},randomValues:r}}};const At=(e,t)=>e.gt(t)?e:t,jt=(e,t)=>e.lt(t)?e:t;var Mt=class extends h{constructor(){super(`LIMBO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:1,max:4294967295}),i=r.max,a=new l.default(16777216),o=new l.default(1),s=new l.default(1e6),c=r.value,u=new l.default(c-1).div(i),d=(100-t)/100,f=a.div(u.mul(a).plus(1)).mul(d),p=At(o,jt(f,s)),m=p.gte(n.targetMultiplier)?new l.default(n.targetMultiplier):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{randomMultiplier:p,result:r.values},randomValues:r}}};const V=(e,t)=>{if(t<0||e<0||t>e)throw Error(`Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.`);t>e-t&&(t=e-t);let n=1;for(let r=1;r<=t;r++)n=n*(e-r+1)/r;return n};var Nt=class extends h{constructor(){super(`MINES`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){if(n.minesCount<=0||n.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(n.selectedTiles.length>25-n.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let r=e.getUniqueRandomInts({min:1,max:25,count:n.minesCount}),i=r.values.some(e=>n.selectedTiles.includes(e)),a=n.hasCashedOut||i,o=(100-t)/100,s=new l.default(V(25-n.minesCount,n.selectedTiles.length)).div(new l.default(V(25,n.selectedTiles.length))),c=n.hasCashedOut&&!i?new l.default(o).div(s):new l.default(0);return{isFinished:a,payout:{legs:[{amount:n.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}};let Pt=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Ft=[8,9,10,11,12,13,14,15,16],It=new z(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var Lt=class extends h{constructor(){super(`PLINKO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let r=t.numberOfRows,i=It.getMultipliers(n)[t.riskLevel][r],a=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),o=a.values.reduce((e,t)=>e+t,0),s=i[o];if(s===void 0)throw Error(`No payout found for end position ${o}`);let c=(0,l.Big)(s);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:a.values},randomValues:a}}};const H=[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],Rt=[37,...H],zt=[[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]],Bt=[[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]],Vt=[[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]],Ht=[[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]],Ut=[[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]],Wt=[[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]],Gt=[0,1,2,3,37],Kt=[[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]],qt=[[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]];let U=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),W=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),G=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),K=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),q=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),Jt=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const J=2.7,Y=5.3,Yt=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw p.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&X(e.value)))throw p.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&Xt(e.values)))throw p.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&Zt(e.values)))throw p.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&Qt(e.values)))throw p.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&$t(e.values)))throw p.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(U).includes(e.parity)))throw p.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.color)))throw p.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.half)))throw p.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.column)))throw p.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.dozen)))throw p.createValidationError(`Invalid dozen bet.`)},X=e=>H.includes(e),Xt=e=>e.length!==2||!e.every(X)?!1:zt.some(([t,n])=>t===e[0]&&n===e[1]),Zt=e=>e.length!==3||!e.every(X)?!1:Vt.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),Qt=e=>e.length!==4||!e.every(X)?!1:Ut.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),$t=e=>e.length!==6||!e.every(X)?!1:Kt.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),en=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw p.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Z(e.value)))throw p.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&tn(e.values)))throw p.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&nn(e.values)))throw p.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&rn(e.values)))throw p.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw p.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&an(e.values)))throw p.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(U).includes(e.parity)))throw p.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.color)))throw p.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.half)))throw p.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.column)))throw p.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.dozen)))throw p.createValidationError(`Invalid dozen bet.`)},Z=e=>Rt.includes(e);function tn(e){return e.length!==2||!e.every(Z)?!1:Bt.some(([t,n])=>t===e[0]&&n===e[1])}const nn=e=>e.length!==3||!e.every(Z)?!1:Ht.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),rn=e=>e.length!==4||!e.every(Z)?!1:Wt.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),an=e=>e.length!==6||!e.every(Z)?!1:qt.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),on=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw p.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},sn=(e,t)=>{on(e,t),e.type===`EUROPEAN`?Yt(e.inputs):en(e.inputs)},cn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Q=[3,6,9,12,15,18,21,24,27,30,33,36],ln=[2,5,8,11,14,17,20,23,26,29,32,35],un=[1,4,7,10,13,16,19,22,25,28,31,34],dn=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],fn=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var pn=class extends h{constructor(){super(`ROULETTE`)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let n=this.getBetTotals(e),r=this.calculateTotalBetAmount(n),i={legs:this.calculatePayoutLegs(e,t)},a=w(i);return{payoutMultiplier:r.gt(0)?a.div(r):new l.Big(0),payout:i}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new l.Big(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return dn.includes(t)&&n.color===`RED`||fn.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return Q.includes(t)&&n.column===`TOP`||ln.includes(t)&&n.column===`MIDDLE`||un.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new l.Big(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(n=>{let r=cn[n],i=this.betPredicates[n];return e[n].map(e=>i(e,t)?{amount:e.amount.mul(r||0)}:{amount:new l.Big(`0`)})})}},mn=class extends pn{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[J]}validateInputs(e){Yt(e)}},hn=class extends pn{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[Y]}validateInputs(e){en(e)}isWinningBasketBet(e,t){return Gt.some(e=>e===t)}},gn=class extends h{europeanGame;americanGame;constructor(){super(`ROULETTE`),this.europeanGame=new mn,this.americanGame=new hn}get supportedEdgeConfigurations(){return[J,Y]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if(sn(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const _n=e=>new gn().getBetAmount(e);let vn=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({}),$=function(e){return 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`,e}({});const yn=new z(new Map([[1,{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}}}],[2,{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}}}],[3,{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}}}],[4,{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}}}],[8,{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}}}]])),bn={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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`]}};var xn=class extends h{constructor(){super(`WHEEL`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(!Object.values($).includes(t.segments))throw Error(`Invalid segments value`);if(!Object.values(vn).includes(t.riskLevel))throw Error(`Invalid risk level`);let r=yn.getMultipliers(n)[t.riskLevel];if(r===void 0)throw Error(`No multipliers found for risk level ${t.riskLevel}`);let i=r[t.segments];if(i===void 0)throw Error(`No multipliers found for segment ${t.segments}`);let a=bn[t.riskLevel];if(a===void 0)throw Error(`No patterns found for risk level ${t.riskLevel}`);let o=a[t.segments];if(o===void 0)throw Error(`No patterns found for segment ${t.segments}`);let s=e.getRandomInt({min:0,max:o.length-1}),c=o[s.value];if(c===void 0)throw Error(`No pattern found for segment ${t.segments} and value ${s.value}`);let u=i[c];if(u===void 0)throw Error(`No payout found for picked segment ${c}`);let d=new l.Big(u);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(d)}]},payoutMultiplier:d,outputs:{result:s.values},randomValues:s}}};exports.ACE_SOFT_BONUS=10,exports.AMERICAN_BASKET=Gt,exports.AMERICAN_HOUSE_EDGE=Y,exports.AdvancedDice=se,exports.AmericanRoulette=hn,exports.BASE_PAYOUT_MULTIPLIERS=O,exports.BLACKJACK_MULTIPLIER=E,exports.BLACKJACK_VALUE=21,exports.BLACK_NUMBERS=fn,exports.BLITZ_CARD_COUNT=52,exports.BLITZ_MAX_CARD_RANGE=51,exports.BLITZ_MIN_CARD_RANGE=0,exports.BLITZ_RANDOM_NUMBER_COUNT=52,exports.BOTTOM_COLUMN=un,exports.BUST_VALUE=21,exports.Baccarat=be,exports.BaccaratBetType=_e,exports.BaccaratOutcome=ge,exports.Blackjack=Xe,exports.BlackjackActionType=Ce,exports.BlackjackOutcome=xe,exports.Blitz=et,exports.CARDS_PER_SUIT=13,exports.Color=W,exports.Column=K,exports.DARTS_BOARD_CONFIGS=R,exports.DARTS_DIFFICULTY_LEVEL=nt,exports.DARTS_MAX_VALUE=tt,exports.DARTS_MIN_VALUE=0,exports.DEALER_STAND_VALUE=17,exports.DICE_EFFECTIVE_RANGE=gt,exports.DICE_MAX_ROLL=B,exports.DICE_MIN_ROLL=0,exports.DOUBLE_DOWN_BET_SIZE_FACTOR=1,exports.Darts=ct,exports.Diamonds=mt,exports.DiamondsResultType=dt,exports.Dice=yt,exports.DiceDirection=ht,exports.Dozen=q,exports.EFFECTIVE_RANGE=v,exports.EUROPEAN_HOUSE_EDGE=J,exports.EuropeanRoulette=mn,exports.FACE_CARD_VALUE=10,exports.GameError=p,exports.GameErrorCode=f,exports.Half=G,exports.INSURANCE_BET_SIZE_FACTOR=D,exports.INSURANCE_WIN_MULTIPLIER=3,exports.InsuranceOutcome=Se,exports.Keno=kt,exports.KenoRiskLevel=bt,exports.LOSE_MULTIPLIER=0,exports.Limbo=Mt,exports.MAX_CARDS_PER_ROUND=63,exports.MAX_WIN_CHANCE=98,exports.MIDDLE_COLUMN=ln,exports.MIN_WIN_CHANCE=.01,exports.Mines=Nt,exports.MultiActionGame=ke,exports.MultiplierCalculator=g,exports.OrigamiGame=m,exports.PAIR_BONUS_PAYOUTS=k,exports.PAYOUT_MULTIPLIERS=cn,exports.PLINKO_ROW_COUNTS=Ft,exports.PUSH_MULTIPLIER=1,exports.PairBonusType=we,exports.Parity=U,exports.Plinko=Lt,exports.PlinkoRiskLevel=Pt,exports.RANDOM_MAX_VALUE=_,exports.RANDOM_MIN_VALUE=0,exports.RED_NUMBERS=dn,exports.RandomValuePool=Oe,exports.RollType=ae,exports.Roulette=gn,exports.RouletteType=Jt,exports.SPLIT_BET_SIZE_FACTOR=1,exports.SingleActionGame=h,exports.THREE_CARD_BONUS_PAYOUTS=Ee,exports.TILE_COUNTS=xt,exports.TOP_COLUMN=Q,exports.ThreeCardBonusType=Te,exports.VALID_AMERICAN_CORNERS=Wt,exports.VALID_AMERICAN_DOUBLE_STREETS=qt,exports.VALID_AMERICAN_SPLITS=Bt,exports.VALID_AMERICAN_STRAIGHTS=Rt,exports.VALID_AMERICAN_STREETS=Ht,exports.VALID_EUROPEAN_CORNERS=Ut,exports.VALID_EUROPEAN_DOUBLE_STREETS=Kt,exports.VALID_EUROPEAN_SPLITS=zt,exports.VALID_EUROPEAN_STRAIGHTS=H,exports.VALID_EUROPEAN_STREETS=Vt,exports.VALID_RANKS=me,exports.VALID_SUITS=pe,exports.WIN_MULTIPLIER=2,exports.Wheel=xn,exports.WheelRiskLevel=vn,exports.WheelSegments=$,exports.advancedDiceGetExclusiveBoundsRange=x,exports.advancedDiceGetInclusiveBoundsRange=ie,exports.advancedDiceIsWithinBoundsExclusive=b,exports.advancedDiceIsWithinBoundsInclusive=re,exports.bigMax=At,exports.bigMin=jt,exports.calculateAdvancedDiceWinChance=S,exports.calculateBaccaratBetAmount=T,exports.calculateBlitzWinChance=$e,exports.calculateDiceWinChance=_t,exports.calculateInsuranceStake=Ne,exports.calculateRouletteBetAmount=_n,exports.diamondsMultipliers=ft,exports.getBlitzDefaults=Ze,exports.getMaxMultiplierForDifficulty=st,exports.hasBlitzWon=Qe,exports.hasDiceWon=vt,exports.isTileCount=St,exports.kenoMultipliers=Ot,exports.nCr=V,exports.plinkoMultipliers=It,exports.rtp92Multipliers=Dt,exports.rtp96Multipliers=Et,exports.rtp97Multipliers=Tt,exports.rtp98Multipliers=wt,exports.rtp99Multipliers=Ct,exports.sumPayout=w,exports.validateAdvancedDiceInputs=oe,exports.validateRouletteGameInputs=sn;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@betorigami/game-engine"),l=require("big.js");l=s(l,1);let u=require("@betorigami/guard"),d=require("@xstate/store");const f=1e4,p=10001,m=e=>{if(e<0)throw c.GameError.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},h=e=>{if(e>1e4)throw c.GameError.createValidationError(`Upper bound ${e} is above maximum allowed value ${f}`)},g=e=>{if(m(e.lower),h(e.upper),e.lower>=e.upper)throw c.GameError.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ee=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw c.GameError.createValidationError(`Bounds must not overlap`)},te=(e,t)=>t>=e.lower&&t<=e.upper,_=e=>e.upper-e.lower+1,v=(e,t)=>t>e.lower&&t<e.upper,y=e=>e.upper-e.lower-1;let ne=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const b=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return g(e.bounds),y(e.bounds);case`ROLL_OUTSIDE`:return g(e.bounds),p-_(e.bounds);case`ROLL_BETWEEN_TWO`:return g(e.firstBounds),g(e.secondBounds),ee(e.firstBounds,e.secondBounds),y(e.firstBounds)+y(e.secondBounds)}})(),n=(0,l.Big)(t).div(p).mul(100);if(n.lt(.01))throw c.GameError.createValidationError(`Win chance too low`);if(n.gt(98))throw c.GameError.createValidationError(`Win chance too high`);return n},re=e=>{b(e)};var ie=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.ADVANCED_DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=b(n),i=e.getRandomInt({min:0,max:f}),a=i.value,o=(()=>{switch(n.mode){case`ROLL_BETWEEN`:return v(n.bounds,a);case`ROLL_OUTSIDE`:return!te(n.bounds,a);case`ROLL_BETWEEN_TWO`:return v(n.firstBounds,a)||v(n.secondBounds,a)}})()?c.MultiplierCalculator.withWinChance(t,r):new l.Big(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}};const ae=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],oe=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],se={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`};let ce=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),le=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const ue={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},x=e=>new l.default(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new l.default(0))),de=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var fe=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.BACCARAT)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return x(e)}determineGameResult({generator:e,gameInputs:t}){this.validateGameInputs(t);let n=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),r=n.values,i=r.slice(0,3),a=r.slice(3,6),o=[],s=0;for(let e of i.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);o.push(t),s=(s+n)%10}let u=[],d=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);u.push(t),d=(d+n)%10}if(!this.isNaturalWin(s,d)){let e=this.shouldDrawThirdPlayerCard(s),t=null;e&&(t=this.mapRandomValueToCardValue(i[2]),o.push(this.mapRandomValueToCard(i[2])),s=(s+t)%10),this.shouldDrawThirdBankerCard(d,t)&&(u.push(this.mapRandomValueToCard(a[2])),d=(d+this.mapRandomValueToCardValue(a[2]))%10)}let f;f=s===d?`TIE`:s>d?`PLAYER_WIN`:`BANKER_WIN`;let p=x(t),{betType:m,multiplier:h}=ue[f],g={legs:t.bets.map(e=>e.type===m?{amount:e.amount.mul(h)}:{amount:de(f,e.type)?e.amount:new l.default(`0`)})},ee=(0,c.sumPayout)(g);return{isFinished:!0,payout:g,payoutMultiplier:p.gt(0)?ee.div(p):new l.default(0),outputs:{playerCards:o,playerHandValue:s,bankerCards:u,bankerHandValue:d,gameOutcome:f,result:n.values},randomValues:n}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new c.Card(e);return{suit:t.suit,rank:se[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let pe=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),me=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),he=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),ge=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),_e=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const ve=2.5,ye=.5,S={PLAYER_BLACKJACK:ve,WIN:2,PUSH:1,LOSE:0},C={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},w={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var T=class e extends c.Card{get numericRank(){return c.FACE_CARD_RANKS.includes(this.rank)?10:c.CARD_RANKS.indexOf(this.rank)+1}static fromValue(t){return u.Guard.against(!c.CARD_VALUES.includes(t),`Invalid card value: ${t}`),new e(t)}},E=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},D=class{cards;value;constructor(e){this.cards=e.map(e=>T.fromValue(e)),this.value=new E(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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},be=class e extends D{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=T.fromValue(e),this.holeCard=T.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new E([this.upCard]).highestHandValue}}},O=class e extends D{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}};const k=e=>[e.pairBonus===null?null:{amount:(0,l.default)(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:(0,l.default)(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),xe=e=>{let t=e.betAmounts.mainBetAmount,n=e.actionType===`BLACKJACK_DOUBLE_DOWN`?t.mul(1):(0,l.default)(0),r=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,i=t.plus(n).mul(S[e.outcome]),a=e.insuranceOutcome===`WON`?r.mul(3):(0,l.default)(0),o=k(e.sideBetResults),s=[{amount:i},...e.insuranceOutcome===void 0?[]:[{amount:a}],...o],d=(0,c.sumPayout)({legs:s}),f=t.plus(r).plus(n).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);u.Guard.against(f.eq(0),`Total bet amount cannot be zero`);let p=d.div(f);u.Guard.against(e.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let m;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:m=n;break;case`BLACKJACK_BUY_INSURANCE`:m=e.insuranceStake;break;case`BLACKJACK_SPLIT`:m=t.mul(1)}return{payouts:s,totalBetAmount:f,multiplier:p,additionalBetAmount:m}},Se=e=>{let t=e.betAmounts.mainBetAmount,n=e.mainHandDoubledDown?t.mul(1):(0,l.default)(0),r=e.splitHandDoubledDown?t.mul(1):(0,l.default)(0),i=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,a=t.plus(n).mul(S[e.mainOutcome]),o=t.plus(r).mul(S[e.splitOutcome]),s=e.insuranceOutcome===`WON`?i.mul(3):(0,l.default)(0),d=k(e.sideBetResults),f=[{amount:a},{amount:o},...e.insuranceOutcome===void 0?[]:[{amount:s}],...d],p=(0,c.sumPayout)({legs:f}),m=t.plus(t).plus(i).plus(n).plus(r).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);u.Guard.against(m.eq(0),`Total bet amount cannot be zero`);let h=p.div(m),g;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:g=t.mul(1);break;case`BLACKJACK_SPLIT`:g=t.mul(1)}return{payouts:f,totalBetAmount:m,multiplier:h,additionalBetAmount:g}},A=(e,t)=>t(e.mul(ye)),j=e=>e.every(t=>t===e[0]),M=e=>{let t=[...e].sort((e,t)=>e-t);return t.every((e,n)=>{let r=t[n-1];return n===0||(u.Guard.againstUndefined(r,`Previous value cannot be undefined`),e===r+1)})},N={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},Ce={...N,Ace:14},we=e=>M(e.map(e=>N[e]))||M(e.map(e=>Ce[e])),Te=(e,t)=>{let n=T.fromValue(e),r=T.fromValue(t);return n.rank===r.rank?e===t?`EXACT_PAIR`:c.CARD_SUIT_COLORS[n.suit]===c.CARD_SUIT_COLORS[r.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},Ee=(e,t)=>({betAmount:e,result:t,payoutMultiplier:C[t]}),De=(e,t,n)=>{let r=T.fromValue(e),i=T.fromValue(t),a=T.fromValue(n),o=[r.rank,i.rank,a.rank],s=j([r.suit,i.suit,a.suit]),c=j(o),l=we(o);return j([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Oe=(e,t)=>({betAmount:e,result:t,payoutMultiplier:w[t]}),ke={state:{isFinished:!1,phase:`uninitialised`,multiplier:(0,l.default)(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},P=e=>T.fromValue(e).value;function Ae(e){u.Guard.against(e.phase!==`in-progress`,`Expected a started, in-progress game state`)}function F(e){u.Guard.against(e.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function I(e){u.Guard.against(e.phase!==`in-progress`&&e.phase!==`playing-main-hand`&&e.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const L=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([P(e.takeOne())]);return n},R=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},z=e=>e.insuranceOutcome===void 0?(0,l.default)(0):e.calculateStake(e.betAmounts.mainBetAmount),B=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=xe({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:z(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},je=e=>{let t=L(e.randomValuePool,e.dealerHand),n=R(e.playerHand,t);return B({...e,dealerHand:t,outcome:n})},Me=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:L(e.randomValuePool,e.dealerHand),n=R(e.mainHand,t),r=R(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=Se({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:z(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var Ne=class extends c.MultiActionGame{roundInsuranceStake;constructor(e,t){super(c.OrigamiGame.BLACKJACK,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return c.RandomValuePool.from(e.getRandomIntsWithReplacement({min:c.MIN_CARD_VALUE,max:c.MAX_CARD_VALUE,count:63}),63)}toExternalState(e){let t=e.phase;switch(t){case`awaiting-insurance`:return{isFinished:!1,phase:`awaiting-insurance`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`in-progress`:return{isFinished:!1,phase:`player-turn`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-main-hand`:return{isFinished:!1,phase:`playing-main-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-split-hand`:return{isFinished:!1,phase:`playing-split-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,outcome:e.outcome,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`split-finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,mainOutcome:e.mainOutcome,splitOutcome:e.splitOutcome,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`uninitialised`:throw Error(`Cannot convert uninitialised state to external state`);default:u.Guard.againstNever(t,`Invalid state received`)}}createGameStore(){let e=e=>{let t=A(e,this.roundInsuranceStake);return u.Guard.against(e.gt(0)&&t.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),t},t=t=>B({...t,calculateStake:e}),n=t=>je({...t,calculateStake:e}),r=t=>Me({...t,calculateStake:e});return(0,d.createStore)({context:ke,on:{START:(e,n)=>{let{state:r}=e;u.Guard.against(r.phase!==`uninitialised`,`START action requires a fresh game`);let i=P(n.randomValuePool.takeOne()),a=P(n.randomValuePool.takeOne()),o=P(n.randomValuePool.takeOne()),s=P(n.randomValuePool.takeOne()),c=O.withInitialDeal([i,a]),d=be.withInitialDeal({upCard:o,holeCard:s}),f={mainBetAmount:(0,l.default)(n.mainBetAmount),pairBonusAmount:(0,l.default)(n.pairBonusAmount),threeCardBonusAmount:(0,l.default)(n.threeCardBonusAmount)},p={pairBonus:(0,l.default)(n.pairBonusAmount).gt(0)?Ee(n.pairBonusAmount,Te(i,a)):null,threeCardBonus:(0,l.default)(n.threeCardBonusAmount).gt(0)?Oe(n.threeCardBonusAmount,De(i,a,o)):null},m={type:`START`,mainBetAmount:n.mainBetAmount,pairBonusAmount:n.pairBonusAmount,threeCardBonusAmount:n.threeCardBonusAmount};if(d.upCard.rank===`Ace`)return{state:{...r,isFinished:!1,phase:`awaiting-insurance`,playerHand:c,dealerHand:d,betAmounts:f,sideBetResults:p},config:{},playerArgument:m};let h={playerHand:c,dealerHand:d,randomValuePool:n.randomValuePool,playerArgument:m,betAmounts:f,sideBetResults:p};return c.isBlackjack&&d.isBlackjack?t({...h,outcome:`PUSH`}):c.isBlackjack?t({...h,outcome:`PLAYER_BLACKJACK`}):d.isBlackjack?t({...h,outcome:`LOSE`}):{state:{...r,isFinished:!1,phase:`in-progress`,playerHand:c,dealerHand:d,insuranceOutcome:void 0,betAmounts:f,sideBetResults:p},config:{},playerArgument:m}},BLACKJACK_BUY_INSURANCE:(n,r)=>{let{state:i}=n;F(i);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=i,l={...i,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?t({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?t({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?t({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...i,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:e(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,n)=>{let{state:r}=e;F(r);let{playerHand:i,dealerHand:a,betAmounts:o,sideBetResults:s}=r,c={playerHand:i,dealerHand:a,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return i.isBlackjack&&a.isBlackjack?t({...c,outcome:`PUSH`}):i.isBlackjack?t({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?t({...c,outcome:`LOSE`}):{state:{...r,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(e,i)=>{let{state:a}=e;switch(I(a),a.phase){case`playing-main-hand`:{let e=a.mainHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?a.splitHand.highestHandValue===21?r({...a,mainHand:e,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...a,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=a.splitHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=a.playerHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:u.Guard.againstNever(a,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(e,t)=>{let{state:i}=e;switch(I(i),i.phase){case`playing-main-hand`:return i.splitHand.highestHandValue===21?r({...i,splitHandDoubledDown:!1,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...i,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return r({...i,splitHandDoubledDown:i.splitHandDoubledDown,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return n({...i,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:u.Guard.againstNever(i,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(e,i)=>{let{state:a}=e;switch(I(a),a.phase){case`playing-main-hand`:{u.Guard.against(a.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.mainHand.addDrawnCards([P(i.randomValuePool.takeOne())]),{betAmounts:t}=a;return a.splitHand.highestHandValue===21?r({...a,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:t.mainBetAmount.mul(1)}}case`playing-split-hand`:{u.Guard.against(a.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.splitHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},splitHandDoubledDown:!0})}case`in-progress`:{u.Guard.against(a.playerHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.playerHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:u.Guard.againstNever(a,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(e,t)=>{let{state:n}=e;Ae(n);let{playerHand:i,betAmounts:a,sideBetResults:o}=n;u.Guard.against(i.cards.length!==2,`Split is only allowed with exactly 2 cards`);let s=i.cards[0],c=i.cards[1];u.Guard.againstUndefined(s,`First card is missing`),u.Guard.againstUndefined(c,`Second card is missing`),u.Guard.against(s.rank!==c.rank,`Split requires two cards of the same rank`);let d=P(t.randomValuePool.takeOne()),f=P(t.randomValuePool.takeOne()),p=O.withInitialDeal([s.value,d]),m=O.withInitialDeal([c.value,f]);if(s.rank===`Ace`)return r({...n,mainHand:p,splitHand:m,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let h=p.highestHandValue===21,g=m.highestHandValue===21;return h&&g?r({mainHand:p,splitHand:m,dealerHand:n.dealerHand,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:n.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:a,sideBetResults:o}):h?{state:{...n,phase:`playing-split-hand`,mainHand:p,splitHand:m,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}:{state:{...n,phase:`playing-main-hand`,multiplier:(0,l.default)(0),mainHand:p,splitHand:m,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(e){if(e.isFinished)return[];switch(e.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.mainHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`playing-split-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.splitHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`player-turn`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(e.playerHand.cards.length===2){t.push(`BLACKJACK_DOUBLE_DOWN`);let n=e.playerHand.cards[0],r=e.playerHand.cards[1];u.Guard.againstUndefined(n,`First player card is missing`),u.Guard.againstUndefined(r,`Second player card is missing`),n.rank===r.rank&&t.push(`BLACKJACK_SPLIT`)}return t}default:u.Guard.againstNever(e,`Invalid phase for getting valid actions`)}}};const Pe=()=>({minPicks:5,maxPicks:36}),Fe=e=>e.length===new Set(e).size,Ie=e=>{let t=(0,l.default)(1),n=(0,l.default)(52);for(let r=0;r<e;r+=1)t=t.mul((0,l.default)(52-r).div(n));return t};var Le=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.BLITZ)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){u.Guard.against(t.pickCount<1||t.pickCount>52,`pickCount must be between 1 and 52`),u.Guard.againstNonInteger(t.pickCount,`pickCount must be an integer`);let r=e.getRandomIntsWithReplacement({min:0,max:51,count:52}),i=r.values.slice(0,t.pickCount),a=Fe(i),o=Ie(t.pickCount),s=a?c.MultiplierCalculator.withMultiplier((0,l.default)(1).div(o),n):(0,l.default)(0);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values,cards:i.map(e=>new c.Card(e).toDto())},randomValues:r}}};const Re=4294967295;let ze=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const Be={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},Ve={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},He={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},Ue={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},We=e=>{let t=V[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},V={EASY:Be,MEDIUM:Ve,HARD:He,EXPERT:Ue};var Ge=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.DARTS)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t}){let n=e.getRandomIntsWithReplacement({min:0,max:Re,count:2}),r=n.values[0],i=n.values[1];u.Guard.againstUndefined(r,`Random number generator returned no value for clockWiseRotation`),u.Guard.againstUndefined(i,`Random number generator returned no value for distanceFromCentre`);let a=t.difficultyLevel,o=(0,l.default)(Ke(a,r,i));return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}};const Ke=(e,t,n)=>{let r=V[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?qe(r,t):a.ringFour},qe=(e,t)=>{let n=e.segments.length,r=Math.floor(t/4294967296*n),i=e.segments[r];return u.Guard.againstUndefined(i,`Segment index ${r} out of bounds`),e.multipliers.ringThree[i]};let Je=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const Ye=new c.MultiplierContainer(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),Xe={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var Ze=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.DIAMONDS)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),i=Ye.getMultipliers(t),a=r.values,o=(0,l.default)(this.calculatePayoutMultiplier(i,a));return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=Xe[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let Qe=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const H=1e4,$e=10001,et=e=>{let t=e.direction===`ABOVE`?H-e.selectedValue:e.selectedValue;return new l.default(t).div($e).mul(100)},tt=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var nt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:0,max:H}),i=et(n),a=tt(n,r.value)?c.MultiplierCalculator.withWinChance(t,i):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(a)}]},payoutMultiplier:a,outputs:{result:r.values},randomValues:r}}};let rt=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const it=[1,2,3,4,5,6,7,8,9,10],at=e=>it.includes(e),ot={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},st={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},ct={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},lt={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},ut={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},dt=new c.MultiplierContainer(new Map([[1,ot],[2,st],[3,ct],[4,lt],[8,ut]]));var ft=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.KENO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){u.Guard.againstEmptyArray(n.selectedNumbers,()=>c.GameError.createValidationError(`No numbers selected`)),u.Guard.against(n.selectedNumbers.length>10,()=>c.GameError.createValidationError(`Maximum of 10 numbers can be selected`));for(let e of n.selectedNumbers)u.Guard.againstNonInteger(e,()=>c.GameError.createValidationError(`Only integers can be selected`)),u.Guard.against(e<0||e>39,()=>c.GameError.createValidationError(`Invalid number selected`));let r=e.getUniqueRandomInts({min:0,max:39,count:10}),i=n.selectedNumbers.filter(e=>r.values.includes(e)),a=n.selectedNumbers.length;if(!at(a))throw Error(`Invalid tile count: ${a}`);let o=dt.getMultipliers(t)[a][n.riskLevel][i.length];if(o===void 0)throw Error(`No multiplier found for matching tile count ${i.length}`);let s=new l.default(o);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values},randomValues:r}}},pt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.LIMBO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:1,max:4294967295}),i=r.max,a=new l.default(16777216),o=new l.default(1),s=new l.default(1e6),u=r.value,d=new l.default(u-1).div(i),f=(100-t)/100,p=a.div(d.mul(a).plus(1)).mul(f),m=(0,c.bigMax)(o,(0,c.bigMin)(p,s)),h=m.gte(n.targetMultiplier)?new l.default(n.targetMultiplier):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(h)}]},payoutMultiplier:h,outputs:{randomMultiplier:m,result:r.values},randomValues:r}}},mt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.MINES)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){if(n.minesCount<=0||n.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(n.selectedTiles.length>25-n.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let r=e.getUniqueRandomInts({min:1,max:25,count:n.minesCount}),i=r.values.some(e=>n.selectedTiles.includes(e)),a=n.hasCashedOut||i,o=(100-t)/100,s=new l.default((0,c.nCr)(25-n.minesCount,n.selectedTiles.length)).div(new l.default((0,c.nCr)(25,n.selectedTiles.length))),u=n.hasCashedOut&&!i?new l.default(o).div(s):new l.default(0);return{isFinished:a,payout:{legs:[{amount:n.betAmount.mul(u)}]},payoutMultiplier:u,outputs:{result:r.values},randomValues:r}}};let ht=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const gt=[8,9,10,11,12,13,14,15,16],_t=new c.MultiplierContainer(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var vt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.PLINKO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let r=t.numberOfRows,i=_t.getMultipliers(n)[t.riskLevel][r],a=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),o=a.values.reduce((e,t)=>e+t,0),s=i[o];if(s===void 0)throw Error(`No payout found for end position ${o}`);let c=(0,l.Big)(s);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:a.values},randomValues:a}}};const U=[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],yt=[37,...U],bt=[[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]],xt=[[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]],St=[[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]],Ct=[[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]],wt=[[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]],Tt=[[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]],Et=[0,1,2,3,37],Dt=[[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]],Ot=[[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]];let W=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),G=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),K=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),q=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),J=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),kt=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const Y=2.7,X=5.3,At=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw c.GameError.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Z(e.value)))throw c.GameError.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&jt(e.values)))throw c.GameError.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&Mt(e.values)))throw c.GameError.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&Nt(e.values)))throw c.GameError.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&Pt(e.values)))throw c.GameError.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw c.GameError.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw c.GameError.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw c.GameError.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw c.GameError.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw c.GameError.createValidationError(`Invalid dozen bet.`)},Z=e=>U.includes(e),jt=e=>e.length!==2||!e.every(Z)?!1:bt.some(([t,n])=>t===e[0]&&n===e[1]),Mt=e=>e.length!==3||!e.every(Z)?!1:St.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),Nt=e=>e.length!==4||!e.every(Z)?!1:wt.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),Pt=e=>e.length!==6||!e.every(Z)?!1:Dt.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),Ft=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw c.GameError.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Q(e.value)))throw c.GameError.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&It(e.values)))throw c.GameError.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&Lt(e.values)))throw c.GameError.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&Rt(e.values)))throw c.GameError.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw c.GameError.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&zt(e.values)))throw c.GameError.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw c.GameError.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw c.GameError.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw c.GameError.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw c.GameError.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw c.GameError.createValidationError(`Invalid dozen bet.`)},Q=e=>yt.includes(e);function It(e){return e.length!==2||!e.every(Q)?!1:xt.some(([t,n])=>t===e[0]&&n===e[1])}const Lt=e=>e.length!==3||!e.every(Q)?!1:Ct.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),Rt=e=>e.length!==4||!e.every(Q)?!1:Tt.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),zt=e=>e.length!==6||!e.every(Q)?!1:Ot.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),Bt=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw c.GameError.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},$=(e,t)=>{Bt(e,t),e.type===`EUROPEAN`?At(e.inputs):Ft(e.inputs)},Vt={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Ht=[3,6,9,12,15,18,21,24,27,30,33,36],Ut=[2,5,8,11,14,17,20,23,26,29,32,35],Wt=[1,4,7,10,13,16,19,22,25,28,31,34],Gt=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Kt=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var qt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.ROULETTE)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let n=this.getBetTotals(e),r=this.calculateTotalBetAmount(n),i={legs:this.calculatePayoutLegs(e,t)},a=(0,c.sumPayout)(i);return{payoutMultiplier:r.gt(0)?a.div(r):new l.Big(0),payout:i}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new l.Big(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return Gt.includes(t)&&n.color===`RED`||Kt.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return Ht.includes(t)&&n.column===`TOP`||Ut.includes(t)&&n.column===`MIDDLE`||Wt.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new l.Big(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(n=>{let r=Vt[n],i=this.betPredicates[n];return e[n].map(e=>i(e,t)?{amount:e.amount.mul(r||0)}:{amount:new l.Big(`0`)})})}},Jt=class extends qt{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[Y]}validateInputs(e){At(e)}},Yt=class extends qt{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(e){Ft(e)}isWinningBasketBet(e,t){return Et.some(e=>e===t)}},Xt=class extends c.SingleActionGame{europeanGame;americanGame;constructor(){super(c.OrigamiGame.ROULETTE),this.europeanGame=new Jt,this.americanGame=new Yt}get supportedEdgeConfigurations(){return[Y,X]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if($(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const Zt=e=>new Xt().getBetAmount(e);exports.ACE_SOFT_BONUS=10,exports.AMERICAN_BASKET=Et,exports.AMERICAN_HOUSE_EDGE=X,exports.AdvancedDice=ie,exports.AmericanRoulette=Yt,exports.BASE_PAYOUT_MULTIPLIERS=S,exports.BLACKJACK_MULTIPLIER=ve,exports.BLACKJACK_VALUE=21,exports.BLACK_NUMBERS=Kt,exports.BLITZ_CARD_COUNT=52,exports.BLITZ_MAX_CARD_RANGE=51,exports.BLITZ_MIN_CARD_RANGE=0,exports.BLITZ_RANDOM_NUMBER_COUNT=52,exports.BOTTOM_COLUMN=Wt,exports.BUST_VALUE=21,exports.Baccarat=fe,exports.BaccaratBetType=le,exports.BaccaratOutcome=ce,exports.Blackjack=Ne,exports.BlackjackActionType=he,exports.BlackjackOutcome=pe,exports.Blitz=Le,exports.CARDS_PER_SUIT=13,exports.Color=G,exports.Column=q,exports.DARTS_BOARD_CONFIGS=V,exports.DARTS_DIFFICULTY_LEVEL=ze,exports.DARTS_MAX_VALUE=Re,exports.DARTS_MIN_VALUE=0,exports.DEALER_STAND_VALUE=17,exports.DICE_EFFECTIVE_RANGE=$e,exports.DICE_MAX_ROLL=H,exports.DICE_MIN_ROLL=0,exports.DOUBLE_DOWN_BET_SIZE_FACTOR=1,exports.Darts=Ge,exports.Diamonds=Ze,exports.DiamondsResultType=Je,exports.Dice=nt,exports.DiceDirection=Qe,exports.Dozen=J,exports.EFFECTIVE_RANGE=p,exports.EUROPEAN_HOUSE_EDGE=Y,exports.EuropeanRoulette=Jt,exports.FACE_CARD_VALUE=10,exports.Half=K,exports.INSURANCE_BET_SIZE_FACTOR=ye,exports.INSURANCE_WIN_MULTIPLIER=3,exports.InsuranceOutcome=me,exports.Keno=ft,exports.KenoRiskLevel=rt,exports.LOSE_MULTIPLIER=0,exports.Limbo=pt,exports.MAX_CARDS_PER_ROUND=63,exports.MAX_WIN_CHANCE=98,exports.MIDDLE_COLUMN=Ut,exports.MIN_WIN_CHANCE=.01,exports.Mines=mt,exports.PAIR_BONUS_PAYOUTS=C,exports.PAYOUT_MULTIPLIERS=Vt,exports.PLINKO_ROW_COUNTS=gt,exports.PUSH_MULTIPLIER=1,exports.PairBonusType=ge,exports.Parity=W,exports.Plinko=vt,exports.PlinkoRiskLevel=ht,exports.RANDOM_MAX_VALUE=f,exports.RANDOM_MIN_VALUE=0,exports.RED_NUMBERS=Gt,exports.RollType=ne,exports.Roulette=Xt,exports.RouletteType=kt,exports.SPLIT_BET_SIZE_FACTOR=1,exports.THREE_CARD_BONUS_PAYOUTS=w,exports.TILE_COUNTS=it,exports.TOP_COLUMN=Ht,exports.ThreeCardBonusType=_e,exports.VALID_AMERICAN_CORNERS=Tt,exports.VALID_AMERICAN_DOUBLE_STREETS=Ot,exports.VALID_AMERICAN_SPLITS=xt,exports.VALID_AMERICAN_STRAIGHTS=yt,exports.VALID_AMERICAN_STREETS=Ct,exports.VALID_EUROPEAN_CORNERS=wt,exports.VALID_EUROPEAN_DOUBLE_STREETS=Dt,exports.VALID_EUROPEAN_SPLITS=bt,exports.VALID_EUROPEAN_STRAIGHTS=U,exports.VALID_EUROPEAN_STREETS=St,exports.VALID_RANKS=oe,exports.VALID_SUITS=ae,exports.WIN_MULTIPLIER=2,exports.advancedDiceGetExclusiveBoundsRange=y,exports.advancedDiceGetInclusiveBoundsRange=_,exports.advancedDiceIsWithinBoundsExclusive=v,exports.advancedDiceIsWithinBoundsInclusive=te,exports.calculateAdvancedDiceWinChance=b,exports.calculateBaccaratBetAmount=x,exports.calculateBlitzWinChance=Ie,exports.calculateDiceWinChance=et,exports.calculateInsuranceStake=A,exports.calculateRouletteBetAmount=Zt,exports.diamondsMultipliers=Ye,exports.getBlitzDefaults=Pe,exports.getMaxMultiplierForDifficulty=We,exports.hasBlitzWon=Fe,exports.hasDiceWon=tt,exports.isTileCount=at,exports.kenoMultipliers=dt,exports.plinkoMultipliers=_t,exports.rtp92Multipliers=ut,exports.rtp96Multipliers=lt,exports.rtp97Multipliers=ct,exports.rtp98Multipliers=st,exports.rtp99Multipliers=ot,exports.validateAdvancedDiceInputs=re,exports.validateRouletteGameInputs=$,Object.keys(c).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return c[e]}})});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,131 +1,6 @@
|
|
|
1
|
+
import { BaseFinishedState, BaseInProgressState, Card as Card$1, CardDto, CardValue, GameContext, GameResult, GameStore, GetGameResultRequest, MultiActionGame, MultiplierContainer, Payout, PayoutLeg, RandomNumberGenerator, RandomValuePool, SingleActionGame } from "@betorigami/game-engine";
|
|
1
2
|
import Big$1, { Big } from "big.js";
|
|
2
|
-
|
|
3
|
-
export declare enum GameErrorCode {
|
|
4
|
-
UNSUPPORTED_EDGE = "UNSUPPORTED_EDGE",
|
|
5
|
-
INPUT_VALIDATION_ERROR = "INPUT_VALIDATION_ERROR"
|
|
6
|
-
}
|
|
7
|
-
export declare class GameError extends Error {
|
|
8
|
-
static createUnsupportedEdgeError(message: string): GameError;
|
|
9
|
-
static createValidationError(message: string): GameError;
|
|
10
|
-
static isGameError(error: unknown): error is GameError;
|
|
11
|
-
errorCode: GameErrorCode;
|
|
12
|
-
constructor(errorCode: GameErrorCode, message?: string);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/games/origami-game.d.ts
|
|
16
|
-
export declare enum OrigamiGame {
|
|
17
|
-
DICE = "DICE",
|
|
18
|
-
MINES = "MINES",
|
|
19
|
-
KENO = "KENO",
|
|
20
|
-
LIMBO = "LIMBO",
|
|
21
|
-
ADVANCED_DICE = "ADVANCED_DICE",
|
|
22
|
-
BACCARAT = "BACCARAT",
|
|
23
|
-
DIAMONDS = "DIAMONDS",
|
|
24
|
-
PLINKO = "PLINKO",
|
|
25
|
-
ROULETTE = "ROULETTE",
|
|
26
|
-
WHEEL = "WHEEL",
|
|
27
|
-
BLACKJACK = "BLACKJACK",
|
|
28
|
-
BLITZ = "BLITZ",
|
|
29
|
-
DARTS = "DARTS"
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/games/game.d.ts
|
|
33
|
-
export interface Game {
|
|
34
|
-
gameId: OrigamiGame;
|
|
35
|
-
supportedEdgeConfigurations: [number, ...number[]];
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/games/random.d.ts
|
|
39
|
-
export type Proof = {
|
|
40
|
-
proofHash: string;
|
|
41
|
-
proofString: string;
|
|
42
|
-
};
|
|
43
|
-
export type SingleRandomValue = {
|
|
44
|
-
value: number;
|
|
45
|
-
values: number[];
|
|
46
|
-
count: 1;
|
|
47
|
-
min: number;
|
|
48
|
-
max: number;
|
|
49
|
-
} & Proof;
|
|
50
|
-
export type MultipleRandomValues = {
|
|
51
|
-
values: number[];
|
|
52
|
-
count: number;
|
|
53
|
-
min: number;
|
|
54
|
-
max: number;
|
|
55
|
-
} & Proof;
|
|
56
|
-
export interface RandomNumberGenerator {
|
|
57
|
-
getRandomInt({ min, max }: {
|
|
58
|
-
min: number;
|
|
59
|
-
max: number;
|
|
60
|
-
}): SingleRandomValue;
|
|
61
|
-
getUniqueRandomInts({ min, max, count }: {
|
|
62
|
-
min: number;
|
|
63
|
-
max: number;
|
|
64
|
-
count: number;
|
|
65
|
-
}): MultipleRandomValues;
|
|
66
|
-
getRandomIntsWithReplacement({ min, max, count }: {
|
|
67
|
-
min: number;
|
|
68
|
-
max: number;
|
|
69
|
-
count: number;
|
|
70
|
-
}): MultipleRandomValues;
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/games/payout.d.ts
|
|
74
|
-
/**
|
|
75
|
-
* A single exact payout amount from a game round.
|
|
76
|
-
*
|
|
77
|
-
* A round returns zero or more legs. Neither their order nor their count is
|
|
78
|
-
* significant: a leg is not tied to a particular bet, an amount may be zero,
|
|
79
|
-
* and the number of legs need not match the number of bets placed. The only
|
|
80
|
-
* supported operation is summing them.
|
|
81
|
-
*
|
|
82
|
-
* Amounts are gross — they include returned stake — and unrounded. Rounding to
|
|
83
|
-
* a currency's precision is the consuming service's decision, not this
|
|
84
|
-
* package's.
|
|
85
|
-
*/
|
|
86
|
-
export type PayoutLeg = Readonly<{
|
|
87
|
-
amount: Big$1;
|
|
88
|
-
}>;
|
|
89
|
-
/**
|
|
90
|
-
* A round's payout, expressed as its constituent legs.
|
|
91
|
-
*/
|
|
92
|
-
export type Payout = Readonly<{
|
|
93
|
-
legs: readonly PayoutLeg[];
|
|
94
|
-
}>;
|
|
95
|
-
/**
|
|
96
|
-
* Totals a round's payout.
|
|
97
|
-
*
|
|
98
|
-
* Summing the legs is lossless; reconstructing the total from a rounded
|
|
99
|
-
* payout multiplier is not, so this is the only supported way to arrive at
|
|
100
|
-
* what a round pays.
|
|
101
|
-
*/
|
|
102
|
-
export declare const sumPayout: (payout: Payout) => Big$1;
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/games/single-action-game.d.ts
|
|
105
|
-
export type EmptyGameOutput = {};
|
|
106
|
-
export interface GetGameResultRequest<TGameInputs> {
|
|
107
|
-
generator: RandomNumberGenerator;
|
|
108
|
-
edge: number;
|
|
109
|
-
gameInputs: TGameInputs;
|
|
110
|
-
}
|
|
111
|
-
export interface GameResult<TGameOutputs = EmptyGameOutput> {
|
|
112
|
-
isFinished: boolean;
|
|
113
|
-
payout: Payout;
|
|
114
|
-
payoutMultiplier: Big$1;
|
|
115
|
-
outputs: TGameOutputs & {
|
|
116
|
-
result: number[];
|
|
117
|
-
};
|
|
118
|
-
randomValues: SingleRandomValue | MultipleRandomValues;
|
|
119
|
-
}
|
|
120
|
-
export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = EmptyGameOutput> implements Game {
|
|
121
|
-
readonly gameId: OrigamiGame;
|
|
122
|
-
protected constructor(gameId: OrigamiGame);
|
|
123
|
-
abstract get supportedEdgeConfigurations(): [number, ...number[]];
|
|
124
|
-
abstract getBetAmount(gameInputs: TGameInputs): Big$1;
|
|
125
|
-
getGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
126
|
-
protected abstract determineGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
3
|
+
export * from "@betorigami/game-engine";
|
|
129
4
|
//#region src/games/advanced-dice/advanced-dice.d.ts
|
|
130
5
|
export type Bounds = {
|
|
131
6
|
lower: number;
|
|
@@ -219,19 +94,6 @@ export declare class Baccarat extends SingleActionGame<BaccaratGameInputs, Bacca
|
|
|
219
94
|
private shouldDrawThirdBankerCard;
|
|
220
95
|
}
|
|
221
96
|
//#endregion
|
|
222
|
-
//#region src/cards/types.d.ts
|
|
223
|
-
declare const CARD_VALUES: number[];
|
|
224
|
-
declare const CARD_SUITS: readonly ["Spades", "Hearts", "Diamonds", "Clubs"];
|
|
225
|
-
type CardSuit = (typeof CARD_SUITS)[number];
|
|
226
|
-
declare const CARD_RANKS: readonly ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"];
|
|
227
|
-
type CardRank = (typeof CARD_RANKS)[number];
|
|
228
|
-
type CardValue = (typeof CARD_VALUES)[number];
|
|
229
|
-
type CardDto = {
|
|
230
|
-
rank: CardRank;
|
|
231
|
-
suit: CardSuit;
|
|
232
|
-
cardValue: CardValue;
|
|
233
|
-
};
|
|
234
|
-
//#endregion
|
|
235
97
|
//#region src/games/blackjack/blackjack.types.d.ts
|
|
236
98
|
export interface BlackjackHandDto {
|
|
237
99
|
cards: ReadonlyArray<CardDto>;
|
|
@@ -486,15 +348,6 @@ Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper fo
|
|
|
486
348
|
*/
|
|
487
349
|
type _ReadonlyObjectDeep<ObjectType extends object> = { readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>; };
|
|
488
350
|
//#endregion
|
|
489
|
-
//#region src/cards/card.d.ts
|
|
490
|
-
declare class Card$1 {
|
|
491
|
-
readonly value: CardValue;
|
|
492
|
-
constructor(rawValue: number);
|
|
493
|
-
get suit(): CardSuit;
|
|
494
|
-
get rank(): CardRank;
|
|
495
|
-
toDto(): CardDto;
|
|
496
|
-
}
|
|
497
|
-
//#endregion
|
|
498
351
|
//#region src/games/blackjack/card/blackjack-card.d.ts
|
|
499
352
|
declare class BlackjackCard extends Card$1 {
|
|
500
353
|
get numericRank(): number;
|
|
@@ -547,70 +400,6 @@ declare class PlayerHand extends BlackjackHand {
|
|
|
547
400
|
addDrawnCards(newCards: ReadonlyArray<CardValue>): PlayerHand;
|
|
548
401
|
}
|
|
549
402
|
//#endregion
|
|
550
|
-
//#region src/games/random-value-pool.d.ts
|
|
551
|
-
export declare class RandomValuePool {
|
|
552
|
-
private readonly source;
|
|
553
|
-
private index;
|
|
554
|
-
private constructor();
|
|
555
|
-
static from(result: MultipleRandomValues, count: number): RandomValuePool;
|
|
556
|
-
get consumedValues(): number[];
|
|
557
|
-
toMultipleRandomValues(): MultipleRandomValues;
|
|
558
|
-
takeOne(): number;
|
|
559
|
-
take(count: number): ReadonlyArray<number>;
|
|
560
|
-
}
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region src/games/multi-action-game.d.ts
|
|
563
|
-
export type BaseInProgressState = Readonly<{
|
|
564
|
-
isFinished: false;
|
|
565
|
-
multiplier: Big$1;
|
|
566
|
-
}>;
|
|
567
|
-
export type BaseFinishedState = Readonly<{
|
|
568
|
-
isFinished: true;
|
|
569
|
-
payout: Payout;
|
|
570
|
-
multiplier: Big$1;
|
|
571
|
-
randomValues: number[];
|
|
572
|
-
}>;
|
|
573
|
-
export type BaseGameState = BaseInProgressState | BaseFinishedState;
|
|
574
|
-
export type GameContext<TAction, TState extends BaseGameState, TConfig> = {
|
|
575
|
-
readonly playerArgument: TAction;
|
|
576
|
-
readonly state: TState;
|
|
577
|
-
readonly config: TConfig;
|
|
578
|
-
readonly additionalBetAmount?: Big$1;
|
|
579
|
-
};
|
|
580
|
-
export type RandomValuePoolEvent = Readonly<{
|
|
581
|
-
randomValuePool: RandomValuePool;
|
|
582
|
-
}>;
|
|
583
|
-
export type UntypedGameContext = GameContext<{
|
|
584
|
-
readonly type: string;
|
|
585
|
-
}, BaseGameState, unknown>;
|
|
586
|
-
export type PlayResult = UntypedGameContext & {
|
|
587
|
-
readonly proof: Proof;
|
|
588
|
-
};
|
|
589
|
-
export interface GameStore<TInternalState extends BaseGameState, TAction, TConfig> {
|
|
590
|
-
send(event: {
|
|
591
|
-
readonly type: string;
|
|
592
|
-
} & RandomValuePoolEvent & Record<string, unknown>): void;
|
|
593
|
-
getSnapshot(): {
|
|
594
|
-
readonly context: GameContext<TAction, TInternalState, TConfig>;
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
export declare abstract class MultiActionGame<TInternalState extends BaseGameState, TExternalState extends BaseGameState, TAction extends {
|
|
598
|
-
readonly type: string;
|
|
599
|
-
}, TConfig> implements Game {
|
|
600
|
-
readonly gameId: OrigamiGame;
|
|
601
|
-
readonly edge: number;
|
|
602
|
-
protected constructor(gameId: OrigamiGame, edge: number);
|
|
603
|
-
abstract get supportedEdgeConfigurations(): [number, ...number[]];
|
|
604
|
-
abstract getValidNextActionTypes(state: TExternalState): ReadonlyArray<TAction['type']>;
|
|
605
|
-
protected abstract createGameStore(): GameStore<TInternalState, TAction, TConfig>;
|
|
606
|
-
protected abstract generateRandomValues(generator: RandomNumberGenerator): RandomValuePool;
|
|
607
|
-
protected abstract toExternalState(internal: TInternalState): TExternalState;
|
|
608
|
-
play(generator: RandomNumberGenerator, action: {
|
|
609
|
-
readonly type: string;
|
|
610
|
-
} & Record<string, unknown>, previousActions?: readonly UntypedGameContext[]): PlayResult;
|
|
611
|
-
private validateEdge;
|
|
612
|
-
}
|
|
613
|
-
//#endregion
|
|
614
403
|
//#region src/games/blackjack/insurance-stake.d.ts
|
|
615
404
|
export type RoundInsuranceStake = (unroundedStake: Big$1) => Big$1;
|
|
616
405
|
export declare const calculateInsuranceStake: (mainBetAmount: Big$1, roundInsuranceStake: RoundInsuranceStake) => Big$1;
|
|
@@ -816,17 +605,6 @@ export type DartboardConfig = ReadonlyDeep<{
|
|
|
816
605
|
export declare const getMaxMultiplierForDifficulty: (difficultyLevel: DARTS_DIFFICULTY_LEVEL) => number;
|
|
817
606
|
export declare const DARTS_BOARD_CONFIGS: Record<DARTS_DIFFICULTY_LEVEL, DartboardConfig>;
|
|
818
607
|
//#endregion
|
|
819
|
-
//#region src/games/infrastructure/multiplier.container.d.ts
|
|
820
|
-
declare class MultiplierContainer<TMultipliers> {
|
|
821
|
-
readonly multipliers: Map<number, TMultipliers>;
|
|
822
|
-
constructor(multipliers: Map<number, TMultipliers>);
|
|
823
|
-
getMultipliers(edge: number): TMultipliers;
|
|
824
|
-
getAllMultipliers(): {
|
|
825
|
-
edge: number;
|
|
826
|
-
multipliers: TMultipliers;
|
|
827
|
-
}[];
|
|
828
|
-
}
|
|
829
|
-
//#endregion
|
|
830
608
|
//#region src/games/diamonds/diamonds.d.ts
|
|
831
609
|
export interface DiamondsGameInputs {
|
|
832
610
|
betAmount: Big$1;
|
|
@@ -1206,46 +984,4 @@ export declare const calculateRouletteBetAmount: (gameInputs: RouletteGameInputs
|
|
|
1206
984
|
//#endregion
|
|
1207
985
|
//#region src/games/roulette/roulette.validation.d.ts
|
|
1208
986
|
export declare const validateRouletteGameInputs: (gameInputs: RouletteGameInputs, edge: number) => void;
|
|
1209
|
-
//#endregion
|
|
1210
|
-
//#region src/games/wheel/wheel.constants.d.ts
|
|
1211
|
-
export declare enum WheelRiskLevel {
|
|
1212
|
-
LOW_RISK = "LOW_RISK",
|
|
1213
|
-
MEDIUM_RISK = "MEDIUM_RISK",
|
|
1214
|
-
HIGH_RISK = "HIGH_RISK"
|
|
1215
|
-
}
|
|
1216
|
-
export declare enum WheelSegments {
|
|
1217
|
-
TEN = 10,
|
|
1218
|
-
TWENTY = 20,
|
|
1219
|
-
THIRTY = 30,
|
|
1220
|
-
FORTY = 40,
|
|
1221
|
-
FIFTY = 50
|
|
1222
|
-
}
|
|
1223
|
-
//#endregion
|
|
1224
|
-
//#region src/games/wheel/wheel.d.ts
|
|
1225
|
-
export interface WheelGameInputs {
|
|
1226
|
-
segments: WheelSegments;
|
|
1227
|
-
riskLevel: WheelRiskLevel;
|
|
1228
|
-
betAmount: Big;
|
|
1229
|
-
}
|
|
1230
|
-
export declare class Wheel extends SingleActionGame<WheelGameInputs> {
|
|
1231
|
-
constructor();
|
|
1232
|
-
get supportedEdgeConfigurations(): [number, ...number[]];
|
|
1233
|
-
getBetAmount(gameInputs: WheelGameInputs): Big;
|
|
1234
|
-
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
|
|
1235
|
-
}
|
|
1236
|
-
//#endregion
|
|
1237
|
-
//#region src/utils/big-max.d.ts
|
|
1238
|
-
export declare const bigMax: (a: Big$1, b: Big$1) => Big$1;
|
|
1239
|
-
//#endregion
|
|
1240
|
-
//#region src/utils/big-min.d.ts
|
|
1241
|
-
export declare const bigMin: (a: Big$1, b: Big$1) => Big$1;
|
|
1242
|
-
//#endregion
|
|
1243
|
-
//#region src/utils/multiplier-calculator.d.ts
|
|
1244
|
-
export declare abstract class MultiplierCalculator {
|
|
1245
|
-
static withMultiplier(multiplier: Big$1, edge: number): Big$1;
|
|
1246
|
-
static withWinChance(edge: number, winChance: Big$1): Big$1;
|
|
1247
|
-
}
|
|
1248
|
-
//#endregion
|
|
1249
|
-
//#region src/utils/ncr.d.ts
|
|
1250
|
-
export declare const nCr: (n: number, r: number) => number;
|
|
1251
987
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,131 +1,6 @@
|
|
|
1
|
+
import { BaseFinishedState, BaseInProgressState, Card as Card$1, CardDto, CardValue, GameContext, GameResult, GameStore, GetGameResultRequest, MultiActionGame, MultiplierContainer, Payout, PayoutLeg, RandomNumberGenerator, RandomValuePool, SingleActionGame } from "@betorigami/game-engine";
|
|
1
2
|
import Big$1, { Big } from "big.js";
|
|
2
|
-
|
|
3
|
-
export declare enum GameErrorCode {
|
|
4
|
-
UNSUPPORTED_EDGE = "UNSUPPORTED_EDGE",
|
|
5
|
-
INPUT_VALIDATION_ERROR = "INPUT_VALIDATION_ERROR"
|
|
6
|
-
}
|
|
7
|
-
export declare class GameError extends Error {
|
|
8
|
-
static createUnsupportedEdgeError(message: string): GameError;
|
|
9
|
-
static createValidationError(message: string): GameError;
|
|
10
|
-
static isGameError(error: unknown): error is GameError;
|
|
11
|
-
errorCode: GameErrorCode;
|
|
12
|
-
constructor(errorCode: GameErrorCode, message?: string);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/games/origami-game.d.ts
|
|
16
|
-
export declare enum OrigamiGame {
|
|
17
|
-
DICE = "DICE",
|
|
18
|
-
MINES = "MINES",
|
|
19
|
-
KENO = "KENO",
|
|
20
|
-
LIMBO = "LIMBO",
|
|
21
|
-
ADVANCED_DICE = "ADVANCED_DICE",
|
|
22
|
-
BACCARAT = "BACCARAT",
|
|
23
|
-
DIAMONDS = "DIAMONDS",
|
|
24
|
-
PLINKO = "PLINKO",
|
|
25
|
-
ROULETTE = "ROULETTE",
|
|
26
|
-
WHEEL = "WHEEL",
|
|
27
|
-
BLACKJACK = "BLACKJACK",
|
|
28
|
-
BLITZ = "BLITZ",
|
|
29
|
-
DARTS = "DARTS"
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/games/game.d.ts
|
|
33
|
-
export interface Game {
|
|
34
|
-
gameId: OrigamiGame;
|
|
35
|
-
supportedEdgeConfigurations: [number, ...number[]];
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/games/random.d.ts
|
|
39
|
-
export type Proof = {
|
|
40
|
-
proofHash: string;
|
|
41
|
-
proofString: string;
|
|
42
|
-
};
|
|
43
|
-
export type SingleRandomValue = {
|
|
44
|
-
value: number;
|
|
45
|
-
values: number[];
|
|
46
|
-
count: 1;
|
|
47
|
-
min: number;
|
|
48
|
-
max: number;
|
|
49
|
-
} & Proof;
|
|
50
|
-
export type MultipleRandomValues = {
|
|
51
|
-
values: number[];
|
|
52
|
-
count: number;
|
|
53
|
-
min: number;
|
|
54
|
-
max: number;
|
|
55
|
-
} & Proof;
|
|
56
|
-
export interface RandomNumberGenerator {
|
|
57
|
-
getRandomInt({ min, max }: {
|
|
58
|
-
min: number;
|
|
59
|
-
max: number;
|
|
60
|
-
}): SingleRandomValue;
|
|
61
|
-
getUniqueRandomInts({ min, max, count }: {
|
|
62
|
-
min: number;
|
|
63
|
-
max: number;
|
|
64
|
-
count: number;
|
|
65
|
-
}): MultipleRandomValues;
|
|
66
|
-
getRandomIntsWithReplacement({ min, max, count }: {
|
|
67
|
-
min: number;
|
|
68
|
-
max: number;
|
|
69
|
-
count: number;
|
|
70
|
-
}): MultipleRandomValues;
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/games/payout.d.ts
|
|
74
|
-
/**
|
|
75
|
-
* A single exact payout amount from a game round.
|
|
76
|
-
*
|
|
77
|
-
* A round returns zero or more legs. Neither their order nor their count is
|
|
78
|
-
* significant: a leg is not tied to a particular bet, an amount may be zero,
|
|
79
|
-
* and the number of legs need not match the number of bets placed. The only
|
|
80
|
-
* supported operation is summing them.
|
|
81
|
-
*
|
|
82
|
-
* Amounts are gross — they include returned stake — and unrounded. Rounding to
|
|
83
|
-
* a currency's precision is the consuming service's decision, not this
|
|
84
|
-
* package's.
|
|
85
|
-
*/
|
|
86
|
-
export type PayoutLeg = Readonly<{
|
|
87
|
-
amount: Big$1;
|
|
88
|
-
}>;
|
|
89
|
-
/**
|
|
90
|
-
* A round's payout, expressed as its constituent legs.
|
|
91
|
-
*/
|
|
92
|
-
export type Payout = Readonly<{
|
|
93
|
-
legs: readonly PayoutLeg[];
|
|
94
|
-
}>;
|
|
95
|
-
/**
|
|
96
|
-
* Totals a round's payout.
|
|
97
|
-
*
|
|
98
|
-
* Summing the legs is lossless; reconstructing the total from a rounded
|
|
99
|
-
* payout multiplier is not, so this is the only supported way to arrive at
|
|
100
|
-
* what a round pays.
|
|
101
|
-
*/
|
|
102
|
-
export declare const sumPayout: (payout: Payout) => Big$1;
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/games/single-action-game.d.ts
|
|
105
|
-
export type EmptyGameOutput = {};
|
|
106
|
-
export interface GetGameResultRequest<TGameInputs> {
|
|
107
|
-
generator: RandomNumberGenerator;
|
|
108
|
-
edge: number;
|
|
109
|
-
gameInputs: TGameInputs;
|
|
110
|
-
}
|
|
111
|
-
export interface GameResult<TGameOutputs = EmptyGameOutput> {
|
|
112
|
-
isFinished: boolean;
|
|
113
|
-
payout: Payout;
|
|
114
|
-
payoutMultiplier: Big$1;
|
|
115
|
-
outputs: TGameOutputs & {
|
|
116
|
-
result: number[];
|
|
117
|
-
};
|
|
118
|
-
randomValues: SingleRandomValue | MultipleRandomValues;
|
|
119
|
-
}
|
|
120
|
-
export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = EmptyGameOutput> implements Game {
|
|
121
|
-
readonly gameId: OrigamiGame;
|
|
122
|
-
protected constructor(gameId: OrigamiGame);
|
|
123
|
-
abstract get supportedEdgeConfigurations(): [number, ...number[]];
|
|
124
|
-
abstract getBetAmount(gameInputs: TGameInputs): Big$1;
|
|
125
|
-
getGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
126
|
-
protected abstract determineGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
3
|
+
export * from "@betorigami/game-engine";
|
|
129
4
|
//#region src/games/advanced-dice/advanced-dice.d.ts
|
|
130
5
|
export type Bounds = {
|
|
131
6
|
lower: number;
|
|
@@ -219,19 +94,6 @@ export declare class Baccarat extends SingleActionGame<BaccaratGameInputs, Bacca
|
|
|
219
94
|
private shouldDrawThirdBankerCard;
|
|
220
95
|
}
|
|
221
96
|
//#endregion
|
|
222
|
-
//#region src/cards/types.d.ts
|
|
223
|
-
declare const CARD_VALUES: number[];
|
|
224
|
-
declare const CARD_SUITS: readonly ["Spades", "Hearts", "Diamonds", "Clubs"];
|
|
225
|
-
type CardSuit = (typeof CARD_SUITS)[number];
|
|
226
|
-
declare const CARD_RANKS: readonly ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"];
|
|
227
|
-
type CardRank = (typeof CARD_RANKS)[number];
|
|
228
|
-
type CardValue = (typeof CARD_VALUES)[number];
|
|
229
|
-
type CardDto = {
|
|
230
|
-
rank: CardRank;
|
|
231
|
-
suit: CardSuit;
|
|
232
|
-
cardValue: CardValue;
|
|
233
|
-
};
|
|
234
|
-
//#endregion
|
|
235
97
|
//#region src/games/blackjack/blackjack.types.d.ts
|
|
236
98
|
export interface BlackjackHandDto {
|
|
237
99
|
cards: ReadonlyArray<CardDto>;
|
|
@@ -486,15 +348,6 @@ Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper fo
|
|
|
486
348
|
*/
|
|
487
349
|
type _ReadonlyObjectDeep<ObjectType extends object> = { readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>; };
|
|
488
350
|
//#endregion
|
|
489
|
-
//#region src/cards/card.d.ts
|
|
490
|
-
declare class Card$1 {
|
|
491
|
-
readonly value: CardValue;
|
|
492
|
-
constructor(rawValue: number);
|
|
493
|
-
get suit(): CardSuit;
|
|
494
|
-
get rank(): CardRank;
|
|
495
|
-
toDto(): CardDto;
|
|
496
|
-
}
|
|
497
|
-
//#endregion
|
|
498
351
|
//#region src/games/blackjack/card/blackjack-card.d.ts
|
|
499
352
|
declare class BlackjackCard extends Card$1 {
|
|
500
353
|
get numericRank(): number;
|
|
@@ -547,70 +400,6 @@ declare class PlayerHand extends BlackjackHand {
|
|
|
547
400
|
addDrawnCards(newCards: ReadonlyArray<CardValue>): PlayerHand;
|
|
548
401
|
}
|
|
549
402
|
//#endregion
|
|
550
|
-
//#region src/games/random-value-pool.d.ts
|
|
551
|
-
export declare class RandomValuePool {
|
|
552
|
-
private readonly source;
|
|
553
|
-
private index;
|
|
554
|
-
private constructor();
|
|
555
|
-
static from(result: MultipleRandomValues, count: number): RandomValuePool;
|
|
556
|
-
get consumedValues(): number[];
|
|
557
|
-
toMultipleRandomValues(): MultipleRandomValues;
|
|
558
|
-
takeOne(): number;
|
|
559
|
-
take(count: number): ReadonlyArray<number>;
|
|
560
|
-
}
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region src/games/multi-action-game.d.ts
|
|
563
|
-
export type BaseInProgressState = Readonly<{
|
|
564
|
-
isFinished: false;
|
|
565
|
-
multiplier: Big$1;
|
|
566
|
-
}>;
|
|
567
|
-
export type BaseFinishedState = Readonly<{
|
|
568
|
-
isFinished: true;
|
|
569
|
-
payout: Payout;
|
|
570
|
-
multiplier: Big$1;
|
|
571
|
-
randomValues: number[];
|
|
572
|
-
}>;
|
|
573
|
-
export type BaseGameState = BaseInProgressState | BaseFinishedState;
|
|
574
|
-
export type GameContext<TAction, TState extends BaseGameState, TConfig> = {
|
|
575
|
-
readonly playerArgument: TAction;
|
|
576
|
-
readonly state: TState;
|
|
577
|
-
readonly config: TConfig;
|
|
578
|
-
readonly additionalBetAmount?: Big$1;
|
|
579
|
-
};
|
|
580
|
-
export type RandomValuePoolEvent = Readonly<{
|
|
581
|
-
randomValuePool: RandomValuePool;
|
|
582
|
-
}>;
|
|
583
|
-
export type UntypedGameContext = GameContext<{
|
|
584
|
-
readonly type: string;
|
|
585
|
-
}, BaseGameState, unknown>;
|
|
586
|
-
export type PlayResult = UntypedGameContext & {
|
|
587
|
-
readonly proof: Proof;
|
|
588
|
-
};
|
|
589
|
-
export interface GameStore<TInternalState extends BaseGameState, TAction, TConfig> {
|
|
590
|
-
send(event: {
|
|
591
|
-
readonly type: string;
|
|
592
|
-
} & RandomValuePoolEvent & Record<string, unknown>): void;
|
|
593
|
-
getSnapshot(): {
|
|
594
|
-
readonly context: GameContext<TAction, TInternalState, TConfig>;
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
export declare abstract class MultiActionGame<TInternalState extends BaseGameState, TExternalState extends BaseGameState, TAction extends {
|
|
598
|
-
readonly type: string;
|
|
599
|
-
}, TConfig> implements Game {
|
|
600
|
-
readonly gameId: OrigamiGame;
|
|
601
|
-
readonly edge: number;
|
|
602
|
-
protected constructor(gameId: OrigamiGame, edge: number);
|
|
603
|
-
abstract get supportedEdgeConfigurations(): [number, ...number[]];
|
|
604
|
-
abstract getValidNextActionTypes(state: TExternalState): ReadonlyArray<TAction['type']>;
|
|
605
|
-
protected abstract createGameStore(): GameStore<TInternalState, TAction, TConfig>;
|
|
606
|
-
protected abstract generateRandomValues(generator: RandomNumberGenerator): RandomValuePool;
|
|
607
|
-
protected abstract toExternalState(internal: TInternalState): TExternalState;
|
|
608
|
-
play(generator: RandomNumberGenerator, action: {
|
|
609
|
-
readonly type: string;
|
|
610
|
-
} & Record<string, unknown>, previousActions?: readonly UntypedGameContext[]): PlayResult;
|
|
611
|
-
private validateEdge;
|
|
612
|
-
}
|
|
613
|
-
//#endregion
|
|
614
403
|
//#region src/games/blackjack/insurance-stake.d.ts
|
|
615
404
|
export type RoundInsuranceStake = (unroundedStake: Big$1) => Big$1;
|
|
616
405
|
export declare const calculateInsuranceStake: (mainBetAmount: Big$1, roundInsuranceStake: RoundInsuranceStake) => Big$1;
|
|
@@ -816,17 +605,6 @@ export type DartboardConfig = ReadonlyDeep<{
|
|
|
816
605
|
export declare const getMaxMultiplierForDifficulty: (difficultyLevel: DARTS_DIFFICULTY_LEVEL) => number;
|
|
817
606
|
export declare const DARTS_BOARD_CONFIGS: Record<DARTS_DIFFICULTY_LEVEL, DartboardConfig>;
|
|
818
607
|
//#endregion
|
|
819
|
-
//#region src/games/infrastructure/multiplier.container.d.ts
|
|
820
|
-
declare class MultiplierContainer<TMultipliers> {
|
|
821
|
-
readonly multipliers: Map<number, TMultipliers>;
|
|
822
|
-
constructor(multipliers: Map<number, TMultipliers>);
|
|
823
|
-
getMultipliers(edge: number): TMultipliers;
|
|
824
|
-
getAllMultipliers(): {
|
|
825
|
-
edge: number;
|
|
826
|
-
multipliers: TMultipliers;
|
|
827
|
-
}[];
|
|
828
|
-
}
|
|
829
|
-
//#endregion
|
|
830
608
|
//#region src/games/diamonds/diamonds.d.ts
|
|
831
609
|
export interface DiamondsGameInputs {
|
|
832
610
|
betAmount: Big$1;
|
|
@@ -1206,46 +984,4 @@ export declare const calculateRouletteBetAmount: (gameInputs: RouletteGameInputs
|
|
|
1206
984
|
//#endregion
|
|
1207
985
|
//#region src/games/roulette/roulette.validation.d.ts
|
|
1208
986
|
export declare const validateRouletteGameInputs: (gameInputs: RouletteGameInputs, edge: number) => void;
|
|
1209
|
-
//#endregion
|
|
1210
|
-
//#region src/games/wheel/wheel.constants.d.ts
|
|
1211
|
-
export declare enum WheelRiskLevel {
|
|
1212
|
-
LOW_RISK = "LOW_RISK",
|
|
1213
|
-
MEDIUM_RISK = "MEDIUM_RISK",
|
|
1214
|
-
HIGH_RISK = "HIGH_RISK"
|
|
1215
|
-
}
|
|
1216
|
-
export declare enum WheelSegments {
|
|
1217
|
-
TEN = 10,
|
|
1218
|
-
TWENTY = 20,
|
|
1219
|
-
THIRTY = 30,
|
|
1220
|
-
FORTY = 40,
|
|
1221
|
-
FIFTY = 50
|
|
1222
|
-
}
|
|
1223
|
-
//#endregion
|
|
1224
|
-
//#region src/games/wheel/wheel.d.ts
|
|
1225
|
-
export interface WheelGameInputs {
|
|
1226
|
-
segments: WheelSegments;
|
|
1227
|
-
riskLevel: WheelRiskLevel;
|
|
1228
|
-
betAmount: Big;
|
|
1229
|
-
}
|
|
1230
|
-
export declare class Wheel extends SingleActionGame<WheelGameInputs> {
|
|
1231
|
-
constructor();
|
|
1232
|
-
get supportedEdgeConfigurations(): [number, ...number[]];
|
|
1233
|
-
getBetAmount(gameInputs: WheelGameInputs): Big;
|
|
1234
|
-
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
|
|
1235
|
-
}
|
|
1236
|
-
//#endregion
|
|
1237
|
-
//#region src/utils/big-max.d.ts
|
|
1238
|
-
export declare const bigMax: (a: Big$1, b: Big$1) => Big$1;
|
|
1239
|
-
//#endregion
|
|
1240
|
-
//#region src/utils/big-min.d.ts
|
|
1241
|
-
export declare const bigMin: (a: Big$1, b: Big$1) => Big$1;
|
|
1242
|
-
//#endregion
|
|
1243
|
-
//#region src/utils/multiplier-calculator.d.ts
|
|
1244
|
-
export declare abstract class MultiplierCalculator {
|
|
1245
|
-
static withMultiplier(multiplier: Big$1, edge: number): Big$1;
|
|
1246
|
-
static withWinChance(edge: number, winChance: Big$1): Big$1;
|
|
1247
|
-
}
|
|
1248
|
-
//#endregion
|
|
1249
|
-
//#region src/utils/ncr.d.ts
|
|
1250
|
-
export declare const nCr: (n: number, r: number) => number;
|
|
1251
987
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Guard as e}from"@betorigami/guard";import t,{Big as n}from"big.js";import{createStore as r}from"@xstate/store";import i from"fast-deep-equal";let a=function(e){return e.UNSUPPORTED_EDGE=`UNSUPPORTED_EDGE`,e.INPUT_VALIDATION_ERROR=`INPUT_VALIDATION_ERROR`,e}({});var o=class e extends Error{static createUnsupportedEdgeError(t){return new e(`UNSUPPORTED_EDGE`,t)}static createValidationError(t){return new e(`INPUT_VALIDATION_ERROR`,t)}static isGameError(t){return t instanceof e}errorCode;constructor(e,t){super(t),this.errorCode=e}};let s=function(e){return e.DICE=`DICE`,e.MINES=`MINES`,e.KENO=`KENO`,e.LIMBO=`LIMBO`,e.ADVANCED_DICE=`ADVANCED_DICE`,e.BACCARAT=`BACCARAT`,e.DIAMONDS=`DIAMONDS`,e.PLINKO=`PLINKO`,e.ROULETTE=`ROULETTE`,e.WHEEL=`WHEEL`,e.BLACKJACK=`BLACKJACK`,e.BLITZ=`BLITZ`,e.DARTS=`DARTS`,e}({});var c=class{gameId;constructor(e){this.gameId=e}getGameResult(t){let n=this.supportedEdgeConfigurations.includes(t.edge);return e.against(!n,()=>o.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}},l=class{static withMultiplier(e,n){return new t(e).times(new t(100-n).div(100))}static withWinChance(e,n){return t(100-e).div(n)}};const u=0,d=1e4,f=10001,p=.01,m=98,h=e=>{if(e<0)throw o.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},g=e=>{if(e>1e4)throw o.createValidationError(`Upper bound ${e} is above maximum allowed value ${d}`)},_=e=>{if(h(e.lower),g(e.upper),e.lower>=e.upper)throw o.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ee=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw o.createValidationError(`Bounds must not overlap`)},te=(e,t)=>t>=e.lower&&t<=e.upper,v=e=>e.upper-e.lower+1,y=(e,t)=>t>e.lower&&t<e.upper,b=e=>e.upper-e.lower-1;let ne=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const x=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return _(e.bounds),b(e.bounds);case`ROLL_OUTSIDE`:return _(e.bounds),f-v(e.bounds);case`ROLL_BETWEEN_TWO`:return _(e.firstBounds),_(e.secondBounds),ee(e.firstBounds,e.secondBounds),b(e.firstBounds)+b(e.secondBounds)}})(),r=n(t).div(f).mul(100);if(r.lt(.01))throw o.createValidationError(`Win chance too low`);if(r.gt(98))throw o.createValidationError(`Win chance too high`);return r},re=e=>{x(e)};var ie=class extends c{constructor(){super(`ADVANCED_DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:r}){let i=x(r),a=e.getRandomInt({min:0,max:d}),o=a.value,s=(()=>{switch(r.mode){case`ROLL_BETWEEN`:return y(r.bounds,o);case`ROLL_OUTSIDE`:return!te(r.bounds,o);case`ROLL_BETWEEN_TWO`:return y(r.firstBounds,o)||y(r.secondBounds,o)}})()?l.withWinChance(t,i):new n(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:a.values},randomValues:a}}};const ae=Array.from({length:52},(e,t)=>t),oe=[`Spades`,`Hearts`,`Diamonds`,`Clubs`],se=[`Ace`,`Two`,`Three`,`Four`,`Five`,`Six`,`Seven`,`Eight`,`Nine`,`Ten`,`Jack`,`Queen`,`King`],ce=[`Jack`,`Queen`,`King`],le={Hearts:`red`,Diamonds:`red`,Spades:`black`,Clubs:`black`};var S=class{value;constructor(t){let n=ae[t];e.againstNullOrUndefined(n,`Invalid card value: ${t}`),this.value=n}get suit(){let t=Math.floor(this.value/13),n=oe[t];return e.againstNullOrUndefined(n,`Invalid suit index: ${t}`),n}get rank(){let t=this.value%13,n=se[t];return e.againstNullOrUndefined(n,`Invalid rank index: ${t}`),n}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}};const C=e=>e.legs.reduce((e,t)=>e.add(t.amount),new t(`0`)),ue=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],de=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],fe={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`};let pe=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),me=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const he={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},w=e=>new t(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new t(0))),ge=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var _e=class extends c{constructor(){super(`BACCARAT`)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return w(e)}determineGameResult({generator:e,gameInputs:n}){this.validateGameInputs(n);let r=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),i=r.values,a=i.slice(0,3),o=i.slice(3,6),s=[],c=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);s.push(t),c=(c+n)%10}let l=[],u=0;for(let e of o.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);l.push(t),u=(u+n)%10}if(!this.isNaturalWin(c,u)){let e=this.shouldDrawThirdPlayerCard(c),t=null;e&&(t=this.mapRandomValueToCardValue(a[2]),s.push(this.mapRandomValueToCard(a[2])),c=(c+t)%10),this.shouldDrawThirdBankerCard(u,t)&&(l.push(this.mapRandomValueToCard(o[2])),u=(u+this.mapRandomValueToCardValue(o[2]))%10)}let d;d=c===u?`TIE`:c>u?`PLAYER_WIN`:`BANKER_WIN`;let f=w(n),{betType:p,multiplier:m}=he[d],h={legs:n.bets.map(e=>e.type===p?{amount:e.amount.mul(m)}:{amount:ge(d,e.type)?e.amount:new t(`0`)})},g=C(h);return{isFinished:!0,payout:h,payoutMultiplier:f.gt(0)?g.div(f):new t(0),outputs:{playerCards:s,playerHandValue:c,bankerCards:l,bankerHandValue:u,gameOutcome:d,result:r.values},randomValues:r}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new S(e);return{suit:t.suit,rank:fe[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let ve=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),ye=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),be=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),xe=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),Se=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const T=2.5,Ce=2,we=1,Te=0,Ee=17,De=21,Oe=21,ke=63,E=.5,Ae=3,je=1,Me=1,Ne=13,Pe=10,Fe=10,D={PLAYER_BLACKJACK:T,WIN:2,PUSH:1,LOSE:0},O={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},k={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var A=class t extends S{get numericRank(){return ce.includes(this.rank)?10:se.indexOf(this.rank)+1}static fromValue(n){return e.against(!ae.includes(n),`Invalid card value: ${n}`),new t(n)}},j=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},M=class{cards;value;constructor(e){this.cards=e.map(e=>A.fromValue(e)),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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},Ie=class e extends M{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=A.fromValue(e),this.holeCard=A.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new j([this.upCard]).highestHandValue}}},N=class e extends M{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}},P=class t{source;index=0;constructor(e){this.source=e}static from(n,r){return e.against(r<=0,`Count must be positive, got ${r}`),e.against(n.values.length!==r,`Expected ${r} values, got ${n.values.length}`),new t(n)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return e.againstUndefined(t,`RandomValuePool exhausted`),this.index+=1,t}take(t){e.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let n=this.source.values.slice(this.index,this.index+t);return this.index+=t,n}},Le=class{gameId;edge;constructor(e,t){this.gameId=e,this.edge=t,this.validateEdge(t)}play(t,n,r=[]){let a=this.createGameStore(),o=this.generateRandomValues(t),s=o.toMultipleRandomValues();for(let e of r)a.send({...e.playerArgument,randomValuePool:o});let c=r[r.length-1];c&&e.against(!i(c.state,this.toExternalState(a.getSnapshot().context.state)),`The final state of the game does not match the expected state based on the previous actions`),a.send({...n,randomValuePool:o});let l=a.getSnapshot().context;return{playerArgument:l.playerArgument,state:this.toExternalState(l.state),config:l.config,additionalBetAmount:l.additionalBetAmount,proof:{proofHash:s.proofHash,proofString:s.proofString}}}validateEdge(t){let n=this.supportedEdgeConfigurations.includes(t);e.against(!n,()=>o.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}};const Re=e=>[e.pairBonus===null?null:{amount:t(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:t(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),ze=n=>{let r=n.betAmounts.mainBetAmount,i=n.actionType===`BLACKJACK_DOUBLE_DOWN`?r.mul(1):t(0),a=n.insuranceOutcome===void 0?t(0):n.insuranceStake,o=r.plus(i).mul(D[n.outcome]),s=n.insuranceOutcome===`WON`?a.mul(3):t(0),c=Re(n.sideBetResults),l=[{amount:o},...n.insuranceOutcome===void 0?[]:[{amount:s}],...c],u=C({legs:l}),d=r.plus(a).plus(i).plus(n.betAmounts.pairBonusAmount).plus(n.betAmounts.threeCardBonusAmount);e.against(d.eq(0),`Total bet amount cannot be zero`);let f=u.div(d);e.against(n.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let p;switch(n.actionType){case`BLACKJACK_DOUBLE_DOWN`:p=i;break;case`BLACKJACK_BUY_INSURANCE`:p=n.insuranceStake;break;case`BLACKJACK_SPLIT`:p=r.mul(1)}return{payouts:l,totalBetAmount:d,multiplier:f,additionalBetAmount:p}},Be=n=>{let r=n.betAmounts.mainBetAmount,i=n.mainHandDoubledDown?r.mul(1):t(0),a=n.splitHandDoubledDown?r.mul(1):t(0),o=n.insuranceOutcome===void 0?t(0):n.insuranceStake,s=r.plus(i).mul(D[n.mainOutcome]),c=r.plus(a).mul(D[n.splitOutcome]),l=n.insuranceOutcome===`WON`?o.mul(3):t(0),u=Re(n.sideBetResults),d=[{amount:s},{amount:c},...n.insuranceOutcome===void 0?[]:[{amount:l}],...u],f=C({legs:d}),p=r.plus(r).plus(o).plus(i).plus(a).plus(n.betAmounts.pairBonusAmount).plus(n.betAmounts.threeCardBonusAmount);e.against(p.eq(0),`Total bet amount cannot be zero`);let m=f.div(p),h;switch(n.actionType){case`BLACKJACK_DOUBLE_DOWN`:h=r.mul(1);break;case`BLACKJACK_SPLIT`:h=r.mul(1)}return{payouts:d,totalBetAmount:p,multiplier:m,additionalBetAmount:h}},Ve=(e,t)=>t(e.mul(E)),F=e=>e.every(t=>t===e[0]),He=t=>{let n=[...t].sort((e,t)=>e-t);return n.every((t,r)=>{let i=n[r-1];return r===0||(e.againstUndefined(i,`Previous value cannot be undefined`),t===i+1)})},Ue={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},We={...Ue,Ace:14},Ge=e=>He(e.map(e=>Ue[e]))||He(e.map(e=>We[e])),Ke=(e,t)=>{let n=A.fromValue(e),r=A.fromValue(t);return n.rank===r.rank?e===t?`EXACT_PAIR`:le[n.suit]===le[r.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},qe=(e,t)=>({betAmount:e,result:t,payoutMultiplier:O[t]}),Je=(e,t,n)=>{let r=A.fromValue(e),i=A.fromValue(t),a=A.fromValue(n),o=[r.rank,i.rank,a.rank],s=F([r.suit,i.suit,a.suit]),c=F(o),l=Ge(o);return F([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Ye=(e,t)=>({betAmount:e,result:t,payoutMultiplier:k[t]}),Xe={state:{isFinished:!1,phase:`uninitialised`,multiplier:t(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},I=e=>A.fromValue(e).value;function Ze(t){e.against(t.phase!==`in-progress`,`Expected a started, in-progress game state`)}function Qe(t){e.against(t.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function L(t){e.against(t.phase!==`in-progress`&&t.phase!==`playing-main-hand`&&t.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const $e=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([I(e.takeOne())]);return n},R=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},et=e=>e.insuranceOutcome===void 0?t(0):e.calculateStake(e.betAmounts.mainBetAmount),tt=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=ze({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:et(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},nt=e=>{let t=$e(e.randomValuePool,e.dealerHand),n=R(e.playerHand,t);return tt({...e,dealerHand:t,outcome:n})},rt=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:$e(e.randomValuePool,e.dealerHand),n=R(e.mainHand,t),r=R(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=Be({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:et(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var it=class extends Le{roundInsuranceStake;constructor(e,t){super(`BLACKJACK`,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return P.from(e.getRandomIntsWithReplacement({min:0,max:51,count:63}),63)}toExternalState(t){let n=t.phase;switch(n){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,payout:t.payout,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,payout:t.payout,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 Error(`Cannot convert uninitialised state to external state`);default:e.againstNever(n,`Invalid state received`)}}createGameStore(){let n=t=>{let n=Ve(t,this.roundInsuranceStake);return e.against(t.gt(0)&&n.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),n},i=e=>tt({...e,calculateStake:n}),a=e=>nt({...e,calculateStake:n}),o=e=>rt({...e,calculateStake:n});return r({context:Xe,on:{START:(n,r)=>{let{state:a}=n;e.against(a.phase!==`uninitialised`,`START action requires a fresh game`);let o=I(r.randomValuePool.takeOne()),s=I(r.randomValuePool.takeOne()),c=I(r.randomValuePool.takeOne()),l=I(r.randomValuePool.takeOne()),u=N.withInitialDeal([o,s]),d=Ie.withInitialDeal({upCard:c,holeCard:l}),f={mainBetAmount:t(r.mainBetAmount),pairBonusAmount:t(r.pairBonusAmount),threeCardBonusAmount:t(r.threeCardBonusAmount)},p={pairBonus:t(r.pairBonusAmount).gt(0)?qe(r.pairBonusAmount,Ke(o,s)):null,threeCardBonus:t(r.threeCardBonusAmount).gt(0)?Ye(r.threeCardBonusAmount,Je(o,s,c)):null},m={type:`START`,mainBetAmount:r.mainBetAmount,pairBonusAmount:r.pairBonusAmount,threeCardBonusAmount:r.threeCardBonusAmount};if(d.upCard.rank===`Ace`)return{state:{...a,isFinished:!1,phase:`awaiting-insurance`,playerHand:u,dealerHand:d,betAmounts:f,sideBetResults:p},config:{},playerArgument:m};let h={playerHand:u,dealerHand:d,randomValuePool:r.randomValuePool,playerArgument:m,betAmounts:f,sideBetResults:p};return u.isBlackjack&&d.isBlackjack?i({...h,outcome:`PUSH`}):u.isBlackjack?i({...h,outcome:`PLAYER_BLACKJACK`}):d.isBlackjack?i({...h,outcome:`LOSE`}):{state:{...a,isFinished:!1,phase:`in-progress`,playerHand:u,dealerHand:d,insuranceOutcome:void 0,betAmounts:f,sideBetResults:p},config:{},playerArgument:m}},BLACKJACK_BUY_INSURANCE:(e,t)=>{let{state:r}=e;Qe(r);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=r,l={...r,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?i({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?i({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?i({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...r,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:n(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,t)=>{let{state:n}=e;Qe(n);let{playerHand:r,dealerHand:a,betAmounts:o,sideBetResults:s}=n,c={playerHand:r,dealerHand:a,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return r.isBlackjack&&a.isBlackjack?i({...c,outcome:`PUSH`}):r.isBlackjack?i({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?i({...c,outcome:`LOSE`}):{state:{...n,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(t,n)=>{let{state:r}=t;switch(L(r),r.phase){case`playing-main-hand`:{let e=r.mainHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r.splitHand.highestHandValue===21?o({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...r,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...r,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=r.splitHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?o({...r,splitHand:e,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...r,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=r.playerHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return e.isBusted?i({...r,playerHand:e,outcome:`LOSE`,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?a({...r,playerHand:e,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...r,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:e.againstNever(r,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(t,n)=>{let{state:r}=t;switch(L(r),r.phase){case`playing-main-hand`:return r.splitHand.highestHandValue===21?o({...r,splitHandDoubledDown:!1,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...r,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return o({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return a({...r,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:e.againstNever(r,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(t,n)=>{let{state:r}=t;switch(L(r),r.phase){case`playing-main-hand`:{e.against(r.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let t=r.mainHand.addDrawnCards([I(n.randomValuePool.takeOne())]),{betAmounts:i}=r;return r.splitHand.highestHandValue===21?o({...r,mainHand:t,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...r,phase:`playing-split-hand`,mainHand:t,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:i.mainBetAmount.mul(1)}}case`playing-split-hand`:{e.against(r.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let t=r.splitHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return o({...r,splitHand:t,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},splitHandDoubledDown:!0})}case`in-progress`:{e.against(r.playerHand.cards.length!==2,`Double down is only allowed as the first action`);let t=r.playerHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return t.isBusted?i({...r,playerHand:t,outcome:`LOSE`,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):a({...r,playerHand:t,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:e.againstNever(r,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(n,r)=>{let{state:i}=n;Ze(i);let{playerHand:a,betAmounts:s,sideBetResults:c}=i;e.against(a.cards.length!==2,`Split is only allowed with exactly 2 cards`);let l=a.cards[0],u=a.cards[1];e.againstUndefined(l,`First card is missing`),e.againstUndefined(u,`Second card is missing`),e.against(l.rank!==u.rank,`Split requires two cards of the same rank`);let d=I(r.randomValuePool.takeOne()),f=I(r.randomValuePool.takeOne()),p=N.withInitialDeal([l.value,d]),m=N.withInitialDeal([u.value,f]);if(l.rank===`Ace`)return o({...i,mainHand:p,splitHand:m,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let h=p.highestHandValue===21,g=m.highestHandValue===21;return h&&g?o({mainHand:p,splitHand:m,dealerHand:i.dealerHand,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:i.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:s,sideBetResults:c}):h?{state:{...i,phase:`playing-split-hand`,mainHand:p,splitHand:m,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:s.mainBetAmount.mul(1)}:{state:{...i,phase:`playing-main-hand`,multiplier:t(0),mainHand:p,splitHand:m,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:s.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let e=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return t.mainHand.cards.length===2&&e.push(`BLACKJACK_DOUBLE_DOWN`),e}case`playing-split-hand`:{let e=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return t.splitHand.cards.length===2&&e.push(`BLACKJACK_DOUBLE_DOWN`),e}case`player-turn`:{let n=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(t.playerHand.cards.length===2){n.push(`BLACKJACK_DOUBLE_DOWN`);let r=t.playerHand.cards[0],i=t.playerHand.cards[1];e.againstUndefined(r,`First player card is missing`),e.againstUndefined(i,`Second player card is missing`),r.rank===i.rank&&n.push(`BLACKJACK_SPLIT`)}return n}default:e.againstNever(t,`Invalid phase for getting valid actions`)}}};const at=0,ot=51,st=52,ct=52,lt=()=>({minPicks:5,maxPicks:36}),ut=e=>e.length===new Set(e).size,dt=e=>{let n=t(1),r=t(52);for(let i=0;i<e;i+=1)n=n.mul(t(52-i).div(r));return n};var ft=class extends c{constructor(){super(`BLITZ`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:n,gameInputs:r,edge:i}){e.against(r.pickCount<1||r.pickCount>52,`pickCount must be between 1 and 52`),e.againstNonInteger(r.pickCount,`pickCount must be an integer`);let a=n.getRandomIntsWithReplacement({min:0,max:51,count:52}),o=a.values.slice(0,r.pickCount),s=ut(o),c=dt(r.pickCount),u=s?l.withMultiplier(t(1).div(c),i):t(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(u)}]},payoutMultiplier:u,outputs:{result:a.values,cards:o.map(e=>new S(e).toDto())},randomValues:a}}};const pt=0,mt=4294967295;let ht=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const gt={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},_t={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},vt={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},yt={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},bt=e=>{let t=z[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},z={EASY:gt,MEDIUM:_t,HARD:vt,EXPERT:yt};var xt=class extends c{constructor(){super(`DARTS`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:n,gameInputs:r}){let i=n.getRandomIntsWithReplacement({min:0,max:mt,count:2}),a=i.values[0],o=i.values[1];e.againstUndefined(a,`Random number generator returned no value for clockWiseRotation`),e.againstUndefined(o,`Random number generator returned no value for distanceFromCentre`);let s=r.difficultyLevel,c=t(St(s,a,o));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:i.values},randomValues:i}}};const St=(e,t,n)=>{let r=z[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?Ct(r,t):a.ringFour},Ct=(t,n)=>{let r=t.segments.length,i=Math.floor(n/4294967296*r),a=t.segments[i];return e.againstUndefined(a,`Segment index ${i} out of bounds`),t.multipliers.ringThree[a]};var B=class{multipliers;constructor(e){this.multipliers=e}getMultipliers(e){let t=this.multipliers.get(e);if(t===void 0)throw Error(`Multipliers for ${e} not found`);return t}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([e,t])=>({edge:e,multipliers:t}))}};let wt=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const Tt=new B(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),Et={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var Dt=class extends c{constructor(){super(`DIAMONDS`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){let i=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),a=Tt.getMultipliers(n),o=i.values,s=t(this.calculatePayoutMultiplier(a,o));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:i.values},randomValues:i}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=Et[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let Ot=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const kt=0,V=1e4,At=10001,jt=e=>{let n=e.direction===`ABOVE`?V-e.selectedValue:e.selectedValue;return new t(n).div(At).mul(100)},Mt=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var Nt=class extends c{constructor(){super(`DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){let i=e.getRandomInt({min:0,max:V}),a=jt(r),o=Mt(r,i.value)?l.withWinChance(n,a):new t(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}};let Pt=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Ft=[1,2,3,4,5,6,7,8,9,10],It=e=>Ft.includes(e),Lt={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},Rt={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},zt={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},Bt={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},Vt={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},Ht=new B(new Map([[1,Lt],[2,Rt],[3,zt],[4,Bt],[8,Vt]]));var Ut=class extends c{constructor(){super(`KENO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:n,edge:r,gameInputs:i}){e.againstEmptyArray(i.selectedNumbers,()=>o.createValidationError(`No numbers selected`)),e.against(i.selectedNumbers.length>10,()=>o.createValidationError(`Maximum of 10 numbers can be selected`));for(let t of i.selectedNumbers)e.againstNonInteger(t,()=>o.createValidationError(`Only integers can be selected`)),e.against(t<0||t>39,()=>o.createValidationError(`Invalid number selected`));let a=n.getUniqueRandomInts({min:0,max:39,count:10}),s=i.selectedNumbers.filter(e=>a.values.includes(e)),c=i.selectedNumbers.length;if(!It(c))throw Error(`Invalid tile count: ${c}`);let l=Ht.getMultipliers(r)[c][i.riskLevel][s.length];if(l===void 0)throw Error(`No multiplier found for matching tile count ${s.length}`);let u=new t(l);return{isFinished:!0,payout:{legs:[{amount:i.betAmount.mul(u)}]},payoutMultiplier:u,outputs:{result:a.values},randomValues:a}}};const Wt=(e,t)=>e.gt(t)?e:t,Gt=(e,t)=>e.lt(t)?e:t;var Kt=class extends c{constructor(){super(`LIMBO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){let i=e.getRandomInt({min:1,max:4294967295}),a=i.max,o=new t(16777216),s=new t(1),c=new t(1e6),l=i.value,u=new t(l-1).div(a),d=(100-n)/100,f=o.div(u.mul(o).plus(1)).mul(d),p=Wt(s,Gt(f,c)),m=p.gte(r.targetMultiplier)?new t(r.targetMultiplier):new t(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{randomMultiplier:p,result:i.values},randomValues:i}}};const H=(e,t)=>{if(t<0||e<0||t>e)throw Error(`Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.`);t>e-t&&(t=e-t);let n=1;for(let r=1;r<=t;r++)n=n*(e-r+1)/r;return n};var qt=class extends c{constructor(){super(`MINES`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(r.selectedTiles.length>25-r.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let i=e.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),a=i.values.some(e=>r.selectedTiles.includes(e)),o=r.hasCashedOut||a,s=(100-n)/100,c=new t(H(25-r.minesCount,r.selectedTiles.length)).div(new t(H(25,r.selectedTiles.length))),l=r.hasCashedOut&&!a?new t(s).div(c):new t(0);return{isFinished:o,payout:{legs:[{amount:r.betAmount.mul(l)}]},payoutMultiplier:l,outputs:{result:i.values},randomValues:i}}};let Jt=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Yt=[8,9,10,11,12,13,14,15,16],Xt=new B(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var Zt=class extends c{constructor(){super(`PLINKO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:r}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let i=t.numberOfRows,a=Xt.getMultipliers(r)[t.riskLevel][i],o=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),s=o.values.reduce((e,t)=>e+t,0),c=a[s];if(c===void 0)throw Error(`No payout found for end position ${s}`);let l=n(c);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(l)}]},payoutMultiplier:l,outputs:{result:o.values},randomValues:o}}};const U=[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],Qt=[37,...U],$t=[[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]],en=[[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]],tn=[[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]],nn=[[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]],rn=[[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]],an=[[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]],on=[0,1,2,3,37],sn=[[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]],cn=[[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]];let W=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),G=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),K=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),q=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),J=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),ln=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const Y=2.7,X=5.3,Z=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw o.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Q(e.value)))throw o.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&un(e.values)))throw o.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&dn(e.values)))throw o.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&fn(e.values)))throw o.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&pn(e.values)))throw o.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw o.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw o.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw o.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw o.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw o.createValidationError(`Invalid dozen bet.`)},Q=e=>U.includes(e),un=e=>e.length!==2||!e.every(Q)?!1:$t.some(([t,n])=>t===e[0]&&n===e[1]),dn=e=>e.length!==3||!e.every(Q)?!1:tn.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),fn=e=>e.length!==4||!e.every(Q)?!1:rn.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),pn=e=>e.length!==6||!e.every(Q)?!1:sn.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),mn=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw o.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&$(e.value)))throw o.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&hn(e.values)))throw o.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&gn(e.values)))throw o.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&_n(e.values)))throw o.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw o.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&vn(e.values)))throw o.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw o.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw o.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw o.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw o.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw o.createValidationError(`Invalid dozen bet.`)},$=e=>Qt.includes(e);function hn(e){return e.length!==2||!e.every($)?!1:en.some(([t,n])=>t===e[0]&&n===e[1])}const gn=e=>e.length!==3||!e.every($)?!1:nn.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),_n=e=>e.length!==4||!e.every($)?!1:an.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),vn=e=>e.length!==6||!e.every($)?!1:cn.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),yn=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw o.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},bn=(e,t)=>{yn(e,t),e.type===`EUROPEAN`?Z(e.inputs):mn(e.inputs)},xn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Sn=[3,6,9,12,15,18,21,24,27,30,33,36],Cn=[2,5,8,11,14,17,20,23,26,29,32,35],wn=[1,4,7,10,13,16,19,22,25,28,31,34],Tn=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],En=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var Dn=class extends c{constructor(){super(`ROULETTE`)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let r=this.getBetTotals(e),i=this.calculateTotalBetAmount(r),a={legs:this.calculatePayoutLegs(e,t)},o=C(a);return{payoutMultiplier:i.gt(0)?o.div(i):new n(0),payout:a}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new n(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return Tn.includes(t)&&n.color===`RED`||En.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return Sn.includes(t)&&n.column===`TOP`||Cn.includes(t)&&n.column===`MIDDLE`||wn.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new n(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(r=>{let i=xn[r],a=this.betPredicates[r];return e[r].map(e=>a(e,t)?{amount:e.amount.mul(i||0)}:{amount:new n(`0`)})})}},On=class extends Dn{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[Y]}validateInputs(e){Z(e)}},kn=class extends Dn{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(e){mn(e)}isWinningBasketBet(e,t){return on.some(e=>e===t)}},An=class extends c{europeanGame;americanGame;constructor(){super(`ROULETTE`),this.europeanGame=new On,this.americanGame=new kn}get supportedEdgeConfigurations(){return[Y,X]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if(bn(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const jn=e=>new An().getBetAmount(e);let Mn=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({}),Nn=function(e){return 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`,e}({});const Pn=new B(new Map([[1,{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}}}],[2,{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}}}],[3,{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}}}],[4,{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}}}],[8,{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}}}]])),Fn={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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`]}};var In=class extends c{constructor(){super(`WHEEL`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:r}){if(!Object.values(Nn).includes(t.segments))throw Error(`Invalid segments value`);if(!Object.values(Mn).includes(t.riskLevel))throw Error(`Invalid risk level`);let i=Pn.getMultipliers(r)[t.riskLevel];if(i===void 0)throw Error(`No multipliers found for risk level ${t.riskLevel}`);let a=i[t.segments];if(a===void 0)throw Error(`No multipliers found for segment ${t.segments}`);let o=Fn[t.riskLevel];if(o===void 0)throw Error(`No patterns found for risk level ${t.riskLevel}`);let s=o[t.segments];if(s===void 0)throw Error(`No patterns found for segment ${t.segments}`);let c=e.getRandomInt({min:0,max:s.length-1}),l=s[c.value];if(l===void 0)throw Error(`No pattern found for segment ${t.segments} and value ${c.value}`);let u=a[l];if(u===void 0)throw Error(`No payout found for picked segment ${l}`);let d=new n(u);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(d)}]},payoutMultiplier:d,outputs:{result:c.values},randomValues:c}}};export{Pe as ACE_SOFT_BONUS,on as AMERICAN_BASKET,X as AMERICAN_HOUSE_EDGE,ie as AdvancedDice,kn as AmericanRoulette,D as BASE_PAYOUT_MULTIPLIERS,T as BLACKJACK_MULTIPLIER,Oe as BLACKJACK_VALUE,En as BLACK_NUMBERS,st as BLITZ_CARD_COUNT,ot as BLITZ_MAX_CARD_RANGE,at as BLITZ_MIN_CARD_RANGE,ct as BLITZ_RANDOM_NUMBER_COUNT,wn as BOTTOM_COLUMN,De as BUST_VALUE,_e as Baccarat,me as BaccaratBetType,pe as BaccaratOutcome,it as Blackjack,be as BlackjackActionType,ve as BlackjackOutcome,ft as Blitz,Ne as CARDS_PER_SUIT,G as Color,q as Column,z as DARTS_BOARD_CONFIGS,ht as DARTS_DIFFICULTY_LEVEL,mt as DARTS_MAX_VALUE,pt as DARTS_MIN_VALUE,Ee as DEALER_STAND_VALUE,At as DICE_EFFECTIVE_RANGE,V as DICE_MAX_ROLL,kt as DICE_MIN_ROLL,je as DOUBLE_DOWN_BET_SIZE_FACTOR,xt as Darts,Dt as Diamonds,wt as DiamondsResultType,Nt as Dice,Ot as DiceDirection,J as Dozen,f as EFFECTIVE_RANGE,Y as EUROPEAN_HOUSE_EDGE,On as EuropeanRoulette,Fe as FACE_CARD_VALUE,o as GameError,a as GameErrorCode,K as Half,E as INSURANCE_BET_SIZE_FACTOR,Ae as INSURANCE_WIN_MULTIPLIER,ye as InsuranceOutcome,Ut as Keno,Pt as KenoRiskLevel,Te as LOSE_MULTIPLIER,Kt as Limbo,ke as MAX_CARDS_PER_ROUND,m as MAX_WIN_CHANCE,Cn as MIDDLE_COLUMN,p as MIN_WIN_CHANCE,qt as Mines,Le as MultiActionGame,l as MultiplierCalculator,s as OrigamiGame,O as PAIR_BONUS_PAYOUTS,xn as PAYOUT_MULTIPLIERS,Yt as PLINKO_ROW_COUNTS,we as PUSH_MULTIPLIER,xe as PairBonusType,W as Parity,Zt as Plinko,Jt as PlinkoRiskLevel,d as RANDOM_MAX_VALUE,u as RANDOM_MIN_VALUE,Tn as RED_NUMBERS,P as RandomValuePool,ne as RollType,An as Roulette,ln as RouletteType,Me as SPLIT_BET_SIZE_FACTOR,c as SingleActionGame,k as THREE_CARD_BONUS_PAYOUTS,Ft as TILE_COUNTS,Sn as TOP_COLUMN,Se as ThreeCardBonusType,an as VALID_AMERICAN_CORNERS,cn as VALID_AMERICAN_DOUBLE_STREETS,en as VALID_AMERICAN_SPLITS,Qt as VALID_AMERICAN_STRAIGHTS,nn as VALID_AMERICAN_STREETS,rn as VALID_EUROPEAN_CORNERS,sn as VALID_EUROPEAN_DOUBLE_STREETS,$t as VALID_EUROPEAN_SPLITS,U as VALID_EUROPEAN_STRAIGHTS,tn as VALID_EUROPEAN_STREETS,de as VALID_RANKS,ue as VALID_SUITS,Ce as WIN_MULTIPLIER,In as Wheel,Mn as WheelRiskLevel,Nn as WheelSegments,b as advancedDiceGetExclusiveBoundsRange,v as advancedDiceGetInclusiveBoundsRange,y as advancedDiceIsWithinBoundsExclusive,te as advancedDiceIsWithinBoundsInclusive,Wt as bigMax,Gt as bigMin,x as calculateAdvancedDiceWinChance,w as calculateBaccaratBetAmount,dt as calculateBlitzWinChance,jt as calculateDiceWinChance,Ve as calculateInsuranceStake,jn as calculateRouletteBetAmount,Tt as diamondsMultipliers,lt as getBlitzDefaults,bt as getMaxMultiplierForDifficulty,ut as hasBlitzWon,Mt as hasDiceWon,It as isTileCount,Ht as kenoMultipliers,H as nCr,Xt as plinkoMultipliers,Vt as rtp92Multipliers,Bt as rtp96Multipliers,zt as rtp97Multipliers,Rt as rtp98Multipliers,Lt as rtp99Multipliers,C as sumPayout,re as validateAdvancedDiceInputs,bn as validateRouletteGameInputs};
|
|
1
|
+
import{CARD_RANKS as e,CARD_SUIT_COLORS as t,CARD_VALUES as n,Card as r,FACE_CARD_RANKS as i,GameError as a,MAX_CARD_VALUE as o,MIN_CARD_VALUE as s,MultiActionGame as c,MultiplierCalculator as l,MultiplierContainer as u,OrigamiGame as d,RandomValuePool as f,SingleActionGame as p,bigMax as m,bigMin as ee,nCr as te,sumPayout as h}from"@betorigami/game-engine";import g,{Big as _}from"big.js";import{Guard as v}from"@betorigami/guard";import{createStore as ne}from"@xstate/store";export*from"@betorigami/game-engine";const re=0,y=1e4,b=10001,ie=.01,ae=98,oe=e=>{if(e<0)throw a.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},se=e=>{if(e>1e4)throw a.createValidationError(`Upper bound ${e} is above maximum allowed value ${y}`)},x=e=>{if(oe(e.lower),se(e.upper),e.lower>=e.upper)throw a.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ce=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw a.createValidationError(`Bounds must not overlap`)},le=(e,t)=>t>=e.lower&&t<=e.upper,ue=e=>e.upper-e.lower+1,S=(e,t)=>t>e.lower&&t<e.upper,C=e=>e.upper-e.lower-1;let de=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const w=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return x(e.bounds),C(e.bounds);case`ROLL_OUTSIDE`:return x(e.bounds),b-ue(e.bounds);case`ROLL_BETWEEN_TWO`:return x(e.firstBounds),x(e.secondBounds),ce(e.firstBounds,e.secondBounds),C(e.firstBounds)+C(e.secondBounds)}})(),n=_(t).div(b).mul(100);if(n.lt(.01))throw a.createValidationError(`Win chance too low`);if(n.gt(98))throw a.createValidationError(`Win chance too high`);return n},fe=e=>{w(e)};var pe=class extends p{constructor(){super(d.ADVANCED_DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=w(n),i=e.getRandomInt({min:0,max:y}),a=i.value,o=(()=>{switch(n.mode){case`ROLL_BETWEEN`:return S(n.bounds,a);case`ROLL_OUTSIDE`:return!le(n.bounds,a);case`ROLL_BETWEEN_TWO`:return S(n.firstBounds,a)||S(n.secondBounds,a)}})()?l.withWinChance(t,r):new _(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}};const me=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],he=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],ge={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`};let _e=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),ve=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const ye={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},T=e=>new g(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new g(0))),be=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var xe=class extends p{constructor(){super(d.BACCARAT)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return T(e)}determineGameResult({generator:e,gameInputs:t}){this.validateGameInputs(t);let n=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),r=n.values,i=r.slice(0,3),a=r.slice(3,6),o=[],s=0;for(let e of i.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);o.push(t),s=(s+n)%10}let c=[],l=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);c.push(t),l=(l+n)%10}if(!this.isNaturalWin(s,l)){let e=this.shouldDrawThirdPlayerCard(s),t=null;e&&(t=this.mapRandomValueToCardValue(i[2]),o.push(this.mapRandomValueToCard(i[2])),s=(s+t)%10),this.shouldDrawThirdBankerCard(l,t)&&(c.push(this.mapRandomValueToCard(a[2])),l=(l+this.mapRandomValueToCardValue(a[2]))%10)}let u;u=s===l?`TIE`:s>l?`PLAYER_WIN`:`BANKER_WIN`;let d=T(t),{betType:f,multiplier:p}=ye[u],m={legs:t.bets.map(e=>e.type===f?{amount:e.amount.mul(p)}:{amount:be(u,e.type)?e.amount:new g(`0`)})},ee=h(m);return{isFinished:!0,payout:m,payoutMultiplier:d.gt(0)?ee.div(d):new g(0),outputs:{playerCards:o,playerHandValue:s,bankerCards:c,bankerHandValue:l,gameOutcome:u,result:n.values},randomValues:n}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new r(e);return{suit:t.suit,rank:ge[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let Se=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),Ce=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),we=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),Te=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),Ee=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const E=2.5,De=2,Oe=1,ke=0,Ae=17,je=21,Me=21,Ne=63,D=.5,Pe=3,Fe=1,Ie=1,Le=13,Re=10,ze=10,O={PLAYER_BLACKJACK:E,WIN:2,PUSH:1,LOSE:0},k={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},A={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var j=class t extends r{get numericRank(){return i.includes(this.rank)?10:e.indexOf(this.rank)+1}static fromValue(e){return v.against(!n.includes(e),`Invalid card value: ${e}`),new t(e)}},M=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},N=class{cards;value;constructor(e){this.cards=e.map(e=>j.fromValue(e)),this.value=new M(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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},Be=class e extends N{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=j.fromValue(e),this.holeCard=j.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new M([this.upCard]).highestHandValue}}},P=class e extends N{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}};const F=e=>[e.pairBonus===null?null:{amount:g(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:g(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),Ve=e=>{let t=e.betAmounts.mainBetAmount,n=e.actionType===`BLACKJACK_DOUBLE_DOWN`?t.mul(1):g(0),r=e.insuranceOutcome===void 0?g(0):e.insuranceStake,i=t.plus(n).mul(O[e.outcome]),a=e.insuranceOutcome===`WON`?r.mul(3):g(0),o=F(e.sideBetResults),s=[{amount:i},...e.insuranceOutcome===void 0?[]:[{amount:a}],...o],c=h({legs:s}),l=t.plus(r).plus(n).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);v.against(l.eq(0),`Total bet amount cannot be zero`);let u=c.div(l);v.against(e.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let d;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:d=n;break;case`BLACKJACK_BUY_INSURANCE`:d=e.insuranceStake;break;case`BLACKJACK_SPLIT`:d=t.mul(1)}return{payouts:s,totalBetAmount:l,multiplier:u,additionalBetAmount:d}},He=e=>{let t=e.betAmounts.mainBetAmount,n=e.mainHandDoubledDown?t.mul(1):g(0),r=e.splitHandDoubledDown?t.mul(1):g(0),i=e.insuranceOutcome===void 0?g(0):e.insuranceStake,a=t.plus(n).mul(O[e.mainOutcome]),o=t.plus(r).mul(O[e.splitOutcome]),s=e.insuranceOutcome===`WON`?i.mul(3):g(0),c=F(e.sideBetResults),l=[{amount:a},{amount:o},...e.insuranceOutcome===void 0?[]:[{amount:s}],...c],u=h({legs:l}),d=t.plus(t).plus(i).plus(n).plus(r).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);v.against(d.eq(0),`Total bet amount cannot be zero`);let f=u.div(d),p;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:p=t.mul(1);break;case`BLACKJACK_SPLIT`:p=t.mul(1)}return{payouts:l,totalBetAmount:d,multiplier:f,additionalBetAmount:p}},I=(e,t)=>t(e.mul(D)),L=e=>e.every(t=>t===e[0]),Ue=e=>{let t=[...e].sort((e,t)=>e-t);return t.every((e,n)=>{let r=t[n-1];return n===0||(v.againstUndefined(r,`Previous value cannot be undefined`),e===r+1)})},We={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},Ge={...We,Ace:14},Ke=e=>Ue(e.map(e=>We[e]))||Ue(e.map(e=>Ge[e])),qe=(e,n)=>{let r=j.fromValue(e),i=j.fromValue(n);return r.rank===i.rank?e===n?`EXACT_PAIR`:t[r.suit]===t[i.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},Je=(e,t)=>({betAmount:e,result:t,payoutMultiplier:k[t]}),Ye=(e,t,n)=>{let r=j.fromValue(e),i=j.fromValue(t),a=j.fromValue(n),o=[r.rank,i.rank,a.rank],s=L([r.suit,i.suit,a.suit]),c=L(o),l=Ke(o);return L([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Xe=(e,t)=>({betAmount:e,result:t,payoutMultiplier:A[t]}),Ze={state:{isFinished:!1,phase:`uninitialised`,multiplier:g(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},R=e=>j.fromValue(e).value;function Qe(e){v.against(e.phase!==`in-progress`,`Expected a started, in-progress game state`)}function $e(e){v.against(e.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function z(e){v.against(e.phase!==`in-progress`&&e.phase!==`playing-main-hand`&&e.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const et=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([R(e.takeOne())]);return n},B=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},tt=e=>e.insuranceOutcome===void 0?g(0):e.calculateStake(e.betAmounts.mainBetAmount),nt=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=Ve({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:tt(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},rt=e=>{let t=et(e.randomValuePool,e.dealerHand),n=B(e.playerHand,t);return nt({...e,dealerHand:t,outcome:n})},it=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:et(e.randomValuePool,e.dealerHand),n=B(e.mainHand,t),r=B(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=He({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:tt(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var at=class extends c{roundInsuranceStake;constructor(e,t){super(d.BLACKJACK,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return f.from(e.getRandomIntsWithReplacement({min:s,max:o,count:63}),63)}toExternalState(e){let t=e.phase;switch(t){case`awaiting-insurance`:return{isFinished:!1,phase:`awaiting-insurance`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`in-progress`:return{isFinished:!1,phase:`player-turn`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-main-hand`:return{isFinished:!1,phase:`playing-main-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-split-hand`:return{isFinished:!1,phase:`playing-split-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,outcome:e.outcome,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`split-finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,mainOutcome:e.mainOutcome,splitOutcome:e.splitOutcome,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`uninitialised`:throw Error(`Cannot convert uninitialised state to external state`);default:v.againstNever(t,`Invalid state received`)}}createGameStore(){let e=e=>{let t=I(e,this.roundInsuranceStake);return v.against(e.gt(0)&&t.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),t},t=t=>nt({...t,calculateStake:e}),n=t=>rt({...t,calculateStake:e}),r=t=>it({...t,calculateStake:e});return ne({context:Ze,on:{START:(e,n)=>{let{state:r}=e;v.against(r.phase!==`uninitialised`,`START action requires a fresh game`);let i=R(n.randomValuePool.takeOne()),a=R(n.randomValuePool.takeOne()),o=R(n.randomValuePool.takeOne()),s=R(n.randomValuePool.takeOne()),c=P.withInitialDeal([i,a]),l=Be.withInitialDeal({upCard:o,holeCard:s}),u={mainBetAmount:g(n.mainBetAmount),pairBonusAmount:g(n.pairBonusAmount),threeCardBonusAmount:g(n.threeCardBonusAmount)},d={pairBonus:g(n.pairBonusAmount).gt(0)?Je(n.pairBonusAmount,qe(i,a)):null,threeCardBonus:g(n.threeCardBonusAmount).gt(0)?Xe(n.threeCardBonusAmount,Ye(i,a,o)):null},f={type:`START`,mainBetAmount:n.mainBetAmount,pairBonusAmount:n.pairBonusAmount,threeCardBonusAmount:n.threeCardBonusAmount};if(l.upCard.rank===`Ace`)return{state:{...r,isFinished:!1,phase:`awaiting-insurance`,playerHand:c,dealerHand:l,betAmounts:u,sideBetResults:d},config:{},playerArgument:f};let p={playerHand:c,dealerHand:l,randomValuePool:n.randomValuePool,playerArgument:f,betAmounts:u,sideBetResults:d};return c.isBlackjack&&l.isBlackjack?t({...p,outcome:`PUSH`}):c.isBlackjack?t({...p,outcome:`PLAYER_BLACKJACK`}):l.isBlackjack?t({...p,outcome:`LOSE`}):{state:{...r,isFinished:!1,phase:`in-progress`,playerHand:c,dealerHand:l,insuranceOutcome:void 0,betAmounts:u,sideBetResults:d},config:{},playerArgument:f}},BLACKJACK_BUY_INSURANCE:(n,r)=>{let{state:i}=n;$e(i);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=i,l={...i,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?t({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?t({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?t({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...i,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:e(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,n)=>{let{state:r}=e;$e(r);let{playerHand:i,dealerHand:a,betAmounts:o,sideBetResults:s}=r,c={playerHand:i,dealerHand:a,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return i.isBlackjack&&a.isBlackjack?t({...c,outcome:`PUSH`}):i.isBlackjack?t({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?t({...c,outcome:`LOSE`}):{state:{...r,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(e,i)=>{let{state:a}=e;switch(z(a),a.phase){case`playing-main-hand`:{let e=a.mainHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?a.splitHand.highestHandValue===21?r({...a,mainHand:e,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...a,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=a.splitHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=a.playerHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:v.againstNever(a,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(e,t)=>{let{state:i}=e;switch(z(i),i.phase){case`playing-main-hand`:return i.splitHand.highestHandValue===21?r({...i,splitHandDoubledDown:!1,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...i,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return r({...i,splitHandDoubledDown:i.splitHandDoubledDown,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return n({...i,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:v.againstNever(i,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(e,i)=>{let{state:a}=e;switch(z(a),a.phase){case`playing-main-hand`:{v.against(a.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.mainHand.addDrawnCards([R(i.randomValuePool.takeOne())]),{betAmounts:t}=a;return a.splitHand.highestHandValue===21?r({...a,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:t.mainBetAmount.mul(1)}}case`playing-split-hand`:{v.against(a.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.splitHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},splitHandDoubledDown:!0})}case`in-progress`:{v.against(a.playerHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.playerHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:v.againstNever(a,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(e,t)=>{let{state:n}=e;Qe(n);let{playerHand:i,betAmounts:a,sideBetResults:o}=n;v.against(i.cards.length!==2,`Split is only allowed with exactly 2 cards`);let s=i.cards[0],c=i.cards[1];v.againstUndefined(s,`First card is missing`),v.againstUndefined(c,`Second card is missing`),v.against(s.rank!==c.rank,`Split requires two cards of the same rank`);let l=R(t.randomValuePool.takeOne()),u=R(t.randomValuePool.takeOne()),d=P.withInitialDeal([s.value,l]),f=P.withInitialDeal([c.value,u]);if(s.rank===`Ace`)return r({...n,mainHand:d,splitHand:f,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let p=d.highestHandValue===21,m=f.highestHandValue===21;return p&&m?r({mainHand:d,splitHand:f,dealerHand:n.dealerHand,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:n.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:a,sideBetResults:o}):p?{state:{...n,phase:`playing-split-hand`,mainHand:d,splitHand:f,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}:{state:{...n,phase:`playing-main-hand`,multiplier:g(0),mainHand:d,splitHand:f,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(e){if(e.isFinished)return[];switch(e.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.mainHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`playing-split-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.splitHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`player-turn`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(e.playerHand.cards.length===2){t.push(`BLACKJACK_DOUBLE_DOWN`);let n=e.playerHand.cards[0],r=e.playerHand.cards[1];v.againstUndefined(n,`First player card is missing`),v.againstUndefined(r,`Second player card is missing`),n.rank===r.rank&&t.push(`BLACKJACK_SPLIT`)}return t}default:v.againstNever(e,`Invalid phase for getting valid actions`)}}};const ot=0,st=51,ct=52,lt=52,ut=()=>({minPicks:5,maxPicks:36}),dt=e=>e.length===new Set(e).size,ft=e=>{let t=g(1),n=g(52);for(let r=0;r<e;r+=1)t=t.mul(g(52-r).div(n));return t};var pt=class extends p{constructor(){super(d.BLITZ)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){v.against(t.pickCount<1||t.pickCount>52,`pickCount must be between 1 and 52`),v.againstNonInteger(t.pickCount,`pickCount must be an integer`);let i=e.getRandomIntsWithReplacement({min:0,max:51,count:52}),a=i.values.slice(0,t.pickCount),o=dt(a),s=ft(t.pickCount),c=o?l.withMultiplier(g(1).div(s),n):g(0);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:i.values,cards:a.map(e=>new r(e).toDto())},randomValues:i}}};const mt=0,ht=4294967295;let gt=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const _t={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},vt={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},yt={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},bt={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},xt=e=>{let t=V[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},V={EASY:_t,MEDIUM:vt,HARD:yt,EXPERT:bt};var St=class extends p{constructor(){super(d.DARTS)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t}){let n=e.getRandomIntsWithReplacement({min:0,max:ht,count:2}),r=n.values[0],i=n.values[1];v.againstUndefined(r,`Random number generator returned no value for clockWiseRotation`),v.againstUndefined(i,`Random number generator returned no value for distanceFromCentre`);let a=t.difficultyLevel,o=g(Ct(a,r,i));return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}};const Ct=(e,t,n)=>{let r=V[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?wt(r,t):a.ringFour},wt=(e,t)=>{let n=e.segments.length,r=Math.floor(t/4294967296*n),i=e.segments[r];return v.againstUndefined(i,`Segment index ${r} out of bounds`),e.multipliers.ringThree[i]};let Tt=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const Et=new u(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),Dt={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var Ot=class extends p{constructor(){super(d.DIAMONDS)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),i=Et.getMultipliers(t),a=r.values,o=g(this.calculatePayoutMultiplier(i,a));return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=Dt[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let kt=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const At=0,H=1e4,jt=10001,Mt=e=>{let t=e.direction===`ABOVE`?H-e.selectedValue:e.selectedValue;return new g(t).div(jt).mul(100)},Nt=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var Pt=class extends p{constructor(){super(d.DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:0,max:H}),i=Mt(n),a=Nt(n,r.value)?l.withWinChance(t,i):new g(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(a)}]},payoutMultiplier:a,outputs:{result:r.values},randomValues:r}}};let Ft=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const It=[1,2,3,4,5,6,7,8,9,10],Lt=e=>It.includes(e),Rt={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},zt={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},Bt={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},Vt={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},Ht={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},Ut=new u(new Map([[1,Rt],[2,zt],[3,Bt],[4,Vt],[8,Ht]]));var Wt=class extends p{constructor(){super(d.KENO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){v.againstEmptyArray(n.selectedNumbers,()=>a.createValidationError(`No numbers selected`)),v.against(n.selectedNumbers.length>10,()=>a.createValidationError(`Maximum of 10 numbers can be selected`));for(let e of n.selectedNumbers)v.againstNonInteger(e,()=>a.createValidationError(`Only integers can be selected`)),v.against(e<0||e>39,()=>a.createValidationError(`Invalid number selected`));let r=e.getUniqueRandomInts({min:0,max:39,count:10}),i=n.selectedNumbers.filter(e=>r.values.includes(e)),o=n.selectedNumbers.length;if(!Lt(o))throw Error(`Invalid tile count: ${o}`);let s=Ut.getMultipliers(t)[o][n.riskLevel][i.length];if(s===void 0)throw Error(`No multiplier found for matching tile count ${i.length}`);let c=new g(s);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}},Gt=class extends p{constructor(){super(d.LIMBO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:1,max:4294967295}),i=r.max,a=new g(16777216),o=new g(1),s=new g(1e6),c=r.value,l=new g(c-1).div(i),u=(100-t)/100,d=a.div(l.mul(a).plus(1)).mul(u),f=m(o,ee(d,s)),p=f.gte(n.targetMultiplier)?new g(n.targetMultiplier):new g(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:f,result:r.values},randomValues:r}}},Kt=class extends p{constructor(){super(d.MINES)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){if(n.minesCount<=0||n.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(n.selectedTiles.length>25-n.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let r=e.getUniqueRandomInts({min:1,max:25,count:n.minesCount}),i=r.values.some(e=>n.selectedTiles.includes(e)),a=n.hasCashedOut||i,o=(100-t)/100,s=new g(te(25-n.minesCount,n.selectedTiles.length)).div(new g(te(25,n.selectedTiles.length))),c=n.hasCashedOut&&!i?new g(o).div(s):new g(0);return{isFinished:a,payout:{legs:[{amount:n.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}};let qt=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Jt=[8,9,10,11,12,13,14,15,16],Yt=new u(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var Xt=class extends p{constructor(){super(d.PLINKO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let r=t.numberOfRows,i=Yt.getMultipliers(n)[t.riskLevel][r],a=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),o=a.values.reduce((e,t)=>e+t,0),s=i[o];if(s===void 0)throw Error(`No payout found for end position ${o}`);let c=_(s);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:a.values},randomValues:a}}};const U=[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],Zt=[37,...U],Qt=[[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]],$t=[[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]],en=[[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]],tn=[[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]],nn=[[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]],rn=[[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]],an=[0,1,2,3,37],on=[[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]],sn=[[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]];let W=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),G=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),K=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),q=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),J=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),cn=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const Y=2.7,X=5.3,ln=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw a.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Z(e.value)))throw a.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&un(e.values)))throw a.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&dn(e.values)))throw a.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&fn(e.values)))throw a.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&pn(e.values)))throw a.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw a.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw a.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw a.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw a.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw a.createValidationError(`Invalid dozen bet.`)},Z=e=>U.includes(e),un=e=>e.length!==2||!e.every(Z)?!1:Qt.some(([t,n])=>t===e[0]&&n===e[1]),dn=e=>e.length!==3||!e.every(Z)?!1:en.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),fn=e=>e.length!==4||!e.every(Z)?!1:nn.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),pn=e=>e.length!==6||!e.every(Z)?!1:on.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),mn=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw a.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Q(e.value)))throw a.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&hn(e.values)))throw a.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&gn(e.values)))throw a.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&_n(e.values)))throw a.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw a.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&vn(e.values)))throw a.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw a.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw a.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw a.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw a.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw a.createValidationError(`Invalid dozen bet.`)},Q=e=>Zt.includes(e);function hn(e){return e.length!==2||!e.every(Q)?!1:$t.some(([t,n])=>t===e[0]&&n===e[1])}const gn=e=>e.length!==3||!e.every(Q)?!1:tn.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),_n=e=>e.length!==4||!e.every(Q)?!1:rn.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),vn=e=>e.length!==6||!e.every(Q)?!1:sn.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),yn=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw a.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},bn=(e,t)=>{yn(e,t),e.type===`EUROPEAN`?ln(e.inputs):mn(e.inputs)},xn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Sn=[3,6,9,12,15,18,21,24,27,30,33,36],Cn=[2,5,8,11,14,17,20,23,26,29,32,35],wn=[1,4,7,10,13,16,19,22,25,28,31,34],Tn=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],En=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var Dn=class extends p{constructor(){super(d.ROULETTE)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let n=this.getBetTotals(e),r=this.calculateTotalBetAmount(n),i={legs:this.calculatePayoutLegs(e,t)},a=h(i);return{payoutMultiplier:r.gt(0)?a.div(r):new _(0),payout:i}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new _(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return Tn.includes(t)&&n.color===`RED`||En.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return Sn.includes(t)&&n.column===`TOP`||Cn.includes(t)&&n.column===`MIDDLE`||wn.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new _(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(n=>{let r=xn[n],i=this.betPredicates[n];return e[n].map(e=>i(e,t)?{amount:e.amount.mul(r||0)}:{amount:new _(`0`)})})}},On=class extends Dn{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[Y]}validateInputs(e){ln(e)}},$=class extends Dn{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(e){mn(e)}isWinningBasketBet(e,t){return an.some(e=>e===t)}},kn=class extends p{europeanGame;americanGame;constructor(){super(d.ROULETTE),this.europeanGame=new On,this.americanGame=new $}get supportedEdgeConfigurations(){return[Y,X]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if(bn(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const An=e=>new kn().getBetAmount(e);export{Re as ACE_SOFT_BONUS,an as AMERICAN_BASKET,X as AMERICAN_HOUSE_EDGE,pe as AdvancedDice,$ as AmericanRoulette,O as BASE_PAYOUT_MULTIPLIERS,E as BLACKJACK_MULTIPLIER,Me as BLACKJACK_VALUE,En as BLACK_NUMBERS,ct as BLITZ_CARD_COUNT,st as BLITZ_MAX_CARD_RANGE,ot as BLITZ_MIN_CARD_RANGE,lt as BLITZ_RANDOM_NUMBER_COUNT,wn as BOTTOM_COLUMN,je as BUST_VALUE,xe as Baccarat,ve as BaccaratBetType,_e as BaccaratOutcome,at as Blackjack,we as BlackjackActionType,Se as BlackjackOutcome,pt as Blitz,Le as CARDS_PER_SUIT,G as Color,q as Column,V as DARTS_BOARD_CONFIGS,gt as DARTS_DIFFICULTY_LEVEL,ht as DARTS_MAX_VALUE,mt as DARTS_MIN_VALUE,Ae as DEALER_STAND_VALUE,jt as DICE_EFFECTIVE_RANGE,H as DICE_MAX_ROLL,At as DICE_MIN_ROLL,Fe as DOUBLE_DOWN_BET_SIZE_FACTOR,St as Darts,Ot as Diamonds,Tt as DiamondsResultType,Pt as Dice,kt as DiceDirection,J as Dozen,b as EFFECTIVE_RANGE,Y as EUROPEAN_HOUSE_EDGE,On as EuropeanRoulette,ze as FACE_CARD_VALUE,K as Half,D as INSURANCE_BET_SIZE_FACTOR,Pe as INSURANCE_WIN_MULTIPLIER,Ce as InsuranceOutcome,Wt as Keno,Ft as KenoRiskLevel,ke as LOSE_MULTIPLIER,Gt as Limbo,Ne as MAX_CARDS_PER_ROUND,ae as MAX_WIN_CHANCE,Cn as MIDDLE_COLUMN,ie as MIN_WIN_CHANCE,Kt as Mines,k as PAIR_BONUS_PAYOUTS,xn as PAYOUT_MULTIPLIERS,Jt as PLINKO_ROW_COUNTS,Oe as PUSH_MULTIPLIER,Te as PairBonusType,W as Parity,Xt as Plinko,qt as PlinkoRiskLevel,y as RANDOM_MAX_VALUE,re as RANDOM_MIN_VALUE,Tn as RED_NUMBERS,de as RollType,kn as Roulette,cn as RouletteType,Ie as SPLIT_BET_SIZE_FACTOR,A as THREE_CARD_BONUS_PAYOUTS,It as TILE_COUNTS,Sn as TOP_COLUMN,Ee as ThreeCardBonusType,rn as VALID_AMERICAN_CORNERS,sn as VALID_AMERICAN_DOUBLE_STREETS,$t as VALID_AMERICAN_SPLITS,Zt as VALID_AMERICAN_STRAIGHTS,tn as VALID_AMERICAN_STREETS,nn as VALID_EUROPEAN_CORNERS,on as VALID_EUROPEAN_DOUBLE_STREETS,Qt as VALID_EUROPEAN_SPLITS,U as VALID_EUROPEAN_STRAIGHTS,en as VALID_EUROPEAN_STREETS,he as VALID_RANKS,me as VALID_SUITS,De as WIN_MULTIPLIER,C as advancedDiceGetExclusiveBoundsRange,ue as advancedDiceGetInclusiveBoundsRange,S as advancedDiceIsWithinBoundsExclusive,le as advancedDiceIsWithinBoundsInclusive,w as calculateAdvancedDiceWinChance,T as calculateBaccaratBetAmount,ft as calculateBlitzWinChance,Mt as calculateDiceWinChance,I as calculateInsuranceStake,An as calculateRouletteBetAmount,Et as diamondsMultipliers,ut as getBlitzDefaults,xt as getMaxMultiplierForDifficulty,dt as hasBlitzWon,Nt as hasDiceWon,Lt as isTileCount,Ut as kenoMultipliers,Yt as plinkoMultipliers,Ht as rtp92Multipliers,Vt as rtp96Multipliers,Bt as rtp97Multipliers,zt as rtp98Multipliers,Rt as rtp99Multipliers,fe as validateAdvancedDiceInputs,bn as validateRouletteGameInputs};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betorigami/game-calculations",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@betorigami/game-engine": "0.0.0-sha-d6d1f10-20260907014734",
|
|
32
33
|
"@betorigami/guard": "^2.0.7",
|
|
33
34
|
"@xstate/store": "^3.16.0",
|
|
34
35
|
"big.js": "^7.0.1",
|