pixi-reels 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/board/HoldAndWinBoard.d.ts.map +1 -1
- package/dist/config/types.d.ts +52 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/core/Reel.d.ts.map +1 -1
- package/dist/core/ReelSet.d.ts +55 -6
- package/dist/core/ReelSet.d.ts.map +1 -1
- package/dist/core/ReelSetBuilder.d.ts +19 -3
- package/dist/core/ReelSetBuilder.d.ts.map +1 -1
- package/dist/debug-BmbbKZrS.cjs +4 -0
- package/dist/debug-BmbbKZrS.cjs.map +1 -0
- package/dist/{debug-BVIT3Sjs.js → debug-BwsaPR3I.js} +382 -244
- package/dist/debug-BwsaPR3I.js.map +1 -0
- package/dist/events/ReelEvents.d.ts +18 -2
- package/dist/events/ReelEvents.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -53
- package/dist/index.js.map +1 -1
- package/dist/spin/SpinController.d.ts +165 -13
- package/dist/spin/SpinController.d.ts.map +1 -1
- package/dist/testing/testHarness.d.ts +5 -0
- package/dist/testing/testHarness.d.ts.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/dist/utils/notify.d.ts +44 -0
- package/dist/utils/notify.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/debug-AjBRiekN.cjs +0 -4
- package/dist/debug-AjBRiekN.cjs.map +0 -1
- package/dist/debug-BVIT3Sjs.js.map +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const e=require(`./ReelSymbol-0kVAZr4S.cjs`);let t=require(`pixi.js`);var n=class{_listeners=new Map;on(e,t,n){return this._add(e,t,n,!1)}once(e,t,n){return this._add(e,t,n,!0)}off(e,t,n){let r=this._listeners.get(e);if(!r)return this;if(!t)return this._listeners.delete(e),this;let i=r.filter(e=>e.fn!==t||n!==void 0&&e.context!==n);return i.length===0?this._listeners.delete(e):this._listeners.set(e,i),this}emit(e,...t){let n=this._listeners.get(e);if(!n||n.length===0)return!1;let r=n.slice();for(let n of r)n.once&&this._removeEntry(e,n),n.fn.apply(n.context,t);return!0}_removeEntry(e,t){let n=this._listeners.get(e);if(!n)return;let r=n.indexOf(t);r!==-1&&(n.splice(r,1),n.length===0&&this._listeners.delete(e))}removeAllListeners(e){return e===void 0?this._listeners.clear():this._listeners.delete(e),this}listenerCount(e){return this._listeners.get(e)?.length??0}_add(e,t,n,r){let i=this._listeners.get(e);return i||(i=[],this._listeners.set(e,i)),i.push({fn:t,context:n,once:r}),this}},r=class{polarity;mainProp;crossProp;feedEdge;_vertical;constructor(e,t){this.orientation=e,this.direction=t,this._vertical=e===`vertical`,this.mainProp=this._vertical?`y`:`x`,this.crossProp=this._vertical?`x`:`y`,this.polarity=t===`forward`?1:-1,this.feedEdge=this.polarity>0?`start`:`end`}getMain(e){return e[this.mainProp]}setMain(e,t){e[this.mainProp]=t}addMain(e,t){e[this.mainProp]+=t}getCross(e){return e[this.crossProp]}setCross(e,t){e[this.crossProp]=t}toLocal(e,t){return this._vertical?{cross:e,main:t}:{cross:t,main:e}}toScreen(e,t){return this._vertical?{x:e,y:t}:{x:t,y:e}}};function i(e,t){return new r(e,t)}var a=i(`vertical`,`forward`),o=1e-9,s=class{_pitch;_bufferStart;_axis;_travel=0;_rot=0;_off=0;constructor(e,t,n,r,i,o,s,c=a,l){this._symbols=e,this._onSymbolWrapped=s,this._curve=l,this._pitch=t+n,this._bufferStart=r,this._axis=c,this._render()}advance(e){if(e===0)return;this._travel+=this._axis.polarity*e;let t=this._travel/this._pitch,n=Math.round(t);Math.abs(t-n)<o&&(t=n);let r=Math.floor(t);for(;this._rot<r;)this._rot++,this._rotateToStart();for(;this._rot>r;)this._rot--,this._rotateToEnd();this._off=this._travel-r*this._pitch,Math.abs(this._off)<o&&(this._off=0),this._render()}setCurve(e){if(this._curve&&!e)for(let e=0;e<this._symbols.length;e++)this._symbols[e].applyCellQuad(null);this._curve=e,this._render()}snapToGrid(){this._travel=0,this._rot=0,this._off=0,this._render()}getCellMain(e){return(e-this._bufferStart)*this._pitch}get slotPitch(){return this._pitch}reshape(e,t,n,r,i){this._pitch=e+t,this._bufferStart=n}_rotateToStart(){let e=this._symbols.pop();this._symbols.unshift(e),this._onSymbolWrapped(e)}_rotateToEnd(){let e=this._symbols.shift();this._symbols.push(e),this._onSymbolWrapped(e)}_render(){let e=this._off,t=this._curve;for(let n=0;n<this._symbols.length;n++){let r=this._symbols[n],i=(n-this._bufferStart)*this._pitch+e;this._axis.setMain(r.view,i),t&&r.applyCellQuad(t.quadFor(i,r.cellInset))}}},c={reel:0,"set-lean":.5,set:1},l=1,u=1e-4,d=.9;function f(e){let t=typeof e==`number`?{amount:e}:e,n=p(t.amount),r=p(t.depth??n*.5),i=d*Math.cos(n*l);return{amount:n,depth:Math.min(r,i)}}function p(e){return Number.isFinite(e)?e<0?0:e>1?1:e:0}var m=class{_arc;_k;_edgeScale;_norm;_edgeMapped;_edgeSlope;_cellMain=0;_cellCross=0;_halfExtent=0;_radius=0;_focusCross=null;constructor(e,t){this._config=e,this._axis=t,this._arc=e.amount*l;let n=Math.sin(this._arc),r=Math.cos(this._arc),i=1-r;this._k=i>0?e.depth/i:0,this._edgeScale=this._perspectiveAt(this._arc),this._norm=this._arc>0?this._arc:1,this._edgeMapped=n*this._edgeScale/this._norm,this._edgeSlope=this._arc>0?this._arc*(r*(1+this._k)-this._k)*this._edgeScale*this._edgeScale/this._norm:1}get config(){return this._config}get isFlat(){return this._arc<u}setGeometry(e,t,n,r){this._cellMain=e,this._cellCross=t,this._halfExtent=(r*n-(n-e))/2,this._radius=this._arc>0?this._halfExtent/this._arc:0}setFocus(e){this._focusCross=e}get focusCross(){return this._focusCross??this._cellCross/2}quadFor(e,t){if(this.isFlat||this._halfExtent<=0)return null;let n=e,r=e+this._cellMain,i=0,a=this._cellCross;if(t){let o=this._axis.toLocal(t.left,t.top),s=this._axis.toLocal(t.right,t.bottom);n=e+o.main*this._cellMain,r=e+s.main*this._cellMain,i=o.cross*this._cellCross,a=s.cross*this._cellCross}let o=this._project(n),s=this._project(r),c=this.focusCross,l=c+(i-c)*o.scale,u=c+(a-c)*o.scale,d=c+(i-c)*s.scale,f=c+(a-c)*s.scale,p=o.main-e,m=s.main-e,h=this._axis.toScreen(l,p),g=this._axis.toScreen(u,p),_=this._axis.toScreen(d,m),v=this._axis.toScreen(f,m),y=this._axis.toScreen(i,n-e),b=this._axis.toScreen(a-i,r-n),x={x:y.x,y:y.y,width:b.x,height:b.y};return this._axis.orientation===`vertical`?{...x,x0:h.x,y0:h.y,x1:g.x,y1:g.y,x2:v.x,y2:v.y,x3:_.x,y3:_.y}:{...x,x0:h.x,y0:h.y,x1:_.x,y1:_.y,x2:v.x,y2:v.y,x3:g.x,y3:g.y}}mapMain(e){return this._project(e).main}scaleAt(e){return this._project(e).scale}_project(e){if(this.isFlat||this._halfExtent<=0)return{main:e,scale:1};let t=this._halfExtent,n=(e-t)/this._radius,r=this._perspectiveAt(Math.min(Math.abs(n),Math.PI)),i=t*this._edgeMapped;return n>this._arc?{main:t+i+(e-2*t)*this._edgeSlope,scale:r}:n<-this._arc?{main:t-i+e*this._edgeSlope,scale:r}:{main:t+t*Math.sin(n)*r/this._norm,scale:r}}_perspectiveAt(e){return 1/(1+this._k*(1-Math.cos(e)))}},h=class{_callbacks=[];_isDestroyed=!1;constructor(e){this._ticker=e}get isDestroyed(){return this._isDestroyed}add(e){this._isDestroyed||(this._callbacks.push(e),this._ticker.add(e))}remove(e){let t=this._callbacks.indexOf(e);t!==-1&&(this._callbacks.splice(t,1),this._ticker.remove(e))}destroy(){if(!this._isDestroyed){for(let e of this._callbacks)this._ticker.remove(e);this._callbacks.length=0,this._isDestroyed=!0}}},g=16,_=class extends t.Container{_mesh;_texture;_isDestroyed=!1;_width;_height;_tickerRef;constructor(e,n,r,i,a,o,s,c=0,l=0){super(),this._source=e,this._renderer=n,this._curve=r,this._axis=i,this._margin=c,this._bleed=l;let u=this._axis.toScreen(l*2,c*2);this._width=Math.max(1,Math.ceil(a+Math.abs(u.x))),this._height=Math.max(1,Math.ceil(o+Math.abs(u.y))),this._texture=t.RenderTexture.create({width:this._width,height:this._height,resolution:n.resolution}),this._mesh=new t.MeshPlane({texture:this._texture,verticesX:g,verticesY:g}),this._mesh.autoResize=!1,this.addChild(this._mesh),this._displace(),this._tickerRef=new h(s),this._tickerRef.add(()=>this.update())}get isDestroyed(){return this._isDestroyed}update(){if(this._isDestroyed)return;let{x:e,y:t}=this._source.position,n=this._axis.toScreen(this._bleed,this._margin);this._source.position.set(n.x,n.y),this._renderer.render({container:this._source,target:this._texture,clear:!0}),this._source.position.set(e,t)}resize(e,t){let n=this._axis.toScreen(this._bleed*2,this._margin*2),r=Math.max(1,Math.ceil(e+Math.abs(n.x))),i=Math.max(1,Math.ceil(t+Math.abs(n.y)));r===this._width&&i===this._height||(this._width=r,this._height=i,this._texture.resize(r,i),this._displace())}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._tickerRef.destroy(),this._mesh.destroy(),this._texture.destroy(!0),super.destroy({children:!0}))}_displace(){let e=this._mesh.geometry.positions,t=this._curve.focusCross,n=g-1;for(let r=0;r<e.length/2;r++){let i=r%g/n,a=Math.floor(r/g)/n,o=this._axis.toLocal(i*this._width,a*this._height),s=o.main-this._margin,c=o.cross-this._bleed,l=this._curve.scaleAt(s),u=this._axis.toScreen(t+(c-t)*l,this._curve.mapMain(s));e[r*2]=u.x,e[r*2+1]=u.y}this._mesh.geometry.positions=e}},v=class{_frame=[];_remaining=0;_cursor=0;_step=-1;setFrame(e,t=`start`){this._frame=[...e],this._remaining=this._frame.length,t===`end`?(this._cursor=0,this._step=1):(this._cursor=this._frame.length-1,this._step=-1)}next(){if(this._remaining===0)throw Error("StopSequencer.next(): frame exhausted. Gate on `hasRemaining` before calling, or reload a frame with `setFrame()`.");this._remaining--;let e=this._frame[this._cursor];return this._cursor+=this._step,e}get hasRemaining(){return this._remaining>0}get remaining(){return this._remaining}reset(){this._frame=[],this._remaining=0,this._cursor=0,this._step=-1}};function y(e,t){return t<0?e.bufferStart?.[-1-t]:t<e.visible.length?e.visible[t]:e.bufferEnd?.[t-e.visible.length]}function b(e,t,n){t<0?(e.bufferStart??=[])[-1-t]=n:t<e.visible.length?e.visible[t]=n:(e.bufferEnd??=[])[t-e.visible.length]=n}function x(e,t){let n=e.bufferEnd?.length??0,r=Array(t+e.visible.length+n);for(let n=0;n<r.length;n++)r[n]=y(e,n-t);return r}function S(e){return{visible:[...e.visible],bufferStart:e.bufferStart?[...e.bufferStart]:void 0,bufferEnd:e.bufferEnd?[...e.bufferEnd]:void 0}}function C(e,t){if(!Array.isArray(e))throw TypeError(`${t}: expected ColumnTarget[], got ${typeof e}.`);for(let n=0;n<e.length;n++){let r=e[n];if(Array.isArray(r))throw TypeError(`${t}: column ${n} is a plain string[]. ${t} takes ColumnTarget[] - wrap each column: grid.map((visible) => ({ visible })).`);if(typeof r!=`object`||!r||!Array.isArray(r.visible))throw TypeError(`${t}: column ${n} has no 'visible' array. Each column is { visible: string[], bufferStart?: string[], bufferEnd?: string[] }.`)}}function ee(e,t,n,r){for(let i=0;i<e.length;i++){let a=t[i]??0,o=n[i]??0,s=e[i],c=te(s.bufferStart),l=te(s.bufferEnd);if(c>=0&&c>=a)throw RangeError(`${r} column ${i}: bufferStart has a symbol at index ${c}, beyond engine bufferSymbols=${a}; it would be silently dropped. Increase bufferSymbols(...) on the builder or remove the extra entry.`);if(l>=0&&l>=o)throw RangeError(`${r} column ${i}: bufferEnd has a symbol at index ${l}, beyond engine bufferSymbols=${o}; it would be silently dropped. Increase bufferSymbols(...) on the builder or remove the extra entry.`)}}function te(e){if(!e)return-1;for(let t=e.length-1;t>=0;t--)if(e[t]!==void 0)return t;return-1}var w=class{name=`standard`;computeDelta(e,t,n){let r=e*t*n/1e3,i=e/2;return Math.max(Math.min(r,i),-i)}},ne=100,T=class extends e.t{onActivate(){this.view.alpha=0,this.view.visible=!1}onDeactivate(){}async playWin(){}stopAnimation(){}resize(){}},E=`__pixi_reels_occupied__`,re=class{container;events;reelIndex;symbols;speed=0;spinningMode=new w;motion;stopSequencer;_axis;_curve;_curveFocus;_warp;_warping;_mainCell;_mainGap;_crossGap;_cellMain;_cellCross;_symbolFactory;_randomProvider;_viewport;_symbolsData;_visibleCells;_bufferStart;_mainOffset;_gsap;_cellStacking;_reelStacking;_extent;_spinCellSize;_symbolGapY;_symbolGapX;_isDestroyed=!1;_isStopping=!1;_spinPresentationActive=!1;_anticipationActive=!1;_atRest=!0;_isNudging=!1;_nudgeQueue=null;_nudgeTween=null;_nudgeReject=null;_occupiedStubs=[];_occupancy=[];_crossReelResolver=null;constructor(r,i,o,c){this.reelIndex=r.reelIndex,this._symbolFactory=i,this._randomProvider=o,this._viewport=c,this._symbolsData=r.symbolsData,this._visibleCells=r.visibleCells,this._bufferStart=r.bufferStart,this._mainOffset=r.mainOffset??0,this._gsap=r.gsap??e.n,this._cellStacking=r.cellStacking??`ascending`,this._reelStacking=r.reelStacking??`ascending`,this._symbolGapY=r.symbolGapY,this._symbolGapX=r.symbolGapX,this._occupancy=Array(r.visibleCells).fill(null),this.events=new n,this.stopSequencer=new v,this._axis=r.axis??a;let l=this._axis.toLocal(r.symbolWidth,r.symbolHeight),u=this._axis.toLocal(r.symbolGapX,r.symbolGapY);this._cellMain=l.main,this._cellCross=l.cross,this._mainGap=u.main,this._crossGap=u.cross,this._extent=r.extent??r.visibleCells*l.main,this._spinCellSize=r.spinCellSize??l.main,this._mainCell=this._spinCellSize;let d=l.cross+u.cross;this.container=new t.Container,this.container.sortableChildren=!0,this._axis.setCross(this.container,r.reelIndex*d),this._axis.setMain(this.container,this._mainOffset),this.container.zIndex=this._reelStacking===`ascending`?r.reelIndex:-r.reelIndex,this.symbols=r.initialSymbols.map((e,t)=>{let n=i.acquire(e),r=this._screenSize(this._spinCellSize,this._cellCross);return n.resize(r.width,r.height),n}),this._curveFocus=r.curveFocus??null,this._warping=r.curveRenderer!==void 0&&r.curve!==void 0,this._curve=this._buildCurve(r.curve,this._mainCell,r.visibleCells);let f=this._warping;if(this.motion=new s(this.symbols,this._mainCell,this._mainGap,r.bufferStart,r.visibleCells,r.bufferEnd,e=>this._onSymbolWrapped(e),this._axis,f?void 0:this._curve),this._setupSymbolPositions(r),f&&r.curveRenderer&&r.curveTicker&&this._curve){let e=this._screenSize(this._extent,this._cellCross);this._warp=new _(this.container,r.curveRenderer,this._curve,this._axis,e.width,e.height,r.curveTicker,this.motion.slotPitch,r.curveBleed??0),this._warp.zIndex=this.container.zIndex,this._axis.setCross(this._warp,this._axis.getCross(this.container)),this._axis.setMain(this._warp,this._axis.getMain(this.container)),this._viewport.maskedContainer.removeChild(this.container),this._viewport.maskedContainer.addChild(this._warp)}}get isDestroyed(){return this._isDestroyed}get isStopping(){return this._isStopping}set isStopping(e){this._isStopping=e}get isNudging(){return this._isNudging}get bufferStart(){return this._bufferStart}get bufferEnd(){return this.symbols.length-this._bufferStart-this._visibleCells}get visibleCells(){return this._visibleCells}get symbolWidth(){return this._axis.toScreen(this._cellCross,this._cellMain).x}get symbolHeight(){return this._axis.toScreen(this._cellCross,this._cellMain).y}_screenSize(e,t){let n=this._axis.toScreen(t,e);return{width:n.x,height:n.y}}_blockSize(e,t){return this._screenSize(t*this._cellMain+(t-1)*this._mainGap,e*this._cellCross+(e-1)*this._crossGap)}get cellMain(){return this._cellMain}get cellCross(){return this._cellCross}get mainGap(){return this._mainGap}get crossGap(){return this._crossGap}get extent(){return this._extent}get mainOffset(){return this._mainOffset}get spinCellSize(){return this._spinCellSize}get gsap(){return this._gsap}get axis(){return this._axis}get curve(){return this._curve}setCurve(e){let t=this.motion.slotPitch-this._mainGap;this._curve=this._buildCurve(e,t,this._visibleCells),this.motion.setCurve(this._curve),this._syncUnmaskedViewOffsets()}update(e){if(this.speed===0)return;let t=Math.min(e,ne),n=this.spinningMode.computeDelta(this.motion.slotPitch,this.speed,t);n!==0&&this.motion.advance(n)}setStopFrame(e){this.stopSequencer.setFrame(e,this._axis.feedEdge)}getVisibleSymbols(){let e=[];for(let t=0;t<this._visibleCells;t++){let n=this._occupancy[t];if(n){let t=this.symbols[this._bufferStart+n.anchorCell];e.push(t.symbolId)}else{let n=this.symbols[this._bufferStart+t].symbolId;n===`__pixi_reels_occupied__`&&this._crossReelResolver?e.push(this._crossReelResolver(this.reelIndex,t)):e.push(n)}}return e}getTarget(){let e=e=>{let t=this.symbols[e]?.symbolId??``;if(t!==`__pixi_reels_occupied__`)return t;for(let t=e-1;t>=0;t--){let e=this.symbols[t]?.symbolId;if(e&&e!==`__pixi_reels_occupied__`)return e}let n=e-this._bufferStart;return n>=0&&this._crossReelResolver?this._crossReelResolver(this.reelIndex,n):this.symbols[this._bufferStart]?.symbolId??``},t=[];for(let n=0;n<this._visibleCells;n++)t.push(e(this._bufferStart+n));let n={visible:t};if(this._bufferStart>0){let t=[];for(let n=0;n<this._bufferStart;n++)t.push(e(this._bufferStart-1-n));n.bufferStart=t}if(this.bufferEnd>0){let t=[];for(let n=0;n<this.bufferEnd;n++)t.push(e(this._bufferStart+this._visibleCells+n));n.bufferEnd=t}return n}setCrossReelResolver(e){this._crossReelResolver=e}getSymbolAt(e){let t=this._occupancy[e],n=t?t.anchorCell:e;return this.symbols[this._bufferStart+n]}getAnchorCell(e){let t=this._occupancy[e];return t?t.anchorCell:e}_setOccupancy(e,t){t===null?this._occupancy[e]=null:this._occupancy[e]={anchorCell:t}}notifySpinStart(){this._spinPresentationActive=!0,this._anticipationActive=!1,this.beginMotion();for(let e=0;e<this.symbols.length;e++)this.symbols[e].onReelSpinStart()}beginMotion(){if(this._atRest){this._atRest=!1;for(let e=0;e<this.symbols.length;e++){let t=this.symbols[e],n=t.view;if(n.parent===this._viewport.unmaskedContainer){let e=this._axis.getMain(n)-this._axis.getMain(this.container);this.container.addChild(n),this._placeSymbolView(t,e,!1)}}}}notifyAnticipationStart(){this._anticipationActive=!0;for(let e=0;e<this.symbols.length;e++)this.symbols[e].onReelAnticipationStart()}notifySpinEnd(){this._spinPresentationActive=!1,this._anticipationActive=!1;for(let e=0;e<this.symbols.length;e++)this.symbols[e].onReelSpinEnd()}notifyLanded(e){this._atRest=!0;let t=e?new Set(e):null;for(let e=this._bufferStart;e<this._bufferStart+this._visibleCells;e++){let n=this.symbols[e];if(this._isUnmasked(n.symbolId)&&n.view.parent===this.container){let e=this._axis.getMain(n.view);this._viewport.unmaskedContainer.addChild(n.view),this._placeSymbolView(n,e,!0)}(t===null||t.has(e-this._bufferStart))&&n.onReelLanded()}}snapToGrid(){this._reMaskLiftedBufferSlots(),this.motion.snapToGrid(),this._syncUnmaskedViewOffsets(),this._finalizeFrame(),this.refreshZIndex()}_reMaskLiftedBufferSlots(){for(let e=0;e<this.symbols.length;e++){let t=this.symbols[e],n=t.view;if(n.parent!==this._viewport.unmaskedContainer||!this._isBufferSlot(e))continue;let r=this._toReelLocalY(n);this.container.addChild(n),this._placeSymbolView(t,r,!1)}}setSymbolAt(e,t){if(this.speed!==0||this._isStopping||this._isNudging)throw Error(`setSymbolAt: cannot swap mid-motion (speed=${this.speed}, isStopping=${this._isStopping}, isNudging=${this._isNudging}). Wait for the spin or nudge to land before calling, or use the result grid via setResult().`);if(!Number.isInteger(e)||e<0||e>=this._visibleCells)throw Error(`setSymbolAt: visibleCell ${e} is out of range [0, ${this._visibleCells}).`);if(!Object.prototype.hasOwnProperty.call(this._symbolsData,t))throw Error(`setSymbolAt: symbolId '${t}' is not registered. Register it via builder.symbols(...).`);let n=this._occupancy[e];if(n)throw Error(`setSymbolAt: visible cell ${e} is a non-anchor cell of a big symbol (anchor at cell ${n.anchorCell}). Use placeSymbols to rebuild the frame.`);let r=this._bufferStart+e,i=this.symbols[r],a=this._symbolsData[i.symbolId];if(a?.size&&(a.size.reels>1||a.size.cells>1))throw Error(`setSymbolAt: cell ${e} currently holds the anchor of big symbol '${i.symbolId}' (${a.size.reels}x${a.size.cells}). Big blocks span multiple cells (and possibly reels); use placeSymbols + the OCCUPIED coordinator instead.`);let o=this._symbolsData[t];if(o?.size&&(o.size.reels>1||o.size.cells>1))throw Error(`setSymbolAt: '${t}' is a big symbol (${o.size.reels}x${o.size.cells}). Use placeSymbols + the OCCUPIED coordinator instead.`);this._replaceSymbol(r,t)}async nudge(e,t){if(this._isDestroyed)throw Error(`nudge: reel has been destroyed.`);if(this.speed!==0||this._isStopping||this._isNudging)throw Error(`nudge: cannot nudge a reel in motion (speed=${this.speed}, isStopping=${this._isStopping}, isNudging=${this._isNudging}). Wait for the spin or previous nudge to land first.`);let{distance:n,direction:r,incoming:i,signal:a}=e;if(!Number.isInteger(n)||n<1)throw Error(`nudge: distance must be a positive integer, got ${n}.`);let o=this.symbols.length;if(n>=o)throw Error(`nudge: distance ${n} must be strictly less than total strip capacity (bufferStart + visibleCells + bufferEnd = ${o}). At distance = total the strip rotates fully and pre-placed buffer entries would be silently dropped.`);if(r!==`forward`&&r!==`reverse`)throw Error(`nudge: direction must be 'forward' or 'reverse', got ${String(r)}.`);if(!Array.isArray(i)||i.length!==n)throw Error(`nudge: incoming must be an array of exactly ${n} symbol id(s), got length ${i?.length}.`);let s=r===`forward`?1:-1,c=s*this._axis.polarity>0;for(let e of i){if(!Object.prototype.hasOwnProperty.call(this._symbolsData,e))throw Error(`nudge: incoming symbol '${e}' is not registered. Register it via builder.symbols(...).`);let t=this._symbolsData[e];if(t?.size&&(t.size.reels>1||t.size.cells>1))throw Error(`nudge: incoming symbol '${e}' is a big symbol (${t.size.reels}x${t.size.cells}). Big symbols are not supported as incoming items (they need an anchor + OCCUPIED coordinator). Pre-existing big symbols on the strip CAN be nudged through.`)}for(let e=0;e<o;e++){let t=this.symbols[e];if(t instanceof T)continue;let i=this._symbolsData[t.symbolId];if(!i?.size)continue;let{reels:a,cells:s}=i.size;if(!(a===1&&s===1)){if(a>1)throw Error(`nudge: reel ${this.reelIndex} carries cross-reel big symbol '${t.symbolId}' (${a}x${s}) at strip[${e}]. Cross-reel blocks can't be nudged from a single reel. the other-reel cells would stay put and split the block.`);if(s>1&&!(c?e+s-1+n<o:e-n>=0)){let i=c?`anchor + h - 1 + distance < total (${e} + ${s} - 1 + ${n} = ${e+s-1+n} vs ${o})`:`anchor - distance >= 0 (${e} - ${n} = ${e-n})`;throw Error(`nudge: block '${t.symbolId}' (${a}x${s}) at strip[${e}] wouldn't survive a distance=${n} ${r} nudge. the wrap boundary would split the anchor from its stubs. Block survival: ${i}.`)}}}for(let e=0;e<this._visibleCells;e++)if(this.symbols[this._bufferStart+e].symbolId===`__pixi_reels_occupied__`&&!this._occupancy[e])throw Error(`nudge: visible cell ${e} is a non-anchor cell of a cross-reel big symbol. Cross-reel blocks can't be nudged from a single reel.`);if(a?.aborted){let e=Error(`nudge: aborted before start.`);throw e.name=`AbortError`,e}let l=e.startDelay??0;if(l>0){let e;try{await new Promise((t,n)=>{let r=setTimeout(t,l);a&&(e=()=>{clearTimeout(r);let e=Error(`nudge: aborted during startDelay.`);e.name=`AbortError`,n(e)},a.addEventListener(`abort`,e,{once:!0}))})}finally{e&&a?.removeEventListener(`abort`,e)}if(this._isDestroyed){let e=Error(`nudge: reel destroyed during startDelay.`);throw e.name=`AbortError`,e}}let u=e.duration??200*n,d=e.ease??`power2.out`,f=this.motion.slotPitch,p=this._bufferStart,m=this.bufferEnd,h=e=>{let t=this.symbols[e];if(t instanceof T)return!0;let n=this._symbolsData[t.symbolId];return!!(n?.size&&(n.size.reels>1||n.size.cells>1))};if(c){let e=Math.min(n,p);for(let t=0;t<e;t++){let r=p-e+t,a=n-e+t;h(r)||this._replaceSymbol(r,i[a])}let t=[],r=n-p;for(let e=1;e<=n;e++)e<=r?t.push(i[r-e]):t.push(this._randomProvider.next(`bufferStart`,this.reelIndex));this._nudgeQueue=t}else{let e=Math.min(n,m);for(let t=0;t<e;t++){let e=p+this._visibleCells+t;h(e)||this._replaceSymbol(e,i[t])}let t=[],r=n-m;for(let e=1;e<=n;e++)e<=r?t.push(i[m+e-1]):t.push(this._randomProvider.next(`bufferEnd`,this.reelIndex));this._nudgeQueue=t}this.motion.snapToGrid(),this._syncUnmaskedViewOffsets(),this.refreshZIndex(),this._isNudging=!0,this.events.emit(`phase:enter`,`nudge`),t?.();let g=s*n*f,_=f*.45,v=()=>{let e=this._nudgeQueue?.length??0;if(e>0){let t=e,n=s*_;for(let e=0;e<t*3&&(this._nudgeQueue?.length??0)>0;e++)this.motion.advance(n)}this.snapToGrid(),this._isNudging=!1,this._nudgeQueue=null,this._nudgeTween=null,this._nudgeReject=null,this.events.emit(`phase:exit`,`nudge`)};try{await new Promise((e,t)=>{this._nudgeReject=t;let n=()=>{this._nudgeTween&&=(this._nudgeTween.kill(),null),v();let e=Error(`nudge: aborted.`);e.name=`AbortError`,t(e)};a&&a.addEventListener(`abort`,n,{once:!0});let r={p:0},i=0;this._nudgeTween=this._gsap.to(r,{p:1,duration:u/1e3,ease:d,onUpdate:()=>{let e=r.p*g,t=g>0?Math.min(e,g):Math.max(e,g),n=t-i;for(;Math.abs(n)>_;){let e=n>0?_:-_;this.motion.advance(e),n-=e}n!==0&&this.motion.advance(n),this._syncUnmaskedViewOffsets(),i=t},onComplete:()=>{a&&a.removeEventListener(`abort`,n),v(),e()}})})}catch(e){throw e}return{symbols:this.getVisibleSymbols()}}skipNudge(){if(!this._isNudging||!this._nudgeTween)return;let e=this._nudgeTween;this._nudgeTween=null,e.progress(1)}placeSymbols(e){this.placeStrip(x(e,this._bufferStart))}placeStrip(e){let t=this.symbols.length;for(let n=0;n<t;n++){let t=e[n]??this._randomProvider.next(this._slotKind(n),this.reelIndex);this._replaceSymbol(n,t)}this.motion.snapToGrid(),this._syncUnmaskedViewOffsets(),this._finalizeFrame(),this.refreshZIndex()}reshape(e,t,n,r){let i=n+e+r,a=this._screenSize(t,this._cellCross);for(;this.symbols.length<i;){let e=this._randomProvider.next(`bufferEnd`,this.reelIndex),t=this._symbolFactory.acquire(e),n=this.symbols.length;t.resize(a.width,a.height),this._placeSymbolView(t,this._axis.getMain(t.view),this._effectiveUnmask(e,n)),this._parentForSymbolId(e,n).addChild(t.view),this.symbols.push(t)}for(;this.symbols.length>i;){let e=this.symbols.pop();e instanceof T?e.view.parent?.removeChild(e.view):this._symbolFactory.release(e)}this._visibleCells=e,this._cellMain=t,this._bufferStart=n,this._occupancy=Array(e).fill(null),this._extent=e*t+(e-1)*this._mainGap;for(let e of this.symbols)e instanceof T||e.resize(a.width,a.height);if(this._curve?.setGeometry(t,this._cellCross,t+this._mainGap,e),this._warp){let e=this._screenSize(this._extent,this._cellCross);this._warp.resize(e.width,e.height)}this.motion.reshape(t,this._mainGap,n,e,r),this.motion.snapToGrid(),this._syncUnmaskedViewOffsets(),this.refreshZIndex()}_computeSymbolZIndex(e,t){let n=this._symbolsData[e]?.zIndex??0,r=this._cellStacking===`ascending`?t:this.symbols.length-1-t;return n*100+r}refreshZIndex(){for(let e=0;e<this.symbols.length;e++){let t=this.symbols[e];if(t instanceof T){t.view.zIndex=e;continue}t.view.zIndex=this._computeSymbolZIndex(t.symbolId,e)}}destroy(){if(!this._isDestroyed){if(this._nudgeTween&&=(this._nudgeTween.kill(),null),this._nudgeReject){let e=Error(`nudge: reel was destroyed.`);e.name=`AbortError`,this._nudgeReject(e),this._nudgeReject=null}this._nudgeQueue=null,this._isNudging=!1;for(let e of this.symbols)e.destroy();for(let e of this._occupiedStubs)e.isDestroyed||e.destroy();this._occupiedStubs=[],this.symbols=[],this._warp?.destroy(),this.container.destroy({children:!0}),this._isDestroyed=!0,this.events.emit(`destroyed`),this.events.removeAllListeners()}}_isUnmasked(e){return!!this._symbolsData[e]?.unmask}_isBufferSlot(e){return e<this._bufferStart||e>=this._bufferStart+this._visibleCells}_slotKind(e){return e<this._bufferStart?`bufferStart`:e>=this._bufferStart+this._visibleCells?`bufferEnd`:`spinning`}_effectiveUnmask(e,t){return this._atRest&&!this._isBufferSlot(t)&&this._isUnmasked(e)}_parentForSymbolId(e,t){return this._effectiveUnmask(e,t)?this._viewport.unmaskedContainer:this.container}_placeSymbolView(e,t,n){let r=e.view;n?(this._axis.setCross(r,this._axis.getCross(this.container)),this._axis.setMain(r,this._axis.getMain(this.container)+t)):(this._axis.setCross(r,0),this._axis.setMain(r,t)),this._curve&&!this._warping&&e.applyCellQuad(this._curve.quadFor(t,e.cellInset))}_buildCurve(e,t,n){if(e===void 0)return;let r=new m(f(e),this._axis);if(!r.isFlat)return r.setGeometry(t,this._cellCross,t+this._mainGap,n),r.setFocus(this._curveFocus),r}_toReelLocalY(e){return e.parent===this._viewport.unmaskedContainer?this._axis.getMain(e)-this._axis.getMain(this.container):this._axis.getMain(e)}_syncUnmaskedViewOffsets(){let e=this._axis.getMain(this.container),t=this._axis.getCross(this.container);if(!(e===0&&t===0))for(let n=0;n<this.symbols.length;n++){let r=this.symbols[n].view;r.parent===this._viewport.unmaskedContainer&&(this._axis.setCross(r,t),this._axis.addMain(r,e))}}offsetLiftedViews(e){if(e!==0)for(let t=0;t<this.symbols.length;t++){let n=this.symbols[t].view;n.parent===this._viewport.unmaskedContainer&&this._axis.addMain(n,e)}}_setupSymbolPositions(e){let t=this._spinCellSize+this._mainGap;this._viewport.maskedContainer.addChild(this.container);for(let n=0;n<this.symbols.length;n++){let r=this.symbols[n],i=(n-e.bufferStart)*t,a=this._effectiveUnmask(r.symbolId,n);this._placeSymbolView(r,i,a),(a?this._viewport.unmaskedContainer:this.container).addChild(r.view)}}_onSymbolWrapped(e){let t;t=this._nudgeQueue&&this._nudgeQueue.length>0?this._nudgeQueue.shift():this._isStopping&&this.stopSequencer.hasRemaining?this.stopSequencer.next():this._randomProvider.next(`spinning`,this.reelIndex),this._replaceSymbol(this.symbols.indexOf(e),t),this._isNudging||this.refreshZIndex()}_replaceSymbol(e,t){let n=this.symbols[e],r=n instanceof T,i=r?this._axis.getMain(n.view):this._toReelLocalY(n.view);if(t===`__pixi_reels_occupied__`){if(r){n.view.alpha=0;return}this._symbolFactory.release(n);let t=this._acquireOccupiedStub();this._axis.setMain(t.view,i),this._axis.setCross(t.view,0),t.view.alpha=0,t.view.visible=!0,t.view.scale.set(1,1),t.view.zIndex=e,t.view.parent!==this.container&&this.container.addChild(t.view),this.symbols[e]=t;return}if(r){this._releaseOccupiedStub(n);let r=this._symbolFactory.acquire(t),a=this._effectiveUnmask(t,e);r.resize(this.symbolWidth,this.symbolHeight),r.view.alpha=1,r.view.scale.set(1,1),this._placeSymbolView(r,i,a),r.view.zIndex=this._computeSymbolZIndex(t,e),this._parentForSymbolId(t,e).addChild(r.view),this.symbols[e]=r,this._spinPresentationActive&&r.onReelSpinStart(!0),this._anticipationActive&&r.onReelAnticipationStart(),this.events.emit(`symbol:created`,t,e);return}if(n.symbolId===t){n.stopAnimation(),n.view.alpha=1,n.view.scale.set(1,1),n.view.rotation=0,n.view.filters=null,n.view.zIndex=this._computeSymbolZIndex(t,e);let r=this._parentForSymbolId(t,e);n.view.parent!==r&&r.addChild(n.view),this._placeSymbolView(n,i,this._effectiveUnmask(t,e)),this._spinPresentationActive&&n.onReelSpinStart(!0),this._anticipationActive&&n.onReelAnticipationStart();return}this._symbolFactory.release(n);let a=this._symbolFactory.acquire(t),o=this._effectiveUnmask(t,e);a.resize(this.symbolWidth,this.symbolHeight),a.view.alpha=1,a.view.scale.set(1,1),this._placeSymbolView(a,i,o),a.view.zIndex=this._computeSymbolZIndex(t,e),this._parentForSymbolId(t,e).addChild(a.view),this.symbols[e]=a,this._spinPresentationActive&&a.onReelSpinStart(!0),this._anticipationActive&&a.onReelAnticipationStart(),this.events.emit(`symbol:created`,t,e)}_acquireOccupiedStub(){for(let e of this._occupiedStubs)if(!e.view.parent)return e;let e=new T;return e.activate(E),this._occupiedStubs.push(e),e}_releaseOccupiedStub(e){e.view.parent?.removeChild(e.view)}_finalizeFrame(){this._occupancy=Array(this._visibleCells).fill(null);for(let e=0;e<this._visibleCells;e++){let t=this.symbols[this._bufferStart+e];if(t instanceof T)continue;let n=this._symbolsData[t.symbolId];if(!n?.size)continue;let r=n.size.reels,i=n.size.cells;if(r===1&&i===1)continue;let a=this._blockSize(r,i);t.resize(a.width,a.height);for(let t=1;t<i;t++){let n=e+t;n<this._visibleCells&&(this._occupancy[n]={anchorCell:e})}}for(let e=0;e<this._bufferStart;e++){let t=this.symbols[e];if(t instanceof T)continue;let n=this._symbolsData[t.symbolId];if(!n?.size)continue;let r=n.size.reels,i=n.size.cells;if(r===1&&i===1||e+i-1<this._bufferStart)continue;let a=this._blockSize(r,i);t.resize(a.width,a.height);let o=e-this._bufferStart;for(let e=1;e<i;e++){let t=o+e;t>=0&&t<this._visibleCells&&(this._occupancy[t]={anchorCell:o})}}}},D=2,O=class{version=2;build(e){let n=new t.Graphics;return this._draw(n,e),n}update(e,t){e.clear(),this._draw(e,t)}_draw(e,t){if(t.rects.length===0){e.rect(0,0,t.width,t.height).fill({color:16777215});return}for(let n of t.rects)e.rect(n.x,n.y,n.width,n.height).fill({color:16777215})}},ie=class{version=2;build(e){let n=new t.Graphics;return this._draw(n,e),n}update(e,t){e.clear(),this._draw(e,t)}_draw(e,t){let n=t.axis.toScreen(t.bleed??0,0);e.rect(-n.x,-n.y,t.width+n.x*2,t.height+n.y*2).fill({color:16777215})}},ae=class extends t.Container{maskedContainer;unmaskedContainer;spotlightContainer;dimOverlay;_mask;_maskStrategy;_maskWidth;_maskHeight;_maskRects=[];_axis;_bleed;_isDestroyed=!1;_dimCount=0;constructor(e,n,r={x:0,y:0},i=new O,o=a,s=0){super(),this.x=r.x,this.y=r.y,this._maskStrategy=i,this._maskWidth=e,this._maskHeight=n,this._axis=o,this._bleed=s,this._mask=this._maskStrategy.build(this._maskContext()),this.maskedContainer=new t.Container,this.maskedContainer.sortableChildren=!0,this.maskedContainer.addChild(this._mask),this.maskedContainer.mask=this._mask,this.addChild(this.maskedContainer),this.unmaskedContainer=new t.Container,this.unmaskedContainer.sortableChildren=!0,this.addChild(this.unmaskedContainer),this.dimOverlay=new t.Graphics,this.dimOverlay.rect(0,0,e,n).fill({color:0,alpha:.5}),this.dimOverlay.visible=!1,this.addChild(this.dimOverlay),this.spotlightContainer=new t.Container,this.spotlightContainer.sortableChildren=!0,this.addChild(this.spotlightContainer)}get maskWidth(){return this._maskWidth}get maskHeight(){return this._maskHeight}get maskRects(){return this._maskRects}get maskGraphics(){return this._mask}get axis(){return this._axis}_maskContext(){return{rects:this._maskRects,width:this._maskWidth,height:this._maskHeight,axis:this._axis,bleed:this._bleed}}get isDestroyed(){return this._isDestroyed}showDim(e=.5){this._dimCount++,this.dimOverlay.alpha=e,this.dimOverlay.visible=!0}hideDim(){this._dimCount>0&&this._dimCount--,this._dimCount===0&&(this.dimOverlay.visible=!1)}updateMaskSize(e,t,n=[]){this._maskWidth=e,this._maskHeight=t,this._maskRects=n,this._maskStrategy.update(this._mask,this._maskContext()),this.dimOverlay.clear(),this.dimOverlay.rect(0,0,e,t).fill({color:0,alpha:.5})}destroy(){this._isDestroyed||(this._isDestroyed=!0,super.destroy({children:!0}))}},k=class{_reel;_speed;_resolve=null;_isActive=!1;constructor(e,t){this._reel=e,this._speed=t}get reel(){return this._reel}get isActive(){return this._isActive}async run(e){return this._isActive=!0,this._reel.events.emit(`phase:enter`,this.name),new Promise(t=>{this._resolve=()=>{this._isActive=!1,this._reel.events.emit(`phase:exit`,this.name),t()},this.onEnter(e)})}skip(){!this.skippable||!this._isActive||(this.onSkip(),this._complete())}forceComplete(){this._isActive&&(this.onSkip(),this._complete())}_complete(){if(this._resolve){let e=this._resolve;this._resolve=null,e()}}},A=class extends k{name=`start`;skippable=!0;_tween=null;_delayedCall=null;onEnter(e){let t=this._reel,n=e.delay??0;t.spinningMode=e.spinningMode,t.speed=0,n>0?this._delayedCall=this._reel.gsap.delayedCall(n/1e3,()=>this._launch()):this._launch()}_launch(){this._delayedCall=null;let e=this._reel,t=this._speed;e.beginMotion();let n=(t.accelerationDuration??300)/1e3,r=t.accelerationEase??`power2.in`;this._tween=this._reel.gsap.timeline(),t.bounceDistance>0&&this._tween.to(e,{speed:-2,duration:.05,ease:`power1.out`}),this._tween.to(e,{speed:t.spinSpeed,duration:n,ease:r,onComplete:()=>{e.notifySpinStart(),this._complete()}})}update(e){}onSkip(){this._kill(),this._reel.speed=this._speed.spinSpeed,this._reel.notifySpinStart()}_kill(){this._delayedCall&&=(this._delayedCall.kill(),null),this._tween&&=(this._tween.kill(),null)}},j=class extends k{name=`spin`;skippable=!1;_elapsed=0;_minTime=0;_readyToStop=!1;onEnter(e){this._elapsed=0,this._minTime=e.minimumSpinTime??this._speed.minimumSpinTime??500,this._readyToStop=!1}update(e){this._elapsed+=e,this._readyToStop&&this._elapsed>=this._minTime&&this._complete()}resolve(){this._readyToStop=!0,this._elapsed>=this._minTime&&this._complete()}onSkip(){}},M=class extends k{name=`stop`;skippable=!0;_config=null;_delayTween=null;_bounceTween=null;_stage=`delay`;_baseY=0;onEnter(e){this._config=e,this._stage=`delay`,this._baseY=this._reel.axis.getMain(this._reel.container);let t=(e.delay??0)/1e3;t>0?this._delayTween=this._reel.gsap.delayedCall(t,()=>this._beginSpinOut()):this._beginSpinOut()}_beginSpinOut(){if(!this._config)return;let e=this._reel,t=this._speed;e.setStopFrame(this._config.targetFrame),e.isStopping=!0,this._config.preserveSpeed?e.speed=Math.max(e.speed,t.spinSpeed*.08):e.speed=t.spinSpeed,this._stage=`spinning`}update(e){this._stage===`spinning`&&(this._reel.stopSequencer.hasRemaining||this._landAndBounce())}_landAndBounce(){let e=this._reel,t=this._speed;e.speed=0,e.isStopping=!1,e.snapToGrid(),e.notifySpinEnd(),e.notifyLanded();let n=t.bounceDistance;if(n<=0){this._stage=`done`,this._complete();return}let r=(t.bounceDuration??600)/2e3,i=e.axis;this._stage=`bouncing`;let a=this._baseY,o=()=>{let t=i.getMain(e.container);e.offsetLiftedViews(t-a),a=t};this._bounceTween=this._reel.gsap.timeline(),this._bounceTween.to(e.container,{[i.mainProp]:this._baseY+i.polarity*n,duration:r,ease:`power1.out`,onUpdate:o}),this._bounceTween.to(e.container,{[i.mainProp]:this._baseY,duration:r,ease:`power1.out`,onUpdate:o,onComplete:()=>{o(),this._stage=`done`,this._complete()}})}onSkip(){this._killTweens();let e=this._reel;e.speed=0,e.isStopping=!1,this._stage!==`done`&&this._config&&e.placeStrip(this._config.targetFrame),e.axis.setMain(e.container,this._baseY),e.snapToGrid(),this._stage=`done`}_killTweens(){this._delayTween&&=(this._delayTween.kill(),null),this._bounceTween&&=(this._bounceTween.kill(),null)}},N=class extends k{name=`anticipation`;skippable=!0;_tween=null;onEnter(e){let t=this._reel,n=this._speed,r=(e.duration??n.anticipationDelay)/1e3,i=n.spinSpeed*(e.speedMultiplier??.3);if(r<=0){this._complete();return}this._tween=this._reel.gsap.timeline(),this._tween.to(t,{speed:i,duration:r*.35,ease:`power2.out`}),this._tween.to({},{duration:r*.65,onComplete:()=>this._complete()})}update(e){}onSkip(){this._kill(),this._reel.speed=this._speed.spinSpeed}_kill(){this._tween&&=(this._tween.kill(),null)}},P=class{_registry=new Map;constructor(){this._registry.set(`start`,(e,t)=>new A(e,t)),this._registry.set(`spin`,(e,t)=>new j(e,t)),this._registry.set(`stop`,(e,t)=>new M(e,t)),this._registry.set(`anticipation`,(e,t)=>new N(e,t))}register(e,t){this._registry.set(e,(e,n)=>new t(e,n))}registerFactory(e,t){this._registry.set(e,t)}create(e,t,n){let r=this._registry.get(e);if(!r)throw Error(`Phase '${e}' not registered. Available: ${[...this._registry.keys()].join(`, `)}`);return r(t,n)}has(e){return this._registry.has(e)}},F={silent:0,error:1,warn:2,info:3},I=`info`;function oe(e){I=e}function L(){return I}var R=new Set,se=typeof document<`u`,ce=`background:#1f1d1b;color:#fef08a;padding:2px 6px;border-radius:3px 0 0 3px;font-weight:700`,le={error:`background:#7f1d1d;color:#fee2e2;padding:2px 6px;border-radius:0 3px 3px 0`,warn:`background:#78350f;color:#fef3c7;padding:2px 6px;border-radius:0 3px 3px 0`,info:`background:#334155;color:#e2e8f0;padding:2px 6px;border-radius:0 3px 3px 0`},ue=`background:transparent;color:inherit;font-weight:400`;function z(e,t,n,r,i){if(F[I]<F[e])return;if(i?.once){if(R.has(t))return;R.add(t)}let a=console[e];se?a(`%cpixi-reels%c${t}%c ${n}`,ce,le[e],ue,...r):a(`[pixi-reels] ${e}(${t}) ${n}`,...r)}function B(e,t,...n){z(`error`,e,t,n)}function V(e,t,...n){z(`warn`,e,t,n)}function de(e,t,...n){z(`warn`,e,t,n,{once:!0})}function H(e,t,...n){z(`info`,e,t,n)}var fe=class{_reels;_speedManager;_frameBuilder;_phaseFactory;_events;_tickerRef;_spinningMode;_defaultSpinMode;_currentSpinMode=`standard`;_hooks;_isSpinning=!1;_spinStartTime=0;_resultSymbols=null;_anticipationReels=[];_anticipationStagger=0;_anticipationSlowdown=null;_anticipationDuration=null;_anticipationProtect=!1;_protectSpent=!1;_teasingReels=new Set;_reelLandedResolvers=new Map;_reelLandedPromises=new Map;_stopDelayOverride=null;_activePhases=new Map;_landedReels=new Set;_slammedReels=new Set;_activeSpinSpeed=null;_allStartedEmitted=!1;_minimumSpinTimeOverride=null;_heldReels=new Set;_wasSkipped=!1;_skipPending=!1;_isDestroyed=!1;_currentSpinResolve=null;_currentSpinReject=null;_pendingAbortError=null;_spinWatchdogCleanup=null;_spinGeneration=0;_skipStage=0;_skipPreviousSpeedName=null;_skipBoostedToName=null;_manualSpeedSinceBoost=!1;_autoSlamRefills=!1;constructor(e,t,n,r,i,a,o,s=`standard`,c){this._reels=e,this._speedManager=t,this._frameBuilder=n,this._phaseFactory=r,this._events=i,this._tickerRef=new h(a),this._spinningMode=o??new w,this._defaultSpinMode=s,this._hooks=c??{isMultiWaysSlot:!1,symbolsData:{},peekTargetShape:()=>null,clearTargetShape:()=>{},multiwaysReelExtent:0,getPinsOnReel:()=>[],migratePinsForReel:()=>[],refreshPinOverlaysForReel:()=>{},buildPinOverlayTweens:()=>[]},this._tickerRef.add(e=>this._onTick(e))}get isSpinning(){return this._isSpinning}get isDestroyed(){return this._isDestroyed}get skipStage(){return this._skipStage}async spin(e){if(this._isSpinning)throw Error(`Cannot start a new spin while one is in progress.`);if(e?.signal?.aborted)return Promise.reject(this._abortError(e.signal));let t=e?.mode??this._defaultSpinMode;if(t===`cascade`&&!this._phaseFactory.has(`cascade:fall`))throw Error(`spin({ mode: 'cascade' }) requires .tumble(...) on the builder.`);if(t===`standard`&&this._reels.some(e=>e.bufferEnd===0))throw Error(`spin({ mode: 'standard' }) requires bufferEnd >= 1: strip scrolling wraps symbols through the below-window buffer. This reel set was built with bufferSymbols({ end: 0 }) for tumble-only use.`);if(this._currentSpinMode=t,this._skipPreviousSpeedName!==null){let e=this._skipPreviousSpeedName;this._skipPreviousSpeedName=null,this._skipBoostedToName=null,!this._manualSpeedSinceBoost&&this._speedManager.activeName!==e&&this._speedManager.set(e)}this._manualSpeedSinceBoost=!1,this._skipStage=0,this._autoSlamRefills=!1,this._isSpinning=!0,this._wasSkipped=!1,this._skipPending=!1,this._pendingAbortError=null,this._spinStartTime=performance.now(),this._resultSymbols=null,this._anticipationReels=[],this._anticipationStagger=0,this._anticipationSlowdown=null,this._anticipationDuration=null,this._anticipationProtect=!1,this._protectSpent=!1,this._teasingReels.clear(),this._reelLandedResolvers.clear(),this._reelLandedPromises.clear(),this._landedReels.clear(),this._slammedReels.clear(),this._allStartedEmitted=!1,this._activePhases.clear(),this._heldReels=this._normalizeHoldReels(e?.holdReels),this._spinGeneration++;let n=this._spinGeneration,r=this._speedManager.active;this._activeSpinSpeed=r,this._events.emit(`spin:start`);let i=new Promise((e,t)=>{this._currentSpinResolve=e,this._currentSpinReject=t});if(this._armSpinWatchdog(e,n),this._heldReels.size===this._reels.length)return Promise.resolve().then(()=>{n===this._spinGeneration&&this._finishSpin()}),i;for(let e=0;e<this._reels.length;e++)this._heldReels.has(e)||this._runReelTask(this._startReel(e,r,n),`spin`,e,n);return i}_runReelTask(e,t,n,r){e.catch(e=>{r===this._spinGeneration&&(B(`phase-chain-threw`,`reel ${n} (${t}) phase chain threw. slamming to recover:`,e),this._slam())})}_normalizeHoldReels(e){let t=new Set;if(!e)return t;for(let n of e)Number.isInteger(n)&&n>=0&&n<this._reels.length&&t.add(n);return t}setResult(e){this._isSpinning&&(this._coordinateBigSymbols(e,e=>{let t=this._hooks.peekTargetShape();return t?t[e]:this._reels[e].visibleCells}),this._resultSymbols=e,this._tryBeginStopSequence(),this._skipPending&&(this._skipPending=!1,this._pressSkip(!1)))}async refill(e){if(this._isSpinning)throw Error(`Cannot refill while a spin or refill is in progress.`);if(!this._phaseFactory.has(`cascade:place`))throw Error(`refill() requires .tumble(...) on the builder.`);let t=e.grid;if(t.length!==this._reels.length)throw RangeError(`refill: grid has ${t.length} column(s) but the reel set has ${this._reels.length}.`);for(let e=0;e<t.length;e++){let n=this._reels[e].visibleCells;if(t[e].visible.length!==n)throw RangeError(`refill: grid column ${e} has ${t[e].visible.length} cell(s) but reel ${e} has ${n} visible cell(s).`)}for(let t of e.winners){if(!Number.isInteger(t.reel)||t.reel<0||t.reel>=this._reels.length)throw RangeError(`refill: winner.reel ${t.reel} out of range [0, ${this._reels.length}).`);let e=this._reels[t.reel].visibleCells;if(!Number.isInteger(t.cell)||t.cell<0||t.cell>=e)throw RangeError(`refill: winner.cell ${t.cell} out of range [0, ${e}) for reel ${t.reel}.`)}this._isSpinning=!0,this._wasSkipped=!1,this._skipPending=!1,this._pendingAbortError=null,this._spinStartTime=performance.now(),this._resultSymbols=null,this._anticipationReels=[],this._anticipationStagger=0,this._anticipationSlowdown=null,this._anticipationDuration=null,this._anticipationProtect=!1,this._protectSpent=!1,this._teasingReels.clear(),this._reelLandedResolvers.clear(),this._reelLandedPromises.clear(),this._landedReels.clear(),this._slammedReels.clear(),this._allStartedEmitted=!1,this._activePhases.clear(),this._heldReels=new Set,this._spinGeneration++,this._currentSpinMode=`cascade`;let n=this._spinGeneration,r=this._speedManager.active;this._activeSpinSpeed=r,this._resultSymbols=t;let i=this._coordinateBigSymbols(t,e=>this._reels[e].visibleCells),a=[];for(let e=0;e<this._reels.length;e++){let t=this._reels[e];a.push(this._frameBuilder.build(e,t.visibleCells,t.bufferStart,t.bufferEnd,i[e]))}this._cachedFrames=a;let o=new Map;for(let t of e.winners){let e=o.get(t.reel);e||(e=[],o.set(t.reel,e)),e.push(t.cell)}for(let e of o.values())e.sort((e,t)=>e-t);this._events.emit(`spin:start`);let s=new Promise(e=>{this._currentSpinResolve=e,this._currentSpinReject=null});if(this._autoSlamRefills)return this._slam(),this._skipStage=2,s;if((e.mode??`combined`)===`gravity-then-drop`){let t=e.gravityHoldMs??250;this._refillTwoStage(r,n,o,t,e.gravityHold,e.onGravityComplete).catch(e=>{n===this._spinGeneration&&(this._events.emit(`cascade:gravity:error`,{error:e}),B(`refill-threw`,`two-stage refill threw (likely from a user-supplied gravityHold/onGravityComplete). slamming to recover:`,e),this._slam())})}else for(let e=0;e<this._reels.length;e++){let t=o.get(e)??[];this._runReelTask(this._refillReel(e,r,n,t),`refill`,e,n)}return s}async _refillReel(e,t,n,r){if(this._isStale(e,n))return;let i=this._reels[e],a=this._frameFor(e),o=this._stopDelayFor(e,t),s=this._phaseFactory.create(`cascade:place`,i,t);if(this._activePhases.set(e,s),await s.run({targetFrame:a,winnerCells:r,initial:!1,delay:o,events:this._events}),this._isStale(e,n))return;let c=this._phaseFactory.create(`cascade:dropIn`,i,t);this._activePhases.set(e,c),await c.run({winnerCells:r,initial:!1,events:this._events}),!this._isStale(e,n)&&this._markLanded(e)}async _refillTwoStage(e,t,n,r,i,a){let o=this._reels.map(async(r,i)=>{if(this._isStale(i,t))return;let a=this._reels[i],o=this._frameFor(i),s=n.get(i)??[],c=this._phaseFactory.create(`cascade:place`,a,e);if(this._activePhases.set(i,c),await c.run({targetFrame:o,winnerCells:s,initial:!1,delay:0,events:this._events}),this._isStale(i,t))return;let l=this._phaseFactory.create(`cascade:dropIn`,a,e);this._activePhases.set(i,l),await l.run({winnerCells:s,initial:!1,role:`gravity`,events:this._events})});if(await Promise.all(o),t!==this._spinGeneration)return;let s=[];if(r>0&&s.push(new Promise(e=>setTimeout(e,r))),i&&s.push(typeof i==`function`?i():i),!(s.length>0&&(await Promise.all(s),t!==this._spinGeneration))&&!(a&&(await a(),t!==this._spinGeneration)))for(let r=0;r<this._reels.length;r++)this._runReelTask(this._refillReelDropInOnly(r,e,t,n.get(r)??[]),`refill`,r,t)}async _refillReelDropInOnly(e,t,n,r){if(this._isStale(e,n))return;let i=this._reels[e],a=this._stopDelayFor(e,t);if(a>0&&(await new Promise(e=>setTimeout(e,a)),this._isStale(e,n)))return;let o=this._phaseFactory.create(`cascade:dropIn`,i,t);this._activePhases.set(e,o),await o.run({winnerCells:r,initial:!1,role:`new`,events:this._events}),!this._isStale(e,n)&&this._markLanded(e)}setAnticipation(e,t=0){let n=typeof t==`object`&&!Array.isArray(t)?t:{stagger:t},r=n.stagger??0;this._anticipationReels=e.filter(e=>!this._heldReels.has(e)),this._anticipationStagger=r,this._anticipationSlowdown=n.slowdown??null,this._anticipationDuration=n.duration??null;let i=n.protect??!1;if(this._anticipationProtect=i===!0?`once`:i,this._protectSpent=!1,this._teasingReels.clear(),this._reelLandedResolvers.clear(),this._reelLandedPromises.clear(),r===`sequential`)for(let e of this._anticipationReels)this._reelLandedPromises.set(e,new Promise(t=>this._reelLandedResolvers.set(e,t)))}setStopDelays(e){this._stopDelayOverride=e?[...e]:null}setMinimumSpinTime(e){this._minimumSpinTimeOverride=Array.isArray(e)?[...e]:e}_minimumSpinTimeFor(e){let t=this._minimumSpinTimeOverride;if(t===null)return;let n=Array.isArray(t)?t[e]:t;if(!(typeof n!=`number`||!Number.isFinite(n)||n<0))return n}requestSkip(){if(this._isSpinning){if(this._resultSymbols){this._pressSkip(!1);return}this._skipPending=!0}}skip(){if(this._isSpinning){if(!this._resultSymbols)throw Error(`skip() called before setResult(). there is nothing to land on yet (standard mode would land on random buffer fill; cascade mode would land invisible). Use reelSet.requestSkip() to queue the slam until setResult() arrives, or wait for setResult() before calling skip().`);this._pressSkip(!0)}}_pressSkip(e){let t=this._nextSlamGroup();if(t!==null){this._slam(t);let n=this._teaseStillRunning();if(this._anticipationProtect===`once`&&(this._protectSpent=!0),n){this._skipStage===0&&(this._skipStage=1);return}this._applyRoundSideEffects(e),this._skipStage=2;return}this._applyRoundSideEffects(e),this._slam(),this._skipStage=2}_nextSlamGroup(){let e=this._protectedTeaseReels();if(e.size===0)return null;let t=[];for(let n=0;n<this._reels.length;n++)e.has(n)||this._landedReels.has(n)||this._heldReels.has(n)||t.push(n);if(t.length>0||this._anticipationProtect!==`stepwise`)return t;let n=this._anticipationReels.find(t=>e.has(t));return n===void 0?t:[n]}_teaseStillRunning(){for(let e of this._anticipationReels)if(!this._landedReels.has(e)&&!this._heldReels.has(e))return!0;return!1}_applyRoundSideEffects(e){if(e&&this._skipStage!==2)if(this._currentSpinMode===`cascade`)this._autoSlamRefills=!0;else{let e=this._findFastestSpeedName();if(e!==null&&e!==this._speedManager.activeName){let{previous:t,current:n}=this._speedManager.set(e);this._skipPreviousSpeedName=t.name,this._skipBoostedToName=n.name,this._events.emit(`skip:boosted`,{previous:t,current:n})}}}_protectedTeaseReels(){let e=new Set;if(this._anticipationProtect===!1||this._anticipationProtect===`once`&&this._protectSpent)return e;let t=this._activeSpinSpeed??this._speedManager.active;if((this._anticipationDuration??t.anticipationDelay)<=0)return e;for(let t of this._anticipationReels)this._landedReels.has(t)||this._heldReels.has(t)||e.add(t);return e}slamStop(e){if(this._isSpinning){if(e?.reels&&e?.except)throw Error(`slamStop: pass either 'reels' or 'except', not both.`);if(this._resultSymbols||V(`slam-before-result`,`slamStop() was called before setResult(), so the reels will land on whatever the strip is currently showing (random fill in standard mode, the invisible fall-out residue in cascade mode) rather than on a result. Use requestSkip() to queue the slam until setResult() arrives, or skipSpin(), which throws in this window instead of landing on nothing.`),e?.reels){this._slam(e.reels)||(this._skipStage=2);return}if(e?.except){let t=new Set(e.except),n=[];for(let e=0;e<this._reels.length;e++)t.has(e)||n.push(e);this._slam(n)||(this._skipStage=2);return}this._slam(),this._skipStage=2}}_isStale(e,t){return t!==this._spinGeneration||this._slammedReels.has(e)}_slam(e){if(!this._isSpinning)return!1;let t=new Set;if(e){for(let n of e)!Number.isInteger(n)||n<0||n>=this._reels.length||this._landedReels.has(n)||this._heldReels.has(n)||t.add(n);if(t.size===0)return!0}else for(let e=0;e<this._reels.length;e++)this._landedReels.has(e)||this._heldReels.has(e)||t.add(e);let n=0;for(let e=0;e<this._reels.length;e++)!this._landedReels.has(e)&&!this._heldReels.has(e)&&n++;let r=t.size<n;if(this._wasSkipped=!0,this._events.emit(`skip:requested`,{reels:[...t],partial:r}),r)for(let e of t){let t=this._activePhases.get(e);t&&(t.forceComplete(),this._activePhases.delete(e)),this._slammedReels.add(e)}else{for(let[,e]of this._activePhases)e.forceComplete();this._activePhases.clear(),this._spinGeneration++}if(this._resultSymbols){let e=this._hooks.peekTargetShape(),n=this._coordinateBigSymbols(this._resultSymbols,t=>e?e[t]:this._reels[t].visibleCells);for(let r of t){let t=this._reels[r];t.speed=0,t.isStopping=!1,this._hooks.isMultiWaysSlot&&e&&this._applyReshape(r,e[r]),t.placeSymbols(n[r]),t.notifySpinEnd(),t.notifyLanded(),this._markLanded(r)}}else for(let e of t){let t=this._reels[e];t.speed=0,t.isStopping=!1,t.snapToGrid(),t.notifySpinEnd(),t.notifyLanded(),this._markLanded(e)}return this._events.emit(`skip:completed`,{reels:[...t],partial:r}),r&&(this._announceAllStartedIfReady(),this._tryBeginStopSequence()),r}notifyManualSpeedChange(){this._manualSpeedSinceBoost=!0}_findFastestSpeedName(){let e=this._speedManager.profileNames;if(e.length<2)return null;let t=null,n=-1/0;for(let r of e){let e=this._speedManager.getProfile(r);e&&e.spinSpeed>n&&(n=e.spinSpeed,t=r)}return t}destroy(){if(!this._isDestroyed){this._clearSpinWatchdog(),this._spinGeneration++;for(let e of this._activePhases.values())e.forceComplete();this._tickerRef.destroy(),this._activePhases.clear(),this._isDestroyed=!0}}_targetCellSizeFor(e,t){return this._hooks.multiwaysReelExtent<=0?e.cellMain:(this._hooks.multiwaysReelExtent-(t-1)*e.mainGap)/t}_applyReshape(e,t){let n=this._reels[e],r=this._targetCellSizeFor(n,t),i=n.visibleCells;return t===i&&r===n.cellMain?!1:(this._events.emit(`adjust:start`,{reelIndex:e,fromCells:i,toCells:t}),n.reshape(t,r,n.bufferStart,n.bufferEnd),this._hooks.refreshPinOverlaysForReel(e),this._events.emit(`adjust:complete`,{reelIndex:e}),!0)}async _startReel(e,t,n){if(this._isStale(e,n))return;let r=this._reels[e],i=this._currentSpinMode===`cascade`,a=this._hooks.isMultiWaysSlot&&this._phaseFactory.has(`adjust`),o=i&&a&&this._hooks.peekTargetShape()!==null;if(o&&(await this._runAdjustForReel(r,e,t,n),this._isStale(e,n)))return;if(i){let n=this._phaseFactory.create(`cascade:fall`,r,t);this._activePhases.set(e,n),await n.run({spinningMode:this._spinningMode,delay:e*t.spinDelay,events:this._events})}else{let n=this._phaseFactory.create(`start`,r,t);this._activePhases.set(e,n),await n.run({spinningMode:this._spinningMode,delay:e*t.spinDelay})}if(this._isStale(e,n))return;let s=this._phaseFactory.create(`spin`,r,t);this._activePhases.set(e,s);let c=s.run({minimumSpinTime:this._minimumSpinTimeFor(e)});if(this._announceAllStartedIfReady()&&this._tryBeginStopSequence(),await c,this._isStale(e,n)||a&&!o&&(await this._runAdjustForReel(r,e,t,n),this._isStale(e,n)))return;let l=this._stopDelayFor(e,t),u=this._frameFor(e),d=this._anticipationDuration??t.anticipationDelay,f=!1;if(this._anticipationReels.includes(e)&&d>0){if(!await this._awaitAnticipationOffset(e,n))return;let a=this._anticipationReels.indexOf(e);this._teasingReels.add(e),r.notifyAnticipationStart(),this._events.emit(`anticipation:reel`,{reelIndex:e,order:a,total:this._anticipationReels.length}),this._events.emit(`spin:stopping`,e);let o=this._phaseFactory.create(`anticipation`,r,t);this._activePhases.set(e,o);let s=this._anticipationConfigFor(e,t);if(await o.run(i?{...s,speedMultiplier:0}:s),this._isStale(e,n))return;f=!0}else this._events.emit(`spin:stopping`,e);if(i){f&&(r.speed=0,r.snapToGrid());let i=this._phaseFactory.create(`cascade:place`,r,t);if(this._activePhases.set(e,i),await i.run({targetFrame:u,winnerCells:[],initial:!0,delay:l,events:this._events}),this._isStale(e,n))return;let a=this._phaseFactory.create(`cascade:dropIn`,r,t);if(this._activePhases.set(e,a),await a.run({winnerCells:[],initial:!0,events:this._events}),this._isStale(e,n))return}else{let i=this._phaseFactory.create(`stop`,r,t);if(this._activePhases.set(e,i),await i.run({targetFrame:u,delay:l,preserveSpeed:f}),this._isStale(e,n))return}this._markLanded(e)}async _runAdjustForReel(e,t,n,r){let i=this._hooks.peekTargetShape(),a=i?i[t]:e.visibleCells,o=this._targetCellSizeFor(e,a),s=this._hooks.buildPinOverlayTweens(t,o);if(!this._applyReshape(t,a)&&s.length===0||s.length===0)return;let c=this._phaseFactory.create(`adjust`,e,n);this._activePhases.set(t,c),await c.run({pinOverlays:s})}async _awaitAnticipationOffset(e,t){let n=this._anticipationReels.indexOf(e);if(n<=0)return!0;let r=this._anticipationStagger;if(r===`sequential`){let r=this._reelLandedPromises.get(this._anticipationReels[n-1]);return!(r&&(await r,this._isStale(e,t)))}let i=Array.isArray(r)?r[n]??0:n*r;return!(i>0&&(await new Promise(e=>setTimeout(e,i)),this._isStale(e,t)))}_anticipationConfigFor(e,t){let n=this._anticipationSlowdown,r=this._anticipationDuration;if(!n)return r==null?{}:{duration:r};let i=this._anticipationReels.length,a=this._anticipationReels.indexOf(e),o=i>1?a/(i-1):0,s=n.from??.3,c=n.to??s,l=n.holdFrom??1,u=n.holdTo??l,d=r??t.anticipationDelay,f={speedMultiplier:s+(c-s)*o},p=l+(u-l)*o;return(r!=null||p!==1)&&(f.duration=d*p),f}_stopDelayFor(e,t){return this._stopDelayOverride?this._stopDelayOverride[e]??0:e*t.stopDelay}_cachedFrames=null;_frameFor(e){return this._cachedFrames?this._cachedFrames[e]:[]}_announceAllStartedIfReady(){if(this._allStartedEmitted)return!1;for(let e=0;e<this._reels.length;e++){if(this._heldReels.has(e)||this._landedReels.has(e))continue;let t=this._activePhases.get(e);if(!t||t.name!==`spin`)return!1}return this._allStartedEmitted=!0,this._events.emit(`spin:allStarted`),!0}_tryBeginStopSequence(){if(!this._resultSymbols)return;for(let e=0;e<this._reels.length;e++){if(this._heldReels.has(e)||this._landedReels.has(e))continue;let t=this._activePhases.get(e);if(!t||t.name!==`spin`)return}let e=this._hooks.peekTargetShape(),t=t=>e?e[t]:this._reels[t].visibleCells,n=this._coordinateBigSymbols(this._resultSymbols,t),r=[];for(let e=0;e<this._reels.length;e++){if(this._heldReels.has(e)){r.push([]);continue}let i=this._reels[e],a=t(e);r.push(this._frameBuilder.build(e,a,i.bufferStart,i.bufferEnd,n[e]))}this._cachedFrames=r;for(let e=0;e<this._reels.length;e++){if(this._heldReels.has(e)||this._landedReels.has(e))continue;let t=this._activePhases.get(e);t?.resolve&&t.resolve()}}_coordinateBigSymbols(e,t){let n=this._reels[0]?.bufferStart??0,r=this._reels[0]?.bufferEnd??0,i=e.map(S),a=this._hooks.symbolsData,o=(e,t)=>y(i[e],t),s=(e,t,n)=>{b(i[e],t,n)};for(let e=0;e<i.length;e++){let c=t(e);for(let l=-n;l<c+r;l++){let n=o(e,l);if(n===void 0)continue;let u=a[n];if(!u?.size)continue;let d=u.size.reels,f=u.size.cells;if(!(d===1&&f===1)){if(l+f>c+r)throw Error(`big symbol '${n}' (${d}x${f}) at (reel=${e}, cell=${l}) extends past the bottom of the strip on reel ${e} (anchor cell + h = ${l+f} > visibleCells + bufferEnd = ${c+r}).`);if(e+d>i.length)throw Error(`big symbol '${n}' (${d}x${f}) at (reel=${e}, cell=${l}) exceeds reel count ${i.length}.`);for(let i=0;i<d;i++){let a=e+i,o=t(a);if(l+f>o+r)throw Error(`big symbol '${n}' (${d}x${f}) at (reel=${e}, cell=${l}) extends past the bottom of the strip on reel ${a} (anchor cell + h = ${l+f} > visibleCells + bufferEnd = ${o+r}).`)}for(let t=0;t<f;t++)for(let n=0;n<d;n++)n===0&&t===0||s(e+n,l+t,E)}}}return i}_markLanded(e){if(this._landedReels.has(e))return;this._landedReels.add(e);let t=this._reelLandedResolvers.get(e);t&&(this._reelLandedResolvers.delete(e),t()),this._teasingReels.delete(e)&&this._events.emit(`anticipation:reelEnd`,{reelIndex:e});let n=this._reels[e],r=n.getVisibleSymbols();n.events.emit(`landed`,r),this._events.emit(`spin:reelLanded`,e,r),this._landedReels.size===this._reels.length-this._heldReels.size&&this._finishSpin()}_armSpinWatchdog(e,t){this._clearSpinWatchdog();let n=e?.signal,r=e?.timeoutMs;if(!n&&(r===void 0||r<=0))return;let i=[];if(n){let e=()=>{t===this._spinGeneration&&this._abortSpin(this._abortError(n))};n.addEventListener(`abort`,e),i.push(()=>n.removeEventListener(`abort`,e))}if(r!==void 0&&r>0){let e=setTimeout(()=>{t===this._spinGeneration&&this._abortSpin(Error(`spin() exceeded its ${r}ms watchdog without landing. setResult() / requestSkip() / slamStop() was never called (most often a failed or timed-out server request). The reels have been force-stopped.`))},r);i.push(()=>clearTimeout(e))}this._spinWatchdogCleanup=()=>{for(let e of i)e()}}_clearSpinWatchdog(){this._spinWatchdogCleanup&&=(this._spinWatchdogCleanup(),null)}_abortError(e){let t=e.reason;return t instanceof Error?t:typeof t==`string`&&t.length>0?Error(t):Error(`spin() was aborted via SpinOptions.signal before the reels landed.`)}_abortSpin(e){this._isSpinning&&(this._clearSpinWatchdog(),this._pendingAbortError=e,this._slam())}_finishSpin(){this._clearSpinWatchdog();let e=this._pendingAbortError;if(e){this._pendingAbortError=null,this._isSpinning=!1,this._activePhases.clear(),this._cachedFrames=null,this._hooks.clearTargetShape();let t=this._currentSpinReject;this._currentSpinResolve=null,this._currentSpinReject=null,t&&t(e);return}let t={symbols:this._reels.map(e=>e.getVisibleSymbols()),wasSkipped:this._wasSkipped,duration:performance.now()-this._spinStartTime};this._isSpinning=!1,this._activePhases.clear(),this._cachedFrames=null,this._hooks.clearTargetShape(),this._events.emit(`spin:allLanded`,t),this._events.emit(`spin:complete`,t),this._currentSpinResolve&&=(this._currentSpinResolve(t),null),this._currentSpinReject=null}_onTick(e){if(!this._isSpinning)return;let t=e.deltaMS;for(let e of this._reels)e.update(t);for(let e of this._activePhases.values())e.isActive&&e.update(t)}},pe=class{_profiles=new Map;_activeName;_active;constructor(e,t){for(let[t,n]of e)this._profiles.set(t,n);let n=this._profiles.get(t);if(!n)throw Error(`Speed profile '${t}' not found. Available: ${[...this._profiles.keys()].join(`, `)}`);this._activeName=t,this._active=n}get active(){return this._active}get activeName(){return this._activeName}set(e){let t=this._profiles.get(e);if(!t)throw Error(`Speed profile '${e}' not found. Available: ${[...this._profiles.keys()].join(`, `)}`);let n=this._active;return this._activeName=e,this._active=t,{previous:n,current:t}}addProfile(e,t){this._profiles.set(e,t)}getProfile(e){return this._profiles.get(e)}get profileNames(){return[...this._profiles.keys()]}},me=class{_reels;_viewport;_promoted=[];_isActive=!1;_isDestroyed=!1;_cycleAbort=null;_events;constructor(e,t,n){this._reels=e,this._viewport=t,this._events=n}get isActive(){return this._isActive}get isDestroyed(){return this._isDestroyed}async show(e,t={}){this.hide(),await this._showInternal(e,t)}async _showInternal(e,t={}){let{dimAmount:n=.5,playWinAnimation:r=!0,promoteAboveMask:i=!0}=t;this._isActive=!0,this._events.emit(`spotlight:start`,e),this._viewport.showDim(n);let a=[],o=new Set;for(let t of e){let e=this._reels[t.reelIndex];if(!e)continue;let n=e.getSymbolAt(t.cellIndex);if(!n)continue;let s=`${t.reelIndex}:${e.getAnchorCell(t.cellIndex)}`;if(!o.has(s)){if(o.add(s),i){let e=n.view.parent;this._promoted.push({symbol:n,originalParent:e,position:t});let r=n.view.getGlobalPosition();this._viewport.spotlightContainer.addChild(n.view);let i=this._viewport.spotlightContainer.toLocal(r);n.view.x=i.x,n.view.y=i.y}r&&a.push(n.playWin())}}a.length>0&&await Promise.all(a)}hide(){this._cycleAbort&&=(this._cycleAbort.abort(),null),this._teardownVisual()}_teardownVisual(){for(let{symbol:e,originalParent:t}of this._promoted)if(e.view.parent===this._viewport.spotlightContainer){if(t){let n=e.view.getGlobalPosition();t.addChild(e.view);let r=t.toLocal(n);e.view.x=r.x,e.view.y=r.y}e.stopAnimation()}this._promoted=[],this._viewport.hideDim();let e=this._isActive;this._isActive=!1,e&&this._events.emit(`spotlight:end`)}async cycle(e,t={}){let{displayDuration:n=2e3,gapDuration:r=300,cycles:i=1}=t;if(e.length===0)return;this.hide();let a=new AbortController;this._cycleAbort=a;let o=a.signal,s=0;for(;i===-1||s<i;){for(let i of e){if(o.aborted||(await this._showInternal(i.positions,t),await this._wait(n,o),o.aborted))return;this._teardownVisual(),await this._wait(r,o)}s++}this._cycleAbort===a&&(this._cycleAbort=null)}destroy(){this._isDestroyed||=(this.hide(),!0)}_wait(e,t){return new Promise(n=>{if(t.aborted){n();return}let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})})}};function U(e,t){return`${e}:${t}`}var he=`run npx pixi-reels-codemod v1-to-v2`,W={visibleRows:`visibleCells`,visibleRowsPerReel:`visibleCellsPerReel`,reelPixelHeights:`reelExtents`},G={"bufferSymbols()":{above:`start`,below:`end`},"multiways()":{minRows:`minCells`,maxRows:`maxCells`,reelPixelHeight:`reelExtent`},"symbolData() size":{w:`reels`,h:`cells`},"tumble() fall/dropIn":{rowStagger:`cellStagger`,rowOrder:`cellOrder`},"offset() trapezoid":{topWidthFactor:`startFactor`,bottomWidthFactor:`endFactor`},"initialFrame() / setResult() column":{bufferAbove:`bufferStart`,bufferBelow:`bufferEnd`}},ge={"reelAnchor()":{top:`start`,bottom:`end`},"tumble() cellOrder":{bottomToTop:`endFirst`,topToBottom:`startFirst`},"nudge() direction":{down:`forward`,up:`reverse`}};function K(e,t,n){return`${e}: '${t}' was renamed to '${n}' in v2; ${he}.`}function q(e,t,n){if(!(!e||typeof e!=`object`)){for(let[r,i]of Object.entries(t))if(r in e)throw Error(K(n,r,i))}}function _e(e,t,n){if(typeof e!=`string`)return;let r=t[e];if(r!==void 0)throw Error(K(n,e,r))}var ve=class e extends t.Container{static PIN_OVERLAY_Z_INDEX=1e4;_events=new n;_reels;_viewport;_spinController;_speedManager;_spotlight;_symbolFactory;_frameBuilder;_frameAPI;_isDestroyed=!1;_pins=new Map;_pinOverlays=new Map;_targetShape=null;_resultSetForCurrentSpin=!1;_isMultiWaysSlot;_nudgesInFlight=0;_multiwaysMinCells=0;_multiwaysMaxCells=0;_multiwaysReelExtent=0;_symbolsData;constructor(e){super(),this._reels=e.reels,this._viewport=e.viewport,this._symbolFactory=e.symbolFactory,this._frameBuilder=e.frameBuilder,this._symbolsData=e.config.symbols,this._isMultiWaysSlot=!!e.config.grid.multiways,e.config.grid.multiways&&(this._multiwaysMinCells=e.config.grid.multiways.minCells,this._multiwaysMaxCells=e.config.grid.multiways.maxCells,this._multiwaysReelExtent=e.config.grid.multiways.reelExtent);for(let e of this._reels)e.setCrossReelResolver((e,t)=>{let n=this.getSymbolFootprint(e,t),r=this._reels[n.anchor.reel];return r.symbols[r.bufferStart+n.anchor.cell].symbolId});let t=this._frameBuilder;this._frameAPI={use(e){t.use(e)},remove(e){t.remove(e)},get middleware(){return t.middleware}},this._speedManager=new pe(e.config.speeds,e.config.initialSpeed),this._spinController=new fe(e.reels,this._speedManager,e.frameBuilder,e.phaseFactory,this._events,e.config.ticker,e.spinningMode,e.defaultSpinMode,{isMultiWaysSlot:this._isMultiWaysSlot,symbolsData:this._symbolsData,peekTargetShape:()=>this.peekTargetShape(),clearTargetShape:()=>this.clearTargetShape(),multiwaysReelExtent:this._multiwaysReelExtent,getPinsOnReel:e=>this._pinsOnReel(e),migratePinsForReel:(e,t)=>this._migratePinsForReel(e,t),refreshPinOverlaysForReel:e=>this.refreshPinOverlaysForReel(e),buildPinOverlayTweens:(e,t)=>this._buildPinOverlayTweens(e,t)}),this._spotlight=new me(e.reels,e.viewport,this._events),this.addChild(this._viewport),this._events.on(`spin:allLanded`,()=>this._onSpinLanded()),this._events.on(`spin:start`,()=>this._onSpinStart())}get events(){return this._events}async spin(e){return this._assertNoNudgeInFlight(`spin`),this._spinController.spin(e)}setResult(e){this._assertNoNudgeInFlight(`setResult`),this._assertGrid(e,`setResult()`);let t=this._applyPinsToGrid(this._cloneTargets(e));this._resultSetForCurrentSpin=!0,this._spinController.setResult(t)}async refill(e){this._assertGrid(e.grid,`refill(): grid`);let t=performance.now(),n=!1,r=()=>{n=!0};this._events.on(`skip:requested`,r);let i=()=>{n=!0,this._spinController.isSpinning&&this._spinController.slamStop()};e.signal&&(e.signal.aborted?i():e.signal.addEventListener(`abort`,i,{once:!0}));try{let r=await this._spinController.refill(e);return{winnersRefilled:e.winners.length,finalGrid:r.symbols,wasSkipped:n||r.wasSkipped,duration:performance.now()-t}}finally{this._events.off(`skip:requested`,r),e.signal&&e.signal.removeEventListener(`abort`,i)}}async destroySymbols(e,t){if(e.length===0)return;let n=(e,n)=>{let r=t?.delay;return typeof r==`function`?r(e,n):r??0};for(let t of e){if(t.reel<0||t.reel>=this._reels.length)throw RangeError(`destroySymbols: cell.reel ${t.reel} out of range [0, ${this._reels.length})`);let e=this._reels[t.reel];if(t.cell<0||t.cell>=e.visibleCells)throw RangeError(`destroySymbols: cell.cell ${t.cell} out of range [0, ${e.visibleCells}) for reel ${t.reel}`)}let r=t?.dim;r&&this._viewport.showDim(typeof r==`number`?r:.35);let i=t?.zIndex===void 0?1e3:t.zIndex,a=t?.signal;this._events.emit(`cascade:destroy:start`,{cells:e});try{let t=await Promise.allSettled(e.map((e,t)=>{let r=this._reels[e.reel],o=r.getSymbolAt(e.cell);if(!o)throw Error(`destroySymbols: reel ${e.reel} has no symbol at visible cell ${e.cell} (strip length ${r.symbols.length}, bufferStart ${r.bufferStart}, visibleCells ${r.visibleCells}). The reel was torn down or reshaped while a cascade was in flight.`);return i!==null&&(o.view.zIndex=i),o.playDestroy({delay:n(e,t),signal:a})})),r=[];for(let n=0;n<t.length;n++)t[n].status===`rejected`&&(r.push(e[n]),V(`destroy-rejected`,`destroySymbols: cell (${e[n].reel}, ${e[n].cell}) playDestroy rejected:`,t[n].reason));this._events.emit(`cascade:destroy:end`,r.length>0?{cells:e,failed:r}:{cells:e})}finally{r&&this._viewport.hideDim()}}async runCascade(e){let t=e.pauseAfterDestroyMs??250,n=e.maxChain??32,r=!1,i=()=>{r=!0};this._events.on(`skip:requested`,i);let a=()=>{r=!0,this._spinController.isSpinning&&this._spinController.slamStop()};e.signal&&(e.signal.aborted?a():e.signal.addEventListener(`abort`,a,{once:!0}));let o=0,s=0,c=this.getVisibleGrid();try{for(;o<n&&!r;){let n=await e.detectWinners(c,o);if(n.length===0)break;s+=n.length;let i=o+1;if(this._events.emit(`cascade:chain:start`,{chain:i,winners:n,currentGrid:c}),e.presentWinners&&(await e.presentWinners({chain:i,winners:n,currentGrid:c}),r))break;let a=e.destroyOptions?.signal?e.destroyOptions:{...e.destroyOptions,signal:e.signal};if(await this.destroySymbols(n,a),r||e.onCascade&&(await e.onCascade({chain:i,winners:n,currentGrid:c}),r)||t>0&&(await new Promise(n=>{let r=setTimeout(n,t);if(!e.signal)return;let i=()=>{clearTimeout(r),n()};e.signal.aborted?i():e.signal.addEventListener(`abort`,i,{once:!0})}),r))break;let l=await e.nextGrid(c,n,o);if(r)break;let u=e.refillMode??`combined`;this._assertGrid(l,`runCascade(): nextGrid`),await this.refill({winners:[...n],grid:l,mode:u,gravityHoldMs:e.gravityHoldMs,gravityHold:e.gravityHold?()=>e.gravityHold({chain:i,winners:n}):void 0,onGravityComplete:e.onGravityComplete?()=>e.onGravityComplete({chain:i,winners:n}):void 0}),o+=1,c=this.getVisibleGrid(),this._events.emit(`cascade:chain:end`,{chain:i,winners:n,nextGrid:c})}}finally{this._events.off(`skip:requested`,i),e.signal&&e.signal.removeEventListener(`abort`,a)}return{chainLength:o,totalWinners:s,finalGrid:c,wasSkipped:r}}setAnticipation(e,t=0){this._spinController.setAnticipation(e,t)}setStopDelays(e){this._spinController.setStopDelays(e)}skipSpin(){this._spinController.skip()}requestSkip(){this._spinController.requestSkip()}slamStop(e){this._spinController.slamStop(e)}setMinimumSpinTime(e){this._spinController.setMinimumSpinTime(e)}get skipStage(){return this._spinController.skipStage}setSymbolAt(e,t,n){if(e<0||e>=this._reels.length)throw RangeError(`setSymbolAt: reel ${e} out of range [0, ${this._reels.length})`);if(this._pins.has(U(e,t)))throw Error(`setSymbolAt: cell (${e}, ${t}) has an active pin. Call unpin(reel, cell) first if you intend to overwrite it.`);this._reels[e].setSymbolAt(t,n)}async nudge(e,t){if(this._spinController.isSpinning)throw Error(`nudge: cannot nudge while a spin or refill is in progress.`);if(!Number.isInteger(e)||e<0||e>=this._reels.length)throw RangeError(`nudge: reel ${e} out of range [0, ${this._reels.length}).`);if(this._reels[e].bufferEnd===0)throw Error(`nudge: requires bufferEnd >= 1. a downward nudge shifts the bottom visible symbol through the below-window buffer. This reel set was built with bufferSymbols({ end: 0 }) for tumble-only use.`);for(let t of this._pins.values())if(t.reel===e)throw Error(`nudge: reel ${e} has an active pin at cell ${t.cell}. Call unpin(${e}, ${t.cell}) first if you intend to nudge through it.`);this._nudgesInFlight++;try{let n=await this._reels[e].nudge(t,()=>{this._events.emit(`nudge:start`,{reelIndex:e,distance:t.distance,direction:t.direction})});return this._events.emit(`nudge:complete`,{reelIndex:e,distance:t.distance,direction:t.direction,symbols:n.symbols}),n}catch(n){throw n instanceof Error&&n.name===`AbortError`&&!this._isDestroyed&&this._events.emit(`nudge:cancelled`,{reelIndex:e,distance:t.distance,direction:t.direction,reason:n.message}),n}finally{this._nudgesInFlight--}}_assertGrid(e,t){C(e,t);let n=G[`initialFrame() / setResult() column`];for(let r=0;r<e.length;r++)q(e[r],n,`${t} column ${r}`);ee(e,this._reels.map(e=>e.bufferStart),this._reels.map(e=>e.bufferEnd),t)}_assertNoNudgeInFlight(e){if(this._nudgesInFlight>0)throw Error(`ReelSet.${e}: cannot be called while nudge() is in flight. Await the nudge() promise before calling ${e}.`)}skipNudge(e){if(e===void 0){for(let e of this._reels)e.isNudging&&e.skipNudge();return}if(!Number.isInteger(e)||e<0||e>=this._reels.length)throw RangeError(`skipNudge: reel ${e} out of range [0, ${this._reels.length}).`);this._reels[e].skipNudge()}setDropOrder(e,t){if(e===null){this._spinController.setStopDelays(null);return}if(Array.isArray(e)){this._spinController.setStopDelays(e);return}let n=this._reels.length,r=t??Math.max(this._speedManager.active.stopDelay,150),i;i=e===`all`?Array(n).fill(0):e===`ltr`?Array.from({length:n},(e,t)=>t*r):Array.from({length:n},(e,t)=>(n-1-t)*r),this._spinController.setStopDelays(i)}get isSpinning(){return this._spinController.isSpinning}get isMultiWaysSlot(){return this._isMultiWaysSlot}setShape(e){if(this._assertNoNudgeInFlight(`setShape`),!this._isMultiWaysSlot)throw Error(`setShape(): slot was not built with .multiways(...). call ReelSetBuilder.multiways() first.`);if(this._resultSetForCurrentSpin)throw Error(`setShape(): must be called BEFORE setResult() in the current spin. Calling setShape after setResult corrupts the cached frames (pins were overlaid at their pre-migration cells). Reorder: spin() → setShape() → setResult().`);if(e.length!==this._reels.length)throw Error(`setShape(): cellsPerReel length ${e.length} must equal reelCount ${this._reels.length}.`);for(let t=0;t<e.length;t++){let n=e[t];if(n<this._multiwaysMinCells||n>this._multiwaysMaxCells)throw Error(`setShape(): cellsPerReel[${t}] = ${n} out of range [${this._multiwaysMinCells}, ${this._multiwaysMaxCells}].`)}let t=!0;for(let n=0;n<this._reels.length;n++)if(this._reels[n].visibleCells!==e[n]){t=!1;break}if(!t){this._targetShape=[...e],this._events.emit(`shape:changed`,[...e]);for(let t=0;t<this._reels.length;t++)this._migratePinsForReel(t,e[t])}}peekTargetShape(){return this._targetShape}clearTargetShape(){this._targetShape=null}getVisibleGrid(){return this._reels.map(e=>e.getVisibleSymbols())}getTargets(){return this._reels.map(e=>e.getTarget())}getSymbolFootprint(e,t){if(e<0||e>=this._reels.length)throw RangeError(`getSymbolFootprint: reel ${e} out of range [0, ${this._reels.length})`);let n=this._reels[e];if(t<0||t>=n.visibleCells)throw RangeError(`getSymbolFootprint: cell ${t} out of range [0, ${n.visibleCells})`);let r=n.getAnchorCell(t),i=n.getSymbolAt(t),a=this._symbolsData[i.symbolId],o=a?.size&&(a.size.reels>1||a.size.cells>1)?a.size:{reels:1,cells:1},s=e;for(let t=e-1;t>=0;t--){let n=this._reels[t];if(r>=n.visibleCells)break;let i=n.getAnchorCell(r),a=n.getSymbolAt(r),o=this._symbolsData[a.symbolId];if(o?.size&&o.size.reels>e-t)return s=t,{anchor:{reel:s,cell:i},size:o.size}}return{anchor:{reel:s,cell:r},size:o}}getBlockBounds(e,t){let n=this.getSymbolFootprint(e,t),r=this._reels[n.anchor.reel],i=r.axis,a=r.motion.slotPitch,o=n.size.reels*r.cellCross+(n.size.reels-1)*r.crossGap,s=n.size.cells*r.cellMain+(n.size.cells-1)*r.mainGap,c=n.anchor.cell,l=r.curve,u=c*a,d=l?l.mapMain(u):u,f=l?l.mapMain(u+s)-d:s,p=l?l.scaleAt(u):1,m=i.toScreen(i.getCross(r.container)+o*(1-p)/2,r.mainOffset+d),h=i.toScreen(o*p,f);return{x:this._viewport.x+m.x,y:this._viewport.y+m.y,width:h.x,height:h.y}}get speed(){return this._speedManager}setSpeed(e){let{previous:t,current:n}=this._speedManager.set(e);this._events.emit(`speed:changed`,n,t),this._spinController.notifyManualSpeedChange()}get spotlight(){return this._spotlight}setCurve(e){if(Array.isArray(e)&&e.length!==this._reels.length)throw Error(`setCurve(): per-reel array length (${e.length}) must equal the reel count (${this._reels.length}).`);for(let t=0;t<this._reels.length;t++)this._reels[t].setCurve(Array.isArray(e)?e[t]:e)}get randomSymbols(){return this._frameBuilder.randomProvider}get reels(){return this._reels}getReel(e){return this._reels[e]}getCellBounds(e,t){if(e<0||e>=this._reels.length)throw RangeError(`getCellBounds: reel ${e} out of range [0, ${this._reels.length})`);let n=this._reels[e];if(t<0||t>=n.visibleCells)throw RangeError(`getCellBounds: cell ${t} out of range [0, ${n.visibleCells})`);let r=n.axis,i=t*n.motion.slotPitch,a=r.toScreen(r.getCross(n.container),r.getMain(n.container)+i),o=r.toScreen(n.cellCross,n.cellMain),s=n.curve?.quadFor(i);if(!s)return{x:this._viewport.x+a.x,y:this._viewport.y+a.y,width:o.x,height:o.y};let c=Math.min(s.x0,s.x1,s.x2,s.x3),l=Math.max(s.x0,s.x1,s.x2,s.x3),u=Math.min(s.y0,s.y1,s.y2,s.y3),d=Math.max(s.y0,s.y1,s.y2,s.y3);return{x:this._viewport.x+a.x+c,y:this._viewport.y+a.y+u,width:l-c,height:d-u}}getCellQuad(e,t){if(e<0||e>=this._reels.length)throw RangeError(`getCellQuad: reel ${e} out of range [0, ${this._reels.length})`);let n=this._reels[e];if(t<0||t>=n.visibleCells)throw RangeError(`getCellQuad: cell ${t} out of range [0, ${n.visibleCells})`);let r=t*n.motion.slotPitch,i=n.curve?.quadFor(r);if(!i)return null;let a=n.axis,o=a.toScreen(a.getCross(n.container),a.getMain(n.container)+r),s=this._viewport.x+o.x,c=this._viewport.y+o.y;return[{x:s+i.x0,y:c+i.y0},{x:s+i.x1,y:c+i.y1},{x:s+i.x2,y:c+i.y2},{x:s+i.x3,y:c+i.y3}]}get viewport(){return this._viewport}pin(e,t,n,r){if(this._assertNoNudgeInFlight(`pin`),e<0||e>=this._reels.length)throw Error(`pin(): reel ${e} out of range [0, ${this._reels.length})`);let i=this._reels[e];if(t<0||t>=i.visibleCells)throw Error(`pin(): cell ${t} out of range [0, ${i.visibleCells})`);let a={reel:e,cell:t,originCell:r?.originCell??t,migration:r?.migration??`origin`,symbolId:n,turns:r?.turns??`permanent`,payload:r?.payload},o=U(e,t);return this._pins.has(o)&&this._destroyPinOverlay(o),this._pins.set(o,a),this._spinController.isSpinning?this._ensurePinOverlay(a):this._applyPinVisually(e,t,n),this._events.emit(`pin:placed`,a),a}unpin(e,t){let n=U(e,t),r=this._pins.get(n);r&&(this._pins.delete(n),this._destroyPinOverlay(n),this._events.emit(`pin:expired`,r,`explicit`))}get pins(){return this._pins}getPin(e,t){return this._pins.get(U(e,t))}async movePin(e,t,n){if(this._spinController.isSpinning)throw Error(`movePin(): cannot move pin while spinning`);let r=U(e.reel,e.cell),i=this._pins.get(r);if(!i)throw Error(`movePin(): no pin at (${e.reel}, ${e.cell})`);if(t.reel<0||t.reel>=this._reels.length)throw Error(`movePin(): to reel ${t.reel} out of range [0, ${this._reels.length})`);let a=this._reels[t.reel];if(t.cell<0||t.cell>=a.visibleCells)throw Error(`movePin(): to cell ${t.cell} out of range [0, ${a.visibleCells})`);if(e.reel===t.reel&&e.cell===t.cell){this._events.emit(`pin:moved`,i,{reel:e.reel,cell:e.cell});return}let o=U(t.reel,t.cell);if(this._pins.has(o))throw Error(`movePin(): a pin already exists at (${t.reel}, ${t.cell})`);this._pins.delete(r);let s={...i,reel:t.reel,cell:t.cell,originCell:t.cell};this._pins.set(o,s),this._destroyPinOverlay(r);let c=this._reels[e.reel],l=c.axis.toScreen(c.axis.getCross(c.container),this._pinOverlayCellMain(c,e.cell,c.motion.slotPitch)),u=a.axis.toScreen(a.axis.getCross(a.container),this._pinOverlayCellMain(a,t.cell,a.motion.slotPitch)),d=n?.backfill??this._frameBuilder.randomProvider.next(`spinning`,e.reel),f=c.getVisibleSymbols();f[e.cell]=d,c.placeSymbols({visible:f});let p=this._symbolFactory.acquire(i.symbolId);p.resize(c.symbolWidth,c.symbolHeight),p.view.x=l.x,p.view.y=l.y,this._viewport.unmaskedContainer.addChild(p.view);try{n?.onFlightCreated?.(p)}catch(e){B(`pin-hook-threw`,`movePin onFlightCreated hook threw. continuing the flight to avoid leaking the flight symbol:`,e)}let m=(n?.duration??400)/1e3,h=n?.easing??`power2.inOut`;await new Promise(e=>{this._reels[0].gsap.to(p.view,{x:u.x,y:u.y,duration:m,ease:h,onComplete:()=>e()})});try{n?.onFlightCompleted?.(p)}catch(e){B(`pin-hook-threw`,`movePin onFlightCompleted hook threw. continuing cleanup:`,e)}let g=a.getVisibleSymbols();g[t.cell]=i.symbolId,a.placeSymbols({visible:g}),this._viewport.unmaskedContainer.removeChild(p.view),this._symbolFactory.release(p),this._events.emit(`pin:moved`,s,{reel:e.reel,cell:e.cell})}get frame(){return this._frameAPI}get isDestroyed(){return this._isDestroyed}destroy(){if(!this._isDestroyed){this._isDestroyed=!0,this._spotlight.destroy(),this._spinController.destroy();for(let e of this._reels)e.destroy();this._destroyAllPinOverlays(),this._symbolFactory.destroy(),this._viewport.destroy(),this._pins.clear(),this._events.emit(`destroyed`),this._events.removeAllListeners(),super.destroy({children:!0})}}_applyPinsToGrid(e){for(let t of this._pins.values()){let n=e[t.reel];n&&t.cell<n.visible.length&&(n.visible[t.cell]=t.symbolId)}return e}_cloneTargets(e){return e.map(S)}_pinsOnReel(e){let t=[];for(let n of this._pins.values())n.reel===e&&t.push(n);return t}_migratePinsForReel(e,t){let n=[],r=this._pinsOnReel(e).sort((e,t)=>e.cell-t.cell),i=new Set,a=[];for(let e of r){let n=e.cell,r,o,s=e.originCell;if(e.migration===`frozen`?n<t?(r=n,o=!1):(r=t-1,o=!0,s=r):(r=Math.min(e.originCell,t-1),o=r!==e.originCell),r===n&&s===e.originCell){i.add(n);continue}a.push({pin:e,fromCell:n,target:r,clamped:o,nextOriginCell:s})}for(let{pin:t,fromCell:r,target:o,clamped:s,nextOriginCell:c}of a){let a=U(t.reel,r);if(i.has(o)){this._pins.delete(a),this._destroyPinOverlay(a),this._events.emit(`pin:expired`,t,`collision`);continue}i.add(o);let l=U(t.reel,o);this._pins.delete(a);let u={...t,cell:o,originCell:c};this._pins.set(l,u);let d=this._pinOverlays.get(a);d&&(this._pinOverlays.delete(a),this._pinOverlays.set(l,{pin:u,overlay:d.overlay})),n.push({pin:u,fromCell:r,toCell:o,clamped:s}),this._events.emit(`pin:migrated`,u,{fromCell:r,toCell:o,clamped:s,reelIndex:e})}return n}_pinOverlayCellMain(e,t,n){return e.axis.getMain(e.container)+t*n}_applyPinVisually(e,t,n){let r=this._reels[e],i=r.getVisibleSymbols();i[t]!==n&&(i[t]=n,r.placeSymbols({visible:i}))}_onSpinLanded(){if(this._destroyAllPinOverlays(),this._pins.size===0)return;let e=[];for(let t of this._pins.values())typeof t.turns==`number`&&(--t.turns,t.turns<=0&&e.push(t));for(let t of e)this._pins.delete(U(t.reel,t.cell)),this._events.emit(`pin:expired`,t,`turns`)}_onSpinStart(){if(this._resultSetForCurrentSpin=!1,this._pins.size>0){let e=[];for(let t of this._pins.values())t.turns===`eval`&&e.push(t);for(let t of e)this._pins.delete(U(t.reel,t.cell)),this._events.emit(`pin:expired`,t,`eval`)}for(let e of this._pins.values())this._ensurePinOverlay(e)}_ensurePinOverlay(t){let n=U(t.reel,t.cell);if(this._pinOverlays.has(n))return;let r=this._reels[t.reel],i=this._symbolFactory.acquire(t.symbolId);i.resize(r.symbolWidth,r.symbolHeight),r.axis.setCross(i.view,r.axis.getCross(r.container)),r.axis.setMain(i.view,this._pinOverlayCellMain(r,t.cell,r.motion.slotPitch)),i.view.zIndex=e.PIN_OVERLAY_Z_INDEX,this._viewport.unmaskedContainer.addChild(i.view),this._pinOverlays.set(n,{pin:t,overlay:i}),this._events.emit(`pin:overlayCreated`,t,i)}refreshPinOverlaysForReel(e){let t=this._reels[e];for(let[,n]of this._pinOverlays){if(n.pin.reel!==e)continue;let{pin:r,overlay:i}=n;i.resize(t.symbolWidth,t.symbolHeight),t.axis.setCross(i.view,t.axis.getCross(t.container)),t.axis.setMain(i.view,this._pinOverlayCellMain(t,r.cell,t.motion.slotPitch))}}_buildPinOverlayTweens(e,t){let n=this._reels[e],r=[],i=t+n.mainGap;for(let[,a]of this._pinOverlays){if(a.pin.reel!==e)continue;let{pin:o,overlay:s}=a;r.push({symbol:s,cellCross:n.cellCross,oldCellMain:n.cellMain,newCellMain:t,fromMain:n.axis.getMain(s.view),toMain:this._pinOverlayCellMain(n,o.cell,i),cross:n.axis.getCross(n.container)})}return r}_destroyPinOverlay(e){let t=this._pinOverlays.get(e);if(!t)return;let{pin:n,overlay:r}=t;this._events.emit(`pin:overlayDestroyed`,n,r),this._viewport.unmaskedContainer.removeChild(r.view),this._symbolFactory.release(r),this._pinOverlays.delete(e)}_destroyAllPinOverlays(){let e=[...this._pinOverlays.keys()];for(let t of e)this._destroyPinOverlay(t)}},J={bufferSymbols:1,symbolGap:{x:0,y:0},initialSpeed:`normal`,maxPoolPerKey:20,zIndexStep:100},ye={NORMAL:{name:`normal`,spinDelay:100,spinSpeed:30,stopDelay:140,anticipationDelay:450,bounceDistance:56,bounceDuration:600,accelerationEase:`power2.in`,decelerationEase:`power2.out`,accelerationDuration:300,minimumSpinTime:500},TURBO:{name:`turbo`,spinDelay:30,spinSpeed:50,stopDelay:0,anticipationDelay:250,bounceDistance:42,bounceDuration:200,accelerationEase:`power2.in`,decelerationEase:`power2.out`,accelerationDuration:200,minimumSpinTime:300},SUPER_TURBO:{name:`superTurbo`,spinDelay:0,spinSpeed:80,stopDelay:0,anticipationDelay:0,bounceDistance:14,bounceDuration:120,accelerationEase:`power1.in`,decelerationEase:`power1.out`,accelerationDuration:50,minimumSpinTime:100}},be=class{_entries=new Map;register(e,t,n){if(this._entries.has(e))throw Error(`Symbol '${e}' is already registered.`);this._entries.set(e,{SymbolClass:t,options:n})}create(e){let t=this._entries.get(e);if(!t)throw Error(`Symbol '${e}' is not registered. Available: ${[...this._entries.keys()].join(`, `)}`);let n=new t.SymbolClass(t.options);return n.activate(e),n}has(e){return this._entries.has(e)}get symbolIds(){return[...this._entries.keys()]}get size(){return this._entries.size}},xe=class{_pools=new Map;_pooled=new Set;_isDestroyed=!1;constructor(e,t,n,r=20){this._factory=e,this._reset=t,this._dispose=n,this._maxPerKey=r}get isDestroyed(){return this._isDestroyed}acquire(e){if(this._isDestroyed)throw Error(`ObjectPool.acquire('${e}') called after destroy(). A ticker or promise callback is still running past teardown; cancel it before destroying the pool.`);let t=this._pools.get(e);if(t&&t.length>0){let e=t.pop();return this._pooled.delete(e),this._reset?.(e),e}return this._factory(e)}release(e,t){if(this._isDestroyed||this._pooled.has(t))return;let n=this._pools.get(e);if(n||(n=[],this._pools.set(e,n)),n.length>=this._maxPerKey){this._dispose?.(t);return}n.push(t),this._pooled.add(t)}size(e){return this._pools.get(e)?.length??0}get totalSize(){let e=0;for(let t of this._pools.values())e+=t.length;return e}clear(){if(this._dispose)for(let e of this._pools.values())for(let t of e)this._dispose(t);this._pools.clear(),this._pooled.clear()}destroy(){this._isDestroyed||=(this.clear(),!0)}},Se=class{_pool;_capacityPerKey;constructor(t,n=20,r=e.n,i=`y`){this._registry=t,this._capacityPerKey=n,this._pool=new xe(e=>{let t=this._registry.create(e);return t.bindGsap(r),t.bindMainAxis(i),t},e=>e.reset(),e=>e.destroy(),n)}get capacityPerKey(){return this._capacityPerKey}acquire(e){let t=this._pool.acquire(e);return t.symbolId!==e&&t.activate(e),t}release(e){let t=e.symbolId;e.deactivate(),this._pool.release(t,e)}destroy(){this._pool.destroy()}},Ce=`*`,we=class{_symbols;_baseWeights={};_pools=new Map;_tables=new Map;_rng;constructor(e,t=Math.random){this._rng=t,this._symbols=Object.keys(e),this._readBaseWeights(e),this._assertUsable()}next(e=`spinning`,t){let n=this._table(e,t),r=this._rng()*n.total,i=0,a=n.cumulative.length-1;for(;i<a;){let e=i+a>>1;n.cumulative[e]<=r?i=e+1:a=e}return n.ids[i]}set(e,t={}){let n=this._key(t.slots??`spinning`,t.reel),r=this._pools.get(n);e===null?this._pools.delete(n):(this._assertKnownIds(e,t),this._pools.set(n,{weights:e.weights?{...e.weights}:void 0,exclude:e.exclude?[...e.exclude]:void 0})),this._tables.clear();try{this._assertDrawable()}catch(e){throw r===void 0?this._pools.delete(n):this._pools.set(n,r),this._tables.clear(),e}}clear(){this._pools.clear(),this._tables.clear()}weights(e={}){let t=this._resolve(e.slots??`spinning`,e.reel),n={};for(let e of this._symbols)n[e]=t[e];return n}setExcludeSpinning(e){this._setExclude(`spinning`,e)}setExcludeBuffer(e){this._setExclude(`buffer`,e)}updateWeights(e){this._symbols=Object.keys(e),this._readBaseWeights(e),this._assertUsable();let t=new Set(this._symbols);for(let[e,n]of this._pools)this._pools.set(e,{weights:n.weights?Object.fromEntries(Object.entries(n.weights).filter(([e])=>t.has(e))):void 0,exclude:n.exclude?.filter(e=>t.has(e))});this._tables.clear(),this._assertDrawable()}_setExclude(e,t){let n=this._pools.get(this._key(e,void 0));this.set({weights:n?.weights,exclude:t},{slots:e})}_key(e,t){return`${e}:${t??Ce}`}_readBaseWeights(e){this._baseWeights={};for(let t of this._symbols)this._baseWeights[t]=e[t].weight}_layerKeys(e,t){let n=e=>t===void 0?[this._key(e,void 0)]:[this._key(e,void 0),this._key(e,t)],r=n(`spinning`);return e===`spinning`||(r.push(...n(`buffer`)),e===`buffer`)||r.push(...n(e)),r}_resolve(e,t){let n={...this._baseWeights},r=this._layerKeys(e,t),i=new Set;for(let e of r){let t=this._pools.get(e);if(t){if(t.weights)for(let[e,r]of Object.entries(t.weights))e in n&&(n[e]=r);if(t.exclude)for(let e of t.exclude)i.add(e)}}for(let e of i)n[e]=0;return n}_table(e,t){let n=this._key(e,t),r=this._tables.get(n);if(r)return r;let i=this._compile(e,t);if(i.total<=0)throw Error(this._emptyPoolMessage(e,t));return this._tables.set(n,i),i}_compile(e,t){let n=this._resolve(e,t),r={ids:[],cumulative:[],total:0};for(let e of this._symbols){let t=n[e];t<=0||(r.total+=t,r.ids.push(e),r.cumulative.push(r.total))}return r}_assertKnownIds(e,t){let n=[...Object.keys(e.weights??{}),...e.exclude??[]];for(let e of n)if(this._baseWeights[e]===void 0)throw Error(`SymbolPool ${this._scopeName(t.slots??`spinning`,t.reel)} names symbol '${e}', which is not registered. Registered ids: ${this._symbols.join(`, `)}.`)}_assertDrawable(){let e=new Set;for(let t of this._pools.keys()){let n=t.slice(t.indexOf(`:`)+1);n!==Ce&&e.add(Number(n))}let t=[`spinning`,`buffer`,`bufferStart`,`bufferEnd`],n=t.map(e=>[e,void 0]);for(let r of e)for(let e of t)n.push([e,r]);for(let[e,t]of n)if(this._compile(e,t).total<=0)throw Error(this._emptyPoolMessage(e,t))}_emptyPoolMessage(e,t){return`No symbol left to draw ${this._scopeName(e,t)}: every registered symbol is excluded or weighted 0, so the strip cannot be filled. Leave at least one symbol drawable.`}_scopeName(e,t){let n={spinning:`spinning cells`,buffer:`buffer cells`,bufferStart:`buffer-start cells`,bufferEnd:`buffer-end cells`}[e];return t===void 0?`for ${n} on every reel`:`for ${n} on reel ${t}`}_assertUsable(){if(this._symbols.length===0)throw Error(`RandomSymbolProvider requires at least one symbol.`);let e=0;for(let t of this._symbols)e+=Math.max(0,this._baseWeights[t]);if(e<=0)throw Error(`RandomSymbolProvider requires at least one symbol with weight > 0; all registered symbols have weight 0, so the spinning strip cannot be filled.`)}},Te=class{_middlewares=[];_sorted=!1;constructor(e){this._randomProvider=e,this.use(new Ee(e)),this.use(new De)}use(e){return this._middlewares.push(e),this._sorted=!1,this}remove(e){return this._middlewares=this._middlewares.filter(t=>t.name!==e),this}build(e,t,n,r,i,a=!1){this._sorted||=(this._middlewares.sort((e,t)=>e.priority-t.priority),!0);let o=n+t+r,s={reelIndex:e,visibleCells:t,bufferStart:n,bufferEnd:r,symbols:Array(o).fill(``),target:i,isSpinning:a,metadata:{}},c=0,l=()=>{c<this._middlewares.length&&this._middlewares[c++].process(s,l)};return l(),s.symbols}buildAll(e,t,n,r,i,a=!1){return Array.from({length:e},(e,o)=>this.build(o,t,n,r,i?.[o],a))}get randomProvider(){return this._randomProvider}get middleware(){return this._middlewares}},Ee=class{name=`random-fill`;priority=0;constructor(e){this._provider=e}process(e,t){for(let t=0;t<e.symbols.length;t++)if(!e.symbols[t]){let n=t<e.bufferStart?`bufferStart`:t>=e.bufferStart+e.visibleCells?`bufferEnd`:`spinning`;e.symbols[t]=this._provider.next(n,e.reelIndex)}t()}},De=class{name=`target-placement`;priority=10;process(e,t){if(e.target){let t=x(e.target,e.bufferStart),n=Math.min(t.length,e.symbols.length);for(let r=0;r<n;r++){let n=t[r];n&&(e.symbols[r]=n)}}t()}};function Oe(e,t){return e===`auto`?t:e}function ke(e){return e===`forward`?1:-1}function Ae(e,t){return e===`auto`?t===`forward`?`endFirst`:`startFirst`:e}function je(e){return{gravity:e?.gravity??`auto`,fall:{duration:e?.fall?.duration??300,ease:e?.fall?.ease??`sine.in`,cellStagger:e?.fall?.cellStagger??0,cellOrder:e?.fall?.cellOrder??`auto`},dropIn:{duration:e?.dropIn?.duration??600,ease:e?.dropIn?.ease??`power2.out`,cellStagger:e?.dropIn?.cellStagger??60,cellOrder:e?.dropIn?.cellOrder??`auto`,distance:e?.dropIn?.distance??`perHole`}}}function Me(e,t){return t?{duration:t.duration??e.duration,ease:t.ease??e.ease,cellStagger:t.cellStagger??e.cellStagger,cellOrder:t.cellOrder??e.cellOrder}:e}function Ne(e,t){return t?{duration:t.duration??e.duration,ease:t.ease??e.ease,cellStagger:t.cellStagger??e.cellStagger,cellOrder:t.cellOrder??e.cellOrder,distance:t.distance??e.distance}:e}var Pe=class extends k{name=`cascade:fall`;skippable=!0;_baseFall;_fall;_timeline=null;_delayedCall=null;_fallingViews=[];_events=null;_startEmitted=!1;_skipAbort=null;_gravity;constructor(e,t,n,r=`auto`){super(e,t),this._baseFall=n,this._fall=n,this._gravity=r}onEnter(e){let t=this._reel;t.spinningMode=e.spinningMode,t.speed=0,t.notifySpinStart(),this._fall=Me(this._baseFall,this._speed.tumble?.fall),this._events=e.events,this._startEmitted=!1,this._skipAbort=new AbortController;let n=(e.delay??0)/1e3;n>0?this._delayedCall=this._reel.gsap.delayedCall(n,()=>this._beginFall(e.events)):this._beginFall(e.events)}_beginFall(e){this._delayedCall=null;let t=this._reel,n=t.axis,r=t.motion.slotPitch,i=t.visibleCells,a=t.reelIndex,o=Oe(this._gravity,n.direction),s=ke(o),c=(i+(s>0?t.bufferEnd:t.bufferStart)+1)*r,l=this._fall.duration/1e3,u=this._fall.cellStagger/1e3,d=[],f=[],p=[];for(let e=0;e<i;e++){let r=t.getSymbolAt(e);d.push(r),f.push(r.view),p.push(n.getMain(r.view))}if(this._fallingViews=f,e.emit(`cascade:fall:start`,{reelIndex:a}),this._startEmitted=!0,l<=0){for(let e of f)e.alpha=0;e.emit(`cascade:fall:end`,{reelIndex:a}),this._fallingViews=[],this._startEmitted=!1,this._events=null,this._skipAbort=null,this._complete();return}let m=this._reel.gsap.timeline({onComplete:()=>{this._timeline=null;for(let e of f)e.alpha=0;this._fallingViews=[],e.emit(`cascade:fall:end`,{reelIndex:a}),this._startEmitted=!1,this._events=null,this._skipAbort=null,this._complete()}});this._timeline=m;let h=Ae(this._fall.cellOrder,o)===`endFirst`;for(let t=0;t<i;t++){let r=f[t],o=d[t],g=p[t],_=(h?i-1-t:t)*u;m.call(()=>{let n=this._skipAbort?.signal;n&&e.emit(`cascade:fall:symbol`,{symbol:o,view:r,reelIndex:a,cellIndex:t,duration:this._fall.duration,ease:this._fall.ease,distance:c,signal:n})},void 0,_),m.to(r,{[n.mainProp]:g+s*c,duration:l,ease:this._fall.ease},_)}}update(e){}onSkip(){this._kill();for(let e of this._fallingViews)e.alpha=0;this._fallingViews=[],this._skipAbort&&!this._skipAbort.signal.aborted&&this._skipAbort.abort(),this._skipAbort=null,this._startEmitted&&this._events&&this._events.emit(`cascade:fall:end`,{reelIndex:this._reel.reelIndex}),this._startEmitted=!1,this._events=null}_kill(){this._delayedCall&&=(this._delayedCall.kill(),null),this._timeline&&=(this._timeline.kill(),null)}};function Fe(e,t,n={}){let r=n.initial??!1,i=n.gravity??`forward`,a=r?e:t.length,o=r?new Set:new Set(t),s=[];for(let t=0;t<e;t++)o.has(t)||s.push(t);let c=e-a,l=[];for(let t=0;t<e;t++){let e=i===`forward`?t<a:t>=c,n;n=e?i===`forward`?t-a:t+a:i===`forward`?s[t-a]:s[t],l.push({cell:t,originalCell:n,offsetCells:t-n,isNew:e})}return l}var Ie=class extends k{name=`cascade:place`;skippable=!0;_config=null;_delayedCall=null;_gravity;constructor(e,t,n=`auto`){super(e,t),this._gravity=n}onEnter(e){this._config=e;let t=(e.delay??0)/1e3;t>0?this._delayedCall=this._reel.gsap.delayedCall(t,()=>this._doPlace()):this._doPlace()}_placement(e){return e.slice(0,this._reel.bufferStart+this._reel.visibleCells)}_doPlace(){if(this._delayedCall=null,!this._config)return;let e=this._reel,{targetFrame:t,events:n}=this._config;e.beginMotion(),e.placeStrip(this._placement(t)),e.snapToGrid(),e.notifySpinEnd();let r=Fe(e.visibleCells,this._config.winnerCells,{initial:this._config.initial,gravity:Oe(this._gravity,e.axis.direction)}),i=[],a=new Set;for(let t of r){let n=e.getAnchorCell(t.cell);if(n!==t.cell&&a.has(n))continue;a.add(n);let r=e.getSymbolAt(t.cell);r.view.visible=!0,r.view.alpha=+(t.offsetCells===0),i.push(r)}n.emit(`cascade:place:end`,{reelIndex:e.reelIndex,placedSymbols:i,isInitial:this._config.initial,winnerCells:this._config.winnerCells}),this._complete()}update(e){}onSkip(){if(this._delayedCall&&=(this._delayedCall.kill(),null),this._config){let e=this._reel;e.placeStrip(this._placement(this._config.targetFrame));for(let t=0;t<e.visibleCells;t++){let n=e.getSymbolAt(t).view;n.alpha=1,n.visible=!0}}}},Le=class extends k{name=`cascade:dropIn`;skippable=!0;_baseDrop;_drop;_timeline=null;_jobs=[];_events=null;_endEvent=`cascade:dropIn:end`;_skipAbort=null;_gravity;constructor(e,t,n,r=`auto`){super(e,t),this._baseDrop=n,this._drop=n,this._gravity=r}onEnter(e){let t=this._reel,n=t.axis,r=t.visibleCells,i=t.motion.slotPitch,a=e.events,o=t.reelIndex,s=e.role??`all`;t.beginMotion(),this._drop=Ne(this._baseDrop,this._speed.tumble?.dropIn),this._skipAbort=new AbortController;let c=s===`gravity`?`cascade:gravity:start`:`cascade:dropIn:start`,l=s===`gravity`?`cascade:gravity:symbol`:`cascade:dropIn:symbol`,u=s===`gravity`?`cascade:gravity:end`:`cascade:dropIn:end`;this._events=a,this._endEvent=u,a.emit(c,{reelIndex:o});let d=Oe(this._gravity,n.direction),f=ke(d),p=Fe(r,e.winnerCells,{initial:e.initial,gravity:d}),m=[],h=new Set;for(let a of p){let o=t.getAnchorCell(a.cell);if(o!==a.cell&&h.has(o))continue;h.add(o);let c=t.getSymbolAt(a.cell);if(a.offsetCells===0){c.view.visible=!0,c.view.alpha=1;continue}let l=n.getMain(c.view),u;switch(this._drop.distance){case`auto`:u=!e.initial&&!a.isNew?a.originalCell*i:l-f*r*i;break;case`perHole`:u=a.originalCell*i;break;default:u=l-f*this._drop.distance}let d=a.isNew;if(s===`gravity`&&d||s===`new`&&!d){s===`gravity`&&d?(c.view.alpha=0,c.view.visible=!0):s===`new`&&!d&&(n.setMain(c.view,l),c.view.alpha=1,c.view.visible=!0);continue}n.setMain(c.view,u),c.view.alpha=1,c.view.visible=!0,m.push({cell:a.cell,symbol:c,view:c.view,startMain:u,finalMain:l,offsetCells:a.offsetCells})}this._jobs=m;let g=()=>{if(this._timeline=null,this._jobs=[],a.emit(u,{reelIndex:o}),this._events=null,this._skipAbort=null,s===`gravity`)for(let e of m)e.symbol.onReelLanded();else t.notifyLanded(m.map(e=>e.cell));this._complete()},_=this._drop.duration/1e3,v=this._drop.cellStagger/1e3;if(m.length===0||_<=0){for(let e of m)n.setMain(e.view,e.finalMain);g();return}let y=this._reel.gsap.timeline({onComplete:g});this._timeline=y;let b=Ae(this._drop.cellOrder,d)===`endFirst`;for(let e=0;e<m.length;e++){let t=m[e],r=(b?m.length-1-e:e)*v;y.call(()=>{let e=this._skipAbort?.signal;e&&a.emit(l,{symbol:t.symbol,view:t.view,reelIndex:o,cellIndex:t.cell,duration:this._drop.duration,ease:this._drop.ease,offsetCells:t.offsetCells,signal:e})},void 0,r),y.to(t.view,{[n.mainProp]:t.finalMain,duration:_,ease:this._drop.ease},r)}}update(e){}onSkip(){let e=this._reel.axis;this._timeline&&=(this._timeline.kill(),null);for(let t of this._jobs)e.setMain(t.view,t.finalMain),t.view.alpha=1,t.view.visible=!0;this._jobs=[];let t=this._reel;for(let e=0;e<t.visibleCells;e++){let n=t.getSymbolAt(e);n.view.alpha=1,n.view.visible=!0}this._skipAbort&&!this._skipAbort.signal.aborted&&this._skipAbort.abort(),this._skipAbort=null,this._events&&=(this._events.emit(this._endEvent,{reelIndex:this._reel.reelIndex}),null)}},Re=class extends k{name=`adjust`;skippable=!0;_durationMs;_ease;_tween=null;_settle=null;constructor(e,t,n){super(e,t),this._durationMs=n.durationMs,this._ease=n.ease??`power2.out`}onEnter(e){let t=e.pinOverlays;if(t.length===0){this._complete();return}if(this._durationMs<=0){this._snapPinOverlays(t),this._complete();return}let n=this._reel.axis;for(let e of t){let t=n.toScreen(e.cellCross,e.newCellMain);e.symbol.resize(t.x,t.y),n.setCross(e.symbol.view,e.cross),n.setMain(e.symbol.view,e.fromMain),e.symbol.view.scale[n.mainProp]=e.newCellMain>0?e.oldCellMain/e.newCellMain:1,e.symbol.view.scale[n.crossProp]=1}this._settle=()=>{for(let e of t)e.symbol.view.scale.set(1,1),n.setMain(e.symbol.view,e.toMain),n.setCross(e.symbol.view,e.cross)};let r=this._durationMs/1e3,i=this._ease;this._tween=this._reel.gsap.timeline({onComplete:()=>{this._settle?.(),this._settle=null,this._tween=null,this._complete()}});for(let e of t)this._tween.to(e.symbol.view,{[n.mainProp]:e.toMain,duration:r,ease:i},0),this._tween.to(e.symbol.view.scale,{[n.mainProp]:1,duration:r,ease:i},0)}update(e){}onSkip(){this._tween&&=(this._tween.progress(1),this._tween.kill(),null),this._settle&&=(this._settle(),null)}_snapPinOverlays(e){let t=this._reel.axis;for(let n of e){let e=t.toScreen(n.cellCross,n.newCellMain);n.symbol.resize(e.x,e.y),t.setCross(n.symbol.view,n.cross),t.setMain(n.symbol.view,n.toMain),n.symbol.view.scale.set(1,1)}}},ze=class{_reelCount;_visibleCells;_symbolWidth;_symbolHeight;_symbolGap={...J.symbolGap};_bufferStart=J.bufferSymbols;_bufferEnd=J.bufferSymbols;_symbolRegistry=new be;_weights={};_symbolPools=[];_speeds=new Map;_initialSpeed=J.initialSpeed;_offset={mode:`none`};_ticker;_spinningMode=new w;_phaseFactory=new P;_phaseConfigurators=[];_middlewares=[];_initialFrame;_symbolDataOverrides={};_tumbleConfig;_defaultSpinMode=`standard`;_visibleCellsPerReel;_reelExtents;_reelAnchor=`center`;_cellStacking=`ascending`;_reelStacking=`ascending`;_orientation=`vertical`;_direction=`forward`;_directionPerReel;_curve;_curvePerReel;_curveFocus=`reel`;_curveMode=`symbol`;_curveBleed=0;_renderer;_multiways;_pinMigrationDuration=200;_pinMigrationEase=`power2.out`;_maskStrategy=new O;_maskStrategyExplicit=!1;_gsap=e.n;_rng=Math.random;_poolCapacity;visibleRows(e){throw Error(K(`ReelSetBuilder`,`visibleRows`,W.visibleRows))}visibleRowsPerReel(e){throw Error(K(`ReelSetBuilder`,`visibleRowsPerReel`,W.visibleRowsPerReel))}reelPixelHeights(e){throw Error(K(`ReelSetBuilder`,`reelPixelHeights`,W.reelPixelHeights))}reels(e){return this._reelCount=e,this}visibleCells(e){return this._visibleCells=e,this}visibleCellsPerReel(e){return this._visibleCellsPerReel=[...e],this}reelExtents(e){return this._reelExtents=[...e],this}reelAnchor(e){return _e(e,ge[`reelAnchor()`],`reelAnchor()`),this._reelAnchor=e,this}cellStacking(e){return this._cellStacking=e,this}reelStacking(e){return this._reelStacking=e,this}orientation(e){return this._orientation=e,this}direction(e){return this._direction=e,this}directionPerReel(e){return this._directionPerReel=e,this}curve(e){return this._curve=e,this}curvePerReel(e){return this._curvePerReel=e,this}curveMode(e){if(e!==`symbol`&&e!==`warp`)throw Error(`curveMode(): expected 'symbol' or 'warp', got "${e}".`);return this._curveMode=e,this}renderer(e){return this._renderer=e,this}curveBleed(e){if(!Number.isFinite(e)||e<0)throw Error(`curveBleed(): expected a non-negative number, got ${e}.`);return this._curveBleed=e,this}curveFocus(e){if(!(e in c))throw Error(`curveFocus(): unknown focus "${e}". Expected one of ${Object.keys(c).join(`, `)}.`);return this._curveFocus=e,this}maskStrategy(e){if(e==null||typeof e.build!=`function`||typeof e.update!=`function`)throw Error(`maskStrategy(): expected a MaskStrategy with build(...) and update(...) methods (e.g. new RectMaskStrategy() or new SharedRectMaskStrategy()).`);if(e.version!==2)throw Error(`maskStrategy(): this strategy declares version ${String(e.version)}, but v2 requires 2. build(ctx) and update(graphics, ctx) now take a single MaskContext { rects, width, height, axis } instead of positional arguments, because a per-reel rect means different things on a vertical and a horizontal set. Add \`readonly version = MASK_STRATEGY_VERSION\` and read the context. See the Migrating to 2.0 guide.`);return this._maskStrategy=e,this._maskStrategyExplicit=!0,this}multiways(e){return q(e,G[`multiways()`],`multiways()`),this._multiways={...e},this}pinMigrationDuration(e){return this._pinMigrationDuration=e,this}pinMigrationEase(e){return this._pinMigrationEase=e,this}symbolSize(e,t){return this._symbolWidth=e,this._symbolHeight=t,this}symbolGap(e,t){return this._symbolGap={x:e,y:t},this}bufferSymbols(e){if(q(e,G[`bufferSymbols()`],`bufferSymbols()`),typeof e==`object`)return this._bufferStart=this._clampBufferMin1(e.start,`bufferSymbols({ start })`),this._bufferEnd=Number.isFinite(e.end)&&e.end>=0?e.end:0,this;let t=this._clampBufferMin1(e,`bufferSymbols(${e})`);return this._bufferStart=t,this._bufferEnd=t,this}_clampBufferMin1(e,t){return!Number.isFinite(e)||e<1?(de(`buffer-clamped`,`${t} is below the minimum of 1; clamping to 1. The motion layer needs at least one buffer cell above (and, outside tumble-only sets, below) the visible window for wrap detection.`),1):e}symbols(e){return e(this._symbolRegistry),this}weights(e){return this._weights=e,this}randomSymbols(e,t={}){return this._symbolPools.push({pool:e,scope:t}),this}symbolData(e){for(let[t,n]of Object.entries(e??{}))q(n?.size,G[`symbolData() size`],`symbolData('${t}').size`);return this._symbolDataOverrides={...this._symbolDataOverrides,...e},this}speed(e,t){return this._speeds.set(e,t),this}initialSpeed(e){return this._initialSpeed=e,this}offsetConfig(e){return q(e,G[`offset() trapezoid`],`offsetConfig()`),this._offset=e,this}ticker(e){return this._ticker=e,this}rng(e){return this._rng=e,this}poolCapacity(e){return this._poolCapacity=e,this}gsap(e){return this._gsap=e,this}spinningMode(e){return this._spinningMode=e,this}frameMiddleware(e){return this._middlewares.push(e),this}phases(e){return this._phaseConfigurators.push(e),this}tumble(e){let t=G[`tumble() fall/dropIn`];return q(e?.fall,t,`tumble({ fall })`),q(e?.dropIn,t,`tumble({ dropIn })`),_e(e?.fall?.cellOrder,ge[`tumble() cellOrder`],`tumble({ fall: { cellOrder } })`),_e(e?.dropIn?.cellOrder,ge[`tumble() cellOrder`],`tumble({ dropIn: { cellOrder } })`),this._tumbleConfig=je(e),this._defaultSpinMode=`cascade`,this}initialFrame(e){C(e,`initialFrame()`);let t=G[`initialFrame() / setResult() column`];for(let n=0;n<(e?.length??0);n++)q(e[n],t,`initialFrame() column ${n}`);return this._initialFrame=e,this}build(){if(this._validate(),this._directionPerReel&&this._directionPerReel.length!==this._reelCount)throw Error(`directionPerReel() length (${this._directionPerReel.length}) must equal reels() (${this._reelCount}).`);if(this._curveMode===`warp`&&!this._renderer)throw Error(`curveMode('warp') renders each reel to a texture, so it needs a renderer: add .renderer(app.renderer). Use the default curveMode('symbol') if you do not have one.`);if(this._curvePerReel&&this._curvePerReel.length!==this._reelCount)throw Error(`curvePerReel() length (${this._curvePerReel.length}) must equal reels() (${this._reelCount}).`);let e=this._reelCount,t=this._symbolWidth,n=this._symbolHeight,r=this._bufferStart,a=this._bufferEnd;if(a===0&&this._defaultSpinMode!==`cascade`)throw Error(`bufferSymbols({ end: 0 }) is tumble-only: the strip machinery wraps symbols through the below-window buffer. Add .tumble(...) to the builder, or keep bufferEnd >= 1.`);let o=this._ticker,s=!!this._multiways,l=this._orientation===`vertical`,u=i(this._orientation,`forward`),d=l?n:t,f=l?t:n,p=l?this._symbolGap.y:this._symbolGap.x,m=l?this._symbolGap.x:this._symbolGap.y,h;if(s)h=Array(e).fill(this._multiways.maxCells);else if(this._visibleCellsPerReel)h=this._visibleCellsPerReel;else{let t=this._visibleCells;h=Array(e).fill(t)}let g;g=s?Array(e).fill(this._multiways.reelExtent):this._reelExtents?this._reelExtents:h.map(e=>e*d+(e-1)*p);let _=g,v=Math.max(..._),y=_.map(e=>{switch(this._reelAnchor){case`start`:return 0;case`end`:return v-e;default:return(v-e)/2}}),b=g.map((e,t)=>{let n=h[t];return(e-(n-1)*p)/n}),x=d,S=s?Array(e).fill(x):b;this._speeds.size===0&&this._speeds.set(`normal`,ye.NORMAL);let C={},te=this._symbolRegistry.symbolIds;for(let e of te){let t=this._symbolDataOverrides[e]??{};C[e]={weight:t.weight??this._weights[e]??10,zIndex:t.zIndex??1,unmask:t.unmask,size:t.size}}let w={grid:{reelCount:e,visibleCells:this._visibleCells??h[0],symbolWidth:t,symbolHeight:n,symbolGap:{...this._symbolGap},bufferSymbols:this._bufferStart,bufferEnd:this._bufferEnd,visibleCellsPerReel:h,reelExtents:g,reelAnchor:this._reelAnchor,multiways:this._multiways},symbols:C,speeds:this._speeds,initialSpeed:this._initialSpeed,offset:this._offset,ticker:o},ne=h.reduce((e,t)=>e+t+r+a,0),T=this._poolCapacity??Math.max(20,ne),E=new Se(this._symbolRegistry,T,this._gsap,u.mainProp),D=new we(C,this._rng);for(let{pool:e,scope:t}of this._symbolPools)D.set(e,t);let O=new Te(D);for(let e of this._middlewares)O.use(e);if(this._tumbleConfig){let e=this._tumbleConfig.fall,t=this._tumbleConfig.dropIn,n=this._tumbleConfig.gravity;this._phaseFactory.registerFactory(`cascade:fall`,(t,r)=>new Pe(t,r,e,n)),this._phaseFactory.registerFactory(`cascade:place`,(e,t)=>new Ie(e,t,n)),this._phaseFactory.registerFactory(`cascade:dropIn`,(e,r)=>new Le(e,r,t,n))}if(s){let e=this._pinMigrationDuration,t=this._pinMigrationEase;this._phaseFactory.registerFactory(`adjust`,(n,r)=>new Re(n,r,{durationMs:typeof e==`function`?e(n.reelIndex):e,ease:t}))}for(let e of this._phaseConfigurators)e(this._phaseFactory);let k=e*(f+m)-m,A=u.toScreen(k,v),j=A.x,M=A.y,N=Object.values(C).some(e=>e.size&&(e.size.reels>1||e.size.cells>1)),P=Object.values(C).some(e=>e.unmask);!this._maskStrategyExplicit&&(N||P)&&m>0&&(this._maskStrategy=new ie,H(`mask-auto-shared`,`auto-selected SharedRectMaskStrategy because ${N?`big symbols are registered`:"one or more symbols use `unmask: true`"} and the cross-axis gap (symbolGap.${l?`x`:`y`}) is > 0. Pass .maskStrategy(...) explicitly to override.`));let F=this._curveFocus!==`reel`&&(this._curve!==void 0||this._curvePerReel!==void 0);!this._maskStrategyExplicit&&F&&(this._maskStrategy=new ie,H(`mask-auto-shared`,`auto-selected SharedRectMaskStrategy because curveFocus('${this._curveFocus}') leans cells across their own reel column. Pass .maskStrategy(...) explicitly to override.`)),this._curveMode===`warp`&&this._curve!==void 0&&P&&H(`warp-skips-unmask`,"curveMode('warp') does not bend symbols with `unmask: true`. They are lifted into `viewport.unmaskedContainer`, outside the reel texture, so they render FLAT above a curved board. The same applies to the win spotlight and pin overlays. Use curveMode('symbol') if those have to follow the drum.");let I=c[this._curveFocus],oe=k/2,L=new ae(j,M,void 0,this._maskStrategy,u,this._curveMode===`warp`?this._curveBleed:0);if(this._initialFrame){let t=Array(e).fill(r),n=Array(e).fill(a);ee(this._initialFrame,t,n,`initialFrame`)}let R=[],se=[];for(let t=0;t<e;t++){let e=h[t],n=u.toScreen(f,S[t]),s=O.build(t,e,r,a,this._initialFrame?.[t]),c=new re({reelIndex:t,visibleCells:e,bufferStart:r,bufferEnd:a,symbolWidth:n.x,symbolHeight:n.y,symbolGapX:this._symbolGap.x,symbolGapY:this._symbolGap.y,symbolsData:C,initialSymbols:s,mainOffset:y[t],extent:g[t],spinCellSize:x,axis:i(this._orientation,this._directionPerReel?.[t]??this._direction),curve:this._curvePerReel?.[t]??this._curve,curveRenderer:this._curveMode===`warp`?this._renderer:void 0,curveTicker:this._curveMode===`warp`?o:void 0,curveBleed:this._curveBleed,curveFocus:I===0?void 0:f/2+I*(oe-t*(f+m)-f/2),cellStacking:this._cellStacking,reelStacking:this._reelStacking,gsap:this._gsap},E,D,L);R.push(c);let l=u.toScreen(t*(f+m),y[t]),d=u.toScreen(f,_[t]);se.push({x:l.x,y:l.y,width:d.x,height:d.y})}return L.updateMaskSize(j,M,se),new ve({config:w,reels:R,viewport:L,symbolFactory:E,frameBuilder:O,phaseFactory:this._phaseFactory,spinningMode:this._spinningMode,defaultSpinMode:this._defaultSpinMode})}_validate(){let e=[];(this._reelCount===void 0||this._reelCount<=0)&&e.push(`reels() must be called with a positive number.`);let t=!!this._visibleCellsPerReel,n=this._visibleCells!==void 0,r=!!this._multiways;if(!r&&!n&&!t&&e.push(`one of visibleCells(n) or visibleCellsPerReel([...]) or multiways({...}) must be called.`),n&&t&&e.push(`cannot call both visibleCells() and visibleCellsPerReel(). pick one.`),r&&t&&e.push(`cannot combine multiways() with visibleCellsPerReel(). MultiWays shapes are server-driven.`),this._reelCount&&t&&this._visibleCellsPerReel.length!==this._reelCount&&e.push(`visibleCellsPerReel length ${this._visibleCellsPerReel.length} must equal reels(${this._reelCount}).`),t){for(let t=0;t<this._visibleCellsPerReel.length;t++)if(this._visibleCellsPerReel[t]<=0){e.push(`visibleCellsPerReel[${t}] = ${this._visibleCellsPerReel[t]} must be positive.`);break}}if(this._reelCount&&this._reelExtents&&this._reelExtents.length!==this._reelCount&&e.push(`reelExtents length ${this._reelExtents.length} must equal reels(${this._reelCount}).`),r){let t=this._multiways;t.minCells<=0||t.maxCells<=0?e.push(`multiways({minCells, maxCells}) must both be positive.`):t.minCells>t.maxCells&&e.push(`multiways: minCells ${t.minCells} cannot exceed maxCells ${t.maxCells}.`),t.reelExtent<=0&&e.push(`multiways({reelExtent}) must be positive.`),this._reelExtents&&e.push(`cannot combine multiways({reelExtent}) with reelExtents([...]). multiways slots use a uniform reel pixel height. Drop reelExtents() or remove the multiways() configuration.`);for(let t of this._symbolRegistry.symbolIds){let n=this._symbolDataOverrides[t]??{};if(n.size&&(n.size.reels>1||n.size.cells>1)){e.push(`big symbol '${t}' (size ${n.size.reels}x${n.size.cells}) cannot be registered on a MultiWays slot. Drop multiways() or remove the size metadata.`);break}}}for(let t of this._symbolRegistry.symbolIds){let n=this._symbolDataOverrides[t]??{},r=n.size;if(!r||r.reels===1&&r.cells===1)continue;let i=n.weight??this._weights[t];i!==void 0&&i>0&&e.push(`big symbol '${t}' (size ${r.reels}x${r.cells}) must have weight 0. big symbols are placed by the server at anchor cells only and never enter random fill. Set weight to 0 (or omit it) and place the symbol via setResult().`),r.reels>1&&this._directionPerReel&&new Set(this._directionPerReel).size>1&&e.push(`big symbol '${t}' spans ${r.reels} reels, which is not supported together with mixed directionPerReel([...]). The cross-reel coordinator assumes one shared feed edge for every reel a block covers. Use a single direction() for the set, or keep blocks within one reel (size.reels === 1).`)}if(this._visibleCells!==void 0&&this._visibleCells<=0&&e.push(`visibleCells() must be called with a positive number.`),(this._symbolWidth===void 0||this._symbolHeight===void 0)&&e.push(`symbolSize() must be called with width and height.`),this._symbolRegistry.size===0&&e.push(`symbols() must register at least one symbol.`),this._ticker||e.push(`ticker() must be called with a PixiJS Ticker.`),this._speeds.size>0&&!this._speeds.has(this._initialSpeed)&&e.push(`initialSpeed '${this._initialSpeed}' does not match any registered speed profile. Available: ${[...this._speeds.keys()].join(`, `)}`),e.length>0)throw Error(`ReelSetBuilder validation failed:\n - ${e.join(`
|
|
2
|
+
- `)}`)}},Be=[`mask`,`cells`,`buffers`,`thresholds`,`axis`,`feed`,`bounds`,`blocks`,`pins`,`hud`],Y={mask:16726832,cells:3321318,buffers:16749824,axis:3199320,feed:6607615,thresholds:16729402,bounds:16723349,blocks:16763904,pins:11490014,hud:16777215},Ve=`pixi-reels:debugOverlay`,He=3458905,Ue=3458905,We=10,Ge=11,X=4,Ke=0,qe=.7,Je=.62;function Ye(e){return e===void 0||e===`all`?new Set(Be):new Set(e)}function Xe(e,t={}){return new Ze(e,t)}var Ze=class{_root=new t.Container;_graphics=new Map;_cellLabels=[];_hudTexts=[];_active;_tickerRef=null;_isDestroyed=!1;_phase;_reelDetach=[];_onStatic=()=>this._redrawStatic();constructor(e,n){if(this._reelSet=e,this._active=Ye(n.layers),this._phase=e.reels.map(()=>`idle`),this._root.zIndex=1e6,this._root.eventMode=`none`,this._root.label=Ve,e.addChild(this._root),e.reels.forEach((e,t)=>{let n=e=>{this._phase[t]=e},r=e=>{this._phase[t]===e&&(this._phase[t]=`idle`)};e.events.on(`phase:enter`,n),e.events.on(`phase:exit`,r),this._reelDetach.push(()=>{e.events.off(`phase:enter`,n),e.events.off(`phase:exit`,r)})}),e.events.on(`shape:changed`,this._onStatic),e.events.on(`adjust:complete`,this._onStatic),n.live){let e=n.ticker??t.Ticker.shared;this._tickerRef=new h(e),this._tickerRef.add(()=>this._redrawLive())}this.redraw()}get isDestroyed(){return this._isDestroyed}setLayers(e){if(!this._isDestroyed){this._active=Ye(e);for(let[e,t]of this._graphics)this._active.has(e)?t.visible=!0:(t.clear(),t.visible=!1);this._active.has(`cells`)||this._hideTextsFrom(this._cellLabels,0),this._active.has(`hud`)||this._hideTextsFrom(this._hudTexts,0),this.redraw()}}redraw(){this._isDestroyed||(this._redrawStatic(),this._redrawLive())}describe(){return{layers:[...this._active],reels:this._reelSet.reels.map((e,t)=>{let n=e.axis,r=this._arrowMains(e),i=e.motion.slotPitch;return{reel:t,orientation:n.orientation,direction:n.direction,feedEdge:n.feedEdge,axisArrow:r,feedMain:this._feedMain(e),thresholds:{start:-(e.bufferStart+1)*i,end:(e.visibleCells+e.bufferEnd)*i},visibleCells:e.visibleCells,phase:this._phase[t]}})}}destroy(){if(!this._isDestroyed){this._isDestroyed=!0,this._tickerRef?.destroy(),this._tickerRef=null,this._reelSet.events.off(`shape:changed`,this._onStatic),this._reelSet.events.off(`adjust:complete`,this._onStatic);for(let e of this._reelDetach)e();this._reelDetach.length=0,this._root.parent&&this._root.parent.removeChild(this._root),this._root.destroy({children:!0}),this._graphics.clear(),this._cellLabels.length=0,this._hudTexts.length=0}}_redrawStatic(){this._isDestroyed||(this._active.has(`mask`)&&this._drawMask(),this._active.has(`cells`)&&this._drawCells(),this._active.has(`buffers`)&&this._drawBuffers(),this._active.has(`thresholds`)&&this._drawThresholds(),this._active.has(`axis`)&&this._drawAxis(),this._active.has(`feed`)&&this._drawFeed())}_redrawLive(){this._isDestroyed||(this._active.has(`bounds`)&&this._drawBounds(),this._active.has(`blocks`)&&this._drawBlocks(),this._active.has(`pins`)&&this._drawPins(),this._active.has(`hud`)&&this._drawHud())}_layer(e){let n=this._graphics.get(e);return n||(n=new t.Graphics,n.label=`${Ve}:${e}`,this._graphics.set(e,n),this._root.addChild(n)),n.visible=!0,n.clear(),n}_text(e,n,r,i){let a=e[n];return a||(a=new t.Text({text:``,style:{fontFamily:`monospace`,fontSize:i,fill:r}}),e[n]=a,this._root.addChild(a)),a.visible=!0,a}_hideTextsFrom(e,t){for(let n=t;n<e.length;n++)e[n].visible=!1}_drawMask(){let e=this._layer(`mask`),t=this._reelSet.viewport,n=t.x,r=t.y;e.rect(n,r,t.maskWidth,t.maskHeight).stroke({color:Y.mask,width:2});for(let i of t.maskRects)e.rect(n+i.x,r+i.y,i.width,i.height).stroke({color:He,width:2})}_drawCells(){let e=this._layer(`cells`),t=0;this._reelSet.reels.forEach((n,r)=>{for(let i=0;i<n.visibleCells;i++){let n=this._reelSet.getCellBounds(r,i),a=this._reelSet.getCellQuad(r,i);a?e.poly(a).stroke({color:Y.cells,width:1}):e.rect(n.x,n.y,n.width,n.height).stroke({color:Y.cells,width:1});let o=this._text(this._cellLabels,t++,Y.cells,10);o.text=`${r},${i}`,o.x=(a?a[0].x:n.x)+3,o.y=(a?a[0].y:n.y)+3}}),this._hideTextsFrom(this._cellLabels,t)}_drawBuffers(){let e=this._layer(`buffers`);for(let t of this._reelSet.reels){let n=t.motion.slotPitch,r=n=>{let r=t.curve,i=r?r.mapMain(n):n,a=r?r.mapMain(n+t.cellMain):n+t.cellMain,o=r?t.cellCross*r.scaleAt(n+t.cellMain/2):t.cellCross,s=this._reelRect(t,(t.cellCross-o)/2,i,o,a-i);e.rect(s.x,s.y,s.width,s.height).stroke({color:Y.buffers,width:1,alpha:.45})};for(let e=1;e<=t.bufferStart;e++)r(-e*n);for(let e=0;e<t.bufferEnd;e++)r((t.visibleCells+e)*n)}}_reelPoint(e,t,n){let r=e.axis,i=r.toScreen(r.getCross(e.container)+t,r.getMain(e.container)+n);return{x:this._reelSet.viewport.x+i.x,y:this._reelSet.viewport.y+i.y}}_reelRect(e,t,n,r,i){let a=this._reelPoint(e,t,n),o=e.axis.toScreen(r,i);return{x:a.x,y:a.y,width:o.x,height:o.y}}_arrowMains(e){let t=e.visibleCells*e.motion.slotPitch,n=e.axis.polarity>0;return{fromMain:n?t*.2:t*.8,toMain:n?t*.8:t*.2}}_feedMain(e){let t=e.motion.slotPitch;return e.axis.feedEdge===`start`?-e.bufferStart*t:e.visibleCells*t}_drawAxis(){let e=this._layer(`axis`);for(let t of this._reelSet.reels){let n=t.visibleCells*t.motion.slotPitch,r=t.cellCross/2,{fromMain:i,toMain:a}=this._arrowMains(t),o=t.axis.polarity>0,s=this._reelPoint(t,r,i),c=this._reelPoint(t,r,a);e.moveTo(s.x,s.y).lineTo(c.x,c.y).stroke({color:Y.axis,width:3});let l=Math.min(n*.12,t.cellCross*.4)||8,u=a-(o?l:-l);for(let n of[-1,1]){let i=this._reelPoint(t,r+n*l*.6,u);e.moveTo(c.x,c.y).lineTo(i.x,i.y).stroke({color:Y.axis,width:3})}}}_drawFeed(){let e=this._layer(`feed`);for(let t of this._reelSet.reels){let n=t.motion.slotPitch,r=this._reelRect(t,0,this._feedMain(t),t.cellCross,n*.18);e.rect(r.x,r.y,r.width,r.height).fill({color:Y.feed,alpha:.55})}}_drawThresholds(){let e=this._layer(`thresholds`);for(let t of this._reelSet.reels){let n=t.motion.slotPitch,r=[-(t.bufferStart+1)*n,(t.visibleCells+t.bufferEnd)*n];for(let n of r){let r=this._reelPoint(t,0,n),i=this._reelPoint(t,t.cellCross,n);e.moveTo(r.x,r.y).lineTo(i.x,i.y).stroke({color:Y.thresholds,width:2,alpha:.9})}}}_drawBounds(){let e=this._layer(`bounds`);this._reelSet.reels.forEach(t=>{for(let n=0;n<t.visibleCells;n++){let r=t.getSymbolAt(n).view.getBounds(),i=this._root.toLocal({x:r.x,y:r.y}),a=this._root.toLocal({x:r.x+r.width,y:r.y+r.height});e.rect(i.x,i.y,a.x-i.x,a.y-i.y).stroke({color:Y.bounds,width:1})}})}_drawBlocks(){let e=this._layer(`blocks`);this._reelSet.reels.forEach((t,n)=>{for(let r=0;r<t.visibleCells;r++){let t=this._reelSet.getSymbolFootprint(n,r);if(t.size.reels<=1&&t.size.cells<=1||t.anchor.reel!==n||t.anchor.cell!==r)continue;let i=this._reelSet.getBlockBounds(n,r);e.rect(i.x,i.y,i.width,i.height).stroke({color:Y.blocks,width:3})}})}_drawPins(){let e=this._layer(`pins`);this._reelSet.reels.forEach((t,n)=>{for(let r=0;r<t.visibleCells;r++){if(!this._reelSet.getPin(n,r))continue;let t=this._reelSet.getCellBounds(n,r);e.rect(t.x,t.y,t.width,t.height).stroke({color:Y.pins,width:3}),e.moveTo(t.x,t.y).lineTo(t.x+t.width,t.y+t.height).moveTo(t.x+t.width,t.y).lineTo(t.x,t.y+t.height).stroke({color:Ue,width:1,alpha:.8})}})}_drawHud(){let e=this._layer(`hud`),t=this._reelSet.viewport,n=t.x+X,r=t.y+X,i=0,a=0;this._reelSet.reels.forEach((e,t)=>{let o=this._text(this._hudTexts,i,Y.hud,We);o.resolution!==1&&(o.resolution=1);let s=e.axis;o.text=`r${t} ${s.orientation===`vertical`?`V`:`H`}${s.direction===`forward`?`F`:`R`} feed=${s.feedEdge} spd=${e.speed.toFixed(1)} ${this._phase[t]} cells=${e.visibleCells}`,o.x=n,o.y=r+i*Ge,a=Math.max(a,o.text.length),i++}),this._hideTextsFrom(this._hudTexts,i),i>0&&e.rect(n-X,r-X,a*We*Je+X*2,i*Ge+X*2).fill({color:Ke,alpha:qe})}};function Z(e){let t=e.reels,n=t.map((e,t)=>({index:t,speed:e.speed,isStopping:e.isStopping,orientation:e.axis.orientation,direction:e.axis.direction,allSymbols:e.symbols.map((t,n)=>({cell:n,symbolId:t.symbolId,main:Math.round(e.axis.getMain(t.view))})),visibleSymbols:e.getVisibleSymbols()})),r=e.getVisibleGrid();return{timestamp:Date.now(),isSpinning:e.isSpinning,currentSpeed:e.speed.activeName,availableSpeeds:e.speed.profileNames,spotlightActive:e.spotlight.isActive,reelCount:t.length,visibleCells:t.map(e=>e.visibleCells),reels:n,grid:r}}function Qe(e){let{grid:t,visibleCells:n}=Z(e);if(t.length===0)return`(empty grid)`;let r=Math.max(...n),i=e=>e.slice(0,8).padEnd(8),a=` `.repeat(8),o=(e,n,r)=>e+t.map(()=>`─`.repeat(8)).join(n)+r,s=[];s.push(o(`┌`,`┬`,`┐`));for(let e=0;e<r;e++){let r=t.map((t,r)=>e<n[r]?i(t[e]??`?`):a);s.push(`│`+r.join(`│`)+`│`)}return s.push(o(`└`,`┴`,`┘`)),s.join(`
|
|
3
|
+
`)}var $e=1e3,Q=[],et=$e,tt=new WeakMap;function nt(e,t=`default`,n={}){$(e),n.maxFrames!==void 0&&n.maxFrames>0&&(et=n.maxFrames);let r=n=>{Q.push({tag:t,trigger:n,snapshot:Z(e)}),Q.length>et&&Q.splice(0,Q.length-et)},i=()=>r(`spin:start`),a=()=>r(`spin:reelLanded`),o=()=>r(`spin:allLanded`),s=()=>r(`spin:complete`),c=()=>$(e);e.events.on(`spin:start`,i),e.events.on(`spin:reelLanded`,a),e.events.on(`spin:allLanded`,o),e.events.on(`spin:complete`,s),e.events.on(`destroyed`,c),tt.set(e,()=>{e.events.off(`spin:start`,i),e.events.off(`spin:reelLanded`,a),e.events.off(`spin:allLanded`,o),e.events.off(`spin:complete`,s),e.events.off(`destroyed`,c)})}function $(e){let t=tt.get(e);t&&(t(),tt.delete(e))}function rt(e){return e===void 0?Q.slice():Q.filter(t=>t.tag===e)}function it(){Q.length=0}function at(e,n){if(typeof window>`u`)return;let r=null,i={reelSet:e,snapshot:()=>Z(e),grid:()=>Qe(e),log:()=>{let t=Z(e);return console.log(`[pixi-reels debug] spinning=${t.isSpinning} speed=${t.currentSpeed}`),console.log(Qe(e)),t},trace:()=>{for(let t of[`spin:start`,`spin:allStarted`,`spin:stopping`,`spin:reelLanded`,`spin:allLanded`,`spin:complete`,`skip:requested`,`skip:completed`,`speed:changed`,`spotlight:start`,`spotlight:end`,`shape:changed`,`adjust:start`,`adjust:complete`,`pin:placed`,`pin:moved`,`pin:expired`,`pin:migrated`,`destroyed`])e.events.on(t,(...e)=>{console.log(`[pixi-reels] ${t}`,...e)});console.log(`[pixi-reels debug] tracing enabled for all events`)},startRecording:(t=`default`,n)=>nt(e,t,n),stopRecording:()=>$(e),getFrames:e=>rt(e),clearFrames:()=>it(),showMask:n=>{if(n){if(r)return;let n=new t.Graphics;n.rect(0,0,e.viewport.maskWidth,e.viewport.maskHeight).fill({color:16711680,alpha:.15});for(let t of e.viewport.maskRects)n.rect(t.x,t.y,t.width,t.height).stroke({color:65280,width:2});e.viewport.unmaskedContainer.addChild(n),r=n}else r&&=(e.viewport.unmaskedContainer.removeChild(r),r.destroy(),null)},overlay:t=>Xe(e,t)},a=window,o=a.__PIXI_REELS_DEBUG_INSTANCES??={},s=n??`reelset_${Object.keys(o).length}`;o[s]=i,a.__PIXI_REELS_DEBUG=i,console.log(`[pixi-reels] Debug mode enabled (key "${s}"). Use __PIXI_REELS_DEBUG.log() or __PIXI_REELS_DEBUG_INSTANCES["${s}"].`)}Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`B`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`G`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`H`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`J`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`K`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`Q`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`U`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`V`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`W`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`X`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`Y`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`Z`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`q`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,`z`,{enumerable:!0,get:function(){return re}});
|
|
4
|
+
//# sourceMappingURL=debug-BmbbKZrS.cjs.map
|