diff --git a/.gitignore b/.gitignore index 307e0388086eb0b74cc97e1114d0633afc525936..994428ea04ef94909d095585e4992f6d5dc4799a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,24 @@ pids ehthumbs.db Thumbs.db -hack +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +*.egg-info/ +.pytest_cache/ +.coverage +htmlcov/ + +# hack issues/ samples/ venv/ +crossword-app/backend-py/src/services/model_cache/ +hack/model_cache/ +cache-dir/ +.KARO.md +CLAUDE.md +crossword-app/backend-py/faiss_cache/ diff --git a/CLAUDE.md b/CLAUDE.md index 4706828551cc021eaa607163494e6f0f4636db83..e874fe7f7d175ffa5a95e52e10dfd556830b27bf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -214,4 +214,6 @@ DATABASE_URL=postgresql://user:pass@host:port/db # Optional - Docker build time: ~5-10 minutes (includes frontend build + Python deps) - Container size: ~1.5GB (includes ML models and dependencies) - Hugging Face Spaces deployment: Automatic on git push -- run unit tests after fixing a bug \ No newline at end of file +- run unit tests after fixing a bug +- do not use any static files for any word generation or clue gebneration. +- we do not prefer inference api based solution \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f6e1da1ec1d273580b98988df310df686c643df8..480c584d056ccfd78d19c98047b0706432accdff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Multi-stage build to optimize performance and security # Stage 1: Builder - Install dependencies and build as root -FROM python:3.11-slim as builder +FROM python:3.11-slim AS builder # Set working directory WORKDIR /app @@ -43,7 +43,7 @@ RUN mkdir -p backend-py/public && cp -r frontend/dist/* backend-py/public/ RUN cd backend-py && ln -sf ../backend/data data # Stage 2: Runtime - Copy only necessary files as non-root user -FROM python:3.11-slim as runtime +FROM python:3.11-slim AS runtime # Copy Python packages from builder stage COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages @@ -78,8 +78,8 @@ ENV PYTHONUNBUFFERED=1 ENV PIP_NO_CACHE_DIR=1 # Health check -HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ - CMD curl -f http://localhost:7860/health || exit 1 +# HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ +# CMD curl -f http://localhost:7860/health || exit 1 # Start the Python backend server with uvicorn for better production performance -CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] \ No newline at end of file +CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] diff --git a/VOCABULARY_OPTIMIZATION.md b/VOCABULARY_OPTIMIZATION.md new file mode 100644 index 0000000000000000000000000000000000000000..5676e66148c8f162549b45a38d516881727f45e6 --- /dev/null +++ b/VOCABULARY_OPTIMIZATION.md @@ -0,0 +1,164 @@ +# Vocabulary Optimization & Unification + +## Problem Solved + +Previously, the crossword system had **vocabulary redundancy** with 3 separate sources: +- **SentenceTransformer Model Vocabulary**: ~30K tokens → ~8-12K actual words after filtering +- **NLTK Words Corpus**: 41,998 words for embeddings in thematic generator +- **WordFreq Database**: 319,938 words for frequency data + +This created inconsistencies, memory waste, and limited vocabulary coverage. + +## Solution: Unified Architecture + +### New Design +- **Single Vocabulary Source**: WordFreq database (319,938 words) +- **Single Embedding Model**: all-mpnet-base-v2 (generates embeddings for any text) +- **Unified Filtering**: Consistent crossword-suitable word filtering +- **Shared Caching**: Single vocabulary + embeddings + frequency cache + +### Key Components + +#### 1. VocabularyManager (`hack/thematic_word_generator.py`) +- Loads and filters WordFreq vocabulary +- Applies crossword-suitable filtering (3-12 chars, alphabetic, excludes boring words) +- Generates frequency data with 10-tier classification +- Handles caching for performance + +#### 2. UnifiedThematicWordGenerator (`hack/thematic_word_generator.py`) +- Uses WordFreq vocabulary instead of NLTK words +- Generates all-mpnet-base-v2 embeddings for WordFreq words +- Maintains 10-tier frequency classification system +- Provides both hack tool API and backend-compatible API + +#### 3. UnifiedWordService (`crossword-app/backend-py/src/services/unified_word_service.py`) +- Bridge adapter for backend integration +- Compatible with existing VectorSearchService interface +- Uses comprehensive WordFreq vocabulary instead of limited model vocabulary + +## Usage + +### For Hack Tools +```python +from thematic_word_generator import UnifiedThematicWordGenerator + +# Initialize with desired vocabulary size +generator = UnifiedThematicWordGenerator(vocab_size_limit=100000) +generator.initialize() + +# Generate thematic words with tier info +results = generator.generate_thematic_words( + topic="science", + num_words=10, + difficulty_tier="tier_5_common" # Optional tier filtering +) + +for word, similarity, tier in results: + print(f"{word}: {similarity:.3f} ({tier})") +``` + +### For Backend Integration + +#### Option 1: Replace VectorSearchService +```python +# In crossword_generator.py +from .unified_word_service import create_unified_word_service + +# Initialize +vector_service = await create_unified_word_service(vocab_size_limit=100000) +crossword_gen = CrosswordGenerator(vector_service=vector_service) +``` + +#### Option 2: Direct Usage +```python +from .unified_word_service import UnifiedWordService + +service = UnifiedWordService(vocab_size_limit=100000) +await service.initialize() + +# Compatible with existing interface +words = await service.find_similar_words("animal", "medium", max_words=15) +``` + +## Performance Improvements + +### Memory Usage +- **Before**: 3 separate vocabularies + embeddings (~500MB+) +- **After**: Single vocabulary + embeddings (~200MB) +- **Reduction**: ~60% memory usage reduction + +### Vocabulary Coverage +- **Before**: Limited to ~8-12K words from model tokenizer +- **After**: Up to 100K+ filtered words from WordFreq database +- **Improvement**: 10x+ vocabulary coverage + +### Consistency +- **Before**: Different words available in hack tools vs backend +- **After**: Same comprehensive vocabulary across all components +- **Benefit**: Consistent word quality and availability + +## Configuration + +### Environment Variables +- `MAX_VOCABULARY_SIZE`: Maximum vocabulary size (default: 100000) +- `EMBEDDING_MODEL`: Model name (default: all-mpnet-base-v2) +- `WORD_SIMILARITY_THRESHOLD`: Minimum similarity (default: 0.3) + +### Vocabulary Size Options +- **Small (10K)**: Fast initialization, basic vocabulary +- **Medium (50K)**: Balanced performance and coverage +- **Large (100K)**: Comprehensive coverage, slower initialization +- **Full (319K)**: Complete WordFreq database, longest initialization + +## Migration Guide + +### For Existing Hack Tools +1. Update imports: `from thematic_word_generator import UnifiedThematicWordGenerator` +2. Replace `ThematicWordGenerator` with `UnifiedThematicWordGenerator` +3. API remains compatible, but now uses comprehensive WordFreq vocabulary + +### For Backend Services +1. Import: `from .unified_word_service import UnifiedWordService` +2. Replace `VectorSearchService` initialization with `UnifiedWordService` +3. All existing methods remain compatible +4. Benefits: Better vocabulary coverage, consistent frequency data + +### Backwards Compatibility +- All existing APIs maintained +- Same method signatures and return formats +- Gradual migration possible - can run both systems in parallel + +## Benefits Summary + +✅ **Eliminates Redundancy**: Single vocabulary source instead of 3 separate ones +✅ **Improves Coverage**: 100K+ words vs previous 8-12K words +✅ **Reduces Memory**: ~60% reduction in memory usage +✅ **Ensures Consistency**: Same vocabulary across hack tools and backend +✅ **Maintains Performance**: Smart caching and batch processing +✅ **Preserves Features**: 10-tier frequency classification, difficulty filtering +✅ **Enables Growth**: Easy to add new features with unified architecture + +## Cache Management + +### Cache Locations +- **Hack tools**: `hack/model_cache/` +- **Backend**: `crossword-app/backend-py/cache/unified_generator/` + +### Cache Files +- `unified_vocabulary_.pkl`: Filtered vocabulary +- `unified_frequencies_.pkl`: Frequency data +- `unified_embeddings__.npy`: Pre-computed embeddings + +### Cache Invalidation +Caches are automatically rebuilt if: +- Vocabulary size limit changes +- Embedding model changes +- WordFreq database updates (rare) + +## Future Enhancements + +1. **Semantic Clustering**: Group words by semantic similarity +2. **Dynamic Difficulty**: Real-time difficulty adjustment based on user performance +3. **Topic Expansion**: Automatic topic discovery and expansion +4. **Multilingual Support**: Extend to other languages using WordFreq +5. **Custom Vocabularies**: Allow domain-specific vocabulary additions \ No newline at end of file diff --git a/crossword-app/backend-py/CROSSWORD_GENERATION_WALKTHROUGH.md b/crossword-app/backend-py/CROSSWORD_GENERATION_WALKTHROUGH.md new file mode 100644 index 0000000000000000000000000000000000000000..148a3c30c60beec8bb6ccabd42aaa8fc4eff0992 --- /dev/null +++ b/crossword-app/backend-py/CROSSWORD_GENERATION_WALKTHROUGH.md @@ -0,0 +1,434 @@ +# Crossword Generation Code Walkthrough + +This document provides a detailed, line-by-line walkthrough of how crossword puzzle generation works in the Python backend, tracing the complete flow from API request to finalized words and clues. + +## Overview + +The Python backend implements AI-powered crossword generation using: +- **FastAPI** for web framework and API endpoints +- **Vector similarity search** with sentence-transformers and FAISS for intelligent word discovery +- **Backtracking algorithm** for word placement in the crossword grid +- **Multi-layer caching system** for performance and fallback mechanisms + +## 1. Application Startup (`app.py`) + +### Entry Point and Service Initialization + +```python +# Lines 66-95: Async lifespan context manager +@asynccontextmanager +async def lifespan(app: FastAPI): + global vector_service + + # Startup initialization + vector_service = VectorSearchService() + await vector_service.initialize() + app.state.vector_service = vector_service +``` + +**Flow:** +1. FastAPI application starts with lifespan context manager +2. Creates global `VectorSearchService` instance (line 79) +3. Calls `vector_service.initialize()` (line 82) which: + - Loads sentence-transformer model (~30-60 seconds) + - Builds or loads cached FAISS index for word embeddings + - Initializes word cache manager for fallbacks +4. Makes vector service available to all API routes via `app.state` + +## 2. API Request Handling (`src/routes/api.py`) + +### Crossword Generation Endpoint + +```python +# Lines 77-118: Main crossword generation endpoint +@router.post("/generate", response_model=PuzzleResponse) +async def generate_puzzle( + request: GeneratePuzzleRequest, + crossword_gen: CrosswordGenerator = Depends(get_crossword_generator) +): +``` + +**Flow:** +1. Client POST request to `/api/generate` with JSON body: + ```json + { + "topics": ["animals", "science"], + "difficulty": "medium", + } + ``` + +2. FastAPI validates request against `GeneratePuzzleRequest` model (lines 20-23) + +3. Dependency injection calls `get_crossword_generator()` (lines 57-63): + ```python + def get_crossword_generator(request: Request) -> CrosswordGenerator: + global generator + if generator is None: + vector_service = getattr(request.app.state, 'vector_service', None) + generator = CrosswordGenerator(vector_service) + return generator + ``` + +4. Creates or reuses `CrosswordGenerator` wrapper with vector service reference + +## 3. Crossword Generation Wrapper (`src/services/crossword_generator_wrapper.py`) + +### Simple Delegation Layer + +```python +# Lines 20-51: Generate puzzle method +async def generate_puzzle( + self, + topics: List[str], + difficulty: str = "medium", + ) -> Dict[str, Any]: +``` + +**Flow:** +1. Wrapper receives request from API route +2. **Line 41**: Imports actual generator to avoid circular imports: + ```python + from .crossword_generator import CrosswordGenerator as ActualGenerator + ``` +3. **Line 42**: Creates actual generator instance with vector service +4. **Line 44**: Delegates to actual generator's `generate_puzzle()` method + +## 4. Core Crossword Generation (`src/services/crossword_generator.py`) + +### 4.1 Main Generation Method + +```python +# Lines 22-66: Core puzzle generation +async def generate_puzzle(self, topics: List[str], difficulty: str = "medium", = False): +``` + +**Key steps:** + +1. **Line 37**: Select words using AI or static sources: + ```python + words = await self._select_words(topics, difficulty, use_ai) + ``` + +2. **Line 44**: Create crossword grid from selected words: + ```python + grid_result = self._create_grid(words) + ``` + +3. **Lines 52-62**: Return structured response with grid, clues, and metadata + +### 4.2 Word Selection Process + +```python +# Lines 68-97: Word selection logic +async def _select_words(self, topics: List[str], difficulty: str, ): +``` + +**Flow branches based on `use_ai` parameter:** + +#### AI-Powered Word Selection (Lines 72-83): +```python +if use_ai and self.vector_service: + for topic in topics: + ai_words = await self.vector_service.find_similar_words( + topic, difficulty, self.max_words // len(topics) + ) + all_words.extend(ai_words) +``` + +#### Fallback to Cached Words (Lines 86-91): +```python +if self.vector_service: + for topic in topics: + cached_words = await self.vector_service._get_cached_fallback( + topic, difficulty, self.max_words // len(topics) + ) +``` + +#### Final Fallback to Static JSON Files (Lines 93-95): +```python +else: + all_words = await self._get_static_words(topics, difficulty) +``` + +### 4.3 Word Sorting for Crossword Viability + +```python +# Lines 129-168: Sort words by crossword suitability +def _sort_words_for_crossword(self, words: List[Dict[str, Any]]): +``` + +**Scoring algorithm:** +- **Lines 138-147**: Length-based scoring (shorter words preferred) +- **Lines 150-153**: Common letter bonus (E, A, R, I, O, T, N, S) +- **Lines 156-158**: Vowel distribution bonus +- **Lines 161-162**: Penalty for very long words + +## 5. AI Word Discovery (`src/services/vector_search.py`) + +### 5.1 Vector Search Initialization + +```python +# Lines 71-143: Service initialization +async def initialize(self): +``` + +**Initialization flow:** +1. **Lines 90-92**: Load sentence-transformer model +2. **Lines 95-119**: Build or load cached FAISS index +3. **Lines 124-134**: Initialize word cache manager + +### 5.2 Core Word Finding Algorithm + +```python +# Lines 279-374: Main word discovery method +async def find_similar_words( + self, + topic: str, + difficulty: str = "medium", + max_words: int = 15 +): +``` + +**Search strategy branches:** + +#### Hierarchical Search (Lines 296-325): +```python +if self.use_hierarchical_search: + all_candidates = await self._hierarchical_search(topic, difficulty, max_words) + combined_results = self._combine_hierarchical_results(all_candidates, max_words * 2) +``` + +#### Traditional Single Search (Lines 328-337): +```python +else: + traditional_results = await self._traditional_single_search(topic, difficulty, max_words * 2) +``` + +### 5.3 Hierarchical Search Process + +```python +# Lines 639-748: Multi-phase hierarchical search +async def _hierarchical_search(self, topic: str, difficulty: str, max_words: int): +``` + +**Three-phase approach:** + +#### Phase 1: Topic Variations (Lines 652-694) +```python +topic_variations = self._expand_topic_variations(topic) # "Animal" → ["Animal", "Animals"] + +for variation in topic_variations: + topic_embedding = self.model.encode([variation], convert_to_numpy=True) + scores, indices = self.faiss_index.search(topic_embedding, search_size) + variation_candidates = self._collect_candidates_with_threshold(scores, indices, threshold, variation, difficulty) +``` + +#### Phase 2: Subcategory Identification (Lines 697-700) +```python +subcategories = self._identify_subcategories(main_topic_candidates, topic) +``` + +#### Phase 3: Subcategory Search (Lines 703-733) +```python +for subcategory in subcategories: + subcat_embedding = self.model.encode([subcategory], convert_to_numpy=True) + sub_scores, sub_indices = self.faiss_index.search(subcat_embedding, sub_search_size) +``` + +### 5.4 Word Quality Filtering + +```python +# Lines 1164-1215: Candidate collection with filtering +def _collect_candidates_with_threshold(self, scores, indices, threshold, topic, difficulty): +``` + +**Multi-stage filtering:** +1. **Line 1176**: Similarity threshold check +2. **Line 1183**: Difficulty matching (word length) +3. **Line 1185**: Interest and topic relevance check: + ```python + if self._is_interesting_word(word, topic) and self._is_topic_relevant(word, topic): + ``` + +## 6. Grid Creation and Word Placement + +### 6.1 Grid Generation Entry Point + +```python +# Lines 170-243: Main grid creation method +def _create_grid(self, words: List[Dict[str, Any]]): +``` + +**Flow:** +1. **Lines 184-203**: Process and sort words by length (longest first) +2. **Lines 209-213**: Calculate appropriate grid size +3. **Lines 212-237**: Multiple placement attempts with increasing grid size +4. **Lines 240-241**: Fallback to simple two-word cross + +### 6.2 Word Placement Algorithm + +```python +# Lines 259-295: Backtracking word placement +def _place_words_in_grid(self, word_list: List[str], word_objs: List[Dict[str, Any]], size: int): +``` + +**Setup:** +- **Line 263**: Initialize empty grid with dots +- **Line 270**: Call recursive backtracking algorithm +- **Lines 272-287**: Generate clues and assign crossword numbers + +### 6.3 Backtracking Algorithm + +```python +# Lines 297-357: Recursive backtracking placement +def _backtrack_placement(self, grid, word_list, word_objs, word_index, placed_words, start_time, timeout): +``` + +**Algorithm flow:** + +#### Base Cases: +- **Lines 302-303**: Timeout check every 50 calls +- **Lines 305-306**: Success when all words placed + +#### First Word Placement (Lines 312-332): +```python +if word_index == 0: + center_row = size // 2 + center_col = (size - len(word)) // 2 + + if self._can_place_word(grid, word, center_row, center_col, "horizontal"): + original_state = self._place_word(grid, word, center_row, center_col, "horizontal") +``` + +#### Subsequent Word Placement (Lines 334-356): +```python +all_placements = self._find_all_intersection_placements(grid, word, placed_words) +all_placements.sort(key=lambda p: p["score"], reverse=True) + +for placement in all_placements: + if self._can_place_word(grid, word, row, col, direction): + # Try placement and recurse + if self._backtrack_placement(...): + return True + # Backtrack if failed + self._remove_word(grid, original_state) +``` + +### 6.4 Word Placement Validation + +```python +# Lines 359-417: Comprehensive placement validation +def _can_place_word(self, grid: List[List[str]], word: str, row: int, col: int, direction: str): +``` + +**Critical validation checks:** +1. **Lines 364-365**: Boundary checks +2. **Lines 372-375**: Word boundary enforcement (no adjacent letters) +3. **Lines 378-390**: Letter-by-letter placement validation +4. **Lines 388-390**: Perpendicular intersection validation + +### 6.5 Intersection Finding + +```python +# Lines 486-505: Find all possible intersections +def _find_all_intersection_placements(self, grid, word, placed_words): +``` + +**Process:** +1. **Lines 491-502**: For each placed word, find letter intersections +2. **Lines 496-502**: Calculate placement position for each intersection +3. **Lines 499-502**: Score placement quality + +## 7. Clue Generation and Final Assembly + +### 7.1 Grid Trimming and Optimization + +```python +# Lines 589-642: Remove excess empty space +def _trim_grid(self, grid, placed_words): +``` + +**Process:** +1. **Lines 595-610**: Find bounding box of all placed words +2. **Lines 612-631**: Create trimmed grid with padding +3. **Lines 634-641**: Update word positions relative to new grid + +### 7.2 Crossword Numbering + +```python +# Lines 698-750: Assign proper crossword numbers and create clues +def _assign_numbers_and_clues(self, placed_words, clues_data): +``` + +**Crossword numbering rules:** +1. **Lines 710-714**: Group words by starting position +2. **Lines 716**: Sort by reading order (top-to-bottom, left-to-right) +3. **Lines 725-749**: Assign shared numbers for words starting at same position +4. **Lines 738-745**: Create clue objects with proper formatting + +### 7.3 Final Response Assembly + +**Back in `crossword_generator.py` lines 52-62:** +```python +return { + "grid": grid_result["grid"], + "clues": grid_result["clues"], + "metadata": { + "topics": topics, + "difficulty": difficulty, + "wordCount": len(grid_result["placed_words"]), + "size": len(grid_result["grid"]), + "aiGenerated": } +} +``` + +## 8. Caching System (`src/services/word_cache.py`) + +### 8.1 Cache Initialization + +```python +# Lines 75-113: Load existing cache files +async def initialize(self): +``` + +**Process:** +1. **Lines 86-108**: Load all `.json` cache files from disk +2. **Lines 99-102**: Validate cache structure and load into memory +3. **Lines 110**: Report loaded cache statistics + +### 8.2 Word Caching + +```python +# Lines 166-224: Cache successful word discoveries +async def cache_words(self, topic, difficulty, words, source="vector_search"): +``` + +**Storage process:** +1. **Lines 186-193**: Enhance words with caching metadata +2. **Lines 196-207**: Create structured cache data with expiration +3. **Lines 210-213**: Save to disk (if permissions allow) +4. **Lines 216-217**: Update in-memory cache + +## Complete Data Flow Summary + +1. **API Request** → `/api/generate` with topics, difficulty, 2. **Route Handler** → Validates request, injects dependencies +3. **Wrapper** → Delegates to actual generator with vector service +4. **Word Selection** → AI vector search OR cached words OR static JSON fallback +5. **Vector Search** (if AI enabled): + - Load sentence-transformer model + - Perform hierarchical semantic search + - Filter by similarity threshold, difficulty, relevance + - Apply word exclusions and variety filtering +6. **Grid Creation**: + - Sort words by crossword viability + - Calculate appropriate grid size + - Use backtracking algorithm to place words + - Validate word boundaries and intersections +7. **Grid Optimization**: + - Trim excess empty space + - Assign proper crossword numbers + - Generate clue objects +8. **Response Assembly** → Return grid, clues, and metadata +9. **Caching** → Store successful AI discoveries for future use + +The system gracefully degrades from AI → cached words → static words, ensuring crossword generation always succeeds even when AI components fail. \ No newline at end of file diff --git a/crossword-app/backend-py/README.md b/crossword-app/backend-py/README.md index db6dbd39fe3dd285f9f6241e2ef00ac7c3463541..9dbecaf323e37c0ecc0a16a07e6ef19c4b701a10 100644 --- a/crossword-app/backend-py/README.md +++ b/crossword-app/backend-py/README.md @@ -1,24 +1,25 @@ -# Python Backend with Vector Similarity Search +# Python Backend with Thematic AI Word Generation -This is the Python implementation of the crossword generator backend, featuring true AI word generation via vector similarity search. +This is the Python implementation of the crossword generator backend, featuring AI-powered thematic word generation using WordFreq vocabulary and semantic embeddings. ## 🚀 Features -- **True Vector Search**: Uses sentence-transformers + FAISS for semantic word discovery -- **30K+ Vocabulary**: Searches through full model vocabulary instead of limited static lists +- **Thematic Word Generation**: Uses sentence-transformers for semantic word discovery from WordFreq vocabulary +- **319K+ Word Database**: Comprehensive vocabulary from WordFreq with frequency data +- **10-Tier Difficulty System**: Smart word selection based on frequency tiers +- **Environment Variable Configuration**: Flexible cache and model configuration - **FastAPI**: Modern, fast Python web framework - **Same API**: Compatible with existing React frontend -- **Hybrid Approach**: AI vector search with static word fallback ## 🔄 Differences from JavaScript Backend | Feature | JavaScript Backend | Python Backend | |---------|-------------------|----------------| -| **Word Generation** | Embedding filtering of static lists | True vector similarity search | -| **Vocabulary Size** | ~100 words per topic | 30K+ words from model | -| **AI Approach** | Semantic similarity filtering | Nearest neighbor search | -| **Performance** | Fast but limited | Slower startup, better results | -| **Dependencies** | Node.js + HuggingFace API | Python + ML libraries | +| **Word Generation** | Static word lists | Thematic AI word generation from 319K vocabulary | +| **Vocabulary Size** | ~100 words per topic | Filtered from 319K WordFreq database | +| **AI Approach** | Basic filtering | Semantic similarity with frequency tiers | +| **Performance** | Fast but limited | Slower startup, richer word selection | +| **Dependencies** | Node.js + static files | Python + ML libraries | ## 🛠️ Setup & Installation @@ -70,10 +71,11 @@ backend-py/ ├── requirements-dev.txt # Full development dependencies ├── src/ │ ├── services/ -│ │ ├── vector_search.py # Core vector similarity search -│ │ └── crossword_generator.py # Puzzle generation logic +│ │ ├── thematic_word_service.py # Thematic AI word generation +│ │ ├── crossword_generator.py # Puzzle generation logic +│ │ └── crossword_generator_wrapper.py # Service wrapper │ └── routes/ -│ └── api.py # API endpoints (matches JS backend) +│ └── api.py # API endpoints (matches JS backend) ├── test-unit/ # Unit tests (pytest framework) - 5 files │ ├── test_crossword_generator.py │ ├── test_api_routes.py @@ -90,8 +92,9 @@ backend-py/ ### Core ML Stack - `sentence-transformers`: Local model loading and embeddings -- `faiss-cpu`: Fast vector similarity search +- `wordfreq`: 319K word vocabulary with frequency data - `torch`: PyTorch for model inference +- `scikit-learn`: Cosine similarity and clustering - `numpy`: Vector operations ### Web Framework @@ -203,39 +206,56 @@ pytest test-unit/ --cov=src --cov-report=html --ignore=test-unit/test_vector_sea ## 🔧 Configuration -Environment variables (set in HuggingFace Spaces): +### Environment Variables + +The backend supports flexible configuration via environment variables: ```bash -# Core settings -PORT=7860 -NODE_ENV=production +# Cache Configuration +CACHE_DIR=/app/cache # Cache directory for all service files +THEMATIC_VOCAB_SIZE_LIMIT=50000 # Maximum vocabulary size (default: 100000) +THEMATIC_MODEL_NAME=all-mpnet-base-v2 # Sentence transformer model -# AI Configuration -EMBEDDING_MODEL=sentence-transformers/all-mpnet-base-v2 -WORD_SIMILARITY_THRESHOLD=0.65 +# Core Application Settings +PORT=7860 # Server port +NODE_ENV=production # Environment mode # Optional -LOG_LEVEL=INFO +LOG_LEVEL=INFO # Logging level ``` -## 🎯 Vector Search Process +### Cache Structure + +The service creates the following cache files: + +``` +{CACHE_DIR}/ +├── vocabulary_{size}.pkl # Processed vocabulary words +├── frequencies_{size}.pkl # Word frequency data +├── embeddings_{model}_{size}.npy # Word embeddings +└── sentence-transformers/ # Hugging Face model cache +``` + +## 🎯 Thematic Word Generation Process 1. **Initialization**: + - Load WordFreq vocabulary database (319K words) + - Filter words for crossword suitability (length, content) - Load sentence-transformers model locally - - Extract 30K+ vocabulary from model tokenizer - - Pre-compute embeddings for all vocabulary words - - Build FAISS index for fast similarity search + - Pre-compute embeddings for filtered vocabulary + - Create 10-tier frequency classification system 2. **Word Generation**: - Get topic embedding: `"Animals" → [768-dim vector]` - - Search FAISS index for nearest neighbors - - Filter by similarity threshold (0.65+) - - Filter by difficulty (word length) + - Compute cosine similarity with all vocabulary embeddings + - Filter by similarity threshold and difficulty tier + - Filter by crossword-specific criteria (length, etc.) - Return top matches with generated clues -3. **Fallback**: - - If vector search fails → use static word lists - - If insufficient AI words → supplement with static words +3. **Multi-Theme Support**: + - Detect multiple themes using clustering + - Generate words that relate to combined themes + - Balance word selection across different topics ## 🧪 Testing @@ -248,16 +268,163 @@ python test_local.py python app.py ``` -## 🐳 Docker Deployment +## 🐳 Container Deployment + +### Docker Run with Cache Configuration + +```bash +# Basic deployment +docker run -e CACHE_DIR=/app/cache \ + -e THEMATIC_VOCAB_SIZE_LIMIT=50000 \ + -v /host/cache:/app/cache \ + -p 7860:7860 \ + your-crossword-app + +# With all configuration options +docker run -e CACHE_DIR=/app/cache \ + -e THEMATIC_VOCAB_SIZE_LIMIT=25000 \ + -e THEMATIC_MODEL_NAME=all-mpnet-base-v2 \ + -e NODE_ENV=production \ + -v /host/cache:/app/cache \ + -p 7860:7860 \ + your-crossword-app +``` + +### Docker Compose + +```yaml +version: '3.8' +services: + crossword-backend: + image: your-crossword-app + environment: + - CACHE_DIR=/app/cache + - THEMATIC_VOCAB_SIZE_LIMIT=50000 + - THEMATIC_MODEL_NAME=all-mpnet-base-v2 + - NODE_ENV=production + volumes: + - ./cache:/app/cache + ports: + - "7860:7860" + restart: unless-stopped +``` + +### Pre-built Cache Strategy (Recommended) + +For production deployments, pre-build the cache to avoid long startup times: + +```bash +# 1. Build cache locally or in a build container +export CACHE_DIR=/local/cache +export THEMATIC_VOCAB_SIZE_LIMIT=50000 +python -c "from src.services.thematic_word_service import ThematicWordService; s=ThematicWordService(); s.initialize()" + +# 2. Deploy with pre-built cache (read-only mount) +docker run -e CACHE_DIR=/app/cache \ + -v /local/cache:/app/cache:ro \ + -p 7860:7860 \ + your-crossword-app +``` + +### Debugging Cache Issues -The Dockerfile has been updated to use Python backend: +If cache files are not being created in your container: -```dockerfile -FROM python:3.9-slim -# ... install dependencies -# ... build frontend (same as before) -# ... copy to backend-py/public/ -CMD ["python", "app.py"] +1. **Check Health Endpoints:** +```bash +# Basic health check +curl http://localhost:7860/api/health + +# Detailed cache status +curl http://localhost:7860/api/health/cache + +# Force cache re-initialization +curl -X POST http://localhost:7860/api/health/cache/reinitialize +``` + +2. **Check Container Logs:** +```bash +docker logs your-container-name +``` +Look for cache directory permissions and initialization messages. + +3. **Test Cache Directory:** +```bash +# Run test script to verify cache setup +docker exec your-container python test_cache_startup.py +``` + +4. **Common Issues:** + - **Permission denied**: Container user can't write to mounted volume + - **Missing dependencies**: ML libraries not installed in container + - **Volume not mounted**: Cache directory not properly mounted + - **Environment variables**: `CACHE_DIR` not set correctly + +5. **Fix Permission Issues:** +```bash +# Option 1: Change ownership of host directory +sudo chown -R 1000:1000 /host/cache + +# Option 2: Run container with specific user +docker run --user 1000:1000 ... + +# Option 3: Set permissions in Dockerfile +RUN mkdir -p /app/cache && chmod 777 /app/cache +``` + +### Kubernetes Deployment + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: crossword-config +data: + CACHE_DIR: "/app/cache" + THEMATIC_VOCAB_SIZE_LIMIT: "50000" + THEMATIC_MODEL_NAME: "all-mpnet-base-v2" + NODE_ENV: "production" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: crossword-cache +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: crossword-backend +spec: + replicas: 1 + selector: + matchLabels: + app: crossword-backend + template: + metadata: + labels: + app: crossword-backend + spec: + containers: + - name: backend + image: your-crossword-app + envFrom: + - configMapRef: + name: crossword-config + volumeMounts: + - name: cache-volume + mountPath: /app/cache + ports: + - containerPort: 7860 + volumes: + - name: cache-volume + persistentVolumeClaim: + claimName: crossword-cache ``` ## 🧪 Testing @@ -301,19 +468,25 @@ pytest tests/ --cov=src --cov-report=html **Startup Time**: - JavaScript: ~2 seconds -- Python: ~30-60 seconds (model download + index building) +- Python: ~30-60 seconds (model download + embedding generation) +- Python (with cache): ~5-10 seconds **Word Quality**: -- JavaScript: Limited by static word lists -- Python: Access to full model vocabulary with semantic understanding +- JavaScript: Limited by static word lists (~100 words/topic) +- Python: Rich thematic generation from 319K word database **Memory Usage**: - JavaScript: ~100MB -- Python: ~500MB-1GB (model + embeddings + FAISS index) +- Python: ~500MB-1GB (model + embeddings) +- Cache Size: ~50-200MB per 50K vocabulary **API Response Time**: -- JavaScript: ~100ms (after cache warm-up) -- Python: ~200-500ms (vector search + filtering) +- JavaScript: ~100ms (static word lookup) +- Python: ~200-500ms (semantic similarity computation) + +**Cache Performance**: +- Vocabulary loading: ~1-2 seconds from cache vs 30+ seconds generation +- Embeddings loading: ~2-5 seconds from cache vs 60+ seconds generation ## 🔄 Migration Strategy @@ -325,8 +498,10 @@ pytest tests/ --cov=src --cov-report=html ## 🎯 Next Steps -- [ ] Test vector search with real model -- [ ] Optimize FAISS index performance +- [x] Replace vector search with thematic word generation +- [x] Implement environment variable cache configuration +- [x] Add 10-tier difficulty system based on word frequency +- [ ] Optimize embedding computation performance - [ ] Add more sophisticated crossword grid generation - [ ] Implement LLM-based clue generation -- [ ] Add caching for frequently requested topics \ No newline at end of file +- [ ] Add cache warming strategies for production deployment \ No newline at end of file diff --git a/crossword-app/backend-py/all-packages.txt b/crossword-app/backend-py/all-packages.txt new file mode 100644 index 0000000000000000000000000000000000000000..6d6cea5cb283a521d721f612e8fa9901d428b3f3 --- /dev/null +++ b/crossword-app/backend-py/all-packages.txt @@ -0,0 +1,69 @@ +annotated-types==0.7.0 +anyio==4.10.0 +certifi==2025.8.3 +charset-normalizer==3.4.3 +click==8.2.1 +exceptiongroup==1.3.0 +faiss-cpu==1.9.0 +fastapi==0.115.0 +filelock==3.19.1 +fsspec==2025.7.0 +h11==0.16.0 +httpcore==1.0.9 +httptools==0.6.4 +httpx==0.28.1 +huggingface-hub==0.26.2 +idna==3.10 +iniconfig==2.1.0 +Jinja2==3.1.6 +joblib==1.5.1 +MarkupSafe==3.0.2 +mpmath==1.3.0 +networkx==3.4.2 +numpy==1.26.4 +nvidia-cublas-cu12==12.4.5.8 +nvidia-cuda-cupti-cu12==12.4.127 +nvidia-cuda-nvrtc-cu12==12.4.127 +nvidia-cuda-runtime-cu12==12.4.127 +nvidia-cudnn-cu12==9.1.0.70 +nvidia-cufft-cu12==11.2.1.3 +nvidia-curand-cu12==10.3.5.147 +nvidia-cusolver-cu12==11.6.1.9 +nvidia-cusparse-cu12==12.3.1.170 +nvidia-nccl-cu12==2.21.5 +nvidia-nvjitlink-cu12==12.4.127 +nvidia-nvtx-cu12==12.4.127 +packaging==25.0 +pillow==11.3.0 +pluggy==1.6.0 +pydantic==2.9.2 +pydantic-settings==2.5.2 +pydantic_core==2.23.4 +pytest==8.3.4 +pytest-asyncio==0.25.0 +python-dotenv==1.0.1 +python-multipart==0.0.12 +PyYAML==6.0.2 +regex==2025.7.34 +requests==2.32.4 +safetensors==0.6.2 +scikit-learn==1.5.2 +scipy==1.15.3 +sentence-transformers==3.3.0 +sniffio==1.3.1 +starlette==0.38.6 +structlog==24.4.0 +sympy==1.13.1 +threadpoolctl==3.6.0 +tokenizers==0.21.4 +tomli==2.2.1 +torch==2.5.1 +tqdm==4.67.1 +transformers==4.47.1 +triton==3.1.0 +typing_extensions==4.14.1 +urllib3==2.5.0 +uvicorn==0.32.1 +uvloop==0.21.0 +watchfiles==1.1.0 +websockets==15.0.1 diff --git a/crossword-app/backend-py/app.py b/crossword-app/backend-py/app.py index 28949a214fe6b9e10e2fc1f7fd47e507b354438e..f60a6386ab124cdcc962370255e2f798ff2992eb 100644 --- a/crossword-app/backend-py/app.py +++ b/crossword-app/backend-py/app.py @@ -17,61 +17,117 @@ import uvicorn from dotenv import load_dotenv from src.routes.api import router as api_router -from src.services.vector_search import VectorSearchService +from src.services.thematic_word_service import ThematicWordService # Load environment variables load_dotenv() -# Set up logging -logging.basicConfig(level=logging.INFO) +# Set up logging with filename and line numbers +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s', + datefmt='%H:%M:%S' +) logger = logging.getLogger(__name__) -def log_with_timestamp(message): - """Helper to log with precise timestamp.""" - timestamp = datetime.now().strftime("%H:%M:%S.%f")[:-3] - logger.info(f"[{timestamp}] {message}") +# All services now use standard Python logging with filename/line numbers -# Global vector search service instance -vector_service = None +# Global thematic service instance +thematic_service = None @asynccontextmanager async def lifespan(app: FastAPI): """Initialize and cleanup application resources.""" - global vector_service + global thematic_service # Startup startup_time = time.time() - log_with_timestamp("🚀 Initializing Python backend with vector search...") + logger.info("🚀 Initializing Python backend with thematic word service...") - # Initialize vector search service + # Initialize thematic service try: service_start = time.time() - log_with_timestamp("🔧 Creating VectorSearchService instance...") - vector_service = VectorSearchService() + logger.info("🔧 Creating ThematicWordService instance...") + thematic_service = ThematicWordService() + + # Log cache configuration for debugging + cache_status = thematic_service.get_cache_status() + logger.info(f"📁 Cache directory: {cache_status['cache_directory']}") + logger.info(f"🔍 Cache directory exists: {os.path.exists(cache_status['cache_directory'])}") + logger.info(f"✏️ Cache directory writable: {os.access(cache_status['cache_directory'], os.W_OK)}") + + # Check for existing cache files + cache_complete = cache_status['complete'] + logger.info(f"📦 Existing cache complete: {cache_complete}") + if not cache_complete: + for cache_type in ['vocabulary_cache', 'frequency_cache', 'embeddings_cache']: + cache_info = cache_status[cache_type] + logger.info(f" {cache_type}: exists={cache_info['exists']}, path={cache_info['path']}") - log_with_timestamp("⚡ Starting vector search initialization...") - await vector_service.initialize() + # Force eager initialization to create cache files + logger.info("⚡ Starting thematic service initialization (creating cache files)...") + await thematic_service.initialize_async() + + # Verify cache files were created + cache_status_after = thematic_service.get_cache_status() + logger.info(f"✅ Cache status after initialization: complete={cache_status_after['complete']}") + for cache_type in ['vocabulary_cache', 'frequency_cache', 'embeddings_cache']: + cache_info = cache_status_after[cache_type] + if cache_info['exists']: + logger.info(f" ✅ {cache_type}: {cache_info.get('size_mb', 0):.1f}MB") + else: + logger.warning(f" ❌ {cache_type}: NOT CREATED") init_time = time.time() - service_start - log_with_timestamp(f"✅ Vector search service initialized in {init_time:.2f}s") + logger.info(f"🎉 Thematic service initialized in {init_time:.2f}s") + + # Initialize WordNet clue generator during startup + logger.info("🔧 Initializing WordNet clue generator...") + try: + wordnet_start = time.time() + from src.services.wordnet_clue_generator import WordNetClueGenerator + cache_dir = thematic_service.cache_dir if thematic_service else "./cache" + wordnet_generator = WordNetClueGenerator(cache_dir=str(cache_dir)) + wordnet_generator.initialize() + + # Store in thematic service for later use + if thematic_service: + thematic_service._wordnet_generator = wordnet_generator + + wordnet_time = time.time() - wordnet_start + logger.info(f"✅ WordNet clue generator initialized in {wordnet_time:.2f}s") + except Exception as e: + logger.warning(f"⚠️ Failed to initialize WordNet clue generator during startup: {e}") + logger.info("📝 WordNet clue generator will be initialized on first use") + + except ImportError as e: + logger.error(f"❌ Missing dependencies for thematic service: {e}") + logger.error("💡 Install missing packages: pip install wordfreq sentence-transformers torch scikit-learn") + raise # Fail fast on missing dependencies + except PermissionError as e: + logger.error(f"❌ Permission error with cache directory: {e}") + logger.error(f"💡 Check cache directory permissions: {thematic_service.cache_dir if 'thematic_service' in locals() else 'unknown'}") + raise # Fail fast on permission issues except Exception as e: - logger.error(f"❌ Failed to initialize vector search service: {e}") - # Continue without vector search (will fallback to static words) + logger.error(f"❌ Failed to initialize thematic service: {e}") + logger.error(f"🔍 Error type: {type(e).__name__}") + import traceback + logger.error(f"📋 Full traceback: {traceback.format_exc()}") + raise # Fail fast instead of continuing without service - # Make vector service available to routes - app.state.vector_service = vector_service + # Make thematic service available to routes + app.state.thematic_service = thematic_service yield # Shutdown logger.info("🛑 Shutting down Python backend...") - if vector_service: - await vector_service.cleanup() + # Thematic service doesn't need cleanup, but we can add it if needed in the future # Create FastAPI app app = FastAPI( title="Crossword Puzzle Generator API", - description="Python backend with AI-powered vector similarity search", + description="Python backend with AI-powered thematic word generation", version="2.0.0", lifespan=lifespan ) diff --git a/crossword-app/backend-py/data/data b/crossword-app/backend-py/data/data deleted file mode 120000 index 20bf75b0d9bf305d9096b954bf9b9b881704fa66..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/data/data +++ /dev/null @@ -1 +0,0 @@ -../backend/data \ No newline at end of file diff --git a/crossword-app/backend-py/data/word-lists/animals.json b/crossword-app/backend-py/data/word-lists/animals.json deleted file mode 100644 index 40d8c4e0ec8f2b27a7ba5d7336ea91c47583ddaf..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/data/word-lists/animals.json +++ /dev/null @@ -1,165 +0,0 @@ -[ - { "word": "DOG", "clue": "Man's best friend" }, - { "word": "CAT", "clue": "Feline pet that purrs" }, - { "word": "ELEPHANT", "clue": "Large mammal with a trunk" }, - { "word": "TIGER", "clue": "Striped big cat" }, - { "word": "WHALE", "clue": "Largest marine mammal" }, - { "word": "BUTTERFLY", "clue": "Colorful flying insect" }, - { "word": "BIRD", "clue": "Flying creature with feathers" }, - { "word": "FISH", "clue": "Aquatic animal with gills" }, - { "word": "LION", "clue": "King of the jungle" }, - { "word": "BEAR", "clue": "Large mammal that hibernates" }, - { "word": "RABBIT", "clue": "Hopping mammal with long ears" }, - { "word": "HORSE", "clue": "Riding animal with hooves" }, - { "word": "SHEEP", "clue": "Woolly farm animal" }, - { "word": "GOAT", "clue": "Horned farm animal" }, - { "word": "DUCK", "clue": "Water bird that quacks" }, - { "word": "CHICKEN", "clue": "Farm bird that lays eggs" }, - { "word": "SNAKE", "clue": "Slithering reptile" }, - { "word": "TURTLE", "clue": "Shelled reptile" }, - { "word": "FROG", "clue": "Amphibian that croaks" }, - { "word": "SHARK", "clue": "Predatory ocean fish" }, - { "word": "DOLPHIN", "clue": "Intelligent marine mammal" }, - { "word": "PENGUIN", "clue": "Flightless Antarctic bird" }, - { "word": "MONKEY", "clue": "Primate that swings in trees" }, - { "word": "ZEBRA", "clue": "Striped African animal" }, - { "word": "GIRAFFE", "clue": "Tallest land animal" }, - { "word": "WOLF", "clue": "Wild canine that howls" }, - { "word": "FOX", "clue": "Cunning red-furred animal" }, - { "word": "DEER", "clue": "Graceful forest animal with antlers" }, - { "word": "MOOSE", "clue": "Large antlered animal" }, - { "word": "SQUIRREL", "clue": "Tree-climbing nut gatherer" }, - { "word": "RACCOON", "clue": "Masked nocturnal animal" }, - { "word": "BEAVER", "clue": "Dam-building rodent" }, - { "word": "OTTER", "clue": "Playful water mammal" }, - { "word": "SEAL", "clue": "Marine mammal with flippers" }, - { "word": "WALRUS", "clue": "Tusked Arctic marine mammal" }, - { "word": "RHINO", "clue": "Horned thick-skinned mammal" }, - { "word": "HIPPO", "clue": "Large African river mammal" }, - { "word": "CHEETAH", "clue": "Fastest land animal" }, - { "word": "LEOPARD", "clue": "Spotted big cat" }, - { "word": "JAGUAR", "clue": "South American big cat" }, - { "word": "PUMA", "clue": "Mountain lion" }, - { "word": "LYNX", "clue": "Wild cat with tufted ears" }, - { "word": "KANGAROO", "clue": "Hopping Australian marsupial" }, - { "word": "KOALA", "clue": "Eucalyptus-eating marsupial" }, - { "word": "PANDA", "clue": "Black and white bamboo eater" }, - { "word": "SLOTH", "clue": "Slow-moving tree dweller" }, - { "word": "ARMADILLO", "clue": "Armored mammal" }, - { "word": "ANTEATER", "clue": "Long-snouted insect eater" }, - { "word": "PLATYPUS", "clue": "Egg-laying mammal with a bill" }, - { "word": "BAT", "clue": "Flying mammal" }, - { "word": "MOLE", "clue": "Underground tunnel digger" }, - { "word": "HEDGEHOG", "clue": "Spiny small mammal" }, - { "word": "PORCUPINE", "clue": "Quill-covered rodent" }, - { "word": "SKUNK", "clue": "Black and white scent-spraying mammal" }, - { "word": "WEASEL", "clue": "Small carnivorous mammal" }, - { "word": "BADGER", "clue": "Burrowing black and white mammal" }, - { "word": "FERRET", "clue": "Domesticated hunting animal" }, - { "word": "MINK", "clue": "Valuable fur-bearing animal" }, - { "word": "EAGLE", "clue": "Majestic bird of prey" }, - { "word": "HAWK", "clue": "Sharp-eyed hunting bird" }, - { "word": "OWL", "clue": "Nocturnal bird with large eyes" }, - { "word": "FALCON", "clue": "Fast diving bird of prey" }, - { "word": "VULTURE", "clue": "Scavenging bird" }, - { "word": "CROW", "clue": "Black intelligent bird" }, - { "word": "RAVEN", "clue": "Large black corvid" }, - { "word": "ROBIN", "clue": "Red-breasted songbird" }, - { "word": "SPARROW", "clue": "Small brown songbird" }, - { "word": "CARDINAL", "clue": "Bright red songbird" }, - { "word": "BLUEJAY", "clue": "Blue crested bird" }, - { "word": "WOODPECKER", "clue": "Tree-pecking bird" }, - { "word": "HUMMINGBIRD", "clue": "Tiny fast-flying bird" }, - { "word": "PELICAN", "clue": "Large-billed water bird" }, - { "word": "FLAMINGO", "clue": "Pink wading bird" }, - { "word": "STORK", "clue": "Long-legged wading bird" }, - { "word": "HERON", "clue": "Tall fishing bird" }, - { "word": "CRANE", "clue": "Large wading bird" }, - { "word": "SWAN", "clue": "Elegant white water bird" }, - { "word": "GOOSE", "clue": "Large waterfowl" }, - { "word": "TURKEY", "clue": "Large ground bird" }, - { "word": "PHEASANT", "clue": "Colorful game bird" }, - { "word": "QUAIL", "clue": "Small ground bird" }, - { "word": "PEACOCK", "clue": "Bird with spectacular tail feathers" }, - { "word": "OSTRICH", "clue": "Largest flightless bird" }, - { "word": "EMU", "clue": "Australian flightless bird" }, - { "word": "KIWI", "clue": "Small flightless New Zealand bird" }, - { "word": "PARROT", "clue": "Colorful talking bird" }, - { "word": "TOUCAN", "clue": "Large-billed tropical bird" }, - { "word": "MACAW", "clue": "Large colorful parrot" }, - { "word": "COCKATOO", "clue": "Crested parrot" }, - { "word": "CANARY", "clue": "Yellow singing bird" }, - { "word": "FINCH", "clue": "Small seed-eating bird" }, - { "word": "PIGEON", "clue": "Common city bird" }, - { "word": "DOVE", "clue": "Symbol of peace" }, - { "word": "SEAGULL", "clue": "Coastal scavenging bird" }, - { "word": "ALBATROSS", "clue": "Large ocean bird" }, - { "word": "PUFFIN", "clue": "Colorful-billed seabird" }, - { "word": "LIZARD", "clue": "Small scaly reptile" }, - { "word": "IGUANA", "clue": "Large tropical lizard" }, - { "word": "GECKO", "clue": "Wall-climbing lizard" }, - { "word": "CHAMELEON", "clue": "Color-changing reptile" }, - { "word": "ALLIGATOR", "clue": "Large American crocodilian" }, - { "word": "CROCODILE", "clue": "Large aquatic reptile" }, - { "word": "PYTHON", "clue": "Large constricting snake" }, - { "word": "COBRA", "clue": "Venomous hooded snake" }, - { "word": "VIPER", "clue": "Poisonous snake" }, - { "word": "RATTLESNAKE", "clue": "Snake with warning tail" }, - { "word": "SALAMANDER", "clue": "Amphibian that can regrow limbs" }, - { "word": "NEWT", "clue": "Small aquatic salamander" }, - { "word": "TOAD", "clue": "Warty amphibian" }, - { "word": "TADPOLE", "clue": "Frog larva" }, - { "word": "SALMON", "clue": "Fish that swims upstream" }, - { "word": "TROUT", "clue": "Freshwater game fish" }, - { "word": "BASS", "clue": "Popular sport fish" }, - { "word": "TUNA", "clue": "Large ocean fish" }, - { "word": "SWORDFISH", "clue": "Fish with long pointed bill" }, - { "word": "MARLIN", "clue": "Large billfish" }, - { "word": "MANTA", "clue": "Large ray fish" }, - { "word": "STINGRAY", "clue": "Flat fish with barbed tail" }, - { "word": "EEL", "clue": "Snake-like fish" }, - { "word": "SEAHORSE", "clue": "Horse-shaped fish" }, - { "word": "ANGELFISH", "clue": "Colorful tropical fish" }, - { "word": "GOLDFISH", "clue": "Common pet fish" }, - { "word": "CLOWNFISH", "clue": "Orange and white anemone fish" }, - { "word": "JELLYFISH", "clue": "Transparent stinging sea creature" }, - { "word": "OCTOPUS", "clue": "Eight-armed sea creature" }, - { "word": "SQUID", "clue": "Ten-armed cephalopod" }, - { "word": "CRAB", "clue": "Sideways-walking crustacean" }, - { "word": "LOBSTER", "clue": "Large marine crustacean" }, - { "word": "SHRIMP", "clue": "Small crustacean" }, - { "word": "STARFISH", "clue": "Five-armed sea creature" }, - { "word": "URCHIN", "clue": "Spiny sea creature" }, - { "word": "CORAL", "clue": "Marine organism that builds reefs" }, - { "word": "SPONGE", "clue": "Simple marine animal" }, - { "word": "OYSTER", "clue": "Pearl-producing mollusk" }, - { "word": "CLAM", "clue": "Burrowing shellfish" }, - { "word": "MUSSEL", "clue": "Dark-shelled mollusk" }, - { "word": "SNAIL", "clue": "Spiral-shelled gastropod" }, - { "word": "SLUG", "clue": "Shell-less gastropod" }, - { "word": "WORM", "clue": "Segmented invertebrate" }, - { "word": "SPIDER", "clue": "Eight-legged web spinner" }, - { "word": "SCORPION", "clue": "Arachnid with stinging tail" }, - { "word": "ANT", "clue": "Social insect worker" }, - { "word": "BEE", "clue": "Honey-making insect" }, - { "word": "WASP", "clue": "Stinging flying insect" }, - { "word": "HORNET", "clue": "Large aggressive wasp" }, - { "word": "FLY", "clue": "Common buzzing insect" }, - { "word": "MOSQUITO", "clue": "Blood-sucking insect" }, - { "word": "BEETLE", "clue": "Hard-shelled insect" }, - { "word": "LADYBUG", "clue": "Red spotted beneficial insect" }, - { "word": "DRAGONFLY", "clue": "Large-winged flying insect" }, - { "word": "GRASSHOPPER", "clue": "Jumping green insect" }, - { "word": "CRICKET", "clue": "Chirping insect" }, - { "word": "MANTIS", "clue": "Praying insect predator" }, - { "word": "MOTH", "clue": "Nocturnal butterfly relative" }, - { "word": "CATERPILLAR", "clue": "Butterfly larva" }, - { "word": "COCOON", "clue": "Insect transformation casing" }, - { "word": "TERMITE", "clue": "Wood-eating social insect" }, - { "word": "TICK", "clue": "Blood-sucking parasite" }, - { "word": "FLEA", "clue": "Jumping parasite" }, - { "word": "LOUSE", "clue": "Small parasitic insect" }, - { "word": "APHID", "clue": "Plant-sucking insect" }, - { "word": "MAGGOT", "clue": "Fly larva" }, - { "word": "GRUB", "clue": "Beetle larva" } -] \ No newline at end of file diff --git a/crossword-app/backend-py/data/word-lists/geography.json b/crossword-app/backend-py/data/word-lists/geography.json deleted file mode 100644 index 188cb6f22f4efe3eccfaa80ab841936e75354956..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/data/word-lists/geography.json +++ /dev/null @@ -1,161 +0,0 @@ -[ - { "word": "MOUNTAIN", "clue": "High elevation landform" }, - { "word": "OCEAN", "clue": "Large body of salt water" }, - { "word": "DESERT", "clue": "Dry, arid region" }, - { "word": "CONTINENT", "clue": "Large landmass" }, - { "word": "RIVER", "clue": "Flowing body of water" }, - { "word": "ISLAND", "clue": "Land surrounded by water" }, - { "word": "FOREST", "clue": "Dense area of trees" }, - { "word": "VALLEY", "clue": "Low area between hills" }, - { "word": "LAKE", "clue": "Body of freshwater" }, - { "word": "BEACH", "clue": "Sandy shore by water" }, - { "word": "CLIFF", "clue": "Steep rock face" }, - { "word": "PLATEAU", "clue": "Elevated flat area" }, - { "word": "CANYON", "clue": "Deep gorge with steep sides" }, - { "word": "GLACIER", "clue": "Moving mass of ice" }, - { "word": "VOLCANO", "clue": "Mountain that erupts" }, - { "word": "PENINSULA", "clue": "Land surrounded by water on three sides" }, - { "word": "ARCHIPELAGO", "clue": "Group of islands" }, - { "word": "PRAIRIE", "clue": "Grassland plain" }, - { "word": "TUNDRA", "clue": "Cold, treeless region" }, - { "word": "SAVANNA", "clue": "Tropical grassland" }, - { "word": "EQUATOR", "clue": "Earth's middle line" }, - { "word": "LATITUDE", "clue": "Distance from equator" }, - { "word": "LONGITUDE", "clue": "Distance from prime meridian" }, - { "word": "CLIMATE", "clue": "Long-term weather pattern" }, - { "word": "MONSOON", "clue": "Seasonal wind pattern" }, - { "word": "CAPITAL", "clue": "Main city of country" }, - { "word": "BORDER", "clue": "Boundary between countries" }, - { "word": "COAST", "clue": "Land meeting the sea" }, - { "word": "STRAIT", "clue": "Narrow water passage" }, - { "word": "DELTA", "clue": "River mouth formation" }, - { "word": "FJORD", "clue": "Narrow inlet between cliffs" }, - { "word": "ATOLL", "clue": "Ring-shaped coral island" }, - { "word": "MESA", "clue": "Flat-topped hill" }, - { "word": "BUTTE", "clue": "Isolated hill with steep sides" }, - { "word": "GORGE", "clue": "Deep narrow valley" }, - { "word": "RAVINE", "clue": "Small narrow gorge" }, - { "word": "RIDGE", "clue": "Long narrow hilltop" }, - { "word": "PEAK", "clue": "Mountain summit" }, - { "word": "SUMMIT", "clue": "Highest point" }, - { "word": "FOOTHILLS", "clue": "Hills at base of mountains" }, - { "word": "RANGE", "clue": "Chain of mountains" }, - { "word": "BASIN", "clue": "Low-lying area" }, - { "word": "WATERSHED", "clue": "Drainage area" }, - { "word": "ESTUARY", "clue": "Where river meets sea" }, - { "word": "BAY", "clue": "Curved inlet of water" }, - { "word": "GULF", "clue": "Large bay" }, - { "word": "CAPE", "clue": "Point of land into water" }, - { "word": "HEADLAND", "clue": "High point of land" }, - { "word": "LAGOON", "clue": "Shallow coastal body of water" }, - { "word": "REEF", "clue": "Underwater rock formation" }, - { "word": "SHOAL", "clue": "Shallow area in water" }, - { "word": "CHANNEL", "clue": "Deep water passage" }, - { "word": "SOUND", "clue": "Large sea inlet" }, - { "word": "HARBOR", "clue": "Sheltered port area" }, - { "word": "INLET", "clue": "Small bay" }, - { "word": "COVE", "clue": "Small sheltered bay" }, - { "word": "MARSH", "clue": "Wetland area" }, - { "word": "SWAMP", "clue": "Forested wetland" }, - { "word": "BOG", "clue": "Acidic wetland" }, - { "word": "OASIS", "clue": "Fertile spot in desert" }, - { "word": "DUNE", "clue": "Sand hill" }, - { "word": "PLAIN", "clue": "Flat grassland" }, - { "word": "STEPPE", "clue": "Dry grassland" }, - { "word": "TAIGA", "clue": "Northern coniferous forest" }, - { "word": "RAINFOREST", "clue": "Dense tropical forest" }, - { "word": "JUNGLE", "clue": "Dense tropical vegetation" }, - { "word": "WOODLAND", "clue": "Area with scattered trees" }, - { "word": "GROVE", "clue": "Small group of trees" }, - { "word": "MEADOW", "clue": "Grassy field" }, - { "word": "PASTURE", "clue": "Grazing land" }, - { "word": "FIELD", "clue": "Open area of land" }, - { "word": "MOOR", "clue": "Open uncultivated land" }, - { "word": "HEATH", "clue": "Shrubland area" }, - { "word": "ARCTIC", "clue": "Cold northern region" }, - { "word": "ANTARCTIC", "clue": "Cold southern region" }, - { "word": "POLAR", "clue": "Of the poles" }, - { "word": "TROPICAL", "clue": "Hot humid climate zone" }, - { "word": "TEMPERATE", "clue": "Moderate climate zone" }, - { "word": "ARID", "clue": "Very dry" }, - { "word": "HUMID", "clue": "Moist air" }, - { "word": "ALTITUDE", "clue": "Height above sea level" }, - { "word": "ELEVATION", "clue": "Height of land" }, - { "word": "TERRAIN", "clue": "Physical features of land" }, - { "word": "TOPOGRAPHY", "clue": "Surface features of area" }, - { "word": "GEOGRAPHY", "clue": "Study of Earth's features" }, - { "word": "CARTOGRAPHY", "clue": "Map making" }, - { "word": "MERIDIAN", "clue": "Longitude line" }, - { "word": "PARALLEL", "clue": "Latitude line" }, - { "word": "HEMISPHERE", "clue": "Half of Earth" }, - { "word": "TROPICS", "clue": "Hot climate zone" }, - { "word": "POLES", "clue": "Earth's endpoints" }, - { "word": "AXIS", "clue": "Earth's rotation line" }, - { "word": "ORBIT", "clue": "Path around sun" }, - { "word": "SEASON", "clue": "Time of year" }, - { "word": "SOLSTICE", "clue": "Longest or shortest day" }, - { "word": "EQUINOX", "clue": "Equal day and night" }, - { "word": "COMPASS", "clue": "Direction-finding tool" }, - { "word": "NAVIGATION", "clue": "Finding your way" }, - { "word": "BEARING", "clue": "Direction or course" }, - { "word": "AZIMUTH", "clue": "Compass direction" }, - { "word": "SCALE", "clue": "Map size ratio" }, - { "word": "LEGEND", "clue": "Map symbol key" }, - { "word": "CONTOUR", "clue": "Elevation line on map" }, - { "word": "GRID", "clue": "Map reference system" }, - { "word": "PROJECTION", "clue": "Map flattening method" }, - { "word": "SURVEY", "clue": "Land measurement" }, - { "word": "BOUNDARY", "clue": "Dividing line" }, - { "word": "FRONTIER", "clue": "Border region" }, - { "word": "TERRITORY", "clue": "Area of land" }, - { "word": "REGION", "clue": "Geographic area" }, - { "word": "ZONE", "clue": "Designated area" }, - { "word": "DISTRICT", "clue": "Administrative area" }, - { "word": "PROVINCE", "clue": "Political subdivision" }, - { "word": "STATE", "clue": "Political entity" }, - { "word": "COUNTY", "clue": "Local government area" }, - { "word": "CITY", "clue": "Large urban area" }, - { "word": "TOWN", "clue": "Small urban area" }, - { "word": "VILLAGE", "clue": "Small rural community" }, - { "word": "HAMLET", "clue": "Very small village" }, - { "word": "SUBURB", "clue": "Residential area outside city" }, - { "word": "URBAN", "clue": "City-like" }, - { "word": "RURAL", "clue": "Countryside" }, - { "word": "METROPOLITAN", "clue": "Large city area" }, - { "word": "POPULATION", "clue": "Number of people" }, - { "word": "DENSITY", "clue": "Crowdedness" }, - { "word": "SETTLEMENT", "clue": "Place where people live" }, - { "word": "COLONY", "clue": "Overseas territory" }, - { "word": "NATION", "clue": "Country" }, - { "word": "REPUBLIC", "clue": "Democratic state" }, - { "word": "KINGDOM", "clue": "Monarchy" }, - { "word": "EMPIRE", "clue": "Large political entity" }, - { "word": "FEDERATION", "clue": "Union of states" }, - { "word": "ALLIANCE", "clue": "Partnership of nations" }, - { "word": "TREATY", "clue": "International agreement" }, - { "word": "TRADE", "clue": "Commercial exchange" }, - { "word": "EXPORT", "clue": "Goods sent abroad" }, - { "word": "IMPORT", "clue": "Goods brought in" }, - { "word": "COMMERCE", "clue": "Business activity" }, - { "word": "INDUSTRY", "clue": "Manufacturing" }, - { "word": "AGRICULTURE", "clue": "Farming" }, - { "word": "MINING", "clue": "Extracting minerals" }, - { "word": "FORESTRY", "clue": "Tree management" }, - { "word": "FISHING", "clue": "Catching fish" }, - { "word": "TOURISM", "clue": "Travel industry" }, - { "word": "TRANSPORTATION", "clue": "Moving people and goods" }, - { "word": "INFRASTRUCTURE", "clue": "Basic facilities" }, - { "word": "COMMUNICATION", "clue": "Information exchange" }, - { "word": "CULTURE", "clue": "Way of life" }, - { "word": "LANGUAGE", "clue": "Communication system" }, - { "word": "RELIGION", "clue": "Belief system" }, - { "word": "ETHNICITY", "clue": "Cultural group" }, - { "word": "MIGRATION", "clue": "Movement of people" }, - { "word": "IMMIGRATION", "clue": "Moving into country" }, - { "word": "EMIGRATION", "clue": "Moving out of country" }, - { "word": "DIASPORA", "clue": "Scattered population" }, - { "word": "NOMAD", "clue": "Wandering person" }, - { "word": "REFUGEE", "clue": "Displaced person" }, - { "word": "CENSUS", "clue": "Population count" }, - { "word": "DEMOGRAPHIC", "clue": "Population characteristic" } -] \ No newline at end of file diff --git a/crossword-app/backend-py/data/word-lists/science.json b/crossword-app/backend-py/data/word-lists/science.json deleted file mode 100644 index 3a66731c0c7f2fb90025b0a6b1b7bbe1e8f8daf9..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/data/word-lists/science.json +++ /dev/null @@ -1,170 +0,0 @@ -[ - { "word": "ATOM", "clue": "Smallest unit of matter" }, - { "word": "GRAVITY", "clue": "Force that pulls objects down" }, - { "word": "MOLECULE", "clue": "Group of atoms bonded together" }, - { "word": "PHOTON", "clue": "Particle of light" }, - { "word": "CHEMISTRY", "clue": "Study of matter and reactions" }, - { "word": "PHYSICS", "clue": "Study of matter and energy" }, - { "word": "BIOLOGY", "clue": "Study of living organisms" }, - { "word": "ELEMENT", "clue": "Pure chemical substance" }, - { "word": "OXYGEN", "clue": "Gas essential for breathing" }, - { "word": "CARBON", "clue": "Element found in all life" }, - { "word": "HYDROGEN", "clue": "Lightest chemical element" }, - { "word": "ENERGY", "clue": "Capacity to do work" }, - { "word": "FORCE", "clue": "Push or pull on an object" }, - { "word": "VELOCITY", "clue": "Speed with direction" }, - { "word": "MASS", "clue": "Amount of matter in object" }, - { "word": "VOLUME", "clue": "Amount of space occupied" }, - { "word": "DENSITY", "clue": "Mass per unit volume" }, - { "word": "PRESSURE", "clue": "Force per unit area" }, - { "word": "TEMPERATURE", "clue": "Measure of heat" }, - { "word": "ELECTRON", "clue": "Negatively charged particle" }, - { "word": "PROTON", "clue": "Positively charged particle" }, - { "word": "NEUTRON", "clue": "Neutral atomic particle" }, - { "word": "NUCLEUS", "clue": "Center of an atom" }, - { "word": "CELL", "clue": "Basic unit of life" }, - { "word": "DNA", "clue": "Genetic blueprint molecule" }, - { "word": "PROTEIN", "clue": "Complex biological molecule" }, - { "word": "ENZYME", "clue": "Biological catalyst" }, - { "word": "VIRUS", "clue": "Infectious agent" }, - { "word": "BACTERIA", "clue": "Single-celled organisms" }, - { "word": "EVOLUTION", "clue": "Change in species over time" }, - { "word": "ISOTOPE", "clue": "Atom variant with different neutrons" }, - { "word": "ION", "clue": "Charged atom or molecule" }, - { "word": "COMPOUND", "clue": "Chemical combination of elements" }, - { "word": "MIXTURE", "clue": "Combined substances retaining properties" }, - { "word": "SOLUTION", "clue": "Dissolved mixture" }, - { "word": "ACID", "clue": "Sour chemical with low pH" }, - { "word": "BASE", "clue": "Alkaline substance with high pH" }, - { "word": "SALT", "clue": "Ionic compound from acid-base reaction" }, - { "word": "CATALYST", "clue": "Substance that speeds reactions" }, - { "word": "RNA", "clue": "Genetic messenger molecule" }, - { "word": "GENE", "clue": "Heredity unit on chromosome" }, - { "word": "CHROMOSOME", "clue": "Gene-carrying structure" }, - { "word": "TISSUE", "clue": "Group of similar cells" }, - { "word": "ORGAN", "clue": "Body part with specific function" }, - { "word": "SYSTEM", "clue": "Group of organs working together" }, - { "word": "ORGANISM", "clue": "Living individual entity" }, - { "word": "SPECIES", "clue": "Group of similar organisms" }, - { "word": "ADAPTATION", "clue": "Survival-enhancing change" }, - { "word": "MUTATION", "clue": "Genetic change in DNA" }, - { "word": "HEREDITY", "clue": "Passing traits to offspring" }, - { "word": "ECOSYSTEM", "clue": "Community and environment" }, - { "word": "HABITAT", "clue": "Natural living environment" }, - { "word": "BIODIVERSITY", "clue": "Variety of life forms" }, - { "word": "PHOTOSYNTHESIS", "clue": "Plant energy-making process" }, - { "word": "RESPIRATION", "clue": "Cellular breathing process" }, - { "word": "METABOLISM", "clue": "Chemical processes in body" }, - { "word": "HOMEOSTASIS", "clue": "Body's internal balance" }, - { "word": "MITOSIS", "clue": "Cell division for growth" }, - { "word": "MEIOSIS", "clue": "Cell division for reproduction" }, - { "word": "EMBRYO", "clue": "Early development stage" }, - { "word": "FOSSIL", "clue": "Preserved ancient remains" }, - { "word": "GEOLOGY", "clue": "Study of Earth's structure" }, - { "word": "MINERAL", "clue": "Natural inorganic crystal" }, - { "word": "ROCK", "clue": "Solid earth material" }, - { "word": "SEDIMENT", "clue": "Settled particles" }, - { "word": "EROSION", "clue": "Gradual wearing away" }, - { "word": "VOLCANO", "clue": "Earth opening spewing lava" }, - { "word": "EARTHQUAKE", "clue": "Ground shaking from plate movement" }, - { "word": "PLATE", "clue": "Earth's crust section" }, - { "word": "MAGMA", "clue": "Molten rock beneath surface" }, - { "word": "LAVA", "clue": "Molten rock on surface" }, - { "word": "CRYSTAL", "clue": "Ordered atomic structure" }, - { "word": "ATMOSPHERE", "clue": "Layer of gases around Earth" }, - { "word": "CLIMATE", "clue": "Long-term weather pattern" }, - { "word": "WEATHER", "clue": "Short-term atmospheric conditions" }, - { "word": "PRECIPITATION", "clue": "Water falling from clouds" }, - { "word": "HUMIDITY", "clue": "Moisture in air" }, - { "word": "WIND", "clue": "Moving air mass" }, - { "word": "STORM", "clue": "Violent weather event" }, - { "word": "HURRICANE", "clue": "Powerful tropical cyclone" }, - { "word": "TORNADO", "clue": "Rotating column of air" }, - { "word": "LIGHTNING", "clue": "Electrical discharge in sky" }, - { "word": "THUNDER", "clue": "Sound of lightning" }, - { "word": "RAINBOW", "clue": "Spectrum of light in sky" }, - { "word": "ASTRONOMY", "clue": "Study of celestial objects" }, - { "word": "GALAXY", "clue": "Collection of stars and planets" }, - { "word": "PLANET", "clue": "Large orbiting celestial body" }, - { "word": "STAR", "clue": "Self-luminous celestial body" }, - { "word": "MOON", "clue": "Natural satellite of planet" }, - { "word": "COMET", "clue": "Icy body with tail" }, - { "word": "ASTEROID", "clue": "Rocky space object" }, - { "word": "METEOR", "clue": "Space rock entering atmosphere" }, - { "word": "ORBIT", "clue": "Curved path around object" }, - { "word": "LIGHT", "clue": "Electromagnetic radiation" }, - { "word": "SPECTRUM", "clue": "Range of electromagnetic radiation" }, - { "word": "WAVELENGTH", "clue": "Distance between wave peaks" }, - { "word": "FREQUENCY", "clue": "Waves per unit time" }, - { "word": "AMPLITUDE", "clue": "Wave height or intensity" }, - { "word": "SOUND", "clue": "Vibrations in air" }, - { "word": "ECHO", "clue": "Reflected sound" }, - { "word": "RESONANCE", "clue": "Vibration amplification" }, - { "word": "DOPPLER", "clue": "Wave frequency shift effect" }, - { "word": "MOTION", "clue": "Change in position" }, - { "word": "ACCELERATION", "clue": "Change in velocity" }, - { "word": "MOMENTUM", "clue": "Mass times velocity" }, - { "word": "INERTIA", "clue": "Resistance to motion change" }, - { "word": "FRICTION", "clue": "Resistance to sliding" }, - { "word": "HEAT", "clue": "Thermal energy transfer" }, - { "word": "COMBUSTION", "clue": "Burning chemical reaction" }, - { "word": "OXIDATION", "clue": "Reaction with oxygen" }, - { "word": "REDUCTION", "clue": "Gain of electrons" }, - { "word": "ELECTROLYSIS", "clue": "Chemical breakdown by electricity" }, - { "word": "CONDUCTIVITY", "clue": "Ability to transfer energy" }, - { "word": "INSULATOR", "clue": "Material blocking energy flow" }, - { "word": "SEMICONDUCTOR", "clue": "Partial electrical conductor" }, - { "word": "MAGNETISM", "clue": "Force of magnetic attraction" }, - { "word": "FIELD", "clue": "Region of force influence" }, - { "word": "CIRCUIT", "clue": "Closed electrical path" }, - { "word": "CURRENT", "clue": "Flow of electric charge" }, - { "word": "VOLTAGE", "clue": "Electric potential difference" }, - { "word": "RESISTANCE", "clue": "Opposition to current flow" }, - { "word": "CAPACITOR", "clue": "Device storing electric charge" }, - { "word": "INDUCTOR", "clue": "Device storing magnetic energy" }, - { "word": "TRANSISTOR", "clue": "Electronic switching device" }, - { "word": "LASER", "clue": "Focused beam of light" }, - { "word": "RADAR", "clue": "Radio detection system" }, - { "word": "SONAR", "clue": "Sound detection system" }, - { "word": "TELESCOPE", "clue": "Instrument for viewing distant objects" }, - { "word": "MICROSCOPE", "clue": "Instrument for viewing small objects" }, - { "word": "HYPOTHESIS", "clue": "Testable scientific prediction" }, - { "word": "THEORY", "clue": "Well-tested scientific explanation" }, - { "word": "LAW", "clue": "Consistently observed scientific rule" }, - { "word": "EXPERIMENT", "clue": "Controlled scientific test" }, - { "word": "OBSERVATION", "clue": "Careful scientific watching" }, - { "word": "MEASUREMENT", "clue": "Quantified observation" }, - { "word": "ANALYSIS", "clue": "Detailed examination of data" }, - { "word": "SYNTHESIS", "clue": "Combining elements into whole" }, - { "word": "VARIABLE", "clue": "Factor that can change" }, - { "word": "CONTROL", "clue": "Unchanged comparison group" }, - { "word": "DATA", "clue": "Information collected from tests" }, - { "word": "STATISTICS", "clue": "Mathematical analysis of data" }, - { "word": "PROBABILITY", "clue": "Likelihood of occurrence" }, - { "word": "PRECISION", "clue": "Exactness of measurement" }, - { "word": "ACCURACY", "clue": "Correctness of measurement" }, - { "word": "ERROR", "clue": "Difference from true value" }, - { "word": "UNCERTAINTY", "clue": "Range of doubt in measurement" }, - { "word": "CALIBRATION", "clue": "Adjusting instrument accuracy" }, - { "word": "STANDARD", "clue": "Reference for measurement" }, - { "word": "UNIT", "clue": "Base measure of quantity" }, - { "word": "METRIC", "clue": "Decimal measurement system" }, - { "word": "WEIGHT", "clue": "Force of gravity on mass" }, - { "word": "CONCENTRATION", "clue": "Amount of substance per volume" }, - { "word": "MOLARITY", "clue": "Moles of solute per liter" }, - { "word": "EQUILIBRIUM", "clue": "State of balanced forces" }, - { "word": "STABILITY", "clue": "Resistance to change" }, - { "word": "DECAY", "clue": "Gradual breakdown process" }, - { "word": "RADIATION", "clue": "Energy emitted from source" }, - { "word": "RADIOACTIVE", "clue": "Emitting nuclear radiation" }, - { "word": "HALFLIFE", "clue": "Time for half to decay" }, - { "word": "FUSION", "clue": "Nuclear combining reaction" }, - { "word": "FISSION", "clue": "Nuclear splitting reaction" }, - { "word": "QUANTUM", "clue": "Discrete packet of energy" }, - { "word": "PARTICLE", "clue": "Tiny piece of matter" }, - { "word": "WAVE", "clue": "Energy transfer disturbance" }, - { "word": "INTERFERENCE", "clue": "Wave interaction effect" }, - { "word": "DIFFRACTION", "clue": "Wave bending around obstacle" }, - { "word": "REFLECTION", "clue": "Bouncing back of waves" }, - { "word": "REFRACTION", "clue": "Bending of waves through medium" } -] \ No newline at end of file diff --git a/crossword-app/backend-py/data/word-lists/technology.json b/crossword-app/backend-py/data/word-lists/technology.json deleted file mode 100644 index ce9828c32c8615ab31f77da9c27ad1de5711a411..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/data/word-lists/technology.json +++ /dev/null @@ -1,221 +0,0 @@ -[ - { "word": "COMPUTER", "clue": "Electronic processing device" }, - { "word": "INTERNET", "clue": "Global computer network" }, - { "word": "ALGORITHM", "clue": "Set of rules for solving problems" }, - { "word": "DATABASE", "clue": "Organized collection of data" }, - { "word": "SOFTWARE", "clue": "Computer programs" }, - { "word": "HARDWARE", "clue": "Physical computer components" }, - { "word": "NETWORK", "clue": "Connected system of computers" }, - { "word": "CODE", "clue": "Programming instructions" }, - { "word": "ROBOT", "clue": "Automated machine" }, - { "word": "ARTIFICIAL", "clue": "Made by humans, not natural" }, - { "word": "DIGITAL", "clue": "Using binary data" }, - { "word": "BINARY", "clue": "Base-2 number system" }, - { "word": "PROCESSOR", "clue": "Computer's brain" }, - { "word": "MEMORY", "clue": "Data storage component" }, - { "word": "KEYBOARD", "clue": "Input device with keys" }, - { "word": "MONITOR", "clue": "Computer display screen" }, - { "word": "MOUSE", "clue": "Pointing input device" }, - { "word": "PRINTER", "clue": "Device that prints documents" }, - { "word": "SCANNER", "clue": "Device that digitizes images" }, - { "word": "CAMERA", "clue": "Device that captures images" }, - { "word": "SMARTPHONE", "clue": "Portable computing device" }, - { "word": "TABLET", "clue": "Touchscreen computing device" }, - { "word": "LAPTOP", "clue": "Portable computer" }, - { "word": "SERVER", "clue": "Computer that serves data" }, - { "word": "CLOUD", "clue": "Internet-based computing" }, - { "word": "WEBSITE", "clue": "Collection of web pages" }, - { "word": "EMAIL", "clue": "Electronic mail" }, - { "word": "BROWSER", "clue": "Web navigation software" }, - { "word": "SEARCH", "clue": "Look for information" }, - { "word": "DOWNLOAD", "clue": "Transfer data to device" }, - { "word": "UPLOAD", "clue": "Transfer data from device" }, - { "word": "BANDWIDTH", "clue": "Data transfer capacity" }, - { "word": "PROTOCOL", "clue": "Communication rules" }, - { "word": "FIREWALL", "clue": "Network security barrier" }, - { "word": "ENCRYPTION", "clue": "Data scrambling for security" }, - { "word": "PASSWORD", "clue": "Secret access code" }, - { "word": "SECURITY", "clue": "Protection from threats" }, - { "word": "VIRUS", "clue": "Malicious computer program" }, - { "word": "MALWARE", "clue": "Harmful software" }, - { "word": "ANTIVIRUS", "clue": "Protection software" }, - { "word": "BACKUP", "clue": "Data safety copy" }, - { "word": "RECOVERY", "clue": "Data restoration process" }, - { "word": "STORAGE", "clue": "Data keeping capacity" }, - { "word": "HARDDRIVE", "clue": "Magnetic storage device" }, - { "word": "FLASH", "clue": "Solid state storage" }, - { "word": "RAM", "clue": "Random access memory" }, - { "word": "ROM", "clue": "Read-only memory" }, - { "word": "CPU", "clue": "Central processing unit" }, - { "word": "GPU", "clue": "Graphics processing unit" }, - { "word": "MOTHERBOARD", "clue": "Main circuit board" }, - { "word": "CHIP", "clue": "Integrated circuit" }, - { "word": "CIRCUIT", "clue": "Electronic pathway" }, - { "word": "TRANSISTOR", "clue": "Electronic switch" }, - { "word": "SILICON", "clue": "Semiconductor material" }, - { "word": "NANOTECHNOLOGY", "clue": "Extremely small scale tech" }, - { "word": "AUTOMATION", "clue": "Self-operating technology" }, - { "word": "MACHINE", "clue": "Mechanical device" }, - { "word": "SENSOR", "clue": "Detection device" }, - { "word": "ACTUATOR", "clue": "Movement device" }, - { "word": "FEEDBACK", "clue": "System response information" }, - { "word": "PROGRAMMING", "clue": "Writing computer instructions" }, - { "word": "FUNCTION", "clue": "Reusable code block" }, - { "word": "VARIABLE", "clue": "Data storage container" }, - { "word": "LOOP", "clue": "Repeating code structure" }, - { "word": "CONDITION", "clue": "Decision-making logic" }, - { "word": "DEBUG", "clue": "Find and fix errors" }, - { "word": "COMPILE", "clue": "Convert code to executable" }, - { "word": "RUNTIME", "clue": "Program execution time" }, - { "word": "API", "clue": "Application programming interface" }, - { "word": "FRAMEWORK", "clue": "Code structure foundation" }, - { "word": "LIBRARY", "clue": "Reusable code collection" }, - { "word": "MODULE", "clue": "Self-contained code unit" }, - { "word": "OBJECT", "clue": "Data and methods container" }, - { "word": "CLASS", "clue": "Object blueprint" }, - { "word": "INHERITANCE", "clue": "Code reuse mechanism" }, - { "word": "INTERFACE", "clue": "System interaction boundary" }, - { "word": "PROTOCOL", "clue": "Communication standard" }, - { "word": "FORMAT", "clue": "Data structure standard" }, - { "word": "SYNTAX", "clue": "Language rules" }, - { "word": "SEMANTIC", "clue": "Meaning in code" }, - { "word": "PARSING", "clue": "Analyzing code structure" }, - { "word": "COMPILER", "clue": "Code translation program" }, - { "word": "INTERPRETER", "clue": "Code execution program" }, - { "word": "VIRTUAL", "clue": "Simulated environment" }, - { "word": "SIMULATION", "clue": "Computer modeling" }, - { "word": "EMULATION", "clue": "System imitation" }, - { "word": "OPTIMIZATION", "clue": "Performance improvement" }, - { "word": "EFFICIENCY", "clue": "Resource usage effectiveness" }, - { "word": "PERFORMANCE", "clue": "System speed and quality" }, - { "word": "BENCHMARK", "clue": "Performance measurement" }, - { "word": "TESTING", "clue": "Quality verification process" }, - { "word": "VALIDATION", "clue": "Correctness checking" }, - { "word": "VERIFICATION", "clue": "Accuracy confirmation" }, - { "word": "QUALITY", "clue": "Standard of excellence" }, - { "word": "MAINTENANCE", "clue": "System upkeep" }, - { "word": "UPDATE", "clue": "Software improvement" }, - { "word": "PATCH", "clue": "Software fix" }, - { "word": "VERSION", "clue": "Software release number" }, - { "word": "RELEASE", "clue": "Software distribution" }, - { "word": "DEPLOYMENT", "clue": "Software installation" }, - { "word": "CONFIGURATION", "clue": "System setup" }, - { "word": "INSTALLATION", "clue": "Software setup process" }, - { "word": "MIGRATION", "clue": "System transition" }, - { "word": "INTEGRATION", "clue": "System combination" }, - { "word": "COMPATIBILITY", "clue": "System cooperation ability" }, - { "word": "INTEROPERABILITY", "clue": "Cross-system communication" }, - { "word": "SCALABILITY", "clue": "Growth accommodation ability" }, - { "word": "RELIABILITY", "clue": "Consistent performance" }, - { "word": "AVAILABILITY", "clue": "System accessibility" }, - { "word": "REDUNDANCY", "clue": "Backup system duplication" }, - { "word": "FAULT", "clue": "System error condition" }, - { "word": "TOLERANCE", "clue": "Error handling ability" }, - { "word": "RECOVERY", "clue": "System restoration" }, - { "word": "MONITORING", "clue": "System observation" }, - { "word": "LOGGING", "clue": "Event recording" }, - { "word": "ANALYTICS", "clue": "Data analysis" }, - { "word": "METRICS", "clue": "Measurement data" }, - { "word": "DASHBOARD", "clue": "Information display panel" }, - { "word": "INTERFACE", "clue": "User interaction design" }, - { "word": "EXPERIENCE", "clue": "User interaction quality" }, - { "word": "USABILITY", "clue": "Ease of use" }, - { "word": "ACCESSIBILITY", "clue": "Universal design principle" }, - { "word": "RESPONSIVE", "clue": "Adaptive design" }, - { "word": "MOBILE", "clue": "Portable device category" }, - { "word": "TOUCHSCREEN", "clue": "Touch-sensitive display" }, - { "word": "GESTURE", "clue": "Touch movement command" }, - { "word": "VOICE", "clue": "Speech interaction" }, - { "word": "RECOGNITION", "clue": "Pattern identification" }, - { "word": "LEARNING", "clue": "Adaptive improvement" }, - { "word": "INTELLIGENCE", "clue": "Artificial reasoning" }, - { "word": "NEURAL", "clue": "Brain-inspired network" }, - { "word": "DEEP", "clue": "Multi-layered learning" }, - { "word": "MACHINE", "clue": "Automated learning system" }, - { "word": "DATA", "clue": "Information collection" }, - { "word": "BIG", "clue": "Large scale data" }, - { "word": "MINING", "clue": "Data pattern extraction" }, - { "word": "ANALYSIS", "clue": "Data examination" }, - { "word": "VISUALIZATION", "clue": "Data graphic representation" }, - { "word": "DASHBOARD", "clue": "Data monitoring panel" }, - { "word": "REPORT", "clue": "Data summary document" }, - { "word": "QUERY", "clue": "Data search request" }, - { "word": "INDEX", "clue": "Data location reference" }, - { "word": "SCHEMA", "clue": "Data structure blueprint" }, - { "word": "TABLE", "clue": "Data organization structure" }, - { "word": "RECORD", "clue": "Data entry" }, - { "word": "FIELD", "clue": "Data element" }, - { "word": "PRIMARY", "clue": "Main identifier key" }, - { "word": "FOREIGN", "clue": "Reference relationship key" }, - { "word": "RELATION", "clue": "Data connection" }, - { "word": "JOIN", "clue": "Data combination operation" }, - { "word": "TRANSACTION", "clue": "Data operation sequence" }, - { "word": "COMMIT", "clue": "Data change confirmation" }, - { "word": "ROLLBACK", "clue": "Data change reversal" }, - { "word": "CONCURRENCY", "clue": "Simultaneous access handling" }, - { "word": "LOCK", "clue": "Data access control" }, - { "word": "SYNCHRONIZATION", "clue": "Timing coordination" }, - { "word": "THREAD", "clue": "Execution sequence" }, - { "word": "PROCESS", "clue": "Running program instance" }, - { "word": "MULTITASKING", "clue": "Multiple process handling" }, - { "word": "PARALLEL", "clue": "Simultaneous execution" }, - { "word": "DISTRIBUTED", "clue": "Spread across multiple systems" }, - { "word": "CLUSTER", "clue": "Group of connected computers" }, - { "word": "GRID", "clue": "Distributed computing network" }, - { "word": "PEER", "clue": "Equal network participant" }, - { "word": "CLIENT", "clue": "Service requesting system" }, - { "word": "SERVICE", "clue": "System functionality provider" }, - { "word": "MICROSERVICE", "clue": "Small independent service" }, - { "word": "CONTAINER", "clue": "Isolated application environment" }, - { "word": "DOCKER", "clue": "Containerization platform" }, - { "word": "KUBERNETES", "clue": "Container orchestration" }, - { "word": "DEVOPS", "clue": "Development operations practice" }, - { "word": "AGILE", "clue": "Flexible development method" }, - { "word": "SCRUM", "clue": "Iterative development framework" }, - { "word": "SPRINT", "clue": "Short development cycle" }, - { "word": "KANBAN", "clue": "Visual workflow management" }, - { "word": "CONTINUOUS", "clue": "Ongoing integration practice" }, - { "word": "PIPELINE", "clue": "Automated workflow" }, - { "word": "BUILD", "clue": "Software compilation process" }, - { "word": "TESTING", "clue": "Quality assurance process" }, - { "word": "AUTOMATION", "clue": "Manual task elimination" }, - { "word": "SCRIPT", "clue": "Automated task sequence" }, - { "word": "BATCH", "clue": "Group processing" }, - { "word": "STREAMING", "clue": "Continuous data flow" }, - { "word": "REALTIME", "clue": "Immediate processing" }, - { "word": "LATENCY", "clue": "Response delay time" }, - { "word": "THROUGHPUT", "clue": "Processing capacity" }, - { "word": "BOTTLENECK", "clue": "Performance limitation point" }, - { "word": "CACHE", "clue": "Fast temporary storage" }, - { "word": "BUFFER", "clue": "Temporary data holder" }, - { "word": "QUEUE", "clue": "Ordered waiting line" }, - { "word": "STACK", "clue": "Last-in-first-out structure" }, - { "word": "HEAP", "clue": "Dynamic memory area" }, - { "word": "POINTER", "clue": "Memory address reference" }, - { "word": "REFERENCE", "clue": "Object location indicator" }, - { "word": "GARBAGE", "clue": "Unused memory collection" }, - { "word": "ALLOCATION", "clue": "Memory assignment" }, - { "word": "DEALLOCATION", "clue": "Memory release" }, - { "word": "LEAK", "clue": "Memory usage error" }, - { "word": "OVERFLOW", "clue": "Capacity exceeding error" }, - { "word": "UNDERFLOW", "clue": "Insufficient data error" }, - { "word": "EXCEPTION", "clue": "Error handling mechanism" }, - { "word": "INTERRUPT", "clue": "Process suspension signal" }, - { "word": "SIGNAL", "clue": "Process communication" }, - { "word": "EVENT", "clue": "System occurrence" }, - { "word": "HANDLER", "clue": "Event processing function" }, - { "word": "CALLBACK", "clue": "Function reference" }, - { "word": "PROMISE", "clue": "Future value placeholder" }, - { "word": "ASYNC", "clue": "Non-blocking operation" }, - { "word": "AWAIT", "clue": "Pause for completion" }, - { "word": "YIELD", "clue": "Temporary function pause" }, - { "word": "GENERATOR", "clue": "Value sequence producer" }, - { "word": "ITERATOR", "clue": "Sequential access pattern" }, - { "word": "RECURSION", "clue": "Self-calling function" }, - { "word": "CLOSURE", "clue": "Function scope retention" }, - { "word": "LAMBDA", "clue": "Anonymous function" }, - { "word": "FUNCTIONAL", "clue": "Function-based programming" }, - { "word": "PROCEDURAL", "clue": "Step-by-step programming" }, - { "word": "DECLARATIVE", "clue": "What-not-how programming" }, - { "word": "IMPERATIVE", "clue": "Command-based programming" } -] \ No newline at end of file diff --git a/crossword-app/backend-py/debug_full_generation.py b/crossword-app/backend-py/debug_full_generation.py deleted file mode 100644 index ede3a8c6bb5bd00d5038de74109685f035b210fe..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/debug_full_generation.py +++ /dev/null @@ -1,316 +0,0 @@ -#!/usr/bin/env python3 -""" -Debug the complete crossword generation process to identify display/numbering issues. -""" - -import asyncio -import sys -import json -from pathlib import Path - -# Add project root to path -project_root = Path(__file__).parent -sys.path.insert(0, str(project_root)) - -from src.services.crossword_generator_fixed import CrosswordGeneratorFixed - -async def debug_complete_generation(): - """Debug the complete crossword generation process.""" - - print("🔍 Debugging Complete Crossword Generation Process\n") - - # Create generator with no vector service to use static words - generator = CrosswordGeneratorFixed(vector_service=None) - - # Override the word selection to use controlled test words - test_words = [ - {"word": "MACHINE", "clue": "Device with moving parts"}, - {"word": "COMPUTER", "clue": "Electronic device"}, - {"word": "EXPERT", "clue": "Person with specialized knowledge"}, - {"word": "SCIENCE", "clue": "Systematic study"}, - {"word": "TECHNOLOGY", "clue": "Applied science"}, - {"word": "RESEARCH", "clue": "Systematic investigation"}, - {"word": "ANALYSIS", "clue": "Detailed examination"}, - {"word": "METHOD", "clue": "Systematic approach"} - ] - - # Mock the word selection method - async def mock_select_words(topics, difficulty, use_ai): - return test_words - generator._select_words = mock_select_words - - print("=" * 70) - print("GENERATING COMPLETE CROSSWORD") - print("=" * 70) - - try: - result = await generator.generate_puzzle(["technology"], "medium", use_ai=False) - - if result: - print("✅ Crossword generation successful!") - - # Analyze the complete result - analyze_crossword_result(result) - else: - print("❌ Crossword generation failed - returned None") - - except Exception as e: - print(f"❌ Crossword generation failed with error: {e}") - import traceback - traceback.print_exc() - -def analyze_crossword_result(result): - """Analyze the complete crossword result for potential issues.""" - - print("\n" + "=" * 70) - print("CROSSWORD RESULT ANALYSIS") - print("=" * 70) - - # Print basic metadata - metadata = result.get("metadata", {}) - print("Metadata:") - for key, value in metadata.items(): - print(f" {key}: {value}") - - # Analyze the grid - grid = result.get("grid", []) - print(f"\nGrid dimensions: {len(grid)}x{len(grid[0]) if grid else 0}") - - print("\nGrid layout:") - print_numbered_grid(grid) - - # Analyze placed words vs clues - clues = result.get("clues", []) - print(f"\nNumber of clues generated: {len(clues)}") - - print("\nClue analysis:") - for i, clue in enumerate(clues): - print(f" Clue {i+1}:") - print(f" Number: {clue.get('number', 'MISSING')}") - print(f" Word: {clue.get('word', 'MISSING')}") - print(f" Direction: {clue.get('direction', 'MISSING')}") - print(f" Position: {clue.get('position', 'MISSING')}") - print(f" Text: {clue.get('text', 'MISSING')}") - - # Check for potential issues - print("\n" + "=" * 70) - print("ISSUE DETECTION") - print("=" * 70) - - check_word_boundary_consistency(grid, clues) - check_numbering_consistency(clues) - check_grid_word_alignment(grid, clues) - -def print_numbered_grid(grid): - """Print grid with coordinates for analysis.""" - if not grid: - print(" Empty grid") - return - - # Print column headers - print(" ", end="") - for c in range(len(grid[0])): - print(f"{c:2d}", end="") - print() - - # Print rows with row numbers - for r in range(len(grid)): - print(f" {r:2d}: ", end="") - for c in range(len(grid[0])): - cell = grid[r][c] - if cell == ".": - print(" .", end="") - else: - print(f" {cell}", end="") - print() - -def check_word_boundary_consistency(grid, clues): - """Check if words in clues match what's actually in the grid.""" - - print("Checking word boundary consistency:") - - issues_found = [] - - for clue in clues: - word = clue.get("word", "") - position = clue.get("position", {}) - direction = clue.get("direction", "") - - if not all([word, position, direction]): - issues_found.append(f"Incomplete clue data: {clue}") - continue - - row = position.get("row", -1) - col = position.get("col", -1) - - if row < 0 or col < 0: - issues_found.append(f"Invalid position for word '{word}': {position}") - continue - - # Extract the actual word from the grid - grid_word = extract_word_from_grid(grid, row, col, direction, len(word)) - - if grid_word != word: - issues_found.append(f"Mismatch for '{word}' at ({row}, {col}) {direction}: grid shows '{grid_word}'") - - if issues_found: - print(" ❌ Issues found:") - for issue in issues_found: - print(f" {issue}") - else: - print(" ✅ All words match grid positions") - -def extract_word_from_grid(grid, row, col, direction, expected_length): - """Extract a word from the grid at the given position and direction.""" - - if row >= len(grid) or col >= len(grid[0]): - return "OUT_OF_BOUNDS" - - word = "" - - if direction == "across": # horizontal - for i in range(expected_length): - if col + i >= len(grid[0]): - return word + "TRUNCATED" - word += grid[row][col + i] - - elif direction == "down": # vertical - for i in range(expected_length): - if row + i >= len(grid): - return word + "TRUNCATED" - word += grid[row + i][col] - - return word - -def check_numbering_consistency(clues): - """Check if clue numbering is consistent and logical.""" - - print("\nChecking numbering consistency:") - - numbers = [clue.get("number", -1) for clue in clues] - issues = [] - - # Check for duplicate numbers - if len(numbers) != len(set(numbers)): - issues.append("Duplicate clue numbers found") - - # Check for missing numbers in sequence - if numbers: - min_num = min(numbers) - max_num = max(numbers) - expected = set(range(min_num, max_num + 1)) - actual = set(numbers) - - if expected != actual: - missing = expected - actual - extra = actual - expected - if missing: - issues.append(f"Missing numbers: {sorted(missing)}") - if extra: - issues.append(f"Extra numbers: {sorted(extra)}") - - if issues: - print(" ❌ Numbering issues:") - for issue in issues: - print(f" {issue}") - else: - print(" ✅ Numbering is consistent") - -def check_grid_word_alignment(grid, clues): - """Check if all words are properly aligned and don't create unintended extensions.""" - - print("\nChecking grid word alignment:") - - # Find all letter sequences in the grid - horizontal_sequences = find_horizontal_sequences(grid) - vertical_sequences = find_vertical_sequences(grid) - - print(f" Found {len(horizontal_sequences)} horizontal sequences") - print(f" Found {len(vertical_sequences)} vertical sequences") - - # Check if each sequence corresponds to a clue - clue_words = {} - for clue in clues: - pos = clue.get("position", {}) - key = (pos.get("row"), pos.get("col"), clue.get("direction")) - clue_words[key] = clue.get("word", "") - - issues = [] - - # Check horizontal sequences - for seq in horizontal_sequences: - row, start_col, word = seq - key = (row, start_col, "across") - if key not in clue_words: - issues.append(f"Unaccounted horizontal sequence: '{word}' at ({row}, {start_col})") - elif clue_words[key] != word: - issues.append(f"Mismatch: clue says '{clue_words[key]}' but grid shows '{word}' at ({row}, {start_col})") - - # Check vertical sequences - for seq in vertical_sequences: - col, start_row, word = seq - key = (start_row, col, "down") - if key not in clue_words: - issues.append(f"Unaccounted vertical sequence: '{word}' at ({start_row}, {col})") - elif clue_words[key] != word: - issues.append(f"Mismatch: clue says '{clue_words[key]}' but grid shows '{word}' at ({start_row}, {col})") - - if issues: - print(" ❌ Alignment issues found:") - for issue in issues: - print(f" {issue}") - else: - print(" ✅ All words are properly aligned") - -def find_horizontal_sequences(grid): - """Find all horizontal letter sequences of length > 1.""" - sequences = [] - - for r in range(len(grid)): - current_word = "" - start_col = None - - for c in range(len(grid[0])): - if grid[r][c] != ".": - if start_col is None: - start_col = c - current_word += grid[r][c] - else: - if current_word and len(current_word) > 1: - sequences.append((r, start_col, current_word)) - current_word = "" - start_col = None - - # Handle word at end of row - if current_word and len(current_word) > 1: - sequences.append((r, start_col, current_word)) - - return sequences - -def find_vertical_sequences(grid): - """Find all vertical letter sequences of length > 1.""" - sequences = [] - - for c in range(len(grid[0])): - current_word = "" - start_row = None - - for r in range(len(grid)): - if grid[r][c] != ".": - if start_row is None: - start_row = r - current_word += grid[r][c] - else: - if current_word and len(current_word) > 1: - sequences.append((c, start_row, current_word)) - current_word = "" - start_row = None - - # Handle word at end of column - if current_word and len(current_word) > 1: - sequences.append((c, start_row, current_word)) - - return sequences - -if __name__ == "__main__": - asyncio.run(debug_complete_generation()) \ No newline at end of file diff --git a/crossword-app/backend-py/debug_grid_direct.py b/crossword-app/backend-py/debug_grid_direct.py deleted file mode 100644 index 01d60e1e91cc6a36886689dfd124df48d14840f6..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/debug_grid_direct.py +++ /dev/null @@ -1,293 +0,0 @@ -#!/usr/bin/env python3 -""" -Direct grid generation test to identify word boundary/display issues. -""" - -import sys -from pathlib import Path - -# Add project root to path -project_root = Path(__file__).parent -sys.path.insert(0, str(project_root)) - -from src.services.crossword_generator_fixed import CrosswordGeneratorFixed - -def test_direct_grid_generation(): - """Test grid generation directly with controlled words.""" - - print("🔍 Direct Grid Generation Test\n") - - generator = CrosswordGeneratorFixed(vector_service=None) - - # Test words that might cause the issues seen in the images - test_words = [ - {"word": "MACHINE", "clue": "Device with moving parts"}, - {"word": "COMPUTER", "clue": "Electronic device"}, - {"word": "EXPERT", "clue": "Person with specialized knowledge"}, - {"word": "SCIENCE", "clue": "Systematic study"}, - {"word": "CAMERA", "clue": "Device for taking photos"}, - {"word": "METHOD", "clue": "Systematic approach"} - ] - - print("=" * 60) - print("TEST 1: Direct grid creation") - print("=" * 60) - - # Test the _create_grid method directly - result = generator._create_grid(test_words) - - if result: - print("✅ Grid generation successful!") - - grid = result["grid"] - placed_words = result["placed_words"] - clues = result["clues"] - - print(f"Grid size: {len(grid)}x{len(grid[0])}") - print(f"Words placed: {len(placed_words)}") - print(f"Clues generated: {len(clues)}") - - # Print the grid - print("\nGenerated Grid:") - print_grid_with_coordinates(grid) - - # Print placed words details - print("\nPlaced Words:") - for i, word_info in enumerate(placed_words): - print(f" {i+1}. {word_info['word']} at ({word_info['row']}, {word_info['col']}) {word_info['direction']}") - - # Print clues - print("\nGenerated Clues:") - for clue in clues: - print(f" {clue['number']}. {clue['direction']}: {clue['word']} - {clue['text']}") - - # Analyze for potential issues - print("\n" + "=" * 60) - print("ANALYSIS") - print("=" * 60) - - analyze_grid_issues(grid, placed_words, clues) - - else: - print("❌ Grid generation failed") - - # Test another scenario that might reproduce the image issues - print("\n" + "=" * 60) - print("TEST 2: Scenario with potential extension words") - print("=" * 60) - - # Words that might create the "MACHINERY" type issue - extension_words = [ - {"word": "MACHINE", "clue": "Device with moving parts"}, - {"word": "MACHINERY", "clue": "Mechanical equipment"}, # Might cause confusion - {"word": "EXPERT", "clue": "Specialist"}, - {"word": "TECHNOLOGY", "clue": "Applied science"}, - ] - - result2 = generator._create_grid(extension_words) - - if result2: - print("✅ Extension test grid generated!") - - grid2 = result2["grid"] - placed_words2 = result2["placed_words"] - - print("\nExtension Test Grid:") - print_grid_with_coordinates(grid2) - - print("\nPlaced Words:") - for i, word_info in enumerate(placed_words2): - print(f" {i+1}. {word_info['word']} at ({word_info['row']}, {word_info['col']}) {word_info['direction']}") - - # Check specifically for MACHINE vs MACHINERY issues - check_machine_machinery_issue(grid2, placed_words2) - - else: - print("❌ Extension test grid generation failed") - -def print_grid_with_coordinates(grid): - """Print grid with row and column coordinates.""" - if not grid: - print(" Empty grid") - return - - # Print column headers - print(" ", end="") - for c in range(len(grid[0])): - print(f"{c:2d}", end="") - print() - - # Print rows - for r in range(len(grid)): - print(f" {r:2d}: ", end="") - for c in range(len(grid[0])): - cell = grid[r][c] - if cell == ".": - print(" .", end="") - else: - print(f" {cell}", end="") - print() - -def analyze_grid_issues(grid, placed_words, clues): - """Analyze the grid for potential boundary/display issues.""" - - print("Checking for potential issues...") - - issues = [] - - # Check 1: Verify each placed word actually exists in the grid - for word_info in placed_words: - word = word_info["word"] - row = word_info["row"] - col = word_info["col"] - direction = word_info["direction"] - - grid_word = extract_word_from_grid(grid, row, col, direction, len(word)) - - if grid_word != word: - issues.append(f"Word mismatch: '{word}' expected at ({row},{col}) {direction}, but grid shows '{grid_word}'") - - # Check 2: Look for unintended letter sequences - all_sequences = find_all_letter_sequences(grid) - intended_words = {(w["row"], w["col"], w["direction"]): w["word"] for w in placed_words} - - for seq_info in all_sequences: - row, col, direction, seq_word = seq_info - key = (row, col, direction) - - if key not in intended_words: - if len(seq_word) > 1: # Only care about multi-letter sequences - issues.append(f"Unintended sequence: '{seq_word}' at ({row},{col}) {direction}") - elif intended_words[key] != seq_word: - issues.append(f"Sequence mismatch: expected '{intended_words[key]}' but found '{seq_word}' at ({row},{col}) {direction}") - - # Check 3: Verify clue consistency - for clue in clues: - clue_word = clue["word"] - pos = clue["position"] - clue_row = pos["row"] - clue_col = pos["col"] - clue_direction = clue["direction"] - - # Convert direction format if needed - direction_map = {"across": "horizontal", "down": "vertical"} - normalized_direction = direction_map.get(clue_direction, clue_direction) - - grid_word = extract_word_from_grid(grid, clue_row, clue_col, normalized_direction, len(clue_word)) - - if grid_word != clue_word: - issues.append(f"Clue mismatch: clue says '{clue_word}' at ({clue_row},{clue_col}) {clue_direction}, but grid shows '{grid_word}'") - - # Report results - if issues: - print("❌ Issues found:") - for issue in issues: - print(f" {issue}") - else: - print("✅ No issues detected - grid appears consistent") - -def extract_word_from_grid(grid, row, col, direction, expected_length): - """Extract word from grid at given position and direction.""" - if row >= len(grid) or col >= len(grid[0]) or row < 0 or col < 0: - return "OUT_OF_BOUNDS" - - word = "" - - if direction in ["horizontal", "across"]: - for i in range(expected_length): - if col + i >= len(grid[0]): - return word + "[TRUNCATED]" - word += grid[row][col + i] - elif direction in ["vertical", "down"]: - for i in range(expected_length): - if row + i >= len(grid): - return word + "[TRUNCATED]" - word += grid[row + i][col] - - return word - -def find_all_letter_sequences(grid): - """Find all letter sequences (horizontal and vertical) in the grid.""" - sequences = [] - - # Horizontal sequences - for r in range(len(grid)): - current_word = "" - start_col = None - - for c in range(len(grid[0])): - if grid[r][c] != ".": - if start_col is None: - start_col = c - current_word += grid[r][c] - else: - if current_word and len(current_word) > 1: - sequences.append((r, start_col, "horizontal", current_word)) - current_word = "" - start_col = None - - # Handle end of row - if current_word and len(current_word) > 1: - sequences.append((r, start_col, "horizontal", current_word)) - - # Vertical sequences - for c in range(len(grid[0])): - current_word = "" - start_row = None - - for r in range(len(grid)): - if grid[r][c] != ".": - if start_row is None: - start_row = r - current_word += grid[r][c] - else: - if current_word and len(current_word) > 1: - sequences.append((start_row, c, "vertical", current_word)) - current_word = "" - start_row = None - - # Handle end of column - if current_word and len(current_word) > 1: - sequences.append((start_row, c, "vertical", current_word)) - - return sequences - -def check_machine_machinery_issue(grid, placed_words): - """Specifically check for MACHINE vs MACHINERY confusion.""" - - print("\nChecking for MACHINE/MACHINERY issue:") - - machine_words = [w for w in placed_words if "MACHINE" in w["word"]] - - if not machine_words: - print(" No MACHINE-related words found") - return - - for word_info in machine_words: - word = word_info["word"] - row = word_info["row"] - col = word_info["col"] - direction = word_info["direction"] - - print(f" Found: '{word}' at ({row},{col}) {direction}") - - # Check what's actually in the grid at this location - grid_word = extract_word_from_grid(grid, row, col, direction, len(word)) - print(f" Grid shows: '{grid_word}'") - - # Check if there are extra letters that might create confusion - if direction == "horizontal": - # Check for letters after the word - end_col = col + len(word) - if end_col < len(grid[0]) and grid[row][end_col] != ".": - extra_letters = "" - check_col = end_col - while check_col < len(grid[0]) and grid[row][check_col] != ".": - extra_letters += grid[row][check_col] - check_col += 1 - if extra_letters: - print(f" ⚠️ Extra letters after word: '{extra_letters}'") - print(f" This might make '{word}' appear as '{word + extra_letters}'") - -if __name__ == "__main__": - test_direct_grid_generation() \ No newline at end of file diff --git a/crossword-app/backend-py/debug_index_error.py b/crossword-app/backend-py/debug_index_error.py deleted file mode 100644 index eb7548b92fdc7b1849d93ce9d3442e3c5b4ee2c7..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/debug_index_error.py +++ /dev/null @@ -1,307 +0,0 @@ -#!/usr/bin/env python3 -""" -Debug the recurring index error by adding comprehensive bounds checking. -""" - -import asyncio -import sys -import logging -from pathlib import Path - -# Add project root to path -project_root = Path(__file__).parent -sys.path.insert(0, str(project_root)) - -from src.services.crossword_generator_fixed import CrosswordGeneratorFixed -from src.services.vector_search import VectorSearchService - -# Enable debug logging -logging.basicConfig(level=logging.DEBUG) -logger = logging.getLogger(__name__) - -class DebugCrosswordGenerator(CrosswordGeneratorFixed): - """Debug version with comprehensive bounds checking.""" - - def _can_place_word(self, grid, word, row, col, direction): - """Enhanced _can_place_word with comprehensive bounds checking.""" - try: - size = len(grid) - logger.debug(f"_can_place_word: word={word}, row={row}, col={col}, direction={direction}, grid_size={size}") - - # Check initial boundaries - if row < 0 or col < 0 or row >= size or col >= size: - logger.debug(f"Initial bounds check failed: row={row}, col={col}, size={size}") - return False - - if direction == "horizontal": - if col + len(word) > size: - logger.debug(f"Horizontal bounds check failed: col+len(word)={col + len(word)} > size={size}") - return False - - # Check word boundaries (no adjacent letters) - with bounds check - if col > 0: - if row >= size or col - 1 >= size or row < 0 or col - 1 < 0: - logger.debug(f"Horizontal left boundary check failed: row={row}, col-1={col-1}, size={size}") - return False - if grid[row][col - 1] != ".": - logger.debug(f"Horizontal left boundary has adjacent letter") - return False - - if col + len(word) < size: - if row >= size or col + len(word) >= size or row < 0 or col + len(word) < 0: - logger.debug(f"Horizontal right boundary check failed: row={row}, col+len={col + len(word)}, size={size}") - return False - if grid[row][col + len(word)] != ".": - logger.debug(f"Horizontal right boundary has adjacent letter") - return False - - # Check each letter position - for i, letter in enumerate(word): - check_row = row - check_col = col + i - if check_row >= size or check_col >= size or check_row < 0 or check_col < 0: - logger.debug(f"Horizontal letter position check failed: letter {i}, row={check_row}, col={check_col}, size={size}") - return False - current_cell = grid[check_row][check_col] - if current_cell != "." and current_cell != letter: - logger.debug(f"Horizontal letter conflict: expected {letter}, found {current_cell}") - return False - - else: # vertical - if row + len(word) > size: - logger.debug(f"Vertical bounds check failed: row+len(word)={row + len(word)} > size={size}") - return False - - # Check word boundaries - with bounds check - if row > 0: - if row - 1 >= size or col >= size or row - 1 < 0 or col < 0: - logger.debug(f"Vertical top boundary check failed: row-1={row-1}, col={col}, size={size}") - return False - if grid[row - 1][col] != ".": - logger.debug(f"Vertical top boundary has adjacent letter") - return False - - if row + len(word) < size: - if row + len(word) >= size or col >= size or row + len(word) < 0 or col < 0: - logger.debug(f"Vertical bottom boundary check failed: row+len={row + len(word)}, col={col}, size={size}") - return False - if grid[row + len(word)][col] != ".": - logger.debug(f"Vertical bottom boundary has adjacent letter") - return False - - # Check each letter position - for i, letter in enumerate(word): - check_row = row + i - check_col = col - if check_row >= size or check_col >= size or check_row < 0 or check_col < 0: - logger.debug(f"Vertical letter position check failed: letter {i}, row={check_row}, col={check_col}, size={size}") - return False - current_cell = grid[check_row][check_col] - if current_cell != "." and current_cell != letter: - logger.debug(f"Vertical letter conflict: expected {letter}, found {current_cell}") - return False - - logger.debug(f"_can_place_word: SUCCESS for word={word}") - return True - - except Exception as e: - logger.error(f"❌ ERROR in _can_place_word: {e}") - logger.error(f" word={word}, row={row}, col={col}, direction={direction}") - logger.error(f" grid_size={len(grid) if grid else 'None'}") - import traceback - traceback.print_exc() - return False - - def _place_word(self, grid, word, row, col, direction): - """Enhanced _place_word with comprehensive bounds checking.""" - try: - size = len(grid) - logger.debug(f"_place_word: word={word}, row={row}, col={col}, direction={direction}, grid_size={size}") - - original_state = [] - - if direction == "horizontal": - for i, letter in enumerate(word): - check_row = row - check_col = col + i - if check_row >= size or check_col >= size or check_row < 0 or check_col < 0: - logger.error(f"❌ _place_word horizontal bounds error: row={check_row}, col={check_col}, size={size}") - raise IndexError(f"Grid index out of range: [{check_row}][{check_col}] in grid of size {size}") - - original_state.append({ - "row": check_row, - "col": check_col, - "value": grid[check_row][check_col] - }) - grid[check_row][check_col] = letter - else: - for i, letter in enumerate(word): - check_row = row + i - check_col = col - if check_row >= size or check_col >= size or check_row < 0 or check_col < 0: - logger.error(f"❌ _place_word vertical bounds error: row={check_row}, col={check_col}, size={size}") - raise IndexError(f"Grid index out of range: [{check_row}][{check_col}] in grid of size {size}") - - original_state.append({ - "row": check_row, - "col": check_col, - "value": grid[check_row][check_col] - }) - grid[check_row][check_col] = letter - - logger.debug(f"_place_word: SUCCESS for word={word}") - return original_state - - except Exception as e: - logger.error(f"❌ ERROR in _place_word: {e}") - logger.error(f" word={word}, row={row}, col={col}, direction={direction}") - logger.error(f" grid_size={len(grid) if grid else 'None'}") - import traceback - traceback.print_exc() - raise - - def _remove_word(self, grid, original_state): - """Enhanced _remove_word with comprehensive bounds checking.""" - try: - size = len(grid) - logger.debug(f"_remove_word: restoring {len(original_state)} positions, grid_size={size}") - - for state in original_state: - check_row = state["row"] - check_col = state["col"] - if check_row >= size or check_col >= size or check_row < 0 or check_col < 0: - logger.error(f"❌ _remove_word bounds error: row={check_row}, col={check_col}, size={size}") - raise IndexError(f"Grid index out of range: [{check_row}][{check_col}] in grid of size {size}") - - grid[check_row][check_col] = state["value"] - - logger.debug(f"_remove_word: SUCCESS") - - except Exception as e: - logger.error(f"❌ ERROR in _remove_word: {e}") - logger.error(f" grid_size={len(grid) if grid else 'None'}") - logger.error(f" original_state={original_state}") - import traceback - traceback.print_exc() - raise - - def _create_simple_cross(self, word_list, word_objs): - """Enhanced _create_simple_cross with comprehensive bounds checking.""" - try: - logger.debug(f"_create_simple_cross: words={word_list}") - - if len(word_list) < 2: - logger.debug("Not enough words for simple cross") - return None - - word1, word2 = word_list[0], word_list[1] - intersections = self._find_word_intersections(word1, word2) - - if not intersections: - logger.debug("No intersections found") - return None - - # Use first intersection - intersection = intersections[0] - size = max(len(word1), len(word2)) + 4 - logger.debug(f"Creating grid of size {size} for simple cross") - - grid = [["." for _ in range(size)] for _ in range(size)] - - # Place first word horizontally in center - center_row = size // 2 - center_col = (size - len(word1)) // 2 - - logger.debug(f"Placing word1 '{word1}' at row={center_row}, col={center_col}") - - for i, letter in enumerate(word1): - check_row = center_row - check_col = center_col + i - if check_row >= size or check_col >= size or check_row < 0 or check_col < 0: - logger.error(f"❌ _create_simple_cross word1 bounds error: row={check_row}, col={check_col}, size={size}") - raise IndexError(f"Grid index out of range: [{check_row}][{check_col}] in grid of size {size}") - grid[check_row][check_col] = letter - - # Place second word vertically at intersection - intersection_col = center_col + intersection["word_pos"] - word2_start_row = center_row - intersection["placed_pos"] - - logger.debug(f"Placing word2 '{word2}' at row={word2_start_row}, col={intersection_col}") - - for i, letter in enumerate(word2): - check_row = word2_start_row + i - check_col = intersection_col - if check_row >= size or check_col >= size or check_row < 0 or check_col < 0: - logger.error(f"❌ _create_simple_cross word2 bounds error: row={check_row}, col={check_col}, size={size}") - raise IndexError(f"Grid index out of range: [{check_row}][{check_col}] in grid of size {size}") - grid[check_row][check_col] = letter - - placed_words = [ - {"word": word1, "row": center_row, "col": center_col, "direction": "horizontal", "number": 1}, - {"word": word2, "row": word2_start_row, "col": intersection_col, "direction": "vertical", "number": 2} - ] - - logger.debug(f"_create_simple_cross: SUCCESS") - - trimmed = self._trim_grid(grid, placed_words) - clues = self._generate_clues(word_objs[:2], trimmed["placed_words"]) - - return { - "grid": trimmed["grid"], - "placed_words": trimmed["placed_words"], - "clues": clues - } - - except Exception as e: - logger.error(f"❌ ERROR in _create_simple_cross: {e}") - import traceback - traceback.print_exc() - raise - -async def test_debug_generator(): - """Test the debug generator to catch index errors.""" - try: - print("🧪 Testing debug crossword generator...") - - # Create mock vector service - vector_service = VectorSearchService() - - # Create debug generator - generator = DebugCrosswordGenerator(vector_service) - - # Test with various topics and difficulties - test_cases = [ - (["animals"], "medium"), - (["science"], "hard"), - (["technology"], "easy"), - (["animals", "science"], "medium"), - ] - - for i, (topics, difficulty) in enumerate(test_cases): - print(f"\n🔬 Test {i+1}: topics={topics}, difficulty={difficulty}") - try: - result = await generator.generate_puzzle(topics, difficulty, use_ai=False) - if result: - print(f"✅ Test {i+1} succeeded") - grid_size = len(result['grid']) - word_count = len(result['clues']) - print(f" Grid: {grid_size}x{grid_size}, Words: {word_count}") - else: - print(f"⚠️ Test {i+1} returned None") - except Exception as e: - print(f"❌ Test {i+1} failed: {e}") - import traceback - traceback.print_exc() - return False - - print(f"\n✅ All debug tests completed!") - return True - - except Exception as e: - print(f"❌ Debug test setup failed: {e}") - import traceback - traceback.print_exc() - return False - -if __name__ == "__main__": - asyncio.run(test_debug_generator()) \ No newline at end of file diff --git a/crossword-app/backend-py/debug_simple.py b/crossword-app/backend-py/debug_simple.py deleted file mode 100644 index 9e0edb1926263311bda3f0b4d88c800b0d5115c0..0000000000000000000000000000000000000000 --- a/crossword-app/backend-py/debug_simple.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python3 -""" -Simple debug test for crossword generator index errors. -""" - -import asyncio -import sys -import logging -from pathlib import Path - -# Add project root to path -project_root = Path(__file__).parent -sys.path.insert(0, str(project_root)) - -from src.services.crossword_generator_fixed import CrosswordGeneratorFixed - -# Enable debug logging -logging.basicConfig(level=logging.DEBUG) -logger = logging.getLogger(__name__) - -async def test_with_static_words(): - """Test generator with static word lists.""" - - # Create generator without vector service - generator = CrosswordGeneratorFixed(vector_service=None) - - # Create test words - test_words = [ - {"word": "CAT", "clue": "Feline pet"}, - {"word": "DOG", "clue": "Man's best friend"}, - {"word": "BIRD", "clue": "Flying animal"}, - {"word": "FISH", "clue": "Aquatic animal"}, - {"word": "ELEPHANT", "clue": "Large mammal"}, - {"word": "TIGER", "clue": "Striped cat"}, - {"word": "HORSE", "clue": "Riding animal"}, - {"word": "BEAR", "clue": "Large carnivore"} - ] - - print(f"🧪 Testing crossword generation with {len(test_words)} words...") - - try: - # Test multiple times to catch intermittent errors - for attempt in range(10): - print(f"\n🔬 Attempt {attempt + 1}/10") - - # Shuffle words to create different scenarios - import random - random.shuffle(test_words) - - # Override the word selection to use our test words - generator._select_words = lambda topics, difficulty, use_ai: test_words - - result = await generator.generate_puzzle(["animals"], "medium", use_ai=False) - - if result: - grid_size = len(result['grid']) - word_count = len(result['clues']) - print(f"✅ Attempt {attempt + 1} succeeded: {grid_size}x{grid_size} grid, {word_count} words") - else: - print(f"⚠️ Attempt {attempt + 1} returned None") - - except IndexError as e: - print(f"❌ INDEX ERROR caught on attempt {attempt + 1}: {e}") - import traceback - traceback.print_exc() - return False - except Exception as e: - print(f"❌ Other error on attempt {attempt + 1}: {e}") - import traceback - traceback.print_exc() - return False - - print(f"\n✅ All 10 attempts completed successfully!") - return True - -async def test_grid_placement_directly(): - """Test grid placement functions directly with problematic data.""" - - generator = CrosswordGeneratorFixed(vector_service=None) - - # Test data that might cause issues - test_cases = [ - { - "words": ["A", "I"], # Very short words - "description": "Very short words" - }, - { - "words": ["VERYLONGWORDTHATMIGHTCAUSEISSUES", "SHORT"], - "description": "Very long word with short word" - }, - { - "words": ["ABCDEFGHIJKLMNOP", "QRSTUVWXYZ"], # Long words - "description": "Two long words" - }, - { - "words": ["TEST", "SETS", "NETS", "PETS"], # Multiple similar words - "description": "Similar words with same endings" - } - ] - - for i, test_case in enumerate(test_cases): - print(f"\n🔬 Grid test {i+1}: {test_case['description']}") - - try: - word_list = test_case["words"] - word_objs = [{"word": w, "clue": f"Clue for {w}"} for w in word_list] - - result = generator._create_grid(word_objs) - - if result: - grid_size = len(result['grid']) - word_count = len(result['placed_words']) - print(f"✅ Grid test {i+1} succeeded: {grid_size}x{grid_size} grid, {word_count} words") - else: - print(f"⚠️ Grid test {i+1} returned None") - - except IndexError as e: - print(f"❌ INDEX ERROR in grid test {i+1}: {e}") - import traceback - traceback.print_exc() - return False - except Exception as e: - print(f"❌ Other error in grid test {i+1}: {e}") - import traceback - traceback.print_exc() - return False - - return True - -if __name__ == "__main__": - print("🧪 Starting debug tests for crossword generator...") - - async def run_tests(): - success1 = await test_with_static_words() - success2 = await test_grid_placement_directly() - - if success1 and success2: - print("\n🎉 All debug tests passed! No index errors detected.") - else: - print("\n❌ Some debug tests failed.") - - asyncio.run(run_tests()) \ No newline at end of file diff --git a/crossword-app/backend-py/public/assets/index-2XJqMaqu.js b/crossword-app/backend-py/public/assets/index-2XJqMaqu.js new file mode 100644 index 0000000000000000000000000000000000000000..153720fac15a98832c586eb10cb8dd9958e06a36 --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-2XJqMaqu.js @@ -0,0 +1,10 @@ +import{r as p,a as C,R as P}from"./vendor-nf7bT_Uh.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))n(t);new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function c(t){const r={};return t.integrity&&(r.integrity=t.integrity),t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?r.credentials="include":t.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(t){if(t.ep)return;t.ep=!0;const r=c(t);fetch(t.href,r)}})();var w={exports:{}},z={};/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var R=p,_=Symbol.for("react.element"),$=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,O=R.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,k={key:!0,ref:!0,__self:!0,__source:!0};function S(s,a,c){var n,t={},r=null,o=null;c!==void 0&&(r=""+c),a.key!==void 0&&(r=""+a.key),a.ref!==void 0&&(o=a.ref);for(n in a)E.call(a,n)&&!k.hasOwnProperty(n)&&(t[n]=a[n]);if(s&&s.defaultProps)for(n in a=s.defaultProps,a)t[n]===void 0&&(t[n]=a[n]);return{$$typeof:_,type:s,key:r,ref:o,props:t,_owner:O.current}}z.Fragment=$;z.jsx=S;z.jsxs=S;w.exports=z;var e=w.exports,N={},b=C;N.createRoot=b.createRoot,N.hydrateRoot=b.hydrateRoot;const T=({onTopicsChange:s,availableTopics:a=[],selectedTopics:c=[]})=>{const n=t=>{const r=c.includes(t)?c.filter(o=>o!==t):[...c,t];s(r)};return e.jsxs("div",{className:"topic-selector",children:[e.jsx("h3",{children:"Select Topics"}),e.jsx("div",{className:"topic-buttons",children:a.map(t=>e.jsx("button",{className:`topic-btn ${c.includes(t.name)?"selected":""}`,onClick:()=>n(t.name),children:t.name},t.id))}),e.jsxs("p",{className:"selected-count",children:[c.length," topic",c.length!==1?"s":""," selected"]})]})},L=({grid:s,clues:a,showSolution:c,onCellChange:n})=>{const[t,r]=p.useState({}),o=(u,l,i)=>{const d=`${u}-${l}`,h={...t,[d]:i.toUpperCase()};r(h),n&&n(u,l,i)},f=(u,l)=>{if(c&&!m(u,l))return s[u][l];const i=`${u}-${l}`;return t[i]||""},m=(u,l)=>s[u][l]===".",g=(u,l)=>{if(!a)return null;const i=a.find(d=>d.position.row===u&&d.position.col===l);return i?i.number:null};if(!s||s.length===0)return e.jsx("div",{className:"puzzle-grid",children:"No puzzle loaded"});const x=s.length,y=s[0]?s[0].length:0;return e.jsx("div",{className:"puzzle-container",children:e.jsx("div",{className:"puzzle-grid",style:{gridTemplateColumns:`repeat(${y}, 35px)`,gridTemplateRows:`repeat(${x}, 35px)`},children:s.map((u,l)=>u.map((i,d)=>{const h=g(l,d);return m(l,d)?e.jsx("div",{className:"grid-cell empty-cell",style:{visibility:"hidden"}},`${l}-${d}`):e.jsxs("div",{className:"grid-cell white-cell",children:[h&&e.jsx("span",{className:"cell-number",children:h}),e.jsx("input",{type:"text",maxLength:"1",value:f(l,d),onChange:v=>o(l,d,v.target.value),className:`cell-input ${c?"solution-text":""}`,disabled:c})]},`${l}-${d}`)}))})})},A=({clues:s=[]})=>{const a=s.filter(t=>t.direction==="across"),c=s.filter(t=>t.direction==="down"),n=({title:t,clueList:r})=>e.jsxs("div",{className:"clue-section",children:[e.jsx("h4",{children:t}),e.jsx("ol",{children:r.map(o=>e.jsxs("li",{className:"clue-item",children:[e.jsx("span",{className:"clue-number",children:o.number}),e.jsx("span",{className:"clue-text",children:o.text})]},`${o.number}-${o.direction}`))})]});return e.jsxs("div",{className:"clue-list",children:[e.jsx(n,{title:"Across",clueList:a}),e.jsx(n,{title:"Down",clueList:c})]})},D=({message:s="Generating puzzle..."})=>e.jsxs("div",{className:"loading-spinner",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{className:"loading-message",children:s})]}),F=()=>{const[s,a]=p.useState(null),[c,n]=p.useState(!1),[t,r]=p.useState(null),[o,f]=p.useState([]),m="",g=p.useCallback(async()=>{try{n(!0);const l=await fetch(`${m}/api/topics`);if(!l.ok)throw new Error("Failed to fetch topics");const i=await l.json();f(i)}catch(l){r(l.message)}finally{n(!1)}},[m]),x=p.useCallback(async(l,i="medium",d=!1)=>{try{n(!0),r(null);const h=await fetch(`${m}/api/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:l,difficulty:i,useAI:d})});if(!h.ok){const v=await h.json().catch(()=>({}));throw new Error(v.message||"Failed to generate puzzle")}const j=await h.json();return a(j),j}catch(h){return r(h.message),null}finally{n(!1)}},[m]),y=p.useCallback(async l=>{try{const i=await fetch(`${m}/api/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({puzzle:s,answers:l})});if(!i.ok)throw new Error("Failed to validate answers");return await i.json()}catch(i){return r(i.message),null}},[m,s]),u=p.useCallback(()=>{a(null),r(null)},[]);return{puzzle:s,loading:c,error:t,topics:o,fetchTopics:g,generatePuzzle:x,validateAnswers:y,resetPuzzle:u}};function G(){const[s,a]=p.useState([]),[c,n]=p.useState("medium"),[t,r]=p.useState(!1),{puzzle:o,loading:f,error:m,topics:g,fetchTopics:x,generatePuzzle:y,resetPuzzle:u}=F();p.useEffect(()=>{x()},[x]);const l=async()=>{if(s.length===0){alert("Please select at least one topic");return}await y(s,c,!1)},i=j=>{a(j)},d=()=>{u(),a([]),r(!1),n("medium")},h=()=>{r(!0)};return e.jsxs("div",{className:"crossword-app",children:[e.jsxs("header",{className:"app-header",children:[e.jsx("h1",{className:"app-title",children:"Crossword Puzzle Generator"}),e.jsx("p",{children:"Select topics and generate your custom crossword puzzle!"})]}),e.jsx(T,{onTopicsChange:i,availableTopics:g,selectedTopics:s}),e.jsxs("div",{className:"puzzle-controls",children:[e.jsxs("select",{value:c,onChange:j=>n(j.target.value),className:"control-btn",children:[e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]}),e.jsx("button",{onClick:l,disabled:f||s.length===0,className:"control-btn generate-btn",children:f?"Generating...":"Generate Puzzle"}),e.jsx("button",{onClick:d,className:"control-btn reset-btn",children:"Reset"}),o&&!t&&e.jsx("button",{onClick:h,className:"control-btn reveal-btn",children:"Reveal Solution"})]}),m&&e.jsxs("div",{className:"error-message",children:["Error: ",m]}),f&&e.jsx(D,{}),o&&!f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"puzzle-info",children:e.jsxs("span",{className:"puzzle-stats",children:[o.metadata.wordCount," words • ",o.metadata.size,"×",o.metadata.size," grid"]})}),e.jsxs("div",{className:"puzzle-layout",children:[e.jsx(L,{grid:o.grid,clues:o.clues,showSolution:t}),e.jsx(A,{clues:o.clues})]})]}),!o&&!f&&!m&&e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"#7f8c8d"},children:'Select topics and click "Generate Puzzle" to start!'})]})}N.createRoot(document.getElementById("root")).render(e.jsx(P.StrictMode,{children:e.jsx(G,{})})); +//# sourceMappingURL=index-2XJqMaqu.js.map diff --git a/crossword-app/backend-py/public/assets/index-2XJqMaqu.js.map b/crossword-app/backend-py/public/assets/index-2XJqMaqu.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9be6b41d022056623230dbdda9c607f7f9a27f4c --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-2XJqMaqu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index-2XJqMaqu.js","sources":["../../node_modules/react/cjs/react-jsx-runtime.production.min.js","../../node_modules/react/jsx-runtime.js","../../node_modules/react-dom/client.js","../../src/components/TopicSelector.jsx","../../src/components/PuzzleGrid.jsx","../../src/components/ClueList.jsx","../../src/components/LoadingSpinner.jsx","../../src/hooks/useCrossword.js","../../src/App.jsx","../../src/main.jsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","'use strict';\n\nvar m = require('react-dom');\nif (process.env.NODE_ENV === 'production') {\n exports.createRoot = m.createRoot;\n exports.hydrateRoot = m.hydrateRoot;\n} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n","import React from 'react';\n\nconst TopicSelector = ({ \n onTopicsChange, \n availableTopics = [], \n selectedTopics = []\n}) => {\n const handleTopicToggle = (topic) => {\n const newSelectedTopics = selectedTopics.includes(topic)\n ? selectedTopics.filter(t => t !== topic)\n : [...selectedTopics, topic];\n \n onTopicsChange(newSelectedTopics);\n };\n\n return (\n
\n

Select Topics

\n
\n {availableTopics.map(topic => (\n handleTopicToggle(topic.name)}\n >\n {topic.name}\n \n ))}\n
\n \n

\n {selectedTopics.length} topic{selectedTopics.length !== 1 ? 's' : ''} selected\n

\n
\n );\n};\n\nexport default TopicSelector;","import React, { useState } from 'react';\n\nconst PuzzleGrid = ({ grid, clues, showSolution, onCellChange }) => {\n const [userAnswers, setUserAnswers] = useState({});\n\n const handleCellInput = (row, col, value) => {\n const key = `${row}-${col}`;\n const newAnswers = { ...userAnswers, [key]: value.toUpperCase() };\n setUserAnswers(newAnswers);\n onCellChange && onCellChange(row, col, value);\n };\n\n const getCellValue = (row, col) => {\n if (showSolution && !isBlackCell(row, col)) {\n return grid[row][col];\n }\n const key = `${row}-${col}`;\n return userAnswers[key] || '';\n };\n\n const isBlackCell = (row, col) => {\n return grid[row][col] === '.';\n };\n\n const getCellNumber = (row, col) => {\n if (!clues) return null;\n const clue = clues.find(c => c.position.row === row && c.position.col === col);\n return clue ? clue.number : null;\n };\n\n if (!grid || grid.length === 0) {\n return
No puzzle loaded
;\n }\n\n const gridRows = grid.length;\n const gridCols = grid[0] ? grid[0].length : 0;\n\n return (\n
\n
\n {grid.map((row, rowIndex) =>\n row.map((cell, colIndex) => {\n const cellNumber = getCellNumber(rowIndex, colIndex);\n const isBlack = isBlackCell(rowIndex, colIndex);\n \n // Only render cells that contain letters (not black/unused cells)\n if (isBlack) {\n return (\n \n
\n );\n }\n \n return (\n \n {cellNumber && {cellNumber}}\n handleCellInput(rowIndex, colIndex, e.target.value)}\n className={`cell-input ${showSolution ? 'solution-text' : ''}`}\n disabled={showSolution}\n />\n
\n );\n })\n )}\n \n \n );\n};\n\nexport default PuzzleGrid;","import React from 'react';\n\nconst ClueList = ({ clues = [] }) => {\n const acrossClues = clues.filter(clue => clue.direction === 'across');\n const downClues = clues.filter(clue => clue.direction === 'down');\n\n const ClueSection = ({ title, clueList }) => (\n
\n

{title}

\n
    \n {clueList.map(clue => (\n
  1. \n {clue.number}\n {clue.text}\n
  2. \n ))}\n
\n
\n );\n\n return (\n
\n \n \n
\n );\n};\n\nexport default ClueList;","import React from 'react';\n\nconst LoadingSpinner = ({ message = \"Generating puzzle...\" }) => {\n return (\n
\n
\n

{message}

\n
\n );\n};\n\nexport default LoadingSpinner;","import { useState, useCallback } from 'react';\n\nconst useCrossword = () => {\n const [puzzle, setPuzzle] = useState(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState(null);\n const [topics, setTopics] = useState([]);\n\n const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || (import.meta.env.PROD ? '' : 'http://localhost:3000');\n\n const fetchTopics = useCallback(async () => {\n try {\n setLoading(true);\n const response = await fetch(`${API_BASE_URL}/api/topics`);\n if (!response.ok) throw new Error('Failed to fetch topics');\n const data = await response.json();\n setTopics(data);\n } catch (err) {\n setError(err.message);\n } finally {\n setLoading(false);\n }\n }, [API_BASE_URL]);\n\n const generatePuzzle = useCallback(async (selectedTopics, difficulty = 'medium', useAI = false) => {\n try {\n setLoading(true);\n setError(null);\n \n const response = await fetch(`${API_BASE_URL}/api/generate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n topics: selectedTopics,\n difficulty,\n useAI\n })\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new Error(errorData.message || 'Failed to generate puzzle');\n }\n \n const puzzleData = await response.json();\n setPuzzle(puzzleData);\n return puzzleData;\n } catch (err) {\n setError(err.message);\n return null;\n } finally {\n setLoading(false);\n }\n }, [API_BASE_URL]);\n\n const validateAnswers = useCallback(async (userAnswers) => {\n try {\n const response = await fetch(`${API_BASE_URL}/api/validate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n puzzle: puzzle,\n answers: userAnswers\n })\n });\n\n if (!response.ok) throw new Error('Failed to validate answers');\n \n return await response.json();\n } catch (err) {\n setError(err.message);\n return null;\n }\n }, [API_BASE_URL, puzzle]);\n\n const resetPuzzle = useCallback(() => {\n setPuzzle(null);\n setError(null);\n }, []);\n\n return {\n puzzle,\n loading,\n error,\n topics,\n fetchTopics,\n generatePuzzle,\n validateAnswers,\n resetPuzzle\n };\n};\n\nexport default useCrossword;","import React, { useState, useEffect } from 'react';\nimport TopicSelector from './components/TopicSelector';\nimport PuzzleGrid from './components/PuzzleGrid';\nimport ClueList from './components/ClueList';\nimport LoadingSpinner from './components/LoadingSpinner';\nimport useCrossword from './hooks/useCrossword';\nimport './styles/puzzle.css';\n\nfunction App() {\n const [selectedTopics, setSelectedTopics] = useState([]);\n const [difficulty, setDifficulty] = useState('medium');\n const [showSolution, setShowSolution] = useState(false);\n \n const {\n puzzle,\n loading,\n error,\n topics,\n fetchTopics,\n generatePuzzle,\n resetPuzzle\n } = useCrossword();\n\n useEffect(() => {\n fetchTopics();\n }, [fetchTopics]);\n\n const handleGeneratePuzzle = async () => {\n if (selectedTopics.length === 0) {\n alert('Please select at least one topic');\n return;\n }\n \n await generatePuzzle(selectedTopics, difficulty, false);\n };\n\n const handleTopicsChange = (topics) => {\n setSelectedTopics(topics);\n };\n\n\n const handleReset = () => {\n resetPuzzle();\n setSelectedTopics([]);\n setShowSolution(false);\n setDifficulty('medium');\n };\n\n const handleRevealSolution = () => {\n setShowSolution(true);\n };\n\n return (\n
\n
\n

Crossword Puzzle Generator

\n

Select topics and generate your custom crossword puzzle!

\n
\n\n \n\n
\n \n \n \n {loading ? 'Generating...' : 'Generate Puzzle'}\n \n \n \n Reset\n \n \n {puzzle && !showSolution && (\n \n Reveal Solution\n \n )}\n
\n\n {error && (\n
\n Error: {error}\n
\n )}\n\n {loading && }\n\n {puzzle && !loading && (\n <>\n
\n \n {puzzle.metadata.wordCount} words • {puzzle.metadata.size}×{puzzle.metadata.size} grid\n \n
\n
\n \n \n
\n \n )}\n\n {!puzzle && !loading && !error && (\n
\n Select topics and click \"Generate Puzzle\" to start!\n
\n )}\n
\n );\n}\n\nexport default App;","import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport App from './App.jsx'\n\nReactDOM.createRoot(document.getElementById('root')).render(\n \n \n ,\n)"],"names":["f","require$$0","k","l","m","n","p","q","c","g","b","d","e","h","reactJsxRuntime_production_min","jsxRuntimeModule","client","TopicSelector","onTopicsChange","availableTopics","selectedTopics","handleTopicToggle","topic","newSelectedTopics","t","jsxs","jsx","PuzzleGrid","grid","clues","showSolution","onCellChange","userAnswers","setUserAnswers","useState","handleCellInput","row","col","value","key","newAnswers","getCellValue","isBlackCell","getCellNumber","clue","gridRows","gridCols","rowIndex","cell","colIndex","cellNumber","ClueList","acrossClues","downClues","ClueSection","title","clueList","LoadingSpinner","message","useCrossword","puzzle","setPuzzle","loading","setLoading","error","setError","topics","setTopics","API_BASE_URL","fetchTopics","useCallback","response","data","err","generatePuzzle","difficulty","useAI","errorData","puzzleData","validateAnswers","resetPuzzle","App","setSelectedTopics","setDifficulty","setShowSolution","useEffect","handleGeneratePuzzle","handleTopicsChange","handleReset","handleRevealSolution","Fragment","ReactDOM","React"],"mappings":";;;;;;;;GASa,IAAIA,EAAEC,EAAiBC,EAAE,OAAO,IAAI,eAAe,EAAEC,EAAE,OAAO,IAAI,gBAAgB,EAAEC,EAAE,OAAO,UAAU,eAAeC,EAAEL,EAAE,mDAAmD,kBAAkBM,EAAE,CAAC,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,EAAE,EAClP,SAASC,EAAEC,EAAE,EAAEC,EAAE,CAAC,IAAIC,EAAEC,EAAE,GAAGC,EAAE,KAAKC,EAAE,KAAcJ,IAAT,SAAaG,EAAE,GAAGH,GAAY,EAAE,MAAX,SAAiBG,EAAE,GAAG,EAAE,KAAc,EAAE,M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AAS,eAAe,MAAM,CAAC,EAAE,aAClDC,EAAM,WAAN,CACC,SAAAlE,MAACuD,IAAI,CAAA,CACP,CACF","x_google_ignoreList":[0,1,2]} \ No newline at end of file diff --git a/crossword-app/backend-py/public/assets/index-7dkEH9uQ.js b/crossword-app/backend-py/public/assets/index-7dkEH9uQ.js new file mode 100644 index 0000000000000000000000000000000000000000..c67e35520c1039059fe9dce1382e451a5622d0c7 --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-7dkEH9uQ.js @@ -0,0 +1,10 @@ +import{r as m,a as R,R as E}from"./vendor-nf7bT_Uh.js";(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))n(t);new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function o(t){const r={};return t.integrity&&(r.integrity=t.integrity),t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?r.credentials="include":t.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(t){if(t.ep)return;t.ep=!0;const r=o(t);fetch(t.href,r)}})();var S={exports:{}},N={};/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var _=m,$=Symbol.for("react.element"),k=Symbol.for("react.fragment"),O=Object.prototype.hasOwnProperty,T=_.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,L={key:!0,ref:!0,__self:!0,__source:!0};function P(s,c,o){var n,t={},r=null,l=null;o!==void 0&&(r=""+o),c.key!==void 0&&(r=""+c.key),c.ref!==void 0&&(l=c.ref);for(n in c)O.call(c,n)&&!L.hasOwnProperty(n)&&(t[n]=c[n]);if(s&&s.defaultProps)for(n in c=s.defaultProps,c)t[n]===void 0&&(t[n]=c[n]);return{$$typeof:$,type:s,key:r,ref:l,props:t,_owner:T.current}}N.Fragment=k;N.jsx=P;N.jsxs=P;S.exports=N;var e=S.exports,w={},C=R;w.createRoot=C.createRoot,w.hydrateRoot=C.hydrateRoot;const A=({onTopicsChange:s,availableTopics:c=[],selectedTopics:o=[],customSentence:n="",onSentenceChange:t})=>{const r=l=>{const x=o.includes(l)?o.filter(i=>i!==l):[...o,l];s(x)};return e.jsxs("div",{className:"topic-selector",children:[e.jsx("h3",{children:"Select Topics"}),e.jsx("div",{className:"topic-buttons",children:c.map(l=>e.jsx("button",{className:`topic-btn ${o.includes(l.name)?"selected":""}`,onClick:()=>r(l.name),children:l.name},l.id))}),e.jsxs("div",{className:"sentence-input-container",children:[e.jsx("label",{htmlFor:"custom-sentence",className:"sentence-label",children:"Custom Sentence (optional)"}),e.jsx("textarea",{id:"custom-sentence",className:"sentence-input",value:n,onChange:l=>t&&t(l.target.value),placeholder:"Enter a sentence to influence word selection...",rows:"3",maxLength:"200"}),e.jsxs("div",{className:"sentence-info",children:[e.jsxs("span",{className:"char-count",children:[n.length,"/200 characters"]}),n&&e.jsx("button",{type:"button",className:"clear-sentence-btn",onClick:()=>t&&t(""),title:"Clear sentence",children:"Clear"})]})]}),e.jsxs("p",{className:"selected-count",children:[o.length," topic",o.length!==1?"s":""," selected"]})]})},F=({grid:s,clues:c,showSolution:o,onCellChange:n})=>{const[t,r]=m.useState({}),l=(d,a,u)=>{const p=`${d}-${a}`,f={...t,[p]:u.toUpperCase()};r(f),n&&n(d,a,u)},x=(d,a)=>{if(o&&!i(d,a))return s[d][a];const u=`${d}-${a}`;return t[u]||""},i=(d,a)=>s[d][a]===".",h=(d,a)=>{if(!c)return null;const u=c.find(p=>p.position.row===d&&p.position.col===a);return u?u.number:null};if(!s||s.length===0)return e.jsx("div",{className:"puzzle-grid",children:"No puzzle loaded"});const g=s.length,z=s[0]?s[0].length:0;return e.jsx("div",{className:"puzzle-container",children:e.jsx("div",{className:"puzzle-grid",style:{gridTemplateColumns:`repeat(${z}, 35px)`,gridTemplateRows:`repeat(${g}, 35px)`},children:s.map((d,a)=>d.map((u,p)=>{const f=h(a,p);return i(a,p)?e.jsx("div",{className:"grid-cell empty-cell",style:{visibility:"hidden"}},`${a}-${p}`):e.jsxs("div",{className:"grid-cell white-cell",children:[f&&e.jsx("span",{className:"cell-number",children:f}),e.jsx("input",{type:"text",maxLength:"1",value:x(a,p),onChange:y=>l(a,p,y.target.value),className:`cell-input ${o?"solution-text":""}`,disabled:o})]},`${a}-${p}`)}))})})},D=({clues:s=[]})=>{const c=s.filter(t=>t.direction==="across"),o=s.filter(t=>t.direction==="down"),n=({title:t,clueList:r})=>e.jsxs("div",{className:"clue-section",children:[e.jsx("h4",{children:t}),e.jsx("ol",{children:r.map(l=>e.jsxs("li",{className:"clue-item",children:[e.jsx("span",{className:"clue-number",children:l.number}),e.jsx("span",{className:"clue-text",children:l.text})]},`${l.number}-${l.direction}`))})]});return e.jsxs("div",{className:"clue-list",children:[e.jsx(n,{title:"Across",clueList:c}),e.jsx(n,{title:"Down",clueList:o})]})},G=({message:s="Generating puzzle..."})=>e.jsxs("div",{className:"loading-spinner",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{className:"loading-message",children:s})]}),B=()=>{const[s,c]=m.useState(null),[o,n]=m.useState(!1),[t,r]=m.useState(null),[l,x]=m.useState([]),i="",h=m.useCallback(async()=>{try{n(!0);const a=await fetch(`${i}/api/topics`);if(!a.ok)throw new Error("Failed to fetch topics");const u=await a.json();x(u)}catch(a){r(a.message)}finally{n(!1)}},[i]),g=m.useCallback(async(a,u="medium",p=!1,f="")=>{try{n(!0),r(null);const j=await fetch(`${i}/api/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:a,difficulty:u,useAI:p,...f&&{customSentence:f}})});if(!j.ok){const b=await j.json().catch(()=>({}));throw new Error(b.message||"Failed to generate puzzle")}const y=await j.json();return c(y),y}catch(j){return r(j.message),null}finally{n(!1)}},[i]),z=m.useCallback(async a=>{try{const u=await fetch(`${i}/api/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({puzzle:s,answers:a})});if(!u.ok)throw new Error("Failed to validate answers");return await u.json()}catch(u){return r(u.message),null}},[i,s]),d=m.useCallback(()=>{c(null),r(null)},[]);return{puzzle:s,loading:o,error:t,topics:l,fetchTopics:h,generatePuzzle:g,validateAnswers:z,resetPuzzle:d}};function U(){const[s,c]=m.useState([]),[o,n]=m.useState("medium"),[t,r]=m.useState(!1),[l,x]=m.useState(""),{puzzle:i,loading:h,error:g,topics:z,fetchTopics:d,generatePuzzle:a,resetPuzzle:u}=B();m.useEffect(()=>{d()},[d]);const p=async()=>{if(s.length===0){alert("Please select at least one topic");return}await a(s,o,!1,l)},f=v=>{c(v)},j=v=>{x(v)},y=()=>{u(),c([]),r(!1),n("medium"),x("")},b=()=>{r(!0)};return e.jsxs("div",{className:"crossword-app",children:[e.jsxs("header",{className:"app-header",children:[e.jsx("h1",{className:"app-title",children:"Crossword Puzzle Generator"}),e.jsx("p",{children:"Select topics and generate your custom crossword puzzle!"})]}),e.jsx(A,{onTopicsChange:f,availableTopics:z,selectedTopics:s,customSentence:l,onSentenceChange:j}),e.jsxs("div",{className:"puzzle-controls",children:[e.jsxs("select",{value:o,onChange:v=>n(v.target.value),className:"control-btn",children:[e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]}),e.jsx("button",{onClick:p,disabled:h||s.length===0,className:"control-btn generate-btn",children:h?"Generating...":"Generate Puzzle"}),e.jsx("button",{onClick:y,className:"control-btn reset-btn",children:"Reset"}),i&&!t&&e.jsx("button",{onClick:b,className:"control-btn reveal-btn",children:"Reveal Solution"})]}),g&&e.jsxs("div",{className:"error-message",children:["Error: ",g]}),h&&e.jsx(G,{}),i&&!h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"puzzle-info",children:e.jsxs("span",{className:"puzzle-stats",children:[i.metadata.wordCount," words • ",i.metadata.size,"×",i.metadata.size," grid"]})}),e.jsxs("div",{className:"puzzle-layout",children:[e.jsx(F,{grid:i.grid,clues:i.clues,showSolution:t}),e.jsx(D,{clues:i.clues})]})]}),!i&&!h&&!g&&e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"#7f8c8d"},children:'Select topics and click "Generate Puzzle" to start!'})]})}w.createRoot(document.getElementById("root")).render(e.jsx(E.StrictMode,{children:e.jsx(U,{})})); +//# sourceMappingURL=index-7dkEH9uQ.js.map diff --git a/crossword-app/backend-py/public/assets/index-7dkEH9uQ.js.map b/crossword-app/backend-py/public/assets/index-7dkEH9uQ.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b7c87e1edbd4c537155d1ad4eac5b8d39e0c3fb6 --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-7dkEH9uQ.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index-7dkEH9uQ.js","sources":["../../node_modules/react/cjs/react-jsx-runtime.production.min.js","../../node_modules/react/jsx-runtime.js","../../node_modules/react-dom/client.js","../../src/components/TopicSelector.jsx","../../src/components/PuzzleGrid.jsx","../../src/components/ClueList.jsx","../../src/components/LoadingSpinner.jsx","../../src/hooks/useCrossword.js","../../src/App.jsx","../../src/main.jsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","'use strict';\n\nvar m = require('react-dom');\nif (process.env.NODE_ENV === 'production') {\n exports.createRoot = m.createRoot;\n exports.hydrateRoot = m.hydrateRoot;\n} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n","import React from 'react';\n\nconst TopicSelector = ({ \n onTopicsChange, \n availableTopics = [], \n selectedTopics = [],\n customSentence = '',\n onSentenceChange\n}) => {\n const handleTopicToggle = (topic) => {\n const newSelectedTopics = selectedTopics.includes(topic)\n ? selectedTopics.filter(t => t !== topic)\n : [...selectedTopics, topic];\n \n onTopicsChange(newSelectedTopics);\n };\n\n return (\n
\n

Select Topics

\n
\n {availableTopics.map(topic => (\n handleTopicToggle(topic.name)}\n >\n {topic.name}\n \n ))}\n
\n \n
\n \n onSentenceChange && onSentenceChange(e.target.value)}\n placeholder=\"Enter a sentence to influence word selection...\"\n rows=\"3\"\n maxLength=\"200\"\n />\n
\n {customSentence.length}/200 characters\n {customSentence && (\n \n )}\n
\n
\n \n

\n {selectedTopics.length} topic{selectedTopics.length !== 1 ? 's' : ''} selected\n

\n
\n );\n};\n\nexport default TopicSelector;","import React, { useState } from 'react';\n\nconst PuzzleGrid = ({ grid, clues, showSolution, onCellChange }) => {\n const [userAnswers, setUserAnswers] = useState({});\n\n const handleCellInput = (row, col, value) => {\n const key = `${row}-${col}`;\n const newAnswers = { ...userAnswers, [key]: value.toUpperCase() };\n setUserAnswers(newAnswers);\n onCellChange && onCellChange(row, col, value);\n };\n\n const getCellValue = (row, col) => {\n if (showSolution && !isBlackCell(row, col)) {\n return grid[row][col];\n }\n const key = `${row}-${col}`;\n return userAnswers[key] || '';\n };\n\n const isBlackCell = (row, col) => {\n return grid[row][col] === '.';\n };\n\n const getCellNumber = (row, col) => {\n if (!clues) return null;\n const clue = clues.find(c => c.position.row === row && c.position.col === col);\n return clue ? clue.number : null;\n };\n\n if (!grid || grid.length === 0) {\n return
No puzzle loaded
;\n }\n\n const gridRows = grid.length;\n const gridCols = grid[0] ? grid[0].length : 0;\n\n return (\n
\n
\n {grid.map((row, rowIndex) =>\n row.map((cell, colIndex) => {\n const cellNumber = getCellNumber(rowIndex, colIndex);\n const isBlack = isBlackCell(rowIndex, colIndex);\n \n // Only render cells that contain letters (not black/unused cells)\n if (isBlack) {\n return (\n \n
\n );\n }\n \n return (\n \n {cellNumber && {cellNumber}}\n handleCellInput(rowIndex, colIndex, e.target.value)}\n className={`cell-input ${showSolution ? 'solution-text' : ''}`}\n disabled={showSolution}\n />\n
\n );\n })\n )}\n \n \n );\n};\n\nexport default PuzzleGrid;","import React from 'react';\n\nconst ClueList = ({ clues = [] }) => {\n const acrossClues = clues.filter(clue => clue.direction === 'across');\n const downClues = clues.filter(clue => clue.direction === 'down');\n\n const ClueSection = ({ title, clueList }) => (\n
\n

{title}

\n
    \n {clueList.map(clue => (\n
  1. \n {clue.number}\n {clue.text}\n
  2. \n ))}\n
\n
\n );\n\n return (\n
\n \n \n
\n );\n};\n\nexport default ClueList;","import React from 'react';\n\nconst LoadingSpinner = ({ message = \"Generating puzzle...\" }) => {\n return (\n
\n
\n

{message}

\n
\n );\n};\n\nexport default LoadingSpinner;","import { useState, useCallback } from 'react';\n\nconst useCrossword = () => {\n const [puzzle, setPuzzle] = useState(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState(null);\n const [topics, setTopics] = useState([]);\n\n const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || (import.meta.env.PROD ? '' : 'http://localhost:3000');\n\n const fetchTopics = useCallback(async () => {\n try {\n setLoading(true);\n const response = await fetch(`${API_BASE_URL}/api/topics`);\n if (!response.ok) throw new Error('Failed to fetch topics');\n const data = await response.json();\n setTopics(data);\n } catch (err) {\n setError(err.message);\n } finally {\n setLoading(false);\n }\n }, [API_BASE_URL]);\n\n const generatePuzzle = useCallback(async (selectedTopics, difficulty = 'medium', useAI = false, customSentence = '') => {\n try {\n setLoading(true);\n setError(null);\n \n const response = await fetch(`${API_BASE_URL}/api/generate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n topics: selectedTopics,\n difficulty,\n useAI,\n ...(customSentence && { customSentence })\n })\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new Error(errorData.message || 'Failed to generate puzzle');\n }\n \n const puzzleData = await response.json();\n setPuzzle(puzzleData);\n return puzzleData;\n } catch (err) {\n setError(err.message);\n return null;\n } finally {\n setLoading(false);\n }\n }, [API_BASE_URL]);\n\n const validateAnswers = useCallback(async (userAnswers) => {\n try {\n const response = await fetch(`${API_BASE_URL}/api/validate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n puzzle: puzzle,\n answers: userAnswers\n })\n });\n\n if (!response.ok) throw new Error('Failed to validate answers');\n \n return await response.json();\n } catch (err) {\n setError(err.message);\n return null;\n }\n }, [API_BASE_URL, puzzle]);\n\n const resetPuzzle = useCallback(() => {\n setPuzzle(null);\n setError(null);\n }, []);\n\n return {\n puzzle,\n loading,\n error,\n topics,\n fetchTopics,\n generatePuzzle,\n validateAnswers,\n resetPuzzle\n };\n};\n\nexport default useCrossword;","import React, { useState, useEffect } from 'react';\nimport TopicSelector from './components/TopicSelector';\nimport PuzzleGrid from './components/PuzzleGrid';\nimport ClueList from './components/ClueList';\nimport LoadingSpinner from './components/LoadingSpinner';\nimport useCrossword from './hooks/useCrossword';\nimport './styles/puzzle.css';\n\nfunction App() {\n const [selectedTopics, setSelectedTopics] = useState([]);\n const [difficulty, setDifficulty] = useState('medium');\n const [showSolution, setShowSolution] = useState(false);\n const [customSentence, setCustomSentence] = useState('');\n \n const {\n puzzle,\n loading,\n error,\n topics,\n fetchTopics,\n generatePuzzle,\n resetPuzzle\n } = useCrossword();\n\n useEffect(() => {\n fetchTopics();\n }, [fetchTopics]);\n\n const handleGeneratePuzzle = async () => {\n if (selectedTopics.length === 0) {\n alert('Please select at least one topic');\n return;\n }\n \n await generatePuzzle(selectedTopics, difficulty, false, customSentence);\n };\n\n const handleTopicsChange = (topics) => {\n setSelectedTopics(topics);\n };\n\n const handleSentenceChange = (sentence) => {\n setCustomSentence(sentence);\n };\n\n\n const handleReset = () => {\n resetPuzzle();\n setSelectedTopics([]);\n setShowSolution(false);\n setDifficulty('medium');\n setCustomSentence('');\n };\n\n const handleRevealSolution = () => {\n setShowSolution(true);\n };\n\n return (\n
\n
\n

Crossword Puzzle Generator

\n

Select topics and generate your custom crossword puzzle!

\n
\n\n \n\n
\n \n \n \n {loading ? 'Generating...' : 'Generate Puzzle'}\n \n \n \n Reset\n \n \n {puzzle && !showSolution && (\n \n Reveal Solution\n \n )}\n
\n\n {error && (\n
\n Error: {error}\n
\n )}\n\n {loading && }\n\n {puzzle && !loading && (\n <>\n
\n \n {puzzle.metadata.wordCount} words • {puzzle.metadata.size}×{puzzle.metadata.size} grid\n \n
\n
\n \n \n
\n \n )}\n\n {!puzzle && !loading && !error && (\n
\n Select topics and click \"Generate Puzzle\" to start!\n
\n )}\n
\n );\n}\n\nexport default App;","import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport App from './App.jsx'\n\nReactDOM.createRoot(document.getElementById('root')).render(\n \n \n ,\n)"],"names":["f","require$$0","k","l","m","n","p","q","c","a","g","b","d","e","h","reactJsxRuntime_production_min","jsxRuntimeModule","client","TopicSelector","onTopicsChange","availableTopics","selectedTopics","customSentence","onSentenceChange","handleTopicToggle","topic","newSelectedTopics","t","jsxs","jsx","PuzzleGrid","grid","clues","showSolution","onCellChange","userAnswers","setUserAnswers","useState","handleCellInput","row","col","value","key","newAnswers","getCellValue","isBlackCell","getCellNumber","clue","gridRows","gridCols","rowIndex","cell","colIndex","cellNumber","ClueList","acrossClues","downClues","ClueSection","title","clueList","LoadingSpinner","message","useCrossword","puzzle","setPuzzle","loading","setLoading","error","setError","topics","setTopics","API_BASE_URL","fetchTopics","useCallback","response","data","err","generatePuzzle","difficulty","useAI","errorData","puzzleData","validateAnswers","resetPuzzle","App","setSelectedTopics","setDifficulty","setShowSolution","setCustomSentence","useEffect","handleGeneratePuzzle","handleTopicsChange","handleSentenceChange","sentence","handleReset","handleRevealSolution","Fragment","ReactDOM","React"],"mappings":";;;;;;;;GASa,IAAIA,EAAEC,EAAiBC,EAAE,OAAO,IAAI,eAAe,EAAEC,EAAE,OAAO,IAAI,gBAAgB,EAAEC,EAAE,OAAO,UAAU,eAAeC,EAAEL,EAAE,mDAAmD,kBAAkBM,EAAE,CAAC,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,EAAE,EAClP,SAASC,EAAEC,EAAEC,EAAEC,EAAE,CAAC,IAAIC,EAAEC,EAAE,GAAGC,EAAE,KAAKC,EAAE,KAAcJ,IAAT,SAAaG,EAAE,GAAGH,GAAYD,EAAE,MAAX,SAAiBI,EAAE,GAAGJ,EAAE,KAAcA,EAAE,MAAX,SAAiBK,EAAEL,EAAE,KAAK,IAAIE,KAAKF,EAAEL,EAAE,KAAKK,EAAEE,CAAC,GAAG,CAACL,EAAE,eAAeK,CAAC,IAAIC,EAAED,CAAC,EAAEF,EAAEE,CAAC,GAAG,GAAGH,GA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GAAU,CAACE,GACVrC,EAAAA,KAAAoE,EAAAA,SAAA,CACE,SAAA,CAAAnE,EAAAA,IAAC,OAAI,UAAU,cACb,SAAAD,EAAAA,KAAC,OAAA,CAAK,UAAU,eACb,SAAA,CAAAmC,EAAO,SAAS,UAAU,YAAUA,EAAO,SAAS,KAAK,IAAEA,EAAO,SAAS,KAAK,OAAA,CAAA,CACnF,CAAA,CACF,EACAnC,EAAAA,KAAC,MAAA,CAAI,UAAU,gBACb,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACC,KAAMiC,EAAO,KACb,MAAOA,EAAO,MACd,aAAA9B,CAAA,CAAA,EAEFJ,EAAAA,IAACyB,EAAA,CAAS,MAAOS,EAAO,KAAA,CAAO,CAAA,CAAA,CACjC,CAAA,EACF,EAGD,CAACA,GAAU,CAACE,GAAW,CAACE,GACvBtC,EAAAA,IAAC,MAAA,CAAI,MAAO,CAAE,UAAW,SAAU,QAAS,OAAQ,MAAO,SAAA,EAAa,SAAA,qDAAA,CAExE,CAAA,EAEJ,CAEJ,CC1IAoE,EAAS,WAAW,SAAS,eAAe,MAAM,CAAC,EAAE,aAClDC,EAAM,WAAN,CACC,SAAArE,MAACuD,IAAI,CAAA,CACP,CACF","x_google_ignoreList":[0,1,2]} \ No newline at end of file diff --git a/crossword-app/backend-py/public/assets/index-CWqdoNhy.css b/crossword-app/backend-py/public/assets/index-CWqdoNhy.css new file mode 100644 index 0000000000000000000000000000000000000000..e3fb9112289bd0000a0ef1ca3266a61f2a5f49f6 --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-CWqdoNhy.css @@ -0,0 +1 @@ +.crossword-app{max-width:1200px;margin:0 auto;padding:20px;font-family:Segoe UI,Tahoma,Geneva,Verdana,sans-serif}.app-header{text-align:center;margin-bottom:30px}.app-title{color:#2c3e50;font-size:2.5rem;margin-bottom:10px}.topic-selector{background:#f8f9fa;padding:20px;border-radius:8px;margin-bottom:20px}.topic-selector h3{margin-top:0;color:#2c3e50}.topic-buttons{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:15px}.topic-btn{padding:8px 16px;border:2px solid #3498db;background:#fff;color:#3498db;border-radius:20px;cursor:pointer;transition:all .3s ease;font-weight:500}.topic-btn:hover,.topic-btn.selected{background:#3498db;color:#fff}.selected-count{color:#7f8c8d;font-size:.9rem;margin:0}.sentence-input-container{margin-top:20px;margin-bottom:15px}.sentence-label{display:block;margin-bottom:8px;color:#2c3e50;font-weight:500;font-size:.95rem}.sentence-input{width:100%;padding:12px;border:2px solid #e1e8ed;border-radius:8px;font-family:inherit;font-size:.9rem;line-height:1.4;resize:vertical;min-height:80px;background:#fff;transition:border-color .3s ease,box-shadow .3s ease;box-sizing:border-box}.sentence-input:focus{outline:none;border-color:#3498db;box-shadow:0 0 0 3px #3498db1a}.sentence-input::placeholder{color:#95a5a6;font-style:italic}.sentence-info{display:flex;justify-content:space-between;align-items:center;margin-top:6px;font-size:.8rem}.char-count{color:#7f8c8d}.clear-sentence-btn{background:#e74c3c;color:#fff;border:none;padding:4px 8px;border-radius:4px;cursor:pointer;font-size:.75rem;transition:background-color .2s ease}.clear-sentence-btn:hover{background:#c0392b}.clear-sentence-btn:active{background:#a93226}.ai-toggle-container{margin:20px 0;padding:15px;background:#f8f9fa;border-radius:8px;border:2px solid #e9ecef;transition:all .3s ease}.ai-toggle-container:has(.ai-checkbox:checked){background:linear-gradient(135deg,#e3f2fd,#f3e5f5);border-color:#3498db}.ai-toggle{display:flex;align-items:center;cursor:pointer;font-weight:500;margin-bottom:8px}.ai-checkbox{width:20px;height:20px;margin-right:12px;cursor:pointer;accent-color:#3498db}.ai-label{font-size:1rem;color:#2c3e50;-webkit-user-select:none;user-select:none}.ai-status{color:#27ae60;font-weight:600;font-size:.9rem}.ai-description{margin:0;font-size:.85rem;color:#6c757d;line-height:1.4;padding-left:32px}.puzzle-controls{display:flex;gap:15px;margin-bottom:20px;justify-content:center}.control-btn{padding:10px 20px;border:none;border-radius:5px;cursor:pointer;font-weight:600;transition:background-color .3s ease}.control-btn:disabled{background:#bdc3c7!important;color:#7f8c8d!important;cursor:not-allowed;opacity:.7}.generate-btn{background:#27ae60;color:#fff}.generate-btn:hover{background:#229954}.generate-btn:disabled{background:#bdc3c7;cursor:not-allowed}.reset-btn{background:#e74c3c;color:#fff}.reset-btn:hover{background:#c0392b}.reveal-btn{background:#f39c12;color:#fff}.reveal-btn:hover{background:#e67e22}.loading-spinner{display:flex;flex-direction:column;align-items:center;padding:40px}.spinner{width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #3498db;border-radius:50%;animation:spin 1s linear infinite;margin-bottom:15px}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.loading-message{color:#7f8c8d;font-size:1.1rem}.puzzle-info{display:flex;justify-content:space-between;align-items:center;margin:20px 0 10px;padding:10px 15px;background:#f8f9fa;border-radius:6px;border-left:4px solid #3498db}.puzzle-stats{font-size:.9rem;color:#6c757d;font-weight:500}.ai-generated-badge{background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;padding:4px 12px;border-radius:15px;font-size:.8rem;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,.2);box-shadow:0 2px 4px #0000001a}.puzzle-layout{display:grid;grid-template-columns:1fr 300px;gap:30px;margin-top:20px}@media (max-width: 768px){.puzzle-layout{grid-template-columns:1fr;gap:20px}.puzzle-info{flex-direction:column;gap:8px;text-align:center}.ai-toggle-container{padding:12px}.ai-description{padding-left:0;text-align:center}}.puzzle-container{display:flex;justify-content:center}.puzzle-grid{display:grid;gap:0;margin:0 auto;width:fit-content;height:fit-content}.grid-cell{width:35px;height:35px;position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;background:#fff}.grid-cell:before{content:"";position:absolute;top:0;left:0;right:-1px;bottom:-1px;border:1px solid #2c3e50;pointer-events:none;z-index:10}.black-cell{background:#f0f0f0}.black-cell:before{background:#f0f0f0;border:1px solid #2c3e50}.white-cell{background:#fff}.empty-cell{background:transparent;border:none;visibility:hidden}.empty-cell:before{display:none}.cell-input{width:100%;height:100%;border:none!important;text-align:center;font-size:16px;font-weight:700;background:transparent;outline:none;text-transform:uppercase;position:relative;z-index:5}.cell-input:focus{background:#e8f4fd;box-shadow:inset 0 0 0 2px #3498db}.cell-number{position:absolute;top:1px;left:2px;font-size:10px;font-weight:700;color:#2c3e50;line-height:1;z-index:15;pointer-events:none}.solution-text{color:#2c3e50!important;font-weight:700!important;background:#fff!important}.solution-text:disabled{opacity:1!important;cursor:default}.grid-cell .solution-text{border:none!important;background:#fff!important}.clue-list{background:#f8f9fa;padding:20px;border-radius:8px;max-height:600px;overflow-y:auto}.clue-section{margin-bottom:25px}.clue-section h4{color:#2c3e50;margin-bottom:15px;font-size:1.2rem;border-bottom:2px solid #3498db;padding-bottom:5px}.clue-section ol{padding-left:0;list-style:none}.clue-item{display:flex;margin-bottom:8px;padding:8px;border-radius:4px;cursor:pointer;transition:background-color .2s ease}.clue-item:hover{background:#e9ecef}.clue-number{font-weight:700;color:#3498db;margin-right:10px;min-width:25px}.clue-text{flex:1;color:#2c3e50}.error-message{background:#f8d7da;color:#721c24;padding:15px;border-radius:5px;margin:20px 0;border:1px solid #f5c6cb}.success-message{background:#d4edda;color:#155724;padding:15px;border-radius:5px;margin:20px 0;border:1px solid #c3e6cb;text-align:center;font-weight:600} diff --git a/crossword-app/backend-py/public/assets/index-DyT-gQda.css b/crossword-app/backend-py/public/assets/index-DyT-gQda.css new file mode 100644 index 0000000000000000000000000000000000000000..48da3201b65f37f9de4bf698047ced7b1ef5b7ee --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-DyT-gQda.css @@ -0,0 +1 @@ +.crossword-app{max-width:1200px;margin:0 auto;padding:20px;font-family:Segoe UI,Tahoma,Geneva,Verdana,sans-serif}.app-header{text-align:center;margin-bottom:30px}.app-title{color:#2c3e50;font-size:2.5rem;margin-bottom:10px}.topic-selector{background:#f8f9fa;padding:20px;border-radius:8px;margin-bottom:20px}.topic-selector h3{margin-top:0;color:#2c3e50}.topic-buttons{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:15px}.topic-btn{padding:8px 16px;border:2px solid #3498db;background:#fff;color:#3498db;border-radius:20px;cursor:pointer;transition:all .3s ease;font-weight:500}.topic-btn:hover,.topic-btn.selected{background:#3498db;color:#fff}.selected-count{color:#7f8c8d;font-size:.9rem;margin:0}.sentence-input-container{margin-top:20px;margin-bottom:15px}.sentence-label{display:block;margin-bottom:8px;color:#2c3e50;font-weight:500;font-size:.95rem}.sentence-input{width:100%;padding:12px;border:2px solid #e1e8ed;border-radius:8px;font-family:inherit;font-size:.9rem;line-height:1.4;resize:vertical;min-height:80px;background:#fff;transition:border-color .3s ease,box-shadow .3s ease;box-sizing:border-box}.sentence-input:focus{outline:none;border-color:#3498db;box-shadow:0 0 0 3px #3498db1a}.sentence-input::placeholder{color:#95a5a6;font-style:italic}.sentence-info{display:flex;justify-content:space-between;align-items:center;margin-top:6px;font-size:.8rem}.char-count{color:#7f8c8d}.clear-sentence-btn{background:#e74c3c;color:#fff;border:none;padding:4px 8px;border-radius:4px;cursor:pointer;font-size:.75rem;transition:background-color .2s ease}.clear-sentence-btn:hover{background:#c0392b}.clear-sentence-btn:active{background:#a93226}.multi-theme-toggle-container{margin-top:20px;margin-bottom:15px;padding:15px;background:#f0f4f8;border:1px solid #e1e8ed;border-radius:8px}.multi-theme-toggle{display:flex;align-items:center;cursor:pointer;margin-bottom:8px}.multi-theme-checkbox{width:18px;height:18px;margin-right:10px;cursor:pointer;accent-color:#3498db}.multi-theme-label{font-weight:500;color:#2c3e50;font-size:.95rem;-webkit-user-select:none;user-select:none}.multi-theme-description{margin:0;font-size:.85rem;color:#5a6c7d;line-height:1.4;font-style:italic;padding-left:28px}.ai-toggle-container{margin:20px 0;padding:15px;background:#f8f9fa;border-radius:8px;border:2px solid #e9ecef;transition:all .3s ease}.ai-toggle-container:has(.ai-checkbox:checked){background:linear-gradient(135deg,#e3f2fd,#f3e5f5);border-color:#3498db}.ai-toggle{display:flex;align-items:center;cursor:pointer;font-weight:500;margin-bottom:8px}.ai-checkbox{width:20px;height:20px;margin-right:12px;cursor:pointer;accent-color:#3498db}.ai-label{font-size:1rem;color:#2c3e50;-webkit-user-select:none;user-select:none}.ai-status{color:#27ae60;font-weight:600;font-size:.9rem}.ai-description{margin:0;font-size:.85rem;color:#6c757d;line-height:1.4;padding-left:32px}.puzzle-controls{display:flex;gap:15px;margin-bottom:20px;justify-content:center}.control-btn{padding:10px 20px;border:none;border-radius:5px;cursor:pointer;font-weight:600;transition:background-color .3s ease}.control-btn:disabled{background:#bdc3c7!important;color:#7f8c8d!important;cursor:not-allowed;opacity:.7}.generate-btn{background:#27ae60;color:#fff}.generate-btn:hover{background:#229954}.generate-btn:disabled{background:#bdc3c7;cursor:not-allowed}.reset-btn{background:#e74c3c;color:#fff}.reset-btn:hover{background:#c0392b}.reveal-btn{background:#f39c12;color:#fff}.reveal-btn:hover{background:#e67e22}.loading-spinner{display:flex;flex-direction:column;align-items:center;padding:40px}.spinner{width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #3498db;border-radius:50%;animation:spin 1s linear infinite;margin-bottom:15px}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.loading-message{color:#7f8c8d;font-size:1.1rem}.puzzle-info{display:flex;justify-content:space-between;align-items:center;margin:20px 0 10px;padding:10px 15px;background:#f8f9fa;border-radius:6px;border-left:4px solid #3498db}.puzzle-stats{font-size:.9rem;color:#6c757d;font-weight:500}.ai-generated-badge{background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;padding:4px 12px;border-radius:15px;font-size:.8rem;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,.2);box-shadow:0 2px 4px #0000001a}.puzzle-layout{display:grid;grid-template-columns:1fr 300px;gap:30px;margin-top:20px}@media (max-width: 768px){.puzzle-layout{grid-template-columns:1fr;gap:20px}.puzzle-info{flex-direction:column;gap:8px;text-align:center}.ai-toggle-container{padding:12px}.ai-description{padding-left:0;text-align:center}}.puzzle-container{display:flex;justify-content:center}.puzzle-grid{display:grid;gap:0;margin:0 auto;width:fit-content;height:fit-content}.grid-cell{width:35px;height:35px;position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;background:#fff}.grid-cell:before{content:"";position:absolute;top:0;left:0;right:-1px;bottom:-1px;border:1px solid #2c3e50;pointer-events:none;z-index:10}.black-cell{background:#f0f0f0}.black-cell:before{background:#f0f0f0;border:1px solid #2c3e50}.white-cell{background:#fff}.empty-cell{background:transparent;border:none;visibility:hidden}.empty-cell:before{display:none}.cell-input{width:100%;height:100%;border:none!important;text-align:center;font-size:16px;font-weight:700;background:transparent;outline:none;text-transform:uppercase;position:relative;z-index:5}.cell-input:focus{background:#e8f4fd;box-shadow:inset 0 0 0 2px #3498db}.cell-number{position:absolute;top:1px;left:2px;font-size:10px;font-weight:700;color:#2c3e50;line-height:1;z-index:15;pointer-events:none}.solution-text{color:#2c3e50!important;font-weight:700!important;background:#fff!important}.solution-text:disabled{opacity:1!important;cursor:default}.grid-cell .solution-text{border:none!important;background:#fff!important}.clue-list{background:#f8f9fa;padding:20px;border-radius:8px;max-height:600px;overflow-y:auto}.clue-section{margin-bottom:25px}.clue-section h4{color:#2c3e50;margin-bottom:15px;font-size:1.2rem;border-bottom:2px solid #3498db;padding-bottom:5px}.clue-section ol{padding-left:0;list-style:none}.clue-item{display:flex;margin-bottom:8px;padding:8px;border-radius:4px;cursor:pointer;transition:background-color .2s ease}.clue-item:hover{background:#e9ecef}.clue-number{font-weight:700;color:#3498db;margin-right:10px;min-width:25px}.clue-text{flex:1;color:#2c3e50}.error-message{background:#f8d7da;color:#721c24;padding:15px;border-radius:5px;margin:20px 0;border:1px solid #f5c6cb}.success-message{background:#d4edda;color:#155724;padding:15px;border-radius:5px;margin:20px 0;border:1px solid #c3e6cb;text-align:center;font-weight:600} diff --git a/crossword-app/backend-py/public/assets/index-V4v18wFW.css b/crossword-app/backend-py/public/assets/index-V4v18wFW.css new file mode 100644 index 0000000000000000000000000000000000000000..9287030735d543ac0da90bc4511c78f4bbc5f65f --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-V4v18wFW.css @@ -0,0 +1 @@ +.crossword-app{max-width:1200px;margin:0 auto;padding:20px;font-family:Segoe UI,Tahoma,Geneva,Verdana,sans-serif}.app-header{text-align:center;margin-bottom:30px}.app-title{color:#2c3e50;font-size:2.5rem;margin-bottom:10px}.topic-selector{background:#f8f9fa;padding:20px;border-radius:8px;margin-bottom:20px}.topic-selector h3{margin-top:0;color:#2c3e50}.topic-buttons{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:15px}.topic-btn{padding:8px 16px;border:2px solid #3498db;background:#fff;color:#3498db;border-radius:20px;cursor:pointer;transition:all .3s ease;font-weight:500}.topic-btn:hover,.topic-btn.selected{background:#3498db;color:#fff}.selected-count{color:#7f8c8d;font-size:.9rem;margin:0}.ai-toggle-container{margin:20px 0;padding:15px;background:#f8f9fa;border-radius:8px;border:2px solid #e9ecef;transition:all .3s ease}.ai-toggle-container:has(.ai-checkbox:checked){background:linear-gradient(135deg,#e3f2fd,#f3e5f5);border-color:#3498db}.ai-toggle{display:flex;align-items:center;cursor:pointer;font-weight:500;margin-bottom:8px}.ai-checkbox{width:20px;height:20px;margin-right:12px;cursor:pointer;accent-color:#3498db}.ai-label{font-size:1rem;color:#2c3e50;-webkit-user-select:none;user-select:none}.ai-status{color:#27ae60;font-weight:600;font-size:.9rem}.ai-description{margin:0;font-size:.85rem;color:#6c757d;line-height:1.4;padding-left:32px}.puzzle-controls{display:flex;gap:15px;margin-bottom:20px;justify-content:center}.control-btn{padding:10px 20px;border:none;border-radius:5px;cursor:pointer;font-weight:600;transition:background-color .3s ease}.control-btn:disabled{background:#bdc3c7!important;color:#7f8c8d!important;cursor:not-allowed;opacity:.7}.generate-btn{background:#27ae60;color:#fff}.generate-btn:hover{background:#229954}.generate-btn:disabled{background:#bdc3c7;cursor:not-allowed}.reset-btn{background:#e74c3c;color:#fff}.reset-btn:hover{background:#c0392b}.reveal-btn{background:#f39c12;color:#fff}.reveal-btn:hover{background:#e67e22}.loading-spinner{display:flex;flex-direction:column;align-items:center;padding:40px}.spinner{width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #3498db;border-radius:50%;animation:spin 1s linear infinite;margin-bottom:15px}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.loading-message{color:#7f8c8d;font-size:1.1rem}.puzzle-info{display:flex;justify-content:space-between;align-items:center;margin:20px 0 10px;padding:10px 15px;background:#f8f9fa;border-radius:6px;border-left:4px solid #3498db}.puzzle-stats{font-size:.9rem;color:#6c757d;font-weight:500}.ai-generated-badge{background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;padding:4px 12px;border-radius:15px;font-size:.8rem;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,.2);box-shadow:0 2px 4px #0000001a}.puzzle-layout{display:grid;grid-template-columns:1fr 300px;gap:30px;margin-top:20px}@media (max-width: 768px){.puzzle-layout{grid-template-columns:1fr;gap:20px}.puzzle-info{flex-direction:column;gap:8px;text-align:center}.ai-toggle-container{padding:12px}.ai-description{padding-left:0;text-align:center}}.puzzle-container{display:flex;justify-content:center}.puzzle-grid{display:grid;gap:0;margin:0 auto;width:fit-content;height:fit-content}.grid-cell{width:35px;height:35px;position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;background:#fff}.grid-cell:before{content:"";position:absolute;top:0;left:0;right:-1px;bottom:-1px;border:1px solid #2c3e50;pointer-events:none;z-index:10}.black-cell{background:#f0f0f0}.black-cell:before{background:#f0f0f0;border:1px solid #2c3e50}.white-cell{background:#fff}.empty-cell{background:transparent;border:none;visibility:hidden}.empty-cell:before{display:none}.cell-input{width:100%;height:100%;border:none!important;text-align:center;font-size:16px;font-weight:700;background:transparent;outline:none;text-transform:uppercase;position:relative;z-index:5}.cell-input:focus{background:#e8f4fd;box-shadow:inset 0 0 0 2px #3498db}.cell-number{position:absolute;top:1px;left:2px;font-size:10px;font-weight:700;color:#2c3e50;line-height:1;z-index:15;pointer-events:none}.solution-text{color:#2c3e50!important;font-weight:700!important;background:#fff!important}.solution-text:disabled{opacity:1!important;cursor:default}.grid-cell .solution-text{border:none!important;background:#fff!important}.clue-list{background:#f8f9fa;padding:20px;border-radius:8px;max-height:600px;overflow-y:auto}.clue-section{margin-bottom:25px}.clue-section h4{color:#2c3e50;margin-bottom:15px;font-size:1.2rem;border-bottom:2px solid #3498db;padding-bottom:5px}.clue-section ol{padding-left:0;list-style:none}.clue-item{display:flex;margin-bottom:8px;padding:8px;border-radius:4px;cursor:pointer;transition:background-color .2s ease}.clue-item:hover{background:#e9ecef}.clue-number{font-weight:700;color:#3498db;margin-right:10px;min-width:25px}.clue-text{flex:1;color:#2c3e50}.error-message{background:#f8d7da;color:#721c24;padding:15px;border-radius:5px;margin:20px 0;border:1px solid #f5c6cb}.success-message{background:#d4edda;color:#155724;padding:15px;border-radius:5px;margin:20px 0;border:1px solid #c3e6cb;text-align:center;font-weight:600} diff --git a/crossword-app/backend-py/public/assets/index-uK3VdD5a.js b/crossword-app/backend-py/public/assets/index-uK3VdD5a.js new file mode 100644 index 0000000000000000000000000000000000000000..38d4241a8f19e96877b1ef4bf8132e34555f062c --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-uK3VdD5a.js @@ -0,0 +1,10 @@ +import{r as m,a as T,R as _}from"./vendor-nf7bT_Uh.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))l(t);new MutationObserver(t=>{for(const s of t)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&l(i)}).observe(document,{childList:!0,subtree:!0});function o(t){const s={};return t.integrity&&(s.integrity=t.integrity),t.referrerPolicy&&(s.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?s.credentials="include":t.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function l(t){if(t.ep)return;t.ep=!0;const s=o(t);fetch(t.href,s)}})();var P={exports:{}},b={};/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var $=m,O=Symbol.for("react.element"),L=Symbol.for("react.fragment"),A=Object.prototype.hasOwnProperty,F=$.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,D={key:!0,ref:!0,__self:!0,__source:!0};function k(n,a,o){var l,t={},s=null,i=null;o!==void 0&&(s=""+o),a.key!==void 0&&(s=""+a.key),a.ref!==void 0&&(i=a.ref);for(l in a)A.call(a,l)&&!D.hasOwnProperty(l)&&(t[l]=a[l]);if(n&&n.defaultProps)for(l in a=n.defaultProps,a)t[l]===void 0&&(t[l]=a[l]);return{$$typeof:O,type:n,key:s,ref:i,props:t,_owner:F.current}}b.Fragment=L;b.jsx=k;b.jsxs=k;P.exports=b;var e=P.exports,C={},S=T;C.createRoot=S.createRoot,C.hydrateRoot=S.hydrateRoot;const G=({onTopicsChange:n,availableTopics:a=[],selectedTopics:o=[],customSentence:l="",onSentenceChange:t,multiTheme:s=!0,onMultiThemeChange:i})=>{const g=c=>{const y=o.includes(c)?o.filter(p=>p!==c):[...o,c];n(y)};return e.jsxs("div",{className:"topic-selector",children:[e.jsx("h3",{children:"Select Topics"}),e.jsx("div",{className:"topic-buttons",children:a.map(c=>e.jsx("button",{className:`topic-btn ${o.includes(c.name)?"selected":""}`,onClick:()=>g(c.name),children:c.name},c.id))}),e.jsxs("div",{className:"sentence-input-container",children:[e.jsx("label",{htmlFor:"custom-sentence",className:"sentence-label",children:"Custom Sentence (optional)"}),e.jsx("textarea",{id:"custom-sentence",className:"sentence-input",value:l,onChange:c=>t&&t(c.target.value),placeholder:"Enter a sentence to influence word selection...",rows:"3",maxLength:"200"}),e.jsxs("div",{className:"sentence-info",children:[e.jsxs("span",{className:"char-count",children:[l.length,"/200 characters"]}),l&&e.jsx("button",{type:"button",className:"clear-sentence-btn",onClick:()=>t&&t(""),title:"Clear sentence",children:"Clear"})]})]}),e.jsxs("div",{className:"multi-theme-toggle-container",children:[e.jsxs("label",{className:"multi-theme-toggle",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:c=>i&&i(c.target.checked),className:"multi-theme-checkbox"}),e.jsx("span",{className:"multi-theme-label",children:"🎯 Use Multi-Theme Processing"})]}),e.jsx("p",{className:"multi-theme-description",children:s?"AI will process each theme separately and balance results":"AI will blend all themes into a single concept"})]}),e.jsxs("p",{className:"selected-count",children:[o.length," topic",o.length!==1?"s":""," selected"]})]})},B=({grid:n,clues:a,showSolution:o,onCellChange:l})=>{const[t,s]=m.useState({}),i=(d,r,u)=>{const h=`${d}-${r}`,x={...t,[h]:u.toUpperCase()};s(x),l&&l(d,r,u)},g=(d,r)=>{if(o&&!c(d,r))return n[d][r];const u=`${d}-${r}`;return t[u]||""},c=(d,r)=>n[d][r]===".",y=(d,r)=>{if(!a)return null;const u=a.find(h=>h.position.row===d&&h.position.col===r);return u?u.number:null};if(!n||n.length===0)return e.jsx("div",{className:"puzzle-grid",children:"No puzzle loaded"});const p=n.length,f=n[0]?n[0].length:0;return e.jsx("div",{className:"puzzle-container",children:e.jsx("div",{className:"puzzle-grid",style:{gridTemplateColumns:`repeat(${f}, 35px)`,gridTemplateRows:`repeat(${p}, 35px)`},children:n.map((d,r)=>d.map((u,h)=>{const x=y(r,h);return c(r,h)?e.jsx("div",{className:"grid-cell empty-cell",style:{visibility:"hidden"}},`${r}-${h}`):e.jsxs("div",{className:"grid-cell white-cell",children:[x&&e.jsx("span",{className:"cell-number",children:x}),e.jsx("input",{type:"text",maxLength:"1",value:g(r,h),onChange:j=>i(r,h,j.target.value),className:`cell-input ${o?"solution-text":""}`,disabled:o})]},`${r}-${h}`)}))})})},M=({clues:n=[]})=>{const a=n.filter(t=>t.direction==="across"),o=n.filter(t=>t.direction==="down"),l=({title:t,clueList:s})=>e.jsxs("div",{className:"clue-section",children:[e.jsx("h4",{children:t}),e.jsx("ol",{children:s.map(i=>e.jsxs("li",{className:"clue-item",children:[e.jsx("span",{className:"clue-number",children:i.number}),e.jsx("span",{className:"clue-text",children:i.text})]},`${i.number}-${i.direction}`))})]});return e.jsxs("div",{className:"clue-list",children:[e.jsx(l,{title:"Across",clueList:a}),e.jsx(l,{title:"Down",clueList:o})]})},U=({message:n="Generating puzzle..."})=>e.jsxs("div",{className:"loading-spinner",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{className:"loading-message",children:n})]}),J=()=>{const[n,a]=m.useState(null),[o,l]=m.useState(!1),[t,s]=m.useState(null),[i,g]=m.useState([]),c="",y=m.useCallback(async()=>{try{l(!0);const r=await fetch(`${c}/api/topics`);if(!r.ok)throw new Error("Failed to fetch topics");const u=await r.json();g(u)}catch(r){s(r.message)}finally{l(!1)}},[c]),p=m.useCallback(async(r,u="medium",h=!1,x="",z=!0)=>{try{l(!0),s(null);const j=await fetch(`${c}/api/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:r,difficulty:u,useAI:h,...x&&{customSentence:x},multiTheme:z})});if(!j.ok){const w=await j.json().catch(()=>({}));throw new Error(w.message||"Failed to generate puzzle")}const v=await j.json();return a(v),v}catch(j){return s(j.message),null}finally{l(!1)}},[c]),f=m.useCallback(async r=>{try{const u=await fetch(`${c}/api/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({puzzle:n,answers:r})});if(!u.ok)throw new Error("Failed to validate answers");return await u.json()}catch(u){return s(u.message),null}},[c,n]),d=m.useCallback(()=>{a(null),s(null)},[]);return{puzzle:n,loading:o,error:t,topics:i,fetchTopics:y,generatePuzzle:p,validateAnswers:f,resetPuzzle:d}};function q(){const[n,a]=m.useState([]),[o,l]=m.useState("medium"),[t,s]=m.useState(!1),[i,g]=m.useState(""),[c,y]=m.useState(!0),{puzzle:p,loading:f,error:d,topics:r,fetchTopics:u,generatePuzzle:h,resetPuzzle:x}=J();m.useEffect(()=>{u()},[u]);const z=async()=>{if(n.length===0){alert("Please select at least one topic");return}await h(n,o,!1,i,c)},j=N=>{a(N)},v=N=>{g(N)},w=N=>{y(N)},R=()=>{x(),a([]),s(!1),l("medium"),g(""),y(!0)},E=()=>{s(!0)};return e.jsxs("div",{className:"crossword-app",children:[e.jsxs("header",{className:"app-header",children:[e.jsx("h1",{className:"app-title",children:"Crossword Puzzle Generator"}),e.jsx("p",{children:"Select topics and generate your custom crossword puzzle!"})]}),e.jsx(G,{onTopicsChange:j,availableTopics:r,selectedTopics:n,customSentence:i,onSentenceChange:v,multiTheme:c,onMultiThemeChange:w}),e.jsxs("div",{className:"puzzle-controls",children:[e.jsxs("select",{value:o,onChange:N=>l(N.target.value),className:"control-btn",children:[e.jsx("option",{value:"easy",children:"Easy"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"hard",children:"Hard"})]}),e.jsx("button",{onClick:z,disabled:f||n.length===0,className:"control-btn generate-btn",children:f?"Generating...":"Generate Puzzle"}),e.jsx("button",{onClick:R,className:"control-btn reset-btn",children:"Reset"}),p&&!t&&e.jsx("button",{onClick:E,className:"control-btn reveal-btn",children:"Reveal Solution"})]}),d&&e.jsxs("div",{className:"error-message",children:["Error: ",d]}),f&&e.jsx(U,{}),p&&!f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"puzzle-info",children:e.jsxs("span",{className:"puzzle-stats",children:[p.metadata.wordCount," words • ",p.metadata.size,"×",p.metadata.size," grid"]})}),e.jsxs("div",{className:"puzzle-layout",children:[e.jsx(B,{grid:p.grid,clues:p.clues,showSolution:t}),e.jsx(M,{clues:p.clues})]})]}),!p&&!f&&!d&&e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"#7f8c8d"},children:'Select topics and click "Generate Puzzle" to start!'})]})}C.createRoot(document.getElementById("root")).render(e.jsx(_.StrictMode,{children:e.jsx(q,{})})); +//# sourceMappingURL=index-uK3VdD5a.js.map diff --git a/crossword-app/backend-py/public/assets/index-uK3VdD5a.js.map b/crossword-app/backend-py/public/assets/index-uK3VdD5a.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c73e543db035c66863934a95410e163ef9562798 --- /dev/null +++ b/crossword-app/backend-py/public/assets/index-uK3VdD5a.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index-uK3VdD5a.js","sources":["../../node_modules/react/cjs/react-jsx-runtime.production.min.js","../../node_modules/react/jsx-runtime.js","../../node_modules/react-dom/client.js","../../src/components/TopicSelector.jsx","../../src/components/PuzzleGrid.jsx","../../src/components/ClueList.jsx","../../src/components/LoadingSpinner.jsx","../../src/hooks/useCrossword.js","../../src/App.jsx","../../src/main.jsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","'use strict';\n\nvar m = require('react-dom');\nif (process.env.NODE_ENV === 'production') {\n exports.createRoot = m.createRoot;\n exports.hydrateRoot = m.hydrateRoot;\n} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n","import React from 'react';\n\nconst TopicSelector = ({ \n onTopicsChange, \n availableTopics = [], \n selectedTopics = [],\n customSentence = '',\n onSentenceChange,\n multiTheme = true,\n onMultiThemeChange\n}) => {\n const handleTopicToggle = (topic) => {\n const newSelectedTopics = selectedTopics.includes(topic)\n ? selectedTopics.filter(t => t !== topic)\n : [...selectedTopics, topic];\n \n onTopicsChange(newSelectedTopics);\n };\n\n return (\n
\n

Select Topics

\n
\n {availableTopics.map(topic => (\n handleTopicToggle(topic.name)}\n >\n {topic.name}\n \n ))}\n
\n \n
\n \n onSentenceChange && onSentenceChange(e.target.value)}\n placeholder=\"Enter a sentence to influence word selection...\"\n rows=\"3\"\n maxLength=\"200\"\n />\n
\n {customSentence.length}/200 characters\n {customSentence && (\n \n )}\n
\n
\n \n
\n \n

\n {multiTheme \n ? \"AI will process each theme separately and balance results\" \n : \"AI will blend all themes into a single concept\"\n }\n

\n
\n \n

\n {selectedTopics.length} topic{selectedTopics.length !== 1 ? 's' : ''} selected\n

\n
\n );\n};\n\nexport default TopicSelector;","import React, { useState } from 'react';\n\nconst PuzzleGrid = ({ grid, clues, showSolution, onCellChange }) => {\n const [userAnswers, setUserAnswers] = useState({});\n\n const handleCellInput = (row, col, value) => {\n const key = `${row}-${col}`;\n const newAnswers = { ...userAnswers, [key]: value.toUpperCase() };\n setUserAnswers(newAnswers);\n onCellChange && onCellChange(row, col, value);\n };\n\n const getCellValue = (row, col) => {\n if (showSolution && !isBlackCell(row, col)) {\n return grid[row][col];\n }\n const key = `${row}-${col}`;\n return userAnswers[key] || '';\n };\n\n const isBlackCell = (row, col) => {\n return grid[row][col] === '.';\n };\n\n const getCellNumber = (row, col) => {\n if (!clues) return null;\n const clue = clues.find(c => c.position.row === row && c.position.col === col);\n return clue ? clue.number : null;\n };\n\n if (!grid || grid.length === 0) {\n return
No puzzle loaded
;\n }\n\n const gridRows = grid.length;\n const gridCols = grid[0] ? grid[0].length : 0;\n\n return (\n
\n
\n {grid.map((row, rowIndex) =>\n row.map((cell, colIndex) => {\n const cellNumber = getCellNumber(rowIndex, colIndex);\n const isBlack = isBlackCell(rowIndex, colIndex);\n \n // Only render cells that contain letters (not black/unused cells)\n if (isBlack) {\n return (\n \n
\n );\n }\n \n return (\n \n {cellNumber && {cellNumber}}\n handleCellInput(rowIndex, colIndex, e.target.value)}\n className={`cell-input ${showSolution ? 'solution-text' : ''}`}\n disabled={showSolution}\n />\n
\n );\n })\n )}\n \n \n );\n};\n\nexport default PuzzleGrid;","import React from 'react';\n\nconst ClueList = ({ clues = [] }) => {\n const acrossClues = clues.filter(clue => clue.direction === 'across');\n const downClues = clues.filter(clue => clue.direction === 'down');\n\n const ClueSection = ({ title, clueList }) => (\n
\n

{title}

\n
    \n {clueList.map(clue => (\n
  1. \n {clue.number}\n {clue.text}\n
  2. \n ))}\n
\n
\n );\n\n return (\n
\n \n \n
\n );\n};\n\nexport default ClueList;","import React from 'react';\n\nconst LoadingSpinner = ({ message = \"Generating puzzle...\" }) => {\n return (\n
\n
\n

{message}

\n
\n );\n};\n\nexport default LoadingSpinner;","import { useState, useCallback } from 'react';\n\nconst useCrossword = () => {\n const [puzzle, setPuzzle] = useState(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState(null);\n const [topics, setTopics] = useState([]);\n\n const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || (import.meta.env.PROD ? '' : 'http://localhost:3000');\n\n const fetchTopics = useCallback(async () => {\n try {\n setLoading(true);\n const response = await fetch(`${API_BASE_URL}/api/topics`);\n if (!response.ok) throw new Error('Failed to fetch topics');\n const data = await response.json();\n setTopics(data);\n } catch (err) {\n setError(err.message);\n } finally {\n setLoading(false);\n }\n }, [API_BASE_URL]);\n\n const generatePuzzle = useCallback(async (selectedTopics, difficulty = 'medium', useAI = false, customSentence = '', multiTheme = true) => {\n try {\n setLoading(true);\n setError(null);\n \n const response = await fetch(`${API_BASE_URL}/api/generate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n topics: selectedTopics,\n difficulty,\n useAI,\n ...(customSentence && { customSentence }),\n multiTheme\n })\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new Error(errorData.message || 'Failed to generate puzzle');\n }\n \n const puzzleData = await response.json();\n setPuzzle(puzzleData);\n return puzzleData;\n } catch (err) {\n setError(err.message);\n return null;\n } finally {\n setLoading(false);\n }\n }, [API_BASE_URL]);\n\n const validateAnswers = useCallback(async (userAnswers) => {\n try {\n const response = await fetch(`${API_BASE_URL}/api/validate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n puzzle: puzzle,\n answers: userAnswers\n })\n });\n\n if (!response.ok) throw new Error('Failed to validate answers');\n \n return await response.json();\n } catch (err) {\n setError(err.message);\n return null;\n }\n }, [API_BASE_URL, puzzle]);\n\n const resetPuzzle = useCallback(() => {\n setPuzzle(null);\n setError(null);\n }, []);\n\n return {\n puzzle,\n loading,\n error,\n topics,\n fetchTopics,\n generatePuzzle,\n validateAnswers,\n resetPuzzle\n };\n};\n\nexport default useCrossword;","import React, { useState, useEffect } from 'react';\nimport TopicSelector from './components/TopicSelector';\nimport PuzzleGrid from './components/PuzzleGrid';\nimport ClueList from './components/ClueList';\nimport LoadingSpinner from './components/LoadingSpinner';\nimport useCrossword from './hooks/useCrossword';\nimport './styles/puzzle.css';\n\nfunction App() {\n const [selectedTopics, setSelectedTopics] = useState([]);\n const [difficulty, setDifficulty] = useState('medium');\n const [showSolution, setShowSolution] = useState(false);\n const [customSentence, setCustomSentence] = useState('');\n const [multiTheme, setMultiTheme] = useState(true);\n \n const {\n puzzle,\n loading,\n error,\n topics,\n fetchTopics,\n generatePuzzle,\n resetPuzzle\n } = useCrossword();\n\n useEffect(() => {\n fetchTopics();\n }, [fetchTopics]);\n\n const handleGeneratePuzzle = async () => {\n if (selectedTopics.length === 0) {\n alert('Please select at least one topic');\n return;\n }\n \n await generatePuzzle(selectedTopics, difficulty, false, customSentence, multiTheme);\n };\n\n const handleTopicsChange = (topics) => {\n setSelectedTopics(topics);\n };\n\n const handleSentenceChange = (sentence) => {\n setCustomSentence(sentence);\n };\n\n const handleMultiThemeChange = (enabled) => {\n setMultiTheme(enabled);\n };\n\n\n const handleReset = () => {\n resetPuzzle();\n setSelectedTopics([]);\n setShowSolution(false);\n setDifficulty('medium');\n setCustomSentence('');\n setMultiTheme(true);\n };\n\n const handleRevealSolution = () => {\n setShowSolution(true);\n };\n\n return (\n
\n
\n

Crossword Puzzle Generator

\n

Select topics and generate your custom crossword puzzle!

\n
\n\n \n\n
\n \n \n \n {loading ? 'Generating...' : 'Generate Puzzle'}\n \n \n \n Reset\n \n \n {puzzle && !showSolution && (\n \n Reveal Solution\n \n )}\n
\n\n {error && (\n
\n Error: {error}\n
\n )}\n\n {loading && }\n\n {puzzle && !loading && (\n <>\n
\n \n {puzzle.metadata.wordCount} words • {puzzle.metadata.size}×{puzzle.metadata.size} grid\n \n
\n
\n \n \n
\n \n )}\n\n {!puzzle && !loading && !error && (\n
\n Select topics and click \"Generate Puzzle\" to start!\n
\n )}\n
\n );\n}\n\nexport default App;","import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport App from './App.jsx'\n\nReactDOM.createRoot(document.getElementById('root')).render(\n \n \n ,\n)"],"names":["f","require$$0","k","l","m","n","p","q","c","g","b","d","e","h","reactJsxRuntime_production_min","jsxRuntimeModule","client","TopicSelector","onTopicsChange","availableTopics","selectedTopics","customSentence","onSentenceChange","multiTheme","onMultiThemeChange","handleTopicToggle","topic","newSelectedTopics","t","jsxs","jsx","PuzzleGrid","grid","clues","showSolution","onCellChange","userAnswers","setUserAnswers","useState","handleCellInput","row","col","value","key","newAnswers","getCellValue","isBlackCell","getCellNumber","clue","gridRows","gridCols","rowIndex","cell","colIndex","cellNumber","ClueList","acrossClues","downClues","ClueSection","title","clueList","LoadingSpinner","message","useCrossword","puzzle","setPuzzle","loading","setLoading","error","setError","topics","setTopics","API_BASE_URL","fetchTopics","useCallback","response","data","err","generatePuzzle","difficulty","useAI","errorData","puzzleData","validateAnswers","resetPuzzle","App","setSelectedTopics","setDifficulty","setShowSolution","setCustomSentence","setMultiTheme","useEffect","handleGeneratePuzzle","handleTopicsChange","handleSentenceChange","sentence","handleMultiThemeChange","enabled","handleReset","handleRevealSolution","Fragment","ReactDOM","React"],"mappings":";;;;;;;;GASa,IAAIA,EAAEC,EAAiBC,EAAE,OAAO,IAAI,eAAe,EAAEC,EAAE,OAAO,IAAI,gBAAgB,EAAEC,EAAE,OAAO,UAAU,eAAeC,EAAEL,EAAE,mDAAmD,kBAAkBM,EAAE,CAAC,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,EAAE,EAClP,SAASC,EAAEC,EAAE,EAAEC,EAAE,CAAC,IAAIC,EAAEC,EAAE,GAAGC,EAAE,KAAKC,EAAE,KAAcJ,IAAT,SAAaG,EAAE,GAAGH,GAAY,EAAE,MAAX,SAAiBG,EAAE,GAAG,EAAE,KAAc,EAAE,MAAX,SAAiBC,EAAE,EAAE,KAAK,IAAIH,KAAK,EAAEN,EAAE,KAAK,EAAEM,CAAC,GAAG,CAACJ,EAAE,eAAeI,CAAC,IAAIC,EAAED,CAAC,EAAE,EAAEA,CAAC,GAAG,GAAGF,GAAGA,EAAE,aAAa,IAAIE,KAAK,EAAEF,EAAE,aAAa,EAAWG,EAAED,CAAC,aAAIC,EAAED,CAAC,EAAE,EAAEA,CAAC,GAAG,MAAM,CAAC,SAASR,EAAE,KAAKM,EAAE,I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\ No newline at end of file diff --git a/crossword-app/backend-py/public/assets/vendor-nf7bT_Uh.js b/crossword-app/backend-py/public/assets/vendor-nf7bT_Uh.js new file mode 100644 index 0000000000000000000000000000000000000000..8eb492a4e6155df80ea9b8025344a4fce510f1d7 --- /dev/null +++ b/crossword-app/backend-py/public/assets/vendor-nf7bT_Uh.js @@ -0,0 +1,33 @@ +function Za(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ui={exports:{}},T={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Kn=Symbol.for("react.element"),Ja=Symbol.for("react.portal"),qa=Symbol.for("react.fragment"),ba=Symbol.for("react.strict_mode"),ef=Symbol.for("react.profiler"),tf=Symbol.for("react.provider"),nf=Symbol.for("react.context"),rf=Symbol.for("react.forward_ref"),lf=Symbol.for("react.suspense"),uf=Symbol.for("react.memo"),of=Symbol.for("react.lazy"),Lo=Symbol.iterator;function sf(e){return e===null||typeof e!="object"?null:(e=Lo&&e[Lo]||e["@@iterator"],typeof e=="function"?e:null)}var $i={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Vi=Object.assign,Ai={};function nn(e,t,n){this.props=e,this.context=t,this.refs=Ai,this.updater=n||$i}nn.prototype.isReactComponent={};nn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};nn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Bi(){}Bi.prototype=nn.prototype;function Du(e,t,n){this.props=e,this.context=t,this.refs=Ai,this.updater=n||$i}var Iu=Du.prototype=new Bi;Iu.constructor=Du;Vi(Iu,nn.prototype);Iu.isPureReactComponent=!0;var Ro=Array.isArray,Hi=Object.prototype.hasOwnProperty,Fu={current:null},Wi={key:!0,ref:!0,__self:!0,__source:!0};function Qi(e,t,n){var r,l={},u=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(u=""+t.key),t)Hi.call(t,r)&&!Wi.hasOwnProperty(r)&&(l[r]=t[r]);var i=arguments.length-2;if(i===1)l.children=n;else if(1>>1,X=C[H];if(0>>1;Hl(vl,z))vtl(qn,vl)?(C[H]=qn,C[vt]=z,H=vt):(C[H]=vl,C[mt]=z,H=mt);else if(vtl(qn,z))C[H]=qn,C[vt]=z,H=vt;else break e}}return N}function l(C,N){var z=C.sortIndex-N.sortIndex;return z!==0?z:C.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var o=Date,i=o.now();e.unstable_now=function(){return o.now()-i}}var s=[],f=[],v=1,m=null,p=3,g=!1,w=!1,k=!1,F=typeof setTimeout=="function"?setTimeout:null,c=typeof clearTimeout=="function"?clearTimeout:null,a=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(C){for(var N=n(f);N!==null;){if(N.callback===null)r(f);else if(N.startTime<=C)r(f),N.sortIndex=N.expirationTime,t(s,N);else break;N=n(f)}}function h(C){if(k=!1,d(C),!w)if(n(s)!==null)w=!0,pl(E);else{var N=n(f);N!==null&&ml(h,N.startTime-C)}}function E(C,N){w=!1,k&&(k=!1,c(P),P=-1),g=!0;var z=p;try{for(d(N),m=n(s);m!==null&&(!(m.expirationTime>N)||C&&!xe());){var H=m.callback;if(typeof H=="function"){m.callback=null,p=m.priorityLevel;var X=H(m.expirationTime<=N);N=e.unstable_now(),typeof X=="function"?m.callback=X:m===n(s)&&r(s),d(N)}else r(s);m=n(s)}if(m!==null)var Jn=!0;else{var mt=n(f);mt!==null&&ml(h,mt.startTime-N),Jn=!1}return Jn}finally{m=null,p=z,g=!1}}var _=!1,x=null,P=-1,B=5,L=-1;function xe(){return!(e.unstable_now()-LC||125H?(C.sortIndex=z,t(f,C),n(s)===null&&C===n(f)&&(k?(c(P),P=-1):k=!0,ml(h,z-H))):(C.sortIndex=X,t(s,C),w||g||(w=!0,pl(E))),C},e.unstable_shouldYield=xe,e.unstable_wrapCallback=function(C){var N=p;return function(){var z=p;p=N;try{return C.apply(this,arguments)}finally{p=z}}}})(Zi);Gi.exports=Zi;var pf=Gi.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var mf=Yi,he=pf;function y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Bl=Object.prototype.hasOwnProperty,vf=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Oo={},Do={};function hf(e){return Bl.call(Do,e)?!0:Bl.call(Oo,e)?!1:vf.test(e)?Do[e]=!0:(Oo[e]=!0,!1)}function yf(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function gf(e,t,n,r){if(t===null||typeof t>"u"||yf(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ie(e,t,n,r,l,u,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=u,this.removeEmptyString=o}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new ie(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];b[t]=new ie(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new ie(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new ie(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new ie(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){b[e]=new ie(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){b[e]=new ie(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){b[e]=new ie(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){b[e]=new ie(e,5,!1,e.toLowerCase(),null,!1,!1)});var Uu=/[\-:]([a-z])/g;function $u(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Uu,$u);b[t]=new ie(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Uu,$u);b[t]=new ie(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Uu,$u);b[t]=new ie(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){b[e]=new ie(e,1,!1,e.toLowerCase(),null,!1,!1)});b.xlinkHref=new ie("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){b[e]=new ie(e,1,!1,e.toLowerCase(),null,!0,!0)});function Vu(e,t,n,r){var l=b.hasOwnProperty(t)?b[t]:null;(l!==null?l.type!==0:r||!(2i||l[o]!==u[i]){var s=` +`+l[o].replace(" at new "," at ");return e.displayName&&s.includes("")&&(s=s.replace("",e.displayName)),s}while(1<=o&&0<=i);break}}}finally{gl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?hn(e):""}function wf(e){switch(e.tag){case 5:return hn(e.type);case 16:return hn("Lazy");case 13:return hn("Suspense");case 19:return hn("SuspenseList");case 0:case 2:case 15:return e=wl(e.type,!1),e;case 11:return e=wl(e.type.render,!1),e;case 1:return e=wl(e.type,!0),e;default:return""}}function Kl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Mt:return"Fragment";case Rt:return"Portal";case Hl:return"Profiler";case Au:return"StrictMode";case Wl:return"Suspense";case Ql:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case bi:return(e.displayName||"Context")+".Consumer";case qi:return(e._context.displayName||"Context")+".Provider";case Bu:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Hu:return t=e.displayName||null,t!==null?t:Kl(e.type)||"Memo";case Ge:t=e._payload,e=e._init;try{return Kl(e(t))}catch{}}return null}function kf(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Kl(t);case 8:return t===Au?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function at(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ts(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Sf(e){var t=ts(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,u=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,u.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function tr(e){e._valueTracker||(e._valueTracker=Sf(e))}function ns(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ts(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function zr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Yl(e,t){var n=t.checked;return V({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Fo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=at(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function rs(e,t){t=t.checked,t!=null&&Vu(e,"checked",t,!1)}function Xl(e,t){rs(e,t);var n=at(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Gl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Gl(e,t.type,at(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function jo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Gl(e,t,n){(t!=="number"||zr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var yn=Array.isArray;function Ht(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=nr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ln(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var kn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ef=["Webkit","ms","Moz","O"];Object.keys(kn).forEach(function(e){Ef.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),kn[t]=kn[e]})});function is(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||kn.hasOwnProperty(e)&&kn[e]?(""+t).trim():t+"px"}function ss(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=is(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Cf=V({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ql(e,t){if(t){if(Cf[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(y(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(y(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(y(61))}if(t.style!=null&&typeof t.style!="object")throw Error(y(62))}}function bl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var eu=null;function Wu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var tu=null,Wt=null,Qt=null;function Vo(e){if(e=Gn(e)){if(typeof tu!="function")throw Error(y(280));var t=e.stateNode;t&&(t=nl(t),tu(e.stateNode,e.type,t))}}function as(e){Wt?Qt?Qt.push(e):Qt=[e]:Wt=e}function fs(){if(Wt){var e=Wt,t=Qt;if(Qt=Wt=null,Vo(e),t)for(e=0;e>>=0,e===0?32:31-(Df(e)/If|0)|0}var rr=64,lr=4194304;function gn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Mr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,u=e.pingedLanes,o=n&268435455;if(o!==0){var i=o&~l;i!==0?r=gn(i):(u&=o,u!==0&&(r=gn(u)))}else o=n&~l,o!==0?r=gn(o):u!==0&&(r=gn(u));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,u=t&-t,l>=u||l===16&&(u&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Yn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Le(t),e[t]=n}function $f(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=En),Go=" ",Zo=!1;function Ls(e,t){switch(e){case"keyup":return pc.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Rs(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ot=!1;function vc(e,t){switch(e){case"compositionend":return Rs(t);case"keypress":return t.which!==32?null:(Zo=!0,Go);case"textInput":return e=t.data,e===Go&&Zo?null:e;default:return null}}function hc(e,t){if(Ot)return e==="compositionend"||!qu&&Ls(e,t)?(e=zs(),wr=Gu=be=null,Ot=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ei(n)}}function Is(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Is(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Fs(){for(var e=window,t=zr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=zr(e.document)}return t}function bu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function xc(e){var t=Fs(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Is(n.ownerDocument.documentElement,n)){if(r!==null&&bu(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,u=Math.min(r.start,l);r=r.end===void 0?u:Math.min(r.end,l),!e.extend&&u>r&&(l=r,r=u,u=l),l=ti(n,u);var o=ti(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),u>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Dt=null,iu=null,_n=null,su=!1;function ni(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;su||Dt==null||Dt!==zr(r)||(r=Dt,"selectionStart"in r&&bu(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_n&&Fn(_n,r)||(_n=r,r=Ir(iu,"onSelect"),0jt||(e.current=mu[jt],mu[jt]=null,jt--)}function O(e,t){jt++,mu[jt]=e.current,e.current=t}var ft={},re=dt(ft),fe=dt(!1),Ct=ft;function Zt(e,t){var n=e.type.contextTypes;if(!n)return ft;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},u;for(u in n)l[u]=t[u];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function ce(e){return e=e.childContextTypes,e!=null}function jr(){I(fe),I(re)}function ai(e,t,n){if(re.current!==ft)throw Error(y(168));O(re,t),O(fe,n)}function Qs(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(y(108,kf(e)||"Unknown",l));return V({},n,r)}function Ur(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ft,Ct=re.current,O(re,e),O(fe,fe.current),!0}function fi(e,t,n){var r=e.stateNode;if(!r)throw Error(y(169));n?(e=Qs(e,t,Ct),r.__reactInternalMemoizedMergedChildContext=e,I(fe),I(re),O(re,e)):I(fe),O(fe,n)}var $e=null,rl=!1,Ol=!1;function Ks(e){$e===null?$e=[e]:$e.push(e)}function jc(e){rl=!0,Ks(e)}function pt(){if(!Ol&&$e!==null){Ol=!0;var e=0,t=M;try{var n=$e;for(M=1;e>=o,l-=o,Ve=1<<32-Le(t)+l|n<P?(B=x,x=null):B=x.sibling;var L=p(c,x,d[P],h);if(L===null){x===null&&(x=B);break}e&&x&&L.alternate===null&&t(c,x),a=u(L,a,P),_===null?E=L:_.sibling=L,_=L,x=B}if(P===d.length)return n(c,x),j&&ht(c,P),E;if(x===null){for(;PP?(B=x,x=null):B=x.sibling;var xe=p(c,x,L.value,h);if(xe===null){x===null&&(x=B);break}e&&x&&xe.alternate===null&&t(c,x),a=u(xe,a,P),_===null?E=xe:_.sibling=xe,_=xe,x=B}if(L.done)return n(c,x),j&&ht(c,P),E;if(x===null){for(;!L.done;P++,L=d.next())L=m(c,L.value,h),L!==null&&(a=u(L,a,P),_===null?E=L:_.sibling=L,_=L);return j&&ht(c,P),E}for(x=r(c,x);!L.done;P++,L=d.next())L=g(x,c,P,L.value,h),L!==null&&(e&&L.alternate!==null&&x.delete(L.key===null?P:L.key),a=u(L,a,P),_===null?E=L:_.sibling=L,_=L);return e&&x.forEach(function(un){return t(c,un)}),j&&ht(c,P),E}function F(c,a,d,h){if(typeof d=="object"&&d!==null&&d.type===Mt&&d.key===null&&(d=d.props.children),typeof d=="object"&&d!==null){switch(d.$$typeof){case er:e:{for(var E=d.key,_=a;_!==null;){if(_.key===E){if(E=d.type,E===Mt){if(_.tag===7){n(c,_.sibling),a=l(_,d.props.children),a.return=c,c=a;break e}}else if(_.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Ge&&pi(E)===_.type){n(c,_.sibling),a=l(_,d.props),a.ref=pn(c,_,d),a.return=c,c=a;break e}n(c,_);break}else t(c,_);_=_.sibling}d.type===Mt?(a=Et(d.props.children,c.mode,h,d.key),a.return=c,c=a):(h=Nr(d.type,d.key,d.props,null,c.mode,h),h.ref=pn(c,a,d),h.return=c,c=h)}return o(c);case Rt:e:{for(_=d.key;a!==null;){if(a.key===_)if(a.tag===4&&a.stateNode.containerInfo===d.containerInfo&&a.stateNode.implementation===d.implementation){n(c,a.sibling),a=l(a,d.children||[]),a.return=c,c=a;break e}else{n(c,a);break}else t(c,a);a=a.sibling}a=Al(d,c.mode,h),a.return=c,c=a}return o(c);case Ge:return _=d._init,F(c,a,_(d._payload),h)}if(yn(d))return w(c,a,d,h);if(sn(d))return k(c,a,d,h);cr(c,d)}return typeof d=="string"&&d!==""||typeof d=="number"?(d=""+d,a!==null&&a.tag===6?(n(c,a.sibling),a=l(a,d),a.return=c,c=a):(n(c,a),a=Vl(d,c.mode,h),a.return=c,c=a),o(c)):n(c,a)}return F}var qt=Zs(!0),Js=Zs(!1),Ar=dt(null),Br=null,Vt=null,ro=null;function lo(){ro=Vt=Br=null}function uo(e){var t=Ar.current;I(Ar),e._currentValue=t}function yu(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Yt(e,t){Br=e,ro=Vt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ae=!0),e.firstContext=null)}function Ce(e){var t=e._currentValue;if(ro!==e)if(e={context:e,memoizedValue:t,next:null},Vt===null){if(Br===null)throw Error(y(308));Vt=e,Br.dependencies={lanes:0,firstContext:e}}else Vt=Vt.next=e;return t}var wt=null;function oo(e){wt===null?wt=[e]:wt.push(e)}function qs(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,oo(t)):(n.next=l.next,l.next=n),t.interleaved=n,Qe(e,r)}function Qe(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ze=!1;function io(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function bs(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Be(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ut(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,R&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Qe(e,n)}return l=r.interleaved,l===null?(t.next=t,oo(r)):(t.next=l.next,l.next=t),r.interleaved=t,Qe(e,n)}function Sr(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ku(e,n)}}function mi(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,u=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};u===null?l=u=o:u=u.next=o,n=n.next}while(n!==null);u===null?l=u=t:u=u.next=t}else l=u=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:u,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Hr(e,t,n,r){var l=e.updateQueue;Ze=!1;var u=l.firstBaseUpdate,o=l.lastBaseUpdate,i=l.shared.pending;if(i!==null){l.shared.pending=null;var s=i,f=s.next;s.next=null,o===null?u=f:o.next=f,o=s;var v=e.alternate;v!==null&&(v=v.updateQueue,i=v.lastBaseUpdate,i!==o&&(i===null?v.firstBaseUpdate=f:i.next=f,v.lastBaseUpdate=s))}if(u!==null){var m=l.baseState;o=0,v=f=s=null,i=u;do{var p=i.lane,g=i.eventTime;if((r&p)===p){v!==null&&(v=v.next={eventTime:g,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var w=e,k=i;switch(p=t,g=n,k.tag){case 1:if(w=k.payload,typeof w=="function"){m=w.call(g,m,p);break e}m=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=k.payload,p=typeof w=="function"?w.call(g,m,p):w,p==null)break e;m=V({},m,p);break e;case 2:Ze=!0}}i.callback!==null&&i.lane!==0&&(e.flags|=64,p=l.effects,p===null?l.effects=[i]:p.push(i))}else g={eventTime:g,lane:p,tag:i.tag,payload:i.payload,callback:i.callback,next:null},v===null?(f=v=g,s=m):v=v.next=g,o|=p;if(i=i.next,i===null){if(i=l.shared.pending,i===null)break;p=i,i=p.next,p.next=null,l.lastBaseUpdate=p,l.shared.pending=null}}while(!0);if(v===null&&(s=m),l.baseState=s,l.firstBaseUpdate=f,l.lastBaseUpdate=v,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else u===null&&(l.shared.lanes=0);Pt|=o,e.lanes=o,e.memoizedState=m}}function vi(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Il.transition;Il.transition={};try{e(!1),t()}finally{M=n,Il.transition=r}}function ha(){return _e().memoizedState}function Ac(e,t,n){var r=it(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ya(e))ga(t,n);else if(n=qs(e,t,n,r),n!==null){var l=ue();Re(n,e,r,l),wa(n,t,r)}}function Bc(e,t,n){var r=it(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ya(e))ga(t,l);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var o=t.lastRenderedState,i=u(o,n);if(l.hasEagerState=!0,l.eagerState=i,Me(i,o)){var s=t.interleaved;s===null?(l.next=l,oo(t)):(l.next=s.next,s.next=l),t.interleaved=l;return}}catch{}finally{}n=qs(e,t,l,r),n!==null&&(l=ue(),Re(n,e,r,l),wa(n,t,r))}}function ya(e){var t=e.alternate;return e===$||t!==null&&t===$}function ga(e,t){xn=Qr=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function wa(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ku(e,n)}}var Kr={readContext:Ce,useCallback:ee,useContext:ee,useEffect:ee,useImperativeHandle:ee,useInsertionEffect:ee,useLayoutEffect:ee,useMemo:ee,useReducer:ee,useRef:ee,useState:ee,useDebugValue:ee,useDeferredValue:ee,useTransition:ee,useMutableSource:ee,useSyncExternalStore:ee,useId:ee,unstable_isNewReconciler:!1},Hc={readContext:Ce,useCallback:function(e,t){return De().memoizedState=[e,t===void 0?null:t],e},useContext:Ce,useEffect:yi,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Cr(4194308,4,ca.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Cr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Cr(4,2,e,t)},useMemo:function(e,t){var n=De();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=De();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ac.bind(null,$,e),[r.memoizedState,e]},useRef:function(e){var t=De();return e={current:e},t.memoizedState=e},useState:hi,useDebugValue:ho,useDeferredValue:function(e){return De().memoizedState=e},useTransition:function(){var e=hi(!1),t=e[0];return e=Vc.bind(null,e[1]),De().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=$,l=De();if(j){if(n===void 0)throw Error(y(407));n=n()}else{if(n=t(),Z===null)throw Error(y(349));xt&30||ra(r,t,n)}l.memoizedState=n;var u={value:n,getSnapshot:t};return l.queue=u,yi(ua.bind(null,r,u,e),[e]),r.flags|=2048,Wn(9,la.bind(null,r,u,n,t),void 0,null),n},useId:function(){var e=De(),t=Z.identifierPrefix;if(j){var n=Ae,r=Ve;n=(r&~(1<<32-Le(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Bn++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Ie]=t,e[$n]=r,Ta(e,t,!1,!1),t.stateNode=e;e:{switch(o=bl(n,r),n){case"dialog":D("cancel",e),D("close",e),l=r;break;case"iframe":case"object":case"embed":D("load",e),l=r;break;case"video":case"audio":for(l=0;ltn&&(t.flags|=128,r=!0,mn(u,!1),t.lanes=4194304)}else{if(!r)if(e=Wr(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),mn(u,!0),u.tail===null&&u.tailMode==="hidden"&&!o.alternate&&!j)return te(t),null}else 2*W()-u.renderingStartTime>tn&&n!==1073741824&&(t.flags|=128,r=!0,mn(u,!1),t.lanes=4194304);u.isBackwards?(o.sibling=t.child,t.child=o):(n=u.last,n!==null?n.sibling=o:t.child=o,u.last=o)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=W(),t.sibling=null,n=U.current,O(U,r?n&1|2:n&1),t):(te(t),null);case 22:case 23:return Eo(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?pe&1073741824&&(te(t),t.subtreeFlags&6&&(t.flags|=8192)):te(t),null;case 24:return null;case 25:return null}throw Error(y(156,t.tag))}function Jc(e,t){switch(to(t),t.tag){case 1:return ce(t.type)&&jr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return bt(),I(fe),I(re),fo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return ao(t),null;case 13:if(I(U),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(y(340));Jt()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return I(U),null;case 4:return bt(),null;case 10:return uo(t.type._context),null;case 22:case 23:return Eo(),null;case 24:return null;default:return null}}var pr=!1,ne=!1,qc=typeof WeakSet=="function"?WeakSet:Set,S=null;function At(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){A(e,t,r)}else n.current=null}function Pu(e,t,n){try{n()}catch(r){A(e,t,r)}}var zi=!1;function bc(e,t){if(au=Or,e=Fs(),bu(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,u=r.focusNode;r=r.focusOffset;try{n.nodeType,u.nodeType}catch{n=null;break e}var o=0,i=-1,s=-1,f=0,v=0,m=e,p=null;t:for(;;){for(var g;m!==n||l!==0&&m.nodeType!==3||(i=o+l),m!==u||r!==0&&m.nodeType!==3||(s=o+r),m.nodeType===3&&(o+=m.nodeValue.length),(g=m.firstChild)!==null;)p=m,m=g;for(;;){if(m===e)break t;if(p===n&&++f===l&&(i=o),p===u&&++v===r&&(s=o),(g=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=g}n=i===-1||s===-1?null:{start:i,end:s}}else n=null}n=n||{start:0,end:0}}else n=null;for(fu={focusedElem:e,selectionRange:n},Or=!1,S=t;S!==null;)if(t=S,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,S=e;else for(;S!==null;){t=S;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var k=w.memoizedProps,F=w.memoizedState,c=t.stateNode,a=c.getSnapshotBeforeUpdate(t.elementType===t.type?k:Ne(t.type,k),F);c.__reactInternalSnapshotBeforeUpdate=a}break;case 3:var d=t.stateNode.containerInfo;d.nodeType===1?d.textContent="":d.nodeType===9&&d.documentElement&&d.removeChild(d.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(y(163))}}catch(h){A(t,t.return,h)}if(e=t.sibling,e!==null){e.return=t.return,S=e;break}S=t.return}return w=zi,zi=!1,w}function Pn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var u=l.destroy;l.destroy=void 0,u!==void 0&&Pu(t,n,u)}l=l.next}while(l!==r)}}function ol(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Nu(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Ma(e){var t=e.alternate;t!==null&&(e.alternate=null,Ma(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ie],delete t[$n],delete t[pu],delete t[Ic],delete t[Fc])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Oa(e){return e.tag===5||e.tag===3||e.tag===4}function Ti(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Oa(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function zu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Fr));else if(r!==4&&(e=e.child,e!==null))for(zu(e,t,n),e=e.sibling;e!==null;)zu(e,t,n),e=e.sibling}function Tu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Tu(e,t,n),e=e.sibling;e!==null;)Tu(e,t,n),e=e.sibling}var J=null,ze=!1;function Xe(e,t,n){for(n=n.child;n!==null;)Da(e,t,n),n=n.sibling}function Da(e,t,n){if(Fe&&typeof Fe.onCommitFiberUnmount=="function")try{Fe.onCommitFiberUnmount(qr,n)}catch{}switch(n.tag){case 5:ne||At(n,t);case 6:var r=J,l=ze;J=null,Xe(e,t,n),J=r,ze=l,J!==null&&(ze?(e=J,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):J.removeChild(n.stateNode));break;case 18:J!==null&&(ze?(e=J,n=n.stateNode,e.nodeType===8?Ml(e.parentNode,n):e.nodeType===1&&Ml(e,n),Dn(e)):Ml(J,n.stateNode));break;case 4:r=J,l=ze,J=n.stateNode.containerInfo,ze=!0,Xe(e,t,n),J=r,ze=l;break;case 0:case 11:case 14:case 15:if(!ne&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var u=l,o=u.destroy;u=u.tag,o!==void 0&&(u&2||u&4)&&Pu(n,t,o),l=l.next}while(l!==r)}Xe(e,t,n);break;case 1:if(!ne&&(At(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(i){A(n,t,i)}Xe(e,t,n);break;case 21:Xe(e,t,n);break;case 22:n.mode&1?(ne=(r=ne)||n.memoizedState!==null,Xe(e,t,n),ne=r):Xe(e,t,n);break;default:Xe(e,t,n)}}function Li(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new qc),t.forEach(function(r){var l=sd.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Pe(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~u}if(r=l,r=W()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*td(r/1960))-r,10e?16:e,et===null)var r=!1;else{if(e=et,et=null,Gr=0,R&6)throw Error(y(331));var l=R;for(R|=4,S=e.current;S!==null;){var u=S,o=u.child;if(S.flags&16){var i=u.deletions;if(i!==null){for(var s=0;sW()-ko?St(e,0):wo|=n),de(e,t)}function Ba(e,t){t===0&&(e.mode&1?(t=lr,lr<<=1,!(lr&130023424)&&(lr=4194304)):t=1);var n=ue();e=Qe(e,t),e!==null&&(Yn(e,t,n),de(e,n))}function id(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ba(e,n)}function sd(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(y(314))}r!==null&&r.delete(t),Ba(e,n)}var Ha;Ha=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||fe.current)ae=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ae=!1,Gc(e,t,n);ae=!!(e.flags&131072)}else ae=!1,j&&t.flags&1048576&&Ys(t,Vr,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;_r(e,t),e=t.pendingProps;var l=Zt(t,re.current);Yt(t,n),l=po(null,t,r,e,l,n);var u=mo();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ce(r)?(u=!0,Ur(t)):u=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,io(t),l.updater=ul,t.stateNode=l,l._reactInternals=t,wu(t,r,e,n),t=Eu(null,t,r,!0,u,n)):(t.tag=0,j&&u&&eo(t),le(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(_r(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=fd(r),e=Ne(r,e),l){case 0:t=Su(null,t,r,e,n);break e;case 1:t=xi(null,t,r,e,n);break e;case 11:t=Ci(null,t,r,e,n);break e;case 14:t=_i(null,t,r,Ne(r.type,e),n);break e}throw Error(y(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ne(r,l),Su(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ne(r,l),xi(e,t,r,l,n);case 3:e:{if(Pa(t),e===null)throw Error(y(387));r=t.pendingProps,u=t.memoizedState,l=u.element,bs(e,t),Hr(t,r,null,n);var o=t.memoizedState;if(r=o.element,u.isDehydrated)if(u={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){l=en(Error(y(423)),t),t=Pi(e,t,r,n,l);break e}else if(r!==l){l=en(Error(y(424)),t),t=Pi(e,t,r,n,l);break e}else for(me=lt(t.stateNode.containerInfo.firstChild),ve=t,j=!0,Te=null,n=Js(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Jt(),r===l){t=Ke(e,t,n);break e}le(e,t,r,n)}t=t.child}return t;case 5:return ea(t),e===null&&hu(t),r=t.type,l=t.pendingProps,u=e!==null?e.memoizedProps:null,o=l.children,cu(r,l)?o=null:u!==null&&cu(r,u)&&(t.flags|=32),xa(e,t),le(e,t,o,n),t.child;case 6:return e===null&&hu(t),null;case 13:return Na(e,t,n);case 4:return so(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=qt(t,null,r,n):le(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ne(r,l),Ci(e,t,r,l,n);case 7:return le(e,t,t.pendingProps,n),t.child;case 8:return le(e,t,t.pendingProps.children,n),t.child;case 12:return le(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,u=t.memoizedProps,o=l.value,O(Ar,r._currentValue),r._currentValue=o,u!==null)if(Me(u.value,o)){if(u.children===l.children&&!fe.current){t=Ke(e,t,n);break e}}else for(u=t.child,u!==null&&(u.return=t);u!==null;){var i=u.dependencies;if(i!==null){o=u.child;for(var s=i.firstContext;s!==null;){if(s.context===r){if(u.tag===1){s=Be(-1,n&-n),s.tag=2;var f=u.updateQueue;if(f!==null){f=f.shared;var v=f.pending;v===null?s.next=s:(s.next=v.next,v.next=s),f.pending=s}}u.lanes|=n,s=u.alternate,s!==null&&(s.lanes|=n),yu(u.return,n,t),i.lanes|=n;break}s=s.next}}else if(u.tag===10)o=u.type===t.type?null:u.child;else if(u.tag===18){if(o=u.return,o===null)throw Error(y(341));o.lanes|=n,i=o.alternate,i!==null&&(i.lanes|=n),yu(o,n,t),o=u.sibling}else o=u.child;if(o!==null)o.return=u;else for(o=u;o!==null;){if(o===t){o=null;break}if(u=o.sibling,u!==null){u.return=o.return,o=u;break}o=o.return}u=o}le(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,Yt(t,n),l=Ce(l),r=r(l),t.flags|=1,le(e,t,r,n),t.child;case 14:return r=t.type,l=Ne(r,t.pendingProps),l=Ne(r.type,l),_i(e,t,r,l,n);case 15:return Ca(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ne(r,l),_r(e,t),t.tag=1,ce(r)?(e=!0,Ur(t)):e=!1,Yt(t,n),ka(t,r,l),wu(t,r,l,n),Eu(null,t,r,!0,e,n);case 19:return za(e,t,n);case 22:return _a(e,t,n)}throw Error(y(156,t.tag))};function Wa(e,t){return ys(e,t)}function ad(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Se(e,t,n,r){return new ad(e,t,n,r)}function _o(e){return e=e.prototype,!(!e||!e.isReactComponent)}function fd(e){if(typeof e=="function")return _o(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Bu)return 11;if(e===Hu)return 14}return 2}function st(e,t){var n=e.alternate;return n===null?(n=Se(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Nr(e,t,n,r,l,u){var o=2;if(r=e,typeof e=="function")_o(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Mt:return Et(n.children,l,u,t);case Au:o=8,l|=8;break;case Hl:return e=Se(12,n,t,l|2),e.elementType=Hl,e.lanes=u,e;case Wl:return e=Se(13,n,t,l),e.elementType=Wl,e.lanes=u,e;case Ql:return e=Se(19,n,t,l),e.elementType=Ql,e.lanes=u,e;case es:return sl(n,l,u,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qi:o=10;break e;case bi:o=9;break e;case Bu:o=11;break e;case Hu:o=14;break e;case Ge:o=16,r=null;break e}throw Error(y(130,e==null?e:typeof e,""))}return t=Se(o,n,t,l),t.elementType=e,t.type=r,t.lanes=u,t}function Et(e,t,n,r){return e=Se(7,e,r,t),e.lanes=n,e}function sl(e,t,n,r){return e=Se(22,e,r,t),e.elementType=es,e.lanes=n,e.stateNode={isHidden:!1},e}function Vl(e,t,n){return e=Se(6,e,null,t),e.lanes=n,e}function Al(e,t,n){return t=Se(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function cd(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Sl(0),this.expirationTimes=Sl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Sl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function xo(e,t,n,r,l,u,o,i,s){return e=new cd(e,t,n,i,s),t===1?(t=1,u===!0&&(t|=8)):t=0,u=Se(3,null,null,t),e.current=u,u.stateNode=e,u.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},io(u),e}function dd(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Xa)}catch(e){console.error(e)}}Xa(),Xi.exports=ye;var gd=Xi.exports;export{yd as R,gd as a,Yi as r}; +//# sourceMappingURL=vendor-nf7bT_Uh.js.map diff --git a/crossword-app/backend-py/public/assets/vendor-nf7bT_Uh.js.map b/crossword-app/backend-py/public/assets/vendor-nf7bT_Uh.js.map new file mode 100644 index 0000000000000000000000000000000000000000..213b87a35046dd047636a3962b8066921cf629c8 --- /dev/null +++ b/crossword-app/backend-py/public/assets/vendor-nf7bT_Uh.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vendor-nf7bT_Uh.js","sources":["../../node_modules/react/cjs/react.production.min.js","../../node_modules/react/index.js","../../node_modules/scheduler/cjs/scheduler.production.min.js","../../node_modules/scheduler/index.js","../../node_modules/react-dom/cjs/react-dom.production.min.js","../../node_modules/react-dom/index.js"],"sourcesContent":["/**\n * @license React\n * react.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var l=Symbol.for(\"react.element\"),n=Symbol.for(\"react.portal\"),p=Symbol.for(\"react.fragment\"),q=Symbol.for(\"react.strict_mode\"),r=Symbol.for(\"react.profiler\"),t=Symbol.for(\"react.provider\"),u=Symbol.for(\"react.context\"),v=Symbol.for(\"react.forward_ref\"),w=Symbol.for(\"react.suspense\"),x=Symbol.for(\"react.memo\"),y=Symbol.for(\"react.lazy\"),z=Symbol.iterator;function A(a){if(null===a||\"object\"!==typeof a)return null;a=z&&a[z]||a[\"@@iterator\"];return\"function\"===typeof a?a:null}\nvar B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B}E.prototype.isReactComponent={};\nE.prototype.setState=function(a,b){if(\"object\"!==typeof a&&\"function\"!==typeof a&&null!=a)throw Error(\"setState(...): takes an object of state variables to update or a function which returns an object of state variables.\");this.updater.enqueueSetState(this,a,b,\"setState\")};E.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,\"forceUpdate\")};function F(){}F.prototype=E.prototype;function G(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B}var H=G.prototype=new F;\nH.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;var I=Array.isArray,J=Object.prototype.hasOwnProperty,K={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};\nfunction M(a,b,e){var d,c={},k=null,h=null;if(null!=b)for(d in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=\"\"+b.key),b)J.call(b,d)&&!L.hasOwnProperty(d)&&(c[d]=b[d]);var g=arguments.length-2;if(1===g)c.children=e;else if(1>>1,e=a[d];if(0>>1;dg(C,c))ng(x,C)?(a[d]=x,a[n]=c,d=n):(a[d]=C,a[m]=c,d=m);else if(ng(x,c))a[d]=x,a[n]=c,d=n;else break a}}return b}\nfunction g(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}if(\"object\"===typeof performance&&\"function\"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()}}else{var p=Date,q=p.now();exports.unstable_now=function(){return p.now()-q}}var r=[],t=[],u=1,v=null,y=3,z=!1,A=!1,B=!1,D=\"function\"===typeof setTimeout?setTimeout:null,E=\"function\"===typeof clearTimeout?clearTimeout:null,F=\"undefined\"!==typeof setImmediate?setImmediate:null;\n\"undefined\"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(a){for(var b=h(t);null!==b;){if(null===b.callback)k(t);else if(b.startTime<=a)k(t),b.sortIndex=b.expirationTime,f(r,b);else break;b=h(t)}}function H(a){B=!1;G(a);if(!A)if(null!==h(r))A=!0,I(J);else{var b=h(t);null!==b&&K(H,b.startTime-a)}}\nfunction J(a,b){A=!1;B&&(B=!1,E(L),L=-1);z=!0;var c=y;try{G(b);for(v=h(r);null!==v&&(!(v.expirationTime>b)||a&&!M());){var d=v.callback;if(\"function\"===typeof d){v.callback=null;y=v.priorityLevel;var e=d(v.expirationTime<=b);b=exports.unstable_now();\"function\"===typeof e?v.callback=e:v===h(r)&&k(r);G(b)}else k(r);v=h(r)}if(null!==v)var w=!0;else{var m=h(t);null!==m&&K(H,m.startTime-b);w=!1}return w}finally{v=null,y=c,z=!1}}var N=!1,O=null,L=-1,P=5,Q=-1;\nfunction M(){return exports.unstable_now()-Qa||125d?(a.sortIndex=c,f(t,a),null===h(r)&&a===h(t)&&(B?(E(L),L=-1):B=!0,K(H,c-d))):(a.sortIndex=e,f(r,a),A||z||(A=!0,I(J)));return a};\nexports.unstable_shouldYield=M;exports.unstable_wrapCallback=function(a){var b=y;return function(){var c=y;y=b;try{return a.apply(this,arguments)}finally{y=c}}};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/scheduler.production.min.js');\n} else {\n module.exports = require('./cjs/scheduler.development.js');\n}\n","/**\n * @license React\n * react-dom.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n/*\n Modernizr 3.0.0pre (Custom Build) | MIT\n*/\n'use strict';var aa=require(\"react\"),ca=require(\"scheduler\");function p(a){for(var b=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+a,c=1;cb}return!1}function v(a,b,c,d,e,f,g){this.acceptsBooleans=2===b||3===b||4===b;this.attributeName=d;this.attributeNamespace=e;this.mustUseProperty=c;this.propertyName=a;this.type=b;this.sanitizeURL=f;this.removeEmptyString=g}var z={};\n\"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style\".split(\" \").forEach(function(a){z[a]=new v(a,0,!1,a,null,!1,!1)});[[\"acceptCharset\",\"accept-charset\"],[\"className\",\"class\"],[\"htmlFor\",\"for\"],[\"httpEquiv\",\"http-equiv\"]].forEach(function(a){var b=a[0];z[b]=new v(b,1,!1,a[1],null,!1,!1)});[\"contentEditable\",\"draggable\",\"spellCheck\",\"value\"].forEach(function(a){z[a]=new v(a,2,!1,a.toLowerCase(),null,!1,!1)});\n[\"autoReverse\",\"externalResourcesRequired\",\"focusable\",\"preserveAlpha\"].forEach(function(a){z[a]=new v(a,2,!1,a,null,!1,!1)});\"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope\".split(\" \").forEach(function(a){z[a]=new v(a,3,!1,a.toLowerCase(),null,!1,!1)});\n[\"checked\",\"multiple\",\"muted\",\"selected\"].forEach(function(a){z[a]=new v(a,3,!0,a,null,!1,!1)});[\"capture\",\"download\"].forEach(function(a){z[a]=new v(a,4,!1,a,null,!1,!1)});[\"cols\",\"rows\",\"size\",\"span\"].forEach(function(a){z[a]=new v(a,6,!1,a,null,!1,!1)});[\"rowSpan\",\"start\"].forEach(function(a){z[a]=new v(a,5,!1,a.toLowerCase(),null,!1,!1)});var ra=/[\\-:]([a-z])/g;function sa(a){return a[1].toUpperCase()}\n\"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height\".split(\" \").forEach(function(a){var b=a.replace(ra,\nsa);z[b]=new v(b,1,!1,a,null,!1,!1)});\"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type\".split(\" \").forEach(function(a){var b=a.replace(ra,sa);z[b]=new v(b,1,!1,a,\"http://www.w3.org/1999/xlink\",!1,!1)});[\"xml:base\",\"xml:lang\",\"xml:space\"].forEach(function(a){var b=a.replace(ra,sa);z[b]=new v(b,1,!1,a,\"http://www.w3.org/XML/1998/namespace\",!1,!1)});[\"tabIndex\",\"crossOrigin\"].forEach(function(a){z[a]=new v(a,1,!1,a.toLowerCase(),null,!1,!1)});\nz.xlinkHref=new v(\"xlinkHref\",1,!1,\"xlink:href\",\"http://www.w3.org/1999/xlink\",!0,!1);[\"src\",\"href\",\"action\",\"formAction\"].forEach(function(a){z[a]=new v(a,1,!1,a.toLowerCase(),null,!0,!0)});\nfunction ta(a,b,c,d){var e=z.hasOwnProperty(b)?z[b]:null;if(null!==e?0!==e.type:d||!(2h||e[g]!==f[h]){var k=\"\\n\"+e[g].replace(\" at new \",\" at \");a.displayName&&k.includes(\"\")&&(k=k.replace(\"\",a.displayName));return k}while(1<=g&&0<=h)}break}}}finally{Na=!1,Error.prepareStackTrace=c}return(a=a?a.displayName||a.name:\"\")?Ma(a):\"\"}\nfunction Pa(a){switch(a.tag){case 5:return Ma(a.type);case 16:return Ma(\"Lazy\");case 13:return Ma(\"Suspense\");case 19:return Ma(\"SuspenseList\");case 0:case 2:case 15:return a=Oa(a.type,!1),a;case 11:return a=Oa(a.type.render,!1),a;case 1:return a=Oa(a.type,!0),a;default:return\"\"}}\nfunction Qa(a){if(null==a)return null;if(\"function\"===typeof a)return a.displayName||a.name||null;if(\"string\"===typeof a)return a;switch(a){case ya:return\"Fragment\";case wa:return\"Portal\";case Aa:return\"Profiler\";case za:return\"StrictMode\";case Ea:return\"Suspense\";case Fa:return\"SuspenseList\"}if(\"object\"===typeof a)switch(a.$$typeof){case Ca:return(a.displayName||\"Context\")+\".Consumer\";case Ba:return(a._context.displayName||\"Context\")+\".Provider\";case Da:var b=a.render;a=a.displayName;a||(a=b.displayName||\nb.name||\"\",a=\"\"!==a?\"ForwardRef(\"+a+\")\":\"ForwardRef\");return a;case Ga:return b=a.displayName||null,null!==b?b:Qa(a.type)||\"Memo\";case Ha:b=a._payload;a=a._init;try{return Qa(a(b))}catch(c){}}return null}\nfunction Ra(a){var b=a.type;switch(a.tag){case 24:return\"Cache\";case 9:return(b.displayName||\"Context\")+\".Consumer\";case 10:return(b._context.displayName||\"Context\")+\".Provider\";case 18:return\"DehydratedFragment\";case 11:return a=b.render,a=a.displayName||a.name||\"\",b.displayName||(\"\"!==a?\"ForwardRef(\"+a+\")\":\"ForwardRef\");case 7:return\"Fragment\";case 5:return b;case 4:return\"Portal\";case 3:return\"Root\";case 6:return\"Text\";case 16:return Qa(b);case 8:return b===za?\"StrictMode\":\"Mode\";case 22:return\"Offscreen\";\ncase 12:return\"Profiler\";case 21:return\"Scope\";case 13:return\"Suspense\";case 19:return\"SuspenseList\";case 25:return\"TracingMarker\";case 1:case 0:case 17:case 2:case 14:case 15:if(\"function\"===typeof b)return b.displayName||b.name||null;if(\"string\"===typeof b)return b}return null}function Sa(a){switch(typeof a){case \"boolean\":case \"number\":case \"string\":case \"undefined\":return a;case \"object\":return a;default:return\"\"}}\nfunction Ta(a){var b=a.type;return(a=a.nodeName)&&\"input\"===a.toLowerCase()&&(\"checkbox\"===b||\"radio\"===b)}\nfunction Ua(a){var b=Ta(a)?\"checked\":\"value\",c=Object.getOwnPropertyDescriptor(a.constructor.prototype,b),d=\"\"+a[b];if(!a.hasOwnProperty(b)&&\"undefined\"!==typeof c&&\"function\"===typeof c.get&&\"function\"===typeof c.set){var e=c.get,f=c.set;Object.defineProperty(a,b,{configurable:!0,get:function(){return e.call(this)},set:function(a){d=\"\"+a;f.call(this,a)}});Object.defineProperty(a,b,{enumerable:c.enumerable});return{getValue:function(){return d},setValue:function(a){d=\"\"+a},stopTracking:function(){a._valueTracker=\nnull;delete a[b]}}}}function Va(a){a._valueTracker||(a._valueTracker=Ua(a))}function Wa(a){if(!a)return!1;var b=a._valueTracker;if(!b)return!0;var c=b.getValue();var d=\"\";a&&(d=Ta(a)?a.checked?\"true\":\"false\":a.value);a=d;return a!==c?(b.setValue(a),!0):!1}function Xa(a){a=a||(\"undefined\"!==typeof document?document:void 0);if(\"undefined\"===typeof a)return null;try{return a.activeElement||a.body}catch(b){return a.body}}\nfunction Ya(a,b){var c=b.checked;return A({},b,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=c?c:a._wrapperState.initialChecked})}function Za(a,b){var c=null==b.defaultValue?\"\":b.defaultValue,d=null!=b.checked?b.checked:b.defaultChecked;c=Sa(null!=b.value?b.value:c);a._wrapperState={initialChecked:d,initialValue:c,controlled:\"checkbox\"===b.type||\"radio\"===b.type?null!=b.checked:null!=b.value}}function ab(a,b){b=b.checked;null!=b&&ta(a,\"checked\",b,!1)}\nfunction bb(a,b){ab(a,b);var c=Sa(b.value),d=b.type;if(null!=c)if(\"number\"===d){if(0===c&&\"\"===a.value||a.value!=c)a.value=\"\"+c}else a.value!==\"\"+c&&(a.value=\"\"+c);else if(\"submit\"===d||\"reset\"===d){a.removeAttribute(\"value\");return}b.hasOwnProperty(\"value\")?cb(a,b.type,c):b.hasOwnProperty(\"defaultValue\")&&cb(a,b.type,Sa(b.defaultValue));null==b.checked&&null!=b.defaultChecked&&(a.defaultChecked=!!b.defaultChecked)}\nfunction db(a,b,c){if(b.hasOwnProperty(\"value\")||b.hasOwnProperty(\"defaultValue\")){var d=b.type;if(!(\"submit\"!==d&&\"reset\"!==d||void 0!==b.value&&null!==b.value))return;b=\"\"+a._wrapperState.initialValue;c||b===a.value||(a.value=b);a.defaultValue=b}c=a.name;\"\"!==c&&(a.name=\"\");a.defaultChecked=!!a._wrapperState.initialChecked;\"\"!==c&&(a.name=c)}\nfunction cb(a,b,c){if(\"number\"!==b||Xa(a.ownerDocument)!==a)null==c?a.defaultValue=\"\"+a._wrapperState.initialValue:a.defaultValue!==\"\"+c&&(a.defaultValue=\"\"+c)}var eb=Array.isArray;\nfunction fb(a,b,c,d){a=a.options;if(b){b={};for(var e=0;e\"+b.valueOf().toString()+\"\";for(b=mb.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;b.firstChild;)a.appendChild(b.firstChild)}});\nfunction ob(a,b){if(b){var c=a.firstChild;if(c&&c===a.lastChild&&3===c.nodeType){c.nodeValue=b;return}}a.textContent=b}\nvar pb={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,\nzoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qb=[\"Webkit\",\"ms\",\"Moz\",\"O\"];Object.keys(pb).forEach(function(a){qb.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);pb[b]=pb[a]})});function rb(a,b,c){return null==b||\"boolean\"===typeof b||\"\"===b?\"\":c||\"number\"!==typeof b||0===b||pb.hasOwnProperty(a)&&pb[a]?(\"\"+b).trim():b+\"px\"}\nfunction sb(a,b){a=a.style;for(var c in b)if(b.hasOwnProperty(c)){var d=0===c.indexOf(\"--\"),e=rb(c,b[c],d);\"float\"===c&&(c=\"cssFloat\");d?a.setProperty(c,e):a[c]=e}}var tb=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});\nfunction ub(a,b){if(b){if(tb[a]&&(null!=b.children||null!=b.dangerouslySetInnerHTML))throw Error(p(137,a));if(null!=b.dangerouslySetInnerHTML){if(null!=b.children)throw Error(p(60));if(\"object\"!==typeof b.dangerouslySetInnerHTML||!(\"__html\"in b.dangerouslySetInnerHTML))throw Error(p(61));}if(null!=b.style&&\"object\"!==typeof b.style)throw Error(p(62));}}\nfunction vb(a,b){if(-1===a.indexOf(\"-\"))return\"string\"===typeof b.is;switch(a){case \"annotation-xml\":case \"color-profile\":case \"font-face\":case \"font-face-src\":case \"font-face-uri\":case \"font-face-format\":case \"font-face-name\":case \"missing-glyph\":return!1;default:return!0}}var wb=null;function xb(a){a=a.target||a.srcElement||window;a.correspondingUseElement&&(a=a.correspondingUseElement);return 3===a.nodeType?a.parentNode:a}var yb=null,zb=null,Ab=null;\nfunction Bb(a){if(a=Cb(a)){if(\"function\"!==typeof yb)throw Error(p(280));var b=a.stateNode;b&&(b=Db(b),yb(a.stateNode,a.type,b))}}function Eb(a){zb?Ab?Ab.push(a):Ab=[a]:zb=a}function Fb(){if(zb){var a=zb,b=Ab;Ab=zb=null;Bb(a);if(b)for(a=0;a>>=0;return 0===a?32:31-(pc(a)/qc|0)|0}var rc=64,sc=4194304;\nfunction tc(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;\ndefault:return a}}function uc(a,b){var c=a.pendingLanes;if(0===c)return 0;var d=0,e=a.suspendedLanes,f=a.pingedLanes,g=c&268435455;if(0!==g){var h=g&~e;0!==h?d=tc(h):(f&=g,0!==f&&(d=tc(f)))}else g=c&~e,0!==g?d=tc(g):0!==f&&(d=tc(f));if(0===d)return 0;if(0!==b&&b!==d&&0===(b&e)&&(e=d&-d,f=b&-b,e>=f||16===e&&0!==(f&4194240)))return b;0!==(d&4)&&(d|=c&16);b=a.entangledLanes;if(0!==b)for(a=a.entanglements,b&=d;0c;c++)b.push(a);return b}\nfunction Ac(a,b,c){a.pendingLanes|=b;536870912!==b&&(a.suspendedLanes=0,a.pingedLanes=0);a=a.eventTimes;b=31-oc(b);a[b]=c}function Bc(a,b){var c=a.pendingLanes&~b;a.pendingLanes=b;a.suspendedLanes=0;a.pingedLanes=0;a.expiredLanes&=b;a.mutableReadLanes&=b;a.entangledLanes&=b;b=a.entanglements;var d=a.eventTimes;for(a=a.expirationTimes;0=be),ee=String.fromCharCode(32),fe=!1;\nfunction ge(a,b){switch(a){case \"keyup\":return-1!==$d.indexOf(b.keyCode);case \"keydown\":return 229!==b.keyCode;case \"keypress\":case \"mousedown\":case \"focusout\":return!0;default:return!1}}function he(a){a=a.detail;return\"object\"===typeof a&&\"data\"in a?a.data:null}var ie=!1;function je(a,b){switch(a){case \"compositionend\":return he(b);case \"keypress\":if(32!==b.which)return null;fe=!0;return ee;case \"textInput\":return a=b.data,a===ee&&fe?null:a;default:return null}}\nfunction ke(a,b){if(ie)return\"compositionend\"===a||!ae&&ge(a,b)?(a=nd(),md=ld=kd=null,ie=!1,a):null;switch(a){case \"paste\":return null;case \"keypress\":if(!(b.ctrlKey||b.altKey||b.metaKey)||b.ctrlKey&&b.altKey){if(b.char&&1=b)return{node:c,offset:b-a};a=d}a:{for(;c;){if(c.nextSibling){c=c.nextSibling;break a}c=c.parentNode}c=void 0}c=Je(c)}}function Le(a,b){return a&&b?a===b?!0:a&&3===a.nodeType?!1:b&&3===b.nodeType?Le(a,b.parentNode):\"contains\"in a?a.contains(b):a.compareDocumentPosition?!!(a.compareDocumentPosition(b)&16):!1:!1}\nfunction Me(){for(var a=window,b=Xa();b instanceof a.HTMLIFrameElement;){try{var c=\"string\"===typeof b.contentWindow.location.href}catch(d){c=!1}if(c)a=b.contentWindow;else break;b=Xa(a.document)}return b}function Ne(a){var b=a&&a.nodeName&&a.nodeName.toLowerCase();return b&&(\"input\"===b&&(\"text\"===a.type||\"search\"===a.type||\"tel\"===a.type||\"url\"===a.type||\"password\"===a.type)||\"textarea\"===b||\"true\"===a.contentEditable)}\nfunction Oe(a){var b=Me(),c=a.focusedElem,d=a.selectionRange;if(b!==c&&c&&c.ownerDocument&&Le(c.ownerDocument.documentElement,c)){if(null!==d&&Ne(c))if(b=d.start,a=d.end,void 0===a&&(a=b),\"selectionStart\"in c)c.selectionStart=b,c.selectionEnd=Math.min(a,c.value.length);else if(a=(b=c.ownerDocument||document)&&b.defaultView||window,a.getSelection){a=a.getSelection();var e=c.textContent.length,f=Math.min(d.start,e);d=void 0===d.end?f:Math.min(d.end,e);!a.extend&&f>d&&(e=d,d=f,f=e);e=Ke(c,f);var g=Ke(c,\nd);e&&g&&(1!==a.rangeCount||a.anchorNode!==e.node||a.anchorOffset!==e.offset||a.focusNode!==g.node||a.focusOffset!==g.offset)&&(b=b.createRange(),b.setStart(e.node,e.offset),a.removeAllRanges(),f>d?(a.addRange(b),a.extend(g.node,g.offset)):(b.setEnd(g.node,g.offset),a.addRange(b)))}b=[];for(a=c;a=a.parentNode;)1===a.nodeType&&b.push({element:a,left:a.scrollLeft,top:a.scrollTop});\"function\"===typeof c.focus&&c.focus();for(c=0;c=document.documentMode,Qe=null,Re=null,Se=null,Te=!1;\nfunction Ue(a,b,c){var d=c.window===c?c.document:9===c.nodeType?c:c.ownerDocument;Te||null==Qe||Qe!==Xa(d)||(d=Qe,\"selectionStart\"in d&&Ne(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Se&&Ie(Se,d)||(Se=d,d=oe(Re,\"onSelect\"),0Tf||(a.current=Sf[Tf],Sf[Tf]=null,Tf--)}function G(a,b){Tf++;Sf[Tf]=a.current;a.current=b}var Vf={},H=Uf(Vf),Wf=Uf(!1),Xf=Vf;function Yf(a,b){var c=a.type.contextTypes;if(!c)return Vf;var d=a.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===b)return d.__reactInternalMemoizedMaskedChildContext;var e={},f;for(f in c)e[f]=b[f];d&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=b,a.__reactInternalMemoizedMaskedChildContext=e);return e}\nfunction Zf(a){a=a.childContextTypes;return null!==a&&void 0!==a}function $f(){E(Wf);E(H)}function ag(a,b,c){if(H.current!==Vf)throw Error(p(168));G(H,b);G(Wf,c)}function bg(a,b,c){var d=a.stateNode;b=b.childContextTypes;if(\"function\"!==typeof d.getChildContext)return c;d=d.getChildContext();for(var e in d)if(!(e in b))throw Error(p(108,Ra(a)||\"Unknown\",e));return A({},c,d)}\nfunction cg(a){a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Vf;Xf=H.current;G(H,a);G(Wf,Wf.current);return!0}function dg(a,b,c){var d=a.stateNode;if(!d)throw Error(p(169));c?(a=bg(a,b,Xf),d.__reactInternalMemoizedMergedChildContext=a,E(Wf),E(H),G(H,a)):E(Wf);G(Wf,c)}var eg=null,fg=!1,gg=!1;function hg(a){null===eg?eg=[a]:eg.push(a)}function ig(a){fg=!0;hg(a)}\nfunction jg(){if(!gg&&null!==eg){gg=!0;var a=0,b=C;try{var c=eg;for(C=1;a>=g;e-=g;rg=1<<32-oc(b)+e|c<w?(x=u,u=null):x=u.sibling;var n=r(e,u,h[w],k);if(null===n){null===u&&(u=x);break}a&&u&&null===n.alternate&&b(e,u);g=f(n,g,w);null===m?l=n:m.sibling=n;m=n;u=x}if(w===h.length)return c(e,u),I&&tg(e,w),l;if(null===u){for(;ww?(x=m,m=null):x=m.sibling;var t=r(e,m,n.value,k);if(null===t){null===m&&(m=x);break}a&&m&&null===t.alternate&&b(e,m);g=f(t,g,w);null===u?l=t:u.sibling=t;u=t;m=x}if(n.done)return c(e,\nm),I&&tg(e,w),l;if(null===m){for(;!n.done;w++,n=h.next())n=q(e,n.value,k),null!==n&&(g=f(n,g,w),null===u?l=n:u.sibling=n,u=n);I&&tg(e,w);return l}for(m=d(e,m);!n.done;w++,n=h.next())n=y(m,e,w,n.value,k),null!==n&&(a&&null!==n.alternate&&m.delete(null===n.key?w:n.key),g=f(n,g,w),null===u?l=n:u.sibling=n,u=n);a&&m.forEach(function(a){return b(e,a)});I&&tg(e,w);return l}function J(a,d,f,h){\"object\"===typeof f&&null!==f&&f.type===ya&&null===f.key&&(f=f.props.children);if(\"object\"===typeof f&&null!==f){switch(f.$$typeof){case va:a:{for(var k=\nf.key,l=d;null!==l;){if(l.key===k){k=f.type;if(k===ya){if(7===l.tag){c(a,l.sibling);d=e(l,f.props.children);d.return=a;a=d;break a}}else if(l.elementType===k||\"object\"===typeof k&&null!==k&&k.$$typeof===Ha&&Ng(k)===l.type){c(a,l.sibling);d=e(l,f.props);d.ref=Lg(a,l,f);d.return=a;a=d;break a}c(a,l);break}else b(a,l);l=l.sibling}f.type===ya?(d=Tg(f.props.children,a.mode,h,f.key),d.return=a,a=d):(h=Rg(f.type,f.key,f.props,null,a.mode,h),h.ref=Lg(a,d,f),h.return=a,a=h)}return g(a);case wa:a:{for(l=f.key;null!==\nd;){if(d.key===l)if(4===d.tag&&d.stateNode.containerInfo===f.containerInfo&&d.stateNode.implementation===f.implementation){c(a,d.sibling);d=e(d,f.children||[]);d.return=a;a=d;break a}else{c(a,d);break}else b(a,d);d=d.sibling}d=Sg(f,a.mode,h);d.return=a;a=d}return g(a);case Ha:return l=f._init,J(a,d,l(f._payload),h)}if(eb(f))return n(a,d,f,h);if(Ka(f))return t(a,d,f,h);Mg(a,f)}return\"string\"===typeof f&&\"\"!==f||\"number\"===typeof f?(f=\"\"+f,null!==d&&6===d.tag?(c(a,d.sibling),d=e(d,f),d.return=a,a=d):\n(c(a,d),d=Qg(f,a.mode,h),d.return=a,a=d),g(a)):c(a,d)}return J}var Ug=Og(!0),Vg=Og(!1),Wg=Uf(null),Xg=null,Yg=null,Zg=null;function $g(){Zg=Yg=Xg=null}function ah(a){var b=Wg.current;E(Wg);a._currentValue=b}function bh(a,b,c){for(;null!==a;){var d=a.alternate;(a.childLanes&b)!==b?(a.childLanes|=b,null!==d&&(d.childLanes|=b)):null!==d&&(d.childLanes&b)!==b&&(d.childLanes|=b);if(a===c)break;a=a.return}}\nfunction ch(a,b){Xg=a;Zg=Yg=null;a=a.dependencies;null!==a&&null!==a.firstContext&&(0!==(a.lanes&b)&&(dh=!0),a.firstContext=null)}function eh(a){var b=a._currentValue;if(Zg!==a)if(a={context:a,memoizedValue:b,next:null},null===Yg){if(null===Xg)throw Error(p(308));Yg=a;Xg.dependencies={lanes:0,firstContext:a}}else Yg=Yg.next=a;return b}var fh=null;function gh(a){null===fh?fh=[a]:fh.push(a)}\nfunction hh(a,b,c,d){var e=b.interleaved;null===e?(c.next=c,gh(b)):(c.next=e.next,e.next=c);b.interleaved=c;return ih(a,d)}function ih(a,b){a.lanes|=b;var c=a.alternate;null!==c&&(c.lanes|=b);c=a;for(a=a.return;null!==a;)a.childLanes|=b,c=a.alternate,null!==c&&(c.childLanes|=b),c=a,a=a.return;return 3===c.tag?c.stateNode:null}var jh=!1;function kh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}\nfunction lh(a,b){a=a.updateQueue;b.updateQueue===a&&(b.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function mh(a,b){return{eventTime:a,lane:b,tag:0,payload:null,callback:null,next:null}}\nfunction nh(a,b,c){var d=a.updateQueue;if(null===d)return null;d=d.shared;if(0!==(K&2)){var e=d.pending;null===e?b.next=b:(b.next=e.next,e.next=b);d.pending=b;return ih(a,c)}e=d.interleaved;null===e?(b.next=b,gh(d)):(b.next=e.next,e.next=b);d.interleaved=b;return ih(a,c)}function oh(a,b,c){b=b.updateQueue;if(null!==b&&(b=b.shared,0!==(c&4194240))){var d=b.lanes;d&=a.pendingLanes;c|=d;b.lanes=c;Cc(a,c)}}\nfunction ph(a,b){var c=a.updateQueue,d=a.alternate;if(null!==d&&(d=d.updateQueue,c===d)){var e=null,f=null;c=c.firstBaseUpdate;if(null!==c){do{var g={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};null===f?e=f=g:f=f.next=g;c=c.next}while(null!==c);null===f?e=f=b:f=f.next=b}else e=f=b;c={baseState:d.baseState,firstBaseUpdate:e,lastBaseUpdate:f,shared:d.shared,effects:d.effects};a.updateQueue=c;return}a=c.lastBaseUpdate;null===a?c.firstBaseUpdate=b:a.next=\nb;c.lastBaseUpdate=b}\nfunction qh(a,b,c,d){var e=a.updateQueue;jh=!1;var f=e.firstBaseUpdate,g=e.lastBaseUpdate,h=e.shared.pending;if(null!==h){e.shared.pending=null;var k=h,l=k.next;k.next=null;null===g?f=l:g.next=l;g=k;var m=a.alternate;null!==m&&(m=m.updateQueue,h=m.lastBaseUpdate,h!==g&&(null===h?m.firstBaseUpdate=l:h.next=l,m.lastBaseUpdate=k))}if(null!==f){var q=e.baseState;g=0;m=l=k=null;h=f;do{var r=h.lane,y=h.eventTime;if((d&r)===r){null!==m&&(m=m.next={eventTime:y,lane:0,tag:h.tag,payload:h.payload,callback:h.callback,\nnext:null});a:{var n=a,t=h;r=b;y=c;switch(t.tag){case 1:n=t.payload;if(\"function\"===typeof n){q=n.call(y,q,r);break a}q=n;break a;case 3:n.flags=n.flags&-65537|128;case 0:n=t.payload;r=\"function\"===typeof n?n.call(y,q,r):n;if(null===r||void 0===r)break a;q=A({},q,r);break a;case 2:jh=!0}}null!==h.callback&&0!==h.lane&&(a.flags|=64,r=e.effects,null===r?e.effects=[h]:r.push(h))}else y={eventTime:y,lane:r,tag:h.tag,payload:h.payload,callback:h.callback,next:null},null===m?(l=m=y,k=q):m=m.next=y,g|=r;\nh=h.next;if(null===h)if(h=e.shared.pending,null===h)break;else r=h,h=r.next,r.next=null,e.lastBaseUpdate=r,e.shared.pending=null}while(1);null===m&&(k=q);e.baseState=k;e.firstBaseUpdate=l;e.lastBaseUpdate=m;b=e.shared.interleaved;if(null!==b){e=b;do g|=e.lane,e=e.next;while(e!==b)}else null===f&&(e.shared.lanes=0);rh|=g;a.lanes=g;a.memoizedState=q}}\nfunction sh(a,b,c){a=b.effects;b.effects=null;if(null!==a)for(b=0;bc?c:4;a(!0);var d=Gh.transition;Gh.transition={};try{a(!1),b()}finally{C=c,Gh.transition=d}}function wi(){return Uh().memoizedState}\nfunction xi(a,b,c){var d=yi(a);c={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(zi(a))Ai(b,c);else if(c=hh(a,b,c,d),null!==c){var e=R();gi(c,a,d,e);Bi(c,b,d)}}\nfunction ii(a,b,c){var d=yi(a),e={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(zi(a))Ai(b,e);else{var f=a.alternate;if(0===a.lanes&&(null===f||0===f.lanes)&&(f=b.lastRenderedReducer,null!==f))try{var g=b.lastRenderedState,h=f(g,c);e.hasEagerState=!0;e.eagerState=h;if(He(h,g)){var k=b.interleaved;null===k?(e.next=e,gh(b)):(e.next=k.next,k.next=e);b.interleaved=e;return}}catch(l){}finally{}c=hh(a,b,e,d);null!==c&&(e=R(),gi(c,a,d,e),Bi(c,b,d))}}\nfunction zi(a){var b=a.alternate;return a===M||null!==b&&b===M}function Ai(a,b){Jh=Ih=!0;var c=a.pending;null===c?b.next=b:(b.next=c.next,c.next=b);a.pending=b}function Bi(a,b,c){if(0!==(c&4194240)){var d=b.lanes;d&=a.pendingLanes;c|=d;b.lanes=c;Cc(a,c)}}\nvar Rh={readContext:eh,useCallback:P,useContext:P,useEffect:P,useImperativeHandle:P,useInsertionEffect:P,useLayoutEffect:P,useMemo:P,useReducer:P,useRef:P,useState:P,useDebugValue:P,useDeferredValue:P,useTransition:P,useMutableSource:P,useSyncExternalStore:P,useId:P,unstable_isNewReconciler:!1},Oh={readContext:eh,useCallback:function(a,b){Th().memoizedState=[a,void 0===b?null:b];return a},useContext:eh,useEffect:mi,useImperativeHandle:function(a,b,c){c=null!==c&&void 0!==c?c.concat([a]):null;return ki(4194308,\n4,pi.bind(null,b,a),c)},useLayoutEffect:function(a,b){return ki(4194308,4,a,b)},useInsertionEffect:function(a,b){return ki(4,2,a,b)},useMemo:function(a,b){var c=Th();b=void 0===b?null:b;a=a();c.memoizedState=[a,b];return a},useReducer:function(a,b,c){var d=Th();b=void 0!==c?c(b):b;d.memoizedState=d.baseState=b;a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:b};d.queue=a;a=a.dispatch=xi.bind(null,M,a);return[d.memoizedState,a]},useRef:function(a){var b=\nTh();a={current:a};return b.memoizedState=a},useState:hi,useDebugValue:ri,useDeferredValue:function(a){return Th().memoizedState=a},useTransition:function(){var a=hi(!1),b=a[0];a=vi.bind(null,a[1]);Th().memoizedState=a;return[b,a]},useMutableSource:function(){},useSyncExternalStore:function(a,b,c){var d=M,e=Th();if(I){if(void 0===c)throw Error(p(407));c=c()}else{c=b();if(null===Q)throw Error(p(349));0!==(Hh&30)||di(d,b,c)}e.memoizedState=c;var f={value:c,getSnapshot:b};e.queue=f;mi(ai.bind(null,d,\nf,a),[a]);d.flags|=2048;bi(9,ci.bind(null,d,f,c,b),void 0,null);return c},useId:function(){var a=Th(),b=Q.identifierPrefix;if(I){var c=sg;var d=rg;c=(d&~(1<<32-oc(d)-1)).toString(32)+c;b=\":\"+b+\"R\"+c;c=Kh++;0\\x3c/script>\",a=a.removeChild(a.firstChild)):\n\"string\"===typeof d.is?a=g.createElement(c,{is:d.is}):(a=g.createElement(c),\"select\"===c&&(g=a,d.multiple?g.multiple=!0:d.size&&(g.size=d.size))):a=g.createElementNS(a,c);a[Of]=b;a[Pf]=d;zj(a,b,!1,!1);b.stateNode=a;a:{g=vb(c,d);switch(c){case \"dialog\":D(\"cancel\",a);D(\"close\",a);e=d;break;case \"iframe\":case \"object\":case \"embed\":D(\"load\",a);e=d;break;case \"video\":case \"audio\":for(e=0;eGj&&(b.flags|=128,d=!0,Dj(f,!1),b.lanes=4194304)}else{if(!d)if(a=Ch(g),null!==a){if(b.flags|=128,d=!0,c=a.updateQueue,null!==c&&(b.updateQueue=c,b.flags|=4),Dj(f,!0),null===f.tail&&\"hidden\"===f.tailMode&&!g.alternate&&!I)return S(b),null}else 2*B()-f.renderingStartTime>Gj&&1073741824!==c&&(b.flags|=128,d=!0,Dj(f,!1),b.lanes=4194304);f.isBackwards?(g.sibling=b.child,b.child=g):(c=f.last,null!==c?c.sibling=g:b.child=g,f.last=g)}if(null!==f.tail)return b=f.tail,f.rendering=\nb,f.tail=b.sibling,f.renderingStartTime=B(),b.sibling=null,c=L.current,G(L,d?c&1|2:c&1),b;S(b);return null;case 22:case 23:return Hj(),d=null!==b.memoizedState,null!==a&&null!==a.memoizedState!==d&&(b.flags|=8192),d&&0!==(b.mode&1)?0!==(fj&1073741824)&&(S(b),b.subtreeFlags&6&&(b.flags|=8192)):S(b),null;case 24:return null;case 25:return null}throw Error(p(156,b.tag));}\nfunction Ij(a,b){wg(b);switch(b.tag){case 1:return Zf(b.type)&&$f(),a=b.flags,a&65536?(b.flags=a&-65537|128,b):null;case 3:return zh(),E(Wf),E(H),Eh(),a=b.flags,0!==(a&65536)&&0===(a&128)?(b.flags=a&-65537|128,b):null;case 5:return Bh(b),null;case 13:E(L);a=b.memoizedState;if(null!==a&&null!==a.dehydrated){if(null===b.alternate)throw Error(p(340));Ig()}a=b.flags;return a&65536?(b.flags=a&-65537|128,b):null;case 19:return E(L),null;case 4:return zh(),null;case 10:return ah(b.type._context),null;case 22:case 23:return Hj(),\nnull;case 24:return null;default:return null}}var Jj=!1,U=!1,Kj=\"function\"===typeof WeakSet?WeakSet:Set,V=null;function Lj(a,b){var c=a.ref;if(null!==c)if(\"function\"===typeof c)try{c(null)}catch(d){W(a,b,d)}else c.current=null}function Mj(a,b,c){try{c()}catch(d){W(a,b,d)}}var Nj=!1;\nfunction Oj(a,b){Cf=dd;a=Me();if(Ne(a)){if(\"selectionStart\"in a)var c={start:a.selectionStart,end:a.selectionEnd};else a:{c=(c=a.ownerDocument)&&c.defaultView||window;var d=c.getSelection&&c.getSelection();if(d&&0!==d.rangeCount){c=d.anchorNode;var e=d.anchorOffset,f=d.focusNode;d=d.focusOffset;try{c.nodeType,f.nodeType}catch(F){c=null;break a}var g=0,h=-1,k=-1,l=0,m=0,q=a,r=null;b:for(;;){for(var y;;){q!==c||0!==e&&3!==q.nodeType||(h=g+e);q!==f||0!==d&&3!==q.nodeType||(k=g+d);3===q.nodeType&&(g+=\nq.nodeValue.length);if(null===(y=q.firstChild))break;r=q;q=y}for(;;){if(q===a)break b;r===c&&++l===e&&(h=g);r===f&&++m===d&&(k=g);if(null!==(y=q.nextSibling))break;q=r;r=q.parentNode}q=y}c=-1===h||-1===k?null:{start:h,end:k}}else c=null}c=c||{start:0,end:0}}else c=null;Df={focusedElem:a,selectionRange:c};dd=!1;for(V=b;null!==V;)if(b=V,a=b.child,0!==(b.subtreeFlags&1028)&&null!==a)a.return=b,V=a;else for(;null!==V;){b=V;try{var n=b.alternate;if(0!==(b.flags&1024))switch(b.tag){case 0:case 11:case 15:break;\ncase 1:if(null!==n){var t=n.memoizedProps,J=n.memoizedState,x=b.stateNode,w=x.getSnapshotBeforeUpdate(b.elementType===b.type?t:Ci(b.type,t),J);x.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var u=b.stateNode.containerInfo;1===u.nodeType?u.textContent=\"\":9===u.nodeType&&u.documentElement&&u.removeChild(u.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p(163));}}catch(F){W(b,b.return,F)}a=b.sibling;if(null!==a){a.return=b.return;V=a;break}V=b.return}n=Nj;Nj=!1;return n}\nfunction Pj(a,b,c){var d=b.updateQueue;d=null!==d?d.lastEffect:null;if(null!==d){var e=d=d.next;do{if((e.tag&a)===a){var f=e.destroy;e.destroy=void 0;void 0!==f&&Mj(b,c,f)}e=e.next}while(e!==d)}}function Qj(a,b){b=b.updateQueue;b=null!==b?b.lastEffect:null;if(null!==b){var c=b=b.next;do{if((c.tag&a)===a){var d=c.create;c.destroy=d()}c=c.next}while(c!==b)}}function Rj(a){var b=a.ref;if(null!==b){var c=a.stateNode;switch(a.tag){case 5:a=c;break;default:a=c}\"function\"===typeof b?b(a):b.current=a}}\nfunction Sj(a){var b=a.alternate;null!==b&&(a.alternate=null,Sj(b));a.child=null;a.deletions=null;a.sibling=null;5===a.tag&&(b=a.stateNode,null!==b&&(delete b[Of],delete b[Pf],delete b[of],delete b[Qf],delete b[Rf]));a.stateNode=null;a.return=null;a.dependencies=null;a.memoizedProps=null;a.memoizedState=null;a.pendingProps=null;a.stateNode=null;a.updateQueue=null}function Tj(a){return 5===a.tag||3===a.tag||4===a.tag}\nfunction Uj(a){a:for(;;){for(;null===a.sibling;){if(null===a.return||Tj(a.return))return null;a=a.return}a.sibling.return=a.return;for(a=a.sibling;5!==a.tag&&6!==a.tag&&18!==a.tag;){if(a.flags&2)continue a;if(null===a.child||4===a.tag)continue a;else a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}\nfunction Vj(a,b,c){var d=a.tag;if(5===d||6===d)a=a.stateNode,b?8===c.nodeType?c.parentNode.insertBefore(a,b):c.insertBefore(a,b):(8===c.nodeType?(b=c.parentNode,b.insertBefore(a,c)):(b=c,b.appendChild(a)),c=c._reactRootContainer,null!==c&&void 0!==c||null!==b.onclick||(b.onclick=Bf));else if(4!==d&&(a=a.child,null!==a))for(Vj(a,b,c),a=a.sibling;null!==a;)Vj(a,b,c),a=a.sibling}\nfunction Wj(a,b,c){var d=a.tag;if(5===d||6===d)a=a.stateNode,b?c.insertBefore(a,b):c.appendChild(a);else if(4!==d&&(a=a.child,null!==a))for(Wj(a,b,c),a=a.sibling;null!==a;)Wj(a,b,c),a=a.sibling}var X=null,Xj=!1;function Yj(a,b,c){for(c=c.child;null!==c;)Zj(a,b,c),c=c.sibling}\nfunction Zj(a,b,c){if(lc&&\"function\"===typeof lc.onCommitFiberUnmount)try{lc.onCommitFiberUnmount(kc,c)}catch(h){}switch(c.tag){case 5:U||Lj(c,b);case 6:var d=X,e=Xj;X=null;Yj(a,b,c);X=d;Xj=e;null!==X&&(Xj?(a=X,c=c.stateNode,8===a.nodeType?a.parentNode.removeChild(c):a.removeChild(c)):X.removeChild(c.stateNode));break;case 18:null!==X&&(Xj?(a=X,c=c.stateNode,8===a.nodeType?Kf(a.parentNode,c):1===a.nodeType&&Kf(a,c),bd(a)):Kf(X,c.stateNode));break;case 4:d=X;e=Xj;X=c.stateNode.containerInfo;Xj=!0;\nYj(a,b,c);X=d;Xj=e;break;case 0:case 11:case 14:case 15:if(!U&&(d=c.updateQueue,null!==d&&(d=d.lastEffect,null!==d))){e=d=d.next;do{var f=e,g=f.destroy;f=f.tag;void 0!==g&&(0!==(f&2)?Mj(c,b,g):0!==(f&4)&&Mj(c,b,g));e=e.next}while(e!==d)}Yj(a,b,c);break;case 1:if(!U&&(Lj(c,b),d=c.stateNode,\"function\"===typeof d.componentWillUnmount))try{d.props=c.memoizedProps,d.state=c.memoizedState,d.componentWillUnmount()}catch(h){W(c,b,h)}Yj(a,b,c);break;case 21:Yj(a,b,c);break;case 22:c.mode&1?(U=(d=U)||null!==\nc.memoizedState,Yj(a,b,c),U=d):Yj(a,b,c);break;default:Yj(a,b,c)}}function ak(a){var b=a.updateQueue;if(null!==b){a.updateQueue=null;var c=a.stateNode;null===c&&(c=a.stateNode=new Kj);b.forEach(function(b){var d=bk.bind(null,a,b);c.has(b)||(c.add(b),b.then(d,d))})}}\nfunction ck(a,b){var c=b.deletions;if(null!==c)for(var d=0;de&&(e=g);d&=~f}d=e;d=B()-d;d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3E3>d?3E3:4320>d?4320:1960*lk(d/1960))-d;if(10a?16:a;if(null===wk)var d=!1;else{a=wk;wk=null;xk=0;if(0!==(K&6))throw Error(p(331));var e=K;K|=4;for(V=a.current;null!==V;){var f=V,g=f.child;if(0!==(V.flags&16)){var h=f.deletions;if(null!==h){for(var k=0;kB()-fk?Kk(a,0):rk|=c);Dk(a,b)}function Yk(a,b){0===b&&(0===(a.mode&1)?b=1:(b=sc,sc<<=1,0===(sc&130023424)&&(sc=4194304)));var c=R();a=ih(a,b);null!==a&&(Ac(a,b,c),Dk(a,c))}function uj(a){var b=a.memoizedState,c=0;null!==b&&(c=b.retryLane);Yk(a,c)}\nfunction bk(a,b){var c=0;switch(a.tag){case 13:var d=a.stateNode;var e=a.memoizedState;null!==e&&(c=e.retryLane);break;case 19:d=a.stateNode;break;default:throw Error(p(314));}null!==d&&d.delete(b);Yk(a,c)}var Vk;\nVk=function(a,b,c){if(null!==a)if(a.memoizedProps!==b.pendingProps||Wf.current)dh=!0;else{if(0===(a.lanes&c)&&0===(b.flags&128))return dh=!1,yj(a,b,c);dh=0!==(a.flags&131072)?!0:!1}else dh=!1,I&&0!==(b.flags&1048576)&&ug(b,ng,b.index);b.lanes=0;switch(b.tag){case 2:var d=b.type;ij(a,b);a=b.pendingProps;var e=Yf(b,H.current);ch(b,c);e=Nh(null,b,d,a,e,c);var f=Sh();b.flags|=1;\"object\"===typeof e&&null!==e&&\"function\"===typeof e.render&&void 0===e.$$typeof?(b.tag=1,b.memoizedState=null,b.updateQueue=\nnull,Zf(d)?(f=!0,cg(b)):f=!1,b.memoizedState=null!==e.state&&void 0!==e.state?e.state:null,kh(b),e.updater=Ei,b.stateNode=e,e._reactInternals=b,Ii(b,d,a,c),b=jj(null,b,d,!0,f,c)):(b.tag=0,I&&f&&vg(b),Xi(null,b,e,c),b=b.child);return b;case 16:d=b.elementType;a:{ij(a,b);a=b.pendingProps;e=d._init;d=e(d._payload);b.type=d;e=b.tag=Zk(d);a=Ci(d,a);switch(e){case 0:b=cj(null,b,d,a,c);break a;case 1:b=hj(null,b,d,a,c);break a;case 11:b=Yi(null,b,d,a,c);break a;case 14:b=$i(null,b,d,Ci(d.type,a),c);break a}throw Error(p(306,\nd,\"\"));}return b;case 0:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),cj(a,b,d,e,c);case 1:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),hj(a,b,d,e,c);case 3:a:{kj(b);if(null===a)throw Error(p(387));d=b.pendingProps;f=b.memoizedState;e=f.element;lh(a,b);qh(b,d,null,c);var g=b.memoizedState;d=g.element;if(f.isDehydrated)if(f={element:d,isDehydrated:!1,cache:g.cache,pendingSuspenseBoundaries:g.pendingSuspenseBoundaries,transitions:g.transitions},b.updateQueue.baseState=\nf,b.memoizedState=f,b.flags&256){e=Ji(Error(p(423)),b);b=lj(a,b,d,c,e);break a}else if(d!==e){e=Ji(Error(p(424)),b);b=lj(a,b,d,c,e);break a}else for(yg=Lf(b.stateNode.containerInfo.firstChild),xg=b,I=!0,zg=null,c=Vg(b,null,d,c),b.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{Ig();if(d===e){b=Zi(a,b,c);break a}Xi(a,b,d,c)}b=b.child}return b;case 5:return Ah(b),null===a&&Eg(b),d=b.type,e=b.pendingProps,f=null!==a?a.memoizedProps:null,g=e.children,Ef(d,e)?g=null:null!==f&&Ef(d,f)&&(b.flags|=32),\ngj(a,b),Xi(a,b,g,c),b.child;case 6:return null===a&&Eg(b),null;case 13:return oj(a,b,c);case 4:return yh(b,b.stateNode.containerInfo),d=b.pendingProps,null===a?b.child=Ug(b,null,d,c):Xi(a,b,d,c),b.child;case 11:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),Yi(a,b,d,e,c);case 7:return Xi(a,b,b.pendingProps,c),b.child;case 8:return Xi(a,b,b.pendingProps.children,c),b.child;case 12:return Xi(a,b,b.pendingProps.children,c),b.child;case 10:a:{d=b.type._context;e=b.pendingProps;f=b.memoizedProps;\ng=e.value;G(Wg,d._currentValue);d._currentValue=g;if(null!==f)if(He(f.value,g)){if(f.children===e.children&&!Wf.current){b=Zi(a,b,c);break a}}else for(f=b.child,null!==f&&(f.return=b);null!==f;){var h=f.dependencies;if(null!==h){g=f.child;for(var k=h.firstContext;null!==k;){if(k.context===d){if(1===f.tag){k=mh(-1,c&-c);k.tag=2;var l=f.updateQueue;if(null!==l){l=l.shared;var m=l.pending;null===m?k.next=k:(k.next=m.next,m.next=k);l.pending=k}}f.lanes|=c;k=f.alternate;null!==k&&(k.lanes|=c);bh(f.return,\nc,b);h.lanes|=c;break}k=k.next}}else if(10===f.tag)g=f.type===b.type?null:f.child;else if(18===f.tag){g=f.return;if(null===g)throw Error(p(341));g.lanes|=c;h=g.alternate;null!==h&&(h.lanes|=c);bh(g,c,b);g=f.sibling}else g=f.child;if(null!==g)g.return=f;else for(g=f;null!==g;){if(g===b){g=null;break}f=g.sibling;if(null!==f){f.return=g.return;g=f;break}g=g.return}f=g}Xi(a,b,e.children,c);b=b.child}return b;case 9:return e=b.type,d=b.pendingProps.children,ch(b,c),e=eh(e),d=d(e),b.flags|=1,Xi(a,b,d,c),\nb.child;case 14:return d=b.type,e=Ci(d,b.pendingProps),e=Ci(d.type,e),$i(a,b,d,e,c);case 15:return bj(a,b,b.type,b.pendingProps,c);case 17:return d=b.type,e=b.pendingProps,e=b.elementType===d?e:Ci(d,e),ij(a,b),b.tag=1,Zf(d)?(a=!0,cg(b)):a=!1,ch(b,c),Gi(b,d,e),Ii(b,d,e,c),jj(null,b,d,!0,a,c);case 19:return xj(a,b,c);case 22:return dj(a,b,c)}throw Error(p(156,b.tag));};function Fk(a,b){return ac(a,b)}\nfunction $k(a,b,c,d){this.tag=a;this.key=c;this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null;this.index=0;this.ref=null;this.pendingProps=b;this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null;this.mode=d;this.subtreeFlags=this.flags=0;this.deletions=null;this.childLanes=this.lanes=0;this.alternate=null}function Bg(a,b,c,d){return new $k(a,b,c,d)}function aj(a){a=a.prototype;return!(!a||!a.isReactComponent)}\nfunction Zk(a){if(\"function\"===typeof a)return aj(a)?1:0;if(void 0!==a&&null!==a){a=a.$$typeof;if(a===Da)return 11;if(a===Ga)return 14}return 2}\nfunction Pg(a,b){var c=a.alternate;null===c?(c=Bg(a.tag,b,a.key,a.mode),c.elementType=a.elementType,c.type=a.type,c.stateNode=a.stateNode,c.alternate=a,a.alternate=c):(c.pendingProps=b,c.type=a.type,c.flags=0,c.subtreeFlags=0,c.deletions=null);c.flags=a.flags&14680064;c.childLanes=a.childLanes;c.lanes=a.lanes;c.child=a.child;c.memoizedProps=a.memoizedProps;c.memoizedState=a.memoizedState;c.updateQueue=a.updateQueue;b=a.dependencies;c.dependencies=null===b?null:{lanes:b.lanes,firstContext:b.firstContext};\nc.sibling=a.sibling;c.index=a.index;c.ref=a.ref;return c}\nfunction Rg(a,b,c,d,e,f){var g=2;d=a;if(\"function\"===typeof a)aj(a)&&(g=1);else if(\"string\"===typeof a)g=5;else a:switch(a){case ya:return Tg(c.children,e,f,b);case za:g=8;e|=8;break;case Aa:return a=Bg(12,c,b,e|2),a.elementType=Aa,a.lanes=f,a;case Ea:return a=Bg(13,c,b,e),a.elementType=Ea,a.lanes=f,a;case Fa:return a=Bg(19,c,b,e),a.elementType=Fa,a.lanes=f,a;case Ia:return pj(c,e,f,b);default:if(\"object\"===typeof a&&null!==a)switch(a.$$typeof){case Ba:g=10;break a;case Ca:g=9;break a;case Da:g=11;\nbreak a;case Ga:g=14;break a;case Ha:g=16;d=null;break a}throw Error(p(130,null==a?a:typeof a,\"\"));}b=Bg(g,c,b,e);b.elementType=a;b.type=d;b.lanes=f;return b}function Tg(a,b,c,d){a=Bg(7,a,d,b);a.lanes=c;return a}function pj(a,b,c,d){a=Bg(22,a,d,b);a.elementType=Ia;a.lanes=c;a.stateNode={isHidden:!1};return a}function Qg(a,b,c){a=Bg(6,a,null,b);a.lanes=c;return a}\nfunction Sg(a,b,c){b=Bg(4,null!==a.children?a.children:[],a.key,b);b.lanes=c;b.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation};return b}\nfunction al(a,b,c,d,e){this.tag=b;this.containerInfo=a;this.finishedWork=this.pingCache=this.current=this.pendingChildren=null;this.timeoutHandle=-1;this.callbackNode=this.pendingContext=this.context=null;this.callbackPriority=0;this.eventTimes=zc(0);this.expirationTimes=zc(-1);this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0;this.entanglements=zc(0);this.identifierPrefix=d;this.onRecoverableError=e;this.mutableSourceEagerHydrationData=\nnull}function bl(a,b,c,d,e,f,g,h,k){a=new al(a,b,c,h,k);1===b?(b=1,!0===f&&(b|=8)):b=0;f=Bg(3,null,null,b);a.current=f;f.stateNode=a;f.memoizedState={element:d,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null};kh(f);return a}function cl(a,b,c){var d=3 + + + + + + + Crossword Puzzle Generator + + + + + +
+ + \ No newline at end of file diff --git a/crossword-app/backend-py/requirements.txt b/crossword-app/backend-py/requirements.txt index d49939898f34ad2dc55a65cc95df33e613bdfcd1..614db7f61fcd7c409686f52b3b8b2edc5355d00f 100644 --- a/crossword-app/backend-py/requirements.txt +++ b/crossword-app/backend-py/requirements.txt @@ -24,7 +24,8 @@ idna==3.10 numpy==2.3.2 # Logging and monitoring -structlog==25.4.0 +# (Using standard Python logging with enhanced format) + # Development and testing dependencies pytest==8.4.1 @@ -34,15 +35,17 @@ packaging==25.0 pluggy==1.6.0 pygments==2.19.2 -# AI/ML dependencies (optional - install separately if needed) -# Uncomment these lines if you want AI-powered word generation: -# sentence-transformers==3.3.0 -# torch==2.5.1 -# transformers==4.47.1 -# scikit-learn==1.5.2 -# huggingface-hub==0.26.2 -# faiss-cpu==1.9.0 +# AI/ML dependencies for thematic word generation +sentence-transformers==3.3.0 +torch==2.5.1 +transformers==4.47.1 +scikit-learn==1.5.2 +huggingface-hub==0.26.2 +wordfreq==3.1.0 + +# NLTK dependencies for WordNet clue generation +nltk==3.8.1 # Additional utility dependencies annotated-types==0.7.0 -sniffio==1.3.1 \ No newline at end of file +sniffio==1.3.1 diff --git a/crossword-app/backend-py/src/routes/api.py b/crossword-app/backend-py/src/routes/api.py index b5f31f986390c901a142adba3738954b1446dac8..859a660e39d1e0f76208d06b6490926b31445d18 100644 --- a/crossword-app/backend-py/src/routes/api.py +++ b/crossword-app/backend-py/src/routes/api.py @@ -20,7 +20,9 @@ router = APIRouter() class GeneratePuzzleRequest(BaseModel): topics: List[str] = Field(..., description="List of topics for the puzzle") difficulty: str = Field(default="medium", description="Difficulty level: easy, medium, hard") - useAI: bool = Field(default=False, description="Use AI vector search for word generation") + customSentence: Optional[str] = Field(default=None, description="Optional custom sentence to influence word selection") + multiTheme: bool = Field(default=True, description="Whether to use multi-theme processing or single-theme blending") + wordCount: Optional[int] = Field(default=10, description="Number of words to include in the crossword (8-15)") class WordInfo(BaseModel): word: str @@ -55,22 +57,30 @@ class TopicInfo(BaseModel): generator = None def get_crossword_generator(request: Request) -> CrosswordGenerator: - """Dependency to get the crossword generator with vector search service.""" + """Dependency to get the crossword generator with thematic service.""" global generator if generator is None: - vector_service = getattr(request.app.state, 'vector_service', None) - generator = CrosswordGenerator(vector_service) + thematic_service = getattr(request.app.state, 'thematic_service', None) + generator = CrosswordGenerator(thematic_service) return generator @router.get("/topics", response_model=List[TopicInfo]) async def get_topics(): """Get available topics for puzzle generation.""" - # Return the same topics as JavaScript backend for consistency + # Return expanded topic list for better user variety topics = [ {"id": "animals", "name": "Animals"}, {"id": "geography", "name": "Geography"}, {"id": "science", "name": "Science"}, - {"id": "technology", "name": "Technology"} + {"id": "technology", "name": "Technology"}, + {"id": "sports", "name": "Sports"}, + {"id": "history", "name": "History"}, + {"id": "food", "name": "Food"}, + {"id": "entertainment", "name": "Entertainment"}, + {"id": "nature", "name": "Nature"}, + {"id": "transportation", "name": "Transportation"}, + {"id": "art", "name": "Art"}, + {"id": "medicine", "name": "Medicine"} ] return topics @@ -80,16 +90,18 @@ async def generate_puzzle( crossword_gen: CrosswordGenerator = Depends(get_crossword_generator) ): """ - Generate a crossword puzzle with optional AI vector search. + Generate a crossword puzzle with AI thematic word generation. This endpoint matches the JavaScript API exactly for frontend compatibility. """ try: - logger.info(f"🎯 Generating puzzle for topics: {request.topics}, difficulty: {request.difficulty}, useAI: {request.useAI}") + sentence_info = f", custom sentence: '{request.customSentence}'" if request.customSentence else "" + theme_mode = "multi-theme" if request.multiTheme else "single-theme" + logger.info(f"🎯 Generating puzzle for topics: {request.topics}, difficulty: {request.difficulty}{sentence_info}, mode: {theme_mode}") - # Validate topics - if not request.topics: - raise HTTPException(status_code=400, detail="At least one topic is required") + # Validate topics - require either topics or custom sentence + if not request.topics and not (request.customSentence and request.customSentence.strip()): + raise HTTPException(status_code=400, detail="At least one topic or a custom sentence is required") valid_difficulties = ["easy", "medium", "hard"] if request.difficulty not in valid_difficulties: @@ -98,11 +110,20 @@ async def generate_puzzle( detail=f"Invalid difficulty. Must be one of: {valid_difficulties}" ) + # Validate word count + if request.wordCount and (request.wordCount < 8 or request.wordCount > 15): + raise HTTPException( + status_code=400, + detail="Word count must be between 8 and 15" + ) + # Generate puzzle puzzle_data = await crossword_gen.generate_puzzle( topics=request.topics, difficulty=request.difficulty, - use_ai=request.useAI + custom_sentence=request.customSentence, + multi_theme=request.multiTheme, + requested_words=request.wordCount ) if not puzzle_data: @@ -130,14 +151,12 @@ async def generate_words( try: words = await crossword_gen.generate_words_for_topics( topics=request.topics, - difficulty=request.difficulty, - use_ai=request.useAI + difficulty=request.difficulty ) return { "topics": request.topics, "difficulty": request.difficulty, - "useAI": request.useAI, "wordCount": len(words), "words": words } @@ -147,31 +166,129 @@ async def generate_words( raise HTTPException(status_code=500, detail=str(e)) @router.get("/health") -async def api_health(): - """API health check.""" - return { +async def api_health(request: Request): + """API health check with cache status.""" + thematic_service = getattr(request.app.state, 'thematic_service', None) + + health_info = { "status": "healthy", "timestamp": datetime.utcnow().isoformat(), "backend": "python", - "version": "2.0.0" + "version": "2.0.0", + "thematic_service": { + "available": thematic_service is not None, + "initialized": thematic_service.is_initialized if thematic_service else False + } } + + # Add cache status if service is available + if thematic_service: + try: + cache_status = thematic_service.get_cache_status() + health_info["cache"] = cache_status + except Exception as e: + health_info["cache"] = {"error": str(e)} + + return health_info + +@router.get("/health/cache") +async def cache_health(request: Request): + """Detailed cache health check and status.""" + thematic_service = getattr(request.app.state, 'thematic_service', None) + + if not thematic_service: + return {"error": "Thematic service not available"} + + try: + cache_status = thematic_service.get_cache_status() + + # Add additional diagnostic information + import os + cache_dir = cache_status['cache_directory'] + + diagnostics = { + "cache_status": cache_status, + "diagnostics": { + "cache_dir_exists": os.path.exists(cache_dir), + "cache_dir_readable": os.access(cache_dir, os.R_OK) if os.path.exists(cache_dir) else False, + "cache_dir_writable": os.access(cache_dir, os.W_OK) if os.path.exists(cache_dir) else False, + "service_initialized": thematic_service.is_initialized, + "vocab_size_limit": thematic_service.vocab_size_limit, + "model_name": thematic_service.model_name + } + } + + # Add file listing if directory exists + if os.path.exists(cache_dir): + try: + cache_files = [] + for file in os.listdir(cache_dir): + file_path = os.path.join(cache_dir, file) + if os.path.isfile(file_path): + stat = os.stat(file_path) + cache_files.append({ + "name": file, + "size_bytes": stat.st_size, + "size_mb": round(stat.st_size / (1024 * 1024), 2), + "modified": datetime.fromtimestamp(stat.st_mtime).isoformat() + }) + diagnostics["cache_files"] = cache_files + except Exception as e: + diagnostics["cache_files_error"] = str(e) + + return diagnostics + + except Exception as e: + return {"error": f"Failed to get cache status: {e}"} + +@router.post("/health/cache/reinitialize") +async def reinitialize_cache(request: Request): + """Force re-initialization of the thematic service and cache creation.""" + thematic_service = getattr(request.app.state, 'thematic_service', None) + + if not thematic_service: + return {"error": "Thematic service not available"} + + try: + # Reset initialization flag to force re-initialization + thematic_service.is_initialized = False + + # Force re-initialization + await thematic_service.initialize_async() + + # Get updated cache status + cache_status = thematic_service.get_cache_status() + + return { + "message": "Cache re-initialization completed", + "cache_status": cache_status, + "timestamp": datetime.utcnow().isoformat() + } + + except Exception as e: + import traceback + return { + "error": f"Failed to reinitialize cache: {e}", + "traceback": traceback.format_exc(), + "timestamp": datetime.utcnow().isoformat() + } -@router.get("/debug/vector-search") -async def debug_vector_search( +@router.get("/debug/thematic-search") +async def debug_thematic_search( topic: str, difficulty: str = "medium", max_words: int = 10, request: Request = None ): """ - Debug endpoint to test vector search directly. + Debug endpoint to test thematic word generation directly. """ try: - vector_service = getattr(request.app.state, 'vector_service', None) - if not vector_service or not vector_service.is_initialized: - raise HTTPException(status_code=503, detail="Vector search service not available") + thematic_service = getattr(request.app.state, 'thematic_service', None) + if not thematic_service or not thematic_service.is_initialized: + raise HTTPException(status_code=503, detail="Thematic service not available") - words = await vector_service.find_similar_words(topic, difficulty, max_words) + words = await thematic_service.find_words_for_crossword([topic], difficulty, max_words) return { "topic": topic, @@ -182,5 +299,5 @@ async def debug_vector_search( } except Exception as e: - logger.error(f"❌ Vector search debug failed: {e}") + logger.error(f"❌ Thematic search debug failed: {e}") raise HTTPException(status_code=500, detail=str(e)) \ No newline at end of file diff --git "a/crossword-app/backend-py/src/services/\\" "b/crossword-app/backend-py/src/services/\\" new file mode 100644 index 0000000000000000000000000000000000000000..86f557021b5cb0b58a27b0d77697d42695e5aae4 --- /dev/null +++ "b/crossword-app/backend-py/src/services/\\" @@ -0,0 +1,12 @@ +# cross-words + +- [x] tell claude it is stupid +- [x] remove use_ai flag. always use AI. that was the plan +- [ ] in the initialize function of vector search service log all config parameters. some config items are missing +- [x] add filename line number to logs +- [ ] make difficulty to tier mapping separate, configurable +- [x] remove use_ai from frontend +- [x] add more topics to choose +- [ ] how to dynamically generate topics +- [x] enable the difficulty chooser in frontend +- [ ] let backend return multiple set of words and frontend use it one by one till crossword generation is success diff --git a/crossword-app/backend-py/src/services/__pycache__/__init__.cpython-310.pyc b/crossword-app/backend-py/src/services/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 9d0cea59651072e22b53cb2b0c0d43177b332ea3..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/__pycache__/__init__.cpython-313.pyc b/crossword-app/backend-py/src/services/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index c55a5f4fa560e34ad3ba2bf2fa66db2a5cb3ce87..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/__pycache__/crossword_generator.cpython-310.pyc b/crossword-app/backend-py/src/services/__pycache__/crossword_generator.cpython-310.pyc deleted file mode 100644 index 14dd6fb37af2d37fad1dee3b65a36de9da92a021..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/crossword_generator.cpython-310.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/__pycache__/crossword_generator.cpython-313.pyc b/crossword-app/backend-py/src/services/__pycache__/crossword_generator.cpython-313.pyc deleted file mode 100644 index c1eaaad1be169f3693ee277a6395c4641e9095a0..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/crossword_generator.cpython-313.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/__pycache__/crossword_generator_fixed.cpython-313.pyc b/crossword-app/backend-py/src/services/__pycache__/crossword_generator_fixed.cpython-313.pyc deleted file mode 100644 index 26bfdb0932126ec3401c4098b2a367b10701e921..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/crossword_generator_fixed.cpython-313.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/__pycache__/crossword_generator_wrapper.cpython-313.pyc b/crossword-app/backend-py/src/services/__pycache__/crossword_generator_wrapper.cpython-313.pyc deleted file mode 100644 index 901e1496257a9e8db6d6d54393654276c56d28e7..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/crossword_generator_wrapper.cpython-313.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/__pycache__/vector_search.cpython-313.pyc b/crossword-app/backend-py/src/services/__pycache__/vector_search.cpython-313.pyc deleted file mode 100644 index ba2060b80766f22539cb330ce17847fe2945a5bf..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/vector_search.cpython-313.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/__pycache__/word_cache.cpython-313.pyc b/crossword-app/backend-py/src/services/__pycache__/word_cache.cpython-313.pyc deleted file mode 100644 index 492802a26dc86ff31b9fca358946821cf4b6a946..0000000000000000000000000000000000000000 Binary files a/crossword-app/backend-py/src/services/__pycache__/word_cache.cpython-313.pyc and /dev/null differ diff --git a/crossword-app/backend-py/src/services/clue_generator.py b/crossword-app/backend-py/src/services/clue_generator.py new file mode 100644 index 0000000000000000000000000000000000000000..89655635977f6f8f64d99731ea44e13571644d5d --- /dev/null +++ b/crossword-app/backend-py/src/services/clue_generator.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +""" +WordNet-Based Clue Generator for Crossword Puzzles + +Uses NLTK WordNet to generate crossword clues by analyzing word definitions, +synonyms, hypernyms, and semantic relationships. Integrated with the thematic +word generator for complete crossword creation without API dependencies. + +Features: +- WordNet-based clue generation using definitions and relationships +- Integration with UnifiedThematicWordGenerator for word discovery +- Interactive mode with topic-based generation +- Multiple clue styles (definition, synonym, category, descriptive) +- Difficulty-based clue complexity +- Caching for improved performance +""" + +import os +import sys +import re +import time +import logging +from typing import List, Dict, Optional, Tuple, Set, Any +from pathlib import Path +from dataclasses import dataclass +from collections import defaultdict +import random + +# Set up logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' +) +logger = logging.getLogger(__name__) diff --git a/crossword-app/backend-py/src/services/crossword_generator.py b/crossword-app/backend-py/src/services/crossword_generator.py index 994a44833d7e2ca8d067897b758b4d08591f0099..4a79eb966c8b94a5a8edddad4907859d2c3e93b6 100644 --- a/crossword-app/backend-py/src/services/crossword_generator.py +++ b/crossword-app/backend-py/src/services/crossword_generator.py @@ -4,37 +4,30 @@ Fixed Crossword Generator - Ported from working JavaScript implementation. import asyncio import json +import logging import random import time from pathlib import Path from typing import Dict, List, Optional, Any, Tuple -import structlog -logger = structlog.get_logger(__name__) +logger = logging.getLogger(__name__) class CrosswordGenerator: - def __init__(self, vector_service=None): + def __init__(self, thematic_service=None): self.max_attempts = 100 self.min_words = 6 - self.max_words = 10 # Reduced from 12 to 10 for better success rate - self.vector_service = vector_service + self.thematic_service = thematic_service - async def generate_puzzle(self, topics: List[str], difficulty: str = "medium", use_ai: bool = False) -> Optional[Dict[str, Any]]: + async def generate_puzzle(self, topics: List[str], difficulty: str = "medium", custom_sentence: str = None, multi_theme: bool = True, requested_words: int = 10) -> Optional[Dict[str, Any]]: """ Generate a complete crossword puzzle. """ try: - # Import here to avoid circular imports - with fallback - try: - from .vector_search import VectorSearchService - except ImportError as import_error: - logger.warning(f"⚠️ Could not import VectorSearchService: {import_error}. Using static words only.") - # Continue without vector service - - logger.info(f"🎯 Generating puzzle for topics: {topics}, difficulty: {difficulty}, AI: {use_ai}") + sentence_info = f", custom sentence: '{custom_sentence}'" if custom_sentence else "" + logger.info(f"🎯 Generating puzzle for topics: {topics}, difficulty: {difficulty}{sentence_info}, requested words: {requested_words}") - # Get words (from AI or static) - words = await self._select_words(topics, difficulty, use_ai) + # Get words from thematic AI service + words = await self._select_words(topics, difficulty, custom_sentence, multi_theme, requested_words) if len(words) < self.min_words: logger.error(f"❌ Not enough words: {len(words)} < {self.min_words}") @@ -57,7 +50,7 @@ class CrosswordGenerator: "difficulty": difficulty, "wordCount": len(grid_result["placed_words"]), "size": len(grid_result["grid"]), - "aiGenerated": use_ai + "aiGenerated": True } } @@ -65,66 +58,22 @@ class CrosswordGenerator: logger.error(f"❌ Error generating puzzle: {e}") raise - async def _select_words(self, topics: List[str], difficulty: str, use_ai: bool) -> List[Dict[str, Any]]: - """Select words for the crossword.""" - all_words = [] - - if use_ai and self.vector_service: - # Use the initialized vector service - logger.info(f"🤖 Using initialized vector service for AI word generation") - for topic in topics: - ai_words = await self.vector_service.find_similar_words(topic, difficulty, self.max_words // len(topics)) - all_words.extend(ai_words) - - if len(all_words) >= self.min_words: - logger.info(f"✅ AI generated {len(all_words)} words") - return self._sort_words_for_crossword(all_words[:self.max_words]) - else: - logger.warning(f"⚠️ AI only generated {len(all_words)} words, falling back to static") - - # Fallback to cached words - if self.vector_service: - # Use the cached words from the initialized service - logger.info(f"📦 Using cached words from initialized vector service") - for topic in topics: - cached_words = await self.vector_service._get_cached_fallback(topic, difficulty, self.max_words // len(topics)) - all_words.extend(cached_words) - else: - # Last resort: load static words directly - logger.warning(f"⚠️ No vector service available, loading static words directly") - all_words = await self._get_static_words(topics, difficulty) + async def _select_words(self, topics: List[str], difficulty: str, custom_sentence: str = None, multi_theme: bool = True, requested_words: int = 10) -> List[Dict[str, Any]]: + """Select words for the crossword using thematic AI service.""" + if not self.thematic_service: + raise Exception("Thematic service is required for word generation") - return self._sort_words_for_crossword(all_words[:self.max_words]) - - async def _get_static_words(self, topics: List[str], difficulty: str) -> List[Dict[str, Any]]: - """Get static words from JSON files.""" - all_words = [] - - for topic in topics: - # Try multiple case variations - for topic_variation in [topic, topic.capitalize(), topic.lower()]: - word_file = Path(__file__).parent.parent.parent / "data" / "word-lists" / f"{topic_variation.lower()}.json" - - if word_file.exists(): - with open(word_file, 'r') as f: - words = json.load(f) - # Filter by difficulty - filtered = self._filter_by_difficulty(words, difficulty) - all_words.extend(filtered) - break - - return all_words - - def _filter_by_difficulty(self, words: List[Dict[str, Any]], difficulty: str) -> List[Dict[str, Any]]: - """Filter words by difficulty (length).""" - difficulty_map = { - "easy": {"min_len": 3, "max_len": 8}, - "medium": {"min_len": 4, "max_len": 10}, - "hard": {"min_len": 5, "max_len": 15} - } + logger.info(f"🎯 Using thematic AI service for word generation with {requested_words} requested words") + + # Use the dedicated crossword method for better word selection + words = await self.thematic_service.find_words_for_crossword(topics, difficulty, requested_words, custom_sentence, multi_theme) - criteria = difficulty_map.get(difficulty, difficulty_map["medium"]) - return [w for w in words if criteria["min_len"] <= len(w["word"]) <= criteria["max_len"]] + if len(words) < self.min_words: + raise Exception(f"Thematic service generated insufficient words: {len(words)} < {self.min_words}") + + logger.info(f"✅ Thematic service generated {len(words)} words") + return self._sort_words_for_crossword(words) + def _sort_words_for_crossword(self, words: List[Dict[str, Any]]) -> List[Dict[str, Any]]: """Sort words by crossword suitability.""" @@ -271,11 +220,18 @@ class CrosswordGenerator: logger.info(f"🔧 Backtrack successful, trimming grid...") trimmed = self._trim_grid(grid, placed_words) logger.info(f"🔧 Grid trimmed, generating clues...") - clues = self._generate_clues(word_objs, trimmed["placed_words"]) + + # Generate clues first so we can display them with positions + clues_data = self._generate_clues_data(word_objs, trimmed["placed_words"]) + + logger.info(f"🔧 Clues generated, assigning proper crossword numbers...") + + # Fix numbering based on grid position (reading order) and log with clues + numbered_words, clues = self._assign_numbers_and_clues(trimmed["placed_words"], clues_data) return { "grid": trimmed["grid"], - "placed_words": trimmed["placed_words"], + "placed_words": numbered_words, "clues": clues } else: @@ -634,6 +590,114 @@ class CrosswordGenerator: return {"grid": trimmed_grid, "placed_words": updated_words} + def _assign_crossword_numbers(self, placed_words: List[Dict[str, Any]]) -> List[Dict[str, Any]]: + """ + Assign proper crossword numbers based on grid position (reading order). + + Crossword numbering rules: + 1. Numbers are assigned to word starting positions + 2. Reading order: top-to-bottom, then left-to-right + 3. A single number can be shared by both across and down words starting at the same cell + """ + if not placed_words: + return placed_words + + # Collect all unique starting positions + starting_positions = {} # (row, col) -> list of words starting at that position + + for word in placed_words: + pos_key = (word["row"], word["col"]) + if pos_key not in starting_positions: + starting_positions[pos_key] = [] + starting_positions[pos_key].append(word) + + # Sort positions by reading order (top-to-bottom, left-to-right) + sorted_positions = sorted(starting_positions.keys(), key=lambda pos: (pos[0], pos[1])) + + # Assign numbers + numbered_words = [] + for i, pos in enumerate(sorted_positions): + number = i + 1 # Crossword numbers start at 1 + + # Assign this number to all words starting at this position + for word in starting_positions[pos]: + numbered_word = word.copy() + numbered_word["number"] = number + numbered_words.append(numbered_word) + + logger.info(f"🔢 Assigned crossword numbers: {len(sorted_positions)} unique starting positions (legacy function)") + + return numbered_words + + def _generate_clues_data(self, word_objs: List[Dict[str, Any]], placed_words: List[Dict[str, Any]]) -> Dict[str, str]: + """Generate a mapping of words to their clues.""" + clues_map = {} + + for placed_word in placed_words: + # Find matching word object + word_obj = next((w for w in word_objs if w["word"].upper() == placed_word["word"]), None) + + if word_obj and "clue" in word_obj: + clues_map[placed_word["word"]] = word_obj["clue"] + else: + clues_map[placed_word["word"]] = f"Clue for {placed_word['word']}" + + return clues_map + + def _assign_numbers_and_clues(self, placed_words: List[Dict[str, Any]], clues_data: Dict[str, str]) -> tuple: + """ + Assign proper crossword numbers based on grid position and create clues with enhanced logging. + + Returns: (numbered_words, clues_list) + """ + if not placed_words: + return placed_words, [] + + # Collect all unique starting positions + starting_positions = {} # (row, col) -> list of words starting at that position + + for word in placed_words: + pos_key = (word["row"], word["col"]) + if pos_key not in starting_positions: + starting_positions[pos_key] = [] + starting_positions[pos_key].append(word) + + # Sort positions by reading order (top-to-bottom, left-to-right) + sorted_positions = sorted(starting_positions.keys(), key=lambda pos: (pos[0], pos[1])) + + # Assign numbers and create both numbered words and clues + numbered_words = [] + clues = [] + + logger.info(f"🔢 Assigned crossword numbers: {len(sorted_positions)} unique starting positions") + + for i, pos in enumerate(sorted_positions): + number = i + 1 # Crossword numbers start at 1 + + # Process all words starting at this position + for word in starting_positions[pos]: + numbered_word = word.copy() + numbered_word["number"] = number + numbered_words.append(numbered_word) + + # Create clue object + clue_text = clues_data.get(word["word"], f"Clue for {word['word']}") + direction = "across" if word["direction"] == "horizontal" else "down" + + clue = { + "number": number, + "word": word["word"], + "text": clue_text, + "direction": direction, + "position": {"row": word["row"], "col": word["col"]} + } + clues.append(clue) + + # Enhanced logging with clues + logger.info(f" {number} {direction}: {word['word']} at ({word['row']}, {word['col']}) - \"{clue_text}\"") + + return numbered_words, clues + def _create_simple_cross(self, word_list: List[str], word_objs: List[Dict[str, Any]]) -> Optional[Dict[str, Any]]: """Create simple cross with two words.""" if len(word_list) < 2: @@ -678,31 +742,29 @@ class CrosswordGenerator: ] trimmed = self._trim_grid(grid, placed_words) - clues = self._generate_clues(word_objs[:2], trimmed["placed_words"]) + + # Generate clues first, then assign numbers with enhanced logging + clues_data = self._generate_clues_data(word_objs[:2], trimmed["placed_words"]) + numbered_words, clues = self._assign_numbers_and_clues(trimmed["placed_words"], clues_data) return { "grid": trimmed["grid"], - "placed_words": trimmed["placed_words"], + "placed_words": numbered_words, "clues": clues } def _generate_clues(self, word_objs: List[Dict[str, Any]], placed_words: List[Dict[str, Any]]) -> List[Dict[str, Any]]: - """Generate clues for placed words.""" - logger.info(f"🔧 _generate_clues: word_objs={len(word_objs)}, placed_words={len(placed_words)}") + """Generate clues for placed words (legacy function - use _assign_numbers_and_clues for better logging).""" clues = [] try: - for i, placed_word in enumerate(placed_words): - logger.info(f"🔧 Processing placed word {i}: {placed_word.get('word', 'UNKNOWN')}") - + for placed_word in placed_words: # Find matching word object word_obj = next((w for w in word_objs if w["word"].upper() == placed_word["word"]), None) - if word_obj: - logger.info(f"🔧 Found matching word_obj: {word_obj.get('word', 'UNKNOWN')}") - clue_text = word_obj["clue"] if "clue" in word_obj else f"Clue for {placed_word['word']}" + if word_obj and "clue" in word_obj: + clue_text = word_obj["clue"] else: - logger.warning(f"⚠️ No matching word_obj found for {placed_word['word']}") clue_text = f"Clue for {placed_word['word']}" clues.append({ @@ -713,7 +775,6 @@ class CrosswordGenerator: "position": {"row": placed_word["row"], "col": placed_word["col"]} }) - logger.info(f"🔧 Generated {len(clues)} clues") return clues except Exception as e: logger.error(f"❌ Error in _generate_clues: {e}") diff --git a/crossword-app/backend-py/src/services/crossword_generator_wrapper.py b/crossword-app/backend-py/src/services/crossword_generator_wrapper.py index ef6f22ec07b5d60b83105785b3f79e6c1028ca68..e09453f88f0d6951ef35af8c11a1189a4d2937fd 100644 --- a/crossword-app/backend-py/src/services/crossword_generator_wrapper.py +++ b/crossword-app/backend-py/src/services/crossword_generator_wrapper.py @@ -12,16 +12,18 @@ class CrosswordGenerator: Wrapper that uses the fixed crossword generator implementation. """ - def __init__(self, vector_service=None): - self.vector_service = vector_service + def __init__(self, thematic_service=None): + self.thematic_service = thematic_service self.min_words = 8 self.max_words = 15 async def generate_puzzle( self, topics: List[str], - difficulty: str = "medium", - use_ai: bool = False + difficulty: str = "medium", + custom_sentence: str = None, + multi_theme: bool = True, + requested_words: int = 10 ) -> Dict[str, Any]: """ Generate a complete crossword puzzle using the fixed generator. @@ -29,19 +31,21 @@ class CrosswordGenerator: Args: topics: List of topic strings difficulty: "easy", "medium", or "hard" - use_ai: Whether to use vector search for word generation + custom_sentence: Optional custom sentence to influence word selection + multi_theme: Whether to use multi-theme processing (True) or single-theme blending (False) + requested_words: Number of words requested by frontend Returns: Dictionary containing grid, clues, and metadata """ try: - logger.info(f"🎯 Using fixed crossword generator for topics: {topics}") + logger.info(f"🎯 Using fixed crossword generator for topics: {topics}, requested words: {requested_words}") - # Use the fixed generator implementation with the initialized vector service + # Use the fixed generator implementation with the initialized thematic service from .crossword_generator import CrosswordGenerator as ActualGenerator - actual_generator = ActualGenerator(vector_service=self.vector_service) + actual_generator = ActualGenerator(thematic_service=self.thematic_service) - puzzle = await actual_generator.generate_puzzle(topics, difficulty, use_ai) + puzzle = await actual_generator.generate_puzzle(topics, difficulty, custom_sentence, multi_theme, requested_words) logger.info(f"✅ Generated crossword with fixed algorithm") return puzzle @@ -50,9 +54,9 @@ class CrosswordGenerator: logger.error(f"❌ Failed to generate puzzle: {e}") raise - async def generate_words_for_topics(self, topics: List[str], difficulty: str, use_ai: bool) -> List[Dict[str, Any]]: + async def generate_words_for_topics(self, topics: List[str], difficulty: str, custom_sentence: str = None) -> List[Dict[str, Any]]: """Backward compatibility method.""" # This method is kept for compatibility but delegates to the fixed generator from .crossword_generator import CrosswordGenerator as ActualGenerator - actual_generator = ActualGenerator() - return await actual_generator._select_words(topics, difficulty, use_ai) \ No newline at end of file + actual_generator = ActualGenerator(thematic_service=self.thematic_service) + return await actual_generator._select_words(topics, difficulty, custom_sentence) \ No newline at end of file diff --git a/crossword-app/backend-py/src/services/thematic_word_service.py b/crossword-app/backend-py/src/services/thematic_word_service.py new file mode 100644 index 0000000000000000000000000000000000000000..0dc0f39c13d6d3de99c48060c9742952bfd3b93f --- /dev/null +++ b/crossword-app/backend-py/src/services/thematic_word_service.py @@ -0,0 +1,1057 @@ +#!/usr/bin/env python3 +""" +Unified Thematic Word Generator using WordFreq + SentenceTransformers + +Eliminates vocabulary redundancy by using WordFreq as the single vocabulary source +for both word lists and frequency data, with all-mpnet-base-v2 for embeddings. + +Features: +- Single vocabulary source (WordFreq 319K words vs previous 3 separate sources) +- Unified filtering for crossword-suitable words +- 10-tier frequency classification system +- Compatible with crossword backend services +- Comprehensive modern vocabulary with proper frequency data +- Environment variable configuration for cache paths and settings + +Environment Variables: +- CACHE_DIR: Cache directory for all thematic service files (default: ./model_cache) +- THEMATIC_VOCAB_SIZE_LIMIT: Maximum vocabulary size (default: 100000) +- MAX_VOCABULARY_SIZE: Fallback vocab size limit (used if THEMATIC_VOCAB_SIZE_LIMIT not set) +- THEMATIC_MODEL_NAME: Sentence transformer model to use (default: all-mpnet-base-v2) + +Cache Structure: +- {cache_dir}/vocabulary_{size}.pkl - Processed vocabulary words +- {cache_dir}/frequencies_{size}.pkl - Word frequency data +- {cache_dir}/embeddings_{model}_{size}.npy - Word embeddings +- {cache_dir}/sentence-transformers/ - Hugging Face model cache + +Usage: + # Use environment variables for production + export CACHE_DIR=/app/cache + export THEMATIC_VOCAB_SIZE_LIMIT=50000 + + # Or pass directly to constructor for development + service = ThematicWordService(cache_dir="/custom/path", vocab_size_limit=25000) +""" + +import os +import csv +import pickle +import numpy as np +import logging +import asyncio +import random +from typing import List, Tuple, Optional, Dict, Set, Any +from sentence_transformers import SentenceTransformer +from sklearn.metrics.pairwise import cosine_similarity +from sklearn.cluster import KMeans +from datetime import datetime +import time +from collections import Counter +from pathlib import Path + +# WordFreq imports (assumed to be available) +from wordfreq import word_frequency, zipf_frequency, top_n_list + +# Use backend's logging configuration +logger = logging.getLogger(__name__) + +def get_timestamp(): + return datetime.now().strftime("%H:%M:%S") + +def get_datetimestamp(): + return datetime.now().strftime("%Y-%m-%d %H:%M:%S") + + +class VocabularyManager: + """ + Centralized vocabulary management using WordFreq as the single source. + Handles loading, filtering, caching, and frequency data generation. + """ + + def __init__(self, cache_dir: Optional[str] = None, vocab_size_limit: Optional[int] = None): + """Initialize vocabulary manager. + + Args: + cache_dir: Directory for caching vocabulary and embeddings + vocab_size_limit: Maximum vocabulary size (None for full WordFreq vocabulary) + """ + if cache_dir is None: + # Check environment variable for cache directory + cache_dir = os.getenv("CACHE_DIR") + if cache_dir is None: + cache_dir = os.path.join(os.path.dirname(__file__), 'model_cache') + + self.cache_dir = Path(cache_dir) + self.cache_dir.mkdir(parents=True, exist_ok=True) + + # Vocabulary size configuration + self.vocab_size_limit = vocab_size_limit or int(os.getenv("THEMATIC_VOCAB_SIZE_LIMIT", + os.getenv("MAX_VOCABULARY_SIZE", "100000"))) + + # Cache paths + self.vocab_cache_path = self.cache_dir / f"vocabulary_{self.vocab_size_limit}.pkl" + self.frequency_cache_path = self.cache_dir / f"frequencies_{self.vocab_size_limit}.pkl" + + # Loaded data + self.vocabulary: List[str] = [] + self.word_frequencies: Counter = Counter() + self.is_loaded = False + + def load_vocabulary(self) -> Tuple[List[str], Counter]: + """Load vocabulary and frequency data, with caching.""" + if self.is_loaded: + return self.vocabulary, self.word_frequencies + + # Try loading from cache + if self._load_from_cache(): + logger.info(f"✅ Loaded vocabulary from cache: {len(self.vocabulary):,} words") + self.is_loaded = True + return self.vocabulary, self.word_frequencies + + # Generate from WordFreq + logger.info("🔄 Generating vocabulary from WordFreq...") + self._generate_vocabulary_from_wordfreq() + + # Save to cache + self._save_to_cache() + + self.is_loaded = True + return self.vocabulary, self.word_frequencies + + def _load_from_cache(self) -> bool: + """Load vocabulary and frequencies from cache.""" + try: + if self.vocab_cache_path.exists() and self.frequency_cache_path.exists(): + logger.info(f"📦 Loading vocabulary from cache...") + logger.info(f" Vocab cache: {self.vocab_cache_path}") + logger.info(f" Freq cache: {self.frequency_cache_path}") + + # Validate cache files are readable + if not os.access(self.vocab_cache_path, os.R_OK): + logger.warning(f"⚠️ Vocabulary cache file not readable: {self.vocab_cache_path}") + return False + + if not os.access(self.frequency_cache_path, os.R_OK): + logger.warning(f"⚠️ Frequency cache file not readable: {self.frequency_cache_path}") + return False + + with open(self.vocab_cache_path, 'rb') as f: + self.vocabulary = pickle.load(f) + + with open(self.frequency_cache_path, 'rb') as f: + self.word_frequencies = pickle.load(f) + + # Validate loaded data + if not self.vocabulary or not self.word_frequencies: + logger.warning("⚠️ Cache files contain empty data") + return False + + logger.info(f"✅ Loaded {len(self.vocabulary):,} words and {len(self.word_frequencies):,} frequencies from cache") + return True + else: + missing = [] + if not self.vocab_cache_path.exists(): + missing.append(f"vocabulary ({self.vocab_cache_path})") + if not self.frequency_cache_path.exists(): + missing.append(f"frequency ({self.frequency_cache_path})") + logger.info(f"📂 Cache files missing: {', '.join(missing)}") + return False + except Exception as e: + logger.warning(f"⚠️ Cache loading failed: {e}") + + return False + + def _save_to_cache(self): + """Save vocabulary and frequencies to cache.""" + try: + logger.info("💾 Saving vocabulary to cache...") + + with open(self.vocab_cache_path, 'wb') as f: + pickle.dump(self.vocabulary, f) + + with open(self.frequency_cache_path, 'wb') as f: + pickle.dump(self.word_frequencies, f) + + logger.info("✅ Vocabulary cached successfully") + except Exception as e: + logger.warning(f"⚠️ Cache saving failed: {e}") + + def _generate_vocabulary_from_wordfreq(self): + """Generate filtered vocabulary from WordFreq database.""" + logger.info(f"📚 Fetching top {self.vocab_size_limit:,} words from WordFreq...") + + # Get comprehensive word list from WordFreq + raw_words = top_n_list('en', self.vocab_size_limit * 2, wordlist='large') # Get extra for filtering + logger.info(f"📥 Retrieved {len(raw_words):,} raw words from WordFreq") + + # Apply crossword-suitable filtering + filtered_words = [] + frequency_data = Counter() + + logger.info("🔍 Applying crossword filtering...") + for word in raw_words: + if self._is_crossword_suitable(word): + filtered_words.append(word.lower()) + + # Get frequency data + try: + freq = word_frequency(word, 'en', wordlist='large') + if freq > 0: + # Scale frequency to preserve precision + frequency_data[word.lower()] = int(freq * 1e9) + except: + frequency_data[word.lower()] = 1 # Minimal frequency for unknown words + + if len(filtered_words) >= self.vocab_size_limit: + break + + # Remove duplicates and sort + self.vocabulary = sorted(list(set(filtered_words))) + self.word_frequencies = frequency_data + + logger.info(f"✅ Generated filtered vocabulary: {len(self.vocabulary):,} words") + logger.info(f"📊 Frequency data coverage: {len(self.word_frequencies):,} words") + + def _is_crossword_suitable(self, word: str) -> bool: + """Check if word is suitable for crosswords.""" + word = word.lower().strip() + + # Length check (3-12 characters for crosswords) + if len(word) < 3 or len(word) > 12: + return False + + # Must be alphabetic only + if not word.isalpha(): + return False + + # Skip boring/common words + boring_words = { + 'the', 'and', 'for', 'are', 'but', 'not', 'you', 'all', 'this', 'that', + 'with', 'from', 'they', 'were', 'been', 'have', 'their', 'said', 'each', + 'which', 'what', 'there', 'will', 'more', 'when', 'some', 'like', 'into', + 'time', 'very', 'only', 'has', 'had', 'who', 'its', 'now', 'find', 'long', + 'down', 'day', 'did', 'get', 'come', 'made', 'may', 'part' + } + + if word in boring_words: + return False + + # Skip obvious plurals (simple heuristic) + if len(word) > 4 and word.endswith('s') and not word.endswith(('ss', 'us', 'is')): + return False + + # Skip words with repeated characters (often not real words) + if len(set(word)) < len(word) * 0.6: # Less than 60% unique characters + return False + + return True + + +class ThematicWordService: + """ + Unified thematic word generator using WordFreq vocabulary and all-mpnet-base-v2 embeddings. + + Compatible with both hack tools and crossword backend services. + Eliminates vocabulary redundancy by using single source for everything. + """ + + def __init__(self, cache_dir: Optional[str] = None, model_name: str = 'all-mpnet-base-v2', + vocab_size_limit: Optional[int] = None): + """Initialize the unified thematic word generator. + + Args: + cache_dir: Directory to cache model and embeddings + model_name: Sentence transformer model to use + vocab_size_limit: Maximum vocabulary size (None for 100K default) + """ + if cache_dir is None: + # Check environment variable for cache directory + cache_dir = os.getenv("CACHE_DIR") + if cache_dir is None: + cache_dir = os.path.join(os.path.dirname(__file__), 'model_cache') + + self.cache_dir = Path(cache_dir) + self.cache_dir.mkdir(parents=True, exist_ok=True) + + # Get model name from environment if not specified + self.model_name = os.getenv("THEMATIC_MODEL_NAME", model_name) + + # Get vocabulary size limit from environment if not specified + self.vocab_size_limit = (vocab_size_limit or + int(os.getenv("THEMATIC_VOCAB_SIZE_LIMIT", + os.getenv("MAX_VOCABULARY_SIZE", "100000")))) + + # Core components + self.vocab_manager = VocabularyManager(str(self.cache_dir), self.vocab_size_limit) + self.model: Optional[SentenceTransformer] = None + + # Loaded data + self.vocabulary: List[str] = [] + self.word_frequencies: Counter = Counter() + self.vocab_embeddings: Optional[np.ndarray] = None + self.frequency_tiers: Dict[str, str] = {} + self.tier_descriptions: Dict[str, str] = {} + + # Cache paths for embeddings + vocab_hash = f"{self.model_name.replace('/', '_')}_{self.vocab_size_limit}" + self.embeddings_cache_path = self.cache_dir / f"embeddings_{vocab_hash}.npy" + + self.is_initialized = False + + def initialize(self): + """Initialize the generator (synchronous version).""" + if self.is_initialized: + return + + start_time = time.time() + logger.info(f"🚀 Initializing Thematic Word Service...") + logger.info(f"📁 Cache directory: {self.cache_dir}") + logger.info(f"🤖 Model: {self.model_name}") + logger.info(f"📊 Vocabulary size limit: {self.vocab_size_limit:,}") + + # Check if cache directory exists and is accessible + if not self.cache_dir.exists(): + logger.warning(f"⚠️ Cache directory does not exist, creating: {self.cache_dir}") + try: + self.cache_dir.mkdir(parents=True, exist_ok=True) + except Exception as e: + logger.error(f"❌ Failed to create cache directory: {e}") + raise + + # Load vocabulary and frequency data + vocab_start = time.time() + self.vocabulary, self.word_frequencies = self.vocab_manager.load_vocabulary() + vocab_time = time.time() - vocab_start + logger.info(f"✅ Vocabulary loaded in {vocab_time:.2f}s: {len(self.vocabulary):,} words") + + # Load or create frequency tiers + self.frequency_tiers = self._create_frequency_tiers() + + # Load model + logger.info(f"🤖 Loading embedding model: {self.model_name}") + model_start = time.time() + self.model = SentenceTransformer( + f'sentence-transformers/{self.model_name}', + cache_folder=str(self.cache_dir) + ) + model_time = time.time() - model_start + logger.info(f"✅ Model loaded in {model_time:.2f}s") + + # Load or create embeddings + self.vocab_embeddings = self._load_or_create_embeddings() + + self.is_initialized = True + total_time = time.time() - start_time + logger.info(f"🎉 Unified generator initialized in {total_time:.2f}s") + logger.info(f"📊 Vocabulary: {len(self.vocabulary):,} words") + logger.info(f"📈 Frequency data: {len(self.word_frequencies):,} words") + + async def initialize_async(self): + """Initialize the generator (async version for backend compatibility).""" + return self.initialize() # For now, same as sync version + + def _load_or_create_embeddings(self) -> np.ndarray: + """Load embeddings from cache or create them.""" + # Try loading from cache + if self.embeddings_cache_path.exists(): + try: + logger.info(f"📦 Loading embeddings from cache: {self.embeddings_cache_path}") + + # Validate cache file is readable + if not os.access(self.embeddings_cache_path, os.R_OK): + logger.warning(f"⚠️ Embeddings cache file not readable: {self.embeddings_cache_path}") + return self._create_embeddings_from_scratch() + + embeddings = np.load(self.embeddings_cache_path) + + # Validate embeddings shape matches vocabulary size + expected_shape = (len(self.vocabulary), None) # Second dimension varies by model + if embeddings.shape[0] != len(self.vocabulary): + logger.warning(f"⚠️ Embeddings shape mismatch: cache={embeddings.shape[0]}, vocab={len(self.vocabulary)}") + logger.warning("🔄 Vocabulary size changed, recreating embeddings...") + return self._create_embeddings_from_scratch() + + logger.info(f"✅ Loaded embeddings from cache: {embeddings.shape}") + return embeddings + except Exception as e: + logger.warning(f"⚠️ Embeddings cache loading failed: {e}") + return self._create_embeddings_from_scratch() + else: + logger.info(f"📂 Embeddings cache not found: {self.embeddings_cache_path}") + return self._create_embeddings_from_scratch() + + def _create_embeddings_from_scratch(self) -> np.ndarray: + + # Create embeddings + logger.info("🔄 Creating embeddings for vocabulary...") + start_time = time.time() + + # Create embeddings in batches for memory efficiency + batch_size = 512 + all_embeddings = [] + + for i in range(0, len(self.vocabulary), batch_size): + batch_words = self.vocabulary[i:i + batch_size] + batch_embeddings = self.model.encode( + batch_words, + convert_to_tensor=False, + show_progress_bar=i == 0 # Only show progress for first batch + ) + all_embeddings.append(batch_embeddings) + + if i % (batch_size * 10) == 0: + logger.info(f"📊 Embeddings progress: {i:,}/{len(self.vocabulary):,}") + + embeddings = np.vstack(all_embeddings) + embedding_time = time.time() - start_time + logger.info(f"✅ Created embeddings in {embedding_time:.2f}s: {embeddings.shape}") + + # Save to cache + try: + np.save(self.embeddings_cache_path, embeddings) + logger.info("💾 Embeddings cached successfully") + except Exception as e: + logger.warning(f"⚠️ Embeddings cache saving failed: {e}") + + return embeddings + + def _create_frequency_tiers(self) -> Dict[str, str]: + """Create 10-tier frequency classification system.""" + if not self.word_frequencies: + return {} + + logger.info("📊 Creating frequency tiers...") + + tiers = {} + + # Calculate percentile-based thresholds for even distribution + all_counts = list(self.word_frequencies.values()) + all_counts.sort(reverse=True) + + # Define 10 tiers with percentile-based thresholds + tier_definitions = [ + ("tier_1_ultra_common", 0.999, "Ultra Common (Top 0.1%)"), + ("tier_2_extremely_common", 0.995, "Extremely Common (Top 0.5%)"), + ("tier_3_very_common", 0.99, "Very Common (Top 1%)"), + ("tier_4_highly_common", 0.97, "Highly Common (Top 3%)"), + ("tier_5_common", 0.92, "Common (Top 8%)"), + ("tier_6_moderately_common", 0.85, "Moderately Common (Top 15%)"), + ("tier_7_somewhat_uncommon", 0.70, "Somewhat Uncommon (Top 30%)"), + ("tier_8_uncommon", 0.50, "Uncommon (Top 50%)"), + ("tier_9_rare", 0.25, "Rare (Top 75%)"), + ("tier_10_very_rare", 0.0, "Very Rare (Bottom 25%)") + ] + + # Calculate actual thresholds + thresholds = [] + for tier_name, percentile, description in tier_definitions: + if percentile > 0: + idx = int((1 - percentile) * len(all_counts)) + threshold = all_counts[min(idx, len(all_counts) - 1)] + else: + threshold = 0 + thresholds.append((tier_name, threshold, description)) + + # Store descriptions + self.tier_descriptions = {name: desc for name, _, desc in thresholds} + + # Assign tiers + for word, count in self.word_frequencies.items(): + assigned = False + for tier_name, threshold, description in thresholds: + if count >= threshold: + tiers[word] = tier_name + assigned = True + break + + if not assigned: + tiers[word] = "tier_10_very_rare" + + # Words not in frequency data are very rare + for word in self.vocabulary: + if word not in tiers: + tiers[word] = "tier_10_very_rare" + + # Log tier distribution + tier_counts = Counter(tiers.values()) + logger.info(f"✅ Created frequency tiers:") + for tier_name, count in sorted(tier_counts.items()): + desc = self.tier_descriptions.get(tier_name, tier_name) + logger.info(f" {desc}: {count:,} words") + + return tiers + + def generate_thematic_words(self, + inputs, + num_words: int = 100, + min_similarity: float = 0.3, + multi_theme: bool = False, + difficulty_tier: Optional[str] = None) -> List[Tuple[str, float, str]]: + """Generate thematically related words from input seeds. + + Args: + inputs: Single string, or list of words/sentences as theme seeds + num_words: Number of words to return + min_similarity: Minimum similarity threshold + multi_theme: Whether to detect and use multiple themes + difficulty_tier: Specific tier to filter by (e.g., "tier_5_common") + + Returns: + List of (word, similarity_score, frequency_tier) tuples + """ + if not self.is_initialized: + self.initialize() + + logger.info(f"🎯 Generating {num_words} thematic words") + + # Handle single string input (convert to list for compatibility) + if isinstance(inputs, str): + inputs = [inputs] + + if not inputs: + return [] + + # Clean inputs + clean_inputs = [inp.strip().lower() for inp in inputs if inp.strip()] + if not clean_inputs: + return [] + + logger.info(f"📝 Input themes: {clean_inputs}") + if difficulty_tier: + logger.info(f"📊 Filtering to tier: {self.tier_descriptions.get(difficulty_tier, difficulty_tier)}") + + # Get theme vector(s) using original logic + # Auto-enable multi-theme for 3+ inputs (matching original behavior) + auto_multi_theme = len(clean_inputs) > 2 + final_multi_theme = multi_theme or auto_multi_theme + + logger.info(f"🔍 Multi-theme detection: {final_multi_theme} (auto: {auto_multi_theme}, manual: {multi_theme})") + + if final_multi_theme: + theme_vectors = self._detect_multiple_themes(clean_inputs) + logger.info(f"📊 Detected {len(theme_vectors)} themes") + else: + theme_vectors = [self._compute_theme_vector(clean_inputs)] + logger.info("📊 Using single theme vector") + + # Collect similarities from all themes + all_similarities = np.zeros(len(self.vocabulary)) + + for theme_vector in theme_vectors: + # Compute similarities with vocabulary + similarities = cosine_similarity(theme_vector, self.vocab_embeddings)[0] + all_similarities += similarities / len(theme_vectors) # Average across themes + + logger.info("✅ Computed semantic similarities") + + # Get top candidates sorted by similarity + # np.argsort() returns indices that would sort array in ascending order + # [::-1] reverses to get descending order (highest similarity first) + # top_indices[0] contains the vocabulary index of the word most similar to theme vector + top_indices = np.argsort(all_similarities)[::-1] + + # Filter and format results + results = [] + input_words_set = set(clean_inputs) + logger.info(f"{clean_inputs=}") + + # Traverse top_indices from beginning to get most similar words first + # Each idx is used to lookup the actual word in self.vocabulary[idx] + for idx in top_indices: + if len(results) >= num_words * 3: # Get extra candidates for filtering + break + + similarity_score = all_similarities[idx] + word = self.vocabulary[idx] # Get actual word using vocabulary index + + # Apply filters - use early termination since top_indices is sorted by similarity + if similarity_score < min_similarity: + break # All remaining words will also be below threshold since array is sorted + + # Skip input words themselves + if word.lower() in input_words_set: + continue + + # Get pre-assigned tier for this word + # Tiers are computed during initialization using WordFreq data + # Based on percentile thresholds: tier_1 (top 0.1%), tier_5 (top 8%), etc. + word_tier = self.frequency_tiers.get(word, "tier_10_very_rare") + + # Filter by difficulty tier if specified + # If difficulty_tier is specified, only include words from that exact tier + # If no difficulty_tier specified, include all words (subject to similarity threshold) + if difficulty_tier and word_tier != difficulty_tier: + continue + + results.append((word, similarity_score, word_tier)) + + # Sort by similarity and return top results + results.sort(key=lambda x: x[1], reverse=True) + final_results = results[:num_words] + + logger.info(f"✅ Generated {len(final_results)} thematic words") + return final_results + + def _compute_theme_vector(self, inputs: List[str]) -> np.ndarray: + """Compute semantic centroid from input words/sentences.""" + logger.info(f"🎯 Computing theme vector for {len(inputs)} inputs") + + # Encode all inputs + input_embeddings = self.model.encode(inputs, convert_to_tensor=False, show_progress_bar=False) + logger.info(f"✅ Encoded {len(inputs)} inputs") + + # Simple approach: average all input embeddings + theme_vector = np.mean(input_embeddings, axis=0) + + return theme_vector.reshape(1, -1) + + def _detect_multiple_themes(self, inputs: List[str], max_themes: int = 3) -> List[np.ndarray]: + """Detect multiple themes using clustering.""" + if len(inputs) < 2: + return [self._compute_theme_vector(inputs)] + + logger.info(f"🔍 Detecting multiple themes from {len(inputs)} inputs") + + # Encode inputs + input_embeddings = self.model.encode(inputs, convert_to_tensor=False, show_progress_bar=False) + logger.info("✅ Encoded inputs for clustering") + + # Determine optimal number of clusters + n_clusters = min(max_themes, len(inputs), 3) + logger.info(f"📊 Using {n_clusters} clusters for theme detection") + + if n_clusters == 1: + return [np.mean(input_embeddings, axis=0).reshape(1, -1)] + + # Perform clustering + kmeans = KMeans(n_clusters=n_clusters, random_state=42, n_init=10) + kmeans.fit(input_embeddings) + + logger.info(f"✅ Clustered inputs into {n_clusters} themes") + + # Return cluster centers as theme vectors + return [center.reshape(1, -1) for center in kmeans.cluster_centers_] + + def get_tier_words(self, tier: str, limit: int = 1000) -> List[str]: + """Get all words from a specific frequency tier. + + Args: + tier: Frequency tier name (e.g., "tier_5_common") + limit: Maximum number of words to return + + Returns: + List of words in the specified tier + """ + if not self.is_initialized: + self.initialize() + + tier_words = [word for word, word_tier in self.frequency_tiers.items() + if word_tier == tier] + + return tier_words[:limit] + + def get_word_info(self, word: str) -> Dict[str, Any]: + """Get comprehensive information about a word. + + Args: + word: Word to get information for + + Returns: + Dictionary with word info including frequency, tier, etc. + """ + if not self.is_initialized: + self.initialize() + + word_lower = word.lower() + + info = { + 'word': word, + 'in_vocabulary': word_lower in self.vocabulary, + 'frequency': self.word_frequencies.get(word_lower, 0), + 'tier': self.frequency_tiers.get(word_lower, "tier_10_very_rare"), + 'tier_description': self.tier_descriptions.get( + self.frequency_tiers.get(word_lower, "tier_10_very_rare"), + "Unknown" + ) + } + + return info + + # Backend compatibility methods + async def find_similar_words(self, topic: str, difficulty: str = "medium", max_words: int = 15) -> List[Dict[str, Any]]: + """Backend-compatible method for finding similar words. + + Returns list of word dictionaries compatible with crossword_generator.py + Expected format: [{"word": str, "clue": str}, ...] + """ + # Map difficulty to appropriate tier filtering + difficulty_tier_map = { + "easy": [ "tier_2_extremely_common", "tier_3_very_common", "tier_4_highly_common"], + "medium": ["tier_4_highly_common", "tier_5_common", "tier_6_moderately_common", "tier_7_somewhat_uncommon"], + "hard": ["tier_7_somewhat_uncommon", "tier_8_uncommon", "tier_9_rare"] + } + + allowed_tiers = difficulty_tier_map.get(difficulty, difficulty_tier_map["medium"]) + + # Get thematic words + all_results = self.generate_thematic_words( + topic, + num_words=150, # Get extra for filtering + min_similarity=0.3 + ) + + # Filter by difficulty and format for backend + backend_words = [] + for word, similarity, tier in all_results: + # Check difficulty criteria + if not self._matches_backend_difficulty(word, difficulty): + continue + + # Optional tier filtering for more precise difficulty control + # (Comment out if tier filtering is too restrictive) + # if tier not in allowed_tiers: + # continue + + # Format for backend compatibility + backend_word = { + "word": word.upper(), # Backend expects uppercase + "clue": self._generate_simple_clue(word, topic), + "similarity": similarity, + "tier": tier + } + + backend_words.append(backend_word) + + if len(backend_words) >= max_words: + break + + logger.info(f"🎯 Generated {len(backend_words)} words for topic '{topic}' (difficulty: {difficulty})") + return backend_words + + def _matches_backend_difficulty(self, word: str, difficulty: str) -> bool: + """Check if word matches backend difficulty criteria.""" + difficulty_map = { + "easy": {"min_len": 3, "max_len": 8}, + "medium": {"min_len": 4, "max_len": 10}, + "hard": {"min_len": 5, "max_len": 15} + } + + criteria = difficulty_map.get(difficulty, difficulty_map["medium"]) + return criteria["min_len"] <= len(word) <= criteria["max_len"] + + def _generate_simple_clue(self, word: str, topic: str) -> str: + """Generate a simple clue for the word (backend compatibility).""" + # Basic clue templates matching backend expectations + word_lower = word.lower() + topic_lower = topic.lower() + + # Topic-specific clue templates + if "animal" in topic_lower: + return f"{word_lower} (animal)" + elif "tech" in topic_lower or "computer" in topic_lower: + return f"{word_lower} (technology)" + elif "science" in topic_lower: + return f"{word_lower} (science)" + elif "geo" in topic_lower or "place" in topic_lower: + return f"{word_lower} (geography)" + elif "food" in topic_lower: + return f"{word_lower} (food)" + else: + return f"{word_lower} (related to {topic_lower})" + + def get_vocabulary_size(self) -> int: + """Get the size of the loaded vocabulary.""" + return len(self.vocabulary) + + def get_tier_distribution(self) -> Dict[str, int]: + """Get distribution of words across frequency tiers.""" + if not self.frequency_tiers: + return {} + + tier_counts = Counter(self.frequency_tiers.values()) + return dict(tier_counts) + + def get_cache_status(self) -> Dict[str, Any]: + """Get detailed cache status information.""" + vocab_exists = self.vocab_manager.vocab_cache_path.exists() + freq_exists = self.vocab_manager.frequency_cache_path.exists() + embeddings_exists = self.embeddings_cache_path.exists() + + status = { + "cache_directory": str(self.cache_dir), + "vocabulary_cache": { + "path": str(self.vocab_manager.vocab_cache_path), + "exists": vocab_exists, + "readable": vocab_exists and os.access(self.vocab_manager.vocab_cache_path, os.R_OK) + }, + "frequency_cache": { + "path": str(self.vocab_manager.frequency_cache_path), + "exists": freq_exists, + "readable": freq_exists and os.access(self.vocab_manager.frequency_cache_path, os.R_OK) + }, + "embeddings_cache": { + "path": str(self.embeddings_cache_path), + "exists": embeddings_exists, + "readable": embeddings_exists and os.access(self.embeddings_cache_path, os.R_OK) + }, + "complete": vocab_exists and freq_exists and embeddings_exists + } + + # Add size information if files exist + for cache_type in ["vocabulary_cache", "frequency_cache", "embeddings_cache"]: + cache_info = status[cache_type] + if cache_info["exists"]: + try: + file_path = Path(cache_info["path"]) + cache_info["size_bytes"] = file_path.stat().st_size + cache_info["size_mb"] = round(cache_info["size_bytes"] / (1024 * 1024), 2) + except Exception as e: + cache_info["size_error"] = str(e) + + return status + + async def find_words_for_crossword(self, topics: List[str], difficulty: str, requested_words: int = 10, custom_sentence: str = None, multi_theme: bool = True) -> List[Dict[str, Any]]: + """ + Crossword-specific word finding method with 50% overgeneration and clue quality filtering. + + Args: + topics: List of topic strings + difficulty: "easy", "medium", or "hard" + requested_words: Number of words requested by frontend + custom_sentence: Optional custom sentence to influence word selection + multi_theme: Whether to use multi-theme processing (True) or single-theme blending (False) + + Returns: + List of word dictionaries: [{"word": str, "clue": str, "similarity": float, "source": "thematic", "tier": str}] + """ + if not self.is_initialized: + await self.initialize_async() + + sentence_info = f", custom sentence: '{custom_sentence}'" if custom_sentence else "" + theme_mode = "multi-theme" if multi_theme else "single-theme" + + # Calculate generation target (3x more for quality filtering - need large pool for clue generation) + generation_target = int(requested_words * 3) + logger.info(f"🎯 Finding words for crossword - topics: {topics}, difficulty: {difficulty}{sentence_info}, mode: {theme_mode}") + logger.info(f"📊 Generating {generation_target} candidates to select best {requested_words} words after clue filtering") + + # Map difficulty to tier preferences + difficulty_tier_map = { + "easy": ["tier_2_extremely_common", "tier_3_very_common", "tier_4_highly_common"], + "medium": ["tier_4_highly_common", "tier_5_common", "tier_6_moderately_common", "tier_7_somewhat_uncommon"], + "hard": ["tier_7_somewhat_uncommon", "tier_8_uncommon", "tier_9_rare"] + } + + # Map difficulty to similarity thresholds + difficulty_similarity_map = { + "easy": 0.4, + "medium": 0.3, + "hard": 0.25 + } + + preferred_tiers = difficulty_tier_map.get(difficulty, difficulty_tier_map["medium"]) + min_similarity = difficulty_similarity_map.get(difficulty, 0.3) + + # Build input list for thematic word generation + input_list = topics.copy() # Start with topics: ["Art"] + + # Add custom sentence as separate input if provided + if custom_sentence: + input_list.append(custom_sentence) # Now: ["Art", "i will always love you"] + + # Determine if multi-theme processing is needed + is_multi_theme = len(input_list) > 1 + + # Set topic_input for generate_thematic_words + topic_input = input_list if is_multi_theme else input_list[0] + + # Get thematic words (get extra for filtering) + raw_results = self.generate_thematic_words( + topic_input, + num_words=150, # Get extra for difficulty filtering + min_similarity=min_similarity, + multi_theme=multi_theme + ) + + # Log generated thematic words sorted by tiers + if raw_results: + # Group results by tier for sorted display + tier_groups = {} + for word, similarity, tier in raw_results: + if tier not in tier_groups: + tier_groups[tier] = [] + tier_groups[tier].append((word, similarity)) + + # Sort tiers from most common to least common + tier_order = [ + "tier_1_ultra_common", + "tier_2_extremely_common", + "tier_3_very_common", + "tier_4_highly_common", + "tier_5_common", + "tier_6_moderately_common", + "tier_7_somewhat_uncommon", + "tier_8_uncommon", + "tier_9_rare", + "tier_10_very_rare" + ] + + # Build single log message with all tier information + log_lines = [f"📊 Generated {len(raw_results)} thematic words, grouped by tiers:"] + + for tier in tier_order: + if tier in tier_groups: + tier_desc = self.tier_descriptions.get(tier, tier) + log_lines.append(f" 📊 {tier_desc}:") + # Sort words within tier alphabetically + tier_words = sorted(tier_groups[tier], key=lambda x: x[0]) + for word, similarity in tier_words: + log_lines.append(f" {word:<15} (similarity: {similarity:.3f})") + + # uncomment this log line if want to print all words returned + logger.info("\n".join(log_lines)) + else: + logger.info("📊 No thematic words generated") + + # Weighted random tier selection for crossword backend + # Step 1: Group raw_results by tier and filter by difficulty/length + tier_groups_filtered = {} + for word, similarity, tier in raw_results: + # Only consider words from preferred tiers for this difficulty + if tier in preferred_tiers: # and self._matches_crossword_difficulty(word, difficulty): + if tier not in tier_groups_filtered: + tier_groups_filtered[tier] = [] + tier_groups_filtered[tier].append((word, similarity, tier)) + + # Step 2: Calculate word distribution across preferred tiers + tier_word_counts = {tier: len(words) for tier, words in tier_groups_filtered.items()} + total_available_words = sum(tier_word_counts.values()) + + logger.info(f"📊 Available words by preferred tier: {tier_word_counts}") + + if total_available_words == 0: + logger.info("⚠️ No words found in preferred tiers, returning empty list") + return [] + + # Step 3: Generate clues for ALL words in preferred tiers (no pre-selection) + candidate_words = [] + + # Generate clues for all available words in preferred tiers + # This gives us a large pool to filter by clue quality + logger.info(f"📊 Generating clues for all {total_available_words} words in preferred tiers") + for tier, words in tier_groups_filtered.items(): + for word, similarity, tier in words: + word_data = { + "word": word.upper(), + "clue": self._generate_crossword_clue(word, topics), + "similarity": float(similarity), + "source": "thematic", + "tier": tier + } + candidate_words.append(word_data) + + # Step 5: Filter candidates by clue quality and select best words + logger.info(f"📊 Generated {len(candidate_words)} candidate words, filtering for clue quality") + + # Separate words by clue quality + quality_words = [] # Words with proper WordNet-based clues + fallback_words = [] # Words with generic fallback clues + + fallback_patterns = ["Related to", "Crossword answer"] + + for word_data in candidate_words: + clue = word_data["clue"] + has_fallback = any(pattern in clue for pattern in fallback_patterns) + + if has_fallback: + fallback_words.append(word_data) + else: + quality_words.append(word_data) + + # Prioritize quality words, use fallback only if needed + final_words = [] + + # First, add quality words up to requested count + if quality_words: + random.shuffle(quality_words) # Randomize selection + final_words.extend(quality_words[:requested_words]) + + # If we don't have enough quality words, add some fallback words + if len(final_words) < requested_words and fallback_words: + needed = requested_words - len(final_words) + random.shuffle(fallback_words) + final_words.extend(fallback_words[:needed]) + + # Final shuffle to avoid quality-based ordering + random.shuffle(final_words) + + logger.info(f"✅ Selected {len(final_words)} words ({len([w for w in final_words if not any(p in w['clue'] for p in fallback_patterns)])} quality, {len([w for w in final_words if any(p in w['clue'] for p in fallback_patterns)])} fallback)") + logger.info(f"📝 Final words: {[w['word'] for w in final_words]}") + return final_words + + def _matches_crossword_difficulty(self, word: str, difficulty: str) -> bool: + """Check if word matches crossword difficulty criteria.""" + difficulty_criteria = { + "easy": {"min_len": 3, "max_len": 8}, + "medium": {"min_len": 4, "max_len": 10}, + "hard": {"min_len": 5, "max_len": 12} + } + + criteria = difficulty_criteria.get(difficulty, difficulty_criteria["medium"]) + return criteria["min_len"] <= len(word) <= criteria["max_len"] + + def _generate_crossword_clue(self, word: str, topics: List[str]) -> str: + """Generate a crossword clue for the word using WordNet.""" + # Initialize WordNet clue generator if not already done + if not hasattr(self, '_wordnet_generator') or self._wordnet_generator is None: + try: + from .wordnet_clue_generator import WordNetClueGenerator + self._wordnet_generator = WordNetClueGenerator( + cache_dir=str(self.cache_dir) + ) + self._wordnet_generator.initialize() + logger.info("✅ WordNet clue generator initialized on-demand") + except Exception as e: + logger.warning(f"⚠️ Failed to initialize WordNet clue generator: {e}") + self._wordnet_generator = None + + # Use WordNet generator if available + if self._wordnet_generator: + try: + primary_topic = topics[0] if topics else "general" + clue = self._wordnet_generator.generate_clue(word, primary_topic) + if clue and len(clue.strip()) > 0: + return clue + except Exception as e: + logger.warning(f"⚠️ WordNet clue generation failed for '{word}': {e}") + + # Fallback to simple templates if WordNet fails + word_lower = word.lower() + primary_topic = topics[0] if topics else "general" + topic_lower = primary_topic.lower() + + # Topic-specific clue templates as fallback + if any(keyword in topic_lower for keyword in ["animal", "pet", "wildlife"]): + return f"{word_lower} (animal)" + elif any(keyword in topic_lower for keyword in ["tech", "computer", "software", "digital"]): + return f"{word_lower} (technology)" + elif any(keyword in topic_lower for keyword in ["science", "biology", "chemistry", "physics"]): + return f"{word_lower} (science)" + elif any(keyword in topic_lower for keyword in ["geo", "place", "city", "country", "location"]): + return f"{word_lower} (geography)" + elif any(keyword in topic_lower for keyword in ["food", "cooking", "cuisine", "recipe"]): + return f"{word_lower} (food)" + elif any(keyword in topic_lower for keyword in ["music", "song", "instrument", "audio"]): + return f"{word_lower} (music)" + elif any(keyword in topic_lower for keyword in ["sport", "game", "athletic", "exercise"]): + return f"{word_lower} (sports)" + else: + return f"{word_lower} (related to {topic_lower})" + + +# Backwards compatibility aliases +ThematicWordGenerator = ThematicWordService # For existing code +UnifiedThematicWordGenerator = ThematicWordService # For existing code + +# Backend service - no interactive demo needed diff --git a/crossword-app/backend-py/src/services/unified_word_service.py b/crossword-app/backend-py/src/services/unified_word_service.py new file mode 100644 index 0000000000000000000000000000000000000000..3434f5a64e219ac9416874625ed0114db466fb4b --- /dev/null +++ b/crossword-app/backend-py/src/services/unified_word_service.py @@ -0,0 +1,250 @@ +""" +Integration adapter for Unified Thematic Word Generator + +This service provides a bridge between the new unified word generator +and the existing crossword backend, enabling the backend to use the +comprehensive WordFreq vocabulary instead of the limited model vocabulary. +""" + +import os +import sys +import logging +from typing import List, Dict, Any, Optional +from pathlib import Path + +logger = logging.getLogger(__name__) + +class UnifiedWordService: + """ + Service adapter for integrating UnifiedThematicWordGenerator with the crossword backend. + + Provides the same interface as VectorSearchService but uses the comprehensive + WordFreq vocabulary instead of model-limited vocabulary. + """ + + def __init__(self, vocab_size_limit: Optional[int] = None): + """Initialize the unified word service. + + Args: + vocab_size_limit: Maximum vocabulary size (None for default 100K) + """ + self.generator = None + self.vocab_size_limit = vocab_size_limit or int(os.getenv("MAX_VOCABULARY_SIZE", "100000")) + self.is_initialized = False + + # Import the generator from hack directory + self._import_generator() + + def _import_generator(self): + """Import the UnifiedThematicWordGenerator from hack directory.""" + try: + # Add hack directory to path + hack_dir = Path(__file__).parent.parent.parent.parent.parent / "hack" + if hack_dir.exists(): + sys.path.insert(0, str(hack_dir)) + logger.info(f"📁 Added hack directory to path: {hack_dir}") + + # Import the generator + from thematic_word_generator import UnifiedThematicWordGenerator + + # Initialize with appropriate cache directory + cache_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'cache', 'unified_generator') + + self.generator = UnifiedThematicWordGenerator( + cache_dir=cache_dir, + vocab_size_limit=self.vocab_size_limit + ) + + logger.info(f"✅ Imported UnifiedThematicWordGenerator with vocab limit: {self.vocab_size_limit:,}") + + except ImportError as e: + logger.error(f"❌ Failed to import UnifiedThematicWordGenerator: {e}") + logger.error(" Make sure the hack directory contains thematic_word_generator.py") + self.generator = None + except Exception as e: + logger.error(f"❌ Error setting up UnifiedThematicWordGenerator: {e}") + self.generator = None + + async def initialize(self): + """Initialize the unified word service.""" + if not self.generator: + logger.error("❌ Cannot initialize: generator not available") + return False + + try: + logger.info("🚀 Initializing Unified Word Service...") + start_time = time.time() + + # Initialize the generator (async compatible) + await self.generator.initialize_async() + + self.is_initialized = True + init_time = time.time() - start_time + + logger.info(f"✅ Unified Word Service initialized in {init_time:.2f}s") + logger.info(f"📊 Vocabulary size: {self.generator.get_vocabulary_size():,} words") + logger.info(f"🎯 Tier distribution: {self.generator.get_tier_distribution()}") + + return True + + except Exception as e: + logger.error(f"❌ Failed to initialize Unified Word Service: {e}") + self.is_initialized = False + return False + + async def find_similar_words( + self, + topic: str, + difficulty: str = "medium", + max_words: int = 15 + ) -> List[Dict[str, Any]]: + """ + Find similar words using the unified generator. + + Compatible with VectorSearchService interface. + + Args: + topic: Topic to find words for + difficulty: Difficulty level (easy/medium/hard) + max_words: Maximum number of words to return + + Returns: + List of word dictionaries: [{"word": str, "clue": str}, ...] + """ + if not self.is_initialized or not self.generator: + logger.error("❌ Service not initialized or generator not available") + return [] + + try: + # Use the generator's backend-compatible method + results = await self.generator.find_similar_words(topic, difficulty, max_words) + + logger.info(f"🎯 Generated {len(results)} words for '{topic}' (difficulty: {difficulty})") + return results + + except Exception as e: + logger.error(f"❌ Error finding similar words for '{topic}': {e}") + return [] + + async def _get_cached_fallback(self, topic: str, difficulty: str, max_words: int) -> List[Dict[str, Any]]: + """ + Fallback method for compatibility with existing backend code. + + Since our unified generator already has comprehensive vocabulary, + this just calls find_similar_words with relaxed criteria. + """ + if not self.is_initialized or not self.generator: + return [] + + try: + # Try with lower similarity threshold as "fallback" + results = self.generator.generate_thematic_words( + topic, + num_words=max_words, + min_similarity=0.2 # Lower threshold for fallback + ) + + # Format for backend compatibility + backend_words = [] + for word, similarity, tier in results: + if self.generator._matches_backend_difficulty(word, difficulty): + backend_word = { + "word": word.upper(), + "clue": self.generator._generate_simple_clue(word, topic), + "similarity": similarity, + "tier": tier + } + backend_words.append(backend_word) + + logger.info(f"📦 Fallback generated {len(backend_words)} words for '{topic}'") + return backend_words[:max_words] + + except Exception as e: + logger.error(f"❌ Error in cached fallback for '{topic}': {e}") + return [] + + def get_vocabulary_size(self) -> int: + """Get the vocabulary size.""" + if self.generator: + return self.generator.get_vocabulary_size() + return 0 + + def get_tier_info(self) -> Dict[str, Any]: + """Get frequency tier information.""" + if not self.generator: + return {} + + return { + "tier_distribution": self.generator.get_tier_distribution(), + "tier_descriptions": getattr(self.generator, 'tier_descriptions', {}), + "vocabulary_size": self.generator.get_vocabulary_size() + } + + +# Import time for initialization timing +import time + +# Factory function for easy backend integration +async def create_unified_word_service(vocab_size_limit: Optional[int] = None) -> Optional[UnifiedWordService]: + """ + Factory function to create and initialize a UnifiedWordService. + + Args: + vocab_size_limit: Maximum vocabulary size (None for default) + + Returns: + Initialized UnifiedWordService or None if initialization failed + """ + try: + service = UnifiedWordService(vocab_size_limit) + + if await service.initialize(): + return service + else: + logger.error("❌ Failed to initialize UnifiedWordService") + return None + + except Exception as e: + logger.error(f"❌ Error creating UnifiedWordService: {e}") + return None + + +# Example usage for testing +async def main(): + """Test the unified word service.""" + print("🧪 Testing Unified Word Service") + print("=" * 50) + + # Create and initialize service + service = await create_unified_word_service(vocab_size_limit=50000) # Smaller vocab for testing + + if not service: + print("❌ Failed to create service") + return + + # Test word generation + test_topics = ["animal", "science", "technology"] + + for topic in test_topics: + print(f"\n🎯 Testing topic: '{topic}'") + print("-" * 30) + + for difficulty in ["easy", "medium", "hard"]: + words = await service.find_similar_words(topic, difficulty, max_words=5) + + print(f" {difficulty.capitalize()}: {len(words)} words") + for word_data in words: + word = word_data['word'] + tier = word_data.get('tier', 'unknown') + print(f" {word:<12} ({tier})") + + print(f"\n📊 Service Info:") + print(f" Vocabulary size: {service.get_vocabulary_size():,}") + print(f" Tier info: {service.get_tier_info()}") + + print("\n✅ Test completed!") + + +if __name__ == "__main__": + import asyncio + asyncio.run(main()) \ No newline at end of file diff --git a/crossword-app/backend-py/src/services/vector_search.py b/crossword-app/backend-py/src/services/vector_search.py index 5948fa99c61d303a49bb4b0c4e631d13a8b4c485..3f974f5883b6180fb23cec5e8fc7235267cd18d2 100644 --- a/crossword-app/backend-py/src/services/vector_search.py +++ b/crossword-app/backend-py/src/services/vector_search.py @@ -3,6 +3,7 @@ Vector similarity search service using sentence-transformers and FAISS. This implements true AI word generation via vector space nearest neighbor search. """ +from math import log import os import logging import asyncio @@ -21,10 +22,7 @@ from pathlib import Path logger = logging.getLogger(__name__) -def log_with_timestamp(message): - """Helper to log with precise timestamp.""" - timestamp = datetime.now().strftime("%H:%M:%S.%f")[:-3] - logger.info(f"[{timestamp}] {message}") +# All logging now uses standard logger with filename/line numbers class VectorSearchService: """ @@ -70,29 +68,29 @@ class VectorSearchService: start_time = time.time() # Log environment configuration for debugging - log_with_timestamp(f"🔧 Environment Configuration:") - log_with_timestamp(f" 📊 Model: {self.model_name}") - log_with_timestamp(f" 🎯 Base Similarity Threshold: {self.base_similarity_threshold}") - log_with_timestamp(f" 📉 Min Similarity Threshold: {self.min_similarity_threshold}") - log_with_timestamp(f" 📈 Max Results: {self.max_results}") - log_with_timestamp(f" 🌟 Hierarchical Search: {self.use_hierarchical_search}") - log_with_timestamp(f" 🔀 Search Randomness: {os.getenv('SEARCH_RANDOMNESS', '0.02')}") - log_with_timestamp(f" 💾 Cache Dir: {os.getenv('WORD_CACHE_DIR', 'auto-detect')}") + logger.info(f"🔧 Environment Configuration:") + logger.info(f" 📊 Model: {self.model_name}") + logger.info(f" 🎯 Base Similarity Threshold: {self.base_similarity_threshold}") + logger.info(f" 📉 Min Similarity Threshold: {self.min_similarity_threshold}") + logger.info(f" 📈 Max Results: {self.max_results}") + logger.info(f" 🌟 Hierarchical Search: {self.use_hierarchical_search}") + logger.info(f" 🔀 Search Randomness: {os.getenv('SEARCH_RANDOMNESS', '0.02')}") + logger.info(f" 💾 Cache Dir: {os.getenv('WORD_CACHE_DIR', 'auto-detect')}") - log_with_timestamp(f"🔧 Loading model: {self.model_name}") + logger.info(f"🔧 Loading model: {self.model_name}") # Load sentence transformer model model_start = time.time() self.model = SentenceTransformer(self.model_name) model_time = time.time() - model_start - log_with_timestamp(f"✅ Model loaded in {model_time:.2f}s: {self.model_name}") + logger.info(f"✅ Model loaded in {model_time:.2f}s: {self.model_name}") # Try to load from cache first if self._load_cached_index(): - log_with_timestamp("🚀 Using cached FAISS index - startup accelerated!") + logger.info("🚀 Using cached FAISS index - startup accelerated!") else: # Build from scratch - log_with_timestamp("🔨 Building FAISS index from scratch...") + logger.info("🔨 Building FAISS index from scratch...") # Get model vocabulary from tokenizer vocab_start = time.time() @@ -102,36 +100,36 @@ class VectorSearchService: # Filter vocabulary for crossword-suitable words self.vocab = self._filter_vocabulary(vocab_dict) vocab_time = time.time() - vocab_start - log_with_timestamp(f"📚 Filtered vocabulary in {vocab_time:.2f}s: {len(self.vocab)} words") + logger.info(f"📚 Filtered vocabulary in {vocab_time:.2f}s: {len(self.vocab)} words") # Pre-compute embeddings for all vocabulary words embedding_start = time.time() - log_with_timestamp("🔄 Starting embedding generation...") + logger.info("🔄 Starting embedding generation...") await self._build_embeddings_index() embedding_time = time.time() - embedding_start - log_with_timestamp(f"🔄 Embeddings built in {embedding_time:.2f}s") + logger.info(f"🔄 Embeddings built in {embedding_time:.2f}s") # Save to cache for next time self._save_index_to_cache() # Initialize cache manager cache_start = time.time() - log_with_timestamp("📦 Initializing word cache manager...") + logger.info("📦 Initializing word cache manager...") try: from .word_cache import WordCacheManager self.cache_manager = WordCacheManager() await self.cache_manager.initialize() cache_time = time.time() - cache_start - log_with_timestamp(f"📦 Cache manager initialized in {cache_time:.2f}s") + logger.info(f"📦 Cache manager initialized in {cache_time:.2f}s") except Exception as e: cache_time = time.time() - cache_start - log_with_timestamp(f"⚠️ Cache manager initialization failed in {cache_time:.2f}s: {e}") - log_with_timestamp("📝 Continuing without persistent caching (in-memory only)") + logger.info(f"⚠️ Cache manager initialization failed in {cache_time:.2f}s: {e}") + logger.info("📝 Continuing without persistent caching (in-memory only)") self.cache_manager = None self.is_initialized = True total_time = time.time() - start_time - log_with_timestamp(f"✅ Vector search service fully initialized in {total_time:.2f}s") + logger.info(f"✅ Vector search service fully initialized in {total_time:.2f}s") except Exception as e: logger.error(f"❌ Failed to initialize vector search: {e}") @@ -140,7 +138,7 @@ class VectorSearchService: def _filter_vocabulary(self, vocab_dict: Dict[str, int]) -> List[str]: """Filter vocabulary to keep only crossword-suitable words.""" - log_with_timestamp(f"📚 Filtering {len(vocab_dict)} vocabulary words...") + logger.info(f"📚 Filtering {len(vocab_dict)} vocabulary words...") # Pre-compile excluded words set for faster lookup excluded_words = { @@ -159,7 +157,7 @@ class VectorSearchService: # Progress logging for large vocabularies if processed % 10000 == 0: - log_with_timestamp(f"📊 Vocabulary filtering progress: {processed}/{len(vocab_dict)}") + logger.info(f"📊 Vocabulary filtering progress: {processed}/{len(vocab_dict)}") # Clean word (remove special tokens) - optimized if word.startswith('##'): @@ -191,7 +189,7 @@ class VectorSearchService: # Remove duplicates efficiently and sort unique_filtered = sorted(list(set(filtered))) - log_with_timestamp(f"📚 Vocabulary filtered: {len(vocab_dict)} → {len(unique_filtered)} words") + logger.info(f"📚 Vocabulary filtered: {len(vocab_dict)} → {len(unique_filtered)} words") return unique_filtered @@ -225,7 +223,7 @@ class VectorSearchService: cpu_count = os.cpu_count() or 1 # Larger batches for better throughput, smaller for HF Spaces limited memory batch_size = min(200 if cpu_count > 2 else 100, len(self.vocab) // 4) - log_with_timestamp(f"⚡ Using batch size {batch_size} with {cpu_count} CPUs") + logger.info(f"⚡ Using batch size {batch_size} with {cpu_count} CPUs") embeddings_list = [] total_batches = (len(self.vocab) + batch_size - 1) // batch_size @@ -249,24 +247,24 @@ class VectorSearchService: # Progress logging - more frequent for slower HF Spaces if batch_num % max(1, total_batches // 10) == 0: progress = (batch_num / total_batches) * 100 - log_with_timestamp(f"📊 Embedding progress: {progress:.1f}% ({i}/{len(self.vocab)} words)") + logger.info(f"📊 Embedding progress: {progress:.1f}% ({i}/{len(self.vocab)} words)") # Combine all embeddings - log_with_timestamp("🔗 Combining embeddings...") + logger.info("🔗 Combining embeddings...") self.word_embeddings = np.vstack(embeddings_list) logger.info(f"📈 Generated embeddings shape: {self.word_embeddings.shape}") # Build FAISS index for fast similarity search - log_with_timestamp("🏗️ Building FAISS index...") + logger.info("🏗️ Building FAISS index...") dimension = self.word_embeddings.shape[1] self.faiss_index = faiss.IndexFlatIP(dimension) # Inner product similarity # Normalize embeddings for cosine similarity - log_with_timestamp("📏 Normalizing embeddings for cosine similarity...") + logger.info("📏 Normalizing embeddings for cosine similarity...") faiss.normalize_L2(self.word_embeddings) # Add to FAISS index - log_with_timestamp("📥 Adding embeddings to FAISS index...") + logger.info("📥 Adding embeddings to FAISS index...") self.faiss_index.add(self.word_embeddings) logger.info(f"🔍 FAISS index built with {self.faiss_index.ntotal} vectors") @@ -316,7 +314,7 @@ class VectorSearchService: # Track these words to prevent future repetition if similar_words: - self._track_used_words(topic, [word['word'] for word in similar_words]) + self._track_used_words(topic, similar_words) # Cache successful results for future use if similar_words: @@ -338,7 +336,7 @@ class VectorSearchService: # Track these words to prevent future repetition if similar_words: - self._track_used_words(topic, [word['word'] for word in similar_words]) + self._track_used_words(topic, similar_words) # If not enough words found, supplement with cached words (more aggressive) if len(similar_words) < max_words * 0.75: # If less than 75% of target, supplement @@ -578,7 +576,8 @@ class VectorSearchService: 'urban', 'rural', 'geological', 'topographical', 'cartographic'] } - for candidate in candidates[:10]: # Only consider top 10 for performance + # for candidate in candidates[:10]: # Only consider top 10 for performance + for candidate in candidates: # Only consider top 10 for performance word = candidate['word'].lower() similarity = candidate['similarity'] @@ -691,6 +690,8 @@ class VectorSearchService: main_topic_candidates.extend(variation_candidates) + if len(main_topic_candidates) <= 10: + logger.info(f"🔍 Main topic search found candidates: {main_topic_candidates}") logger.info(f"🔍 Main topic search found {len(main_topic_candidates)} candidates") # Phase 2: Identify subcategories from best candidates @@ -919,7 +920,18 @@ class VectorSearchService: max_words: int ) -> List[Dict[str, Any]]: """ - Ensure diverse representation from different search sources. + Balance word selection across different search sources for optimal variety. + + Allocates selection quotas to ensure representation from main topic searches + and subcategory searches, preventing over-concentration from any single source + while maintaining quality standards. + + Args: + candidates: Word candidates with search source metadata + max_words: Target number of words to select + + Returns: + Balanced selection ensuring source diversity """ if len(candidates) <= max_words: return candidates @@ -1047,38 +1059,38 @@ class VectorSearchService: """Load FAISS index from cache if available.""" try: if not self._cache_exists(): - log_with_timestamp("📁 No cached index found - will build new index") + logger.info("📁 No cached index found - will build new index") return False - log_with_timestamp("📁 Loading cached FAISS index...") + logger.info("📁 Loading cached FAISS index...") cache_start = time.time() # Load vocabulary with open(self.vocab_cache_path, 'rb') as f: self.vocab = pickle.load(f) - log_with_timestamp(f"📚 Loaded {len(self.vocab)} vocabulary words from cache") + logger.info(f"📚 Loaded {len(self.vocab)} vocabulary words from cache") # Load embeddings self.word_embeddings = np.load(self.embeddings_cache_path) - log_with_timestamp(f"📈 Loaded embeddings shape: {self.word_embeddings.shape}") + logger.info(f"📈 Loaded embeddings shape: {self.word_embeddings.shape}") # Load FAISS index self.faiss_index = faiss.read_index(self.faiss_cache_path) - log_with_timestamp(f"🔍 Loaded FAISS index with {self.faiss_index.ntotal} vectors") + logger.info(f"🔍 Loaded FAISS index with {self.faiss_index.ntotal} vectors") cache_time = time.time() - cache_start - log_with_timestamp(f"✅ Successfully loaded cached index in {cache_time:.2f}s") + logger.info(f"✅ Successfully loaded cached index in {cache_time:.2f}s") return True except Exception as e: - log_with_timestamp(f"❌ Failed to load cached index: {e}") - log_with_timestamp("🔄 Will rebuild index from scratch") + logger.info(f"❌ Failed to load cached index: {e}") + logger.info("🔄 Will rebuild index from scratch") return False def _save_index_to_cache(self): """Save the built FAISS index to cache for future use.""" try: - log_with_timestamp("💾 Saving FAISS index to cache...") + logger.info("💾 Saving FAISS index to cache...") save_start = time.time() # Save vocabulary @@ -1092,12 +1104,12 @@ class VectorSearchService: faiss.write_index(self.faiss_index, self.faiss_cache_path) save_time = time.time() - save_start - log_with_timestamp(f"✅ Index cached successfully in {save_time:.2f}s") - log_with_timestamp(f"📁 Cache location: {self.index_cache_dir}") + logger.info(f"✅ Index cached successfully in {save_time:.2f}s") + logger.info(f"📁 Cache location: {self.index_cache_dir}") except Exception as e: - log_with_timestamp(f"⚠️ Failed to cache index: {e}") - log_with_timestamp("📝 Continuing without caching (performance will be slower next startup)") + logger.info(f"⚠️ Failed to cache index: {e}") + logger.info("📝 Continuing without caching (performance will be slower next startup)") def _is_topic_relevant(self, word: str, topic: str) -> bool: """ @@ -1182,16 +1194,16 @@ class VectorSearchService: # Filter by difficulty and quality if self._matches_difficulty(word, difficulty): difficulty_passed += 1 - if self._is_interesting_word(word, topic) and self._is_topic_relevant(word, topic): - interesting_passed += 1 - candidates.append({ - "word": word, - "clue": self._generate_clue(word, topic), - "similarity": float(score), - "source": "vector_search" - }) - else: - rejected_words.append(f"{word}({score:.3f})") + # if self._is_interesting_word(word, topic) and self._is_topic_relevant(word, topic): + interesting_passed += 1 + candidates.append({ + "word": word, + "clue": self._generate_clue(word, topic), + "similarity": float(score), + "source": "vector_search" + }) + # else: + # rejected_words.append(f"{word}({score:.3f})") else: rejected_words.append(f"{word}({score:.3f})") @@ -1341,58 +1353,49 @@ class VectorSearchService: "animals": [ {"word": "DOG", "clue": "Man's best friend"}, {"word": "CAT", "clue": "Feline pet"}, - {"word": "ELEPHANT", "clue": "Large mammal with trunk"}, - {"word": "TIGER", "clue": "Striped big cat"}, - {"word": "BIRD", "clue": "Flying creature"}, {"word": "FISH", "clue": "Aquatic animal"}, - {"word": "HORSE", "clue": "Riding animal"}, - {"word": "BEAR", "clue": "Large mammal"}, - {"word": "WHALE", "clue": "Marine mammal"}, - {"word": "LION", "clue": "King of jungle"}, - {"word": "RABBIT", "clue": "Hopping mammal"}, - {"word": "SNAKE", "clue": "Slithering reptile"} ], "science": [ - {"word": "ATOM", "clue": "Basic unit of matter"}, - {"word": "CELL", "clue": "Basic unit of life"}, - {"word": "DNA", "clue": "Genetic material"}, - {"word": "ENERGY", "clue": "Capacity to do work"}, - {"word": "FORCE", "clue": "Push or pull"}, - {"word": "GRAVITY", "clue": "Force of attraction"}, - {"word": "LIGHT", "clue": "Electromagnetic radiation"}, - {"word": "MATTER", "clue": "Physical substance"}, - {"word": "MOTION", "clue": "Change in position"}, - {"word": "OXYGEN", "clue": "Essential gas"}, - {"word": "PHYSICS", "clue": "Study of matter and energy"}, - {"word": "THEORY", "clue": "Scientific explanation"} + # {"word": "ATOM", "clue": "Basic unit of matter"}, + # {"word": "CELL", "clue": "Basic unit of life"}, + # {"word": "DNA", "clue": "Genetic material"}, + # {"word": "ENERGY", "clue": "Capacity to do work"}, + # {"word": "FORCE", "clue": "Push or pull"}, + # {"word": "GRAVITY", "clue": "Force of attraction"}, + # {"word": "LIGHT", "clue": "Electromagnetic radiation"}, + # {"word": "MATTER", "clue": "Physical substance"}, + # {"word": "MOTION", "clue": "Change in position"}, + # {"word": "OXYGEN", "clue": "Essential gas"}, + # {"word": "PHYSICS", "clue": "Study of matter and energy"}, + # {"word": "THEORY", "clue": "Scientific explanation"} ], "technology": [ - {"word": "COMPUTER", "clue": "Electronic device"}, - {"word": "INTERNET", "clue": "Global network"}, - {"word": "SOFTWARE", "clue": "Computer programs"}, - {"word": "ROBOT", "clue": "Automated machine"}, - {"word": "DATA", "clue": "Information"}, - {"word": "CODE", "clue": "Programming instructions"}, - {"word": "DIGITAL", "clue": "Electronic format"}, - {"word": "NETWORK", "clue": "Connected systems"}, - {"word": "SYSTEM", "clue": "Organized whole"}, - {"word": "DEVICE", "clue": "Technical apparatus"}, - {"word": "MOBILE", "clue": "Portable technology"}, - {"word": "SCREEN", "clue": "Display surface"} + # {"word": "COMPUTER", "clue": "Electronic device"}, + # {"word": "INTERNET", "clue": "Global network"}, + # {"word": "SOFTWARE", "clue": "Computer programs"}, + # {"word": "ROBOT", "clue": "Automated machine"}, + # {"word": "DATA", "clue": "Information"}, + # {"word": "CODE", "clue": "Programming instructions"}, + # {"word": "DIGITAL", "clue": "Electronic format"}, + # {"word": "NETWORK", "clue": "Connected systems"}, + # {"word": "SYSTEM", "clue": "Organized whole"}, + # {"word": "DEVICE", "clue": "Technical apparatus"}, + # {"word": "MOBILE", "clue": "Portable technology"}, + # {"word": "SCREEN", "clue": "Display surface"} ], "geography": [ - {"word": "MOUNTAIN", "clue": "High landform"}, - {"word": "RIVER", "clue": "Flowing water"}, - {"word": "OCEAN", "clue": "Large body of water"}, - {"word": "DESERT", "clue": "Arid region"}, - {"word": "FOREST", "clue": "Dense trees"}, - {"word": "ISLAND", "clue": "Land surrounded by water"}, - {"word": "VALLEY", "clue": "Low area between hills"}, - {"word": "LAKE", "clue": "Inland water body"}, - {"word": "COAST", "clue": "Land by the sea"}, - {"word": "PLAIN", "clue": "Flat land"}, - {"word": "HILL", "clue": "Small elevation"}, - {"word": "CLIFF", "clue": "Steep rock face"} + # {"word": "MOUNTAIN", "clue": "High landform"}, + # {"word": "RIVER", "clue": "Flowing water"}, + # {"word": "OCEAN", "clue": "Large body of water"}, + # {"word": "DESERT", "clue": "Arid region"}, + # {"word": "FOREST", "clue": "Dense trees"}, + # {"word": "ISLAND", "clue": "Land surrounded by water"}, + # {"word": "VALLEY", "clue": "Low area between hills"}, + # {"word": "LAKE", "clue": "Inland water body"}, + # {"word": "COAST", "clue": "Land by the sea"}, + # {"word": "PLAIN", "clue": "Flat land"}, + # {"word": "HILL", "clue": "Small elevation"}, + # {"word": "CLIFF", "clue": "Steep rock face"} ] } @@ -1441,4 +1444,4 @@ class VectorSearchService: del self.faiss_index if self.cache_manager: await self.cache_manager.cleanup_expired_caches() - self.is_initialized = False \ No newline at end of file + self.is_initialized = False diff --git a/crossword-app/backend-py/src/services/wordnet_clue_generator.py b/crossword-app/backend-py/src/services/wordnet_clue_generator.py new file mode 100644 index 0000000000000000000000000000000000000000..adb1312005f22fb19fb536468df73516d6660a4c --- /dev/null +++ b/crossword-app/backend-py/src/services/wordnet_clue_generator.py @@ -0,0 +1,640 @@ +#!/usr/bin/env python3 +""" +WordNet-Based Clue Generator for Crossword Puzzles + +Uses NLTK WordNet to generate crossword clues by analyzing word definitions, +synonyms, hypernyms, and semantic relationships. Integrated with the thematic +word generator for complete crossword creation without API dependencies. + +Features: +- WordNet-based clue generation using definitions and relationships +- Integration with UnifiedThematicWordGenerator for word discovery +- Interactive mode with topic-based generation +- Multiple clue styles (definition, synonym, category, descriptive) +- Difficulty-based clue complexity +- Caching for improved performance +""" + +import os +import sys +import re +import time +import logging +from typing import List, Dict, Optional, Tuple, Set, Any +from pathlib import Path +from dataclasses import dataclass +from collections import defaultdict +import random + +# NLTK imports +try: + import nltk + from nltk.corpus import wordnet as wn + from nltk.stem import WordNetLemmatizer + NLTK_AVAILABLE = True +except ImportError: + print("❌ NLTK not available. Install with: pip install nltk") + NLTK_AVAILABLE = False + +# Add hack directory to path for imports +sys.path.insert(0, str(Path(__file__).parent)) + +try: + from .thematic_word_service import ThematicWordService as UnifiedThematicWordGenerator + THEMATIC_AVAILABLE = True +except ImportError as e: + print(f"❌ Thematic generator import error: {e}") + THEMATIC_AVAILABLE = False + +# Set up logging +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' +) +logger = logging.getLogger(__name__) + + +@dataclass +class WordNetClueEntry: + """Complete crossword entry with WordNet-generated clue and metadata.""" + word: str + clue: str + topic: str + similarity_score: float + frequency_tier: str + tier_description: str + clue_type: str # definition, synonym, hypernym, etc. + synset_info: Optional[str] = None + definition_source: Optional[str] = None + + +def ensure_nltk_data(nltk_data_dir: Optional[str] = None): + """Ensure required NLTK data is downloaded to specified directory. + + Args: + nltk_data_dir: Custom directory for NLTK data. If None, uses default. + """ + if not NLTK_AVAILABLE: + return False + + # Set up custom NLTK data directory + if nltk_data_dir: + nltk_data_path = Path(nltk_data_dir) + nltk_data_path.mkdir(parents=True, exist_ok=True) + + # Add custom path to NLTK search path (at the beginning for priority) + if str(nltk_data_path) not in nltk.data.path: + nltk.data.path.insert(0, str(nltk_data_path)) + logger.info(f"📂 Added NLTK data path: {nltk_data_path}") + + # Map corpus names to their actual directory paths + corpus_paths = { + 'wordnet': 'corpora/wordnet', + 'omw-1.4': 'corpora/omw-1.4', + 'punkt': 'tokenizers/punkt', + 'averaged_perceptron_tagger': 'taggers/averaged_perceptron_tagger' + } + + required_corpora = ['wordnet', 'punkt', 'averaged_perceptron_tagger', 'omw-1.4'] + + for corpus in required_corpora: + corpus_path = corpus_paths[corpus] + + try: + # Try to find corpus in current search paths + found_corpus = nltk.data.find(corpus_path) + logger.info(f"✅ Found {corpus} at: {found_corpus}") + except LookupError: + # Check if it exists in our custom directory + if nltk_data_dir: + local_corpus_path = Path(nltk_data_dir) / corpus_path + if local_corpus_path.exists(): + logger.info(f"✅ Found {corpus} locally at: {local_corpus_path}") + continue + + # Only download if not found anywhere + logger.warning(f"❌ {corpus} not found, attempting download...") + try: + if nltk_data_dir: + # Download to custom directory + logger.info(f"📥 Downloading {corpus} to: {nltk_data_dir}") + nltk.download(corpus, download_dir=nltk_data_dir, quiet=False) + logger.info(f"✅ Downloaded {corpus} to: {nltk_data_dir}") + else: + # Download to default directory + logger.info(f"📥 Downloading {corpus} to default location") + nltk.download(corpus, quiet=False) + logger.info(f"✅ Downloaded {corpus} to default location") + except Exception as e: + logger.warning(f"⚠️ Failed to download {corpus}: {e}") + return False + + return True + + +class WordNetClueGenerator: + """ + WordNet-based clue generator that creates crossword clues using semantic + relationships and definitions from the WordNet lexical database. + """ + + def __init__(self, cache_dir: Optional[str] = None): + """Initialize WordNet clue generator. + + Args: + cache_dir: Directory for caching (used for both model cache and NLTK data) + """ + self.cache_dir = cache_dir or str(Path(__file__).parent / 'model_cache') + self.nltk_data_dir = str(Path(self.cache_dir) / 'nltk_data') + self.lemmatizer = None + self.clue_cache = {} + self.is_initialized = False + + # Simple clue generation using definition concatenation + + # Words to avoid in clues (common words that don't make good clues) + self.avoid_words = { + 'thing', 'stuff', 'item', 'object', 'entity', 'something', 'anything', + 'person', 'people', 'someone', 'anyone', 'somebody', 'anybody', + 'place', 'location', 'somewhere', 'anywhere', 'area', 'spot', + 'time', 'moment', 'period', 'while', 'when', 'then', + 'way', 'manner', 'method', 'means', 'how', 'what', 'which' + } + + def initialize(self): + """Initialize the WordNet clue generator.""" + if self.is_initialized: + return True + + if not NLTK_AVAILABLE: + logger.error("❌ NLTK not available - cannot initialize WordNet generator") + return False + + logger.info("🚀 Initializing WordNet Clue Generator...") + logger.info(f"📂 Using cache directory: {self.cache_dir}") + logger.info(f"📂 Using NLTK data directory: {self.nltk_data_dir}") + start_time = time.time() + + # Ensure NLTK data is available in cache directory + if not ensure_nltk_data(self.nltk_data_dir): + logger.error("❌ Failed to download required NLTK data") + return False + + # Initialize lemmatizer + try: + self.lemmatizer = WordNetLemmatizer() + logger.info("✅ WordNet lemmatizer initialized") + except Exception as e: + logger.error(f"❌ Failed to initialize lemmatizer: {e}") + return False + + self.is_initialized = True + init_time = time.time() - start_time + logger.info(f"✅ WordNet clue generator ready in {init_time:.2f}s") + + return True + + def generate_clue(self, word: str, topic: str = "", clue_style: str = "auto", + difficulty: str = "medium") -> str: + """Generate a crossword clue using WordNet definitions. + + Args: + word: Target word for clue generation + topic: Topic context (for fallback only) + clue_style: Ignored - kept for compatibility + difficulty: Ignored - kept for compatibility + + Returns: + Generated crossword clue + """ + if not self.is_initialized: + if not self.initialize(): + return f"Related to {topic}" if topic else "Crossword answer" + + word_clean = word.lower().strip() + + # Get synsets + synsets = wn.synsets(word_clean) + if not synsets: + return f"Related to {topic}" if topic else "Crossword answer" + + # Limit to max 3 synsets, randomly select if more than 3 + if len(synsets) > 3: + import random + synsets = random.sample(synsets, 3) + + # Get all definitions and filter out those containing the target word + definitions = [] + word_variants = { + word_clean, + word_clean + 's', + word_clean + 'ing', + word_clean + 'ed', + word_clean + 'er', + word_clean + 'ly' + } + + for syn in synsets: + definition = syn.definition() + definition_lower = definition.lower() + + # Check if any variant of the target word appears in the definition + contains_target = False + for variant in word_variants: + if f" {variant} " in f" {definition_lower} " or definition_lower.startswith(variant + " "): + contains_target = True + break + + # Only include definitions that don't contain the target word + if not contains_target: + definitions.append(definition) + + # If no clean definitions found, return fallback + if not definitions: + return f"Related to {topic}" if topic else "Crossword answer" + + # Concatenate clean definitions + clue = "; ".join(definitions) + + return clue + + def _generate_fallback_clue(self, word: str, topic: str) -> str: + """Generate fallback clue when WordNet fails.""" + if topic: + return f"Related to {topic}" + return "Crossword answer" + + + def get_clue_info(self, word: str) -> Dict[str, Any]: + """Get detailed information about WordNet data for a word.""" + if not self.is_initialized: + return {"error": "Generator not initialized"} + + word_clean = word.lower().strip() + synsets = self._get_synsets(word_clean) + + info = { + "word": word, + "synsets_count": len(synsets), + "synsets": [] + } + + for synset in synsets[:3]: # Top 3 synsets + synset_info = { + "name": synset.name(), + "pos": synset.pos(), + "definition": synset.definition(), + "examples": synset.examples()[:2], + "hypernyms": [h.name() for h in synset.hypernyms()[:2]], + "synonyms": [l.name().replace('_', ' ') for l in synset.lemmas()[:3]] + } + info["synsets"].append(synset_info) + + return info + + +class IntegratedWordNetCrosswordGenerator: + """ + Complete crossword generation system using WordNet clues and thematic word discovery. + """ + + def __init__(self, vocab_size_limit: Optional[int] = None, cache_dir: Optional[str] = None): + """Initialize the integrated WordNet crossword generator. + + Args: + vocab_size_limit: Maximum vocabulary size for thematic generator + cache_dir: Cache directory for models and data + """ + self.cache_dir = cache_dir or str(Path(__file__).parent / 'model_cache') + self.vocab_size_limit = vocab_size_limit or 50000 + + # Initialize components + self.thematic_generator = None + self.clue_generator = None + self.is_initialized = False + + # Stats + self.stats = { + 'words_discovered': 0, + 'clues_generated': 0, + 'cache_hits': 0, + 'total_time': 0.0 + } + + def initialize(self): + """Initialize both generators.""" + if self.is_initialized: + return True + + start_time = time.time() + logger.info("🚀 Initializing Integrated WordNet Crossword Generator...") + + success = True + + # Initialize WordNet clue generator with consistent cache directory + logger.info("🔄 Initializing WordNet clue generator...") + self.clue_generator = WordNetClueGenerator(self.cache_dir) + if not self.clue_generator.initialize(): + logger.error("❌ Failed to initialize WordNet clue generator") + success = False + else: + logger.info("✅ WordNet clue generator ready") + logger.info(f"📂 NLTK data stored in: {self.clue_generator.nltk_data_dir}") + + # Initialize thematic word generator + if THEMATIC_AVAILABLE: + logger.info("🔄 Initializing thematic word generator...") + try: + self.thematic_generator = UnifiedThematicWordGenerator( + cache_dir=self.cache_dir, + vocab_size_limit=self.vocab_size_limit + ) + self.thematic_generator.initialize() + logger.info(f"✅ Thematic generator ready ({self.thematic_generator.get_vocabulary_size():,} words)") + except Exception as e: + logger.error(f"❌ Failed to initialize thematic generator: {e}") + success = False + else: + logger.warning("⚠️ Thematic generator not available - limited word discovery") + + self.is_initialized = success + init_time = time.time() - start_time + logger.info(f"{'✅' if success else '❌'} Initialization {'completed' if success else 'failed'} in {init_time:.2f}s") + + return success + + def generate_crossword_entries(self, topic: str, num_words: int = 15, + difficulty: str = "medium", clue_style: str = "auto") -> List[WordNetClueEntry]: + """Generate complete crossword entries for a topic. + + Args: + topic: Topic for word generation + num_words: Number of entries to generate + difficulty: Difficulty level ('easy', 'medium', 'hard') + clue_style: Clue generation style + + Returns: + List of WordNetClueEntry objects + """ + if not self.is_initialized: + if not self.initialize(): + return [] + + start_time = time.time() + logger.info(f"🎯 Generating {num_words} crossword entries for '{topic}' (difficulty: {difficulty})") + + # Generate thematic words + if self.thematic_generator: + try: + # Get more words than needed for better selection + word_results = self.thematic_generator.generate_thematic_words( + inputs=topic, + num_words=num_words * 2, + min_similarity=0.2 + ) + self.stats['words_discovered'] += len(word_results) + except Exception as e: + logger.error(f"❌ Word generation failed: {e}") + word_results = [] + else: + # Fallback: use some common words related to topic + word_results = [(topic.upper(), 0.9, "tier_5_common")] + + if not word_results: + logger.warning(f"⚠️ No words found for topic '{topic}'") + return [] + + # Generate clues for words + entries = [] + for word, similarity, tier in word_results[:num_words]: + try: + clue = self.clue_generator.generate_clue( + word=word, + topic=topic, + clue_style=clue_style, + difficulty=difficulty + ) + + if clue: + tier_desc = self._get_tier_description(tier) + entry = WordNetClueEntry( + word=word.upper(), + clue=clue, + topic=topic, + similarity_score=similarity, + frequency_tier=tier, + tier_description=tier_desc, + clue_type=clue_style + ) + entries.append(entry) + self.stats['clues_generated'] += 1 + + except Exception as e: + logger.error(f"❌ Failed to generate clue for '{word}': {e}") + + # Sort by similarity and limit results + entries.sort(key=lambda x: x.similarity_score, reverse=True) + final_entries = entries[:num_words] + + total_time = time.time() - start_time + self.stats['total_time'] += total_time + + logger.info(f"✅ Generated {len(final_entries)} entries in {total_time:.2f}s") + return final_entries + + def _get_tier_description(self, tier: str) -> str: + """Get tier description from thematic generator or provide default.""" + if self.thematic_generator and hasattr(self.thematic_generator, 'tier_descriptions'): + return self.thematic_generator.tier_descriptions.get(tier, tier) + return tier.replace('_', ' ').title() + + def get_stats(self) -> Dict[str, Any]: + """Get generation statistics.""" + return { + **self.stats, + 'thematic_available': self.thematic_generator is not None, + 'wordnet_available': self.clue_generator is not None and self.clue_generator.is_initialized, + 'vocab_size': self.thematic_generator.get_vocabulary_size() if self.thematic_generator else 0 + } + + +def main(): + """Interactive WordNet crossword generator.""" + if not NLTK_AVAILABLE: + print("❌ NLTK not available. Please install with: pip install nltk") + return + + print("🚀 WordNet Crossword Generator") + print("=" * 60) + print("Using NLTK WordNet for clue generation + thematic word discovery") + + # Initialize generator + cache_dir = str(Path(__file__).parent / 'model_cache') + generator = IntegratedWordNetCrosswordGenerator( + vocab_size_limit=50000, + cache_dir=cache_dir + ) + + print("\n🔄 Initializing system...") + if not generator.initialize(): + print("❌ Failed to initialize system") + return + + stats = generator.get_stats() + print(f"\n📊 System Status:") + print(f" WordNet clues: {'✅' if stats['wordnet_available'] else '❌'}") + print(f" Thematic words: {'✅' if stats['thematic_available'] else '❌'}") + if stats['vocab_size'] > 0: + print(f" Vocabulary: {stats['vocab_size']:,} words") + + print(f"\n🎮 INTERACTIVE MODE") + print("=" * 60) + print("Commands:") + print(" - Generate words and clues for topic") + print(" - Generate specific number of entries") + print(" - Set difficulty (easy/medium/hard)") + print(" style