@digilogiclabs/saas-factory-ui 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -34044,7 +34044,20 @@ function RandomPlayerPicker({
34044
34044
  }
34045
34045
  }
34046
34046
  const activeN = activePool.length;
34047
- if (activeN < 2) return;
34047
+ if (activeN < 2) {
34048
+ if (removeWinnersRef.current && activePool.length === 1 && history.length > 0) {
34049
+ const survivor = activePool[0];
34050
+ if (survivor) {
34051
+ const promoted = [survivor, ...history].slice(0, 20);
34052
+ setPool([]);
34053
+ setWinner(survivor);
34054
+ setRevealKey((k) => k + 1);
34055
+ setHistory(promoted);
34056
+ onPick?.(survivor, promoted, { lastStanding: true });
34057
+ }
34058
+ }
34059
+ return;
34060
+ }
34048
34061
  const activeAnglePerWedge = 2 * Math.PI / activeN;
34049
34062
  const activeRotation = rotation;
34050
34063
  const activeReelY = reelY;
@@ -34209,8 +34222,19 @@ function RandomPlayerPicker({
34209
34222
  popTimer.current = null;
34210
34223
  pendingPopIdxRef.current = null;
34211
34224
  if (!removeWinnersRef.current) return;
34212
- setPool((p) => p.filter((_, i) => i !== finalWinnerIdx));
34213
- if (activePool.length - 1 >= 2) setWinner(null);
34225
+ const survivors = activePool.filter((_, i) => i !== finalWinnerIdx);
34226
+ const survivor = survivors.length === 1 ? survivors[0] : void 0;
34227
+ if (survivor) {
34228
+ const promoted = [survivor, ...nextHistory].slice(0, 20);
34229
+ setPool([]);
34230
+ setWinner(survivor);
34231
+ setRevealKey((k) => k + 1);
34232
+ setHistory(promoted);
34233
+ onPick?.(survivor, promoted, { lastStanding: true });
34234
+ } else {
34235
+ setPool(survivors);
34236
+ setWinner(null);
34237
+ }
34214
34238
  setRotation(0);
34215
34239
  setReelY(0);
34216
34240
  }, 2800);
@@ -38832,6 +38856,33 @@ function GameTimer({
38832
38856
  if (rafRef.current) cancelAnimationFrame(rafRef.current);
38833
38857
  };
38834
38858
  }, [running, tick]);
38859
+ useEffect61(() => {
38860
+ if (!running || mode !== "countdown") return;
38861
+ let timeoutId = null;
38862
+ const disarm = () => {
38863
+ if (timeoutId !== null) {
38864
+ clearTimeout(timeoutId);
38865
+ timeoutId = null;
38866
+ }
38867
+ };
38868
+ const arm = () => {
38869
+ disarm();
38870
+ const remainingUntilDone = durationMs - elapsedRef.current;
38871
+ if (remainingUntilDone > 0) {
38872
+ timeoutId = setTimeout(tick, remainingUntilDone + 50);
38873
+ }
38874
+ };
38875
+ const onVisibility = () => {
38876
+ if (document.hidden) arm();
38877
+ else disarm();
38878
+ };
38879
+ document.addEventListener("visibilitychange", onVisibility);
38880
+ if (document.hidden) arm();
38881
+ return () => {
38882
+ disarm();
38883
+ document.removeEventListener("visibilitychange", onVisibility);
38884
+ };
38885
+ }, [running, mode, durationMs, tick]);
38835
38886
  const start = useCallback51(() => {
38836
38887
  if (completed && mode === "countdown") return;
38837
38888
  setRunning(true);