@betorigami/game-calculations 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- var Zr=Object.create;var{getPrototypeOf:Xr,defineProperty:w,getOwnPropertyNames:Er,getOwnPropertyDescriptor:Ir}=Object,Sr=Object.prototype.hasOwnProperty;var N=(r,i,o)=>{o=r!=null?Zr(Xr(r)):{};let e=i||!r||!r.__esModule?w(o,"default",{value:r,enumerable:!0}):o;for(let c of Er(r))if(!Sr.call(e,c))w(e,c,{get:()=>r[c],enumerable:!0});return e},tr=new WeakMap,sr=(r)=>{var i=tr.get(r),o;if(i)return i;if(i=w({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function")Er(r).map((e)=>!Sr.call(i,e)&&w(i,e,{get:()=>r[e],enumerable:!(o=Ir(r,e))||o.enumerable}));return tr.set(r,i),i};var br=(r,i)=>{for(var o in i)w(r,o,{get:i[o],enumerable:!0,configurable:!0,set:(e)=>i[o]=()=>e})};var Gi={};br(Gi,{wheelMultipliers:()=>zr,validateRouletteGameInputs:()=>_i,validateAdvancedDiceInputs:()=>oi,plinkoMultipliers:()=>Pr,calculateRouletteBetAmount:()=>yi,calculateBaccaratBetAmount:()=>Tr,WheelSegments:()=>nr,WheelRiskLevel:()=>cr,Wheel:()=>Wr,VALID_SUITS:()=>hr,VALID_RANKS:()=>xr,VALID_EUROPEAN_STREETS:()=>m,VALID_EUROPEAN_STRAIGHTS:()=>Y,VALID_EUROPEAN_SPLITS:()=>b,VALID_EUROPEAN_DOUBLE_STREETS:()=>or,VALID_EUROPEAN_CORNERS:()=>rr,VALID_AMERICAN_STREETS:()=>g,VALID_AMERICAN_STRAIGHTS:()=>s,VALID_AMERICAN_SPLITS:()=>u,VALID_AMERICAN_DOUBLE_STREETS:()=>er,VALID_AMERICAN_CORNERS:()=>ir,RouletteType:()=>F,Roulette:()=>$r,RollType:()=>Lr,RANDOM_MIN_VALUE:()=>a,RANDOM_MAX_VALUE:()=>j,PlinkoRiskLevel:()=>Hr,Plinko:()=>Ur,Parity:()=>K,OrigamiGame:()=>d,Mines:()=>vr,MIN_WIN_CHANCE:()=>Ar,MAX_WIN_CHANCE:()=>lr,Limbo:()=>Rr,KenoRiskLevel:()=>Nr,Keno:()=>Vr,Half:()=>D,GameErrorCode:()=>fr,GameError:()=>S,Game:()=>A,EFFECTIVE_RANGE:()=>Z,Dozen:()=>M,DiceDirection:()=>pr,Dice:()=>Mr,DiamondsResultType:()=>Cr,Diamonds:()=>Dr,Column:()=>p,Color:()=>C,BaccaratOutcome:()=>yr,BaccaratBetType:()=>_r,Baccarat:()=>Gr,AdvancedDice:()=>Br,AMERICAN_BASKET:()=>$});module.exports=sr(Gi);var d;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(d||={});class A{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}var U=require("big.js");var fr;((i)=>i.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(fr||={});class S extends Error{static createValidationError(r){return new S("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof S}errorCode;constructor(r,i){super(i);this.errorCode=r}}var a=0,j=1e4,Z=10001,Ar=0.01,lr=98,ur=(r)=>{if(r<a)throw S.createValidationError(`Lower bound ${r} is below minimum allowed value ${a}`)},mr=(r)=>{if(r>j)throw S.createValidationError(`Upper bound ${r} is above maximum allowed value ${j}`)},P=(r)=>{if(ur(r.lower),mr(r.upper),r.lower>=r.upper)throw S.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},gr=(r,i)=>{let[o,e]=r.lower<=i.lower?[r,i]:[i,r];if(o.upper>e.lower)throw S.createValidationError("Bounds must not overlap")},ri=(r,i)=>i>=r.lower&&i<=r.upper,ii=(r)=>r.upper-r.lower+1,J=(r,i)=>i>r.lower&&i<r.upper,Q=(r)=>r.upper-r.lower-1,Lr;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Lr||={});var dr=(r)=>{let o=(()=>{switch(r.mode){case"ROLL_BETWEEN":return P(r.bounds),Q(r.bounds);case"ROLL_OUTSIDE":return P(r.bounds),Z-ii(r.bounds);case"ROLL_BETWEEN_TWO":return P(r.firstBounds),P(r.secondBounds),gr(r.firstBounds,r.secondBounds),Q(r.firstBounds)+Q(r.secondBounds)}})(),e=U.Big(o).div(Z).mul(100);if(e.lt(Ar))throw S.createValidationError("Win chance too low");if(e.gt(lr))throw S.createValidationError("Win chance too high");return e},oi=(r)=>{dr(r)};class Br extends A{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=dr(o),c=r.getRandomInt({min:a,max:j}),n=c.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(o.mode){case"ROLL_BETWEEN":return J(o.bounds,n);case"ROLL_OUTSIDE":return!ri(o.bounds,n);case"ROLL_BETWEEN_TWO":return J(o.firstBounds,n)||J(o.secondBounds,n)}})()?new U.Big(100-i).div(e):new U.Big(0),outputs:{result:c.values},randomValues:c}}}var V=N(require("big.js"));var hr=["Clubs","Diamonds","Hearts","Spades"],xr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],yr;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(yr||={});var _r;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(_r||={});var ei={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Tr=(r)=>{return new V.default(0).add(r.bets.reduce((o,e)=>o.add(e.amount),new V.default(0)))};class Gr extends A{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(o!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(i);let e=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),c=e.values,n=c.slice(0,3),E=c.slice(3,6),L=[],l=0;for(let h of n.slice(0,2)){let x=this.mapRandomValueToCard(h),H=this.mapRandomValueToCardValue(h);L.push(x),l=(l+H)%10}let B=[],f=0;for(let h of E.slice(0,2)){let x=this.mapRandomValueToCard(h),H=this.mapRandomValueToCardValue(h);B.push(x),f=(f+H)%10}if(!this.isNaturalWin(l,f)){let h=this.shouldDrawThirdPlayerCard(l),x=null;if(h)x=this.mapRandomValueToCardValue(n[2]),L.push(this.mapRandomValueToCard(n[2])),l=(l+x)%10;if(this.shouldDrawThirdBankerCard(f,x))B.push(this.mapRandomValueToCard(E[2])),f=(f+this.mapRandomValueToCardValue(E[2]))%10}let y;if(l===f)y="TIE";else y=l>f?"PLAYER_WIN":"BANKER_WIN";let _=Tr(i),{betType:k,multiplier:Jr}=ei[y],Qr=new V.default(0).add(i.bets.filter((h)=>h.type===k).reduce((h,x)=>h.add(x.amount.mul(Jr)),new V.default(0)));return{isFinished:!0,payoutMultiplier:_.gt(0)?Qr.div(_):new V.default(0),outputs:{playerCards:L,playerHandValue:l,bankerCards:B,bankerHandValue:f,gameOutcome:y,result:e.values},randomValues:e}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((i)=>i.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let i=hr[Math.floor(r/13)],o=xr[r%13];return{suit:i,rank:o}}isNaturalWin(r,i){let o=[8,9];return o.includes(r)||o.includes(i)}mapRandomValueToCardValue(r){let i=r%13;if(i===0)return 1;if(i>=10)return 10;return i+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,i){if(i===null)return r<=5;if(r<=2)return!0;if(r===3)return i!==8;if(r===4)return[2,3,4,5,6,7].includes(i);if(r===5)return[4,5,6,7].includes(i);if(r===6)return[6,7].includes(i);return!1}}var Kr=N(require("big.js"));class T{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let i=this.multipliers.get(r);if(i===void 0)throw new Error(`Multipliers for ${r} not found`);return i}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,i])=>({edge:r,multipliers:i}))}}var Cr;((E)=>{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"})(Cr||={});var ci={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},ni=new T(new Map([[2,ci]])),ti={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Dr extends A{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:i}){let o=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=ni.getMultipliers(i),c=o.values,n=this.calculatePayoutMultiplier(e,c);return{isFinished:!0,payoutMultiplier:Kr.default(n),outputs:{result:o.values},randomValues:o}}calculatePayoutMultiplier(r,i){let o=new Map;for(let n of i){let E=o.get(n)||0;o.set(n,E+1)}let e=[...o.values()].filter((n)=>n>1),c=this.classifyResult(e);return c===null?0:r[c]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[i,o]=r;if(i===void 0)return null;if(o===void 0){let e=ti[i];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${i}`);return e}return i===3||o===3?"FULL_HOUSE":"TWO_PAIR"}}var q=N(require("big.js"));var pr;((o)=>{o.ABOVE="ABOVE";o.BELOW="BELOW"})(pr||={});class Mr extends A{constructor(){super("DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:0,max:1e4}),c=e.min,L=e.max-c+1-1,l=o.direction==="ABOVE"?L-o.selectedValue:o.selectedValue,B=new q.default(l).div(L).mul(100);return{isFinished:!0,payoutMultiplier:(o.direction==="ABOVE"?e.value>o.selectedValue:e.value<o.selectedValue)?new q.default(100-i).div(B):new q.default(0),outputs:{result:e.values},randomValues:e}}}var X=N(require("big.js"));var Nr;((c)=>{c.CLASSIC="CLASSIC";c.LOW_RISK="LOW_RISK";c.MEDIUM_RISK="MEDIUM_RISK";c.HIGH_RISK="HIGH_RISK"})(Nr||={});var Ei={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class Vr extends A{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Ei}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:i,gameInputs:o}){if(i!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(o.selectedNumbers.length===0)throw new Error("No numbers selected");if(o.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let E of o.selectedNumbers){if(E%1!==0)throw new Error("Only integers can be selected");if(E<0||E>39)throw new Error("Invalid number selected")}let e=r.getUniqueRandomInts({min:0,max:39,count:10}),c=o.selectedNumbers.filter((E)=>e.values.includes(E));return{isFinished:!0,payoutMultiplier:c.length>0?new X.default(this.multipliers[o.selectedNumbers.length][o.riskLevel][c.length]??0):new X.default(0),outputs:{result:e.values},randomValues:e}}validateMultiplierOverrides(r){for(let[i,o]of Object.entries(r)){let e=Number(i);for(let[c,n]of Object.entries(o))if(n.length!==e+1)throw new Error(`Invalid count of multipliers for tiles ${e} and risk level ${c}. Expected ${e+1}, but got ${n.length}`)}}}var G=N(require("big.js"));var wr=(r,i)=>{return r.gt(i)?r:i};var Or=(r,i)=>{return r.lt(i)?r:i};class Rr extends A{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:1,max:4294967295}),c=e.max,n=new G.default(16777216),E=new G.default(1),L=new G.default(1e6),l=e.value,B=new G.default(l-1).div(c),f=(100-i)/100,y=n.div(B.mul(n).plus(1)).mul(f),_=wr(E,Or(y,L));return{isFinished:!0,payoutMultiplier:_.gte(o.targetMultiplier)?new G.default(o.targetMultiplier):new G.default(0),outputs:{randomMultiplier:_,result:e.values},randomValues:e}}}var O=N(require("big.js"));var I=(r,i)=>{if(i<0||r<0||i>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(i>r-i)i=r-i;let o=1;for(let e=1;e<=i;e++)o=o*(r-e+1)/e;return o};class vr extends A{constructor(){super("MINES")}determineGameResult({generator:r,edge:i,gameInputs:o}){if(o.minesCount<=0||o.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(o.selectedTiles.length>25-o.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let E=r.getUniqueRandomInts({min:1,max:25,count:o.minesCount}),L=E.values.some((k)=>o.selectedTiles.includes(k)),l=o.hasCashedOut||L,B=(100-i)/100,f=new O.default(I(25-o.minesCount,o.selectedTiles.length)).div(new O.default(I(25,o.selectedTiles.length))),_=o.hasCashedOut&&!L?new O.default(B).div(f):new O.default(0);return{isFinished:l,payoutMultiplier:_,outputs:{result:E.values},randomValues:E}}}var kr=require("big.js");var Hr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(Hr||={});var Si=[{rows:8,payout:{["LOW_RISK"]:[5.6,2.1,1.1,1,0.5,1,1.1,2.1,5.6],["MEDIUM_RISK"]:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],["HIGH_RISK"]:[29,4,1.5,0.3,0.2,0.3,1.5,4,29]}},{rows:9,payout:{["LOW_RISK"]:[5.6,2,1.6,1,0.7,0.7,1,1.6,2,5.6],["MEDIUM_RISK"]:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],["HIGH_RISK"]:[43,7,2,0.6,0.2,0.2,0.6,2,7,43]}},{rows:10,payout:{["LOW_RISK"]:[8.9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,8.9],["MEDIUM_RISK"]:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],["HIGH_RISK"]:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76]}},{rows:11,payout:{["LOW_RISK"]:[8.4,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8.4],["MEDIUM_RISK"]:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],["HIGH_RISK"]:[120,14,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,14,120]}},{rows:12,payout:{["LOW_RISK"]:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],["MEDIUM_RISK"]:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],["HIGH_RISK"]:[170,24,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,24,170]}},{rows:13,payout:{["LOW_RISK"]:[8.1,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8.1],["MEDIUM_RISK"]:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],["HIGH_RISK"]:[260,37,11,4,1,0.2,0.2,0.2,0.2,1,4,11,37,260]}},{rows:14,payout:{["LOW_RISK"]:[7.1,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7.1],["MEDIUM_RISK"]:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],["HIGH_RISK"]:[420,56,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56,420]}},{rows:15,payout:{["LOW_RISK"]:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],["MEDIUM_RISK"]:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],["HIGH_RISK"]:[620,83,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,83,620]}},{rows:16,payout:{["LOW_RISK"]:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16],["MEDIUM_RISK"]:[110,41,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41,110],["HIGH_RISK"]:[1000,130,26,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26,130,1000]}}],Pr=new T(new Map([[1,Si]]));class Ur extends A{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(i.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(i.numberOfRows<8||i.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=Pr.getMultipliers(o),c=r.getRandomIntsWithReplacement({min:0,max:1,count:i.numberOfRows}),E=c.values.reduce((l,B)=>l+B,0);return{isFinished:!0,payoutMultiplier:new kr.Big(e.find((l)=>l.rows===i.numberOfRows)?.payout[i.riskLevel][E]??0),outputs:{result:c.values},randomValues:c}}}var t=require("big.js");var Y=[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],s=[37,...Y],b=[[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]],u=[[0,1],[0,3],[0,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]],m=[[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]],g=[[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]],rr=[[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]],ir=[[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]],$=[0,1,2,3,37],or=[[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]],er=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],K;((o)=>{o.EVEN="EVEN";o.ODD="ODD"})(K||={});var C;((o)=>{o.RED="RED";o.BLACK="BLACK"})(C||={});var D;((o)=>{o.LOW="LOW";o.HIGH="HIGH"})(D||={});var p;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(p||={});var M;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(M||={});var F;((o)=>{o.AMERICAN="AMERICAN";o.EUROPEAN="EUROPEAN"})(F||={});var z=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&R(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&fi(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&Ai(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&li(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&Li(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},R=(r)=>{return Y.includes(r)},fi=(r)=>{if(r.length!==2)return!1;if(!r.every(R))return!1;return b.some(([i,o])=>i===r[0]&&o===r[1])},Ai=(r)=>{if(r.length!==3)return!1;if(!r.every(R))return!1;return m.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},li=(r)=>{if(r.length!==4)return!1;if(!r.every(R))return!1;return rr.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},Li=(r)=>{if(r.length!==6)return!1;if(!r.every(R))return!1;return or.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var W=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&v(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&di(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&Bi(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&hi(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.basketBets.every((i)=>i.amount.gte(0)))throw S.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&xi(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},v=(r)=>{return s.includes(r)};function di(r){if(r.length!==2)return!1;if(!r.every(v))return!1;return u.some(([i,o])=>i===r[0]&&o===r[1])}var Bi=(r)=>{if(r.length!==3)return!1;if(!r.every(v))return!1;return g.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},hi=(r)=>{if(r.length!==4)return!1;if(!r.every(v))return!1;return ir.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},xi=(r)=>{if(r.length!==6)return!1;if(!r.every(v))return!1;return er.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var ar=(r)=>{return new t.Big(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0)))},jr=(r)=>{return new t.Big(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.basketBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0)))},yi=(r)=>{return r.type==="EUROPEAN"?ar(r.inputs):jr(r.inputs)};class qr extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){z(i);let o=r.getRandomInt({min:0,max:36}),e=o.value,c=this.determineBetOutcomes(i,e),n=ar(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t.Big(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t.Big(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t.Big(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t.Big(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t.Big(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t.Big(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t.Big(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0)))}}class Yr extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){W(i);let o=r.getRandomInt({min:0,max:37}),e=o.value,c=this.determineBetOutcomes(i,e),n=jr(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t.Big(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>$.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>!$.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0||i===37)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t.Big(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t.Big(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t.Big(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t.Big(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t.Big(0))).add(r.winningBets.basketBets.reduce((i,o)=>i.plus(o.amount.mul(7)),new t.Big(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t.Big(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0)))}}class $r extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new qr,this.americanGame=new Yr}determineGameResult(r){let{gameInputs:i,...o}=r;if(r.edge===2.7&&i.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}if(r.edge===5.3&&i.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:c,result:e.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var _i=(r)=>{if(r.type==="EUROPEAN")z(r.inputs);else W(r.inputs)};var Fr=require("big.js");var cr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(cr||={});var nr;((n)=>{n[n.TEN=10]="TEN";n[n.TWENTY=20]="TWENTY";n[n.THIRTY=30]="THIRTY";n[n.FORTY=40]="FORTY";n[n.FIFTY=50]="FIFTY"})(nr||={});var Ti=[{segments:10,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[0,1.9,0,1.5,0,2,0,1.5,0,3],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,9.9]}},{segments:20,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.8,0,2,0,2,0,1.5,0,2,0,2,0,3,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19.8]}},{segments:30,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,2,0,3,0,1.7,0,1.5,0,2,0,1.5,0,2,0,1.5,0,2,0,4,0,1.5,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29.7]}},{segments:40,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[2,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0,1.6,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39.6]}},{segments:50,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,5,0,1.5,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49.5]}}],zr=new T(new Map([[1,Ti]]));class Wr extends A{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(!Object.values(nr).includes(i.segments))throw new Error("Invalid segments value");if(!Object.values(cr).includes(i.riskLevel))throw new Error("Invalid risk level");let e=zr.getMultipliers(o).find((L)=>L.segments===i.segments);if(e===void 0)throw new Error(`Multiplier not found for segment ${i.segments}`);let c=r.getRandomInt({min:0,max:i.segments-1}),n=e.payout[i.riskLevel][c.value];if(n===void 0)throw new Error(`Payout not found for risk ${i.riskLevel} and value ${c.value}`);return{isFinished:!0,payoutMultiplier:new Fr.Big(n),outputs:{result:c.values},randomValues:c}}}
1
+ var Wr=Object.create;var{getPrototypeOf:ur,defineProperty:w,getOwnPropertyNames:fr,getOwnPropertyDescriptor:br}=Object,Or=Object.prototype.hasOwnProperty;var N=(r,o,i)=>{i=r!=null?Wr(ur(r)):{};let E=o||!r||!r.__esModule?w(i,"default",{value:r,enumerable:!0}):i;for(let A of fr(r))if(!Or.call(E,A))w(E,A,{get:()=>r[A],enumerable:!0});return E},er=new WeakMap,sr=(r)=>{var o=er.get(r),i;if(o)return o;if(o=w({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function")fr(r).map((E)=>!Or.call(o,E)&&w(o,E,{get:()=>r[E],enumerable:!(i=br(r,E))||i.enumerable}));return er.set(r,o),o};var mr=(r,o)=>{for(var i in o)w(r,i,{get:o[i],enumerable:!0,configurable:!0,set:(E)=>o[i]=()=>E})};var Uo={};mr(Uo,{validateRouletteGameInputs:()=>Mo,validateAdvancedDiceInputs:()=>Ao,plinkoMultipliers:()=>m,diamondsMultipliers:()=>Dr,calculateRouletteBetAmount:()=>lo,calculateBaccaratBetAmount:()=>Kr,WheelSegments:()=>M,WheelRiskLevel:()=>l,Wheel:()=>Jr,VALID_SUITS:()=>Gr,VALID_RANKS:()=>Lr,VALID_EUROPEAN_STREETS:()=>ir,VALID_EUROPEAN_STRAIGHTS:()=>j,VALID_EUROPEAN_SPLITS:()=>rr,VALID_EUROPEAN_DOUBLE_STREETS:()=>nr,VALID_EUROPEAN_CORNERS:()=>Ar,VALID_AMERICAN_STREETS:()=>Er,VALID_AMERICAN_STRAIGHTS:()=>g,VALID_AMERICAN_SPLITS:()=>or,VALID_AMERICAN_DOUBLE_STREETS:()=>tr,VALID_AMERICAN_CORNERS:()=>cr,RouletteType:()=>z,Roulette:()=>jr,RollType:()=>Sr,RANDOM_MIN_VALUE:()=>Y,RANDOM_MAX_VALUE:()=>k,PlinkoRiskLevel:()=>s,Plinko:()=>Pr,Parity:()=>K,PLINKO_ROW_COUNTS:()=>So,OrigamiGame:()=>S,Mines:()=>vr,MIN_WIN_CHANCE:()=>dr,MAX_WIN_CHANCE:()=>Br,Limbo:()=>hr,KenoRiskLevel:()=>Mr,Keno:()=>wr,Half:()=>Z,GameErrorCode:()=>Rr,GameError:()=>e,Game:()=>R,EFFECTIVE_RANGE:()=>W,Dozen:()=>D,DiceDirection:()=>ar,Dice:()=>lr,DiamondsResultType:()=>_r,Diamonds:()=>Nr,Column:()=>_,Color:()=>p,BaccaratOutcome:()=>yr,BaccaratBetType:()=>Cr,Baccarat:()=>pr,AdvancedDice:()=>xr,AMERICAN_BASKET:()=>q});module.exports=sr(Uo);var S;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(S||={});class R{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}var F=require("big.js");var Rr;((o)=>o.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(Rr||={});class e extends Error{static createValidationError(r){return new e("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof e}errorCode;constructor(r,o){super(o);this.errorCode=r}}var Y=0,k=1e4,W=10001,dr=0.01,Br=98,gr=(r)=>{if(r<Y)throw e.createValidationError(`Lower bound ${r} is below minimum allowed value ${Y}`)},ro=(r)=>{if(r>k)throw e.createValidationError(`Upper bound ${r} is above maximum allowed value ${k}`)},P=(r)=>{if(gr(r.lower),ro(r.upper),r.lower>=r.upper)throw e.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},oo=(r,o)=>{let[i,E]=r.lower<=o.lower?[r,o]:[o,r];if(i.upper>E.lower)throw e.createValidationError("Bounds must not overlap")},io=(r,o)=>o>=r.lower&&o<=r.upper,Eo=(r)=>r.upper-r.lower+1,Q=(r,o)=>o>r.lower&&o<r.upper,X=(r)=>r.upper-r.lower-1,Sr;((E)=>{E.ROLL_BETWEEN="ROLL_BETWEEN";E.ROLL_OUTSIDE="ROLL_OUTSIDE";E.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Sr||={});var Tr=(r)=>{let i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return P(r.bounds),X(r.bounds);case"ROLL_OUTSIDE":return P(r.bounds),W-Eo(r.bounds);case"ROLL_BETWEEN_TWO":return P(r.firstBounds),P(r.secondBounds),oo(r.firstBounds,r.secondBounds),X(r.firstBounds)+X(r.secondBounds)}})(),E=F.Big(i).div(W).mul(100);if(E.lt(dr))throw e.createValidationError("Win chance too low");if(E.gt(Br))throw e.createValidationError("Win chance too high");return E},Ao=(r)=>{Tr(r)};class xr extends R{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=Tr(i),A=r.getRandomInt({min:Y,max:k}),c=A.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(i.mode){case"ROLL_BETWEEN":return Q(i.bounds,c);case"ROLL_OUTSIDE":return!io(i.bounds,c);case"ROLL_BETWEEN_TWO":return Q(i.firstBounds,c)||Q(i.secondBounds,c)}})()?new F.Big(100-o).div(E):new F.Big(0),outputs:{result:A.values},randomValues:A}}}var a=N(require("big.js"));var Gr=["Clubs","Diamonds","Hearts","Spades"],Lr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],yr;((E)=>{E.PLAYER_WIN="PLAYER_WIN";E.TIE="TIE";E.BANKER_WIN="BANKER_WIN"})(yr||={});var Cr;((E)=>{E.PLAYER="PLAYER";E.TIE="TIE";E.BANKER="BANKER"})(Cr||={});var co={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Kr=(r)=>{return new a.default(0).add(r.bets.reduce((i,E)=>i.add(E.amount),new a.default(0)))};class pr extends R{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(i!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(o);let E=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),A=E.values,c=A.slice(0,3),t=A.slice(3,6),O=[],d=0;for(let x of c.slice(0,2)){let L=this.mapRandomValueToCard(x),U=this.mapRandomValueToCardValue(x);O.push(L),d=(d+U)%10}let B=[],f=0;for(let x of t.slice(0,2)){let L=this.mapRandomValueToCard(x),U=this.mapRandomValueToCardValue(x);B.push(L),f=(f+U)%10}if(!this.isNaturalWin(d,f)){let x=this.shouldDrawThirdPlayerCard(d),L=null;if(x)L=this.mapRandomValueToCardValue(c[2]),O.push(this.mapRandomValueToCard(c[2])),d=(d+L)%10;if(this.shouldDrawThirdBankerCard(f,L))B.push(this.mapRandomValueToCard(t[2])),f=(f+this.mapRandomValueToCardValue(t[2]))%10}let T;if(d===f)T="TIE";else T=d>f?"PLAYER_WIN":"BANKER_WIN";let G=Kr(o),{betType:v,multiplier:Qr}=co[T],Xr=new a.default(0).add(o.bets.filter((x)=>x.type===v).reduce((x,L)=>x.add(L.amount.mul(Qr)),new a.default(0)));return{isFinished:!0,payoutMultiplier:G.gt(0)?Xr.div(G):new a.default(0),outputs:{playerCards:O,playerHandValue:d,bankerCards:B,bankerHandValue:f,gameOutcome:T,result:E.values},randomValues:E}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((o)=>o.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let o=Gr[Math.floor(r/13)],i=Lr[r%13];return{suit:o,rank:i}}isNaturalWin(r,o){let i=[8,9];return i.includes(r)||i.includes(o)}mapRandomValueToCardValue(r){let o=r%13;if(o===0)return 1;if(o>=10)return 10;return o+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,o){if(o===null)return r<=5;if(r<=2)return!0;if(r===3)return o!==8;if(r===4)return[2,3,4,5,6,7].includes(o);if(r===5)return[4,5,6,7].includes(o);if(r===6)return[6,7].includes(o);return!1}}var Zr=N(require("big.js"));class y{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let o=this.multipliers.get(r);if(o===void 0)throw new Error(`Multipliers for ${r} not found`);return o}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,o])=>({edge:r,multipliers:o}))}}var _r;((t)=>{t.PAIR="PAIR";t.TWO_PAIR="TWO_PAIR";t.THREE_OF_A_KIND="THREE_OF_A_KIND";t.FULL_HOUSE="FULL_HOUSE";t.FOUR_OF_A_KIND="FOUR_OF_A_KIND";t.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(_r||={});var no={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},to={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},eo={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},fo={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},Oo={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},Dr=new y(new Map([[1,no],[2,to],[3,eo],[4,fo],[8,Oo]])),Ro={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Nr extends R{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:o}){let i=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),E=Dr.getMultipliers(o),A=i.values,c=this.calculatePayoutMultiplier(E,A);return{isFinished:!0,payoutMultiplier:Zr.default(c),outputs:{result:i.values},randomValues:i}}calculatePayoutMultiplier(r,o){let i=new Map;for(let c of o){let t=i.get(c)||0;i.set(c,t+1)}let E=[...i.values()].filter((c)=>c>1),A=this.classifyResult(E);return A===null?0:r[A]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[o,i]=r;if(o===void 0)return null;if(i===void 0){let E=Ro[o];if(E===void 0)throw new Error(`Unexpected single diamond repeat count: ${o}`);return E}return o===3||i===3?"FULL_HOUSE":"TWO_PAIR"}}var $=N(require("big.js"));var ar;((i)=>{i.ABOVE="ABOVE";i.BELOW="BELOW"})(ar||={});class lr extends R{constructor(){super("DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:0,max:1e4}),A=E.min,O=E.max-A+1-1,d=i.direction==="ABOVE"?O-i.selectedValue:i.selectedValue,B=new $.default(d).div(O).mul(100);return{isFinished:!0,payoutMultiplier:(i.direction==="ABOVE"?E.value>i.selectedValue:E.value<i.selectedValue)?new $.default(100-o).div(B):new $.default(0),outputs:{result:E.values},randomValues:E}}}var u=N(require("big.js"));var Mr;((A)=>{A.CLASSIC="CLASSIC";A.LOW_RISK="LOW_RISK";A.MEDIUM_RISK="MEDIUM_RISK";A.HIGH_RISK="HIGH_RISK"})(Mr||={});var Bo={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class wr extends R{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Bo}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:o,gameInputs:i}){if(o!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(i.selectedNumbers.length===0)throw new Error("No numbers selected");if(i.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let t of i.selectedNumbers){if(t%1!==0)throw new Error("Only integers can be selected");if(t<0||t>39)throw new Error("Invalid number selected")}let E=r.getUniqueRandomInts({min:0,max:39,count:10}),A=i.selectedNumbers.filter((t)=>E.values.includes(t));return{isFinished:!0,payoutMultiplier:A.length>0?new u.default(this.multipliers[i.selectedNumbers.length][i.riskLevel][A.length]??0):new u.default(0),outputs:{result:E.values},randomValues:E}}validateMultiplierOverrides(r){for(let[o,i]of Object.entries(r)){let E=Number(o);for(let[A,c]of Object.entries(i))if(c.length!==E+1)throw new Error(`Invalid count of multipliers for tiles ${E} and risk level ${A}. Expected ${E+1}, but got ${c.length}`)}}}var C=N(require("big.js"));var Vr=(r,o)=>{return r.gt(o)?r:o};var Hr=(r,o)=>{return r.lt(o)?r:o};class hr extends R{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:1,max:4294967295}),A=E.max,c=new C.default(16777216),t=new C.default(1),O=new C.default(1e6),d=E.value,B=new C.default(d-1).div(A),f=(100-o)/100,T=c.div(B.mul(c).plus(1)).mul(f),G=Vr(t,Hr(T,O));return{isFinished:!0,payoutMultiplier:G.gte(i.targetMultiplier)?new C.default(i.targetMultiplier):new C.default(0),outputs:{randomMultiplier:G,result:E.values},randomValues:E}}}var V=N(require("big.js"));var b=(r,o)=>{if(o<0||r<0||o>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(o>r-o)o=r-o;let i=1;for(let E=1;E<=o;E++)i=i*(r-E+1)/E;return i};class vr extends R{constructor(){super("MINES")}determineGameResult({generator:r,edge:o,gameInputs:i}){if(i.minesCount<=0||i.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(i.selectedTiles.length>25-i.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let t=r.getUniqueRandomInts({min:1,max:25,count:i.minesCount}),O=t.values.some((v)=>i.selectedTiles.includes(v)),d=i.hasCashedOut||O,B=(100-o)/100,f=new V.default(b(25-i.minesCount,i.selectedTiles.length)).div(new V.default(b(25,i.selectedTiles.length))),G=i.hasCashedOut&&!O?new V.default(B).div(f):new V.default(0);return{isFinished:d,payoutMultiplier:G,outputs:{result:t.values},randomValues:t}}}var Ur=require("big.js");var s;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(s||={});var So=[8,9,10,11,12,13,14,15,16],To={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},xo={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},Go={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},Lo={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},yo={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},m=new y(new Map([[1,To],[2,xo],[3,Go],[4,Lo],[8,yo]]));class Pr extends R{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(o.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(o.numberOfRows<8||o.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let E=o.numberOfRows,t=m.getMultipliers(i)[o.riskLevel][E],O=r.getRandomIntsWithReplacement({min:0,max:1,count:o.numberOfRows}),B=O.values.reduce((T,G)=>T+G,0),f=t[B];if(f===void 0)throw new Error(`No payout found for end position ${B}`);return{isFinished:!0,payoutMultiplier:Ur.Big(f),outputs:{result:O.values},randomValues:O}}}var n=require("big.js");var j=[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],g=[37,...j],rr=[[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]],or=[[0,1],[0,3],[0,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]],ir=[[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]],Er=[[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]],Ar=[[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]],cr=[[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]],q=[0,1,2,3,37],nr=[[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]],tr=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],K;((i)=>{i.EVEN="EVEN";i.ODD="ODD"})(K||={});var p;((i)=>{i.RED="RED";i.BLACK="BLACK"})(p||={});var Z;((i)=>{i.LOW="LOW";i.HIGH="HIGH"})(Z||={});var _;((E)=>{E.TOP="TOP";E.MIDDLE="MIDDLE";E.BOTTOM="BOTTOM"})(_||={});var D;((E)=>{E.FIRST="FIRST";E.SECOND="SECOND";E.THIRD="THIRD"})(D||={});var z;((i)=>{i.AMERICAN="AMERICAN";i.EUROPEAN="EUROPEAN"})(z||={});var I=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw e.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&H(o.value)))throw e.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&Co(o.values)))throw e.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&Ko(o.values)))throw e.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&po(o.values)))throw e.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&Zo(o.values)))throw e.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.parity)))throw e.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(p).includes(o.color)))throw e.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw e.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.column)))throw e.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(D).includes(o.dozen)))throw e.createValidationError("Invalid dozen bet.")},H=(r)=>{return j.includes(r)},Co=(r)=>{if(r.length!==2)return!1;if(!r.every(H))return!1;return rr.some(([o,i])=>o===r[0]&&i===r[1])},Ko=(r)=>{if(r.length!==3)return!1;if(!r.every(H))return!1;return ir.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},po=(r)=>{if(r.length!==4)return!1;if(!r.every(H))return!1;return Ar.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},Zo=(r)=>{if(r.length!==6)return!1;if(!r.every(H))return!1;return nr.some(([o,i,E,A,c,t])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&t===r[5])};var J=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw e.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&h(o.value)))throw e.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&_o(o.values)))throw e.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&Do(o.values)))throw e.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&No(o.values)))throw e.createValidationError("Invalid corner bet.");if(!r.basketBets.every((o)=>o.amount.gte(0)))throw e.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&ao(o.values)))throw e.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.parity)))throw e.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(p).includes(o.color)))throw e.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw e.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.column)))throw e.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(D).includes(o.dozen)))throw e.createValidationError("Invalid dozen bet.")},h=(r)=>{return g.includes(r)};function _o(r){if(r.length!==2)return!1;if(!r.every(h))return!1;return or.some(([o,i])=>o===r[0]&&i===r[1])}var Do=(r)=>{if(r.length!==3)return!1;if(!r.every(h))return!1;return Er.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},No=(r)=>{if(r.length!==4)return!1;if(!r.every(h))return!1;return cr.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},ao=(r)=>{if(r.length!==6)return!1;if(!r.every(h))return!1;return tr.some(([o,i,E,A,c,t])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&t===r[5])};var Fr=(r)=>{return new n.Big(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0)))},Yr=(r)=>{return new n.Big(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.basketBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0)))},lo=(r)=>{return r.type==="EUROPEAN"?Fr(r.inputs):Yr(r.inputs)};class kr extends R{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){I(o);let i=r.getRandomInt({min:0,max:36}),E=i.value,A=this.determineBetOutcomes(o,E),c=Fr(o),t=this.calculateTotalPayoutAmount(A),O=c.gt(0)?t.div(c):new n.Big(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:O,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n.Big(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n.Big(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n.Big(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n.Big(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n.Big(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n.Big(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0)))}}class $r extends R{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){J(o);let i=r.getRandomInt({min:0,max:37}),E=i.value,A=this.determineBetOutcomes(o,E),c=Yr(o),t=this.calculateTotalPayoutAmount(A),O=c.gt(0)?t.div(c):new n.Big(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:O,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>q.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>!q.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0||o===37)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n.Big(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n.Big(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n.Big(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n.Big(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n.Big(0))).add(r.winningBets.basketBets.reduce((o,i)=>o.plus(i.amount.mul(7)),new n.Big(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n.Big(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0)))}}class jr extends R{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new kr,this.americanGame=new $r}determineGameResult(r){let{gameInputs:o,...i}=r;if(r.edge===2.7&&o.type==="EUROPEAN"){let E=this.europeanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"european",betOutcomes:A,result:E.outputs.result}}}if(r.edge===5.3&&o.type==="AMERICAN"){let E=this.americanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"american",betOutcomes:A,result:E.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var Mo=(r)=>{if(r.type==="EUROPEAN")I(r.inputs);else J(r.inputs)};var Ir=require("big.js");var l;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(l||={});var M;((c)=>{c[c.TEN=10]="TEN";c[c.TWENTY=20]="TWENTY";c[c.THIRTY=30]="THIRTY";c[c.FORTY=40]="FORTY";c[c.FIFTY=50]="FIFTY"})(M||={});var wo={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}}},Vo={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}}},Ho={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}}},ho={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}}},vo={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}}},qr=new y(new Map([[1,wo],[2,Vo],[3,Ho],[4,ho],[8,vo]]));var zr={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class Jr extends R{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(!Object.values(M).includes(o.segments))throw new Error("Invalid segments value");if(!Object.values(l).includes(o.riskLevel))throw new Error("Invalid risk level");let A=qr.getMultipliers(i)[o.riskLevel];if(A===void 0)throw new Error(`No multipliers found for risk level ${o.riskLevel}`);let c=A[o.segments];if(c===void 0)throw new Error(`No multipliers found for segment ${o.segments}`);let t=zr[o.riskLevel];if(t===void 0)throw new Error(`No patterns found for risk level ${o.riskLevel}`);let O=t[o.segments];if(O===void 0)throw new Error(`No patterns found for segment ${o.segments}`);let d=r.getRandomInt({min:0,max:O.length-1}),B=O[d.value];if(B===void 0)throw new Error(`No pattern found for segment ${o.segments} and value ${d.value}`);let f=c[B];if(f===void 0)throw new Error(`No payout found for picked segment ${B}`);return{isFinished:!0,payoutMultiplier:new Ir.Big(f),outputs:{result:d.values},randomValues:d}}}
package/dist/index.d.ts CHANGED
@@ -163,6 +163,15 @@ export declare class Baccarat extends Game<BaccaratGameInputs, BaccaratGameOutpu
163
163
  private shouldDrawThirdPlayerCard;
164
164
  private shouldDrawThirdBankerCard;
165
165
  }
166
+ declare class MultiplierContainer<TMultipliers> {
167
+ readonly multipliers: Map<number, TMultipliers>;
168
+ constructor(multipliers: Map<number, TMultipliers>);
169
+ getMultipliers(edge: number): TMultipliers;
170
+ getAllMultipliers(): {
171
+ edge: number;
172
+ multipliers: TMultipliers;
173
+ }[];
174
+ }
166
175
  export interface DiamondsGameInputs {
167
176
  }
168
177
  export declare enum DiamondsResultType {
@@ -174,6 +183,7 @@ export declare enum DiamondsResultType {
174
183
  FIVE_OF_A_KIND = "FIVE_OF_A_KIND"
175
184
  }
176
185
  export type DiamondsMultipliers = Record<keyof typeof DiamondsResultType, number>;
186
+ export declare const diamondsMultipliers: MultiplierContainer<DiamondsMultipliers>;
177
187
  export declare class Diamonds extends Game<DiamondsGameInputs> {
178
188
  constructor();
179
189
  protected determineGameResult({ generator, edge }: GetGameResultRequest<DiamondsGameInputs>): GameResult;
@@ -230,15 +240,6 @@ export declare class Mines extends Game<MinesGameInputs> {
230
240
  constructor();
231
241
  protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<MinesGameInputs>): GameResult;
232
242
  }
233
- declare class MultiplierContainer<TMultipliers> {
234
- readonly multipliers: Map<number, TMultipliers>;
235
- constructor(multipliers: Map<number, TMultipliers>);
236
- getMultipliers(edge: number): TMultipliers;
237
- getAllMultipliers(): {
238
- edge: number;
239
- multipliers: TMultipliers;
240
- }[];
241
- }
242
243
  export declare enum PlinkoRiskLevel {
243
244
  LOW_RISK = "LOW_RISK",
244
245
  MEDIUM_RISK = "MEDIUM_RISK",
@@ -248,15 +249,25 @@ export interface PlinkoGameInputs {
248
249
  numberOfRows: number;
249
250
  riskLevel: PlinkoRiskLevel;
250
251
  }
251
- export interface PlinkoMultipliers {
252
- rows: number;
253
- payout: Record<PlinkoRiskLevel, number[]>;
254
- }
255
- export declare const plinkoMultipliers: MultiplierContainer<PlinkoMultipliers[]>;
256
252
  export declare class Plinko extends Game<PlinkoGameInputs> {
257
253
  constructor();
258
254
  protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<PlinkoGameInputs>): GameResult;
259
255
  }
256
+ export declare const PLINKO_ROW_COUNTS: readonly [
257
+ 8,
258
+ 9,
259
+ 10,
260
+ 11,
261
+ 12,
262
+ 13,
263
+ 14,
264
+ 15,
265
+ 16
266
+ ];
267
+ export type PlinkoRowCount = (typeof PLINKO_ROW_COUNTS)[number];
268
+ export type PlinkoMultiplierSet = Record<PlinkoRowCount, number[]>;
269
+ export type PlinkoMultipliers = Record<PlinkoRiskLevel, PlinkoMultiplierSet>;
270
+ export declare const plinkoMultipliers: MultiplierContainer<PlinkoMultipliers>;
260
271
  export declare const VALID_EUROPEAN_STRAIGHTS: readonly [
261
272
  0,
262
273
  1,
@@ -1606,11 +1617,6 @@ export interface WheelGameInputs {
1606
1617
  segments: WheelSegments;
1607
1618
  riskLevel: WheelRiskLevel;
1608
1619
  }
1609
- export interface WheelMultipliers {
1610
- segments: WheelSegments;
1611
- payout: Record<WheelRiskLevel, number[]>;
1612
- }
1613
- export declare const wheelMultipliers: MultiplierContainer<WheelMultipliers[]>;
1614
1620
  export declare class Wheel extends Game<WheelGameInputs> {
1615
1621
  constructor();
1616
1622
  protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var h;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(h||={});class A{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}import{Big as j}from"big.js";var dr;((i)=>i.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(dr||={});class S extends Error{static createValidationError(r){return new S("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof S}errorCode;constructor(r,i){super(i);this.errorCode=r}}var q=0,Y=1e4,Q=10001,Br=0.01,hr=98,xr=(r)=>{if(r<q)throw S.createValidationError(`Lower bound ${r} is below minimum allowed value ${q}`)},yr=(r)=>{if(r>Y)throw S.createValidationError(`Upper bound ${r} is above maximum allowed value ${Y}`)},v=(r)=>{if(xr(r.lower),yr(r.upper),r.lower>=r.upper)throw S.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},_r=(r,i)=>{let[o,e]=r.lower<=i.lower?[r,i]:[i,r];if(o.upper>e.lower)throw S.createValidationError("Bounds must not overlap")},Tr=(r,i)=>i>=r.lower&&i<=r.upper,Gr=(r)=>r.upper-r.lower+1,U=(r,i)=>i>r.lower&&i<r.upper,a=(r)=>r.upper-r.lower-1,Kr;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Kr||={});var Z=(r)=>{let o=(()=>{switch(r.mode){case"ROLL_BETWEEN":return v(r.bounds),a(r.bounds);case"ROLL_OUTSIDE":return v(r.bounds),Q-Gr(r.bounds);case"ROLL_BETWEEN_TWO":return v(r.firstBounds),v(r.secondBounds),_r(r.firstBounds,r.secondBounds),a(r.firstBounds)+a(r.secondBounds)}})(),e=j(o).div(Q).mul(100);if(e.lt(Br))throw S.createValidationError("Win chance too low");if(e.gt(hr))throw S.createValidationError("Win chance too high");return e},hi=(r)=>{Z(r)};class Cr extends A{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=Z(o),c=r.getRandomInt({min:q,max:Y}),n=c.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(o.mode){case"ROLL_BETWEEN":return U(o.bounds,n);case"ROLL_OUTSIDE":return!Tr(o.bounds,n);case"ROLL_BETWEEN_TWO":return U(o.firstBounds,n)||U(o.secondBounds,n)}})()?new j(100-i).div(e):new j(0),outputs:{result:c.values},randomValues:c}}}import N from"big.js";var Dr=["Clubs","Diamonds","Hearts","Spades"],pr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],Mr;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(Mr||={});var Nr;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(Nr||={});var Vr={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},wr=(r)=>{return new N(0).add(r.bets.reduce((o,e)=>o.add(e.amount),new N(0)))};class Or extends A{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(o!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(i);let e=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),c=e.values,n=c.slice(0,3),E=c.slice(3,6),L=[],l=0;for(let B of n.slice(0,2)){let x=this.mapRandomValueToCard(B),R=this.mapRandomValueToCardValue(B);L.push(x),l=(l+R)%10}let d=[],f=0;for(let B of E.slice(0,2)){let x=this.mapRandomValueToCard(B),R=this.mapRandomValueToCardValue(B);d.push(x),f=(f+R)%10}if(!this.isNaturalWin(l,f)){let B=this.shouldDrawThirdPlayerCard(l),x=null;if(B)x=this.mapRandomValueToCardValue(n[2]),L.push(this.mapRandomValueToCard(n[2])),l=(l+x)%10;if(this.shouldDrawThirdBankerCard(f,x))d.push(this.mapRandomValueToCard(E[2])),f=(f+this.mapRandomValueToCardValue(E[2]))%10}let y;if(l===f)y="TIE";else y=l>f?"PLAYER_WIN":"BANKER_WIN";let _=wr(i),{betType:O,multiplier:lr}=Vr[y],Lr=new N(0).add(i.bets.filter((B)=>B.type===O).reduce((B,x)=>B.add(x.amount.mul(lr)),new N(0)));return{isFinished:!0,payoutMultiplier:_.gt(0)?Lr.div(_):new N(0),outputs:{playerCards:L,playerHandValue:l,bankerCards:d,bankerHandValue:f,gameOutcome:y,result:e.values},randomValues:e}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((i)=>i.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let i=Dr[Math.floor(r/13)],o=pr[r%13];return{suit:i,rank:o}}isNaturalWin(r,i){let o=[8,9];return o.includes(r)||o.includes(i)}mapRandomValueToCardValue(r){let i=r%13;if(i===0)return 1;if(i>=10)return 10;return i+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,i){if(i===null)return r<=5;if(r<=2)return!0;if(r===3)return i!==8;if(r===4)return[2,3,4,5,6,7].includes(i);if(r===5)return[4,5,6,7].includes(i);if(r===6)return[6,7].includes(i);return!1}}import Rr from"big.js";class T{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let i=this.multipliers.get(r);if(i===void 0)throw new Error(`Multipliers for ${r} not found`);return i}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,i])=>({edge:r,multipliers:i}))}}var vr;((E)=>{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"})(vr||={});var kr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},Hr=new T(new Map([[2,kr]])),Pr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Ur extends A{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:i}){let o=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=Hr.getMultipliers(i),c=o.values,n=this.calculatePayoutMultiplier(e,c);return{isFinished:!0,payoutMultiplier:Rr(n),outputs:{result:o.values},randomValues:o}}calculatePayoutMultiplier(r,i){let o=new Map;for(let n of i){let E=o.get(n)||0;o.set(n,E+1)}let e=[...o.values()].filter((n)=>n>1),c=this.classifyResult(e);return c===null?0:r[c]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[i,o]=r;if(i===void 0)return null;if(o===void 0){let e=Pr[i];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${i}`);return e}return i===3||o===3?"FULL_HOUSE":"TWO_PAIR"}}import $ from"big.js";var ar;((o)=>{o.ABOVE="ABOVE";o.BELOW="BELOW"})(ar||={});class jr extends A{constructor(){super("DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:0,max:1e4}),c=e.min,L=e.max-c+1-1,l=o.direction==="ABOVE"?L-o.selectedValue:o.selectedValue,d=new $(l).div(L).mul(100);return{isFinished:!0,payoutMultiplier:(o.direction==="ABOVE"?e.value>o.selectedValue:e.value<o.selectedValue)?new $(100-i).div(d):new $(0),outputs:{result:e.values},randomValues:e}}}import X from"big.js";var qr;((c)=>{c.CLASSIC="CLASSIC";c.LOW_RISK="LOW_RISK";c.MEDIUM_RISK="MEDIUM_RISK";c.HIGH_RISK="HIGH_RISK"})(qr||={});var Yr={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class $r extends A{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Yr}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:i,gameInputs:o}){if(i!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(o.selectedNumbers.length===0)throw new Error("No numbers selected");if(o.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let E of o.selectedNumbers){if(E%1!==0)throw new Error("Only integers can be selected");if(E<0||E>39)throw new Error("Invalid number selected")}let e=r.getUniqueRandomInts({min:0,max:39,count:10}),c=o.selectedNumbers.filter((E)=>e.values.includes(E));return{isFinished:!0,payoutMultiplier:c.length>0?new X(this.multipliers[o.selectedNumbers.length][o.riskLevel][c.length]??0):new X(0),outputs:{result:e.values},randomValues:e}}validateMultiplierOverrides(r){for(let[i,o]of Object.entries(r)){let e=Number(i);for(let[c,n]of Object.entries(o))if(n.length!==e+1)throw new Error(`Invalid count of multipliers for tiles ${e} and risk level ${c}. Expected ${e+1}, but got ${n.length}`)}}}import G from"big.js";var I=(r,i)=>{return r.gt(i)?r:i};var s=(r,i)=>{return r.lt(i)?r:i};class Fr extends A{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:1,max:4294967295}),c=e.max,n=new G(16777216),E=new G(1),L=new G(1e6),l=e.value,d=new G(l-1).div(c),f=(100-i)/100,y=n.div(d.mul(n).plus(1)).mul(f),_=I(E,s(y,L));return{isFinished:!0,payoutMultiplier:_.gte(o.targetMultiplier)?new G(o.targetMultiplier):new G(0),outputs:{randomMultiplier:_,result:e.values},randomValues:e}}}import k from"big.js";var F=(r,i)=>{if(i<0||r<0||i>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(i>r-i)i=r-i;let o=1;for(let e=1;e<=i;e++)o=o*(r-e+1)/e;return o};class zr extends A{constructor(){super("MINES")}determineGameResult({generator:r,edge:i,gameInputs:o}){if(o.minesCount<=0||o.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(o.selectedTiles.length>25-o.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let E=r.getUniqueRandomInts({min:1,max:25,count:o.minesCount}),L=E.values.some((O)=>o.selectedTiles.includes(O)),l=o.hasCashedOut||L,d=(100-i)/100,f=new k(F(25-o.minesCount,o.selectedTiles.length)).div(new k(F(25,o.selectedTiles.length))),_=o.hasCashedOut&&!L?new k(d).div(f):new k(0);return{isFinished:l,payoutMultiplier:_,outputs:{result:E.values},randomValues:E}}}import{Big as Wr}from"big.js";var Jr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(Jr||={});var Qr=[{rows:8,payout:{["LOW_RISK"]:[5.6,2.1,1.1,1,0.5,1,1.1,2.1,5.6],["MEDIUM_RISK"]:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],["HIGH_RISK"]:[29,4,1.5,0.3,0.2,0.3,1.5,4,29]}},{rows:9,payout:{["LOW_RISK"]:[5.6,2,1.6,1,0.7,0.7,1,1.6,2,5.6],["MEDIUM_RISK"]:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],["HIGH_RISK"]:[43,7,2,0.6,0.2,0.2,0.6,2,7,43]}},{rows:10,payout:{["LOW_RISK"]:[8.9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,8.9],["MEDIUM_RISK"]:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],["HIGH_RISK"]:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76]}},{rows:11,payout:{["LOW_RISK"]:[8.4,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8.4],["MEDIUM_RISK"]:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],["HIGH_RISK"]:[120,14,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,14,120]}},{rows:12,payout:{["LOW_RISK"]:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],["MEDIUM_RISK"]:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],["HIGH_RISK"]:[170,24,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,24,170]}},{rows:13,payout:{["LOW_RISK"]:[8.1,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8.1],["MEDIUM_RISK"]:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],["HIGH_RISK"]:[260,37,11,4,1,0.2,0.2,0.2,0.2,1,4,11,37,260]}},{rows:14,payout:{["LOW_RISK"]:[7.1,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7.1],["MEDIUM_RISK"]:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],["HIGH_RISK"]:[420,56,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56,420]}},{rows:15,payout:{["LOW_RISK"]:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],["MEDIUM_RISK"]:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],["HIGH_RISK"]:[620,83,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,83,620]}},{rows:16,payout:{["LOW_RISK"]:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16],["MEDIUM_RISK"]:[110,41,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41,110],["HIGH_RISK"]:[1000,130,26,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26,130,1000]}}],Zr=new T(new Map([[1,Qr]]));class Xr extends A{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(i.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(i.numberOfRows<8||i.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=Zr.getMultipliers(o),c=r.getRandomIntsWithReplacement({min:0,max:1,count:i.numberOfRows}),E=c.values.reduce((l,d)=>l+d,0);return{isFinished:!0,payoutMultiplier:new Wr(e.find((l)=>l.rows===i.numberOfRows)?.payout[i.riskLevel][E]??0),outputs:{result:c.values},randomValues:c}}}import{Big as t}from"big.js";var z=[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],b=[37,...z],u=[[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]],m=[[0,1],[0,3],[0,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]],g=[[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]],rr=[[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]],ir=[[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]],or=[[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]],W=[0,1,2,3,37],er=[[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]],cr=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],K;((o)=>{o.EVEN="EVEN";o.ODD="ODD"})(K||={});var C;((o)=>{o.RED="RED";o.BLACK="BLACK"})(C||={});var D;((o)=>{o.LOW="LOW";o.HIGH="HIGH"})(D||={});var p;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(p||={});var M;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(M||={});var J;((o)=>{o.AMERICAN="AMERICAN";o.EUROPEAN="EUROPEAN"})(J||={});var H=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&V(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&Ir(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&sr(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&br(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&ur(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},V=(r)=>{return z.includes(r)},Ir=(r)=>{if(r.length!==2)return!1;if(!r.every(V))return!1;return u.some(([i,o])=>i===r[0]&&o===r[1])},sr=(r)=>{if(r.length!==3)return!1;if(!r.every(V))return!1;return g.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},br=(r)=>{if(r.length!==4)return!1;if(!r.every(V))return!1;return ir.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},ur=(r)=>{if(r.length!==6)return!1;if(!r.every(V))return!1;return er.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var P=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&w(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&mr(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&gr(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&ri(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.basketBets.every((i)=>i.amount.gte(0)))throw S.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&ii(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},w=(r)=>{return b.includes(r)};function mr(r){if(r.length!==2)return!1;if(!r.every(w))return!1;return m.some(([i,o])=>i===r[0]&&o===r[1])}var gr=(r)=>{if(r.length!==3)return!1;if(!r.every(w))return!1;return rr.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},ri=(r)=>{if(r.length!==4)return!1;if(!r.every(w))return!1;return or.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},ii=(r)=>{if(r.length!==6)return!1;if(!r.every(w))return!1;return cr.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var nr=(r)=>{return new t(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t(0)))},tr=(r)=>{return new t(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.basketBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t(0)))},no=(r)=>{return r.type==="EUROPEAN"?nr(r.inputs):tr(r.inputs)};class Er extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){H(i);let o=r.getRandomInt({min:0,max:36}),e=o.value,c=this.determineBetOutcomes(i,e),n=nr(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0)))}}class Sr extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){P(i);let o=r.getRandomInt({min:0,max:37}),e=o.value,c=this.determineBetOutcomes(i,e),n=tr(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>W.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>!W.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0||i===37)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t(0))).add(r.winningBets.basketBets.reduce((i,o)=>i.plus(o.amount.mul(7)),new t(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0)))}}class oi extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Er,this.americanGame=new Sr}determineGameResult(r){let{gameInputs:i,...o}=r;if(r.edge===2.7&&i.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}if(r.edge===5.3&&i.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:c,result:e.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var Ao=(r)=>{if(r.type==="EUROPEAN")H(r.inputs);else P(r.inputs)};import{Big as ei}from"big.js";var fr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(fr||={});var Ar;((n)=>{n[n.TEN=10]="TEN";n[n.TWENTY=20]="TWENTY";n[n.THIRTY=30]="THIRTY";n[n.FORTY=40]="FORTY";n[n.FIFTY=50]="FIFTY"})(Ar||={});var ci=[{segments:10,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[0,1.9,0,1.5,0,2,0,1.5,0,3],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,9.9]}},{segments:20,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.8,0,2,0,2,0,1.5,0,2,0,2,0,3,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19.8]}},{segments:30,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,2,0,3,0,1.7,0,1.5,0,2,0,1.5,0,2,0,1.5,0,2,0,4,0,1.5,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29.7]}},{segments:40,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[2,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0,1.6,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39.6]}},{segments:50,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,5,0,1.5,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49.5]}}],ni=new T(new Map([[1,ci]]));class ti extends A{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(!Object.values(Ar).includes(i.segments))throw new Error("Invalid segments value");if(!Object.values(fr).includes(i.riskLevel))throw new Error("Invalid risk level");let e=ni.getMultipliers(o).find((L)=>L.segments===i.segments);if(e===void 0)throw new Error(`Multiplier not found for segment ${i.segments}`);let c=r.getRandomInt({min:0,max:i.segments-1}),n=e.payout[i.riskLevel][c.value];if(n===void 0)throw new Error(`Payout not found for risk ${i.riskLevel} and value ${c.value}`);return{isFinished:!0,payoutMultiplier:new ei(n),outputs:{result:c.values},randomValues:c}}}export{ni as wheelMultipliers,Ao as validateRouletteGameInputs,hi as validateAdvancedDiceInputs,Zr as plinkoMultipliers,no as calculateRouletteBetAmount,wr as calculateBaccaratBetAmount,Ar as WheelSegments,fr as WheelRiskLevel,ti as Wheel,Dr as VALID_SUITS,pr as VALID_RANKS,g as VALID_EUROPEAN_STREETS,z as VALID_EUROPEAN_STRAIGHTS,u as VALID_EUROPEAN_SPLITS,er as VALID_EUROPEAN_DOUBLE_STREETS,ir as VALID_EUROPEAN_CORNERS,rr as VALID_AMERICAN_STREETS,b as VALID_AMERICAN_STRAIGHTS,m as VALID_AMERICAN_SPLITS,cr as VALID_AMERICAN_DOUBLE_STREETS,or as VALID_AMERICAN_CORNERS,J as RouletteType,oi as Roulette,Kr as RollType,q as RANDOM_MIN_VALUE,Y as RANDOM_MAX_VALUE,Jr as PlinkoRiskLevel,Xr as Plinko,K as Parity,h as OrigamiGame,zr as Mines,Br as MIN_WIN_CHANCE,hr as MAX_WIN_CHANCE,Fr as Limbo,qr as KenoRiskLevel,$r as Keno,D as Half,dr as GameErrorCode,S as GameError,A as Game,Q as EFFECTIVE_RANGE,M as Dozen,ar as DiceDirection,jr as Dice,vr as DiamondsResultType,Ur as Diamonds,p as Column,C as Color,Mr as BaccaratOutcome,Nr as BaccaratBetType,Or as Baccarat,Cr as AdvancedDice,W as AMERICAN_BASKET};
1
+ var x;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(x||={});class R{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}import{Big as k}from"big.js";var Gr;((o)=>o.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(Gr||={});class e extends Error{static createValidationError(r){return new e("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof e}errorCode;constructor(r,o){super(o);this.errorCode=r}}var $=0,j=1e4,X=10001,Lr=0.01,yr=98,Cr=(r)=>{if(r<$)throw e.createValidationError(`Lower bound ${r} is below minimum allowed value ${$}`)},Kr=(r)=>{if(r>j)throw e.createValidationError(`Upper bound ${r} is above maximum allowed value ${j}`)},h=(r)=>{if(Cr(r.lower),Kr(r.upper),r.lower>=r.upper)throw e.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},pr=(r,o)=>{let[i,E]=r.lower<=o.lower?[r,o]:[o,r];if(i.upper>E.lower)throw e.createValidationError("Bounds must not overlap")},Zr=(r,o)=>o>=r.lower&&o<=r.upper,_r=(r)=>r.upper-r.lower+1,F=(r,o)=>o>r.lower&&o<r.upper,Y=(r)=>r.upper-r.lower-1,Dr;((E)=>{E.ROLL_BETWEEN="ROLL_BETWEEN";E.ROLL_OUTSIDE="ROLL_OUTSIDE";E.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Dr||={});var W=(r)=>{let i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return h(r.bounds),Y(r.bounds);case"ROLL_OUTSIDE":return h(r.bounds),X-_r(r.bounds);case"ROLL_BETWEEN_TWO":return h(r.firstBounds),h(r.secondBounds),pr(r.firstBounds,r.secondBounds),Y(r.firstBounds)+Y(r.secondBounds)}})(),E=k(i).div(X).mul(100);if(E.lt(Lr))throw e.createValidationError("Win chance too low");if(E.gt(yr))throw e.createValidationError("Win chance too high");return E},Mo=(r)=>{W(r)};class Nr extends R{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=W(i),A=r.getRandomInt({min:$,max:j}),c=A.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(i.mode){case"ROLL_BETWEEN":return F(i.bounds,c);case"ROLL_OUTSIDE":return!Zr(i.bounds,c);case"ROLL_BETWEEN_TWO":return F(i.firstBounds,c)||F(i.secondBounds,c)}})()?new k(100-o).div(E):new k(0),outputs:{result:A.values},randomValues:A}}}import N from"big.js";var ar=["Clubs","Diamonds","Hearts","Spades"],lr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],Mr;((E)=>{E.PLAYER_WIN="PLAYER_WIN";E.TIE="TIE";E.BANKER_WIN="BANKER_WIN"})(Mr||={});var wr;((E)=>{E.PLAYER="PLAYER";E.TIE="TIE";E.BANKER="BANKER"})(wr||={});var Vr={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Hr=(r)=>{return new N(0).add(r.bets.reduce((i,E)=>i.add(E.amount),new N(0)))};class hr extends R{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(i!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(o);let E=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),A=E.values,c=A.slice(0,3),t=A.slice(3,6),O=[],d=0;for(let T of c.slice(0,2)){let L=this.mapRandomValueToCard(T),H=this.mapRandomValueToCardValue(T);O.push(L),d=(d+H)%10}let B=[],f=0;for(let T of t.slice(0,2)){let L=this.mapRandomValueToCard(T),H=this.mapRandomValueToCardValue(T);B.push(L),f=(f+H)%10}if(!this.isNaturalWin(d,f)){let T=this.shouldDrawThirdPlayerCard(d),L=null;if(T)L=this.mapRandomValueToCardValue(c[2]),O.push(this.mapRandomValueToCard(c[2])),d=(d+L)%10;if(this.shouldDrawThirdBankerCard(f,L))B.push(this.mapRandomValueToCard(t[2])),f=(f+this.mapRandomValueToCardValue(t[2]))%10}let S;if(d===f)S="TIE";else S=d>f?"PLAYER_WIN":"BANKER_WIN";let G=Hr(o),{betType:V,multiplier:Tr}=Vr[S],xr=new N(0).add(o.bets.filter((T)=>T.type===V).reduce((T,L)=>T.add(L.amount.mul(Tr)),new N(0)));return{isFinished:!0,payoutMultiplier:G.gt(0)?xr.div(G):new N(0),outputs:{playerCards:O,playerHandValue:d,bankerCards:B,bankerHandValue:f,gameOutcome:S,result:E.values},randomValues:E}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((o)=>o.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let o=ar[Math.floor(r/13)],i=lr[r%13];return{suit:o,rank:i}}isNaturalWin(r,o){let i=[8,9];return i.includes(r)||i.includes(o)}mapRandomValueToCardValue(r){let o=r%13;if(o===0)return 1;if(o>=10)return 10;return o+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,o){if(o===null)return r<=5;if(r<=2)return!0;if(r===3)return o!==8;if(r===4)return[2,3,4,5,6,7].includes(o);if(r===5)return[4,5,6,7].includes(o);if(r===6)return[6,7].includes(o);return!1}}import vr from"big.js";class y{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let o=this.multipliers.get(r);if(o===void 0)throw new Error(`Multipliers for ${r} not found`);return o}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,o])=>({edge:r,multipliers:o}))}}var Ur;((t)=>{t.PAIR="PAIR";t.TWO_PAIR="TWO_PAIR";t.THREE_OF_A_KIND="THREE_OF_A_KIND";t.FULL_HOUSE="FULL_HOUSE";t.FOUR_OF_A_KIND="FOUR_OF_A_KIND";t.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(Ur||={});var Pr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},Fr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},Yr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},kr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},$r={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},jr=new y(new Map([[1,Pr],[2,Fr],[3,Yr],[4,kr],[8,$r]])),qr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class zr extends R{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:o}){let i=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),E=jr.getMultipliers(o),A=i.values,c=this.calculatePayoutMultiplier(E,A);return{isFinished:!0,payoutMultiplier:vr(c),outputs:{result:i.values},randomValues:i}}calculatePayoutMultiplier(r,o){let i=new Map;for(let c of o){let t=i.get(c)||0;i.set(c,t+1)}let E=[...i.values()].filter((c)=>c>1),A=this.classifyResult(E);return A===null?0:r[A]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[o,i]=r;if(o===void 0)return null;if(i===void 0){let E=qr[o];if(E===void 0)throw new Error(`Unexpected single diamond repeat count: ${o}`);return E}return o===3||i===3?"FULL_HOUSE":"TWO_PAIR"}}import q from"big.js";var Ir;((i)=>{i.ABOVE="ABOVE";i.BELOW="BELOW"})(Ir||={});class Jr extends R{constructor(){super("DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:0,max:1e4}),A=E.min,O=E.max-A+1-1,d=i.direction==="ABOVE"?O-i.selectedValue:i.selectedValue,B=new q(d).div(O).mul(100);return{isFinished:!0,payoutMultiplier:(i.direction==="ABOVE"?E.value>i.selectedValue:E.value<i.selectedValue)?new q(100-o).div(B):new q(0),outputs:{result:E.values},randomValues:E}}}import u from"big.js";var Qr;((A)=>{A.CLASSIC="CLASSIC";A.LOW_RISK="LOW_RISK";A.MEDIUM_RISK="MEDIUM_RISK";A.HIGH_RISK="HIGH_RISK"})(Qr||={});var Xr={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class Wr extends R{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Xr}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:o,gameInputs:i}){if(o!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(i.selectedNumbers.length===0)throw new Error("No numbers selected");if(i.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let t of i.selectedNumbers){if(t%1!==0)throw new Error("Only integers can be selected");if(t<0||t>39)throw new Error("Invalid number selected")}let E=r.getUniqueRandomInts({min:0,max:39,count:10}),A=i.selectedNumbers.filter((t)=>E.values.includes(t));return{isFinished:!0,payoutMultiplier:A.length>0?new u(this.multipliers[i.selectedNumbers.length][i.riskLevel][A.length]??0):new u(0),outputs:{result:E.values},randomValues:E}}validateMultiplierOverrides(r){for(let[o,i]of Object.entries(r)){let E=Number(o);for(let[A,c]of Object.entries(i))if(c.length!==E+1)throw new Error(`Invalid count of multipliers for tiles ${E} and risk level ${A}. Expected ${E+1}, but got ${c.length}`)}}}import C from"big.js";var b=(r,o)=>{return r.gt(o)?r:o};var s=(r,o)=>{return r.lt(o)?r:o};class ur extends R{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:1,max:4294967295}),A=E.max,c=new C(16777216),t=new C(1),O=new C(1e6),d=E.value,B=new C(d-1).div(A),f=(100-o)/100,S=c.div(B.mul(c).plus(1)).mul(f),G=b(t,s(S,O));return{isFinished:!0,payoutMultiplier:G.gte(i.targetMultiplier)?new C(i.targetMultiplier):new C(0),outputs:{randomMultiplier:G,result:E.values},randomValues:E}}}import v from"big.js";var z=(r,o)=>{if(o<0||r<0||o>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(o>r-o)o=r-o;let i=1;for(let E=1;E<=o;E++)i=i*(r-E+1)/E;return i};class br extends R{constructor(){super("MINES")}determineGameResult({generator:r,edge:o,gameInputs:i}){if(i.minesCount<=0||i.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(i.selectedTiles.length>25-i.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let t=r.getUniqueRandomInts({min:1,max:25,count:i.minesCount}),O=t.values.some((V)=>i.selectedTiles.includes(V)),d=i.hasCashedOut||O,B=(100-o)/100,f=new v(z(25-i.minesCount,i.selectedTiles.length)).div(new v(z(25,i.selectedTiles.length))),G=i.hasCashedOut&&!O?new v(B).div(f):new v(0);return{isFinished:d,payoutMultiplier:G,outputs:{result:t.values},randomValues:t}}}import{Big as io}from"big.js";var m;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(m||={});var ni=[8,9,10,11,12,13,14,15,16],sr={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},mr={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},gr={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},ro={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},oo={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},g=new y(new Map([[1,sr],[2,mr],[3,gr],[4,ro],[8,oo]]));class Eo extends R{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(o.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(o.numberOfRows<8||o.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let E=o.numberOfRows,t=g.getMultipliers(i)[o.riskLevel][E],O=r.getRandomIntsWithReplacement({min:0,max:1,count:o.numberOfRows}),B=O.values.reduce((S,G)=>S+G,0),f=t[B];if(f===void 0)throw new Error(`No payout found for end position ${B}`);return{isFinished:!0,payoutMultiplier:io(f),outputs:{result:O.values},randomValues:O}}}import{Big as n}from"big.js";var I=[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],rr=[37,...I],or=[[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]],ir=[[0,1],[0,3],[0,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]],Er=[[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]],Ar=[[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]],cr=[[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]],nr=[[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]],J=[0,1,2,3,37],tr=[[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]],er=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],K;((i)=>{i.EVEN="EVEN";i.ODD="ODD"})(K||={});var p;((i)=>{i.RED="RED";i.BLACK="BLACK"})(p||={});var Z;((i)=>{i.LOW="LOW";i.HIGH="HIGH"})(Z||={});var _;((E)=>{E.TOP="TOP";E.MIDDLE="MIDDLE";E.BOTTOM="BOTTOM"})(_||={});var D;((E)=>{E.FIRST="FIRST";E.SECOND="SECOND";E.THIRD="THIRD"})(D||={});var Q;((i)=>{i.AMERICAN="AMERICAN";i.EUROPEAN="EUROPEAN"})(Q||={});var U=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw e.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&a(o.value)))throw e.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&Ao(o.values)))throw e.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&co(o.values)))throw e.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&no(o.values)))throw e.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&to(o.values)))throw e.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.parity)))throw e.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(p).includes(o.color)))throw e.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw e.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.column)))throw e.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(D).includes(o.dozen)))throw e.createValidationError("Invalid dozen bet.")},a=(r)=>{return I.includes(r)},Ao=(r)=>{if(r.length!==2)return!1;if(!r.every(a))return!1;return or.some(([o,i])=>o===r[0]&&i===r[1])},co=(r)=>{if(r.length!==3)return!1;if(!r.every(a))return!1;return Er.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},no=(r)=>{if(r.length!==4)return!1;if(!r.every(a))return!1;return cr.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},to=(r)=>{if(r.length!==6)return!1;if(!r.every(a))return!1;return tr.some(([o,i,E,A,c,t])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&t===r[5])};var P=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw e.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&l(o.value)))throw e.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&eo(o.values)))throw e.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&fo(o.values)))throw e.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&Oo(o.values)))throw e.createValidationError("Invalid corner bet.");if(!r.basketBets.every((o)=>o.amount.gte(0)))throw e.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&Ro(o.values)))throw e.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.parity)))throw e.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(p).includes(o.color)))throw e.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw e.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.column)))throw e.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(D).includes(o.dozen)))throw e.createValidationError("Invalid dozen bet.")},l=(r)=>{return rr.includes(r)};function eo(r){if(r.length!==2)return!1;if(!r.every(l))return!1;return ir.some(([o,i])=>o===r[0]&&i===r[1])}var fo=(r)=>{if(r.length!==3)return!1;if(!r.every(l))return!1;return Ar.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},Oo=(r)=>{if(r.length!==4)return!1;if(!r.every(l))return!1;return nr.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},Ro=(r)=>{if(r.length!==6)return!1;if(!r.every(l))return!1;return er.some(([o,i,E,A,c,t])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&t===r[5])};var fr=(r)=>{return new n(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n(0)))},Or=(r)=>{return new n(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.basketBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n(0)))},li=(r)=>{return r.type==="EUROPEAN"?fr(r.inputs):Or(r.inputs)};class Rr extends R{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){U(o);let i=r.getRandomInt({min:0,max:36}),E=i.value,A=this.determineBetOutcomes(o,E),c=fr(o),t=this.calculateTotalPayoutAmount(A),O=c.gt(0)?t.div(c):new n(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:O,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0)))}}class dr extends R{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){P(o);let i=r.getRandomInt({min:0,max:37}),E=i.value,A=this.determineBetOutcomes(o,E),c=Or(o),t=this.calculateTotalPayoutAmount(A),O=c.gt(0)?t.div(c):new n(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:O,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>J.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>!J.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0||o===37)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n(0))).add(r.winningBets.basketBets.reduce((o,i)=>o.plus(i.amount.mul(7)),new n(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0)))}}class Bo extends R{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Rr,this.americanGame=new dr}determineGameResult(r){let{gameInputs:o,...i}=r;if(r.edge===2.7&&o.type==="EUROPEAN"){let E=this.europeanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"european",betOutcomes:A,result:E.outputs.result}}}if(r.edge===5.3&&o.type==="AMERICAN"){let E=this.americanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"american",betOutcomes:A,result:E.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var hi=(r)=>{if(r.type==="EUROPEAN")U(r.inputs);else P(r.inputs)};import{Big as yo}from"big.js";var M;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(M||={});var w;((c)=>{c[c.TEN=10]="TEN";c[c.TWENTY=20]="TWENTY";c[c.THIRTY=30]="THIRTY";c[c.FORTY=40]="FORTY";c[c.FIFTY=50]="FIFTY"})(w||={});var So={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}}},To={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}}},xo={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}}},Go={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}}},Lo={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}}},Br=new y(new Map([[1,So],[2,To],[3,xo],[4,Go],[8,Lo]]));var Sr={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class Co extends R{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(!Object.values(w).includes(o.segments))throw new Error("Invalid segments value");if(!Object.values(M).includes(o.riskLevel))throw new Error("Invalid risk level");let A=Br.getMultipliers(i)[o.riskLevel];if(A===void 0)throw new Error(`No multipliers found for risk level ${o.riskLevel}`);let c=A[o.segments];if(c===void 0)throw new Error(`No multipliers found for segment ${o.segments}`);let t=Sr[o.riskLevel];if(t===void 0)throw new Error(`No patterns found for risk level ${o.riskLevel}`);let O=t[o.segments];if(O===void 0)throw new Error(`No patterns found for segment ${o.segments}`);let d=r.getRandomInt({min:0,max:O.length-1}),B=O[d.value];if(B===void 0)throw new Error(`No pattern found for segment ${o.segments} and value ${d.value}`);let f=c[B];if(f===void 0)throw new Error(`No payout found for picked segment ${B}`);return{isFinished:!0,payoutMultiplier:new yo(f),outputs:{result:d.values},randomValues:d}}}export{hi as validateRouletteGameInputs,Mo as validateAdvancedDiceInputs,g as plinkoMultipliers,jr as diamondsMultipliers,li as calculateRouletteBetAmount,Hr as calculateBaccaratBetAmount,w as WheelSegments,M as WheelRiskLevel,Co as Wheel,ar as VALID_SUITS,lr as VALID_RANKS,Er as VALID_EUROPEAN_STREETS,I as VALID_EUROPEAN_STRAIGHTS,or as VALID_EUROPEAN_SPLITS,tr as VALID_EUROPEAN_DOUBLE_STREETS,cr as VALID_EUROPEAN_CORNERS,Ar as VALID_AMERICAN_STREETS,rr as VALID_AMERICAN_STRAIGHTS,ir as VALID_AMERICAN_SPLITS,er as VALID_AMERICAN_DOUBLE_STREETS,nr as VALID_AMERICAN_CORNERS,Q as RouletteType,Bo as Roulette,Dr as RollType,$ as RANDOM_MIN_VALUE,j as RANDOM_MAX_VALUE,m as PlinkoRiskLevel,Eo as Plinko,K as Parity,ni as PLINKO_ROW_COUNTS,x as OrigamiGame,br as Mines,Lr as MIN_WIN_CHANCE,yr as MAX_WIN_CHANCE,ur as Limbo,Qr as KenoRiskLevel,Wr as Keno,Z as Half,Gr as GameErrorCode,e as GameError,R as Game,X as EFFECTIVE_RANGE,D as Dozen,Ir as DiceDirection,Jr as Dice,Ur as DiamondsResultType,zr as Diamonds,_ as Column,p as Color,Mr as BaccaratOutcome,wr as BaccaratBetType,hr as Baccarat,Nr as AdvancedDice,J as AMERICAN_BASKET};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/game-calculations",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",