@sudobility/sudojo_lib 0.0.149 → 0.0.150

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.
@@ -1 +1 @@
1
- {"version":3,"file":"sudokuPresenter.d.ts","sourceRoot":"","sources":["../../src/utils/sudokuPresenter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,QAAQ,EAEb,WAAW,EACX,UAAU,EAGV,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AA0D1B;;GAEG;AACH,iBAAS,kBAAkB,CACzB,WAAW,EAAE,WAAW,GAAG,IAAI,GAC9B,UAAU,GAAG,IAAI,CAyBnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,UAAU,GAAG,IAAI,GAC5B,MAAM,GAAG,IAAI,CA4Bf;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,OAAO,GAAG,cAAc,CAEnE;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GACxB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAoC9B;AAuMD,MAAM,WAAW,mBAAmB;IAClC,gCAAgC;IAChC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,mDAAmD;IACnD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,yDAAyD;IACzD,UAAU,EAAE,OAAO,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,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M,GAAG,IAAI,GAC3B,MAAM,GAAG,IAAI,CAiBf;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,UAAU,EAAE,EACnB,aAAa,EAAE,MAAM,GAAG,IAAI,GAC3B,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAIpB;AAMD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,WAAW,CAOd;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB,GAAG,gBAAgB,CAanB;AAED;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -298,6 +298,8 @@ function getPencilmarks(cell, hintCell) {
298
298
  */
299
299
  export function presentBoard(options) {
300
300
  const { cells, selectedIndex, showErrors, hintStep = null, selectedDigitCells = null, } = options;
301
+ // Detect conflict hint (has links with type 'conflict')
302
+ const isConflictHint = hintStep?.links?.some(link => link.type === 'conflict') ?? false;
301
303
  // Calculate hint cell map
302
304
  const cellHints = calculateCellHints(hintStep);
303
305
  // Get selected cell properties (if any)
@@ -337,13 +339,21 @@ export function presentBoard(options) {
337
339
  }
338
340
  // Get text info
339
341
  const { digit, textColor, isGiven } = getCellText(cell, showErrors, hintCell);
342
+ // In conflict hints, override textColor for orange source cells
343
+ let finalTextColor = textColor;
344
+ if (isConflictHint &&
345
+ hintCell &&
346
+ !hintCell.fill &&
347
+ hintCell.color === SudokuColor.ORANGE) {
348
+ finalTextColor = ThemeColor.WARNING;
349
+ }
340
350
  // Get pencilmarks if no digit
341
351
  const pencilmarks = digit === null ? getPencilmarks(cell, hintCell) : [];
342
352
  return {
343
353
  index,
344
354
  backgroundColor: finalBgColor,
345
355
  borderColor: finalBorderColor,
346
- textColor,
356
+ textColor: finalTextColor,
347
357
  digit,
348
358
  isGiven,
349
359
  pencilmarks,
@@ -1 +1 @@
1
- {"version":3,"file":"sudokuPresenter.js","sourceRoot":"","sources":["../../src/utils/sudokuPresenter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAOL,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,GAEb,MAAM,kBAAkB,CAAC;AAE1B,gFAAgF;AAChF,8CAA8C;AAC9C,gFAAgF;AAEhF;;GAEG;AACH,MAAM,KAAK;IAIT,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3B,MAAM,GAAG,GAAG,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC7B,MAAM,GAAG,GAAG,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;YACvC,CAAC;QACH,CAAC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AI,CAAC,KAAK;KAClB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAItC;IACC,8CAA8C;IAC9C,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CACjD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CACxB,CAAC;IAE7B,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EACH,kBAAkB,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC;YACnD,UAAU,CAAC,QAAQ;QACrB,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/**\n * Sudoku presenter - port of renderable/SudokuPresenter.kt\n *\n * Handles all display logic for the Sudoku board including:\n * - Cell background colors based on selection state\n * - Cell border colors for selected cells\n * - Text colors (given, input, hint actions)\n * - Hint visualization (areas, cells)\n * - Pencilmark coloring\n */\n\nimport type { SudokuCell } from '../types/sudoku';\nimport { blockOf, columnOf, rowOf } from '../types/sudoku';\nimport {\n type CellDisplayState,\n type DisplayCellGroup,\n type DisplayLink,\n type HintCell,\n type HintStep,\n type PencilmarkDisplayState,\n SudokuColor,\n ThemeColor,\n UIColorDark,\n UIColorLight,\n type UIColorPalette,\n} from '../types/display';\n\n// =============================================================================\n// Block Definition (matches PlayBoard.blocks)\n// =============================================================================\n\n/**\n * Block class - matches Kotlin Block class\n */\nclass Block {\n readonly index: number;\n readonly cellIndices: number[];\n\n constructor(index: number) {\n this.index = index;\n const blockRow = Math.floor(index / 3);\n const blockCol = index % 3;\n this.cellIndices = [];\n for (let r = 0; r < 3; r++) {\n for (let c = 0; c < 3; c++) {\n const row = blockRow * 3 + r;\n const col = blockCol * 3 + c;\n this.cellIndices.push(row * 9 + col);\n }\n }\n }\n}\n\n/**\n * Row class - matches Kotlin Row class\n */\nclass Row {\n readonly index: number;\n readonly cellIndices: number[];\n\n constructor(index: number) {\n this.index = index;\n this.cellIndices = Array.from({ length: 9 }, (_, col) => index * 9 + col);\n }\n}\n\n/**\n * Column class - matches Kotlin Column class\n */\nclass Column {\n readonly index: number;\n readonly cellIndices: number[];\n\n constructor(index: number) {\n this.index = index;\n this.cellIndices = Array.from({ length: 9 }, (_, row) => row * 9 + index);\n }\n}\n\n// =============================================================================\n// Color Conversion (matches CellPresenter.colorOf)\n// =============================================================================\n\n/**\n * Convert SudokuColor to ThemeColor - matches CellPresenter.colorOf\n */\nfunction sudokuColorToTheme(\n sudokuColor: SudokuColor | null\n): ThemeColor | null {\n switch (sudokuColor) {\n case SudokuColor.BLUE:\n return ThemeColor.SELECTED;\n case SudokuColor.GREEN:\n return ThemeColor.SUCCESS;\n case SudokuColor.YELLOW:\n return ThemeColor.WARNING_SECONDARY;\n case SudokuColor.ORANGE:\n return ThemeColor.WARNING;\n case SudokuColor.RED:\n return ThemeColor.ERROR;\n case SudokuColor.WHITE:\n return ThemeColor.BACKGROUND;\n case SudokuColor.LIGHT_GRAY:\n return ThemeColor.BACKGROUND_SECONDARY;\n case SudokuColor.BLACK:\n return ThemeColor.LABEL;\n case SudokuColor.GRAY:\n return ThemeColor.LABEL_SECONDARY;\n case SudokuColor.CLEAR:\n return ThemeColor.CLEAR;\n default:\n return null;\n }\n}\n\n/**\n * Convert ThemeColor to actual CSS color - matches RendererColor.color\n */\nexport function themeColorToCSS(\n palette: UIColorPalette,\n themeColor: ThemeColor | null\n): string | null {\n switch (themeColor) {\n case ThemeColor.NONE:\n case ThemeColor.CLEAR:\n return palette.clear;\n case ThemeColor.SELECTED:\n return palette.systemPurple;\n case ThemeColor.SUCCESS:\n return palette.systemBlue;\n case ThemeColor.WARNING_SECONDARY:\n return palette.systemYellow;\n case ThemeColor.WARNING:\n return palette.systemOrange;\n case ThemeColor.ERROR:\n return palette.systemRed;\n case ThemeColor.BACKGROUND:\n return palette.systemBackground;\n case ThemeColor.BACKGROUND_SECONDARY:\n return palette.secondarySystemBackground;\n case ThemeColor.LABEL:\n return palette.label;\n case ThemeColor.LABEL_SECONDARY:\n return palette.secondaryLabel;\n case ThemeColor.DISABLED:\n return palette.systemGray;\n default:\n return null;\n }\n}\n\n/**\n * Get the color palette for the current theme\n */\nexport function getColorPalette(isDarkMode: boolean): UIColorPalette {\n return isDarkMode ? UIColorDark : UIColorLight;\n}\n\n// =============================================================================\n// Hint Processing (matches BoardPresenter.calculateCellHints)\n// =============================================================================\n\n/**\n * Process hint areas and cells into a map of cell hints\n * Matches BoardPresenter.calculateCellHints\n */\nexport function calculateCellHints(\n hintStep: HintStep | null\n): Map<number, HintCell> | null {\n if (!hintStep) return null;\n\n const hintsCell = new Map<number, HintCell>();\n\n // Process areas first\n hintStep.areas?.forEach(area => {\n let cellIndices: number[];\n\n switch (area.type) {\n case 'block':\n cellIndices = new Block(area.index).cellIndices;\n break;\n case 'row':\n cellIndices = new Row(area.index).cellIndices;\n break;\n case 'column':\n cellIndices = new Column(area.index).cellIndices;\n break;\n }\n\n cellIndices.forEach(index => {\n hintsCell.set(index, {\n index,\n color: area.color,\n fill: true, // Areas always use fill\n });\n });\n });\n\n // Process cells (overrides areas)\n hintStep.cells?.forEach(cell => {\n hintsCell.set(cell.index, cell);\n });\n\n return hintsCell;\n}\n\n// =============================================================================\n// Cell Color Logic (matches BlockPresenter.color)\n// =============================================================================\n\ninterface CellColorResult {\n backgroundColor: ThemeColor;\n borderColor: ThemeColor | null;\n}\n\n/**\n * Determine background and border colors for a cell\n * Matches BlockPresenter.color exactly\n */\nfunction getCellColors(\n cellIndex: number,\n cellBlockIndex: number,\n cellRowIndex: number,\n cellColumnIndex: number,\n cellHasValue: boolean,\n selectedIndex: number | null,\n selectedBlockIndex: number | null,\n selectedRowIndex: number | null,\n selectedColumnIndex: number | null,\n selectedDigitCells: Set<number> | null\n): CellColorResult {\n // Default background based on block (checkerboard pattern)\n const defaultBackgroundColor =\n cellBlockIndex % 2 === 0\n ? ThemeColor.BACKGROUND_SECONDARY\n : ThemeColor.BACKGROUND;\n\n if (selectedIndex === null) {\n return { backgroundColor: defaultBackgroundColor, borderColor: null };\n }\n\n if (selectedDigitCells !== null) {\n // Digit highlighting mode\n if (selectedDigitCells.has(cellIndex)) {\n // Highlighted cells (have the same digit)\n return { backgroundColor: ThemeColor.SELECTED, borderColor: null };\n }\n\n // Check if this cell is \"impossible\" (in same row/col/block as highlighted cells)\n let isImpossible = cellHasValue;\n if (!isImpossible) {\n for (const highlightedIndex of selectedDigitCells) {\n const hRow = rowOf(highlightedIndex);\n const hCol = columnOf(highlightedIndex);\n const hBlock = blockOf(highlightedIndex);\n if (\n cellRowIndex === hRow ||\n cellColumnIndex === hCol ||\n cellBlockIndex === hBlock\n ) {\n isImpossible = true;\n break;\n }\n }\n }\n\n if (isImpossible) {\n return { backgroundColor: ThemeColor.LABEL_SECONDARY, borderColor: null };\n }\n\n // Possible cells\n return { backgroundColor: defaultBackgroundColor, borderColor: null };\n }\n\n // Normal selection mode\n if (selectedIndex === cellIndex) {\n // Selected cell: default background + SELECTED border\n return {\n backgroundColor: defaultBackgroundColor,\n borderColor: ThemeColor.SELECTED,\n };\n }\n\n if (\n selectedBlockIndex === cellBlockIndex ||\n selectedRowIndex === cellRowIndex ||\n selectedColumnIndex === cellColumnIndex\n ) {\n // Same row, column or block: SELECTED background\n return { backgroundColor: ThemeColor.SELECTED, borderColor: null };\n }\n\n // Other cells\n return { backgroundColor: defaultBackgroundColor, borderColor: null };\n}\n\n// =============================================================================\n// Cell Text Logic (matches CellPresenter.present)\n// =============================================================================\n\ninterface CellTextResult {\n digit: number | null;\n textColor: ThemeColor | null;\n isGiven: boolean;\n}\n\n/**\n * Determine what digit and color to display in a cell\n * Matches CellPresenter.present logic\n */\nfunction getCellText(\n cell: SudokuCell,\n showErrors: boolean,\n hintCell: HintCell | null\n): CellTextResult {\n // Hint select action takes priority\n if (hintCell?.actions?.select != null) {\n return {\n digit: hintCell.actions.select,\n textColor: ThemeColor.SELECTED,\n isGiven: false,\n };\n }\n\n // Hint unselect action (wrong digit to remove)\n if (hintCell?.actions?.unselect != null) {\n return {\n digit: hintCell.actions.unselect,\n textColor: ThemeColor.ERROR,\n isGiven: false,\n };\n }\n\n // User input\n if (cell.input !== null) {\n let textColor: ThemeColor;\n if (showErrors) {\n textColor =\n cell.input === cell.solution ? ThemeColor.SUCCESS : ThemeColor.ERROR;\n } else {\n textColor = ThemeColor.LABEL_SECONDARY;\n }\n return { digit: cell.input, textColor, isGiven: false };\n }\n\n // Given (original)\n if (cell.given !== null) {\n return { digit: cell.given, textColor: ThemeColor.LABEL, isGiven: true };\n }\n\n return { digit: null, textColor: null, isGiven: false };\n}\n\n// =============================================================================\n// Pencilmark Logic (matches CellPresenter.present pencilmark section)\n// =============================================================================\n\n/**\n * Get pencilmark display states\n * Matches CellPresenter.present pencilmark logic\n */\nfunction getPencilmarks(\n cell: SudokuCell,\n hintCell: HintCell | null\n): PencilmarkDisplayState[] {\n const cellPencilmarks = cell.pencilmarks\n ? new Set(cell.pencilmarks)\n : new Set<number>();\n const adding = hintCell?.actions?.add ? new Set(hintCell.actions.add) : null;\n const removing = hintCell?.actions?.remove\n ? new Set(hintCell.actions.remove)\n : null;\n const highlighting = hintCell?.actions?.highlight\n ? new Set(hintCell.actions.highlight)\n : null;\n\n const result: PencilmarkDisplayState[] = [];\n\n for (let pencilmark = 1; pencilmark <= 9; pencilmark++) {\n let color: ThemeColor | null = null;\n\n if (highlighting?.has(pencilmark)) {\n color = ThemeColor.SELECTED;\n } else if (adding?.has(pencilmark)) {\n color = ThemeColor.SUCCESS;\n } else if (removing?.has(pencilmark)) {\n color = ThemeColor.ERROR;\n } else if (cellPencilmarks.has(pencilmark)) {\n color = ThemeColor.LABEL_SECONDARY;\n }\n\n if (color !== null) {\n result.push({ digit: pencilmark, color });\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Main Presenter Function\n// =============================================================================\n\nexport interface PresentBoardOptions {\n /** The 81 cells of the board */\n cells: SudokuCell[];\n /** Currently selected cell index (0-80) or null */\n selectedIndex: number | null;\n /** Whether to show errors (compare input vs solution) */\n showErrors: boolean;\n /** Current hint step (if any) */\n hintStep?: HintStep | null;\n /** Set of cell indices with the selected digit (for digit highlighting) */\n selectedDigitCells?: Set<number> | null;\n}\n\n/**\n * Generate display states for all cells\n * This is the main presenter function that matches the Kotlin renderable behavior\n */\nexport function presentBoard(options: PresentBoardOptions): CellDisplayState[] {\n const {\n cells,\n selectedIndex,\n showErrors,\n hintStep = null,\n selectedDigitCells = null,\n } = options;\n\n // Calculate hint cell map\n const cellHints = calculateCellHints(hintStep);\n\n // Get selected cell properties (if any)\n const _selectedCell = selectedIndex !== null ? cells[selectedIndex] : null;\n void _selectedCell; // Reserved for future use\n const selectedBlockIndex =\n selectedIndex !== null ? blockOf(selectedIndex) : null;\n const selectedRowIndex = selectedIndex !== null ? rowOf(selectedIndex) : null;\n const selectedColumnIndex =\n selectedIndex !== null ? columnOf(selectedIndex) : null;\n\n // Generate display state for each cell\n return cells.map((cell, index) => {\n const cellBlockIndex = blockOf(index);\n const cellRowIndex = rowOf(index);\n const cellColumnIndex = columnOf(index);\n const cellHasValue = cell.input !== null || cell.given !== null;\n\n // Get hint for this cell\n const hintCell = cellHints?.get(index) ?? null;\n\n // Get base colors\n const { backgroundColor, borderColor } = getCellColors(\n index,\n cellBlockIndex,\n cellRowIndex,\n cellColumnIndex,\n cellHasValue,\n selectedIndex,\n selectedBlockIndex,\n selectedRowIndex,\n selectedColumnIndex,\n selectedDigitCells\n );\n\n // Apply hint colors if present\n let finalBgColor = backgroundColor;\n let finalBorderColor = borderColor;\n\n if (hintCell) {\n if (hintCell.fill) {\n // Hint uses fill: override background\n const hintBgColor = sudokuColorToTheme(hintCell.color);\n if (hintBgColor !== null) {\n finalBgColor = hintBgColor;\n }\n } else {\n // Hint uses border\n const hintBdrColor = sudokuColorToTheme(\n hintCell.color ?? SudokuColor.BLUE\n );\n if (hintBdrColor !== null) {\n finalBorderColor = hintBdrColor;\n }\n }\n }\n\n // Get text info\n const { digit, textColor, isGiven } = getCellText(\n cell,\n showErrors,\n hintCell\n );\n\n // Get pencilmarks if no digit\n const pencilmarks = digit === null ? getPencilmarks(cell, hintCell) : [];\n\n return {\n index,\n backgroundColor: finalBgColor,\n borderColor: finalBorderColor,\n textColor,\n digit,\n isGiven,\n pencilmarks,\n };\n });\n}\n\n// =============================================================================\n// Utility: Get cells with a specific digit\n// =============================================================================\n\n/**\n * Get indices of cells that contain a specific digit (given or input)\n * Used for digit highlighting mode\n */\nexport function getCellsWithDigit(\n cells: SudokuCell[],\n digit: number\n): Set<number> {\n const result = new Set<number>();\n cells.forEach((cell, index) => {\n if (cell.given === digit || cell.input === digit) {\n result.add(index);\n }\n });\n return result;\n}\n\n/**\n * Get the selected digit for digit highlighting mode\n * Matches Kotlin SudokuInteractor.selectedDigit logic:\n * - If selected cell has a given value: return given\n * - If selected cell has a CORRECT input (input === solution): return input\n * - Otherwise: return null (no digit highlighting)\n */\nexport function getSelectedDigit(\n cells: SudokuCell[],\n selectedIndex: number | null\n): number | null {\n if (selectedIndex === null) return null;\n\n const cell = cells[selectedIndex];\n if (!cell) return null;\n\n // Given value takes priority\n if (cell.given !== null) {\n return cell.given;\n }\n\n // Only correct input triggers digit highlighting\n if (cell.input !== null && cell.input === cell.solution) {\n return cell.input;\n }\n\n return null;\n}\n\n/**\n * Compute selectedDigitCells based on selected cell\n * Returns Set of cell indices that have the same digit as selected cell\n * Returns null if selected cell doesn't have a highlightable digit\n */\nexport function computeSelectedDigitCells(\n cells: SudokuCell[],\n selectedIndex: number | null\n): Set<number> | null {\n const selectedDigit = getSelectedDigit(cells, selectedIndex);\n if (selectedDigit === null) return null;\n return getCellsWithDigit(cells, selectedDigit);\n}\n\n// =============================================================================\n// Link and Group Conversion\n// =============================================================================\n\n/**\n * Convert a solver link to display link format\n * Converts row/col coordinates to flat cell index\n */\nexport function convertSolverLink(link: {\n fromRow: number;\n fromCol: number;\n toRow: number;\n toCol: number;\n type: 'strong' | 'weak' | 'conflict';\n digit: number;\n}): DisplayLink {\n return {\n fromIndex: link.fromRow * 9 + link.fromCol,\n toIndex: link.toRow * 9 + link.toCol,\n type: link.type,\n digit: link.digit,\n };\n}\n\n/**\n * Convert a solver cell group to display format\n * Converts row/col pairs to flat cell indices and SolverColor to ThemeColor\n */\nexport function convertSolverCellGroup(group: {\n name: string;\n color: string;\n cells: number[][];\n}): DisplayCellGroup {\n // Map solver color string to SudokuColor enum\n const sudokuColor = Object.values(SudokuColor).find(\n c => c.toLowerCase() === group.color.toLowerCase()\n ) as SudokuColor | undefined;\n\n return {\n name: group.name,\n color:\n sudokuColorToTheme(sudokuColor ?? SudokuColor.BLUE) ??\n ThemeColor.SELECTED,\n cellIndices: group.cells.map(cell => (cell[0] ?? 0) * 9 + (cell[1] ?? 0)),\n };\n}\n\n/**\n * Export sudokuColorToTheme for external use\n */\nexport { sudokuColorToTheme };\n"]}
1
+ {"version":3,"file":"sudokuPresenter.js","sourceRoot":"","sources":["../../src/utils/sudokuPresenter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAOL,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,GAEb,MAAM,kBAAkB,CAAC;AAE1B,gFAAgF;AAChF,8CAA8C;AAC9C,gFAAgF;AAEhF;;GAEG;AACH,MAAM,KAAK;IAIT,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,MA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,WAAW,EAAE,CACxB,CAAC;IAE7B,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EACH,kBAAkB,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC;YACnD,UAAU,CAAC,QAAQ;QACrB,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/**\n * Sudoku presenter - port of renderable/SudokuPresenter.kt\n *\n * Handles all display logic for the Sudoku board including:\n * - Cell background colors based on selection state\n * - Cell border colors for selected cells\n * - Text colors (given, input, hint actions)\n * - Hint visualization (areas, cells)\n * - Pencilmark coloring\n */\n\nimport type { SudokuCell } from '../types/sudoku';\nimport { blockOf, columnOf, rowOf } from '../types/sudoku';\nimport {\n type CellDisplayState,\n type DisplayCellGroup,\n type DisplayLink,\n type HintCell,\n type HintStep,\n type PencilmarkDisplayState,\n SudokuColor,\n ThemeColor,\n UIColorDark,\n UIColorLight,\n type UIColorPalette,\n} from '../types/display';\n\n// =============================================================================\n// Block Definition (matches PlayBoard.blocks)\n// =============================================================================\n\n/**\n * Block class - matches Kotlin Block class\n */\nclass Block {\n readonly index: number;\n readonly cellIndices: number[];\n\n constructor(index: number) {\n this.index = index;\n const blockRow = Math.floor(index / 3);\n const blockCol = index % 3;\n this.cellIndices = [];\n for (let r = 0; r < 3; r++) {\n for (let c = 0; c < 3; c++) {\n const row = blockRow * 3 + r;\n const col = blockCol * 3 + c;\n this.cellIndices.push(row * 9 + col);\n }\n }\n }\n}\n\n/**\n * Row class - matches Kotlin Row class\n */\nclass Row {\n readonly index: number;\n readonly cellIndices: number[];\n\n constructor(index: number) {\n this.index = index;\n this.cellIndices = Array.from({ length: 9 }, (_, col) => index * 9 + col);\n }\n}\n\n/**\n * Column class - matches Kotlin Column class\n */\nclass Column {\n readonly index: number;\n readonly cellIndices: number[];\n\n constructor(index: number) {\n this.index = index;\n this.cellIndices = Array.from({ length: 9 }, (_, row) => row * 9 + index);\n }\n}\n\n// =============================================================================\n// Color Conversion (matches CellPresenter.colorOf)\n// =============================================================================\n\n/**\n * Convert SudokuColor to ThemeColor - matches CellPresenter.colorOf\n */\nfunction sudokuColorToTheme(\n sudokuColor: SudokuColor | null\n): ThemeColor | null {\n switch (sudokuColor) {\n case SudokuColor.BLUE:\n return ThemeColor.SELECTED;\n case SudokuColor.GREEN:\n return ThemeColor.SUCCESS;\n case SudokuColor.YELLOW:\n return ThemeColor.WARNING_SECONDARY;\n case SudokuColor.ORANGE:\n return ThemeColor.WARNING;\n case SudokuColor.RED:\n return ThemeColor.ERROR;\n case SudokuColor.WHITE:\n return ThemeColor.BACKGROUND;\n case SudokuColor.LIGHT_GRAY:\n return ThemeColor.BACKGROUND_SECONDARY;\n case SudokuColor.BLACK:\n return ThemeColor.LABEL;\n case SudokuColor.GRAY:\n return ThemeColor.LABEL_SECONDARY;\n case SudokuColor.CLEAR:\n return ThemeColor.CLEAR;\n default:\n return null;\n }\n}\n\n/**\n * Convert ThemeColor to actual CSS color - matches RendererColor.color\n */\nexport function themeColorToCSS(\n palette: UIColorPalette,\n themeColor: ThemeColor | null\n): string | null {\n switch (themeColor) {\n case ThemeColor.NONE:\n case ThemeColor.CLEAR:\n return palette.clear;\n case ThemeColor.SELECTED:\n return palette.systemPurple;\n case ThemeColor.SUCCESS:\n return palette.systemBlue;\n case ThemeColor.WARNING_SECONDARY:\n return palette.systemYellow;\n case ThemeColor.WARNING:\n return palette.systemOrange;\n case ThemeColor.ERROR:\n return palette.systemRed;\n case ThemeColor.BACKGROUND:\n return palette.systemBackground;\n case ThemeColor.BACKGROUND_SECONDARY:\n return palette.secondarySystemBackground;\n case ThemeColor.LABEL:\n return palette.label;\n case ThemeColor.LABEL_SECONDARY:\n return palette.secondaryLabel;\n case ThemeColor.DISABLED:\n return palette.systemGray;\n default:\n return null;\n }\n}\n\n/**\n * Get the color palette for the current theme\n */\nexport function getColorPalette(isDarkMode: boolean): UIColorPalette {\n return isDarkMode ? UIColorDark : UIColorLight;\n}\n\n// =============================================================================\n// Hint Processing (matches BoardPresenter.calculateCellHints)\n// =============================================================================\n\n/**\n * Process hint areas and cells into a map of cell hints\n * Matches BoardPresenter.calculateCellHints\n */\nexport function calculateCellHints(\n hintStep: HintStep | null\n): Map<number, HintCell> | null {\n if (!hintStep) return null;\n\n const hintsCell = new Map<number, HintCell>();\n\n // Process areas first\n hintStep.areas?.forEach(area => {\n let cellIndices: number[];\n\n switch (area.type) {\n case 'block':\n cellIndices = new Block(area.index).cellIndices;\n break;\n case 'row':\n cellIndices = new Row(area.index).cellIndices;\n break;\n case 'column':\n cellIndices = new Column(area.index).cellIndices;\n break;\n }\n\n cellIndices.forEach(index => {\n hintsCell.set(index, {\n index,\n color: area.color,\n fill: true, // Areas always use fill\n });\n });\n });\n\n // Process cells (overrides areas)\n hintStep.cells?.forEach(cell => {\n hintsCell.set(cell.index, cell);\n });\n\n return hintsCell;\n}\n\n// =============================================================================\n// Cell Color Logic (matches BlockPresenter.color)\n// =============================================================================\n\ninterface CellColorResult {\n backgroundColor: ThemeColor;\n borderColor: ThemeColor | null;\n}\n\n/**\n * Determine background and border colors for a cell\n * Matches BlockPresenter.color exactly\n */\nfunction getCellColors(\n cellIndex: number,\n cellBlockIndex: number,\n cellRowIndex: number,\n cellColumnIndex: number,\n cellHasValue: boolean,\n selectedIndex: number | null,\n selectedBlockIndex: number | null,\n selectedRowIndex: number | null,\n selectedColumnIndex: number | null,\n selectedDigitCells: Set<number> | null\n): CellColorResult {\n // Default background based on block (checkerboard pattern)\n const defaultBackgroundColor =\n cellBlockIndex % 2 === 0\n ? ThemeColor.BACKGROUND_SECONDARY\n : ThemeColor.BACKGROUND;\n\n if (selectedIndex === null) {\n return { backgroundColor: defaultBackgroundColor, borderColor: null };\n }\n\n if (selectedDigitCells !== null) {\n // Digit highlighting mode\n if (selectedDigitCells.has(cellIndex)) {\n // Highlighted cells (have the same digit)\n return { backgroundColor: ThemeColor.SELECTED, borderColor: null };\n }\n\n // Check if this cell is \"impossible\" (in same row/col/block as highlighted cells)\n let isImpossible = cellHasValue;\n if (!isImpossible) {\n for (const highlightedIndex of selectedDigitCells) {\n const hRow = rowOf(highlightedIndex);\n const hCol = columnOf(highlightedIndex);\n const hBlock = blockOf(highlightedIndex);\n if (\n cellRowIndex === hRow ||\n cellColumnIndex === hCol ||\n cellBlockIndex === hBlock\n ) {\n isImpossible = true;\n break;\n }\n }\n }\n\n if (isImpossible) {\n return { backgroundColor: ThemeColor.LABEL_SECONDARY, borderColor: null };\n }\n\n // Possible cells\n return { backgroundColor: defaultBackgroundColor, borderColor: null };\n }\n\n // Normal selection mode\n if (selectedIndex === cellIndex) {\n // Selected cell: default background + SELECTED border\n return {\n backgroundColor: defaultBackgroundColor,\n borderColor: ThemeColor.SELECTED,\n };\n }\n\n if (\n selectedBlockIndex === cellBlockIndex ||\n selectedRowIndex === cellRowIndex ||\n selectedColumnIndex === cellColumnIndex\n ) {\n // Same row, column or block: SELECTED background\n return { backgroundColor: ThemeColor.SELECTED, borderColor: null };\n }\n\n // Other cells\n return { backgroundColor: defaultBackgroundColor, borderColor: null };\n}\n\n// =============================================================================\n// Cell Text Logic (matches CellPresenter.present)\n// =============================================================================\n\ninterface CellTextResult {\n digit: number | null;\n textColor: ThemeColor | null;\n isGiven: boolean;\n}\n\n/**\n * Determine what digit and color to display in a cell\n * Matches CellPresenter.present logic\n */\nfunction getCellText(\n cell: SudokuCell,\n showErrors: boolean,\n hintCell: HintCell | null\n): CellTextResult {\n // Hint select action takes priority\n if (hintCell?.actions?.select != null) {\n return {\n digit: hintCell.actions.select,\n textColor: ThemeColor.SELECTED,\n isGiven: false,\n };\n }\n\n // Hint unselect action (wrong digit to remove)\n if (hintCell?.actions?.unselect != null) {\n return {\n digit: hintCell.actions.unselect,\n textColor: ThemeColor.ERROR,\n isGiven: false,\n };\n }\n\n // User input\n if (cell.input !== null) {\n let textColor: ThemeColor;\n if (showErrors) {\n textColor =\n cell.input === cell.solution ? ThemeColor.SUCCESS : ThemeColor.ERROR;\n } else {\n textColor = ThemeColor.LABEL_SECONDARY;\n }\n return { digit: cell.input, textColor, isGiven: false };\n }\n\n // Given (original)\n if (cell.given !== null) {\n return { digit: cell.given, textColor: ThemeColor.LABEL, isGiven: true };\n }\n\n return { digit: null, textColor: null, isGiven: false };\n}\n\n// =============================================================================\n// Pencilmark Logic (matches CellPresenter.present pencilmark section)\n// =============================================================================\n\n/**\n * Get pencilmark display states\n * Matches CellPresenter.present pencilmark logic\n */\nfunction getPencilmarks(\n cell: SudokuCell,\n hintCell: HintCell | null\n): PencilmarkDisplayState[] {\n const cellPencilmarks = cell.pencilmarks\n ? new Set(cell.pencilmarks)\n : new Set<number>();\n const adding = hintCell?.actions?.add ? new Set(hintCell.actions.add) : null;\n const removing = hintCell?.actions?.remove\n ? new Set(hintCell.actions.remove)\n : null;\n const highlighting = hintCell?.actions?.highlight\n ? new Set(hintCell.actions.highlight)\n : null;\n\n const result: PencilmarkDisplayState[] = [];\n\n for (let pencilmark = 1; pencilmark <= 9; pencilmark++) {\n let color: ThemeColor | null = null;\n\n if (highlighting?.has(pencilmark)) {\n color = ThemeColor.SELECTED;\n } else if (adding?.has(pencilmark)) {\n color = ThemeColor.SUCCESS;\n } else if (removing?.has(pencilmark)) {\n color = ThemeColor.ERROR;\n } else if (cellPencilmarks.has(pencilmark)) {\n color = ThemeColor.LABEL_SECONDARY;\n }\n\n if (color !== null) {\n result.push({ digit: pencilmark, color });\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Main Presenter Function\n// =============================================================================\n\nexport interface PresentBoardOptions {\n /** The 81 cells of the board */\n cells: SudokuCell[];\n /** Currently selected cell index (0-80) or null */\n selectedIndex: number | null;\n /** Whether to show errors (compare input vs solution) */\n showErrors: boolean;\n /** Current hint step (if any) */\n hintStep?: HintStep | null;\n /** Set of cell indices with the selected digit (for digit highlighting) */\n selectedDigitCells?: Set<number> | null;\n}\n\n/**\n * Generate display states for all cells\n * This is the main presenter function that matches the Kotlin renderable behavior\n */\nexport function presentBoard(options: PresentBoardOptions): CellDisplayState[] {\n const {\n cells,\n selectedIndex,\n showErrors,\n hintStep = null,\n selectedDigitCells = null,\n } = options;\n\n // Detect conflict hint (has links with type 'conflict')\n const isConflictHint =\n hintStep?.links?.some(link => link.type === 'conflict') ?? false;\n\n // Calculate hint cell map\n const cellHints = calculateCellHints(hintStep);\n\n // Get selected cell properties (if any)\n const _selectedCell = selectedIndex !== null ? cells[selectedIndex] : null;\n void _selectedCell; // Reserved for future use\n const selectedBlockIndex =\n selectedIndex !== null ? blockOf(selectedIndex) : null;\n const selectedRowIndex = selectedIndex !== null ? rowOf(selectedIndex) : null;\n const selectedColumnIndex =\n selectedIndex !== null ? columnOf(selectedIndex) : null;\n\n // Generate display state for each cell\n return cells.map((cell, index) => {\n const cellBlockIndex = blockOf(index);\n const cellRowIndex = rowOf(index);\n const cellColumnIndex = columnOf(index);\n const cellHasValue = cell.input !== null || cell.given !== null;\n\n // Get hint for this cell\n const hintCell = cellHints?.get(index) ?? null;\n\n // Get base colors\n const { backgroundColor, borderColor } = getCellColors(\n index,\n cellBlockIndex,\n cellRowIndex,\n cellColumnIndex,\n cellHasValue,\n selectedIndex,\n selectedBlockIndex,\n selectedRowIndex,\n selectedColumnIndex,\n selectedDigitCells\n );\n\n // Apply hint colors if present\n let finalBgColor = backgroundColor;\n let finalBorderColor = borderColor;\n\n if (hintCell) {\n if (hintCell.fill) {\n // Hint uses fill: override background\n const hintBgColor = sudokuColorToTheme(hintCell.color);\n if (hintBgColor !== null) {\n finalBgColor = hintBgColor;\n }\n } else {\n // Hint uses border\n const hintBdrColor = sudokuColorToTheme(\n hintCell.color ?? SudokuColor.BLUE\n );\n if (hintBdrColor !== null) {\n finalBorderColor = hintBdrColor;\n }\n }\n }\n\n // Get text info\n const { digit, textColor, isGiven } = getCellText(\n cell,\n showErrors,\n hintCell\n );\n\n // In conflict hints, override textColor for orange source cells\n let finalTextColor = textColor;\n if (\n isConflictHint &&\n hintCell &&\n !hintCell.fill &&\n hintCell.color === SudokuColor.ORANGE\n ) {\n finalTextColor = ThemeColor.WARNING;\n }\n\n // Get pencilmarks if no digit\n const pencilmarks = digit === null ? getPencilmarks(cell, hintCell) : [];\n\n return {\n index,\n backgroundColor: finalBgColor,\n borderColor: finalBorderColor,\n textColor: finalTextColor,\n digit,\n isGiven,\n pencilmarks,\n };\n });\n}\n\n// =============================================================================\n// Utility: Get cells with a specific digit\n// =============================================================================\n\n/**\n * Get indices of cells that contain a specific digit (given or input)\n * Used for digit highlighting mode\n */\nexport function getCellsWithDigit(\n cells: SudokuCell[],\n digit: number\n): Set<number> {\n const result = new Set<number>();\n cells.forEach((cell, index) => {\n if (cell.given === digit || cell.input === digit) {\n result.add(index);\n }\n });\n return result;\n}\n\n/**\n * Get the selected digit for digit highlighting mode\n * Matches Kotlin SudokuInteractor.selectedDigit logic:\n * - If selected cell has a given value: return given\n * - If selected cell has a CORRECT input (input === solution): return input\n * - Otherwise: return null (no digit highlighting)\n */\nexport function getSelectedDigit(\n cells: SudokuCell[],\n selectedIndex: number | null\n): number | null {\n if (selectedIndex === null) return null;\n\n const cell = cells[selectedIndex];\n if (!cell) return null;\n\n // Given value takes priority\n if (cell.given !== null) {\n return cell.given;\n }\n\n // Only correct input triggers digit highlighting\n if (cell.input !== null && cell.input === cell.solution) {\n return cell.input;\n }\n\n return null;\n}\n\n/**\n * Compute selectedDigitCells based on selected cell\n * Returns Set of cell indices that have the same digit as selected cell\n * Returns null if selected cell doesn't have a highlightable digit\n */\nexport function computeSelectedDigitCells(\n cells: SudokuCell[],\n selectedIndex: number | null\n): Set<number> | null {\n const selectedDigit = getSelectedDigit(cells, selectedIndex);\n if (selectedDigit === null) return null;\n return getCellsWithDigit(cells, selectedDigit);\n}\n\n// =============================================================================\n// Link and Group Conversion\n// =============================================================================\n\n/**\n * Convert a solver link to display link format\n * Converts row/col coordinates to flat cell index\n */\nexport function convertSolverLink(link: {\n fromRow: number;\n fromCol: number;\n toRow: number;\n toCol: number;\n type: 'strong' | 'weak' | 'conflict';\n digit: number;\n}): DisplayLink {\n return {\n fromIndex: link.fromRow * 9 + link.fromCol,\n toIndex: link.toRow * 9 + link.toCol,\n type: link.type,\n digit: link.digit,\n };\n}\n\n/**\n * Convert a solver cell group to display format\n * Converts row/col pairs to flat cell indices and SolverColor to ThemeColor\n */\nexport function convertSolverCellGroup(group: {\n name: string;\n color: string;\n cells: number[][];\n}): DisplayCellGroup {\n // Map solver color string to SudokuColor enum\n const sudokuColor = Object.values(SudokuColor).find(\n c => c.toLowerCase() === group.color.toLowerCase()\n ) as SudokuColor | undefined;\n\n return {\n name: group.name,\n color:\n sudokuColorToTheme(sudokuColor ?? SudokuColor.BLUE) ??\n ThemeColor.SELECTED,\n cellIndices: group.cells.map(cell => (cell[0] ?? 0) * 9 + (cell[1] ?? 0)),\n };\n}\n\n/**\n * Export sudokuColorToTheme for external use\n */\nexport { sudokuColorToTheme };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/sudojo_lib",
3
- "version": "0.0.149",
3
+ "version": "0.0.150",
4
4
  "description": "Business logic library for Sudojo app",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",