@fgv/ts-sudoku-lib 5.0.0-9 → 5.0.1-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.
Files changed (49) hide show
  1. package/CHANGELOG.json +9 -3
  2. package/dist/tsdoc-metadata.json +1 -1
  3. package/eslint.config.js +16 -0
  4. package/package.json +21 -21
  5. package/CHANGELOG.md +0 -106
  6. package/lib/index.d.ts.map +0 -1
  7. package/lib/index.js.map +0 -1
  8. package/lib/packlets/collections/collections.d.ts.map +0 -1
  9. package/lib/packlets/collections/collections.js.map +0 -1
  10. package/lib/packlets/collections/index.d.ts.map +0 -1
  11. package/lib/packlets/collections/index.js.map +0 -1
  12. package/lib/packlets/common/cage.d.ts.map +0 -1
  13. package/lib/packlets/common/cage.js.map +0 -1
  14. package/lib/packlets/common/cell.d.ts.map +0 -1
  15. package/lib/packlets/common/cell.js.map +0 -1
  16. package/lib/packlets/common/common.d.ts.map +0 -1
  17. package/lib/packlets/common/common.js.map +0 -1
  18. package/lib/packlets/common/converters.d.ts.map +0 -1
  19. package/lib/packlets/common/converters.js.map +0 -1
  20. package/lib/packlets/common/ids.d.ts.map +0 -1
  21. package/lib/packlets/common/ids.js.map +0 -1
  22. package/lib/packlets/common/index.d.ts.map +0 -1
  23. package/lib/packlets/common/index.js.map +0 -1
  24. package/lib/packlets/common/model.d.ts.map +0 -1
  25. package/lib/packlets/common/model.js.map +0 -1
  26. package/lib/packlets/common/public.d.ts.map +0 -1
  27. package/lib/packlets/common/public.js.map +0 -1
  28. package/lib/packlets/common/puzzle.d.ts.map +0 -1
  29. package/lib/packlets/common/puzzle.js.map +0 -1
  30. package/lib/packlets/common/puzzleSession.d.ts.map +0 -1
  31. package/lib/packlets/common/puzzleSession.js.map +0 -1
  32. package/lib/packlets/common/puzzleState.d.ts.map +0 -1
  33. package/lib/packlets/common/puzzleState.js.map +0 -1
  34. package/lib/packlets/file/converters.d.ts.map +0 -1
  35. package/lib/packlets/file/converters.js.map +0 -1
  36. package/lib/packlets/file/index.d.ts.map +0 -1
  37. package/lib/packlets/file/index.js.map +0 -1
  38. package/lib/packlets/file/model.d.ts.map +0 -1
  39. package/lib/packlets/file/model.js.map +0 -1
  40. package/lib/packlets/puzzles/anyPuzzle.d.ts.map +0 -1
  41. package/lib/packlets/puzzles/anyPuzzle.js.map +0 -1
  42. package/lib/packlets/puzzles/index.d.ts.map +0 -1
  43. package/lib/packlets/puzzles/index.js.map +0 -1
  44. package/lib/packlets/puzzles/killerSudokuPuzzle.d.ts.map +0 -1
  45. package/lib/packlets/puzzles/killerSudokuPuzzle.js.map +0 -1
  46. package/lib/packlets/puzzles/sudokuPuzzle.d.ts.map +0 -1
  47. package/lib/packlets/puzzles/sudokuPuzzle.js.map +0 -1
  48. package/lib/packlets/puzzles/sudokuXPuzzle.d.ts.map +0 -1
  49. package/lib/packlets/puzzles/sudokuXPuzzle.js.map +0 -1
package/CHANGELOG.json CHANGED
@@ -1,17 +1,23 @@
1
1
  {
2
2
  "name": "@fgv/ts-sudoku-lib",
3
3
  "entries": [
4
+ {
5
+ "version": "5.0.1",
6
+ "tag": "@fgv/ts-sudoku-lib_v5.0.1",
7
+ "date": "Tue, 23 Sep 2025 03:13:55 GMT",
8
+ "comments": {}
9
+ },
4
10
  {
5
11
  "version": "5.0.0",
6
12
  "tag": "@fgv/ts-sudoku-lib_v5.0.0",
7
- "date": "Thu, 17 Jul 2025 00:13:24 GMT",
13
+ "date": "Tue, 23 Sep 2025 02:54:20 GMT",
8
14
  "comments": {
9
15
  "none": [
10
16
  {
11
- "comment": "upgrade-dependencies"
17
+ "comment": "version updates and minor fixes"
12
18
  },
13
19
  {
14
- "comment": "bump version"
20
+ "comment": "update rushstack"
15
21
  }
16
22
  ]
17
23
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.49.1"
8
+ "packageVersion": "7.52.12"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,16 @@
1
+ // ESLint 9 flat config
2
+ const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
3
+ const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
4
+ const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
5
+
6
+ module.exports = [
7
+ ...nodeProfile,
8
+ packletsPlugin,
9
+ ...tsdocPlugin,
10
+ {
11
+ // Override specific rules if needed
12
+ rules: {
13
+ '@rushstack/packlets/mechanics': 'warn'
14
+ }
15
+ }
16
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-sudoku-lib",
3
- "version": "5.0.0-9",
3
+ "version": "5.0.1-0",
4
4
  "description": "Sudoku rules library",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-sudoku-lib.d.ts",
@@ -16,39 +16,39 @@
16
16
  "homepage": "https://github.com/ErikFortune/fgv/libraries/ts-sudoku-lib#readme",
17
17
  "sideEffects": false,
18
18
  "devDependencies": {
19
- "@microsoft/api-documenter": "^7.26.29",
20
- "@microsoft/api-extractor": "^7.49.1",
19
+ "@microsoft/api-documenter": "^7.26.31",
20
+ "@microsoft/api-extractor": "^7.52.10",
21
21
  "@types/jest": "^29.5.14",
22
22
  "@types/node": "^20.14.9",
23
- "@typescript-eslint/eslint-plugin": "^7.14.1",
24
- "@typescript-eslint/parser": "^7.14.1",
23
+ "@typescript-eslint/eslint-plugin": "^8.42.0",
24
+ "@typescript-eslint/parser": "^8.42.0",
25
25
  "cspell": "^8.3.2",
26
- "eslint": "^8.57.0",
27
- "eslint-config-prettier": "^10.1.5",
26
+ "eslint": "^9.35.0",
27
+ "eslint-config-prettier": "^10.1.8",
28
28
  "eslint-plugin-header": "^3.1.1",
29
29
  "eslint-plugin-import": "^2.32.0",
30
30
  "eslint-plugin-node": "^11.1.0",
31
- "eslint-plugin-prettier": "^5.5.1",
32
- "eslint-plugin-promise": "^6.2.0",
31
+ "eslint-plugin-prettier": "^5.5.4",
32
+ "eslint-plugin-promise": "^7.2.1",
33
33
  "jest": "^29.7.0",
34
34
  "prettier": "^3.6.2",
35
- "rimraf": "^5.0.7",
36
- "ts-jest": "^29.4.0",
35
+ "rimraf": "^6.0.1",
36
+ "ts-jest": "^29.4.1",
37
37
  "ts-node": "^10.9.2",
38
- "typescript": "^5.7.3",
39
- "eslint-plugin-n": "^16.6.2",
40
- "@rushstack/heft": "~0.74.0",
41
- "@rushstack/heft-node-rig": "~2.9.0",
38
+ "typescript": "5.8.3",
39
+ "eslint-plugin-n": "^17.21.3",
40
+ "@rushstack/heft": "0.74.4",
41
+ "@rushstack/heft-node-rig": "2.9.5",
42
42
  "@types/heft-jest": "1.0.6",
43
- "@rushstack/eslint-config": "~4.4.0",
44
- "@rushstack/heft-jest-plugin": "~0.16.9",
43
+ "@rushstack/eslint-config": "4.4.0",
44
+ "@rushstack/heft-jest-plugin": "0.16.13",
45
45
  "eslint-plugin-tsdoc": "~0.4.0",
46
- "@fgv/ts-utils": "5.0.0-9",
47
- "@fgv/ts-utils-jest": "5.0.0-9",
48
- "@fgv/ts-json-base": "5.0.0-9"
46
+ "@fgv/ts-utils": "5.0.1-0",
47
+ "@fgv/ts-utils-jest": "5.0.1-0",
48
+ "@fgv/ts-json-base": "5.0.1-0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@fgv/ts-utils": "5.0.0-9"
51
+ "@fgv/ts-utils": "5.0.1-0"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "heft build --clean",
package/CHANGELOG.md DELETED
@@ -1,106 +0,0 @@
1
- # Change Log - @fgv/ts-sudoku-lib
2
-
3
- This log was last generated on Thu, 17 Jul 2025 00:13:24 GMT and should not be manually modified.
4
-
5
- ## 5.0.0
6
- Thu, 17 Jul 2025 00:13:24 GMT
7
-
8
- ### Updates
9
-
10
- - upgrade-dependencies
11
- - bump version
12
-
13
- ## 4.6.0
14
- Wed, 02 Jul 2025 05:48:16 GMT
15
-
16
- _Version update only_
17
-
18
- ## 4.5.1
19
- Wed, 02 Jul 2025 05:47:11 GMT
20
-
21
- ### Updates
22
-
23
- - update rushstack
24
-
25
- ## 4.5.0
26
- Tue, 01 Jul 2025 03:26:11 GMT
27
-
28
- ### Patches
29
-
30
- - Fix redundant conditional logic in updateCellValue and updateCellNotes methods that called identical functions in both branches of ternary operator
31
- - Fix incorrect TypeScript declaration file reference and build script in package.json
32
-
33
- ## 4.4.0
34
- Sat, 01 Feb 2025 17:13:10 GMT
35
-
36
- _Version update only_
37
-
38
- ## 4.3.0
39
- Thu, 30 Jan 2025 00:35:17 GMT
40
-
41
- _Version update only_
42
-
43
- ## 4.2.2
44
- Thu, 23 Jan 2025 06:19:32 GMT
45
-
46
- _Version update only_
47
-
48
- ## 4.2.1
49
- Tue, 21 Jan 2025 04:19:21 GMT
50
-
51
- _Version update only_
52
-
53
- ## 4.2.0
54
- Mon, 20 Jan 2025 09:46:53 GMT
55
-
56
- _Version update only_
57
-
58
- ## 4.1.0
59
- Thu, 09 Jan 2025 05:33:39 GMT
60
-
61
- ### Updates
62
-
63
- - update dependencies
64
-
65
- ## 4.0.2
66
- Tue, 14 May 2024 14:45:53 GMT
67
-
68
- _Version update only_
69
-
70
- ## 4.0.1
71
- Tue, 14 May 2024 05:02:20 GMT
72
-
73
- ### Updates
74
-
75
- - publish
76
-
77
- ## 4.0.0
78
- Tue, 14 May 2024 03:09:27 GMT
79
-
80
- ### Updates
81
-
82
- - update dependencies
83
- - update generated api docs
84
-
85
- ## 3.0.0
86
- Mon, 22 Jan 2024 07:00:18 GMT
87
-
88
- ### Updates
89
-
90
- - bump versions
91
- - refactor
92
- - initial checkin
93
- - Match ts-utils refactor
94
- - update dependencies
95
-
96
- ## 2.2.0
97
- Thu, 18 Jan 2024 05:45:04 GMT
98
-
99
- ### Updates
100
-
101
- - bump versions
102
- - refactor
103
- - initial checkin
104
- - Match ts-utils refactor
105
- - update dependencies
106
-
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC"}
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAAwC;AAK/B,oBAAI;AAJb,4DAA8C;AAI/B,0BAAO;AAFtB,yDAAuC;AACvC,oDAAkC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as File from './packlets/file';\nimport * as Puzzles from './packlets/puzzles';\n\nexport * from './packlets/collections';\nexport * from './packlets/common';\nexport { File, Puzzles };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/collections.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG9D;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,SAAgB,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAEvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkC;IAExD,OAAO;IASP;;;;;OAKG;WACW,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAIjF;;;;;OAKG;WACW,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAI1D;;;;;OAKG;IACI,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;IAUnD;;;;;OAKG;IACI,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,kBAAkB,CAAC;CAO9D;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2C;IAElE;;OAEG;IACH,WAAkB,OAAO,IAAI,gBAAgB,CAQ5C;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collections.js","sourceRoot":"","sources":["../../../src/packlets/collections/collections.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;AACpC,oDAAsC;AAEtC,4CAAqE;AAErE,sCAA8D;AAC9D,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AA,eAAI,EAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;CACF;AAlED,4CAkEC;AAED;;;GAGG;AACH,MAAa,iBAAiB;IAG5B;;OAEG;IACI,MAAM,KAAK,OAAO;QACvB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;YAChC,iBAAiB,CAAC,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,WAAW;iBACzD,OAAO,CAAC,sBAAc,CAAC;iBACvB,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC;iBAClC,OAAO,EAAE,CAAC;QACf,CAAC;QACD,OAAO,iBAAiB,CAAC,QAAQ,CAAC;IACpC,CAAC;;AAdH,8CAeC;AAdgB,0BAAQ,GAAiC,SAAS,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as FileData from '../file';\nimport * as Puzzles from '../puzzles';\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\n\nimport { IPuzzleDescription, PuzzleSession } from '../common';\nimport DefaultPuzzles from './data/puzzles.json';\n\n/**\n * A collection of puzzles of various types.\n * @public\n */\nexport class PuzzleCollection {\n /**\n * All puzzles in the collection.\n */\n public readonly puzzles: readonly IPuzzleDescription[];\n\n private readonly _byId: Map<string, IPuzzleDescription>;\n\n private constructor(puzzles: FileData.Model.IPuzzlesFile) {\n this.puzzles = puzzles.puzzles;\n this._byId = new Map(\n this.puzzles\n .map((p): [string | undefined, IPuzzleDescription] => [p.id, p])\n .filter((p): p is [string, IPuzzleDescription] => p !== undefined)\n );\n }\n\n /**\n * Creates a new puzzle from a loaded {@link File.Model.IPuzzlesFile | PuzzlesFile}\n * @param from - The {@link File.Model.IPuzzlesFile | puzzles file} to be loaded.\n * @returns `Success` with the resulting {@link PuzzleCollection | PuzzleCollection}\n * or `Failure` with details if an error occurs.\n */\n public static create(from: FileData.Model.IPuzzlesFile): Result<PuzzleCollection> {\n return captureResult(() => new PuzzleCollection(from));\n }\n\n /**\n * Creates a new puzzle from a JSON file.\n * @param path - path to the JSON file to be loaded.\n * @returns `Success` with the resulting {@link PuzzleCollection | PuzzleCollection}\n * or `Failure` with details if an error occurs.\n */\n public static load(path: string): Result<PuzzleCollection> {\n return FileData.Converters.loadJsonPuzzlesFileSync(path).onSuccess(PuzzleCollection.create);\n }\n\n /**\n * Gets a puzzle by id from this collection.\n * @param id - The string ID of the puzzle to be returned.\n * @returns `Success` with the requested {@link PuzzleSession | puzzle}, or\n * `Failure` with details if an error occurs.\n */\n public getPuzzle(id: string): Result<PuzzleSession> {\n return this.getDescription(id)\n .onSuccess((desc) => {\n return Puzzles.Any.create(desc);\n })\n .onSuccess((puzzle) => {\n return PuzzleSession.create(puzzle);\n });\n }\n\n /**\n * Gets a puzzle by id from this collection.\n * @param id - The string ID of the puzzle to be returned.\n * @returns `Success` with the requested {@link PuzzleSession | puzzle}, or\n * `Failure` with details if an error occurs.\n */\n public getDescription(id: string): Result<IPuzzleDescription> {\n const desc = this._byId.get(id);\n if (!desc) {\n return fail(`Puzzle \"${id}\" not found`);\n }\n return succeed(desc);\n }\n}\n\n/**\n * Get well-known {@link PuzzleCollection | puzzle collections}.\n * @public\n */\nexport class PuzzleCollections {\n private static _default: PuzzleCollection | undefined = undefined;\n\n /**\n * The default {@link PuzzleCollection | puzzle collection}.\n */\n public static get default(): PuzzleCollection {\n if (!PuzzleCollections._default) {\n PuzzleCollections._default = FileData.Converters.puzzlesFile\n .convert(DefaultPuzzles)\n .onSuccess(PuzzleCollection.create)\n .orThrow();\n }\n return PuzzleCollections._default;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/index.ts"],"names":[],"mappings":"AAwBA,cAAc,eAAe,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/collections/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;AAEH,gDAA8B","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './collections';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cage.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/cage.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,qBAAa,IAAK,YAAW,KAAK;IAChC,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IACnC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAE9B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACtC,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO;IAQP,IAAW,OAAO,IAAI,MAAM,EAAE,CAE7B;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;WAEa,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAIvF,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIjC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO;IAY5E,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC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BAAN,MAAM,CAAE,QAAQ,CAAC,MAAM,CAAC,CAAA,EAAE,CAAC;gBAC9B,8DAA8D;gBAC9D,IAAI,CAAA,MAAA,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,0CAAE,KAAK,MAAK,KAAK,EAAE,CAAC;oBAC/D,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,eAAe,CAAC,KAAkB;;QACvC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;QACjC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,8DAA8D;YAC9D,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,0CAAE,KAAK,CAAC;YAC/D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,QAAQ,CAAC,KAAmB;QACjC,OAAO,IAAI,CAAC,QAAQ;aACjB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;;YACV,8DAA8D;YAC9D,MAAM,KAAK,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,0CAAE,KAAK,CAAC;YAC5D,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACrC,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;CACF;AAjED,oBAiEC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport { CageId, CageType, CellId } from './common';\nimport { ICage } from './public';\nimport { PuzzleState } from './puzzleState';\n\n/**\n * @internal\n */\nexport class Cage implements ICage {\n public readonly id: CageId;\n public readonly cageType: CageType;\n public readonly total: number;\n\n protected readonly _cellIds: CellId[];\n private _values: Set<number>;\n\n private constructor(id: CageId, type: CageType, total: number, cells: CellId[]) {\n this.id = id;\n this.cageType = type;\n this.total = total;\n this._cellIds = Array.from(cells);\n this._values = new Set();\n }\n\n public get cellIds(): CellId[] {\n return Array.from(this._cellIds);\n }\n\n public get numCells(): number {\n return this._cellIds.length;\n }\n\n public static create(id: CageId, type: CageType, total: number, cells: CellId[]): Result<Cage> {\n return captureResult(() => new Cage(id, type, total, cells));\n }\n\n public containsCell(id: CellId): boolean {\n return this._cellIds.includes(id);\n }\n\n public containsValue(value: number, state: PuzzleState, ignore?: CellId[]): boolean {\n for (const cellId of this._cellIds) {\n if (!ignore?.includes(cellId)) {\n /* c8 ignore next - defense in depth, ? should never happen */\n if (state.getCellContents(cellId).orDefault()?.value === value) {\n return true;\n }\n }\n }\n return false;\n }\n\n public containedValues(state: PuzzleState): Set<number> {\n const values = new Set<number>();\n for (const cellId of this._cellIds) {\n /* c8 ignore next - defense in depth, ? should never happen */\n const value = state.getCellContents(cellId).orDefault()?.value;\n if (value !== undefined) {\n values.add(value);\n }\n }\n return values;\n }\n\n public toString(state?: PuzzleState): string {\n return this._cellIds\n .map((id) => {\n /* c8 ignore next - defense in depth, ? should never happen */\n const value = state?.getCellContents(id).orDefault()?.value;\n return value ? String(value) : '.';\n })\n .join('');\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/cell.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAiB,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,IAAK,YAAW,SAAS,EAAE,KAAK;IAC3C,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAEvC,SAAgB,SAAS,EAAE,OAAO,CAAC;IACnC,SAAgB,cAAc,CAAC,EAAE,MAAM,CAAC;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CAAC,CAAC;IACL,CAAC;IAEM,WAAW,CAAC,KAAyB,EAAE,KAAkB;QAC9D,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,QAAuB,EAAE,EAAE;YAC1E,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,WAAW,CAAC,KAAe,EAAE,KAAkB;QACpD,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,QAAuB,EAAE,EAAE;YAC1E,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,QAAQ,CAAC,KAAmB;;QACjC,MAAM,QAAQ,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC;QAC7D,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,cAAc,mCAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,CAAC;QACrD,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACjE,CAAC;CACF;AAxED,oBAwEC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, fail, succeed } from '@fgv/ts-utils';\nimport { Cage } from './cage';\nimport { CellId, ICellContents, ICellState } from './common';\nimport { ICell } from './public';\nimport { PuzzleState } from './puzzleState';\n\n/**\n * @internal\n */\nexport interface ICellInit {\n readonly id: CellId;\n readonly row: number;\n readonly col: number;\n readonly immutableValue?: number;\n}\n\n/**\n * @internal\n */\nexport class Cell implements ICellInit, ICell {\n public readonly id: CellId;\n public readonly row: number;\n public readonly col: number;\n public readonly cages: readonly Cage[];\n\n public readonly immutable: boolean;\n public readonly immutableValue?: number;\n\n public constructor(init: ICellInit, cages: readonly Cage[]) {\n this.id = init.id;\n this.row = init.row;\n this.col = init.col;\n this.cages = [...cages];\n this.immutableValue = init.immutableValue;\n this.immutable = init.immutableValue !== undefined;\n }\n\n public isValid(state: PuzzleState): boolean {\n if (this.immutable) {\n return true;\n }\n const cell = state.getCellContents(this.id).orDefault();\n return cell !== undefined && this.isValidValue(cell.value, state);\n }\n\n public hasValue(state: PuzzleState): boolean {\n if (this.immutable) {\n return true;\n }\n const cell = state.getCellContents(this.id).orDefault();\n /* c8 ignore next - defense in depth ? should never happen */\n return cell?.value !== undefined;\n }\n\n public isValidValue(value: number | undefined, state: PuzzleState): boolean {\n if (this.immutable) {\n return false;\n } else if (value === undefined) {\n return true;\n }\n return !this.cages.find((cage) => cage.containsValue(value, state, [this.id]));\n }\n\n public update(value: number | undefined, notes: number[]): Result<ICellState> {\n if (this.immutable) {\n return fail(`cannot set value \"${value}\" in immutable cell ${this.id}`);\n }\n return succeed({\n id: this.id,\n value,\n notes\n });\n }\n\n public updateValue(value: number | undefined, state: PuzzleState): Result<ICellState> {\n return state.getCellContents(this.id).onSuccess((contents: ICellContents) => {\n return this.update(value, contents.notes);\n });\n }\n\n public updateNotes(notes: number[], state: PuzzleState): Result<ICellState> {\n return state.getCellContents(this.id).onSuccess((contents: ICellContents) => {\n return this.update(contents.value, notes);\n });\n }\n\n public toString(state?: PuzzleState): string {\n const contents = state?.getCellContents(this.id).orDefault();\n const value = this.immutableValue ?? contents?.value;\n return value && value >= 1 && value <= 9 ? String(value) : '.';\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/common.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,GAAG,GAAG,QAAQ,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AAEH,MAAM,WAAW,U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E,EAAE,GAAG,EAAE,EAAE,EAAE;IACpB,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IACpB,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;CACrB,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Brand } from '@fgv/ts-utils';\n\n/**\n * Nominal identifier for a single {@Link ICell | cell} in a {@link PuzzleSession | puzzle}.\n * @public\n */\nexport type CellId = Brand<string, 'CellId'>;\n\n/**\n * Nominal identifier for a single {@Link ICage | cage} in a {@link PuzzleSession | puzzle}.\n * @public\n */\nexport type CageId = Brand<string, 'CageId'>;\n\n/**\n * Identifies the type of a {@Link ICage | cage}.\n * @public\n */\nexport type CageType = 'row' | 'column' | 'section' | 'x' | 'killer';\n\n/**\n * The row/column coordinate of a single {@Link ICell | cell} in a {@link PuzzleSession | puzzle}.\n * @public\n */\nexport interface IRowColumn {\n row: number;\n col: number;\n}\n\n/**\n * The contents of a single {@Link ICell | cell} in a {@link PuzzleSession | puzzle}.\n * @public\n */\nexport interface ICellContents {\n /**\n * The value of the {@link ICell | cell}, or `undefined` if no value has been assigned.\n */\n readonly value?: number;\n /**\n * Any notes associated with the {@link ICell | cell}.\n */\n readonly notes: number[];\n}\n\n/**\n * Describes the state of or a state update for a single {@link ICell |cell} in a\n * {@link PuzzleSession | puzzle}.\n * @public\n */\n\nexport interface ICellState extends ICellContents {\n readonly id: CellId;\n}\n\n/**\n * Describes the rules that apply to the puzzle.\n * @public\n */\nexport type PuzzleType = 'killer-sudoku' | 'sudoku' | 'sudoku-x';\n\n/**\n * All supported public types.\n * @public\n */\nexport const allPuzzleTypes: PuzzleType[] = ['killer-sudoku', 'sudoku', 'sudoku-x'];\n\n/**\n * The minimum and maximum possible values for a {@link ICage | cage}, by cage size in\n * {@link ICell | cells}.\n * @public\n */\nexport const totalsByCageSize: readonly { min: number; max: number }[] = [\n { min: 0, max: 0 },\n { min: 1, max: 9 },\n { min: 3, max: 17 },\n { min: 6, max: 24 },\n { min: 10, max: 30 },\n { min: 15, max: 35 },\n { min: 21, max: 39 },\n { min: 28, max: 42 },\n { min: 36, max: 44 },\n { min: 45, max: 45 }\n];\n\n/**\n * Navigation direction within a puzzle.\n * @public\n *\n */\nexport type NavigationDirection = 'down' | 'left' | 'right' | 'up';\n\n/**\n * Wrapping rules when navigating within a puzzle.\n * @public\n */\nexport type NavigationWrap = 'none' | 'wrap-around' | 'wrap-next';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/converters.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAqC,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAkB,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;A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GAGG;AACU,QAAA,UAAU,GAGnB,qBAAU,CAAC,eAAe,CAAa,uBAAc,CAAC,CAAC;AAE3D;;;GAGG;AACU,QAAA,iBAAiB,GAAkC,qBAAU,CAAC,YAAY,CACrF;IACE,EAAE,EAAE,qBAAU,CAAC,MAAM;IACrB,WAAW,EAAE,qBAAU,CAAC,MAAM;IAC9B,IAAI,EAAE,kBAAU;IAChB,KAAK,EAAE,qBAAU,CAAC,MAAM;IACxB,IAAI,EAAE,qBAAU,CAAC,MAAM;IACvB,IAAI,EAAE,qBAAU,CAAC,MAAM;IACvB,KAAK,EAAE,qBAAU,CAAC,KAAK,CAAC,CAAC,qBAAU,CAAC,MAAM,EAAE,qBAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,kBAAO,EAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CACrG,EACD;IACE,cAAc,EAAE,CAAC,IAAI,CAAC;CACvB,CACF,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converter, Converters, Result, fail, succeed } from '@fgv/ts-utils';\nimport { CageId, CellId, PuzzleType, allPuzzleTypes } from './common';\nimport { IPuzzleDescription } from './model';\n\nconst cageIdRegExp: RegExp = /^(R[A-Z]$)|(C[0-9]$)|(S[A-Z][0-9]$)|(X[1-2]$)|(K[A-Za-z]$)/;\n\nfunction validateCageId(from: string): Result<CageId> {\n if (cageIdRegExp.test(from)) {\n return succeed(from as CageId);\n }\n return fail(`malformed cage ID \"${from}\" (expected \"R[A-Z]\", \"C[0-9]\" or \"S[A-Z][0-9]\")`);\n}\n\nconst cellIdRegExp: RegExp = /^[A-Z][0-9]$/;\nfunction validateCellId(from: string): Result<CellId> {\n if (cellIdRegExp.test(from)) {\n return succeed(from as CellId);\n }\n return fail(`malformed cell ID \"${from}\" (expected \"[A-Z][0-9]\")`);\n}\n\n/**\n * Converts an arbitrary value to a {@link CageId | CageId}.\n * @public\n */\nexport const cageId: Converter<CageId> = Converters.string.map(validateCageId);\n\n/**\n * Converts an arbitrary value to a {@link CellId | CellId}.\n * @public\n */\nexport const cellId: Converter<CellId> = Converters.string.map(validateCellId);\n\n/**\n * Converts an arbitrary value to a {@link PuzzleType | PuzzleType}.\n * @public\n */\nexport const puzzleType: Converter<\n PuzzleType,\n ReadonlyArray<PuzzleType>\n> = Converters.enumeratedValue<PuzzleType>(allPuzzleTypes);\n\n/**\n * Converts an arbitrary object to a {@link IPuzzleDescription | IPuzzleDescription}.\n * @public\n */\nexport const puzzleDescription: Converter<IPuzzleDescription> = Converters.strictObject<IPuzzleDescription>(\n {\n id: Converters.string,\n description: Converters.string,\n type: puzzleType,\n level: Converters.number,\n rows: Converters.number,\n cols: Converters.number,\n cells: Converters.oneOf([Converters.string, Converters.stringArray.map((s) => succeed(s.join('')))])\n },\n {\n optionalFields: ['id']\n }\n);\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/ids.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AASxC;;GAEG;AACH,qBAAa,GAAG;WACA,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;WAO5C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;WAYzD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;WAI9B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;WAIjC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;WAQ/C,OAAO,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,CAAC;CAiBpB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/packlets/common/ids.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAsD;AAEtD,yDAA2C;AAG3C,MAAM,cAAc,GAAW,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACjD,MAAM,cAAc,GAAW,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAEjD,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IA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G,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9B,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,IAAI,MAAM,CAAC,YAAY,CAAC,cAAc,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,YAAY,CACxE,cAAc,GAAG,GAAG,CACrB,EAAY,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,OAAO,CACnB,QAAgB,EAChB,OAAe,EACf,QAAgB,EAChB,OAAe;QAEf,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,IAAI,GAAG,GAAG,QAAQ,EAAE,GAAG,GAAG,QAAQ,GAAG,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;YACzD,KAAK,IAAI,GAAG,GAAG,QAAQ,EAAE,GAAG,GAAG,QAAQ,GAAG,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;gBACzD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE;oBACxD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACjB,OAAO,IAAA,kBAAO,EAAC,EAAE,CAAC,CAAC;gBACrB,CAAC,CAAC,CAAC;gBAEH,2DAA2D;gBAC3D,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;oBACvB,OAAO,IAAA,eAAI,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AA1DD,kBA0DC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, fail, succeed } from '@fgv/ts-utils';\nimport { CageId, CellId, IRowColumn } from './common';\nimport * as Converters from './converters';\nimport { ICage, ICell } from './public';\n\nconst firstRowIdChar: number = 'A'.charCodeAt(0);\nconst firstColIdChar: number = '1'.charCodeAt(0);\n\nfunction isRowColumn(from: unknown): from is IRowColumn {\n return typeof from === 'object' && from !== null && 'row' in from && `col` in from;\n}\n\n/**\n * @public\n */\nexport class Ids {\n public static cageId(from: string | ICage): Result<CageId> {\n if (typeof from === 'string') {\n return Converters.cageId.convert(from);\n }\n return succeed(from.id);\n }\n\n public static cellId(spec: string | IRowColumn | ICell): Result<CellId> {\n if (isRowColumn(spec)) {\n if ('id' in spec) {\n return succeed(spec.id);\n }\n const row = String.fromCharCode(firstRowIdChar + spec.row);\n const col = String.fromCharCode(firstColIdChar + spec.col);\n return succeed(`${row}${col}` as CellId);\n }\n return Converters.cellId.convert(spec);\n }\n\n public static rowCageId(row: number): CageId {\n return `R${String.fromCharCode(firstRowIdChar + row)}` as CageId;\n }\n\n public static columnCageId(col: number): CageId {\n return `C${String.fromCharCode(firstColIdChar + col)}` as CageId;\n }\n\n public static sectionCageId(row: number, col: number): CageId {\n row = Math.floor(row / 3) * 3;\n col = Math.floor(col / 3) * 3;\n return `S${String.fromCharCode(firstRowIdChar + row)}${String.fromCharCode(\n firstColIdChar + col\n )}` as CageId;\n }\n\n public static cellIds(\n firstRow: number,\n numRows: number,\n firstCol: number,\n numCols: number\n ): Result<CellId[]> {\n const cellIds: CellId[] = [];\n for (let row = firstRow; row < firstRow + numRows; row++) {\n for (let col = firstCol; col < firstCol + numCols; col++) {\n const result = this.cellId({ row, col }).onSuccess((id) => {\n cellIds.push(id);\n return succeed(id);\n });\n\n /* c8 ignore next 3 - defense in depth should not happen */\n if (result.isFailure()) {\n return fail(result.message);\n }\n }\n }\n return succeed(cellIds);\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/common/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAA2C;AAYlC,gCAAU;AAVnB,yCAAuB;AACvB,yCAAuB;AACvB,2CAAyB;AACzB,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,gDAA8B","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './converters';\n\nexport * from './cage';\nexport * from './cell';\nexport * from './common';\nexport { Ids } from './ids';\nexport * from './model';\nexport * from './public';\nexport * from './puzzle';\nexport * from './puzzleSession';\nexport * from './puzzleState';\n\nexport { Converters };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/model.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/packlets/common/model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { PuzzleType } from './common';\n\n/**\n * Description of a single puzzle.\n * @public\n */\nexport interface IPuzzleDescription {\n id?: string;\n description: string;\n type: PuzzleType;\n level: number;\n rows: number;\n cols: number;\n cells: string;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/public.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/packlets/common/public.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { CageId, CageType, CellId } from './common';\n\n/**\n * Describes the structure of a single cage in a {@link PuzzleSession | puzzle}.\n * Does not describe state.\n * @public\n */\nexport interface ICage {\n /**\n * Unique identifier for the cage.\n */\n readonly id: CageId;\n\n /**\n * The {@link CageType | type} of the cage.\n */\n readonly cageType: CageType;\n\n /**\n * The expected sum of all cells in the cage.\n */\n readonly total: number;\n\n /**\n * The number of cells in the cage.\n */\n readonly numCells: number;\n\n /**\n * The identity of each cell in the cage.\n */\n readonly cellIds: CellId[];\n\n /**\n * Determines if a supplied cell is present in the cage.\n * @param id - the identifier to be searched.\n */\n containsCell(id: CellId): boolean;\n}\n\n/**\n * Describes the structure of a single cell in a {@link PuzzleSession | puzzle}.\n * Does not describe state.\n * @public\n */\nexport interface ICell {\n /**\n * Unique identifier for the cell.\n */\n readonly id: CellId;\n\n /**\n * Row number of the cell.\n */\n readonly row: number;\n\n /**\n * Column number of the cell.\n */\n readonly col: number;\n\n /**\n * All of the {@Link ICage | cages} to which this cell belongs.\n */\n readonly cages: readonly ICage[];\n\n /**\n * Indicates whether this cell is a given value (immutable).\n */\n readonly immutable: boolean;\n\n /**\n * Given value of this cell, or `undefined` if the cell is not immutable.\n */\n readonly immutableValue?: number;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"puzzle.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/puzzle.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAA6B,MAAM,eAAe,CA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AAI,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;gBAC3B,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC3B,GAAG,GAAG,CAAC,CAAC;gBACR,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;oBACzB,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;gBAChE,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAA,eAAI,EAAC,6BAA6B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/B,CAAC;CACF;AA1cD,wBA0cC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, fail, mapResults, succeed } from '@fgv/ts-utils';\nimport {\n CageId,\n CellId,\n ICellContents,\n ICellState,\n IRowColumn,\n NavigationDirection,\n NavigationWrap\n} from './common';\n\nimport { Cage } from './cage';\nimport { Cell } from './cell';\nimport { Ids } from './ids';\nimport { IPuzzleDescription } from './model';\nimport { ICell } from './public';\nimport { PuzzleState } from './puzzleState';\n\nconst basicCageTotal: number = 45;\n\n/**\n * @internal\n */\nexport interface ICellUpdate {\n from: ICellState;\n to: ICellState;\n}\n\n/**\n * @internal\n */\nexport interface IPuzzleUpdate {\n from: PuzzleState;\n to: PuzzleState;\n cells: ICellUpdate[];\n}\n\n/**\n * @internal\n */\nexport class Puzzle {\n public readonly id?: string;\n public readonly description: string;\n public readonly initialState: PuzzleState;\n\n /**\n * @internal\n */\n protected readonly _rows: Map<CageId, Cage>;\n\n /**\n * @internal\n */\n protected readonly _columns: Map<CageId, Cage>;\n\n /**\n * @internal\n */\n protected readonly _sections: Map<CageId, Cage>;\n\n /**\n * @internal\n */\n protected readonly _cages: Map<CageId, Cage>;\n\n /**\n * @internal\n */\n protected readonly _cells: Map<CellId, Cell>;\n\n /**\n * Constructs a new puzzle state.\n * @param puzzle - {@Link IPuzzleDescription | Puzzle description} from which this puzzle state\n * is to be initialized.\n */\n protected constructor(puzzle: IPuzzleDescription, extraCages?: [CageId, Cage][]) {\n /* c8 ignore next - ?? is defense in depth */\n extraCages = extraCages ?? [];\n\n if (puzzle.rows !== 9) {\n throw new Error(`Puzzle '${puzzle.description}' unsupported row count ${puzzle.rows}`);\n }\n if (puzzle.cols !== 9) {\n throw new Error(`Puzzle '${puzzle.description}' unsupported column count ${puzzle.cols}`);\n }\n if (puzzle.cells.length !== puzzle.rows * puzzle.cols) {\n throw new Error(\n `Puzzle '${puzzle.description}\" expected ${puzzle.rows * puzzle.cols} cells, found ${\n puzzle.cells.length\n }`\n );\n }\n\n this.id = puzzle.id;\n this.description = puzzle.description;\n\n const rows = Puzzle._createRowCages(puzzle.rows, puzzle.cols).orThrow();\n const columns = Puzzle._createColumnCages(puzzle.rows, puzzle.cols).orThrow();\n const sections = Puzzle._createSectionCages(puzzle.rows, puzzle.cols).orThrow();\n const cages = [...rows, ...columns, ...sections, ...extraCages];\n this._rows = new Map(rows);\n this._columns = new Map(columns);\n this._sections = new Map(sections);\n this._cages = new Map(cages);\n this._cells = new Map();\n\n const cellInit = [...puzzle.cells];\n for (let row = 0; row < this._rows.size; row++) {\n const rowCage = this.getRow(row).orThrow();\n for (let col = 0; col < this._columns.size; col++) {\n const id = Ids.cellId({ row, col }).orThrow();\n const colCage = this.getColumn(col).orThrow();\n const sectionCage = this.getSection({ row, col }).orThrow();\n const otherCages = extraCages.filter(([__key, cage]) => cage.containsCell(id));\n\n const init = cellInit.shift();\n /* c8 ignore next - defense in depth/make type check happy. undefined init should never happen */\n const immutableValue = init === '.' ? undefined : Number.parseInt(init ?? '0');\n if (\n immutableValue !== undefined &&\n (Number.isNaN(immutableValue) || immutableValue < 1 || immutableValue > 9)\n ) {\n throw new Error(`Puzzle ${puzzle.description} illegal value \"${init}\" for cell ${id}`);\n }\n const cages = [rowCage, colCage, sectionCage, ...otherCages.map(([__key, state]) => state)];\n const cell = new Cell({ id, immutableValue, row, col }, cages);\n this._cells.set(id, cell);\n }\n }\n\n this.initialState = PuzzleState.create(\n Array.from(this._cells.entries()).map(([id, state]): ICellState => {\n return { id, value: state.immutableValue, notes: [] };\n })\n ).orThrow();\n }\n\n public get numRows(): number {\n return this._rows.size;\n }\n\n public get numColumns(): number {\n return this._columns.size;\n }\n\n public get rows(): Cage[] {\n return Array.from(this._rows.values());\n }\n\n public get cols(): Cage[] {\n return Array.from(this._columns.values());\n }\n\n public get sections(): Cage[] {\n return Array.from(this._sections.values());\n }\n\n public get cages(): Cage[] {\n return Array.from(this._cages.values());\n }\n\n public get cells(): Cell[] {\n return Array.from(this._cells.values());\n }\n\n /**\n * @internal\n */\n protected static _createRowCages(numRows: number, numCols: number): Result<[CageId, Cage][]> {\n const cages: [CageId, Cage][] = [];\n for (let r = 0; r < numRows; r++) {\n const id = Ids.rowCageId(r);\n const cellIds = Ids.cellIds(r, 1, 0, numCols);\n /* c8 ignore next 3 - defense in depth should never happen */\n if (cellIds.isFailure()) {\n return fail(cellIds.message);\n }\n\n const result = Cage.create(id, 'row', basicCageTotal, cellIds.value).onSuccess((cage) => {\n cages.push([id, cage]);\n return succeed(cage);\n });\n /* c8 ignore next 3 - defense in depth should never happen */\n if (result.isFailure()) {\n return fail(result.message);\n }\n }\n return succeed(cages);\n }\n\n /**\n * @internal\n */\n protected static _createColumnCages(numRows: number, numCols: number): Result<[CageId, Cage][]> {\n const cages: [CageId, Cage][] = [];\n for (let c = 0; c < numCols; c++) {\n const id = Ids.columnCageId(c);\n const cellIds = Ids.cellIds(0, numRows, c, 1);\n /* c8 ignore next 3 - defense in depth should never happen */\n if (cellIds.isFailure()) {\n return fail(cellIds.message);\n }\n\n const result = Cage.create(id, 'column', basicCageTotal, cellIds.value).onSuccess((cage) => {\n cages.push([id, cage]);\n return succeed(cage);\n });\n /* c8 ignore next 3 - defense in depth should never happen */\n if (result.isFailure()) {\n return fail(result.message);\n }\n }\n return succeed(cages);\n }\n\n /**\n * @internal\n */\n private static _createSectionCages(numRows: number, numCols: number): Result<[CageId, Cage][]> {\n const cages: [CageId, Cage][] = [];\n for (let r = 0; r < numRows; r += 3) {\n for (let c = 0; c < numCols; c += 3) {\n const id = Ids.sectionCageId(r, c);\n const cellIds = Ids.cellIds(r, 3, c, 3);\n /* c8 ignore next 3 - defense in depth should never happen */\n if (cellIds.isFailure()) {\n return fail(cellIds.message);\n }\n\n const result = Cage.create(id, 'section', basicCageTotal, cellIds.value).onSuccess((cage) => {\n cages.push([id, cage]);\n return succeed(cage);\n });\n /* c8 ignore next 3 - defense in depth should never happen */\n if (result.isFailure()) {\n return fail(result.message);\n }\n }\n }\n return succeed(cages);\n }\n\n public checkIsSolved(state: PuzzleState): boolean {\n for (const id of this._cells.keys()) {\n if (!state.hasValue(id)) {\n return false;\n }\n }\n for (const cell of this._cells.values()) {\n if (!cell.isValid(state)) {\n return false;\n }\n }\n return true;\n }\n\n public checkIsValid(state: PuzzleState): boolean {\n for (const cell of this._cells.values()) {\n if (!cell.isValid(state)) {\n return false;\n }\n }\n return true;\n }\n\n public getEmptyCells(state: PuzzleState): Cell[] {\n return Array.from(this._cells.values()).filter((c) => !state.hasValue(c.id));\n }\n\n public getInvalidCells(state: PuzzleState): Cell[] {\n return Array.from(this._cells.values()).filter((c) => !c.isValid(state));\n }\n\n public getCellContents(\n spec: string | IRowColumn,\n state: PuzzleState\n ): Result<{ cell: Cell; contents: ICellContents }> {\n return this.getCell(spec).onSuccess((cell) => {\n if (cell.immutable) {\n const contents: ICellContents = { value: cell.immutableValue, notes: [] };\n return succeed({ cell, contents });\n }\n return state.getCellContents(cell.id).onSuccess((contents: ICellContents) => {\n return succeed({ cell, contents });\n });\n });\n }\n\n public getCell(spec: string | IRowColumn | ICell): Result<Cell> {\n const want = Ids.cellId(spec);\n if (want.isFailure()) {\n return fail(want.message);\n }\n\n const cell = this._cells.get(want.value);\n return cell ? succeed(cell) : fail(`Cell ${want.value} not found`);\n }\n\n public getCellNeighbor(\n spec: string | IRowColumn | ICell,\n direction: NavigationDirection,\n wrap: NavigationWrap\n ): Result<ICell> {\n return this.getCell(spec).onSuccess((cell) => {\n const move =\n direction === 'left' || direction === 'right'\n ? this._moveColumn(cell, direction, wrap)\n : this._moveRow(cell, direction, wrap);\n return move.onSuccess((next) => this.getCell(next));\n });\n }\n\n public updateContents(wantUpdates: ICellState[] | ICellState, state: PuzzleState): Result<IPuzzleUpdate> {\n wantUpdates = Array.isArray(wantUpdates) ? wantUpdates : [wantUpdates];\n return mapResults(\n wantUpdates.map((u) =>\n this.getCellContents(u.id, state).onSuccess((existing) =>\n existing.cell.update(u.value, u.notes).onSuccess((to) => {\n const from: ICellState = { id: u.id, ...existing.contents };\n return succeed({ from, to });\n })\n )\n )\n ).onSuccess((cellUpdates) => {\n return state.update(cellUpdates.map(({ to }) => to)).onSuccess((updatedState: PuzzleState) => {\n return succeed({\n from: state,\n to: updatedState,\n cells: cellUpdates\n });\n });\n });\n }\n\n public updateValues(wantUpdates: ICellState[] | ICellState, state: PuzzleState): Result<IPuzzleUpdate> {\n wantUpdates = Array.isArray(wantUpdates) ? wantUpdates : [wantUpdates];\n return mapResults(\n wantUpdates.map((u) =>\n this.getCellContents(u.id, state).onSuccess((existing) =>\n existing.cell.update(u.value, existing.contents.notes).onSuccess((to) => {\n const from: ICellState = { id: u.id, ...existing.contents };\n return succeed({ from, to });\n })\n )\n )\n ).onSuccess((cellUpdates) => {\n return state.update(cellUpdates.map(({ to }) => to)).onSuccess((updatedState: PuzzleState) => {\n return succeed({\n from: state,\n to: updatedState,\n cells: cellUpdates\n });\n });\n });\n }\n\n public updateNotes(wantUpdates: ICellState[] | ICellState, state: PuzzleState): Result<IPuzzleUpdate> {\n wantUpdates = Array.isArray(wantUpdates) ? wantUpdates : [wantUpdates];\n return mapResults(\n wantUpdates.map((u) =>\n this.getCellContents(u.id, state).onSuccess((existing) =>\n existing.cell.update(existing.contents.value, u.notes).onSuccess((to) => {\n const from: ICellState = { id: u.id, ...existing.contents };\n return succeed({ from, to });\n })\n )\n )\n ).onSuccess((cellUpdates) => {\n return state.update(cellUpdates.map(({ to }) => to)).onSuccess((updatedState: PuzzleState) => {\n return succeed({\n from: state,\n to: updatedState,\n cells: cellUpdates\n });\n });\n });\n }\n\n public updateCellValue(\n want: string | IRowColumn,\n value: number | undefined,\n state: PuzzleState\n ): Result<IPuzzleUpdate> {\n const idResult = Ids.cellId(want);\n const notes: number[] = [];\n return idResult.onSuccess((id) => {\n const update: ICellState = { id, value, notes };\n return this.updateValues([update], state);\n });\n }\n\n public updateCellNotes(\n want: string | IRowColumn,\n notes: number[],\n state: PuzzleState\n ): Result<IPuzzleUpdate> {\n const idResult = Ids.cellId(want);\n const value = undefined;\n return idResult.onSuccess((id) => {\n const update: ICellState = { id, value, notes };\n return this.updateNotes([update], state);\n });\n }\n\n public getRow(row: CageId | number): Result<Cage> {\n const id = typeof row === 'number' ? Ids.rowCageId(row) : row;\n const cage = this._rows.get(id);\n return cage ? succeed(cage) : fail(`Row ${id} not found`);\n }\n\n public getColumn(col: CageId | number): Result<Cage> {\n const id = typeof col === 'number' ? Ids.columnCageId(col) : col;\n const cage = this._columns.get(id);\n return cage ? succeed(cage) : fail(`Column ${id} not found`);\n }\n\n public getSection(spec: CageId | IRowColumn): Result<Cage> {\n const id = typeof spec === 'object' ? Ids.sectionCageId(spec.row, spec.col) : spec;\n const cage = this._sections.get(id);\n return cage ? succeed(cage) : fail(`Section ${id} not found`);\n }\n\n public getCage(id: CageId): Result<Cage> {\n const cage = this._cages.get(id);\n return cage ? succeed(cage) : fail(`Cage ${id} not found`);\n }\n\n public toStrings(state: PuzzleState): string[] {\n return Array.from(this._rows.values()).map((row) => row.toString(state));\n }\n\n public toString(state: PuzzleState): string {\n return this.toStrings(state).join('\\n');\n }\n\n private _moveColumn(\n current: IRowColumn,\n direction: 'left' | 'right',\n wrap: NavigationWrap\n ): Result<IRowColumn> {\n const row = current.row;\n\n let col = current.col;\n if (direction === 'left') {\n if (col > 0) {\n col = col - 1;\n } else if (wrap !== 'none') {\n col = this.numColumns - 1;\n if (wrap === 'wrap-next') {\n return this._moveRow({ row, col }, 'up', 'wrap-around');\n }\n } else {\n return fail(`cannot move left from column ${current.col}`);\n }\n } else if (direction === 'right') {\n if (col < this.numColumns - 1) {\n col = col + 1;\n } else if (wrap !== 'none') {\n col = 0;\n if (wrap === 'wrap-next') {\n return this._moveRow({ row, col }, 'down', 'wrap-around');\n }\n } else {\n return fail(`cannot move right from column ${current.col}`);\n }\n }\n return succeed({ row, col });\n }\n\n private _moveRow(current: IRowColumn, direction: 'up' | 'down', wrap: NavigationWrap): Result<IRowColumn> {\n let row = current.row;\n const col = current.col;\n\n if (direction === 'up') {\n if (row > 0) {\n row = row - 1;\n } else if (wrap !== 'none') {\n row = this.numRows - 1;\n if (wrap === 'wrap-next') {\n return this._moveColumn({ row, col }, 'left', 'wrap-around');\n }\n } else {\n return fail(`cannot move up from row ${current.row}`);\n }\n } else if (direction === 'down') {\n if (row < this.numRows - 1) {\n row = row + 1;\n } else if (wrap !== 'none') {\n row = 0;\n if (wrap === 'wrap-next') {\n return this._moveColumn({ row, col }, 'right', 'wrap-around');\n }\n } else {\n return fail(`cannot move down from row ${current.row}`);\n }\n }\n return succeed({ row, col });\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"puzzleSession.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/puzzleSession.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEtG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,UAAU,WAAW;IACnB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;;GAGG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACI,KAAK,EAAE,WAAW,CAAC;IAE1B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC;IAEhC;;OAEG;IACH,SAAS,aAAa,MAAM,EAAE,MAAM;IAQpC;;OAEG;IACH,IAAW,EAAE,IAAI,MAAM,GAAG,SAAS,CAElC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,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,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEO,QAAQ,CAAC,OAAsB;QACrC,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;IAEO,KAAK,CAAC,IAAoB;QAChC,IAAI,IAAI,YAAY,WAAI,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,SAAG,CAAC,MAAM,CAAC,IAAI,CAAC;aACpB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE;YAChB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAClC,CAAC,CAAC;aACD,SAAS,EAAE,CAAC;IACjB,CAAC;IAEO,KAAK,CAAC,IAAiC;QAC7C,IAAI,IAAI,YAAY,WAAI,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAA2B,CAAC,CAAC,SAAS,EAAE,CAAC;IACvE,CAAC;CACF;AArXD,sCAqXC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { Cage } from './cage';\nimport { Cell } from './cell';\nimport { ICellContents, ICellState, IRowColumn, NavigationDirection, NavigationWrap } from './common';\nimport { Ids } from './ids';\nimport { ICage, ICell } from './public';\nimport { ICellUpdate, Puzzle } from './puzzle';\nimport { PuzzleState } from './puzzleState';\n\ninterface IPuzzleStep {\n updates: ICellUpdate[];\n}\n\n/**\n * Represents a single puzzle session, including puzzle, current state and redo/undo.\n * @public\n */\nexport class PuzzleSession {\n /**\n * The current {@link PuzzleState | state} of this puzzle session.\n */\n public state: PuzzleState;\n\n protected readonly _puzzle: Puzzle;\n protected _nextStep: number;\n protected _numSteps: number;\n protected _steps: IPuzzleStep[];\n\n /**\n * @internal\n */\n protected constructor(puzzle: Puzzle) {\n this._puzzle = puzzle;\n this.state = puzzle.initialState;\n this._nextStep = 0;\n this._numSteps = 0;\n this._steps = [];\n }\n\n /**\n * ID of the puzzle being solved.\n */\n public get id(): string | undefined {\n return this._puzzle.id;\n }\n\n /**\n * Description of the puzzle being solved.\n */\n public get description(): string {\n return this._puzzle.description;\n }\n\n /**\n * Number of rows in the puzzle being solved.\n */\n public get numRows(): number {\n return this._puzzle.numRows;\n }\n\n /**\n * Number of columns in the puzzle being solved.\n */\n public get numColumns(): number {\n return this._puzzle.numColumns;\n }\n\n /**\n * The row {@link ICage | cages} in the puzzle being solved.\n */\n public get rows(): ICage[] {\n return this._puzzle.rows;\n }\n\n /**\n * The column {@link ICage | cages} in the puzzle being solved.\n */\n public get cols(): ICage[] {\n return this._puzzle.cols;\n }\n\n /**\n * The section {@link ICage | cages} in the puzzle being solved.\n */\n public get sections(): ICage[] {\n return this._puzzle.sections;\n }\n\n /**\n * All {@link ICage | cages} in the puzzle being solved.\n */\n public get cages(): ICage[] {\n return this._puzzle.cages;\n }\n\n /**\n * The cells {@link ICell | cells} in the puzzle being solved.\n */\n public get cells(): ICell[] {\n return this._puzzle.cells;\n }\n\n /**\n * Index of the next step in this puzzle session.\n */\n public get nextStep(): number {\n return this._nextStep;\n }\n\n /**\n * Number of steps currently elapsed in this puzzle session. Note\n * that after undo, `nextStep` will be less than `numSteps`.\n */\n public get numSteps(): number {\n return this._numSteps;\n }\n\n /***\n * Indicates whether undo is currently possible.\n */\n public get canUndo(): boolean {\n return this._nextStep > 0;\n }\n\n /**\n * Indicates whether redo is currently possible.\n */\n public get canRedo(): boolean {\n return this._nextStep < this._numSteps;\n }\n\n /**\n * Creates a new {@link PuzzleSession | puzzle session} from a supplied\n * {@link Puzzle | puzzle}.\n * @param puzzle - The {@link Puzzle | puzzle} from which the session is to be\n * initialized.\n * @returns `Success` with the requested {@link PuzzleSession | puzzle session},\n * or `Failure` with details if an error occurs.\n */\n public static create(puzzle: Puzzle): Result<PuzzleSession> {\n return captureResult(() => new PuzzleSession(puzzle));\n }\n\n /**\n * Determines if the puzzle is correctly solved.\n * @returns `true` if the puzzle is solved, `false` if the puzzle has\n * empty or invalid cells.\n */\n public checkIsSolved(): boolean {\n return this._puzzle.checkIsSolved(this.state);\n }\n\n /**\n * Determines if the puzzle is valid in its current state.\n * @returns `true` if all non-empty cells in the puzzle are valid,\n * or `false` if any cells are invalid.\n */\n public checkIsValid(): boolean {\n return this._puzzle.checkIsValid(this.state);\n }\n\n /**\n * Gets all of the currently empty {@link ICell | cells} in the puzzle.\n * @returns An array of {@link ICell | ICell} with all empty cells.\n */\n public getEmptyCells(): ICell[] {\n return this._puzzle.getEmptyCells(this.state);\n }\n\n /**\n * Gets all of the currently invalid {@link ICell | cells} in the puzzle.\n * @returns An array of {@link ICell | ICell} with all invalid cells.\n */\n public getInvalidCells(): ICell[] {\n return this._puzzle.getInvalidCells(this.state);\n }\n\n /**\n * Determines if a cell is valid.\n * @param spec - A `string` ({@link CellId | CellId}), {@link IRowColumn | RowColumn} or {@link ICell | ICell}\n * describing the cell to be tested.\n * @returns `true` if the cell value is valid, `false` if the cell value or the cell itself is invalid.\n */\n public cellIsValid(spec: string | IRowColumn | ICell): boolean {\n return this._cell(spec)?.isValid(this.state) === true;\n }\n\n /**\n * Determines if a cell has a value.\n * @param spec - A `string` ({@link CellId | CellId}), {@link IRowColumn | RowColumn} or {@link ICell | ICell}\n * describing the cell to be tested.\n * @returns `true` if the cell has a value, `false` if the cell is empty or the cell itself is invalid.\n */\n public cellHasValue(spec: string | IRowColumn | ICell): boolean {\n return this._cell(spec)?.hasValue(this.state) === true;\n }\n\n /**\n * Determines if supplied value is valid for a specific cell.\n * @param spec - A `string` ({@link CellId | CellId}), {@link IRowColumn | RowColumn} or {@link ICell | ICell}\n * describing the cell to be tested.\n * @param value - The value to be tested.\n * @returns `true` if `value` is valid for the requested cell, `false` if the value or the cell itself is invalid.\n */\n public isValidForCell(spec: string | IRowColumn | ICell, value: number): boolean {\n return this._cell(spec)?.isValidValue(value, this.state) === true;\n }\n\n /**\n * Gets the neighbor for a cell in a given direction using specified wrapping rules.\n * @param spec - A `string` ({@link CellId | CellId}), {@link IRowColumn | RowColumn} or {@link ICell | ICell}\n * describing the cell to be tested.\n * @param direction - The direction of the desired neighbor.\n * @param wrap - Wrapping rules to be applied.\n * @returns `Success` with the requested {@link ICell | cell}, or `Failure` with details if an error occurs.\n */\n public getCellNeighbor(\n spec: string | IRowColumn | ICell,\n direction: NavigationDirection,\n wrap: NavigationWrap\n ): Result<ICell> {\n return this._puzzle.getCellNeighbor(spec, direction, wrap);\n }\n\n /**\n * Gets the {@link ICellContents | contents} for a specified cell.\n * @param spec - A `string` ({@link CellId | CellId}), {@link IRowColumn | RowColumn} or {@link ICell | ICell}\n * describing the cell to be queried.\n * @returns `Success` with the {@link ICell | cell description} and {@link ICellContents | cell contents}, or\n * `Failure` with details if an error occurs.\n */\n public getCellContents(spec: string | IRowColumn): Result<{ cell: ICell; contents: ICellContents }> {\n return this._puzzle.getCellContents(spec, this.state);\n }\n\n /**\n * Updates the value of a cell.\n * @param spec - A `string`, {@link IRowColumn | row and column}, or {@link ICell | cell} identifying\n * the cell to be updated.\n * @param value - A new value for the cell.\n * @returns `Success` with `this` if the update is applied, `Failure` with details if an error occurs.\n */\n public updateCellValue(spec: string | IRowColumn | ICell, value: number | undefined): Result<this> {\n const idResult = Ids.cellId(spec);\n return idResult.onSuccess((id) => {\n const notes: number[] = [];\n const update: ICellState = { id, value, notes };\n return this._puzzle.updateValues(update, this.state).onSuccess((update) => {\n this._addMove(update.cells);\n this.state = update.to;\n return succeed(this);\n });\n });\n }\n\n /**\n * Updates the notes on a cell.\n * @param spec - A `string`, {@link IRowColumn | row and column}, or {@link ICell | cell} identifying\n * the cell to be updated.\n * @param notes - New notes for the cell.\n * @returns `Success` with `this` if the update is applied, `Failure` with details if an error occurs.\n */\n public updateCellNotes(spec: string | IRowColumn | ICell, notes: number[]): Result<this> {\n const idResult = Ids.cellId(spec);\n return idResult.onSuccess((id) => {\n const value = undefined;\n const update: ICellState = { id, value, notes };\n return this._puzzle.updateNotes(update, this.state).onSuccess((update) => {\n this._addMove(update.cells);\n this.state = update.to;\n return succeed(this);\n });\n });\n }\n\n /**\n * Updates value & notes for multiple cells.\n * @param updates - An array of {@link ICellState | cell state} objects, each describing\n * one cell to be updated.\n * @returns `Success` with `this` if the updates are applied, `Failure` with details if\n * an error occurs.\n */\n public updateCells(updates: ICellState[]): Result<this> {\n return this._puzzle.updateContents(updates, this.state).onSuccess((update) => {\n this._addMove(update.cells);\n this.state = update.to;\n return succeed(this);\n });\n }\n\n /**\n * Determines if some {@link ICage | cage} contains a specific value.\n * @param spec - A `string` ({@link CageId | CageId}) or {@link ICage | ICage}\n * indicating the cage to be tested.\n * @param value - The value to be tested.\n * @returns `true` if the cage exists and contains the specified value,\n * `false` otherwise.\n */\n public cageContainsValue(spec: string | ICage, value: number): boolean {\n return this._cage(spec)?.containsValue(value, this.state) === true;\n }\n\n /**\n * Determines the numbers currently present in some cage.\n * @param spec - A `string` ({@link CageId | CageId}) or {@link ICage | ICage}\n * indicating the cage to be tested.\n * @returns A `Set<number>` containing all numbers present in the cage.\n */\n public cageContainedValues(spec: string | ICage): Set<number> {\n return this._cage(spec)?.containedValues(this.state) ?? new Set<number>();\n }\n\n /**\n * Undo a single move in this puzzle session.\n * @returns `Success` with `this` if the undo is applied, or `Failure`\n * with details if an error occurs.\n */\n public undo(): Result<this> {\n if (!this.canUndo) {\n return fail(`nothing to undo`);\n }\n\n return this._puzzle\n .updateContents(\n this._steps[this._nextStep - 1].updates.map((u) => u.from),\n this.state\n )\n .onSuccess((update) => {\n this._nextStep--;\n this.state = update.to;\n return succeed(this);\n });\n }\n\n /**\n * Redo a single move in this puzzle session.\n * @returns `Success` with `this` if the redo is applied, or `Failure`\n * with details if an error occurs.\n */\n public redo(): Result<this> {\n if (!this.canRedo) {\n return fail('nothing to redo');\n }\n return this._puzzle\n .updateContents(\n this._steps[this._nextStep].updates.map((u) => u.to),\n this.state\n )\n .onSuccess((update) => {\n this._nextStep++;\n this.state = update.to;\n return succeed(this);\n });\n }\n\n /**\n * Gets a string representation of this puzzle, one string\n * per row.\n */\n public toStrings(): string[] {\n return this._puzzle.toStrings(this.state);\n }\n\n private _addMove(updates: ICellUpdate[]): void {\n if (this._nextStep < this._steps.length) {\n this._steps[this._nextStep++] = { updates };\n } else {\n this._steps.push({ updates });\n this._nextStep = this._steps.length;\n }\n this._numSteps = this._nextStep;\n }\n\n private _cage(spec: string | ICage): Cage | undefined {\n if (spec instanceof Cage) {\n return spec;\n }\n return Ids.cageId(spec)\n .onSuccess((id) => {\n return this._puzzle.getCage(id);\n })\n .orDefault();\n }\n\n private _cell(spec: string | IRowColumn | ICell): Cell | undefined {\n if (spec instanceof Cell) {\n return spec;\n }\n return this._puzzle.getCell(spec as string | IRowColumn).orDefault();\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"puzzleState.d.ts","sourceRoot":"","sources":["../../../src/packlets/common/puzzleState.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE7D;;GAEG;AACH,qBAAa,WAAW;IACtB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEtD;;OAEG;IACH,SAAS,aAAa,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE;IAK9E;;;;OAIG;WACW,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC;IAI9D;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;IAW7E;;;;;OAKG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;IAKzD;;;;;OAKG;IACI,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAKpC;;;;;;OAMG;IACI,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,C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AA,eAAI,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,EAAU;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjC,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,MAAK,SAAS,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,OAAqB;QACjC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC3C,OAAO,IAAA,eAAI,EAAC,oBAAoB,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AA7ED,kCA6EC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, fail, succeed } from '@fgv/ts-utils';\nimport { CellId, ICellContents, ICellState } from './common';\n\n/**\n * @public\n */\nexport class PuzzleState {\n /**\n * @internal\n */\n protected readonly _cells: Map<CellId, ICellContents>;\n\n /**\n * @internal\n */\n protected constructor(from: Map<CellId, ICellContents>, updates?: ICellState[]) {\n const entries = [...Array.from(from.entries()), ...PuzzleState._toEntries(updates)];\n this._cells = new Map(entries);\n }\n\n /**\n * Constructs a new {@link PuzzleState | PuzzleState}.\n * @param cells - An array of {@link ICellState | CellState} used to initialize the state.\n * @returns The new {@link PuzzleState | PuzzleState}.\n */\n public static create(cells: ICellState[]): Result<PuzzleState> {\n return succeed(new PuzzleState(new Map(), cells));\n }\n\n /**\n * Convert {@link ICellContents | CellContents} to `[`{@link CellId | CellId}`,` {@link ICellContents | CellContents}`]`\n * tuple for `Map` construction.\n * @param states - An array of {@link ICellContents | CellContents} to be converted.\n * @returns The corresponding array of `[`{@link CellId | CellId}`,` {@link ICellContents | CellContents}`]`\n * @internal\n */\n protected static _toEntries(states?: ICellState[]): [CellId, ICellContents][] {\n /* c8 ignore next 3 - defense in depth */\n if (!states) {\n return [];\n }\n return states.map((state) => {\n const { id, value, notes } = state;\n return [id, { value, notes }];\n });\n }\n\n /**\n * Gets the contents of a cell specified by {@link CellId | id}.\n * @param id - The {@link CellId | id} of the cell to be retrieved.\n * @returns A {@link ICellContents | CellContents} with the contents of\n * the requested cell.\n */\n public getCellContents(id: CellId): Result<ICellContents> {\n const cell = this._cells.get(id);\n return cell ? succeed(cell) : fail(`cell ${id} not found`);\n }\n\n /**\n * Determines if some cell has an assigned value.\n * @param id - The {@link CellId | id} of the cell to be tested.\n * @returns `true` if the cell has a value, `false` if the cell\n * is empty or invalid.\n */\n public hasValue(id: CellId): boolean {\n const cell = this._cells.get(id);\n return cell?.value !== undefined;\n }\n\n /**\n * Creates a new {@link PuzzleState | PuzzleState} which corresponds\n * to this state with updates applied.\n * @param updates - An array of {@link ICellState | CellState} to be\n * applied.\n * @returns A new {@link PuzzleState} with updates applied.\n */\n public update(updates: ICellState[]): Result<PuzzleState> {\n const updated = new PuzzleState(this._cells, updates);\n if (updated._cells.size > this._cells.size) {\n return fail(`update added cells`);\n }\n return succeed(updated);\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/file/converters.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAc,MAAM,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvC;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,YAAY,CAE9C,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAE1E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../src/packlets/file/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAwBH,0DAEC;AAxBD,4CAA8D;AAG9D,oDAA6C;AAC7C,sCAA2D;AAE3D;;;GAGG;AACU,QAAA,WAAW,GAA4B,qBAAU,CAAC,YAAY,CAAe;IACxF,OAAO,EAAE,qBAAU,CAAC,OAAO,CAAC,mBAAgB,CAAC,iBAAiB,CAAC;CAChE,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,IAAY;IAClD,OAAO,uBAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAW,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converter, Converters, Result } from '@fgv/ts-utils';\nimport { IPuzzlesFile } from './model';\n\nimport { JsonFile } from '@fgv/ts-json-base';\nimport { Converters as CommonConverters } from '../common';\n\n/**\n * Converts an arbitrary object to a {@link File.Model.IPuzzlesFile | IPuzzlesFile}.\n * @public\n */\nexport const puzzlesFile: Converter<IPuzzlesFile> = Converters.strictObject<IPuzzlesFile>({\n puzzles: Converters.arrayOf(CommonConverters.puzzleDescription)\n});\n\n/**\n * Loads an arbitrary JSON file and parses it to return a validated\n * {@link File.Model.IPuzzlesFile | IPuzzlesFile}.\n * @param path - String path to the file\n * @returns `Success` with the resulting file, or `Failure` with details if an\n * error occurs.\n * @public\n */\nexport function loadJsonPuzzlesFileSync(path: string): Result<IPuzzlesFile> {\n return JsonFile.convertJsonFileSync(path, puzzlesFile);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/file/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/file/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAA2C;AAGlC,gCAAU;AAFnB,+CAAiC;AAEZ,sBAAK","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './converters';\nimport * as Model from './model';\n\nexport { Converters, Model };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/packlets/file/model.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/packlets/file/model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { IPuzzleDescription } from '../common';\n\n/**\n * Parsed file containing a collection of puzzles.\n * @public\n */\nexport interface IPuzzlesFile {\n puzzles: IPuzzleDescription[];\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"anyPuzzle.d.ts","sourceRoot":"","sources":["../../../src/packlets/puzzles/anyPuzzle.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAQ,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKvD;;;GAGG;AACH,qBAAa,SAAS;WACN,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;CAajE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"anyPuzzle.js","sourceRoot":"","sources":["../../../src/packlets/puzzles/anyPuzzle.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,4CAA6C;AAG7C,6DAA0D;AAC1D,iDAA8C;AAC9C,mDAAgD;AAEhD;;;GAGG;AACH,MAAa,SAAS;IACb,MAAM,CAAC,MAAM,CAAC,MAA0B;QAC7C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,QAAQ;gBACX,OAAO,2BAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACrC,KAAK,UAAU;gBACb,OAAO,6BAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACtC,KAAK,eAAe;gBAClB,OAAO,uCAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC3C,sBAAsB;YACtB;gBACE,OAAO,IAAA,eAAI,EAAC,WAAW,MAAM,CAAC,WAAW,sBAAsB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF;AAdD,8BAcC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, fail } from '@fgv/ts-utils';\n\nimport { IPuzzleDescription, Puzzle } from '../common';\nimport { KillerSudokuPuzzle } from './killerSudokuPuzzle';\nimport { SudokuPuzzle } from './sudokuPuzzle';\nimport { SudokuXPuzzle } from './sudokuXPuzzle';\n\n/**\n * Static class to instantiate any puzzle from a {@link PuzzleDescription | puzzle description}.\n * @internal\n */\nexport class AnyPuzzle {\n public static create(puzzle: IPuzzleDescription): Result<Puzzle> {\n switch (puzzle.type) {\n case 'sudoku':\n return SudokuPuzzle.create(puzzle);\n case 'sudoku-x':\n return SudokuXPuzzle.create(puzzle);\n case 'killer-sudoku':\n return KillerSudokuPuzzle.create(puzzle);\n /* c8 ignore next 2 */\n default:\n return fail(`Puzzle '${puzzle.description}' unsupported type ${puzzle.type}`);\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/puzzles/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/puzzles/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,2CAA+C;AAKtC,oFALa,qBAAG,OAKb;AAJZ,6DAAoE;AAItD,uFAJiB,uCAAM,OAIjB;AAHpB,iDAAwD;AAGlC,uFAHG,2BAAM,OAGH;AAF5B,mDAA2D;AAE7B,wFAFJ,6BAAO,OAEI","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { AnyPuzzle as Any } from './anyPuzzle';\nimport { KillerSudokuPuzzle as Killer } from './killerSudokuPuzzle';\nimport { SudokuPuzzle as Sudoku } from './sudokuPuzzle';\nimport { SudokuXPuzzle as SudokuX } from './sudokuXPuzzle';\n\nexport { Any, Killer, Sudoku, SudokuX };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"killerSudokuPuzzle.d.ts","sourceRoot":"","sources":["../../../src/packlets/puzzles/killerS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I,CAAC,KAAK,CAAC,CAAC,CAAC;gBACjC,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;CACF;AAtHD,gDAsHC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { Cage, CageId, CellId, IPuzzleDescription, Ids, Puzzle, totalsByCageSize } from '../common';\n\nconst cageDefFormat: RegExp = /^[A-Za-z][0-9][0-9]$/;\n\n/**\n * @public\n */\nexport class KillerSudokuPuzzle extends Puzzle {\n private constructor(puzzle: IPuzzleDescription, cages: [CageId, Cage][]) {\n super(puzzle, cages);\n }\n\n public static create(desc: IPuzzleDescription): Result<Puzzle> {\n /* c8 ignore next 3 */\n if (desc.type !== 'killer-sudoku') {\n return fail(`Puzzle '${desc.description}' unsupported type ${desc.type}`);\n }\n\n return captureResult(() => {\n const { cages, givens } = KillerSudokuPuzzle._getKillerCages(desc);\n const cells = KillerSudokuPuzzle._getKillerCells(desc, givens);\n return new KillerSudokuPuzzle({ ...desc, cells }, cages);\n })\n .onSuccess((puzzle) => {\n return succeed(puzzle);\n })\n .onFailure((message) => {\n return fail(`Failed to load killer puzzle \"${desc.description}\" - ${message}`);\n });\n }\n\n private static _getKillerCages(puzzle: IPuzzleDescription): { cages: [CageId, Cage][]; givens: Cage[] } {\n const decl = puzzle.cells.split('|');\n if (decl.length !== 2) {\n throw new Error(`malformed cells|cages \"${puzzle.cells}\"`);\n }\n\n const cageCells = KillerSudokuPuzzle._getCageCells(puzzle, decl[0]);\n const allCages = KillerSudokuPuzzle._getCages(puzzle, cageCells, decl[1]);\n const cages = allCages.filter(([__id, cage]) => cage.numCells > 1);\n const givens = allCages.filter(([__id, cage]) => cage.numCells === 1).map(([__id, cage]) => cage);\n return { cages, givens };\n }\n\n private static _getCageCells(puzzle: IPuzzleDescription, mappingDecl: string): Map<string, CellId[]> {\n const cages: Map<string, CellId[]> = new Map();\n const cageMapping = Array.from(mappingDecl);\n\n if (cageMapping.length !== puzzle.rows * puzzle.cols) {\n const expected = puzzle.rows * puzzle.cols;\n const got = cageMapping.length;\n throw new Error(`expected ${expected} cell mappings, found ${got}`);\n }\n\n for (let row = 0; row < puzzle.rows; row++) {\n for (let col = 0; col < puzzle.cols; col++) {\n const cage = cageMapping.shift()!;\n const cell = Ids.cellId({ row, col }).orThrow();\n const cells = cages.get(cage) ?? [];\n cells.push(cell);\n cages.set(cage, cells);\n }\n }\n\n return cages;\n }\n\n private static _getCages(\n __puzzle: IPuzzleDescription,\n cageCells: Map<string, CellId[]>,\n cagePart: string\n ): [CageId, Cage][] {\n const cages = new Map<CageId, Cage>();\n\n const cageDefs = cagePart.split(',');\n if (cageDefs.length !== cageCells.size) {\n throw new Error(`expected ${cageCells.size} cage sizes, found ${cageDefs.length}`);\n }\n\n for (const def of cageDefs) {\n if (!cageDefFormat.test(def)) {\n throw new Error(`malformed cage spec ${def}`);\n }\n const cage = def.slice(0, 1);\n const cageId = Ids.cageId(`K${cage}`).orThrow();\n\n const total = Number.parseInt(def.slice(1));\n const cells = cageCells.get(cage);\n /* c8 ignore next 3 - should never happen */\n if (!cells) {\n throw new Error(`cage ${cageId} has no cells`);\n }\n if (cells.length < 1 || cells.length > 9) {\n throw new Error(`invalid cell count ${cells.length} for cage ${cageId}`);\n }\n const { min, max } = totalsByCageSize[cells.length];\n if (total < min || total > max) {\n throw new Error(`invalid total ${total} for cage ${cageId} (expected ${min}..${max})`);\n }\n\n cages.set(cageId, Cage.create(cageId, 'killer', total, cells).orThrow());\n }\n\n return Array.from(cages.entries());\n }\n\n private static _getKillerCells(puzzle: IPuzzleDescription, givens: Cage[]): string {\n const cells: string[] = [];\n for (let row = 0; row < puzzle.rows; row++) {\n for (let col = 0; col < puzzle.cols; col++) {\n const cellId = Ids.cellId({ row, col }).orThrow();\n const cage = givens.find((g) => g.cellIds[0] === cellId);\n if (cage) {\n /* c8 ignore next 3 - defense in depth should never happen */\n if (cage.total < 1 || cage.total > 9) {\n throw new Error(`invalid total ${cage.total} for cell ${cellId}`);\n }\n cells.push(String(cage.total));\n } else {\n cells.push('.');\n }\n }\n }\n return cells.join('');\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sudokuPuzzle.d.ts","sourceRoot":"","sources":["../../../src/packlets/puzzles/sudokuPuzzle.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEvD;;GAEG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,OAAO;WAIO,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;CAUjE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sudokuPuzzle.js","sourceRoot":"","sources":["../../../src/packlets/puzzles/sudokuPuzzle.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,4CAAqE;AACrE,sCAAuD;AAEvD;;GAEG;AACH,MAAa,YAAa,SAAQ,eAAM;IACtC,YAAoB,MAA0B;QAC5C,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,MAA0B;QAC7C,sBAAsB;QACtB,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAA,eAAI,EAAC,WAAW,MAAM,CAAC,WAAW,sBAAsB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACxE,OAAO,IAAA,kBAAO,EAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAfD,oCAeC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { IPuzzleDescription, Puzzle } from '../common';\n\n/**\n * @public\n */\nexport class SudokuPuzzle extends Puzzle {\n private constructor(puzzle: IPuzzleDescription) {\n super(puzzle);\n }\n\n public static create(puzzle: IPuzzleDescription): Result<Puzzle> {\n /* c8 ignore next 3 */\n if (puzzle.type !== 'sudoku') {\n return fail(`Puzzle '${puzzle.description}' unsupported type ${puzzle.type}`);\n }\n\n return captureResult(() => new SudokuPuzzle(puzzle)).onSuccess((puzzle) => {\n return succeed(puzzle);\n });\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sudokuXPuzzle.d.ts","sourceRoot":"","sources":["../../../src/packlets/puzzles/sudokuXPuzzle.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAA0B,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAwB,kBAAkB,EAAO,MAAM,EAAE,MAAM,WAAW,CAAC;AAElF;;GAEG;AACH,qBAAa,aAAc,SAAQ,MAAM;IACvC,OAAO;WAIO,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAYhE,OAAO,CAAC,MAAM,CAAC,UAAU;CAmB1B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sudokuXPuzzle.js","sourceRoot":"","sources":["../../../src/packlets/puzzles/sudokuXPuzzle.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,4CAA+D;AAC/D,sCAAkF;AAElF;;GAEG;AACH,MAAa,aAAc,SAAQ,eAAM;IACvC,YAAoB,MAA0B,EA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O,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,YAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAExC,MAAM,EAAE,GAAG,aAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;QACzD,MAAM,EAAE,GAAG,aAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;QACzD,OAAO;YACL,CAAC,IAAI,EAAE,EAAE,CAAC;YACV,CAAC,IAAI,EAAE,EAAE,CAAC;SACX,CAAC;IACJ,CAAC;CACF;AApCD,sCAoCC","sourcesContent":["/*\n * MIT License\n *\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, succeed } from '@fgv/ts-utils';\nimport { Cage, CageId, CellId, IPuzzleDescription, Ids, Puzzle } from '../common';\n\n/**\n * @public\n */\nexport class SudokuXPuzzle extends Puzzle {\n private constructor(puzzle: IPuzzleDescription, extraCages: [CageId, Cage][]) {\n super(puzzle, extraCages);\n }\n\n public static create(puzzle: IPuzzleDescription): Result<Puzzle> {\n /* c8 ignore next 3 */\n if (puzzle.type !== 'sudoku-x') {\n return fail(`Puzzle '${puzzle.description}' unsupported type ${puzzle.type}`);\n }\n return captureResult(() => {\n return new SudokuXPuzzle(puzzle, SudokuXPuzzle._getXCages(puzzle));\n }).onSuccess((puzzle) => {\n return succeed(puzzle);\n });\n }\n\n private static _getXCages(puzzle: IPuzzleDescription): [CageId, Cage][] {\n const x1Cells: CellId[] = [];\n const x2Cells: CellId[] = [];\n\n for (let row = 0, col1 = 0, col2 = puzzle.cols - 1; row < puzzle.rows; row++, col1++, col2--) {\n x1Cells.push(Ids.cellId({ row, col: col1 }).orThrow());\n x2Cells.push(Ids.cellId({ row, col: col2 }).orThrow());\n }\n\n const x1Id = Ids.cageId('X1').orThrow();\n const x2Id = Ids.cageId('X2').orThrow();\n\n const x1 = Cage.create(x1Id, 'x', 45, x1Cells).orThrow();\n const x2 = Cage.create(x2Id, 'x', 45, x2Cells).orThrow();\n return [\n [x1Id, x1],\n [x2Id, x2]\n ];\n }\n}\n"]}