cubing 0.26.2 → 0.26.5

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.
Files changed (88) hide show
  1. package/dist/esm/alg/index.js +1 -1
  2. package/dist/esm/bluetooth/index.js +11 -7
  3. package/dist/esm/bluetooth/index.js.map +2 -2
  4. package/dist/esm/{chunk-4OCHKVLJ.js → chunk-7K6HJKEG.js} +5 -5
  5. package/dist/esm/chunk-7K6HJKEG.js.map +7 -0
  6. package/dist/esm/{chunk-DO7GZAW4.js → chunk-FCB447RN.js} +4 -4
  7. package/dist/esm/chunk-FCB447RN.js.map +7 -0
  8. package/dist/esm/{chunk-HD2CMNE4.js → chunk-GNKVWDWW.js} +7 -627
  9. package/dist/esm/chunk-GNKVWDWW.js.map +7 -0
  10. package/dist/esm/{chunk-ESSOEWR6.js → chunk-GOBAXDTU.js} +61 -341
  11. package/dist/esm/chunk-GOBAXDTU.js.map +7 -0
  12. package/dist/esm/{chunk-FB7SFELN.js → chunk-ITRA3DUQ.js} +2 -2
  13. package/dist/esm/{chunk-FB7SFELN.js.map → chunk-ITRA3DUQ.js.map} +0 -0
  14. package/dist/esm/{chunk-RGEST6KF.js → chunk-K62P6E3H.js} +7 -7
  15. package/dist/esm/{chunk-RGEST6KF.js.map → chunk-K62P6E3H.js.map} +0 -0
  16. package/dist/esm/{chunk-3NFDCQI2.js → chunk-LJBHUHEP.js} +2 -56
  17. package/dist/esm/{chunk-3NFDCQI2.js.map → chunk-LJBHUHEP.js.map} +3 -3
  18. package/dist/esm/{chunk-NSLR2SC4.js → chunk-NHCGS73I.js} +2 -2
  19. package/dist/esm/{chunk-NSLR2SC4.js.map → chunk-NHCGS73I.js.map} +0 -0
  20. package/dist/esm/{chunk-3ADPLDWG.js → chunk-TB6NTLZY.js} +370 -81
  21. package/dist/esm/chunk-TB6NTLZY.js.map +7 -0
  22. package/dist/esm/chunk-VCOUFQGJ.js +240 -0
  23. package/dist/esm/chunk-VCOUFQGJ.js.map +7 -0
  24. package/dist/esm/chunk-VFDAQ42O.js +684 -0
  25. package/dist/esm/chunk-VFDAQ42O.js.map +7 -0
  26. package/dist/esm/{chunk-ZPAGJE7S.js → chunk-WQK6XWML.js} +2 -2
  27. package/dist/esm/{chunk-ZPAGJE7S.js.map → chunk-WQK6XWML.js.map} +1 -1
  28. package/dist/esm/kpuzzle/index.js +4 -6
  29. package/dist/esm/notation/index.js +2 -2
  30. package/dist/esm/protocol/index.js +4 -4
  31. package/dist/esm/puzzle-geometry/index.js +2 -2
  32. package/dist/esm/puzzles/index.js +4 -12
  33. package/dist/esm/{puzzles-dynamic-side-events-CXNWDLKD.js → puzzles-dynamic-side-events-HOXBZYWI.js} +21 -21
  34. package/dist/esm/{puzzles-dynamic-side-events-CXNWDLKD.js.map → puzzles-dynamic-side-events-HOXBZYWI.js.map} +1 -1
  35. package/dist/esm/{puzzles-dynamic-unofficial-CKTRIKMY.js → puzzles-dynamic-unofficial-MGVOFUDR.js} +79 -79
  36. package/dist/esm/{puzzles-dynamic-unofficial-CKTRIKMY.js.map → puzzles-dynamic-unofficial-MGVOFUDR.js.map} +1 -1
  37. package/dist/esm/scramble/index.js +2 -6
  38. package/dist/esm/search/index.js +9 -10
  39. package/dist/esm/{search-dynamic-sgs-side-events-ZDPMZ4Y7.js → search-dynamic-sgs-side-events-KK62JAWA.js} +7 -6
  40. package/dist/esm/{search-dynamic-sgs-side-events-ZDPMZ4Y7.js.map → search-dynamic-sgs-side-events-KK62JAWA.js.map} +1 -1
  41. package/dist/esm/{search-dynamic-sgs-unofficial-RAGEBTDP.js → search-dynamic-sgs-unofficial-VLNIEUW3.js} +8 -7
  42. package/dist/esm/{search-dynamic-sgs-unofficial-RAGEBTDP.js.map → search-dynamic-sgs-unofficial-VLNIEUW3.js.map} +1 -1
  43. package/dist/esm/{search-dynamic-solve-4x4x4-W455FUFG.js → search-dynamic-solve-4x4x4-S5JPXMNU.js} +7 -6
  44. package/dist/esm/{search-dynamic-solve-4x4x4-W455FUFG.js.map → search-dynamic-solve-4x4x4-S5JPXMNU.js.map} +1 -1
  45. package/dist/esm/{search-dynamic-solve-fto-ZM45FTCO.js → search-dynamic-solve-fto-WROONLZS.js} +6 -6
  46. package/dist/esm/search-dynamic-solve-fto-WROONLZS.js.map +7 -0
  47. package/dist/esm/{search-dynamic-solve-kilominx-PAW6HKT5.js → search-dynamic-solve-kilominx-UEFJENHO.js} +2 -2
  48. package/dist/esm/{search-dynamic-solve-kilominx-PAW6HKT5.js.map → search-dynamic-solve-kilominx-UEFJENHO.js.map} +0 -0
  49. package/dist/esm/search-worker-inside-generated-string-AVMDARJP.js +3768 -0
  50. package/dist/esm/search-worker-inside-generated-string-AVMDARJP.js.map +7 -0
  51. package/dist/esm/{search-worker-js-entry-5IIKIMTU.js → search-worker-js-entry-KJRZ3CJQ.js} +22 -21
  52. package/dist/esm/{search-worker-js-entry-5IIKIMTU.js.map → search-worker-js-entry-KJRZ3CJQ.js.map} +1 -1
  53. package/dist/esm/{search-worker-ts-entry-BV3J54MW.js → search-worker-ts-entry-AFMPRPSV.js} +3 -3
  54. package/dist/esm/{search-worker-ts-entry-BV3J54MW.js.map → search-worker-ts-entry-AFMPRPSV.js.map} +0 -0
  55. package/dist/esm/stream/index.js +1 -1
  56. package/dist/esm/twisty/index.js +65 -38
  57. package/dist/esm/twisty/index.js.map +3 -3
  58. package/dist/esm/{twisty-dynamic-3d-KFFJZNMZ.js → twisty-dynamic-3d-AVZOMIIW.js} +25 -8
  59. package/dist/esm/twisty-dynamic-3d-AVZOMIIW.js.map +7 -0
  60. package/dist/types/{Alg-6f3dc52c.d.ts → Alg-5cf4b166.d.ts} +2 -2
  61. package/dist/types/{KPuzzleDefinition-121e85a8.d.ts → KState-84892e94.d.ts} +77 -5
  62. package/dist/types/{PuzzleLoader-9243f44d.d.ts → TwizzleLink-24ea1412.d.ts} +42 -145
  63. package/dist/types/alg/index.d.ts +3 -3
  64. package/dist/types/bluetooth/index.d.ts +4 -5
  65. package/dist/types/{bluetooth-puzzle-679d8ca3.d.ts → bluetooth-puzzle-0f2e5f07.d.ts} +2 -2
  66. package/dist/types/kpuzzle/index.d.ts +2 -8
  67. package/dist/types/notation/index.d.ts +1 -1
  68. package/dist/types/{outside-f7ba9c00.d.ts → outside-d0ced6cc.d.ts} +2 -2
  69. package/dist/types/{parse-6d363160.d.ts → parse-9db7ee51.d.ts} +1 -1
  70. package/dist/types/protocol/index.d.ts +3 -6
  71. package/dist/types/puzzle-geometry/index.d.ts +3 -3
  72. package/dist/types/puzzles/index.d.ts +6 -16
  73. package/dist/types/scramble/index.d.ts +3 -4
  74. package/dist/types/search/index.d.ts +3 -4
  75. package/dist/types/stream/index.d.ts +3 -4
  76. package/dist/types/twisty/index.d.ts +5 -6
  77. package/package.json +6 -2
  78. package/dist/esm/.DS_Store +0 -0
  79. package/dist/esm/chunk-3ADPLDWG.js.map +0 -7
  80. package/dist/esm/chunk-4OCHKVLJ.js.map +0 -7
  81. package/dist/esm/chunk-DO7GZAW4.js.map +0 -7
  82. package/dist/esm/chunk-ESSOEWR6.js.map +0 -7
  83. package/dist/esm/chunk-HD2CMNE4.js.map +0 -7
  84. package/dist/esm/search-dynamic-solve-fto-ZM45FTCO.js.map +0 -7
  85. package/dist/esm/search-worker-inside-generated-string-VBEHCGJ6.js +0 -3768
  86. package/dist/esm/search-worker-inside-generated-string-VBEHCGJ6.js.map +0 -7
  87. package/dist/esm/twisty-dynamic-3d-KFFJZNMZ.js.map +0 -7
  88. package/dist/types/KState-73482114.d.ts +0 -70
@@ -2,7 +2,7 @@ import {
2
2
  Alg,
3
3
  Move,
4
4
  TraversalDownUp
5
- } from "./chunk-DO7GZAW4.js";
5
+ } from "./chunk-FCB447RN.js";
6
6
  import {
7
7
  __privateAdd,
8
8
  __privateGet,
@@ -138,24 +138,6 @@ function moveToTransformationUncached(kpuzzle, move) {
138
138
  throw new Error(`Invalid move for KPuzzle (${kpuzzle.name()}): ${move}`);
139
139
  }
140
140
 
141
- // src/cubing/kpuzzle/3x3x3/puzzle-orientation.ts
142
- function experimentalIs3x3x3Solved(state, options) {
143
- if (options.ignorePuzzleOrientation) {
144
- state = normalizePuzzleOrientation(state);
145
- }
146
- if (options.ignoreCenterOrientation) {
147
- state = new KState(state.kpuzzle, {
148
- EDGES: state.stateData.EDGES,
149
- CORNERS: state.stateData.CORNERS,
150
- CENTERS: {
151
- pieces: state.stateData.CENTERS.pieces,
152
- orientation: new Array(6).fill(0)
153
- }
154
- });
155
- }
156
- return !!state.experimentalToTransformation()?.isIdentityTransformation();
157
- }
158
-
159
141
  // src/cubing/kpuzzle/KState.ts
160
142
  var KState = class {
161
143
  constructor(kpuzzle, stateData) {
@@ -202,11 +184,11 @@ var KState = class {
202
184
  }
203
185
  return new KTransformation(this.kpuzzle, transformationData);
204
186
  }
205
- experimentalIs3x3x3Solved(options) {
206
- if (this.kpuzzle.name() !== "3x3x3") {
207
- throw new Error("`KState.experimentalIs3x3x3Solved()` only supports 3x3x3 states.");
187
+ experimentalIsSolved(options) {
188
+ if (!this.kpuzzle.definition.experimentalIsStateSolved) {
189
+ throw new Error("`KState.experimentalIsSolved()` is not supported for this puzzle at the moment.");
208
190
  }
209
- return experimentalIs3x3x3Solved(this, options);
191
+ return this.kpuzzle.definition.experimentalIsStateSolved(this, options);
210
192
  }
211
193
  };
212
194
 
@@ -529,611 +511,9 @@ var KPuzzle = class {
529
511
  _moveToTransformationDataCache = new WeakMap();
530
512
  _cachedCanConvertStateToUniqueTransformation = new WeakMap();
531
513
 
532
- // src/cubing/kpuzzle/3x3x3/3x3x3.kpuzzle.json.ts
533
- var cube3x3x3KPuzzleDefinition = {
534
- name: "3x3x3",
535
- orbits: {
536
- EDGES: { numPieces: 12, numOrientations: 2 },
537
- CORNERS: { numPieces: 8, numOrientations: 3 },
538
- CENTERS: { numPieces: 6, numOrientations: 4 }
539
- },
540
- startStateData: {
541
- EDGES: {
542
- pieces: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
543
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
544
- },
545
- CORNERS: {
546
- pieces: [0, 1, 2, 3, 4, 5, 6, 7],
547
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
548
- },
549
- CENTERS: {
550
- pieces: [0, 1, 2, 3, 4, 5],
551
- orientation: [0, 0, 0, 0, 0, 0]
552
- }
553
- },
554
- moves: {
555
- U: {
556
- EDGES: {
557
- permutation: [1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11],
558
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
559
- },
560
- CORNERS: {
561
- permutation: [1, 2, 3, 0, 4, 5, 6, 7],
562
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
563
- },
564
- CENTERS: {
565
- permutation: [0, 1, 2, 3, 4, 5],
566
- orientation: [1, 0, 0, 0, 0, 0]
567
- }
568
- },
569
- y: {
570
- EDGES: {
571
- permutation: [1, 2, 3, 0, 5, 6, 7, 4, 10, 8, 11, 9],
572
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
573
- },
574
- CORNERS: {
575
- permutation: [1, 2, 3, 0, 7, 4, 5, 6],
576
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
577
- },
578
- CENTERS: {
579
- permutation: [0, 2, 3, 4, 1, 5],
580
- orientation: [1, 0, 0, 0, 0, 3]
581
- }
582
- },
583
- x: {
584
- EDGES: {
585
- permutation: [4, 8, 0, 9, 6, 10, 2, 11, 5, 7, 1, 3],
586
- orientation: [1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0]
587
- },
588
- CORNERS: {
589
- permutation: [4, 0, 3, 5, 7, 6, 2, 1],
590
- orientation: [2, 1, 2, 1, 1, 2, 1, 2]
591
- },
592
- CENTERS: {
593
- permutation: [2, 1, 5, 3, 0, 4],
594
- orientation: [0, 3, 0, 1, 2, 2]
595
- }
596
- },
597
- L: {
598
- EDGES: {
599
- permutation: [0, 1, 2, 11, 4, 5, 6, 9, 8, 3, 10, 7],
600
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
601
- },
602
- CORNERS: {
603
- permutation: [0, 1, 6, 2, 4, 3, 5, 7],
604
- orientation: [0, 0, 2, 1, 0, 2, 1, 0]
605
- },
606
- CENTERS: {
607
- permutation: [0, 1, 2, 3, 4, 5],
608
- orientation: [0, 1, 0, 0, 0, 0]
609
- }
610
- },
611
- F: {
612
- EDGES: {
613
- permutation: [9, 1, 2, 3, 8, 5, 6, 7, 0, 4, 10, 11],
614
- orientation: [1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0]
615
- },
616
- CORNERS: {
617
- permutation: [3, 1, 2, 5, 0, 4, 6, 7],
618
- orientation: [1, 0, 0, 2, 2, 1, 0, 0]
619
- },
620
- CENTERS: {
621
- permutation: [0, 1, 2, 3, 4, 5],
622
- orientation: [0, 0, 1, 0, 0, 0]
623
- }
624
- },
625
- R: {
626
- EDGES: {
627
- permutation: [0, 8, 2, 3, 4, 10, 6, 7, 5, 9, 1, 11],
628
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
629
- },
630
- CORNERS: {
631
- permutation: [4, 0, 2, 3, 7, 5, 6, 1],
632
- orientation: [2, 1, 0, 0, 1, 0, 0, 2]
633
- },
634
- CENTERS: {
635
- permutation: [0, 1, 2, 3, 4, 5],
636
- orientation: [0, 0, 0, 1, 0, 0]
637
- }
638
- },
639
- B: {
640
- EDGES: {
641
- permutation: [0, 1, 10, 3, 4, 5, 11, 7, 8, 9, 6, 2],
642
- orientation: [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1]
643
- },
644
- CORNERS: {
645
- permutation: [0, 7, 1, 3, 4, 5, 2, 6],
646
- orientation: [0, 2, 1, 0, 0, 0, 2, 1]
647
- },
648
- CENTERS: {
649
- permutation: [0, 1, 2, 3, 4, 5],
650
- orientation: [0, 0, 0, 0, 1, 0]
651
- }
652
- },
653
- D: {
654
- EDGES: {
655
- permutation: [0, 1, 2, 3, 7, 4, 5, 6, 8, 9, 10, 11],
656
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
657
- },
658
- CORNERS: {
659
- permutation: [0, 1, 2, 3, 5, 6, 7, 4],
660
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
661
- },
662
- CENTERS: {
663
- permutation: [0, 1, 2, 3, 4, 5],
664
- orientation: [0, 0, 0, 0, 0, 1]
665
- }
666
- },
667
- z: {
668
- EDGES: {
669
- permutation: [9, 3, 11, 7, 8, 1, 10, 5, 0, 4, 2, 6],
670
- orientation: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
671
- },
672
- CORNERS: {
673
- permutation: [3, 2, 6, 5, 0, 4, 7, 1],
674
- orientation: [1, 2, 1, 2, 2, 1, 2, 1]
675
- },
676
- CENTERS: {
677
- permutation: [1, 5, 2, 0, 4, 3],
678
- orientation: [1, 1, 1, 1, 3, 1]
679
- }
680
- },
681
- M: {
682
- EDGES: {
683
- permutation: [2, 1, 6, 3, 0, 5, 4, 7, 8, 9, 10, 11],
684
- orientation: [1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0]
685
- },
686
- CORNERS: {
687
- permutation: [0, 1, 2, 3, 4, 5, 6, 7],
688
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
689
- },
690
- CENTERS: {
691
- permutation: [4, 1, 0, 3, 5, 2],
692
- orientation: [2, 0, 0, 0, 2, 0]
693
- }
694
- },
695
- E: {
696
- EDGES: {
697
- permutation: [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 8, 10],
698
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
699
- },
700
- CORNERS: {
701
- permutation: [0, 1, 2, 3, 4, 5, 6, 7],
702
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
703
- },
704
- CENTERS: {
705
- permutation: [0, 4, 1, 2, 3, 5],
706
- orientation: [0, 0, 0, 0, 0, 0]
707
- }
708
- },
709
- S: {
710
- EDGES: {
711
- permutation: [0, 3, 2, 7, 4, 1, 6, 5, 8, 9, 10, 11],
712
- orientation: [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]
713
- },
714
- CORNERS: {
715
- permutation: [0, 1, 2, 3, 4, 5, 6, 7],
716
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
717
- },
718
- CENTERS: {
719
- permutation: [1, 5, 2, 0, 4, 3],
720
- orientation: [1, 1, 0, 1, 0, 1]
721
- }
722
- },
723
- u: {
724
- EDGES: {
725
- permutation: [1, 2, 3, 0, 4, 5, 6, 7, 10, 8, 11, 9],
726
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
727
- },
728
- CORNERS: {
729
- permutation: [1, 2, 3, 0, 4, 5, 6, 7],
730
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
731
- },
732
- CENTERS: {
733
- permutation: [0, 2, 3, 4, 1, 5],
734
- orientation: [1, 0, 0, 0, 0, 0]
735
- }
736
- },
737
- l: {
738
- EDGES: {
739
- permutation: [2, 1, 6, 11, 0, 5, 4, 9, 8, 3, 10, 7],
740
- orientation: [1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0]
741
- },
742
- CORNERS: {
743
- permutation: [0, 1, 6, 2, 4, 3, 5, 7],
744
- orientation: [0, 0, 2, 1, 0, 2, 1, 0]
745
- },
746
- CENTERS: {
747
- permutation: [4, 1, 0, 3, 5, 2],
748
- orientation: [2, 1, 0, 0, 2, 0]
749
- }
750
- },
751
- f: {
752
- EDGES: {
753
- permutation: [9, 3, 2, 7, 8, 1, 6, 5, 0, 4, 10, 11],
754
- orientation: [1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0]
755
- },
756
- CORNERS: {
757
- permutation: [3, 1, 2, 5, 0, 4, 6, 7],
758
- orientation: [1, 0, 0, 2, 2, 1, 0, 0]
759
- },
760
- CENTERS: {
761
- permutation: [1, 5, 2, 0, 4, 3],
762
- orientation: [1, 1, 1, 1, 0, 1]
763
- }
764
- },
765
- r: {
766
- EDGES: {
767
- permutation: [4, 8, 0, 3, 6, 10, 2, 7, 5, 9, 1, 11],
768
- orientation: [1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0]
769
- },
770
- CORNERS: {
771
- permutation: [4, 0, 2, 3, 7, 5, 6, 1],
772
- orientation: [2, 1, 0, 0, 1, 0, 0, 2]
773
- },
774
- CENTERS: {
775
- permutation: [2, 1, 5, 3, 0, 4],
776
- orientation: [0, 0, 0, 1, 2, 2]
777
- }
778
- },
779
- b: {
780
- EDGES: {
781
- permutation: [0, 5, 10, 1, 4, 7, 11, 3, 8, 9, 6, 2],
782
- orientation: [0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1]
783
- },
784
- CORNERS: {
785
- permutation: [0, 7, 1, 3, 4, 5, 2, 6],
786
- orientation: [0, 2, 1, 0, 0, 0, 2, 1]
787
- },
788
- CENTERS: {
789
- permutation: [3, 0, 2, 5, 4, 1],
790
- orientation: [3, 3, 0, 3, 1, 3]
791
- }
792
- },
793
- d: {
794
- EDGES: {
795
- permutation: [0, 1, 2, 3, 7, 4, 5, 6, 9, 11, 8, 10],
796
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
797
- },
798
- CORNERS: {
799
- permutation: [0, 1, 2, 3, 5, 6, 7, 4],
800
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
801
- },
802
- CENTERS: {
803
- permutation: [0, 4, 1, 2, 3, 5],
804
- orientation: [0, 0, 0, 0, 0, 1]
805
- }
806
- }
807
- }
808
- };
809
- cube3x3x3KPuzzleDefinition.moves["Uw"] = cube3x3x3KPuzzleDefinition.moves["u"];
810
- cube3x3x3KPuzzleDefinition.moves["Lw"] = cube3x3x3KPuzzleDefinition.moves["l"];
811
- cube3x3x3KPuzzleDefinition.moves["Fw"] = cube3x3x3KPuzzleDefinition.moves["f"];
812
- cube3x3x3KPuzzleDefinition.moves["Rw"] = cube3x3x3KPuzzleDefinition.moves["r"];
813
- cube3x3x3KPuzzleDefinition.moves["Bw"] = cube3x3x3KPuzzleDefinition.moves["b"];
814
- cube3x3x3KPuzzleDefinition.moves["Dw"] = cube3x3x3KPuzzleDefinition.moves["d"];
815
- cube3x3x3KPuzzleDefinition.moves["Rv"] = cube3x3x3KPuzzleDefinition.moves["x"];
816
- cube3x3x3KPuzzleDefinition.moves["Uv"] = cube3x3x3KPuzzleDefinition.moves["y"];
817
- cube3x3x3KPuzzleDefinition.moves["Fv"] = cube3x3x3KPuzzleDefinition.moves["z"];
818
- cube3x3x3KPuzzleDefinition.moves["Lv"] = {
819
- EDGES: {
820
- permutation: [2, 10, 6, 11, 0, 8, 4, 9, 1, 3, 5, 7],
821
- orientation: [1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0]
822
- },
823
- CORNERS: {
824
- permutation: [1, 7, 6, 2, 0, 3, 5, 4],
825
- orientation: [2, 1, 2, 1, 1, 2, 1, 2]
826
- },
827
- CENTERS: {
828
- permutation: [4, 1, 0, 3, 5, 2],
829
- orientation: [2, 1, 0, 3, 2, 0]
830
- }
831
- };
832
- cube3x3x3KPuzzleDefinition.moves["Dv"] = {
833
- EDGES: {
834
- permutation: [3, 0, 1, 2, 7, 4, 5, 6, 9, 11, 8, 10],
835
- orientation: [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
836
- },
837
- CORNERS: {
838
- permutation: [3, 0, 1, 2, 5, 6, 7, 4],
839
- orientation: [0, 0, 0, 0, 0, 0, 0, 0]
840
- },
841
- CENTERS: {
842
- permutation: [0, 4, 1, 2, 3, 5],
843
- orientation: [3, 0, 0, 0, 0, 1]
844
- }
845
- };
846
- cube3x3x3KPuzzleDefinition.moves["Bv"] = {
847
- EDGES: {
848
- permutation: [8, 5, 10, 1, 9, 7, 11, 3, 4, 0, 6, 2],
849
- orientation: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
850
- },
851
- CORNERS: {
852
- permutation: [4, 7, 1, 0, 5, 3, 2, 6],
853
- orientation: [1, 2, 1, 2, 2, 1, 2, 1]
854
- },
855
- CENTERS: {
856
- permutation: [3, 0, 2, 5, 4, 1],
857
- orientation: [3, 3, 3, 3, 1, 3]
858
- }
859
- };
860
-
861
- // src/cubing/kpuzzle/index.ts
862
- var experimental3x3x3KPuzzle = new KPuzzle(cube3x3x3KPuzzleDefinition);
863
-
864
- // src/cubing/protocol/binary/orbit-indexing.ts
865
- function identityPermutation(numElems) {
866
- const arr = new Array(numElems);
867
- for (let i = 0; i < numElems; i++) {
868
- arr[i] = i;
869
- }
870
- return arr;
871
- }
872
- function orientationsToMask(radix, orientations) {
873
- let val = 0;
874
- for (const orientation of orientations) {
875
- val *= radix;
876
- val += orientation;
877
- }
878
- return val;
879
- }
880
- function maskToOrientations(radix, numElems, mask) {
881
- const arr = [];
882
- while (mask > 0) {
883
- arr.push(mask % radix);
884
- mask = Math.floor(mask / radix);
885
- }
886
- return new Array(numElems - arr.length).fill(0).concat(arr.reverse());
887
- }
888
- function permutationToLex(permutation) {
889
- const n = permutation.length;
890
- let lexicographicIdx = 0;
891
- for (let i = 0; i < n - 1; i++) {
892
- lexicographicIdx = lexicographicIdx * (n - i);
893
- for (let j = i + 1; j < n; j++) {
894
- if (permutation[i] > permutation[j]) {
895
- lexicographicIdx += 1;
896
- }
897
- }
898
- }
899
- return lexicographicIdx;
900
- }
901
- function lexToPermutation(numPieces, lexicographicIdx) {
902
- const permutation = new Array(numPieces);
903
- permutation[numPieces - 1] = 0;
904
- for (let i = numPieces - 2; i >= 0; i--) {
905
- permutation[i] = lexicographicIdx % (numPieces - i);
906
- lexicographicIdx = Math.floor(lexicographicIdx / (numPieces - i));
907
- for (let j = i + 1; j < numPieces; j++) {
908
- if (permutation[j] >= permutation[i]) {
909
- permutation[j] = permutation[j] + 1;
910
- }
911
- }
912
- }
913
- return permutation;
914
- }
915
-
916
- // src/cubing/protocol/binary/puzzle-orientation.ts
917
- function puzzleOrientationIdx(state) {
918
- const idxU = state.stateData["CENTERS"].pieces[0];
919
- const idxD = state.stateData["CENTERS"].pieces[5];
920
- const unadjustedIdxL = state.stateData["CENTERS"].pieces[1];
921
- let idxL = unadjustedIdxL;
922
- if (idxU < unadjustedIdxL) {
923
- idxL--;
924
- }
925
- if (idxD < unadjustedIdxL) {
926
- idxL--;
927
- }
928
- return [idxU, idxL];
929
- }
930
- var puzzleOrientationCacheRaw = new Array(6).fill(0).map(() => {
931
- return new Array(6);
932
- });
933
- var puzzleOrientationCacheInitialized = false;
934
- function puzzleOrientationCache() {
935
- if (!puzzleOrientationCacheInitialized) {
936
- {
937
- const uAlgs = ["", "z", "x", "z'", "x'", "x2"].map((s) => Alg.fromString(s));
938
- const yAlg = new Alg("y");
939
- for (const uAlg of uAlgs) {
940
- let transformation = experimental3x3x3KPuzzle.algToTransformation(uAlg);
941
- for (let i = 0; i < 4; i++) {
942
- transformation = transformation.applyAlg(yAlg);
943
- const [idxU, idxL] = puzzleOrientationIdx(transformation.toKState());
944
- puzzleOrientationCacheRaw[idxU][idxL] = transformation.invert();
945
- }
946
- }
947
- }
948
- }
949
- return puzzleOrientationCacheRaw;
950
- }
951
- function normalizePuzzleOrientation(state) {
952
- const [idxU, idxL] = puzzleOrientationIdx(state);
953
- const orientationTransformation = puzzleOrientationCache()[idxU][idxL];
954
- return state.applyTransformation(orientationTransformation);
955
- }
956
- function reorientPuzzle(state, idxU, idxL) {
957
- return state.applyTransformation(puzzleOrientationCache()[idxU][idxL].invert());
958
- }
959
-
960
- // src/cubing/protocol/binary/binary3x3x3.ts
961
- var BIT_LENGTHS = [29, 12, 16, 13, 3, 2, 1, 12];
962
- function arraySum(arr) {
963
- let total = 0;
964
- for (const entry of arr) {
965
- total += entry;
966
- }
967
- return total;
968
- }
969
- function splitBinary(bitLengths, buffy) {
970
- const u8buffy = new Uint8Array(buffy);
971
- let at = 0;
972
- let bits = 0;
973
- let accum = 0;
974
- const values = [];
975
- for (const bitLength of bitLengths) {
976
- while (bits < bitLength) {
977
- accum = accum << 8 | u8buffy[at++];
978
- bits += 8;
979
- }
980
- values.push(accum >> bits - bitLength & (1 << bitLength) - 1);
981
- bits -= bitLength;
982
- }
983
- return values;
984
- }
985
- function concatBinary(bitLengths, values) {
986
- const buffy = new Uint8Array(Math.ceil(arraySum(bitLengths) / 8));
987
- let at = 0;
988
- let bits = 0;
989
- let accum = 0;
990
- for (let i = 0; i < bitLengths.length; i++) {
991
- accum = accum << bitLengths[i] | values[i];
992
- bits += bitLengths[i];
993
- while (bits >= 8) {
994
- buffy[at++] = accum >> bits - 8;
995
- bits -= 8;
996
- }
997
- }
998
- if (bits > 0) {
999
- buffy[at++] = accum << 8 - bits;
1000
- }
1001
- return buffy;
1002
- }
1003
- function supportsPuzzleOrientation(components) {
1004
- return components.poIdxU !== 7;
1005
- }
1006
- function reid3x3x3ToBinaryComponents(state) {
1007
- const normedState = normalizePuzzleOrientation(state);
1008
- const epLex = permutationToLex(normedState.stateData["EDGES"].pieces);
1009
- const eoMask = orientationsToMask(2, normedState.stateData["EDGES"].orientation);
1010
- const cpLex = permutationToLex(normedState.stateData["CORNERS"].pieces);
1011
- const coMask = orientationsToMask(3, normedState.stateData["CORNERS"].orientation);
1012
- const [poIdxU, poIdxL] = puzzleOrientationIdx(state);
1013
- const moSupport = 1;
1014
- const moMask = orientationsToMask(4, normedState.stateData["CENTERS"].orientation);
1015
- return {
1016
- epLex,
1017
- eoMask,
1018
- cpLex,
1019
- coMask,
1020
- poIdxU,
1021
- poIdxL,
1022
- moSupport,
1023
- moMask
1024
- };
1025
- }
1026
- function binaryComponentsToTwizzleBinary(components) {
1027
- const { epLex, eoMask, cpLex, coMask, poIdxU, poIdxL, moSupport, moMask } = components;
1028
- return concatBinary(BIT_LENGTHS, [
1029
- epLex,
1030
- eoMask,
1031
- cpLex,
1032
- coMask,
1033
- poIdxU,
1034
- poIdxL,
1035
- moSupport,
1036
- moMask
1037
- ]);
1038
- }
1039
- function reid3x3x3ToTwizzleBinary(state) {
1040
- const components = reid3x3x3ToBinaryComponents(state);
1041
- return binaryComponentsToTwizzleBinary(components);
1042
- }
1043
- function twizzleBinaryToBinaryComponents(buffer) {
1044
- const [epLex, eoMask, cpLex, coMask, poIdxU, poIdxL, moSupport, moMask] = splitBinary(BIT_LENGTHS, buffer);
1045
- return {
1046
- epLex,
1047
- eoMask,
1048
- cpLex,
1049
- coMask,
1050
- poIdxU,
1051
- poIdxL,
1052
- moSupport,
1053
- moMask
1054
- };
1055
- }
1056
- function binaryComponentsToReid3x3x3(components) {
1057
- if (components.moSupport !== 1) {
1058
- throw new Error("Must support center orientation.");
1059
- }
1060
- const normedState = new KState(experimental3x3x3KPuzzle, {
1061
- EDGES: {
1062
- pieces: lexToPermutation(12, components.epLex),
1063
- orientation: maskToOrientations(2, 12, components.eoMask)
1064
- },
1065
- CORNERS: {
1066
- pieces: lexToPermutation(8, components.cpLex),
1067
- orientation: maskToOrientations(3, 8, components.coMask)
1068
- },
1069
- CENTERS: {
1070
- pieces: identityPermutation(6),
1071
- orientation: maskToOrientations(4, 6, components.moMask)
1072
- }
1073
- });
1074
- if (!supportsPuzzleOrientation(components)) {
1075
- return normedState;
1076
- }
1077
- return reorientPuzzle(normedState, components.poIdxU, components.poIdxL);
1078
- }
1079
- function validateComponents(components) {
1080
- const errors = [];
1081
- if (components.epLex < 0 || components.epLex >= 479001600) {
1082
- errors.push(`epLex (${components.epLex}) out of range`);
1083
- }
1084
- if (components.cpLex < 0 || components.cpLex >= 40320) {
1085
- errors.push(`cpLex (${components.cpLex}) out of range`);
1086
- }
1087
- if (components.coMask < 0 || components.coMask >= 6561) {
1088
- errors.push(`coMask (${components.coMask}) out of range`);
1089
- }
1090
- if (components.poIdxU < 0 || components.poIdxU >= 6) {
1091
- if (supportsPuzzleOrientation(components)) {
1092
- errors.push(`poIdxU (${components.poIdxU}) out of range`);
1093
- }
1094
- }
1095
- if (components.eoMask < 0 || components.eoMask >= 4096) {
1096
- errors.push(`eoMask (${components.eoMask}) out of range`);
1097
- }
1098
- if (components.moMask < 0 || components.moMask >= 4096) {
1099
- errors.push(`moMask (${components.moMask}) out of range`);
1100
- }
1101
- if (components.poIdxL < 0 || components.poIdxL >= 4) {
1102
- errors.push(`poIdxL (${components.poIdxL}) out of range`);
1103
- }
1104
- if (components.moSupport < 0 || components.moSupport >= 2) {
1105
- errors.push(`moSupport (${components.moSupport}) out of range`);
1106
- }
1107
- return errors;
1108
- }
1109
- function twizzleBinaryToReid3x3x3(buffy) {
1110
- const components = twizzleBinaryToBinaryComponents(buffy);
1111
- const errors = validateComponents(components);
1112
- if (errors.length !== 0) {
1113
- throw new Error(`Invalid binary state components: ${errors.join(", ")}`);
1114
- }
1115
- return binaryComponentsToReid3x3x3(components);
1116
- }
1117
-
1118
- // src/cubing/protocol/binary/hex.ts
1119
- function bufferToSpacedHex(buffer) {
1120
- return Array.prototype.map.call(new Uint8Array(buffer), (x) => ("00" + x.toString(16)).slice(-2)).join(" ");
1121
- }
1122
- function spacedHexToBuffer(hex) {
1123
- return new Uint8Array(hex.split(" ").map((c) => parseInt(c, 16)));
1124
- }
1125
-
1126
514
  export {
1127
- normalizePuzzleOrientation,
1128
- reid3x3x3ToTwizzleBinary,
1129
- twizzleBinaryToBinaryComponents,
1130
- binaryComponentsToReid3x3x3,
1131
- twizzleBinaryToReid3x3x3,
1132
- bufferToSpacedHex,
1133
- spacedHexToBuffer,
1134
515
  KState,
1135
516
  KTransformation,
1136
- KPuzzle,
1137
- experimental3x3x3KPuzzle
517
+ KPuzzle
1138
518
  };
1139
- //# sourceMappingURL=chunk-HD2CMNE4.js.map
519
+ //# sourceMappingURL=chunk-GNKVWDWW.js.map