karaoke-gen 0.105.4__py3-none-any.whl → 0.107.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- backend/api/routes/users.py +14 -3
- backend/config.py +3 -0
- backend/services/encoding_interface.py +4 -0
- backend/services/job_notification_service.py +4 -21
- backend/tests/test_job_notification_service.py +24 -58
- backend/tests/test_video_worker_orchestrator.py +189 -0
- backend/workers/video_worker_orchestrator.py +7 -0
- karaoke_gen/instrumental_review/server.py +145 -35
- karaoke_gen/nextjs_frontend/__init__.py +98 -0
- karaoke_gen/nextjs_frontend/out/404/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/404.html +1 -0
- karaoke_gen/nextjs_frontend/out/__next.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/__next._full.txt +22 -0
- karaoke_gen/nextjs_frontend/out/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/01a7f8fe40f1ff47.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/112f346e31f991df.js +4 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/16d1a4dd9d8a873a.js +3 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/1ab85c362b8b0e86.js +9 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/247eb132b7f7b574.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/2b80d15cc95e4818.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/32c7eba5cd46c1bc.js +7 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/483f26794eae53d0.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/550c3b02e85f196a.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/55c5ade44387bef8.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/5628d92b5893add2.css +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/56ebf7665e4341c8.js +7 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/5997132b61dec430.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/5ea55255bce3eb9e.js +5 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/5eda89a57490b3cd.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/692f5d9e0d700c76.js +3 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/71d7a05b14f9f0f4.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/81ac355749ef3302.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/95f7e5934dbb0e5d.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/9bce8f19eaa46940.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/a6dad97d9634a72d.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/a9ed54eed3e14c92.js +2 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/b35cd41238ecfb17.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/b5bc3c3d5ebd49eb.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/b5c078c08db5ae32.js +5 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/be9c44a178104187.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/c4c840e18cb4861c.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/c645af7d6b65f73e.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/d2c5e2575df784d4.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/d30af02b96d81462.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/d9bdf64f4ec1e9b7.js +7 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/dcde6ed684dacd0e.js +5 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/e422cbe931246000.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/e483af34fc792d38.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/e57422aad6b897da.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/ef02697fb404726a.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/ff1a16fafef87110.js +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/chunks/turbopack-2d9ca3017a9deedf.js +3 -0
- karaoke_gen/nextjs_frontend/out/_next/static/zpw_-rjFIDV5tlPPtnvRI/_buildManifest.js +11 -0
- karaoke_gen/nextjs_frontend/out/_next/static/zpw_-rjFIDV5tlPPtnvRI/_clientMiddlewareManifest.json +1 -0
- karaoke_gen/nextjs_frontend/out/_next/static/zpw_-rjFIDV5tlPPtnvRI/_ssgManifest.js +1 -0
- karaoke_gen/nextjs_frontend/out/_not-found/__next._full.txt +18 -0
- karaoke_gen/nextjs_frontend/out/_not-found/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/_not-found/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/_not-found/__next._not-found.__PAGE__.txt +5 -0
- karaoke_gen/nextjs_frontend/out/_not-found/__next._not-found.txt +4 -0
- karaoke_gen/nextjs_frontend/out/_not-found/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/_not-found/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/_not-found/index.txt +18 -0
- karaoke_gen/nextjs_frontend/out/admin/__next._full.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/admin/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/admin/__next.admin.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/__next.admin.txt +7 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/__next._full.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/__next.admin.beta.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/__next.admin.beta.txt +4 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/__next.admin.txt +7 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/admin/beta/index.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/admin/index.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/__next._full.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/__next.admin.jobs.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/__next.admin.jobs.txt +4 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/__next.admin.txt +7 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/admin/jobs/index.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/__next._full.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/__next.admin.rate-limits.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/__next.admin.rate-limits.txt +4 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/__next.admin.txt +7 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/admin/rate-limits/index.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/__next._full.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/__next.admin.searches.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/__next.admin.searches.txt +4 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/__next.admin.txt +7 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/admin/searches/index.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/users/__next._full.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/users/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/admin/users/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/users/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/admin/users/__next.admin.txt +7 -0
- karaoke_gen/nextjs_frontend/out/admin/users/__next.admin.users.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/users/__next.admin.users.txt +4 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next._full.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next.admin.txt +7 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next.admin.users.detail.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next.admin.users.detail.txt +4 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/__next.admin.users.txt +4 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/admin/users/detail/index.txt +25 -0
- karaoke_gen/nextjs_frontend/out/admin/users/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/admin/users/index.txt +25 -0
- karaoke_gen/nextjs_frontend/out/app/__next._full.txt +22 -0
- karaoke_gen/nextjs_frontend/out/app/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/app/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/app/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/app/__next.app.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/app/__next.app.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/app/index.txt +22 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next._full.txt +19 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next.app.jobs.$oc$slug.__PAGE__.txt +6 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next.app.jobs.$oc$slug.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next.app.jobs.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/__next.app.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/index.txt +19 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next._full.txt +19 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next.app.jobs.$oc$slug.__PAGE__.txt +6 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next.app.jobs.$oc$slug.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next.app.jobs.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/__next.app.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/instrumental/index.txt +19 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next._full.txt +19 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next.app.jobs.$oc$slug.__PAGE__.txt +6 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next.app.jobs.$oc$slug.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next.app.jobs.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/__next.app.txt +4 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/app/jobs/local/review/index.txt +19 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/__next._full.txt +22 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/__next.auth.txt +4 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/__next.auth.verify.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/__next.auth.verify.txt +4 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/auth/verify/index.txt +22 -0
- karaoke_gen/nextjs_frontend/out/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/index.txt +22 -0
- karaoke_gen/nextjs_frontend/out/manifest.webmanifest +31 -0
- karaoke_gen/nextjs_frontend/out/order/success/__next._full.txt +22 -0
- karaoke_gen/nextjs_frontend/out/order/success/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/order/success/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/order/success/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/order/success/__next.order.success.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/order/success/__next.order.success.txt +4 -0
- karaoke_gen/nextjs_frontend/out/order/success/__next.order.txt +4 -0
- karaoke_gen/nextjs_frontend/out/order/success/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/order/success/index.txt +22 -0
- karaoke_gen/nextjs_frontend/out/payment/success/__next._full.txt +22 -0
- karaoke_gen/nextjs_frontend/out/payment/success/__next._head.txt +8 -0
- karaoke_gen/nextjs_frontend/out/payment/success/__next._index.txt +9 -0
- karaoke_gen/nextjs_frontend/out/payment/success/__next._tree.txt +2 -0
- karaoke_gen/nextjs_frontend/out/payment/success/__next.payment.success.__PAGE__.txt +9 -0
- karaoke_gen/nextjs_frontend/out/payment/success/__next.payment.success.txt +4 -0
- karaoke_gen/nextjs_frontend/out/payment/success/__next.payment.txt +4 -0
- karaoke_gen/nextjs_frontend/out/payment/success/index.html +1 -0
- karaoke_gen/nextjs_frontend/out/payment/success/index.txt +22 -0
- karaoke_gen/nextjs_frontend/out/screenshots/email-action_reminder.png +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/email-beta_welcome.png +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/email-job_completion.png +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/example-output.avif +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/homepage-full.png +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/homepage-hero.png +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/instrumental-review.avif +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/instrumental-review.png +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/job-dashboard.avif +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/lyrics-review.avif +0 -0
- karaoke_gen/nextjs_frontend/out/screenshots/lyrics-review.png +0 -0
- karaoke_gen/nextjs_frontend/out/sw.js +183 -0
- karaoke_gen/utils/cli_args.py +3 -3
- karaoke_gen/utils/gen_cli.py +4 -0
- karaoke_gen/utils/remote_cli.py +8 -40
- {karaoke_gen-0.105.4.dist-info → karaoke_gen-0.107.0.dist-info}/METADATA +1 -1
- {karaoke_gen-0.105.4.dist-info → karaoke_gen-0.107.0.dist-info}/RECORD +227 -121
- {karaoke_gen-0.105.4.dist-info → karaoke_gen-0.107.0.dist-info}/WHEEL +1 -1
- lyrics_transcriber/correction/agentic/agent.py +83 -60
- lyrics_transcriber/correction/anchor_sequence.py +48 -3
- lyrics_transcriber/correction/corrector.py +92 -58
- lyrics_transcriber/review/server.py +165 -33
- lyrics_transcriber/utils/tracing.py +214 -0
- karaoke_gen/instrumental_review/static/index.html +0 -1721
- lyrics_transcriber/frontend/.gitignore +0 -24
- lyrics_transcriber/frontend/.yarn/releases/yarn-4.7.0.cjs +0 -935
- lyrics_transcriber/frontend/.yarnrc.yml +0 -3
- lyrics_transcriber/frontend/README.md +0 -50
- lyrics_transcriber/frontend/REPLACE_ALL_FUNCTIONALITY.md +0 -210
- lyrics_transcriber/frontend/__init__.py +0 -25
- lyrics_transcriber/frontend/e2e/agentic-corrections.spec.ts +0 -207
- lyrics_transcriber/frontend/e2e/fixtures/agentic-correction-data.json +0 -226
- lyrics_transcriber/frontend/eslint.config.js +0 -28
- lyrics_transcriber/frontend/index.html +0 -22
- lyrics_transcriber/frontend/package-lock.json +0 -4553
- lyrics_transcriber/frontend/package.json +0 -48
- lyrics_transcriber/frontend/playwright.config.ts +0 -69
- lyrics_transcriber/frontend/public/android-chrome-192x192.png +0 -0
- lyrics_transcriber/frontend/public/android-chrome-512x512.png +0 -0
- lyrics_transcriber/frontend/src/App.tsx +0 -243
- lyrics_transcriber/frontend/src/api.ts +0 -262
- lyrics_transcriber/frontend/src/components/AIFeedbackModal.tsx +0 -111
- lyrics_transcriber/frontend/src/components/AddLyricsModal.tsx +0 -114
- lyrics_transcriber/frontend/src/components/AgenticCorrectionMetrics.tsx +0 -204
- lyrics_transcriber/frontend/src/components/AppHeader.tsx +0 -65
- lyrics_transcriber/frontend/src/components/AudioPlayer.tsx +0 -180
- lyrics_transcriber/frontend/src/components/CorrectedWordWithActions.tsx +0 -175
- lyrics_transcriber/frontend/src/components/CorrectionAnnotationModal.tsx +0 -359
- lyrics_transcriber/frontend/src/components/CorrectionDetailCard.tsx +0 -281
- lyrics_transcriber/frontend/src/components/CorrectionMetrics.tsx +0 -162
- lyrics_transcriber/frontend/src/components/DurationTimelineView.tsx +0 -257
- lyrics_transcriber/frontend/src/components/EditActionBar.tsx +0 -94
- lyrics_transcriber/frontend/src/components/EditModal.tsx +0 -720
- lyrics_transcriber/frontend/src/components/EditTimelineSection.tsx +0 -592
- lyrics_transcriber/frontend/src/components/EditWordList.tsx +0 -431
- lyrics_transcriber/frontend/src/components/FileUpload.tsx +0 -77
- lyrics_transcriber/frontend/src/components/FindReplaceModal.tsx +0 -467
- lyrics_transcriber/frontend/src/components/Header.tsx +0 -520
- lyrics_transcriber/frontend/src/components/LyricsAnalyzer.tsx +0 -1526
- lyrics_transcriber/frontend/src/components/LyricsSynchronizer/SyncControls.tsx +0 -216
- lyrics_transcriber/frontend/src/components/LyricsSynchronizer/TimelineCanvas.tsx +0 -721
- lyrics_transcriber/frontend/src/components/LyricsSynchronizer/UpcomingWordsBar.tsx +0 -80
- lyrics_transcriber/frontend/src/components/LyricsSynchronizer/index.tsx +0 -999
- lyrics_transcriber/frontend/src/components/MetricsDashboard.tsx +0 -51
- lyrics_transcriber/frontend/src/components/ModeSelectionModal.tsx +0 -127
- lyrics_transcriber/frontend/src/components/ModeSelector.tsx +0 -67
- lyrics_transcriber/frontend/src/components/ModelSelector.tsx +0 -23
- lyrics_transcriber/frontend/src/components/PreviewVideoSection.tsx +0 -177
- lyrics_transcriber/frontend/src/components/ReferenceView.tsx +0 -268
- lyrics_transcriber/frontend/src/components/ReplaceAllLyricsModal.tsx +0 -336
- lyrics_transcriber/frontend/src/components/ReviewChangesModal.tsx +0 -354
- lyrics_transcriber/frontend/src/components/SegmentDetailsModal.tsx +0 -64
- lyrics_transcriber/frontend/src/components/TimelineEditor.tsx +0 -383
- lyrics_transcriber/frontend/src/components/TimingOffsetModal.tsx +0 -131
- lyrics_transcriber/frontend/src/components/TranscriptionView.tsx +0 -266
- lyrics_transcriber/frontend/src/components/WordDivider.tsx +0 -191
- lyrics_transcriber/frontend/src/components/shared/components/HighlightedText.tsx +0 -466
- lyrics_transcriber/frontend/src/components/shared/components/SourceSelector.tsx +0 -56
- lyrics_transcriber/frontend/src/components/shared/components/Word.tsx +0 -89
- lyrics_transcriber/frontend/src/components/shared/constants.ts +0 -30
- lyrics_transcriber/frontend/src/components/shared/hooks/useWordClick.ts +0 -180
- lyrics_transcriber/frontend/src/components/shared/styles.ts +0 -13
- lyrics_transcriber/frontend/src/components/shared/types.js +0 -2
- lyrics_transcriber/frontend/src/components/shared/types.ts +0 -135
- lyrics_transcriber/frontend/src/components/shared/utils/keyboardHandlers.ts +0 -177
- lyrics_transcriber/frontend/src/components/shared/utils/localStorage.ts +0 -78
- lyrics_transcriber/frontend/src/components/shared/utils/referenceLineCalculator.ts +0 -75
- lyrics_transcriber/frontend/src/components/shared/utils/segmentOperations.ts +0 -360
- lyrics_transcriber/frontend/src/components/shared/utils/timingUtils.ts +0 -110
- lyrics_transcriber/frontend/src/components/shared/utils/wordUtils.ts +0 -22
- lyrics_transcriber/frontend/src/hooks/useManualSync.ts +0 -537
- lyrics_transcriber/frontend/src/main.tsx +0 -11
- lyrics_transcriber/frontend/src/theme.ts +0 -406
- lyrics_transcriber/frontend/src/types/global.d.ts +0 -9
- lyrics_transcriber/frontend/src/types.js +0 -2
- lyrics_transcriber/frontend/src/types.ts +0 -199
- lyrics_transcriber/frontend/src/validation.ts +0 -132
- lyrics_transcriber/frontend/src/vite-env.d.ts +0 -1
- lyrics_transcriber/frontend/tsconfig.app.json +0 -26
- lyrics_transcriber/frontend/tsconfig.json +0 -25
- lyrics_transcriber/frontend/tsconfig.node.json +0 -23
- lyrics_transcriber/frontend/tsconfig.tsbuildinfo +0 -1
- lyrics_transcriber/frontend/update_version.js +0 -11
- lyrics_transcriber/frontend/vite.config.d.ts +0 -2
- lyrics_transcriber/frontend/vite.config.js +0 -15
- lyrics_transcriber/frontend/vite.config.ts +0 -16
- lyrics_transcriber/frontend/web_assets/android-chrome-192x192.png +0 -0
- lyrics_transcriber/frontend/web_assets/android-chrome-512x512.png +0 -0
- lyrics_transcriber/frontend/web_assets/apple-touch-icon.png +0 -0
- lyrics_transcriber/frontend/web_assets/assets/index-BSMgOq4Z.js +0 -44465
- lyrics_transcriber/frontend/web_assets/assets/index-BSMgOq4Z.js.map +0 -1
- lyrics_transcriber/frontend/web_assets/favicon-16x16.png +0 -0
- lyrics_transcriber/frontend/web_assets/favicon-32x32.png +0 -0
- lyrics_transcriber/frontend/web_assets/favicon.ico +0 -0
- lyrics_transcriber/frontend/web_assets/index.html +0 -22
- lyrics_transcriber/frontend/web_assets/nomad-karaoke-logo.png +0 -0
- lyrics_transcriber/frontend/web_assets/nomad-karaoke-logo.svg +0 -5
- lyrics_transcriber/frontend/yarn.lock +0 -3711
- {lyrics_transcriber/frontend/public → karaoke_gen/nextjs_frontend/out}/apple-touch-icon.png +0 -0
- {lyrics_transcriber/frontend/public → karaoke_gen/nextjs_frontend/out}/favicon-16x16.png +0 -0
- {lyrics_transcriber/frontend/public → karaoke_gen/nextjs_frontend/out}/favicon-32x32.png +0 -0
- {lyrics_transcriber/frontend/public → karaoke_gen/nextjs_frontend/out}/favicon.ico +0 -0
- {lyrics_transcriber/frontend/public → karaoke_gen/nextjs_frontend/out}/nomad-karaoke-logo.svg +0 -0
- /lyrics_transcriber/frontend/public/nomad-karaoke-logo.png → /karaoke_gen/nextjs_frontend/out/nomad-logo.png +0 -0
- {karaoke_gen-0.105.4.dist-info → karaoke_gen-0.107.0.dist-info}/entry_points.txt +0 -0
- {karaoke_gen-0.105.4.dist-info → karaoke_gen-0.107.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,78280,e=>{"use strict";let t;var r=e.i(43476),n=e.i(71645),a=e.i(18566),s=e.i(38036),l=e.i(54858),i=e.i(17521),i=i,o=e.i(47163);function d({className:e,...t}){return(0,r.jsx)(i.default,{role:"status","aria-label":"Loading",className:(0,o.cn)("size-4 animate-spin",e),...t})}var c=e.i(67881),u=e.i(71689),m=e.i(63209),h=e.i(22016),f=e.i(75254);let x=(0,f.default)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),p=(0,f.default)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);var g=e.i(43531),w=e.i(74080),v=Array(12).fill(0),b=({visible:e,className:t})=>n.default.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},n.default.createElement("div",{className:"sonner-spinner"},v.map((e,t)=>n.default.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),y=n.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},n.default.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),j=n.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},n.default.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),_=n.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},n.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),N=n.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},n.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),C=n.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},n.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),k=1,S=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:r,...n}=e,a="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:k++,s=this.toasts.find(e=>e.id===a),l=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),s?this.toasts=this.toasts.map(t=>t.id===a?(this.publish({...t,...e,id:a,title:r}),{...t,...e,id:a,dismissible:l,title:r}):t):this.addToast({title:r,...n,dismissible:l,id:a}),a},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{let r;if(!t)return;void 0!==t.loading&&(r=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));let a=e instanceof Promise?e:e(),s=void 0!==r,l,i=a.then(async e=>{if(l=["resolve",e],n.default.isValidElement(e))s=!1,this.create({id:r,type:"default",message:e});else if(T(e)&&!e.ok){s=!1;let n="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,a="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description;this.create({id:r,type:"error",message:n,description:a})}else if(void 0!==t.success){s=!1;let n="function"==typeof t.success?await t.success(e):t.success,a="function"==typeof t.description?await t.description(e):t.description;this.create({id:r,type:"success",message:n,description:a})}}).catch(async e=>{if(l=["reject",e],void 0!==t.error){s=!1;let n="function"==typeof t.error?await t.error(e):t.error,a="function"==typeof t.description?await t.description(e):t.description;this.create({id:r,type:"error",message:n,description:a})}}).finally(()=>{var e;s&&(this.dismiss(r),r=void 0),null==(e=t.finally)||e.call(t)}),o=()=>new Promise((e,t)=>i.then(()=>"reject"===l[0]?t(l[1]):e(l[1])).catch(t));return"string"!=typeof r&&"number"!=typeof r?{unwrap:o}:Object.assign(r,{unwrap:o})},this.custom=(e,t)=>{let r=(null==t?void 0:t.id)||k++;return this.create({jsx:e(r),id:r,...t}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},T=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,E=Object.assign((e,t)=>{let r=(null==t?void 0:t.id)||k++;return S.addToast({title:e,...t,id:r}),r},{success:S.success,info:S.info,warning:S.warning,error:S.error,custom:S.custom,message:S.message,promise:S.promise,dismiss:S.dismiss,loading:S.loading},{getHistory:()=>S.toasts,getToasts:()=>S.getActiveToasts()});function M(e){return void 0!==e.label}function R(...e){return e.filter(Boolean).join(" ")}!function(e,{insertAt:t}={}){if(!e||"undefined"==typeof document)return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===t&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
2
|
+
`);var A=e=>{var t,r,a,s,l,i,o,d,c,u,m,h,f,x;let{invert:p,toast:g,unstyled:w,interacting:v,setHeights:k,visibleToasts:S,heights:T,index:E,toasts:A,expanded:P,removeToast:D,defaultRichColors:B,closeButton:L,style:z,cancelButtonStyle:I,actionButtonStyle:O,className:W="",descriptionClassName:F="",duration:H,position:$,gap:U,loadingIcon:Y,expandByDefault:q,classNames:X,icons:V,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:K}=e,[G,Z]=n.default.useState(null),[Q,ee]=n.default.useState(null),[et,er]=n.default.useState(!1),[en,ea]=n.default.useState(!1),[es,el]=n.default.useState(!1),[ei,eo]=n.default.useState(!1),[ed,ec]=n.default.useState(!1),[eu,em]=n.default.useState(0),[eh,ef]=n.default.useState(0),ex=n.default.useRef(g.duration||H||4e3),ep=n.default.useRef(null),eg=n.default.useRef(null),ew=0===E,ev=E+1<=S,eb=g.type,ey=!1!==g.dismissible,ej=g.className||"",e_=g.descriptionClassName||"",eN=n.default.useMemo(()=>T.findIndex(e=>e.toastId===g.id)||0,[T,g.id]),eC=n.default.useMemo(()=>{var e;return null!=(e=g.closeButton)?e:L},[g.closeButton,L]),ek=n.default.useMemo(()=>g.duration||H||4e3,[g.duration,H]),eS=n.default.useRef(0),eT=n.default.useRef(0),eE=n.default.useRef(0),eM=n.default.useRef(null),[eR,eA]=$.split("-"),eP=n.default.useMemo(()=>T.reduce((e,t,r)=>r>=eN?e:e+t.height,0),[T,eN]),eD=(()=>{let[e,t]=n.default.useState(document.hidden);return n.default.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),eB=g.invert||p,eL="loading"===eb;eT.current=n.default.useMemo(()=>eN*U+eP,[eN,eP]),n.default.useEffect(()=>{ex.current=ek},[ek]),n.default.useEffect(()=>{er(!0)},[]),n.default.useEffect(()=>{let e=eg.current;if(e){let t=e.getBoundingClientRect().height;return ef(t),k(e=>[{toastId:g.id,height:t,position:g.position},...e]),()=>k(e=>e.filter(e=>e.toastId!==g.id))}},[k,g.id]),n.default.useLayoutEffect(()=>{if(!et)return;let e=eg.current,t=e.style.height;e.style.height="auto";let r=e.getBoundingClientRect().height;e.style.height=t,ef(r),k(e=>e.find(e=>e.toastId===g.id)?e.map(e=>e.toastId===g.id?{...e,height:r}:e):[{toastId:g.id,height:r,position:g.position},...e])},[et,g.title,g.description,k,g.id]);let ez=n.default.useCallback(()=>{ea(!0),em(eT.current),k(e=>e.filter(e=>e.toastId!==g.id)),setTimeout(()=>{D(g)},200)},[g,D,k,eT]);return n.default.useEffect(()=>{let e;if((!g.promise||"loading"!==eb)&&g.duration!==1/0&&"loading"!==g.type)return P||v||K&&eD?(()=>{if(eE.current<eS.current){let e=new Date().getTime()-eS.current;ex.current=ex.current-e}eE.current=new Date().getTime()})():ex.current!==1/0&&(eS.current=new Date().getTime(),e=setTimeout(()=>{var e;null==(e=g.onAutoClose)||e.call(g,g),ez()},ex.current)),()=>clearTimeout(e)},[P,v,g,eb,K,eD,ez]),n.default.useEffect(()=>{g.delete&&ez()},[ez,g.delete]),n.default.createElement("li",{tabIndex:0,ref:eg,className:R(W,ej,null==X?void 0:X.toast,null==(t=null==g?void 0:g.classNames)?void 0:t.toast,null==X?void 0:X.default,null==X?void 0:X[eb],null==(r=null==g?void 0:g.classNames)?void 0:r[eb]),"data-sonner-toast":"","data-rich-colors":null!=(a=g.richColors)?a:B,"data-styled":!(g.jsx||g.unstyled||w),"data-mounted":et,"data-promise":!!g.promise,"data-swiped":ed,"data-removed":en,"data-visible":ev,"data-y-position":eR,"data-x-position":eA,"data-index":E,"data-front":ew,"data-swiping":es,"data-dismissible":ey,"data-type":eb,"data-invert":eB,"data-swipe-out":ei,"data-swipe-direction":Q,"data-expanded":!!(P||q&&et),style:{"--index":E,"--toasts-before":E,"--z-index":A.length-E,"--offset":`${en?eu:eT.current}px`,"--initial-height":q?"auto":`${eh}px`,...z,...g.style},onDragEnd:()=>{el(!1),Z(null),eM.current=null},onPointerDown:e=>{eL||!ey||(ep.current=new Date,em(eT.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(el(!0),eM.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,r,n;if(ei||!ey)return;eM.current=null;let a=Number((null==(e=eg.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),s=Number((null==(t=eg.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),l=new Date().getTime()-(null==(r=ep.current)?void 0:r.getTime()),i="x"===G?a:s,o=Math.abs(i)/l;if(Math.abs(i)>=20||o>.11){em(eT.current),null==(n=g.onDismiss)||n.call(g,g),ee("x"===G?a>0?"right":"left":s>0?"down":"up"),ez(),eo(!0),ec(!1);return}el(!1),Z(null)},onPointerMove:t=>{var r,n,a,s;if(!eM.current||!ey||(null==(r=window.getSelection())?void 0:r.toString().length)>0)return;let l=t.clientY-eM.current.y,i=t.clientX-eM.current.x,o=null!=(n=e.swipeDirections)?n:function(e){let[t,r]=e.split("-"),n=[];return t&&n.push(t),r&&n.push(r),n}($);!G&&(Math.abs(i)>1||Math.abs(l)>1)&&Z(Math.abs(i)>Math.abs(l)?"x":"y");let d={x:0,y:0};"y"===G?(o.includes("top")||o.includes("bottom"))&&(o.includes("top")&&l<0||o.includes("bottom")&&l>0)&&(d.y=l):"x"===G&&(o.includes("left")||o.includes("right"))&&(o.includes("left")&&i<0||o.includes("right")&&i>0)&&(d.x=i),(Math.abs(d.x)>0||Math.abs(d.y)>0)&&ec(!0),null==(a=eg.current)||a.style.setProperty("--swipe-amount-x",`${d.x}px`),null==(s=eg.current)||s.style.setProperty("--swipe-amount-y",`${d.y}px`)}},eC&&!g.jsx?n.default.createElement("button",{"aria-label":J,"data-disabled":eL,"data-close-button":!0,onClick:eL||!ey?()=>{}:()=>{var e;ez(),null==(e=g.onDismiss)||e.call(g,g)},className:R(null==X?void 0:X.closeButton,null==(s=null==g?void 0:g.classNames)?void 0:s.closeButton)},null!=(l=null==V?void 0:V.close)?l:C):null,g.jsx||(0,n.isValidElement)(g.title)?g.jsx?g.jsx:"function"==typeof g.title?g.title():g.title:n.default.createElement(n.default.Fragment,null,eb||g.icon||g.promise?n.default.createElement("div",{"data-icon":"",className:R(null==X?void 0:X.icon,null==(i=null==g?void 0:g.classNames)?void 0:i.icon)},g.promise||"loading"===g.type&&!g.icon?g.icon||(null!=V&&V.loading?n.default.createElement("div",{className:R(null==X?void 0:X.loader,null==(h=null==g?void 0:g.classNames)?void 0:h.loader,"sonner-loader"),"data-visible":"loading"===eb},V.loading):Y?n.default.createElement("div",{className:R(null==X?void 0:X.loader,null==(f=null==g?void 0:g.classNames)?void 0:f.loader,"sonner-loader"),"data-visible":"loading"===eb},Y):n.default.createElement(b,{className:R(null==X?void 0:X.loader,null==(x=null==g?void 0:g.classNames)?void 0:x.loader),visible:"loading"===eb})):null,"loading"!==g.type?g.icon||(null==V?void 0:V[eb])||(e=>{switch(e){case"success":return y;case"info":return _;case"warning":return j;case"error":return N;default:return null}})(eb):null):null,n.default.createElement("div",{"data-content":"",className:R(null==X?void 0:X.content,null==(o=null==g?void 0:g.classNames)?void 0:o.content)},n.default.createElement("div",{"data-title":"",className:R(null==X?void 0:X.title,null==(d=null==g?void 0:g.classNames)?void 0:d.title)},"function"==typeof g.title?g.title():g.title),g.description?n.default.createElement("div",{"data-description":"",className:R(F,e_,null==X?void 0:X.description,null==(c=null==g?void 0:g.classNames)?void 0:c.description)},"function"==typeof g.description?g.description():g.description):null),(0,n.isValidElement)(g.cancel)?g.cancel:g.cancel&&M(g.cancel)?n.default.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||I,onClick:e=>{var t,r;M(g.cancel)&&ey&&(null==(r=(t=g.cancel).onClick)||r.call(t,e),ez())},className:R(null==X?void 0:X.cancelButton,null==(u=null==g?void 0:g.classNames)?void 0:u.cancelButton)},g.cancel.label):null,(0,n.isValidElement)(g.action)?g.action:g.action&&M(g.action)?n.default.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||O,onClick:e=>{var t,r;M(g.action)&&(null==(r=(t=g.action).onClick)||r.call(t,e),e.defaultPrevented||ez())},className:R(null==X?void 0:X.actionButton,null==(m=null==g?void 0:g.classNames)?void 0:m.actionButton)},g.action.label):null))};function P(){if("undefined"==typeof window||"undefined"==typeof document)return"ltr";let e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function D({activeAudio:e,onAudioChange:t,hasOriginal:n,hasWithBacking:a,hasCustom:s,hasUploaded:l,uploadedFilename:i}){let d=[{type:"original",label:"Original",available:n},{type:"backing",label:"Backing Vocals Only",available:!0},{type:"clean",label:"Pure Instrumental",available:!0},{type:"with_backing",label:"Instrumental + Backing",available:a},{type:"custom",label:"Custom",available:s},{type:"uploaded",label:"Uploaded",available:l,title:i}].filter(e=>e.available);return(0,r.jsx)("div",{className:"flex flex-wrap gap-1 bg-background rounded-md p-0.5",children:d.map(n=>(0,r.jsx)("button",{type:"button",onClick:()=>t(n.type),title:n.title,className:(0,o.cn)("px-2.5 py-1.5 rounded text-xs font-medium transition-all","text-muted-foreground hover:text-foreground",e===n.type&&"bg-primary text-primary-foreground"),children:n.label},n.type))})}function B({amplitudes:e,duration:t,currentTime:a,muteRegions:s,audibleSegments:l,zoomLevel:i,onSeek:o,onRegionCreate:d,isShiftHeld:c}){let u=(0,n.useRef)(null),m=(0,n.useRef)(null),h=(0,n.useRef)(!1),f=(0,n.useRef)(0),x=(0,n.useRef)(0),p=(0,n.useCallback)(()=>{let r=u.current;if(!r||!e.length)return;let n=r.getContext("2d");if(!n)return;let a=r.width,i=r.height,o=i/2;n.fillStyle="#0d1117",n.fillRect(0,0,a,i),n.strokeStyle="rgba(255, 255, 255, 0.1)",n.setLineDash([4,4]),n.beginPath(),n.moveTo(0,o),n.lineTo(a,o),n.stroke(),n.setLineDash([]);let d=a/e.length;e.forEach((r,a)=>{let c=Math.max(2,r*i*.9),u=o-c/2,m=a/e.length*t,h=s.some(e=>m>=e.start_seconds&&m<=e.end_seconds),f=l.some(e=>m>=e.start_seconds&&m<=e.end_seconds);h?n.fillStyle="rgba(13, 17, 23, 0.8)":f?n.fillStyle="#ec4899":n.fillStyle="#60a5fa",n.fillRect(a*d,u,Math.max(1,d-.5),c)})},[e,t,s,l]),g=(0,n.useCallback)(()=>{let e=u.current,t=m.current;e&&t&&(e.width=t.clientWidth*i,e.height=t.clientHeight)},[i]);(0,n.useEffect)(()=>{g(),p()},[g,p,i]),(0,n.useEffect)(()=>{let e=()=>{g(),p()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[g,p]);let w=t>0&&u.current?a/t*u.current.width:0,v=e=>{if(!h.current)return;let r=u.current;if(!r)return;let n=r.getBoundingClientRect(),a=(e.clientX-n.left)/n.width*t;if(!Number.isFinite(t)||t<=0){h.current=!1;return}let s=Math.min(f.current,a),l=Math.max(f.current,a);l-s>.5&&d(s,l),h.current=!1};return(0,r.jsx)("div",{ref:m,className:"relative flex-1 overflow-x-auto overflow-y-hidden bg-[#0d1117] min-h-[120px]",children:(0,r.jsxs)("div",{className:"relative h-full",style:{width:`${100*i}%`,minWidth:"100%"},children:[(0,r.jsx)("canvas",{ref:u,className:"block h-full cursor-pointer",onMouseDown:e=>{let r=u.current;if(!r)return;let n=r.getBoundingClientRect(),a=e.clientX-n.left,s=a/n.width*t;Number.isFinite(t)&&!(t<=0)&&(e.shiftKey||c?(h.current=!0,f.current=s,x.current=a):o(s))},onMouseMove:e=>{if(!h.current)return},onMouseUp:v,onMouseLeave:e=>{h.current&&v(e)}}),(0,r.jsx)("div",{className:"absolute top-0 w-0.5 h-full bg-primary pointer-events-none z-10",style:{left:`${w}px`,boxShadow:"0 0 8px var(--primary)"},children:(0,r.jsx)("div",{className:"absolute -top-0 -left-1 w-2.5 h-2.5 bg-primary rounded-full"})})]})})}(0,n.forwardRef)(function(e,t){let{invert:r,position:a="bottom-right",hotkey:s=["altKey","KeyT"],expand:l,closeButton:i,className:o,offset:d,mobileOffset:c,theme:u="light",richColors:m,duration:h,style:f,visibleToasts:x=3,toastOptions:p,dir:g=P(),gap:v=14,loadingIcon:b,icons:y,containerAriaLabel:j="Notifications",pauseWhenPageIsHidden:_}=e,[N,C]=n.default.useState([]),k=n.default.useMemo(()=>Array.from(new Set([a].concat(N.filter(e=>e.position).map(e=>e.position)))),[N,a]),[T,E]=n.default.useState([]),[M,R]=n.default.useState(!1),[D,B]=n.default.useState(!1),[L,z]=n.default.useState("system"!==u?u:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),I=n.default.useRef(null),O=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),W=n.default.useRef(null),F=n.default.useRef(!1),H=n.default.useCallback(e=>{C(t=>{var r;return null!=(r=t.find(t=>t.id===e.id))&&r.delete||S.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return n.default.useEffect(()=>S.subscribe(e=>{e.dismiss?C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t)):setTimeout(()=>{w.default.flushSync(()=>{C(t=>{let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),{...t[r],...e},...t.slice(r+1)]:[e,...t]})})})}),[]),n.default.useEffect(()=>{if("system"!==u)return void z(u);if("system"===u&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?z("dark"):z("light")),"undefined"==typeof window)return;let e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{z(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{z(e?"dark":"light")}catch(e){console.error(e)}})}},[u]),n.default.useEffect(()=>{N.length<=1&&R(!1)},[N]),n.default.useEffect(()=>{let e=e=>{var t,r;s.every(t=>e[t]||e.code===t)&&(R(!0),null==(t=I.current)||t.focus()),"Escape"===e.code&&(document.activeElement===I.current||null!=(r=I.current)&&r.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s]),n.default.useEffect(()=>{if(I.current)return()=>{W.current&&(W.current.focus({preventScroll:!0}),W.current=null,F.current=!1)}},[I.current]),n.default.createElement("section",{ref:t,"aria-label":`${j} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((t,a)=>{var s;let u,[w,j]=t.split("-");return N.length?n.default.createElement("ol",{key:t,dir:"auto"===g?P():g,tabIndex:-1,ref:I,className:o,"data-sonner-toaster":!0,"data-theme":L,"data-y-position":w,"data-lifted":M&&N.length>1&&!l,"data-x-position":j,style:{"--front-toast-height":`${(null==(s=T[0])?void 0:s.height)||0}px`,"--width":"356px","--gap":`${v}px`,...f,...(u={},[d,c].forEach((e,t)=>{let r=1===t,n=r?"--mobile-offset":"--offset",a=r?"16px":"32px";function s(e){["top","right","bottom","left"].forEach(t=>{u[`${n}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?s(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?u[`${n}-${t}`]=a:u[`${n}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):s(a)}),u)},onBlur:e=>{F.current&&!e.currentTarget.contains(e.relatedTarget)&&(F.current=!1,W.current&&(W.current.focus({preventScroll:!0}),W.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||F.current||(F.current=!0,W.current=e.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{D||R(!1)},onDragEnd:()=>R(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||B(!0)},onPointerUp:()=>B(!1)},N.filter(e=>!e.position&&0===a||e.position===t).map((a,s)=>{var o,d;return n.default.createElement(A,{key:a.id,icons:y,index:s,toast:a,defaultRichColors:m,duration:null!=(o=null==p?void 0:p.duration)?o:h,className:null==p?void 0:p.className,descriptionClassName:null==p?void 0:p.descriptionClassName,invert:r,visibleToasts:x,closeButton:null!=(d=null==p?void 0:p.closeButton)?d:i,interacting:D,position:t,style:null==p?void 0:p.style,unstyled:null==p?void 0:p.unstyled,classNames:null==p?void 0:p.classNames,cancelButtonStyle:null==p?void 0:p.cancelButtonStyle,actionButtonStyle:null==p?void 0:p.actionButtonStyle,removeToast:H,toasts:N.filter(e=>e.position==a.position),heights:T.filter(e=>e.position==a.position),setHeights:E,expandByDefault:l,gap:v,loadingIcon:b,expanded:M,pauseWhenPageIsHidden:_,swipeDirections:e.swipeDirections})})):null}))});var L=e.i(37727);function z(e){if(!Number.isFinite(e))return"0:00";let t=Math.floor(e/60),r=Math.floor(e%60);return`${t}:${r.toString().padStart(2,"0")}`}function I({regions:e,audibleSegments:t,hasCustom:n,isCreatingCustom:a,onRemoveRegion:s,onClearAll:l,onCreateCustom:i,onSeekTo:o,onAddSegment:d}){let u=e.length>0,m=t.length>0;return(0,r.jsxs)("div",{className:"flex-1 bg-card border border-border rounded-lg p-3 flex flex-col gap-2 max-h-[140px]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("span",{className:"text-sm font-semibold",children:["Mute Regions ",u&&`(${e.length})`]}),u&&(0,r.jsxs)("div",{className:"flex gap-1.5",children:[(0,r.jsx)(c.Button,{variant:"secondary",size:"sm",onClick:l,className:"h-7 text-xs",children:"Clear"}),!n&&(0,r.jsx)(c.Button,{size:"sm",onClick:i,disabled:a,className:"h-7 text-xs",children:a?"Creating...":"Create Custom"})]})]}),u?(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 overflow-y-auto flex-1",children:e.map((e,t)=>(0,r.jsxs)("div",{className:"inline-flex items-center gap-1 px-2 py-1 bg-secondary rounded text-xs",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>o(e.start_seconds),className:"hover:text-primary cursor-pointer",children:[z(e.start_seconds)," - ",z(e.end_seconds)]}),(0,r.jsx)("button",{type:"button",onClick:()=>s(t),className:"text-muted-foreground hover:text-destructive ml-1",children:(0,r.jsx)(L.X,{className:"w-3 h-3"})})]},t))}):(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:m?"Click segments below or Shift + drag on waveform":"No backing vocals detected - clean instrumental recommended"}),m&&(0,r.jsxs)("div",{className:"flex flex-wrap gap-1",children:[t.slice(0,8).map((e,t)=>(0,r.jsxs)("button",{type:"button",onClick:()=>d(t),title:"Add to mute regions",className:"px-1.5 py-0.5 bg-background border border-border rounded text-[10px] text-muted-foreground hover:border-primary hover:text-primary transition-colors",children:[z(e.start_seconds)," - ",z(e.end_seconds)]},t)),t.length>8&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground px-1 py-0.5",children:["+",t.length-8," more"]})]})]})}var O=e.i(10708);function W({value:e,onChange:t,hasWithBacking:n,hasOriginal:a,hasCustom:s,hasUploaded:l,uploadedFilename:i,muteRegionsCount:d,backingVocalAnalysis:c}){let u=[{value:"clean",label:"Clean Instrumental",description:"No backing vocals",available:!0},{value:"with_backing",label:"With Backing Vocals",description:"All backing vocals included",available:n},{value:"original",label:"Original Audio",description:"Full original with lead vocals",available:a},{value:"custom",label:"Custom",description:`${d} region${1!==d?"s":""} muted`,available:s},{value:"uploaded",label:"Uploaded",description:i||"Custom instrumental file",available:l}].filter(e=>e.available);return(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)(O.Label,{className:"text-sm font-semibold",children:"Final Selection"}),(0,r.jsx)("div",{className:"flex flex-col gap-2",children:u.map(n=>(0,r.jsxs)("button",{type:"button",onClick:()=>t(n.value),className:(0,o.cn)("flex items-center gap-3 p-3 rounded-lg transition-all text-left","bg-secondary hover:bg-secondary/80","border-2 border-transparent",e===n.value&&"border-primary bg-primary/10"),children:[(0,r.jsx)("div",{className:(0,o.cn)("w-4 h-4 rounded-full border-2 flex items-center justify-center flex-shrink-0",e===n.value?"border-primary":"border-muted-foreground"),children:e===n.value&&(0,r.jsx)("div",{className:"w-2 h-2 rounded-full bg-primary"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"text-sm font-medium flex items-center gap-2",children:[n.label,c?.recommended_selection===n.value&&(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-green-500/20 text-green-500 rounded",children:"Recommended"})]}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:n.description})]})]},n.value))})]})}var F=e.i(69074);function H({onUpload:e,isUploading:t,acceptedFormats:a=[".flac",".mp3",".wav",".m4a",".ogg"]}){let s=(0,n.useRef)(null),l=async t=>{let r=t.target.files?.[0];if(r)try{await e(r)}finally{s.current&&(s.current.value="")}};return(0,r.jsx)(c.Button,{variant:"secondary",size:"sm",disabled:t,className:"relative h-8 text-xs",asChild:!0,children:(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)(F.Upload,{className:"w-3.5 h-3.5 mr-1.5"}),t?"Uploading...":"Upload",(0,r.jsx)("input",{ref:s,type:"file",accept:a.join(","),onChange:l,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:t})]})})}let $={original:"original",backing:"backing_vocals",clean:"clean_instrumental",with_backing:"with_backing",custom:"custom_instrumental",uploaded:"uploaded_instrumental"};function U(e){if(!Number.isFinite(e))return"0:00";let t=Math.floor(e/60),r=Math.floor(e%60);return`${t}:${r.toString().padStart(2,"0")}`}function Y({job:e,isLocalMode:t=!1}){let s=(0,a.useRouter)(),i=(0,n.useRef)(null),[o,m]=(0,n.useState)(null),[f,w]=(0,n.useState)(null),[v,b]=(0,n.useState)(!0),[y,j]=(0,n.useState)(null),[_,N]=(0,n.useState)("backing"),[C,k]=(0,n.useState)(!1),[S,T]=(0,n.useState)(0),[M,R]=(0,n.useState)(0),[A,P]=(0,n.useState)("with_backing"),[L,z]=(0,n.useState)([]),[O,F]=(0,n.useState)(!1),[Y,q]=(0,n.useState)(!1),[X,V]=(0,n.useState)(""),[J,K]=(0,n.useState)(1),[G,Z]=(0,n.useState)(!1),[Q,ee]=(0,n.useState)(!1),[et,er]=(0,n.useState)(!1),[en,ea]=(0,n.useState)(!1),es=o?.has_original??!1,el=!!o?.audio_urls.with_backing,ei=(0,n.useMemo)(()=>o?.analysis.audible_segments??[],[o?.analysis.audible_segments]),eo=(0,n.useCallback)(()=>{let e=i.current;e&&(C?e.pause():e.play().catch(()=>{}))},[C]);(0,n.useEffect)(()=>{!async function(){try{let[t,r]=await Promise.all([l.api.getInstrumentalAnalysis(e.job_id),l.api.getWaveformData(e.job_id)]);m(t),w(r);let n=t.analysis.recommended_selection;P("clean"===n?"clean":"with_backing");let a=r.duration_seconds??r.duration??0;R(a),t.has_uploaded_instrumental&&q(!0)}catch(e){j(e instanceof Error?e.message:"Failed to load data")}finally{b(!1)}}()},[e.job_id]),(0,n.useEffect)(()=>{let e=e=>{"Shift"===e.key&&ea(!0),e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||"Space"===e.code&&(e.preventDefault(),eo())},t=e=>{"Shift"===e.key&&ea(!1)};return document.addEventListener("keydown",e),document.addEventListener("keyup",t),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",t)}},[eo]),(0,n.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>k(!0),r=()=>k(!1),n=()=>k(!1),a=()=>{e.duration&&Number.isFinite(e.duration)&&R(e.duration)};return e.addEventListener("play",t),e.addEventListener("pause",r),e.addEventListener("ended",n),e.addEventListener("loadedmetadata",a),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",r),e.removeEventListener("ended",n),e.removeEventListener("loadedmetadata",a)}},[v]),(0,n.useEffect)(()=>{let e,t=i.current;if(!t||!C)return;let r=()=>{T(t.currentTime),e=requestAnimationFrame(r)};return e=requestAnimationFrame(r),()=>{cancelAnimationFrame(e)}},[C]);let ed=(0,n.useCallback)(()=>{let t=$[_];return l.api.getAudioStreamUrl(e.job_id,t)},[e.job_id,_]),ec=(0,n.useCallback)(t=>{let r=i.current;if(!r)return;let n=!r.paused,a=r.currentTime;r.pause(),N(t);let s=$[t];r.src=l.api.getAudioStreamUrl(e.job_id,s),r.addEventListener("loadeddata",()=>{r.currentTime=a,n&&r.play().catch(()=>{})},{once:!0})},[e.job_id]),eu=(0,n.useCallback)((e,t=!0)=>{let r=i.current;r&&Number.isFinite(e)&&(r.currentTime=e,T(e),t&&r.paused&&r.play().catch(()=>{}))},[]),em=(0,n.useCallback)((e,t)=>{z(r=>{let n=[...r,{start_seconds:e,end_seconds:t}];return n.sort((e,t)=>e.start_seconds-t.start_seconds),function(e){if(e.length<2)return e;let t=[e[0]];for(let r=1;r<e.length;r++){let n=t[t.length-1],a=e[r];a.start_seconds<=n.end_seconds+.5?n.end_seconds=Math.max(n.end_seconds,a.end_seconds):t.push(a)}return t}(n)}),F(!1)},[]),eh=(0,n.useCallback)(e=>{z(t=>t.filter((t,r)=>r!==e)),F(!1)},[]),ef=(0,n.useCallback)(()=>{z([]),F(!1)},[]),ex=(0,n.useCallback)(e=>{let t=ei[e];t&&em(t.start_seconds,t.end_seconds)},[ei,em]),ep=(0,n.useCallback)(async()=>{if(0===L.length)return;let t=i.current;t&&!t.paused&&t.pause(),Z(!0);try{await l.api.createCustomInstrumental(e.job_id,L),F(!0),P("custom"),N("custom"),t&&(t.src=l.api.getAudioStreamUrl(e.job_id,"custom_instrumental"),t.addEventListener("loadeddata",()=>{t.currentTime=S,C&&t.play().catch(()=>{})},{once:!0})),E.success("Custom instrumental created")}catch(e){E.error(e instanceof Error?e.message:"Failed to create custom"),C&&t&&t.play().catch(()=>{})}finally{Z(!1)}},[e.job_id,L,C,S]),eg=(0,n.useCallback)(async t=>{ee(!0);try{let r=await l.api.uploadCustomInstrumental(e.job_id,t);q(!0),V(t.name),N("uploaded"),P("uploaded");let n=i.current;if(n){let t=n.currentTime;n.src=l.api.getAudioStreamUrl(e.job_id,"uploaded_instrumental"),n.addEventListener("loadeddata",()=>{n.currentTime=t},{once:!0})}E.success(`Uploaded ${t.name} (${r.duration_seconds.toFixed(1)}s)`)}catch(e){E.error(e instanceof Error?e.message:"Upload failed")}finally{ee(!1)}},[e.job_id]),[ew,ev]=(0,n.useState)(!1),[eb,ey]=(0,n.useState)(2),ej=(0,n.useCallback)(async()=>{er(!0);try{await l.api.selectInstrumental(e.job_id,A),t?(ev(!0),ey(2)):(E.success("Selection submitted successfully"),setTimeout(()=>{s.push("/app")},1500))}catch(e){E.error(e instanceof Error?e.message:"Failed to submit selection"),er(!1)}},[e.job_id,A,s,t]);if((0,n.useEffect)(()=>{if(!ew)return;let e=setInterval(()=>{ey(t=>t<=1?(clearInterval(e),window.close(),0):t-1)},1e3);return()=>clearInterval(e)},[ew]),v)return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(d,{className:"w-8 h-8 mx-auto mb-4"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:"Loading instrumental analysis..."})]})});if(y)return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,r.jsx)("p",{className:"text-destructive mb-4",children:y}),!t&&(0,r.jsx)(c.Button,{variant:"outline",asChild:!0,children:(0,r.jsxs)(h.default,{href:"/app",children:[(0,r.jsx)(u.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back to dashboard"]})})]})});if(ew){let e={clean:"Clean Instrumental",with_backing:"With Backing Vocals",custom:"Custom",uploaded:"Uploaded Instrumental",original:"Original Audio"}[A]||A;return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsxs)("h2",{className:"text-2xl font-semibold text-green-500 mb-4",children:[(0,r.jsx)(g.Check,{className:"w-8 h-8 inline-block mr-2"}),"Selection Submitted"]}),(0,r.jsxs)("p",{className:"mb-2",children:["You selected: ",(0,r.jsx)("strong",{children:e})]}),(0,r.jsx)("p",{className:"text-muted-foreground",children:eb>0?`Closing in ${eb}s...`:"You can close this window now."})]})})}let e_=f?.amplitudes??[];return(0,r.jsxs)("div",{className:"flex flex-col h-screen bg-background p-4 gap-3 overflow-hidden",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between flex-shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("span",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,r.jsx)("img",{src:"https://gen.nomadkaraoke.com/nomad-karaoke-logo.svg",alt:"Nomad Karaoke",className:"h-10",onError:e=>{e.currentTarget.style.display="none"}}),"Instrumental Review"]}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[e.artist," ",e.artist&&e.title?"-":""," ",e.title]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[ei.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"px-2.5 py-1 rounded-full text-xs bg-secondary text-muted-foreground",children:[ei.length," segments"]}),(0,r.jsxs)("span",{className:"px-2.5 py-1 rounded-full text-xs bg-secondary text-muted-foreground",children:[o?.analysis.audible_percentage.toFixed(0),"% backing vocals"]})]}),(0,r.jsx)("span",{className:`px-2.5 py-1 rounded-full text-xs ${o?.analysis.recommended_selection==="clean"?"bg-green-500/15 text-green-500":"bg-amber-500/15 text-amber-500"}`,children:o?.analysis.recommended_selection==="clean"?"Clean recommended":"Review needed"})]})]}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col bg-card border border-border rounded-xl overflow-hidden min-h-0",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-secondary border-b border-border gap-3 flex-shrink-0 flex-wrap",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(c.Button,{size:"icon",onClick:eo,className:"rounded-full w-8 h-8",children:C?(0,r.jsx)(p,{className:"w-4 h-4"}):(0,r.jsx)(x,{className:"w-4 h-4 ml-0.5"})}),(0,r.jsxs)("span",{className:"font-mono text-sm min-w-[90px]",children:[U(S),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" / ",U(M)]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(D,{activeAudio:_,onAudioChange:ec,hasOriginal:es,hasWithBacking:el,hasCustom:O,hasUploaded:Y,uploadedFilename:X}),(0,r.jsx)(H,{onUpload:eg,isUploading:Q})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex bg-background rounded-md p-0.5",children:[1,2,4].map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>K(e),className:`w-7 h-7 rounded text-xs font-medium transition-colors ${J===e?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,children:[e,"x"]},e))}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[(0,r.jsx)("kbd",{className:"px-1.5 py-0.5 bg-background border border-border rounded text-[10px] font-mono",children:"Shift"}),"+drag"]}),(0,r.jsx)("kbd",{className:"px-1.5 py-0.5 bg-background border border-border rounded text-[10px] font-mono",children:"Space"})]})]}),(0,r.jsx)(B,{amplitudes:e_,duration:M,currentTime:S,muteRegions:L,audibleSegments:ei,zoomLevel:J,onSeek:eu,onRegionCreate:em,isShiftHeld:en}),(0,r.jsxs)("div",{className:"flex justify-between px-3 py-1 text-[10px] text-muted-foreground bg-black/40 flex-shrink-0",children:[(0,r.jsx)("span",{children:"0:00"}),(0,r.jsx)("span",{children:U(.25*M)}),(0,r.jsx)("span",{children:U(.5*M)}),(0,r.jsx)("span",{children:U(.75*M)}),(0,r.jsx)("span",{children:U(M)})]})]}),(0,r.jsx)("audio",{ref:i,src:ed(),className:"hidden"}),(0,r.jsxs)("div",{className:"flex gap-3 flex-shrink-0",children:[(0,r.jsx)(I,{regions:L,audibleSegments:ei,hasCustom:O,isCreatingCustom:G,onRemoveRegion:eh,onClearAll:ef,onCreateCustom:ep,onSeekTo:eu,onAddSegment:ex}),(0,r.jsxs)("div",{className:"w-[340px] bg-card border border-border rounded-lg p-3 flex flex-col gap-2",children:[(0,r.jsx)(W,{value:A,onChange:P,hasWithBacking:el,hasOriginal:es,hasCustom:O,hasUploaded:Y,uploadedFilename:X,muteRegionsCount:L.length,backingVocalAnalysis:o?.analysis}),(0,r.jsxs)(c.Button,{onClick:ej,disabled:et,className:"mt-auto w-full",children:[(0,r.jsx)(g.Check,{className:"w-4 h-4 mr-2"}),et?"Submitting...":"Confirm & Continue"]})]})]})]})}var q=e.i(78716),X=e.i(70065),V=e.i(74886);function J(e,t){return t.map(t=>(function(e,t){for(let r of e){let e=r.words.find(e=>e.id===t);if(e)return e}})(e,t)).filter(e=>void 0!==e)}var K=e.i(7233);function G({currentSource:e,onSourceChange:t,availableSources:n,onAddLyrics:a}){return(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 items-center",children:[n.map(n=>(0,r.jsx)(c.Button,{size:"sm",variant:e===n?"default":"outline",onClick:()=>t(n),className:"h-6 px-2 text-[0.7rem] leading-tight min-w-0",children:n.charAt(0).toUpperCase()+n.slice(1)},n)),a&&(0,r.jsxs)(c.Button,{size:"sm",variant:"outline",onClick:a,className:"h-6 px-2 text-[0.7rem] leading-tight min-w-0",children:[(0,r.jsx)(K.Plus,{className:"h-3 w-3 mr-0.5"}),"New"]})]})}var Z=e.i(28231);let Q="rgba(34, 197, 94, 0.25)",ee=n.default.memo(function({word:e,shouldFlash:t,isAnchor:n,isCorrectedGap:a,isUncorrectedGap:s,isCurrentlyPlaying:l,padding:i="px-[3px] py-[1px]",onClick:d,correction:c}){if(/^\s+$/.test(e))return(0,r.jsx)(r.Fragment,{children:e});let u=(0,r.jsx)("span",{className:(0,o.cn)("inline-block mr-[0.25em] transition-colors duration-200 cursor-pointer rounded-sm text-[0.85rem] leading-[1.2]",i,l?"bg-blue-500 text-white":n?"bg-blue-500/25":a?"bg-green-500/25":s?"bg-orange-500/25":"",t&&"animate-lyrics-flash",c&&"underline decoration-dotted underline-offset-2 decoration-muted-foreground","hover:bg-foreground/[0.08]"),onClick:d,children:e});return c?(0,r.jsx)(Z.TooltipProvider,{delayDuration:200,children:(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:u}),(0,r.jsx)(Z.TooltipContent,{side:"top",className:"max-w-xs",children:(0,r.jsxs)("div",{className:"text-xs space-y-0.5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:"Original:"}),' "',c.originalWord,'"']}),(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:"Corrected by:"})," ",c.handler]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:"Source:"})," ",c.source]}),c.reason&&(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:"Reason:"})," ",c.reason]}),void 0!==c.confidence&&c.confidence>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:"Confidence:"})," ",(100*c.confidence).toFixed(0),"%"]})]})})]})}):u}),et=(0,f.default)("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]),er=(0,f.default)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);var en=e.i(69638);function ea({word:e,originalWord:t,onRevert:n,onEdit:a,onAccept:s,onClick:l,backgroundColor:i,shouldFlash:d,showActions:u=!0}){let m=(e,t)=>{e.stopPropagation(),t()};return(0,r.jsxs)("span",{className:(0,o.cn)("inline-flex items-center gap-0.5 px-[3px] py-[1px] rounded-sm cursor-pointer relative","hover:bg-green-500/35",d&&"animate-pulse"),style:{backgroundColor:i||Q},onClick:l,children:[(0,r.jsx)("span",{className:"absolute -top-3.5 left-0 text-[0.6rem] text-muted-foreground line-through opacity-70 whitespace-nowrap pointer-events-none",children:t}),(0,r.jsx)("span",{className:"text-[0.85rem] leading-[1.2] font-semibold",children:e}),u&&(0,r.jsx)("span",{className:"inline-flex items-center gap-[1px] ml-0.5",children:(0,r.jsxs)(Z.TooltipProvider,{delayDuration:200,children:[(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsx)(c.Button,{size:"icon",variant:"ghost",className:"h-5 w-5 min-h-0 min-w-0 p-0.5 bg-slate-800/90 dark:bg-slate-800/90 border border-border hover:bg-slate-700 dark:hover:bg-slate-700 hover:scale-110 transition-transform",onClick:e=>m(e,n),"aria-label":"revert correction",children:(0,r.jsx)(et,{className:"h-3.5 w-3.5"})})}),(0,r.jsx)(Z.TooltipContent,{side:"top",children:"Revert to original"})]}),(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsx)(c.Button,{size:"icon",variant:"ghost",className:"h-5 w-5 min-h-0 min-w-0 p-0.5 bg-slate-800/90 dark:bg-slate-800/90 border border-border hover:bg-slate-700 dark:hover:bg-slate-700 hover:scale-110 transition-transform",onClick:e=>m(e,a),"aria-label":"edit correction",children:(0,r.jsx)(er,{className:"h-3.5 w-3.5"})})}),(0,r.jsx)(Z.TooltipContent,{side:"top",children:"Edit correction"})]}),(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsx)(c.Button,{size:"icon",variant:"ghost",className:"h-5 w-5 min-h-0 min-w-0 p-0.5 bg-slate-800/90 dark:bg-slate-800/90 border border-border hover:bg-slate-700 dark:hover:bg-slate-700 hover:scale-110 transition-transform text-green-500 hidden sm:flex",onClick:e=>m(e,s),"aria-label":"accept correction",children:(0,r.jsx)(en.CheckCircle,{className:"h-3.5 w-3.5"})})}),(0,r.jsx)(Z.TooltipContent,{side:"top",children:"Accept correction"})]})]})})]})}function es({text:e,segments:t,wordPositions:a=[],anchors:s,highlightInfo:l,mode:i,onElementClick:o,onWordClick:d,flashingType:u,isReference:m,currentSource:h="",preserveSegments:f=!1,linePositions:x=[],currentTime:p=0,referenceCorrections:g=new Map,gaps:w=[],flashingHandler:v,corrections:b=[],reviewMode:y=!1,onRevertCorrection:j,onEditCorrection:_,onAcceptCorrection:N,onShowCorrectionDetail:C}){let{handleWordClick:k}=function({mode:e,onElementClick:t,onWordClick:r,isReference:a=!1,currentSource:s="",gaps:l=[],anchors:i=[],corrections:o=[]}){return{handleWordClick:(0,n.useCallback)((n,d,c,u)=>{let m=c&&(a?c.reference_word_ids[s]?.includes(d):c.transcribed_word_ids.includes(d)),h=u||l.find(e=>e.transcribed_word_ids.includes(d)||Object.values(e.reference_word_ids).some(e=>e.includes(d))),f=h&&(a?h.reference_word_ids[s]?.includes(d):h.transcribed_word_ids.includes(d)||o.some(e=>e.corrected_word_id===d||e.word_id===d));if(a&&s){let e=l?.find(e=>e.reference_word_ids[s]?.includes(d));e&&(u=e)}"highlight"===e||"edit"===e||"delete_word"===e?m&&c?r?.({word_id:d,type:"anchor",anchor:c,gap:void 0}):f&&u||o.some(e=>(e.corrected_word_id===d||e.word_id===d)&&u?.transcribed_word_ids.includes(e.word_id))?r?.({word_id:d,type:"gap",anchor:void 0,gap:u}):r?.({word_id:d,type:"other",anchor:void 0,gap:void 0}):m&&c?t({type:"anchor",data:{...c,wordId:d,word:n,anchor_sequences:i}}):f&&u?t({type:"gap",data:{...u,wordId:d,word:n,anchor_sequences:i}}):a||t({type:"gap",data:{...{id:`synthetic-${d}`,transcribed_word_ids:[d],transcription_position:-1,preceding_anchor_id:null,following_anchor_id:null,reference_word_ids:{}},wordId:d,word:n,anchor_sequences:i}})},[e,r,t,a,s,l,i,o])}}({mode:i,onElementClick:o,onWordClick:d,isReference:m,currentSource:h,gaps:w,anchors:s,corrections:b}),S=e=>{if(!u)return!1;if("type"in e){if("handler"===u&&v)return b.some(t=>t.handler===v&&(t.corrected_word_id===e.word.id||t.word_id===e.word.id));let r=e.sequence,n=b.some(t=>(t.word_id===e.word.id||t.corrected_word_id===e.word.id)&&r?.transcribed_word_ids?.includes(t.word_id))||e.isCorrected;return!!("anchor"===u&&"anchor"===e.type||"corrected"===u&&n||"uncorrected"===u&&"gap"===e.type&&!n||"word"===u&&(l?.type==="anchor"&&"anchor"===e.type&&(m&&h&&l.sequence?J(t||[],l.sequence.reference_word_ids[h]||[]).some(t=>t.id===e.word.id):J(t||[],l.sequence.transcribed_word_ids).some(t=>t.id===e.word.id))||l?.type==="gap"&&"gap"===e.type&&(m&&h&&l.sequence?J(t||[],l.sequence.reference_word_ids[h]||[]).some(t=>t.id===e.word.id):J(t||[],l.sequence.transcribed_word_ids).some(t=>t.id===e.word.id))||l?.type==="correction"&&m&&h&&l.correction?.reference_positions?.[h]?.toString()===e.word.id))}return!1},T=e=>{if(m)return!1;if("type"in e&&void 0!==p&&"start_time"in e.word){let t=e.word;return null!==t.start_time&&null!==t.end_time&&p>=t.start_time&&p<=t.end_time}return!1},E=window.innerWidth<640;return(0,r.jsx)("div",{className:`font-mono m-0 leading-tight ${f?"whitespace-normal":"whitespace-pre-wrap"}`,children:(()=>{if(a&&!t)return a.map((e,t)=>{let s=b?.find(t=>t.corrected_word_id===e.word.id||t.word_id===e.word.id);return s&&"AgenticCorrector"===s.handler?(0,r.jsxs)(n.default.Fragment,{children:[(0,r.jsx)(ea,{word:e.word.text,originalWord:s.original_word,correction:{originalWord:s.original_word,handler:s.handler,confidence:s.confidence,source:s.source,reason:s.reason},shouldFlash:S(e),showActions:y&&!E,onRevert:()=>j?.(e.word.id),onEdit:()=>_?.(e.word.id),onAccept:()=>N?.(e.word.id),onClick:()=>{E?C?.(e.word.id):k(e.word.text,e.word.id,"anchor"===e.type?e.sequence:void 0,"gap"===e.type?e.sequence:void 0)}}),t<a.length-1&&" "]},e.word.id):(0,r.jsxs)(n.default.Fragment,{children:[(0,r.jsx)(ee,{word:e.word.text,shouldFlash:S(e),isAnchor:"anchor"===e.type,isCorrectedGap:e.isCorrected,isUncorrectedGap:"gap"===e.type&&!e.isCorrected,isCurrentlyPlaying:T(e),onClick:()=>k(e.word.text,e.word.id,"anchor"===e.type?e.sequence:void 0,"gap"===e.type?e.sequence:void 0),correction:s?{originalWord:s.original_word,handler:s.handler,confidence:s.confidence,source:s.source,reason:s.reason}:null}),t<a.length-1&&" "]},e.word.id)});if(t)return t.map(e=>(0,r.jsx)("div",{className:"flex items-start mb-0",children:(0,r.jsx)("div",{className:"flex-1",children:e.words.map((t,l)=>{let i=a.find(e=>e.word.id===t.id),o=i?.type==="anchor"?s?.find(e=>(e.reference_word_ids[h]||[]).includes(t.id)):void 0,d=g.has(t.id),c=i?.type==="gap"&&!d,u=i?.type==="gap"?i.sequence:void 0,m=b?.find(e=>e.corrected_word_id===t.id||e.word_id===t.id);if(m&&"AgenticCorrector"===m.handler)return(0,r.jsxs)(n.default.Fragment,{children:[(0,r.jsx)(ea,{word:t.text,originalWord:m.original_word,correction:{originalWord:m.original_word,handler:m.handler,confidence:m.confidence,source:m.source,reason:m.reason},shouldFlash:S(i||{word:t.text,id:t.id}),showActions:y&&!E,onRevert:()=>j?.(t.id),onEdit:()=>_?.(t.id),onAccept:()=>N?.(t.id),onClick:()=>{E?C?.(t.id):k(t.text,t.id,o,u)}}),l<e.words.length-1&&" "]},t.id);let f=m?{originalWord:m.original_word,handler:m.handler,confidence:m.confidence,source:m.source,reason:m.reason}:null;return(0,r.jsxs)(n.default.Fragment,{children:[(0,r.jsx)(ee,{word:t.text,shouldFlash:S(i||{word:t.text,id:t.id}),isAnchor:!!o,isCorrectedGap:d,isUncorrectedGap:c,isCurrentlyPlaying:T(i||{word:t.text,id:t.id}),onClick:()=>k(t.text,t.id,o,u),correction:f}),l<e.words.length-1&&" "]},t.id)})})},e.id));if(e){let t=e.split("\n"),n=0;return t.map((e,t)=>{let a=x?.find(e=>e.position===n);if(a?.isEmpty)return n++,(0,r.jsxs)("div",{className:"flex items-start mb-0 leading-none",children:[(0,r.jsx)("span",{className:"text-muted-foreground w-8 min-w-[2em] text-right mr-2 select-none font-mono pt-[1px] text-[0.8rem] leading-none",children:a.lineNumber}),(0,r.jsx)("div",{className:"w-[18px]"}),(0,r.jsx)("div",{className:"flex-1 h-4"})]},`empty-${t}`);let l=e.split(" "),i=[];return l.forEach((e,a)=>{if(""===e)return null;if(/^\s+$/.test(e))return i.push((0,r.jsx)("span",{children:" "},`space-${t}-${a}`));let l=`${h}-word-${n}`;n++;let o=h?s?.find(e=>e.reference_word_ids[h]?.includes(l)):void 0,d=g.has(l);i.push((0,r.jsx)(ee,{word:e,shouldFlash:S({word:e,id:l}),isAnchor:!!o,isCorrectedGap:d,isUncorrectedGap:!1,isCurrentlyPlaying:T({word:e,id:l}),onClick:()=>k(e,l,o,void 0)},l))}),(0,r.jsxs)("div",{className:"flex items-start mb-0 leading-none",children:[(0,r.jsx)("span",{className:"text-muted-foreground w-8 min-w-[2em] text-right mr-2 select-none font-mono pt-[1px] text-[0.8rem] leading-none",children:a?.lineNumber??t}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-[18px] w-[18px] min-h-0 min-w-0 p-[1px] mr-1",onClick:()=>{navigator.clipboard.writeText(e)},children:(0,r.jsx)(V.Copy,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("div",{className:"flex-1",children:i})]},`line-${t}`)})}return null})()})}function el({referenceSources:e,anchors:t,onElementClick:a,onWordClick:s,flashingType:l,corrected_segments:i,currentSource:o,onSourceChange:d,highlightInfo:u,mode:m,gaps:h,corrections:f,onAddLyrics:x}){let p=(0,n.useMemo)(()=>Object.keys(e),[e]),g=(0,n.useMemo)(()=>o||(p.length>0?p[0]:""),[o,p]),w=(0,n.useMemo)(()=>{let r=[],n=new Map;return t?.forEach(t=>{let r=t.reference_positions[g];void 0===r||(n.has(r)||n.set(r,[]),J(e[g].segments,t.reference_word_ids[g]||[]).forEach(e=>{let a={word:{id:e.id,text:e.text,start_time:e.start_time??void 0,end_time:e.end_time??void 0},type:"anchor",sequence:t,isInRange:!0};n.get(r).push(a)}))}),h?.forEach(r=>{let a=r.preceding_anchor_id?t?.find(e=>e.id===r.preceding_anchor_id):void 0,s=r.following_anchor_id?t?.find(e=>e.id===r.following_anchor_id):void 0,l=a?.reference_positions[g]??s?.reference_positions[g];if(void 0===l)return;let i=a?l+1:l-1;n.has(i)||n.set(i,[]),J(e[g].segments,r.reference_word_ids[g]||[]).forEach(e=>{let t=f?.some(t=>t.reference_positions?.[g]?.toString()===e.id&&r.transcribed_word_ids.includes(t.word_id)),a={word:{id:e.id,text:e.text,start_time:e.start_time??void 0,end_time:e.end_time??void 0},type:"gap",sequence:r,isInRange:!0,isCorrected:t};n.get(i).push(a)})}),Array.from(n.entries()).sort(([e],[t])=>e-t).forEach(([,e])=>{r.push(...e)}),r},[t,h,g,e,f]),{linePositions:v}=(0,n.useMemo)(()=>(function(e,t,r){let n=[],a=0,s=t?.map(t=>{let n=t.reference_word_ids[r];return n?.length?{referenceWordIds:n,transcriptionLine:e.findIndex(e=>{let r=e.words.map(e=>e.id);return!!r.length&&r.every(e=>t.transcribed_word_ids.includes(e))})}:null})?.filter(e=>null!==e)??[];s.sort((e,t)=>{let r=e.referenceWordIds[0],n=t.referenceWordIds[0];return r.localeCompare(n)});let l=0;for(s.forEach(e=>{for(;l<e.transcriptionLine;)n.push({position:a,lineNumber:l,isEmpty:!1}),a+=1,l++;n.push({position:a,lineNumber:l,isEmpty:!1}),l++,a++});l<e.length;)n.push({position:a,lineNumber:l,isEmpty:!1}),a+=1,l++;return{linePositions:n}})(i,t,g),[i,t,g]),b=(0,n.useMemo)(()=>{let e=new Map;return f?.forEach(t=>{let r=t.reference_positions?.[g];void 0!==r&&e.set(r.toString(),t.corrected_word)}),e},[f,g]),y=e[g]?.segments||[],j=e=>{navigator.clipboard.writeText(e)};return(0,r.jsx)(X.Card,{className:"p-2 relative",children:(0,r.jsxs)(X.CardContent,{className:"p-0",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Reference Lyrics"}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-5 w-5 min-h-0 min-w-0 p-0.5",onClick:()=>{j(y.map(e=>e.words.map(e=>e.text).join(" ")).join("\n"))},title:"Copy all reference lyrics",children:(0,r.jsx)(V.Copy,{className:"h-4 w-4"})})]}),(0,r.jsx)(G,{availableSources:p,currentSource:g,onSourceChange:d,onAddLyrics:x})]}),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:y.map((e,n)=>(0,r.jsxs)("div",{className:"flex items-start w-full hover:bg-muted/50 transition-colors",children:[(0,r.jsx)("div",{className:"flex items-center gap-0.5 pr-1",children:(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-[18px] w-[18px] min-h-0 min-w-0 p-[1px]",onClick:()=>j(e.words.map(e=>e.text).join(" ")),children:(0,r.jsx)(V.Copy,{className:"h-3.5 w-3.5"})})}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)(es,{wordPositions:w.filter(t=>e.words.some(e=>e.id===t.word.id)),segments:[e],anchors:t,onElementClick:a,onWordClick:s,flashingType:l,highlightInfo:u,mode:m,isReference:!0,currentSource:g,linePositions:v,referenceCorrections:b,gaps:h,preserveSegments:!0})})]},n))})]})})}var ei=e.i(30030),eo=e.i(48425),ed=e.i(42727),ec=e.i(81140),eu=e.i(69340),em=n.forwardRef((e,t)=>{let{pressed:n,defaultPressed:a=!1,onPressedChange:s,...l}=e,[i=!1,o]=(0,eu.useControllableState)({prop:n,onChange:s,defaultProp:a});return(0,r.jsx)(eo.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...l,ref:t,onClick:(0,ec.composeEventHandlers)(e.onClick,()=>{e.disabled||o(!i)})})});em.displayName="Toggle";var eh=e.i(86318),ef="ToggleGroup",[ex,ep]=(0,ei.createContextScope)(ef,[ed.createRovingFocusGroupScope]),eg=(0,ed.createRovingFocusGroupScope)(),ew=n.default.forwardRef((e,t)=>{let{type:n,...a}=e;if("single"===n)return(0,r.jsx)(ey,{...a,ref:t});if("multiple"===n)return(0,r.jsx)(ej,{...a,ref:t});throw Error(`Missing prop \`type\` expected on \`${ef}\``)});ew.displayName=ef;var[ev,eb]=ex(ef),ey=n.default.forwardRef((e,t)=>{let{value:a,defaultValue:s,onValueChange:l=()=>{},...i}=e,[o,d]=(0,eu.useControllableState)({prop:a,defaultProp:s,onChange:l});return(0,r.jsx)(ev,{scope:e.__scopeToggleGroup,type:"single",value:o?[o]:[],onItemActivate:d,onItemDeactivate:n.default.useCallback(()=>d(""),[d]),children:(0,r.jsx)(eC,{...i,ref:t})})}),ej=n.default.forwardRef((e,t)=>{let{value:a,defaultValue:s,onValueChange:l=()=>{},...i}=e,[o=[],d]=(0,eu.useControllableState)({prop:a,defaultProp:s,onChange:l}),c=n.default.useCallback(e=>d((t=[])=>[...t,e]),[d]),u=n.default.useCallback(e=>d((t=[])=>t.filter(t=>t!==e)),[d]);return(0,r.jsx)(ev,{scope:e.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:c,onItemDeactivate:u,children:(0,r.jsx)(eC,{...i,ref:t})})});ew.displayName=ef;var[e_,eN]=ex(ef),eC=n.default.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:a=!1,rovingFocus:s=!0,orientation:l,dir:i,loop:o=!0,...d}=e,c=eg(n),u=(0,eh.useDirection)(i),m={role:"group",dir:u,...d};return(0,r.jsx)(e_,{scope:n,rovingFocus:s,disabled:a,children:s?(0,r.jsx)(ed.Root,{asChild:!0,...c,orientation:l,dir:u,loop:o,children:(0,r.jsx)(eo.Primitive.div,{...m,ref:t})}):(0,r.jsx)(eo.Primitive.div,{...m,ref:t})})}),ek="ToggleGroupItem",eS=n.default.forwardRef((e,t)=>{let a=eb(ek,e.__scopeToggleGroup),s=eN(ek,e.__scopeToggleGroup),l=eg(e.__scopeToggleGroup),i=a.value.includes(e.value),o=s.disabled||e.disabled,d={...e,pressed:i,disabled:o},c=n.default.useRef(null);return s.rovingFocus?(0,r.jsx)(ed.Item,{asChild:!0,...l,focusable:!o,active:i,ref:c,children:(0,r.jsx)(eT,{...d,ref:t})}):(0,r.jsx)(eT,{...d,ref:t})});eS.displayName=ek;var eT=n.default.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:a,...s}=e,l=eb(ek,n),i={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},o="single"===l.type?i:void 0;return(0,r.jsx)(em,{...o,...s,ref:t,onPressedChange:e=>{e?l.onItemActivate(a):l.onItemDeactivate(a)}})}),eE=e.i(25913);let eM=(0,eE.cva)("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted/50 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-primary data-[state=on]:text-primary-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent border border-input",outline:"border border-input bg-transparent shadow-xs hover:border-primary hover:bg-primary/10"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),eR=n.createContext({size:"default",variant:"default"});function eA({className:e,variant:t,size:n,children:a,...s}){return(0,r.jsx)(ew,{"data-slot":"toggle-group","data-variant":t,"data-size":n,className:(0,o.cn)("group/toggle-group flex w-fit items-center rounded-md border border-input",e),...s,children:(0,r.jsx)(eR.Provider,{value:{variant:t,size:n},children:a})})}function eP({className:e,children:t,variant:a,size:s,...l}){let i=n.useContext(eR);return(0,r.jsx)(eS,{"data-slot":"toggle-group-item","data-variant":i.variant||a,"data-size":i.size||s,className:(0,o.cn)(eM({variant:i.variant||a,size:i.size||s}),"min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 border-0 border-r border-input last:border-r-0",e),...l,children:t})}var eD=e.i(27612);let eB=(0,f.default)("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);var eL=e.i(3116);let ez=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>((t&=63)<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),eI=(e,t)=>{let r={...e},n=r.corrected_segments[t];return r.corrected_segments=r.corrected_segments.filter((e,r)=>r!==t),r.anchor_sequences=r.anchor_sequences.map(e=>({...e,transcribed_word_ids:e.transcribed_word_ids.filter(e=>!n.words.some(t=>t.id===e))})),r.gap_sequences=r.gap_sequences.map(e=>({...e,transcribed_word_ids:e.transcribed_word_ids.filter(e=>!n.words.some(t=>t.id===e))})),r};var eO=e.i(30374);function eW({open:e,onClose:t,segment:n,segmentIndex:a}){return n&&null!==a?(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-lg",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsxs)(eO.DialogTitle,{children:["Segment ",a," Details"]})}),(0,r.jsx)("pre",{className:"m-0 font-mono text-sm whitespace-pre-wrap break-words overflow-auto max-h-[60vh] bg-muted p-4 rounded",children:JSON.stringify(n,null,2)})]})}):null}let eF=(0,f.default)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function eH({segments:e,corrections:t,anchors:n,gaps:a,onWordClick:s}){let l=(e,t,r)=>{let n=r-t;return 0===n?0:Math.max(0,Math.min(100,(e-t)/n*100))};return(0,r.jsx)("div",{className:"flex flex-col gap-3 p-2 overflow-x-auto min-w-full",children:e.map(e=>{let i=e.words.filter(e=>null!==e.start_time&&null!==e.end_time);if(0===i.length)return null;let d=Math.min(...i.map(e=>e.start_time)),c=Math.max(...i.map(e=>e.end_time));return(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-full",children:[(0,r.jsx)("div",{className:"relative h-5 border-b border-border mb-1",children:((e,t)=>{let n=[],a=Math.floor(e),s=Math.ceil(t);for(let i=a;i<=s;i+=2)if(i>=e&&i<=t){let a=l(i,e,t);n.push((0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"absolute w-[1px] h-2 bg-muted-foreground/50 bottom-0",style:{left:`${a}%`}}),(0,r.jsxs)("div",{className:"absolute text-[0.65rem] text-muted-foreground bottom-2.5 whitespace-nowrap -translate-x-1/2",style:{left:`${a}%`},children:[i,"s"]})]},i))}return n})(d,c)}),(0,r.jsx)("div",{className:"relative h-[60px] flex items-stretch min-w-full bg-background rounded mb-2",style:{touchAction:"pan-y"},children:e.words.map((i,u)=>{if(null===i.start_time||null===i.end_time)return null;let m=l(i.start_time,d,c),h=l(i.end_time,d,c),f=i.end_time-i.start_time,x=f>2,p=t.find(e=>e.corrected_word_id===i.id||e.word_id===i.id),g=n.some(e=>e.transcribed_word_ids.includes(i.id)),w=a.some(e=>e.transcribed_word_ids.includes(i.id))&&!p,v="hsl(var(--secondary))";return g?v="rgba(59, 130, 246, 0.25)":p?v=Q:w&&(v="rgba(249, 115, 22, 0.25)"),(0,r.jsxs)("div",{className:(0,o.cn)("absolute h-full flex flex-col justify-center items-center px-1 py-0.5","border-r border-white/30 text-[0.75rem] cursor-pointer transition-all","hover:opacity-80 hover:scale-[1.02] hover:z-10","overflow-hidden text-ellipsis whitespace-nowrap min-w-[20px]",x&&"border-2 border-red-500 shadow-[0_0_4px_rgba(244,67,54,0.5)]"),style:{left:`${m}%`,width:`${h-m}%`,backgroundColor:v},onClick:()=>s?.(i.id),children:[x&&(0,r.jsx)(eF,{className:"absolute -top-0.5 -right-0.5 h-4 w-4 text-red-500"}),p&&(0,r.jsx)("span",{className:"text-[0.65rem] text-muted-foreground leading-none mb-0.5 line-through opacity-85 font-medium bg-background/80 px-0.5 rounded-sm",children:p.original_word}),(0,r.jsx)("span",{className:(0,o.cn)("leading-tight overflow-hidden text-ellipsis whitespace-nowrap w-full text-center",p?"text-[0.85rem] font-bold text-green-400":"text-[0.75rem] font-medium"),children:i.text}),f>.1&&(0,r.jsxs)("span",{className:"text-[0.6rem] text-foreground/60 leading-none mt-0.5 font-semibold",children:[f.toFixed(1),"s"]})]},`${e.id}-${u}`)})})]},e.id)})})}function e$({data:e,onElementClick:t,onWordClick:a,flashingType:s,flashingHandler:l,highlightInfo:i,mode:o,onPlaySegment:d,currentTime:u=0,anchors:m=[],onDataChange:h,reviewMode:f=!1,onRevertCorrection:p,onEditCorrection:g,onAcceptCorrection:w,onShowCorrectionDetail:v}){let[b,y]=(0,n.useState)(null),[j,_]=(0,n.useState)("text");return(0,r.jsx)(X.Card,{className:"p-2",children:(0,r.jsxs)(X.CardContent,{className:"p-0",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Corrected Transcription"}),(0,r.jsxs)(eA,{type:"single",value:j,onValueChange:e=>e&&_(e),className:"h-7",children:[(0,r.jsxs)(eP,{value:"text","aria-label":"text view",className:"h-7 px-2.5 text-[0.75rem]",children:[(0,r.jsx)(eB,{className:"h-3.5 w-3.5 mr-1"}),"Text"]}),(0,r.jsxs)(eP,{value:"duration","aria-label":"duration view",className:"h-7 px-2.5 text-[0.75rem]",children:[(0,r.jsx)(eL.Clock,{className:"h-3.5 w-3.5 mr-1.5"}),"Timeline"]})]})]}),"duration"===j?(0,r.jsx)(eH,{segments:e.corrected_segments,corrections:e.corrections||[],anchors:e.anchor_sequences||[],gaps:e.gap_sequences||[],onWordClick:t=>{for(let r of e.corrected_segments)if(r.words.find(e=>e.id===t)){a?.({word_id:t,type:"other",anchor:void 0,gap:void 0});break}}}):(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:e.corrected_segments.map((n,b)=>{let j=n.words.map(t=>{let r=e.corrections?.find(e=>e.corrected_word_id===t.id||e.word_id===t.id),n=e.anchor_sequences?.find(e=>e.transcribed_word_ids.includes(t.id)),a=e.gap_sequences?.find(r=>{let n=r.transcribed_word_ids.includes(t.id),a=Object.values(r.reference_word_ids).some(e=>e.includes(t.id)),s=e.corrections.some(e=>(e.corrected_word_id===t.id||e.word_id===t.id)&&r.transcribed_word_ids.includes(e.word_id));return n||a||s});return{word:{id:t.id,text:t.text,start_time:t.start_time??void 0,end_time:t.end_time??void 0},type:n?"anchor":a?"gap":"other",sequence:n||a,isInRange:!0,isCorrected:!!r}});return(0,r.jsxs)("div",{className:"flex items-start w-full hover:bg-muted/50 transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center gap-0.5 min-w-[2.5em] pr-1",children:[(0,r.jsx)("span",{className:"text-muted-foreground w-[1.8em] text-right mr-1 select-none font-mono text-[0.8rem] leading-tight cursor-pointer hover:underline",onClick:()=>y(b),children:b}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-[18px] w-[18px] min-h-0 min-w-0 p-[1px] text-destructive hover:text-destructive",onClick:()=>{h&&h(eI(e,b))},title:"Delete segment",children:(0,r.jsx)(eD.Trash2,{className:"h-3.5 w-3.5"})}),null!==n.start_time&&(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-[18px] w-[18px] min-h-0 min-w-0 p-[1px]",onClick:()=>d?.(n.start_time),title:"Play segment",children:(0,r.jsx)(x,{className:"h-3.5 w-3.5"})})]}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)(es,{wordPositions:j,anchors:m,onElementClick:t,onWordClick:a,flashingType:s,flashingHandler:l,highlightInfo:i,mode:o,preserveSegments:!0,currentTime:u,gaps:e.gap_sequences,corrections:e.corrections,reviewMode:f,onRevertCorrection:p,onEditCorrection:g,onAcceptCorrection:w,onShowCorrectionDetail:v})})]},n.id)})}),(0,r.jsx)(eW,{open:null!==b,onClose:()=>y(null),segment:null!==b?e.corrected_segments[b]:null,segmentIndex:b})]})})}var eU=e.i(23750),eY=e.i(84762),eq=e.i(31278);function eX({open:e,onClose:t,onAdd:a}){let[s,l]=(0,n.useState)(""),[i,o]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[m,h]=(0,n.useState)(null),f=async()=>{if(s.trim()&&i.trim()){u(!0),h(null);try{await a(s.trim(),i.trim()),l(""),o(""),t()}catch(e){h(e instanceof Error?e.message:"Failed to add lyrics")}finally{u(!1)}}},x=()=>{d||(l(""),o(""),h(null),t())};return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&x(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-lg",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsx)(eO.DialogTitle,{children:"Add Reference Lyrics"})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{htmlFor:"source",children:"Source Name"}),(0,r.jsx)(eU.Input,{id:"source",value:s,onChange:e=>l(e.target.value),placeholder:"e.g., manual, genius, azlyrics...",disabled:d})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{htmlFor:"lyrics",children:"Lyrics"}),(0,r.jsx)(eY.Textarea,{id:"lyrics",value:i,onChange:e=>o(e.target.value),placeholder:"Paste lyrics here...",rows:10,disabled:d,className:"font-mono text-sm"})]}),m&&(0,r.jsx)("p",{className:"text-sm text-destructive",children:m})]}),(0,r.jsxs)(eO.DialogFooter,{children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:x,disabled:d,children:"Cancel"}),(0,r.jsx)(c.Button,{onClick:f,disabled:d||!s.trim()||!i.trim(),children:d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eq.Loader2,{className:"h-4 w-4 mr-2 animate-spin"}),"Adding..."]}):"Add Lyrics"})]})]})})}var eV=e.i(62870),eJ=e.i(70152),eK=e.i(20783),eG=e.i(99682),eZ=e.i(35804),eQ=e.i(75830),e0=["PageUp","PageDown"],e1=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],e2={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},e5="Slider",[e4,e8,e3]=(0,eQ.createCollection)(e5),[e6,e7]=(0,ei.createContextScope)(e5,[e3]),[e9,te]=e6(e5),tt=n.forwardRef((e,t)=>{let{name:a,min:s=0,max:l=100,step:i=1,orientation:o="horizontal",disabled:d=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[s],value:m,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:x=!1,form:p,...g}=e,w=n.useRef(new Set),v=n.useRef(0),b="horizontal"===o,[y=[],j]=(0,eu.useControllableState)({prop:m,defaultProp:u,onChange:e=>{let t=[...w.current];t[v.current]?.focus(),h(e)}}),_=n.useRef(y);function N(e,t,{commit:r}={commit:!1}){let n,a=(String(i).split(".")[1]||"").length,o=Math.round((Math.round((e-s)/i)*i+s)*(n=Math.pow(10,a)))/n,d=(0,eJ.clamp)(o,[s,l]);j((e=[])=>{let n=function(e=[],t,r){let n=[...e];return n[r]=t,n.sort((e,t)=>e-t)}(e,d,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,r)=>e[r+1]-t))>=t;return!0}(n,c*i))return e;{v.current=n.indexOf(d);let t=String(n)!==String(e);return t&&r&&f(n),t?n:e}})}return(0,r.jsx)(e9,{scope:e.__scopeSlider,name:a,disabled:d,min:s,max:l,valueIndexToChangeRef:v,thumbs:w.current,values:y,orientation:o,form:p,children:(0,r.jsx)(e4.Provider,{scope:e.__scopeSlider,children:(0,r.jsx)(e4.Slot,{scope:e.__scopeSlider,children:(0,r.jsx)(b?ta:ts,{"aria-disabled":d,"data-disabled":d?"":void 0,...g,ref:t,onPointerDown:(0,ec.composeEventHandlers)(g.onPointerDown,()=>{d||(_.current=y)}),min:s,max:l,inverted:x,onSlideStart:d?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let r=e.map(e=>Math.abs(e-t)),n=Math.min(...r);return r.indexOf(n)}(y,e);N(e,t)},onSlideMove:d?void 0:function(e){N(e,v.current)},onSlideEnd:d?void 0:function(){let e=_.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!d&&N(s,0,{commit:!0}),onEndKeyDown:()=>!d&&N(l,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!d){let r=e0.includes(e.key)||e.shiftKey&&e1.includes(e.key),n=v.current;N(y[n]+i*(r?10:1)*t,n,{commit:!0})}}})})})})});tt.displayName=e5;var[tr,tn]=e6(e5,{startEdge:"left",endEdge:"right",size:"width",direction:1}),ta=n.forwardRef((e,t)=>{let{min:a,max:s,dir:l,inverted:i,onSlideStart:o,onSlideMove:d,onSlideEnd:c,onStepKeyDown:u,...m}=e,[h,f]=n.useState(null),x=(0,eK.useComposedRefs)(t,e=>f(e)),p=n.useRef(void 0),g=(0,eh.useDirection)(l),w="ltr"===g,v=w&&!i||!w&&i;function b(e){let t=p.current||h.getBoundingClientRect(),r=tp([0,t.width],v?[a,s]:[s,a]);return p.current=t,r(e-t.left)}return(0,r.jsx)(tr,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,r.jsx)(tl,{dir:g,"data-orientation":"horizontal",...m,ref:x,style:{...m.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=b(e.clientX);o?.(t)},onSlideMove:e=>{let t=b(e.clientX);d?.(t)},onSlideEnd:()=>{p.current=void 0,c?.()},onStepKeyDown:e=>{let t=e2[v?"from-left":"from-right"].includes(e.key);u?.({event:e,direction:t?-1:1})}})})}),ts=n.forwardRef((e,t)=>{let{min:a,max:s,inverted:l,onSlideStart:i,onSlideMove:o,onSlideEnd:d,onStepKeyDown:c,...u}=e,m=n.useRef(null),h=(0,eK.useComposedRefs)(t,m),f=n.useRef(void 0),x=!l;function p(e){let t=f.current||m.current.getBoundingClientRect(),r=tp([0,t.height],x?[s,a]:[a,s]);return f.current=t,r(e-t.top)}return(0,r.jsx)(tr,{scope:e.__scopeSlider,startEdge:x?"bottom":"top",endEdge:x?"top":"bottom",size:"height",direction:x?1:-1,children:(0,r.jsx)(tl,{"data-orientation":"vertical",...u,ref:h,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=p(e.clientY);i?.(t)},onSlideMove:e=>{let t=p(e.clientY);o?.(t)},onSlideEnd:()=>{f.current=void 0,d?.()},onStepKeyDown:e=>{let t=e2[x?"from-bottom":"from-top"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),tl=n.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:a,onSlideMove:s,onSlideEnd:l,onHomeKeyDown:i,onEndKeyDown:o,onStepKeyDown:d,...c}=e,u=te(e5,n);return(0,r.jsx)(eo.Primitive.span,{...c,ref:t,onKeyDown:(0,ec.composeEventHandlers)(e.onKeyDown,e=>{"Home"===e.key?(i(e),e.preventDefault()):"End"===e.key?(o(e),e.preventDefault()):e0.concat(e1).includes(e.key)&&(d(e),e.preventDefault())}),onPointerDown:(0,ec.composeEventHandlers)(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),u.thumbs.has(t)?t.focus():a(e)}),onPointerMove:(0,ec.composeEventHandlers)(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&s(e)}),onPointerUp:(0,ec.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),l(e))})})}),ti="SliderTrack",to=n.forwardRef((e,t)=>{let{__scopeSlider:n,...a}=e,s=te(ti,n);return(0,r.jsx)(eo.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...a,ref:t})});to.displayName=ti;var td="SliderRange",tc=n.forwardRef((e,t)=>{let{__scopeSlider:a,...s}=e,l=te(td,a),i=tn(td,a),o=n.useRef(null),d=(0,eK.useComposedRefs)(t,o),c=l.values.length,u=l.values.map(e=>tx(e,l.min,l.max)),m=c>1?Math.min(...u):0,h=100-Math.max(...u);return(0,r.jsx)(eo.Primitive.span,{"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,...s,ref:d,style:{...e.style,[i.startEdge]:m+"%",[i.endEdge]:h+"%"}})});tc.displayName=td;var tu="SliderThumb",tm=n.forwardRef((e,t)=>{let a=e8(e.__scopeSlider),[s,l]=n.useState(null),i=(0,eK.useComposedRefs)(t,e=>l(e)),o=n.useMemo(()=>s?a().findIndex(e=>e.ref.current===s):-1,[a,s]);return(0,r.jsx)(th,{...e,ref:i,index:o})}),th=n.forwardRef((e,t)=>{var a,s,l,i,o;let d,c,{__scopeSlider:u,index:m,name:h,...f}=e,x=te(tu,u),p=tn(tu,u),[g,w]=n.useState(null),v=(0,eK.useComposedRefs)(t,e=>w(e)),b=!g||x.form||!!g.closest("form"),y=(0,eZ.useSize)(g),j=x.values[m],_=void 0===j?0:tx(j,x.min,x.max),N=(a=m,(s=x.values.length)>2?`Value ${a+1} of ${s}`:2===s?["Minimum","Maximum"][a]:void 0),C=y?.[p.size],k=C?(l=C,i=_,o=p.direction,c=tp([0,50],[0,d=l/2]),(d-c(i)*o)*o):0;return n.useEffect(()=>{if(g)return x.thumbs.add(g),()=>{x.thumbs.delete(g)}},[g,x.thumbs]),(0,r.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[p.startEdge]:`calc(${_}% + ${k}px)`},children:[(0,r.jsx)(e4.ItemSlot,{scope:e.__scopeSlider,children:(0,r.jsx)(eo.Primitive.span,{role:"slider","aria-label":e["aria-label"]||N,"aria-valuemin":x.min,"aria-valuenow":j,"aria-valuemax":x.max,"aria-orientation":x.orientation,"data-orientation":x.orientation,"data-disabled":x.disabled?"":void 0,tabIndex:x.disabled?void 0:0,...f,ref:v,style:void 0===j?{display:"none"}:e.style,onFocus:(0,ec.composeEventHandlers)(e.onFocus,()=>{x.valueIndexToChangeRef.current=m})})}),b&&(0,r.jsx)(tf,{name:h??(x.name?x.name+(x.values.length>1?"[]":""):void 0),form:x.form,value:j},m)]})});tm.displayName=tu;var tf=e=>{let{value:t,...a}=e,s=n.useRef(null),l=(0,eG.usePrevious)(t);return n.useEffect(()=>{let e=s.current,r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(l!==t&&r){let n=new Event("input",{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[l,t]),(0,r.jsx)("input",{style:{display:"none"},...a,ref:s,defaultValue:t})};function tx(e,t,r){return(0,eJ.clamp)(100/(r-t)*(e-t),[0,100])}function tp(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function tg({className:e,defaultValue:t,value:a,min:s=0,max:l=100,...i}){let d=n.useMemo(()=>Array.isArray(a)?a:Array.isArray(t)?t:[s,l],[a,t,s,l]);return(0,r.jsxs)(tt,{"data-slot":"slider",defaultValue:t,value:a,min:s,max:l,className:(0,o.cn)("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[(0,r.jsx)(to,{"data-slot":"slider-track",className:"bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",children:(0,r.jsx)(tc,{"data-slot":"slider-range",className:"bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),Array.from({length:d.length},(e,t)=>(0,r.jsx)(tm,{"data-slot":"slider-thumb",className:"border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},t))]})}var tw=e.i(94179);let tv=(0,eE.cva)("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function tb({className:e,variant:t,...n}){return(0,r.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,o.cn)(tv({variant:t}),e),...n})}function ty({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"alert-description",className:(0,o.cn)("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}let tj=[{value:"SOUND_ALIKE",label:"Sound-Alike Error",description:'Homophones or similar-sounding words (e.g., "out" vs "now")'},{value:"BACKGROUND_VOCALS",label:"Background Vocals",description:"Backing vocals that should be removed from karaoke"},{value:"EXTRA_WORDS",label:"Extra Filler Words",description:'Transcription added words like "And", "But", "Well"'},{value:"PUNCTUATION_ONLY",label:"Punctuation/Style Only",description:"Only punctuation or capitalization differences"},{value:"REPEATED_SECTION",label:"Repeated Section",description:"Chorus or verse repetition not in condensed references"},{value:"COMPLEX_MULTI_ERROR",label:"Complex Multi-Error",description:"Multiple different error types in one section"},{value:"AMBIGUOUS",label:"Ambiguous",description:"Unclear without listening to audio"},{value:"NO_ERROR",label:"No Error",description:"Transcription matches at least one reference source"},{value:"MANUAL_EDIT",label:"Manual Edit",description:"Human-initiated correction not from detected gap"}],t_={1:"1 - Very Uncertain",2:"2 - Somewhat Uncertain",3:"3 - Neutral",4:"4 - Fairly Confident",5:"5 - Very Confident"};function tN({open:e,onClose:t,onSave:a,onSkip:s,originalText:l,correctedText:i,wordIdsAffected:o,agenticProposal:d,referenceSources:u,audioHash:m,artist:h,title:f,sessionId:x,gapId:p}){let[g,w]=(0,n.useState)("MANUAL_EDIT"),[v,b]=(0,n.useState)("REPLACE"),[y,j]=(0,n.useState)(3),[_,N]=(0,n.useState)(""),[C,k]=(0,n.useState)(!1),[S,T]=(0,n.useState)("");(0,n.useEffect)(()=>{d&&d.gap_category&&(w(d.gap_category),k(!!d.replacement_text&&i.toLowerCase().includes(d.replacement_text.toLowerCase())))},[d,i]),(0,n.useEffect)(()=>{l===i?b("NO_ACTION"):""===i?b("DELETE"):""===l?b("INSERT"):b("REPLACE")},[l,i]);let E=()=>{w("MANUAL_EDIT"),j(3),N(""),T(""),k(!1),t()};return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&E(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[(0,r.jsxs)(eO.DialogHeader,{children:[(0,r.jsx)(eO.DialogTitle,{children:"Annotate Your Correction"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Help improve the AI by explaining your correction"})]}),(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"bg-muted p-4 rounded-lg",children:[(0,r.jsx)("h4",{className:"text-sm font-medium mb-2",children:"Your Correction:"}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("span",{className:"text-xs text-destructive",children:"Original:"}),(0,r.jsx)("p",{className:"font-mono text-sm line-through text-destructive",children:l||"(empty)"})]}),(0,r.jsx)("span",{className:"text-lg",children:"→"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("span",{className:"text-xs text-green-500",children:"Corrected:"}),(0,r.jsx)("p",{className:"font-mono text-sm font-bold text-green-500",children:i||"(empty)"})]})]})]}),d&&(0,r.jsx)(tb,{variant:"default",children:(0,r.jsxs)(ty,{children:[(0,r.jsx)("h4",{className:"font-medium mb-2",children:"AI Suggestion:"}),(0,r.jsxs)("p",{className:"text-sm",children:["Category: ",(0,r.jsx)("strong",{children:d.gap_category})]}),(0,r.jsxs)("p",{className:"text-sm",children:["Action: ",(0,r.jsx)("strong",{children:d.action}),d.replacement_text&&` → "${d.replacement_text}"`]}),(0,r.jsxs)("p",{className:"text-sm",children:["Reason: ",d.reason]}),(0,r.jsx)("p",{className:"text-sm mt-2",children:C?"✓ Your correction matches the AI suggestion":"✗ Your correction differs from the AI suggestion"})]})}),u.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-sm font-medium mb-2",children:"Reference Sources Consulted:"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:u.map(e=>(0,r.jsx)(tw.Badge,{variant:"secondary",children:e},e))})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{children:"Correction Type *"}),(0,r.jsxs)(eV.Select,{value:g,onValueChange:e=>w(e),children:[(0,r.jsx)(eV.SelectTrigger,{children:(0,r.jsx)(eV.SelectValue,{placeholder:"Select correction type"})}),(0,r.jsx)(eV.SelectContent,{children:tj.map(e=>(0,r.jsx)(eV.SelectItem,{value:e.value,children:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-medium",children:e.label}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description})]})},e.value))})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{children:"Confidence in Your Correction *"}),(0,r.jsx)(tg,{value:[y],min:1,max:5,step:1,onValueChange:([e])=>j(e)}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:t_[y]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{htmlFor:"reasoning",children:"Reasoning *"}),(0,r.jsx)(eY.Textarea,{id:"reasoning",value:_,onChange:e=>{N(e.target.value),T("")},placeholder:"Explain why this correction is needed (minimum 10 characters)...",rows:4,className:S?"border-destructive":""}),(0,r.jsx)("p",{className:`text-sm ${S?"text-destructive":"text-muted-foreground"}`,children:S||`${_.length}/10 minimum characters`})]})]}),(0,r.jsxs)(eO.DialogFooter,{children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:()=>{E(),s()},children:"Skip"}),(0,r.jsx)(c.Button,{onClick:()=>{if(_.length<10)return void T("Reasoning must be at least 10 characters");let e={audio_hash:m,gap_id:p||null,annotation_type:g,action_taken:v,original_text:l,corrected_text:i,confidence:y,reasoning:_,word_ids_affected:o,agentic_proposal:d||null,agentic_category:d?.gap_category||null,agentic_agreed:C,reference_sources_consulted:u,artist:h,title:f,session_id:x};a(e),E()},children:"Save & Continue"})]})]})})}let tC=(0,f.default)("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var tk=e.i(67240);let tS=(0,f.default)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),tT=(0,f.default)("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]),tE=(0,f.default)("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]),tM=(0,f.default)("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);function tR({onAddWord:e,onMergeWords:t,onAddSegmentBefore:n,onAddSegmentAfter:a,onSplitSegment:s,onMergeSegment:l,canMerge:i=!1,isFirst:d=!1,isLast:u=!1,className:m}){return(0,r.jsx)("div",{className:(0,o.cn)("flex items-center justify-center h-auto min-h-[20px] my-0 w-full overflow-hidden",m),children:(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-center px-2 z-10",children:[(0,r.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:e,title:"Add Word",className:"h-6 px-2 text-primary text-[0.7rem]",children:[(0,r.jsx)(K.Plus,{className:"h-4 w-4 mr-1"}),"Add Word"]}),d&&n&&l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:n,title:"Add Segment",className:"h-6 px-2 text-green-500 text-[0.7rem]",children:[(0,r.jsx)(K.Plus,{className:"h-4 w-4 mr-1 rotate-90"}),"Add Segment"]}),(0,r.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:l,title:"Merge with Previous Segment",className:"h-6 px-2 text-yellow-500 text-[0.7rem]",children:[(0,r.jsx)(tM,{className:"h-4 w-4 mr-1 rotate-90"}),"Merge Segment"]})]}),t&&!u&&(0,r.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:t,disabled:!i,title:"Merge Words",className:"h-6 px-2 text-primary text-[0.7rem] disabled:opacity-50",children:[(0,r.jsx)(tM,{className:"h-4 w-4 mr-1 rotate-90"}),"Merge Words"]}),s&&!u&&(0,r.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:s,title:"Split Segment",className:"h-6 px-2 text-yellow-500 text-[0.7rem]",children:[(0,r.jsx)(tT,{className:"h-4 w-4 mr-1 rotate-90"}),"Split Segment"]}),u&&a&&l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:a,title:"Add Segment",className:"h-6 px-2 text-green-500 text-[0.7rem]",children:[(0,r.jsx)(K.Plus,{className:"h-4 w-4 mr-1 rotate-90"}),"Add Segment"]}),(0,r.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:l,title:"Merge with Next Segment",className:"h-6 px-2 text-yellow-500 text-[0.7rem]",children:[(0,r.jsx)(tM,{className:"h-4 w-4 mr-1 rotate-90"}),"Merge Segment"]})]})]})})}let tA=(0,n.memo)(function({word:e,index:t,onWordUpdate:n,onSplitWord:a,onRemoveWord:s,wordsLength:l,onTabNavigation:i,isMobile:o}){return(0,r.jsxs)("div",{className:`flex ${o?"flex-col gap-2":"flex-row gap-4"} items-${o?"stretch":"end"} py-1`,children:[(0,r.jsxs)("div",{className:`flex gap-2 items-end ${o?"":"flex-1"}`,children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)(O.Label,{htmlFor:`word-text-${t}`,className:"text-xs text-muted-foreground mb-1",children:["Word ",t]}),(0,r.jsx)(eU.Input,{id:`word-text-${t}`,value:e.text,onChange:e=>n(t,{text:e.target.value}),onKeyDown:e=>{"Tab"!==e.key||e.shiftKey||(e.preventDefault(),i(t))},className:"h-8"})]}),o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:()=>a(t),title:"Split Word",className:"h-8 w-8 text-primary",children:(0,r.jsx)(tT,{className:"h-4 w-4"})}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:()=>s(t),disabled:l<=1,title:"Remove Word",className:"h-8 w-8 text-destructive",children:(0,r.jsx)(eD.Trash2,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:`flex gap-2 items-end ${o?"justify-start":"justify-end"}`,children:[(0,r.jsxs)("div",{className:`${o?"w-20":"w-24"}`,children:[(0,r.jsx)(O.Label,{className:"text-xs text-muted-foreground mb-1",children:"Start"}),(0,r.jsx)(eU.Input,{type:"number",value:e.start_time?.toFixed(2)??"",onChange:e=>n(t,{start_time:parseFloat(e.target.value)}),step:.01,className:"h-8"})]}),(0,r.jsxs)("div",{className:`${o?"w-20":"w-24"}`,children:[(0,r.jsx)(O.Label,{className:"text-xs text-muted-foreground mb-1",children:"End"}),(0,r.jsx)(eU.Input,{type:"number",value:e.end_time?.toFixed(2)??"",onChange:e=>n(t,{end_time:parseFloat(e.target.value)}),step:.01,className:"h-8"})]}),!o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:()=>a(t),title:"Split Word",className:"h-8 w-8 text-primary",children:(0,r.jsx)(tT,{className:"h-4 w-4"})}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:()=>s(t),disabled:l<=1,title:"Remove Word",className:"h-8 w-8 text-destructive",children:(0,r.jsx)(eD.Trash2,{className:"h-4 w-4"})})]})]})]})}),tP=(0,n.memo)(function({word:e,index:t,onWordUpdate:n,onSplitWord:a,onRemoveWord:s,onAddWord:l,onMergeWords:i,onSplitSegment:o,onAddSegment:d,onMergeSegment:c,wordsLength:u,isGlobal:m,onTabNavigation:h,isMobile:f}){return(0,r.jsxs)("div",{children:[(0,r.jsx)(tA,{word:e,index:t,onWordUpdate:n,onSplitWord:a,onRemoveWord:s,wordsLength:u,onTabNavigation:h,isMobile:f}),!m&&(0,r.jsx)(tR,{onAddWord:()=>l(t),onMergeWords:()=>i(t),onSplitSegment:()=>o?.(t),onAddSegmentAfter:t===u-1?()=>d?.(t+1):void 0,onMergeSegment:t===u-1?()=>c?.(!0):void 0,canMerge:t<u-1,isLast:t===u-1}),m&&(0,r.jsx)(tR,{onAddWord:()=>l(t),onMergeWords:t<u-1?()=>i(t):void 0,canMerge:t<u-1})]},e.id)});function tD({words:e,onWordUpdate:t,onSplitWord:a,onMergeWords:s,onAddWord:l,onRemoveWord:i,onReplaceAllWords:o,onSplitSegment:d,onAddSegment:u,onMergeSegment:m,isGlobal:h=!1}){let f=window.innerWidth<640,[x,p]=(0,n.useState)(""),[g,w]=(0,n.useState)(1),v=h?50:e.length,b=Math.ceil(e.length/v),y=(g-1)*v,j=Math.min(y+v,e.length),_=(0,n.useMemo)(()=>h?e.slice(y,j):e,[e,h,y,j]),N=t=>{let r=(t+1)%e.length;h&&(r<y||r>=j)?(w(Math.floor(r/v)+1),setTimeout(()=>{C(r)},50)):C(r)},C=e=>{let t=document.getElementById(`word-text-${e}`);t&&(t.focus(),t.select())};return(0,r.jsxs)("div",{className:"flex flex-col gap-2 flex-grow min-h-0",children:[!h&&(0,r.jsx)(tR,{onAddWord:()=>l(-1),onAddSegmentBefore:()=>u?.(0),onMergeSegment:()=>m?.(!1),isFirst:!0}),h&&(0,r.jsx)(tR,{onAddWord:()=>l(-1)}),(0,r.jsx)("div",{className:"flex flex-col gap-1 flex-grow overflow-y-auto mb-0 pt-2 scrollbar-thin",children:_.map((n,o)=>{let c=h?y+o:o;return(0,r.jsx)(tP,{word:n,index:c,onWordUpdate:t,onSplitWord:a,onRemoveWord:i,onAddWord:l,onMergeWords:s,onSplitSegment:d,onAddSegment:u,onMergeSegment:m,wordsLength:e.length,isGlobal:h,onTabNavigation:N,isMobile:f},n.id)})}),h&&b>1&&(0,r.jsxs)("div",{className:"flex justify-center items-center gap-2 mb-2",children:[(0,r.jsx)(c.Button,{variant:"outline",size:"sm",onClick:()=>w(e=>Math.max(1,e-1)),disabled:1===g,children:"Previous"}),(0,r.jsxs)("span",{className:"text-sm",children:["Page ",g," of ",b]}),(0,r.jsx)(c.Button,{variant:"outline",size:"sm",onClick:()=>w(e=>Math.min(b,e+1)),disabled:g===b,children:"Next"}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground ml-2",children:["Words ",y+1,"-",j," of ",e.length]})]}),(0,r.jsxs)("div",{className:"flex gap-2 mb-1",children:[(0,r.jsx)(eU.Input,{value:x,onChange:e=>p(e.target.value),placeholder:"Replace all words",className:"flex-grow"}),(0,r.jsxs)(c.Button,{onClick:()=>{o?o(x):x.trim().split(/\s+/).forEach((r,n)=>{n<e.length&&t(n,{text:r})}),p("")},size:"sm",className:"whitespace-nowrap",children:[(0,r.jsx)(tE,{className:"h-4 w-4 mr-1"}),"Replace All"]})]})]})}var tB=e.i(73884);let tL=(0,f.default)("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);function tz({words:e,startTime:t,endTime:a,onWordUpdate:s,onUnsyncWord:l,currentTime:i=0,onPlaySegment:d,showPlaybackIndicator:c=!0}){let u=(0,n.useRef)(null),[m,h]=(0,n.useState)(null),f=(t,r,n,a)=>{if(a){if(n===e.length-1)return!1;let t=e[n+1];return!!t&&null!==t.start_time&&r>t.start_time}return e.some((e,a)=>a!==n&&null!==e.start_time&&null!==e.end_time&&(t>=e.start_time&&t<=e.end_time||r>=e.start_time&&r<=e.end_time||t<=e.start_time&&r>=e.end_time))},x=e=>Math.max(0,Math.min(100,(e-t)/(a-t)*100)),p=(r,n,s)=>{let l=u.current?.getBoundingClientRect();if(!l)return;let i=e[n];if(null===i.start_time||null===i.end_time)return;let o=r.clientX-l.left,d=o/l.width*(a-t);h({wordIndex:n,type:s,initialX:o,initialTime:d,word:i})},g=()=>{h(null)};return(0,r.jsxs)("div",{ref:u,className:"relative h-[75px] bg-card rounded my-2 px-2 border border-border",onMouseMove:r=>{if(!m||!u.current)return;let n=u.current.getBoundingClientRect(),l=r.clientX-n.left,i=n.width,o=e[m.wordIndex];if(null!==o.start_time&&null!==o.end_time&&null!==m.word.start_time&&null!==m.word.end_time){if("resize-right"===m.type){let e=m.word.end_time-m.word.start_time,r=l-m.initialX,n=Math.max(o.start_time+.1,m.word.end_time+r/(e/(a-t)*i)*e);if(f(o.start_time,n,m.wordIndex,!0))return;s(m.wordIndex,{start_time:o.start_time,end_time:n})}else if("resize-left"===m.type){let e=m.word.end_time-m.word.start_time,r=l-m.initialX,n=Math.min(o.end_time-.1,m.word.start_time+r/(e/(a-t)*i)*e);if(f(n,o.end_time,m.wordIndex,!0))return;s(m.wordIndex,{start_time:n,end_time:o.end_time})}else if("move"===m.type){let e=l-m.initialX,r=o.end_time-o.start_time,n=m.word.start_time+e/(i/(a-t)),d=n+r;if(n<t||d>a||f(n,d,m.wordIndex,!1))return;s(m.wordIndex,{start_time:n,end_time:d})}}},onMouseUp:g,onMouseLeave:g,children:[(0,r.jsx)("div",{className:"absolute top-0 left-0 right-0 h-10 border-b border-border cursor-pointer",onClick:e=>{let r=u.current?.getBoundingClientRect();r&&d&&d((e.clientX-r.left)/r.width*(a-t)+t)},children:(()=>{let e=[],n=Math.floor(t),s=Math.ceil(a);for(let l=n;l<=s;l++)if(l>=t&&l<=a){let t=x(l);e.push((0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"absolute top-5 w-[1px] h-[18px] bg-muted-foreground",style:{left:`${t}%`}}),(0,r.jsxs)("div",{className:"absolute top-[5px] -translate-x-1/2 text-[0.8rem] font-bold text-foreground bg-card px-1 rounded-sm",style:{left:`${t}%`},children:[l,"s"]})]},l))}return e})()}),c&&i>=t&&i<=a&&(0,r.jsx)("div",{className:"absolute top-0 w-0.5 h-full bg-destructive pointer-events-none transition-[left] duration-100 z-10",style:{left:`${x(i)}%`}}),e.map((t,n)=>{if(null===t.start_time||null===t.end_time)return null;let a=x(t.start_time),s=x(t.end_time);return(0,r.jsxs)("div",{className:(0,o.cn)("absolute h-[30px] top-10 bg-primary rounded text-primary-foreground px-2 py-1","cursor-move select-none flex items-center text-sm font-sans transition-colors",!!i&&null!==t.start_time&&null!==t.end_time&&i>=t.start_time&&i<=t.end_time&&"bg-purple-500 dark:bg-purple-600"),style:{left:`${a}%`,width:`${s-a}%`,maxWidth:`calc(${100-a}%)`},onMouseDown:e=>{e.stopPropagation(),p(e,n,"move")},onContextMenu:t=>{let r;return t.preventDefault(),t.stopPropagation(),void(null!==(r=e[n]).start_time&&null!==r.end_time&&l&&l(n))},children:[(0,r.jsx)("div",{className:"absolute top-0 left-0 w-2.5 h-full cursor-col-resize hover:bg-primary-foreground/20 rounded-l",onMouseDown:e=>{e.stopPropagation(),p(e,n,"resize-left")}}),t.text,(0,r.jsx)("div",{className:"absolute top-0 right-0 w-2.5 h-full cursor-col-resize hover:bg-primary-foreground/20 rounded-r",onMouseDown:e=>{e.stopPropagation(),p(e,n,"resize-right")}})]},n)})]})}let tI=(0,n.memo)(function({isSpacebarPressed:e,onTapStart:t,onTapEnd:a}){let s=(0,n.useRef)(!1),l=(0,n.useCallback)(()=>{s.current=!0,t()},[t]),i=(0,n.useCallback)(()=>{s.current&&(s.current=!1,a())},[a]);return(0,r.jsxs)(c.Button,{variant:e?"secondary":"default",onTouchStart:e=>{e.preventDefault(),l()},onTouchEnd:e=>{e.preventDefault(),i()},onMouseDown:l,onMouseUp:i,onMouseLeave:i,className:(0,o.cn)("py-6 text-lg font-bold w-full min-h-[56px] select-none touch-manipulation",e&&"bg-secondary"),children:[(0,r.jsx)(tL,{className:"h-5 w-5 mr-2"}),e?"HOLD...":"TAP"]})});function tO({words:e,startTime:t,endTime:n,originalStartTime:a,originalEndTime:s,currentStartTime:l,currentEndTime:i,currentTime:d,isManualSyncing:u,syncWordIndex:m,isSpacebarPressed:h,onWordUpdate:f,onPlaySegment:p,startManualSync:g,isGlobal:w=!1,onTapStart:v,onTapEnd:b}){let y=window.innerWidth<640,j=u&&m>=0&&m<e.length?{index:m+1,total:e.length,text:e[m]?.text||""}:null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:(0,o.cn)("mb-0",y?"h-20":"h-[120px]"),children:(0,r.jsx)(tz,{words:e,startTime:t,endTime:n,onWordUpdate:f,currentTime:d,onPlaySegment:p})}),(0,r.jsxs)("div",{className:(0,o.cn)("flex items-center justify-between gap-2",y?"flex-col items-stretch mt-2 mb-3":"flex-row mt-0 mb-0"),children:[!y&&(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,r.jsxs)("div",{children:["Original Time Range: ",a?.toFixed(2)??"N/A"," -"," ",s?.toFixed(2)??"N/A"]}),(0,r.jsxs)("div",{children:["Current Time Range: ",l?.toFixed(2)??"N/A"," -"," ",i?.toFixed(2)??"N/A"]})]}),(0,r.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2",y?"flex-col items-stretch":"flex-row"),children:[(0,r.jsx)(c.Button,{variant:u?"outline":"default",onClick:g,className:(0,o.cn)(u?"border-destructive text-destructive hover:bg-destructive/10":"bg-primary"),children:u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tB.XCircle,{className:"h-4 w-4 mr-1"}),"Cancel"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x,{className:"h-4 w-4 mr-1"}),"Tap To Sync"]})}),j&&(0,r.jsxs)("div",{className:(0,o.cn)("text-center",y?"":"text-left"),children:[(0,r.jsxs)("div",{className:"text-sm",children:["Word ",j.index," of ",j.total,":"," ",(0,r.jsx)("strong",{children:j.text})]}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:h?"Holding... Release when word ends":y?"Tap the button when word starts":"Press spacebar when word starts (tap for short words, hold for long words)"})]}),y&&u&&v&&b&&(0,r.jsx)(tI,{isSpacebarPressed:h,onTapStart:v,onTapEnd:b})]})]})]})}let tW=!1,tF=(e,r)=>{t=e,tW=r};function tH({open:e,onClose:t,segment:a,segmentIndex:s,originalSegment:l,onSave:i,onPlaySegment:o,currentTime:d=0,onDelete:u,onAddSegment:m,onSplitSegment:h,onMergeSegment:f,setModalSpacebarHandler:p,originalTranscribedSegment:g,isGlobal:w=!1,isLoading:v=!1}){let[b,y]=(0,n.useState)(a),[j,_]=(0,n.useState)(!1),N=(0,n.useRef)(d);(0,n.useEffect)(()=>{N.current=d},[d]),(0,n.useEffect)(()=>{y(a)},[a]),(0,n.useEffect)(()=>{let e=()=>{_(!!window.isAudioPlaying)};e();let t=setInterval(e,100);return()=>clearInterval(t)},[]);let C=(0,n.useCallback)(e=>{if(!b)return;let t=e.map(e=>e.start_time).filter(e=>null!==e),r=e.map(e=>e.end_time).filter(e=>null!==e),n=t.length>0?Math.min(...t):null,a=r.length>0?Math.max(...r):null;y({...b,words:e,text:e.map(e=>e.text).join(" "),start_time:n,end_time:a})},[b]),{isManualSyncing:k,syncWordIndex:S,startManualSync:T,handleSpacebar:E,isSpacebarPressed:M,handleTapStart:R,handleTapEnd:A,cleanupManualSync:P}=function({editedSegment:e,currentTime:t,onPlaySegment:r,updateSegment:a}){let[s,l]=(0,n.useState)(!1),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)(-1),u=(0,n.useRef)(t),[m,h]=(0,n.useState)(!1),f=(0,n.useRef)(null),x=(0,n.useRef)([]),p=(0,n.useRef)(null),g=(0,n.useRef)(!1);(0,n.useEffect)(()=>{u.current=t},[t]),(0,n.useEffect)(()=>{e&&(x.current=[...e.words])},[e]),(0,n.useEffect)(()=>{g.current&&(g.current=!1,a(x.current))},[a,d]);let w=(0,n.useCallback)(()=>{l(!1),o(!1),c(-1),h(!1),f.current=null,p.current=null,g.current=!1,window.toggleAudioPlayback&&window.isAudioPlaying&&window.toggleAudioPlayback()},[]),v=(0,n.useCallback)(()=>{s&&!i&&(o(!0),window.toggleAudioPlayback&&window.isAudioPlaying&&window.toggleAudioPlayback())},[s,i]),b=(0,n.useCallback)(()=>{if(s&&i){if(o(!1),e){let t=e.words.findIndex(e=>null===e.start_time||null===e.end_time);-1!==t&&t!==d&&c(t)}r&&void 0!==u.current&&r(u.current)}},[s,i,r,e,d]),y=(0,n.useCallback)(t=>{if("Space"===t.code){if(t.preventDefault(),t.stopPropagation(),s&&e&&!m&&!i){if(h(!0),f.current=u.current,p.current=Date.now(),d<e.words.length){let e=[...x.current],t=e[d],r=u.current;if(t.start_time=r,d>0){let t=e[d-1];if(null!==t.start_time){let e=r-t.start_time;(null===t.end_time||null!==t.end_time&&t.end_time>r)&&(e>1?t.end_time=t.start_time+.5:t.end_time=r-.005)}}x.current=e,g.current=!0}}else if(!s&&e&&r){if("global-replacement"===e.id)return;let t=e.start_time??0,n=e.end_time??0;u.current>=t&&u.current<=n?window.toggleAudioPlayback&&window.toggleAudioPlayback():r(t)}}},[s,e,d,r,m,i]),j=(0,n.useCallback)(t=>{if("Space"===t.code&&(t.preventDefault(),t.stopPropagation(),s&&e&&m&&!i)){let t=p.current?Date.now()-p.current:0;if(h(!1),d<e.words.length){let r=[...x.current],n=r[d];t<200?n.end_time=(f.current||u.current)+.5:n.end_time=u.current,x.current=r,d===e.words.length-1?(l(!1),c(-1),f.current=null,p.current=null):c(d+1),g.current=!0}}},[s,e,d,m,i]);(0,n.useEffect)(()=>{if(s&&e&&d>0){let e=[...x.current],t=e[d-1],r=e[d];t&&r&&null!==t.end_time&&null!==r.start_time&&t.end_time>r.start_time&&(t.end_time=r.start_time-.01,x.current=e,g.current=!0)}},[d,s,e]);let _=(0,n.useCallback)(e=>{"keydown"===e.type?y(e):"keyup"===e.type&&j(e)},[y,j]),N=(0,n.useCallback)(()=>{if(s&&e&&!m&&!i&&(h(!0),f.current=u.current,p.current=Date.now(),d<e.words.length)){let e=[...x.current],t=e[d],r=u.current;if(t.start_time=r,d>0){let t=e[d-1];if(null!==t.start_time){let e=r-t.start_time;(null===t.end_time||null!==t.end_time&&t.end_time>r)&&(e>1?t.end_time=t.start_time+.5:t.end_time=r-.005)}}x.current=e,g.current=!0}},[s,e,d,m,i]),C=(0,n.useCallback)(()=>{if(!s||!e||!m||i)return;let t=p.current?Date.now()-p.current:0;if(h(!1),d<e.words.length){let r=[...x.current],n=r[d];t<200?n.end_time=(f.current||u.current)+.5:n.end_time=u.current,x.current=r,d===e.words.length-1?(l(!1),c(-1),f.current=null,p.current=null):c(d+1),g.current=!0}},[s,e,d,m,i]),k=(0,n.useCallback)(()=>{if(s)return void w();if(!e||!r)return;x.current=[...e.words];let t=e.words.findIndex(e=>null===e.start_time||null===e.end_time);l(!0),c(-1!==t?t:0),h(!1),f.current=null,p.current=null,g.current=!1,r((e.start_time??0)-3)},[s,e,r,w]);return(0,n.useEffect)(()=>{if(!e||!s||"global-replacement"===e.id)return;let t=()=>{let t=e.end_time??0;window.isAudioPlaying&&u.current>t&&(window.toggleAudioPlayback?.(),w())};t();let r=setInterval(t,100);return()=>{clearInterval(r)}},[s,e,w]),{isManualSyncing:s,isPaused:i,syncWordIndex:d,startManualSync:k,pauseManualSync:v,resumeManualSync:b,cleanupManualSync:w,handleSpacebar:_,isSpacebarPressed:m,handleTapStart:N,handleTapEnd:C}}({editedSegment:b,currentTime:d,onPlaySegment:o,updateSegment:C});(0,n.useEffect)(()=>(e&&tF(E,!0),()=>{tF(void 0,!1)}),[e,E]),(0,n.useEffect)(()=>{if(!b||k||w)return;let e=b.end_time??0;j&&d>e&&window.toggleAudioPlayback?.()},[d,b,k,w,j]);let D=(0,n.useCallback)((e,t)=>{if(!b)return;let r=[...b.words];r[e]={...r[e],...t},C(r)},[b,C]),B=(0,n.useCallback)(e=>{let t,r;if(!b)return;let n=[...b.words],a=b.start_time??0,s=b.end_time??a+1;if(void 0===e||-1===e){let e=n[0],l=e?.start_time??s;t=a,(r=a+(l-a)/2)-t<.1&&(r=t+.2)}else{let l=n[e],i=n[e+1],o=l?.end_time??a,d=i?.start_time??s;t=o,(r=d)-t<.1&&(r=t+.2)}let l={id:ez(),text:"",start_time:t,end_time:r,confidence:1};void 0===e||-1===e?n.unshift(l):n.splice(e+1,0,l),C(n)},[b,C]),L=(0,n.useCallback)(e=>{if(!b)return;let t=b.words[e],r=t.text.split(/\s+/).filter(e=>e.length>0);if(r.length<=1){let e=Math.ceil(t.text.length/2);r[0]=t.text.slice(0,e),r[1]=t.text.slice(e)}let n=r.map(e=>({id:ez(),text:e,start_time:null,end_time:null,confidence:1})),a=[...b.words];a.splice(e,1,...n),C(a)},[b,C]),z=(0,n.useCallback)(e=>{if(!b||e>=b.words.length-1)return;let t=b.words[e],r=b.words[e+1],n=[...b.words];n.splice(e,2,{id:ez(),text:`${t.text} ${r.text}`.trim(),start_time:t.start_time,end_time:r.end_time,confidence:1}),C(n)},[b,C]),I=(0,n.useCallback)(e=>{b&&C(b.words.filter((t,r)=>r!==e))},[b,C]),O=(0,n.useCallback)(e=>{if(!b)return;let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(0===t.length)return;let r=b.start_time??0,n=((b.end_time??r+1)-r)/t.length;C(t.map((e,t)=>({id:ez(),text:e,start_time:r+t*n,end_time:r+(t+1)*n,confidence:1})))},[b,C]),W=(0,n.useCallback)(()=>{l&&y(JSON.parse(JSON.stringify(l)))},[l]),F=(0,n.useCallback)(()=>{g&&y(JSON.parse(JSON.stringify(g)))},[g]),H=(0,n.useCallback)(()=>{P(),t()},[P,t]),$=(0,n.useCallback)(()=>{b&&(i(b),H())},[b,i,H]),U=(0,n.useCallback)(()=>{a&&o&&(j?window.toggleAudioPlayback?.():o(a.start_time??0))},[a,o,j]),Y=(0,n.useCallback)(()=>{null!==s&&(u?.(s),H())},[s,u,H]),q=(0,n.useCallback)(e=>{null!==s&&b&&($(),h?.(s,e))},[s,b,$,h]),X=(0,n.useCallback)(e=>{null!==s&&b&&($(),f?.(s,e),H())},[s,b,$,f,H]),V=(0,n.useCallback)(e=>{if(null!==s&&b){$();let t=0===e?s:s+1;m?.(t),H()}},[s,b,$,m,H]);if(!v&&(!a||!b||!l)||!v&&!w&&null===s)return null;let J=b?.start_time??0,K=b?.end_time??J+1;return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&H(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-[960px] max-h-[90vh] overflow-hidden flex flex-col",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsxs)(eO.DialogTitle,{className:"flex items-center gap-2",children:["Edit ",w?"All Words":`Segment ${s}`,a&&null!==a.start_time&&o&&(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U,children:j?(0,r.jsx)(tC,{className:"h-4 w-4"}):(0,r.jsx)(x,{className:"h-4 w-4"})})]})}),v?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 py-12",children:[(0,r.jsx)(eq.Loader2,{className:"h-12 w-12 animate-spin text-primary"}),(0,r.jsxs)("p",{className:"mt-4 text-lg font-semibold",children:["Loading ",w?"all words":"segment","..."]})]}):b?(0,r.jsxs)("div",{className:"flex-1 overflow-auto space-y-4",children:[b.words.some(e=>null!==e.start_time)&&(0,r.jsx)(tO,{words:b.words,startTime:J,endTime:K,originalStartTime:l?.start_time??null,originalEndTime:l?.end_time??null,currentStartTime:b.start_time,currentEndTime:b.end_time,currentTime:d,isManualSyncing:k,syncWordIndex:S,isSpacebarPressed:M,onWordUpdate:D,onPlaySegment:o,startManualSync:T,isGlobal:w,onTapStart:R,onTapEnd:A}),(0,r.jsx)(tD,{words:b.words,onWordUpdate:D,onSplitWord:L,onMergeWords:z,onAddWord:B,onRemoveWord:I,onReplaceAllWords:O,onSplitSegment:q,onAddSegment:V,onMergeSegment:X,isGlobal:w})]}):(0,r.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,r.jsx)("p",{className:"text-lg",children:"No segment data available"})}),(0,r.jsxs)(eO.DialogFooter,{className:"flex flex-wrap gap-2 justify-between sm:justify-between",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:W,className:"text-orange-600 border-orange-600 hover:bg-orange-50 dark:text-orange-400 dark:border-orange-400 dark:hover:bg-orange-950",children:[(0,r.jsx)(tk.RotateCcw,{className:"h-4 w-4 mr-1"}),"Reset"]}),g&&(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:F,children:[(0,r.jsx)(tS,{className:"h-4 w-4 mr-1"}),"Un-Correct"]}),!w&&u&&(0,r.jsxs)(c.Button,{variant:"destructive",size:"sm",onClick:Y,children:[(0,r.jsx)(eD.Trash2,{className:"h-4 w-4 mr-1"}),"Delete Segment"]})]}),(0,r.jsxs)("div",{className:"flex gap-2 ml-auto",children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:H,children:"Cancel"}),(0,r.jsx)(c.Button,{onClick:$,disabled:v||!b||0===b.words.length,children:"Save"})]})]})]})})}var t$=e.i(19036),tU=e.i(96626),tY=e.i(30207),tq=e.i(34620),tX="ScrollArea",[tV,tJ]=(0,ei.createContextScope)(tX),[tK,tG]=tV(tX),tZ=n.forwardRef((e,t)=>{let{__scopeScrollArea:a,type:s="hover",dir:l,scrollHideDelay:i=600,...o}=e,[d,c]=n.useState(null),[u,m]=n.useState(null),[h,f]=n.useState(null),[x,p]=n.useState(null),[g,w]=n.useState(null),[v,b]=n.useState(0),[y,j]=n.useState(0),[_,N]=n.useState(!1),[C,k]=n.useState(!1),S=(0,eK.useComposedRefs)(t,e=>c(e)),T=(0,eh.useDirection)(l);return(0,r.jsx)(tK,{scope:a,type:s,dir:T,scrollHideDelay:i,scrollArea:d,viewport:u,onViewportChange:m,content:h,onContentChange:f,scrollbarX:x,onScrollbarXChange:p,scrollbarXEnabled:_,onScrollbarXEnabledChange:N,scrollbarY:g,onScrollbarYChange:w,scrollbarYEnabled:C,onScrollbarYEnabledChange:k,onCornerWidthChange:b,onCornerHeightChange:j,children:(0,r.jsx)(eo.Primitive.div,{dir:T,...o,ref:S,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});tZ.displayName=tX;var tQ="ScrollAreaViewport",t0=n.forwardRef((e,t)=>{let{__scopeScrollArea:a,children:s,nonce:l,...i}=e,o=tG(tQ,a),d=n.useRef(null),c=(0,eK.useComposedRefs)(t,d,o.onViewportChange);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),(0,r.jsx)(eo.Primitive.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,r.jsx)("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});t0.displayName=tQ;var t1="ScrollAreaScrollbar",t2=n.forwardRef((e,t)=>{let{forceMount:a,...s}=e,l=tG(t1,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=l,d="horizontal"===e.orientation;return n.useEffect(()=>(d?i(!0):o(!0),()=>{d?i(!1):o(!1)}),[d,i,o]),"hover"===l.type?(0,r.jsx)(t5,{...s,ref:t,forceMount:a}):"scroll"===l.type?(0,r.jsx)(t4,{...s,ref:t,forceMount:a}):"auto"===l.type?(0,r.jsx)(t8,{...s,ref:t,forceMount:a}):"always"===l.type?(0,r.jsx)(t3,{...s,ref:t}):null});t2.displayName=t1;var t5=n.forwardRef((e,t)=>{let{forceMount:a,...s}=e,l=tG(t1,e.__scopeScrollArea),[i,o]=n.useState(!1);return n.useEffect(()=>{let e=l.scrollArea,t=0;if(e){let r=()=>{window.clearTimeout(t),o(!0)},n=()=>{t=window.setTimeout(()=>o(!1),l.scrollHideDelay)};return e.addEventListener("pointerenter",r),e.addEventListener("pointerleave",n),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",r),e.removeEventListener("pointerleave",n)}}},[l.scrollArea,l.scrollHideDelay]),(0,r.jsx)(tU.Presence,{present:a||i,children:(0,r.jsx)(t8,{"data-state":i?"visible":"hidden",...s,ref:t})})}),t4=n.forwardRef((e,t)=>{var a;let{forceMount:s,...l}=e,i=tG(t1,e.__scopeScrollArea),o="horizontal"===e.orientation,d=rf(()=>u("SCROLL_END"),100),[c,u]=(a={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},n.useReducer((e,t)=>a[e][t]??e,"hidden"));return n.useEffect(()=>{if("idle"===c){let e=window.setTimeout(()=>u("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[c,i.scrollHideDelay,u]),n.useEffect(()=>{let e=i.viewport,t=o?"scrollLeft":"scrollTop";if(e){let r=e[t],n=()=>{let n=e[t];r!==n&&(u("SCROLL"),d()),r=n};return e.addEventListener("scroll",n),()=>e.removeEventListener("scroll",n)}},[i.viewport,o,u,d]),(0,r.jsx)(tU.Presence,{present:s||"hidden"!==c,children:(0,r.jsx)(t3,{"data-state":"hidden"===c?"hidden":"visible",...l,ref:t,onPointerEnter:(0,ec.composeEventHandlers)(e.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:(0,ec.composeEventHandlers)(e.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),t8=n.forwardRef((e,t)=>{let a=tG(t1,e.__scopeScrollArea),{forceMount:s,...l}=e,[i,o]=n.useState(!1),d="horizontal"===e.orientation,c=rf(()=>{if(a.viewport){let e=a.viewport.offsetWidth<a.viewport.scrollWidth,t=a.viewport.offsetHeight<a.viewport.scrollHeight;o(d?e:t)}},10);return rx(a.viewport,c),rx(a.content,c),(0,r.jsx)(tU.Presence,{present:s||i,children:(0,r.jsx)(t3,{"data-state":i?"visible":"hidden",...l,ref:t})})}),t3=n.forwardRef((e,t)=>{let{orientation:a="vertical",...s}=e,l=tG(t1,e.__scopeScrollArea),i=n.useRef(null),o=n.useRef(0),[d,c]=n.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=rd(d.viewport,d.content),m={...s,sizes:d,onSizesChange:c,hasThumb:!!(u>0&&u<1),onThumbChange:e=>i.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function h(e,t){return function(e,t,r,n="ltr"){let a=rc(r),s=t||a/2,l=r.scrollbar.paddingStart+s,i=r.scrollbar.size-r.scrollbar.paddingEnd-(a-s),o=r.content-r.viewport;return rm([l,i],"ltr"===n?[0,o]:[-1*o,0])(e)}(e,o.current,d,t)}return"horizontal"===a?(0,r.jsx)(t6,{...m,ref:t,onThumbPositionChange:()=>{if(l.viewport&&i.current){let e=ru(l.viewport.scrollLeft,d,l.dir);i.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{l.viewport&&(l.viewport.scrollLeft=e)},onDragScroll:e=>{l.viewport&&(l.viewport.scrollLeft=h(e,l.dir))}}):"vertical"===a?(0,r.jsx)(t7,{...m,ref:t,onThumbPositionChange:()=>{if(l.viewport&&i.current){let e=ru(l.viewport.scrollTop,d);i.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{l.viewport&&(l.viewport.scrollTop=e)},onDragScroll:e=>{l.viewport&&(l.viewport.scrollTop=h(e))}}):null}),t6=n.forwardRef((e,t)=>{let{sizes:a,onSizesChange:s,...l}=e,i=tG(t1,e.__scopeScrollArea),[o,d]=n.useState(),c=n.useRef(null),u=(0,eK.useComposedRefs)(t,c,i.onScrollbarXChange);return n.useEffect(()=>{c.current&&d(getComputedStyle(c.current))},[c]),(0,r.jsx)(rt,{"data-orientation":"horizontal",...l,ref:u,sizes:a,style:{bottom:0,left:"rtl"===i.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===i.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":rc(a)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,r)=>{if(i.viewport){var n,a;let s=i.viewport.scrollLeft+t.deltaX;e.onWheelScroll(s),n=s,a=r,n>0&&n<a&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ro(o.paddingLeft),paddingEnd:ro(o.paddingRight)}})}})}),t7=n.forwardRef((e,t)=>{let{sizes:a,onSizesChange:s,...l}=e,i=tG(t1,e.__scopeScrollArea),[o,d]=n.useState(),c=n.useRef(null),u=(0,eK.useComposedRefs)(t,c,i.onScrollbarYChange);return n.useEffect(()=>{c.current&&d(getComputedStyle(c.current))},[c]),(0,r.jsx)(rt,{"data-orientation":"vertical",...l,ref:u,sizes:a,style:{top:0,right:"ltr"===i.dir?0:void 0,left:"rtl"===i.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":rc(a)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,r)=>{if(i.viewport){var n,a;let s=i.viewport.scrollTop+t.deltaY;e.onWheelScroll(s),n=s,a=r,n>0&&n<a&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ro(o.paddingTop),paddingEnd:ro(o.paddingBottom)}})}})}),[t9,re]=tV(t1),rt=n.forwardRef((e,t)=>{let{__scopeScrollArea:a,sizes:s,hasThumb:l,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:d,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:m,onResize:h,...f}=e,x=tG(t1,a),[p,g]=n.useState(null),w=(0,eK.useComposedRefs)(t,e=>g(e)),v=n.useRef(null),b=n.useRef(""),y=x.viewport,j=s.content-s.viewport,_=(0,tY.useCallbackRef)(m),N=(0,tY.useCallbackRef)(c),C=rf(h,10);function k(e){v.current&&u({x:e.clientX-v.current.left,y:e.clientY-v.current.top})}return n.useEffect(()=>{let e=e=>{let t=e.target;p?.contains(t)&&_(e,j)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[y,p,j,_]),n.useEffect(N,[s,N]),rx(p,C),rx(x.content,C),(0,r.jsx)(t9,{scope:a,scrollbar:p,hasThumb:l,onThumbChange:(0,tY.useCallbackRef)(i),onThumbPointerUp:(0,tY.useCallbackRef)(o),onThumbPositionChange:N,onThumbPointerDown:(0,tY.useCallbackRef)(d),children:(0,r.jsx)(eo.Primitive.div,{...f,ref:w,style:{position:"absolute",...f.style},onPointerDown:(0,ec.composeEventHandlers)(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),v.current=p.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",x.viewport&&(x.viewport.style.scrollBehavior="auto"),k(e))}),onPointerMove:(0,ec.composeEventHandlers)(e.onPointerMove,k),onPointerUp:(0,ec.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,x.viewport&&(x.viewport.style.scrollBehavior=""),v.current=null})})})}),rr="ScrollAreaThumb",rn=n.forwardRef((e,t)=>{let{forceMount:n,...a}=e,s=re(rr,e.__scopeScrollArea);return(0,r.jsx)(tU.Presence,{present:n||s.hasThumb,children:(0,r.jsx)(ra,{ref:t,...a})})}),ra=n.forwardRef((e,t)=>{let{__scopeScrollArea:a,style:s,...l}=e,i=tG(rr,a),o=re(rr,a),{onThumbPositionChange:d}=o,c=(0,eK.useComposedRefs)(t,e=>o.onThumbChange(e)),u=n.useRef(void 0),m=rf(()=>{u.current&&(u.current(),u.current=void 0)},100);return n.useEffect(()=>{let e=i.viewport;if(e){let t=()=>{m(),u.current||(u.current=rh(e,d),d())};return d(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[i.viewport,m,d]),(0,r.jsx)(eo.Primitive.div,{"data-state":o.hasThumb?"visible":"hidden",...l,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:(0,ec.composeEventHandlers)(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),r=e.clientX-t.left,n=e.clientY-t.top;o.onThumbPointerDown({x:r,y:n})}),onPointerUp:(0,ec.composeEventHandlers)(e.onPointerUp,o.onThumbPointerUp)})});rn.displayName=rr;var rs="ScrollAreaCorner",rl=n.forwardRef((e,t)=>{let n=tG(rs,e.__scopeScrollArea),a=!!(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&a?(0,r.jsx)(ri,{...e,ref:t}):null});rl.displayName=rs;var ri=n.forwardRef((e,t)=>{let{__scopeScrollArea:a,...s}=e,l=tG(rs,a),[i,o]=n.useState(0),[d,c]=n.useState(0),u=!!(i&&d);return rx(l.scrollbarX,()=>{let e=l.scrollbarX?.offsetHeight||0;l.onCornerHeightChange(e),c(e)}),rx(l.scrollbarY,()=>{let e=l.scrollbarY?.offsetWidth||0;l.onCornerWidthChange(e),o(e)}),u?(0,r.jsx)(eo.Primitive.div,{...s,ref:t,style:{width:i,height:d,position:"absolute",right:"ltr"===l.dir?0:void 0,left:"rtl"===l.dir?0:void 0,bottom:0,...e.style}}):null});function ro(e){return e?parseInt(e,10):0}function rd(e,t){let r=e/t;return isNaN(r)?0:r}function rc(e){let t=rd(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-r)*t,18)}function ru(e,t,r="ltr"){let n=rc(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-a,l=t.content-t.viewport,i=(0,eJ.clamp)(e,"ltr"===r?[0,l]:[-1*l,0]);return rm([0,l],[0,s-n])(i)}function rm(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}var rh=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return!function a(){let s={left:e.scrollLeft,top:e.scrollTop},l=r.left!==s.left,i=r.top!==s.top;(l||i)&&t(),r=s,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function rf(e,t){let r=(0,tY.useCallbackRef)(e),a=n.useRef(0);return n.useEffect(()=>()=>window.clearTimeout(a.current),[]),n.useCallback(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(r,t)},[r,t])}function rx(e,t){let r=(0,tY.useCallbackRef)(t);(0,tq.useLayoutEffect)(()=>{let t=0;if(e){let n=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(r)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.unobserve(e)}}},[e,r])}function rp({className:e,children:t,...n}){return(0,r.jsxs)(tZ,{"data-slot":"scroll-area",className:(0,o.cn)("relative",e),...n,children:[(0,r.jsx)(t0,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),(0,r.jsx)(rg,{}),(0,r.jsx)(rl,{})]})}function rg({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(t2,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,o.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:(0,r.jsx)(rn,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function rw({open:e,onClose:t,onReplace:a,data:s}){let[l,i]=(0,n.useState)(""),[o,d]=(0,n.useState)(""),[u,h]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[p,g]=(0,n.useState)(!1),[w,v]=(0,n.useState)([]),[b,y]=(0,n.useState)(null),[j,_]=(0,n.useState)(!1);(0,n.useEffect)(()=>{e&&(v([]),y(null))},[e]),(0,n.useEffect)(()=>{if(!e||!l){v([]),y(null);return}_(!0);let t=setTimeout(()=>{try{let e,t=[],r=s.corrected_segments||[];if(f)e=new RegExp(l,u?"g":"gi");else{let t=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=new RegExp(t,u?"g":"gi")}r.forEach((r,n)=>{r.words.forEach((a,s)=>{if(e.test(a.text)){e.lastIndex=0;let l=a.text.replace(e,o);t.push({segmentIndex:n,wordIndex:s,segmentText:r.text,wordText:a.text,replacement:l,willBeRemoved:""===l.trim()})}})}),v(t),y(null)}catch(e){y(e instanceof Error?e.message:"Invalid regex pattern"),v([])}finally{_(!1)}},300);return()=>clearTimeout(t)},[e,s,l,o,u,f,p]);let N=()=>{l&&!b&&(a(l,o,{caseSensitive:u,useRegex:f,fullTextMode:p}),t())};return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-2xl",onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||b||!l||(e.preventDefault(),N())},children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsx)(eO.DialogTitle,{children:"Find and Replace"})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{htmlFor:"find",children:"Find"}),(0,r.jsx)(eU.Input,{id:"find",value:l,onChange:e=>i(e.target.value),placeholder:"Text to find...",autoFocus:!0,className:b?"border-destructive":""}),b&&(0,r.jsx)("p",{className:"text-sm text-destructive",children:b})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{htmlFor:"replace",children:"Replace with"}),(0,r.jsx)(eU.Input,{id:"replace",value:o,onChange:e=>d(e.target.value),placeholder:"Replacement text..."})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(t$.Switch,{id:"caseSensitive",checked:u,onCheckedChange:h}),(0,r.jsx)(O.Label,{htmlFor:"caseSensitive",children:"Case sensitive"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(t$.Switch,{id:"useRegex",checked:f,onCheckedChange:x}),(0,r.jsx)(O.Label,{htmlFor:"useRegex",children:"Use regex"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(t$.Switch,{id:"fullTextMode",checked:p,onCheckedChange:g}),(0,r.jsx)(O.Label,{htmlFor:"fullTextMode",children:"Full text mode"})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h4",{className:"font-medium",children:"Preview"}),j&&(0,r.jsx)(eq.Loader2,{className:"h-4 w-4 animate-spin"})]}),w.some(e=>e.willBeRemoved)&&(0,r.jsxs)(tb,{variant:"destructive",children:[(0,r.jsx)(m.AlertCircle,{className:"h-4 w-4"}),(0,r.jsx)(ty,{children:"Some replacements will result in empty words, which will be removed."})]}),!j&&l&&0===w.length&&!b&&(0,r.jsx)(tb,{children:(0,r.jsx)(ty,{children:"No matches found"})}),!j&&w.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:[w.length," ",1===w.length?"match":"matches"," found"]}),(0,r.jsx)(rp,{className:"h-48 border rounded-md p-2",children:(0,r.jsxs)("div",{className:"space-y-2",children:[w.slice(0,50).map((e,t)=>(0,r.jsxs)("div",{className:"text-sm p-2 bg-muted rounded",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-destructive font-medium",children:e.wordText}),(0,r.jsx)("span",{className:"text-muted-foreground",children:" → "}),e.willBeRemoved?(0,r.jsx)("span",{className:"text-yellow-600 font-medium",children:"(will be removed)"}):(0,r.jsx)("span",{className:"text-primary font-medium",children:e.replacement})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:["Segment ",e.segmentIndex+1]})]},t)),w.length>50&&(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:[w.length-50," more matches not shown"]})]})})]})]})]}),(0,r.jsxs)(eO.DialogFooter,{children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:t,children:"Cancel"}),(0,r.jsxs)(c.Button,{onClick:N,disabled:!l||!!b||0===w.length,children:["Replace All (",w.length,")"]})]})]})})}var rv=e.i(16715);let rb=(0,f.default)("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);function ry({open:e,onClose:t,onSelectReplace:n,onSelectResync:a,hasExistingLyrics:s}){return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-md",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsxs)(eO.DialogTitle,{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{children:"Edit All Lyrics"}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8",children:(0,r.jsx)(L.X,{className:"h-4 w-4"})})]})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose how you want to edit the lyrics:"}),(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[s&&(0,r.jsx)("div",{className:(0,o.cn)("p-4 border-2 border-primary rounded-lg cursor-pointer","hover:bg-primary/10 transition-colors"),onClick:a,children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(rv.RefreshCw,{className:"h-10 w-10 text-primary mt-0.5"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-primary",children:"Re-sync Existing Lyrics"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Keep the current lyrics text and fix timing issues. Use this when lyrics are correct but timing has drifted, especially in the second half of the song."}),(0,r.jsx)("p",{className:"text-xs text-green-500 mt-2",children:"Recommended for fixing timing drift"})]})]})}),(0,r.jsx)("div",{className:(0,o.cn)("p-4 border rounded-lg cursor-pointer","hover:bg-muted/30 hover:border-muted-foreground transition-colors"),onClick:n,children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(rb,{className:"h-10 w-10 text-muted-foreground mt-0.5"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Replace All Lyrics"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Paste completely new lyrics from clipboard and manually sync timing for all words from scratch."}),(0,r.jsx)("p",{className:"text-xs text-yellow-500 mt-2",children:"All existing timing data will be lost"})]})]})})]})]}),(0,r.jsx)(eO.DialogFooter,{children:(0,r.jsx)(c.Button,{variant:"outline",onClick:t,children:"Cancel"})})]})})}var rj=e.i(83086);let r_=(0,f.default)("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),rN=(0,f.default)("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var rC=e.i(73375),rk=e.i(63059);function rS(e){let t=new Map;return e.forEach((e,r)=>{e.words.forEach(e=>{t.set(e.id,r)})}),t}let rT=(0,n.memo)(function({words:e,segments:t,visibleStartTime:a,visibleEndTime:s,currentTime:l,selectedWordIds:i,onWordClick:o,onBackgroundClick:d,onTimeBarClick:u,onSelectionComplete:m,onWordTimingChange:h,onWordsMove:f,syncWordIndex:x,isManualSyncing:p,onScrollChange:g,audioDuration:w,zoomSeconds:v,height:b=200,isDarkMode:y=!0}){let j={playhead:"#f97316",wordBlock:y?"#dc2626":"#ef4444",wordBlockSelected:y?"#b91c1c":"#dc2626",wordBlockCurrent:y?"#ef4444":"#f87171",wordTextCurrent:y?"#fca5a5":"#991b1b",wordText:y?"#f8fafc":"#1e293b",upcomingWordBg:y?"#2a2a2a":"#e5e7eb",upcomingWordText:y?"#e5e5e5":"#374151",timeBarBg:y?"#1a1a1a":"#f3f4f6",timeBarText:y?"#888888":"#6b7280",timelineBg:y?"#0f0f0f":"#ffffff",gridLine:y?"#64748b":"#94a3b8",borderLine:y?"#2a2a2a":"#cbd5e1",handleStroke:y?"#0f0f0f":"#ffffff",playheadShadow:y?"rgba(0,0,0,0.6)":"rgba(0,0,0,0.3)"},_=(0,n.useRef)(null),N=(0,n.useRef)(null),[C,k]=(0,n.useState)(800),S=(0,n.useRef)(void 0),T=(0,n.useRef)(new Map),[E,M]=(0,n.useState)("none"),R=(0,n.useRef)(null),A=(0,n.useRef)(null),P=(0,n.useRef)(new Map),[D,B]=(0,n.useState)(null),[L,z]=(0,n.useState)(null),[I,O]=(0,n.useState)("default");(0,n.useEffect)(()=>{let e=()=>{N.current&&k(N.current.clientWidth)};e();let t=new ResizeObserver(e);return N.current&&t.observe(N.current),()=>t.disconnect()},[]),(0,n.useEffect)(()=>{T.current=function(e,t){let r=new Map,n=rS(t),a=t.map((e,t)=>{let r=e.words.filter(e=>null!==e.start_time);return{idx:t,minStart:r.length>0?Math.min(...r.map(e=>e.start_time)):1/0}}).filter(e=>e.minStart!==1/0).sort((e,t)=>e.minStart-t.minStart),s=new Map;for(let t of(a.forEach(({idx:e},t)=>{s.set(e,t%2)}),e)){let e=n.get(t.id);void 0!==e&&s.has(e)?r.set(t.id,s.get(e)):r.set(t.id,0)}return r}(e,t)},[e,t]);let W=(0,n.useCallback)(e=>{let t=s-a;return t<=0?0:8+(e-a)/t*(C-16)},[a,s,C]),F=(0,n.useCallback)(e=>{let t=s-a;return a+(e-8)/(C-16)*t},[a,s,C]),H=(0,n.useCallback)(e=>{if(null===e.start_time||null===e.end_time)return null;let t=T.current.get(e.id)||0,r=W(e.start_time),n=W(e.end_time),a=Math.max(n-r,4);return{startX:r,endX:n,blockWidth:a,y:50+50*t,level:t}},[W]),$=(0,n.useCallback)((e,t,r)=>{let n=H(e);if(!n)return!1;let a=n.startX+n.blockWidth-4,s=n.y+12;return 6>Math.abs(t-a)&&6>Math.abs(r-s)},[H]),U=(0,n.useCallback)((t,r)=>{for(let n of e){let e=H(n);if(e&&t>=e.startX&&t<=e.startX+e.blockWidth&&r>=e.y&&r<=e.y+24)return n}return null},[e,H]),Y=(0,n.useCallback)(t=>{let r=Math.min(t.startX,t.endX),n=Math.max(t.startX,t.endX),a=Math.min(t.startY,t.endY),s=Math.max(t.startY,t.endY),l=[];for(let t of e){let e=H(t);e&&e.startX+e.blockWidth>=r&&e.startX<=n&&e.y+24>=a&&e.y<=s&&l.push(t.id)}return l},[e,H]),q=(0,n.useCallback)(()=>{let r=_.current;if(!r)return;let n=r.getContext("2d");if(!n)return;let o=window.devicePixelRatio||1;r.width=C*o,r.height=b*o,n.scale(o,o),n.fillStyle=j.timelineBg,n.fillRect(0,0,C,b),n.fillStyle=j.timeBarBg,n.fillRect(0,0,C,28);let d=s-a,c=d>15?2:d>8?1:.5,u=Math.ceil(a/c)*c;n.fillStyle=j.timeBarText,n.font="11px system-ui, -apple-system, sans-serif",n.textAlign="center";for(let e=u;e<=s;e+=c){let t=W(e);n.beginPath(),n.strokeStyle=j.gridLine,n.lineWidth=1,n.moveTo(t,22),n.lineTo(t,28),n.stroke(),e%1==0&&n.fillText(function(e){let t=Math.floor(e/60),r=Math.floor(e%60);return`${t.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}(e),t,18)}n.beginPath(),n.strokeStyle=j.borderLine,n.lineWidth=1,n.moveTo(0,28),n.lineTo(C,28),n.stroke();let m=rS(t),h=e.filter(e=>null!==e.start_time&&null!==e.end_time),f=h.find(e=>l>=e.start_time&&l<=e.end_time)?.id||null;for(let e of h){let t=H(e);if(!t)continue;let r=i.has(e.id),a=e.id===f,s=e.id===L;if(r?n.fillStyle=j.wordBlockSelected:a?n.fillStyle=j.wordBlockCurrent:n.fillStyle=j.wordBlock,n.fillRect(t.startX,t.y,t.blockWidth,24),r&&(n.strokeStyle=j.playhead,n.lineWidth=2,n.strokeRect(t.startX,t.y,t.blockWidth,24),s||1===i.size)){let e=t.startX+t.blockWidth-4,r=t.y+12;n.beginPath(),n.fillStyle=j.playhead,n.arc(e,r,4,0,2*Math.PI),n.fill(),n.strokeStyle=j.handleStroke,n.lineWidth=1,n.stroke()}}let g=new Map;for(let e of h){let t=m.get(e.id);void 0!==t&&(g.has(t)||g.set(t,[]),g.get(t).push(e))}for(let[,e]of(n.font="11px system-ui, -apple-system, sans-serif",n.textAlign="left",g)){let t=[...e].sort((e,t)=>(e.start_time||0)-(t.start_time||0));if(0===t.length)continue;let r=50+50*(T.current.get(t[0].id)||0)-3,a=-1/0;for(let e of t){let t=W(e.start_time),s=n.measureText(e.text).width,l=Math.max(t,a+3);l<C-10&&(n.fillStyle=e.id===f?j.wordTextCurrent:j.wordText,n.fillText(e.text,l,r),a=l+s)}}if(p&&x>=0){let t=e.slice(x).filter(e=>null===e.start_time),r=W(l)+10;n.font="11px system-ui, -apple-system, sans-serif";for(let e=0;e<Math.min(t.length,12);e++){let a=t[e],s=n.measureText(a.text).width+10;if(n.fillStyle=j.upcomingWordBg,n.fillRect(r,146,s,20),n.fillStyle=j.upcomingWordText,n.textAlign="left",n.fillText(a.text,r+5,160),(r+=s+3)>C-20)break}}if(l>=a&&l<=s){let e=W(l);n.beginPath(),n.fillStyle=j.playhead,n.strokeStyle=j.handleStroke,n.lineWidth=1,n.moveTo(e-6,2),n.lineTo(e+6,2),n.lineTo(e,24),n.closePath(),n.fill(),n.stroke(),n.beginPath(),n.strokeStyle=j.playhead,n.lineWidth=2,n.moveTo(e,28),n.lineTo(e,b),n.stroke(),n.beginPath(),n.strokeStyle=j.playheadShadow,n.lineWidth=1,n.moveTo(e+1,28),n.lineTo(e+1,b),n.stroke()}if(D){n.fillStyle="rgba(25, 118, 210, 0.2)",n.strokeStyle="rgba(25, 118, 210, 0.8)",n.lineWidth=1;let e=Math.min(D.startX,D.endX),t=Math.min(D.startY,D.endY),r=Math.abs(D.endX-D.startX),a=Math.abs(D.endY-D.startY);n.fillRect(e,t,r,a),n.strokeRect(e,t,r,a)}},[C,b,a,s,l,e,t,i,D,L,x,p,W,H,j]);(0,n.useEffect)(()=>{let e=()=>{q(),S.current=requestAnimationFrame(e)};return e(),()=>{S.current&&cancelAnimationFrame(S.current)}},[q]);let X=(0,n.useCallback)(t=>{let r=_.current?.getBoundingClientRect();if(!r)return;let n=t.clientX-r.left,a=t.clientY-r.top,s=F(n);if(a<28)return void u(Math.max(0,s));let l=U(n,a);if(l&&i.has(l.id)){if($(l,n,a)){M("resize"),R.current={x:n,y:a,time:s},A.current=l.id,P.current=new Map([[l.id,{start:l.start_time,end:l.end_time}]]);return}M("move"),R.current={x:n,y:a,time:s},A.current=l.id;let t=new Map;for(let r of i){let n=e.find(e=>e.id===r);n&&null!==n.start_time&&null!==n.end_time&&t.set(r,{start:n.start_time,end:n.end_time})}P.current=t;return}l?o(l.id,t):(M("selection"),R.current={x:n,y:a,time:s},B({startX:n,startY:a,endX:n,endY:a}))},[F,u,U,i,$,o,e]),V=(0,n.useCallback)(e=>{let t=_.current?.getBoundingClientRect();if(!t)return;let r=e.clientX-t.left,n=e.clientY-t.top,a=F(r);if("none"===E){let e=U(r,n);z(e?.id||null),e&&i.has(e.id)?O($(e,r,n)?"ew-resize":"grab"):e||n<28?O("pointer"):O("default")}if(R.current){if("selection"===E)B({startX:R.current.x,startY:R.current.y,endX:r,endY:n});else if("resize"===E&&A.current){let e=P.current.get(A.current);if(e){let t=a-R.current.time,r=Math.max(e.start+.05,e.end+t);h(A.current,e.start,r)}O("ew-resize")}else if("move"===E){let e=a-R.current.time,t=[];for(let[r,n]of P.current){let a=Math.max(0,n.start+e),s=Math.max(a+.05,n.end+e);t.push({wordId:r,newStartTime:a,newEndTime:s})}t.length>0&&f(t),O("grabbing")}}},[E,F,U,i,$,h,f]),J=(0,n.useCallback)(e=>{let t=_.current?.getBoundingClientRect();if("selection"===E&&R.current&&t){let r=e.clientX-t.left,n=e.clientY-t.top;if(5>Math.sqrt(Math.pow(r-R.current.x,2)+Math.pow(n-R.current.y,2)))d();else{let e=Y({startX:R.current.x,startY:R.current.y,endX:r,endY:n});e.length>0&&m(e)}}M("none"),R.current=null,A.current=null,P.current=new Map,B(null),O("default")},[E,d,Y,m]),K=(0,n.useCallback)(e=>{let t=(0!==e.deltaX?e.deltaX:e.deltaY)/100*(v/4),r=Math.max(0,Math.min(w-v,a+t));r!==a&&g(r)},[a,v,w,g]),G=(0,n.useCallback)(()=>{g(Math.max(0,a-.25*v))},[a,v,g]),Z=(0,n.useCallback)(()=>{g(Math.max(0,Math.min(w-v,a+.25*v)))},[a,v,w,g]);return(0,r.jsx)("div",{className:"flex flex-col gap-1",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:G,disabled:a<=0,children:(0,r.jsx)(rC.ChevronLeft,{className:"h-4 w-4"})}),(0,r.jsx)("div",{ref:N,className:"flex-1 rounded overflow-hidden",style:{height:b,cursor:I},children:(0,r.jsx)("canvas",{ref:_,style:{width:"100%",height:"100%",display:"block",cursor:I},onMouseDown:X,onMouseMove:V,onMouseUp:J,onMouseLeave:J,onWheel:K})}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Z,disabled:a>=w-v,children:(0,r.jsx)(rk.ChevronRight,{className:"h-4 w-4"})})]})})}),rE=(0,n.memo)(function({words:e,syncWordIndex:t,isManualSyncing:a,maxWordsToShow:s=20}){let l=(0,n.useMemo)(()=>!a||t<0?[]:e.slice(t).filter(e=>null===e.start_time).slice(0,s),[e,t,a,s]),i=(0,n.useMemo)(()=>!a||t<0?0:e.slice(t).filter(e=>null===e.start_time).length,[e,t,a]);return 0===l.length?null:(0,r.jsxs)("div",{className:"h-11 bg-muted rounded flex items-center px-2 gap-1 overflow-hidden",children:[l.map((e,t)=>(0,r.jsx)("span",{className:(0,o.cn)("px-2 py-1 rounded text-sm whitespace-nowrap",0===t?"bg-destructive text-destructive-foreground font-bold border-2 border-destructive":"bg-muted-foreground/20 text-foreground"),children:e.text},e.id)),i>s&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:["+",i-s," more"]})]})});var rM=e.i(69035);let rR=(0,f.default)("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]),rA=(0,f.default)("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]),rP=(0,f.default)("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]),rD=(0,f.default)("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]),rB=(0,f.default)("Pointer",[["path",{d:"M22 14a8 8 0 0 1-8 8",key:"56vcr3"}],["path",{d:"M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1agjmk"}],["path",{d:"M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1",key:"wdbh2u"}],["path",{d:"M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10",key:"1ibuk9"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"g6ys72"}]]),rL=(0,n.memo)(function({isManualSyncing:e,isPaused:t,onStartSync:n,onPauseSync:a,onResumeSync:s,onClearSync:l,onEditLyrics:i,onPlay:o,onStop:d,isPlaying:u,hasSelectedWords:m,selectedWordCount:h,onUnsyncFromCursor:f,onEditSelectedWord:g,onDeleteSelected:w,canUnsyncFromCursor:v,isMobile:b=!1,onTapStart:y,onTapEnd:j,isTapping:_=!1}){return(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:o,disabled:u,children:[(0,r.jsx)(x,{className:"h-4 w-4 mr-1"}),"Play"]}),(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:d,disabled:!u,children:[(0,r.jsx)(tC,{className:"h-4 w-4 mr-1"}),"Stop"]}),!b&&(0,r.jsx)(rM.Separator,{orientation:"vertical",className:"h-6"}),e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(c.Button,{variant:"destructive",size:"sm",onClick:n,children:[(0,r.jsx)(tC,{className:"h-4 w-4 mr-1"}),"Stop Sync"]}),(0,r.jsxs)(c.Button,{variant:t?"default":"outline",size:"sm",onClick:t?s:a,className:t?"bg-green-600 hover:bg-green-700":"",children:[t?(0,r.jsx)(x,{className:"h-4 w-4 mr-1"}):(0,r.jsx)(p,{className:"h-4 w-4 mr-1"}),t?"Resume":"Pause"]}),b&&!t&&y&&j&&(0,r.jsxs)(c.Button,{variant:_?"secondary":"default",size:"sm",onTouchStart:e=>{e.preventDefault(),y()},onTouchEnd:e=>{e.preventDefault(),j()},onMouseDown:y,onMouseUp:j,className:_?"bg-yellow-500":"bg-green-600",children:[(0,r.jsx)(rB,{className:"h-4 w-4 mr-1"}),_?"Release":"TAP"]})]}):(0,r.jsxs)(c.Button,{size:"sm",onClick:n,children:[(0,r.jsx)(rR,{className:"h-4 w-4 mr-1"}),"Start Sync"]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:l,disabled:e&&!t,children:[(0,r.jsx)(eD.Trash2,{className:"h-4 w-4 mr-1"}),"Clear Sync"]}),(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:i,disabled:e&&!t,children:[(0,r.jsx)(rD,{className:"h-4 w-4 mr-1"}),"Edit Lyrics"]}),!b&&(0,r.jsx)(rM.Separator,{orientation:"vertical",className:"h-6"}),(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:f,disabled:!v||e&&!t,children:[(0,r.jsx)(rP,{className:"h-4 w-4 mr-1"}),"Unsync from Cursor"]}),(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:g,disabled:!m||1!==h,children:[(0,r.jsx)(rA,{className:"h-4 w-4 mr-1"}),"Edit Word"]}),(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:w,disabled:!m||e&&!t,className:"text-destructive hover:text-destructive",children:[(0,r.jsx)(eD.Trash2,{className:"h-4 w-4 mr-1"}),"Delete",m&&h>0?` (${h})`:""]})]})]})});function rz(e){return JSON.parse(JSON.stringify(e))}let rI=(0,n.memo)(function({segments:e,currentTime:t,onPlaySegment:a,onSave:s,onCancel:l,setModalSpacebarHandler:i}){let o=window.matchMedia("(prefers-color-scheme: dark)").matches,d=window.innerWidth<640,[u,m]=(0,n.useState)(()=>rz(e)),h=(0,n.useMemo)(()=>u.flatMap(e=>e.words),[u]),f=(0,n.useMemo)(()=>{if("function"==typeof window.getAudioDuration){let e=window.getAudioDuration();return e>0?e:300}return 300},[]),[x,p]=(0,n.useState)(12),[g,w]=(0,n.useState)(0),v=(0,n.useMemo)(()=>Math.min(g+x,f),[g,x,f]),[b,y]=(0,n.useState)(!1),[j,_]=(0,n.useState)(!1),[N,C]=(0,n.useState)(-1),[k,S]=(0,n.useState)(!1),T=(0,n.useRef)(null),E=(0,n.useRef)(null),M=(0,n.useRef)(t),[R,A]=(0,n.useState)(new Set),[P,D]=(0,n.useState)(!1),[B,L]=(0,n.useState)(""),[z,I]=(0,n.useState)(!1),[O,W]=(0,n.useState)(""),[F,H]=(0,n.useState)(null);(0,n.useEffect)(()=>{M.current=t},[t]),(0,n.useEffect)(()=>{b&&!j&&t>0&&(t>v-.1*x?w(Math.max(0,t-.1*x)):t<g&&w(Math.max(0,t-1)))},[t,b,j,g,v,x]);let $=(0,n.useCallback)(e=>{p(2+e[0]/50*22)},[]),U=(0,n.useMemo)(()=>(x-2)/22*50,[x]),Y=(0,n.useCallback)(e=>{w(e)},[]),q=(0,n.useCallback)(e=>{m(t=>{let r=rz(t),n=new Map(e.map(e=>[e.id,e]));for(let e of r){e.words=e.words.map(e=>n.get(e.id)||e);let t=e.words.filter(e=>null!==e.start_time&&null!==e.end_time);t.length>0?(e.start_time=Math.min(...t.map(e=>e.start_time)),e.end_time=Math.max(...t.map(e=>e.end_time))):(e.start_time=null,e.end_time=null)}return r})},[]),[X,V]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=()=>{V("boolean"==typeof window.isAudioPlaying&&window.isAudioPlaying)};e();let t=setInterval(e,100);return()=>clearInterval(t)},[]);let J=(0,n.useCallback)(()=>{a&&a(M.current)},[a]),K=(0,n.useCallback)(()=>{"function"==typeof window.toggleAudioPlayback&&window.isAudioPlaying&&window.toggleAudioPlayback(),b&&(y(!1),_(!1),S(!1))},[b]),G=(0,n.useCallback)(()=>{if(b){y(!1),_(!1),C(-1),S(!1),K();return}let e=h.findIndex(e=>null===e.start_time||null===e.end_time);y(!0),_(!1),C(-1!==e?e:0),S(!1),a&&a(Math.max(0,M.current-1))},[b,h,a,K]),Z=(0,n.useCallback)(()=>{_(!0),K()},[K]),Q=(0,n.useCallback)(()=>{_(!1);let e=h.findIndex(e=>null===e.start_time||null===e.end_time);-1!==e&&e!==N&&C(e),a&&a(M.current)},[h,N,a]),ee=(0,n.useCallback)(()=>{m(e=>{let t=rz(e);for(let e of t){for(let t of e.words)t.start_time=null,t.end_time=null;e.start_time=null,e.end_time=null}return t}),C(-1)},[]),et=(0,n.useCallback)(()=>{let e=M.current;m(t=>{let r=rz(t);for(let t of r){for(let r of t.words)null!==r.start_time&&r.start_time>e&&(r.start_time=null,r.end_time=null);let r=t.words.filter(e=>null!==e.start_time&&null!==e.end_time);r.length>0?(t.start_time=Math.min(...r.map(e=>e.start_time)),t.end_time=Math.max(...r.map(e=>e.end_time))):(t.start_time=null,t.end_time=null)}return r})},[]),er=(0,n.useMemo)(()=>{let e=M.current;return h.some(t=>null!==t.start_time&&t.start_time>e)},[h,t]),en=(0,n.useCallback)(()=>{L(u.map(e=>e.text).join("\n")),D(!0)},[u]),ea=(0,n.useCallback)(()=>{m(B.split("\n").filter(e=>e.trim()).map((e,t)=>{let r=e.trim().split(/\s+/).map((e,r)=>({id:`word-${t}-${r}-${Date.now()}`,text:e,start_time:null,end_time:null,confidence:1}));return{id:`segment-${t}-${Date.now()}`,text:e.trim(),words:r,start_time:null,end_time:null}})),D(!1),C(-1)},[B]),es=(0,n.useCallback)(()=>{if(1!==R.size)return;let e=Array.from(R)[0],t=h.find(t=>t.id===e);t&&(H(e),W(t.text),I(!0))},[R,h]),el=(0,n.useCallback)(()=>{if(!F)return;let e=O.trim();if(!e)return;let t=e.split(/\s+/);if(1===t.length)q(h.map(e=>e.id===F?{...e,text:t[0]}:e));else{let e=h.find(e=>e.id===F);if(!e)return;m(r=>{let n=rz(r);for(let r of n){let n=r.words.findIndex(e=>e.id===F);if(-1!==n){let a=t.map((t,r)=>({id:0===r?F:`${F}-split-${r}`,text:t,start_time:0===r?e.start_time:null,end_time:0===r?e.end_time:null,confidence:1}));r.words.splice(n,1,...a),r.text=r.words.map(e=>e.text).join(" ");break}}return n})}I(!1),H(null),W(""),A(new Set)},[F,O,h,q]),ei=(0,n.useCallback)(()=>{0!==R.size&&(m(e=>{let t=rz(e);for(let e of t){e.words=e.words.filter(e=>!R.has(e.id)),e.text=e.words.map(e=>e.text).join(" ");let t=e.words.filter(e=>null!==e.start_time&&null!==e.end_time);t.length>0?(e.start_time=Math.min(...t.map(e=>e.start_time)),e.end_time=Math.max(...t.map(e=>e.end_time))):(e.start_time=null,e.end_time=null)}return t.filter(e=>e.words.length>0)}),A(new Set))},[R]),eo=(0,n.useCallback)((e,t)=>{t.shiftKey||t.ctrlKey||t.metaKey?A(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r}):A(new Set([e]))},[]),ed=(0,n.useCallback)(()=>{A(new Set)},[]),ec=(0,n.useCallback)((e,t,r)=>{m(n=>{let a=rz(n);for(let n of a){let a=n.words.find(t=>t.id===e);if(a){a.start_time=Math.max(0,t),a.end_time=Math.max(a.start_time+.05,r);let e=n.words.filter(e=>null!==e.start_time&&null!==e.end_time);e.length>0&&(n.start_time=Math.min(...e.map(e=>e.start_time)),n.end_time=Math.max(...e.map(e=>e.end_time)));break}}return a})},[]),eu=(0,n.useCallback)(e=>{m(t=>{let r=rz(t),n=new Map(e.map(e=>[e.wordId,e]));for(let e of r){for(let t of e.words){let e=n.get(t.id);e&&(t.start_time=e.newStartTime,t.end_time=e.newEndTime)}let t=e.words.filter(e=>null!==e.start_time&&null!==e.end_time);t.length>0&&(e.start_time=Math.min(...t.map(e=>e.start_time)),e.end_time=Math.max(...t.map(e=>e.end_time)))}return r})},[]),em=(0,n.useCallback)(e=>{w(Math.min(Math.max(0,e-x/2),Math.max(0,f-x))),a&&(a(e),setTimeout(()=>{"function"==typeof window.toggleAudioPlayback&&window.isAudioPlaying&&window.toggleAudioPlayback()},50))},[x,f,a]),eh=(0,n.useCallback)(e=>{A(new Set(e))},[]),ef=(0,n.useCallback)(e=>{if("Space"!==e.code||!b||j||N<0||N>=h.length||(e.preventDefault(),e.stopPropagation(),k))return;S(!0),T.current=M.current,E.current=Date.now();let t=[...h];if(t[N].start_time=M.current,N>0){let e=t[N-1];null!==e.start_time&&null===e.end_time&&(M.current-e.start_time>1?e.end_time=e.start_time+.5:e.end_time=M.current-.005)}q(t)},[b,j,N,h,k,q]),ex=(0,n.useCallback)(e=>{if("Space"!==e.code||!b||j||!k)return;e.preventDefault(),e.stopPropagation(),S(!1);let t=E.current?Date.now()-E.current:0,r=[...h],n=r[N];t<200?n.end_time=(T.current||M.current)+.5:n.end_time=M.current,q(r),N<h.length-1?C(N+1):(y(!1),C(-1),K()),T.current=null,E.current=null},[b,j,k,N,h,q,K]),ep=(0,n.useCallback)(e=>{"keydown"===e.type?ef(e):"keyup"===e.type&&ex(e)},[ef,ex]),eg=(0,n.useRef)(ep);eg.current=ep,(0,n.useEffect)(()=>(i(e=>{"Space"===e.code&&(e.preventDefault(),e.stopPropagation(),eg.current(e))}),()=>{i(void 0)}),[i]);let ew=(0,n.useCallback)(()=>{if(!b||j||N<0||N>=h.length||k)return;S(!0),T.current=M.current,E.current=Date.now();let e=[...h];if(e[N].start_time=M.current,N>0){let t=e[N-1];null!==t.start_time&&null===t.end_time&&(M.current-t.start_time>1?t.end_time=t.start_time+.5:t.end_time=M.current-.005)}q(e)},[b,j,N,h,k,q]),ev=(0,n.useCallback)(()=>{if(!b||j||!k)return;S(!1);let e=E.current?Date.now()-E.current:0,t=[...h],r=t[N];e<200?r.end_time=(T.current||M.current)+.5:r.end_time=M.current,q(t),N<h.length-1?C(N+1):(y(!1),C(-1),K()),T.current=null,E.current=null},[b,j,k,N,h,q,K]),eb=(0,n.useCallback)(()=>{s(u)},[u,s]),ey=(0,n.useMemo)(()=>{let e=h.length,t=h.filter(e=>null!==e.start_time&&null!==e.end_time).length;return{total:e,synced:t,remaining:e-t}},[h]),ej=(0,n.useCallback)(()=>b?k?{primary:"⏱️ Holding... release when word ends",secondary:"Release spacebar when the word finishes"}:0===ey.remaining?{primary:"✅ All words synced!",secondary:'Click "Stop Sync" then "Apply" to save'}:{primary:"👆 Press SPACEBAR when you hear each word",secondary:"Tap for short words, hold for longer words"}:0===ey.synced?{primary:'Click "Start Sync" to begin timing words',secondary:"Audio will play and you'll tap spacebar for each word"}:ey.remaining>0?{primary:`${ey.remaining} words remaining to sync`,secondary:'Click "Start Sync" to continue, or "Unsync from Cursor" to re-sync from a point'}:{primary:"✅ All words synced!",secondary:'Click "Apply" to save changes, or make adjustments first'},[b,k,ey.synced,ey.remaining])();return(0,r.jsxs)("div",{className:"flex flex-col h-full gap-2",children:[(0,r.jsx)("div",{className:"flex justify-end items-center h-6",children:(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[ey.synced," / ",ey.total," words synced",ey.remaining>0&&` (${ey.remaining} remaining)`]})}),(0,r.jsx)("div",{className:"h-14 flex-shrink-0",children:(0,r.jsxs)("div",{className:`p-3 h-full rounded flex flex-col justify-center ${b?"bg-green-600 text-white":"bg-muted"}`,children:[(0,r.jsx)("p",{className:"text-sm font-medium leading-tight",children:ej.primary}),(0,r.jsx)("p",{className:"text-xs opacity-90 leading-tight",children:ej.secondary})]})}),(0,r.jsx)("div",{className:"min-h-[88px] flex-shrink-0",children:(0,r.jsx)(rL,{isManualSyncing:b,isPaused:j,onStartSync:G,onPauseSync:Z,onResumeSync:Q,onClearSync:ee,onEditLyrics:en,onPlay:J,onStop:K,isPlaying:X,hasSelectedWords:R.size>0,selectedWordCount:R.size,onUnsyncFromCursor:et,onEditSelectedWord:es,onDeleteSelected:ei,canUnsyncFromCursor:er,isMobile:d,onTapStart:ew,onTapEnd:ev,isTapping:k})}),(0,r.jsx)("div",{className:"h-11 flex-shrink-0",children:b&&(0,r.jsx)(rE,{words:h,syncWordIndex:N,isManualSyncing:b})}),(0,r.jsx)("div",{className:"flex-1 min-h-[200px]",children:(0,r.jsx)(rT,{words:h,segments:u,visibleStartTime:g,visibleEndTime:v,currentTime:t,selectedWordIds:R,onWordClick:eo,onBackgroundClick:ed,onTimeBarClick:em,onSelectionComplete:eh,onWordTimingChange:ec,onWordsMove:eu,syncWordIndex:N,isManualSyncing:b,onScrollChange:Y,audioDuration:f,zoomSeconds:x,height:200,isDarkMode:o})}),(0,r.jsxs)("div",{className:"flex items-center gap-4 px-2",children:[(0,r.jsx)(r_,{className:"h-4 w-4 text-muted-foreground"}),(0,r.jsx)(tg,{value:[U],onValueChange:$,min:0,max:50,step:1,className:"flex-1",disabled:b&&!j}),(0,r.jsx)(rN,{className:"h-4 w-4 text-muted-foreground"}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground min-w-[60px]",children:[x.toFixed(1),"s view"]})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-4 pt-4 border-t",children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:l,children:"Cancel"}),(0,r.jsx)(c.Button,{onClick:eb,disabled:b&&!j,children:"Apply"})]}),(0,r.jsx)(eO.Dialog,{open:P,onOpenChange:D,children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-2xl",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsx)(eO.DialogTitle,{children:"Edit Lyrics"})}),(0,r.jsxs)(tb,{variant:"destructive",children:[(0,r.jsx)(eF,{className:"h-4 w-4"}),(0,r.jsx)(ty,{children:"Editing lyrics will reset all timing data. You will need to re-sync the entire song."})]}),(0,r.jsx)(eY.Textarea,{value:B,onChange:e=>L(e.target.value),placeholder:"Enter lyrics, one line per segment...",rows:15,className:"font-mono"}),(0,r.jsxs)(eO.DialogFooter,{children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:()=>D(!1),children:"Cancel"}),(0,r.jsx)(c.Button,{variant:"destructive",onClick:ea,children:"Save & Reset Timing"})]})]})}),(0,r.jsx)(eO.Dialog,{open:z,onOpenChange:I,children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-sm",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsx)(eO.DialogTitle,{children:"Edit Word"})}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Edit the word text. Enter multiple words separated by spaces to split."}),(0,r.jsx)(eU.Input,{value:O,onChange:e=>W(e.target.value),autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&el()}}),(0,r.jsxs)(eO.DialogFooter,{children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),(0,r.jsx)(c.Button,{onClick:el,children:"Save"})]})]})})]})});function rO({open:e,onClose:t,onSave:a,onPlaySegment:s,currentTime:l=0,setModalSpacebarHandler:i,existingSegments:o=[]}){let[d,m]=(0,n.useState)("selection"),[h,f]=(0,n.useState)(""),[x,p]=(0,n.useState)([]);(0,n.useEffect)(()=>{e&&(m("selection"),f(""),p([]))},[e]);let g=(0,n.useMemo)(()=>{if(!h.trim())return{lines:0,words:0};let e=h.trim().split("\n").filter(e=>e.trim().length>0),t=e.reduce((e,t)=>e+t.trim().split(/\s+/).length,0);return{lines:e.length,words:t}},[h]),w=(0,n.useCallback)(()=>{if(!h.trim())return;let e=h.trim().split("\n").filter(e=>e.trim().length>0),t=[];e.forEach(e=>{let r=e.trim().split(/\s+/).filter(e=>e.length>0).map(e=>({id:ez(),text:e,start_time:null,end_time:null,confidence:1,created_during_correction:!0}));t.push({id:ez(),text:e.trim(),words:r,start_time:null,end_time:null})}),p(t),m("resync")},[h]),v=(0,n.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();f(e)}catch(e){console.error("Failed to read from clipboard:",e),alert("Failed to read from clipboard. Please paste manually.")}},[]),b=(0,n.useCallback)(()=>{m("selection"),f(""),p([]),t()},[t]),y=(0,n.useCallback)(e=>{a(e),b()},[a,b]),j=(0,n.useCallback)(()=>{m("replace")},[]),_=(0,n.useCallback)(()=>{m("resync")},[]),N=(0,n.useCallback)(()=>{m("selection"),f(""),p([])},[]),C="resync"===d&&x.length>0?x:o,k=o.length>0&&o.some(e=>e.words.length>0);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ry,{open:e&&"selection"===d,onClose:b,onSelectReplace:j,onSelectResync:_,hasExistingLyrics:k}),(0,r.jsx)(eO.Dialog,{open:e&&"replace"===d,onOpenChange:e=>!e&&b(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-2xl h-[80vh] max-h-[80vh] flex flex-col",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsxs)(eO.DialogTitle,{className:"flex items-center gap-2",children:[(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:N,className:"h-8 w-8",children:(0,r.jsx)(u.ArrowLeft,{className:"h-4 w-4"})}),(0,r.jsx)("span",{className:"flex-1",children:"Replace All Lyrics"}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:b,className:"h-8 w-8",children:(0,r.jsx)(L.X,{className:"h-4 w-4"})})]})}),(0,r.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Paste your new lyrics below:"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Each line will become a separate segment. Words will be separated by spaces."})]}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:v,children:[(0,r.jsx)(rb,{className:"h-4 w-4 mr-2"}),"Paste from Clipboard"]}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground font-medium",children:[g.lines," lines, ",g.words," words"]})]}),(0,r.jsx)(eY.Textarea,{value:h,onChange:e=>f(e.target.value),placeholder:`Paste your lyrics here...
|
|
3
|
+
Each line will become a segment
|
|
4
|
+
Words will be separated by spaces`,className:"flex-1 resize-none font-mono text-sm min-h-[300px]"})]}),(0,r.jsxs)(eO.DialogFooter,{children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:b,children:"Cancel"}),(0,r.jsxs)(c.Button,{onClick:w,disabled:!h.trim(),children:[(0,r.jsx)(rj.Sparkles,{className:"h-4 w-4 mr-2"}),"Continue to Sync"]})]})]})}),(0,r.jsx)(eO.Dialog,{open:e&&"resync"===d,onOpenChange:e=>!e&&b(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-[calc(100vw-4vw)] w-[calc(100vw-4vw)] h-[90vh] max-h-[90vh] flex flex-col",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsxs)(eO.DialogTitle,{className:"flex items-center gap-2",children:[(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:N,className:"h-8 w-8",children:(0,r.jsx)(u.ArrowLeft,{className:"h-4 w-4"})}),(0,r.jsx)("span",{className:"flex-1",children:x.length>0?"Sync New Lyrics":"Re-sync Existing Lyrics"}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:b,className:"h-8 w-8",children:(0,r.jsx)(L.X,{className:"h-4 w-4"})})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:C.length>0?(0,r.jsx)(rI,{segments:C,currentTime:l,onPlaySegment:s,onSave:y,onCancel:b,setModalSpacebarHandler:i}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-muted-foreground",children:"No lyrics to sync"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Go back and paste new lyrics, or close this modal."}),(0,r.jsxs)(c.Button,{variant:"outline",onClick:N,children:[(0,r.jsx)(u.ArrowLeft,{className:"h-4 w-4 mr-2"}),"Back to Selection"]})]})})]})})]})}let rW=(e,t)=>null===e?null:e+t/1e3,rF=(e,t)=>{if(0===t)return e;let r=e.words.map(e=>0===t?e:{...e,start_time:rW(e.start_time,t),end_time:rW(e.end_time,t)}),n=r.map(e=>e.start_time).filter(e=>null!==e),a=r.map(e=>e.end_time).filter(e=>null!==e),s=n.length>0?Math.min(...n):null,l=a.length>0?Math.max(...a):null;return{...e,words:r,start_time:s,end_time:l}},rH=(e,t)=>0===t?e:{...e,corrected_segments:e.corrected_segments.map(e=>rF(e,t))};function r$({apiClient:e,isModalOpen:t,updatedData:a,videoRef:s,timingOffsetMs:l=0}){let[i,o]=(0,n.useState)({status:"loading"});return((0,n.useEffect)(()=>{t&&e&&(async()=>{o({status:"loading"});try{let t=0!==l?rH(a,l):a,r=await e.generatePreviewVideo(t);if("error"===r.status)return void o({status:"error",error:r.message||"Failed to generate preview video"});if(!r.preview_hash)return void o({status:"error",error:"No preview hash received from server"});let n=e.getPreviewVideoUrl(r.preview_hash);o({status:"ready",videoUrl:n})}catch(e){o({status:"error",error:e.message||"Failed to generate preview video"})}})()},[t,e,a,l]),e)?(0,r.jsxs)("div",{className:"mb-4",children:["loading"===i.status&&(0,r.jsxs)("div",{className:"flex items-center gap-3 p-4",children:[(0,r.jsx)(eq.Loader2,{className:"h-5 w-5 animate-spin"}),(0,r.jsx)("span",{children:"Generating preview video..."})]}),"error"===i.status&&(0,r.jsx)(tb,{variant:"destructive",className:"mb-4",children:(0,r.jsxs)(ty,{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{children:i.error}),(0,r.jsx)(c.Button,{variant:"ghost",size:"sm",onClick:()=>o({status:"loading"}),children:"Retry"})]})}),"ready"===i.status&&i.videoUrl&&(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)("video",{ref:s,controls:!0,autoPlay:!0,src:i.videoUrl,className:"block w-full h-auto",children:"Your browser does not support the video tag."})})]}):null}function rU({open:e,onClose:t,data:n,onSubmit:a,isSubmitting:s=!1,apiClient:l=null,timingOffsetMs:i=0}){let o=n.corrections||[],d=n.corrected_segments?.length||0,m=o.some(e=>"ManualCorrector"===e.handler||"UserEdit"===e.handler);return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsx)(eO.DialogTitle,{children:"Preview Video (With Vocals)"})}),(0,r.jsx)(r$,{apiClient:l,isModalOpen:e,updatedData:n,timingOffsetMs:i}),(0,r.jsxs)("div",{className:"text-sm text-muted-foreground space-y-1",children:[m?(0,r.jsx)("p",{children:"Manual corrections detected. Review the preview to ensure the lyrics are synchronized correctly."}):(0,r.jsx)("p",{children:"No manual corrections detected. If everything looks good in the preview, click submit and the server will generate the final karaoke video."}),(0,r.jsxs)("p",{children:["Total segments: ",d]})]}),(0,r.jsxs)(eO.DialogFooter,{className:"border-t pt-4",children:[(0,r.jsxs)(c.Button,{variant:"ghost",onClick:t,className:"text-primary",children:[(0,r.jsx)(u.ArrowLeft,{className:"h-4 w-4 mr-2"}),"Cancel"]}),(0,r.jsxs)(c.Button,{onClick:a,disabled:s,className:"bg-green-600 hover:bg-green-700",children:["Complete Review",(0,r.jsx)(F.Upload,{className:"h-4 w-4 ml-2"})]})]})]})})}function rY({open:e,onClose:t,currentOffset:a,onApply:s}){let[l,i]=(0,n.useState)(a);return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(eO.DialogContent,{className:"max-w-md",children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsx)(eO.DialogTitle,{children:"Adjust Timing Offset"})}),(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(O.Label,{children:"Offset (milliseconds)"}),(0,r.jsxs)("div",{className:"flex gap-4 items-center",children:[(0,r.jsx)(tg,{value:[l],min:-5e3,max:5e3,step:10,onValueChange:([e])=>i(e),className:"flex-1"}),(0,r.jsx)(eU.Input,{type:"number",value:l,onChange:e=>i(Number(e.target.value)),className:"w-24"})]}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Positive values shift lyrics later, negative values shift them earlier."})]}),(0,r.jsxs)("div",{className:"bg-muted p-3 rounded space-y-1",children:[(0,r.jsxs)("p",{className:"text-sm",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Current offset:"})," ",(0,r.jsxs)("span",{className:"font-mono",children:[a,"ms"]})]}),(0,r.jsxs)("p",{className:"text-sm",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"New offset:"})," ",(0,r.jsxs)("span",{className:"font-mono font-medium",children:[l,"ms"]})]}),(0,r.jsxs)("p",{className:"text-sm",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Change:"})," ",(0,r.jsxs)("span",{className:"font-mono",children:[l-a,"ms"]})]})]})]}),(0,r.jsxs)(eO.DialogFooter,{className:"flex gap-2 sm:justify-between",children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:()=>{i(0)},children:"Reset to 0"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:t,children:"Cancel"}),(0,r.jsx)(c.Button,{onClick:()=>{s(l),t()},children:"Apply"})]})]})]})})}var rq="Progress",[rX,rV]=(0,ei.createContextScope)(rq),[rJ,rK]=rX(rq),rG=n.forwardRef((e,t)=>{var n,a;let{__scopeProgress:s,value:l=null,max:i,getValueLabel:o=r0,...d}=e;(i||0===i)&&!r5(i)&&console.error((n=`${i}`,`Invalid prop \`max\` of value \`${n}\` supplied to \`Progress\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`));let c=r5(i)?i:100;null===l||r4(l,c)||console.error((a=`${l}`,`Invalid prop \`value\` of value \`${a}\` supplied to \`Progress\`. The \`value\` prop must be:
|
|
5
|
+
- a positive number
|
|
6
|
+
- less than the value passed to \`max\` (or 100 if no \`max\` prop is set)
|
|
7
|
+
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
8
|
+
|
|
9
|
+
Defaulting to \`null\`.`));let u=r4(l,c)?l:null,m=r2(u)?o(u,c):void 0;return(0,r.jsx)(rJ,{scope:s,value:u,max:c,children:(0,r.jsx)(eo.Primitive.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":r2(u)?u:void 0,"aria-valuetext":m,role:"progressbar","data-state":r1(u,c),"data-value":u??void 0,"data-max":c,...d,ref:t})})});rG.displayName=rq;var rZ="ProgressIndicator",rQ=n.forwardRef((e,t)=>{let{__scopeProgress:n,...a}=e,s=rK(rZ,n);return(0,r.jsx)(eo.Primitive.div,{"data-state":r1(s.value,s.max),"data-value":s.value??void 0,"data-max":s.max,...a,ref:t})});function r0(e,t){return`${Math.round(e/t*100)}%`}function r1(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function r2(e){return"number"==typeof e}function r5(e){return r2(e)&&!isNaN(e)&&e>0}function r4(e,t){return r2(e)&&!isNaN(e)&&e<=t&&e>=0}function r8({className:e,value:t,...n}){return(0,r.jsx)(rG,{"data-slot":"progress",className:(0,o.cn)("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",e),...n,children:(0,r.jsx)(rQ,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})})}rQ.displayName=rZ;let r3=(0,f.default)("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);function r6({open:e,onClose:t,originalWord:n,correctedWord:a,category:s,confidence:l,reason:i,handler:d,source:u,onRevert:m,onEdit:h,onAccept:f}){let x=window.innerWidth<640;return(0,r.jsx)(eO.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(eO.DialogContent,{className:(0,o.cn)("max-w-md",x&&"max-h-[85vh]"),children:[(0,r.jsx)(eO.DialogHeader,{children:(0,r.jsxs)(eO.DialogTitle,{className:"flex justify-between items-center",children:[(0,r.jsx)("span",{className:"text-lg font-semibold",children:"Correction Details"}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8",children:(0,r.jsx)(L.X,{className:"h-4 w-4"})})]})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mb-1 block",children:"Change"}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex-1 px-3 py-2 bg-red-100 dark:bg-red-900/30 rounded text-center line-through",children:(0,r.jsx)("span",{className:"font-medium",children:n})}),(0,r.jsx)(r3,{className:"h-4 w-4 text-muted-foreground"}),(0,r.jsx)("div",{className:"flex-1 px-3 py-2 bg-green-100 dark:bg-green-900/30 rounded text-center",children:(0,r.jsx)("span",{className:"font-semibold",children:a})})]})]}),s&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mb-1 block",children:"Category"}),(0,r.jsxs)(tw.Badge,{variant:"outline",className:"text-sm",children:[s&&({SOUND_ALIKE:"",PUNCTUATION_ONLY:"",BACKGROUND_VOCALS:"",EXTRA_WORDS:"",REPEATED_SECTION:"",COMPLEX_MULTI_ERROR:"",AMBIGUOUS:"",NO_ERROR:""})[s]||""," ",s?s.split("_").map(e=>e.charAt(0)+e.slice(1).toLowerCase()).join(" "):"Unknown"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Confidence"}),(0,r.jsxs)("span",{className:"text-xs font-semibold",children:[(100*l).toFixed(0),"%"]})]}),(0,r.jsx)(r8,{value:100*l,className:"h-2"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mb-1 block",children:"Reasoning"}),(0,r.jsx)("div",{className:"p-3 bg-muted rounded border text-sm leading-relaxed",children:i})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsxs)(tw.Badge,{variant:"outline",className:"text-xs",children:["Handler: ",d]}),(0,r.jsxs)(tw.Badge,{variant:"outline",className:"text-xs",children:["Source: ",u]})]})]}),(0,r.jsxs)(eO.DialogFooter,{className:(0,o.cn)("gap-2",x&&"flex-col"),children:[(0,r.jsx)(c.Button,{variant:"outline",onClick:()=>{m(),t()},className:(0,o.cn)("text-destructive",x&&"w-full h-11"),children:"Revert to Original"}),(0,r.jsx)(c.Button,{variant:"outline",onClick:()=>{h(),t()},className:(0,o.cn)(x&&"w-full h-11"),children:"Edit Correction"}),(0,r.jsx)(c.Button,{onClick:()=>{f(),t()},className:(0,o.cn)("bg-green-600 hover:bg-green-700",x&&"w-full h-11"),children:"Mark as Correct"})]})]})})}let r7=e=>{let t=e.original_segments[0]?.text||"",r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e),r&=r;return`song_${r}`},r9=e=>JSON.parse(JSON.stringify(e)).corrected_segments.map(e=>{let{id:t,...r}=e;return{...r,words:e.words.map(e=>{let{id:t,...r}=e;return r})}}),ne=(0,f.default)("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);var nt=e.i(55436);let nr=(0,f.default)("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),nn=(0,f.default)("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]),na=(0,f.default)("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);var ns=e.i(86311),nl=e.i(86536);let ni=(0,f.default)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),no=(0,f.default)("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);function nd({effectiveMode:e,onChange:t}){return(0,r.jsx)(Z.TooltipProvider,{children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5 h-8",children:[(0,r.jsx)("span",{className:"text-[0.75rem] text-muted-foreground",children:"Mode:"}),(0,r.jsxs)(eA,{type:"single",value:e,onValueChange:e=>"edit"===e&&t(e),className:"h-8",children:[(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)(eP,{value:"edit",className:"h-8 px-2 text-[0.75rem]",children:[(0,r.jsx)(er,{className:"h-3.5 w-3.5 mr-1"}),"Edit"]})}),(0,r.jsx)(Z.TooltipContent,{children:(0,r.jsx)("p",{children:"Default mode; click words to edit that lyrics segment"})})]}),(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)(eP,{value:"highlight",className:"h-8 px-2 text-[0.75rem]",disabled:!0,children:[(0,r.jsx)(no,{className:"h-3.5 w-3.5 mr-1"}),"Highlight"]})}),(0,r.jsx)(Z.TooltipContent,{children:(0,r.jsx)("p",{children:"Hold SHIFT and click words to highlight the matching anchor sequence"})})]}),(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)(eP,{value:"delete_word",className:"h-8 px-2 text-[0.75rem]",disabled:!0,children:[(0,r.jsx)(eD.Trash2,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]})}),(0,r.jsx)(Z.TooltipContent,{children:(0,r.jsx)("p",{children:"Hold CTRL and click words to delete them"})})]})]})]})})}function nc({audioUrl:e,onTimeUpdate:t}){let[a,s]=(0,n.useState)(!1),[l,i]=(0,n.useState)(0),[o,d]=(0,n.useState)(0),u=(0,n.useRef)(null);(0,n.useEffect)(()=>{let r;if(!e)return;let n=new Audio(e);u.current=n;let a=()=>{let e=n.currentTime;i(e),t?.(e),r=requestAnimationFrame(a)};return n.addEventListener("play",()=>{s(!0),window.isAudioPlaying=!0,a()}),n.addEventListener("pause",()=>{s(!1),window.isAudioPlaying=!1,cancelAnimationFrame(r)}),n.addEventListener("ended",()=>{cancelAnimationFrame(r),s(!1),window.isAudioPlaying=!1,i(0)}),n.addEventListener("loadedmetadata",()=>{d(n.duration)}),()=>{cancelAnimationFrame(r),n.pause(),n.src="",u.current=null,window.isAudioPlaying=!1}},[e,t]);let m=e=>{let t=Math.floor(e/60),r=Math.floor(e%60);return`${t}:${r.toString().padStart(2,"0")}`},h=(0,n.useCallback)(e=>{u.current&&(u.current.currentTime=e,i(e),u.current.play(),s(!0))},[]),f=(0,n.useCallback)(()=>{u.current&&(a?u.current.pause():u.current.play(),s(!a))},[a]);return((0,n.useEffect)(()=>{if(e)return window.seekAndPlayAudio=h,window.toggleAudioPlayback=f,window.getAudioDuration=()=>o,()=>{delete window.seekAndPlayAudio,delete window.toggleAudioPlayback,delete window.getAudioDuration}},[e,h,f,o]),e)?(0,r.jsxs)("div",{className:"flex items-center gap-2 bg-card rounded h-8",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mr-1",children:"Playback:"}),(0,r.jsx)(c.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 p-0.5",onClick:()=>{u.current&&(a?u.current.pause():u.current.play(),s(!a))},children:a?(0,r.jsx)(p,{className:"h-4 w-4"}):(0,r.jsx)(x,{className:"h-4 w-4"})}),(0,r.jsx)("span",{className:"text-xs min-w-[32px]",children:m(l)}),(0,r.jsx)(tg,{value:[l],min:0,max:o||100,step:.1,onValueChange:e=>{if(!u.current)return;let t=e[0];u.current.currentTime=t,i(t)},className:"w-[100px] mx-1"}),(0,r.jsx)("span",{className:"text-xs min-w-[32px]",children:m(o)})]}):null}function nu({isReadOnly:e,onFileLoad:t,data:n,onMetricClick:a,effectiveMode:s,onModeChange:l,apiClient:i,audioHash:d,onTimeUpdate:u,onHandlerToggle:m,isUpdatingHandlers:h,onHandlerClick:f,onFindReplace:x,onEditAll:p,onUnCorrectAll:g,onResetCorrections:w,onTimingOffset:v,timingOffsetMs:b=0,onUndo:y,onRedo:j,canUndo:_,canRedo:N,annotationsEnabled:C=!0,onAnnotationsToggle:k,reviewMode:S=!1,onReviewModeToggle:T,onAcceptAllCorrections:E,onAcceptHighConfidenceCorrections:M,onRevertAllCorrections:R}){let A=window.innerWidth<768,P=n.corrections?.reduce((e,t)=>(e[t.handler]=(e[t.handler]||0)+1,e),{})||{},D=n.metadata.available_handlers||[],B=new Set(n.metadata.enabled_handlers||[]),L=D.some(e=>"AgenticCorrector"===e.id),z=n.corrections.reduce((e,t)=>{let r=n.gap_sequences.find(e=>e.transcribed_word_ids.includes(t.word_id));return r&&(e[r.id]=(e[r.id]||0)+1),e},{}),I=Object.keys(z).length,W=n.gap_sequences.length-I,H=n.corrections.filter(e=>!e.is_deletion&&!e.split_total).length,$=n.corrections.filter(e=>e.split_total).length,U=n.corrections.filter(e=>e.is_deletion).length,Y=n.metadata.total_words||0,q=n.anchor_sequences?.reduce((e,t)=>e+(t.transcribed_word_ids?.length||0),0)??0,V=n.anchor_sequences?.filter(e=>e?.reference_word_ids&&Object.keys(e.reference_word_ids).length>1).length??0,J=n.gap_sequences.filter(e=>!z[e.id]&&e.transcribed_word_ids.length>0),K=J.reduce((e,t)=>e+t.transcribed_word_ids.length,0),G=Y>0?Math.round(q/Y*100):0,Q=H+$,ee=Y>0?Math.round(Q/Y*100):0,et=Y>0?Math.round(K/Y*100):0;return(0,r.jsx)(Z.TooltipProvider,{children:(0,r.jsxs)("div",{className:"space-y-2",children:[e&&(0,r.jsxs)("div",{className:"flex items-center gap-1 text-muted-foreground text-sm mb-2",children:[(0,r.jsx)(ne,{className:"h-4 w-4"}),(0,r.jsx)("span",{children:"View Only Mode"})]}),(0,r.jsxs)("div",{className:"flex gap-2 justify-end items-center mb-2",children:[!e&&L&&T&&(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)(tw.Badge,{variant:S?"default":"outline",className:"cursor-pointer",onClick:()=>T(!S),children:[(0,r.jsx)(nl.Eye,{className:"h-3 w-3 mr-1"}),S?"Review Mode":"Review Off"]})}),(0,r.jsx)(Z.TooltipContent,{children:S?"Hide inline correction actions":"Show inline actions on all corrections for quick review"})]}),e&&(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:t,className:(0,o.cn)(A&&"w-full"),children:[(0,r.jsx)(F.Upload,{className:"h-4 w-4 mr-1"}),"Load File"]})]}),(0,r.jsxs)("div",{className:(0,o.cn)("flex gap-2 mb-2 overflow-hidden",A?"flex-col":"flex-row",A?"h-auto":"h-[140px]"),children:[(0,r.jsxs)(X.Card,{className:(0,o.cn)("p-2",A?"w-full":"w-[280px] min-w-[280px]"),children:[(0,r.jsx)("h4",{className:"text-xs text-muted-foreground mb-1",children:"Correction Handlers"}),(0,r.jsx)("div",{className:"flex-1 overflow-auto flex flex-col",children:D.map(e=>(0,r.jsx)("div",{className:"mb-1",children:(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(t$.Switch,{checked:B.has(e.id),onCheckedChange:t=>m(e.id,t),disabled:h,className:"scale-75"}),(0,r.jsxs)(O.Label,{className:"text-xs cursor-pointer",onClick:()=>f?.(e.id),children:[e.name," (",P[e.id]||0,")"]})]})}),(0,r.jsx)(Z.TooltipContent,{children:(0,r.jsx)("p",{children:e.description})})]})},e.id))})]}),(0,r.jsxs)("div",{className:"flex-1 grid grid-cols-3 gap-2 h-full",children:[(0,r.jsxs)(X.Card,{className:"p-2 cursor-pointer hover:bg-muted/30 transition-colors flex flex-col overflow-hidden h-full",onClick:a.anchor,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 mb-0.5",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded bg-blue-500/25 shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:"Anchor Sequences"})]}),(0,r.jsxs)("span",{className:"text-lg font-semibold leading-tight",children:[n.metadata.anchor_sequences_count??"-"," (",G,"%)"]}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground leading-tight",children:"Matched sections between transcription and reference"}),(0,r.jsxs)("div",{className:"mt-auto space-y-0 text-[10px]",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Words in Anchors"}),(0,r.jsx)("span",{children:q})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Multi-source Matches"}),(0,r.jsx)("span",{children:V})]})]})]}),(0,r.jsxs)(X.Card,{className:"p-2 cursor-pointer hover:bg-muted/30 transition-colors flex flex-col overflow-hidden h-full",onClick:a.corrected,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 mb-0.5",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded bg-green-500/25 shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:"Corrected Gaps"})]}),(0,r.jsxs)("span",{className:"text-lg font-semibold text-green-500 leading-tight",children:[I," (",ee,"%)"]}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground leading-tight",children:"Successfully corrected sections"}),(0,r.jsxs)("div",{className:"mt-auto space-y-0 text-[10px]",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Words Replaced"}),(0,r.jsx)("span",{children:H})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Words Added / Deleted"}),(0,r.jsxs)("span",{children:["+",$," / -",U]})]})]})]}),(0,r.jsxs)(X.Card,{className:"p-2 cursor-pointer hover:bg-muted/30 transition-colors flex flex-col overflow-hidden h-full",onClick:a.uncorrected,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 mb-0.5",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded bg-orange-500/25 shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:"Uncorrected Gaps"})]}),(0,r.jsxs)("span",{className:"text-lg font-semibold text-amber-500 leading-tight",children:[W," (",et,"%)"]}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground leading-tight",children:"Sections that may need manual review"}),(0,r.jsxs)("div",{className:"mt-auto space-y-0 text-[10px]",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Words Uncorrected"}),(0,r.jsx)("span",{children:K})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Number of Gaps"}),(0,r.jsx)("span",{children:J.length})]})]})]})]})]}),!e&&S&&L&&n.corrections?.length>0&&(0,r.jsx)(X.Card,{className:"p-2 mb-2 bg-accent/50",children:(0,r.jsxs)("div",{className:(0,o.cn)("flex gap-2",A?"flex-col":"flex-row items-center justify-between"),children:[(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Batch Actions (",n.corrections.length," corrections)"]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[M&&(0,r.jsxs)(c.Button,{size:"sm",onClick:M,className:"bg-green-600 hover:bg-green-700 text-xs h-7",children:[(0,r.jsx)(ni,{className:"h-3 w-3 mr-1"}),"Accept High Confidence (",n.corrections.filter(e=>e.confidence>=.8).length,")"]}),E&&(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:E,className:"text-xs h-7",children:[(0,r.jsx)(ni,{className:"h-3 w-3 mr-1"}),"Accept All"]}),R&&(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:R,className:"text-destructive text-xs h-7",children:[(0,r.jsx)(tB.XCircle,{className:"h-3 w-3 mr-1"}),"Revert All"]})]})]})}),(0,r.jsx)(X.Card,{className:"p-2 mb-2",children:(0,r.jsxs)("div",{className:(0,o.cn)("flex gap-2 items-center",A?"flex-col items-start":"flex-row"),children:[(0,r.jsxs)("div",{className:"flex gap-1 flex-wrap items-center flex-1",children:[(0,r.jsx)(nd,{effectiveMode:s,onChange:l}),!e&&w&&(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:w,className:"h-8 text-xs text-amber-500 border-amber-500/50 hover:border-amber-500 hover:bg-amber-500/10",children:[(0,r.jsx)(nr,{className:"h-3.5 w-3.5 mr-1"}),"Undo All"]})}),(0,r.jsx)(Z.TooltipContent,{children:"Undo all your changes"})]}),!e&&(0,r.jsxs)("div",{className:"flex h-8",children:[(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsx)(c.Button,{variant:"outline",size:"icon",onClick:y,disabled:!_,className:"h-8 w-8",children:(0,r.jsx)(nr,{className:"h-3.5 w-3.5"})})}),(0,r.jsx)(Z.TooltipContent,{children:"Undo"})]}),(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsx)(c.Button,{variant:"outline",size:"icon",onClick:j,disabled:!N,className:"h-8 w-8",children:(0,r.jsx)(nn,{className:"h-3.5 w-3.5"})})}),(0,r.jsx)(Z.TooltipContent,{children:"Redo"})]})]}),!e&&(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:x,className:"h-8 text-xs",children:[(0,r.jsx)(nt.Search,{className:"h-3.5 w-3.5 mr-1"}),"Find/Replace"]}),!e&&p&&(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:p,className:"h-8 text-xs",children:[(0,r.jsx)(er,{className:"h-3.5 w-3.5 mr-1"}),"Edit All"]}),!e&&g&&(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:g,className:"h-8 text-xs",children:[(0,r.jsx)(tk.RotateCcw,{className:"h-3.5 w-3.5 mr-1"}),"Undo Auto Corrections"]})}),(0,r.jsx)(Z.TooltipContent,{children:"Revert only automatic AI corrections (keeps your manual edits)"})]}),!e&&v&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:v,className:(0,o.cn)("h-8 text-xs",0!==b&&"border-purple-500 text-purple-500"),children:[(0,r.jsx)(na,{className:"h-3.5 w-3.5 mr-1"}),"Timing Offset"]}),0!==b&&(0,r.jsxs)("span",{className:"ml-1 text-xs font-bold text-purple-500",children:[b>0?"+":"",b,"ms"]})]}),!e&&k&&(0,r.jsxs)(Z.Tooltip,{children:[(0,r.jsx)(Z.TooltipTrigger,{asChild:!0,children:(0,r.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:()=>k(!C),className:(0,o.cn)("h-8 text-xs",C&&"border-primary"),children:[(0,r.jsx)(ns.MessageSquare,{className:"h-3.5 w-3.5 mr-1"}),C?"Feedback On":"Feedback Off"]})}),(0,r.jsx)(Z.TooltipContent,{children:C?"Click to disable annotation prompts when editing":"Click to enable annotation prompts when editing"})]})]}),(0,r.jsx)(nc,{audioUrl:i?i.getAudioUrl(d):null,onTimeUpdate:u})]})})]})})}function nm({data:e,onFileLoad:a,apiClient:s,isReadOnly:l,audioHash:i}){let d,u=window.innerWidth<768,[m,h]=(0,n.useState)(null),[f,x]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[w,v]=(0,n.useState)(()=>{if(!e?.reference_lyrics)return"";let t=Object.keys(e.reference_lyrics);return t.length>0?t[0]:""}),[b,y]=(0,n.useState)(!1),[j]=(0,n.useState)(()=>JSON.parse(JSON.stringify(e))),[_,N]=(0,n.useState)("edit"),[C,k]=(0,n.useState)(!1),[S,T]=(0,n.useState)(!1),[E,M]=(0,n.useState)(null),[R,A]=(0,n.useState)(!1),[P,D]=(0,n.useState)(!1),[B,L]=(0,n.useState)(0),[z,I]=(0,n.useState)(!1),[O,W]=(0,n.useState)(null),[F,H]=(0,n.useState)(!1),[$,U]=(0,n.useState)(!1),[Y,X]=(0,n.useState)(!1),[V,K]=(0,n.useState)(!1),[G,Z]=(0,n.useState)(!1),[Q,ee]=(0,n.useState)(0),[et,er]=(0,n.useState)(!1),[en,ea]=(0,n.useState)([]),[es,ei]=(0,n.useState)(!1),[eo,ed]=(0,n.useState)(null),[ec,eu]=(0,n.useState)(()=>{let e=localStorage.getItem("annotationsEnabled");return null===e||"true"===e}),[em,eh]=(0,n.useState)(!1),[ef,ex]=(0,n.useState)(null),[ep,eg]=(0,n.useState)([e]),[ew,ev]=(0,n.useState)(0),eb=ep[ew],ey=(0,n.useCallback)((e,t)=>{let r=ep.slice(0,ew+1),n=JSON.parse(JSON.stringify(e));r.push(n),eg(r),ev(r.length-1)},[ep,ew]);(0,n.useEffect)(()=>{eg([e]),ev(0)},[e]),(0,n.useEffect)(()=>{let t=(e=>{let t=r7(e),r=localStorage.getItem("lyrics_analyzer_data"),n=r?JSON.parse(r):{};if(n[t])try{let r=n[t];if(r.original_segments[0]?.text===e.original_segments[0]?.text){let a=r9(r),s=r9(e);if(JSON.stringify(a)!==JSON.stringify(s))return r;delete n[t],localStorage.setItem("lyrics_analyzer_data",JSON.stringify(n))}}catch(e){console.error("Failed to parse saved data:",e),delete n[t],localStorage.setItem("lyrics_analyzer_data",JSON.stringify(n))}return null})(e);t&&window.confirm("Found saved progress for this song. Would you like to restore it?")&&(eg([t]),ev(0))},[e]),(0,n.useEffect)(()=>{let t,r,n;l||(t=r7(e),(n=(r=localStorage.getItem("lyrics_analyzer_data"))?JSON.parse(r):{})[t]=eb,localStorage.setItem("lyrics_analyzer_data",JSON.stringify(n)))},[eb,l,e]),(0,n.useEffect)(()=>{var e;let r,n,a,{handleKeyDown:s,handleKeyUp:l,cleanup:i}=(e={setIsShiftPressed:k,setIsCtrlPressed:T},Math.random().toString(36).substr(2,9),r=()=>{e.setIsShiftPressed(!1),e.setIsCtrlPressed?.(!1),document.body.style.userSelect=""},n=()=>{r()},a=()=>{r()},window.addEventListener("blur",n),window.addEventListener("focus",a),{handleKeyDown:r=>{r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||("Shift"===r.key?(e.setIsShiftPressed(!0),document.body.style.userSelect="none"):"Control"===r.key||"Ctrl"===r.key||"Meta"===r.key?e.setIsCtrlPressed?.(!0):(" "===r.key||"Space"===r.code)&&(r.preventDefault(),tW&&t?t(r):window.toggleAudioPlayback&&!tW&&window.toggleAudioPlayback()))},handleKeyUp:e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||(r(),(" "===e.key||"Space"===e.code)&&(e.preventDefault(),tW&&t&&t(e)))},cleanup:()=>{window.removeEventListener("blur",n),window.removeEventListener("focus",a)}});return window.addEventListener("keydown",s),window.addEventListener("keyup",l),Y&&(k(!1),T(!1)),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",l),document.body.style.userSelect="",i()}},[Y]),(0,n.useEffect)(()=>{X(!!(m||E||P||$||V||R||G))},[m,E,P,$,V,R,G]);let ej=S?"delete_word":C?"highlight":_,e_=(0,n.useCallback)((e,t)=>{x(null),g(null),requestAnimationFrame(()=>{requestAnimationFrame(()=>{x(e),t&&g(t),setTimeout(()=>{x(null),g(null)},1200)})})},[]),eN=(0,n.useCallback)(e=>{ea(t=>[...t,e])},[]),eC=(0,n.useCallback)(()=>{},[]),ek=(0,n.useCallback)(e=>{eu(e),localStorage.setItem("annotationsEnabled",String(e))},[]),eS=(0,n.useCallback)((e,t,r,n)=>{ec&&!l&&(ed({originalText:e,correctedText:t,wordIdsAffected:r,gapId:n}),ei(!0))},[ec,l]),eT=(0,n.useCallback)(e=>{let t=eb.corrections?.find(t=>t.corrected_word_id===e||t.word_id===e);if(!t)return;let r=t.reason?.match(/\[([A-Z_]+)\]/),n=r?r[1]:null,a=eb.corrected_segments.flatMap(e=>e.words).find(t=>t.id===e)?.text||t.corrected_word;ex({wordId:e,originalWord:t.original_word,correctedWord:a,category:n,confidence:t.confidence,reason:t.reason,handler:t.handler,source:t.source}),eh(!0)},[eb]),eE=(0,n.useCallback)(e=>{if("delete_word"===ej){ey(function(e,t){let r=e.corrected_segments.findIndex(e=>e.words.some(e=>e.id===t));if(-1===r)return e;let n=e.corrected_segments[r],a=n.words.findIndex(e=>e.id===t);if(-1===a)return e;let s=n.words.filter((e,t)=>t!==a);if(!(s.length>0))return eI(e,r);{let t,a={...n,words:s,text:s.map(e=>e.text).join(" ")};return t={...e},a.words=a.words.map(e=>({...e,id:e.id||ez()})),t.corrected_segments[r]=a,t}}(eb,e.word_id),"delete word"),e_("word");return}if("highlight"===ej){let t=eb.corrections?.find(t=>t.corrected_word_id===e.word_id||t.word_id===e.word_id);if(t)return"AgenticCorrector"===t.handler?void eT(e.word_id):(g({type:"correction",transcribed_words:[],correction:t}),void x("word"));let r=eb.anchor_sequences?.find(t=>t.transcribed_word_ids.includes(e.word_id)||Object.values(t.reference_word_ids).some(t=>t.includes(e.word_id)));if(r){let e=eb.corrected_segments.flatMap(e=>e.words),t=J([{id:"temp",words:e,text:e.map(e=>e.text).join(" "),start_time:e[0]?.start_time??null,end_time:e[e.length-1]?.end_time??null}],r.transcribed_word_ids),n=Object.fromEntries(Object.entries(r.reference_word_ids).map(([e,t])=>{let r=eb.reference_lyrics[e].segments.flatMap(e=>e.words),n={id:`temp-${e}`,words:r,text:r.map(e=>e.text).join(" "),start_time:r[0]?.start_time??null,end_time:r[r.length-1]?.end_time??null};return[e,J([n],t)]}));g({type:"anchor",sequence:r,transcribed_words:t,reference_words:n}),x("word");return}}else if("edit"===ej){let t=eb.corrected_segments.findIndex(t=>t.words.some(t=>t.id===e.word_id));if(-1!==t){let e=eb.corrected_segments[t];M({segment:e,index:t,originalSegment:JSON.parse(JSON.stringify(e))})}}},[eb,ej,ey,e_,eT]),eM=(0,n.useCallback)(e=>{if(!E)return;let t=ep[ew],r=t.corrected_segments.map((t,r)=>r===E.index?e:t);ey({...t,corrected_segments:r},"update segment");let n=E.originalSegment||E.segment;if(n&&n.text!==e.text){let t=e.words.map(e=>e.id);eS(n.text,e.text,t)}M(null)},[ep,ew,E,ey,eS]),eR=(0,n.useCallback)(e=>{ey(eI(eb,e),"delete segment")},[eb,ey]),eA=(0,n.useCallback)(e=>{let t=eb.corrections?.find(t=>t.corrected_word_id===e||t.word_id===e);if(!t)return;let r=eb.corrected_segments.findIndex(t=>t.words.some(t=>t.id===e));if(-1===r)return;let n=eb.corrected_segments[r],a=n.words.map(r=>r.id===e?{...r,text:t.original_word,id:t.word_id}:r),s=a.map(e=>e.text).join(" "),l={...n,words:a,text:s},i=eb.corrected_segments.map((e,t)=>t===r?l:e),o=eb.corrections?.filter(t=>t.corrected_word_id!==e&&t.word_id!==e)||[];ey({...eb,corrected_segments:i,corrections:o},"revert correction")},[eb,ey]),eP=(0,n.useCallback)(e=>{let t=eb.corrected_segments.findIndex(t=>t.words.some(t=>t.id===e));if(-1===t)return;let r=eb.corrected_segments[t];M({segment:r,index:t,originalSegment:r})},[eb]),eD=(0,n.useCallback)(e=>{},[]),eB=(0,n.useCallback)(()=>{eb.corrections?.forEach(e=>{console.log("Batch accepted correction:",e.corrected_word_id||e.word_id)})},[eb.corrections]),eL=(0,n.useCallback)(()=>{(eb.corrections?.filter(e=>e.confidence>=.8)||[]).forEach(e=>{console.log("Batch accepted high-confidence correction:",e.corrected_word_id||e.word_id)})},[eb.corrections]),eO=(0,n.useCallback)(()=>{if(!window.confirm(`Are you sure you want to revert all ${eb.corrections?.length||0} corrections?`))return;let e=[...eb.corrections||[]].reverse(),t=eb;for(let r of e){let e=r.corrected_word_id||r.word_id,n=t.corrected_segments.findIndex(t=>t.words.some(t=>t.id===e));if(-1===n)continue;let a=t.corrected_segments[n],s=a.words.map(t=>t.id===e?{...t,text:r.original_word,id:r.word_id}:t),l=s.map(e=>e.text).join(" "),i={...a,words:s,text:l},o=t.corrected_segments.map((e,t)=>t===n?i:e);t={...t,corrected_segments:o,corrections:t.corrections?.filter(t=>t.corrected_word_id!==e&&t.word_id!==e)||[]}}ey(t,"revert all corrections")},[eb,ey]),eW=(0,n.useCallback)(()=>{D(!0)},[]),eF=(0,n.useCallback)(async()=>{if(s)try{let e=0!==Q?rH(eb,Q):eb;if(await s.submitCorrections(e),en.length>0)try{await s.submitAnnotations(en)}catch(e){console.error("Failed to submit annotations:",e)}y(!0),D(!1),window.close()}catch(e){console.error("Failed to submit corrections:",e),alert("Failed to submit corrections. Please try again.")}},[s,eb,Q,en]),eH=(0,n.useCallback)(e=>{if(window.seekAndPlayAudio){let t=0!==Q?e+Q/1e3:e;window.seekAndPlayAudio(t)}},[Q]),eU=(0,n.useCallback)(()=>{if(window.confirm("Are you sure you want to reset all corrections?")){let t,r,n;t=r7(e),n=(r=localStorage.getItem("lyrics_analyzer_data"))?JSON.parse(r):{},delete n[t],localStorage.setItem("lyrics_analyzer_data",JSON.stringify(n)),eg([JSON.parse(JSON.stringify(e))]),ev(0),h(null),x(null),g(null),N("edit")}},[e]),eY=(0,n.useCallback)(e=>{let t,r,n,a;ey((n=(r=Math.max(0,((t={...eb}).corrected_segments[e].start_time??1)-1))+1,a={id:ez(),text:"REPLACE",start_time:r,end_time:n,words:[{id:ez(),text:"REPLACE",start_time:r,end_time:n,confidence:1}]},t.corrected_segments.splice(e,0,a),t),"add segment")},[eb,ey]),eq=(0,n.useCallback)((e,t)=>{let r=((e,t,r)=>{let n={...e},a=n.corrected_segments[t],s=a.words.slice(0,r+1),l=a.words.slice(r+1);if(0===l.length)return null;let i=s[s.length-1],o=l[0],d=l[l.length-1],c={...a,words:s,text:s.map(e=>e.text).join(" "),end_time:i.end_time??null},u={id:ez(),words:l,text:l.map(e=>e.text).join(" "),start_time:o.start_time??null,end_time:d.end_time??null};return n.corrected_segments.splice(t,1,c,u),n})(eb,e,t);r&&(ey(r,"split segment"),M(null))},[eb,ey]),eV=(0,n.useCallback)((e,t)=>{ey(function(e,t,r){let n=[...e.corrected_segments],a=r?t+1:t-1;if(a<0||a>=n.length)return e;let s=n[t],l=n[a];return n.splice(Math.min(t,a),2,{id:ez(),words:r?[...s.words,...l.words]:[...l.words,...s.words],text:r?`${s.text} ${l.text}`:`${l.text} ${s.text}`,start_time:Math.min(s.start_time??1/0,l.start_time??1/0),end_time:Math.max(s.end_time??-1/0,l.end_time??-1/0)}),{...e,corrected_segments:n}}(eb,e,t),"merge segment"),M(null)},[eb,ey]),eJ=(0,n.useCallback)(async(e,t)=>{if(s)try{I(!0);let r=new Set(eb.metadata.enabled_handlers||[]);t?r.add(e):r.delete(e);let n=await s.updateHandlers(Array.from(r));ey(n,`toggle handler ${e}`),h(null),x(null),g(null),e_("corrected")}catch(e){console.error("Failed to update handlers:",e),alert("Failed to update correction handlers. Please try again.")}finally{I(!1)}},[s,eb.metadata.enabled_handlers,e_,ey]),eK=(0,n.useCallback)(e=>{W(e),x("handler"),setTimeout(()=>{W(null),x(null)},1500)},[]),eG=(0,n.useCallback)(e=>{tF(e,!!e)},[]),eZ=(0,n.useCallback)(async(e,t)=>{if(s)try{H(!0);let r=await s.addLyrics(e,t);ey(r,"add lyrics")}finally{H(!1)}},[s,ey]),eQ=(0,n.useCallback)((e,t,r)=>{ey(function(e,t,r,n={caseSensitive:!1,useRegex:!1,fullTextMode:!1}){let a={...e};return n.fullTextMode?a.corrected_segments=e.corrected_segments.map(e=>{let a;a=n.useRegex?new RegExp(t,n.caseSensitive?"g":"gi"):new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n.caseSensitive?"g":"gi");let s=e.text;if(!a.test(s))return e;a.lastIndex=0;let l=s.replace(a,r),i=l.trim().split(/\s+/).filter(e=>e.length>0),o=[];if(i.length===e.words.length)for(let t=0;t<i.length;t++)o.push({...e.words[t],text:i[t]});else if(i.length<e.words.length){let t=0;for(let r=0;r<i.length;r++){for(;t<e.words.length&&""===e.words[t].text.trim();)t++;t<e.words.length?(o.push({...e.words[t],text:i[r]}),t++):o.push({id:ez(),text:i[r],start_time:null,end_time:null})}}else for(let t=0;t<i.length;t++)t<e.words.length?o.push({...e.words[t],text:i[t]}):o.push({id:ez(),text:i[t],start_time:null,end_time:null});return{...e,words:o,text:l}}):a.corrected_segments=e.corrected_segments.map(e=>{let a=e.words.map(e=>{let a;return a=n.useRegex?new RegExp(t,n.caseSensitive?"g":"gi"):new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n.caseSensitive?"g":"gi"),{...e,text:e.text.replace(a,r)}});return a=a.filter(e=>""!==e.text.trim()),{...e,words:a,text:a.map(e=>e.text).join(" ")}}),a.corrected_segments=a.corrected_segments.filter(e=>e.words.length>0),a}(eb,e,t,r),"find/replace")},[eb,ey]),e0=(0,n.useCallback)(()=>{j.original_segments&&window.confirm("Are you sure you want to revert all segments to their original state?")&&ey({...eb,corrected_segments:JSON.parse(JSON.stringify(j.original_segments))},"un-correct all segments")},[j.original_segments,eb,ey]),e1=(0,n.useCallback)(()=>{A(!0)},[]),e2=(0,n.useCallback)(e=>{ey({...eb,corrected_segments:e},"replace all lyrics"),A(!1)},[eb,ey]),e5=(0,n.useCallback)(()=>{ew>0&&ev(ew-1)},[ew]),e4=(0,n.useCallback)(()=>{ew<ep.length-1&&ev(ew+1)},[ew,ep]),e8=ew>0,e3=ew<ep.length-1,e6=(0,n.useMemo)(()=>({anchor:()=>e_("anchor"),corrected:()=>e_("corrected"),uncorrected:()=>e_("uncorrected")}),[e_]),e7=(0,n.useMemo)(()=>0!==Q?rH(eb,Q):eb,[eb,Q]),e9=(0,n.useCallback)(()=>{Z(!0)},[]),te=(0,n.useCallback)(e=>{ee(e)},[]);return(0,r.jsxs)("div",{className:"max-w-full overflow-x-hidden",children:[(0,r.jsx)(nu,{isReadOnly:l,onFileLoad:a,data:eb,onMetricClick:e6,effectiveMode:ej,onModeChange:N,apiClient:s,audioHash:i,onTimeUpdate:L,onHandlerToggle:eJ,isUpdatingHandlers:z,onHandlerClick:eK,onFindReplace:()=>K(!0),onEditAll:e1,onTimingOffset:e9,timingOffsetMs:Q,onUndo:e5,onRedo:e4,canUndo:e8,canRedo:e3,onUnCorrectAll:e0,onResetCorrections:eU,annotationsEnabled:ec,onAnnotationsToggle:ek,reviewMode:et,onReviewModeToggle:er,onAcceptAllCorrections:eB,onAcceptHighConfidenceCorrections:eL,onRevertAllCorrections:eO}),(0,r.jsxs)("div",{className:(0,o.cn)("grid gap-2",u?"grid-cols-1":"grid-cols-2"),children:[(0,r.jsx)(e$,{data:e7,mode:ej,onElementClick:h,onWordClick:eE,flashingType:f,flashingHandler:O,highlightInfo:p,onPlaySegment:eH,currentTime:Y?void 0:B,anchors:eb.anchor_sequences,onDataChange:e=>{ey(e,"direct data change")},reviewMode:et,onRevertCorrection:eA,onEditCorrection:eP,onAcceptCorrection:eD,onShowCorrectionDetail:eT}),(0,r.jsx)(el,{referenceSources:eb.reference_lyrics,anchors:eb.anchor_sequences,gaps:eb.gap_sequences,mode:ej,onElementClick:h,onWordClick:eE,flashingType:f,highlightInfo:p,currentSource:w,onSourceChange:v,corrected_segments:eb.corrected_segments,corrections:eb.corrections,onAddLyrics:()=>U(!0)})]}),!l&&s&&(0,r.jsx)("div",{className:"h-16"}),!l&&s&&(0,r.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 bg-background border-t shadow-lg py-3 px-4 z-50 flex justify-center items-center gap-4",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"Lyrics look good?"}),(0,r.jsxs)(c.Button,{onClick:eW,disabled:b,children:[b?"Review Complete":"Preview Video",(0,r.jsx)(q.Video,{className:"ml-2 h-4 w-4"})]})]}),(0,r.jsx)(tH,{open:!!E,onClose:()=>{M(null),eG(void 0)},segment:E?.segment?0!==Q?rF(E.segment,Q):E.segment:null,segmentIndex:E?.index??null,originalSegment:E?.originalSegment?0!==Q?rF(E.originalSegment,Q):E.originalSegment:null,onSave:eM,onDelete:eR,onAddSegment:eY,onSplitSegment:eq,onMergeSegment:eV,onPlaySegment:eH,currentTime:B,originalTranscribedSegment:E?.segment&&E?.index!==null&&j.original_segments?(d=j.original_segments.find(e=>e.id===E.segment.id)||null)&&0!==Q?rF(d,Q):d:null}),(0,r.jsx)(rU,{open:P,onClose:()=>D(!1),data:eb,onSubmit:eF,apiClient:s,timingOffsetMs:Q}),(0,r.jsx)(eX,{open:$,onClose:()=>U(!1),onAdd:eZ}),(0,r.jsx)(rw,{open:V,onClose:()=>K(!1),onReplace:eQ,data:eb}),(0,r.jsx)(rY,{open:G,onClose:()=>Z(!1),currentOffset:Q,onApply:te}),(0,r.jsx)(rO,{open:R,onClose:()=>A(!1),onSave:e2,onPlaySegment:eH,currentTime:B,setModalSpacebarHandler:eG,existingSegments:eb.corrected_segments}),eo&&(0,r.jsx)(tN,{open:es,onClose:()=>{ei(!1),ed(null)},onSave:eN,onSkip:eC,originalText:eo.originalText,correctedText:eo.correctedText,wordIdsAffected:eo.wordIdsAffected,referenceSources:Object.keys(eb.reference_lyrics||{}),audioHash:i,artist:eb.metadata?.audio_filepath?.split("/").pop()?.split(".")[0]||"Unknown",title:eb.metadata?.audio_filepath?.split("/").pop()?.split(".")[0]||"Unknown",sessionId:i,gapId:eo.gapId}),ef&&(0,r.jsx)(r6,{open:em,onClose:()=>{eh(!1),ex(null)},originalWord:ef.originalWord,correctedWord:ef.correctedWord,category:ef.category,confidence:ef.confidence,reason:ef.reason,handler:ef.handler,source:ef.source,onRevert:()=>{eA(ef.wordId),eh(!1),ex(null)},onEdit:()=>{eP(ef.wordId),eh(!1),ex(null)},onAccept:()=>{eD(ef.wordId),eh(!1),ex(null)}})]})}var nh=e.i(62474);let nf=[...new Set(["8000","8001","8764","8765","8766","8767","8768","8769","8765","8766","8767","8768","8769","8770","3000","3001","3002"])];function nx(){let e=(0,a.useParams)();(0,a.useRouter)();let{jobId:t,routeType:i}=function(e){if(!e||0===e.length)return{jobId:null,routeType:"unknown"};if(2===e.length){let[t,r]=e;if("review"===r)return{jobId:t,routeType:"review"};if("instrumental"===r)return{jobId:t,routeType:"instrumental"}}return{jobId:null,routeType:"unknown"}}(e.slug),{user:o,isLoading:f}=(0,s.useAuth)(),[x,p]=(0,n.useState)({status:"loading"});if((0,n.useEffect)(()=>{!async function(){if(function(){let{hostname:e,port:t}=window.location;return("localhost"===e||"127.0.0.1"===e)&&nf.includes(t)}()){var e;let t=i;"unknown"===t&&(t=window.location.pathname.includes("instrumental")?"instrumental":"review"),p({status:"local_mode",job:{job_id:"local",status:"review"===(e={routeType:t}).routeType?"awaiting_review":"awaiting_instrumental_selection",progress:50,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),artist:e.artist||"Local Artist",title:e.title||"Local Title",user_email:"local@localhost",audio_hash:"local"},routeType:t});return}if(!t||"unknown"===i)return p({status:"invalid_route"});if(!f){if(!o)return p({status:"not_authenticated"});try{let e=await l.api.getJob(t),r=e.user_email===o.email,n="admin"===o.role;if(!r&&!n)return void p({status:"not_authorized",reason:"You don't have permission to access this job"});let a=function(e){switch(e){case"review":return["awaiting_review","in_review"];case"instrumental":return["awaiting_instrumental_selection"];default:return[]}}(i);if(!a.includes(e.status))return void p({status:"wrong_state",currentState:e.status,expectedStates:a});p({status:"authorized",job:e,routeType:i})}catch(e){e&&"object"==typeof e&&"status"in e&&404===e.status?p({status:"job_not_found"}):p({status:"not_authorized",reason:"Failed to load job details"})}}}()},[t,i,o,f]),"loading"===x.status)return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(d,{className:"w-8 h-8 mx-auto mb-4"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:"Loading..."})]})});if("invalid_route"===x.status)return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,r.jsx)(m.AlertCircle,{className:"w-12 h-12 mx-auto mb-4 text-red-500"}),(0,r.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Page not found"}),(0,r.jsx)("p",{className:"text-muted-foreground mb-4",children:"The page you're looking for doesn't exist."}),(0,r.jsx)(c.Button,{variant:"outline",asChild:!0,children:(0,r.jsxs)(h.default,{href:"/app",children:[(0,r.jsx)(u.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back to dashboard"]})})]})});if("not_authenticated"===x.status)return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,r.jsx)(m.AlertCircle,{className:"w-12 h-12 mx-auto mb-4 text-amber-500"}),(0,r.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Sign in required"}),(0,r.jsx)("p",{className:"text-muted-foreground mb-4",children:"You need to sign in to access this page."}),(0,r.jsx)(c.Button,{asChild:!0,children:(0,r.jsx)(h.default,{href:"/app",children:"Sign in"})})]})});if("not_authorized"===x.status)return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,r.jsx)(m.AlertCircle,{className:"w-12 h-12 mx-auto mb-4 text-red-500"}),(0,r.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Access denied"}),(0,r.jsx)("p",{className:"text-muted-foreground mb-4",children:x.reason}),(0,r.jsx)(c.Button,{variant:"outline",asChild:!0,children:(0,r.jsxs)(h.default,{href:"/app",children:[(0,r.jsx)(u.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back to dashboard"]})})]})});if("job_not_found"===x.status)return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,r.jsx)(m.AlertCircle,{className:"w-12 h-12 mx-auto mb-4 text-red-500"}),(0,r.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Job not found"}),(0,r.jsx)("p",{className:"text-muted-foreground mb-4",children:"The job you're looking for doesn't exist or has been deleted."}),(0,r.jsx)(c.Button,{variant:"outline",asChild:!0,children:(0,r.jsxs)(h.default,{href:"/app",children:[(0,r.jsx)(u.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back to dashboard"]})})]})});if("wrong_state"===x.status){let e="review"===i?"lyrics review":"instrumental selection";return(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,r.jsx)(m.AlertCircle,{className:"w-12 h-12 mx-auto mb-4 text-amber-500"}),(0,r.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Not available"}),(0,r.jsxs)("p",{className:"text-muted-foreground mb-4",children:['This job is currently in "',x.currentState,'" state and is not ready for ',e,"."]}),(0,r.jsx)(c.Button,{variant:"outline",asChild:!0,children:(0,r.jsxs)(h.default,{href:"/app",children:[(0,r.jsx)(u.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back to dashboard"]})})]})})}let{job:g,routeType:w}=x,v="local_mode"===x.status;return"review"===w?(0,r.jsx)(np,{job:g,isLocalMode:v}):"instrumental"===w?(0,r.jsx)(Y,{job:g,isLocalMode:v}):null}function np({job:e,isLocalMode:t=!1}){let[a,s]=(0,n.useState)(null),[i,o]=(0,n.useState)(!0),[f,x]=(0,n.useState)(null),p=(0,l.createLyricsReviewApiClient)(e.job_id);(0,n.useEffect)(()=>{!async function(){try{o(!0),x(null);let t=await l.lyricsReviewApi.getCorrectionData(e.job_id);s(t)}catch(e){console.error("Failed to load correction data:",e),x(e instanceof Error?e.message:"Failed to load lyrics data")}finally{o(!1)}}()},[e.job_id]);let g=(0,n.useCallback)(()=>{console.log("File load requested")},[]),w=(0,n.useCallback)(()=>{console.log("Show metadata requested",e)},[e]);return i?(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(d,{className:"w-8 h-8 mx-auto mb-4"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:"Loading lyrics data..."})]})}):f||!a?(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,r.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,r.jsx)(m.AlertCircle,{className:"w-12 h-12 mx-auto mb-4 text-red-500"}),(0,r.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Failed to load lyrics"}),(0,r.jsx)("p",{className:"text-muted-foreground mb-4",children:f||"Could not load lyrics data for this job."}),!t&&(0,r.jsx)(c.Button,{variant:"outline",asChild:!0,children:(0,r.jsxs)(h.default,{href:"/app",children:[(0,r.jsx)(u.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back to dashboard"]})})]})}):(0,r.jsxs)("div",{className:"min-h-screen bg-background",children:[(0,r.jsx)("header",{className:"border-b bg-card/80 backdrop-blur-sm sticky top-0 z-50 px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[!t&&(0,r.jsx)(c.Button,{variant:"ghost",size:"sm",asChild:!0,children:(0,r.jsxs)(h.default,{href:"/app",children:[(0,r.jsx)(u.ArrowLeft,{className:"w-4 h-4 mr-2"}),"Back"]})}),(0,r.jsx)("img",{src:"/static/nomad-karaoke-logo.svg",alt:"Nomad Karaoke",style:{height:40}}),(0,r.jsx)("h1",{className:"text-lg font-bold",children:"Lyrics Transcription Review"})]}),(0,r.jsx)(nh.ThemeToggle,{})]})}),(0,r.jsx)("main",{className:"px-4 py-2",children:(0,r.jsx)(nm,{data:a,onFileLoad:g,onShowMetadata:w,apiClient:p,isReadOnly:!1,audioHash:a.metadata?.audio_hash||e.audio_hash||e.job_id})})]})}e.s(["JobRouterClient",()=>nx],78280)}]);
|